@baishuyun/ai-design 2.0.48 → 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 +18 -0
- package/package.json +4 -4
- package/src/components/agent-drawer.tsx +40 -6
- package/src/components/agent-helper/condition-input/index.tsx +18 -21
- package/src/components/agent-helper/condition-item/index.tsx +1 -0
- package/src/components/agent-helper/field-edit-preference-select/index.tsx +31 -4
- package/src/components/agent-helper/field-value-input/dept-select.tsx +447 -0
- package/src/components/agent-helper/field-value-input/index.tsx +3 -2
- package/src/components/agent-helper/field-value-input/picker-inputs.tsx +11 -6
- package/src/components/agent-helper/relational-operator-select/index.tsx +37 -23
- package/src/components/agent-helper/table/index.tsx +6 -2
- package/src/components/agent-select.tsx +115 -35
- package/src/components/card.tsx +19 -6
- package/src/components/output-config-editor.tsx +23 -17
- package/src/stories/FieldValueInput.stories.tsx +6 -3
- package/src/stories/RelationalOperatorSelect.stories.tsx +27 -0
- package/style.css +147 -126
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
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
|
+
|
|
12
|
+
## 2.0.49
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- mobile style
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @baishuyun/ai-feat-utils@2.0.44
|
|
19
|
+
- @baishuyun/types@3.0.41
|
|
20
|
+
|
|
3
21
|
## 2.0.48
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baishuyun/ai-design",
|
|
3
|
-
"version": "2.0.
|
|
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.
|
|
64
|
-
"@baishuyun/types": "3.0.
|
|
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.
|
|
87
|
+
"@baishuyun/types": "3.0.42",
|
|
88
88
|
"@baishuyun/typescript-config": "2.0.9"
|
|
89
89
|
},
|
|
90
90
|
"keywords": [],
|
|
@@ -17,8 +17,20 @@ export interface AgentDrawerProps {
|
|
|
17
17
|
trigger?: React.ReactNode;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/** 关闭图标(设计稿 40434:34111,20×20,#121111) */
|
|
21
|
+
const CloseIcon = () => (
|
|
22
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" aria-hidden="true">
|
|
23
|
+
<path
|
|
24
|
+
d="M11.2584 9.99867L17.874 3.37975C18.0348 3.21757 18.125 2.99839 18.125 2.76996C18.125 2.54153 18.0348 2.32235 17.874 2.16017L17.8388 2.12495C17.6764 1.96522 17.4578 1.87572 17.23 1.87572C17.0023 1.87572 16.7837 1.96522 16.6213 2.12495L10.0027 8.75414L3.38708 2.12495C3.22461 1.96478 3.00568 1.875 2.77759 1.875C2.54951 1.875 2.33057 1.96478 2.1681 2.12495L2.13143 2.16017C2.05026 2.23946 1.98576 2.33419 1.94172 2.43878C1.89769 2.54338 1.875 2.65573 1.875 2.76923C1.875 2.88272 1.89769 2.99507 1.94172 3.09967C1.98576 3.20427 2.05026 3.299 2.13143 3.37828L8.74706 9.99867L2.13143 16.6205C1.97109 16.7826 1.88115 17.0015 1.88115 17.2296C1.88115 17.4577 1.97109 17.6765 2.13143 17.8386L2.1681 17.8739C2.33014 18.0343 2.5489 18.1243 2.77686 18.1243C3.00482 18.1243 3.22358 18.0343 3.38561 17.8739L10.0027 11.2549L16.6183 17.8739C16.7804 18.0347 16.9995 18.125 17.2278 18.125C17.4561 18.125 17.6752 18.0347 17.8373 17.8739L17.874 17.8386C18.0343 17.6765 18.1243 17.4577 18.1243 17.2296C18.1243 17.0015 18.0343 16.7826 17.874 16.6205L11.2598 9.99867H11.2584Z"
|
|
25
|
+
fill="#121111"
|
|
26
|
+
/>
|
|
27
|
+
</svg>
|
|
28
|
+
);
|
|
29
|
+
|
|
20
30
|
/**
|
|
21
|
-
*
|
|
31
|
+
* 智能体选择抽屉(移动端从底部滑出),复用 AgentSelect 列表,选中后自动关闭。
|
|
32
|
+
* 视觉对齐设计稿 40434:34107:顶部圆角面板 +「全部智能体」18px 标题 +
|
|
33
|
+
* 关闭按钮 + 搜索框 + 全宽列表行。
|
|
22
34
|
* shadow DOM 兼容逻辑统一由 EnhancedDrawer 处理。
|
|
23
35
|
*/
|
|
24
36
|
export const AgentDrawer = ({
|
|
@@ -60,14 +72,35 @@ export const AgentDrawer = ({
|
|
|
60
72
|
<EnhancedDrawer
|
|
61
73
|
open={open}
|
|
62
74
|
onOpenChange={setOpen}
|
|
63
|
-
direction="
|
|
64
|
-
width={300}
|
|
75
|
+
direction="bottom"
|
|
65
76
|
title="选择智能体"
|
|
77
|
+
// DrawerContent 内联 style 强制 borderRadius: 0(会压掉方向圆角),
|
|
78
|
+
// 用 !important 任意值恢复设计稿的顶部 10px 圆角
|
|
79
|
+
className="rounded-t-[10px]!"
|
|
66
80
|
>
|
|
67
|
-
<div className="
|
|
81
|
+
<div className="flex flex-col">
|
|
82
|
+
{/* 头部:标题 18px Bold + 关闭(设计稿 40434:34109,上 20、下 20、左右 12) */}
|
|
83
|
+
<div className="flex items-center justify-between px-[12px] pt-[20px] pb-[20px]">
|
|
84
|
+
<span className="text-[18px] font-bold text-[#030303] leading-[normal]">
|
|
85
|
+
全部智能体
|
|
86
|
+
</span>
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
aria-label="关闭"
|
|
90
|
+
className="shrink-0 size-[20px] border-none bg-transparent p-0 text-[#121111] cursor-pointer"
|
|
91
|
+
onClick={() => setOpen(false)}
|
|
92
|
+
>
|
|
93
|
+
<CloseIcon />
|
|
94
|
+
</button>
|
|
95
|
+
</div>
|
|
96
|
+
{/* 搜索 + 列表(样式见 AgentSelect large;85px ≈ 头部块高度;
|
|
97
|
+
底部 16px 内边距,设计稿 40654:39900) */}
|
|
68
98
|
<div
|
|
69
|
-
className="overflow-y-auto"
|
|
70
|
-
style={{
|
|
99
|
+
className="overflow-y-auto pb-[16px]"
|
|
100
|
+
style={{
|
|
101
|
+
maxHeight: 'calc(100vh - 52px - 85px)',
|
|
102
|
+
scrollbarWidth: 'none',
|
|
103
|
+
}}
|
|
71
104
|
data-vaul-no-drag
|
|
72
105
|
>
|
|
73
106
|
<AgentSelect
|
|
@@ -76,6 +109,7 @@ export const AgentDrawer = ({
|
|
|
76
109
|
onSelect={handleSelect}
|
|
77
110
|
showSearch={showSearch}
|
|
78
111
|
showAllItems
|
|
112
|
+
large
|
|
79
113
|
/>
|
|
80
114
|
</div>
|
|
81
115
|
</div>
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { useState, useCallback, useRef } from 'react';
|
|
2
|
-
import type {
|
|
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,
|
|
122
|
-
|
|
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,
|
|
153
|
+
const newFields = [...selectedFields, resolved];
|
|
127
154
|
setValue({ type: 'edit_any_specified_field', fields: newFields });
|
|
128
155
|
setOpen(false);
|
|
129
156
|
},
|