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