@baishuyun/ai-design 2.1.8 → 2.1.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/agent-helper/field-select/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,GAAG,EAAE,MAAM,OAAO,CAAC;AAIpE,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAiB,MAAM,kBAAkB,CAAC;AAiFzE;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,SAAS,CAOxD,CAAC;AA2EF,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,kBAAkB,GAAI,wFAQhC,uBAAuB,gBAwIzB,CAAC;AAmCF,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC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uGlB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baishuyun/ai-design",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "description": "AI 功能 UI 组件库 - 所有 AI 功能的 UI 表现唯一真相来源",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -7,39 +7,85 @@ import { SearchIcon } from '../../bs-icons';
7
7
 
8
8
  const ToggleIcon = ({ expanded }: { expanded: boolean }) => (
9
9
  <svg
10
- width="16" height="16" viewBox="0 0 16 16" fill="none"
10
+ width="16"
11
+ height="16"
12
+ viewBox="0 0 16 16"
13
+ fill="none"
11
14
  className={cn('shrink-0', transCls)}
12
15
  style={{ transform: expanded ? 'rotate(0deg)' : 'rotate(-90deg)' }}
13
16
  >
14
- <path d="M5 7L8 10L11 7" stroke="#666666" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
17
+ <path
18
+ d="M5 7L8 10L11 7"
19
+ stroke="#666666"
20
+ strokeWidth="1.2"
21
+ strokeLinecap="round"
22
+ strokeLinejoin="round"
23
+ />
15
24
  </svg>
16
25
  );
17
26
 
18
27
  const DropdownChevron = ({ open }: { open: boolean }) => (
19
28
  <svg
20
- width="16" height="16" viewBox="0 0 16 16" fill="none"
29
+ width="16"
30
+ height="16"
31
+ viewBox="0 0 16 16"
32
+ fill="none"
21
33
  className={cn('shrink-0', transCls)}
22
34
  style={{ transform: open ? 'rotate(180deg)' : 'rotate(0deg)' }}
23
35
  >
24
- <path d="M4 6L8 10L12 6" stroke="#666666" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
36
+ <path
37
+ d="M4 6L8 10L12 6"
38
+ stroke="#666666"
39
+ strokeWidth="1.2"
40
+ strokeLinecap="round"
41
+ strokeLinejoin="round"
42
+ />
25
43
  </svg>
26
44
  );
27
45
 
28
46
  // ── FieldType → Badge Mapping ─────────────────────────────────────
29
47
 
30
- interface BadgeStyle { label: string; bgColor: string; textColor: string }
48
+ interface BadgeStyle {
49
+ label: string;
50
+ bgColor: string;
51
+ textColor: string;
52
+ }
31
53
 
32
54
  const FIELD_TYPE_BADGE_MAP: Partial<Record<FieldType, BadgeStyle>> = {};
33
55
 
34
56
  const textTypes: FieldType[] = [
35
- 'text', 'textarea', 'password', 'radio', 'radiogroup', 'combo', 'combocheck',
36
- 'checkboxgroup', 'address', 'location', 'separator', 'user',
37
- 'usergroup', 'dept', 'deptgroup', 'sn', 'formula', 'flowState', 'flowstate',
38
- 'subform', 'unknown',
57
+ 'text',
58
+ 'textarea',
59
+ 'password',
60
+ 'radio',
61
+ 'radiogroup',
62
+ 'combo',
63
+ 'combocheck',
64
+ 'checkboxgroup',
65
+ 'address',
66
+ 'location',
67
+ 'separator',
68
+ 'user',
69
+ 'usergroup',
70
+ 'dept',
71
+ 'deptgroup',
72
+ 'sn',
73
+ 'formula',
74
+ 'flowState',
75
+ 'flowstate',
76
+ 'subform',
77
+ 'unknown',
39
78
  ];
40
79
  const numberTypes: FieldType[] = ['number'];
41
80
  const datetimeTypes: FieldType[] = ['datetime'];
42
- const fileTypes: FieldType[] = ['upload', 'image', 'linkdata', 'linkquery', 'dataload', 'signature'];
81
+ const fileTypes: FieldType[] = [
82
+ 'upload',
83
+ 'image',
84
+ 'linkdata',
85
+ 'linkquery',
86
+ 'dataload',
87
+ 'signature',
88
+ ];
43
89
 
44
90
  for (const t of textTypes) {
45
91
  FIELD_TYPE_BADGE_MAP[t] = { label: '文本', bgColor: '#F0F6FF', textColor: '#0265FF' };
@@ -56,7 +102,6 @@ for (const t of fileTypes) {
56
102
 
57
103
  FIELD_TYPE_BADGE_MAP['button'] = { label: '按钮', bgColor: '#DDF6DD', textColor: '#1EC31E' };
58
104
 
59
-
60
105
  // ── Type Badge Component ──────────────────────────────────────────
61
106
 
62
107
  function TypeBadge({ style }: { style: BadgeStyle }) {
@@ -96,7 +141,6 @@ export const FIELD_SELECT_TYPE_BLACKLIST: Array<FieldType> = [
96
141
  'dataload',
97
142
  'linkquery',
98
143
  'linkdata',
99
- 'button',
100
144
  'separator',
101
145
  'subform',
102
146
  ];
@@ -107,8 +151,14 @@ function buildNodeKey(field: IField, index: number): string {
107
151
  return field.widget?.widgetName || String(index);
108
152
  }
109
153
 
110
- function buildItemNodeKey(parentKey: string, item: { widget?: { widgetName?: string }; value?: unknown; text?: string }, index: number): string {
111
- return (item as { widget?: { widgetName?: string } }).widget?.widgetName || `${parentKey}-${index}`;
154
+ function buildItemNodeKey(
155
+ parentKey: string,
156
+ item: { widget?: { widgetName?: string }; value?: unknown; text?: string },
157
+ index: number
158
+ ): string {
159
+ return (
160
+ (item as { widget?: { widgetName?: string } }).widget?.widgetName || `${parentKey}-${index}`
161
+ );
112
162
  }
113
163
 
114
164
  function buildFieldTree(fields: IField[], searchQuery: string): FieldTreeNode[] {
@@ -127,9 +177,7 @@ function buildFieldTree(fields: IField[], searchQuery: string): FieldTreeNode[]
127
177
 
128
178
  // Only items with a 'widget' property (ISubformField) are expandable sub-fields
129
179
  const items = field.widget?.items;
130
- const subformItems = items?.filter(
131
- (item): item is ISubformField => 'widget' in item
132
- );
180
+ const subformItems = items?.filter((item): item is ISubformField => 'widget' in item);
133
181
  const hasItems = subformItems && subformItems.length > 0;
134
182
  const rootKey = parentWidgetName || buildNodeKey(field, i);
135
183
 
@@ -204,10 +252,7 @@ export const FieldSelectPopover = ({
204
252
  return s;
205
253
  });
206
254
 
207
- const tree = useMemo(
208
- () => buildFieldTree(fields, searchQuery),
209
- [fields, searchQuery]
210
- );
255
+ const tree = useMemo(() => buildFieldTree(fields, searchQuery), [fields, searchQuery]);
211
256
 
212
257
  const toggleExpanded = useCallback((key: string) => {
213
258
  setExpandedKeys((prev) => {
@@ -233,9 +278,8 @@ export const FieldSelectPopover = ({
233
278
  const isExpanded = expandedKeys.has(node.key);
234
279
  const isSelected = selectedKey != null && node.key === selectedKey;
235
280
  const paddingLeft = node.depth * 22 + 10;
236
- const badge = node.fieldType && showTypeBadge
237
- ? FIELD_TYPE_BADGE_MAP[node.fieldType]
238
- : undefined;
281
+ const badge =
282
+ node.fieldType && showTypeBadge ? FIELD_TYPE_BADGE_MAP[node.fieldType] : undefined;
239
283
 
240
284
  const handleRowClick = () => {
241
285
  if (node.isExpandable) {
@@ -259,9 +303,7 @@ export const FieldSelectPopover = ({
259
303
  'flex items-center justify-between w-full h-[34px] rounded-[4px] text-left',
260
304
  'pr-[10px]',
261
305
  transCls,
262
- isSelected
263
- ? 'bg-[#F0F6FF] text-[#0265FF]'
264
- : 'text-[#030303] hover:bg-[#EFF0F6]'
306
+ isSelected ? 'bg-[#F0F6FF] text-[#0265FF]' : 'text-[#030303] hover:bg-[#EFF0F6]'
265
307
  )}
266
308
  style={{ paddingLeft: `${paddingLeft}px`, paddingTop: 7, paddingBottom: 7 }}
267
309
  >
@@ -275,9 +317,7 @@ export const FieldSelectPopover = ({
275
317
  <span className="w-[16px] h-[16px] shrink-0" />
276
318
  ) : null}
277
319
 
278
- <span className="text-[14px] truncate leading-[normal]">
279
- {node.label}
280
- </span>
320
+ <span className="text-[14px] truncate leading-[normal]">{node.label}</span>
281
321
  </div>
282
322
 
283
323
  {badge && <TypeBadge style={badge} />}
@@ -285,9 +325,7 @@ export const FieldSelectPopover = ({
285
325
 
286
326
  {/* Children when expanded */}
287
327
  {node.isExpandable && isExpanded && (
288
- <div>
289
- {node.children.map((child) => renderNodeRow(child))}
290
- </div>
328
+ <div>{node.children.map((child) => renderNodeRow(child))}</div>
291
329
  )}
292
330
  </div>
293
331
  );
@@ -393,10 +431,7 @@ export const FieldSelect = ({
393
431
  const triggerBtnRef = useRef<HTMLButtonElement | null>(null);
394
432
 
395
433
  const selectedKey = controlledValue !== undefined ? controlledValue : internalSelectedKey;
396
- const displayLabel = useMemo(
397
- () => getLabelByKey(fields, selectedKey),
398
- [fields, selectedKey]
399
- );
434
+ const displayLabel = useMemo(() => getLabelByKey(fields, selectedKey), [fields, selectedKey]);
400
435
 
401
436
  const handleSelect = useCallback(
402
437
  (field: IField, nodeKey: string) => {
@@ -423,11 +458,17 @@ export const FieldSelect = ({
423
458
  const setTriggerRef = useCallback((node: HTMLButtonElement | null) => {
424
459
  triggerBtnRef.current = node;
425
460
  if (node) setTriggerWidth(node.offsetWidth);
426
- if (!node) { setPortalContainer(null); return; }
461
+ if (!node) {
462
+ setPortalContainer(null);
463
+ return;
464
+ }
427
465
  const rootNode = node.getRootNode();
428
466
  if (rootNode instanceof ShadowRoot) {
429
467
  const existing = rootNode.querySelector<HTMLElement>('[data-bs-field-select-portal]');
430
- if (existing) { setPortalContainer(existing); return; }
468
+ if (existing) {
469
+ setPortalContainer(existing);
470
+ return;
471
+ }
431
472
  const container = document.createElement('div');
432
473
  container.setAttribute('data-bs-field-select-portal', 'true');
433
474
  rootNode.appendChild(container);