@magicbe/antd-crud 0.0.27 → 0.0.30
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.
- package/dist/components/Action.d.ts +1 -5
- package/dist/components/Add.js +1 -5
- package/dist/components/Context.d.ts +4 -6
- package/dist/components/Context.js +10 -2
- package/dist/components/Edit.js +2 -6
- package/dist/components/Filter.d.ts +1 -6
- package/dist/components/Table.d.ts +1 -14
- package/dist/components/Table.js +2 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +2 -3
- package/dist/index.d.ts +4 -4
- package/dist/interface.d.ts +34 -2
- package/package.json +1 -1
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
|
|
3
|
-
className?: string;
|
|
4
|
-
}
|
|
5
|
-
export interface ActionRef {
|
|
6
|
-
}
|
|
2
|
+
import { ActionProps, ActionRef } from "../interface";
|
|
7
3
|
declare const _default: React.ForwardRefExoticComponent<ActionProps & React.RefAttributes<ActionRef>>;
|
|
8
4
|
export default _default;
|
|
9
5
|
/**自定义渲染 */
|
package/dist/components/Add.js
CHANGED
|
@@ -28,14 +28,10 @@ import Field from "./Field";
|
|
|
28
28
|
import { isObject, isString } from "lodash";
|
|
29
29
|
import { useTableContext } from "./Context";
|
|
30
30
|
var AddForm = React.forwardRef(function (_a, ref) {
|
|
31
|
-
var _b;
|
|
32
31
|
var default_data = _a.default_data;
|
|
33
32
|
var form = AntdForm.useForm()[0];
|
|
34
33
|
var columns = useTableContext().columns;
|
|
35
|
-
var fields =
|
|
36
|
-
var dataIndex = _a.dataIndex;
|
|
37
|
-
return !!dataIndex;
|
|
38
|
-
})) === null || _b === void 0 ? void 0 : _b.filter(function (_a) {
|
|
34
|
+
var fields = columns === null || columns === void 0 ? void 0 : columns.filter(function (_a) {
|
|
39
35
|
var add = _a.add, edit = _a.edit;
|
|
40
36
|
return !!add;
|
|
41
37
|
}).map(function (_a) {
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { AnyObject, FormRef, type ContentProps } from "../interface";
|
|
3
|
-
import { type FilterRef } from "./Filter";
|
|
4
|
-
import { type ActionRef } from "./Action";
|
|
5
|
-
import { type TableRef } from "./Table";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AnyObject, ContentRef, type FilterRef, FormRef, type ContentProps, ActionRef, TableRef } from "../interface";
|
|
6
3
|
interface TableContextProps<RecordType> extends ContentProps<RecordType> {
|
|
7
4
|
filter_ref: React.RefObject<FilterRef>;
|
|
8
5
|
action_ref: React.RefObject<ActionRef>;
|
|
@@ -10,6 +7,7 @@ interface TableContextProps<RecordType> extends ContentProps<RecordType> {
|
|
|
10
7
|
content_ref: React.RefObject<HTMLDivElement>;
|
|
11
8
|
form_ref: React.RefObject<FormRef>;
|
|
12
9
|
}
|
|
13
|
-
|
|
10
|
+
type RefTable = <RecordType = AnyObject>(props: React.PropsWithChildren<ContentProps<RecordType>> & React.RefAttributes<ContentRef>) => React.ReactElement;
|
|
11
|
+
export declare const TableContextProvider: RefTable;
|
|
14
12
|
export declare const useTableContext: () => Partial<TableContextProps<any>>;
|
|
15
13
|
export {};
|
|
@@ -21,15 +21,23 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
-
import React, { useContext } from "react";
|
|
24
|
+
import React, { useContext, useImperativeHandle } from "react";
|
|
25
25
|
var TableContext = React.createContext({});
|
|
26
|
-
|
|
26
|
+
var TableContextProviderPrev = function (_a, ref) {
|
|
27
27
|
var children = _a.children, _b = _a.drawer, drawer = _b === void 0 ? 600 : _b, props = __rest(_a, ["children", "drawer"]);
|
|
28
28
|
var filter_ref = React.createRef();
|
|
29
29
|
var action_ref = React.createRef();
|
|
30
30
|
var table_ref = React.createRef();
|
|
31
31
|
var content_ref = React.createRef();
|
|
32
32
|
var form_ref = React.createRef();
|
|
33
|
+
useImperativeHandle(ref, function () { return ({
|
|
34
|
+
filter_ref: filter_ref,
|
|
35
|
+
action_ref: action_ref,
|
|
36
|
+
table_ref: table_ref,
|
|
37
|
+
content_ref: content_ref,
|
|
38
|
+
form_ref: form_ref,
|
|
39
|
+
}); });
|
|
33
40
|
return (_jsx(TableContext.Provider, __assign({ value: __assign(__assign({}, props), { drawer: drawer, filter_ref: filter_ref, action_ref: action_ref, table_ref: table_ref, content_ref: content_ref, form_ref: form_ref }) }, { children: children })));
|
|
34
41
|
};
|
|
42
|
+
export var TableContextProvider = React.forwardRef(TableContextProviderPrev);
|
|
35
43
|
export var useTableContext = function () { return useContext(TableContext); };
|
package/dist/components/Edit.js
CHANGED
|
@@ -28,14 +28,10 @@ import { useTableContext } from "./Context";
|
|
|
28
28
|
import { isObject, isString } from "lodash";
|
|
29
29
|
import Field from "./Field";
|
|
30
30
|
var EditForm = React.forwardRef(function (_a, ref) {
|
|
31
|
-
var _b;
|
|
32
|
-
var _c = _a.default_data, default_data = _c === void 0 ? {} : _c;
|
|
31
|
+
var _b = _a.default_data, default_data = _b === void 0 ? {} : _b;
|
|
33
32
|
var form = AntdForm.useForm()[0];
|
|
34
33
|
var columns = useTableContext().columns;
|
|
35
|
-
var fields =
|
|
36
|
-
var dataIndex = _a.dataIndex;
|
|
37
|
-
return !!dataIndex;
|
|
38
|
-
})) === null || _b === void 0 ? void 0 : _b.filter(function (_a) {
|
|
34
|
+
var fields = columns === null || columns === void 0 ? void 0 : columns.filter(function (_a) {
|
|
39
35
|
var edit = _a.edit;
|
|
40
36
|
return !!edit;
|
|
41
37
|
}).map(function (_a) {
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
export interface FilterProps {
|
|
4
|
-
}
|
|
5
|
-
export interface FilterRef {
|
|
6
|
-
form: FormInstance;
|
|
7
|
-
}
|
|
2
|
+
import { FilterProps, FilterRef } from "../interface";
|
|
8
3
|
declare const _default: React.ForwardRefExoticComponent<FilterProps & React.RefAttributes<FilterRef>>;
|
|
9
4
|
export default _default;
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import { type AnyObject } from "../interface";
|
|
3
|
-
export interface TableProps {
|
|
4
|
-
}
|
|
5
|
-
type getPageData = () => ({
|
|
6
|
-
current?: number;
|
|
7
|
-
pageSize?: number;
|
|
8
|
-
});
|
|
9
|
-
type loadRecords = (params?: any) => void;
|
|
10
|
-
export interface TableRef {
|
|
11
|
-
getPageData: getPageData;
|
|
12
|
-
loadRecords: loadRecords;
|
|
13
|
-
selected_keys: React.Key[];
|
|
14
|
-
selected_rows: AnyObject[];
|
|
15
|
-
}
|
|
2
|
+
import { TableProps, TableRef, type AnyObject } from "../interface";
|
|
16
3
|
declare const _default: React.ForwardRefExoticComponent<TableProps & React.RefAttributes<TableRef>>;
|
|
17
4
|
export default _default;
|
|
18
5
|
interface ActionProps {
|
package/dist/components/Table.js
CHANGED
|
@@ -65,7 +65,7 @@ import { useTableContext } from "./Context";
|
|
|
65
65
|
import AddForm from "./Add";
|
|
66
66
|
import EditForm from "./Edit";
|
|
67
67
|
var Table = function (_a, ref) {
|
|
68
|
-
var _b = useTableContext(), getSources = _b.getSources, selectionType = _b.rowSelection, action = _b.action, content_ref = _b.content_ref, filter_ref = _b.filter_ref, _pagination_ = _b.pagination, props = __rest(_b, ["getSources", "rowSelection", "action", "content_ref", "filter_ref", "pagination"]);
|
|
68
|
+
var _b = useTableContext(), getSources = _b.getSources, selectionType = _b.rowSelection, action = _b.action, content_ref = _b.content_ref, filter_ref = _b.filter_ref, pageSizeOptions = _b.pageSizeOptions, _pagination_ = _b.pagination, props = __rest(_b, ["getSources", "rowSelection", "action", "content_ref", "filter_ref", "pageSizeOptions", "pagination"]);
|
|
69
69
|
var _c = useState([]), sources = _c[0], setSources = _c[1];
|
|
70
70
|
var _d = useState(), total = _d[0], setTotal = _d[1];
|
|
71
71
|
var _e = useState(), page = _e[0], setPage = _e[1];
|
|
@@ -159,6 +159,7 @@ var Table = function (_a, ref) {
|
|
|
159
159
|
current: page,
|
|
160
160
|
total: total,
|
|
161
161
|
pageSize: size,
|
|
162
|
+
pageSizeOptions: pageSizeOptions,
|
|
162
163
|
showTotal: function (totle) { return "\u5171\u8BA1 ".concat(totle, " \u6761\u6570\u636E"); },
|
|
163
164
|
showSizeChanger: true,
|
|
164
165
|
showQuickJumper: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { type ContentProps, type AnyObject } from "../interface";
|
|
3
|
-
type RefTable = <RecordType = AnyObject>(props: React.PropsWithChildren<ContentProps<RecordType>>) => React.ReactElement;
|
|
2
|
+
import { type ContentProps, type ContentRef, type AnyObject } from "../interface";
|
|
3
|
+
type RefTable = <RecordType = AnyObject>(props: React.PropsWithChildren<ContentProps<RecordType>> & React.RefAttributes<ContentRef>) => React.ReactElement;
|
|
4
4
|
declare const _default: RefTable;
|
|
5
5
|
export default _default;
|
package/dist/components/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import React
|
|
13
|
+
import React from "react";
|
|
14
14
|
import Filter from "./Filter";
|
|
15
15
|
import Action from "./Action";
|
|
16
16
|
import Table from "./Table";
|
|
@@ -20,7 +20,6 @@ var Content = function () {
|
|
|
20
20
|
return (_jsxs("div", __assign({ ref: content_ref }, { children: [_jsx(Filter, { ref: filter_ref }), _jsx(Action, { ref: action_ref }), _jsx(Table, { ref: table_ref })] })));
|
|
21
21
|
};
|
|
22
22
|
var ContentPrev = function (props, ref) {
|
|
23
|
-
|
|
24
|
-
return (_jsx(TableContextProvider, __assign({}, props, { children: _jsx(Content, {}) })));
|
|
23
|
+
return (_jsx(TableContextProvider, __assign({}, props, { ref: ref }, { children: _jsx(Content, {}) })));
|
|
25
24
|
};
|
|
26
25
|
export default React.forwardRef(ContentPrev);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { type AnyObject, type BaseColumnField, type ColumnInputField, type ColumnTextAreaField, type ColumnInputNumberField, type ColumnSelectField, type ColumnCascaderField, type ColumnCheckboxField, type ColumnCheckboxGroupField, type ColumnDatePickerField, type ColumnDatePickerYearPickerField, type ColumnDatePickerMonthPickerField, type ColumnDatePickerWeekPickerField, type ColumnDatePickerTimePickerField, type ColumnDatePickerRangePickerField, type ColumnDatePickerQuarterPickerField, type ColumnTimePickerField, type ColumnTimePickerRangePickerField, type ColumnRadioField, type ColumnRadioGroupField, type ColumnSwitchField, type ColumnField, type ColumnFieldKeys, type ColumnType, type Source, type getSourceFunction, type GetSourceFunctionParams, type add, type addHandleMap, type edit, type editHandleMap, type del, type CustomFilter, type filter, type MasterCustomActionGroup, type RecordCustomActionGroup, type CustomActionGroup, type CustomAction, type ContentProps, type ContentRef, type FormRef, } from "./interface";
|
|
1
|
+
export { type AnyObject, type BaseColumnField, type ColumnInputField, type ColumnTextAreaField, type ColumnInputNumberField, type ColumnSelectField, type ColumnCascaderField, type ColumnCheckboxField, type ColumnCheckboxGroupField, type ColumnDatePickerField, type ColumnDatePickerYearPickerField, type ColumnDatePickerMonthPickerField, type ColumnDatePickerWeekPickerField, type ColumnDatePickerTimePickerField, type ColumnDatePickerRangePickerField, type ColumnDatePickerQuarterPickerField, type ColumnTimePickerField, type ColumnTimePickerRangePickerField, type ColumnRadioField, type ColumnRadioGroupField, type ColumnSwitchField, type ColumnField, type ColumnFieldKeys, type ColumnType, type Source, type getSourceFunction, type GetSourceFunctionParams, type add, type addHandleMap, type edit, type editHandleMap, type del, type CustomFilter, type filter, type MasterCustomActionGroup, type RecordCustomActionGroup, type CustomActionGroup, type CustomAction, type ContentProps, type ContentRef, type FormRef, type FilterProps, type FilterRef, type ActionProps, type ActionRef, type TableProps, type getPageData, type loadRecords, type TableRef, } from "./interface";
|
|
2
2
|
export { default as CrudTable, } from "./components";
|
|
3
3
|
export { TableContextProvider, useTableContext, } from "./components/Context";
|
|
4
|
-
export { default as Filter,
|
|
5
|
-
export { default as Action, AppendAction as MastAppend, DeleteAction as MastDelete, EditAction as MastEdit,
|
|
6
|
-
export { default as Table, AppendAction as RowAppend, DeleteAction as RowDelete, EditAction as RowEdit,
|
|
4
|
+
export { default as Filter, } from "./components/Filter";
|
|
5
|
+
export { default as Action, AppendAction as MastAppend, DeleteAction as MastDelete, EditAction as MastEdit, } from "./components/Action";
|
|
6
|
+
export { default as Table, AppendAction as RowAppend, DeleteAction as RowDelete, EditAction as RowEdit, } from "./components/Table";
|
|
7
7
|
export { default as CrudConfigProvider, } from "./config";
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TableProps, type InputProps, type SelectProps, type CascaderProps, type DatePickerProps, type InputNumberProps, type CheckboxProps, type RadioProps, type SwitchProps, type TimePickerProps, TreeSelectProps } from "antd";
|
|
1
|
+
import { type TableProps as AntdTableProps, type InputProps, type SelectProps, type CascaderProps, type DatePickerProps, type InputNumberProps, type CheckboxProps, type RadioProps, type SwitchProps, type TimePickerProps, type TreeSelectProps, type PaginationProps } from "antd";
|
|
2
2
|
import { type CheckboxGroupProps } from "antd/es/checkbox";
|
|
3
3
|
import { FormInstance, Rule } from "antd/es/form";
|
|
4
4
|
import { TextAreaProps } from "antd/es/input";
|
|
@@ -165,7 +165,7 @@ export interface DrawerProps {
|
|
|
165
165
|
edit?: number;
|
|
166
166
|
}
|
|
167
167
|
/**主体参数 */
|
|
168
|
-
export interface ContentProps<RecordType = AnyObject> extends Omit<
|
|
168
|
+
export interface ContentProps<RecordType = AnyObject> extends Omit<AntdTableProps<RecordType>, "columns" | "pagination" | "dataSource" | "loading" | "rowSelection"> {
|
|
169
169
|
columns?: ColumnType<RecordType>[];
|
|
170
170
|
getSources?: getSourceFunction;
|
|
171
171
|
add?: add;
|
|
@@ -176,12 +176,44 @@ export interface ContentProps<RecordType = AnyObject> extends Omit<TableProps<Re
|
|
|
176
176
|
rowSelection?: RowSelectionType;
|
|
177
177
|
pagination?: false;
|
|
178
178
|
drawer?: number | DrawerProps;
|
|
179
|
+
pageSizeOptions?: PaginationProps["pageSizeOptions"];
|
|
179
180
|
}
|
|
180
181
|
/**主体暴露 */
|
|
181
182
|
export interface ContentRef {
|
|
183
|
+
filter_ref: React.RefObject<FilterRef>;
|
|
184
|
+
action_ref: React.RefObject<ActionRef>;
|
|
185
|
+
table_ref: React.RefObject<TableRef>;
|
|
186
|
+
content_ref: React.RefObject<HTMLDivElement>;
|
|
187
|
+
form_ref: React.RefObject<FormRef>;
|
|
182
188
|
}
|
|
183
189
|
/**表单REF */
|
|
184
190
|
export interface FormRef {
|
|
185
191
|
form: FormInstance;
|
|
186
192
|
}
|
|
193
|
+
/**筛选 */
|
|
194
|
+
export interface FilterProps {
|
|
195
|
+
}
|
|
196
|
+
export interface FilterRef {
|
|
197
|
+
form: FormInstance;
|
|
198
|
+
}
|
|
199
|
+
/**操作 */
|
|
200
|
+
export interface ActionProps {
|
|
201
|
+
className?: string;
|
|
202
|
+
}
|
|
203
|
+
export interface ActionRef {
|
|
204
|
+
}
|
|
205
|
+
/**表单 */
|
|
206
|
+
export interface TableProps {
|
|
207
|
+
}
|
|
208
|
+
export type getPageData = () => ({
|
|
209
|
+
current?: number;
|
|
210
|
+
pageSize?: number;
|
|
211
|
+
});
|
|
212
|
+
export type loadRecords = (params?: any) => void;
|
|
213
|
+
export interface TableRef {
|
|
214
|
+
getPageData: getPageData;
|
|
215
|
+
loadRecords: loadRecords;
|
|
216
|
+
selected_keys: React.Key[];
|
|
217
|
+
selected_rows: AnyObject[];
|
|
218
|
+
}
|
|
187
219
|
export {};
|