@baishuyun/ai-design 2.0.49 → 2.0.50

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,14 @@
1
1
  # @baishuyun/ai-design
2
2
 
3
+ ## 2.0.50
4
+
5
+ ### Patch Changes
6
+
7
+ - agent helper error
8
+ - Updated dependencies
9
+ - @baishuyun/ai-feat-utils@2.0.45
10
+ - @baishuyun/types@3.0.42
11
+
3
12
  ## 2.0.49
4
13
 
5
14
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baishuyun/ai-design",
3
- "version": "2.0.49",
3
+ "version": "2.0.50",
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.44",
64
- "@baishuyun/types": "3.0.41"
63
+ "@baishuyun/ai-feat-utils": "2.0.45",
64
+ "@baishuyun/types": "3.0.42"
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.41",
87
+ "@baishuyun/types": "3.0.42",
88
88
  "@baishuyun/typescript-config": "2.0.9"
89
89
  },
90
90
  "keywords": [],
@@ -1,5 +1,12 @@
1
1
  import { useState, useCallback, useRef } from 'react';
2
- import type { IField, ICondition, IConditionItem, quantifier, IFieldValueService, FieldType } from '@baishuyun/types';
2
+ import type {
3
+ IField,
4
+ ICondition,
5
+ IConditionItem,
6
+ quantifier,
7
+ IFieldValueService,
8
+ FieldType,
9
+ } from '@baishuyun/types';
3
10
  import { cn } from '../../../lib/utils';
4
11
  import { transCls } from '../../../const/ui';
5
12
  import { ConditonTriggerDescription } from '../condition-trigger-description';
@@ -23,12 +30,7 @@ function createEmptyItem(): IConditionItem {
23
30
  };
24
31
  }
25
32
 
26
- const FilterFieldTypeBlacklist: Array<FieldType> = [
27
- 'button',
28
- 'separator',
29
- 'subform',
30
- 'upload',
31
- ];
33
+ const FilterFieldTypeBlacklist: Array<FieldType> = ['button', 'separator', 'subform'];
32
34
 
33
35
  export interface ConditionInputProps {
34
36
  targetName: string;
@@ -56,11 +58,11 @@ export const ConditionInput = ({
56
58
  targetName,
57
59
  quantifier: 'all',
58
60
  items: [],
59
- },
61
+ }
60
62
  ).current;
61
63
 
62
64
  const fields = allFields.filter(
63
- (f) => !FilterFieldTypeBlacklist.includes(f.widget?.type as FieldType),
65
+ (f) => !FilterFieldTypeBlacklist.includes(f.widget?.type as FieldType)
64
66
  );
65
67
 
66
68
  const [internalValue, setInternalValue] = useState<ICondition>(defaultCondition);
@@ -72,14 +74,14 @@ export const ConditionInput = ({
72
74
  if (!isControlled) setInternalValue(next);
73
75
  onChange?.(next);
74
76
  },
75
- [isControlled, onChange],
77
+ [isControlled, onChange]
76
78
  );
77
79
 
78
80
  const handleQuantifierChange = useCallback(
79
81
  (nextQuantifier: quantifier) => {
80
82
  updateValue({ ...currentValue, quantifier: nextQuantifier });
81
83
  },
82
- [currentValue, updateValue],
84
+ [currentValue, updateValue]
83
85
  );
84
86
 
85
87
  const handleAddCondition = useCallback(() => {
@@ -111,7 +113,7 @@ export const ConditionInput = ({
111
113
  'text-[14px] leading-[normal] text-[#0265FF]',
112
114
  'hover:opacity-80',
113
115
  disabled && 'opacity-50 cursor-not-allowed',
114
- transCls,
116
+ transCls
115
117
  )}
116
118
  >
117
119
  <AddIcon />
@@ -127,7 +129,7 @@ export const ConditionInput = ({
127
129
  'text-[14px] leading-[normal] text-[#FF5631]',
128
130
  'hover:opacity-80',
129
131
  disabled && 'opacity-50 cursor-not-allowed',
130
- transCls,
132
+ transCls
131
133
  )}
132
134
  >
133
135
  删除全部
@@ -150,10 +152,7 @@ ConditionInput.displayName = 'ConditionInput';
150
152
 
151
153
  // ── BsConditionInput (IBsCondition string ↔ ICondition adapter) ──────────────
152
154
 
153
- function parseBsCondition(
154
- str: string | undefined,
155
- targetName: string,
156
- ): ICondition {
155
+ function parseBsCondition(str: string | undefined, targetName: string): ICondition {
157
156
  if (str) {
158
157
  try {
159
158
  const parsed = bsConditionParse2Condition(str);
@@ -198,9 +197,7 @@ export const BsConditionInput = ({
198
197
  disabled = false,
199
198
  className,
200
199
  }: BsConditionInputProps) => {
201
- const defaultBS = useRef<string>(
202
- defaultValue ?? defaultBsConditionString(targetName),
203
- ).current;
200
+ const defaultBS = useRef<string>(defaultValue ?? defaultBsConditionString(targetName)).current;
204
201
 
205
202
  const [internalValue, setInternalValue] = useState<string>(defaultBS);
206
203
  const isControlled = controlledValue !== undefined;
@@ -214,7 +211,7 @@ export const BsConditionInput = ({
214
211
  if (!isControlled) setInternalValue(bsStr);
215
212
  onChange?.(bsStr);
216
213
  },
217
- [isControlled, onChange, targetName],
214
+ [isControlled, onChange, targetName]
218
215
  );
219
216
 
220
217
  return (
@@ -3,7 +3,7 @@ import { cn } from '../../../lib/utils';
3
3
  import { transCls } from '../../../const/ui';
4
4
  import { Popover, PopoverTrigger, PopoverContent } from '../../ui/popover';
5
5
  import { FieldSelectPopover } from '../field-select';
6
- import type { IField } from '@baishuyun/types';
6
+ import type { IField, ISubformField } from '@baishuyun/types';
7
7
  import type { FormActionFieldEditPreference } from '@baishuyun/types';
8
8
 
9
9
  // ── Inline SVG Icons ──────────────────────────────────────────────
@@ -62,6 +62,29 @@ function FieldChip({ label, onRemove }: { label: string; onRemove: () => void })
62
62
 
63
63
  // ── Types ─────────────────────────────────────────────────────────
64
64
 
65
+ /**
66
+ * 解析选中的字段:
67
+ * 顶层字段 nodeKey 无 '.',原样返回;
68
+ * 子表单子字段 nodeKey 形如 parent.childWidgetName,从父字段 items 中取出
69
+ * 子字段,构造 label 为子字段名、widgetName 为完整路径的独立 IField,
70
+ * 使 FieldChip 显示子字段名而非「子表单」字段名。
71
+ */
72
+ function resolveSelectedField(field: IField, nodeKey: string): IField {
73
+ const dotIndex = nodeKey.indexOf('.');
74
+ if (dotIndex < 0) return field;
75
+ const childWidgetName = nodeKey.slice(dotIndex + 1);
76
+ const item = field.widget?.items?.find(
77
+ (it): it is ISubformField =>
78
+ 'widget' in it && it.widget?.widgetName === childWidgetName
79
+ );
80
+ if (!item) return field;
81
+ return {
82
+ ...field,
83
+ label: item.label,
84
+ widget: { ...item.widget, widgetName: nodeKey },
85
+ } as IField;
86
+ }
87
+
65
88
  export interface FieldEditPreferenceSelectProps {
66
89
  fields: IField[];
67
90
  value?: FormActionFieldEditPreference;
@@ -118,12 +141,16 @@ export const FieldEditPreferenceSelect = ({
118
141
  );
119
142
 
120
143
  const handleAddField = useCallback(
121
- (field: IField, _nodeKey: string) => {
122
- if (selectedFields.some((f) => f.label === field.label)) {
144
+ (field: IField, nodeKey: string) => {
145
+ // 子表单子字段解析为独立字段(label=子字段名,widgetName=完整路径)
146
+ const resolved = resolveSelectedField(field, nodeKey);
147
+ // 以 widgetName(子字段为完整路径)去重,避免同名子字段误判
148
+ const resolvedKey = resolved.widget?.widgetName ?? resolved.label;
149
+ if (selectedFields.some((f) => (f.widget?.widgetName ?? f.label) === resolvedKey)) {
123
150
  setOpen(false);
124
151
  return;
125
152
  }
126
- const newFields = [...selectedFields, field];
153
+ const newFields = [...selectedFields, resolved];
127
154
  setValue({ type: 'edit_any_specified_field', fields: newFields });
128
155
  setOpen(false);
129
156
  },
@@ -131,7 +131,8 @@ export function ComboInput({ field, value, onChange, disabled, service, showLabe
131
131
  type="button"
132
132
  onClick={() => handleSelect(item.value)}
133
133
  className={cn(
134
- 'h-[34px] px-[10px] rounded-[4px] text-left text-[14px] leading-[normal]',
134
+ // shrink-0 防止 flex 容器 max-height 下子项收缩坍缩,改走 overflow 滚动
135
+ 'shrink-0 h-[34px] px-[10px] rounded-[4px] text-left text-[14px] leading-[normal]',
135
136
  value === item.value
136
137
  ? 'bg-[#F0F6FF] text-[#0265FF]'
137
138
  : 'text-[#030303] hover:bg-[#EFF0F6]',
@@ -504,7 +505,8 @@ export function AsyncPicker({ field, value, onChange, disabled, service, kind, m
504
505
  type="button"
505
506
  onClick={() => handleSelect(opt)}
506
507
  className={cn(
507
- 'flex items-center gap-[10px] h-[34px] px-[10px] rounded-[4px] text-left',
508
+ // shrink-0 防止 flex 容器 max-height 下子项收缩坍缩,改走 overflow 滚动
509
+ 'shrink-0 flex items-center gap-[10px] h-[34px] px-[10px] rounded-[4px] text-left',
508
510
  isSelected
509
511
  ? 'bg-[#F0F6FF] text-[#0265FF]'
510
512
  : 'text-[#030303] hover:bg-[#EFF0F6]',
@@ -684,7 +686,8 @@ export function TextMultiSelect({ field, value, onChange, disabled, service, sho
684
686
  type="button"
685
687
  onClick={() => handleToggle(opt)}
686
688
  className={cn(
687
- 'flex items-center gap-[10px] h-[34px] px-[10px] rounded-[4px] text-left',
689
+ // shrink-0 防止 flex 容器 max-height 下子项收缩坍缩,改走 overflow 滚动
690
+ 'shrink-0 flex items-center gap-[10px] h-[34px] px-[10px] rounded-[4px] text-left',
688
691
  checked
689
692
  ? 'bg-[#F0F6FF] text-[#0265FF]'
690
693
  : 'text-[#030303] hover:bg-[#EFF0F6]',
@@ -1027,7 +1030,8 @@ export function AddressInput({ field, value, onChange, disabled, service, showLa
1027
1030
  setKeyword('');
1028
1031
  }}
1029
1032
  className={cn(
1030
- 'h-[34px] px-[10px] rounded-[4px] text-left text-[14px] leading-[normal]',
1033
+ // shrink-0 防止 flex 容器 max-height 下子项收缩坍缩,改走 overflow 滚动
1034
+ 'shrink-0 h-[34px] px-[10px] rounded-[4px] text-left text-[14px] leading-[normal]',
1031
1035
  'text-[#030303] hover:bg-[#EFF0F6]',
1032
1036
  transCls,
1033
1037
  )}
@@ -1124,7 +1128,8 @@ export function LocationInput({ field, value, onChange, disabled, service, showL
1124
1128
  setKeyword('');
1125
1129
  }}
1126
1130
  className={cn(
1127
- 'h-[34px] px-[10px] rounded-[4px] text-left text-[14px] leading-[normal]',
1131
+ // shrink-0 防止 flex 容器 max-height 下子项收缩坍缩,改走 overflow 滚动
1132
+ 'shrink-0 h-[34px] px-[10px] rounded-[4px] text-left text-[14px] leading-[normal]',
1128
1133
  'text-[#030303] hover:bg-[#EFF0F6]',
1129
1134
  transCls,
1130
1135
  )}