@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
package/dist/lib/helpers.js
CHANGED
|
@@ -8,12 +8,12 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
8
8
|
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); }
|
|
9
9
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
10
|
import { router } from "@inertiajs/react";
|
|
11
|
-
import Schema from '@rc-component/async-validator';
|
|
12
11
|
import http from "./http";
|
|
13
12
|
import container from "./container";
|
|
14
|
-
import React, {
|
|
13
|
+
import React, { Suspense } from "react";
|
|
15
14
|
import global from "./global";
|
|
16
15
|
import { ModalContext } from "../components/ModalContext";
|
|
16
|
+
import { uniq } from "lodash";
|
|
17
17
|
export function replaceUrl(url, params) {
|
|
18
18
|
return url.replace(/__([\w]+)__/g, function (match, key) {
|
|
19
19
|
return params[key] || match;
|
|
@@ -37,53 +37,6 @@ export function replaceParams(params, data) {
|
|
|
37
37
|
export function routerNavigateTo(url, config) {
|
|
38
38
|
return router.visit(url, _objectSpread({}, config));
|
|
39
39
|
}
|
|
40
|
-
export function handleRules(dataRules, data) {
|
|
41
|
-
return new Promise(function (resolve) {
|
|
42
|
-
var validator = new Schema(dataRules);
|
|
43
|
-
validator.validate(data, function (errors, fields) {
|
|
44
|
-
if (errors) {
|
|
45
|
-
resolve(false);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
resolve(true);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
export function asyncFilter(_x, _x2) {
|
|
53
|
-
return _asyncFilter.apply(this, arguments);
|
|
54
|
-
}
|
|
55
|
-
function _asyncFilter() {
|
|
56
|
-
_asyncFilter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(arr, predicate) {
|
|
57
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
58
|
-
while (1) switch (_context.prev = _context.next) {
|
|
59
|
-
case 0:
|
|
60
|
-
_context.next = 2;
|
|
61
|
-
return Promise.all(arr.map(predicate)).then(function (results) {
|
|
62
|
-
return arr.filter(function (_v, index) {
|
|
63
|
-
return results[index];
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
case 2:
|
|
67
|
-
return _context.abrupt("return", _context.sent);
|
|
68
|
-
case 3:
|
|
69
|
-
case "end":
|
|
70
|
-
return _context.stop();
|
|
71
|
-
}
|
|
72
|
-
}, _callee);
|
|
73
|
-
}));
|
|
74
|
-
return _asyncFilter.apply(this, arguments);
|
|
75
|
-
}
|
|
76
|
-
export function filterObjectKeys(obj, keysToKeep) {
|
|
77
|
-
if (_typeof(obj) !== 'object' || !obj) {
|
|
78
|
-
return obj;
|
|
79
|
-
}
|
|
80
|
-
return Object.keys(obj).filter(function (key) {
|
|
81
|
-
return !keysToKeep.includes(key);
|
|
82
|
-
}).reduce(function (newObj, key) {
|
|
83
|
-
newObj[key] = obj[key];
|
|
84
|
-
return newObj;
|
|
85
|
-
}, {});
|
|
86
|
-
}
|
|
87
40
|
export function createScript(url) {
|
|
88
41
|
var scriptTags = window.document.querySelectorAll('script');
|
|
89
42
|
var len = scriptTags.length;
|
|
@@ -103,21 +56,21 @@ export function createScript(url) {
|
|
|
103
56
|
document.body.appendChild(node);
|
|
104
57
|
});
|
|
105
58
|
}
|
|
106
|
-
export function modalShow(
|
|
59
|
+
export function modalShow(_x) {
|
|
107
60
|
return _modalShow.apply(this, arguments);
|
|
108
61
|
}
|
|
109
62
|
function _modalShow() {
|
|
110
|
-
_modalShow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
63
|
+
_modalShow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
111
64
|
var props, res, Component, _afterClose, modal;
|
|
112
|
-
return _regeneratorRuntime().wrap(function
|
|
113
|
-
while (1) switch (
|
|
65
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
66
|
+
while (1) switch (_context.prev = _context.next) {
|
|
114
67
|
case 0:
|
|
115
68
|
props = options.content.props;
|
|
116
69
|
if (!options.content.url) {
|
|
117
|
-
|
|
70
|
+
_context.next = 8;
|
|
118
71
|
break;
|
|
119
72
|
}
|
|
120
|
-
|
|
73
|
+
_context.next = 4;
|
|
121
74
|
return http({
|
|
122
75
|
method: 'get',
|
|
123
76
|
url: options.content.url,
|
|
@@ -126,9 +79,9 @@ function _modalShow() {
|
|
|
126
79
|
}
|
|
127
80
|
});
|
|
128
81
|
case 4:
|
|
129
|
-
res =
|
|
82
|
+
res = _context.sent;
|
|
130
83
|
if (!(typeof res.data === 'string')) {
|
|
131
|
-
|
|
84
|
+
_context.next = 7;
|
|
132
85
|
break;
|
|
133
86
|
}
|
|
134
87
|
throw new Error('modal response is not vail');
|
|
@@ -136,14 +89,12 @@ function _modalShow() {
|
|
|
136
89
|
props = res.data;
|
|
137
90
|
case 8:
|
|
138
91
|
if (props) {
|
|
139
|
-
|
|
92
|
+
_context.next = 10;
|
|
140
93
|
break;
|
|
141
94
|
}
|
|
142
95
|
throw new Error('modal props is empty');
|
|
143
96
|
case 10:
|
|
144
|
-
Component =
|
|
145
|
-
return container.get('Modal.' + upperFirst(props.type));
|
|
146
|
-
});
|
|
97
|
+
Component = container.get('Modal.' + upperFirst(props.type));
|
|
147
98
|
_afterClose = function afterClose() {};
|
|
148
99
|
modal = global.modal.info(_objectSpread(_objectSpread({}, options), {}, {
|
|
149
100
|
closable: true,
|
|
@@ -161,23 +112,77 @@ function _modalShow() {
|
|
|
161
112
|
_afterClose = callback;
|
|
162
113
|
}
|
|
163
114
|
}
|
|
164
|
-
}, /*#__PURE__*/React.createElement(Component, props)),
|
|
115
|
+
}, /*#__PURE__*/React.createElement(Suspense, null, /*#__PURE__*/React.createElement(Component, props))),
|
|
165
116
|
afterClose: function afterClose() {
|
|
166
117
|
_afterClose && _afterClose();
|
|
167
118
|
}
|
|
168
119
|
}));
|
|
169
|
-
return
|
|
120
|
+
return _context.abrupt("return", {
|
|
170
121
|
destroy: modal.destroy,
|
|
171
122
|
update: modal.update
|
|
172
123
|
});
|
|
173
124
|
case 14:
|
|
174
125
|
case "end":
|
|
175
|
-
return
|
|
126
|
+
return _context.stop();
|
|
176
127
|
}
|
|
177
|
-
},
|
|
128
|
+
}, _callee);
|
|
178
129
|
}));
|
|
179
130
|
return _modalShow.apply(this, arguments);
|
|
180
131
|
}
|
|
181
132
|
export function upperFirst(str) {
|
|
182
133
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
134
|
+
}
|
|
135
|
+
export function getProValueTypeMap() {
|
|
136
|
+
var columnKeys = Object.keys(container.list('Column.'));
|
|
137
|
+
var readonlyKeys = Object.keys(container.list('Column.Readonly.'));
|
|
138
|
+
var types = uniq(columnKeys.concat(readonlyKeys));
|
|
139
|
+
return types.reduce(function (map, type) {
|
|
140
|
+
map[type] = {
|
|
141
|
+
render: function render(text, props) {
|
|
142
|
+
var renderComponent = 'Column.Readonly.' + upperFirst(type);
|
|
143
|
+
if (container.check(renderComponent)) {
|
|
144
|
+
var Component = container.get(renderComponent);
|
|
145
|
+
return /*#__PURE__*/React.createElement(Suspense, null, /*#__PURE__*/React.createElement(Component, props));
|
|
146
|
+
}
|
|
147
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, text);
|
|
148
|
+
},
|
|
149
|
+
renderFormItem: function renderFormItem(text, props) {
|
|
150
|
+
var renderComponent = 'Column.' + upperFirst(type);
|
|
151
|
+
if (container.check(renderComponent)) {
|
|
152
|
+
var Component = container.get(renderComponent);
|
|
153
|
+
return /*#__PURE__*/React.createElement(Suspense, null, /*#__PURE__*/React.createElement(Component, props));
|
|
154
|
+
}
|
|
155
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, text);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
return map;
|
|
159
|
+
}, {});
|
|
160
|
+
}
|
|
161
|
+
export function handleCondition(condition, data) {
|
|
162
|
+
switch (condition.operator) {
|
|
163
|
+
case 'eq':
|
|
164
|
+
case '=':
|
|
165
|
+
return data[condition.field] == condition.value;
|
|
166
|
+
case 'neq':
|
|
167
|
+
case '!=':
|
|
168
|
+
case '<>':
|
|
169
|
+
return data[condition.field] != condition.value;
|
|
170
|
+
case 'gt':
|
|
171
|
+
case '>':
|
|
172
|
+
return data[condition.field] > condition.value;
|
|
173
|
+
case 'gte':
|
|
174
|
+
case '>=':
|
|
175
|
+
return data[condition.field] >= condition.value;
|
|
176
|
+
case 'lt':
|
|
177
|
+
case '<':
|
|
178
|
+
return data[condition.field] < condition.value;
|
|
179
|
+
case 'elt':
|
|
180
|
+
case '<=':
|
|
181
|
+
return data[condition.field] <= condition.value;
|
|
182
|
+
case 'in':
|
|
183
|
+
return data[condition.field] && condition.value.includes(data[condition.field]);
|
|
184
|
+
case 'not in':
|
|
185
|
+
return data[condition.field] && !condition.value.includes(data[condition.field]);
|
|
186
|
+
}
|
|
187
|
+
return false;
|
|
183
188
|
}
|
package/dist/lib/http.js
CHANGED
|
@@ -13,6 +13,7 @@ http.interceptors.request.use(function (config) {
|
|
|
13
13
|
config.headers['X-Requested-With'] = 'XMLHttpRequest';
|
|
14
14
|
return config;
|
|
15
15
|
});
|
|
16
|
+
var timer;
|
|
16
17
|
http.interceptors.response.use(function (response) {
|
|
17
18
|
var _response$config$fetc;
|
|
18
19
|
var checkInfo = function checkInfo(data) {
|
|
@@ -37,8 +38,12 @@ http.interceptors.response.use(function (response) {
|
|
|
37
38
|
}
|
|
38
39
|
var showInfo = checkInfo(response.data);
|
|
39
40
|
if (response.data.url) {
|
|
40
|
-
|
|
41
|
+
if (timer) {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
}
|
|
44
|
+
timer = setTimeout(function () {
|
|
41
45
|
routerNavigateTo(response.data.url);
|
|
46
|
+
timer = null;
|
|
42
47
|
}, showInfo ? 2000 : 0);
|
|
43
48
|
}
|
|
44
49
|
if (response.data.status == 0) {
|
|
@@ -8,6 +8,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
8
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
9
|
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); }
|
|
10
10
|
import http from "./http";
|
|
11
|
+
import { handleCondition } from "./helpers";
|
|
11
12
|
var uploadValidator = function uploadValidator(_, value) {
|
|
12
13
|
return new Promise(function (resolve, reject) {
|
|
13
14
|
if (!value) {
|
|
@@ -80,6 +81,7 @@ export var schemaHandler = {
|
|
|
80
81
|
schema.formItemProps.rules.push({
|
|
81
82
|
validator: uploadValidator
|
|
82
83
|
});
|
|
84
|
+
schema.fieldProps.dataIndex = schema.dataIndex;
|
|
83
85
|
return _objectSpread(_objectSpread({}, schema), {}, {
|
|
84
86
|
transform: uploadTransform
|
|
85
87
|
});
|
|
@@ -88,28 +90,80 @@ export var schemaHandler = {
|
|
|
88
90
|
schema.formItemProps.rules.push({
|
|
89
91
|
validator: uploadValidator
|
|
90
92
|
});
|
|
93
|
+
schema.fieldProps.dataIndex = schema.dataIndex;
|
|
91
94
|
return _objectSpread(_objectSpread({}, schema), {}, {
|
|
92
95
|
transform: uploadTransform
|
|
93
96
|
});
|
|
94
97
|
},
|
|
98
|
+
action: function action(schema) {
|
|
99
|
+
schema.fieldProps = {
|
|
100
|
+
actions: schema.actions
|
|
101
|
+
};
|
|
102
|
+
return schema;
|
|
103
|
+
},
|
|
104
|
+
dependency: function dependency(schema) {
|
|
105
|
+
var _columns = schema.columns,
|
|
106
|
+
valueType = schema.valueType;
|
|
107
|
+
return {
|
|
108
|
+
valueType: valueType,
|
|
109
|
+
name: [schema.showCondition.field],
|
|
110
|
+
columns: function columns(fields) {
|
|
111
|
+
return handleCondition(schema.showCondition, fields) ? _columns : [];
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
ueditor: function ueditor(schema) {
|
|
116
|
+
if (!schema.formItemProps) {
|
|
117
|
+
schema.formItemProps = {};
|
|
118
|
+
}
|
|
119
|
+
if (!schema.formItemProps.rules) {
|
|
120
|
+
schema.formItemProps.rules = [];
|
|
121
|
+
}
|
|
122
|
+
schema.formItemProps.rules.push({
|
|
123
|
+
validator: function () {
|
|
124
|
+
var _validator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(rule, value) {
|
|
125
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
126
|
+
while (1) switch (_context.prev = _context.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
if (!(value.slice(0, 7) === '[抓取图片中]')) {
|
|
129
|
+
_context.next = 2;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
throw new Error('请等待图片抓取完成');
|
|
133
|
+
case 2:
|
|
134
|
+
return _context.abrupt("return", true);
|
|
135
|
+
case 3:
|
|
136
|
+
case "end":
|
|
137
|
+
return _context.stop();
|
|
138
|
+
}
|
|
139
|
+
}, _callee);
|
|
140
|
+
}));
|
|
141
|
+
function validator(_x, _x2) {
|
|
142
|
+
return _validator.apply(this, arguments);
|
|
143
|
+
}
|
|
144
|
+
return validator;
|
|
145
|
+
}()
|
|
146
|
+
});
|
|
147
|
+
return _objectSpread({}, schema);
|
|
148
|
+
},
|
|
95
149
|
select: function select(schema) {
|
|
96
150
|
var _schema$fieldProps;
|
|
97
151
|
schema.searchOnChange = true;
|
|
98
152
|
if ((_schema$fieldProps = schema.fieldProps) !== null && _schema$fieldProps !== void 0 && _schema$fieldProps.searchUrl) {
|
|
99
153
|
return _objectSpread(_objectSpread({}, schema), {}, {
|
|
100
154
|
request: function () {
|
|
101
|
-
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
155
|
+
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
102
156
|
var res;
|
|
103
|
-
return _regeneratorRuntime().wrap(function
|
|
104
|
-
while (1) switch (
|
|
157
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
158
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
105
159
|
case 0:
|
|
106
|
-
|
|
160
|
+
_context2.next = 2;
|
|
107
161
|
return http(schema.fieldProps.searchUrl, {
|
|
108
162
|
params: params
|
|
109
163
|
});
|
|
110
164
|
case 2:
|
|
111
|
-
res =
|
|
112
|
-
return
|
|
165
|
+
res = _context2.sent;
|
|
166
|
+
return _context2.abrupt("return", res.data.map(function (item) {
|
|
113
167
|
return {
|
|
114
168
|
label: item.label || item.value,
|
|
115
169
|
value: item.value
|
|
@@ -117,11 +171,11 @@ export var schemaHandler = {
|
|
|
117
171
|
}));
|
|
118
172
|
case 4:
|
|
119
173
|
case "end":
|
|
120
|
-
return
|
|
174
|
+
return _context2.stop();
|
|
121
175
|
}
|
|
122
|
-
},
|
|
176
|
+
}, _callee2);
|
|
123
177
|
}));
|
|
124
|
-
function request(
|
|
178
|
+
function request(_x3) {
|
|
125
179
|
return _request.apply(this, arguments);
|
|
126
180
|
}
|
|
127
181
|
return request;
|
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.5",
|
|
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
|
},
|