@tbox.cn/app-agent-ui-kit 0.0.0-stage → 1.0.0-alpha.6
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/LICENSE +21 -0
- package/README.md +16 -2
- package/assets/keyboard-circle.svg +12 -0
- package/assets/more-circle.svg +3 -0
- package/assets/new-chat.svg +3 -0
- package/assets/quick-command-star.svg +3 -0
- package/assets/send-gradient.svg +14 -0
- package/assets/stop@2x.png +0 -0
- package/assets/voice-circle.svg +3 -0
- package/package.json +58 -3
- package/src/ChatPage.tsx +332 -0
- package/src/card/define-card.ts +34 -0
- package/src/card/primitives.test.tsx +147 -0
- package/src/card/primitives.tsx +627 -0
- package/src/card/use-card-actions.ts +86 -0
- package/src/chat-config.test.ts +46 -0
- package/src/chat-config.ts +80 -0
- package/src/components/ActionBar/DebugButton.test.tsx +84 -0
- package/src/components/ActionBar/DebugButton.tsx +53 -0
- package/src/components/ActionBar/index.test.tsx +83 -0
- package/src/components/ActionBar/index.tsx +158 -0
- package/src/components/CardRenderer.tsx +36 -0
- package/src/components/ChatHeader/index.test.tsx +74 -0
- package/src/components/ChatHeader/index.tsx +77 -0
- package/src/components/ChatInput/index.test.tsx +156 -0
- package/src/components/ChatInput/index.tsx +290 -0
- package/src/components/ChatInput/voice/VoicePressField.tsx +43 -0
- package/src/components/ChatInput/voice/VoiceRecordingOverlay.tsx +51 -0
- package/src/components/ChatInput/voice/machine.ts +27 -0
- package/src/components/ChatInput/voice/useVoicePress.ts +207 -0
- package/src/components/HistoryEntry/index.tsx +41 -0
- package/src/components/MediaList/index.tsx +270 -0
- package/src/components/MessageBubble/index.test.tsx +134 -0
- package/src/components/MessageBubble/index.tsx +202 -0
- package/src/components/PullDownIndicator/index.tsx +31 -0
- package/src/components/QuickCommands/index.test.tsx +99 -0
- package/src/components/QuickCommands/index.tsx +52 -0
- package/src/components/ReasoningBlock/index.tsx +61 -0
- package/src/components/ScrollToBottomButton/index.tsx +8 -0
- package/src/components/ToolCallBlock/detail.test.ts +346 -0
- package/src/components/ToolCallBlock/detail.ts +204 -0
- package/src/components/ToolCallBlock/index.test.tsx +261 -0
- package/src/components/ToolCallBlock/index.tsx +230 -0
- package/src/components/ToolCallBlock/titles.ts +102 -0
- package/src/hooks/use-drag-gesture.test.ts +66 -0
- package/src/hooks/use-drag-gesture.ts +129 -0
- package/src/hooks/use-pull-down-history.ts +241 -0
- package/src/hooks/use-pull-down-wheel-native.test.ts +64 -0
- package/src/hooks/useMediaUpload.ts +242 -0
- package/src/hooks/useTTSAutoPlay.ts +82 -0
- package/src/icons.ts +39 -0
- package/src/index.ts +122 -0
- package/src/shell.contract.json +59 -0
- package/src/shell.test.ts +61 -0
- package/src/shell.ts +45 -0
- package/src/store-context.tsx +92 -0
- package/src/test/setup.ts +7 -0
- package/src/theme/base.css +132 -0
- package/src/theme/contract.json +72 -0
- package/src/theme/motion.css +19 -0
- package/src/theme/theme-contract.test.ts +69 -0
- package/src/theme/theme.ts +17 -0
- package/src/theme/tokens.css +81 -0
- package/src/types.ts +29 -0
- package/src/utils/copyText.ts +11 -0
- package/src/utils/haptics.test.ts +51 -0
- package/src/utils/haptics.ts +44 -0
- package/src/utils/imagePreview.ts +10 -0
- package/src/utils/pull-down-machine.test.ts +188 -0
- package/src/utils/pull-down-machine.ts +157 -0
- package/src/utils/session-error.ts +5 -0
- package/src/utils/toast.ts +15 -0
- package/src/utils/tool-call-display.test.ts +240 -0
- package/src/utils/tool-call-display.ts +146 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { createRoot } from 'react-dom/client';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
import ChatHeader from './index';
|
|
6
|
+
|
|
7
|
+
interface MockChatState {
|
|
8
|
+
helloAck: { mallScope?: Record<string, string> } | null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let mockHelloAck: MockChatState['helloAck'] = null;
|
|
12
|
+
|
|
13
|
+
vi.mock('../../store-context', () => ({
|
|
14
|
+
useChatStore: (selector: (s: MockChatState) => unknown) =>
|
|
15
|
+
selector({ helloAck: mockHelloAck }),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
vi.mock('../../chat-config', () => ({
|
|
19
|
+
useChatConfigStore: (selector: (s: { enableTTS: boolean }) => unknown) =>
|
|
20
|
+
selector({ enableTTS: false }),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
function renderHeader(container: HTMLDivElement) {
|
|
24
|
+
flushSync(() => {
|
|
25
|
+
createRoot(container).render(
|
|
26
|
+
<ChatHeader ttsAutoPlay={false} onToggleTTS={() => {}} onClearChat={() => {}} />,
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe('ChatHeader 品牌区(014 T7:mallScope.mallName 驱动,非 mall 部署降级)', () => {
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
mockHelloAck = null;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('有 mallScope.mallName → 渲染品牌区(mark + mallName)', () => {
|
|
37
|
+
mockHelloAck = { mallScope: { mallId: 'mall-demo', mallName: '示例商场' } };
|
|
38
|
+
const container = document.createElement('div');
|
|
39
|
+
document.body.appendChild(container);
|
|
40
|
+
try {
|
|
41
|
+
renderHeader(container);
|
|
42
|
+
const brand = container.querySelector('.chat-header__brand');
|
|
43
|
+
expect(brand).not.toBeNull();
|
|
44
|
+
expect(brand?.textContent).toContain('示例商场');
|
|
45
|
+
expect(brand?.getAttribute('aria-label')).toBe('示例商场');
|
|
46
|
+
} finally {
|
|
47
|
+
document.body.removeChild(container);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('无 mallScope(非 mall 部署)→ 不渲染品牌区', () => {
|
|
52
|
+
mockHelloAck = null;
|
|
53
|
+
const container = document.createElement('div');
|
|
54
|
+
document.body.appendChild(container);
|
|
55
|
+
try {
|
|
56
|
+
renderHeader(container);
|
|
57
|
+
expect(container.querySelector('.chat-header__brand')).toBeNull();
|
|
58
|
+
} finally {
|
|
59
|
+
document.body.removeChild(container);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('mallScope 缺 mallName → 不渲染品牌区(回显不完整降级)', () => {
|
|
64
|
+
mockHelloAck = { mallScope: { mallId: 'mall-demo' } };
|
|
65
|
+
const container = document.createElement('div');
|
|
66
|
+
document.body.appendChild(container);
|
|
67
|
+
try {
|
|
68
|
+
renderHeader(container);
|
|
69
|
+
expect(container.querySelector('.chat-header__brand')).toBeNull();
|
|
70
|
+
} finally {
|
|
71
|
+
document.body.removeChild(container);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { CaretDown, SpeakerHigh, SpeakerSlash, Trash } from '@phosphor-icons/react';
|
|
3
|
+
import { useChatConfigStore } from '../../chat-config';
|
|
4
|
+
import { useChatStore } from '../../store-context';
|
|
5
|
+
|
|
6
|
+
interface ChatHeaderProps {
|
|
7
|
+
ttsAutoPlay: boolean;
|
|
8
|
+
onToggleTTS: () => void;
|
|
9
|
+
onClearChat: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default function ChatHeader({ ttsAutoPlay, onToggleTTS, onClearChat }: ChatHeaderProps) {
|
|
13
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
14
|
+
const headerRef = useRef<HTMLDivElement>(null);
|
|
15
|
+
const enableTTS = useChatConfigStore((s) => s.enableTTS);
|
|
16
|
+
// 品牌名三级来源:chat.json identity.name → HELLO_ACK 的 mallName(商圈部署回显)→ 不渲染
|
|
17
|
+
const identity = useChatConfigStore((s) => s.identity);
|
|
18
|
+
const mallName = useChatStore((s) => s.helloAck?.mallScope?.mallName);
|
|
19
|
+
const brandName = identity?.name ?? mallName;
|
|
20
|
+
|
|
21
|
+
const handleClear = useCallback(() => {
|
|
22
|
+
onClearChat();
|
|
23
|
+
setIsExpanded(false);
|
|
24
|
+
}, [onClearChat]);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!isExpanded || typeof document === 'undefined') return;
|
|
28
|
+
const onOutside = (e: Event) => {
|
|
29
|
+
if (headerRef.current && !headerRef.current.contains(e.target as Node)) setIsExpanded(false);
|
|
30
|
+
};
|
|
31
|
+
document.addEventListener('touchstart', onOutside, true);
|
|
32
|
+
document.addEventListener('mousedown', onOutside, true);
|
|
33
|
+
return () => {
|
|
34
|
+
document.removeEventListener('touchstart', onOutside, true);
|
|
35
|
+
document.removeEventListener('mousedown', onOutside, true);
|
|
36
|
+
};
|
|
37
|
+
}, [isExpanded]);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className="chat-header pointer-events-none absolute left-1/2 top-[calc(5px+env(safe-area-inset-top,0px))] z-[100] flex w-full max-w-content -translate-x-1/2 flex-col items-end px-4" ref={headerRef}>
|
|
41
|
+
{brandName ? (
|
|
42
|
+
<div className="chat-header__brand absolute left-4 top-[2px] inline-flex min-h-[22px] items-center text-foreground" aria-label={brandName}>
|
|
43
|
+
<span className="chat-header__brand-mark mr-[7px] h-[17px] w-[3.5px] rounded-[1px] bg-primary" aria-hidden="true" />
|
|
44
|
+
<span className="chat-header__brand-name text-xs font-[760] leading-none tracking-normal">{brandName}</span>
|
|
45
|
+
{identity?.tagline ? <span className="chat-header__brand-tagline ml-[6px] overflow-hidden text-ellipsis whitespace-nowrap text-xs leading-none text-muted-foreground">{identity.tagline}</span> : null}
|
|
46
|
+
</div>
|
|
47
|
+
) : null}
|
|
48
|
+
<div className={`chat-header__group flex items-center gap-[2px] overflow-hidden rounded-[6px] border-[0.5px] border-border bg-[rgba(255,255,255,0.96)] shadow-sm transition-[opacity,transform] motion-reduce:transition-none ${!isExpanded ? ' chat-header__group--collapsed pointer-events-none mb-0 max-h-0 px-[3px] py-0 opacity-0 [transform:translateY(-4px)]' : ' pointer-events-auto mb-[3px] max-h-10 px-[3px] py-[3px] opacity-100 [transform:translateY(0)]'}`}>
|
|
49
|
+
<button type="button" className="chat-header__btn inline-flex min-h-[26px] appearance-none items-center justify-center gap-[3.5px] rounded-[4px] border-0 bg-transparent px-[7.5px] py-0 text-secondary-foreground [font-family:inherit] active:bg-muted focus-visible:outline-[1.5px] focus-visible:outline-offset-[-1px] focus-visible:outline-[rgba(9,107,250,0.24)]" onClick={handleClear}>
|
|
50
|
+
<Trash size={22} className="chat-header__btn-icon size-[11px] shrink-0 text-primary" />
|
|
51
|
+
<span className="chat-header__btn-text text-inherit text-xs font-[560] leading-none whitespace-nowrap">清空</span>
|
|
52
|
+
</button>
|
|
53
|
+
{enableTTS && (
|
|
54
|
+
<button type="button" className="chat-header__btn inline-flex min-h-[26px] appearance-none items-center justify-center gap-[3.5px] rounded-[4px] border-0 bg-transparent px-[7.5px] py-0 text-secondary-foreground [font-family:inherit] active:bg-muted focus-visible:outline-[1.5px] focus-visible:outline-offset-[-1px] focus-visible:outline-[rgba(9,107,250,0.24)]" onClick={onToggleTTS}>
|
|
55
|
+
{ttsAutoPlay ? (
|
|
56
|
+
<SpeakerHigh size={22} className="chat-header__btn-icon size-[11px] shrink-0 text-primary" />
|
|
57
|
+
) : (
|
|
58
|
+
<SpeakerSlash size={22} className="chat-header__btn-icon size-[11px] shrink-0 text-primary" />
|
|
59
|
+
)}
|
|
60
|
+
<span className="chat-header__btn-text text-inherit text-xs font-[560] leading-none whitespace-nowrap">{ttsAutoPlay ? '关闭' : '播放'}</span>
|
|
61
|
+
</button>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
<button
|
|
65
|
+
className="chat-header__toggle pointer-events-auto flex h-[22px] w-7 appearance-none items-center justify-center rounded-[4px] border-[0.5px] border-border bg-[rgba(255,255,255,0.92)] text-muted-foreground shadow-sm [font-family:inherit] active:bg-muted focus-visible:outline-[1.5px] focus-visible:outline-offset-[1px] focus-visible:outline-[rgba(9,107,250,0.24)]"
|
|
66
|
+
type="button"
|
|
67
|
+
aria-label={isExpanded ? '收起对话工具' : '展开对话工具'}
|
|
68
|
+
aria-expanded={isExpanded}
|
|
69
|
+
onClick={() => setIsExpanded((p) => !p)}
|
|
70
|
+
>
|
|
71
|
+
<span className={`chat-header__arrow flex items-center justify-center transition-transform duration-[var(--tbox-motion-duration-base)] ease-[var(--tbox-motion-easing-standard)] motion-reduce:transition-none ${isExpanded ? ' chat-header__arrow--up rotate-180' : ''}`}>
|
|
72
|
+
<CaretDown size={14} />
|
|
73
|
+
</span>
|
|
74
|
+
</button>
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { act } from 'react';
|
|
3
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
|
+
import type { VoiceInteractionState } from './voice/machine';
|
|
6
|
+
|
|
7
|
+
const mocks = vi.hoisted(() => ({
|
|
8
|
+
interactionState: 'idle' as VoiceInteractionState,
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
vi.mock('@tbox.cn/app-agent-sdk-client', () => ({
|
|
12
|
+
isInAlipayShell: () => false,
|
|
13
|
+
useASRAdapter: () => undefined,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
vi.mock('../../hooks/useMediaUpload', () => ({
|
|
17
|
+
useMediaUpload: () => ({
|
|
18
|
+
items: [],
|
|
19
|
+
addFiles: vi.fn(),
|
|
20
|
+
addFromBridge: vi.fn(),
|
|
21
|
+
removeItem: vi.fn(),
|
|
22
|
+
retry: vi.fn(),
|
|
23
|
+
clear: vi.fn(),
|
|
24
|
+
uploading: false,
|
|
25
|
+
}),
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
vi.mock('../../components/MediaList', () => ({ MediaList: () => null }));
|
|
29
|
+
|
|
30
|
+
vi.mock('./voice/useVoicePress', () => ({
|
|
31
|
+
useVoicePress: () => ({
|
|
32
|
+
interactionState: mocks.interactionState,
|
|
33
|
+
overlayVisible: mocks.interactionState !== 'idle',
|
|
34
|
+
countdown: null,
|
|
35
|
+
handlers: {
|
|
36
|
+
onTouchStart: vi.fn(),
|
|
37
|
+
onTouchMove: vi.fn(),
|
|
38
|
+
onTouchEnd: vi.fn(),
|
|
39
|
+
onTouchCancel: vi.fn(),
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
import { ChatInput } from './index';
|
|
45
|
+
import { useChatConfigStore } from '../../chat-config';
|
|
46
|
+
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
mocks.interactionState = 'idle';
|
|
49
|
+
// 重置回构建期快照(对齐模板 config/chat.json 出厂值;派生矩阵用例经 setState 驱动水合模拟)
|
|
50
|
+
useChatConfigStore.setState({
|
|
51
|
+
enableImageUpload: false,
|
|
52
|
+
enableVideoUpload: false,
|
|
53
|
+
enableTTS: false,
|
|
54
|
+
enableVoiceInput: true,
|
|
55
|
+
defaultInputMode: 'TEXT',
|
|
56
|
+
});
|
|
57
|
+
document.body.innerHTML = '';
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('ChatInput 语音活动状态', () => {
|
|
61
|
+
it('idle、识别中和结束时依次向页面投影 false、true、false', async () => {
|
|
62
|
+
const onVoiceActivityChange = vi.fn();
|
|
63
|
+
const container = document.createElement('div');
|
|
64
|
+
document.body.appendChild(container);
|
|
65
|
+
const root = createRoot(container);
|
|
66
|
+
const render = () => root.render(
|
|
67
|
+
<ChatInput onSend={vi.fn()} onVoiceActivityChange={onVoiceActivityChange} />,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
await act(async () => render());
|
|
71
|
+
expect(onVoiceActivityChange).toHaveBeenLastCalledWith(false);
|
|
72
|
+
|
|
73
|
+
mocks.interactionState = 'processing';
|
|
74
|
+
await act(async () => render());
|
|
75
|
+
expect(onVoiceActivityChange).toHaveBeenLastCalledWith(true);
|
|
76
|
+
|
|
77
|
+
mocks.interactionState = 'idle';
|
|
78
|
+
await act(async () => render());
|
|
79
|
+
expect(onVoiceActivityChange).toHaveBeenLastCalledWith(false);
|
|
80
|
+
|
|
81
|
+
await act(async () => root.unmount());
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('ChatInput 派生模式(服务端 defaultInputMode 水合)', () => {
|
|
86
|
+
/** voice 态投影:录音模式显示"键盘"切换图标;text 态显示"语音"切换图标 */
|
|
87
|
+
const inVoiceMode = (container: HTMLElement) =>
|
|
88
|
+
container.querySelector('img[alt="键盘"]') !== null;
|
|
89
|
+
|
|
90
|
+
const renderInput = async (root: ReturnType<typeof createRoot>) => {
|
|
91
|
+
await act(async () => root.render(<ChatInput onSend={vi.fn()} />));
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
it('① voice 关 + defaultInputMode=VOICE → 强制 text(语音按钮隐藏)', async () => {
|
|
95
|
+
useChatConfigStore.setState({ enableVoiceInput: false, defaultInputMode: 'VOICE' });
|
|
96
|
+
const container = document.createElement('div');
|
|
97
|
+
document.body.appendChild(container);
|
|
98
|
+
const root = createRoot(container);
|
|
99
|
+
await renderInput(root);
|
|
100
|
+
expect(inVoiceMode(container)).toBe(false);
|
|
101
|
+
await act(async () => root.unmount());
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('② voice 开 + defaultInputMode=VOICE → 初始即 voice', async () => {
|
|
105
|
+
useChatConfigStore.setState({ enableVoiceInput: true, defaultInputMode: 'VOICE' });
|
|
106
|
+
const container = document.createElement('div');
|
|
107
|
+
document.body.appendChild(container);
|
|
108
|
+
const root = createRoot(container);
|
|
109
|
+
await renderInput(root);
|
|
110
|
+
expect(inVoiceMode(container)).toBe(true);
|
|
111
|
+
await act(async () => root.unmount());
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('③ 初值 TEXT 渲染后水合 VOICE → 派生自动转 voice(useState 捕获竞态修复)', async () => {
|
|
115
|
+
useChatConfigStore.setState({ enableVoiceInput: true, defaultInputMode: 'TEXT' });
|
|
116
|
+
const container = document.createElement('div');
|
|
117
|
+
document.body.appendChild(container);
|
|
118
|
+
const root = createRoot(container);
|
|
119
|
+
await renderInput(root);
|
|
120
|
+
expect(inVoiceMode(container)).toBe(false);
|
|
121
|
+
// 模拟 HELLO_ACK 晚到水合(服务端 defaultInputMode='VOICE')
|
|
122
|
+
useChatConfigStore.setState({ defaultInputMode: 'VOICE' });
|
|
123
|
+
await renderInput(root);
|
|
124
|
+
expect(inVoiceMode(container)).toBe(true);
|
|
125
|
+
await act(async () => root.unmount());
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('④ 用户手动切 text 后水合 VOICE 到达 → 显式选择优先,保持 text', async () => {
|
|
129
|
+
useChatConfigStore.setState({ enableVoiceInput: true, defaultInputMode: 'VOICE' });
|
|
130
|
+
const container = document.createElement('div');
|
|
131
|
+
document.body.appendChild(container);
|
|
132
|
+
const root = createRoot(container);
|
|
133
|
+
await renderInput(root);
|
|
134
|
+
expect(inVoiceMode(container)).toBe(true);
|
|
135
|
+
// 用户手动切回 text(voice 态的"键盘"切换钮——div 容器 onClick)
|
|
136
|
+
const keyboardToggle = container.querySelector<HTMLElement>('.tbox-voice-toggle')!;
|
|
137
|
+
await act(async () => keyboardToggle.click());
|
|
138
|
+
await renderInput(root);
|
|
139
|
+
expect(inVoiceMode(container)).toBe(false);
|
|
140
|
+
// 水合再次下发 VOICE(如重连回显)——用户显式选择仍优先
|
|
141
|
+
useChatConfigStore.setState({ defaultInputMode: 'VOICE' });
|
|
142
|
+
await renderInput(root);
|
|
143
|
+
expect(inVoiceMode(container)).toBe(false);
|
|
144
|
+
await act(async () => root.unmount());
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('⑤ voice 开 + defaultInputMode=TEXT → text', async () => {
|
|
148
|
+
useChatConfigStore.setState({ enableVoiceInput: true, defaultInputMode: 'TEXT' });
|
|
149
|
+
const container = document.createElement('div');
|
|
150
|
+
document.body.appendChild(container);
|
|
151
|
+
const root = createRoot(container);
|
|
152
|
+
await renderInput(root);
|
|
153
|
+
expect(inVoiceMode(container)).toBe(false);
|
|
154
|
+
await act(async () => root.unmount());
|
|
155
|
+
});
|
|
156
|
+
});
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useMediaUpload } from '../../hooks/useMediaUpload';
|
|
3
|
+
import { useASRAdapter, isInAlipayShell } from '@tbox.cn/app-agent-sdk-client';
|
|
4
|
+
import { useChatConfigStore } from '../../chat-config';
|
|
5
|
+
|
|
6
|
+
import type { ChatInputMessage, InputMethod } from '../../types';
|
|
7
|
+
import { MediaList } from '../../components/MediaList';
|
|
8
|
+
import { useVoicePress } from './voice/useVoicePress';
|
|
9
|
+
import { VoicePressField } from './voice/VoicePressField';
|
|
10
|
+
import { VoiceRecordingOverlay } from './voice/VoiceRecordingOverlay';
|
|
11
|
+
import newChatIcon from '../../../assets/new-chat.svg';
|
|
12
|
+
import voiceIcon from '../../../assets/voice-circle.svg';
|
|
13
|
+
import keyboardIcon from '../../../assets/keyboard-circle.svg';
|
|
14
|
+
import sendIcon from '../../../assets/send-gradient.svg';
|
|
15
|
+
import stopIcon from '../../../assets/stop@2x.png';
|
|
16
|
+
import moreIcon from '../../../assets/more-circle.svg';
|
|
17
|
+
|
|
18
|
+
type PickKind = 'image' | 'camera' | 'video';
|
|
19
|
+
|
|
20
|
+
/** 媒体选取菜单图标(远程素材,对齐原模板)。 */
|
|
21
|
+
const OPTION_ICONS: Record<PickKind, { icon: string; label: string }> = {
|
|
22
|
+
image: { icon: 'https://mdn.alipayobjects.com/huamei_nzq4hr/afts/img/A*DfDhSYAMzoQAAAAAHiAAAAgAel-hAQ/original', label: '相册' },
|
|
23
|
+
camera: { icon: 'https://mdn.alipayobjects.com/huamei_nzq4hr/afts/img/A*xdKLSabxqmQAAAAAOnAAAAgAel-hAQ/original', label: '拍摄' },
|
|
24
|
+
video: { icon: 'https://mdn.alipayobjects.com/huamei_nzq4hr/afts/img/A*xdKLSabxqmQAAAAAOnAAAAgAel-hAQ/original', label: '视频' },
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const MENU_ANIMATION_MS = 250;
|
|
28
|
+
|
|
29
|
+
/** 菜单展开时选项的错峰入场延迟(旧 less 的 `:nth-child(n)` transition-delay)。 */
|
|
30
|
+
const MENU_OPTION_DELAY_CLASS: Record<number, string> = {
|
|
31
|
+
0: '[.tbox-media-picker-menu--visible_&]:[transition-delay:0.05s]',
|
|
32
|
+
1: '[.tbox-media-picker-menu--visible_&]:[transition-delay:0.1s]',
|
|
33
|
+
2: '[.tbox-media-picker-menu--visible_&]:[transition-delay:0.15s]',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** 连接终态阻断(登录失败/scope 拒绝):提示条 + 输入禁用 + 可选重试入口 */
|
|
37
|
+
export interface ChatBlocked {
|
|
38
|
+
message: string;
|
|
39
|
+
onRetry?: () => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 媒体上传默认约束(分类型数量 + 单文件大小)。如需放开/收紧按业务改这里。 */
|
|
43
|
+
const DEFAULT_MEDIA_CONFIG = {
|
|
44
|
+
image: { maxCount: 9, maxSize: 10 * 1024 * 1024 },
|
|
45
|
+
video: { maxCount: 1, maxSize: 50 * 1024 * 1024 },
|
|
46
|
+
file: { maxCount: 5, maxSize: 20 * 1024 * 1024 },
|
|
47
|
+
} as const;
|
|
48
|
+
const MEDIA_MAX_TOTAL = 9;
|
|
49
|
+
|
|
50
|
+
/** 对话输入框(对齐原模板):媒体预览 + 新对话 + 药丸[输入框/按住说话 + 语音切换 + 发送/“+”] + 动画选取菜单 + 免责声明。 */
|
|
51
|
+
export function ChatInput({
|
|
52
|
+
generating,
|
|
53
|
+
blocked,
|
|
54
|
+
onSend,
|
|
55
|
+
onCancel,
|
|
56
|
+
onNewChat,
|
|
57
|
+
onVoiceActivityChange,
|
|
58
|
+
disclaimer = '以上内容由AI生成,请谨慎甄别。',
|
|
59
|
+
}: {
|
|
60
|
+
generating?: boolean;
|
|
61
|
+
blocked?: ChatBlocked;
|
|
62
|
+
onSend: (msg: ChatInputMessage) => void;
|
|
63
|
+
onCancel?: () => void;
|
|
64
|
+
onNewChat?: () => void;
|
|
65
|
+
onVoiceActivityChange?: (active: boolean) => void;
|
|
66
|
+
disclaimer?: string;
|
|
67
|
+
}) {
|
|
68
|
+
const [text, setText] = useState('');
|
|
69
|
+
const imageRef = useRef<HTMLInputElement>(null);
|
|
70
|
+
const cameraRef = useRef<HTMLInputElement>(null);
|
|
71
|
+
const videoRef = useRef<HTMLInputElement>(null);
|
|
72
|
+
const closeTimerRef = useRef<ReturnType<typeof setTimeout>>();
|
|
73
|
+
const { items, addFiles, addFromBridge, removeItem, retry, clear, uploading } = useMediaUpload(
|
|
74
|
+
MEDIA_MAX_TOTAL,
|
|
75
|
+
DEFAULT_MEDIA_CONFIG,
|
|
76
|
+
);
|
|
77
|
+
const asr = useASRAdapter();
|
|
78
|
+
const inShell = isInAlipayShell();
|
|
79
|
+
const enableImage = useChatConfigStore((s) => s.enableImageUpload);
|
|
80
|
+
const enableVideo = useChatConfigStore((s) => s.enableVideoUpload);
|
|
81
|
+
const enableVoice = useChatConfigStore((s) => s.enableVoiceInput);
|
|
82
|
+
const defaultInputMode = useChatConfigStore((s) => s.defaultInputMode);
|
|
83
|
+
// 派生模式(禁 useState 捕获初值——水合晚到时服务端 defaultInputMode 进不了已捕获 state):
|
|
84
|
+
// userMode=null 跟随默认(随水合重渲染更新);显式值 = 用户手动切换优先
|
|
85
|
+
const [userMode, setUserMode] = useState<'text' | 'voice' | null>(null);
|
|
86
|
+
const inputMode: 'text' | 'voice' =
|
|
87
|
+
!enableVoice ? 'text' : userMode ?? (defaultInputMode === 'VOICE' ? 'voice' : 'text');
|
|
88
|
+
const [menuVisible, setMenuVisible] = useState(false);
|
|
89
|
+
const [menuAnimating, setMenuAnimating] = useState(false);
|
|
90
|
+
|
|
91
|
+
const voice = useVoicePress({
|
|
92
|
+
disabled: generating || !!blocked,
|
|
93
|
+
asr,
|
|
94
|
+
onResult: (t) => onSend({ text: t, mediaItems: [], inputMethod: 'voice' }),
|
|
95
|
+
});
|
|
96
|
+
const voiceActive = voice.interactionState !== 'idle';
|
|
97
|
+
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
onVoiceActivityChange?.(voiceActive);
|
|
100
|
+
}, [onVoiceActivityChange, voiceActive]);
|
|
101
|
+
|
|
102
|
+
useEffect(() => () => onVoiceActivityChange?.(false), [onVoiceActivityChange]);
|
|
103
|
+
|
|
104
|
+
const isWebPc = !inShell && typeof window !== 'undefined' && window.innerWidth > 450;
|
|
105
|
+
|
|
106
|
+
const pick = (kind: PickKind) => {
|
|
107
|
+
if (inShell) {
|
|
108
|
+
addFromBridge(kind);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
(kind === 'image' ? imageRef : kind === 'camera' ? cameraRef : videoRef).current?.click();
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// 媒体选项:相册 / 拍摄(移动端)/ 视频,按 config 开关
|
|
115
|
+
const menuOptions = [
|
|
116
|
+
enableImage && { type: 'image' as const, ...OPTION_ICONS.image },
|
|
117
|
+
enableImage && !isWebPc && { type: 'camera' as const, ...OPTION_ICONS.camera },
|
|
118
|
+
enableVideo && { type: 'video' as const, ...OPTION_ICONS.video },
|
|
119
|
+
].filter(Boolean) as { type: PickKind; icon: string; label: string }[];
|
|
120
|
+
|
|
121
|
+
const openMenu = () => {
|
|
122
|
+
setMenuVisible(true);
|
|
123
|
+
requestAnimationFrame(() => requestAnimationFrame(() => setMenuAnimating(true)));
|
|
124
|
+
};
|
|
125
|
+
const closeMenu = () => {
|
|
126
|
+
if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
|
|
127
|
+
setMenuAnimating(false);
|
|
128
|
+
closeTimerRef.current = setTimeout(() => setMenuVisible(false), MENU_ANIMATION_MS);
|
|
129
|
+
};
|
|
130
|
+
const onPlus = () => {
|
|
131
|
+
if (menuVisible) return closeMenu();
|
|
132
|
+
if (menuOptions.length <= 1) return menuOptions[0] && pick(menuOptions[0].type);
|
|
133
|
+
openMenu();
|
|
134
|
+
};
|
|
135
|
+
const onMenuSelect = (kind: PickKind) => {
|
|
136
|
+
closeMenu();
|
|
137
|
+
pick(kind);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!menuVisible) return;
|
|
142
|
+
const onDown = (e: MouseEvent | TouchEvent) => {
|
|
143
|
+
const t = e.target as HTMLElement;
|
|
144
|
+
if (t && !t.closest('.tbox-media-picker') && !t.closest('.tbox-media-picker-menu')) closeMenu();
|
|
145
|
+
};
|
|
146
|
+
document.addEventListener('mousedown', onDown);
|
|
147
|
+
document.addEventListener('touchstart', onDown, { passive: true });
|
|
148
|
+
return () => {
|
|
149
|
+
document.removeEventListener('mousedown', onDown);
|
|
150
|
+
document.removeEventListener('touchstart', onDown);
|
|
151
|
+
};
|
|
152
|
+
}, [menuVisible]);
|
|
153
|
+
|
|
154
|
+
useEffect(() => () => closeTimerRef.current && clearTimeout(closeTimerRef.current), []);
|
|
155
|
+
|
|
156
|
+
const canSend = !!(text.trim() || items.length > 0) && !uploading && inputMode === 'text' && !blocked;
|
|
157
|
+
|
|
158
|
+
const submit = () => {
|
|
159
|
+
if (!canSend) return;
|
|
160
|
+
const media = items.filter((it) => it.fileId && !it.illegal);
|
|
161
|
+
const inputMethod: InputMethod = media.length ? media[0].type : 'text';
|
|
162
|
+
onSend({ text: text.trim(), mediaItems: media, inputMethod });
|
|
163
|
+
setText('');
|
|
164
|
+
clear();
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const onPickFiles = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
168
|
+
addFiles(e.target.files ? Array.from(e.target.files) : []);
|
|
169
|
+
e.target.value = '';
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const toggleMode = () => {
|
|
173
|
+
if (blocked) return;
|
|
174
|
+
setUserMode(inputMode === 'text' ? 'voice' : 'text');
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<div className="tbox-chat-input relative z-[1] mx-auto w-full max-w-content bg-transparent px-page pt-2 pb-[calc(8px+env(safe-area-inset-bottom,0px))]">
|
|
179
|
+
<MediaList
|
|
180
|
+
items={items}
|
|
181
|
+
onRemove={removeItem}
|
|
182
|
+
onRetry={retry}
|
|
183
|
+
onPickImage={() => pick('image')}
|
|
184
|
+
onPickCamera={() => pick('camera')}
|
|
185
|
+
onPickVideo={() => pick('video')}
|
|
186
|
+
enableImage={enableImage}
|
|
187
|
+
enableVideo={enableVideo}
|
|
188
|
+
isWebPc={isWebPc}
|
|
189
|
+
/>
|
|
190
|
+
|
|
191
|
+
<div className="tbox-chat-input__row flex flex-wrap items-end gap-2">
|
|
192
|
+
{onNewChat && (
|
|
193
|
+
<div className="tbox-new-chat-btn flex size-11 shrink-0 items-center justify-center rounded-full bg-[rgba(255,255,255,0.5)] shadow-[0_1px_10px_rgba(110,139,180,0.24)]" onClick={onNewChat}>
|
|
194
|
+
<img className="tbox-new-chat-btn__icon size-[22px]" src={newChatIcon} alt="新对话" />
|
|
195
|
+
</div>
|
|
196
|
+
)}
|
|
197
|
+
|
|
198
|
+
<div className="tbox-chat-input__wrapper flex min-w-0 flex-1 items-end gap-[14px] rounded-[var(--tbox-input-radius)] border border-border bg-[var(--tbox-input-bg)] p-[var(--tbox-input-padding)] shadow-[0_1px_10px_rgba(110,139,180,0.24)] transition-[border-color,box-shadow] duration-[var(--tbox-motion-duration-fast)] ease-[var(--tbox-motion-easing-standard)] focus-within:border-primary focus-within:shadow-[0_0_0_1.5px_rgba(9,107,250,0.12)]">
|
|
199
|
+
<input ref={imageRef} type="file" accept="image/*" multiple hidden onChange={onPickFiles} />
|
|
200
|
+
<input ref={cameraRef} type="file" accept="image/*" capture="environment" hidden onChange={onPickFiles} />
|
|
201
|
+
<input ref={videoRef} type="file" accept="video/*" hidden onChange={onPickFiles} />
|
|
202
|
+
|
|
203
|
+
{inputMode === 'voice' ? (
|
|
204
|
+
<VoicePressField
|
|
205
|
+
disabled={generating || !!blocked}
|
|
206
|
+
interactionState={voice.interactionState}
|
|
207
|
+
handlers={voice.handlers}
|
|
208
|
+
/>
|
|
209
|
+
) : (
|
|
210
|
+
<textarea
|
|
211
|
+
className="tbox-chat-input__field min-w-0 flex-1 resize-none border-0 bg-transparent p-0 text-base leading-[24px] text-foreground outline-none max-h-[100px] [font-family:inherit] placeholder:text-muted-foreground disabled:opacity-[0.45]"
|
|
212
|
+
value={text}
|
|
213
|
+
placeholder={blocked?.message ?? '有什么需要问我的吗'}
|
|
214
|
+
rows={1}
|
|
215
|
+
disabled={!!blocked}
|
|
216
|
+
onChange={(e) => setText(e.target.value)}
|
|
217
|
+
onKeyDown={(e) => {
|
|
218
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
submit();
|
|
221
|
+
}
|
|
222
|
+
}}
|
|
223
|
+
/>
|
|
224
|
+
)}
|
|
225
|
+
|
|
226
|
+
{enableVoice && (
|
|
227
|
+
<div className="tbox-voice-toggle flex size-[22px] shrink-0 items-center justify-center" onClick={toggleMode}>
|
|
228
|
+
<img
|
|
229
|
+
className="tbox-voice-toggle__icon size-[22px]"
|
|
230
|
+
src={inputMode === 'voice' ? keyboardIcon : voiceIcon}
|
|
231
|
+
alt={inputMode === 'voice' ? '键盘' : '语音'}
|
|
232
|
+
/>
|
|
233
|
+
</div>
|
|
234
|
+
)}
|
|
235
|
+
|
|
236
|
+
{blocked ? null : generating ? (
|
|
237
|
+
<div className="tbox-chat-input__send tbox-chat-input__send--active flex size-[var(--tbox-send-btn-size)] shrink-0 items-center justify-center" onClick={onCancel}>
|
|
238
|
+
<img className="tbox-chat-input__send-img block size-[var(--tbox-send-btn-size)]" src={stopIcon} alt="停止" />
|
|
239
|
+
</div>
|
|
240
|
+
) : canSend ? (
|
|
241
|
+
<div className="tbox-chat-input__send tbox-chat-input__send--active flex size-[var(--tbox-send-btn-size)] shrink-0 items-center justify-center" onClick={submit}>
|
|
242
|
+
<img className="tbox-chat-input__send-img block size-[var(--tbox-send-btn-size)]" src={sendIcon} alt="发送" />
|
|
243
|
+
</div>
|
|
244
|
+
) : menuOptions.length > 0 ? (
|
|
245
|
+
<div className="tbox-media-picker relative shrink-0">
|
|
246
|
+
<div
|
|
247
|
+
className={`tbox-media-picker__trigger flex shrink-0 items-center justify-center transition-transform duration-[var(--tbox-motion-duration-base)] ease-[ease] ${menuVisible ? ' tbox-media-picker__trigger--open rotate-45' : ''}`}
|
|
248
|
+
onClick={onPlus}
|
|
249
|
+
>
|
|
250
|
+
<img className="tbox-media-picker__trigger-icon size-[var(--tbox-send-btn-size)]" src={moreIcon} alt="更多" />
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
) : null}
|
|
254
|
+
</div>
|
|
255
|
+
{blocked && (
|
|
256
|
+
<div className="tbox-chat-input__blocked flex basis-full items-center gap-[6px] rounded-[6px] bg-[rgba(255,241,241,0.9)] px-[10px] py-[6px] text-xs leading-[16.8px] text-destructive">
|
|
257
|
+
<span className="tbox-chat-input__blocked-msg min-w-0 flex-1">{blocked.message}</span>
|
|
258
|
+
{blocked.onRetry && (
|
|
259
|
+
<button type="button" className="tbox-chat-input__blocked-retry shrink-0 rounded-full border-0 bg-primary px-[10px] py-[3px] text-xs leading-[normal] text-white [font-family:inherit]" onClick={blocked.onRetry}>
|
|
260
|
+
重试
|
|
261
|
+
</button>
|
|
262
|
+
)}
|
|
263
|
+
</div>
|
|
264
|
+
)}
|
|
265
|
+
</div>
|
|
266
|
+
|
|
267
|
+
{menuVisible && (
|
|
268
|
+
<div className={`tbox-media-picker-menu mt-3 flex h-[66px] flex-row overflow-hidden transition-all will-change-[opacity,transform] ${menuAnimating ? ' tbox-media-picker-menu--visible [transform:translateY(0)] opacity-100 duration-[var(--tbox-motion-duration-base)] ease-out' : ' [transform:translateY(5px)] opacity-0 duration-[var(--tbox-motion-duration-fast)] ease-in'}`}>
|
|
269
|
+
{menuOptions.map((o, index) => (
|
|
270
|
+
<div key={o.type} className={`tbox-media-picker-menu__option flex h-[66px] w-28 shrink-0 items-center justify-center overflow-hidden rounded-[10px] bg-[rgba(0,0,0,0.04)] opacity-0 transition-all duration-[var(--tbox-motion-duration-base)] ease-out will-change-[opacity,transform] [.tbox-media-picker-menu--visible_&]:opacity-100 [.tbox-media-picker-menu--visible_&]:[transform:translateY(0)] ${MENU_OPTION_DELAY_CLASS[index] ?? ''} ${index > 0 ? ' ml-[7.5px]' : ''}`} onClick={() => onMenuSelect(o.type)}>
|
|
271
|
+
<div className="tbox-media-picker-menu__option-content flex h-6 flex-row items-center">
|
|
272
|
+
<img className="tbox-media-picker-menu__option-icon size-6 shrink-0" src={o.icon} alt="" />
|
|
273
|
+
<span className="tbox-media-picker-menu__option-label ml-1 text-sm font-normal leading-[18.5px] text-secondary-foreground">{o.label}</span>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
))}
|
|
277
|
+
</div>
|
|
278
|
+
)}
|
|
279
|
+
|
|
280
|
+
{disclaimer && <div className="tbox-chat-input__disclaimer mt-[5px] text-center text-xs leading-[15px] text-muted-foreground">{disclaimer}</div>}
|
|
281
|
+
|
|
282
|
+
<VoiceRecordingOverlay
|
|
283
|
+
visible={voice.overlayVisible}
|
|
284
|
+
interactionState={voice.interactionState}
|
|
285
|
+
countdown={voice.countdown}
|
|
286
|
+
handlers={voice.handlers}
|
|
287
|
+
/>
|
|
288
|
+
</div>
|
|
289
|
+
);
|
|
290
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { VoiceInteractionState } from './machine';
|
|
2
|
+
import type { VoicePressHandlers } from './useVoicePress';
|
|
3
|
+
|
|
4
|
+
/** 各交互态的按压条底色(旧 less 的 `--pressing` / `--recording-*` / `--processing` 规则)。 */
|
|
5
|
+
const FIELD_STATE_CLASS: Record<VoiceInteractionState, string> = {
|
|
6
|
+
idle: '',
|
|
7
|
+
pressing: 'bg-[#eef4ff]',
|
|
8
|
+
'recording-active': 'bg-[#eef4ff]',
|
|
9
|
+
'recording-cancel': 'bg-[#fff1f1]',
|
|
10
|
+
processing: 'bg-[#f5f7fb]',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function fieldText(s: VoiceInteractionState): string {
|
|
14
|
+
if (s === 'recording-cancel') return '松开取消';
|
|
15
|
+
if (s === 'processing') return '识别中...';
|
|
16
|
+
if (s === 'pressing' || s === 'recording-active') return '松开转文字';
|
|
17
|
+
return '按住说话';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** “按住说话”输入条(替代文本框,语音模式下显示)。 */
|
|
21
|
+
export function VoicePressField({
|
|
22
|
+
disabled,
|
|
23
|
+
interactionState,
|
|
24
|
+
handlers,
|
|
25
|
+
}: {
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
interactionState: VoiceInteractionState;
|
|
28
|
+
handlers: VoicePressHandlers;
|
|
29
|
+
}) {
|
|
30
|
+
return (
|
|
31
|
+
<div
|
|
32
|
+
className={`tbox-voice-press-field tbox-voice-press-field--${interactionState} flex h-6 min-w-0 flex-1 touch-none select-none items-center justify-center overflow-hidden rounded-[25px] [-webkit-touch-callout:none] ${FIELD_STATE_CLASS[interactionState]} ${disabled ? ' tbox-voice-press-field--disabled opacity-[0.35]' : ''}`}
|
|
33
|
+
onTouchStart={disabled ? undefined : handlers.onTouchStart}
|
|
34
|
+
onTouchMove={disabled ? undefined : handlers.onTouchMove}
|
|
35
|
+
onTouchEnd={disabled ? undefined : handlers.onTouchEnd}
|
|
36
|
+
onTouchCancel={disabled ? undefined : handlers.onTouchCancel}
|
|
37
|
+
>
|
|
38
|
+
<div className="tbox-voice-press-field__content flex w-full items-center justify-center px-[10px]">
|
|
39
|
+
<span className="tbox-voice-press-field__text text-base font-semibold leading-[24px] text-foreground">{fieldText(interactionState)}</span>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|