@tbox.cn/app-agent-ui-kit 1.0.0-alpha.13 → 1.0.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/package.json +3 -3
  2. package/src/ChatPage.tsx +77 -151
  3. package/src/card/action-list-pending.test.tsx +96 -31
  4. package/src/card/primitives.test.tsx +20 -7
  5. package/src/card/primitives.tsx +54 -41
  6. package/src/card/use-card-actions.ts +23 -14
  7. package/src/card/view-card-inline.test.tsx +34 -2
  8. package/src/card/view-card.test.tsx +3 -3
  9. package/src/card/view-card.tsx +24 -29
  10. package/src/chat-config.test.ts +13 -8
  11. package/src/chat-config.ts +29 -8
  12. package/src/components/ChatInput/index.test.tsx +37 -0
  13. package/src/components/ChatInput/index.tsx +19 -6
  14. package/src/components/ChatInput/use-auto-rows.test.tsx +78 -0
  15. package/src/components/ChatInput/use-auto-rows.ts +68 -0
  16. package/src/components/HistoryEntry/index.tsx +3 -1
  17. package/src/components/HistoryList.tsx +52 -0
  18. package/src/components/MessageBubble/index.tsx +2 -3
  19. package/src/components/QuickCommands/index.test.tsx +25 -5
  20. package/src/components/QuickCommands/index.tsx +30 -27
  21. package/src/hooks/use-pull-down-history.ts +3 -4
  22. package/src/hooks/use-pull-down-wheel-native.test.ts +4 -8
  23. package/src/hooks/use-stick-to-bottom.test.tsx +142 -0
  24. package/src/hooks/use-stick-to-bottom.ts +218 -0
  25. package/src/index.ts +1 -2
  26. package/src/preview-provider.tsx +2 -1
  27. package/src/shell.contract.json +12 -13
  28. package/src/shell.test.ts +107 -11
  29. package/src/shell.ts +13 -10
  30. package/src/test/setup.ts +31 -0
  31. package/src/theme/base.css +5 -0
  32. package/src/theme/contract.json +1 -0
  33. package/src/theme/tokens.css +1 -0
  34. package/src/components/ChatHeader/index.test.tsx +0 -74
  35. package/src/components/ChatHeader/index.tsx +0 -77
@@ -1,77 +0,0 @@
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
- }