@baishuyun/ai-design 2.0.41 → 2.0.42

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.
@@ -0,0 +1,362 @@
1
+ import { useState } from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react-vite';
3
+ import {
4
+ TeamWideFormSelect,
5
+ TeamWideFormDrawer,
6
+ } from '../components/agent-helper/team-wide-form-select';
7
+ import type { TeamWideFormSelectChangeResult } from '../components/agent-helper/team-wide-form-select/types';
8
+ import type { IAllAppsAndFormsData } from '@baishuyun/types';
9
+
10
+ // ── Mock:按 /dashboard/app/form/list 真实返回结构构造 ────────────
11
+
12
+ const CURRENT_APP_ID = 'app_current';
13
+
14
+ const mockData: IAllAppsAndFormsData = {
15
+ dock_corps: [],
16
+ dock_items: [],
17
+ items: [
18
+ {
19
+ _id: 'default',
20
+ name: '默认分组',
21
+ appcount: 2,
22
+ apps: [
23
+ {
24
+ _id: CURRENT_APP_ID,
25
+ appname: '客户管理系统',
26
+ parent: 'default',
27
+ style: { color: 3, icon: 66 },
28
+ copyable: true,
29
+ deletable: true,
30
+ editable: true,
31
+ dock: false,
32
+ isFavorite: true,
33
+ appType: 1,
34
+ appStatus: 1,
35
+ disable_export: false,
36
+ formList: {
37
+ aggregate_table: null,
38
+ etl_table: null,
39
+ dash: [
40
+ {
41
+ appId: CURRENT_APP_ID,
42
+ entryId: 'dash_1',
43
+ hasCoop: false,
44
+ icon: 60,
45
+ name: '销售报表',
46
+ type: 'dash',
47
+ },
48
+ ],
49
+ form: [
50
+ {
51
+ appId: CURRENT_APP_ID,
52
+ entryId: 'form_1',
53
+ hasCoop: true,
54
+ icon: 51,
55
+ name: '采购订单表',
56
+ type: 'form',
57
+ },
58
+ {
59
+ appId: CURRENT_APP_ID,
60
+ entryId: 'group_1',
61
+ hasCoop: true,
62
+ icon: 25,
63
+ name: '客户资料',
64
+ type: 'group',
65
+ child: [
66
+ {
67
+ appId: CURRENT_APP_ID,
68
+ entryId: 'form_2',
69
+ hasCoop: true,
70
+ icon: 53,
71
+ name: '客户信息表',
72
+ type: 'form',
73
+ },
74
+ {
75
+ appId: CURRENT_APP_ID,
76
+ entryId: 'group_1_1',
77
+ hasCoop: true,
78
+ icon: 25,
79
+ name: '客户资料分组一',
80
+ type: 'group',
81
+ child: [
82
+ {
83
+ appId: CURRENT_APP_ID,
84
+ entryId: 'form_3',
85
+ hasCoop: true,
86
+ icon: 56,
87
+ name: '供应商管理表',
88
+ type: 'form',
89
+ },
90
+ {
91
+ appId: CURRENT_APP_ID,
92
+ entryId: 'form_4',
93
+ hasCoop: true,
94
+ icon: 56,
95
+ name: '客户表单',
96
+ type: 'form',
97
+ },
98
+ ],
99
+ },
100
+ ],
101
+ },
102
+ ],
103
+ refApps: [],
104
+ },
105
+ },
106
+ {
107
+ _id: 'app_2',
108
+ appname: '应用二',
109
+ parent: 'default',
110
+ style: { color: 1, icon: 40 },
111
+ copyable: true,
112
+ deletable: true,
113
+ editable: true,
114
+ dock: false,
115
+ isFavorite: false,
116
+ appType: 1,
117
+ appStatus: 1,
118
+ disable_export: false,
119
+ formList: {
120
+ aggregate_table: null,
121
+ dash: null,
122
+ etl_table: null,
123
+ form: [
124
+ {
125
+ appId: 'app_2',
126
+ entryId: 'app2_form_1',
127
+ hasCoop: true,
128
+ icon: 0,
129
+ name: '未命名表单',
130
+ type: 'form',
131
+ },
132
+ {
133
+ appId: 'app_2',
134
+ entryId: 'app2_group_1',
135
+ hasCoop: true,
136
+ icon: 25,
137
+ name: '我的分组一',
138
+ type: 'group',
139
+ child: [
140
+ {
141
+ appId: 'app_2',
142
+ entryId: 'app2_form_2',
143
+ hasCoop: true,
144
+ icon: 58,
145
+ name: '供应商管理表',
146
+ type: 'form',
147
+ },
148
+ {
149
+ appId: 'app_2',
150
+ entryId: 'app2_group_1_1',
151
+ hasCoop: true,
152
+ icon: 25,
153
+ name: '我的分组一杠1',
154
+ type: 'group',
155
+ child: [
156
+ {
157
+ appId: 'app_2',
158
+ entryId: 'app2_form_3',
159
+ hasCoop: true,
160
+ icon: 57,
161
+ name: '客户信息',
162
+ type: 'form',
163
+ },
164
+ ],
165
+ },
166
+ ],
167
+ },
168
+ ],
169
+ refApps: [],
170
+ },
171
+ },
172
+ ],
173
+ },
174
+ {
175
+ _id: 'group_b',
176
+ name: '解决方案模板',
177
+ appcount: 2,
178
+ apps: [
179
+ {
180
+ _id: 'app_3',
181
+ appname: '宠物管理',
182
+ parent: 'group_b',
183
+ style: { color: 3, icon: 67 },
184
+ copyable: true,
185
+ deletable: true,
186
+ editable: true,
187
+ dock: false,
188
+ isFavorite: false,
189
+ appType: 1,
190
+ appStatus: 1,
191
+ disable_export: false,
192
+ formList: {
193
+ aggregate_table: null,
194
+ dash: null,
195
+ etl_table: null,
196
+ form: [
197
+ {
198
+ appId: 'app_3',
199
+ entryId: 'app3_form_1',
200
+ hasCoop: true,
201
+ icon: 0,
202
+ name: '宠物信息',
203
+ type: 'form',
204
+ },
205
+ ],
206
+ refApps: [],
207
+ },
208
+ },
209
+ {
210
+ _id: 'app_4',
211
+ appname: '空白应用(无表单)',
212
+ parent: 'group_b',
213
+ style: { color: 2, icon: 44 },
214
+ copyable: true,
215
+ deletable: true,
216
+ editable: true,
217
+ dock: false,
218
+ isFavorite: false,
219
+ appType: 1,
220
+ appStatus: 1,
221
+ disable_export: false,
222
+ },
223
+ ],
224
+ },
225
+ ],
226
+ };
227
+
228
+ // ── Meta ──────────────────────────────────────────────────────────
229
+
230
+ const meta: Meta<typeof TeamWideFormSelect> = {
231
+ title: 'Agent Helper/TeamWideFormSelect',
232
+ component: TeamWideFormSelect,
233
+ parameters: { layout: 'centered' },
234
+ args: {
235
+ data: mockData,
236
+ placeholder: '请选择表单',
237
+ },
238
+ decorators: [
239
+ (Story) => (
240
+ <div style={{ width: 320, padding: 20 }}>
241
+ <Story />
242
+ </div>
243
+ ),
244
+ ],
245
+ };
246
+
247
+ export default meta;
248
+ type Story = StoryObj<typeof meta>;
249
+
250
+ // ── 下拉模式 ──────────────────────────────────────────────────────
251
+
252
+ export const Dropdown: Story = {
253
+ name: '下拉 — 全量树',
254
+ };
255
+
256
+ export const DropdownWithCurrentApp: Story = {
257
+ name: '下拉 — 按当前应用分组',
258
+ args: { currentAppId: CURRENT_APP_ID },
259
+ };
260
+
261
+ export const DropdownSelected: Story = {
262
+ name: '下拉 — 已选中',
263
+ args: { currentAppId: CURRENT_APP_ID, defaultValue: 'form_3' },
264
+ };
265
+
266
+ export const DropdownDisabled: Story = {
267
+ name: '下拉 — 禁用',
268
+ args: { defaultValue: 'form_1', disabled: true },
269
+ };
270
+
271
+ export const DropdownEmpty: Story = {
272
+ name: '下拉 — 空数据',
273
+ args: { data: { dock_corps: [], dock_items: [], items: [] } },
274
+ };
275
+
276
+ // ── 抽屉模式 ──────────────────────────────────────────────────────
277
+
278
+ export const DrawerMode: Story = {
279
+ name: '抽屉 — 左侧滑入',
280
+ render: (args) => {
281
+ const [open, setOpen] = useState(false);
282
+ const [selected, setSelected] =
283
+ useState<TeamWideFormSelectChangeResult | null>(null);
284
+
285
+ return (
286
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
287
+ <button
288
+ type="button"
289
+ onClick={() => setOpen(true)}
290
+ style={{
291
+ height: 34,
292
+ padding: '0 12px',
293
+ border: '1px solid #E0E0E0',
294
+ borderRadius: 4,
295
+ background: '#fff',
296
+ cursor: 'pointer',
297
+ fontSize: 14,
298
+ }}
299
+ >
300
+ {selected ? selected.form.name : '切换表单'}
301
+ </button>
302
+ <TeamWideFormDrawer
303
+ data={args.data}
304
+ currentAppId={args.currentAppId}
305
+ open={open}
306
+ onOpenChange={setOpen}
307
+ value={selected?.entryId}
308
+ onChange={setSelected}
309
+ />
310
+ {selected && (
311
+ <div style={{ fontSize: 12, color: '#666', wordBreak: 'break-all' }}>
312
+ 已选择: {selected.form.name}(appId: {selected.appId}, entryId:{' '}
313
+ {selected.entryId})
314
+ </div>
315
+ )}
316
+ </div>
317
+ );
318
+ },
319
+ args: { currentAppId: CURRENT_APP_ID },
320
+ decorators: [
321
+ (Story) => (
322
+ <div style={{ padding: 20 }}>
323
+ <Story />
324
+ </div>
325
+ ),
326
+ ],
327
+ };
328
+
329
+ // ── 交互式(下拉) ────────────────────────────────────────────────
330
+
331
+ export const Interactive: Story = {
332
+ render: (args) => {
333
+ const [selected, setSelected] =
334
+ useState<TeamWideFormSelectChangeResult | null>(null);
335
+ const [useCurrentApp, setUseCurrentApp] = useState(true);
336
+
337
+ return (
338
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
339
+ <label style={{ fontSize: 13, display: 'flex', alignItems: 'center', gap: 4 }}>
340
+ <input
341
+ type="checkbox"
342
+ checked={useCurrentApp}
343
+ onChange={(e) => setUseCurrentApp(e.target.checked)}
344
+ />
345
+ 按当前应用分组展示
346
+ </label>
347
+ <TeamWideFormSelect
348
+ {...args}
349
+ currentAppId={useCurrentApp ? CURRENT_APP_ID : undefined}
350
+ value={selected?.entryId ?? ''}
351
+ onChange={setSelected}
352
+ />
353
+ <div style={{ fontSize: 12, color: '#666', wordBreak: 'break-all', maxWidth: 300 }}>
354
+ 已选择:{' '}
355
+ {selected
356
+ ? `${selected.form.name}(appId: ${selected.appId}, entryId: ${selected.entryId})`
357
+ : '无'}
358
+ </div>
359
+ </div>
360
+ );
361
+ },
362
+ };
package/style.css CHANGED
@@ -502,6 +502,9 @@
502
502
  .mt-\[4px\] {
503
503
  margin-top: 4px;
504
504
  }
505
+ .mt-\[7px\] {
506
+ margin-top: 7px;
507
+ }
505
508
  .mt-\[8px\] {
506
509
  margin-top: 8px;
507
510
  }
@@ -1857,6 +1860,9 @@
1857
1860
  .pt-\[8px\] {
1858
1861
  padding-top: 8px;
1859
1862
  }
1863
+ .pt-\[9px\] {
1864
+ padding-top: 9px;
1865
+ }
1860
1866
  .pt-\[20px\] {
1861
1867
  padding-top: 20px;
1862
1868
  }