@magicbe/antd-crud 0.0.19 → 0.0.23
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.js +22 -10
- package/dist/components/Add.d.ts +2 -5
- package/dist/components/Context.d.ts +3 -2
- package/dist/components/Context.js +3 -2
- package/dist/components/Edit.d.ts +2 -5
- package/dist/components/Table.js +66 -38
- package/dist/index.d.ts +1 -1
- package/dist/interface.d.ts +11 -1
- package/package.json +1 -5
|
@@ -50,9 +50,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
53
|
-
import React, { Fragment, useImperativeHandle, useState } from "react";
|
|
53
|
+
import React, { Fragment, useImperativeHandle, useMemo, useState } from "react";
|
|
54
54
|
import { Button, Drawer, Modal, Space } from "antd";
|
|
55
|
-
import { isArray, isEmpty, isFunction, isObject } from "lodash";
|
|
55
|
+
import { isArray, isEmpty, isFunction, isNumber, isObject } from "lodash";
|
|
56
56
|
import { DeleteOutlined, EditFilled, PlusOutlined } from "@ant-design/icons";
|
|
57
57
|
import createEmotion from "@emotion/css/create-instance";
|
|
58
58
|
import { useTableContext } from "./Context";
|
|
@@ -150,8 +150,7 @@ var append_action_default_children = (_jsxs(Space, { children: [_jsx(PlusOutline
|
|
|
150
150
|
export var AppendAction = function (_a) {
|
|
151
151
|
var _b = _a.children, children = _b === void 0 ? append_action_default_children : _b;
|
|
152
152
|
var _c = Modal.useModal(), modalInstance = _c[0], modalContextHolder = _c[1];
|
|
153
|
-
var
|
|
154
|
-
var _d = useTableContext(), content_ref = _d.content_ref, table_ref = _d.table_ref, filter_ref = _d.filter_ref, add = _d.add;
|
|
153
|
+
var _d = useTableContext(), content_ref = _d.content_ref, table_ref = _d.table_ref, filter_ref = _d.filter_ref, form_ref = _d.form_ref, add = _d.add, drawer = _d.drawer;
|
|
155
154
|
/**添加表单抽屉 */
|
|
156
155
|
var _e = useState(false), add_drawer_open = _e[0], setAdd_drawer_open = _e[1];
|
|
157
156
|
var _f = useState(), init_data = _f[0], setInit_data = _f[1];
|
|
@@ -181,7 +180,7 @@ export var AppendAction = function (_a) {
|
|
|
181
180
|
}); };
|
|
182
181
|
var onConfirm = function () {
|
|
183
182
|
var _a;
|
|
184
|
-
(_a =
|
|
183
|
+
(_a = form_ref === null || form_ref === void 0 ? void 0 : form_ref.current) === null || _a === void 0 ? void 0 : _a.form.validateFields().then(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
185
184
|
var keys, rows, before, handle, after, page_data, filter_data, error_1;
|
|
186
185
|
var _a, _b, _c, _d, _e;
|
|
187
186
|
return __generator(this, function (_f) {
|
|
@@ -242,7 +241,14 @@ export var AppendAction = function (_a) {
|
|
|
242
241
|
};
|
|
243
242
|
/**新增操作 */
|
|
244
243
|
var add_extra = (_jsxs(Space, { children: [_jsx(Button, __assign({ onClick: switchAddDrawer }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ type: "primary", onClick: onConfirm, loading: loading }, { children: "\u786E\u5B9A" }))] }));
|
|
245
|
-
|
|
244
|
+
var drawer_width = useMemo(function () {
|
|
245
|
+
if (isNumber(drawer))
|
|
246
|
+
return drawer;
|
|
247
|
+
if (isObject(drawer))
|
|
248
|
+
return drawer.add;
|
|
249
|
+
return 600;
|
|
250
|
+
}, [drawer]);
|
|
251
|
+
return (_jsxs(Fragment, { children: [_jsx(Button, __assign({ type: "primary", onClick: switchAddDrawer }, { children: children })), _jsx(Drawer, __assign({ title: "\u65B0\u589E", width: drawer_width, onClose: switchAddDrawer, open: add_drawer_open, closable: false, extra: add_extra, getContainer: function () { return content_ref.current; }, destroyOnClose: true }, { children: _jsx(AddForm, { ref: form_ref, default_data: init_data }) })), modalContextHolder] }));
|
|
246
252
|
};
|
|
247
253
|
var delete_action_default_children = (_jsxs(Space, { children: [_jsx(DeleteOutlined, {}), "\u5220\u9664"] }));
|
|
248
254
|
/**删除方法 */
|
|
@@ -356,8 +362,7 @@ var edit_action_default_children = (_jsxs(Space, { children: [_jsx(EditFilled, {
|
|
|
356
362
|
export var EditAction = function (_a) {
|
|
357
363
|
var _b = _a.children, children = _b === void 0 ? edit_action_default_children : _b;
|
|
358
364
|
var _c = Modal.useModal(), modalInstance = _c[0], modalContextHolder = _c[1];
|
|
359
|
-
var _d = useTableContext(), content_ref = _d.content_ref, table_ref = _d.table_ref, filter_ref = _d.filter_ref, edit = _d.edit;
|
|
360
|
-
var edit_form_ref = React.createRef();
|
|
365
|
+
var _d = useTableContext(), content_ref = _d.content_ref, table_ref = _d.table_ref, filter_ref = _d.filter_ref, form_ref = _d.form_ref, edit = _d.edit, drawer = _d.drawer;
|
|
361
366
|
/**编辑 */
|
|
362
367
|
var _e = useState(false), edit_drawer_open = _e[0], setEdit_drawer_open = _e[1];
|
|
363
368
|
var _f = useState(false), loading = _f[0], setLoading = _f[1];
|
|
@@ -388,7 +393,7 @@ export var EditAction = function (_a) {
|
|
|
388
393
|
}); };
|
|
389
394
|
var onConfirm = function () {
|
|
390
395
|
var _a;
|
|
391
|
-
(_a =
|
|
396
|
+
(_a = form_ref === null || form_ref === void 0 ? void 0 : form_ref.current) === null || _a === void 0 ? void 0 : _a.form.validateFields().then(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
392
397
|
var keys, rows, before, handle, after, page_data, filter_data, error_4;
|
|
393
398
|
var _a, _b, _c, _d, _e;
|
|
394
399
|
return __generator(this, function (_f) {
|
|
@@ -450,6 +455,13 @@ export var EditAction = function (_a) {
|
|
|
450
455
|
};
|
|
451
456
|
/**编辑操作 */
|
|
452
457
|
var edit_extra = (_jsxs(Space, { children: [_jsx(Button, __assign({ onClick: switchEditDrawer }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ type: "primary", onClick: onConfirm, loading: loading }, { children: "\u786E\u5B9A" }))] }));
|
|
453
|
-
|
|
458
|
+
var drawer_width = useMemo(function () {
|
|
459
|
+
if (isNumber(drawer))
|
|
460
|
+
return drawer;
|
|
461
|
+
if (isObject(drawer))
|
|
462
|
+
return drawer.add;
|
|
463
|
+
return 600;
|
|
464
|
+
}, [drawer]);
|
|
465
|
+
return (_jsxs(Fragment, { children: [_jsx(Button, __assign({ onClick: onClick }, { children: children })), _jsx(Drawer, __assign({ title: "\u7F16\u8F91", width: drawer_width, onClose: switchEditDrawer, open: edit_drawer_open, closable: false, extra: edit_extra, getContainer: function () { return content_ref.current; }, destroyOnClose: true }, { children: _jsx(EditForm, { ref: form_ref, default_data: init_data }) })), modalContextHolder] }));
|
|
454
466
|
};
|
|
455
467
|
var templateObject_1;
|
package/dist/components/Add.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { FormRef } from "../interface";
|
|
3
3
|
export interface AddFormProps {
|
|
4
4
|
default_data?: Record<string, any>;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
form: FormInstance;
|
|
8
|
-
}
|
|
9
|
-
declare const AddForm: React.ForwardRefExoticComponent<AddFormProps & React.RefAttributes<AddFormRef>>;
|
|
6
|
+
declare const AddForm: React.ForwardRefExoticComponent<AddFormProps & React.RefAttributes<FormRef>>;
|
|
10
7
|
export default AddForm;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import { AnyObject, type ContentProps } from "../interface";
|
|
2
|
+
import { AnyObject, FormRef, type ContentProps } from "../interface";
|
|
3
3
|
import { type FilterRef } from "./Filter";
|
|
4
4
|
import { type ActionRef } from "./Action";
|
|
5
5
|
import { type TableRef } from "./Table";
|
|
@@ -8,7 +8,8 @@ interface TableContextProps<RecordType> extends ContentProps<RecordType> {
|
|
|
8
8
|
action_ref: React.RefObject<ActionRef>;
|
|
9
9
|
table_ref: React.RefObject<TableRef>;
|
|
10
10
|
content_ref: React.RefObject<HTMLDivElement>;
|
|
11
|
+
form_ref: React.RefObject<FormRef>;
|
|
11
12
|
}
|
|
12
|
-
export declare const TableContextProvider: <RecordType extends AnyObject = AnyObject>({ children, ...props }: React.PropsWithChildren<ContentProps<RecordType>>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const TableContextProvider: <RecordType extends AnyObject = AnyObject>({ children, drawer, ...props }: React.PropsWithChildren<ContentProps<RecordType>>) => import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export declare const useTableContext: () => Partial<TableContextProps<any>>;
|
|
14
15
|
export {};
|
|
@@ -24,11 +24,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
24
|
import React, { useContext } from "react";
|
|
25
25
|
var TableContext = React.createContext({});
|
|
26
26
|
export var TableContextProvider = function (_a) {
|
|
27
|
-
var children = _a.children, props = __rest(_a, ["children"]);
|
|
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
|
+
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 })));
|
|
33
34
|
};
|
|
34
35
|
export var useTableContext = function () { return useContext(TableContext); };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
export interface EditFormRef {
|
|
4
|
-
form: FormInstance;
|
|
5
|
-
}
|
|
2
|
+
import { FormRef } from "../interface";
|
|
6
3
|
export interface EditFormProps {
|
|
7
4
|
default_data?: Record<string, any>;
|
|
8
5
|
}
|
|
9
|
-
declare const EditForm: React.ForwardRefExoticComponent<EditFormProps & React.RefAttributes<
|
|
6
|
+
declare const EditForm: React.ForwardRefExoticComponent<EditFormProps & React.RefAttributes<FormRef>>;
|
|
10
7
|
export default EditForm;
|
package/dist/components/Table.js
CHANGED
|
@@ -60,12 +60,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
60
60
|
import { Table as AntdTable, Button, Drawer, Modal, Space } from "antd";
|
|
61
61
|
import React, { Fragment, useEffect, useImperativeHandle, useMemo, useState } from "react";
|
|
62
62
|
import { DeleteOutlined, EditFilled, PlusOutlined } from "@ant-design/icons";
|
|
63
|
-
import { get, isArray, isEmpty, isFunction, isObject } from "lodash";
|
|
63
|
+
import { get, isArray, isEmpty, isFunction, isNumber, isObject } from "lodash";
|
|
64
64
|
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, props = __rest(_b, ["getSources", "rowSelection", "action", "content_ref", "filter_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"]);
|
|
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];
|
|
@@ -157,14 +157,18 @@ var Table = function (_a, ref) {
|
|
|
157
157
|
}
|
|
158
158
|
return nexts;
|
|
159
159
|
}, [props.columns]);
|
|
160
|
-
var pagination = useMemo(function () {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
160
|
+
var pagination = useMemo(function () {
|
|
161
|
+
if (_pagination_ === false)
|
|
162
|
+
return false;
|
|
163
|
+
return ({
|
|
164
|
+
current: page,
|
|
165
|
+
total: total,
|
|
166
|
+
pageSize: size,
|
|
167
|
+
showTotal: function (totle) { return "\u5171\u8BA1 ".concat(totle, " \u6761\u6570\u636E"); },
|
|
168
|
+
showSizeChanger: true,
|
|
169
|
+
showQuickJumper: true,
|
|
170
|
+
});
|
|
171
|
+
}, [total, page, size]);
|
|
168
172
|
var onRowSelectionChange = function (keys, rows) {
|
|
169
173
|
setSelected_keys(keys);
|
|
170
174
|
setSelected_rows(rows);
|
|
@@ -201,9 +205,8 @@ export default React.forwardRef(Table);
|
|
|
201
205
|
var append_action_default_children = (_jsxs(Space, { children: [_jsx(PlusOutlined, {}), "\u65B0\u589E"] }));
|
|
202
206
|
export var AppendAction = function (_a) {
|
|
203
207
|
var _b = _a.children, children = _b === void 0 ? append_action_default_children : _b, row = _a.row;
|
|
204
|
-
var _c = useTableContext(), rowKey = _c.rowKey, content_ref = _c.content_ref, table_ref = _c.table_ref, filter_ref = _c.filter_ref, add = _c.add;
|
|
208
|
+
var _c = useTableContext(), rowKey = _c.rowKey, content_ref = _c.content_ref, table_ref = _c.table_ref, filter_ref = _c.filter_ref, form_ref = _c.form_ref, add = _c.add, drawer = _c.drawer;
|
|
205
209
|
var _d = Modal.useModal(), modalInstance = _d[0], modalContextHolder = _d[1];
|
|
206
|
-
var add_form_ref = React.createRef();
|
|
207
210
|
var _e = useState(false), add_drawer_open = _e[0], setAdd_drawer_open = _e[1];
|
|
208
211
|
var _f = useState(false), loading = _f[0], setLoading = _f[1];
|
|
209
212
|
var _g = useState(), init_data = _g[0], setInit_data = _g[1];
|
|
@@ -233,7 +236,7 @@ export var AppendAction = function (_a) {
|
|
|
233
236
|
}); };
|
|
234
237
|
var onConfirm = function () {
|
|
235
238
|
var _a;
|
|
236
|
-
(_a =
|
|
239
|
+
(_a = form_ref === null || form_ref === void 0 ? void 0 : form_ref.current) === null || _a === void 0 ? void 0 : _a.form.validateFields().then(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
237
240
|
var before, handle, after, page_data, filter_data, error_1;
|
|
238
241
|
var _a, _b, _c;
|
|
239
242
|
return __generator(this, function (_d) {
|
|
@@ -313,37 +316,55 @@ export var AppendAction = function (_a) {
|
|
|
313
316
|
}); };
|
|
314
317
|
/**新增操作 */
|
|
315
318
|
var add_extra = (_jsxs(Space, { children: [_jsx(Button, __assign({ onClick: switchAddDrawer }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ type: "primary", onClick: onConfirm, loading: loading }, { children: "\u786E\u5B9A" }))] }));
|
|
316
|
-
|
|
319
|
+
var drawer_width = useMemo(function () {
|
|
320
|
+
if (isNumber(drawer))
|
|
321
|
+
return drawer;
|
|
322
|
+
if (isObject(drawer))
|
|
323
|
+
return drawer.add;
|
|
324
|
+
return 600;
|
|
325
|
+
}, [drawer]);
|
|
326
|
+
return (_jsxs(Fragment, { children: [_jsx(Button, __assign({ type: "link", size: "small", onClick: onClick }, { children: children })), _jsx(Drawer, __assign({ title: "\u65B0\u589E", width: drawer_width, onClose: switchAddDrawer, open: add_drawer_open, closable: false, extra: add_extra, getContainer: function () { return content_ref.current; }, destroyOnClose: true }, { children: _jsx(AddForm, { default_data: init_data, ref: form_ref }) })), modalContextHolder] }));
|
|
317
327
|
};
|
|
318
328
|
var edit_action_default_children = (_jsxs(Space, { children: [_jsx(EditFilled, {}), "\u7F16\u8F91"] }));
|
|
319
329
|
export var EditAction = function (_a) {
|
|
320
330
|
var _b = _a.children, children = _b === void 0 ? edit_action_default_children : _b, row = _a.row;
|
|
321
|
-
var
|
|
322
|
-
var _c = useTableContext(), edit = _c.edit, rowKey = _c.rowKey, content_ref = _c.content_ref, table_ref = _c.table_ref, filter_ref = _c.filter_ref;
|
|
331
|
+
var _c = useTableContext(), edit = _c.edit, rowKey = _c.rowKey, content_ref = _c.content_ref, table_ref = _c.table_ref, filter_ref = _c.filter_ref, form_ref = _c.form_ref, drawer = _c.drawer;
|
|
323
332
|
var _d = Modal.useModal(), modalInstance = _d[0], modalContextHolder = _d[1];
|
|
324
333
|
var _e = useState(false), edit_drawer_open = _e[0], setEdit_drawer_open = _e[1];
|
|
325
334
|
var _f = useState(), init_data = _f[0], setInit_data = _f[1];
|
|
326
335
|
var _g = useState(false), loading = _g[0], setLoading = _g[1];
|
|
336
|
+
var _h = useState(false), clickLoading = _h[0], setClickLoading = _h[1];
|
|
327
337
|
var switchEditDrawer = function () { return setEdit_drawer_open(!edit_drawer_open); };
|
|
328
|
-
var
|
|
338
|
+
var _j = useMemo(function () {
|
|
329
339
|
var key = get(row, String(rowKey));
|
|
330
340
|
return ({ keys: [key], rows: [row] });
|
|
331
|
-
}, [row]), keys =
|
|
341
|
+
}, [row]), keys = _j.keys, rows = _j.rows;
|
|
332
342
|
var onClick = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
333
|
-
var init, data;
|
|
343
|
+
var init, data, error_2;
|
|
334
344
|
return __generator(this, function (_a) {
|
|
335
345
|
switch (_a.label) {
|
|
336
346
|
case 0:
|
|
337
|
-
if (!isObject(edit)) return [3 /*break*/,
|
|
347
|
+
if (!isObject(edit)) return [3 /*break*/, 5];
|
|
338
348
|
init = edit.init;
|
|
339
|
-
if (!isFunction(init)) return [3 /*break*/,
|
|
340
|
-
|
|
349
|
+
if (!isFunction(init)) return [3 /*break*/, 5];
|
|
350
|
+
setClickLoading(true);
|
|
351
|
+
_a.label = 1;
|
|
341
352
|
case 1:
|
|
353
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
354
|
+
return [4 /*yield*/, init({ rows: rows, keys: keys })];
|
|
355
|
+
case 2:
|
|
342
356
|
data = _a.sent();
|
|
343
357
|
if (data)
|
|
344
358
|
setInit_data(data);
|
|
345
|
-
|
|
346
|
-
case
|
|
359
|
+
return [3 /*break*/, 5];
|
|
360
|
+
case 3:
|
|
361
|
+
error_2 = _a.sent();
|
|
362
|
+
console.error(error_2);
|
|
363
|
+
return [3 /*break*/, 5];
|
|
364
|
+
case 4:
|
|
365
|
+
setClickLoading(false);
|
|
366
|
+
return [7 /*endfinally*/];
|
|
367
|
+
case 5:
|
|
347
368
|
switchEditDrawer();
|
|
348
369
|
return [2 /*return*/];
|
|
349
370
|
}
|
|
@@ -351,8 +372,8 @@ export var EditAction = function (_a) {
|
|
|
351
372
|
}); };
|
|
352
373
|
var onConfirm = function () {
|
|
353
374
|
var _a;
|
|
354
|
-
(_a =
|
|
355
|
-
var before, handle, after, page_data, filter_data,
|
|
375
|
+
(_a = form_ref === null || form_ref === void 0 ? void 0 : form_ref.current) === null || _a === void 0 ? void 0 : _a.form.validateFields().then(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
376
|
+
var before, handle, after, page_data, filter_data, error_3;
|
|
356
377
|
var _a, _b, _c;
|
|
357
378
|
return __generator(this, function (_d) {
|
|
358
379
|
switch (_d.label) {
|
|
@@ -391,11 +412,11 @@ export var EditAction = function (_a) {
|
|
|
391
412
|
(_c = table_ref === null || table_ref === void 0 ? void 0 : table_ref.current) === null || _c === void 0 ? void 0 : _c.loadRecords(Object.assign({}, page_data, filter_data));
|
|
392
413
|
return [3 /*break*/, 11];
|
|
393
414
|
case 9:
|
|
394
|
-
|
|
395
|
-
console.error(
|
|
415
|
+
error_3 = _d.sent();
|
|
416
|
+
console.error(error_3);
|
|
396
417
|
modalInstance.error({
|
|
397
418
|
title: "错误",
|
|
398
|
-
content: String(
|
|
419
|
+
content: String(error_3)
|
|
399
420
|
});
|
|
400
421
|
return [3 /*break*/, 11];
|
|
401
422
|
case 10:
|
|
@@ -408,7 +429,14 @@ export var EditAction = function (_a) {
|
|
|
408
429
|
};
|
|
409
430
|
/**新增操作 */
|
|
410
431
|
var edit_extra = (_jsxs(Space, { children: [_jsx(Button, __assign({ onClick: switchEditDrawer }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ type: "primary", onClick: onConfirm, loading: loading }, { children: "\u786E\u5B9A" }))] }));
|
|
411
|
-
|
|
432
|
+
var drawer_width = useMemo(function () {
|
|
433
|
+
if (isNumber(drawer))
|
|
434
|
+
return drawer;
|
|
435
|
+
if (isObject(drawer))
|
|
436
|
+
return drawer.add;
|
|
437
|
+
return 600;
|
|
438
|
+
}, [drawer]);
|
|
439
|
+
return (_jsxs(Fragment, { children: [_jsx(Button, __assign({ type: "link", size: "small", onClick: onClick, loading: clickLoading }, { children: children })), _jsx(Drawer, __assign({ title: "\u7F16\u8F91", width: drawer_width, onClose: switchEditDrawer, open: edit_drawer_open, closable: false, extra: edit_extra, getContainer: function () { return content_ref.current; }, destroyOnClose: true }, { children: _jsx(EditForm, { ref: form_ref, default_data: init_data }) })), modalContextHolder] }));
|
|
412
440
|
};
|
|
413
441
|
var delete_action_default_children = (_jsxs(Space, { children: [_jsx(DeleteOutlined, {}), "\u5220\u9664"] }));
|
|
414
442
|
export var DeleteAction = function (_a) {
|
|
@@ -421,7 +449,7 @@ export var DeleteAction = function (_a) {
|
|
|
421
449
|
return ({ keys: [key], rows: [row] });
|
|
422
450
|
}, [row]), keys = _f.keys, rows = _f.rows;
|
|
423
451
|
var onClick = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
424
|
-
var before, handle, after, res, page_data, filter_data,
|
|
452
|
+
var before, handle, after, res, page_data, filter_data, error_4;
|
|
425
453
|
var _a, _b, _c;
|
|
426
454
|
return __generator(this, function (_d) {
|
|
427
455
|
switch (_d.label) {
|
|
@@ -463,11 +491,11 @@ export var DeleteAction = function (_a) {
|
|
|
463
491
|
(_c = table_ref === null || table_ref === void 0 ? void 0 : table_ref.current) === null || _c === void 0 ? void 0 : _c.loadRecords(Object.assign({}, page_data, filter_data));
|
|
464
492
|
return [3 /*break*/, 12];
|
|
465
493
|
case 10:
|
|
466
|
-
|
|
467
|
-
console.error(
|
|
494
|
+
error_4 = _d.sent();
|
|
495
|
+
console.error(error_4);
|
|
468
496
|
modalInstance.error({
|
|
469
497
|
title: "错误",
|
|
470
|
-
content: String(
|
|
498
|
+
content: String(error_4),
|
|
471
499
|
});
|
|
472
500
|
return [3 /*break*/, 12];
|
|
473
501
|
case 11:
|
|
@@ -483,7 +511,7 @@ export var DeleteAction = function (_a) {
|
|
|
483
511
|
title: "提示",
|
|
484
512
|
content: "\u786E\u5B9A\u8981\u5220\u9664 ".concat(keys === null || keys === void 0 ? void 0 : keys.length, " \u6761\u6570\u636E\u5417?"),
|
|
485
513
|
onOk: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
486
|
-
var
|
|
514
|
+
var error_5;
|
|
487
515
|
return __generator(this, function (_a) {
|
|
488
516
|
switch (_a.label) {
|
|
489
517
|
case 0:
|
|
@@ -494,12 +522,12 @@ export var DeleteAction = function (_a) {
|
|
|
494
522
|
resolve(true);
|
|
495
523
|
return [3 /*break*/, 3];
|
|
496
524
|
case 2:
|
|
497
|
-
|
|
525
|
+
error_5 = _a.sent();
|
|
498
526
|
modalInstance.error({
|
|
499
527
|
title: "错误",
|
|
500
|
-
content: String(
|
|
528
|
+
content: String(error_5)
|
|
501
529
|
});
|
|
502
|
-
reject(
|
|
530
|
+
reject(error_5);
|
|
503
531
|
return [3 /*break*/, 3];
|
|
504
532
|
case 3: return [2 /*return*/];
|
|
505
533
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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, } 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, } from "./interface";
|
|
2
2
|
export { default as CrudTable, } from "./components";
|
|
3
3
|
export { TableContextProvider, useTableContext, } from "./components/Context";
|
|
4
4
|
export { default as Filter, type FilterProps, type FilterRef, } from "./components/Filter";
|
package/dist/interface.d.ts
CHANGED
|
@@ -154,18 +154,28 @@ export interface CustomAction {
|
|
|
154
154
|
}
|
|
155
155
|
/**操作 */
|
|
156
156
|
export type Action = boolean | React.FC | React.FC[] | CustomAction;
|
|
157
|
+
export interface DrawerProps {
|
|
158
|
+
add?: number;
|
|
159
|
+
edit?: number;
|
|
160
|
+
}
|
|
157
161
|
/**主体参数 */
|
|
158
162
|
export interface ContentProps<RecordType = AnyObject> extends Omit<TableProps<RecordType>, "columns" | "pagination" | "dataSource" | "loading" | "rowSelection"> {
|
|
159
163
|
columns?: ColumnType<RecordType>[];
|
|
160
|
-
getSources?: getSourceFunction
|
|
164
|
+
getSources?: getSourceFunction;
|
|
161
165
|
add?: add;
|
|
162
166
|
del?: del;
|
|
163
167
|
edit?: edit;
|
|
164
168
|
filter?: filter;
|
|
165
169
|
action?: Action;
|
|
166
170
|
rowSelection?: RowSelectionType;
|
|
171
|
+
pagination?: false;
|
|
172
|
+
drawer?: number | DrawerProps;
|
|
167
173
|
}
|
|
168
174
|
/**主体暴露 */
|
|
169
175
|
export interface ContentRef {
|
|
170
176
|
}
|
|
177
|
+
/**表单REF */
|
|
178
|
+
export interface FormRef {
|
|
179
|
+
form: FormInstance;
|
|
180
|
+
}
|
|
171
181
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicbe/antd-crud",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "antd crud table",
|
|
5
5
|
"author": "wang quan",
|
|
6
6
|
"private": false,
|
|
@@ -17,10 +17,6 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
|
-
"publishConfig": {
|
|
21
|
-
"access": "public",
|
|
22
|
-
"registry": "https://registry.npmjs.org/"
|
|
23
|
-
},
|
|
24
20
|
"dependencies": {
|
|
25
21
|
"@ant-design/icons": "^5.4.0",
|
|
26
22
|
"@emotion/css": "^11.13.0",
|