@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,394 +0,0 @@
1
- .tbox-voice-page-lock,
2
- .tbox-voice-page-lock * {
3
- user-select: none !important;
4
- -webkit-user-select: none !important;
5
- -webkit-touch-callout: none !important;
6
- -webkit-user-drag: none !important;
7
- }
8
-
9
- .tbox-chat-input {
10
- position: relative;
11
- z-index: 1;
12
- width: 100%;
13
- max-width: var(--tbox-content-max-width);
14
- margin: 0 auto;
15
- box-sizing: border-box;
16
- padding: 8PX var(--tbox-page-gutter) calc(8PX + env(safe-area-inset-bottom, 0PX));
17
- background: transparent;
18
-
19
- &__row {
20
- display: flex;
21
- align-items: flex-end;
22
- gap: 8PX;
23
- flex-wrap: wrap;
24
- }
25
-
26
- /* 连接终态阻断提示条(禁用输入 + 重试入口;配色沿用既有 token,不硬编码) */
27
- &__blocked {
28
- flex-basis: 100%;
29
- display: flex;
30
- align-items: center;
31
- gap: 12px;
32
- padding: 12px 20px;
33
- border-radius: 12px;
34
- background: rgba(255, 241, 241, 0.9);
35
- color: var(--tbox-error);
36
- font-size: 24px;
37
- line-height: 1.4;
38
-
39
- &-msg {
40
- flex: 1;
41
- min-width: 0;
42
- }
43
-
44
- &-retry {
45
- flex-shrink: 0;
46
- padding: 6px 20px;
47
- border: none;
48
- border-radius: 999px;
49
- background: var(--tbox-primary);
50
- color: #fff;
51
- font-size: 22px;
52
- }
53
- }
54
-
55
- /* 半透明白色药丸 */
56
- &__wrapper {
57
- display: flex;
58
- align-items: flex-end;
59
- flex: 1;
60
- min-width: 0;
61
- gap: 14PX;
62
- background: var(--tbox-input-bg);
63
- border: 1PX solid var(--tbox-border);
64
- border-radius: var(--tbox-input-radius);
65
- padding: var(--tbox-input-padding);
66
- box-shadow: 0 1PX 10PX rgba(110, 139, 180, 0.24);
67
- transition: border-color var(--tbox-transition-fast), box-shadow var(--tbox-transition-fast);
68
- }
69
-
70
- /* 聚焦蓝环 */
71
- &__wrapper:focus-within {
72
- border-color: var(--tbox-primary);
73
- box-shadow: 0 0 0 1.5PX rgba(9, 107, 250, 0.12);
74
- }
75
-
76
- &__field {
77
- flex: 1;
78
- min-width: 0;
79
- resize: none;
80
- border: none;
81
- outline: none;
82
- background: transparent;
83
- font-family: inherit;
84
- font-size: 15PX;
85
- line-height: 24PX;
86
- max-height: 100PX;
87
- color: var(--tbox-text-primary);
88
- padding: 0;
89
-
90
- &::placeholder {
91
- color: var(--tbox-text-muted);
92
- }
93
-
94
- /* 连接终态阻断(登录失败/scope 拒绝):禁用态弱化输入框 */
95
- &:disabled {
96
- opacity: 0.45;
97
- }
98
- }
99
-
100
- /* 发送 / 停止(图片图标) */
101
- &__send {
102
- width: var(--tbox-send-btn-size);
103
- height: var(--tbox-send-btn-size);
104
- flex-shrink: 0;
105
- display: flex;
106
- align-items: center;
107
- justify-content: center;
108
- }
109
-
110
- &__send-img {
111
- width: var(--tbox-send-btn-size);
112
- height: var(--tbox-send-btn-size);
113
- display: block;
114
- }
115
-
116
- &__disclaimer {
117
- margin-top: 5PX;
118
- text-align: center;
119
- font-size: 10PX;
120
- line-height: 1.5;
121
- color: var(--tbox-text-muted);
122
- }
123
- }
124
-
125
- /* 新对话按钮(药丸左侧,圆形) */
126
- .tbox-new-chat-btn {
127
- width: 44PX;
128
- height: 44PX;
129
- flex-shrink: 0;
130
- display: flex;
131
- align-items: center;
132
- justify-content: center;
133
- border-radius: 50%;
134
- background: rgba(255, 255, 255, 0.5);
135
- box-shadow: 0 1PX 10PX rgba(110, 139, 180, 0.24);
136
-
137
- &__icon {
138
- width: 22PX;
139
- height: 22PX;
140
- }
141
- }
142
-
143
- /* 语音切换 */
144
- .tbox-voice-toggle {
145
- width: 22PX;
146
- height: 22PX;
147
- flex-shrink: 0;
148
- display: flex;
149
- align-items: center;
150
- justify-content: center;
151
-
152
- &__icon {
153
- width: 22PX;
154
- height: 22PX;
155
- }
156
-
157
- &--active {
158
- opacity: 0.7;
159
- }
160
- }
161
-
162
- /* “+” 媒体选取触发 + 弹出菜单 */
163
- .tbox-media-picker {
164
- position: relative;
165
- flex-shrink: 0;
166
-
167
- &__trigger {
168
- display: flex;
169
- align-items: center;
170
- justify-content: center;
171
- flex-shrink: 0;
172
- transition: transform var(--tbox-motion-duration-base) ease;
173
-
174
- &--open {
175
- transform: rotate(45deg);
176
- }
177
- }
178
-
179
- &__trigger-icon {
180
- width: var(--tbox-send-btn-size);
181
- height: var(--tbox-send-btn-size);
182
- }
183
- }
184
-
185
- /* 媒体选取菜单(输入行下方,动画展开,对齐原模板) */
186
- .tbox-media-picker-menu {
187
- margin-top: 24px;
188
- display: flex;
189
- flex-direction: row;
190
- height: 132px;
191
- overflow: hidden;
192
- opacity: 0;
193
- transform: translateY(10px);
194
- transition: all var(--tbox-motion-duration-fast) ease-in;
195
- will-change: opacity, transform;
196
-
197
- &--visible {
198
- opacity: 1;
199
- transform: translateY(0);
200
- transition: all var(--tbox-motion-duration-base) ease-out;
201
- }
202
-
203
- &__option {
204
- display: flex;
205
- overflow: hidden;
206
- flex-shrink: 0;
207
- justify-content: center;
208
- align-items: center;
209
- width: 224px;
210
- height: 132px;
211
- border-radius: 20px;
212
- background: rgba(0, 0, 0, 0.04);
213
- opacity: 0;
214
- transform: translateY(15px);
215
- transition: all var(--tbox-motion-duration-base) ease-out;
216
- will-change: opacity, transform;
217
-
218
- & + & {
219
- margin-left: 15px;
220
- }
221
- }
222
-
223
- &--visible &__option {
224
- opacity: 1;
225
- transform: translateY(0);
226
- }
227
-
228
- &--visible &__option:nth-child(1) { transition-delay: 0.05s; }
229
- &--visible &__option:nth-child(2) { transition-delay: 0.1s; }
230
- &--visible &__option:nth-child(3) { transition-delay: 0.15s; }
231
-
232
- &__option-content {
233
- display: flex;
234
- flex-direction: row;
235
- align-items: center;
236
- height: 48px;
237
- }
238
-
239
- &__option-icon {
240
- flex-shrink: 0;
241
- width: 48px;
242
- height: 48px;
243
- }
244
-
245
- &__option-label {
246
- margin-left: 8px;
247
- font-weight: 400;
248
- font-size: 26px;
249
- color: var(--tbox-text-secondary);
250
- line-height: 37px;
251
- }
252
- }
253
-
254
- /* 按住说话输入条 */
255
- .tbox-voice-press-field {
256
- flex: 1;
257
- min-width: 0;
258
- height: 24PX;
259
- display: flex;
260
- align-items: center;
261
- justify-content: center;
262
- border-radius: 50px;
263
- box-sizing: border-box;
264
- overflow: hidden;
265
- user-select: none;
266
- -webkit-user-select: none;
267
- -webkit-touch-callout: none;
268
- touch-action: none;
269
-
270
- &--disabled {
271
- opacity: 0.35;
272
- }
273
- &--pressing,
274
- &--recording-active {
275
- background: #eef4ff; /* mall-vis 语音按住浅蓝底 */
276
- }
277
- &--recording-cancel {
278
- background: #fff1f1; /* mall-vis 取消态浅红底 */
279
- }
280
- &--processing {
281
- background: #f5f7fb; /* mall-vis 处理中浅灰底 */
282
- }
283
-
284
- &__content {
285
- width: 100%;
286
- display: flex;
287
- align-items: center;
288
- justify-content: center;
289
- padding: 0 20px;
290
- box-sizing: border-box;
291
- }
292
-
293
- &__text {
294
- font-size: 15PX;
295
- font-weight: 600;
296
- line-height: 24PX;
297
- color: var(--tbox-text-primary);
298
- }
299
- }
300
-
301
- /* 录音全屏浮层 */
302
- .tbox-voice-overlay {
303
- position: fixed;
304
- inset: 0;
305
- z-index: 300;
306
- user-select: none;
307
- -webkit-user-select: none;
308
- -webkit-touch-callout: none;
309
- touch-action: none;
310
-
311
- &__mask {
312
- position: absolute;
313
- inset: 0;
314
- background: rgba(255, 255, 255, 0.01);
315
- }
316
-
317
- &__capture {
318
- position: absolute;
319
- inset: 0;
320
- display: flex;
321
- align-items: flex-end;
322
- justify-content: center;
323
- padding: 0 var(--tbox-page-gutter) calc(56px + env(safe-area-inset-bottom, 16px));
324
- box-sizing: border-box;
325
- user-select: none;
326
- -webkit-user-select: none;
327
- touch-action: none;
328
- }
329
-
330
- &__panel {
331
- width: 100%;
332
- max-width: var(--tbox-content-max-width);
333
- display: flex;
334
- flex-direction: column;
335
- align-items: center;
336
- }
337
-
338
- &__bubble {
339
- width: 268px;
340
- height: 82px;
341
- background-image: url('https://mdn.alipayobjects.com/huamei_frp8ut/afts/img/A*O6TCSrNeWvwAAAAAQHAAAAgAet-KAQ/original');
342
- background-size: 100% 100%;
343
- background-repeat: no-repeat;
344
- display: flex;
345
- align-items: center;
346
- justify-content: center;
347
- margin-bottom: 40px;
348
- }
349
-
350
- &__bubble-text {
351
- font-size: 24px;
352
- line-height: 62px;
353
- color: #fff;
354
- font-weight: 500;
355
- white-space: nowrap;
356
- }
357
-
358
- &__tip {
359
- font-size: 24px;
360
- line-height: 48px;
361
- color: var(--tbox-text-muted);
362
- font-weight: 500;
363
- margin-bottom: 32px;
364
- text-align: center;
365
-
366
- &--cancel {
367
- color: var(--tbox-error);
368
- }
369
- }
370
-
371
- &__button {
372
- width: 100%;
373
- height: 100px;
374
- border-radius: 52px;
375
- display: flex;
376
- align-items: center;
377
- justify-content: center;
378
- background-image: linear-gradient(162deg, var(--tbox-primary) -22%, var(--tbox-primary-dark) 108%);
379
- box-shadow: 0 12px 28px rgba(80, 111, 255, 0.24);
380
-
381
- &--cancel {
382
- background-image: linear-gradient(162deg, #fd3030 -22%, #f48686 108%);
383
- }
384
- }
385
-
386
- &__wave {
387
- width: 484px;
388
- height: 48px;
389
- background-image: url('https://mdn.alipayobjects.com/huamei_frp8ut/afts/img/A*5PDvR4j7fBgAAAAAVBAAAAgAet-KAQ/original');
390
- background-size: 100% 100%;
391
- background-repeat: no-repeat;
392
- pointer-events: none;
393
- }
394
- }
@@ -1,49 +0,0 @@
1
- /* 顶部历史入口:参考稿的浅灰胶囊,居中跟随内容滚动;历史拉出后由页面撤下。 */
2
- .history-entry {
3
- display: flex;
4
- justify-content: center;
5
- /* 自身不留边距;与欢迎区的 4PX 间距由页面 index.less 的 `.history-entry ~ .mall-home` 统一编排。 */
6
- padding: 0;
7
-
8
- &__button {
9
- appearance: none;
10
- padding: 3PX 12PX;
11
- border: none;
12
- border-radius: 25PX;
13
- background: rgba(15, 64, 113, 0.06);
14
- color: var(--tbox-text-muted);
15
- font-size: 11.5PX;
16
- font-weight: 400;
17
- line-height: 16PX;
18
- transition: background var(--tbox-transition-fast);
19
-
20
- &:active {
21
- background: rgba(15, 64, 113, 0.1);
22
- }
23
-
24
- /* 加载态小转子:与文案同处胶囊内,替代原独立指示器 */
25
- display: inline-flex;
26
- align-items: center;
27
- gap: 5PX;
28
-
29
- &:disabled {
30
- /* 未就绪只是短暂不可点,保持视觉常态;加载态由文案表达。 */
31
- cursor: default;
32
- }
33
- }
34
-
35
- &__spinner {
36
- width: 10PX;
37
- height: 10PX;
38
- border: 1.5PX solid rgba(15, 64, 113, 0.18);
39
- border-top-color: var(--tbox-primary);
40
- border-radius: 50%;
41
- animation: history-entry-spin 0.6s linear infinite;
42
- }
43
- }
44
-
45
- @keyframes history-entry-spin {
46
- to {
47
- transform: rotate(360deg);
48
- }
49
- }
@@ -1,241 +0,0 @@
1
- .tbox-media-list {
2
- display: flex;
3
- align-items: flex-end;
4
- gap: 16px;
5
- padding: 0 0 16px;
6
- overflow: visible;
7
- }
8
-
9
- .tbox-media-list__scroll {
10
- display: flex;
11
- flex-wrap: nowrap;
12
- overflow-x: auto;
13
- gap: 16px;
14
- -webkit-overflow-scrolling: touch;
15
- min-width: 0;
16
-
17
- &::-webkit-scrollbar {
18
- display: none;
19
- }
20
- }
21
-
22
- .tbox-media-item {
23
- width: var(--tbox-media-item-size);
24
- min-width: var(--tbox-media-item-size);
25
- height: var(--tbox-media-item-size);
26
- border-radius: var(--tbox-media-item-radius);
27
- overflow: visible;
28
- position: relative;
29
- background: #f5f5f5;
30
-
31
- &--image {
32
- overflow: hidden;
33
- }
34
-
35
- &__thumb {
36
- width: 100%;
37
- height: 100%;
38
- display: block;
39
- object-fit: cover;
40
- }
41
-
42
- &__overlay {
43
- position: absolute;
44
- inset: 0;
45
- display: flex;
46
- flex-direction: column;
47
- align-items: center;
48
- justify-content: center;
49
- background: rgba(0, 0, 0, 0.5);
50
- border-radius: var(--tbox-media-item-radius);
51
- gap: 8px;
52
- }
53
-
54
- &__progress-ring {
55
- width: 60px;
56
- height: 60px;
57
- border-radius: 50%;
58
- display: flex;
59
- align-items: center;
60
- justify-content: center;
61
- transition: background var(--tbox-motion-duration-base) ease;
62
- }
63
-
64
- &__progress-inner {
65
- width: 48px;
66
- height: 48px;
67
- border-radius: 50%;
68
- background: rgba(0, 0, 0, 0.7);
69
- display: flex;
70
- align-items: center;
71
- justify-content: center;
72
- }
73
-
74
- &__progress-text {
75
- color: #fff;
76
- font-size: 20px;
77
- font-weight: bold;
78
- text-align: center;
79
- }
80
-
81
- &__status-icon {
82
- display: flex;
83
- align-items: center;
84
- justify-content: center;
85
- }
86
-
87
- &__status-text {
88
- color: rgba(255, 255, 255, 0.85);
89
- font-size: 20px;
90
- font-weight: 500;
91
- text-align: center;
92
- white-space: nowrap;
93
- }
94
-
95
- &__remove {
96
- position: absolute;
97
- top: 12px;
98
- right: 12px;
99
- width: 36px;
100
- height: 36px;
101
- border-radius: 18px;
102
- background: rgba(0, 0, 0, 0.55);
103
- display: flex;
104
- align-items: center;
105
- justify-content: center;
106
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
107
- z-index: 2;
108
- }
109
- }
110
-
111
- /* 非图片(视频/文件)卡片 */
112
- .tbox-file-item {
113
- display: flex;
114
- flex-direction: row;
115
- align-items: center;
116
- gap: 12px;
117
- min-width: 280px;
118
- height: var(--tbox-media-item-size);
119
- border-radius: var(--tbox-media-item-radius);
120
- background: #fcfcfc;
121
- padding: 16px;
122
- box-sizing: border-box;
123
- position: relative;
124
- overflow: visible;
125
-
126
- &__icon {
127
- flex-shrink: 0;
128
- width: 48px;
129
- height: 48px;
130
- display: flex;
131
- align-items: center;
132
- justify-content: center;
133
- }
134
-
135
- &__info {
136
- display: flex;
137
- flex-direction: column;
138
- justify-content: center;
139
- gap: 4px;
140
- flex: 1;
141
- min-width: 0;
142
- }
143
-
144
- &__name {
145
- font-size: 24px;
146
- color: #333;
147
- font-weight: 500;
148
- overflow: hidden;
149
- text-overflow: ellipsis;
150
- white-space: nowrap;
151
- max-width: 100%;
152
- }
153
-
154
- &__meta {
155
- font-size: 20px;
156
- color: rgba(0, 0, 0, 0.25);
157
- white-space: nowrap;
158
-
159
- &--failed {
160
- color: var(--tbox-error);
161
- }
162
- }
163
-
164
- .tbox-media-item__remove {
165
- position: absolute;
166
- top: 12px;
167
- right: 12px;
168
- }
169
- }
170
-
171
- /* 末尾“加更多”按钮 */
172
- .tbox-media-add {
173
- width: var(--tbox-media-item-size);
174
- min-width: var(--tbox-media-item-size);
175
- height: var(--tbox-media-item-size);
176
- border-radius: var(--tbox-media-item-radius);
177
- background: rgba(255, 255, 255, 0.6);
178
- display: flex;
179
- align-items: center;
180
- justify-content: center;
181
- flex-shrink: 0;
182
- position: relative;
183
- }
184
-
185
- /* 加更多的二级 popover */
186
- .tbox-media-popover {
187
- position: absolute;
188
- bottom: calc(var(--tbox-media-item-size) + 8px);
189
- right: 0;
190
- width: var(--tbox-media-item-size);
191
- background: #fff;
192
- border-radius: 20px;
193
- padding: 16px 0;
194
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
195
- z-index: 10;
196
- opacity: 0;
197
- transform: translateY(8px);
198
- transition: opacity var(--tbox-motion-duration-fast) ease-out, transform var(--tbox-motion-duration-fast) ease-out;
199
- pointer-events: none;
200
-
201
- &--visible {
202
- opacity: 1;
203
- transform: translateY(0);
204
- pointer-events: auto;
205
- }
206
-
207
- &__item {
208
- display: flex;
209
- flex-direction: row;
210
- align-items: center;
211
- height: 60px;
212
- gap: 8px;
213
- padding: 0 16px;
214
-
215
- & + & {
216
- margin-top: 8px;
217
- }
218
- }
219
-
220
- &__icon-wrap {
221
- width: 40px;
222
- height: 40px;
223
- border-radius: 8px;
224
- display: flex;
225
- align-items: center;
226
- justify-content: center;
227
- flex-shrink: 0;
228
- }
229
-
230
- &__icon {
231
- width: 32px;
232
- height: 32px;
233
- }
234
-
235
- &__label {
236
- font-size: 28px;
237
- color: rgba(31, 59, 99, 0.88);
238
- font-weight: 400;
239
- line-height: 1.4;
240
- }
241
- }