@cloudtower/eagle 490.0.7 → 490.0.8

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.
@@ -19,6 +19,12 @@ export declare const TagSpan: import("@linaria/react").StyledComponent<import("r
19
19
  export declare const FullView: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
20
20
  export declare const NameTag: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & Record<never, unknown>>;
21
21
  export declare const FormItemDiv: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
22
+ /**
23
+ * FieldTitle 组件
24
+ * 使用场景:用于表单字段的标题展示
25
+ * 使用地方:主要在 Modal 等表单容器中使用
26
+ * 注意:默认字体大小为 12px,可通过 --field-title-font-size CSS 变量覆盖
27
+ */
22
28
  export declare const FieldTitle: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
23
29
  export declare const ExpandArrow: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLElement> & import("react").HTMLAttributes<HTMLElement> & Record<never, unknown>>;
24
30
  export declare const WarningAlert: import("@linaria/core").LinariaClassName;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { ColumnsType, ColumnType, TableProps as AntdTableProps } from "antd/lib/table";
3
3
  import { TableRowSelection, ExpandableConfig } from "antd/lib/table/interface";
4
4
  import { ITableSkeletonProps } from "./TableSkeleton";
@@ -12,39 +12,155 @@ type Columns<T> = ColumnsType<T>[0];
12
12
  export interface RequiredColumnProps<T> extends Omit<Columns<T>, "onHeaderCell" | "onCell" | "title"> {
13
13
  key: Exclude<Columns<T>["key"], undefined | number>;
14
14
  dataIndex: Exclude<ColumnType<T>["dataIndex"], undefined>;
15
+ /**
16
+ * 是否支持排序。设置为 true 时,点击表头可触发排序。
17
+ * @default false
18
+ */
15
19
  sortable?: boolean;
20
+ /**
21
+ * 列宽度。支持数字(像素)或字符串(如 "20%")。
22
+ */
16
23
  width?: number | string;
17
24
  onHeaderCell?: (column: ColumnType<T>) => any;
18
25
  onCell?: (column: T) => any;
19
26
  /**
20
- * removed params for title function
21
- * because we need to cast the function in customize column
22
- * which cannot access the header params
27
+ * 列标题。支持 React 节点或返回 React 节点的函数。
28
+ * 注意:函数形式不接收参数,与 antd 原生 title 函数签名不同。
23
29
  */
24
30
  title: React.ReactNode | (() => React.ReactNode);
31
+ /**
32
+ * 是否允许用户自定义该列。用于列配置功能。
33
+ * @default true
34
+ */
25
35
  customizable?: boolean;
26
36
  }
27
37
  export type SorterOrder = "descend" | "ascend" | undefined;
38
+ /**
39
+ * 表格组件,基于 antd Table 二次封装,提供统一的 CloudTower 表格样式。
40
+ *
41
+ * @description
42
+ * 用于展示结构化数据列表,支持排序、行选择、展开行、加载状态、错误状态等功能。
43
+ * 数据源要求每条记录包含 id 字段作为唯一标识。
44
+ *
45
+ * @example
46
+ * // 基础用法
47
+ * import { Table } from "@cloudtower/eagle";
48
+ *
49
+ * interface VMData {
50
+ * id: string;
51
+ * name: string;
52
+ * status: string;
53
+ * cpu: number;
54
+ * }
55
+ *
56
+ * const columns = [
57
+ * { key: "name", title: "名称", dataIndex: "name" },
58
+ * { key: "status", title: "状态", dataIndex: "status" },
59
+ * { key: "cpu", title: "CPU", dataIndex: "cpu" },
60
+ * ];
61
+ *
62
+ * <Table<VMData> columns={columns} dataSource={vms} />
63
+ *
64
+ * @example
65
+ * // 带行选择
66
+ * import { Table } from "@cloudtower/eagle";
67
+ * import { useState } from "react";
68
+ *
69
+ * const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
70
+ *
71
+ * <Table<VMData>
72
+ * columns={columns}
73
+ * dataSource={vms}
74
+ * rowSelection={{
75
+ * selectedRowKeys: selectedKeys,
76
+ * onChange: (keys) => setSelectedKeys(keys as string[]),
77
+ * }}
78
+ * />
79
+ *
80
+ * @example
81
+ * // 带排序和加载状态
82
+ * import { Table } from "@cloudtower/eagle";
83
+ *
84
+ * <Table<VMData>
85
+ * columns={columns}
86
+ * dataSource={vms}
87
+ * loading={isLoading}
88
+ * onSorterChange={(order, key) => {
89
+ * console.log("排序:", order, key);
90
+ * }}
91
+ * />
92
+ *
93
+ * @see TableForm - 表格表单,用于行内编辑场景
94
+ * @see SummaryTable - 摘要表格,用于键值对信息展示
95
+ * @see BatchOperation - 批量操作工具栏,配合行选择使用
96
+ */
28
97
  export interface TableProps<T extends {
29
98
  id: string;
30
99
  }> {
100
+ /**
101
+ * 是否显示边框。
102
+ * @default false
103
+ */
31
104
  bordered?: boolean;
105
+ /**
106
+ * 是否显示加载状态。为 true 时显示骨架屏加载动画。
107
+ * @default false
108
+ */
32
109
  loading?: boolean;
33
110
  /**
34
- * This means errorEl.
111
+ * 错误状态内容。传入后将覆盖 dataSource,显示错误信息而非数据。
35
112
  */
36
113
  error?: React.ReactNode | string;
114
+ /**
115
+ * 数据源数组。每条记录必须包含 id 字段作为唯一标识。
116
+ */
37
117
  dataSource: T[] | undefined;
118
+ /**
119
+ * 列配置数组。定义表格的列结构。
120
+ */
38
121
  columns: RequiredColumnProps<T>[];
122
+ /**
123
+ * 排序变化回调。当用户点击可排序列的表头时触发。
124
+ * @param order - 排序方向:"descend"(降序)、"ascend"(升序)、null(取消排序)
125
+ * @param key - 排序列的 key
126
+ */
39
127
  onSorterChange?: (order: SorterOrder | null, key?: string | number) => void;
128
+ /**
129
+ * 行点击回调。
130
+ * @deprecated 请使用 onRow 替代
131
+ * @param record - 点击行的数据记录
132
+ * @param index - 行索引
133
+ * @param evt - 鼠标事件
134
+ */
40
135
  onRowClick?: (record: T, index: number, evt: React.MouseEvent<HTMLElement, MouseEvent>) => void;
136
+ /**
137
+ * 行样式类名函数。根据行数据和索引返回自定义类名。
138
+ */
41
139
  rowClassName?: (record: T, index: number) => string;
140
+ /**
141
+ * 表格滚动配置。
142
+ * @example
143
+ * // 固定表头,内容区滚动
144
+ * scroll={{ y: 400 }}
145
+ * // 水平滚动
146
+ * scroll={{ x: 1200 }}
147
+ */
42
148
  scroll?: {
43
149
  x?: number | string | true;
44
150
  y?: number | string;
45
151
  };
152
+ /**
153
+ * 列宽调整回调。启用 resizable 后,用户拖拽调整列宽时触发。
154
+ */
46
155
  onResize?: (column: RequiredColumnProps<T>[]) => void;
156
+ /**
157
+ * 是否允许调整列宽。
158
+ * @default false
159
+ */
47
160
  resizable?: boolean;
161
+ /**
162
+ * 自定义表格组件。用于覆盖默认的 table/thead/tbody 渲染。
163
+ */
48
164
  components?: {
49
165
  table?: (props: any) => any;
50
166
  header?: {
@@ -58,25 +174,63 @@ export interface TableProps<T extends {
58
174
  cell?: (props: any) => any;
59
175
  };
60
176
  };
177
+ /**
178
+ * 行操作菜单组件。在每行末尾渲染操作按钮或菜单。
179
+ */
61
180
  RowMenu?: React.FC<{
62
181
  record: T;
63
182
  index: number;
64
183
  }>;
184
+ /**
185
+ * 行选择配置。启用后显示复选框列,支持单选或多选。
186
+ * @see https://ant.design/components/table-cn#rowSelection
187
+ */
65
188
  rowSelection?: TableRowSelection<T>;
189
+ /**
190
+ * 空数据时的显示内容。
191
+ */
66
192
  empty?: string | React.ReactNode;
193
+ /**
194
+ * 表格布局方式。
195
+ * - "fixed":固定布局,列宽由第一行决定
196
+ * - "auto":自动布局,列宽由内容决定
197
+ * @default "fixed"
198
+ */
67
199
  tableLayout?: "fixed" | "auto";
68
200
  /**
69
- * @deprecated use loading instead
201
+ * 初始化加载状态。
202
+ * @deprecated 请使用 loading 替代
70
203
  */
71
204
  initLoading?: boolean;
205
+ /**
206
+ * 行的唯一标识字段。支持字符串或函数。
207
+ * @default "id"
208
+ */
72
209
  rowKey?: AntdTableProps<T>["rowKey"];
210
+ /**
211
+ * 表格容器引用。用于获取表格尺寸信息。
212
+ */
73
213
  wrapper?: React.MutableRefObject<HTMLDivElement | null>;
214
+ /**
215
+ * 分页配置。传入后将启用前端分页,通常用于骨架屏行数计算。
216
+ */
74
217
  pagination?: {
75
218
  current: number;
76
219
  pageSize: number;
77
220
  };
221
+ /**
222
+ * 行属性配置。用于设置行事件(如 onClick、onMouseEnter 等)。
223
+ * @see https://ant.design/components/table-cn#onRow
224
+ */
78
225
  onRow?: AntdTableProps<T>["onRow"];
226
+ /**
227
+ * 骨架屏配置。自定义加载状态下的骨架屏样式。
228
+ */
79
229
  skeletonProps?: ITableSkeletonProps;
230
+ /**
231
+ * 展开行配置。用于渲染可展开的行内容。
232
+ * @see https://ant.design/components/table-cn#expandable
233
+ */
80
234
  expandable?: ExpandableConfig<T>;
81
235
  }
82
236
  export {};
@@ -1,77 +1,66 @@
1
+ import React from "react";
1
2
  import { Table } from "../../../src/core";
2
3
  import { StoryObj } from "@storybook/react";
3
- import React from "react";
4
4
  declare const meta: {
5
5
  component: <T extends {
6
6
  id: string;
7
7
  }>(props: import("../../../src/core").TableProps<T>) => React.JSX.Element;
8
8
  title: "Core/Table | 表格组件";
9
+ parameters: {
10
+ docs: {
11
+ description: {
12
+ component: string;
13
+ };
14
+ };
15
+ };
9
16
  };
10
17
  export default meta;
11
18
  type Story = StoryObj<typeof Table>;
12
19
  /**
13
- * loading error 不存在的情况下
14
- *
15
- * 显示表格数据
20
+ * 基础表格展示,仅配置 columns dataSource。
16
21
  */
17
- export declare const ShowData: Story;
22
+ export declare const Basic: Story;
18
23
  /**
19
- * 自定义骨架屏表头,表身高度
24
+ * 带排序功能的表格,点击表头触发排序回调。
20
25
  */
21
- export declare const CustomHeight: Story;
26
+ export declare const WithSorter: Story;
22
27
  /**
23
- * 初始化 loading
28
+ * 带行选择的表格,支持多选和全选。
24
29
  */
25
- export declare const InitLoading: Story;
30
+ export declare const WithRowSelection: Story;
26
31
  /**
27
- * 使用分页作为骨架数量 loading
32
+ * 带行操作菜单的表格,在每行末尾渲染操作按钮。
28
33
  */
29
- export declare const LoadingSkeletonWithPageSize: Story;
34
+ export declare const WithRowMenu: Story;
30
35
  /**
31
- * 在 loading error dataSource 存在值的情况下
32
- *
33
- * 显示 loading
36
+ * 加载状态,显示骨架屏动画。
34
37
  */
35
- export declare const ShowLoadingWithDataAndError: Story;
38
+ export declare const Loading: Story;
36
39
  /**
37
- * 在 error dataSource 存在值的情况下
38
- *
39
- * 显示 error
40
+ * 自定义骨架屏配置,可调整行数、表头高度、行高度。
40
41
  */
41
- export declare const ShowError: Story;
42
+ export declare const CustomSkeleton: Story;
42
43
  /**
43
- * 在 loading dataSource 存在值的情况下
44
- *
45
- * 显示 loading
44
+ * 错误状态,显示错误信息替代数据。
46
45
  */
47
- export declare const ShowLoadingWithData: Story;
46
+ export declare const ErrorState: Story;
48
47
  /**
49
- * 在 error loading dataSource 不存在值的情况下
50
- *
51
- * 显示空表格
48
+ * 空数据状态,显示空状态提示。
52
49
  */
53
- export declare const ShowEmpty: Story;
50
+ export declare const Empty: Story;
54
51
  /**
55
- * 仅存在 loading 的情况
56
- *
57
- * 显示 Loading
52
+ * 固定表头,内容区滚动。
58
53
  */
59
- export declare const ShowLoadingWithEmpty: Story;
54
+ export declare const FixedHeader: Story;
60
55
  /**
61
- * 在 error false 的情况
62
- *
63
- * 显示 data
56
+ * 可展开行,点击展开显示详细信息。
64
57
  */
65
- export declare const ErrorFalse: Story;
58
+ export declare const Expandable: Story;
66
59
  /**
67
- * error loading dataSource 不存在值的情况下
68
- *
69
- * 固定表头显示空表格
60
+ * 使用 onRow 设置行事件。
70
61
  */
71
- export declare const ShowEmptyForFixd: Story;
62
+ export declare const WithOnRow: Story;
72
63
  /**
73
- * loading error 不存在的情况下
74
- *
75
- * 显示表格数据,表格可以展开
64
+ * @deprecated 请使用 loading 替代
76
65
  */
77
- export declare const ShowCanExpandData: Story;
66
+ export declare const InitLoading: Story;