@magicbe/antd-crud 0.0.44 → 0.0.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.
- package/dist/components/Action.js +8 -4
- package/dist/components/Table.js +8 -4
- package/dist/config.d.ts +7 -2
- package/dist/config.js +9 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -47,6 +47,7 @@ import createEmotion from "@emotion/css/create-instance";
|
|
|
47
47
|
import { useTableContext } from "./Context";
|
|
48
48
|
import AddForm from "./Add";
|
|
49
49
|
import EditForm from "./Edit";
|
|
50
|
+
import { useCrudConfigContext } from "../config";
|
|
50
51
|
var _a = createEmotion({ key: "action" }), css = _a.css, cx = _a.cx;
|
|
51
52
|
var wrapper_css = css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n margin-bottom: 25px;\n"], ["\n margin-bottom: 25px;\n"])));
|
|
52
53
|
/**操作 */
|
|
@@ -142,6 +143,7 @@ var append_action_default_children = (_jsxs(Button, { type: "primary", children:
|
|
|
142
143
|
export var AppendAction = function (_a) {
|
|
143
144
|
var _b = _a.children, children = _b === void 0 ? append_action_default_children : _b;
|
|
144
145
|
var _c = Modal.useModal(), modalInstance = _c[0], modalContextHolder = _c[1];
|
|
146
|
+
var showErrorModal = useCrudConfigContext().showErrorModal;
|
|
145
147
|
var _d = useTableContext(), table_ref = _d.table_ref, filter_ref = _d.filter_ref, form_ref = _d.form_ref, add = _d.add, drawer = _d.drawer;
|
|
146
148
|
/**添加表单抽屉 */
|
|
147
149
|
var _e = useState(false), add_drawer_open = _e[0], setAdd_drawer_open = _e[1];
|
|
@@ -218,7 +220,7 @@ export var AppendAction = function (_a) {
|
|
|
218
220
|
case 10:
|
|
219
221
|
error_1 = _f.sent();
|
|
220
222
|
console.error(error_1);
|
|
221
|
-
modalInstance.error({
|
|
223
|
+
showErrorModal && modalInstance.error({
|
|
222
224
|
title: "错误",
|
|
223
225
|
content: String(error_1)
|
|
224
226
|
});
|
|
@@ -248,6 +250,7 @@ export var DeleteAction = function (_a) {
|
|
|
248
250
|
var _b = _a.children, children = _b === void 0 ? delete_action_default_children : _b;
|
|
249
251
|
var _c = Modal.useModal(), modalInstance = _c[0], modalContextHolder = _c[1];
|
|
250
252
|
var _d = useTableContext(), table_ref = _d.table_ref, filter_ref = _d.filter_ref, del = _d.del;
|
|
253
|
+
var showErrorModal = useCrudConfigContext().showErrorModal;
|
|
251
254
|
var _e = useState(false), loading = _e[0], setLoading = _e[1];
|
|
252
255
|
var onClick = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
253
256
|
var keys, rows, before, handle, after, res, page_data, filter_data, error_2;
|
|
@@ -327,7 +330,7 @@ export var DeleteAction = function (_a) {
|
|
|
327
330
|
return [3 /*break*/, 3];
|
|
328
331
|
case 2:
|
|
329
332
|
error_3 = _a.sent();
|
|
330
|
-
modalInstance.error({
|
|
333
|
+
showErrorModal && modalInstance.error({
|
|
331
334
|
title: "错误",
|
|
332
335
|
content: String(error_3)
|
|
333
336
|
});
|
|
@@ -350,7 +353,8 @@ var edit_action_default_children = (_jsxs(Button, { children: [_jsx(EditFilled,
|
|
|
350
353
|
export var EditAction = function (_a) {
|
|
351
354
|
var _b = _a.children, children = _b === void 0 ? edit_action_default_children : _b;
|
|
352
355
|
var _c = Modal.useModal(), modalInstance = _c[0], modalContextHolder = _c[1];
|
|
353
|
-
var
|
|
356
|
+
var showErrorModal = useCrudConfigContext().showErrorModal;
|
|
357
|
+
var _d = useTableContext(), table_ref = _d.table_ref, filter_ref = _d.filter_ref, form_ref = _d.form_ref, edit = _d.edit, drawer = _d.drawer;
|
|
354
358
|
/**编辑 */
|
|
355
359
|
var _e = useState(false), edit_drawer_open = _e[0], setEdit_drawer_open = _e[1];
|
|
356
360
|
var _f = useState(false), loading = _f[0], setLoading = _f[1];
|
|
@@ -428,7 +432,7 @@ export var EditAction = function (_a) {
|
|
|
428
432
|
case 10:
|
|
429
433
|
error_4 = _f.sent();
|
|
430
434
|
console.error(error_4);
|
|
431
|
-
modalInstance.error({
|
|
435
|
+
showErrorModal && modalInstance.error({
|
|
432
436
|
title: "错误",
|
|
433
437
|
content: String(error_4)
|
|
434
438
|
});
|
package/dist/components/Table.js
CHANGED
|
@@ -69,6 +69,7 @@ import { useTableContext } from "./Context";
|
|
|
69
69
|
import AddForm from "./Add";
|
|
70
70
|
import EditForm from "./Edit";
|
|
71
71
|
import { css } from "@emotion/css";
|
|
72
|
+
import { useCrudConfigContext } from "../config";
|
|
72
73
|
var Table = React.forwardRef(function (_a, ref) {
|
|
73
74
|
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, _c = _b.actionColumn, actionColumn = _c === void 0 ? {} : _c, _pagination_ = _b.pagination, props = __rest(_b, ["getSources", "rowSelection", "action", "content_ref", "filter_ref", "pageSizeOptions", "actionColumn", "pagination"]);
|
|
74
75
|
var _d = useState([]), sources = _d[0], setSources = _d[1];
|
|
@@ -209,6 +210,7 @@ var action_cls = css(templateObject_1 || (templateObject_1 = __makeTemplateObjec
|
|
|
209
210
|
var append_action_default_children = (_jsxs(Button, { type: "link", size: "small", className: action_cls, children: [_jsx(PlusOutlined, {}), "\u65B0\u589E"] }));
|
|
210
211
|
export var AppendAction = function (_a) {
|
|
211
212
|
var _b = _a.children, children = _b === void 0 ? append_action_default_children : _b, row = _a.row;
|
|
213
|
+
var showErrorModal = useCrudConfigContext().showErrorModal;
|
|
212
214
|
var _c = useTableContext(), rowKey = _c.rowKey, table_ref = _c.table_ref, filter_ref = _c.filter_ref, form_ref = _c.form_ref, add = _c.add, drawer = _c.drawer;
|
|
213
215
|
var _d = Modal.useModal(), modalInstance = _d[0], modalContextHolder = _d[1];
|
|
214
216
|
var _e = useState(false), add_drawer_open = _e[0], setAdd_drawer_open = _e[1];
|
|
@@ -282,7 +284,7 @@ export var AppendAction = function (_a) {
|
|
|
282
284
|
case 9:
|
|
283
285
|
error_1 = _d.sent();
|
|
284
286
|
console.error(error_1);
|
|
285
|
-
modalInstance.error({
|
|
287
|
+
showErrorModal && modalInstance.error({
|
|
286
288
|
title: "错误",
|
|
287
289
|
content: String(error_1)
|
|
288
290
|
});
|
|
@@ -332,7 +334,8 @@ export var AppendAction = function (_a) {
|
|
|
332
334
|
var edit_action_default_children = (_jsxs(Button, { type: "link", size: "small", className: action_cls, children: [_jsx(EditFilled, {}), "\u7F16\u8F91"] }));
|
|
333
335
|
export var EditAction = function (_a) {
|
|
334
336
|
var _b = _a.children, children = _b === void 0 ? edit_action_default_children : _b, row = _a.row;
|
|
335
|
-
var
|
|
337
|
+
var showErrorModal = useCrudConfigContext().showErrorModal;
|
|
338
|
+
var _c = useTableContext(), edit = _c.edit, rowKey = _c.rowKey, table_ref = _c.table_ref, filter_ref = _c.filter_ref, form_ref = _c.form_ref, drawer = _c.drawer;
|
|
336
339
|
var _d = Modal.useModal(), modalInstance = _d[0], modalContextHolder = _d[1];
|
|
337
340
|
var _e = useState(false), edit_drawer_open = _e[0], setEdit_drawer_open = _e[1];
|
|
338
341
|
var _f = useState(), init_data = _f[0], setInit_data = _f[1];
|
|
@@ -421,7 +424,7 @@ export var EditAction = function (_a) {
|
|
|
421
424
|
case 10:
|
|
422
425
|
error_3 = _d.sent();
|
|
423
426
|
console.error(error_3);
|
|
424
|
-
modalInstance.error({
|
|
427
|
+
showErrorModal && modalInstance.error({
|
|
425
428
|
title: "错误",
|
|
426
429
|
content: String(error_3)
|
|
427
430
|
});
|
|
@@ -449,6 +452,7 @@ var delete_action_default_children = (_jsxs(Button, { size: "small", type: "link
|
|
|
449
452
|
export var DeleteAction = function (_a) {
|
|
450
453
|
var _b = _a.children, children = _b === void 0 ? delete_action_default_children : _b, row = _a.row;
|
|
451
454
|
var _c = useTableContext(), table_ref = _c.table_ref, filter_ref = _c.filter_ref, del = _c.del, rowKey = _c.rowKey;
|
|
455
|
+
var showErrorModal = useCrudConfigContext().showErrorModal;
|
|
452
456
|
var _d = Modal.useModal(), modalInstance = _d[0], modalContextHolder = _d[1];
|
|
453
457
|
var _e = useState(false), loading = _e[0], setLoading = _e[1];
|
|
454
458
|
var _f = useMemo(function () {
|
|
@@ -526,7 +530,7 @@ export var DeleteAction = function (_a) {
|
|
|
526
530
|
return [3 /*break*/, 3];
|
|
527
531
|
case 2:
|
|
528
532
|
error_5 = _a.sent();
|
|
529
|
-
modalInstance.error({
|
|
533
|
+
showErrorModal && modalInstance.error({
|
|
530
534
|
title: "错误",
|
|
531
535
|
content: String(error_5)
|
|
532
536
|
});
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { ConfigProviderProps } from "antd";
|
|
2
|
-
import React, { PropsWithChildren } from "react";
|
|
3
|
-
|
|
2
|
+
import React, { FC, PropsWithChildren } from "react";
|
|
3
|
+
export interface CustomConfigProviderProps {
|
|
4
|
+
showErrorModal?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const CrudConfigContextProvider: FC<PropsWithChildren<CustomConfigProviderProps>>;
|
|
7
|
+
export declare const useCrudConfigContext: () => CustomConfigProviderProps;
|
|
8
|
+
declare const CrudConfigProvider: React.FC<PropsWithChildren<ConfigProviderProps & CustomConfigProviderProps>>;
|
|
4
9
|
export default CrudConfigProvider;
|
package/dist/config.js
CHANGED
|
@@ -22,8 +22,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import { ConfigProvider } from "antd";
|
|
25
|
+
import React from "react";
|
|
26
|
+
var CrudConfigContext = React.createContext({});
|
|
27
|
+
export var CrudConfigContextProvider = function (_a) {
|
|
28
|
+
var children = _a.children, _b = _a.showErrorModal, showErrorModal = _b === void 0 ? true : _b;
|
|
29
|
+
return (_jsx(CrudConfigContext.Provider, { value: { showErrorModal: showErrorModal }, children: children }));
|
|
30
|
+
};
|
|
31
|
+
export var useCrudConfigContext = function () { return React.useContext(CrudConfigContext); };
|
|
25
32
|
var CrudConfigProvider = function (_a) {
|
|
26
|
-
var children = _a.children, props = __rest(_a, ["children"]);
|
|
27
|
-
return (_jsx(ConfigProvider, __assign({}, props, { children: children })));
|
|
33
|
+
var children = _a.children, _b = _a.showErrorModal, showErrorModal = _b === void 0 ? true : _b, props = __rest(_a, ["children", "showErrorModal"]);
|
|
34
|
+
return (_jsx(CrudConfigContextProvider, { showErrorModal: showErrorModal, children: _jsx(ConfigProvider, __assign({}, props, { children: children })) }));
|
|
28
35
|
};
|
|
29
36
|
export default CrudConfigProvider;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { TableContextProvider, useTableContext, } from "./components/Context";
|
|
|
4
4
|
export { default as Filter, } from "./components/Filter";
|
|
5
5
|
export { default as Action, AppendAction as MastAppend, DeleteAction as MastDelete, EditAction as MastEdit, } from "./components/Action";
|
|
6
6
|
export { default as Table, AppendAction as RowAppend, DeleteAction as RowDelete, EditAction as RowEdit, } from "./components/Table";
|
|
7
|
-
export { default as CrudConfigProvider, } from "./config";
|
|
7
|
+
export { default as CrudConfigProvider, type CustomConfigProviderProps, CrudConfigContextProvider, useCrudConfigContext, } from "./config";
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,4 @@ export { TableContextProvider, useTableContext, } from "./components/Context";
|
|
|
3
3
|
export { default as Filter, } from "./components/Filter";
|
|
4
4
|
export { default as Action, AppendAction as MastAppend, DeleteAction as MastDelete, EditAction as MastEdit, } from "./components/Action";
|
|
5
5
|
export { default as Table, AppendAction as RowAppend, DeleteAction as RowDelete, EditAction as RowEdit, } from "./components/Table";
|
|
6
|
-
export { default as CrudConfigProvider, } from "./config";
|
|
6
|
+
export { default as CrudConfigProvider, CrudConfigContextProvider, useCrudConfigContext, } from "./config";
|