@magicbe/antd-crud 0.0.32 → 0.0.35
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 +14 -25
- package/dist/components/Add.js +1 -1
- package/dist/components/Context.js +1 -1
- package/dist/components/Edit.js +1 -1
- package/dist/components/Field.js +1 -1
- package/dist/components/Filter.js +1 -1
- package/dist/components/Table.js +10 -10
- package/dist/components/index.js +2 -2
- package/package.json +3 -3
|
@@ -2,17 +2,6 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
2
2
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
|
-
var __assign = (this && this.__assign) || function () {
|
|
6
|
-
__assign = Object.assign || function(t) {
|
|
7
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
-
s = arguments[i];
|
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
-
t[p] = s[p];
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
};
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
5
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
6
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
7
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -23,8 +12,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
12
|
});
|
|
24
13
|
};
|
|
25
14
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
-
return g =
|
|
15
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
16
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
17
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
18
|
function step(op) {
|
|
30
19
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -76,7 +65,7 @@ var Action = function (_a, ref) {
|
|
|
76
65
|
/**自定义渲染数组 */
|
|
77
66
|
if (isArray(action)) {
|
|
78
67
|
var children = action.map(function (Component, key) { return (_jsx(CustormRender, { children: _jsx(Component, {}) }, key)); });
|
|
79
|
-
return (_jsx(Space,
|
|
68
|
+
return (_jsx(Space, { className: cx(wrapper_css, className), children: children }));
|
|
80
69
|
}
|
|
81
70
|
/**自定义渲染对象 */
|
|
82
71
|
if (isObject(action)) {
|
|
@@ -95,7 +84,7 @@ var Action = function (_a, ref) {
|
|
|
95
84
|
/**自定义渲染数组 */
|
|
96
85
|
if (isArray(master)) {
|
|
97
86
|
var children = master.map(function (Component, key) { return (_jsx(CustormRender, { children: _jsx(Component, {}) }, key)); });
|
|
98
|
-
return (_jsx(Space,
|
|
87
|
+
return (_jsx(Space, { className: cx(wrapper_css, className), children: children }));
|
|
99
88
|
}
|
|
100
89
|
/**自定义渲染对象 */
|
|
101
90
|
if (isObject(master)) {
|
|
@@ -130,11 +119,11 @@ var Action = function (_a, ref) {
|
|
|
130
119
|
if (edit === true)
|
|
131
120
|
edit_element = _jsx(EditAction, {});
|
|
132
121
|
}
|
|
133
|
-
return (_jsxs(Space,
|
|
122
|
+
return (_jsxs(Space, { className: cx(wrapper_css, className), children: [add_element, edit_element, del_element] }));
|
|
134
123
|
}
|
|
135
124
|
}
|
|
136
125
|
/**默认渲染 */
|
|
137
|
-
return (_jsxs(Space,
|
|
126
|
+
return (_jsxs(Space, { className: cx(wrapper_css, className), children: [_jsx(AppendAction, {}), _jsx(EditAction, {}), _jsx(DeleteAction, {})] }));
|
|
138
127
|
};
|
|
139
128
|
export default React.forwardRef(Action);
|
|
140
129
|
/**自定义渲染 */
|
|
@@ -145,7 +134,7 @@ export var CustormRender = function (_a) {
|
|
|
145
134
|
var getSelectedRows = function () { var _a; return (_a = table_ref === null || table_ref === void 0 ? void 0 : table_ref.current) === null || _a === void 0 ? void 0 : _a.selected_rows; };
|
|
146
135
|
return React.cloneElement(children, { add: add, edit: edit, del: del, getSelectedKeys: getSelectedKeys, getSelectedRows: getSelectedRows });
|
|
147
136
|
};
|
|
148
|
-
var append_action_default_children = (_jsxs(
|
|
137
|
+
var append_action_default_children = (_jsxs(Button, { type: "primary", children: [_jsx(PlusOutlined, {}), "\u65B0\u589E"] }));
|
|
149
138
|
/**新增方法 */
|
|
150
139
|
export var AppendAction = function (_a) {
|
|
151
140
|
var _b = _a.children, children = _b === void 0 ? append_action_default_children : _b;
|
|
@@ -240,7 +229,7 @@ export var AppendAction = function (_a) {
|
|
|
240
229
|
}); });
|
|
241
230
|
};
|
|
242
231
|
/**新增操作 */
|
|
243
|
-
var add_extra = (_jsxs(Space, { children: [_jsx(Button,
|
|
232
|
+
var add_extra = (_jsxs(Space, { children: [_jsx(Button, { onClick: switchAddDrawer, children: "\u53D6\u6D88" }), _jsx(Button, { type: "primary", onClick: onConfirm, loading: loading, children: "\u786E\u5B9A" })] }));
|
|
244
233
|
var drawer_width = useMemo(function () {
|
|
245
234
|
if (isNumber(drawer))
|
|
246
235
|
return drawer;
|
|
@@ -248,9 +237,9 @@ export var AppendAction = function (_a) {
|
|
|
248
237
|
return drawer.add;
|
|
249
238
|
return 600;
|
|
250
239
|
}, [drawer]);
|
|
251
|
-
return (_jsxs(Fragment, { children: [
|
|
240
|
+
return (_jsxs(Fragment, { children: [React.cloneElement(children, { onClick: switchAddDrawer }), _jsx(Drawer, { 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, keyboard: false, children: _jsx(AddForm, { ref: form_ref, default_data: init_data }) }), modalContextHolder] }));
|
|
252
241
|
};
|
|
253
|
-
var delete_action_default_children = (_jsxs(
|
|
242
|
+
var delete_action_default_children = (_jsxs(Button, { type: "primary", danger: true, children: [_jsx(DeleteOutlined, {}), "\u5220\u9664"] }));
|
|
254
243
|
/**删除方法 */
|
|
255
244
|
export var DeleteAction = function (_a) {
|
|
256
245
|
var _b = _a.children, children = _b === void 0 ? delete_action_default_children : _b;
|
|
@@ -355,9 +344,9 @@ export var DeleteAction = function (_a) {
|
|
|
355
344
|
});
|
|
356
345
|
});
|
|
357
346
|
};
|
|
358
|
-
return (_jsxs(Fragment, { children: [
|
|
347
|
+
return (_jsxs(Fragment, { children: [React.cloneElement(children, { onClick: onClick, loading: loading }), modalContextHolder] }));
|
|
359
348
|
};
|
|
360
|
-
var edit_action_default_children = (_jsxs(
|
|
349
|
+
var edit_action_default_children = (_jsxs(Button, { children: [_jsx(EditFilled, {}), "\u7F16\u8F91"] }));
|
|
361
350
|
/**编辑方法 */
|
|
362
351
|
export var EditAction = function (_a) {
|
|
363
352
|
var _b = _a.children, children = _b === void 0 ? edit_action_default_children : _b;
|
|
@@ -454,7 +443,7 @@ export var EditAction = function (_a) {
|
|
|
454
443
|
}); });
|
|
455
444
|
};
|
|
456
445
|
/**编辑操作 */
|
|
457
|
-
var edit_extra = (_jsxs(Space, { children: [_jsx(Button,
|
|
446
|
+
var edit_extra = (_jsxs(Space, { children: [_jsx(Button, { onClick: switchEditDrawer, children: "\u53D6\u6D88" }), _jsx(Button, { type: "primary", onClick: onConfirm, loading: loading, children: "\u786E\u5B9A" })] }));
|
|
458
447
|
var drawer_width = useMemo(function () {
|
|
459
448
|
if (isNumber(drawer))
|
|
460
449
|
return drawer;
|
|
@@ -462,6 +451,6 @@ export var EditAction = function (_a) {
|
|
|
462
451
|
return drawer.add;
|
|
463
452
|
return 600;
|
|
464
453
|
}, [drawer]);
|
|
465
|
-
return (_jsxs(Fragment, { children: [
|
|
454
|
+
return (_jsxs(Fragment, { children: [React.cloneElement(children, { onClick: onClick }), _jsx(Drawer, { 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, keyboard: false, children: _jsx(EditForm, { ref: form_ref, default_data: init_data }) }), modalContextHolder] }));
|
|
466
455
|
};
|
|
467
456
|
var templateObject_1;
|
package/dist/components/Add.js
CHANGED
|
@@ -53,6 +53,6 @@ var AddForm = React.forwardRef(function (_a, ref) {
|
|
|
53
53
|
useImperativeHandle(ref, function () { return ({
|
|
54
54
|
form: form,
|
|
55
55
|
}); });
|
|
56
|
-
return (_jsx(AntdForm,
|
|
56
|
+
return (_jsx(AntdForm, { form: form, layout: "vertical", initialValues: default_data, children: fields.map(function (field) { return _createElement(Field, __assign({}, field, { key: String(field.dataIndex) })); }) }));
|
|
57
57
|
});
|
|
58
58
|
export default AddForm;
|
|
@@ -37,7 +37,7 @@ var TableContextProviderPrev = function (_a, ref) {
|
|
|
37
37
|
content_ref: content_ref,
|
|
38
38
|
form_ref: form_ref,
|
|
39
39
|
}); });
|
|
40
|
-
return (_jsx(TableContext.Provider,
|
|
40
|
+
return (_jsx(TableContext.Provider, { 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 }));
|
|
41
41
|
};
|
|
42
42
|
export var TableContextProvider = React.forwardRef(TableContextProviderPrev);
|
|
43
43
|
export var useTableContext = function () { return useContext(TableContext); };
|
package/dist/components/Edit.js
CHANGED
|
@@ -53,6 +53,6 @@ var EditForm = React.forwardRef(function (_a, ref) {
|
|
|
53
53
|
useImperativeHandle(ref, function () { return ({
|
|
54
54
|
form: form,
|
|
55
55
|
}); });
|
|
56
|
-
return (_jsx(AntdForm,
|
|
56
|
+
return (_jsx(AntdForm, { form: form, layout: "vertical", initialValues: default_data, children: fields.map(function (field) { return _createElement(Field, __assign({}, field, { key: String(field.dataIndex) })); }) }));
|
|
57
57
|
});
|
|
58
58
|
export default EditForm;
|
package/dist/components/Field.js
CHANGED
|
@@ -65,6 +65,6 @@ var Field = function (props) {
|
|
|
65
65
|
};
|
|
66
66
|
return getNext(field);
|
|
67
67
|
}, [field, dataIndex, title]), Component = _a.Component, name = _a.name, label = _a.label, _b = _a.option, option = _b === void 0 ? {} : _b, rules = _a.rules;
|
|
68
|
-
return (_jsx(Form.Item,
|
|
68
|
+
return (_jsx(Form.Item, { name: name, label: label, rules: rules, hidden: field === "Hidden", children: _jsx(Component, __assign({}, option)) }));
|
|
69
69
|
};
|
|
70
70
|
export default Field;
|
|
@@ -67,7 +67,7 @@ var Filter = function (_a, ref) {
|
|
|
67
67
|
var initialValues;
|
|
68
68
|
if (!(filters === null || filters === void 0 ? void 0 : filters.length))
|
|
69
69
|
return _jsx(Fragment, {});
|
|
70
|
-
return (_jsxs(Form,
|
|
70
|
+
return (_jsxs(Form, { layout: "inline", onFinish: onFinish, className: wrapper_css, form: form, initialValues: initialValues, children: [filters === null || filters === void 0 ? void 0 : filters.map(function (filter) { return _createElement(Field, __assign({}, filter, { key: String(filter.dataIndex) })); }), _jsxs(Space, { children: [_jsxs(Button, { htmlType: "submit", type: "primary", children: [_jsx(SearchOutlined, {}), "\u67E5\u8BE2"] }), _jsxs(Button, { htmlType: "reset", children: [_jsx(UndoOutlined, {}), "\u91CD\u7F6E"] })] })] }));
|
|
71
71
|
};
|
|
72
72
|
export default React.forwardRef(Filter);
|
|
73
73
|
var templateObject_1;
|
package/dist/components/Table.js
CHANGED
|
@@ -19,8 +19,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g =
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
24
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
25
|
function step(op) {
|
|
26
26
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -200,7 +200,7 @@ var Table = function (_a, ref) {
|
|
|
200
200
|
return (_jsx(AntdTable, __assign({}, props, { rowSelection: rowSelection, columns: columns, loading: loading, onChange: loadRecords, dataSource: sources, pagination: pagination })));
|
|
201
201
|
};
|
|
202
202
|
export default React.forwardRef(Table);
|
|
203
|
-
var append_action_default_children = (_jsxs(
|
|
203
|
+
var append_action_default_children = (_jsxs(Button, { type: "link", size: "small", children: [_jsx(PlusOutlined, {}), "\u65B0\u589E"] }));
|
|
204
204
|
export var AppendAction = function (_a) {
|
|
205
205
|
var _b = _a.children, children = _b === void 0 ? append_action_default_children : _b, row = _a.row;
|
|
206
206
|
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;
|
|
@@ -313,7 +313,7 @@ export var AppendAction = function (_a) {
|
|
|
313
313
|
});
|
|
314
314
|
}); };
|
|
315
315
|
/**新增操作 */
|
|
316
|
-
var add_extra = (_jsxs(Space, { children: [_jsx(Button,
|
|
316
|
+
var add_extra = (_jsxs(Space, { children: [_jsx(Button, { onClick: switchAddDrawer, children: "\u53D6\u6D88" }), _jsx(Button, { type: "primary", onClick: onConfirm, loading: loading, children: "\u786E\u5B9A" })] }));
|
|
317
317
|
var drawer_width = useMemo(function () {
|
|
318
318
|
if (isNumber(drawer))
|
|
319
319
|
return drawer;
|
|
@@ -321,9 +321,9 @@ export var AppendAction = function (_a) {
|
|
|
321
321
|
return drawer.add;
|
|
322
322
|
return 600;
|
|
323
323
|
}, [drawer]);
|
|
324
|
-
return (_jsxs(Fragment, { children: [
|
|
324
|
+
return (_jsxs(Fragment, { children: [React.cloneElement(children, { onClick: onClick }), _jsx(Drawer, { 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, keyboard: false, children: _jsx(AddForm, { default_data: init_data, ref: form_ref }) }), modalContextHolder] }));
|
|
325
325
|
};
|
|
326
|
-
var edit_action_default_children = (_jsxs(
|
|
326
|
+
var edit_action_default_children = (_jsxs(Button, { type: "link", size: "small", children: [_jsx(EditFilled, {}), "\u7F16\u8F91"] }));
|
|
327
327
|
export var EditAction = function (_a) {
|
|
328
328
|
var _b = _a.children, children = _b === void 0 ? edit_action_default_children : _b, row = _a.row;
|
|
329
329
|
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;
|
|
@@ -429,7 +429,7 @@ export var EditAction = function (_a) {
|
|
|
429
429
|
}); });
|
|
430
430
|
};
|
|
431
431
|
/**新增操作 */
|
|
432
|
-
var edit_extra = (_jsxs(Space, { children: [_jsx(Button,
|
|
432
|
+
var edit_extra = (_jsxs(Space, { children: [_jsx(Button, { onClick: switchEditDrawer, children: "\u53D6\u6D88" }), _jsx(Button, { type: "primary", onClick: onConfirm, loading: loading, children: "\u786E\u5B9A" })] }));
|
|
433
433
|
var drawer_width = useMemo(function () {
|
|
434
434
|
if (isNumber(drawer))
|
|
435
435
|
return drawer;
|
|
@@ -437,9 +437,9 @@ export var EditAction = function (_a) {
|
|
|
437
437
|
return drawer.add;
|
|
438
438
|
return 600;
|
|
439
439
|
}, [drawer]);
|
|
440
|
-
return (_jsxs(Fragment, { children: [
|
|
440
|
+
return (_jsxs(Fragment, { children: [React.cloneElement(children, { onClick: onClick, loading: clickLoading }), _jsx(Drawer, { 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, keyboard: false, children: _jsx(EditForm, { ref: form_ref, default_data: init_data }) }), modalContextHolder] }));
|
|
441
441
|
};
|
|
442
|
-
var delete_action_default_children = (_jsxs(
|
|
442
|
+
var delete_action_default_children = (_jsxs(Button, { size: "small", type: "link", danger: true, children: [_jsx(DeleteOutlined, {}), "\u5220\u9664"] }));
|
|
443
443
|
export var DeleteAction = function (_a) {
|
|
444
444
|
var _b = _a.children, children = _b === void 0 ? delete_action_default_children : _b, row = _a.row;
|
|
445
445
|
var _c = useTableContext(), table_ref = _c.table_ref, filter_ref = _c.filter_ref, del = _c.del, rowKey = _c.rowKey;
|
|
@@ -540,5 +540,5 @@ export var DeleteAction = function (_a) {
|
|
|
540
540
|
});
|
|
541
541
|
});
|
|
542
542
|
};
|
|
543
|
-
return (_jsxs(Fragment, { children: [
|
|
543
|
+
return (_jsxs(Fragment, { children: [React.cloneElement(children, { onClick: onClick, loading: loading }), modalContextHolder] }));
|
|
544
544
|
};
|
package/dist/components/index.js
CHANGED
|
@@ -17,9 +17,9 @@ import Table from "./Table";
|
|
|
17
17
|
import { TableContextProvider, useTableContext } from "./Context";
|
|
18
18
|
var Content = function () {
|
|
19
19
|
var _a = useTableContext(), filter_ref = _a.filter_ref, action_ref = _a.action_ref, table_ref = _a.table_ref, content_ref = _a.content_ref;
|
|
20
|
-
return (_jsxs("div",
|
|
20
|
+
return (_jsxs("div", { 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
|
-
return (_jsx(TableContextProvider, __assign({}, props, { ref: ref
|
|
23
|
+
return (_jsx(TableContextProvider, __assign({}, props, { ref: ref, children: _jsx(Content, {}) })));
|
|
24
24
|
};
|
|
25
25
|
export default React.forwardRef(ContentPrev);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicbe/antd-crud",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"description": "antd crud table",
|
|
5
5
|
"author": "wang quan",
|
|
6
6
|
"private": false,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@ant-design/icons": "^5.4.0",
|
|
22
22
|
"@emotion/css": "^11.13.0",
|
|
23
|
-
"antd": "5.
|
|
23
|
+
"antd": "5.22.5",
|
|
24
24
|
"deepmerge": "^4.3.1",
|
|
25
25
|
"lodash": "^4.17.21",
|
|
26
26
|
"react": "^18.2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@types/react-dom": "^18.0.9",
|
|
42
42
|
"http-proxy-middleware": "^3.0.0",
|
|
43
43
|
"react-scripts": "^5.0.1",
|
|
44
|
-
"typescript": "
|
|
44
|
+
"typescript": "5.7.3"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"lint": "eslint --ext js,ts,tsx src --max-warnings 5",
|