@tbox.cn/app-agent-ui-kit 1.0.0-alpha.1 → 1.0.0-alpha.11
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/README.md +56 -3
- package/package.json +22 -7
- package/src/ChatPage.tsx +115 -20
- package/src/card/action-list-pending.test.tsx +91 -0
- package/src/card/define-card.test.ts +25 -0
- package/src/card/define-card.ts +47 -0
- package/src/card/primitives.test.tsx +157 -0
- package/src/card/primitives.tsx +717 -0
- package/src/card/use-card-actions.ts +86 -0
- package/src/card/view-card-inline.test.tsx +42 -0
- package/src/card/view-card.test.tsx +79 -0
- package/src/card/view-card.tsx +250 -0
- package/src/chat-config.test.ts +35 -71
- package/src/chat-config.ts +29 -7
- package/src/components/ActionBar/DebugButton.test.tsx +3 -0
- package/src/components/ActionBar/DebugButton.tsx +5 -10
- package/src/components/ActionBar/index.tsx +13 -14
- package/src/components/BottomSheet/index.test.tsx +97 -0
- package/src/components/BottomSheet/index.tsx +49 -0
- package/src/components/ChatHeader/index.tsx +19 -17
- package/src/components/ChatInput/index.test.tsx +2 -2
- package/src/components/ChatInput/index.tsx +44 -33
- package/src/components/ChatInput/voice/VoicePressField.tsx +12 -3
- package/src/components/ChatInput/voice/VoiceRecordingOverlay.tsx +9 -9
- package/src/components/ChatInput/voice/useVoicePress.ts +1 -1
- package/src/components/HistoryEntry/index.tsx +4 -4
- package/src/components/MediaList/index.tsx +42 -28
- package/src/components/MessageBubble/index.tsx +59 -28
- package/src/components/PullDownIndicator/index.tsx +3 -4
- package/src/components/QuickCommands/index.test.tsx +3 -1
- package/src/components/QuickCommands/index.tsx +33 -10
- package/src/components/ReasoningBlock/index.tsx +14 -9
- package/src/components/ScrollToBottomButton/index.tsx +7 -5
- package/src/components/ToolCallBlock/index.tsx +58 -38
- package/src/icons.ts +39 -0
- package/src/index.ts +75 -1
- package/src/overlay/Overlay.tsx +154 -0
- package/src/overlay/focus.ts +53 -0
- package/src/overlay/index.ts +16 -0
- package/src/overlay/inert.ts +27 -0
- package/src/overlay/layers.ts +21 -0
- package/src/overlay/overlay.ssr.test.tsx +27 -0
- package/src/overlay/overlay.test.tsx +209 -0
- package/src/overlay/presence.ts +86 -0
- package/src/overlay/scroll-lock.ts +62 -0
- package/src/overlay/stack.ts +111 -0
- package/src/overlay/use-overlay.ts +80 -0
- package/src/preview-provider.tsx +47 -0
- package/src/shell.contract.json +75 -0
- package/src/shell.test.ts +72 -0
- package/src/shell.ts +60 -0
- package/src/surface.test.tsx +35 -0
- package/src/surface.tsx +44 -0
- package/src/theme/base.css +167 -0
- package/src/theme/contract.json +123 -2
- package/src/theme/theme-contract.test.ts +19 -3
- package/src/theme/{tokens.less → tokens.css} +19 -20
- package/src/utils/image-preview-host.tsx +95 -0
- package/src/utils/imagePreview.test.ts +32 -0
- package/src/utils/imagePreview.ts +14 -5
- package/src/utils/toast.test.ts +64 -0
- package/src/utils/toast.ts +100 -7
- package/src/ChatPage.less +0 -62
- package/src/components/ActionBar/index.less +0 -123
- package/src/components/ChatHeader/index.less +0 -148
- package/src/components/ChatInput/index.less +0 -394
- package/src/components/HistoryEntry/index.less +0 -49
- package/src/components/MediaList/index.less +0 -241
- package/src/components/MessageBubble/index.less +0 -325
- package/src/components/PullDownIndicator/index.less +0 -32
- package/src/components/QuickCommands/index.less +0 -63
- package/src/components/ReasoningBlock/index.less +0 -90
- package/src/components/ScrollToBottomButton/index.less +0 -32
- package/src/components/ToolCallBlock/index.less +0 -312
- package/src/theme/global.less +0 -99
- /package/src/theme/{motion.less → motion.css} +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 图片预览宿主(只经动态 `import()` 加载):Yet Another React Lightbox + Zoom / Counter 插件。
|
|
3
|
+
*
|
|
4
|
+
* - 单例挂载到 body,关闭动画播完(`on.exited`)才卸载;
|
|
5
|
+
* - 滚动锁 / 焦点 / Escape 走 kit overlay 内核(Escape 由栈顶分发,因此关掉 YARL 自带的
|
|
6
|
+
* `closeOnEscape` 与 `noScroll`,避免两套滚动锁互相覆盖);
|
|
7
|
+
* - 层级经 YARL 的 `--yarl__portal_zindex` 变量钉到 preview 档。
|
|
8
|
+
*/
|
|
9
|
+
import { useRef } from 'react';
|
|
10
|
+
import type { CSSProperties } from 'react';
|
|
11
|
+
import { createRoot } from 'react-dom/client';
|
|
12
|
+
import type { Root } from 'react-dom/client';
|
|
13
|
+
import Lightbox from 'yet-another-react-lightbox';
|
|
14
|
+
import type { ControllerRef } from 'yet-another-react-lightbox';
|
|
15
|
+
import Counter from 'yet-another-react-lightbox/plugins/counter';
|
|
16
|
+
import Zoom from 'yet-another-react-lightbox/plugins/zoom';
|
|
17
|
+
|
|
18
|
+
import 'yet-another-react-lightbox/styles.css';
|
|
19
|
+
import 'yet-another-react-lightbox/plugins/counter.css';
|
|
20
|
+
|
|
21
|
+
import { OVERLAY_LAYER_Z, useOverlay } from '../overlay';
|
|
22
|
+
|
|
23
|
+
interface PreviewHostProps {
|
|
24
|
+
images: string[];
|
|
25
|
+
index: number;
|
|
26
|
+
onClosed: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function PreviewHost({ images, index, onClosed }: PreviewHostProps) {
|
|
30
|
+
const panelRef = useRef<HTMLDivElement>(null);
|
|
31
|
+
const controllerRef = useRef<ControllerRef>(null);
|
|
32
|
+
|
|
33
|
+
useOverlay({
|
|
34
|
+
active: true,
|
|
35
|
+
onDismiss: () => controllerRef.current?.close(),
|
|
36
|
+
panelRef,
|
|
37
|
+
rootRef: panelRef,
|
|
38
|
+
trapFocus: false,
|
|
39
|
+
lockScroll: true,
|
|
40
|
+
inertApp: true,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div ref={panelRef}>
|
|
45
|
+
<Lightbox
|
|
46
|
+
open
|
|
47
|
+
close={() => controllerRef.current?.close()}
|
|
48
|
+
index={index}
|
|
49
|
+
slides={images.map((src) => ({ src }))}
|
|
50
|
+
plugins={images.length > 1 ? [Zoom, Counter] : [Zoom]}
|
|
51
|
+
controller={{
|
|
52
|
+
ref: controllerRef,
|
|
53
|
+
closeOnBackdropClick: true,
|
|
54
|
+
closeOnPullDown: true,
|
|
55
|
+
closeOnEscape: false,
|
|
56
|
+
}}
|
|
57
|
+
carousel={{ finite: true }}
|
|
58
|
+
animation={{ fade: 180, swipe: 300 }}
|
|
59
|
+
noScroll={{ disabled: true }}
|
|
60
|
+
toolbar={{ buttons: ['close'] }}
|
|
61
|
+
labels={{ Close: '关闭', Next: '下一张', Previous: '上一张' }}
|
|
62
|
+
portal={{
|
|
63
|
+
container: {
|
|
64
|
+
style: { '--yarl__portal_zindex': String(OVERLAY_LAYER_Z.preview) } as CSSProperties,
|
|
65
|
+
},
|
|
66
|
+
}}
|
|
67
|
+
on={{ exited: onClosed }}
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let active: { root: Root; host: HTMLDivElement } | null = null;
|
|
74
|
+
|
|
75
|
+
function teardown(): void {
|
|
76
|
+
const current = active;
|
|
77
|
+
active = null;
|
|
78
|
+
if (!current) return;
|
|
79
|
+
// 卸载推迟到微任务外:避免在 YARL 自身回调栈里同步 unmount 同一个根。
|
|
80
|
+
window.setTimeout(() => {
|
|
81
|
+
current.root.unmount();
|
|
82
|
+
current.host.remove();
|
|
83
|
+
}, 0);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** 打开预览(`previewImages` 的唯一实现;已有预览时先关闭再开)。 */
|
|
87
|
+
export function openImagePreview(images: string[], index: number): void {
|
|
88
|
+
teardown();
|
|
89
|
+
const host = document.createElement('div');
|
|
90
|
+
host.setAttribute('data-tbox-image-preview', '');
|
|
91
|
+
document.body.append(host);
|
|
92
|
+
const root = createRoot(host);
|
|
93
|
+
active = { root, host };
|
|
94
|
+
root.render(<PreviewHost images={images} index={index} onClosed={teardown} />);
|
|
95
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
|
|
4
|
+
const toastMock = vi.hoisted(() => vi.fn(async () => {}));
|
|
5
|
+
vi.mock('./toast', () => ({ toast: toastMock }));
|
|
6
|
+
|
|
7
|
+
// 预览宿主 chunk 加载失败:动态 import 直接拒绝
|
|
8
|
+
vi.mock('./image-preview-host', () => {
|
|
9
|
+
throw new Error('chunk missing');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const { previewImages } = await import('./imagePreview');
|
|
13
|
+
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
toastMock.mockClear();
|
|
16
|
+
document.body.innerHTML = '';
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('previewImages', () => {
|
|
20
|
+
it('空列表/无 document 时而早返回,不触达宿主', async () => {
|
|
21
|
+
await previewImages([]);
|
|
22
|
+
expect(toastMock).not.toHaveBeenCalled();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('宿主加载失败:自吞并提示,不抛未处理拒绝', async () => {
|
|
26
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
27
|
+
await expect(previewImages(['https://example.com/a.png'])).resolves.toBeUndefined();
|
|
28
|
+
expect(warn).toHaveBeenCalled();
|
|
29
|
+
expect(toastMock).toHaveBeenCalledWith('图片预览加载失败,请重试', 'error');
|
|
30
|
+
warn.mockRestore();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* 图片预览(按需加载预览宿主)。
|
|
3
|
+
* 预览宿主(Yet Another Lightbox + 缩放手势)依赖较重——用动态 import 切成单独 chunk,
|
|
4
4
|
* 仅在用户首次点开图片时加载,不占首屏体积。
|
|
5
5
|
*/
|
|
6
6
|
export async function previewImages(images: string[], defaultIndex = 0): Promise<void> {
|
|
7
|
-
if (!images.length) return;
|
|
8
|
-
const
|
|
9
|
-
|
|
7
|
+
if (!images.length || typeof document === 'undefined') return;
|
|
8
|
+
const index = Math.min(Math.max(0, Math.trunc(defaultIndex)), images.length - 1);
|
|
9
|
+
try {
|
|
10
|
+
const host = await import('./image-preview-host');
|
|
11
|
+
host.openImagePreview(images, index);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
// 调用方(气泡/媒体列表)都是 fire-and-forget:这里必须自吞,否则一次 chunk 失败就是未处理拒绝,
|
|
14
|
+
// 且用户点了没反应。失败提示走纯 DOM toast(同 chunk 之外,不依赖预览宿主)。
|
|
15
|
+
console.warn('previewImages: 预览宿主加载失败', error);
|
|
16
|
+
const { toast } = await import('./toast');
|
|
17
|
+
void toast('图片预览加载失败,请重试', 'error');
|
|
18
|
+
}
|
|
10
19
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { toast } from './toast';
|
|
4
|
+
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
vi.useFakeTimers();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
vi.useRealTimers();
|
|
11
|
+
document.body.innerHTML = '';
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
function bubbles(): HTMLElement[] {
|
|
15
|
+
return [...document.querySelectorAll<HTMLElement>('[data-tbox-toast]')];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('toast', () => {
|
|
19
|
+
it('单实例:新提示替换旧提示并重置计时', async () => {
|
|
20
|
+
await toast('第一条');
|
|
21
|
+
await toast('第二条');
|
|
22
|
+
expect(bubbles()).toHaveLength(1);
|
|
23
|
+
expect(bubbles()[0].textContent).toBe('第二条');
|
|
24
|
+
vi.advanceTimersByTime(1999);
|
|
25
|
+
expect(bubbles()).toHaveLength(1);
|
|
26
|
+
vi.advanceTimersByTime(1);
|
|
27
|
+
expect(bubbles()[0].getAttribute('data-state')).toBe('closed');
|
|
28
|
+
vi.advanceTimersByTime(150);
|
|
29
|
+
expect(bubbles()).toHaveLength(0);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('语气决定图标与可访问语义', async () => {
|
|
33
|
+
await toast('成功', 'success');
|
|
34
|
+
expect(bubbles()[0].querySelector('svg')?.getAttribute('class')).toContain('text-success');
|
|
35
|
+
await toast('失败', 'error');
|
|
36
|
+
expect(bubbles()[0].querySelector('svg')?.getAttribute('class')).toContain('text-destructive');
|
|
37
|
+
await toast('普通');
|
|
38
|
+
expect(bubbles()[0].querySelector('svg')).toBeNull();
|
|
39
|
+
const host = document.querySelector('[role="status"]') as HTMLElement;
|
|
40
|
+
expect(host.getAttribute('aria-live')).toBe('polite');
|
|
41
|
+
expect(host.getAttribute('aria-atomic')).toBe('true');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('内容按纯文本写入,不解释 HTML', async () => {
|
|
45
|
+
await toast('<b>加粗</b>');
|
|
46
|
+
expect(bubbles()[0].querySelector('b')).toBeNull();
|
|
47
|
+
expect(bubbles()[0].textContent).toBe('<b>加粗</b>');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('隐藏中又来一条:替换旧节点,不留隐形残骸', async () => {
|
|
51
|
+
await toast('第一条');
|
|
52
|
+
vi.advanceTimersByTime(2000); // 进入 150ms 隐藏窗口
|
|
53
|
+
await toast('第二条'); // 在隐藏窗口内替换
|
|
54
|
+
vi.advanceTimersByTime(400);
|
|
55
|
+
expect(bubbles()).toHaveLength(1);
|
|
56
|
+
expect(bubbles()[0].textContent).toBe('第二条');
|
|
57
|
+
expect(bubbles()[0].getAttribute('data-state')).toBe('open');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('不拦截点击(pointer-events 关闭)', async () => {
|
|
61
|
+
await toast('提示');
|
|
62
|
+
expect(bubbles()[0].className).toContain('pointer-events-none');
|
|
63
|
+
});
|
|
64
|
+
});
|
package/src/utils/toast.ts
CHANGED
|
@@ -2,14 +2,107 @@
|
|
|
2
2
|
export type ToastTone = 'info' | 'success' | 'error';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* 与 imagePreview 共用同一个 antd-mobile 动态 chunk——首次弹提示/看大图时才加载,
|
|
7
|
-
* 不占首屏体积。错误反馈等延迟一帧无感。
|
|
5
|
+
* 轻提示:纯 DOM 实现,不依赖 React、不依赖任何组件库。
|
|
8
6
|
*
|
|
9
|
-
*
|
|
7
|
+
* 为什么不用组件库:`toast` 的调用方里有 React 树外的命令式通道(SDK chat-store 的 `deps.toast`),
|
|
8
|
+
* 组件库方案要求应用根部挂 Provider 并接线;纯 DOM 版零接线、可静态导入(不再等动态 chunk),
|
|
9
|
+
* 且 Node/SSR 环境直接空返回(不再需要 ssr.noExternal 兜底)。
|
|
10
|
+
*
|
|
11
|
+
* 语义对齐被替换的 antd Toast:单实例(新提示替换旧提示并重置计时)、2000ms、视口居中、不拦截点击、
|
|
12
|
+
* 图标区 36px;额外补 `role="status"` + `aria-live` 让读屏可朗读。
|
|
13
|
+
*
|
|
14
|
+
* @param tone 语气:success → 成功图标,error → 失败图标,info/省略 → 无图标
|
|
10
15
|
*/
|
|
11
16
|
export async function toast(content: string, tone: ToastTone = 'info'): Promise<void> {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
if (typeof document === 'undefined' || !document.body) return;
|
|
18
|
+
clearTimers();
|
|
19
|
+
const host = ensureHost();
|
|
20
|
+
const next = buildToast(content, tone);
|
|
21
|
+
if (bubble?.isConnected) bubble.replaceWith(next);
|
|
22
|
+
else host.append(next);
|
|
23
|
+
bubble = next;
|
|
24
|
+
hideTimer = window.setTimeout(hide, TOAST_DURATION);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const TOAST_DURATION = 2000;
|
|
28
|
+
const FADE_OUT_MS = 150;
|
|
29
|
+
|
|
30
|
+
const HOST_CLASS = 'pointer-events-none fixed inset-0 z-[1300] flex items-center justify-center px-6';
|
|
31
|
+
const BUBBLE_CLASS = [
|
|
32
|
+
'pointer-events-none flex max-w-[min(80vw,320px)] flex-col items-center gap-1.5',
|
|
33
|
+
'rounded-lg bg-[rgba(0,0,0,0.75)] px-4 py-3 text-center text-sm leading-5 text-white',
|
|
34
|
+
'transition-opacity duration-150 data-[state=closed]:opacity-0 motion-reduce:transition-none',
|
|
35
|
+
].join(' ');
|
|
36
|
+
|
|
37
|
+
let host: HTMLDivElement | null = null;
|
|
38
|
+
let bubble: HTMLDivElement | null = null;
|
|
39
|
+
let hideTimer: number | undefined;
|
|
40
|
+
let removeTimer: number | undefined;
|
|
41
|
+
|
|
42
|
+
function ensureHost(): HTMLDivElement {
|
|
43
|
+
if (host?.isConnected) return host;
|
|
44
|
+
const el = document.createElement('div');
|
|
45
|
+
el.className = HOST_CLASS;
|
|
46
|
+
el.setAttribute('role', 'status');
|
|
47
|
+
el.setAttribute('aria-live', 'polite');
|
|
48
|
+
el.setAttribute('aria-atomic', 'true');
|
|
49
|
+
document.body.append(el);
|
|
50
|
+
host = el;
|
|
51
|
+
return el;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function iconNode(tone: Exclude<ToastTone, 'info'>): SVGSVGElement {
|
|
55
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
56
|
+
svg.setAttribute('viewBox', '0 0 24 24');
|
|
57
|
+
svg.setAttribute('fill', 'none');
|
|
58
|
+
svg.setAttribute('stroke', 'currentColor');
|
|
59
|
+
svg.setAttribute('stroke-width', '2');
|
|
60
|
+
svg.setAttribute('stroke-linecap', 'round');
|
|
61
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
62
|
+
svg.setAttribute('class', `size-9 ${tone === 'success' ? 'text-success' : 'text-destructive'}`);
|
|
63
|
+
const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
64
|
+
circle.setAttribute('cx', '12');
|
|
65
|
+
circle.setAttribute('cy', '12');
|
|
66
|
+
circle.setAttribute('r', '10');
|
|
67
|
+
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
68
|
+
path.setAttribute('d', tone === 'success' ? 'm8 12 3 3 5-6' : 'm9 9 6 6M15 9l-6 6');
|
|
69
|
+
svg.append(circle, path);
|
|
70
|
+
return svg;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function buildToast(content: string, tone: ToastTone): HTMLDivElement {
|
|
74
|
+
const el = document.createElement('div');
|
|
75
|
+
el.className = BUBBLE_CLASS;
|
|
76
|
+
el.setAttribute('data-tbox-toast', '');
|
|
77
|
+
el.setAttribute('data-state', 'open');
|
|
78
|
+
if (tone !== 'info') el.append(iconNode(tone));
|
|
79
|
+
const text = document.createElement('span');
|
|
80
|
+
text.className = '[overflow-wrap:anywhere]';
|
|
81
|
+
// textContent 而非 innerHTML:提示内容是业务/模型文本,不做 HTML 解释。
|
|
82
|
+
text.textContent = content;
|
|
83
|
+
el.append(text);
|
|
84
|
+
return el;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function clearTimers(): void {
|
|
88
|
+
if (hideTimer !== undefined) window.clearTimeout(hideTimer);
|
|
89
|
+
if (removeTimer !== undefined) window.clearTimeout(removeTimer);
|
|
90
|
+
hideTimer = undefined;
|
|
91
|
+
removeTimer = undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function hide(): void {
|
|
95
|
+
const node = bubble;
|
|
96
|
+
if (!node) return;
|
|
97
|
+
node.setAttribute('data-state', 'closed');
|
|
98
|
+
// 引用保留到真正移除:这段时间里再来一条提示,`toast()` 会 replaceWith 掉这个节点(
|
|
99
|
+
// 提前置 null 会让它既不被替换也不被移除,留下永不清理的隐形残骸)。
|
|
100
|
+
removeTimer = window.setTimeout(() => {
|
|
101
|
+
node.remove();
|
|
102
|
+
if (bubble === node) bubble = null;
|
|
103
|
+
if (host && !host.childElementCount) {
|
|
104
|
+
host.remove();
|
|
105
|
+
host = null;
|
|
106
|
+
}
|
|
107
|
+
}, FADE_OUT_MS);
|
|
15
108
|
}
|
package/src/ChatPage.less
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
.chat-page {
|
|
2
|
-
position: relative;
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
width: 100%;
|
|
6
|
-
height: 100vh;
|
|
7
|
-
height: 100dvh;
|
|
8
|
-
min-height: 0;
|
|
9
|
-
overflow: hidden;
|
|
10
|
-
background: var(--tbox-bg-page);
|
|
11
|
-
|
|
12
|
-
&__bg {
|
|
13
|
-
position: absolute;
|
|
14
|
-
inset: 0;
|
|
15
|
-
z-index: 0;
|
|
16
|
-
background: var(--tbox-bg-page);
|
|
17
|
-
pointer-events: none;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&__body-wrapper {
|
|
21
|
-
position: relative;
|
|
22
|
-
z-index: 1;
|
|
23
|
-
display: flex;
|
|
24
|
-
flex: 1;
|
|
25
|
-
flex-direction: column;
|
|
26
|
-
min-height: 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&__body {
|
|
30
|
-
flex: 1;
|
|
31
|
-
width: 100%;
|
|
32
|
-
max-width: var(--tbox-content-max-width);
|
|
33
|
-
min-height: 0;
|
|
34
|
-
margin: 0 auto;
|
|
35
|
-
padding: calc(12PX + env(safe-area-inset-top, 0PX)) 0 24PX;
|
|
36
|
-
overflow-y: auto;
|
|
37
|
-
overflow-x: hidden;
|
|
38
|
-
overflow-anchor: none;
|
|
39
|
-
overscroll-behavior: contain;
|
|
40
|
-
scrollbar-width: none;
|
|
41
|
-
-webkit-overflow-scrolling: touch;
|
|
42
|
-
|
|
43
|
-
&::-webkit-scrollbar {
|
|
44
|
-
display: none;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&__orphan-card {
|
|
49
|
-
margin-right: var(--tbox-page-gutter);
|
|
50
|
-
margin-left: var(--tbox-page-gutter);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* 顶部历史入口在场时欢迎区不再叠加自身顶部留白:胶囊到标题区留 4PX(= 欢迎区自带上边距)。 */
|
|
54
|
-
.history-entry ~ .mall-home {
|
|
55
|
-
padding-top: 0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/* 对话开始后首页仍保留,消息接在联单主卡下方。 */
|
|
59
|
-
&--conversation &__body {
|
|
60
|
-
padding-top: calc(12PX + env(safe-area-inset-top, 0PX));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 助手消息操作栏(mall-vis 蓝系 token 化)。
|
|
3
|
-
* - 图标 phosphor 矢量(currentColor):默认灰(--tbox-text-muted)、active 态蓝(--tbox-primary)
|
|
4
|
-
* - active 底 / TTS 播放底:--tbox-primary-light(蓝系浅底)
|
|
5
|
-
* - 调试文字 / 波形条:--tbox-text-secondary
|
|
6
|
-
* - 按压底:--tbox-bg-subtle
|
|
7
|
-
*/
|
|
8
|
-
.tbox-action-bar {
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
gap: 16px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.tbox-action-btn {
|
|
15
|
-
padding: 0;
|
|
16
|
-
border: 0;
|
|
17
|
-
color: var(--tbox-text-muted);
|
|
18
|
-
font: inherit;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
width: 52px;
|
|
21
|
-
height: 52px;
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
justify-content: center;
|
|
25
|
-
flex-shrink: 0;
|
|
26
|
-
border-radius: 26px;
|
|
27
|
-
background: #fff;
|
|
28
|
-
transition: background-color var(--tbox-motion-duration-fast) ease, transform var(--tbox-motion-duration-fast) ease;
|
|
29
|
-
|
|
30
|
-
&:active {
|
|
31
|
-
background: var(--tbox-bg-subtle);
|
|
32
|
-
transform: scale(0.97);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&--active {
|
|
36
|
-
color: var(--tbox-primary);
|
|
37
|
-
background: var(--tbox-primary-light);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&__icon-wrap {
|
|
41
|
-
width: 28px;
|
|
42
|
-
height: 28px;
|
|
43
|
-
display: flex;
|
|
44
|
-
align-items: center;
|
|
45
|
-
justify-content: center;
|
|
46
|
-
flex-shrink: 0;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* 调试按钮:独立 pill(icon + “调试” 文字) */
|
|
51
|
-
.tbox-debug-btn {
|
|
52
|
-
display: inline-flex;
|
|
53
|
-
align-items: center;
|
|
54
|
-
justify-content: center;
|
|
55
|
-
gap: 8px;
|
|
56
|
-
height: 52px;
|
|
57
|
-
padding: 0 22px;
|
|
58
|
-
border-radius: 26px;
|
|
59
|
-
background: #fff;
|
|
60
|
-
color: var(--tbox-text-secondary);
|
|
61
|
-
transition: background-color var(--tbox-motion-duration-fast) ease, transform var(--tbox-motion-duration-fast) ease;
|
|
62
|
-
|
|
63
|
-
&:active {
|
|
64
|
-
background: var(--tbox-bg-subtle);
|
|
65
|
-
transform: scale(0.97);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
&__icon {
|
|
69
|
-
width: 28px;
|
|
70
|
-
height: 28px;
|
|
71
|
-
flex-shrink: 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&__text {
|
|
75
|
-
font-size: 21px;
|
|
76
|
-
line-height: 1;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* TTS 播放波形(红系主色,随 token 走) */
|
|
81
|
-
.tbox-tts-wave {
|
|
82
|
-
display: flex;
|
|
83
|
-
align-items: center;
|
|
84
|
-
justify-content: center;
|
|
85
|
-
gap: 3px;
|
|
86
|
-
width: 28px;
|
|
87
|
-
height: 28px;
|
|
88
|
-
|
|
89
|
-
&__bar {
|
|
90
|
-
width: 3px;
|
|
91
|
-
border-radius: 999px;
|
|
92
|
-
background: var(--tbox-primary);
|
|
93
|
-
transform-origin: center bottom;
|
|
94
|
-
animation: tbox-tts-wave 0.8s ease-in-out infinite;
|
|
95
|
-
}
|
|
96
|
-
&__bar--1 {
|
|
97
|
-
height: 14px;
|
|
98
|
-
animation-delay: 0s;
|
|
99
|
-
}
|
|
100
|
-
&__bar--2 {
|
|
101
|
-
height: 18px;
|
|
102
|
-
animation-delay: 0.15s;
|
|
103
|
-
}
|
|
104
|
-
&__bar--3 {
|
|
105
|
-
height: 12px;
|
|
106
|
-
animation-delay: 0.3s;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.tbox-tts-btn--playing {
|
|
111
|
-
color: var(--tbox-primary);
|
|
112
|
-
background: var(--tbox-primary-light);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
@keyframes tbox-tts-wave {
|
|
116
|
-
0%,
|
|
117
|
-
100% {
|
|
118
|
-
transform: scaleY(0.6);
|
|
119
|
-
}
|
|
120
|
-
50% {
|
|
121
|
-
transform: scaleY(1);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/* 顶部品牌区 + 右对齐控件条带(014 T7:mall 形态——品牌名来自 HELLO_ACK.mallScope.mallName)。 */
|
|
2
|
-
.chat-header {
|
|
3
|
-
position: absolute;
|
|
4
|
-
top: calc(10px + env(safe-area-inset-top, 0px));
|
|
5
|
-
left: 50%;
|
|
6
|
-
z-index: 100;
|
|
7
|
-
display: flex;
|
|
8
|
-
width: 100%;
|
|
9
|
-
max-width: var(--tbox-content-max-width);
|
|
10
|
-
padding: 0 32px;
|
|
11
|
-
flex-direction: column;
|
|
12
|
-
align-items: flex-end;
|
|
13
|
-
pointer-events: none;
|
|
14
|
-
transform: translateX(-50%);
|
|
15
|
-
|
|
16
|
-
&__brand {
|
|
17
|
-
position: absolute;
|
|
18
|
-
top: 4px;
|
|
19
|
-
left: 32px;
|
|
20
|
-
display: inline-flex;
|
|
21
|
-
align-items: center;
|
|
22
|
-
min-height: 44px;
|
|
23
|
-
color: var(--tbox-text-primary);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&__brand-mark {
|
|
27
|
-
width: 7px;
|
|
28
|
-
height: 34px;
|
|
29
|
-
margin-right: 14px;
|
|
30
|
-
background: var(--tbox-primary);
|
|
31
|
-
border-radius: 2px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&__brand-name {
|
|
35
|
-
font-size: 24px;
|
|
36
|
-
font-weight: 760;
|
|
37
|
-
line-height: 1;
|
|
38
|
-
letter-spacing: 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&__group {
|
|
42
|
-
display: flex;
|
|
43
|
-
align-items: center;
|
|
44
|
-
max-height: 80px;
|
|
45
|
-
margin-bottom: 6px;
|
|
46
|
-
padding: 6px;
|
|
47
|
-
gap: 4px;
|
|
48
|
-
overflow: hidden;
|
|
49
|
-
opacity: 1;
|
|
50
|
-
pointer-events: auto;
|
|
51
|
-
background: rgba(255, 255, 255, 0.96);
|
|
52
|
-
border: 1px solid var(--tbox-border);
|
|
53
|
-
border-radius: 12px;
|
|
54
|
-
box-shadow: var(--tbox-shadow-sm);
|
|
55
|
-
transform: translateY(0);
|
|
56
|
-
transition: opacity var(--tbox-transition-base), transform var(--tbox-transition-base);
|
|
57
|
-
|
|
58
|
-
&--collapsed {
|
|
59
|
-
max-height: 0;
|
|
60
|
-
margin-bottom: 0;
|
|
61
|
-
padding-top: 0;
|
|
62
|
-
padding-bottom: 0;
|
|
63
|
-
opacity: 0;
|
|
64
|
-
pointer-events: none;
|
|
65
|
-
transform: translateY(-8px);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&__btn {
|
|
70
|
-
display: inline-flex;
|
|
71
|
-
align-items: center;
|
|
72
|
-
justify-content: center;
|
|
73
|
-
min-height: 52px;
|
|
74
|
-
padding: 0 15px;
|
|
75
|
-
gap: 7px;
|
|
76
|
-
color: var(--tbox-text-secondary);
|
|
77
|
-
appearance: none;
|
|
78
|
-
background: transparent;
|
|
79
|
-
border: 0;
|
|
80
|
-
border-radius: 8px;
|
|
81
|
-
|
|
82
|
-
&:active {
|
|
83
|
-
background: var(--tbox-bg-subtle);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&:focus-visible {
|
|
87
|
-
outline: 3px solid rgba(9, 107, 250, 0.24);
|
|
88
|
-
outline-offset: -2px;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
&__btn-icon {
|
|
93
|
-
width: 22px;
|
|
94
|
-
height: 22px;
|
|
95
|
-
color: var(--tbox-primary);
|
|
96
|
-
flex-shrink: 0;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
&__btn-text {
|
|
100
|
-
color: inherit;
|
|
101
|
-
font-size: 22px;
|
|
102
|
-
font-weight: 560;
|
|
103
|
-
line-height: 1;
|
|
104
|
-
white-space: nowrap;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
&__toggle {
|
|
108
|
-
display: flex;
|
|
109
|
-
align-items: center;
|
|
110
|
-
justify-content: center;
|
|
111
|
-
width: 56px;
|
|
112
|
-
height: 44px;
|
|
113
|
-
color: var(--tbox-text-muted);
|
|
114
|
-
appearance: none;
|
|
115
|
-
pointer-events: auto;
|
|
116
|
-
background: rgba(255, 255, 255, 0.92);
|
|
117
|
-
border: 1px solid var(--tbox-border);
|
|
118
|
-
border-radius: 8px;
|
|
119
|
-
box-shadow: var(--tbox-shadow-sm);
|
|
120
|
-
|
|
121
|
-
&:active {
|
|
122
|
-
background: var(--tbox-bg-subtle);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
&:focus-visible {
|
|
126
|
-
outline: 3px solid rgba(9, 107, 250, 0.24);
|
|
127
|
-
outline-offset: 2px;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
&__arrow {
|
|
132
|
-
display: flex;
|
|
133
|
-
align-items: center;
|
|
134
|
-
justify-content: center;
|
|
135
|
-
transition: transform var(--tbox-transition-base);
|
|
136
|
-
|
|
137
|
-
&--up {
|
|
138
|
-
transform: rotate(180deg);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
@media (prefers-reduced-motion: reduce) {
|
|
144
|
-
.chat-header__group,
|
|
145
|
-
.chat-header__arrow {
|
|
146
|
-
transition: none;
|
|
147
|
-
}
|
|
148
|
-
}
|