@kne/react-form-antd 3.0.28 → 3.0.30
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/index.cjs +465 -909
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +504 -911
- package/dist/index.modern.js.map +1 -1
- package/package.json +5 -7
package/dist/index.modern.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React__default, { forwardRef, useRef, useState, useEffect, useMemo, useCallback, useImperativeHandle } from 'react';
|
|
1
|
+
import React, { forwardRef, useState, useMemo, useRef, useEffect, useImperativeHandle, useCallback } from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import classnames from 'classnames';
|
|
5
|
-
import { preset as preset$2, Form as Form$1,
|
|
4
|
+
import { preset as preset$2, Form as Form$1, useReset, useSubmit } from '@kne/react-form';
|
|
6
5
|
export * from '@kne/react-form';
|
|
7
6
|
import { preset as preset$1, widget, hooks, hoc } from '@kne/react-form-helper';
|
|
8
7
|
export { hooks, utils, widget } from '@kne/react-form-helper';
|
|
9
8
|
import { merge, get, omit, uniqueId, groupBy } from 'lodash';
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import { LoadingOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons';
|
|
13
|
-
import AvatarEditor from 'react-avatar-editor';
|
|
14
|
-
import dayjs from 'dayjs';
|
|
15
|
-
import useControlValue from '@kne/use-control-value';
|
|
9
|
+
import { Button, message, Upload, TreeSelect, TimePicker, Input, Switch as Switch$1, Select, Radio, InputNumber, DatePicker, Checkbox as Checkbox$1, Cascader as Cascader$1 } from 'antd';
|
|
10
|
+
import { UploadOutlined } from '@ant-design/icons';
|
|
16
11
|
import useEvent from '@kne/use-event';
|
|
17
12
|
import { withFetch as withFetch$1 } from '@kne/react-fetch';
|
|
13
|
+
import dayjs from 'dayjs';
|
|
14
|
+
import useControlValue from '@kne/use-control-value';
|
|
18
15
|
|
|
19
16
|
function _extends() {
|
|
20
17
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -89,7 +86,7 @@ var preset = (props => {
|
|
|
89
86
|
preset$2(globalParams.rules);
|
|
90
87
|
});
|
|
91
88
|
|
|
92
|
-
const _excluded$
|
|
89
|
+
const _excluded$6 = ["className", "cache", "enterSubmit", "scrollToError", "scrollProps", "type", "size", "children"];
|
|
93
90
|
const {
|
|
94
91
|
ScrollToError,
|
|
95
92
|
EnterSubmit,
|
|
@@ -106,7 +103,7 @@ const Form = forwardRef((originProps, ref) => {
|
|
|
106
103
|
scrollProps,
|
|
107
104
|
children
|
|
108
105
|
} = originProps,
|
|
109
|
-
props = _objectWithoutPropertiesLoose(originProps, _excluded$
|
|
106
|
+
props = _objectWithoutPropertiesLoose(originProps, _excluded$6);
|
|
110
107
|
const baseClass = 'react-form';
|
|
111
108
|
let computedClass = baseClass;
|
|
112
109
|
const {
|
|
@@ -122,24 +119,24 @@ const Form = forwardRef((originProps, ref) => {
|
|
|
122
119
|
if (size !== 'middle') {
|
|
123
120
|
computedClass += `--${size}`;
|
|
124
121
|
}
|
|
125
|
-
const maxLabel = /*#__PURE__*/
|
|
126
|
-
return /*#__PURE__*/
|
|
122
|
+
const maxLabel = /*#__PURE__*/React.createElement(MaxLabelProvider, null, children);
|
|
123
|
+
return /*#__PURE__*/React.createElement("form", {
|
|
127
124
|
className: classnames(baseClass, computedClass, className),
|
|
128
125
|
onSubmit: e => {
|
|
129
126
|
e.preventDefault();
|
|
130
127
|
e.stopPropagation();
|
|
131
128
|
}
|
|
132
|
-
}, /*#__PURE__*/
|
|
129
|
+
}, /*#__PURE__*/React.createElement(SizeProvider, {
|
|
133
130
|
value: {
|
|
134
131
|
size
|
|
135
132
|
}
|
|
136
|
-
}, /*#__PURE__*/
|
|
133
|
+
}, /*#__PURE__*/React.createElement(Form$1, _extends({}, props, {
|
|
137
134
|
ref: ref
|
|
138
|
-
}), cache ? /*#__PURE__*/
|
|
135
|
+
}), cache ? /*#__PURE__*/React.createElement(FormStore, {
|
|
139
136
|
cache: cache
|
|
140
|
-
}) : null, scrollToError ? /*#__PURE__*/
|
|
137
|
+
}) : null, scrollToError ? /*#__PURE__*/React.createElement(ScrollToError, {
|
|
141
138
|
scrollProps: scrollProps
|
|
142
|
-
}) : null, enterSubmit ? /*#__PURE__*/
|
|
139
|
+
}) : null, enterSubmit ? /*#__PURE__*/React.createElement(EnterSubmit, null, maxLabel) : maxLabel)));
|
|
143
140
|
});
|
|
144
141
|
Form.defaultProps = {
|
|
145
142
|
scrollToError: true,
|
|
@@ -161,424 +158,424 @@ Form.propTypes = {
|
|
|
161
158
|
})
|
|
162
159
|
};
|
|
163
160
|
|
|
164
|
-
const
|
|
165
|
-
width: "1em",
|
|
166
|
-
height: "1em",
|
|
167
|
-
viewBox: "0 0 14 14",
|
|
168
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
169
|
-
xmlnsXlink: "http://www.w3.org/1999/xlink"
|
|
170
|
-
}, props), /*#__PURE__*/React.createElement("title", null, "\u65CB\u8F6C"), /*#__PURE__*/React.createElement("g", {
|
|
171
|
-
id: "PC\\u7AEF",
|
|
172
|
-
stroke: "none",
|
|
173
|
-
strokeWidth: 1,
|
|
174
|
-
fill: "none",
|
|
175
|
-
fillRule: "evenodd"
|
|
176
|
-
}, /*#__PURE__*/React.createElement("g", {
|
|
177
|
-
id: "\\u56FE\\u6807",
|
|
178
|
-
transform: "translate(-77.000000, -1567.000000)",
|
|
179
|
-
fill: "#222222",
|
|
180
|
-
fillRule: "nonzero"
|
|
181
|
-
}, /*#__PURE__*/React.createElement("g", {
|
|
182
|
-
id: "\\u65CB\\u8F6C",
|
|
183
|
-
transform: "translate(77.000000, 1567.000000)"
|
|
184
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
185
|
-
d: "M9.16414904,5.6345426 C9.35110931,5.6345426 9.53041217,5.70881228 9.66261304,5.84101315 C9.79481391,5.97321402 9.86908359,6.15251688 9.86908359,6.33947715 L9.86908359,12.683888 C9.86908359,13.0732126 9.55347364,13.3888226 9.16414904,13.3888226 L0.704934547,13.3888226 C0.315609953,13.3888226 1.8189894e-12,13.0732126 1.8189894e-12,12.683888 L1.8189894e-12,6.33947715 C1.8189894e-12,6.15251688 0.0742696765,5.97321402 0.206470548,5.84101315 C0.33867142,5.70881228 0.517974281,5.6345426 0.704934547,5.6345426 L9.16414904,5.6345426 Z M8.4592145,7.04441168 L1.40986909,7.04441168 L1.40986909,11.9789535 L8.4592145,11.9789535 L8.4592145,7.04441168 Z M7.58258803,0.714885198 C7.63035214,0.738767256 7.66052367,0.787585825 7.66052367,0.840987728 L7.66052367,2.02739256 C11.1625178,2.03011634 14,4.86980822 14,8.37180343 C14,8.62367799 13.8656872,8.85643618 13.6475639,8.98238459 C13.4294405,9.108333 13.1606904,9.108333 12.942567,8.98238459 C12.7244437,8.85643618 12.5900924,8.62367799 12.5901309,8.37180343 C12.5901323,5.64845715 10.3838686,3.43998499 7.66052367,3.43726164 L7.66052367,4.50664733 C7.66052367,4.56004923 7.63035214,4.6088678 7.58258803,4.63274986 C7.53482391,4.65663192 7.47766614,4.65147801 7.43494462,4.61943686 L4.99093655,2.78660706 C4.95543522,2.75998107 4.93454178,2.71819419 4.93454178,2.67381753 C4.93454178,2.62944087 4.95543522,2.58765399 4.99093655,2.561028 L7.43494462,0.728198195 C7.47766614,0.696157053 7.53482391,0.691003139 7.58258803,0.714885198 Z",
|
|
186
|
-
id: "\\u5F62\\u72B6\\u7ED3\\u5408"
|
|
187
|
-
})))));
|
|
188
|
-
|
|
189
|
-
const FullIcon = props => /*#__PURE__*/React.createElement("svg", _extends({
|
|
190
|
-
width: "1em",
|
|
191
|
-
height: "1em",
|
|
192
|
-
viewBox: "0 0 14 14",
|
|
193
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
194
|
-
xmlnsXlink: "http://www.w3.org/1999/xlink"
|
|
195
|
-
}, props), /*#__PURE__*/React.createElement("title", null, "\u5145\u6EE1"), /*#__PURE__*/React.createElement("g", {
|
|
196
|
-
id: "PC\\u7AEF",
|
|
197
|
-
stroke: "none",
|
|
198
|
-
strokeWidth: 1,
|
|
199
|
-
fill: "none",
|
|
200
|
-
fillRule: "evenodd"
|
|
201
|
-
}, /*#__PURE__*/React.createElement("g", {
|
|
202
|
-
id: "\\u56FE\\u6807",
|
|
203
|
-
transform: "translate(-145.000000, -1567.000000)",
|
|
204
|
-
fill: "#222222",
|
|
205
|
-
fillRule: "nonzero"
|
|
206
|
-
}, /*#__PURE__*/React.createElement("g", {
|
|
207
|
-
id: "\\u5145\\u6EE1",
|
|
208
|
-
transform: "translate(145.000000, 1567.000000)"
|
|
209
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
210
|
-
d: "M12.09375,0 C12.35,0 12.6,0.05 12.8359375,0.15 C13.0640625,0.2453125 13.2671875,0.3828125 13.4421875,0.5578125 C13.6171875,0.7328125 13.7546875,0.9375 13.85,1.1640625 C13.95,1.4 14,1.65 14,1.90625 L14,1.90625 L14,12.09375 C14,12.35 13.95,12.6 13.85,12.8359375 C13.7546875,13.0640625 13.6171875,13.2671875 13.4421875,13.4421875 C13.2671875,13.6171875 13.0625,13.7546875 12.8359375,13.85 C12.6,13.95 12.35,14 12.09375,14 L12.09375,14 L1.90625,14 C1.65,14 1.4,13.95 1.1640625,13.85 C0.9359375,13.7546875 0.7328125,13.6171875 0.5578125,13.4421875 C0.3828125,13.2671875 0.2453125,13.0625 0.15,12.8359375 C0.05,12.6 0,12.35 0,12.09375 L0,12.09375 L0,1.90625 C0,1.65 0.05,1.4 0.15,1.1640625 C0.2453125,0.9359375 0.3828125,0.7328125 0.5578125,0.5578125 C0.7328125,0.3828125 0.9375,0.2453125 1.1640625,0.15 C1.4,0.05 1.65,0 1.90625,0 L1.90625,0 Z M12.09375,1.125 L1.90625,1.125 C1.475,1.125 1.125,1.475 1.125,1.90625 L1.125,1.90625 L1.125,12.09375 C1.125,12.525 1.475,12.875 1.90625,12.875 L1.90625,12.875 L12.09375,12.875 C12.525,12.875 12.875,12.525 12.875,12.09375 L12.875,12.09375 L12.875,1.90625 C12.875,1.475 12.525,1.125 12.09375,1.125 L12.09375,1.125 Z M2.5734375,7.484375 C2.878125,7.490625 3.125,7.740625 3.125,8.046875 L3.125,8.046875 L3.125,10.0640625 L5.1265625,8.0625 C5.3453125,7.84375 5.703125,7.84375 5.921875,8.0625 C6.140625,8.28125 6.140625,8.6390625 5.921875,8.8578125 L5.921875,8.8578125 L3.903125,10.875 L5.909375,10.875 C6.2265625,10.875 6.4890625,11.13125 6.484375,11.4484375 C6.478125,11.7546875 6.228125,12 5.921875,12 L5.921875,12 L2.5734375,12 C2.25625,12 2,11.74375 2,11.4265625 L2,11.4265625 L2,8.0578125 C2,7.740625 2.2578125,7.478125 2.5734375,7.484375 Z M11.4296875,2 C11.7453125,2 12,2.25625 12,2.5703125 L12,2.5703125 L12,5.940625 C12,6.2578125 11.7421875,6.5203125 11.4265625,6.5140625 C11.121875,6.5078125 10.875,6.2578125 10.875,5.9515625 L10.875,5.9515625 L10.875,3.9359375 L8.8734375,5.9375 C8.6546875,6.15625 8.296875,6.15625 8.078125,5.9375 C7.859375,5.71875 7.859375,5.3609375 8.078125,5.1421875 L8.078125,5.1421875 L10.0953125,3.125 L8.0890625,3.125 C7.771875,3.125 7.509375,2.86875 7.515625,2.5515625 C7.521875,2.2453125 7.771875,2 8.078125,2 L8.078125,2 Z",
|
|
211
|
-
id: "\\u5F62\\u72B6\\u7ED3\\u5408"
|
|
212
|
-
})))));
|
|
213
|
-
|
|
214
|
-
const getPopupContainer = triggerNode => {
|
|
215
|
-
const findAntdPopupContainer = el => {
|
|
216
|
-
if (el === document.body || !el.parentElement) {
|
|
217
|
-
return document.body;
|
|
218
|
-
}
|
|
219
|
-
const targetEl = [].slice.call(el.classList, 0).find(className => ['ant-modal-body', 'ant-modal-content', 'ant-popover-content'].indexOf(className) > -1);
|
|
220
|
-
if (targetEl) {
|
|
221
|
-
return el;
|
|
222
|
-
}
|
|
223
|
-
return findAntdPopupContainer(el.parentElement);
|
|
224
|
-
};
|
|
225
|
-
return findAntdPopupContainer(triggerNode);
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
const _excluded$7 = ["close", "file", "editor", "onComplete"];
|
|
161
|
+
const _excluded$5 = ["action", "value", "onChange", "drag", "children", "displayFilename", "accept", "fileSize", "onError", "onUploadComplete", "onBeforeUpload", "maxLength", "transformResponse"];
|
|
229
162
|
const {
|
|
230
|
-
useOnChange: useOnChange$
|
|
163
|
+
useOnChange: useOnChange$b
|
|
231
164
|
} = hooks;
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
165
|
+
const {
|
|
166
|
+
Dragger
|
|
167
|
+
} = Upload;
|
|
168
|
+
const uploadParams = globalParams.field.upload;
|
|
169
|
+
const decodeURIComponentSafe = str => {
|
|
170
|
+
try {
|
|
171
|
+
return decodeURIComponent(str);
|
|
172
|
+
} catch (e) {
|
|
173
|
+
return str;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const computedFilename = (path, displayFilename = 'filename') => {
|
|
177
|
+
const strArray = path.split('?');
|
|
178
|
+
if (strArray[1]) {
|
|
179
|
+
const query = {};
|
|
180
|
+
strArray[1].split('&').forEach(str => {
|
|
181
|
+
const [key, value] = str.split('=');
|
|
182
|
+
query[key] = value;
|
|
183
|
+
});
|
|
184
|
+
if (query[displayFilename]) {
|
|
185
|
+
return decodeURIComponentSafe(query[displayFilename]);
|
|
246
186
|
}
|
|
247
|
-
|
|
187
|
+
}
|
|
188
|
+
return path;
|
|
189
|
+
};
|
|
190
|
+
const valueToList = (value, displayFilename) => {
|
|
191
|
+
if (!value) {
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
return value.map(item => {
|
|
195
|
+
return {
|
|
196
|
+
uid: uniqueId(),
|
|
197
|
+
name: computedFilename(item.substr(item.lastIndexOf('/') + 1), displayFilename),
|
|
198
|
+
status: 'done',
|
|
199
|
+
response: {
|
|
200
|
+
code: 200,
|
|
201
|
+
results: item
|
|
202
|
+
}
|
|
203
|
+
};
|
|
248
204
|
});
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
205
|
+
};
|
|
206
|
+
const listToValue = value => {
|
|
207
|
+
return (value || []).slice(0).filter(({
|
|
208
|
+
status
|
|
209
|
+
}) => status === 'done').map(({
|
|
210
|
+
response
|
|
211
|
+
}) => response.results);
|
|
212
|
+
};
|
|
213
|
+
const _Upload = _ref => {
|
|
214
|
+
let {
|
|
215
|
+
action,
|
|
216
|
+
value,
|
|
217
|
+
onChange,
|
|
218
|
+
drag,
|
|
219
|
+
children,
|
|
220
|
+
displayFilename,
|
|
221
|
+
accept,
|
|
222
|
+
fileSize: size,
|
|
223
|
+
onError,
|
|
224
|
+
onUploadComplete,
|
|
225
|
+
onBeforeUpload,
|
|
226
|
+
maxLength,
|
|
227
|
+
transformResponse
|
|
228
|
+
} = _ref,
|
|
229
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
230
|
+
displayFilename = displayFilename || uploadParams.displayFilename;
|
|
231
|
+
value = value || [];
|
|
232
|
+
const [list, setList] = useState([]);
|
|
233
|
+
const valueList = useMemo(() => {
|
|
234
|
+
return valueToList(value.filter(url => {
|
|
235
|
+
return !list.find(file => decodeURIComponentSafe(get(file, 'response.results', '')) === decodeURIComponentSafe(url));
|
|
236
|
+
}), displayFilename).concat(list);
|
|
237
|
+
}, [list, value, displayFilename]);
|
|
238
|
+
const changeHandler = info => {
|
|
239
|
+
var _info$fileList;
|
|
240
|
+
if (['uploading', 'done', 'error', 'removed'].indexOf(info.file.status) === -1) {
|
|
241
|
+
return;
|
|
262
242
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
borderRadius: editor.borderRadius,
|
|
270
|
-
color: [24, 144, 255, 1] // RGBA
|
|
271
|
-
,
|
|
272
|
-
scale: scale,
|
|
273
|
-
rotate: rotate
|
|
274
|
-
}), /*#__PURE__*/React__default.createElement(Row, {
|
|
275
|
-
gutter: 4,
|
|
276
|
-
align: "middle"
|
|
277
|
-
}, /*#__PURE__*/React__default.createElement(Col, {
|
|
278
|
-
span: 4
|
|
279
|
-
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
280
|
-
title: "\u65CB\u8F6C",
|
|
281
|
-
placement: "bottom",
|
|
282
|
-
getPopupContainer: getPopupContainer
|
|
283
|
-
}, /*#__PURE__*/React__default.createElement(RotateIcon, {
|
|
284
|
-
className: "react-form-avatar-btn",
|
|
285
|
-
onClick: () => {
|
|
286
|
-
setRotate(rotate => {
|
|
287
|
-
return (rotate - 90) % 360;
|
|
288
|
-
});
|
|
243
|
+
if (((_info$fileList = info.fileList) == null ? void 0 : _info$fileList.length) > maxLength) {
|
|
244
|
+
var _info$fileList2;
|
|
245
|
+
if (JSON.stringify(info.file) === JSON.stringify(info.fileList[((_info$fileList2 = info.fileList) == null ? void 0 : _info$fileList2.length) - 1])) {
|
|
246
|
+
onError(`上传文件不能超过最大允许数量${maxLength}`, 'lengthError', maxLength);
|
|
247
|
+
}
|
|
248
|
+
return;
|
|
289
249
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
250
|
+
if (info.file.status === 'done' && info.fileList.find(({
|
|
251
|
+
uid
|
|
252
|
+
}) => uid === info.file.uid)) {
|
|
253
|
+
info.file.response = (transformResponse || uploadParams.transformResponse)(info.file.response);
|
|
254
|
+
if (info.file.response.code === 200) {
|
|
255
|
+
info.file.name = computedFilename(info.file.response.results.substr(info.file.response.results.lastIndexOf('/') + 1), displayFilename);
|
|
256
|
+
onUploadComplete(info);
|
|
257
|
+
} else {
|
|
258
|
+
info.file.status = 'error';
|
|
259
|
+
onError(info.file.response.msg, 'xhrError', info.file.response);
|
|
260
|
+
}
|
|
300
261
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
placement: "bottom",
|
|
307
|
-
formatter: () => '大小',
|
|
308
|
-
getPopupContainer
|
|
309
|
-
},
|
|
310
|
-
value: scale,
|
|
311
|
-
step: 0.05,
|
|
312
|
-
min: 0.2,
|
|
313
|
-
max: 3,
|
|
314
|
-
onChange: setScale
|
|
315
|
-
})))));
|
|
316
|
-
});
|
|
317
|
-
const _Avatar = ({
|
|
318
|
-
className,
|
|
319
|
-
value: imageUrl,
|
|
320
|
-
onChange: propsChange,
|
|
321
|
-
beforeUpload: onBeforeUpload,
|
|
322
|
-
transformResponse,
|
|
323
|
-
action,
|
|
324
|
-
imageType,
|
|
325
|
-
fileSize: size,
|
|
326
|
-
children,
|
|
327
|
-
extraRender,
|
|
328
|
-
onError,
|
|
329
|
-
openEditor,
|
|
330
|
-
editorTips,
|
|
331
|
-
editor: targetEditor,
|
|
332
|
-
previewImg,
|
|
333
|
-
previewRender
|
|
334
|
-
}) => {
|
|
335
|
-
const [loading, setLoading] = useState(false);
|
|
336
|
-
const [showImageUrl, setImageUrl] = useState(imageUrl);
|
|
337
|
-
useRef();
|
|
338
|
-
const defaultEditor = {
|
|
339
|
-
open: false,
|
|
340
|
-
width: 250,
|
|
341
|
-
height: 250,
|
|
342
|
-
borderRadius: 1,
|
|
343
|
-
text: "确定",
|
|
344
|
-
cancelText: '取消',
|
|
345
|
-
title: "裁剪图片",
|
|
346
|
-
tips: null
|
|
347
|
-
};
|
|
348
|
-
const editor = merge({}, defaultEditor, {
|
|
349
|
-
open: openEditor,
|
|
350
|
-
tips: editorTips
|
|
351
|
-
}, targetEditor);
|
|
352
|
-
useEffect(() => {
|
|
353
|
-
setImageUrl(imageUrl);
|
|
354
|
-
}, [imageUrl]);
|
|
355
|
-
|
|
356
|
-
/* base64转blob */
|
|
357
|
-
const dataURLtoBlob = dataurl => {
|
|
358
|
-
let arr = dataurl.split(",");
|
|
359
|
-
// 注意base64的最后面中括号和引号是不转译的
|
|
360
|
-
let _arr = arr[1].substring(0, arr[1].length - 2);
|
|
361
|
-
let mime = arr[0].match(/:(.*?);/)[1],
|
|
362
|
-
bstr = atob(_arr),
|
|
363
|
-
n = bstr.length,
|
|
364
|
-
u8arr = new Uint8Array(n);
|
|
365
|
-
while (n--) {
|
|
366
|
-
u8arr[n] = bstr.charCodeAt(n);
|
|
262
|
+
const {
|
|
263
|
+
done
|
|
264
|
+
} = groupBy(info.fileList, file => file.status === 'done' ? 'done' : 'uploading');
|
|
265
|
+
if (['done', 'removed'].indexOf(info.file.status) > -1) {
|
|
266
|
+
onChange(listToValue(done));
|
|
367
267
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
if (!isJpgOrPng) {
|
|
377
|
-
onError(`只支持${imageType.map(str => str.replace("image/", "")).join("/")}格式图片!`, "typeError", {
|
|
378
|
-
type: imageType,
|
|
379
|
-
fileType: file.type
|
|
380
|
-
});
|
|
381
|
-
reject();
|
|
382
|
-
return false;
|
|
383
|
-
}
|
|
384
|
-
const isLt = file.size / 1024 / 1024 < size;
|
|
385
|
-
if (!isLt) {
|
|
386
|
-
onError(`图片不能超过${size}MB!`, "sizeError", {
|
|
387
|
-
size,
|
|
388
|
-
fileSize: file.size
|
|
389
|
-
});
|
|
390
|
-
reject();
|
|
391
|
-
return false;
|
|
268
|
+
setList(list => {
|
|
269
|
+
const newList = list.slice(0);
|
|
270
|
+
const index = list.findIndex(({
|
|
271
|
+
uid
|
|
272
|
+
}) => uid === info.file.uid);
|
|
273
|
+
if (info.file.status === 'removed') {
|
|
274
|
+
index > -1 && newList.splice(index, 1);
|
|
275
|
+
return newList;
|
|
392
276
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if (editor.open) {
|
|
397
|
-
createAvatarEditor({
|
|
398
|
-
editor,
|
|
399
|
-
file,
|
|
400
|
-
title: editor.title,
|
|
401
|
-
icon: "",
|
|
402
|
-
width: editor.width * 2,
|
|
403
|
-
cancelText: editor.cancelText,
|
|
404
|
-
okText: editor.text,
|
|
405
|
-
onComplete: base64 => {
|
|
406
|
-
setImageUrl(base64);
|
|
407
|
-
let blob = dataURLtoBlob(base64);
|
|
408
|
-
const files = new window.File([blob], file.name, {
|
|
409
|
-
type: file.type
|
|
410
|
-
});
|
|
411
|
-
onBeforeUpload && onBeforeUpload(files);
|
|
412
|
-
resolve(files);
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
} else {
|
|
416
|
-
onBeforeUpload && onBeforeUpload(file);
|
|
417
|
-
resolve(file);
|
|
277
|
+
if (index === -1) {
|
|
278
|
+
newList.push(info.file);
|
|
279
|
+
return newList;
|
|
418
280
|
}
|
|
281
|
+
newList.splice(index, 1, info.file);
|
|
282
|
+
return newList;
|
|
419
283
|
});
|
|
420
284
|
};
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
285
|
+
const beforeUploadHandler = file => {
|
|
286
|
+
const isLt = file.size / 1024 / 1024 < size;
|
|
287
|
+
if (!isLt) {
|
|
288
|
+
onError(`文件不能超过${size}MB!`, 'sizeError', {
|
|
289
|
+
size,
|
|
290
|
+
fileSize: file.size
|
|
291
|
+
});
|
|
292
|
+
return false;
|
|
425
293
|
}
|
|
426
|
-
if (
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
if (response.code === 200) {
|
|
430
|
-
propsChange(response.results);
|
|
431
|
-
} else {
|
|
432
|
-
onError(response.msg, "xhrError", response);
|
|
433
|
-
}
|
|
294
|
+
if (maxLength === 1) {
|
|
295
|
+
onChange([]);
|
|
296
|
+
setList([]);
|
|
434
297
|
}
|
|
298
|
+
return onBeforeUpload && onBeforeUpload(file);
|
|
435
299
|
};
|
|
436
|
-
const headers = Object.assign({},
|
|
437
|
-
if (typeof
|
|
438
|
-
Object.assign(headers,
|
|
300
|
+
const headers = Object.assign({}, uploadParams.headers);
|
|
301
|
+
if (typeof uploadParams.getHeaders === 'function') {
|
|
302
|
+
Object.assign(headers, uploadParams.getHeaders());
|
|
439
303
|
}
|
|
440
|
-
|
|
304
|
+
const UploadComponent = drag ? Dragger : Upload;
|
|
305
|
+
return /*#__PURE__*/React.createElement(UploadComponent, _extends({}, omit(uploadParams, ['action', 'transformResponse']), props, {
|
|
441
306
|
headers: headers,
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
beforeUpload:
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}, previewImg && showImageUrl ? previewRender ? previewRender(showImageUrl) : /*#__PURE__*/React__default.createElement("div", {
|
|
451
|
-
className: "preview"
|
|
452
|
-
}, /*#__PURE__*/React__default.createElement("img", {
|
|
453
|
-
src: showImageUrl,
|
|
454
|
-
alt: "avatar"
|
|
455
|
-
})) : uploadButton, extraRender ? extraRender(showImageUrl) : '')));
|
|
307
|
+
action: action || uploadParams.action,
|
|
308
|
+
fileList: valueList,
|
|
309
|
+
accept: accept.join(','),
|
|
310
|
+
onChange: changeHandler,
|
|
311
|
+
beforeUpload: beforeUploadHandler
|
|
312
|
+
}), typeof children === 'function' ? children({
|
|
313
|
+
size: props.size
|
|
314
|
+
}) : children);
|
|
456
315
|
};
|
|
457
|
-
|
|
458
|
-
|
|
316
|
+
_Upload.defaultProps = {
|
|
317
|
+
value: [],
|
|
318
|
+
accept: [],
|
|
459
319
|
fileSize: 2,
|
|
460
|
-
|
|
461
|
-
children:
|
|
462
|
-
|
|
463
|
-
},
|
|
464
|
-
|
|
320
|
+
maxLength: 1,
|
|
321
|
+
children: ({
|
|
322
|
+
size
|
|
323
|
+
}) => /*#__PURE__*/React.createElement(Button, {
|
|
324
|
+
size: size
|
|
325
|
+
}, /*#__PURE__*/React.createElement(UploadOutlined, null), "\u70B9\u51FB\u4E0A\u4F20"),
|
|
465
326
|
onError: info => message.error(info),
|
|
466
|
-
|
|
467
|
-
previewRender: null,
|
|
468
|
-
openEditor: false
|
|
327
|
+
onUploadComplete: () => {}
|
|
469
328
|
};
|
|
470
|
-
const
|
|
471
|
-
const render = useOnChange$
|
|
472
|
-
return render(
|
|
329
|
+
const UploadInput = props => {
|
|
330
|
+
const render = useOnChange$b(props);
|
|
331
|
+
return render(_Upload);
|
|
473
332
|
};
|
|
474
|
-
|
|
475
|
-
fieldName: '
|
|
333
|
+
UploadInput.defaultProps = {
|
|
334
|
+
fieldName: 'upload'
|
|
476
335
|
};
|
|
477
|
-
|
|
336
|
+
UploadInput.field = _Upload;
|
|
478
337
|
|
|
338
|
+
const _excluded$4 = ["data", "setData", "send", "loadMore", "isComplete", "refresh", "reload", "fetchEmitter", "isLoading", "children", "onLoaded", "fetchProps", "requestParams"];
|
|
479
339
|
const {
|
|
480
|
-
useOnChange: useOnChange$
|
|
340
|
+
useOnChange: useOnChange$a
|
|
481
341
|
} = hooks;
|
|
482
|
-
const
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
342
|
+
const withFetch = WrappedComponent => {
|
|
343
|
+
const FieldInner = withFetch$1(_ref => {
|
|
344
|
+
let {
|
|
345
|
+
data,
|
|
346
|
+
setData,
|
|
347
|
+
send,
|
|
348
|
+
loadMore,
|
|
349
|
+
isComplete,
|
|
350
|
+
refresh,
|
|
351
|
+
reload,
|
|
352
|
+
fetchEmitter,
|
|
353
|
+
isLoading,
|
|
354
|
+
children,
|
|
355
|
+
onLoaded,
|
|
356
|
+
fetchProps
|
|
357
|
+
} = _ref,
|
|
358
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
359
|
+
const refreshRef = useRef(refresh);
|
|
360
|
+
refreshRef.current = refresh;
|
|
361
|
+
const reloadRef = useRef(reload);
|
|
362
|
+
reloadRef.current = reload;
|
|
363
|
+
const setDataRef = useRef(setData);
|
|
364
|
+
setDataRef.current = setData;
|
|
365
|
+
const dataRef = useRef(data);
|
|
366
|
+
useEffect(() => {
|
|
367
|
+
const token1 = fetchEmitter.addListener('select-fetch-refresh', () => refreshRef.current());
|
|
368
|
+
const token2 = fetchEmitter.addListener('select-fetch-reload', () => reloadRef.current());
|
|
369
|
+
const token3 = fetchEmitter.addListener('select-fetch-set-data', () => setDataRef.current());
|
|
370
|
+
return () => {
|
|
371
|
+
token1 && token1.remove();
|
|
372
|
+
token2 && token2.remove();
|
|
373
|
+
token3 && token3.remove();
|
|
374
|
+
};
|
|
375
|
+
}, [fetchEmitter]);
|
|
376
|
+
useEffect(() => {
|
|
377
|
+
onLoaded && onLoaded(dataRef.current);
|
|
378
|
+
}, []);
|
|
379
|
+
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, children({
|
|
380
|
+
data,
|
|
381
|
+
fetchProps,
|
|
382
|
+
loadMore,
|
|
383
|
+
send,
|
|
384
|
+
refresh,
|
|
385
|
+
reload,
|
|
386
|
+
isLoading,
|
|
387
|
+
isComplete,
|
|
388
|
+
setData
|
|
389
|
+
})));
|
|
390
|
+
});
|
|
391
|
+
const useFetchEmitter = ref => {
|
|
392
|
+
const emitter = useEvent();
|
|
393
|
+
useImperativeHandle(ref, () => {
|
|
394
|
+
return {
|
|
395
|
+
refresh: () => emitter.emit('select-fetch-refresh'),
|
|
396
|
+
reload: () => emitter.emit('select-fetch-reload'),
|
|
397
|
+
setData: data => emitter.emit('select-fetch-set-data', data)
|
|
398
|
+
};
|
|
399
|
+
}, [emitter]);
|
|
400
|
+
return emitter;
|
|
401
|
+
};
|
|
402
|
+
const Fetch = forwardRef((props, ref) => {
|
|
403
|
+
const emitter = useFetchEmitter(ref);
|
|
404
|
+
const render = useOnChange$a(Object.assign({
|
|
405
|
+
placeholder: `请选择${props.label}`
|
|
406
|
+
}, props, {
|
|
407
|
+
fetchEmitter: emitter
|
|
408
|
+
}));
|
|
409
|
+
return render(FieldInner);
|
|
410
|
+
});
|
|
411
|
+
Fetch.field = forwardRef((props, ref) => {
|
|
412
|
+
const emitter = useFetchEmitter(ref);
|
|
413
|
+
return /*#__PURE__*/React.createElement(FieldInner, _extends({}, props, {
|
|
414
|
+
fetchEmitter: emitter
|
|
415
|
+
}));
|
|
416
|
+
});
|
|
417
|
+
return Fetch;
|
|
488
418
|
};
|
|
489
419
|
|
|
490
420
|
const {
|
|
491
|
-
useOnChange: useOnChange$
|
|
492
|
-
useCheckedToValue: useCheckedToValue$1
|
|
421
|
+
useOnChange: useOnChange$9
|
|
493
422
|
} = hooks;
|
|
494
|
-
const {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
const checkedProps = useCheckedToValue$1(Object.assign({}, props, {
|
|
500
|
-
onChange: e => {
|
|
501
|
-
e.target.type = 'checkbox';
|
|
502
|
-
props.onChange && props.onChange(e);
|
|
503
|
-
}
|
|
504
|
-
}));
|
|
505
|
-
const render = useOnChange$a(checkedProps);
|
|
506
|
-
return render(WithCheckbox);
|
|
423
|
+
const _TreeSelect = props => {
|
|
424
|
+
const render = useOnChange$9(Object.assign({
|
|
425
|
+
placeholder: `请选择${props.label || ''}`
|
|
426
|
+
}, props));
|
|
427
|
+
return render(TreeSelect);
|
|
507
428
|
};
|
|
508
|
-
|
|
509
|
-
|
|
429
|
+
_TreeSelect.Fetch = withFetch(TreeSelect);
|
|
430
|
+
_TreeSelect.defaultProps = _TreeSelect.Fetch.defaultProps = {
|
|
431
|
+
fieldName: 'treeSelect'
|
|
510
432
|
};
|
|
433
|
+
_TreeSelect.TreeNode = TreeSelect.TreeNode;
|
|
511
434
|
|
|
512
435
|
const {
|
|
513
|
-
useOnChange: useOnChange$
|
|
436
|
+
useOnChange: useOnChange$8
|
|
514
437
|
} = hooks;
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
438
|
+
const {
|
|
439
|
+
RangePicker: RangePicker$1
|
|
440
|
+
} = TimePicker;
|
|
441
|
+
const _TimePicker = props => {
|
|
442
|
+
const render = useOnChange$8(Object.assign({
|
|
443
|
+
placeholder: `请选择${props.label || ''}`
|
|
444
|
+
}, props));
|
|
445
|
+
return render(TimePicker);
|
|
519
446
|
};
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
447
|
+
_TimePicker.defaultProps = {
|
|
448
|
+
fieldName: 'timePicker'
|
|
449
|
+
};
|
|
450
|
+
const _RangePicker$1 = props => {
|
|
451
|
+
const render = useOnChange$8(Object.assign({
|
|
452
|
+
placeholder: `请选择${props.label || ''}`
|
|
453
|
+
}, props));
|
|
454
|
+
return render(RangePicker$1);
|
|
455
|
+
};
|
|
456
|
+
_RangePicker$1.defaultProps = {
|
|
457
|
+
fieldName: 'rangeTimePicker'
|
|
523
458
|
};
|
|
459
|
+
_TimePicker.RangePicker = _RangePicker$1;
|
|
524
460
|
|
|
525
461
|
const {
|
|
526
|
-
|
|
462
|
+
useDecorator: useDecorator$2
|
|
527
463
|
} = hooks;
|
|
464
|
+
const TextArea = props => {
|
|
465
|
+
const render = useDecorator$2(Object.assign({
|
|
466
|
+
placeholder: `请输入${props.label}`
|
|
467
|
+
}, props));
|
|
468
|
+
return render(Input.TextArea);
|
|
469
|
+
};
|
|
470
|
+
TextArea.defaultProps = {
|
|
471
|
+
fieldName: 'textArea'
|
|
472
|
+
};
|
|
473
|
+
|
|
528
474
|
const {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
475
|
+
useOnChange: useOnChange$7,
|
|
476
|
+
useCheckedToValue: useCheckedToValue$1
|
|
477
|
+
} = hooks;
|
|
478
|
+
const {
|
|
479
|
+
withChecked: withChecked$1
|
|
480
|
+
} = hoc;
|
|
481
|
+
const WithSwitch = withChecked$1(Switch$1);
|
|
482
|
+
const Switch = props => {
|
|
483
|
+
const checkedProps = useCheckedToValue$1(props);
|
|
484
|
+
const render = useOnChange$7(checkedProps);
|
|
485
|
+
return render(WithSwitch);
|
|
486
|
+
};
|
|
487
|
+
Switch.defaultProps = {
|
|
488
|
+
fieldName: 'switch'
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
const {
|
|
492
|
+
useOnChange: useOnChange$6
|
|
493
|
+
} = hooks;
|
|
494
|
+
const _Select = props => {
|
|
495
|
+
const render = useOnChange$6(Object.assign({
|
|
535
496
|
placeholder: `请选择${props.label || ''}`
|
|
536
497
|
}, props));
|
|
537
|
-
return render(
|
|
498
|
+
return render(Select);
|
|
538
499
|
};
|
|
539
|
-
|
|
540
|
-
|
|
500
|
+
_Select.Fetch = withFetch(Select);
|
|
501
|
+
_Select.Option = Select.Option;
|
|
502
|
+
_Select.OptGroup = Select.OptGroup;
|
|
503
|
+
_Select.defaultProps = _Select.Fetch.defaultProps = {
|
|
504
|
+
fieldName: 'select'
|
|
541
505
|
};
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
506
|
+
|
|
507
|
+
const _excluded$3 = ["onChange"];
|
|
508
|
+
const {
|
|
509
|
+
useOnChange: useOnChange$5
|
|
510
|
+
} = hooks;
|
|
511
|
+
const RadioGroup = _ref => {
|
|
512
|
+
let {
|
|
513
|
+
onChange
|
|
514
|
+
} = _ref,
|
|
515
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
516
|
+
const handler = useCallback(e => {
|
|
517
|
+
onChange && onChange(e.target.value);
|
|
518
|
+
}, [onChange]);
|
|
519
|
+
return /*#__PURE__*/React.createElement(Radio.Group, _extends({}, props, {
|
|
520
|
+
onChange: handler
|
|
521
|
+
}));
|
|
547
522
|
};
|
|
548
|
-
|
|
549
|
-
|
|
523
|
+
const _RadioGroup = props => {
|
|
524
|
+
const render = useOnChange$5(props);
|
|
525
|
+
return render(RadioGroup);
|
|
550
526
|
};
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
527
|
+
_RadioGroup.defaultProps = {
|
|
528
|
+
fieldName: 'radioGroup'
|
|
529
|
+
};
|
|
530
|
+
_RadioGroup.Radio = Radio;
|
|
531
|
+
|
|
532
|
+
const {
|
|
533
|
+
useDecorator: useDecorator$1
|
|
534
|
+
} = hooks;
|
|
535
|
+
const InputNumberField = props => {
|
|
536
|
+
const render = useDecorator$1(Object.assign({
|
|
537
|
+
placeholder: `请输入${props.label}`
|
|
554
538
|
}, props));
|
|
555
|
-
return render(
|
|
539
|
+
return render(InputNumber);
|
|
556
540
|
};
|
|
557
|
-
|
|
558
|
-
fieldName: '
|
|
541
|
+
InputNumberField.defaultProps = {
|
|
542
|
+
fieldName: 'inputNumber',
|
|
543
|
+
autoComplete: 'off'
|
|
559
544
|
};
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
545
|
+
|
|
546
|
+
const {
|
|
547
|
+
useDecorator
|
|
548
|
+
} = hooks;
|
|
549
|
+
const InputField = props => {
|
|
550
|
+
const render = useDecorator(Object.assign({
|
|
551
|
+
placeholder: `请输入${props.label}`
|
|
563
552
|
}, props));
|
|
564
|
-
return render(
|
|
553
|
+
return render(Input);
|
|
565
554
|
};
|
|
566
|
-
|
|
567
|
-
|
|
555
|
+
InputField.Password = props => {
|
|
556
|
+
const render = useDecorator(Object.assign({
|
|
557
|
+
placeholder: `请输入${props.label}`
|
|
558
|
+
}, props));
|
|
559
|
+
return render(Input.Password);
|
|
560
|
+
};
|
|
561
|
+
InputField.defaultProps = {
|
|
562
|
+
fieldName: 'input',
|
|
563
|
+
autoComplete: 'off'
|
|
564
|
+
};
|
|
565
|
+
InputField.Password.defaultProps = {
|
|
566
|
+
fieldName: 'password',
|
|
567
|
+
autoComplete: 'off'
|
|
568
568
|
};
|
|
569
|
-
_DatePicker.MonthPicker = _MonthPicker;
|
|
570
|
-
_DatePicker.RangePicker = _RangePicker$1;
|
|
571
|
-
_DatePicker.WeekPicker = _WeekPicker;
|
|
572
569
|
|
|
573
|
-
const _excluded$
|
|
570
|
+
const _excluded$2 = ["soFarText"];
|
|
574
571
|
const {
|
|
575
|
-
useOnChange: useOnChange$
|
|
572
|
+
useOnChange: useOnChange$4
|
|
576
573
|
} = hooks;
|
|
577
574
|
const PickerToday = _ref => {
|
|
578
575
|
let {
|
|
579
576
|
soFarText
|
|
580
577
|
} = _ref,
|
|
581
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
578
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
582
579
|
const [data, onChange] = useControlValue(props);
|
|
583
580
|
const ref_d = useRef();
|
|
584
581
|
const newData = useMemo(() => {
|
|
@@ -609,7 +606,7 @@ const PickerToday = _ref => {
|
|
|
609
606
|
onChange([newData.start, v || '']);
|
|
610
607
|
};
|
|
611
608
|
const foot = () => {
|
|
612
|
-
return /*#__PURE__*/
|
|
609
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
613
610
|
type: newData.showZj ? 'primary' : 'default',
|
|
614
611
|
onClick: v => {
|
|
615
612
|
ref_d.current.blur();
|
|
@@ -617,20 +614,20 @@ const PickerToday = _ref => {
|
|
|
617
614
|
}
|
|
618
615
|
}, soFarText || '至今');
|
|
619
616
|
};
|
|
620
|
-
return /*#__PURE__*/
|
|
617
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
621
618
|
style: {
|
|
622
619
|
display: 'flex'
|
|
623
620
|
}
|
|
624
|
-
}, /*#__PURE__*/
|
|
621
|
+
}, /*#__PURE__*/React.createElement(DatePicker, _extends({}, _extends({
|
|
625
622
|
showToday: false
|
|
626
623
|
}, props, {
|
|
627
624
|
placeholder: newData.placeholder[0],
|
|
628
625
|
value: newData.start
|
|
629
626
|
}), {
|
|
630
627
|
onChange: startChange
|
|
631
|
-
})), /*#__PURE__*/
|
|
628
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
632
629
|
className: 'svg_box'
|
|
633
|
-
}, /*#__PURE__*/
|
|
630
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
634
631
|
viewBox: "0 0 1024 1024",
|
|
635
632
|
focusable: "false",
|
|
636
633
|
"data-icon": "swap-right",
|
|
@@ -638,13 +635,13 @@ const PickerToday = _ref => {
|
|
|
638
635
|
height: "1em",
|
|
639
636
|
fill: "currentColor",
|
|
640
637
|
"aria-hidden": "true"
|
|
641
|
-
}, /*#__PURE__*/
|
|
638
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
642
639
|
d: "M873.1 596.2l-164-208A32 32 0 00684 376h-64.8c-6.7 0-10.4 7.7-6.3 13l144.3 183H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h695.9c26.8 0 41.7-30.8 25.2-51.8z"
|
|
643
|
-
}))), /*#__PURE__*/
|
|
640
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
644
641
|
className: newData.showZj ? 'data_range_picker data_range_picker_dis' : 'data_range_picker'
|
|
645
|
-
}, /*#__PURE__*/
|
|
642
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
646
643
|
className: newData.showZj ? 'zhijin zhijin_show' : 'zhijin'
|
|
647
|
-
}, soFarText || '至今'), /*#__PURE__*/
|
|
644
|
+
}, soFarText || '至今'), /*#__PURE__*/React.createElement(DatePicker, _extends({}, _extends({
|
|
648
645
|
showToday: false
|
|
649
646
|
}, props, {
|
|
650
647
|
placeholder: newData.showZj ? '' : newData.placeholder[1],
|
|
@@ -656,7 +653,7 @@ const PickerToday = _ref => {
|
|
|
656
653
|
}))));
|
|
657
654
|
};
|
|
658
655
|
const RangePickerToday = props => {
|
|
659
|
-
const render = useOnChange$
|
|
656
|
+
const render = useOnChange$4(props);
|
|
660
657
|
return render(PickerToday);
|
|
661
658
|
};
|
|
662
659
|
RangePickerToday.defaultProps = {
|
|
@@ -665,454 +662,139 @@ RangePickerToday.defaultProps = {
|
|
|
665
662
|
RangePickerToday.field = PickerToday;
|
|
666
663
|
|
|
667
664
|
const {
|
|
668
|
-
|
|
665
|
+
useOnChange: useOnChange$3
|
|
669
666
|
} = hooks;
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
|
|
667
|
+
const {
|
|
668
|
+
MonthPicker,
|
|
669
|
+
RangePicker,
|
|
670
|
+
WeekPicker
|
|
671
|
+
} = DatePicker;
|
|
672
|
+
const _DatePicker = props => {
|
|
673
|
+
const render = useOnChange$3(Object.assign({
|
|
674
|
+
placeholder: `请选择${props.label || ''}`
|
|
673
675
|
}, props));
|
|
674
|
-
return render(
|
|
676
|
+
return render(DatePicker);
|
|
675
677
|
};
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
678
|
+
_DatePicker.defaultProps = {
|
|
679
|
+
fieldName: 'datePicker'
|
|
680
|
+
};
|
|
681
|
+
const _MonthPicker = props => {
|
|
682
|
+
const render = useOnChange$3(Object.assign({
|
|
683
|
+
placeholder: ['开始时间', '结束时间']
|
|
679
684
|
}, props));
|
|
680
|
-
return render(
|
|
685
|
+
return render(MonthPicker);
|
|
681
686
|
};
|
|
682
|
-
|
|
683
|
-
fieldName: '
|
|
684
|
-
autoComplete: 'off'
|
|
687
|
+
_MonthPicker.defaultProps = {
|
|
688
|
+
fieldName: 'monthDatePicker'
|
|
685
689
|
};
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
690
|
+
const _RangePicker = props => {
|
|
691
|
+
const render = useOnChange$3(Object.assign({
|
|
692
|
+
placeholder: ['开始时间', '结束时间']
|
|
693
|
+
}, props));
|
|
694
|
+
return render(RangePicker);
|
|
695
|
+
};
|
|
696
|
+
_RangePicker.defaultProps = {
|
|
697
|
+
fieldName: 'rangeDatePicker'
|
|
698
|
+
};
|
|
699
|
+
const _WeekPicker = props => {
|
|
700
|
+
const render = useOnChange$3(Object.assign({
|
|
701
|
+
placeholder: ['开始时间', '结束时间']
|
|
702
|
+
}, props));
|
|
703
|
+
return render(WeekPicker);
|
|
704
|
+
};
|
|
705
|
+
_WeekPicker.defaultProps = {
|
|
706
|
+
fieldName: 'weekDatePicker'
|
|
689
707
|
};
|
|
708
|
+
_DatePicker.MonthPicker = _MonthPicker;
|
|
709
|
+
_DatePicker.RangePicker = _RangePicker;
|
|
710
|
+
_DatePicker.WeekPicker = _WeekPicker;
|
|
690
711
|
|
|
691
712
|
const {
|
|
692
|
-
|
|
713
|
+
useOnChange: useOnChange$2
|
|
693
714
|
} = hooks;
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
return render(InputNumber$1);
|
|
715
|
+
const _CheckboxGroup = Checkbox$1.Group;
|
|
716
|
+
const CheckboxGroup = props => {
|
|
717
|
+
const render = useOnChange$2(props);
|
|
718
|
+
return render(_CheckboxGroup);
|
|
699
719
|
};
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
720
|
+
CheckboxGroup.Checkbox = Checkbox$1;
|
|
721
|
+
CheckboxGroup.defaultProps = {
|
|
722
|
+
fieldName: 'checkboxGroup'
|
|
703
723
|
};
|
|
704
724
|
|
|
705
|
-
const _excluded$5 = ["onChange"];
|
|
706
725
|
const {
|
|
707
|
-
useOnChange: useOnChange$
|
|
726
|
+
useOnChange: useOnChange$1,
|
|
727
|
+
useCheckedToValue
|
|
708
728
|
} = hooks;
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
const
|
|
715
|
-
onChange
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
729
|
+
const {
|
|
730
|
+
withChecked
|
|
731
|
+
} = hoc;
|
|
732
|
+
const WithCheckbox = withChecked(Checkbox$1);
|
|
733
|
+
const Checkbox = props => {
|
|
734
|
+
const checkedProps = useCheckedToValue(Object.assign({}, props, {
|
|
735
|
+
onChange: e => {
|
|
736
|
+
e.target.type = 'checkbox';
|
|
737
|
+
props.onChange && props.onChange(e);
|
|
738
|
+
}
|
|
719
739
|
}));
|
|
740
|
+
const render = useOnChange$1(checkedProps);
|
|
741
|
+
return render(WithCheckbox);
|
|
720
742
|
};
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
return render(RadioGroup$1);
|
|
743
|
+
Checkbox.defaultProps = {
|
|
744
|
+
fieldName: 'checkbox'
|
|
724
745
|
};
|
|
725
|
-
|
|
726
|
-
|
|
746
|
+
|
|
747
|
+
const {
|
|
748
|
+
useOnChange
|
|
749
|
+
} = hooks;
|
|
750
|
+
const Cascader = props => {
|
|
751
|
+
const render = useOnChange(props);
|
|
752
|
+
return render(Cascader$1);
|
|
753
|
+
};
|
|
754
|
+
Cascader.defaultProps = {
|
|
755
|
+
fieldName: 'cascader'
|
|
727
756
|
};
|
|
728
|
-
_RadioGroup.Radio = Radio;
|
|
729
757
|
|
|
730
|
-
const
|
|
758
|
+
const ResetButton = props => {
|
|
759
|
+
const resetProps = useReset();
|
|
760
|
+
return /*#__PURE__*/React.createElement(Button, _extends({}, resetProps, props));
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
const _excluded$1 = ["realTime", "disabled"],
|
|
764
|
+
_excluded2 = ["isPass", "isLoading"];
|
|
765
|
+
const SubmitButton = _ref => {
|
|
766
|
+
let {
|
|
767
|
+
realTime,
|
|
768
|
+
disabled
|
|
769
|
+
} = _ref,
|
|
770
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
771
|
+
const _useSubmit = useSubmit(props),
|
|
772
|
+
{
|
|
773
|
+
isPass,
|
|
774
|
+
isLoading
|
|
775
|
+
} = _useSubmit,
|
|
776
|
+
submitProps = _objectWithoutPropertiesLoose(_useSubmit, _excluded2);
|
|
777
|
+
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
778
|
+
loading: isLoading,
|
|
779
|
+
disabled: disabled || (realTime ? !isPass : false)
|
|
780
|
+
}, props, submitProps));
|
|
781
|
+
};
|
|
782
|
+
SubmitButton.defaultProps = {
|
|
783
|
+
type: 'primary',
|
|
784
|
+
disabled: false
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
const _excluded = ["onClick"];
|
|
731
788
|
const {
|
|
732
|
-
|
|
733
|
-
} = hooks;
|
|
734
|
-
const withFetch = WrappedComponent => {
|
|
735
|
-
const FieldInner = withFetch$1(_ref => {
|
|
736
|
-
let {
|
|
737
|
-
data,
|
|
738
|
-
setData,
|
|
739
|
-
send,
|
|
740
|
-
loadMore,
|
|
741
|
-
isComplete,
|
|
742
|
-
refresh,
|
|
743
|
-
reload,
|
|
744
|
-
fetchEmitter,
|
|
745
|
-
isLoading,
|
|
746
|
-
children,
|
|
747
|
-
onLoaded,
|
|
748
|
-
fetchProps
|
|
749
|
-
} = _ref,
|
|
750
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
751
|
-
const refreshRef = useRef(refresh);
|
|
752
|
-
refreshRef.current = refresh;
|
|
753
|
-
const reloadRef = useRef(reload);
|
|
754
|
-
reloadRef.current = reload;
|
|
755
|
-
const setDataRef = useRef(setData);
|
|
756
|
-
setDataRef.current = setData;
|
|
757
|
-
const dataRef = useRef(data);
|
|
758
|
-
useEffect(() => {
|
|
759
|
-
const token1 = fetchEmitter.addListener('select-fetch-refresh', () => refreshRef.current());
|
|
760
|
-
const token2 = fetchEmitter.addListener('select-fetch-reload', () => reloadRef.current());
|
|
761
|
-
const token3 = fetchEmitter.addListener('select-fetch-set-data', () => setDataRef.current());
|
|
762
|
-
return () => {
|
|
763
|
-
token1 && token1.remove();
|
|
764
|
-
token2 && token2.remove();
|
|
765
|
-
token3 && token3.remove();
|
|
766
|
-
};
|
|
767
|
-
}, [fetchEmitter]);
|
|
768
|
-
useEffect(() => {
|
|
769
|
-
onLoaded && onLoaded(dataRef.current);
|
|
770
|
-
}, []);
|
|
771
|
-
return /*#__PURE__*/React__default.createElement(WrappedComponent, _extends({}, props, children({
|
|
772
|
-
data,
|
|
773
|
-
fetchProps,
|
|
774
|
-
loadMore,
|
|
775
|
-
send,
|
|
776
|
-
refresh,
|
|
777
|
-
reload,
|
|
778
|
-
isLoading,
|
|
779
|
-
isComplete,
|
|
780
|
-
setData
|
|
781
|
-
})));
|
|
782
|
-
});
|
|
783
|
-
const useFetchEmitter = ref => {
|
|
784
|
-
const emitter = useEvent();
|
|
785
|
-
useImperativeHandle(ref, () => {
|
|
786
|
-
return {
|
|
787
|
-
refresh: () => emitter.emit('select-fetch-refresh'),
|
|
788
|
-
reload: () => emitter.emit('select-fetch-reload'),
|
|
789
|
-
setData: data => emitter.emit('select-fetch-set-data', data)
|
|
790
|
-
};
|
|
791
|
-
}, [emitter]);
|
|
792
|
-
return emitter;
|
|
793
|
-
};
|
|
794
|
-
const Fetch = forwardRef((props, ref) => {
|
|
795
|
-
const emitter = useFetchEmitter(ref);
|
|
796
|
-
const render = useOnChange$5(Object.assign({
|
|
797
|
-
placeholder: `请选择${props.label}`
|
|
798
|
-
}, props, {
|
|
799
|
-
fetchEmitter: emitter
|
|
800
|
-
}));
|
|
801
|
-
return render(FieldInner);
|
|
802
|
-
});
|
|
803
|
-
Fetch.field = forwardRef((props, ref) => {
|
|
804
|
-
const emitter = useFetchEmitter(ref);
|
|
805
|
-
return /*#__PURE__*/React__default.createElement(FieldInner, _extends({}, props, {
|
|
806
|
-
fetchEmitter: emitter
|
|
807
|
-
}));
|
|
808
|
-
});
|
|
809
|
-
return Fetch;
|
|
810
|
-
};
|
|
811
|
-
|
|
812
|
-
const {
|
|
813
|
-
useOnChange: useOnChange$4
|
|
814
|
-
} = hooks;
|
|
815
|
-
const _Select = props => {
|
|
816
|
-
const render = useOnChange$4(Object.assign({
|
|
817
|
-
placeholder: `请选择${props.label || ''}`
|
|
818
|
-
}, props));
|
|
819
|
-
return render(Select$1);
|
|
820
|
-
};
|
|
821
|
-
_Select.Fetch = withFetch(Select$1);
|
|
822
|
-
_Select.Option = Select$1.Option;
|
|
823
|
-
_Select.OptGroup = Select$1.OptGroup;
|
|
824
|
-
_Select.defaultProps = _Select.Fetch.defaultProps = {
|
|
825
|
-
fieldName: 'select'
|
|
826
|
-
};
|
|
827
|
-
|
|
828
|
-
const {
|
|
829
|
-
useOnChange: useOnChange$3,
|
|
830
|
-
useCheckedToValue
|
|
831
|
-
} = hooks;
|
|
832
|
-
const {
|
|
833
|
-
withChecked
|
|
834
|
-
} = hoc;
|
|
835
|
-
const WithSwitch = withChecked(Switch$2);
|
|
836
|
-
const Switch$1 = props => {
|
|
837
|
-
const checkedProps = useCheckedToValue(props);
|
|
838
|
-
const render = useOnChange$3(checkedProps);
|
|
839
|
-
return render(WithSwitch);
|
|
840
|
-
};
|
|
841
|
-
Switch$1.defaultProps = {
|
|
842
|
-
fieldName: 'switch'
|
|
843
|
-
};
|
|
844
|
-
|
|
845
|
-
const {
|
|
846
|
-
useDecorator
|
|
847
|
-
} = hooks;
|
|
848
|
-
const TextArea$1 = props => {
|
|
849
|
-
const render = useDecorator(Object.assign({
|
|
850
|
-
placeholder: `请输入${props.label}`
|
|
851
|
-
}, props));
|
|
852
|
-
return render(Input$1.TextArea);
|
|
853
|
-
};
|
|
854
|
-
TextArea$1.defaultProps = {
|
|
855
|
-
fieldName: 'textArea'
|
|
856
|
-
};
|
|
857
|
-
|
|
858
|
-
const {
|
|
859
|
-
useOnChange: useOnChange$2
|
|
860
|
-
} = hooks;
|
|
861
|
-
const {
|
|
862
|
-
RangePicker
|
|
863
|
-
} = TimePicker$1;
|
|
864
|
-
const _TimePicker = props => {
|
|
865
|
-
const render = useOnChange$2(Object.assign({
|
|
866
|
-
placeholder: `请选择${props.label || ''}`
|
|
867
|
-
}, props));
|
|
868
|
-
return render(TimePicker$1);
|
|
869
|
-
};
|
|
870
|
-
_TimePicker.defaultProps = {
|
|
871
|
-
fieldName: 'timePicker'
|
|
872
|
-
};
|
|
873
|
-
const _RangePicker = props => {
|
|
874
|
-
const render = useOnChange$2(Object.assign({
|
|
875
|
-
placeholder: `请选择${props.label || ''}`
|
|
876
|
-
}, props));
|
|
877
|
-
return render(RangePicker);
|
|
878
|
-
};
|
|
879
|
-
_RangePicker.defaultProps = {
|
|
880
|
-
fieldName: 'rangeTimePicker'
|
|
881
|
-
};
|
|
882
|
-
_TimePicker.RangePicker = _RangePicker;
|
|
883
|
-
|
|
884
|
-
const {
|
|
885
|
-
useOnChange: useOnChange$1
|
|
886
|
-
} = hooks;
|
|
887
|
-
const _TreeSelect = props => {
|
|
888
|
-
const render = useOnChange$1(Object.assign({
|
|
889
|
-
placeholder: `请选择${props.label || ''}`
|
|
890
|
-
}, props));
|
|
891
|
-
return render(TreeSelect$1);
|
|
892
|
-
};
|
|
893
|
-
_TreeSelect.Fetch = withFetch(TreeSelect$1);
|
|
894
|
-
_TreeSelect.defaultProps = _TreeSelect.Fetch.defaultProps = {
|
|
895
|
-
fieldName: 'treeSelect'
|
|
896
|
-
};
|
|
897
|
-
_TreeSelect.TreeNode = TreeSelect$1.TreeNode;
|
|
898
|
-
|
|
899
|
-
const _excluded$3 = ["action", "value", "onChange", "drag", "children", "displayFilename", "accept", "fileSize", "onError", "onUploadComplete", "onBeforeUpload", "maxLength", "transformResponse"];
|
|
900
|
-
const {
|
|
901
|
-
useOnChange
|
|
902
|
-
} = hooks;
|
|
903
|
-
const {
|
|
904
|
-
Dragger
|
|
905
|
-
} = Upload$1;
|
|
906
|
-
const uploadParams = globalParams.field.upload;
|
|
907
|
-
const decodeURIComponentSafe = str => {
|
|
908
|
-
try {
|
|
909
|
-
return decodeURIComponent(str);
|
|
910
|
-
} catch (e) {
|
|
911
|
-
return str;
|
|
912
|
-
}
|
|
913
|
-
};
|
|
914
|
-
const computedFilename = (path, displayFilename = 'filename') => {
|
|
915
|
-
const strArray = path.split('?');
|
|
916
|
-
if (strArray[1]) {
|
|
917
|
-
const query = {};
|
|
918
|
-
strArray[1].split('&').forEach(str => {
|
|
919
|
-
const [key, value] = str.split('=');
|
|
920
|
-
query[key] = value;
|
|
921
|
-
});
|
|
922
|
-
if (query[displayFilename]) {
|
|
923
|
-
return decodeURIComponentSafe(query[displayFilename]);
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
return path;
|
|
927
|
-
};
|
|
928
|
-
const valueToList = (value, displayFilename) => {
|
|
929
|
-
if (!value) {
|
|
930
|
-
return [];
|
|
931
|
-
}
|
|
932
|
-
return value.map(item => {
|
|
933
|
-
return {
|
|
934
|
-
uid: uniqueId(),
|
|
935
|
-
name: computedFilename(item.substr(item.lastIndexOf('/') + 1), displayFilename),
|
|
936
|
-
status: 'done',
|
|
937
|
-
response: {
|
|
938
|
-
code: 200,
|
|
939
|
-
results: item
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
});
|
|
943
|
-
};
|
|
944
|
-
const listToValue = value => {
|
|
945
|
-
return (value || []).slice(0).filter(({
|
|
946
|
-
status
|
|
947
|
-
}) => status === 'done').map(({
|
|
948
|
-
response
|
|
949
|
-
}) => response.results);
|
|
950
|
-
};
|
|
951
|
-
const _Upload = _ref => {
|
|
952
|
-
let {
|
|
953
|
-
action,
|
|
954
|
-
value,
|
|
955
|
-
onChange,
|
|
956
|
-
drag,
|
|
957
|
-
children,
|
|
958
|
-
displayFilename,
|
|
959
|
-
accept,
|
|
960
|
-
fileSize: size,
|
|
961
|
-
onError,
|
|
962
|
-
onUploadComplete,
|
|
963
|
-
onBeforeUpload,
|
|
964
|
-
maxLength,
|
|
965
|
-
transformResponse
|
|
966
|
-
} = _ref,
|
|
967
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
968
|
-
displayFilename = displayFilename || uploadParams.displayFilename;
|
|
969
|
-
value = value || [];
|
|
970
|
-
const [list, setList] = useState([]);
|
|
971
|
-
const valueList = useMemo(() => {
|
|
972
|
-
return valueToList(value.filter(url => {
|
|
973
|
-
return !list.find(file => decodeURIComponentSafe(get(file, 'response.results', '')) === decodeURIComponentSafe(url));
|
|
974
|
-
}), displayFilename).concat(list);
|
|
975
|
-
}, [list, value, displayFilename]);
|
|
976
|
-
const changeHandler = info => {
|
|
977
|
-
var _info$fileList;
|
|
978
|
-
if (['uploading', 'done', 'error', 'removed'].indexOf(info.file.status) === -1) {
|
|
979
|
-
return;
|
|
980
|
-
}
|
|
981
|
-
if (((_info$fileList = info.fileList) == null ? void 0 : _info$fileList.length) > maxLength) {
|
|
982
|
-
var _info$fileList2;
|
|
983
|
-
if (JSON.stringify(info.file) === JSON.stringify(info.fileList[((_info$fileList2 = info.fileList) == null ? void 0 : _info$fileList2.length) - 1])) {
|
|
984
|
-
onError(`上传文件不能超过最大允许数量${maxLength}`, 'lengthError', maxLength);
|
|
985
|
-
}
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
if (info.file.status === 'done' && info.fileList.find(({
|
|
989
|
-
uid
|
|
990
|
-
}) => uid === info.file.uid)) {
|
|
991
|
-
info.file.response = (transformResponse || uploadParams.transformResponse)(info.file.response);
|
|
992
|
-
if (info.file.response.code === 200) {
|
|
993
|
-
info.file.name = computedFilename(info.file.response.results.substr(info.file.response.results.lastIndexOf('/') + 1), displayFilename);
|
|
994
|
-
onUploadComplete(info);
|
|
995
|
-
} else {
|
|
996
|
-
info.file.status = 'error';
|
|
997
|
-
onError(info.file.response.msg, 'xhrError', info.file.response);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
const {
|
|
1001
|
-
done
|
|
1002
|
-
} = groupBy(info.fileList, file => file.status === 'done' ? 'done' : 'uploading');
|
|
1003
|
-
if (['done', 'removed'].indexOf(info.file.status) > -1) {
|
|
1004
|
-
onChange(listToValue(done));
|
|
1005
|
-
}
|
|
1006
|
-
setList(list => {
|
|
1007
|
-
const newList = list.slice(0);
|
|
1008
|
-
const index = list.findIndex(({
|
|
1009
|
-
uid
|
|
1010
|
-
}) => uid === info.file.uid);
|
|
1011
|
-
if (info.file.status === 'removed') {
|
|
1012
|
-
index > -1 && newList.splice(index, 1);
|
|
1013
|
-
return newList;
|
|
1014
|
-
}
|
|
1015
|
-
if (index === -1) {
|
|
1016
|
-
newList.push(info.file);
|
|
1017
|
-
return newList;
|
|
1018
|
-
}
|
|
1019
|
-
newList.splice(index, 1, info.file);
|
|
1020
|
-
return newList;
|
|
1021
|
-
});
|
|
1022
|
-
};
|
|
1023
|
-
const beforeUploadHandler = file => {
|
|
1024
|
-
const isLt = file.size / 1024 / 1024 < size;
|
|
1025
|
-
if (!isLt) {
|
|
1026
|
-
onError(`文件不能超过${size}MB!`, 'sizeError', {
|
|
1027
|
-
size,
|
|
1028
|
-
fileSize: file.size
|
|
1029
|
-
});
|
|
1030
|
-
return false;
|
|
1031
|
-
}
|
|
1032
|
-
if (maxLength === 1) {
|
|
1033
|
-
onChange([]);
|
|
1034
|
-
setList([]);
|
|
1035
|
-
}
|
|
1036
|
-
return onBeforeUpload && onBeforeUpload(file);
|
|
1037
|
-
};
|
|
1038
|
-
const headers = Object.assign({}, uploadParams.headers);
|
|
1039
|
-
if (typeof uploadParams.getHeaders === 'function') {
|
|
1040
|
-
Object.assign(headers, uploadParams.getHeaders());
|
|
1041
|
-
}
|
|
1042
|
-
const UploadComponent = drag ? Dragger : Upload$1;
|
|
1043
|
-
return /*#__PURE__*/React__default.createElement(UploadComponent, _extends({}, omit(uploadParams, ['action', 'transformResponse']), props, {
|
|
1044
|
-
headers: headers,
|
|
1045
|
-
action: action || uploadParams.action,
|
|
1046
|
-
fileList: valueList,
|
|
1047
|
-
accept: accept.join(','),
|
|
1048
|
-
onChange: changeHandler,
|
|
1049
|
-
beforeUpload: beforeUploadHandler
|
|
1050
|
-
}), typeof children === 'function' ? children({
|
|
1051
|
-
size: props.size
|
|
1052
|
-
}) : children);
|
|
1053
|
-
};
|
|
1054
|
-
_Upload.defaultProps = {
|
|
1055
|
-
value: [],
|
|
1056
|
-
accept: [],
|
|
1057
|
-
fileSize: 2,
|
|
1058
|
-
maxLength: 1,
|
|
1059
|
-
children: ({
|
|
1060
|
-
size
|
|
1061
|
-
}) => /*#__PURE__*/React__default.createElement(Button, {
|
|
1062
|
-
size: size
|
|
1063
|
-
}, /*#__PURE__*/React__default.createElement(UploadOutlined, null), "\u70B9\u51FB\u4E0A\u4F20"),
|
|
1064
|
-
onError: info => message.error(info),
|
|
1065
|
-
onUploadComplete: () => {}
|
|
1066
|
-
};
|
|
1067
|
-
const UploadInput = props => {
|
|
1068
|
-
const render = useOnChange(props);
|
|
1069
|
-
return render(_Upload);
|
|
1070
|
-
};
|
|
1071
|
-
UploadInput.defaultProps = {
|
|
1072
|
-
fieldName: 'upload'
|
|
1073
|
-
};
|
|
1074
|
-
UploadInput.field = _Upload;
|
|
1075
|
-
|
|
1076
|
-
const _excluded$2 = ["realTime", "disabled"],
|
|
1077
|
-
_excluded2$1 = ["isPass", "isLoading"];
|
|
1078
|
-
const SubmitButton = _ref => {
|
|
1079
|
-
let {
|
|
1080
|
-
realTime,
|
|
1081
|
-
disabled
|
|
1082
|
-
} = _ref,
|
|
1083
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
1084
|
-
const _useSubmit = useSubmit(props),
|
|
1085
|
-
{
|
|
1086
|
-
isPass,
|
|
1087
|
-
isLoading
|
|
1088
|
-
} = _useSubmit,
|
|
1089
|
-
submitProps = _objectWithoutPropertiesLoose(_useSubmit, _excluded2$1);
|
|
1090
|
-
return /*#__PURE__*/React__default.createElement(Button, _extends({
|
|
1091
|
-
loading: isLoading,
|
|
1092
|
-
disabled: disabled || (realTime ? !isPass : false)
|
|
1093
|
-
}, props, submitProps));
|
|
1094
|
-
};
|
|
1095
|
-
SubmitButton.defaultProps = {
|
|
1096
|
-
type: 'primary',
|
|
1097
|
-
disabled: false
|
|
1098
|
-
};
|
|
1099
|
-
|
|
1100
|
-
const ResetButton = props => {
|
|
1101
|
-
const resetProps = useReset();
|
|
1102
|
-
return /*#__PURE__*/React__default.createElement(Button, _extends({}, resetProps, props));
|
|
1103
|
-
};
|
|
1104
|
-
|
|
1105
|
-
const _excluded$1 = ["onClick"];
|
|
1106
|
-
const {
|
|
1107
|
-
useCacheRemove
|
|
789
|
+
useCacheRemove
|
|
1108
790
|
} = hooks;
|
|
1109
791
|
const CancelButton = _ref => {
|
|
1110
792
|
let {
|
|
1111
793
|
onClick
|
|
1112
794
|
} = _ref,
|
|
1113
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded
|
|
795
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1114
796
|
const remove = useCacheRemove();
|
|
1115
|
-
return /*#__PURE__*/
|
|
797
|
+
return /*#__PURE__*/React.createElement(Button, _extends({}, props, {
|
|
1116
798
|
onClick: (...args) => {
|
|
1117
799
|
remove();
|
|
1118
800
|
onClick && onClick(...args);
|
|
@@ -1120,112 +802,23 @@ const CancelButton = _ref => {
|
|
|
1120
802
|
}));
|
|
1121
803
|
};
|
|
1122
804
|
|
|
1123
|
-
const
|
|
1124
|
-
_excluded2 = ["className", "title", "formProps", "footer", "content", "isReset"];
|
|
1125
|
-
const FetchForm = withFetch$1(Form);
|
|
1126
|
-
const CommonModal = forwardRef(({
|
|
1127
|
-
formProps,
|
|
1128
|
-
footer,
|
|
1129
|
-
close,
|
|
1130
|
-
onCancel,
|
|
1131
|
-
isReset,
|
|
1132
|
-
children
|
|
1133
|
-
}, ref) => {
|
|
1134
|
-
const TargetForm = formProps.hasOwnProperty('url') ? FetchForm : Form;
|
|
1135
|
-
return /*#__PURE__*/React__default.createElement(TargetForm, _extends({}, formProps, {
|
|
1136
|
-
ref: ref
|
|
1137
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
1138
|
-
className: "ant-modal-body"
|
|
1139
|
-
}, children), /*#__PURE__*/React__default.createElement("div", {
|
|
1140
|
-
className: "ant-modal-footer"
|
|
1141
|
-
}, footer ? footer : /*#__PURE__*/React__default.createElement(Space, null, isReset ? /*#__PURE__*/React__default.createElement(ResetButton, null, "\u91CD\u7F6E") : /*#__PURE__*/React__default.createElement(CancelButton, {
|
|
1142
|
-
onClick: () => {
|
|
1143
|
-
onCancel && onCancel();
|
|
1144
|
-
}
|
|
1145
|
-
}, "\u53D6\u6D88"), /*#__PURE__*/React__default.createElement(SubmitButton, {
|
|
1146
|
-
type: "primary"
|
|
1147
|
-
}, "\u786E\u5B9A"))));
|
|
1148
|
-
});
|
|
1149
|
-
const FormModal = forwardRef((_ref, ref) => {
|
|
1150
|
-
let {
|
|
1151
|
-
className,
|
|
1152
|
-
formProps = {},
|
|
1153
|
-
footer,
|
|
1154
|
-
children,
|
|
1155
|
-
isReset
|
|
1156
|
-
} = _ref,
|
|
1157
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1158
|
-
return /*#__PURE__*/React__default.createElement(Modal, _extends({}, props, {
|
|
1159
|
-
className: classnames(className, 'react-form-modal'),
|
|
1160
|
-
footer: null
|
|
1161
|
-
}), /*#__PURE__*/React__default.createElement(CommonModal, {
|
|
1162
|
-
ref: ref,
|
|
1163
|
-
formProps: formProps,
|
|
1164
|
-
footer: footer,
|
|
1165
|
-
isReset: isReset,
|
|
1166
|
-
onCancel: props.onCancel
|
|
1167
|
-
}, children));
|
|
1168
|
-
});
|
|
1169
|
-
FormModal.modal = _ref2 => {
|
|
1170
|
-
let {
|
|
1171
|
-
className,
|
|
1172
|
-
title,
|
|
1173
|
-
formProps = {},
|
|
1174
|
-
footer,
|
|
1175
|
-
content,
|
|
1176
|
-
isReset
|
|
1177
|
-
} = _ref2,
|
|
1178
|
-
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
1179
|
-
return Modal.info(_extends({}, props, {
|
|
1180
|
-
title: title ? /*#__PURE__*/React__default.createElement("div", {
|
|
1181
|
-
className: "ant-modal-header"
|
|
1182
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
1183
|
-
className: "ant-modal-title"
|
|
1184
|
-
}, title)) : null,
|
|
1185
|
-
className: classnames(className, 'react-form-modal'),
|
|
1186
|
-
content: /*#__PURE__*/React__default.createElement(CommonModal, {
|
|
1187
|
-
formProps: formProps,
|
|
1188
|
-
footer: footer,
|
|
1189
|
-
isReset: isReset,
|
|
1190
|
-
onCancel: props.onCancel
|
|
1191
|
-
}, content),
|
|
1192
|
-
icon: null,
|
|
1193
|
-
footer: null
|
|
1194
|
-
}));
|
|
1195
|
-
};
|
|
1196
|
-
|
|
1197
|
-
const Avatar = AvatarInput;
|
|
1198
|
-
const Cascader = Cascader$1;
|
|
1199
|
-
const Checkbox = Checkbox$1;
|
|
1200
|
-
const CheckboxGroup = CheckboxGroup$1;
|
|
1201
|
-
const DatePicker = _DatePicker;
|
|
1202
|
-
const DatePickerToday = RangePickerToday;
|
|
1203
|
-
const Input = InputField;
|
|
1204
|
-
const InputNumber = InputNumberField;
|
|
1205
|
-
const RadioGroup = _RadioGroup;
|
|
1206
|
-
const Select = _Select;
|
|
1207
|
-
const Switch = Switch$1;
|
|
1208
|
-
const TextArea = TextArea$1;
|
|
1209
|
-
const TimePicker = _TimePicker;
|
|
1210
|
-
const TreeSelect = _TreeSelect;
|
|
1211
|
-
const Upload = UploadInput;
|
|
805
|
+
const FormAntd = Form;
|
|
1212
806
|
const fields = {
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
CheckboxGroup,
|
|
1217
|
-
DatePicker,
|
|
1218
|
-
DatePickerToday,
|
|
1219
|
-
Input,
|
|
1220
|
-
InputNumber,
|
|
1221
|
-
RadioGroup,
|
|
1222
|
-
Select,
|
|
1223
|
-
Switch,
|
|
807
|
+
Upload: UploadInput,
|
|
808
|
+
TreeSelect: _TreeSelect,
|
|
809
|
+
TimePicker: _TimePicker,
|
|
1224
810
|
TextArea,
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
811
|
+
Switch,
|
|
812
|
+
Select: _Select,
|
|
813
|
+
RadioGroup: _RadioGroup,
|
|
814
|
+
InputNumber: InputNumberField,
|
|
815
|
+
Input: InputField,
|
|
816
|
+
DatePickerToday: RangePickerToday,
|
|
817
|
+
DatePicker: _DatePicker,
|
|
818
|
+
CheckboxGroup,
|
|
819
|
+
Checkbox,
|
|
820
|
+
Cascader
|
|
1228
821
|
};
|
|
1229
822
|
|
|
1230
|
-
export {
|
|
823
|
+
export { CancelButton, Cascader, Checkbox, CheckboxGroup, _DatePicker as DatePicker, RangePickerToday as DatePickerToday, FormAntd, InputField as Input, InputNumberField as InputNumber, _RadioGroup as RadioGroup, ResetButton, _Select as Select, SubmitButton, Switch, TextArea, _TimePicker as TimePicker, _TreeSelect as TreeSelect, UploadInput as Upload, Form as default, fields, preset };
|
|
1231
824
|
//# sourceMappingURL=index.modern.js.map
|