@baishuyun/ai-design 2.0.2 → 2.0.4

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":"output-config-editor.d.ts","sourceRoot":"","sources":["../../../src/components/output-config-editor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,wBAAwB,EAAE,WAAW,EAAE,MAAM,EAAiB,MAAM,kBAAkB,CAAC;AAkChH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,wBAAwB,CAAC,KAAK,IAAI,CAAC;IAE5D,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAwED,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,uBAAuB,+BA6VrH"}
1
+ {"version":3,"file":"output-config-editor.d.ts","sourceRoot":"","sources":["../../../src/components/output-config-editor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,wBAAwB,EAAE,WAAW,EAAE,MAAM,EAAiB,MAAM,kBAAkB,CAAC;AAkChH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,wBAAwB,CAAC,KAAK,IAAI,CAAC;IAE5D,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAmFD,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,uBAAuB,+BA6VrH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baishuyun/ai-design",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
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.2",
64
- "@baishuyun/types": "3.0.2"
63
+ "@baishuyun/types": "3.0.4",
64
+ "@baishuyun/ai-feat-utils": "2.0.4"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "react": "^19.0.0",
@@ -83,9 +83,9 @@
83
83
  "typescript": "^5.5.0",
84
84
  "vite": "^5.1.4",
85
85
  "vite-plugin-dts": "^4.5.4",
86
- "@baishuyun/tailwind-config": "3.0.2",
87
- "@baishuyun/typescript-config": "2.0.2",
88
- "@baishuyun/types": "3.0.2"
86
+ "@baishuyun/tailwind-config": "3.0.4",
87
+ "@baishuyun/typescript-config": "2.0.4",
88
+ "@baishuyun/types": "3.0.4"
89
89
  },
90
90
  "keywords": [],
91
91
  "author": "",
@@ -1,5 +1,6 @@
1
- import type { IAppDetail, IEntryAliasItem, IEntryDetail } from '@baishuyun/types';
1
+ import type { IAppDetail, IEntryAliasItem, IEntryDetail, IEntryRef } from '@baishuyun/types';
2
2
  import type { EntryTreeItem, BsEntrySelectChangeResult } from './types';
3
+ import { FormSelectItem } from '../agent-helper/form-select';
3
4
 
4
5
  export const DEPTH_PADDING: Record<number, string> = {
5
6
  0: 'pl-[10px]',
@@ -24,14 +25,18 @@ export function buildEntryTreeFromAliasMap(
24
25
  appDetail: IAppDetail,
25
26
  searchQuery: string
26
27
  ): EntryTreeItem[] {
27
- const { entryIdAliasMap: originMap, entryMap } = appDetail;
28
+ const { entryIdAliasMap: originMap, entryMap, entryList } = appDetail;
29
+
30
+ const formIdWhiteList = new Set(flattenEntryList(entryList).map((e) => e.id));
28
31
 
29
32
  const entryIdAliasMap: Record<string, IEntryAliasItem> = {
30
33
  // ...originMap,
31
34
  };
32
35
 
33
36
  for (const [_, v] of Object.entries(originMap ?? {})) {
34
- entryIdAliasMap[v.formId as string] = v;
37
+ if (formIdWhiteList.has(v.formId)) {
38
+ entryIdAliasMap[v.formId as string] = v;
39
+ }
35
40
  }
36
41
 
37
42
  const aliasKeys = Object.keys(entryIdAliasMap);
@@ -108,6 +113,68 @@ export function buildEntryTreeFromAliasMap(
108
113
  return result;
109
114
  }
110
115
 
116
+ const flattenFormEntries = (entries: IEntryDetail[]): FormSelectItem[] => {
117
+ const result: FormSelectItem[] = [];
118
+ for (const entry of entries) {
119
+ result.push({
120
+ id: entry.entryId,
121
+ name: entry?.name || entry.entryId,
122
+ icon: entry?.icon || 0,
123
+ type: entry.type,
124
+ parent: entry.parent || undefined,
125
+ itemType: entry.type === 'group' ? 'group' : 'form',
126
+ });
127
+ if (entry.child?.length) {
128
+ for (const child of flattenFormEntries(entry.child)) {
129
+ result.push({ ...child, parent: entry.entryId });
130
+ }
131
+ }
132
+ }
133
+ return result;
134
+ };
135
+
136
+ interface IEntryItem {
137
+ id: string;
138
+ }
139
+
140
+ const flattenEntryList = (entryList: IEntryRef[]): Array<IEntryItem> => {
141
+ const items: IEntryItem[] = [];
142
+
143
+ for (const entry of entryList) {
144
+ items.push({
145
+ id: entry.id,
146
+ });
147
+
148
+ if (entry.child?.length) {
149
+ for (const c of flattenEntryList(entry.child)) {
150
+ items.push({
151
+ id: c.id,
152
+ });
153
+ }
154
+ }
155
+ }
156
+
157
+ return items;
158
+ };
159
+
160
+ export const getEntries = (appDetail: IAppDetail): FormSelectItem[] => {
161
+ const { entryIdAliasMap, entryMap, entryList } = appDetail;
162
+ const whiteList = new Set(flattenEntryList(entryList).map((e) => e.id));
163
+ const aliasKeys = Object.keys(entryIdAliasMap).filter((k) => whiteList.has(k));
164
+
165
+ if (aliasKeys.length === 0) {
166
+ return [];
167
+ }
168
+
169
+ const entries = aliasKeys
170
+ .map((id) => {
171
+ return entryMap[id] as IEntryDetail;
172
+ })
173
+ .filter(Boolean);
174
+
175
+ return flattenFormEntries(entries);
176
+ };
177
+
111
178
  export function filterTreeBySearch(nodes: EntryTreeItem[], searchQuery: string): EntryTreeItem[] {
112
179
  const lowerQuery = searchQuery.toLowerCase().trim();
113
180
  if (!lowerQuery) return nodes;
@@ -1,2 +1,3 @@
1
1
  export { BsEntrySelect } from './bs-entry-select';
2
2
  export type { BsEntrySelectProps, BsEntrySelectChangeResult } from './types';
3
+ export { buildEntryTreeFromAliasMap, getEntries } from './build-tree';
@@ -101,11 +101,22 @@ function findFieldByName(fields: OutputFieldOption[], fieldName: string): Output
101
101
  return undefined;
102
102
  }
103
103
 
104
+
105
+ const VALID_TYPE_MAP: Partial<Record<FieldType, Set<FieldType>>> = {
106
+ 'text': new Set(['text', 'textarea']),
107
+ 'number': new Set(['text', 'textarea']),
108
+ }
109
+
110
+ const EMPTY_SET = new Set();
111
+
104
112
  function filterFieldsByType(fields: OutputFieldOption[], targetType: FieldType | ''): OutputFieldOption[] {
105
113
  return fields.reduce<OutputFieldOption[]>((acc, f) => {
106
114
  const selfMatches = f.type === targetType;
115
+ const validTypeSet = VALID_TYPE_MAP[targetType as FieldType] ?? EMPTY_SET;
116
+ const generalMatches = validTypeSet.has(f.type);
117
+
107
118
  const filteredChildren = f.children ? filterFieldsByType(f.children, targetType) : [];
108
- if (selfMatches || filteredChildren.length > 0) {
119
+ if (selfMatches || generalMatches || filteredChildren.length > 0) {
109
120
  acc.push({ ...f, children: filteredChildren.length > 0 ? filteredChildren : f.children });
110
121
  }
111
122
  return acc;
package/src/index.ts CHANGED
@@ -46,7 +46,11 @@ export { AttachmentPart } from './components/attachment-part';
46
46
  export type { FilePart } from './components/attachment-part';
47
47
  export { AttachmentsPreviewer } from './components/attachments-previewer';
48
48
  export { BaseButton } from './components/base-button';
49
- export { BsEntrySelect } from './components/bs-entry-select';
49
+ export {
50
+ BsEntrySelect,
51
+ buildEntryTreeFromAliasMap,
52
+ getEntries,
53
+ } from './components/bs-entry-select';
50
54
  export type { BsEntrySelectProps, BsEntrySelectChangeResult } from './components/bs-entry-select';
51
55
  export { BorderAnimation } from './components/border-animation';
52
56
  export { BorderColorAnimation } from './components/border-color-animation';
@@ -78,7 +82,11 @@ export type {
78
82
  TriggerCardConfig,
79
83
  } from './components/agent-helper/trigger-select';
80
84
  export { FormSelect } from './components/agent-helper/form-select';
81
- export { AppSelect, groupsToAppTreeNodes, ALL_APPS_VALUE } from './components/agent-helper/app-select';
85
+ export {
86
+ AppSelect,
87
+ groupsToAppTreeNodes,
88
+ ALL_APPS_VALUE,
89
+ } from './components/agent-helper/app-select';
82
90
  export type { AppSelectProps } from './components/agent-helper/app-select';
83
91
  export type {
84
92
  FormSelectProps,
@@ -98,7 +106,10 @@ export { TriggerTimePreferenceSelect } from './components/agent-helper/trigger-t
98
106
  export type { TriggerTimePreferenceSelectProps } from './components/agent-helper/trigger-time-preference-select';
99
107
  export { OffsetPreferenceSelect } from './components/agent-helper/offset-preference-select';
100
108
  export type { OffsetPreferenceSelectProps } from './components/agent-helper/offset-preference-select';
101
- export { RepeatPreferenceTypeSelect, RepeatPreferenceTypeOptions } from './components/agent-helper/repeat-preference-type-select';
109
+ export {
110
+ RepeatPreferenceTypeSelect,
111
+ RepeatPreferenceTypeOptions,
112
+ } from './components/agent-helper/repeat-preference-type-select';
102
113
  export type {
103
114
  RepeatPreferenceTypeOption,
104
115
  RepeatPreferenceTypeSelectProps,
@@ -113,7 +124,10 @@ export type {
113
124
  MonthdaysOption,
114
125
  MonthdaysSelectProps,
115
126
  } from './components/agent-helper/monthdays-select';
116
- export { RepeatByTypeSelect, RepeatByTypeOptions } from './components/agent-helper/repeat-by-type-select';
127
+ export {
128
+ RepeatByTypeSelect,
129
+ RepeatByTypeOptions,
130
+ } from './components/agent-helper/repeat-by-type-select';
117
131
  export type {
118
132
  RepeatByTypeOption,
119
133
  RepeatByTypeSelectProps,
@@ -193,7 +207,11 @@ export { DataTable } from './components/agent-helper/table';
193
207
  export * from './components/agent-helper/table';
194
208
  export type { DataTableProps } from './components/agent-helper/table';
195
209
  export { DatePicker, DateInput } from './components/agent-helper/date-picker';
196
- export type { DatePickerProps, DateInputProps, DateFormat } from './components/agent-helper/date-picker';
210
+ export type {
211
+ DatePickerProps,
212
+ DateInputProps,
213
+ DateFormat,
214
+ } from './components/agent-helper/date-picker';
197
215
  export { DateRangePicker } from './components/date-range-picker';
198
216
  export type { DateRangePickerProps } from './components/date-range-picker';
199
217
  export { ExecLogFilter } from './components/agent-helper/exec-log-filter';