@quansitech/antd-admin 1.1.3 → 1.1.5
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/Column/Cascader.js +6 -4
- package/dist/components/Column/File.js +14 -10
- package/dist/components/Column/Readonly/Action/index.d.ts +1 -1
- package/dist/components/Column/Readonly/Action/index.js +3 -1
- package/dist/components/Column/Readonly/Action.d.ts +2 -3
- package/dist/components/Column/Readonly/Action.js +29 -64
- package/dist/components/Column/Readonly/Cascader.js +6 -8
- package/dist/components/Column/Readonly/File.js +6 -2
- package/dist/components/Column/Readonly/Ueditor.d.ts +1 -0
- package/dist/components/Column/Readonly/Ueditor.js +3 -2
- package/dist/components/Column/Readonly/Ueditor.scss +6 -0
- package/dist/components/Column/Readonly/index.d.ts +5 -5
- package/dist/components/Column/Readonly/index.js +15 -5
- package/dist/components/Column/Readonly/types.d.ts +4 -6
- package/dist/components/Column/Ueditor.d.ts +0 -1
- package/dist/components/Column/Ueditor.js +25 -47
- package/dist/components/Column/index.d.ts +4 -4
- package/dist/components/Column/index.js +12 -4
- package/dist/components/Form/Action/index.d.ts +1 -1
- package/dist/components/Form/Action/index.js +3 -1
- package/dist/components/Form/Actions.js +10 -22
- package/dist/components/Form.d.ts +3 -0
- package/dist/components/Form.js +13 -63
- package/dist/components/Layout/New.d.ts +2 -2
- package/dist/components/Layout/New.js +61 -91
- package/dist/components/Layout.d.ts +1 -3
- package/dist/components/Layout.js +65 -39
- package/dist/components/Table/Action/Button.js +13 -14
- package/dist/components/Table/Action/StartEditable.d.ts +1 -0
- package/dist/components/Table/Action/StartEditable.js +61 -15
- package/dist/components/Table/Action/index.d.ts +2 -2
- package/dist/components/Table/Action/index.js +6 -2
- package/dist/components/Table/ToolbarActions.js +7 -10
- package/dist/components/Table.d.ts +2 -0
- package/dist/components/Table.js +67 -110
- package/dist/components/TableContext.d.ts +6 -3
- package/dist/components/Tabs.js +17 -26
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -3
- package/dist/lib/container.d.ts +1 -0
- package/dist/lib/container.js +31 -5
- package/dist/lib/helpers.d.ts +4 -5
- package/dist/lib/helpers.js +70 -65
- package/dist/lib/http.js +6 -1
- package/dist/lib/schemaHandler.js +63 -9
- package/dist/lib/writeExtra.js +1 -1
- package/package.json +2 -1
|
@@ -35,32 +35,78 @@ export default function (props) {
|
|
|
35
35
|
setLoading = _useState2[1];
|
|
36
36
|
var onSaveClick = /*#__PURE__*/function () {
|
|
37
37
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
38
|
-
var _tableContext$actionR3;
|
|
39
|
-
return _regeneratorRuntime().wrap(function _callee$(
|
|
40
|
-
while (1) switch (
|
|
38
|
+
var data, _loop, dataKey, _tableContext$actionR3;
|
|
39
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
40
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
41
41
|
case 0:
|
|
42
42
|
setLoading(true);
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
data = tableContext.getEditedValues();
|
|
44
|
+
if (!props.saveRequest.data) {
|
|
45
|
+
_context2.next = 13;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
data = {};
|
|
49
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(dataKey) {
|
|
50
|
+
var match;
|
|
51
|
+
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
52
|
+
while (1) switch (_context.prev = _context.next) {
|
|
53
|
+
case 0:
|
|
54
|
+
data[dataKey] = [];
|
|
55
|
+
match = props.saveRequest.data[dataKey].match(/^__(\w+)__$/);
|
|
56
|
+
if (match) {
|
|
57
|
+
_context.next = 4;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
return _context.abrupt("return", 1);
|
|
61
|
+
case 4:
|
|
62
|
+
tableContext.getEditedValues().forEach(function (item) {
|
|
63
|
+
data[dataKey].push(item[match[1]]);
|
|
64
|
+
});
|
|
65
|
+
case 5:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
69
|
+
}, _loop);
|
|
70
|
+
});
|
|
71
|
+
_context2.t0 = _regeneratorRuntime().keys(props.saveRequest.data);
|
|
72
|
+
case 6:
|
|
73
|
+
if ((_context2.t1 = _context2.t0()).done) {
|
|
74
|
+
_context2.next = 13;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
dataKey = _context2.t1.value;
|
|
78
|
+
return _context2.delegateYield(_loop(dataKey), "t2", 9);
|
|
79
|
+
case 9:
|
|
80
|
+
if (!_context2.t2) {
|
|
81
|
+
_context2.next = 11;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
return _context2.abrupt("continue", 6);
|
|
85
|
+
case 11:
|
|
86
|
+
_context2.next = 6;
|
|
87
|
+
break;
|
|
88
|
+
case 13:
|
|
89
|
+
_context2.prev = 13;
|
|
90
|
+
_context2.next = 16;
|
|
45
91
|
return http({
|
|
46
92
|
method: props.saveRequest.method,
|
|
47
93
|
url: props.saveRequest.url,
|
|
48
|
-
data:
|
|
94
|
+
data: data
|
|
49
95
|
});
|
|
50
|
-
case
|
|
51
|
-
|
|
96
|
+
case 16:
|
|
97
|
+
_context2.next = 18;
|
|
52
98
|
return (_tableContext$actionR3 = tableContext.actionRef) === null || _tableContext$actionR3 === void 0 ? void 0 : _tableContext$actionR3.reload();
|
|
53
|
-
case
|
|
54
|
-
|
|
99
|
+
case 18:
|
|
100
|
+
_context2.prev = 18;
|
|
55
101
|
setLoading(false);
|
|
56
|
-
return
|
|
57
|
-
case
|
|
102
|
+
return _context2.finish(18);
|
|
103
|
+
case 21:
|
|
58
104
|
onCancelClick();
|
|
59
|
-
case
|
|
105
|
+
case 22:
|
|
60
106
|
case "end":
|
|
61
|
-
return
|
|
107
|
+
return _context2.stop();
|
|
62
108
|
}
|
|
63
|
-
}, _callee, null, [[
|
|
109
|
+
}, _callee, null, [[13,, 18, 21]]);
|
|
64
110
|
}));
|
|
65
111
|
return function onSaveClick() {
|
|
66
112
|
return _ref.apply(this, arguments);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
Button: Promise<typeof import("./Button")>;
|
|
3
|
-
StartEditable: Promise<typeof import("./StartEditable")>;
|
|
2
|
+
Button: () => Promise<typeof import("./Button")>;
|
|
3
|
+
StartEditable: () => Promise<typeof import("./StartEditable")>;
|
|
4
4
|
};
|
|
5
5
|
export default _default;
|
|
@@ -11,7 +11,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
11
11
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
12
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
import React, {
|
|
14
|
+
import React, { Suspense, useEffect, useState } from "react";
|
|
15
15
|
import container from "../../lib/container";
|
|
16
16
|
import { Badge, Space } from "antd";
|
|
17
17
|
import { upperFirst } from "es-toolkit";
|
|
@@ -25,9 +25,7 @@ export default function (_ref) {
|
|
|
25
25
|
useEffect(function () {
|
|
26
26
|
setComponents(actions.map(function (a) {
|
|
27
27
|
return {
|
|
28
|
-
Component:
|
|
29
|
-
return container.get('Table.Action.' + upperFirst(a.type));
|
|
30
|
-
}),
|
|
28
|
+
Component: container.get('Table.Action.' + upperFirst(a.type)),
|
|
31
29
|
props: _objectSpread({}, a)
|
|
32
30
|
};
|
|
33
31
|
}));
|
|
@@ -35,18 +33,17 @@ export default function (_ref) {
|
|
|
35
33
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Space, {
|
|
36
34
|
wrap: true
|
|
37
35
|
}, components.map(function (c) {
|
|
38
|
-
return
|
|
39
|
-
key: c.props.title
|
|
36
|
+
return /*#__PURE__*/React.createElement(Suspense, {
|
|
37
|
+
key: c.props.title
|
|
38
|
+
}, c.props.badge ? /*#__PURE__*/React.createElement(Badge, {
|
|
40
39
|
count: c.props.badge,
|
|
41
40
|
style: {
|
|
42
41
|
zIndex: 100
|
|
43
42
|
}
|
|
44
43
|
}, /*#__PURE__*/React.createElement(c.Component, _extends({}, c.props, {
|
|
45
44
|
selectedRows: selectedRows
|
|
46
|
-
}))) : /*#__PURE__*/React.createElement(c.Component, _extends({
|
|
47
|
-
key: c.props.title
|
|
48
|
-
}, c.props, {
|
|
45
|
+
}))) : /*#__PURE__*/React.createElement(c.Component, _extends({}, c.props, {
|
|
49
46
|
selectedRows: selectedRows
|
|
50
|
-
}));
|
|
47
|
+
})));
|
|
51
48
|
})));
|
|
52
49
|
}
|
|
@@ -15,5 +15,7 @@ export type TableProps = ProTableProps<any, any> & {
|
|
|
15
15
|
searchUrl: string;
|
|
16
16
|
search?: boolean;
|
|
17
17
|
extraRenderValues?: Record<string, any>[];
|
|
18
|
+
rowSelection: boolean;
|
|
19
|
+
dateFormatter: string;
|
|
18
20
|
};
|
|
19
21
|
export default function (props: TableProps): React.JSX.Element;
|
package/dist/components/Table.js
CHANGED
|
@@ -3,7 +3,6 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
|
3
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
7
6
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
7
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
8
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -18,9 +17,9 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
18
17
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
18
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
20
19
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
21
|
-
import React, {
|
|
22
|
-
import {
|
|
23
|
-
import { cloneDeep, isArray, uniqueId
|
|
20
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
21
|
+
import { ProTable } from "@ant-design/pro-components";
|
|
22
|
+
import { cloneDeep, isArray, uniqueId } from "es-toolkit/compat";
|
|
24
23
|
import { TableContext } from "./TableContext";
|
|
25
24
|
import ToolbarActions from "./Table/ToolbarActions";
|
|
26
25
|
import container from "../lib/container";
|
|
@@ -61,109 +60,32 @@ export default function (props) {
|
|
|
61
60
|
current: params.current
|
|
62
61
|
}));
|
|
63
62
|
}
|
|
63
|
+
if (res.data.extraRenderValues) {
|
|
64
|
+
setExtraRenderValues(res.data.extraRenderValues);
|
|
65
|
+
}
|
|
64
66
|
return _context.abrupt("return", {
|
|
65
67
|
data: res.data.dataSource || [],
|
|
66
68
|
success: true
|
|
67
69
|
});
|
|
68
|
-
case
|
|
69
|
-
_context.prev =
|
|
70
|
+
case 12:
|
|
71
|
+
_context.prev = 12;
|
|
70
72
|
setLoading(false);
|
|
71
|
-
return _context.finish(
|
|
72
|
-
case
|
|
73
|
+
return _context.finish(12);
|
|
74
|
+
case 15:
|
|
73
75
|
case "end":
|
|
74
76
|
return _context.stop();
|
|
75
77
|
}
|
|
76
|
-
}, _callee, null, [[5,,
|
|
78
|
+
}, _callee, null, [[5,, 12, 15]]);
|
|
77
79
|
}));
|
|
78
80
|
return function request(_x, _x2, _x3) {
|
|
79
81
|
return _ref.apply(this, arguments);
|
|
80
82
|
};
|
|
81
83
|
}();
|
|
82
|
-
var
|
|
83
|
-
var actionRef = useRef();
|
|
84
|
-
var _useState = useState(function () {
|
|
85
|
-
return [];
|
|
86
|
-
}),
|
|
87
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
88
|
-
editableKeys = _useState2[0],
|
|
89
|
-
setEditableKeys = _useState2[1];
|
|
90
|
-
var _useState3 = useState([]),
|
|
91
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
92
|
-
columns = _useState4[0],
|
|
93
|
-
setColumns = _useState4[1];
|
|
94
|
-
var _useState5 = useState([]),
|
|
95
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
96
|
-
selectedRows = _useState6[0],
|
|
97
|
-
setSelectedRows = _useState6[1];
|
|
98
|
-
var _useState7 = useState([]),
|
|
99
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
100
|
-
editableValues = _useState8[0],
|
|
101
|
-
setEditableValues = _useState8[1];
|
|
102
|
-
var _useState9 = useState(false),
|
|
103
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
104
|
-
loading = _useState10[0],
|
|
105
|
-
setLoading = _useState10[1];
|
|
106
|
-
var _useState11 = useState(false),
|
|
107
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
108
|
-
initialized = _useState12[0],
|
|
109
|
-
setInitialized = _useState12[1];
|
|
110
|
-
var _useState13 = useState(),
|
|
111
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
112
|
-
pagination = _useState14[0],
|
|
113
|
-
setPagination = _useState14[1];
|
|
114
|
-
var _useState15 = useState([]),
|
|
115
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
116
|
-
dataSource = _useState16[0],
|
|
117
|
-
setDataSource = _useState16[1];
|
|
118
|
-
var _useState17 = useState(true),
|
|
119
|
-
_useState18 = _slicedToArray(_useState17, 2),
|
|
120
|
-
sticky = _useState18[0],
|
|
121
|
-
setSticky = _useState18[1];
|
|
122
|
-
var modalContext = useContext(ModalContext);
|
|
123
|
-
useEffect(function () {
|
|
84
|
+
var columns = useMemo(function () {
|
|
124
85
|
var _cloneDeep;
|
|
125
|
-
|
|
126
|
-
setPagination(props.pagination || false);
|
|
127
|
-
setDataSource(postData(props.dataSource));
|
|
128
|
-
|
|
129
|
-
// 重新定义列
|
|
130
|
-
setColumns((_cloneDeep = cloneDeep(props.columns)) === null || _cloneDeep === void 0 ? void 0 : _cloneDeep.map(function (c) {
|
|
86
|
+
return (_cloneDeep = cloneDeep(props.columns)) === null || _cloneDeep === void 0 ? void 0 : _cloneDeep.map(function (c) {
|
|
131
87
|
var _props$defaultSearchV;
|
|
132
88
|
c.key = c.dataIndex;
|
|
133
|
-
|
|
134
|
-
// 列render
|
|
135
|
-
var renderComponent = 'Column.Readonly.' + upperFirst(c.valueType);
|
|
136
|
-
if (container.check(renderComponent)) {
|
|
137
|
-
var Component = /*#__PURE__*/lazy(function () {
|
|
138
|
-
return container.get(renderComponent);
|
|
139
|
-
});
|
|
140
|
-
c.render = function (dom, record, index, action) {
|
|
141
|
-
return /*#__PURE__*/React.createElement(Component, _extends({}, c, {
|
|
142
|
-
schema: c,
|
|
143
|
-
key: c.title,
|
|
144
|
-
index: index,
|
|
145
|
-
record: record
|
|
146
|
-
}));
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// 列查询及编辑render
|
|
151
|
-
var formItemComponent = 'Column.' + upperFirst(c.valueType);
|
|
152
|
-
if (container.check(formItemComponent)) {
|
|
153
|
-
var _Component = /*#__PURE__*/lazy(function () {
|
|
154
|
-
return container.get(formItemComponent);
|
|
155
|
-
});
|
|
156
|
-
c.renderFormItem = function (schema, config, form) {
|
|
157
|
-
return /*#__PURE__*/React.createElement(_Component, {
|
|
158
|
-
config: config,
|
|
159
|
-
form: form,
|
|
160
|
-
index: schema.index,
|
|
161
|
-
schema: schema,
|
|
162
|
-
fieldProps: c.fieldProps,
|
|
163
|
-
key: c.title
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
89
|
if (((_props$defaultSearchV = props.defaultSearchValue) === null || _props$defaultSearchV === void 0 ? void 0 : _props$defaultSearchV[c.dataIndex]) !== undefined) {
|
|
168
90
|
c.initialValue = props.defaultSearchValue[c.dataIndex];
|
|
169
91
|
}
|
|
@@ -172,21 +94,13 @@ export default function (props) {
|
|
|
172
94
|
return container.schemaHandler[c.valueType](c);
|
|
173
95
|
}
|
|
174
96
|
return c;
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
setInitialized(true);
|
|
178
|
-
if (!modalContext.inModal) {
|
|
179
|
-
var _document$querySelect;
|
|
180
|
-
setSticky({
|
|
181
|
-
offsetHeader: ((_document$querySelect = document.querySelector('.ant-layout-header')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.clientHeight) || 56
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}, []);
|
|
97
|
+
});
|
|
98
|
+
}, [props.columns]);
|
|
185
99
|
var postData = function postData(data) {
|
|
186
100
|
if (!isArray(data)) {
|
|
187
101
|
return data;
|
|
188
102
|
}
|
|
189
|
-
|
|
103
|
+
columns.map(function (column) {
|
|
190
104
|
switch (column.valueType) {
|
|
191
105
|
case 'dateTime':
|
|
192
106
|
data = data.map(function (row) {
|
|
@@ -206,6 +120,53 @@ export default function (props) {
|
|
|
206
120
|
return row;
|
|
207
121
|
});
|
|
208
122
|
};
|
|
123
|
+
var formRef = useRef();
|
|
124
|
+
var actionRef = useRef();
|
|
125
|
+
var _useState = useState(function () {
|
|
126
|
+
return [];
|
|
127
|
+
}),
|
|
128
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
129
|
+
editableKeys = _useState2[0],
|
|
130
|
+
setEditableKeys = _useState2[1];
|
|
131
|
+
var _useState3 = useState([]),
|
|
132
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
133
|
+
selectedRows = _useState4[0],
|
|
134
|
+
setSelectedRows = _useState4[1];
|
|
135
|
+
var _useState5 = useState([]),
|
|
136
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
137
|
+
editableValues = _useState6[0],
|
|
138
|
+
setEditableValues = _useState6[1];
|
|
139
|
+
var _useState7 = useState(false),
|
|
140
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
141
|
+
loading = _useState8[0],
|
|
142
|
+
setLoading = _useState8[1];
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
var _useState9 = useState(props.pagination),
|
|
145
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
146
|
+
pagination = _useState10[0],
|
|
147
|
+
setPagination = _useState10[1];
|
|
148
|
+
var _useState11 = useState(postData(props.dataSource)),
|
|
149
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
150
|
+
dataSource = _useState12[0],
|
|
151
|
+
setDataSource = _useState12[1];
|
|
152
|
+
var _useState13 = useState(true),
|
|
153
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
154
|
+
sticky = _useState14[0],
|
|
155
|
+
setSticky = _useState14[1];
|
|
156
|
+
var _useState15 = useState(props.extraRenderValues),
|
|
157
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
158
|
+
extraRenderValues = _useState16[0],
|
|
159
|
+
setExtraRenderValues = _useState16[1];
|
|
160
|
+
var modalContext = useContext(ModalContext);
|
|
161
|
+
useEffect(function () {
|
|
162
|
+
setLoading(false);
|
|
163
|
+
if (!modalContext.inModal) {
|
|
164
|
+
var _document$querySelect;
|
|
165
|
+
setSticky({
|
|
166
|
+
offsetHeader: ((_document$querySelect = document.querySelector('.ant-layout-header')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.clientHeight) || 56
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}, []);
|
|
209
170
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
210
171
|
value: {
|
|
211
172
|
getTableProps: function getTableProps() {
|
|
@@ -217,16 +178,11 @@ export default function (props) {
|
|
|
217
178
|
editableKeys: editableKeys,
|
|
218
179
|
actionRef: actionRef.current,
|
|
219
180
|
formRef: formRef.current,
|
|
220
|
-
extraRenderValues:
|
|
181
|
+
extraRenderValues: extraRenderValues,
|
|
182
|
+
dataSource: dataSource
|
|
221
183
|
}
|
|
222
|
-
},
|
|
223
|
-
type: "list",
|
|
224
|
-
list: 2
|
|
225
|
-
}), /*#__PURE__*/React.createElement(ProTable, {
|
|
184
|
+
}, /*#__PURE__*/React.createElement(ProTable, {
|
|
226
185
|
rowKey: props.rowKey,
|
|
227
|
-
style: {
|
|
228
|
-
display: initialized ? 'block' : 'none'
|
|
229
|
-
},
|
|
230
186
|
tableClassName: 'qs-antd-table',
|
|
231
187
|
columns: columns,
|
|
232
188
|
onDataSourceChange: setDataSource,
|
|
@@ -250,6 +206,7 @@ export default function (props) {
|
|
|
250
206
|
// 是否立即搜索
|
|
251
207
|
if (c.searchOnChange) {
|
|
252
208
|
var _formRef$current;
|
|
209
|
+
// @ts-ignore
|
|
253
210
|
(_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.submit();
|
|
254
211
|
}
|
|
255
212
|
}
|
|
@@ -2,13 +2,16 @@ import React from "react";
|
|
|
2
2
|
import { ActionType } from "@ant-design/pro-components";
|
|
3
3
|
import { TableProps } from "./Table";
|
|
4
4
|
import { FormInstance } from "antd/lib/form";
|
|
5
|
-
type TableContextValue = {
|
|
5
|
+
export type TableContextValue = {
|
|
6
6
|
getTableProps: () => TableProps;
|
|
7
7
|
getEditedValues: () => Record<string, any>[];
|
|
8
8
|
editableKeys: React.Key[];
|
|
9
|
-
actionRef?: ActionType
|
|
9
|
+
actionRef?: ActionType & {
|
|
10
|
+
startEditable: (key: React.Key, row?: any) => boolean;
|
|
11
|
+
cancelEditable: (key: React.Key) => void;
|
|
12
|
+
};
|
|
10
13
|
formRef?: FormInstance;
|
|
11
14
|
extraRenderValues?: Record<string, any>[];
|
|
15
|
+
dataSource: any[];
|
|
12
16
|
};
|
|
13
17
|
export declare const TableContext: React.Context<TableContextValue>;
|
|
14
|
-
export {};
|
package/dist/components/Tabs.js
CHANGED
|
@@ -5,53 +5,44 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { Tabs } from "antd";
|
|
8
|
-
import React, {
|
|
8
|
+
import React, { Suspense, useEffect, useMemo, useState } from "react";
|
|
9
9
|
import container from "../lib/container";
|
|
10
10
|
import { routerNavigateTo } from "../lib/helpers";
|
|
11
11
|
import { upperFirst } from "es-toolkit";
|
|
12
|
-
import { ProSkeleton } from "@ant-design/pro-components";
|
|
13
12
|
export default function (props) {
|
|
14
|
-
var _useState = useState(
|
|
13
|
+
var _useState = useState(),
|
|
15
14
|
_useState2 = _slicedToArray(_useState, 2),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
setActiveKey = _useState4[1];
|
|
22
|
-
useEffect(function () {
|
|
23
|
-
setActiveKey(props.defaultActiveKey || Object.keys(props.tabs)[0]);
|
|
24
|
-
setItems(Object.keys(props.tabs).map(function (key) {
|
|
15
|
+
activeKey = _useState2[0],
|
|
16
|
+
setActiveKey = _useState2[1];
|
|
17
|
+
var items = useMemo(function () {
|
|
18
|
+
return Object.keys(props.tabs).map(function (key) {
|
|
19
|
+
var _t$pane;
|
|
25
20
|
var t = props.tabs[key];
|
|
26
21
|
if (!t.pane) {
|
|
27
22
|
return {
|
|
28
23
|
key: key,
|
|
29
24
|
label: t.title,
|
|
30
|
-
children: /*#__PURE__*/React.createElement(React.Fragment, null
|
|
31
|
-
list: 2
|
|
32
|
-
}))
|
|
25
|
+
children: /*#__PURE__*/React.createElement(React.Fragment, null)
|
|
33
26
|
};
|
|
34
27
|
}
|
|
35
|
-
var Component =
|
|
36
|
-
var _t$pane;
|
|
37
|
-
return container.get('Tab.Pane.' + upperFirst((_t$pane = t.pane) === null || _t$pane === void 0 ? void 0 : _t$pane.component));
|
|
38
|
-
});
|
|
28
|
+
var Component = container.get('Tab.Pane.' + upperFirst((_t$pane = t.pane) === null || _t$pane === void 0 ? void 0 : _t$pane.component));
|
|
39
29
|
return {
|
|
40
30
|
key: key,
|
|
41
31
|
label: t.title,
|
|
42
|
-
children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Suspense,
|
|
43
|
-
fallback: /*#__PURE__*/React.createElement(ProSkeleton, {
|
|
44
|
-
list: 2
|
|
45
|
-
})
|
|
46
|
-
}, /*#__PURE__*/React.createElement(Component, t.pane.props)))
|
|
32
|
+
children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Suspense, null, /*#__PURE__*/React.createElement(Component, t.pane.props)))
|
|
47
33
|
};
|
|
48
|
-
})
|
|
34
|
+
});
|
|
35
|
+
}, [props.tabs]);
|
|
36
|
+
useEffect(function () {
|
|
37
|
+
setActiveKey(props.defaultActiveKey || Object.keys(props.tabs)[0]);
|
|
49
38
|
}, []);
|
|
50
39
|
var onChange = function onChange(key) {
|
|
51
40
|
setActiveKey(key);
|
|
52
41
|
var tab = props.tabs[key];
|
|
53
42
|
if (tab.url) {
|
|
54
|
-
routerNavigateTo(tab.url
|
|
43
|
+
routerNavigateTo(tab.url, {
|
|
44
|
+
preserveState: true
|
|
45
|
+
});
|
|
55
46
|
}
|
|
56
47
|
};
|
|
57
48
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tabs, {
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import container from "./lib/container";
|
|
|
2
2
|
import Layout from "./components/Layout";
|
|
3
3
|
import http from "./lib/http";
|
|
4
4
|
export { container, Layout, http, };
|
|
5
|
-
export declare const Form: Promise<typeof import("./components/Form")>;
|
|
6
|
-
export declare const Table: Promise<typeof import("./components/Table")>;
|
|
7
|
-
export declare const Tabs: Promise<typeof import("./components/Tabs")>;
|
|
5
|
+
export declare const Form: () => Promise<typeof import("./components/Form")>;
|
|
6
|
+
export declare const Table: () => Promise<typeof import("./components/Table")>;
|
|
7
|
+
export declare const Tabs: () => Promise<typeof import("./components/Tabs")>;
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,12 @@ import container from "./lib/container";
|
|
|
2
2
|
import Layout from "./components/Layout";
|
|
3
3
|
import http from "./lib/http";
|
|
4
4
|
export { container, Layout, http };
|
|
5
|
-
export var Form =
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export var Form = function Form() {
|
|
6
|
+
return import("./components/Form");
|
|
7
|
+
};
|
|
8
|
+
export var Table = function Table() {
|
|
9
|
+
return import("./components/Table");
|
|
10
|
+
};
|
|
11
|
+
export var Tabs = function Tabs() {
|
|
12
|
+
return import("./components/Tabs");
|
|
13
|
+
};
|
package/dist/lib/container.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ declare const container: {
|
|
|
3
3
|
register(name: string, componentLoader: any): void;
|
|
4
4
|
get(name: string): any;
|
|
5
5
|
check(name: string): boolean;
|
|
6
|
+
list(prefix: string): Record<string, any>;
|
|
6
7
|
schemaHandler: Record<string, (schema: any) => import("@ant-design/pro-utils").ProSchema | import("@ant-design/pro-table").ProColumnType>;
|
|
7
8
|
routerNavigateTo: typeof routerNavigateTo;
|
|
8
9
|
};
|
package/dist/lib/container.js
CHANGED
|
@@ -15,13 +15,15 @@ import columnReadonly from "../components/Column/Readonly";
|
|
|
15
15
|
import columnReadonlyAction from "../components/Column/Readonly/Action/index";
|
|
16
16
|
import tableAction from "../components/Table/Action";
|
|
17
17
|
import formAction from "../components/Form/Action";
|
|
18
|
+
import { lazy } from "react";
|
|
19
|
+
import { lowerFirst } from "lodash";
|
|
18
20
|
var components = {};
|
|
19
21
|
var container = {
|
|
20
22
|
register: function register(name, componentLoader) {
|
|
21
23
|
if (this.check(name)) {
|
|
22
24
|
throw new Error("Component ".concat(name, " already registered"));
|
|
23
25
|
}
|
|
24
|
-
components[name] = componentLoader;
|
|
26
|
+
components[name] = /*#__PURE__*/lazy(componentLoader);
|
|
25
27
|
},
|
|
26
28
|
get: function get(name) {
|
|
27
29
|
if (!this.check(name)) {
|
|
@@ -32,6 +34,19 @@ var container = {
|
|
|
32
34
|
check: function check(name) {
|
|
33
35
|
return !!components[name];
|
|
34
36
|
},
|
|
37
|
+
list: function list(prefix) {
|
|
38
|
+
var _this = this;
|
|
39
|
+
prefix = prefix.replace(/\.$/, '');
|
|
40
|
+
var keys = Object.keys(components).filter(function (key) {
|
|
41
|
+
return key.match(new RegExp("^".concat(prefix, "\\.\\w+$")));
|
|
42
|
+
}).map(function (key) {
|
|
43
|
+
return key.replace(new RegExp("^".concat(prefix, "\\.")), '');
|
|
44
|
+
});
|
|
45
|
+
return keys.reduce(function (acc, key) {
|
|
46
|
+
acc[lowerFirst(key)] = _this.get(prefix + '.' + key);
|
|
47
|
+
return acc;
|
|
48
|
+
}, {});
|
|
49
|
+
},
|
|
35
50
|
schemaHandler: schemaHandler,
|
|
36
51
|
routerNavigateTo: routerNavigateTo
|
|
37
52
|
};
|
|
@@ -66,14 +81,25 @@ function _autoRegister() {
|
|
|
66
81
|
|
|
67
82
|
// -------- 弹窗 -----------
|
|
68
83
|
{
|
|
69
|
-
container.register('Modal.Table',
|
|
70
|
-
|
|
84
|
+
container.register('Modal.Table', function () {
|
|
85
|
+
return import("../components/Table");
|
|
86
|
+
});
|
|
87
|
+
container.register('Modal.Form', function () {
|
|
88
|
+
return import("../components/Form");
|
|
89
|
+
});
|
|
90
|
+
container.register('Modal.Tabs', function () {
|
|
91
|
+
return import("../components/Tabs");
|
|
92
|
+
});
|
|
71
93
|
}
|
|
72
94
|
|
|
73
95
|
// -------- Tabs -----------
|
|
74
96
|
{
|
|
75
|
-
container.register('Tab.Pane.Table',
|
|
76
|
-
|
|
97
|
+
container.register('Tab.Pane.Table', function () {
|
|
98
|
+
return import("../components/Table");
|
|
99
|
+
});
|
|
100
|
+
container.register('Tab.Pane.Form', function () {
|
|
101
|
+
return import("../components/Form");
|
|
102
|
+
});
|
|
77
103
|
}
|
|
78
104
|
|
|
79
105
|
// -------- 表格 -----------
|
package/dist/lib/helpers.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { VisitOptions } from "@inertiajs/core/types/types";
|
|
2
|
-
import {
|
|
2
|
+
import { ModalFuncProps } from "antd";
|
|
3
3
|
export declare function replaceUrl(url: string, params: any): string;
|
|
4
4
|
export declare function replaceParams(params: Record<string, any>, data: Record<string, any>): Record<string, any>;
|
|
5
5
|
export declare function routerNavigateTo(url: string, config?: VisitOptions): void;
|
|
6
|
-
export declare function handleRules(dataRules: Rules, data: any): Promise<unknown>;
|
|
7
|
-
export declare function asyncFilter(arr: any[], predicate: (item: any) => PromiseLike<any>): Promise<any[]>;
|
|
8
|
-
export declare function filterObjectKeys(obj: Record<string, any>, keysToKeep: string[]): Record<string, any>;
|
|
9
6
|
export declare function createScript(url: string): Promise<unknown>;
|
|
10
7
|
export declare function modalShow(options: ModalOptions): Promise<{
|
|
11
8
|
destroy: () => void;
|
|
12
|
-
update: (configUpdate:
|
|
9
|
+
update: (configUpdate: ModalFuncProps | ((prevConfig: ModalFuncProps) => ModalFuncProps)) => void;
|
|
13
10
|
}>;
|
|
14
11
|
export declare function upperFirst(str: string): string;
|
|
12
|
+
export declare function getProValueTypeMap(): any;
|
|
13
|
+
export declare function handleCondition(condition: Condition, data: any): any;
|