@quansitech/antd-admin 1.1.45 → 1.1.47
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/lib/helpers.d.ts +2 -0
- package/dist/lib/helpers.js +7 -0
- package/dist/lib/schemaHandler.js +77 -36
- package/package.json +1 -1
package/dist/lib/helpers.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VisitOptions } from "@inertiajs/core/types/types";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import { ModalFuncProps } from "antd";
|
|
3
4
|
import { Condition, ModalOptions } from "../types";
|
|
4
5
|
export declare function replaceUrl(url: string, params: any): string;
|
|
@@ -17,3 +18,4 @@ export declare function filterObjectKeys(obj: Record<string, any>, keysToFilter:
|
|
|
17
18
|
export declare function diffTree(tree1: any[], tree2: any[], childKey: string): any[];
|
|
18
19
|
export declare function findValuePath(obj: any, target: any, path?: string[]): string[] | null;
|
|
19
20
|
export declare function getValueByPath(obj: any, path: string[]): any;
|
|
21
|
+
export declare function renderTextarea(text: string): React.JSX.Element;
|
package/dist/lib/helpers.js
CHANGED
|
@@ -289,4 +289,11 @@ export function getValueByPath(obj, path) {
|
|
|
289
289
|
_iterator.f();
|
|
290
290
|
}
|
|
291
291
|
return current;
|
|
292
|
+
}
|
|
293
|
+
export function renderTextarea(text) {
|
|
294
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
295
|
+
style: {
|
|
296
|
+
whiteSpace: 'pre-wrap'
|
|
297
|
+
}
|
|
298
|
+
}, text));
|
|
292
299
|
}
|
|
@@ -8,7 +8,7 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
8
8
|
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); } }
|
|
9
9
|
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); }); }; }
|
|
10
10
|
import http from "./http";
|
|
11
|
-
import { deepSet, handleCondition } from "./helpers";
|
|
11
|
+
import { deepSet, handleCondition, renderTextarea } from "./helpers";
|
|
12
12
|
import container from "./container";
|
|
13
13
|
import { itemRender } from "./FormList";
|
|
14
14
|
import { lowerFirst } from "es-toolkit";
|
|
@@ -31,6 +31,43 @@ var uploadValidator = function uploadValidator(_, value) {
|
|
|
31
31
|
resolve(true);
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var handleUploadRules = function handleUploadRules(rules) {
|
|
35
|
+
var rRule = rules.find(function (rule) {
|
|
36
|
+
return rule.required;
|
|
37
|
+
});
|
|
38
|
+
if (rRule) {
|
|
39
|
+
rules.push({
|
|
40
|
+
validator: function () {
|
|
41
|
+
var _validator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_, value) {
|
|
42
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
43
|
+
while (1) switch (_context.prev = _context.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
if (!(value === '0' || value === 0)) {
|
|
46
|
+
_context.next = 2;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
throw new Error(rRule.message);
|
|
50
|
+
case 2:
|
|
51
|
+
return _context.abrupt("return", true);
|
|
52
|
+
case 3:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context.stop();
|
|
55
|
+
}
|
|
56
|
+
}, _callee);
|
|
57
|
+
}));
|
|
58
|
+
function validator(_x, _x2) {
|
|
59
|
+
return _validator.apply(this, arguments);
|
|
60
|
+
}
|
|
61
|
+
return validator;
|
|
62
|
+
}()
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
rules.push({
|
|
66
|
+
validator: uploadValidator
|
|
67
|
+
});
|
|
68
|
+
console.log(rules);
|
|
69
|
+
return rules;
|
|
70
|
+
};
|
|
34
71
|
export var commonHandler = function commonHandler(schema) {
|
|
35
72
|
var _schema$formItemProps;
|
|
36
73
|
schema.valueType = lowerFirst(schema.valueType);
|
|
@@ -52,22 +89,22 @@ export var commonHandler = function commonHandler(schema) {
|
|
|
52
89
|
if (!((_schema$formItemProps = schema.formItemProps) !== null && _schema$formItemProps !== void 0 && _schema$formItemProps.rules)) {
|
|
53
90
|
deepSet(schema, 'formItemProps.rules', []);
|
|
54
91
|
}
|
|
55
|
-
schema.fieldProps.withValidator = function (
|
|
92
|
+
schema.fieldProps.withValidator = function (_validator2) {
|
|
56
93
|
schema.formItemProps.rules.push({
|
|
57
94
|
validator: function validator(rules, value) {
|
|
58
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
59
|
-
return _regeneratorRuntime().wrap(function
|
|
60
|
-
while (1) switch (
|
|
95
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
96
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
97
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
61
98
|
case 0:
|
|
62
|
-
|
|
63
|
-
return
|
|
99
|
+
_context2.next = 2;
|
|
100
|
+
return _validator2(value);
|
|
64
101
|
case 2:
|
|
65
|
-
return
|
|
102
|
+
return _context2.abrupt("return", true);
|
|
66
103
|
case 3:
|
|
67
104
|
case "end":
|
|
68
|
-
return
|
|
105
|
+
return _context2.stop();
|
|
69
106
|
}
|
|
70
|
-
},
|
|
107
|
+
}, _callee2);
|
|
71
108
|
}))();
|
|
72
109
|
}
|
|
73
110
|
});
|
|
@@ -105,17 +142,21 @@ export var schemaHandler = {
|
|
|
105
142
|
}
|
|
106
143
|
return _objectSpread({}, schema);
|
|
107
144
|
},
|
|
145
|
+
textarea: function textarea(schema) {
|
|
146
|
+
schema.renderText = function (text) {
|
|
147
|
+
return renderTextarea(text);
|
|
148
|
+
};
|
|
149
|
+
return _objectSpread({}, schema);
|
|
150
|
+
},
|
|
108
151
|
// 上传
|
|
109
152
|
image: function image(schema) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
153
|
+
var _schema$formItemProps2;
|
|
154
|
+
schema.formItemProps.rules = handleUploadRules((_schema$formItemProps2 = schema.formItemProps) === null || _schema$formItemProps2 === void 0 ? void 0 : _schema$formItemProps2.rules);
|
|
113
155
|
return _objectSpread({}, schema);
|
|
114
156
|
},
|
|
115
157
|
file: function file(schema) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
158
|
+
var _schema$formItemProps3;
|
|
159
|
+
schema.formItemProps.rules = handleUploadRules((_schema$formItemProps3 = schema.formItemProps) === null || _schema$formItemProps3 === void 0 ? void 0 : _schema$formItemProps3.rules);
|
|
119
160
|
return _objectSpread({}, schema);
|
|
120
161
|
},
|
|
121
162
|
action: function action(schema) {
|
|
@@ -155,31 +196,31 @@ export var schemaHandler = {
|
|
|
155
196
|
}
|
|
156
197
|
schema.formItemProps.rules.push({
|
|
157
198
|
validator: function () {
|
|
158
|
-
var
|
|
159
|
-
return _regeneratorRuntime().wrap(function
|
|
160
|
-
while (1) switch (
|
|
199
|
+
var _validator3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(rule, value) {
|
|
200
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
201
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
161
202
|
case 0:
|
|
162
203
|
if (value) {
|
|
163
|
-
|
|
204
|
+
_context3.next = 2;
|
|
164
205
|
break;
|
|
165
206
|
}
|
|
166
|
-
return
|
|
207
|
+
return _context3.abrupt("return", true);
|
|
167
208
|
case 2:
|
|
168
209
|
if (!(value.slice(0, 7) === '[抓取图片中]')) {
|
|
169
|
-
|
|
210
|
+
_context3.next = 4;
|
|
170
211
|
break;
|
|
171
212
|
}
|
|
172
213
|
throw new Error('请等待图片抓取完成');
|
|
173
214
|
case 4:
|
|
174
|
-
return
|
|
215
|
+
return _context3.abrupt("return", true);
|
|
175
216
|
case 5:
|
|
176
217
|
case "end":
|
|
177
|
-
return
|
|
218
|
+
return _context3.stop();
|
|
178
219
|
}
|
|
179
|
-
},
|
|
220
|
+
}, _callee3);
|
|
180
221
|
}));
|
|
181
|
-
function validator(
|
|
182
|
-
return
|
|
222
|
+
function validator(_x3, _x4) {
|
|
223
|
+
return _validator3.apply(this, arguments);
|
|
183
224
|
}
|
|
184
225
|
return validator;
|
|
185
226
|
}()
|
|
@@ -192,18 +233,18 @@ export var schemaHandler = {
|
|
|
192
233
|
if ((_schema$fieldProps = schema.fieldProps) !== null && _schema$fieldProps !== void 0 && _schema$fieldProps.searchUrl) {
|
|
193
234
|
return _objectSpread(_objectSpread({}, schema), {}, {
|
|
194
235
|
request: function () {
|
|
195
|
-
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
236
|
+
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
196
237
|
var res;
|
|
197
|
-
return _regeneratorRuntime().wrap(function
|
|
198
|
-
while (1) switch (
|
|
238
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
239
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
199
240
|
case 0:
|
|
200
|
-
|
|
241
|
+
_context4.next = 2;
|
|
201
242
|
return http(schema.fieldProps.searchUrl, {
|
|
202
243
|
params: params
|
|
203
244
|
});
|
|
204
245
|
case 2:
|
|
205
|
-
res =
|
|
206
|
-
return
|
|
246
|
+
res = _context4.sent;
|
|
247
|
+
return _context4.abrupt("return", res.data.map(function (item) {
|
|
207
248
|
return {
|
|
208
249
|
label: item.label || item.value,
|
|
209
250
|
value: item.value
|
|
@@ -211,11 +252,11 @@ export var schemaHandler = {
|
|
|
211
252
|
}));
|
|
212
253
|
case 4:
|
|
213
254
|
case "end":
|
|
214
|
-
return
|
|
255
|
+
return _context4.stop();
|
|
215
256
|
}
|
|
216
|
-
},
|
|
257
|
+
}, _callee4);
|
|
217
258
|
}));
|
|
218
|
-
function request(
|
|
259
|
+
function request(_x5) {
|
|
219
260
|
return _request.apply(this, arguments);
|
|
220
261
|
}
|
|
221
262
|
return request;
|