@hi-ui/table 4.0.0-beta.45 → 4.0.0-beta.46

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.
@@ -132,11 +132,11 @@ var FilterDropdown = function FilterDropdown(_ref3) {
132
132
  var _useUncontrolledToggl = useToggle.useUncontrolledToggle({
133
133
  onOpen: function onOpen() {
134
134
  _onOpen === null || _onOpen === void 0 ? void 0 : _onOpen();
135
- onFilterDropdownVisibleChange === null || onFilterDropdownVisibleChange === void 0 ? void 0 : onFilterDropdownVisibleChange(true, column);
135
+ onFilterDropdownVisibleChange === null || onFilterDropdownVisibleChange === void 0 ? void 0 : onFilterDropdownVisibleChange(true, column.raw);
136
136
  },
137
137
  onClose: function onClose() {
138
138
  _onClose === null || _onClose === void 0 ? void 0 : _onClose();
139
- onFilterDropdownVisibleChange === null || onFilterDropdownVisibleChange === void 0 ? void 0 : onFilterDropdownVisibleChange(false, column);
139
+ onFilterDropdownVisibleChange === null || onFilterDropdownVisibleChange === void 0 ? void 0 : onFilterDropdownVisibleChange(false, column.raw);
140
140
  }
141
141
  }),
142
142
  menuVisible = _useUncontrolledToggl[0],
@@ -163,7 +163,7 @@ var FilterDropdown = function FilterDropdown(_ref3) {
163
163
  width: filterDropdownWidth
164
164
  }
165
165
  }, typeAssertion.isFunction(filterDropdown) ? filterDropdown({
166
- columnData: column,
166
+ columnData: column.raw,
167
167
  setFilterDropdownVisible: menuVisibleAction.set
168
168
  }) : null)));
169
169
  };
@@ -104,11 +104,11 @@ var FilterDropdown = function FilterDropdown(_ref3) {
104
104
  var _useUncontrolledToggl = useUncontrolledToggle({
105
105
  onOpen: function onOpen() {
106
106
  _onOpen === null || _onOpen === void 0 ? void 0 : _onOpen();
107
- onFilterDropdownVisibleChange === null || onFilterDropdownVisibleChange === void 0 ? void 0 : onFilterDropdownVisibleChange(true, column);
107
+ onFilterDropdownVisibleChange === null || onFilterDropdownVisibleChange === void 0 ? void 0 : onFilterDropdownVisibleChange(true, column.raw);
108
108
  },
109
109
  onClose: function onClose() {
110
110
  _onClose === null || _onClose === void 0 ? void 0 : _onClose();
111
- onFilterDropdownVisibleChange === null || onFilterDropdownVisibleChange === void 0 ? void 0 : onFilterDropdownVisibleChange(false, column);
111
+ onFilterDropdownVisibleChange === null || onFilterDropdownVisibleChange === void 0 ? void 0 : onFilterDropdownVisibleChange(false, column.raw);
112
112
  }
113
113
  }),
114
114
  menuVisible = _useUncontrolledToggl[0],
@@ -135,7 +135,7 @@ var FilterDropdown = function FilterDropdown(_ref3) {
135
135
  width: filterDropdownWidth
136
136
  }
137
137
  }, isFunction(filterDropdown) ? filterDropdown({
138
- columnData: column,
138
+ columnData: column.raw,
139
139
  setFilterDropdownVisible: menuVisibleAction.set
140
140
  }) : null)));
141
141
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { HiBaseHTMLProps } from '@hi-ui/core';
3
- import { TableExtra, TableRowFunc, TableHeaderRowFunc } from './types';
3
+ import { TableExtra, TableColumnItem, TableOnRowReturn } from './types';
4
4
  import { UseTableProps } from './use-table';
5
5
  import { UseEmbedExpandProps } from './hooks/use-embed-expand';
6
6
  export declare const EMBED_DATA_KEY: string;
@@ -19,13 +19,13 @@ export interface BaseTableProps extends Omit<HiBaseHTMLProps<'div'>, 'onDrop' |
19
19
  */
20
20
  striped?: boolean;
21
21
  /**
22
- * 表格内容行事件处理函数
22
+ * 表格内容行事件处理函数,对于统计行(合计或均值),rowData 为 null
23
23
  */
24
- onRow?: TableRowFunc;
24
+ onRow?: (rowData: Record<string, any> | null, index: number) => TableOnRowReturn;
25
25
  /**
26
26
  * 行标题事件处理函数
27
27
  */
28
- onHeaderRow?: TableHeaderRowFunc;
28
+ onHeaderRow?: (columns: TableColumnItem[], index: number) => TableOnRowReturn;
29
29
  /**
30
30
  * 数据为空时的展示内容
31
31
  */
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { TableRowFunc } from './types';
2
+ import { TableOnRowReturn } from './types';
3
3
  export declare const TableProvider: import("react").Provider<(Omit<{
4
4
  getColgroupProps: (column: import("./types").FlattedTableColumnItemData, index: number) => {
5
5
  style: {
@@ -38,7 +38,7 @@ export declare const TableProvider: import("react").Provider<(Omit<{
38
38
  isTree: boolean;
39
39
  cellRender: ((text: any) => import("react").ReactNode) | undefined;
40
40
  showColMenu: boolean | undefined;
41
- onLoadChildren: any;
41
+ onLoadChildren: ((item: import("./types").TableRowEventData) => void | Promise<void | any[]>) | undefined;
42
42
  scrollLeft: number;
43
43
  scrollRight: number;
44
44
  rootProps: {
@@ -47,7 +47,6 @@ export declare const TableProvider: import("react").Provider<(Omit<{
47
47
  setting?: boolean | undefined;
48
48
  loading?: boolean | undefined;
49
49
  uniqueId?: string | undefined;
50
- extra?: import("react").ReactNode;
51
50
  };
52
51
  activeSorterColumn: string | null;
53
52
  setActiveSorterColumn: import("react").Dispatch<import("react").SetStateAction<string | null>>;
@@ -101,7 +100,7 @@ export declare const TableProvider: import("react").Provider<(Omit<{
101
100
  hasAvgColumn: boolean;
102
101
  sumRow: Record<string, any>;
103
102
  hasSumColumn: boolean;
104
- onRow?: TableRowFunc | undefined;
103
+ onRow?: ((rowData: Record<string, any> | null, index: number) => TableOnRowReturn) | undefined;
105
104
  striped: boolean;
106
105
  }) | null>;
107
106
  export declare const useTableContext: () => Omit<{
@@ -142,7 +141,7 @@ export declare const useTableContext: () => Omit<{
142
141
  isTree: boolean;
143
142
  cellRender: ((text: any) => import("react").ReactNode) | undefined;
144
143
  showColMenu: boolean | undefined;
145
- onLoadChildren: any;
144
+ onLoadChildren: ((item: import("./types").TableRowEventData) => void | Promise<void | any[]>) | undefined;
146
145
  scrollLeft: number;
147
146
  scrollRight: number;
148
147
  rootProps: {
@@ -151,7 +150,6 @@ export declare const useTableContext: () => Omit<{
151
150
  setting?: boolean | undefined;
152
151
  loading?: boolean | undefined;
153
152
  uniqueId?: string | undefined;
154
- extra?: import("react").ReactNode;
155
153
  };
156
154
  activeSorterColumn: string | null;
157
155
  setActiveSorterColumn: import("react").Dispatch<import("react").SetStateAction<string | null>>;
@@ -205,6 +203,6 @@ export declare const useTableContext: () => Omit<{
205
203
  hasAvgColumn: boolean;
206
204
  sumRow: Record<string, any>;
207
205
  hasSumColumn: boolean;
208
- onRow?: TableRowFunc | undefined;
206
+ onRow?: ((rowData: Record<string, any> | null, index: number) => TableOnRowReturn) | undefined;
209
207
  striped: boolean;
210
208
  };
@@ -1,9 +1,14 @@
1
1
  import React from 'react';
2
- import { SelectProps } from '@hi-ui/select';
3
2
  import { PaginationProps } from '@hi-ui/pagination';
4
- export declare type TableAlign = 'left' | 'right' | 'center';
3
+ export declare type TableColumnItemAlignEnum = 'left' | 'right' | 'center';
5
4
  export declare type TableFrozenColumnOptions = {
5
+ /**
6
+ * 表格从左侧冻结至某列
7
+ */
6
8
  left?: React.ReactText;
9
+ /**
10
+ * 表格从右侧冻结至某列
11
+ */
7
12
  right?: React.ReactText;
8
13
  };
9
14
  export declare type TableExtra = {
@@ -11,68 +16,132 @@ export declare type TableExtra = {
11
16
  header?: React.ReactNode;
12
17
  };
13
18
  export declare type TableCheckAllOptions = {
14
- title?: React.ReactNode;
19
+ /**
20
+ * 添加全选按钮右侧过滤 icon
21
+ */
15
22
  filterIcon?: React.ReactNode;
23
+ /**
24
+ * 自定义渲染全选内容
25
+ */
16
26
  render?: (checkboxNode: React.ReactNode) => React.ReactNode;
17
27
  };
18
28
  export declare type TableRowSelection = {
29
+ /**
30
+ * 设置选中列列宽
31
+ */
19
32
  checkboxColWidth?: number;
33
+ /**
34
+ * 选中的行(受控
35
+ */
20
36
  selectedRowKeys?: React.ReactText[];
37
+ /**
38
+ * 行选择的配置项
39
+ */
21
40
  getCheckboxConfig?: (rowData: object) => {
22
41
  disabled?: boolean;
23
42
  };
24
- onChange?: (selectedRowKeys: React.ReactText[], targetRow?: object | object[], shouldChecked?: boolean) => void;
25
43
  /**
26
- *。暂不对外暴露
27
- * @private
44
+ * 选中项发生变化时的回调
28
45
  */
46
+ onChange?: (selectedRowKeys: React.ReactText[], targetRow?: object | object[], shouldChecked?: boolean) => void;
29
47
  /**
30
48
  * 全选配置集合
31
49
  */
32
50
  checkAllOptions?: TableCheckAllOptions;
33
51
  };
34
- export declare type TableRowReturn = {
52
+ export declare type TableOnRowReturn = {
53
+ /**
54
+ * 行点击事件
55
+ */
35
56
  onClick?: (event: React.MouseEvent) => void;
57
+ /**
58
+ * 行双击事件
59
+ */
36
60
  onDoubleClick?: (event: React.MouseEvent) => void;
61
+ /**
62
+ * 行右键菜单事件
63
+ */
37
64
  onContextMenu?: (event: React.MouseEvent) => void;
65
+ /**
66
+ * 行鼠标入场事件
67
+ */
38
68
  onMouseEnter?: (event: React.MouseEvent) => void;
69
+ /**
70
+ * 行鼠标出场事件
71
+ */
39
72
  onMouseLeave?: (event: React.MouseEvent) => void;
40
73
  };
41
- export declare type TableHeaderRowFunc = (columns: TableColumnItem[], index: number) => TableRowReturn;
42
- /**
43
- * 对于合计行或者均值行统计,rowData 为 null
44
- */
45
- export declare type TableRowFunc = (rowData: Record<string, any> | null, index: number) => TableRowReturn;
74
+ export interface TableColumnItemRenderReturn {
75
+ children: React.ReactNode;
76
+ props: {
77
+ colSpan?: number;
78
+ rowSpan?: number;
79
+ };
80
+ }
46
81
  export declare type TableColumnItem = {
47
- title: React.ReactNode;
82
+ /**
83
+ * 列标题
84
+ */
85
+ title: React.ReactNode | ((column: TableColumnEventData) => React.ReactNode);
86
+ /**
87
+ * 列对应数据项的唯一标识
88
+ */
48
89
  dataKey?: string;
49
- align?: TableAlign;
90
+ /**
91
+ * 该列宽度
92
+ */
93
+ width?: number;
94
+ /**
95
+ * 列对齐方式
96
+ */
97
+ align?: TableColumnItemAlignEnum;
98
+ /**
99
+ * 列排序函数
100
+ */
50
101
  sorter?: (a: any, b: any) => number;
102
+ /**
103
+ * 该列是否支持平均值
104
+ */
51
105
  avg?: boolean;
106
+ /**
107
+ * 该列是否支持合计
108
+ */
52
109
  total?: boolean;
53
- width?: number;
110
+ /**
111
+ * 多级表头
112
+ */
54
113
  children?: TableColumnItem[];
55
114
  /**
56
- * @deprecated
115
+ * 控制单元格自定义渲染
116
+ */
117
+ render?: (text: any, rowItem: Record<string, any>, rowIndex: number, dataKey: string) => React.ReactNode | TableColumnItemRenderReturn;
118
+ /**
119
+ * 列类名 className
57
120
  */
58
- selectFilters?: SelectProps;
59
- defaultSortOrder?: 'ascend' | 'descend';
60
121
  className?: string;
61
- render?: (text: any, rowItem: Record<string, any>, rowIndex: number, dataKey: string) => React.ReactNode | {
62
- children: React.ReactNode;
63
- props: {
64
- colSpan?: number;
65
- rowSpan?: number;
66
- };
67
- };
122
+ /**
123
+ * 自定义 filter 图标
124
+ */
68
125
  filterIcon?: React.ReactNode;
126
+ /**
127
+ * 自定义筛选菜单宽度
128
+ */
69
129
  filterDropdownWidth?: number;
130
+ /**
131
+ * 自定义筛选菜单 className
132
+ */
70
133
  filterDropdownClassName?: string;
134
+ /**
135
+ * 自定义筛选下拉选项显示状态改变时的回调方法
136
+ */
137
+ onFilterDropdownVisibleChange?: (filterDropdownVisible: boolean, item: TableColumnItem) => void;
138
+ /**
139
+ * 自定义筛选菜单,此函数只负责渲染图层,需要自行编写各种交互
140
+ */
71
141
  filterDropdown?: (props: {
72
142
  columnData: TableColumnItem;
73
143
  setFilterDropdownVisible: Function;
74
144
  }) => React.ReactNode;
75
- onFilterDropdownVisibleChange?: (filterDropdownVisible: boolean, item: TableColumnItem) => void;
76
145
  };
77
146
  export declare type TableDataSource = {
78
147
  url: string;
@@ -150,9 +219,9 @@ export interface FlattedTableColumnItemData extends TableColumnItem {
150
219
  leftStickyWidth?: number;
151
220
  rightStickyWidth?: number;
152
221
  }
153
- export interface TableNodeRequiredProps {
222
+ export interface TableColumnEventData extends FlattedTableColumnItemData {
154
223
  }
155
- export interface TableRowEventData extends FlattedTableRowData, TableNodeRequiredProps {
224
+ export interface TableRowEventData extends FlattedTableRowData {
156
225
  }
157
226
  export interface TableRowRequiredProps {
158
227
  expanded: boolean;
@@ -39,7 +39,7 @@ export declare const useTable: ({ data, columns: columnsProp, defaultFixedToColu
39
39
  isTree: boolean;
40
40
  cellRender: ((text: any) => React.ReactNode) | undefined;
41
41
  showColMenu: boolean | undefined;
42
- onLoadChildren: any;
42
+ onLoadChildren: ((item: TableRowEventData) => Promise<any[] | void> | void) | undefined;
43
43
  scrollLeft: number;
44
44
  scrollRight: number;
45
45
  rootProps: {
@@ -63,7 +63,6 @@ export declare const useTable: ({ data, columns: columnsProp, defaultFixedToColu
63
63
  * 唯一 id 前缀,废弃
64
64
  */
65
65
  uniqueId?: string | undefined;
66
- extra?: React.ReactNode;
67
66
  };
68
67
  activeSorterColumn: string | null;
69
68
  setActiveSorterColumn: React.Dispatch<React.SetStateAction<string | null>>;
@@ -216,9 +215,15 @@ export interface UseTableProps {
216
215
  * 唯一 id 前缀,废弃
217
216
  */
218
217
  uniqueId?: string;
218
+ /**
219
+ * 开始拖拽时触发
220
+ */
219
221
  onDragStart?: (evt: React.DragEvent, option: {
220
222
  dragNode: object;
221
223
  }) => void;
224
+ /**
225
+ * 拖拽行放开时触发
226
+ */
222
227
  onDrop?: (evt: React.DragEvent, option: {
223
228
  dragNode: object;
224
229
  dropNode: object;
@@ -226,6 +231,9 @@ export interface UseTableProps {
226
231
  after: object;
227
232
  };
228
233
  }) => boolean | Promise<any>;
234
+ /**
235
+ * 拖拽成功时触发
236
+ */
229
237
  onDropEnd?: (option: {
230
238
  dragNode: object;
231
239
  dropNode: object;
@@ -237,11 +245,13 @@ export interface UseTableProps {
237
245
  * 初始时展开所有行
238
246
  */
239
247
  defaultExpandAll?: boolean;
240
- extra?: React.ReactNode;
241
248
  /**
242
249
  * 全局控制单元格自定义渲染,优先级低于 column 的 render 方法
243
250
  */
244
251
  cellRender?: (text: any) => React.ReactNode;
245
- onLoadChildren?: any;
252
+ /**
253
+ * 点击异步加载子项
254
+ */
255
+ onLoadChildren?: (item: TableRowEventData) => Promise<any[] | void> | void;
246
256
  }
247
257
  export declare type UseTableReturn = ReturnType<typeof useTable>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/table",
3
- "version": "4.0.0-beta.45",
3
+ "version": "4.0.0-beta.46",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HIUI <mi-hiui@xiaomi.com>",
@@ -43,24 +43,24 @@
43
43
  "url": "https://github.com/XiaoMi/hiui/issues"
44
44
  },
45
45
  "dependencies": {
46
- "@hi-ui/button": "^4.0.0-beta.12",
47
- "@hi-ui/checkbox": "^4.0.0-beta.11",
46
+ "@hi-ui/button": "^4.0.0-beta.13",
47
+ "@hi-ui/checkbox": "^4.0.0-beta.12",
48
48
  "@hi-ui/classname": "^4.0.0-beta.0",
49
49
  "@hi-ui/core-css": "^4.0.0-beta.5",
50
50
  "@hi-ui/dom-utils": "^4.0.0-beta.5",
51
- "@hi-ui/drawer": "^4.0.0-beta.24",
52
- "@hi-ui/empty-state": "^4.0.0-beta.19",
51
+ "@hi-ui/drawer": "^4.0.0-beta.25",
52
+ "@hi-ui/empty-state": "^4.0.0-beta.20",
53
53
  "@hi-ui/env": "^4.0.0-beta.0",
54
54
  "@hi-ui/func-utils": "^4.0.0-beta.12",
55
55
  "@hi-ui/icon-button": "^4.0.0-beta.9",
56
56
  "@hi-ui/icons": "^4.0.0-beta.10",
57
- "@hi-ui/loading": "^4.0.0-beta.17",
57
+ "@hi-ui/loading": "^4.0.0-beta.18",
58
58
  "@hi-ui/locale-context": "^4.0.0-beta.18",
59
59
  "@hi-ui/object-utils": "^4.0.0-beta.11",
60
- "@hi-ui/pagination": "^4.0.0-beta.28",
61
- "@hi-ui/popper": "^4.0.0-beta.13",
60
+ "@hi-ui/pagination": "^4.0.0-beta.29",
61
+ "@hi-ui/popper": "^4.0.0-beta.14",
62
62
  "@hi-ui/react-utils": "^4.0.0-beta.5",
63
- "@hi-ui/select": "^4.0.0-beta.26",
63
+ "@hi-ui/select": "^4.0.0-beta.27",
64
64
  "@hi-ui/spinner": "^4.0.0-beta.9",
65
65
  "@hi-ui/times": "^4.0.0-beta.5",
66
66
  "@hi-ui/tree-utils": "^4.0.0-beta.4",
@@ -86,5 +86,5 @@
86
86
  "react": "^17.0.1",
87
87
  "react-dom": "^17.0.1"
88
88
  },
89
- "gitHead": "1639653e72981dcce445765c8b80866adcffcad0"
89
+ "gitHead": "64cc3305632f0d88f852f4a95cba7c27ff388a2d"
90
90
  }