@quansitech/antd-admin 1.1.3 → 1.1.4
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 +1 -1
- package/dist/components/Column/Readonly/Action.js +7 -9
- 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.js +8 -38
- 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 +44 -70
- package/dist/components/Layout.d.ts +1 -3
- package/dist/components/Layout.js +73 -31
- 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 +44 -84
- package/dist/components/TableContext.d.ts +5 -1
- 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 +3 -1
- package/dist/lib/helpers.js +30 -5
- package/dist/lib/schemaHandler.js +25 -0
- package/dist/lib/writeExtra.js +1 -1
- package/package.json +2 -1
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,19 +60,22 @@ 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);
|
|
@@ -89,81 +91,37 @@ export default function (props) {
|
|
|
89
91
|
setEditableKeys = _useState2[1];
|
|
90
92
|
var _useState3 = useState([]),
|
|
91
93
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
selectedRows = _useState4[0],
|
|
95
|
+
setSelectedRows = _useState4[1];
|
|
94
96
|
var _useState5 = useState([]),
|
|
95
97
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
var _useState7 = useState(
|
|
98
|
+
editableValues = _useState6[0],
|
|
99
|
+
setEditableValues = _useState6[1];
|
|
100
|
+
var _useState7 = useState(false),
|
|
99
101
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var _useState9 = useState(
|
|
102
|
+
loading = _useState8[0],
|
|
103
|
+
setLoading = _useState8[1];
|
|
104
|
+
var _useState9 = useState(),
|
|
103
105
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var _useState11 = useState(
|
|
106
|
+
pagination = _useState10[0],
|
|
107
|
+
setPagination = _useState10[1];
|
|
108
|
+
var _useState11 = useState([]),
|
|
107
109
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
var _useState13 = useState(),
|
|
110
|
+
dataSource = _useState12[0],
|
|
111
|
+
setDataSource = _useState12[1];
|
|
112
|
+
var _useState13 = useState(true),
|
|
111
113
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
sticky = _useState14[0],
|
|
115
|
+
setSticky = _useState14[1];
|
|
114
116
|
var _useState15 = useState([]),
|
|
115
117
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
var
|
|
119
|
-
_useState18 = _slicedToArray(_useState17, 2),
|
|
120
|
-
sticky = _useState18[0],
|
|
121
|
-
setSticky = _useState18[1];
|
|
122
|
-
var modalContext = useContext(ModalContext);
|
|
123
|
-
useEffect(function () {
|
|
118
|
+
extraRenderValues = _useState16[0],
|
|
119
|
+
setExtraRenderValues = _useState16[1];
|
|
120
|
+
var columns = useMemo(function () {
|
|
124
121
|
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) {
|
|
122
|
+
return (_cloneDeep = cloneDeep(props.columns)) === null || _cloneDeep === void 0 ? void 0 : _cloneDeep.map(function (c) {
|
|
131
123
|
var _props$defaultSearchV;
|
|
132
124
|
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
125
|
if (((_props$defaultSearchV = props.defaultSearchValue) === null || _props$defaultSearchV === void 0 ? void 0 : _props$defaultSearchV[c.dataIndex]) !== undefined) {
|
|
168
126
|
c.initialValue = props.defaultSearchValue[c.dataIndex];
|
|
169
127
|
}
|
|
@@ -172,9 +130,15 @@ export default function (props) {
|
|
|
172
130
|
return container.schemaHandler[c.valueType](c);
|
|
173
131
|
}
|
|
174
132
|
return c;
|
|
175
|
-
})
|
|
133
|
+
});
|
|
134
|
+
}, [props.columns]);
|
|
135
|
+
var modalContext = useContext(ModalContext);
|
|
136
|
+
useEffect(function () {
|
|
137
|
+
// @ts-ignore
|
|
138
|
+
setPagination(props.pagination || false);
|
|
139
|
+
setDataSource(postData(props.dataSource));
|
|
140
|
+
setExtraRenderValues(props.extraRenderValues);
|
|
176
141
|
setLoading(false);
|
|
177
|
-
setInitialized(true);
|
|
178
142
|
if (!modalContext.inModal) {
|
|
179
143
|
var _document$querySelect;
|
|
180
144
|
setSticky({
|
|
@@ -186,7 +150,7 @@ export default function (props) {
|
|
|
186
150
|
if (!isArray(data)) {
|
|
187
151
|
return data;
|
|
188
152
|
}
|
|
189
|
-
|
|
153
|
+
columns.map(function (column) {
|
|
190
154
|
switch (column.valueType) {
|
|
191
155
|
case 'dateTime':
|
|
192
156
|
data = data.map(function (row) {
|
|
@@ -217,16 +181,11 @@ export default function (props) {
|
|
|
217
181
|
editableKeys: editableKeys,
|
|
218
182
|
actionRef: actionRef.current,
|
|
219
183
|
formRef: formRef.current,
|
|
220
|
-
extraRenderValues:
|
|
184
|
+
extraRenderValues: extraRenderValues,
|
|
185
|
+
dataSource: dataSource
|
|
221
186
|
}
|
|
222
|
-
},
|
|
223
|
-
type: "list",
|
|
224
|
-
list: 2
|
|
225
|
-
}), /*#__PURE__*/React.createElement(ProTable, {
|
|
187
|
+
}, /*#__PURE__*/React.createElement(ProTable, {
|
|
226
188
|
rowKey: props.rowKey,
|
|
227
|
-
style: {
|
|
228
|
-
display: initialized ? 'block' : 'none'
|
|
229
|
-
},
|
|
230
189
|
tableClassName: 'qs-antd-table',
|
|
231
190
|
columns: columns,
|
|
232
191
|
onDataSourceChange: setDataSource,
|
|
@@ -250,6 +209,7 @@ export default function (props) {
|
|
|
250
209
|
// 是否立即搜索
|
|
251
210
|
if (c.searchOnChange) {
|
|
252
211
|
var _formRef$current;
|
|
212
|
+
// @ts-ignore
|
|
253
213
|
(_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.submit();
|
|
254
214
|
}
|
|
255
215
|
}
|
|
@@ -6,9 +6,13 @@ 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
18
|
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,5 +1,6 @@
|
|
|
1
1
|
import { VisitOptions } from "@inertiajs/core/types/types";
|
|
2
2
|
import { Rules } from "@rc-component/async-validator/lib/interface";
|
|
3
|
+
import { ModalFuncProps } from "antd";
|
|
3
4
|
export declare function replaceUrl(url: string, params: any): string;
|
|
4
5
|
export declare function replaceParams(params: Record<string, any>, data: Record<string, any>): Record<string, any>;
|
|
5
6
|
export declare function routerNavigateTo(url: string, config?: VisitOptions): void;
|
|
@@ -9,6 +10,7 @@ export declare function filterObjectKeys(obj: Record<string, any>, keysToKeep: s
|
|
|
9
10
|
export declare function createScript(url: string): Promise<unknown>;
|
|
10
11
|
export declare function modalShow(options: ModalOptions): Promise<{
|
|
11
12
|
destroy: () => void;
|
|
12
|
-
update: (configUpdate:
|
|
13
|
+
update: (configUpdate: ModalFuncProps | ((prevConfig: ModalFuncProps) => ModalFuncProps)) => void;
|
|
13
14
|
}>;
|
|
14
15
|
export declare function upperFirst(str: string): string;
|
|
16
|
+
export declare function getProValueTypeMap(): any;
|
package/dist/lib/helpers.js
CHANGED
|
@@ -11,9 +11,10 @@ import { router } from "@inertiajs/react";
|
|
|
11
11
|
import Schema from '@rc-component/async-validator';
|
|
12
12
|
import http from "./http";
|
|
13
13
|
import container from "./container";
|
|
14
|
-
import React, {
|
|
14
|
+
import React, { Suspense } from "react";
|
|
15
15
|
import global from "./global";
|
|
16
16
|
import { ModalContext } from "../components/ModalContext";
|
|
17
|
+
import { uniq } from "lodash";
|
|
17
18
|
export function replaceUrl(url, params) {
|
|
18
19
|
return url.replace(/__([\w]+)__/g, function (match, key) {
|
|
19
20
|
return params[key] || match;
|
|
@@ -141,9 +142,7 @@ function _modalShow() {
|
|
|
141
142
|
}
|
|
142
143
|
throw new Error('modal props is empty');
|
|
143
144
|
case 10:
|
|
144
|
-
Component =
|
|
145
|
-
return container.get('Modal.' + upperFirst(props.type));
|
|
146
|
-
});
|
|
145
|
+
Component = container.get('Modal.' + upperFirst(props.type));
|
|
147
146
|
_afterClose = function afterClose() {};
|
|
148
147
|
modal = global.modal.info(_objectSpread(_objectSpread({}, options), {}, {
|
|
149
148
|
closable: true,
|
|
@@ -161,7 +160,7 @@ function _modalShow() {
|
|
|
161
160
|
_afterClose = callback;
|
|
162
161
|
}
|
|
163
162
|
}
|
|
164
|
-
}, /*#__PURE__*/React.createElement(Component, props)),
|
|
163
|
+
}, /*#__PURE__*/React.createElement(Suspense, null, /*#__PURE__*/React.createElement(Component, props))),
|
|
165
164
|
afterClose: function afterClose() {
|
|
166
165
|
_afterClose && _afterClose();
|
|
167
166
|
}
|
|
@@ -180,4 +179,30 @@ function _modalShow() {
|
|
|
180
179
|
}
|
|
181
180
|
export function upperFirst(str) {
|
|
182
181
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
182
|
+
}
|
|
183
|
+
export function getProValueTypeMap() {
|
|
184
|
+
var columnKeys = Object.keys(container.list('Column.'));
|
|
185
|
+
var readonlyKeys = Object.keys(container.list('Column.Readonly.'));
|
|
186
|
+
var types = uniq(columnKeys.concat(readonlyKeys));
|
|
187
|
+
return types.reduce(function (map, type) {
|
|
188
|
+
map[type] = {
|
|
189
|
+
render: function render(text, props) {
|
|
190
|
+
var renderComponent = 'Column.Readonly.' + upperFirst(type);
|
|
191
|
+
if (container.check(renderComponent)) {
|
|
192
|
+
var Component = container.get(renderComponent);
|
|
193
|
+
return /*#__PURE__*/React.createElement(Suspense, null, /*#__PURE__*/React.createElement(Component, props));
|
|
194
|
+
}
|
|
195
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, text);
|
|
196
|
+
},
|
|
197
|
+
renderFormItem: function renderFormItem(text, props) {
|
|
198
|
+
var renderComponent = 'Column.' + upperFirst(type);
|
|
199
|
+
if (container.check(renderComponent)) {
|
|
200
|
+
var Component = container.get(renderComponent);
|
|
201
|
+
return /*#__PURE__*/React.createElement(Suspense, null, /*#__PURE__*/React.createElement(Component, props));
|
|
202
|
+
}
|
|
203
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, text);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
return map;
|
|
207
|
+
}, {});
|
|
183
208
|
}
|
|
@@ -80,6 +80,7 @@ export var schemaHandler = {
|
|
|
80
80
|
schema.formItemProps.rules.push({
|
|
81
81
|
validator: uploadValidator
|
|
82
82
|
});
|
|
83
|
+
schema.fieldProps.dataIndex = schema.dataIndex;
|
|
83
84
|
return _objectSpread(_objectSpread({}, schema), {}, {
|
|
84
85
|
transform: uploadTransform
|
|
85
86
|
});
|
|
@@ -88,10 +89,34 @@ export var schemaHandler = {
|
|
|
88
89
|
schema.formItemProps.rules.push({
|
|
89
90
|
validator: uploadValidator
|
|
90
91
|
});
|
|
92
|
+
schema.fieldProps.dataIndex = schema.dataIndex;
|
|
91
93
|
return _objectSpread(_objectSpread({}, schema), {}, {
|
|
92
94
|
transform: uploadTransform
|
|
93
95
|
});
|
|
94
96
|
},
|
|
97
|
+
action: function action(schema) {
|
|
98
|
+
schema.fieldProps = {
|
|
99
|
+
actions: schema.actions
|
|
100
|
+
};
|
|
101
|
+
return schema;
|
|
102
|
+
},
|
|
103
|
+
ueditor: function ueditor(schema) {
|
|
104
|
+
if (!schema.formItemProps) {
|
|
105
|
+
schema.formItemProps = {};
|
|
106
|
+
}
|
|
107
|
+
if (!schema.fieldProps.rules) {
|
|
108
|
+
schema.fieldProps.rules = [];
|
|
109
|
+
}
|
|
110
|
+
// schema.formItemProps.rules.push({
|
|
111
|
+
// validator: async (rule: any, value: any) => {
|
|
112
|
+
// if (this.catching) {
|
|
113
|
+
// throw new Error('正在抓取图片')
|
|
114
|
+
// }
|
|
115
|
+
// return true
|
|
116
|
+
// }
|
|
117
|
+
// })
|
|
118
|
+
return _objectSpread({}, schema);
|
|
119
|
+
},
|
|
95
120
|
select: function select(schema) {
|
|
96
121
|
var _schema$fieldProps;
|
|
97
122
|
schema.searchOnChange = true;
|
package/dist/lib/writeExtra.js
CHANGED
|
@@ -20,7 +20,7 @@ export default function () {
|
|
|
20
20
|
var extra_script = "\nimport {container} from \"@quansitech/antd-admin\";\n\n".concat(extras.map(function (e) {
|
|
21
21
|
var cs = [];
|
|
22
22
|
for (var componentKey in e.component) {
|
|
23
|
-
cs.push("container.register('".concat(componentKey, "', ()
|
|
23
|
+
cs.push("container.register('".concat(componentKey, "', ()=>import('../../../vendor").concat(path.join('/', e.path, e.component[componentKey]), "'));"));
|
|
24
24
|
}
|
|
25
25
|
return cs.join('\n');
|
|
26
26
|
}), "\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quansitech/antd-admin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@types/react": "^18.3.0",
|
|
26
26
|
"@types/react-dom": "^18.3.0",
|
|
27
27
|
"father": "^4.5.1",
|
|
28
|
+
"jest": "^29.7.0",
|
|
28
29
|
"sass-embedded": "^1.80.6",
|
|
29
30
|
"typescript": "^5.6.3"
|
|
30
31
|
},
|