@baishuyun/ai-design 2.0.3 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @baishuyun/ai-design
2
2
 
3
+ ## 2.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - fix entry select
8
+ - Updated dependencies
9
+ - @baishuyun/ai-feat-utils@2.0.4
10
+ - @baishuyun/types@3.0.4
11
+
3
12
  ## 2.0.3
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.3",
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.3",
64
- "@baishuyun/types": "3.0.3"
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.3",
87
- "@baishuyun/types": "3.0.3",
88
- "@baishuyun/typescript-config": "2.0.3"
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';
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';