@cloudtower/eagle 490.0.5 → 490.0.6

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.
Files changed (54) hide show
  1. package/README.md +34 -0
  2. package/dist/cjs/core/Cascader/cascader.widget.js +12 -12
  3. package/dist/cjs/core/SearchInput/SearchInput.hook.js +124 -0
  4. package/dist/cjs/core/SearchInput/SearchInput.js +253 -0
  5. package/dist/cjs/core/SearchInput/SearchInput.style.js +13 -0
  6. package/dist/cjs/core/index.js +6 -6
  7. package/dist/cjs/index.js +172 -172
  8. package/dist/cjs/legacy-antd.js +89 -89
  9. package/dist/cjs/stats1.html +1 -1
  10. package/dist/components.css +3304 -3281
  11. package/dist/esm/core/Cascader/cascader.widget.js +1 -1
  12. package/dist/esm/core/SearchInput/SearchInput.hook.js +117 -0
  13. package/dist/esm/core/SearchInput/SearchInput.js +247 -0
  14. package/dist/esm/core/SearchInput/SearchInput.style.js +7 -0
  15. package/dist/esm/index.js +1 -1
  16. package/dist/esm/legacy-antd.js +1 -1
  17. package/dist/esm/stats1.html +1 -1
  18. package/dist/linaria.merged.scss +4417 -4388
  19. package/dist/src/core/Cascader/cascader.type.d.ts +1 -1
  20. package/dist/src/core/ImmersiveDialog/type.d.ts +127 -19
  21. package/dist/src/core/MediumDialog/MediumDialog.type.d.ts +49 -1
  22. package/dist/src/core/SearchInput/SearchInput.d.ts +2 -0
  23. package/dist/src/core/SearchInput/SearchInput.hook.d.ts +9 -0
  24. package/dist/src/core/SearchInput/SearchInput.style.d.ts +5 -0
  25. package/dist/src/core/SearchInput/{searchInput.type.d.ts → SearchInput.type.d.ts} +18 -2
  26. package/dist/src/core/SearchInput/__test__/SearchInput.hook.test.d.ts +1 -0
  27. package/dist/src/core/SearchInput/index.d.ts +2 -4
  28. package/dist/src/core/SmallDialog/SmallDialog.type.d.ts +150 -21
  29. package/dist/src/core/TableForm/types.d.ts +216 -68
  30. package/dist/src/core/WizardDialog/type.d.ts +147 -13
  31. package/dist/src/core/index.d.ts +0 -1
  32. package/dist/src/coreX/Dialogs/DeleteDialog/DeleteDialog.type.d.ts +100 -9
  33. package/dist/src/coreX/Dialogs/RejectDialog/RejectDialog.type.d.ts +126 -19
  34. package/dist/stories/docs/core/ImmersiveDialog.stories.d.ts +76 -8
  35. package/dist/stories/docs/core/MediumDialog.stories.d.ts +42 -8
  36. package/dist/stories/docs/core/SearchInput.stories.d.ts +6 -1
  37. package/dist/stories/docs/core/SmallDialog.stories.d.ts +86 -7
  38. package/dist/stories/docs/core/TableForm.stories.d.ts +40 -26
  39. package/dist/stories/docs/core/WizardDialog.stories.d.ts +65 -6
  40. package/dist/stories/docs/coreX/Dialogs/DeleteDialog.stories.d.ts +20 -19
  41. package/dist/stories/docs/coreX/Dialogs/RejectDialog.stories.d.ts +24 -23
  42. package/dist/style.css +3304 -3281
  43. package/docs/core/ImmersiveDialog/guide.md +298 -0
  44. package/docs/core/LegacyModal/migrate-guide.md +422 -0
  45. package/docs/core/MediumDialog/guide.md +263 -0
  46. package/docs/core/SmallDialog/guide.md +224 -0
  47. package/docs/core/TableForm/guide.md +195 -0
  48. package/docs/core/WizardDialog/guide.md +322 -0
  49. package/docs/coreX/DeleteDialog/guide.md +161 -0
  50. package/docs/coreX/RejectDialog/guide.md +185 -0
  51. package/docs/llms.txt +169 -0
  52. package/package.json +6 -5
  53. package/dist/cjs/core/SearchInput/index.js +0 -164
  54. package/dist/esm/core/SearchInput/index.js +0 -157
@@ -1,86 +1,122 @@
1
1
  /// <reference types="react" />
2
2
  import { ColumnBodyImpls } from "../../core/TableForm/Columns";
3
3
  import { ButtonProps } from "../Button";
4
+ /** 单元格错误信息,key 为列标识 */
4
5
  export type ErrorInfo = Record<string, {
5
6
  errorMessage: string;
6
7
  isError: boolean;
7
8
  }>;
9
+ /**
10
+ * 表单校验触发模式
11
+ */
8
12
  export declare enum ValidateTriggerType {
13
+ /** 标准模式:首次 blur 后触发校验,之后每次 change 也触发 */
9
14
  Normal = 0,
15
+ /** 激进模式:每次 change 都触发校验 */
10
16
  Aggressive = 1,
17
+ /** 惰性模式:仅 blur 时触发校验 */
11
18
  Lazy = 2
12
19
  }
20
+ /**
21
+ * 自定义列渲染函数的参数
22
+ */
13
23
  export type CustomizedColumnRenderProps = {
24
+ /** 当前单元格的值 */
14
25
  value?: any;
26
+ /** 当前行索引(header 行时为 undefined) */
15
27
  rowIndex?: number;
28
+ /** 值变更回调 */
16
29
  onChange: (value: any) => void;
30
+ /** 是否禁用 */
17
31
  disabled?: boolean;
32
+ /** 失焦回调 */
18
33
  onBlur?: () => void;
34
+ /** 占位文本 */
19
35
  placeholder?: string;
36
+ /** 是否为表头行(批量填充行) */
20
37
  isHeader: boolean;
38
+ /** 是否处于错误状态 */
21
39
  error?: boolean;
40
+ /** 当前行的完整数据 */
22
41
  formValue: any;
23
42
  };
43
+ /**
44
+ * TableForm 列配置。
45
+ * 每列可选择内置类型(text/input/password/checkbox/affix)或通过 render 自定义渲染。
46
+ */
24
47
  export type TableFormColumn = {
25
48
  /**
26
- * 列类型,指定后会使用 ColumnBodyImpls 枚举渲染单元格,否则使用 render 函数渲染
27
- * @enum {number}
49
+ * 列类型,使用内置列组件渲染单元格
50
+ * - "text": 只读文本展示
51
+ * - "input": 文本输入框
52
+ * - "password": 密码输入框(可切换显示/隐藏)
53
+ * - "checkbox": 复选框
54
+ * - "affix": 带前缀/后缀的输入框
55
+ *
56
+ * 不指定 type 时需提供 render 函数自定义渲染。
28
57
  */
29
58
  type?: keyof typeof ColumnBodyImpls;
30
- /**
31
- * 列标题
32
- */
59
+ /** 列标题,显示在表头 */
33
60
  title?: string | React.ReactNode;
34
- /**
35
- * 列唯一标识
36
- */
61
+ /** 列唯一标识,同时作为行数据对象的 key */
37
62
  key: string;
38
63
  /**
39
- * 列副标题,只在 `disableBatchFilling``false`,且 `type`'text' 时生效
64
+ * 列副标题。仅当 disableBatchFilling 为 false type 为 "text" 时显示。
65
+ * 若需要在任何情况下显示副标题,请使用 subTitleRender。
40
66
  */
41
67
  subTitle?: string;
42
68
  /**
43
69
  * 列副标题颜色
70
+ * - "": 默认颜色
71
+ * - "primary": 主色
72
+ * - "success": 成功色
73
+ * - "warning": 警告色
74
+ * - "danger": 危险色
44
75
  */
45
76
  subTitleColor?: "" | "primary" | "success" | "warning" | "danger";
46
77
  /**
47
- * 列副标题渲染函数,优先级高于 `subTitle`,即使 `disableBatchFilling``true` 也会生效
78
+ * 列副标题自定义渲染函数。优先级高于 subTitle,即使 disableBatchFilling 为 true 也会生效。
48
79
  */
49
80
  subTitleRender?: (props: CustomizedColumnRenderProps) => React.ReactNode;
50
- /**
51
- * 列单元格图标
52
- */
81
+ /** 列单元格图标 */
53
82
  bodyIcon?: any;
54
- /**
55
- * 列单元格错误图标
56
- */
83
+ /** 列单元格错误状态图标 */
57
84
  bodyErrorIcon?: any;
58
- /**
59
- * 列宽度
60
- */
85
+ /** 列宽度 */
61
86
  width?: number | string;
87
+ /** 覆盖单元格显示文本(仅 text 类型) */
62
88
  displayText?: string;
89
+ /** 单元格默认值,新增行时使用 */
63
90
  defaultValue?: any;
91
+ /** 是否隐藏该列 */
64
92
  hidden?: boolean;
93
+ /** 输入框占位文本 */
65
94
  placeholder?: string;
95
+ /**
96
+ * 批量填充时是否自动递增末尾数字。
97
+ * 例如输入 "host0",各行会自动填充为 "host0"、"host1"、"host2"...
98
+ */
66
99
  autoIncrease?: boolean;
100
+ /** 禁用 affix 类型的前缀输入(仅 type="affix" 时生效) */
67
101
  disablePrefix?: boolean;
102
+ /** 禁用 affix 类型的后缀输入(仅 type="affix" 时生效) */
68
103
  disableSuffix?: boolean;
104
+ /** 自定义数据,透传给列渲染组件 */
69
105
  customData?: any;
70
106
  /**
71
107
  * 列对齐方式
108
+ * @default "left"
72
109
  */
73
110
  align?: "left" | "right" | "center";
74
- /**
75
- * 列行描述渲染函数
76
- */
111
+ /** 列行描述渲染函数,在单元格下方渲染额外说明 */
77
112
  renderDescription?: (props: RenderRowDescriptionProps) => React.ReactNode;
78
113
  /**
79
- * 列单元格渲染函数
114
+ * 自定义单元格渲染函数。不指定 type 时必须提供此函数。
115
+ * 即使指定了 type,render 也会覆盖内置渲染。
80
116
  */
81
117
  render?: (props: CustomizedColumnRenderProps) => React.ReactNode;
82
118
  /**
83
- * 列验证函数
119
+ * 列级别校验函数。返回错误信息字符串表示校验失败,返回 undefined 表示通过。
84
120
  */
85
121
  validator?: (params: {
86
122
  value: any;
@@ -99,6 +135,7 @@ export interface ColumnHeaderCellProps {
99
135
  onBlur?: (key: string, error?: string) => void;
100
136
  onVisibleChange?: (visible: boolean) => void;
101
137
  }
138
+ /** 行数据类型,key 为列标识,value 为单元格值 */
102
139
  export type DataType = {
103
140
  [columnKey: string]: any;
104
141
  };
@@ -120,20 +157,36 @@ export interface ColumnBodyCellProps {
120
157
  error?: string | null;
121
158
  onValidate?: (id: string, isValid: boolean) => void;
122
159
  }
160
+ /** 添加行按钮的 Props */
123
161
  export type AddRowButtonProps = {
162
+ /** 行添加配置 */
124
163
  config: RowAddConfigurations;
164
+ /** 自定义样式 */
125
165
  style?: React.CSSProperties;
166
+ /** 列配置,用于生成空行默认值 */
126
167
  columns: TableFormColumn[];
168
+ /** 添加行回调 */
127
169
  addData: (data: DataType[]) => void;
170
+ /** 当前表格数据 */
128
171
  data: DataType[];
129
172
  };
173
+ /**
174
+ * 行添加配置
175
+ */
130
176
  export type RowAddConfigurations = {
177
+ /** 是否允许添加行 */
131
178
  addible: boolean;
179
+ /** 添加按钮文案,支持字符串或返回 ReactNode 的函数 */
132
180
  text?: (() => React.ReactNode) | string;
181
+ /** 添加按钮的额外属性 */
133
182
  buttonProps?: ButtonProps;
183
+ /** 最大行数限制,达到上限后添加按钮禁用 */
134
184
  maximum?: number;
185
+ /** 添加按钮区域的自定义类名 */
135
186
  className?: string;
187
+ /** 添加按钮右侧的额外操作区域 */
136
188
  extraAction?: React.ReactNode;
189
+ /** 完全自定义添加按钮组件 */
137
190
  CustomizedButton?: (props: AddRowButtonProps) => React.ReactElement;
138
191
  };
139
192
  export interface TableFormRowsProps extends Pick<TableFormProps, "columns" | "disabled" | "deleteConfig" | "disableBatchFilling" | "validateTriggerType" | "renderRowDescription" | "rowValidator" | "onBodyBlur" | "row" | "errors"> {
@@ -146,123 +199,218 @@ export interface TableFormRowsProps extends Pick<TableFormProps, "columns" | "di
146
199
  rowSplitType?: TableFormRowSplitType;
147
200
  onValidate?: (id: string, isValid: boolean) => void;
148
201
  }
202
+ /** 行描述渲染函数的参数 */
149
203
  export type RenderRowDescriptionProps = {
204
+ /** 当前行索引 */
150
205
  rowIndex: number;
206
+ /** 当前行数据 */
151
207
  rowData: DataType;
208
+ /** 表头批量填充的最新值 */
152
209
  latestData?: DataType[];
153
210
  };
211
+ /**
212
+ * @deprecated 请使用 TableFormRowConfiguration 的 deletable + disableActions 替代
213
+ */
154
214
  export type DeletableConfigurations = {
155
215
  deletable: boolean;
156
216
  specifyRowDeleteDisabled?: (rowIndex: number, allData: DataType[]) => boolean;
157
217
  };
218
+ /** 行操作类型 */
158
219
  export type TableFormRowActions = "delete";
220
+ /** 行分隔样式类型 */
159
221
  export type TableFormRowSplitType = "border" | "zebraMarking";
222
+ /**
223
+ * 表格行配置。统一管理行级别的交互行为,替代已废弃的 draggable/deleteConfig/rowSplitType/renderRowDescription/rowValidator。
224
+ */
160
225
  export type TableFormRowConfiguration = {
226
+ /**
227
+ * 行分隔样式
228
+ * - "border": 边框分隔(默认)
229
+ * - "zebraMarking": 斑马纹分隔
230
+ */
161
231
  splitType?: TableFormRowSplitType;
232
+ /** 是否允许拖拽排序 */
162
233
  draggable?: boolean;
234
+ /**
235
+ * 是否允许删除行。传 boolean 控制全部行,传函数可按行索引动态控制。
236
+ */
163
237
  deletable?: boolean | ((rowIndex: number, allData: DataType[]) => boolean);
238
+ /** 行描述文本数组,按索引对应每一行 */
164
239
  descriptions?: (string | React.ReactNode)[];
240
+ /**
241
+ * 禁用指定行操作。传数组禁用所有行的指定操作,传函数可按行索引动态控制。
242
+ */
165
243
  disableActions?: TableFormRowActions[] | ((rowIndex: number, allData: DataType[]) => TableFormRowActions[] | undefined);
244
+ /** 行级别校验函数。返回错误信息字符串表示校验失败,返回 undefined 表示通过。 */
166
245
  validator?: (rowIndex: number, rowData: DataType) => string | undefined;
246
+ /** 自定义行描述渲染函数,按行返回描述内容 */
167
247
  customizedDescription?: (props: RenderRowDescriptionProps) => React.ReactNode | string;
168
248
  };
249
+ /**
250
+ * 表格错误信息数组,按行索引对应。
251
+ * 每项可以是:
252
+ * - string: 行级别错误信息
253
+ * - { [columnKey]: string | null }: 单元格级别错误信息
254
+ * - null: 该行无错误
255
+ */
169
256
  export type TableFormErrorsType = (string | {
170
257
  [columnKey: string]: string | null;
171
258
  } | null)[];
259
+ /**
260
+ * TableForm 是行内编辑的表格表单组件,适用于批量数据录入场景。
261
+ * 支持多种列类型(文本/输入/密码/复选框/前后缀/自定义)、表头批量填充、
262
+ * 行的增删和拖拽排序、三种校验模式、以及外部错误信息注入。
263
+ *
264
+ * @example
265
+ * ```tsx
266
+ * import React, { useRef } from "react";
267
+ * import { TableForm } from "@cloudtower/eagle";
268
+ * import type { TableFormColumn, TableFormHandle } from "@cloudtower/eagle";
269
+ *
270
+ * const columns: TableFormColumn[] = [
271
+ * { key: "name", title: "主机名", type: "input", autoIncrease: true },
272
+ * { key: "ip", title: "管理 IP", type: "input",
273
+ * validator: ({ value }) => !value ? "IP 不能为空" : undefined },
274
+ * { key: "password", title: "密码", type: "password" },
275
+ * ];
276
+ *
277
+ * const App = () => {
278
+ * const ref = useRef<TableFormHandle>(null);
279
+ * return (
280
+ * <TableForm
281
+ * ref={ref}
282
+ * columns={columns}
283
+ * defaultData={[{ name: "host0", ip: "", password: "" }]}
284
+ * rowAddConfig={{ addible: true, maximum: 10 }}
285
+ * row={{ deletable: true, draggable: true }}
286
+ * onBodyChange={(data) => console.log("数据变更:", data)}
287
+ * />
288
+ * );
289
+ * };
290
+ * ```
291
+ *
292
+ * @example
293
+ * ```tsx
294
+ * // 自定义列渲染
295
+ * import React from "react";
296
+ * import { TableForm, Select } from "@cloudtower/eagle";
297
+ * import type { TableFormColumn } from "@cloudtower/eagle";
298
+ *
299
+ * const columns: TableFormColumn[] = [
300
+ * { key: "name", title: "名称", type: "input" },
301
+ * {
302
+ * key: "role",
303
+ * title: "角色",
304
+ * defaultValue: "worker",
305
+ * render({ isHeader, value, onChange, placeholder, ...rest }) {
306
+ * return (
307
+ * <Select
308
+ * size="small"
309
+ * value={value}
310
+ * onChange={onChange}
311
+ * placeholder={isHeader ? "批量选择" : "请选择"}
312
+ * options={[
313
+ * { label: "Master", value: "master" },
314
+ * { label: "Worker", value: "worker" },
315
+ * ]}
316
+ * />
317
+ * );
318
+ * },
319
+ * },
320
+ * ];
321
+ * ```
322
+ *
323
+ * @see Form 标准表单容器,适用于非表格化的表单场景
324
+ * @see SortableList 可拖拽排序列表,适用于纯排序(无编辑)场景
325
+ */
172
326
  export type TableFormProps = {
173
- /**
174
- * 表格默认数据
175
- */
327
+ /** 表格初始数据,每项为一行数据对象,key 对应列的 key */
176
328
  defaultData?: DataType[];
177
- /**
178
- * 表格列配置
179
- */
329
+ /** 表格列配置数组 */
180
330
  columns: TableFormColumn[];
181
331
  /**
182
- * 表格是否禁用单元格默认控件
332
+ * 是否禁用所有单元格的默认控件(输入框、复选框等)
333
+ * @default false
183
334
  */
184
335
  disabled?: boolean;
185
- /**
186
- * 表格行添加配置
187
- */
336
+ /** 行添加配置,包含添加按钮文案、最大行数等 */
188
337
  rowAddConfig?: RowAddConfigurations;
189
338
  /**
190
- * @deprecated use "row" configuration instead
339
+ * @deprecated 请使用 row 配置的 deletable + disableActions 替代
191
340
  */
192
341
  deleteConfig?: DeletableConfigurations;
193
342
  /**
194
343
  * 表格大小
344
+ * @default "default"
195
345
  */
196
346
  size?: "default" | "large" | "small";
197
347
  /**
198
- * @deprecated use "row" configuration instead
348
+ * @deprecated 请使用 row.draggable 替代
199
349
  */
200
350
  draggable?: boolean;
201
351
  /**
202
- * 表格是否禁用批量填充
352
+ * 是否禁用表头批量填充功能。禁用后表头只显示标题,不显示输入控件。
353
+ * @default false
203
354
  */
204
355
  disableBatchFilling?: boolean;
205
- /**
206
- * 表格类名
207
- */
356
+ /** 自定义类名 */
208
357
  className?: string;
209
358
  /**
210
- * @deprecated use "row" configuration instead
359
+ * @deprecated 请使用 row.splitType 替代
211
360
  */
212
361
  rowSplitType?: TableFormRowSplitType;
213
362
  /**
214
- * 表格验证触发类型,使用 ValidateTriggerType 枚举
215
- * @enum {number}
363
+ * 校验触发模式
364
+ * - Normal: 首次 blur 后触发,之后每次 change 也触发
365
+ * - Aggressive: 每次 change 都触发
366
+ * - Lazy: 仅 blur 时触发
367
+ * @default ValidateTriggerType.Normal
216
368
  */
217
369
  validateTriggerType?: ValidateTriggerType;
218
- /**
219
- * 表格最大高度
220
- */
370
+ /** 表格最大高度,超出后出现滚动条 */
221
371
  maxHeight?: number | string;
222
- /**
223
- * 表格行配置
224
- */
372
+ /** 表格行配置,统一管理拖拽、删除、分隔样式、行描述、行校验等 */
225
373
  row?: TableFormRowConfiguration;
226
374
  /**
227
- * 表格行错误信息
375
+ * 外部注入的错误信息数组,按行索引对应。
376
+ * 支持行级别(字符串)和单元格级别(对象)两种格式。
228
377
  */
229
378
  errors?: TableFormErrorsType;
230
379
  /**
231
- * @deprecated use "row" configuration instead
380
+ * @deprecated 请使用 row.customizedDescription 替代
232
381
  */
233
382
  renderRowDescription?: (props: RenderRowDescriptionProps) => React.ReactNode;
234
383
  /**
235
- * @deprecated use "row" configuration instead
384
+ * @deprecated 请使用 row.validator 替代
236
385
  */
237
386
  rowValidator?: (rowIndex: number, rowData: DataType) => string | undefined;
238
- /**
239
- * 表格头部数据变化的回调
240
- */
387
+ /** 表头批量填充值变更回调 */
241
388
  onHeaderChange?: (data: any[], columnKey: string) => void;
242
- /**
243
- * 表格头部数据失去焦点时的回调
244
- */
389
+ /** 表头批量填充输入框失焦回调 */
245
390
  onHeaderBlur?: (data: any[], columnKey: string) => void;
246
- /**
247
- * 表格行数据变化的回调
248
- */
391
+ /** 行数据变更回调。data 为完整表格数据,rowIndex 和 columnKey 标识变更位置。 */
249
392
  onBodyChange?: (value: DataType[], rowIndex?: number, columnKey?: string) => void;
250
- /**
251
- * 表格行数据添加的回调
252
- */
393
+ /** 新增行回调。value 为新增后的完整数据,rowIndex 为新行索引。 */
253
394
  onBodyAdd?: (value: DataType[], rowIndex: number) => void;
254
- /**
255
- * 表格行数据失去焦点时的回调
256
- */
395
+ /** 行数据失焦回调 */
257
396
  onBodyBlur?: (value: DataType, rowIndex?: number, columnKey?: string) => void;
258
397
  /**
259
- * 是否隐藏空表格
398
+ * 是否在无数据时隐藏表格(仅显示添加按钮)
399
+ * @default false
260
400
  */
261
401
  hideEmptyTable?: boolean;
262
402
  };
403
+ /**
404
+ * TableForm 的 ref handle,通过 useRef<TableFormHandle> 获取。
405
+ * 提供命令式操作表格数据和校验的方法。
406
+ */
263
407
  export type TableFormHandle = {
408
+ /** 设置表格数据并触发 onBodyChange 回调 */
264
409
  setData: (data: DataType[]) => void;
410
+ /** 设置表格数据但不触发 onBodyChange 回调(静默更新) */
265
411
  setDataWithoutTriggerChange: (data: DataType[]) => void;
412
+ /** 触发全表校验(所有行、所有列) */
266
413
  validateWholeFields: () => void;
414
+ /** 返回当前表格是否全部校验通过 */
267
415
  isValid: () => boolean;
268
416
  };
@@ -1,31 +1,165 @@
1
1
  /// <reference types="react" />
2
2
  import { ImmersiveDialogProps } from "../../core/ImmersiveDialog/type";
3
+ /**
4
+ * 基于 ImmersiveDialog 的多步骤向导对话框。
5
+ *
6
+ * @description
7
+ * 自动管理步骤导航、步骤指示器和按钮文案切换。
8
+ * 非最后一步时,确定按钮显示"下一步"并触发 `onNextStep`;
9
+ * 最后一步时显示"确定"并触发 `onOk`。左侧面板默认渲染垂直步骤条。
10
+ * 通过 `usePushModal` 打开。
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * // 基础三步向导——创建集群
15
+ * import { WizardDialog } from "@cloudtower/eagle";
16
+ * import { usePushModal } from "@cloudtower/eagle/KitStoreProvider";
17
+ *
18
+ * const pushModal = usePushModal();
19
+ *
20
+ * pushModal({
21
+ * component: () => (
22
+ * <WizardDialog
23
+ * title="创建集群"
24
+ * steps={[
25
+ * { title: "基本信息", children: <ClusterBasicForm /> },
26
+ * { title: "网络配置", children: <ClusterNetworkForm /> },
27
+ * { title: "确认创建", children: <ClusterConfirmPanel /> },
28
+ * ]}
29
+ * onOk={(e) => handleCreate()}
30
+ * />
31
+ * ),
32
+ * props: { name: "CreateClusterWizard" },
33
+ * });
34
+ * ```
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * // 带步骤校验的向导——onNextStep 返回 false 阻止导航
39
+ * <WizardDialog
40
+ * title="创建虚拟机"
41
+ * steps={steps}
42
+ * onNextStep={(nextStep) => {
43
+ * if (!validateCurrentStep()) {
44
+ * message.error("请完善当前步骤的必填项");
45
+ * return false; // 阻止跳转到下一步
46
+ * }
47
+ * }}
48
+ * onOk={(e) => handleSubmit()}
49
+ * />
50
+ * ```
51
+ *
52
+ * 注意以下继承属性在 WizardDialog 中有特殊行为:
53
+ * - `footerLeftAction`:WizardDialog 内部使用此属性渲染"上一步"按钮,外部传入会被覆盖。
54
+ * - `isContentFull`:WizardDialog 内部强制设为 `false`,外部传入无效。
55
+ *
56
+ * @see ImmersiveDialog 基础全屏对话框组件
57
+ * @see Steps 步骤条组件
58
+ */
3
59
  export type WizardDialogProps = ImmersiveDialogProps & {
4
- /** 当前步骤 */
60
+ /**
61
+ * 当前步骤索引(从 0 开始)。
62
+ *
63
+ * @description
64
+ * 传入此属性时进入受控模式,步骤切换完全由外部状态驱动;
65
+ * 不传时为非受控模式,组件内部自动管理当前步骤。
66
+ *
67
+ * @default 0
68
+ */
5
69
  step?: number;
6
- /** 步骤配置数组 */
70
+ /**
71
+ * 步骤配置数组,每项定义一个向导步骤。
72
+ *
73
+ * @description
74
+ * 每个步骤包含 `title`(显示在左侧步骤条中的标题)和
75
+ * `children`(该步骤的主体内容,通常为表单或信息面板)。
76
+ * 步骤数量决定导航行为:非最后一步点击确定按钮触发 `onNextStep`,
77
+ * 最后一步触发 `onOk`。
78
+ */
7
79
  steps?: {
8
- /** 步骤标题 */
80
+ /** 步骤标题,显示在左侧垂直步骤条中 */
9
81
  title: string;
10
- /** 步骤内容渲染 */
82
+ /** 步骤内容,通常为表单或信息展示面板 */
11
83
  children: React.ReactNode;
12
84
  }[];
13
- /** 是否隐藏步骤 */
85
+ /**
86
+ * 是否隐藏左侧步骤指示器。
87
+ *
88
+ * @description
89
+ * 设为 `true` 时不渲染默认的垂直步骤条。
90
+ * 可配合 `left` 属性放置自定义的步骤指示器或其他导航内容。
91
+ *
92
+ * @default false
93
+ */
14
94
  hideSteps?: boolean;
15
- /** 左侧自定义内容 */
95
+ /**
96
+ * 左侧面板自定义内容。
97
+ *
98
+ * @description
99
+ * 传入后将替换默认的步骤指示器。常用于自定义步骤导航样式。
100
+ */
16
101
  left?: React.ReactNode;
17
- /** 右侧自定义内容 */
102
+ /**
103
+ * 右侧面板自定义内容。
104
+ *
105
+ * @description
106
+ * 渲染在主内容区域右侧的额外面板。
107
+ */
18
108
  right?: React.ReactNode;
19
- /** 是否销毁其他步骤内容 */
109
+ /**
110
+ * 是否销毁非当前步骤的内容。
111
+ *
112
+ * @description
113
+ * - `true`:仅渲染当前步骤,切换时销毁前一步骤的 DOM,节省内存。
114
+ * - `false`:所有步骤始终保留在 DOM 中,通过 `display: none` 隐藏非当前步骤。
115
+ * 适用于需要保留表单状态的场景(如用户在步骤间来回切换时不丢失已填写的数据)。
116
+ *
117
+ * @default false
118
+ */
20
119
  destroyOtherStep?: boolean;
21
- /** 上一步的文本 */
120
+ /**
121
+ * "上一步"按钮的自定义文本。
122
+ *
123
+ * @default t("common.prev_step")(i18n:上一步 / Previous)
124
+ */
22
125
  prevText?: string;
23
- /** 上一步的回调 */
126
+ /**
127
+ * 点击"上一步"按钮时的回调。
128
+ *
129
+ * @param step - 即将跳转到的步骤索引(当前步骤 - 1)
130
+ */
24
131
  onPrevStep?: (step: number) => void;
25
- /** 下一步的文本 */
132
+ /**
133
+ * "下一步"按钮的自定义文本。
134
+ *
135
+ * @description
136
+ * 仅在非最后一步时显示,替换确定按钮的默认"下一步"文案。
137
+ *
138
+ * @default t("common.next_step")(i18n:下一步 / Next)
139
+ */
26
140
  nextText?: string;
27
- /** 下一步的回调 */
141
+ /**
142
+ * 点击"下一步"时的回调,支持阻止导航。
143
+ *
144
+ * @description
145
+ * 在非最后一步点击确定按钮时触发。这是实现步骤校验的核心机制:
146
+ * - 返回 `false` 将**阻止**导航到下一步(可用于表单校验失败时阻止前进)。
147
+ * - 返回 `void`(不返回值)或返回非 `false` 值时正常跳转到下一步。
148
+ *
149
+ * 注意:仅严格等于 `false`(`=== false`)时才阻止,返回 `undefined` 或其他假值不会阻止。
150
+ *
151
+ * @param step - 即将跳转到的步骤索引(当前步骤 + 1)
152
+ * @returns 返回 `false` 阻止导航,返回 `void` 允许导航
153
+ */
28
154
  onNextStep?: (step: number) => void | boolean;
29
- /** 步骤改变时的回调 */
155
+ /**
156
+ * 步骤发生变化时的回调。
157
+ *
158
+ * @description
159
+ * 无论是通过"上一步"、"下一步"按钮,还是点击左侧步骤条直接跳转,
160
+ * 步骤变化后都会触发此回调。适合用于同步外部状态或埋点。
161
+ *
162
+ * @param step - 变化后的新步骤索引
163
+ */
30
164
  onStepChange?: (step: number) => void;
31
165
  };
@@ -162,7 +162,6 @@ export { default as Overflow } from "./Overflow";
162
162
  export { default as Pagination } from "./Pagination";
163
163
  export { default as Percent } from "./Percent";
164
164
  export { default as Radio } from "./Radio";
165
- export { default as SearchInput } from "./SearchInput";
166
165
  export { default as Second } from "./Second";
167
166
  export { default as SegmentControl } from "./SegmentControl";
168
167
  export { default as Select } from "./Select";