@zhubangyun/lowcode-core 5.3.131 → 5.3.181
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/es/components/react-render/index.d.ts +5 -8
- package/es/components/react-render/index.js +12 -19
- package/es/components/react-render/react-render-factory.d.ts +3 -0
- package/es/components/react-render/react-render-factory.js +50 -0
- package/es/components/schema-render/components/schema-render-base.js +1 -1
- package/es/index.d.ts +2 -3
- package/es/index.js +2 -3
- package/es/utils/{common → api}/RestApi.d.ts +10 -8
- package/es/utils/{common → api}/RestApi.js +142 -85
- package/es/utils/api/index.d.ts +2 -0
- package/es/utils/api/index.js +49 -2
- package/es/utils/cache/index.d.ts +9 -0
- package/es/utils/cache/index.js +75 -0
- package/es/utils/common/SingletonInstanceMap.d.ts +7 -0
- package/es/utils/common/SingletonInstanceMap.js +73 -0
- package/es/utils/common/index.d.ts +0 -2
- package/es/utils/common/index.js +1 -30
- package/es/utils/{common/RestFormApi.d.ts → form/form.api.d.ts} +9 -4
- package/es/utils/{common/RestFormApi.js → form/form.api.js} +85 -36
- package/es/utils/form/form.handler.js +0 -0
- package/es/utils/form/form.instance.d.ts +26 -0
- package/es/utils/form/form.instance.js +100 -0
- package/es/utils/form/form.process.js +0 -0
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +2 -0
- package/lib/components/react-render/index.d.ts +5 -8
- package/lib/components/react-render/index.js +12 -21
- package/lib/components/react-render/react-render-factory.d.ts +3 -0
- package/lib/components/react-render/react-render-factory.js +55 -0
- package/lib/components/schema-render/components/schema-render-base.js +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +4 -6
- package/lib/utils/{common → api}/RestApi.d.ts +10 -8
- package/lib/utils/{common → api}/RestApi.js +142 -85
- package/lib/utils/api/index.d.ts +2 -0
- package/lib/utils/api/index.js +51 -2
- package/lib/utils/cache/index.d.ts +9 -0
- package/lib/utils/cache/index.js +80 -0
- package/lib/utils/common/SingletonInstanceMap.d.ts +7 -0
- package/lib/utils/common/SingletonInstanceMap.js +78 -0
- package/lib/utils/common/index.d.ts +0 -2
- package/lib/utils/common/index.js +2 -32
- package/lib/utils/{common/RestFormApi.d.ts → form/form.api.d.ts} +9 -4
- package/lib/utils/{common/RestFormApi.js → form/form.api.js} +85 -36
- package/lib/utils/form/form.handler.js +1 -0
- package/lib/utils/form/form.instance.d.ts +26 -0
- package/lib/utils/form/form.instance.js +105 -0
- package/lib/utils/form/form.process.js +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +2 -0
- package/package.json +1 -1
- package/es/utils/common/ClientCache.d.ts +0 -36
- package/es/utils/common/ClientCache.js +0 -120
- package/lib/utils/common/ClientCache.d.ts +0 -36
- package/lib/utils/common/ClientCache.js +0 -125
- /package/es/utils/{common → api}/Request.d.ts +0 -0
- /package/es/utils/{common → api}/Request.js +0 -0
- /package/lib/utils/{common → api}/Request.d.ts +0 -0
- /package/lib/utils/{common → api}/Request.js +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.SingletonInstanceMap = void 0;
|
|
6
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
var SingletonInstanceMap = exports.SingletonInstanceMap = /*#__PURE__*/function () {
|
|
9
|
+
function SingletonInstanceMap() {
|
|
10
|
+
this.valueMap = new Map();
|
|
11
|
+
this.lockMap = new Map();
|
|
12
|
+
}
|
|
13
|
+
var _proto = SingletonInstanceMap.prototype;
|
|
14
|
+
_proto.getInstance = /*#__PURE__*/function () {
|
|
15
|
+
var _getInstance = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(key) {
|
|
16
|
+
var self, value;
|
|
17
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
18
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
19
|
+
case 0:
|
|
20
|
+
self = this;
|
|
21
|
+
if (!this.valueMap.has(key)) {
|
|
22
|
+
_context2.next = 5;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
return _context2.abrupt("return", Promise.resolve(this.valueMap.get(key)));
|
|
26
|
+
case 5:
|
|
27
|
+
if (!this.lockMap.get(key)) {
|
|
28
|
+
_context2.next = 9;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
return _context2.abrupt("return", new Promise(function (resolve, reject) {
|
|
32
|
+
setTimeout( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
33
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
34
|
+
while (1) switch (_context.prev = _context.next) {
|
|
35
|
+
case 0:
|
|
36
|
+
resolve(self.getInstance(key));
|
|
37
|
+
case 1:
|
|
38
|
+
case "end":
|
|
39
|
+
return _context.stop();
|
|
40
|
+
}
|
|
41
|
+
}, _callee);
|
|
42
|
+
})), 1000);
|
|
43
|
+
}));
|
|
44
|
+
case 9:
|
|
45
|
+
_context2.prev = 9;
|
|
46
|
+
this.lockMap.set(key, true);
|
|
47
|
+
_context2.next = 13;
|
|
48
|
+
return this.createInstance(key);
|
|
49
|
+
case 13:
|
|
50
|
+
value = _context2.sent;
|
|
51
|
+
this.valueMap.set(key, value);
|
|
52
|
+
this.lockMap.set(key, false);
|
|
53
|
+
return _context2.abrupt("return", Promise.resolve(value));
|
|
54
|
+
case 19:
|
|
55
|
+
_context2.prev = 19;
|
|
56
|
+
_context2.t0 = _context2["catch"](9);
|
|
57
|
+
throw _context2.t0;
|
|
58
|
+
case 22:
|
|
59
|
+
_context2.prev = 22;
|
|
60
|
+
this.lockMap.set(key, false);
|
|
61
|
+
return _context2.finish(22);
|
|
62
|
+
case 25:
|
|
63
|
+
case "end":
|
|
64
|
+
return _context2.stop();
|
|
65
|
+
}
|
|
66
|
+
}, _callee2, this, [[9, 19, 22, 25]]);
|
|
67
|
+
}));
|
|
68
|
+
function getInstance(_x) {
|
|
69
|
+
return _getInstance.apply(this, arguments);
|
|
70
|
+
}
|
|
71
|
+
return getInstance;
|
|
72
|
+
}();
|
|
73
|
+
_proto.clear = function clear() {
|
|
74
|
+
this.lockMap.clear();
|
|
75
|
+
this.valueMap.clear();
|
|
76
|
+
};
|
|
77
|
+
return SingletonInstanceMap;
|
|
78
|
+
}();
|
|
@@ -1,43 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
exports.__esModule = true;
|
|
5
|
-
exports.
|
|
4
|
+
exports.loadPlugins = void 0;
|
|
6
5
|
exports.uuid = uuid;
|
|
7
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
8
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
9
6
|
var _uuid = require("uuid");
|
|
10
|
-
var _ClientCache = require("./ClientCache");
|
|
11
|
-
var _api = require("../api");
|
|
12
7
|
var _LoadPlugins = require("./LoadPlugins");
|
|
13
8
|
exports.loadPlugins = _LoadPlugins.loadPlugins;
|
|
14
9
|
function uuid(prefix, separator) {
|
|
15
10
|
return [prefix, separator, (0, _uuid.v4)()].filter(function (v) {
|
|
16
11
|
return !!v;
|
|
17
12
|
}).join("");
|
|
18
|
-
}
|
|
19
|
-
var schemaCache = exports.schemaCache = new _ClientCache.ClientCache({
|
|
20
|
-
name: "schema",
|
|
21
|
-
loadData: function () {
|
|
22
|
-
var _loadData = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(name) {
|
|
23
|
-
var res;
|
|
24
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
25
|
-
while (1) switch (_context.prev = _context.next) {
|
|
26
|
-
case 0:
|
|
27
|
-
_context.next = 2;
|
|
28
|
-
return _api.request.get("schemas/" + name + ".json");
|
|
29
|
-
case 2:
|
|
30
|
-
res = _context.sent;
|
|
31
|
-
return _context.abrupt("return", res.data);
|
|
32
|
-
case 4:
|
|
33
|
-
case "end":
|
|
34
|
-
return _context.stop();
|
|
35
|
-
}
|
|
36
|
-
}, _callee);
|
|
37
|
-
}));
|
|
38
|
-
function loadData(_x) {
|
|
39
|
-
return _loadData.apply(this, arguments);
|
|
40
|
-
}
|
|
41
|
-
return loadData;
|
|
42
|
-
}()
|
|
43
|
-
});
|
|
13
|
+
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { BaseRequestOptions, RestApi
|
|
1
|
+
import { BaseRequestOptions, RestApi } from "../api/RestApi";
|
|
2
|
+
import { AxiosRequestConfig } from "axios";
|
|
2
3
|
export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
4
|
+
private readonly formId;
|
|
5
|
+
private readonly mock;
|
|
3
6
|
private initialized;
|
|
4
7
|
private schema;
|
|
5
|
-
constructor(
|
|
6
|
-
initialize(): Promise<
|
|
7
|
-
search(params?: Record<string, any>, page?: number, pageSize?: number): Promise<
|
|
8
|
+
constructor(formId: string, mock?: boolean);
|
|
9
|
+
initialize(): Promise<boolean>;
|
|
10
|
+
search(params?: Record<string, any>, page?: number, pageSize?: number): Promise<import("../api/RestApi").ManyResult<DataType>>;
|
|
8
11
|
getById(id: string, options?: BaseRequestOptions<DataType>): Promise<any>;
|
|
12
|
+
save(data: DataType, options?: BaseRequestOptions<DataType>): Promise<any>;
|
|
9
13
|
create(data: DataType, options?: BaseRequestOptions<DataType>): Promise<any>;
|
|
10
14
|
update(id: string, data: DataType, options?: BaseRequestOptions<DataType>): Promise<any>;
|
|
11
15
|
deleteById(id: string, options?: BaseRequestOptions<DataType>): Promise<any>;
|
|
16
|
+
handleRequestConfig(config: AxiosRequestConfig): void;
|
|
12
17
|
}
|
|
@@ -6,13 +6,18 @@ exports.RestFormApi = void 0;
|
|
|
6
6
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
7
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
8
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
9
|
-
var _RestApi2 = require("
|
|
9
|
+
var _RestApi2 = require("../api/RestApi");
|
|
10
|
+
var _api = require("../api");
|
|
10
11
|
var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
11
|
-
function RestFormApi(
|
|
12
|
+
function RestFormApi(formId, mock) {
|
|
12
13
|
var _this;
|
|
13
|
-
_this = _RestApi.call(this, "forms
|
|
14
|
+
_this = _RestApi.call(this, "forms", {}) || this;
|
|
15
|
+
_this.formId = void 0;
|
|
16
|
+
_this.mock = void 0;
|
|
14
17
|
_this.initialized = false;
|
|
15
18
|
_this.schema = void 0;
|
|
19
|
+
_this.formId = formId;
|
|
20
|
+
_this.mock = !!mock;
|
|
16
21
|
return _this;
|
|
17
22
|
}
|
|
18
23
|
(0, _inheritsLoose2["default"])(RestFormApi, _RestApi);
|
|
@@ -22,28 +27,35 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
22
27
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
23
28
|
while (1) switch (_context.prev = _context.next) {
|
|
24
29
|
case 0:
|
|
25
|
-
if (this.initialized) {
|
|
26
|
-
_context.next =
|
|
30
|
+
if (!this.initialized) {
|
|
31
|
+
_context.next = 4;
|
|
27
32
|
break;
|
|
28
33
|
}
|
|
29
|
-
_context.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
34
|
+
return _context.abrupt("return", true);
|
|
35
|
+
case 4:
|
|
36
|
+
_context.prev = 4;
|
|
37
|
+
_context.next = 7;
|
|
38
|
+
return (0, _api.getSchema)(this.formId, this.mock);
|
|
39
|
+
case 7:
|
|
40
|
+
this.schema = _context.sent;
|
|
41
|
+
this.initialized = !!this.schema;
|
|
42
|
+
_context.next = 15;
|
|
35
43
|
break;
|
|
36
|
-
case
|
|
37
|
-
_context.prev =
|
|
38
|
-
_context.t0 = _context["catch"](
|
|
44
|
+
case 11:
|
|
45
|
+
_context.prev = 11;
|
|
46
|
+
_context.t0 = _context["catch"](4);
|
|
47
|
+
console.log("获取schema失败!", {
|
|
48
|
+
id: this.formId,
|
|
49
|
+
mock: this.mock
|
|
50
|
+
});
|
|
39
51
|
throw _context.t0;
|
|
40
|
-
case
|
|
52
|
+
case 15:
|
|
41
53
|
return _context.abrupt("return", this.initialized);
|
|
42
|
-
case
|
|
54
|
+
case 16:
|
|
43
55
|
case "end":
|
|
44
56
|
return _context.stop();
|
|
45
57
|
}
|
|
46
|
-
}, _callee, this, [[
|
|
58
|
+
}, _callee, this, [[4, 11]]);
|
|
47
59
|
}));
|
|
48
60
|
function initialize() {
|
|
49
61
|
return _initialize.apply(this, arguments);
|
|
@@ -99,65 +111,102 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
99
111
|
}
|
|
100
112
|
return getById;
|
|
101
113
|
}();
|
|
102
|
-
_proto.
|
|
103
|
-
var
|
|
114
|
+
_proto.save = /*#__PURE__*/function () {
|
|
115
|
+
var _save = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(data, options) {
|
|
116
|
+
var config;
|
|
104
117
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
105
118
|
while (1) switch (_context4.prev = _context4.next) {
|
|
106
119
|
case 0:
|
|
107
120
|
_context4.next = 2;
|
|
108
121
|
return this.initialize();
|
|
109
122
|
case 2:
|
|
110
|
-
|
|
111
|
-
|
|
123
|
+
config = {};
|
|
124
|
+
this.handleRequestConfig(config);
|
|
125
|
+
return _context4.abrupt("return", _RestApi.prototype.save.call(this, data, options));
|
|
126
|
+
case 5:
|
|
112
127
|
case "end":
|
|
113
128
|
return _context4.stop();
|
|
114
129
|
}
|
|
115
130
|
}, _callee4, this);
|
|
116
131
|
}));
|
|
117
|
-
function
|
|
118
|
-
return
|
|
132
|
+
function save(_x6, _x7) {
|
|
133
|
+
return _save.apply(this, arguments);
|
|
119
134
|
}
|
|
120
|
-
return
|
|
135
|
+
return save;
|
|
121
136
|
}();
|
|
122
|
-
_proto.
|
|
123
|
-
var
|
|
137
|
+
_proto.create = /*#__PURE__*/function () {
|
|
138
|
+
var _create = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(data, options) {
|
|
139
|
+
var config;
|
|
124
140
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
125
141
|
while (1) switch (_context5.prev = _context5.next) {
|
|
126
142
|
case 0:
|
|
127
143
|
_context5.next = 2;
|
|
128
144
|
return this.initialize();
|
|
129
145
|
case 2:
|
|
130
|
-
|
|
131
|
-
|
|
146
|
+
config = {};
|
|
147
|
+
this.handleRequestConfig(config);
|
|
148
|
+
return _context5.abrupt("return", _RestApi.prototype.create.call(this, data, options));
|
|
149
|
+
case 5:
|
|
132
150
|
case "end":
|
|
133
151
|
return _context5.stop();
|
|
134
152
|
}
|
|
135
153
|
}, _callee5, this);
|
|
136
154
|
}));
|
|
137
|
-
function
|
|
138
|
-
return
|
|
155
|
+
function create(_x8, _x9) {
|
|
156
|
+
return _create.apply(this, arguments);
|
|
139
157
|
}
|
|
140
|
-
return
|
|
158
|
+
return create;
|
|
141
159
|
}();
|
|
142
|
-
_proto.
|
|
143
|
-
var
|
|
160
|
+
_proto.update = /*#__PURE__*/function () {
|
|
161
|
+
var _update = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(id, data, options) {
|
|
162
|
+
var config;
|
|
144
163
|
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
145
164
|
while (1) switch (_context6.prev = _context6.next) {
|
|
146
165
|
case 0:
|
|
147
166
|
_context6.next = 2;
|
|
148
167
|
return this.initialize();
|
|
149
168
|
case 2:
|
|
150
|
-
|
|
151
|
-
|
|
169
|
+
config = {};
|
|
170
|
+
this.handleRequestConfig(config);
|
|
171
|
+
return _context6.abrupt("return", _RestApi.prototype.update.call(this, id, data, options));
|
|
172
|
+
case 5:
|
|
152
173
|
case "end":
|
|
153
174
|
return _context6.stop();
|
|
154
175
|
}
|
|
155
176
|
}, _callee6, this);
|
|
156
177
|
}));
|
|
157
|
-
function
|
|
178
|
+
function update(_x10, _x11, _x12) {
|
|
179
|
+
return _update.apply(this, arguments);
|
|
180
|
+
}
|
|
181
|
+
return update;
|
|
182
|
+
}();
|
|
183
|
+
_proto.deleteById = /*#__PURE__*/function () {
|
|
184
|
+
var _deleteById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(id, options) {
|
|
185
|
+
var config;
|
|
186
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
187
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
188
|
+
case 0:
|
|
189
|
+
_context7.next = 2;
|
|
190
|
+
return this.initialize();
|
|
191
|
+
case 2:
|
|
192
|
+
config = {};
|
|
193
|
+
this.handleRequestConfig(config);
|
|
194
|
+
return _context7.abrupt("return", _RestApi.prototype.deleteById.call(this, id, options));
|
|
195
|
+
case 5:
|
|
196
|
+
case "end":
|
|
197
|
+
return _context7.stop();
|
|
198
|
+
}
|
|
199
|
+
}, _callee7, this);
|
|
200
|
+
}));
|
|
201
|
+
function deleteById(_x13, _x14) {
|
|
158
202
|
return _deleteById.apply(this, arguments);
|
|
159
203
|
}
|
|
160
204
|
return deleteById;
|
|
161
205
|
}();
|
|
206
|
+
_proto.handleRequestConfig = function handleRequestConfig(config) {
|
|
207
|
+
config.params = config.params || {};
|
|
208
|
+
config.params.formId = this.formId;
|
|
209
|
+
config.params.mock = this.mock;
|
|
210
|
+
};
|
|
162
211
|
return RestFormApi;
|
|
163
212
|
}(_RestApi2.RestApi);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FormInstance } from "antd/lib";
|
|
2
|
+
import { NamePath, StoreValue } from "antd/es/form/interface";
|
|
3
|
+
declare type NamePaths = (string | number)[];
|
|
4
|
+
export declare class SubFormInstance implements FormInstance {
|
|
5
|
+
parentForm: FormInstance;
|
|
6
|
+
namePath: NamePaths;
|
|
7
|
+
constructor(form: FormInstance, namePath: NamePaths);
|
|
8
|
+
overwritePathName(name: NamePath): any[];
|
|
9
|
+
overwriteFields(fields: any[]): any[];
|
|
10
|
+
getFieldError(name: NamePath): string[];
|
|
11
|
+
getFieldValue(name: NamePath): StoreValue;
|
|
12
|
+
getFieldWarning(name: NamePath): string[];
|
|
13
|
+
getFieldsError(nameList: NamePath[] | undefined): any[];
|
|
14
|
+
getFieldsValue(nameList?: NamePath[] | true, filterFunc?: (meta: any) => boolean): any;
|
|
15
|
+
isFieldTouched(name: NamePath): boolean;
|
|
16
|
+
isFieldValidating(name: NamePath): boolean;
|
|
17
|
+
isFieldsTouched(): boolean;
|
|
18
|
+
isFieldsValidating(nameList: NamePath[]): boolean;
|
|
19
|
+
resetFields(fields: NamePath[] | undefined): void;
|
|
20
|
+
setFieldValue(name: NamePath, value: any): void;
|
|
21
|
+
setFields(fields: any[]): void;
|
|
22
|
+
setFieldsValue(values: any): void;
|
|
23
|
+
submit(): void;
|
|
24
|
+
validateFields(nameList: NamePath[] | undefined): Promise<any>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.SubFormInstance = void 0;
|
|
6
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
|
+
var SubFormInstance = exports.SubFormInstance = /*#__PURE__*/function () {
|
|
8
|
+
function SubFormInstance(form, namePath) {
|
|
9
|
+
this.parentForm = void 0;
|
|
10
|
+
this.namePath = void 0;
|
|
11
|
+
this.parentForm = form;
|
|
12
|
+
this.namePath = namePath;
|
|
13
|
+
}
|
|
14
|
+
var _proto = SubFormInstance.prototype;
|
|
15
|
+
_proto.overwritePathName = function overwritePathName(name) {
|
|
16
|
+
if (Array.isArray(name)) {
|
|
17
|
+
return [].concat(this.namePath, name);
|
|
18
|
+
} else {
|
|
19
|
+
return [].concat(this.namePath, [name]);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
_proto.overwriteFields = function overwriteFields(fields) {
|
|
23
|
+
var _this = this;
|
|
24
|
+
return fields === null || fields === void 0 ? void 0 : fields.map(function (field) {
|
|
25
|
+
return (0, _extends2["default"])({}, field, {
|
|
26
|
+
name: _this.overwritePathName(field.name)
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
_proto.getFieldError = function getFieldError(name) {
|
|
31
|
+
return this.parentForm.getFieldError(this.overwritePathName(name));
|
|
32
|
+
};
|
|
33
|
+
_proto.getFieldValue = function getFieldValue(name) {
|
|
34
|
+
return this.parentForm.getFieldValue(this.overwritePathName(name));
|
|
35
|
+
};
|
|
36
|
+
_proto.getFieldWarning = function getFieldWarning(name) {
|
|
37
|
+
return this.parentForm.getFieldWarning(this.overwritePathName(name));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
;
|
|
42
|
+
_proto.getFieldsError = function getFieldsError(nameList) {
|
|
43
|
+
var _this2 = this;
|
|
44
|
+
return this.parentForm.getFieldsError(nameList === null || nameList === void 0 ? void 0 : nameList.map(function (name) {
|
|
45
|
+
return _this2.overwritePathName(name);
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
;
|
|
51
|
+
_proto.getFieldsValue = function getFieldsValue(nameList, filterFunc) {
|
|
52
|
+
var values = (0, _extends2["default"])({}, this.parentForm.getFieldValue(this.namePath));
|
|
53
|
+
values.parent = this.parentForm.getFieldsValue(true);
|
|
54
|
+
return values;
|
|
55
|
+
};
|
|
56
|
+
_proto.isFieldTouched = function isFieldTouched(name) {
|
|
57
|
+
return this.parentForm.isFieldTouched(this.overwritePathName(name));
|
|
58
|
+
};
|
|
59
|
+
_proto.isFieldValidating = function isFieldValidating(name) {
|
|
60
|
+
return this.parentForm.isFieldValidating(this.overwritePathName(name));
|
|
61
|
+
};
|
|
62
|
+
_proto.isFieldsTouched = function isFieldsTouched() {
|
|
63
|
+
return this.parentForm.isFieldsTouched();
|
|
64
|
+
};
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
_proto.isFieldsValidating = function isFieldsValidating(nameList) {
|
|
67
|
+
var _this3 = this;
|
|
68
|
+
return this.parentForm.isFieldsValidating(nameList.map(function (name) {
|
|
69
|
+
return _this3.overwritePathName(name);
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
72
|
+
_proto.resetFields = function resetFields(fields) {
|
|
73
|
+
if (Array.isArray(fields)) {
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
this.parentForm.resetFields(this.overwriteFields(fields));
|
|
76
|
+
} else {
|
|
77
|
+
this.parentForm.resetFields();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
_proto.setFieldValue = function setFieldValue(name, value) {
|
|
81
|
+
return this.parentForm.setFieldValue(this.overwritePathName(name), value);
|
|
82
|
+
};
|
|
83
|
+
_proto.setFields = function setFields(fields) {
|
|
84
|
+
this.parentForm.setFields(this.overwriteFields(fields));
|
|
85
|
+
};
|
|
86
|
+
_proto.setFieldsValue = function setFieldsValue(values) {
|
|
87
|
+
var _this4 = this;
|
|
88
|
+
if (!values) return;
|
|
89
|
+
//删除父值
|
|
90
|
+
delete values.parent;
|
|
91
|
+
Object.keys(values).forEach(function (name) {
|
|
92
|
+
return _this4.parentForm.setFieldValue(_this4.overwritePathName(name), values[name]);
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
_proto.submit = function submit() {
|
|
96
|
+
this.parentForm.submit();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
;
|
|
101
|
+
_proto.validateFields = function validateFields(nameList) {
|
|
102
|
+
return this.parentForm.validateFields(nameList);
|
|
103
|
+
};
|
|
104
|
+
return SubFormInstance;
|
|
105
|
+
}();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import * as cache from "./cache";
|
|
1
2
|
import * as common from "./common";
|
|
2
3
|
import * as api from "./api";
|
|
3
4
|
import * as designer from "./designer";
|
|
4
5
|
declare const _default: {
|
|
5
6
|
api: typeof api;
|
|
7
|
+
cache: typeof cache;
|
|
6
8
|
designer: typeof designer;
|
|
7
9
|
common: typeof common;
|
|
8
10
|
};
|
package/lib/utils/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
var cache = _interopRequireWildcard(require("./cache"));
|
|
5
6
|
var common = _interopRequireWildcard(require("./common"));
|
|
6
7
|
var api = _interopRequireWildcard(require("./api"));
|
|
7
8
|
var designer = _interopRequireWildcard(require("./designer"));
|
|
@@ -9,6 +10,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
9
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
10
11
|
var _default = exports["default"] = {
|
|
11
12
|
api: api,
|
|
13
|
+
cache: cache,
|
|
12
14
|
designer: designer,
|
|
13
15
|
common: common
|
|
14
16
|
};
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export declare type LoadData = (key: string) => Promise<any>;
|
|
2
|
-
export declare class ClientCache {
|
|
3
|
-
private cacheMap;
|
|
4
|
-
name: string;
|
|
5
|
-
loadData: LoadData;
|
|
6
|
-
constructor(options: {
|
|
7
|
-
name: string;
|
|
8
|
-
loadData: LoadData;
|
|
9
|
-
});
|
|
10
|
-
/**
|
|
11
|
-
* 获取值
|
|
12
|
-
* @param key
|
|
13
|
-
* @param cache 是否从缓存中获取
|
|
14
|
-
*/
|
|
15
|
-
get(key: string, cache?: boolean): Promise<any>;
|
|
16
|
-
/**
|
|
17
|
-
* 重新加载
|
|
18
|
-
* @param key
|
|
19
|
-
*/
|
|
20
|
-
reload(key: string): Promise<any>;
|
|
21
|
-
/**
|
|
22
|
-
* 手动设置
|
|
23
|
-
* @param key
|
|
24
|
-
* @param value
|
|
25
|
-
*/
|
|
26
|
-
set(key: string, value: any): void;
|
|
27
|
-
/**
|
|
28
|
-
* 删除某个缓存
|
|
29
|
-
* @param key
|
|
30
|
-
*/
|
|
31
|
-
delete(key: string): void;
|
|
32
|
-
/**
|
|
33
|
-
* 删除全部缓存
|
|
34
|
-
*/
|
|
35
|
-
clear(): void;
|
|
36
|
-
}
|