@tbox.cn/app-agent-ui-kit 1.0.0-alpha.1 → 1.0.0-alpha.7

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 (46) hide show
  1. package/README.md +1 -1
  2. package/package.json +9 -6
  3. package/src/ChatPage.tsx +34 -7
  4. package/src/card/define-card.ts +34 -0
  5. package/src/card/primitives.test.tsx +147 -0
  6. package/src/card/primitives.tsx +627 -0
  7. package/src/card/use-card-actions.ts +86 -0
  8. package/src/chat-config.test.ts +35 -71
  9. package/src/chat-config.ts +18 -0
  10. package/src/components/ActionBar/DebugButton.tsx +3 -3
  11. package/src/components/ActionBar/index.tsx +13 -14
  12. package/src/components/ChatHeader/index.tsx +19 -17
  13. package/src/components/ChatInput/index.tsx +32 -26
  14. package/src/components/ChatInput/voice/VoicePressField.tsx +12 -3
  15. package/src/components/ChatInput/voice/VoiceRecordingOverlay.tsx +9 -9
  16. package/src/components/HistoryEntry/index.tsx +3 -4
  17. package/src/components/MediaList/index.tsx +42 -28
  18. package/src/components/MessageBubble/index.tsx +52 -27
  19. package/src/components/PullDownIndicator/index.tsx +3 -4
  20. package/src/components/QuickCommands/index.tsx +6 -6
  21. package/src/components/ReasoningBlock/index.tsx +14 -9
  22. package/src/components/ScrollToBottomButton/index.tsx +2 -4
  23. package/src/components/ToolCallBlock/index.tsx +54 -36
  24. package/src/icons.ts +39 -0
  25. package/src/index.ts +54 -1
  26. package/src/shell.contract.json +59 -0
  27. package/src/shell.test.ts +61 -0
  28. package/src/shell.ts +45 -0
  29. package/src/theme/base.css +132 -0
  30. package/src/theme/contract.json +1 -1
  31. package/src/theme/theme-contract.test.ts +3 -3
  32. package/src/theme/{tokens.less → tokens.css} +14 -12
  33. package/src/ChatPage.less +0 -62
  34. package/src/components/ActionBar/index.less +0 -123
  35. package/src/components/ChatHeader/index.less +0 -148
  36. package/src/components/ChatInput/index.less +0 -394
  37. package/src/components/HistoryEntry/index.less +0 -49
  38. package/src/components/MediaList/index.less +0 -241
  39. package/src/components/MessageBubble/index.less +0 -325
  40. package/src/components/PullDownIndicator/index.less +0 -32
  41. package/src/components/QuickCommands/index.less +0 -63
  42. package/src/components/ReasoningBlock/index.less +0 -90
  43. package/src/components/ScrollToBottomButton/index.less +0 -32
  44. package/src/components/ToolCallBlock/index.less +0 -312
  45. package/src/theme/global.less +0 -99
  46. /package/src/theme/{motion.less → motion.css} +0 -0
@@ -5,7 +5,9 @@
5
5
  * 所以这些设计变量必须落在 client。卡片组件与页面统一用 var(--tbox-*) 引用,
6
6
  * 禁止硬编码十六进制色值 / px 字号。
7
7
  *
8
- * 注:这里的 px 会被 postcss-px-to-viewport(750 基准)转成 vw。
8
+ * 单位约定(2026-11 统一样式层):全部长/字号/圆角/阴影写**物理 px**(大写 `PX`)。
9
+ * 组件样式一律走 Tailwind 工具类(4px 标度 + 12/14/16/18/20/24/30/36 字号档),
10
+ * 这些变量只服务主题投影(`rounded-lg` / `shadow-sm` 等);模板里的 pxtorem 已无小写 px 可转。
9
11
  * 视觉源对照与域色矩阵见 docs/reference/templates.md(视觉体系与域色矩阵)。
10
12
  */
11
13
  :root {
@@ -33,9 +35,9 @@
33
35
  --tbox-border-strong: #d3dae6;
34
36
 
35
37
  /* 阴影 */
36
- --tbox-shadow-sm: 0 8px 26px rgba(38, 59, 92, 0.05);
37
- --tbox-shadow-md: 0 12px 32px rgba(24, 82, 177, 0.1);
38
- --tbox-shadow-lg: 0 14px 34px rgba(2, 46, 122, 0.08);
38
+ --tbox-shadow-sm: 0 4PX 13PX rgba(38, 59, 92, 0.05);
39
+ --tbox-shadow-md: 0 6PX 16PX rgba(24, 82, 177, 0.1);
40
+ --tbox-shadow-lg: 0 7PX 17PX rgba(2, 46, 122, 0.08);
39
41
 
40
42
  /* 状态色 */
41
43
  --tbox-success: #169e5a;
@@ -46,14 +48,14 @@
46
48
  正文 .msg-markdown / __text = 25px,次要信息(时间/角色) = 18~19px,标题 h1~h4 = 36/32/30/28px。
47
49
  注意:rootValue 100 + 根字号脚本会把 px 折半渲染(750 稿 → ≈375 手机列),
48
50
  所以这里写的是 2x 值,别按普通 web 的 12/14/16 写(那样渲染出来只有一半、发虚)。 */
49
- --tbox-fs-heading: 30px; /* ≈气泡 h3:商品名 / 店名 */
50
- --tbox-fs-body: 25px; /* =气泡正文 */
51
- --tbox-fs-caption: 20px; /* ≈气泡次要信息(时间/角色) */
51
+ --tbox-fs-heading: 15PX; /* ≈气泡 h3:商品名 / 店名 */
52
+ --tbox-fs-body: 12.5PX; /* =气泡正文 */
53
+ --tbox-fs-caption: 10PX; /* ≈气泡次要信息(时间/角色) */
52
54
 
53
55
  /* 圆角 */
54
- --tbox-radius-sm: 12px;
55
- --tbox-radius-md: 18px;
56
- --tbox-radius-lg: 48px;
56
+ --tbox-radius-sm: 6PX;
57
+ --tbox-radius-md: 9PX;
58
+ --tbox-radius-lg: 24PX;
57
59
 
58
60
  /* 内容最大宽度(对齐参考 H5):全宽渐变底 + 内容区 720px 居中。
59
61
  大写 PX 不被 postcss-pxtorem 转换(正则大小写敏感),保持固定像素。 */
@@ -62,8 +64,8 @@
62
64
  --tbox-page-gutter: 16PX;
63
65
 
64
66
  /* 媒体缩略图 */
65
- --tbox-media-item-size: 174px;
66
- --tbox-media-item-radius: 12px;
67
+ --tbox-media-item-size: 87PX;
68
+ --tbox-media-item-radius: 6PX;
67
69
 
68
70
  /* 输入框 */
69
71
  --tbox-input-bg: rgba(255, 255, 255, 0.7);
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
- }