@magicbe/antd-crud 0.0.58 → 0.0.60

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.
@@ -101,23 +101,17 @@ var Table = React.forwardRef(function (_a, ref) {
101
101
  /**自定义渲染 */
102
102
  else if (isFunction(record_1)) {
103
103
  var Component_1 = record_1;
104
- nexts === null || nexts === void 0 ? void 0 : nexts.push({
105
- title: "操作",
106
- render: function (value, row, index) { return React.cloneElement(_jsx(Component_1, {}), { value: value, row: row, index: index }); },
107
- });
104
+ nexts === null || nexts === void 0 ? void 0 : nexts.push(__assign({ title: "操作", render: function (value, row, index) { return React.cloneElement(_jsx(Component_1, {}), { value: value, row: row, index: index }); } }, actionColumn));
108
105
  }
109
106
  /**自定义渲染数组 */
110
107
  else if (isArray(record_1)) {
111
- nexts === null || nexts === void 0 ? void 0 : nexts.push({
112
- title: "操作",
113
- render: function (value, row, index) {
108
+ nexts === null || nexts === void 0 ? void 0 : nexts.push(__assign({ title: "操作", render: function (value, row, index) {
114
109
  return (_jsx(Space, { children: record_1.map(function (Component, key) { return React.cloneElement(_jsx(Component, {}, key), {
115
110
  value: value,
116
111
  row: row,
117
112
  index: index,
118
113
  }); }) }));
119
- }
120
- });
114
+ } }, actionColumn));
121
115
  }
122
116
  /**对象渲染 */
123
117
  else if (isObject(record_1) && !isEmpty(action)) {
@@ -125,9 +119,7 @@ var Table = React.forwardRef(function (_a, ref) {
125
119
  var add_element_1 = _jsx(Fragment, {});
126
120
  var edit_element_1 = _jsx(Fragment, {});
127
121
  var del_element_1 = _jsx(Fragment, {});
128
- nexts === null || nexts === void 0 ? void 0 : nexts.push({
129
- title: "操作",
130
- render: function (_, row, index) {
122
+ nexts === null || nexts === void 0 ? void 0 : nexts.push(__assign({ title: "操作", render: function (_, row, index) {
131
123
  /**新增 */
132
124
  if (add_1 === true)
133
125
  add_element_1 = React.cloneElement(_jsx(AppendAction, {}), { row: row, index: index });
@@ -150,8 +142,7 @@ var Table = React.forwardRef(function (_a, ref) {
150
142
  del_element_1 = React.cloneElement(_jsx(Component, {}), { row: row, index: index });
151
143
  }
152
144
  return (_jsxs(Space, { children: [add_element_1, edit_element_1, del_element_1] }));
153
- }
154
- });
145
+ } }, actionColumn));
155
146
  }
156
147
  }
157
148
  return nexts;
@@ -190,14 +181,15 @@ var Table = React.forwardRef(function (_a, ref) {
190
181
  type: selectionType,
191
182
  });
192
183
  }, [selectionType]);
193
- var loadRecords = function (params) {
184
+ var loadRecords = function (params, filter, sorter, extra) {
194
185
  var _a;
195
186
  if (params === void 0) { params = {}; }
187
+ if (filter === void 0) { filter = {}; }
196
188
  setLoading(true);
197
189
  var filter_data = (_a = filter_ref === null || filter_ref === void 0 ? void 0 : filter_ref.current) === null || _a === void 0 ? void 0 : _a.form.getFieldsValue();
198
190
  if (!getSources)
199
191
  return console.warn("getSources is not defined");
200
- getSources(Object.assign({}, params, filter_data)).then(function (_a) {
192
+ getSources(Object.assign({}, params, filter_data), filter, sorter, extra).then(function (_a) {
201
193
  var total = _a.total, sources = _a.sources, page = _a.page, size = _a.size;
202
194
  setSources(sources);
203
195
  setTotal(total);
@@ -3,7 +3,7 @@ import { type CheckboxGroupProps } from "antd/es/checkbox";
3
3
  import { FormInstance, Rule } from "antd/es/form";
4
4
  import { PasswordProps, TextAreaProps } from "antd/es/input";
5
5
  import { type RadioGroupProps } from "antd/es/radio";
6
- import { RowSelectionType, type ColumnType as AntdColumnType } from "antd/es/table/interface";
6
+ import { RowSelectionType, SorterResult, TableCurrentDataSource, TablePaginationConfig, type ColumnType as AntdColumnType } from "antd/es/table/interface";
7
7
  import React from "react";
8
8
  export type AnyObject = Record<PropertyKey, any>;
9
9
  /**字段列 */
@@ -112,7 +112,7 @@ export interface GetSourceFunctionParams extends Record<string, any> {
112
112
  pageSize?: number;
113
113
  }
114
114
  /**获取数据的方法 */
115
- export type getSourceFunction<RecordType = AnyObject> = (params?: GetSourceFunctionParams) => Promise<Source<RecordType>>;
115
+ export type getSourceFunction<RecordType = AnyObject> = (params?: GetSourceFunctionParams, filter?: Record<string, any>, sorter?: SorterResult<RecordType> | SorterResult<RecordType>[], extra?: TableCurrentDataSource<RecordType>) => Promise<Source<RecordType>>;
116
116
  export interface Selection<RecordType = AnyObject> {
117
117
  keys?: React.Key[];
118
118
  rows?: RecordType[];
@@ -167,7 +167,7 @@ export interface DrawerProps {
167
167
  /**主体参数 */
168
168
  export interface ContentProps<RecordType = AnyObject> extends Omit<AntdTableProps<RecordType>, "columns" | "pagination" | "dataSource" | "loading" | "rowSelection"> {
169
169
  columns?: ColumnType<RecordType>[];
170
- getSources?: getSourceFunction;
170
+ getSources?: getSourceFunction<RecordType>;
171
171
  add?: add;
172
172
  del?: del;
173
173
  edit?: edit;
@@ -208,7 +208,7 @@ export type getPageData = () => ({
208
208
  current?: number;
209
209
  pageSize?: number;
210
210
  });
211
- export type loadRecords = (params?: any) => void;
211
+ export type loadRecords = (params: TablePaginationConfig, filter?: Record<string, any>, sorter?: SorterResult | SorterResult[], extra?: TableCurrentDataSource) => void;
212
212
  export type getRecords<T = AnyObject> = () => T[];
213
213
  export interface TableRef<RecordType = AnyObject> {
214
214
  getPageData: getPageData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicbe/antd-crud",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "description": "antd crud table",
5
5
  "author": "wang quan",
6
6
  "private": false,