@tbox.cn/app-agent-ui-kit 1.0.0-alpha.1 → 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.
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
@@ -1,325 +0,0 @@
1
- .msg-row {
2
- display: flex;
3
- align-items: flex-start;
4
- margin-bottom: 20px;
5
- padding: 0 var(--tbox-page-gutter);
6
-
7
- &--user {
8
- flex-direction: row-reverse;
9
- }
10
- &--bot {
11
- flex-direction: row;
12
- }
13
- }
14
-
15
- .msg-main {
16
- min-width: 0;
17
- }
18
- .msg-row--bot .msg-main {
19
- flex: 1;
20
- }
21
-
22
- .msg-meta {
23
- display: flex;
24
- align-items: center;
25
- margin-bottom: 6px;
26
-
27
- &--user {
28
- justify-content: flex-end;
29
- margin-right: 0;
30
- }
31
- &--bot {
32
- justify-content: flex-start;
33
- }
34
-
35
- &__role {
36
- font-size: 19px;
37
- color: var(--tbox-text-secondary);
38
- margin-right: 8px;
39
- }
40
- &__time {
41
- font-size: 18px;
42
- color: var(--tbox-text-muted);
43
- }
44
- }
45
-
46
- /* 意图空文本出卡(无气泡、有卡):卡片前间距由 meta 下边距提供——
47
- meta 无 border → 折叠语义 max(12, 卡 mt),未来全局卡框间距调整自然跟随 */
48
- .msg-meta--solo-card {
49
- margin-bottom: 12px;
50
- }
51
-
52
- /* 多卡纵向铺开 wrapper(决策出卡 >1 张时 SDK CardCarousel 外层;单卡直出无此层) */
53
- .msg-cards {
54
- margin-top: 8px;
55
- }
56
-
57
- .msg-bubble {
58
- padding: 18px 22px;
59
- line-height: 1.6;
60
- /* mall-vis 气泡影(demo .msg-bubble 基座影,用户气泡沿用;bot 气泡自持双层影) */
61
- box-shadow: 0 4px 16px rgba(50, 65, 92, 0.08);
62
-
63
- &--user {
64
- background: rgba(255, 255, 255, 0.9);
65
- border-radius: 48px 8px 48px 48px;
66
- width: fit-content;
67
- max-width: 100%;
68
- margin-left: auto;
69
- margin-right: 0;
70
- margin-bottom: 8px;
71
- display: flex;
72
- align-items: center;
73
- min-height: 48px;
74
- }
75
-
76
- &--bot {
77
- position: relative;
78
- font-size: 30px;
79
- line-height: 1.6;
80
- padding: 22px;
81
- color: var(--tbox-text-primary);
82
- background: rgba(255, 255, 255, 0.4);
83
- border: 1px solid #edf0f6;
84
- border-radius: 8px 48px 48px;
85
- box-shadow:
86
- 0 3px 8px 5px rgba(1, 112, 254, 0.0392),
87
- 0 2px 4px rgba(72, 78, 86, 0.0706);
88
- /* 卡片在对话气泡之后显示:间距由气泡下边距提供(单一来源;
89
- 不写 .tbox-card 规则——避免特异性压过全局卡框、避免复制全局间距值) */
90
- margin-bottom: 12px;
91
- }
92
-
93
- &__text {
94
- font-size: 25px;
95
- }
96
-
97
- &__error {
98
- color: var(--tbox-error);
99
- font-size: 25px;
100
- line-height: 1.6;
101
- white-space: pre-wrap;
102
- overflow-wrap: anywhere;
103
-
104
- &--with-content {
105
- margin-top: 14px;
106
- padding-top: 14px;
107
- border-top: 1px solid var(--tbox-error);
108
- }
109
- }
110
-
111
- &--user &__text {
112
- color: var(--tbox-text-primary);
113
- font-weight: 500;
114
- overflow-wrap: break-word;
115
- }
116
- }
117
-
118
- /* 用户消息附带的图片缩略图 */
119
- .msg-media {
120
- display: flex;
121
- flex-wrap: nowrap;
122
- overflow-x: auto;
123
- gap: 16px;
124
- direction: rtl;
125
- margin-right: 12px;
126
- margin-top: 4px;
127
- -webkit-overflow-scrolling: touch;
128
-
129
- &::-webkit-scrollbar {
130
- display: none;
131
- }
132
-
133
- &__thumb {
134
- direction: ltr;
135
- width: var(--tbox-media-item-size);
136
- min-width: var(--tbox-media-item-size);
137
- height: var(--tbox-media-item-size);
138
- border-radius: var(--tbox-media-item-radius);
139
- object-fit: cover;
140
- flex-shrink: 0;
141
- }
142
- }
143
-
144
- .msg-toolbar {
145
- display: flex;
146
- align-items: center;
147
- margin-top: 8px;
148
- opacity: 0.4;
149
-
150
- &--user {
151
- justify-content: flex-end;
152
- padding-right: 12px;
153
- }
154
-
155
- &__action {
156
- display: flex;
157
- align-items: center;
158
- justify-content: center;
159
- width: 34px;
160
- height: 28px;
161
- }
162
- }
163
-
164
- .msg-toolbar-row {
165
- display: flex;
166
- align-items: center;
167
- gap: 12px;
168
- /* 操作栏间距由前元素 margin-bottom 提供(气泡 mb 12 / 卡片 mb 12):
169
- 不能自设 margin-top——气泡有 border 阻断折叠,自设会与气泡 mb 叠加成 24px */
170
- margin-top: 0;
171
- flex-wrap: wrap;
172
- }
173
-
174
- /* 3 个点 loading 指示器 */
175
- .msg-thinking,
176
- .msg-thinking-inline {
177
- display: flex;
178
- justify-content: flex-start;
179
- align-items: center;
180
- gap: 8px;
181
- padding: 10px 0;
182
- margin-left: 12px;
183
-
184
- &__dot {
185
- width: 10px;
186
- height: 10px;
187
- border-radius: 50%;
188
- background: #aab3c2; /* mall-vis thinking 点灰(非主色) */
189
- animation: dot-fade 1.4s ease-in-out infinite;
190
-
191
- &--2 {
192
- animation-delay: 0.2s;
193
- }
194
- &--3 {
195
- animation-delay: 0.4s;
196
- }
197
- }
198
- }
199
-
200
- @keyframes dot-fade {
201
- 0%,
202
- 80%,
203
- 100% {
204
- opacity: 0.3;
205
- }
206
- 40% {
207
- opacity: 1;
208
- }
209
- }
210
-
211
- /* 流式光标 */
212
- .msg-cursor {
213
- display: inline-block;
214
- width: 4px;
215
- height: 24px;
216
- background: #5874ff; /* mall-vis 流式光标蓝 */
217
- margin-left: 4px;
218
- vertical-align: middle;
219
- animation: blink 1s step-end infinite;
220
- }
221
-
222
- @keyframes blink {
223
- 0%,
224
- 100% {
225
- opacity: 1;
226
- }
227
- 50% {
228
- opacity: 0;
229
- }
230
- }
231
-
232
- /* Markdown */
233
- .msg-markdown {
234
- font-size: 25px;
235
- color: var(--tbox-text-primary);
236
- overflow-wrap: anywhere;
237
-
238
- h1,
239
- h2,
240
- h3,
241
- h4,
242
- h5,
243
- h6 {
244
- margin: 16px 0 8px;
245
- font-weight: 600;
246
- line-height: 1.4;
247
- }
248
- h1 {
249
- font-size: 36px;
250
- }
251
- h2 {
252
- font-size: 32px;
253
- }
254
- h3 {
255
- font-size: 30px;
256
- }
257
- h4 {
258
- font-size: 28px;
259
- }
260
-
261
- p {
262
- margin: 8px 0;
263
- }
264
- strong {
265
- font-weight: 600;
266
- }
267
- em {
268
- font-style: italic;
269
- }
270
- a {
271
- color: var(--tbox-primary);
272
- text-decoration: underline;
273
- }
274
- ul,
275
- ol {
276
- padding-left: 32px;
277
- margin: 8px 0;
278
- }
279
- li {
280
- margin: 4px 0;
281
- }
282
- blockquote {
283
- border-left: 4px solid #667eea; /* mall-vis 引用竖条(ReasoningBlock 折叠族同源) */
284
- padding-left: 16px;
285
- margin: 12px 0;
286
- color: var(--tbox-text-secondary);
287
- }
288
- code {
289
- background: rgba(0, 0, 0, 0.06);
290
- padding: 2px 8px;
291
- border-radius: 6px;
292
- font-size: 26px;
293
- font-family: Menlo, Monaco, Consolas, monospace;
294
- }
295
- pre {
296
- background: #1e1e2e;
297
- border-radius: 12px;
298
- padding: 20px;
299
- margin: 12px 0;
300
- overflow-x: auto;
301
-
302
- code {
303
- background: none;
304
- padding: 0;
305
- color: #cdd6f4;
306
- font-size: 24px;
307
- }
308
- }
309
- table {
310
- width: 100%;
311
- border-collapse: collapse;
312
- margin: 12px 0;
313
- }
314
- th,
315
- td {
316
- border: 1px solid var(--tbox-border);
317
- padding: 8px 12px;
318
- text-align: left;
319
- font-size: 26px;
320
- }
321
- th {
322
- background: var(--tbox-bg-subtle);
323
- font-weight: 600;
324
- }
325
- }
@@ -1,32 +0,0 @@
1
- .pull-indicator {
2
- display: flex;
3
- align-items: center;
4
- justify-content: center;
5
- height: 60px;
6
- gap: 12px;
7
-
8
- &--animated {
9
- transition: margin-top var(--tbox-motion-duration-base) ease-out;
10
- }
11
-
12
- &__spinner {
13
- width: 32px;
14
- height: 32px;
15
- border: 3px solid var(--tbox-border-strong);
16
- border-top-color: var(--tbox-primary);
17
- border-radius: 50%;
18
- animation: pull-spin 0.6s linear infinite;
19
- }
20
-
21
- &__text {
22
- font-size: 26px;
23
- color: #8c8c8c;
24
- line-height: 1;
25
- }
26
- }
27
-
28
- @keyframes pull-spin {
29
- to {
30
- transform: rotate(360deg);
31
- }
32
- }
@@ -1,63 +0,0 @@
1
- .quick-commands {
2
- position: relative;
3
- z-index: 1;
4
- width: 100%;
5
- max-width: var(--tbox-content-max-width);
6
- margin: 0 auto;
7
- box-sizing: border-box;
8
- display: flex;
9
- gap: 8PX;
10
- overflow-x: auto;
11
- padding: 0 var(--tbox-page-gutter) 9PX;
12
- -ms-overflow-style: none;
13
- scrollbar-width: none;
14
-
15
- &::-webkit-scrollbar {
16
- display: none;
17
- }
18
-
19
- /* 语音交互时只隐藏胶囊,保留原高度和页面灰底,继续遮挡聊天内容。 */
20
- &--hidden {
21
- visibility: hidden;
22
- pointer-events: none;
23
- }
24
-
25
- &__item {
26
- flex: 1 0 auto;
27
- display: inline-flex;
28
- align-items: center;
29
- justify-content: center;
30
- gap: 5PX;
31
- height: 34PX;
32
- padding: 0 13PX;
33
- appearance: none;
34
- /* mall-vis 快捷指令胶囊:白底 + 2px 描边 + 50px 胶囊圆角(数据仍服务端驱动) */
35
- background: rgba(255, 255, 255, 0.92);
36
- border: 1PX solid rgba(15, 64, 113, 0.14);
37
- border-radius: 25PX;
38
- box-shadow: 0 4PX 16PX rgba(38, 59, 92, 0.05);
39
- transition: background var(--tbox-transition-fast), border-color var(--tbox-transition-fast);
40
-
41
- &:active {
42
- border-color: var(--tbox-primary);
43
- }
44
- }
45
-
46
- &__icon {
47
- width: 16PX;
48
- height: 16PX;
49
- object-fit: contain;
50
- }
51
-
52
- &__icon-svg {
53
- color: var(--tbox-primary);
54
- }
55
-
56
- &__label {
57
- color: var(--tbox-text-primary);
58
- font-size: 13PX;
59
- font-weight: 500;
60
- line-height: 18PX;
61
- white-space: nowrap;
62
- }
63
- }
@@ -1,90 +0,0 @@
1
- .reasoning {
2
- margin: 0 0 16px;
3
- border-radius: 14px;
4
- overflow: hidden;
5
- min-width: 0;
6
- max-width: 100%;
7
- box-sizing: border-box;
8
-
9
- &--active {
10
- background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.06) 100%);
11
- }
12
- &--done {
13
- background: rgba(0, 0, 0, 0.03);
14
- }
15
-
16
- &__header {
17
- display: flex;
18
- align-items: center;
19
- justify-content: space-between;
20
- padding: 14px 18px;
21
- }
22
-
23
- &__left {
24
- display: flex;
25
- align-items: center;
26
- gap: 8px;
27
- }
28
-
29
- &__indicator {
30
- width: 10px;
31
- height: 10px;
32
- border-radius: 50%;
33
- background: #b0bec5;
34
- flex-shrink: 0;
35
-
36
- &--pulse {
37
- background: #667eea;
38
- animation: reasoning-pulse 1.5s ease-in-out infinite;
39
- }
40
- }
41
-
42
- &__title {
43
- font-size: 22px;
44
- font-weight: 600;
45
- color: #6b7a99;
46
- }
47
- &--active &__title {
48
- color: #667eea;
49
- }
50
-
51
- &__duration {
52
- font-size: 20px;
53
- color: #9ba7c3;
54
- }
55
-
56
- &__toggle {
57
- font-size: 20px;
58
- color: #8b95b0;
59
- }
60
-
61
- &__content {
62
- margin: 0 18px 16px;
63
- padding-left: 42px;
64
- border-left: 3px solid #d6dce8;
65
- font-size: 22px;
66
- color: #8b95b0;
67
- line-height: 1.7;
68
- overflow-wrap: break-word;
69
- overflow: hidden;
70
-
71
- p {
72
- margin: 6px 0;
73
- }
74
- }
75
- &--active &__content {
76
- border-left-color: #667eea;
77
- }
78
- }
79
-
80
- @keyframes reasoning-pulse {
81
- 0%,
82
- 100% {
83
- opacity: 0.4;
84
- transform: scale(0.8);
85
- }
86
- 50% {
87
- opacity: 1;
88
- transform: scale(1.2);
89
- }
90
- }
@@ -1,32 +0,0 @@
1
- .scroll-to-bottom-btn {
2
- position: absolute;
3
- right: 32px;
4
- bottom: 32px;
5
- width: 72px;
6
- height: 72px;
7
- border-radius: 50%;
8
- background: #fff;
9
- box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.12);
10
- display: flex;
11
- align-items: center;
12
- justify-content: center;
13
- z-index: 10;
14
- opacity: 0;
15
- transform: scale(0.8);
16
- transition: opacity var(--tbox-motion-duration-fast) ease, transform var(--tbox-motion-duration-fast) ease;
17
- pointer-events: none;
18
-
19
- &--visible {
20
- opacity: 1;
21
- transform: scale(1);
22
- pointer-events: auto;
23
- }
24
-
25
- &__arrow {
26
- width: 0;
27
- height: 0;
28
- border-left: 12px solid transparent;
29
- border-right: 12px solid transparent;
30
- border-top: 14px solid #666;
31
- }
32
- }