@baishuyun/ai-design 2.0.44 → 2.0.47

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/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @baishuyun/ai-design
2
2
 
3
+ ## 2.0.47
4
+
5
+ ### Patch Changes
6
+
7
+ - fix agent helper style
8
+ - Updated dependencies
9
+ - @baishuyun/ai-feat-utils@2.0.42
10
+ - @baishuyun/types@3.0.39
11
+
12
+ ## 2.0.46
13
+
14
+ ### Patch Changes
15
+
16
+ - fix host style overwrite
17
+ - Updated dependencies
18
+ - @baishuyun/ai-feat-utils@2.0.41
19
+ - @baishuyun/types@3.0.38
20
+
21
+ ## 2.0.45
22
+
23
+ ### Patch Changes
24
+
25
+ - fix mask layer
26
+ - Updated dependencies
27
+ - @baishuyun/ai-feat-utils@2.0.40
28
+ - @baishuyun/types@3.0.37
29
+
3
30
  ## 2.0.44
4
31
 
5
32
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baishuyun/ai-design",
3
- "version": "2.0.44",
3
+ "version": "2.0.47",
4
4
  "description": "AI 功能 UI 组件库 - 所有 AI 功能的 UI 表现唯一真相来源",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -60,8 +60,8 @@
60
60
  "tw-animate-css": "^1.4.0",
61
61
  "vaul": "^1.1.2",
62
62
  "zod": "^4.1.13",
63
- "@baishuyun/ai-feat-utils": "2.0.39",
64
- "@baishuyun/types": "3.0.36"
63
+ "@baishuyun/ai-feat-utils": "2.0.42",
64
+ "@baishuyun/types": "3.0.39"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "react": "^19.0.0",
@@ -84,7 +84,7 @@
84
84
  "vite": "^5.1.4",
85
85
  "vite-plugin-dts": "^4.5.4",
86
86
  "@baishuyun/tailwind-config": "3.0.9",
87
- "@baishuyun/types": "3.0.36",
87
+ "@baishuyun/types": "3.0.39",
88
88
  "@baishuyun/typescript-config": "2.0.9"
89
89
  },
90
90
  "keywords": [],
@@ -6,6 +6,7 @@ import { SquareChecker } from '../../square-checker';
6
6
  import type { IAppGroup, IAppGroupItem } from '@baishuyun/types';
7
7
  import { AppIcon } from '../../font-icon';
8
8
  import { SearchIcon } from '../../bs-icons';
9
+ import classNames from 'classnames';
9
10
 
10
11
  // ── Tree Node Type ────────────────────────────────────────────────
11
12
 
@@ -41,7 +42,10 @@ export function groupsToAppTreeNodes(groups: IAppGroup[]): AppTreeNode[] {
41
42
  /** Folder/group icon (16x16) */
42
43
  const FolderIcon = () => (
43
44
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
44
- <path d="M13.9004 15H2.65039C2.25257 15 1.87104 14.842 1.58973 14.5607C1.30843 14.2794 1.15039 13.8978 1.15039 13.5V4.5C1.15039 4.10218 1.30843 3.72064 1.58973 3.43934C1.87104 3.15804 2.25257 3 2.65039 3H7.15039L8.65039 4.5H13.9004C14.0974 4.5 14.2924 4.5388 14.4744 4.61418C14.6564 4.68956 14.8218 4.80005 14.9611 4.93934C15.1003 5.07863 15.2108 5.24399 15.2862 5.42597C15.3616 5.60796 15.4004 5.80302 15.4004 6H2.65039V13.5L4.25539 7.5H16.0754C16.1927 7.49595 16.3093 7.51947 16.4158 7.56867C16.5223 7.61788 16.6158 7.69139 16.6888 7.78331C16.7617 7.87523 16.8121 7.98298 16.8358 8.0979C16.8595 8.21282 16.856 8.33171 16.8254 8.445L15.3704 13.875C15.2865 14.1999 15.0961 14.4873 14.8296 14.6913C14.5631 14.8952 14.2359 15.0039 13.9004 15Z" fill="#6F81BD"/>
45
+ <path
46
+ d="M13.9004 15H2.65039C2.25257 15 1.87104 14.842 1.58973 14.5607C1.30843 14.2794 1.15039 13.8978 1.15039 13.5V4.5C1.15039 4.10218 1.30843 3.72064 1.58973 3.43934C1.87104 3.15804 2.25257 3 2.65039 3H7.15039L8.65039 4.5H13.9004C14.0974 4.5 14.2924 4.5388 14.4744 4.61418C14.6564 4.68956 14.8218 4.80005 14.9611 4.93934C15.1003 5.07863 15.2108 5.24399 15.2862 5.42597C15.3616 5.60796 15.4004 5.80302 15.4004 6H2.65039V13.5L4.25539 7.5H16.0754C16.1927 7.49595 16.3093 7.51947 16.4158 7.56867C16.5223 7.61788 16.6158 7.69139 16.6888 7.78331C16.7617 7.87523 16.8121 7.98298 16.8358 8.0979C16.8595 8.21282 16.856 8.33171 16.8254 8.445L15.3704 13.875C15.2865 14.1999 15.0961 14.4873 14.8296 14.6913C14.5631 14.8952 14.2359 15.0039 13.9004 15Z"
47
+ fill="#6F81BD"
48
+ />
45
49
  </svg>
46
50
  );
47
51
 
@@ -70,11 +74,20 @@ const FolderIcon = () => (
70
74
  /** Collapse/expand toggle (18x18) — shown on expandable parent nodes */
71
75
  const ToggleIcon = ({ expanded }: { expanded: boolean }) => (
72
76
  <svg
73
- width="18" height="18" viewBox="0 0 18 18" fill="none"
77
+ width="18"
78
+ height="18"
79
+ viewBox="0 0 18 18"
80
+ fill="none"
74
81
  className={cn('shrink-0', transCls)}
75
82
  style={{ transform: expanded ? 'rotate(0deg)' : 'rotate(-90deg)' }}
76
83
  >
77
- <path d="M6 8L9 11L12 8" stroke="#666666" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
84
+ <path
85
+ d="M6 8L9 11L12 8"
86
+ stroke="#666666"
87
+ strokeWidth="1.2"
88
+ strokeLinecap="round"
89
+ strokeLinejoin="round"
90
+ />
78
91
  </svg>
79
92
  );
80
93
 
@@ -97,11 +110,20 @@ const MoreIcon = () => (
97
110
  /** Dropdown chevron in trigger — matches Figma trigger icon */
98
111
  const DropdownChevron = ({ open }: { open: boolean }) => (
99
112
  <svg
100
- width="16" height="16" viewBox="0 0 16 16" fill="none"
113
+ width="16"
114
+ height="16"
115
+ viewBox="0 0 16 16"
116
+ fill="none"
101
117
  className={cn('shrink-0', transCls)}
102
118
  style={{ transform: open ? 'rotate(180deg)' : 'rotate(0deg)' }}
103
119
  >
104
- <path d="M4 6L8 10L12 6" stroke="#666666" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
120
+ <path
121
+ d="M4 6L8 10L12 6"
122
+ stroke="#666666"
123
+ strokeWidth="1.2"
124
+ strokeLinecap="round"
125
+ strokeLinejoin="round"
126
+ />
105
127
  </svg>
106
128
  );
107
129
 
@@ -130,6 +152,7 @@ export interface AppSelectProps {
130
152
  maxVisibleChips?: number;
131
153
  /** Additional className */
132
154
  className?: string;
155
+ contentCls?: string;
133
156
  /** Show a "全部应用" (All Apps) item at the top. Only effective in single mode. */
134
157
  showAll?: boolean;
135
158
  /** Allow selecting an empty value as the first option. Only effective in single mode. */
@@ -137,6 +160,8 @@ export interface AppSelectProps {
137
160
  /** Label for the empty option. Default "无". */
138
161
  emptyLabel?: string;
139
162
  popoverContentOnly?: boolean; // for testing: render only the popover content without the trigger
163
+
164
+ disableMaxHeight?: boolean;
140
165
  }
141
166
 
142
167
  // ── Helpers ───────────────────────────────────────────────────────
@@ -171,6 +196,8 @@ export const AppSelect = ({
171
196
  disabled = false,
172
197
  maxVisibleChips = 4,
173
198
  className,
199
+ contentCls,
200
+ disableMaxHeight,
174
201
  }: AppSelectProps) => {
175
202
  const [open, setOpen] = useState(false);
176
203
  const [searchQuery, setSearchQuery] = useState('');
@@ -181,6 +208,11 @@ export const AppSelect = ({
181
208
  const [triggerWidth, setTriggerWidth] = useState<number>(0);
182
209
  const triggerBtnRef = useRef<HTMLButtonElement | null>(null);
183
210
 
211
+ const maxTreeHeightCls = classNames({
212
+ 'max-h-[400px]': !disableMaxHeight,
213
+ 'max-h-full': disableMaxHeight,
214
+ });
215
+
184
216
  // Expanded node IDs (only nodes with children can be expanded)
185
217
  const [expandedIds, setExpandedIds] = useState<Set<string>>(() => {
186
218
  // Start with root nodes expanded
@@ -213,7 +245,7 @@ export const AppSelect = ({
213
245
 
214
246
  // Selected labels for trigger
215
247
  const selectedLabels = useMemo(() => {
216
- const ids = Array.isArray(resolvedValue) ? resolvedValue : (resolvedValue ? [resolvedValue] : []);
248
+ const ids = Array.isArray(resolvedValue) ? resolvedValue : resolvedValue ? [resolvedValue] : [];
217
249
  return ids.map((id) => nodeMap.get(id)?.label ?? id);
218
250
  }, [resolvedValue, nodeMap]);
219
251
 
@@ -236,7 +268,10 @@ export const AppSelect = ({
236
268
  const labelMatch = node?.label?.toLowerCase().includes(q);
237
269
  const filteredChildren = node.children ? filterTree(node.children) : [];
238
270
  if (labelMatch || filteredChildren.length > 0) {
239
- result.push({ ...node, children: filteredChildren.length > 0 ? filteredChildren : node.children });
271
+ result.push({
272
+ ...node,
273
+ children: filteredChildren.length > 0 ? filteredChildren : node.children,
274
+ });
240
275
  }
241
276
  }
242
277
  return result;
@@ -249,11 +284,17 @@ export const AppSelect = ({
249
284
  const setTriggerRef = useCallback((node: HTMLButtonElement | null) => {
250
285
  triggerBtnRef.current = node;
251
286
  if (node) setTriggerWidth(node.offsetWidth);
252
- if (!node) { setPortalContainer(null); return; }
287
+ if (!node) {
288
+ setPortalContainer(null);
289
+ return;
290
+ }
253
291
  const rootNode = node.getRootNode();
254
292
  if (rootNode instanceof ShadowRoot) {
255
293
  const existing = rootNode.querySelector<HTMLElement>('[data-bs-app-select-portal]');
256
- if (existing) { setPortalContainer(existing); return; }
294
+ if (existing) {
295
+ setPortalContainer(existing);
296
+ return;
297
+ }
257
298
  const container = document.createElement('div');
258
299
  container.setAttribute('data-bs-app-select-portal', 'true');
259
300
  rootNode.appendChild(container);
@@ -354,9 +395,7 @@ export const AppSelect = ({
354
395
  'flex items-center gap-[6px] w-full h-[34px] rounded-[4px] text-left',
355
396
  'pr-[10px]',
356
397
  transCls,
357
- isSelected
358
- ? 'bg-[#F0F6FF] text-[#0265FF]'
359
- : 'text-[#030303] hover:bg-[#EFF0F6]'
398
+ isSelected ? 'bg-[#F0F6FF] text-[#0265FF]' : 'text-[#030303] hover:bg-[#EFF0F6]'
360
399
  )}
361
400
  style={{ paddingLeft: `${leftPad}px`, paddingTop: '10px', paddingBottom: '10px' }}
362
401
  >
@@ -376,7 +415,7 @@ export const AppSelect = ({
376
415
 
377
416
  {/* SquareChecker for multi-select on leaf nodes — always visible */}
378
417
  {mode === 'multiple' && !hasChildren && node.type !== 'group' && (
379
- <span onClick={(e) => e.stopPropagation()} className='grid place-items-center'>
418
+ <span onClick={(e) => e.stopPropagation()} className="grid place-items-center">
380
419
  <SquareChecker
381
420
  checked={isSelected}
382
421
  onCheckedChange={() => handleSelect(node.id, node)}
@@ -388,9 +427,7 @@ export const AppSelect = ({
388
427
 
389
428
  {/* Children (when expanded) */}
390
429
  {hasChildren && isExpanded && (
391
- <div>
392
- {node.children!.map((child) => renderNodeRow(child, depth + 1))}
393
- </div>
430
+ <div>{node.children!.map((child) => renderNodeRow(child, depth + 1))}</div>
394
431
  )}
395
432
  </div>
396
433
  );
@@ -403,70 +440,70 @@ export const AppSelect = ({
403
440
  const hasMultiSelection = mode === 'multiple' && multiSelectedLabels.length > 0;
404
441
 
405
442
  const popoverContent = (
406
- <div className="flex flex-col gap-[4px]">
407
- {/* Search */}
408
- <div className="flex items-center gap-[6px] border border-[#E0E0E0] rounded-[4px] h-[30px] px-[10px] py-[5px]">
409
- <SearchIcon />
410
- <input
411
- type="text"
412
- value={searchQuery}
413
- onChange={(e) => setSearchQuery(e.target.value)}
414
- placeholder={searchPlaceholder}
415
- className="flex-1 outline-none text-[14px] placeholder:text-[#999999] bg-transparent min-w-0 text-[#030303]"
416
- />
417
- </div>
418
-
419
- {/* Empty option */}
420
- {allowEmpty && mode === 'single' && !searchQuery.trim() && (
421
- <button
422
- type="button"
423
- onClick={() => {
424
- updateValue('');
425
- setOpen(false);
426
- }}
427
- className={cn(
428
- 'flex items-center w-full h-[34px] rounded-[4px] text-left',
429
- 'px-[10px]',
430
- transCls,
431
- 'text-[#030303] hover:bg-[#EFF0F6]'
432
- )}
433
- >
434
- <span className="text-[14px] leading-[normal]">{emptyLabel}</span>
435
- </button>
436
- )}
437
-
438
- {/* "全部应用" item */}
439
- {showAll && mode === 'single' && !searchQuery.trim() && (
440
- <button
441
- type="button"
442
- onClick={() => {
443
- updateValue(ALL_APPS_VALUE);
444
- setOpen(false);
445
- }}
446
- className={cn(
447
- 'flex items-center w-full h-[34px] rounded-[4px] text-left',
448
- 'px-[10px]',
449
- transCls,
450
- selectedIds.has(ALL_APPS_VALUE)
451
- ? 'bg-[#F0F6FF] text-[#0265FF]'
452
- : 'text-[#030303] hover:bg-[#EFF0F6]'
453
- )}
454
- >
455
- <span className="text-[14px] leading-[normal]">全部应用</span>
456
- </button>
457
- )}
458
-
459
- {/* Tree */}
460
- <div className="max-h-[400px] overflow-y-auto">
461
- {filteredNodes.length > 0 ? (
462
- filteredNodes.map((node) => renderNodeRow(node, 0))
463
- ) : (
464
- <div className="flex items-center justify-center h-[60px] text-[12px] text-[#999999]">
465
- {searchQuery.trim() ? '未找到相关应用' : '暂无应用'}
466
- </div>
467
- )}
468
- </div>
443
+ <div className={classNames('flex flex-col gap-[4px]', contentCls)}>
444
+ {/* Search */}
445
+ <div className="flex items-center gap-[6px] border border-[#E0E0E0] rounded-[4px] h-[30px] px-[10px] py-[5px]">
446
+ <SearchIcon />
447
+ <input
448
+ type="text"
449
+ value={searchQuery}
450
+ onChange={(e) => setSearchQuery(e.target.value)}
451
+ placeholder={searchPlaceholder}
452
+ className="flex-1 outline-none text-[14px] placeholder:text-[#999999] bg-transparent min-w-0 text-[#030303]"
453
+ />
454
+ </div>
455
+
456
+ {/* Empty option */}
457
+ {allowEmpty && mode === 'single' && !searchQuery.trim() && (
458
+ <button
459
+ type="button"
460
+ onClick={() => {
461
+ updateValue('');
462
+ setOpen(false);
463
+ }}
464
+ className={cn(
465
+ 'flex items-center w-full h-[34px] rounded-[4px] text-left',
466
+ 'px-[10px]',
467
+ transCls,
468
+ 'text-[#030303] hover:bg-[#EFF0F6]'
469
+ )}
470
+ >
471
+ <span className="text-[14px] leading-[normal]">{emptyLabel}</span>
472
+ </button>
473
+ )}
474
+
475
+ {/* "全部应用" item */}
476
+ {showAll && mode === 'single' && !searchQuery.trim() && (
477
+ <button
478
+ type="button"
479
+ onClick={() => {
480
+ updateValue(ALL_APPS_VALUE);
481
+ setOpen(false);
482
+ }}
483
+ className={cn(
484
+ 'flex items-center w-full h-[34px] rounded-[4px] text-left',
485
+ 'px-[10px]',
486
+ transCls,
487
+ selectedIds.has(ALL_APPS_VALUE)
488
+ ? 'bg-[#F0F6FF] text-[#0265FF]'
489
+ : 'text-[#030303] hover:bg-[#EFF0F6]'
490
+ )}
491
+ >
492
+ <span className="text-[14px] leading-[normal]">全部应用</span>
493
+ </button>
494
+ )}
495
+
496
+ {/* Tree */}
497
+ <div className={classNames('overflow-y-auto', maxTreeHeightCls)}>
498
+ {filteredNodes.length > 0 ? (
499
+ filteredNodes.map((node) => renderNodeRow(node, 0))
500
+ ) : (
501
+ <div className="flex items-center justify-center h-[60px] text-[12px] text-[#999999]">
502
+ {searchQuery.trim() ? '未找到相关应用' : '暂无应用'}
469
503
  </div>
504
+ )}
505
+ </div>
506
+ </div>
470
507
  );
471
508
 
472
509
  if (popoverContentOnly) {
@@ -511,9 +548,7 @@ export const AppSelect = ({
511
548
  <span className="text-[14px] text-[#030303] truncate leading-[normal]">
512
549
  {label}
513
550
  </span>
514
- <span
515
- className="cursor-pointer flex items-center shrink-0 hover:bg-[#EFF0F6]"
516
- >
551
+ <span className="cursor-pointer flex items-center shrink-0 hover:bg-[#EFF0F6]">
517
552
  <CloseIcon />
518
553
  </span>
519
554
  </span>