@kne/react-form-antd 3.0.30 → 3.0.32
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 → index.js} +365 -5
- package/dist/index.js.map +1 -0
- package/dist/index.modern.js +353 -33
- package/dist/index.modern.js.map +1 -1
- package/package.json +8 -5
- package/dist/index.cjs.map +0 -1
package/dist/index.modern.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { forwardRef, useRef, useState, useEffect, useMemo, useImperativeHandle, useCallback } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import classnames from 'classnames';
|
|
4
5
|
import { preset as preset$2, Form as Form$1, useReset, useSubmit } from '@kne/react-form';
|
|
@@ -6,8 +7,10 @@ export * from '@kne/react-form';
|
|
|
6
7
|
import { preset as preset$1, widget, hooks, hoc } from '@kne/react-form-helper';
|
|
7
8
|
export { hooks, utils, widget } from '@kne/react-form-helper';
|
|
8
9
|
import { merge, get, omit, uniqueId, groupBy } from 'lodash';
|
|
9
|
-
import {
|
|
10
|
-
import { UploadOutlined } from '@ant-design/icons';
|
|
10
|
+
import { App, Modal, Row, Col, Tooltip, Slider, message, Upload, Button, TreeSelect, TimePicker, Input, Switch as Switch$1, Select, Radio, InputNumber, DatePicker, Checkbox as Checkbox$1, Cascader as Cascader$1 } from 'antd';
|
|
11
|
+
import { LoadingOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons';
|
|
12
|
+
import withLayer from '@kne/with-layer';
|
|
13
|
+
import AvatarEditor from 'react-avatar-editor';
|
|
11
14
|
import useEvent from '@kne/use-event';
|
|
12
15
|
import { withFetch as withFetch$1 } from '@kne/react-fetch';
|
|
13
16
|
import dayjs from 'dayjs';
|
|
@@ -86,7 +89,7 @@ var preset = (props => {
|
|
|
86
89
|
preset$2(globalParams.rules);
|
|
87
90
|
});
|
|
88
91
|
|
|
89
|
-
const _excluded$
|
|
92
|
+
const _excluded$7 = ["className", "cache", "enterSubmit", "scrollToError", "scrollProps", "type", "size", "children"];
|
|
90
93
|
const {
|
|
91
94
|
ScrollToError,
|
|
92
95
|
EnterSubmit,
|
|
@@ -103,7 +106,7 @@ const Form = forwardRef((originProps, ref) => {
|
|
|
103
106
|
scrollProps,
|
|
104
107
|
children
|
|
105
108
|
} = originProps,
|
|
106
|
-
props = _objectWithoutPropertiesLoose(originProps, _excluded$
|
|
109
|
+
props = _objectWithoutPropertiesLoose(originProps, _excluded$7);
|
|
107
110
|
const baseClass = 'react-form';
|
|
108
111
|
let computedClass = baseClass;
|
|
109
112
|
const {
|
|
@@ -119,24 +122,24 @@ const Form = forwardRef((originProps, ref) => {
|
|
|
119
122
|
if (size !== 'middle') {
|
|
120
123
|
computedClass += `--${size}`;
|
|
121
124
|
}
|
|
122
|
-
const maxLabel = /*#__PURE__*/
|
|
123
|
-
return /*#__PURE__*/
|
|
125
|
+
const maxLabel = /*#__PURE__*/React__default.createElement(MaxLabelProvider, null, children);
|
|
126
|
+
return /*#__PURE__*/React__default.createElement("form", {
|
|
124
127
|
className: classnames(baseClass, computedClass, className),
|
|
125
128
|
onSubmit: e => {
|
|
126
129
|
e.preventDefault();
|
|
127
130
|
e.stopPropagation();
|
|
128
131
|
}
|
|
129
|
-
}, /*#__PURE__*/
|
|
132
|
+
}, /*#__PURE__*/React__default.createElement(SizeProvider, {
|
|
130
133
|
value: {
|
|
131
134
|
size
|
|
132
135
|
}
|
|
133
|
-
}, /*#__PURE__*/
|
|
136
|
+
}, /*#__PURE__*/React__default.createElement(Form$1, _extends({}, props, {
|
|
134
137
|
ref: ref
|
|
135
|
-
}), cache ? /*#__PURE__*/
|
|
138
|
+
}), cache ? /*#__PURE__*/React__default.createElement(FormStore, {
|
|
136
139
|
cache: cache
|
|
137
|
-
}) : null, scrollToError ? /*#__PURE__*/
|
|
140
|
+
}) : null, scrollToError ? /*#__PURE__*/React__default.createElement(ScrollToError, {
|
|
138
141
|
scrollProps: scrollProps
|
|
139
|
-
}) : null, enterSubmit ? /*#__PURE__*/
|
|
142
|
+
}) : null, enterSubmit ? /*#__PURE__*/React__default.createElement(EnterSubmit, null, maxLabel) : maxLabel)));
|
|
140
143
|
});
|
|
141
144
|
Form.defaultProps = {
|
|
142
145
|
scrollToError: true,
|
|
@@ -158,6 +161,322 @@ Form.propTypes = {
|
|
|
158
161
|
})
|
|
159
162
|
};
|
|
160
163
|
|
|
164
|
+
const RotateIcon = props => /*#__PURE__*/React.createElement("svg", _extends({
|
|
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$6 = ["close", "file", "editor", "onComplete"];
|
|
229
|
+
const {
|
|
230
|
+
useOnChange: useOnChange$c
|
|
231
|
+
} = hooks;
|
|
232
|
+
const avatarParams = globalParams.field.avatar;
|
|
233
|
+
const createAvatarEditor = withLayer(_ref => {
|
|
234
|
+
let {
|
|
235
|
+
close,
|
|
236
|
+
file,
|
|
237
|
+
editor,
|
|
238
|
+
onComplete
|
|
239
|
+
} = _ref,
|
|
240
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
241
|
+
const editorRef = useRef(null);
|
|
242
|
+
const [rotate, setRotate] = useState(0);
|
|
243
|
+
const [scale, setScale] = useState(() => {
|
|
244
|
+
if (editor.width === editor.height) {
|
|
245
|
+
return 1;
|
|
246
|
+
}
|
|
247
|
+
return 0.35;
|
|
248
|
+
});
|
|
249
|
+
App.useApp();
|
|
250
|
+
return /*#__PURE__*/React__default.createElement(Modal, _extends({}, props, {
|
|
251
|
+
className: editor.className,
|
|
252
|
+
centered: true,
|
|
253
|
+
onOk: () => {
|
|
254
|
+
onComplete && onComplete(editorRef.current.getImage().toDataURL());
|
|
255
|
+
close();
|
|
256
|
+
}
|
|
257
|
+
}), editor.tips ? /*#__PURE__*/React__default.createElement("div", {
|
|
258
|
+
className: "react-form-avatar-tips"
|
|
259
|
+
}, editor.tips) : null, /*#__PURE__*/React__default.createElement("div", {
|
|
260
|
+
style: {
|
|
261
|
+
"width": editor.width,
|
|
262
|
+
"margin": "auto"
|
|
263
|
+
}
|
|
264
|
+
}, /*#__PURE__*/React__default.createElement(AvatarEditor, {
|
|
265
|
+
ref: editorRef,
|
|
266
|
+
image: file,
|
|
267
|
+
width: editor.width,
|
|
268
|
+
height: editor.height,
|
|
269
|
+
border: 1,
|
|
270
|
+
borderRadius: editor.borderRadius,
|
|
271
|
+
color: [24, 144, 255, 1] // RGBA
|
|
272
|
+
,
|
|
273
|
+
scale: scale,
|
|
274
|
+
rotate: rotate
|
|
275
|
+
}), /*#__PURE__*/React__default.createElement(Row, {
|
|
276
|
+
gutter: 4,
|
|
277
|
+
align: "middle"
|
|
278
|
+
}, /*#__PURE__*/React__default.createElement(Col, {
|
|
279
|
+
span: 4
|
|
280
|
+
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
281
|
+
title: "\u65CB\u8F6C",
|
|
282
|
+
placement: "bottom",
|
|
283
|
+
getPopupContainer: getPopupContainer
|
|
284
|
+
}, /*#__PURE__*/React__default.createElement(RotateIcon, {
|
|
285
|
+
className: "react-form-avatar-btn",
|
|
286
|
+
onClick: () => {
|
|
287
|
+
setRotate(rotate => {
|
|
288
|
+
return (rotate - 90) % 360;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}))), /*#__PURE__*/React__default.createElement(Col, {
|
|
292
|
+
span: 4
|
|
293
|
+
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
294
|
+
title: "\u8FD8\u539F",
|
|
295
|
+
placement: "bottom",
|
|
296
|
+
getPopupContainer: getPopupContainer
|
|
297
|
+
}, /*#__PURE__*/React__default.createElement(FullIcon, {
|
|
298
|
+
className: "react-form-avatar-btn",
|
|
299
|
+
onClick: () => {
|
|
300
|
+
setScale(1);
|
|
301
|
+
}
|
|
302
|
+
}))), /*#__PURE__*/React__default.createElement(Col, {
|
|
303
|
+
flex: 1
|
|
304
|
+
}, /*#__PURE__*/React__default.createElement(Slider, {
|
|
305
|
+
className: "react-form-avatar-slider",
|
|
306
|
+
tooltip: {
|
|
307
|
+
placement: "bottom",
|
|
308
|
+
formatter: () => '大小',
|
|
309
|
+
getPopupContainer
|
|
310
|
+
},
|
|
311
|
+
value: scale,
|
|
312
|
+
step: 0.05,
|
|
313
|
+
min: 0.2,
|
|
314
|
+
max: 3,
|
|
315
|
+
onChange: setScale
|
|
316
|
+
})))));
|
|
317
|
+
});
|
|
318
|
+
const _Avatar = ({
|
|
319
|
+
className,
|
|
320
|
+
value: imageUrl,
|
|
321
|
+
onChange: propsChange,
|
|
322
|
+
beforeUpload: onBeforeUpload,
|
|
323
|
+
transformResponse,
|
|
324
|
+
action,
|
|
325
|
+
imageType,
|
|
326
|
+
fileSize: size,
|
|
327
|
+
children,
|
|
328
|
+
extraRender,
|
|
329
|
+
onError,
|
|
330
|
+
openEditor,
|
|
331
|
+
editorTips,
|
|
332
|
+
editor: targetEditor,
|
|
333
|
+
previewImg,
|
|
334
|
+
previewRender
|
|
335
|
+
}) => {
|
|
336
|
+
const [loading, setLoading] = useState(false);
|
|
337
|
+
const [showImageUrl, setImageUrl] = useState(imageUrl);
|
|
338
|
+
useRef();
|
|
339
|
+
const defaultEditor = {
|
|
340
|
+
open: false,
|
|
341
|
+
width: 250,
|
|
342
|
+
height: 250,
|
|
343
|
+
borderRadius: 1,
|
|
344
|
+
text: "确定",
|
|
345
|
+
cancelText: '取消',
|
|
346
|
+
title: "裁剪图片",
|
|
347
|
+
tips: null
|
|
348
|
+
};
|
|
349
|
+
const editor = merge({}, defaultEditor, {
|
|
350
|
+
open: openEditor,
|
|
351
|
+
tips: editorTips
|
|
352
|
+
}, targetEditor);
|
|
353
|
+
useEffect(() => {
|
|
354
|
+
setImageUrl(imageUrl);
|
|
355
|
+
}, [imageUrl]);
|
|
356
|
+
|
|
357
|
+
/* base64转blob */
|
|
358
|
+
const dataURLtoBlob = dataurl => {
|
|
359
|
+
let arr = dataurl.split(",");
|
|
360
|
+
// 注意base64的最后面中括号和引号是不转译的
|
|
361
|
+
let _arr = arr[1].substring(0, arr[1].length - 2);
|
|
362
|
+
let mime = arr[0].match(/:(.*?);/)[1],
|
|
363
|
+
bstr = atob(_arr),
|
|
364
|
+
n = bstr.length,
|
|
365
|
+
u8arr = new Uint8Array(n);
|
|
366
|
+
while (n--) {
|
|
367
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
368
|
+
}
|
|
369
|
+
return new Blob([u8arr], {
|
|
370
|
+
type: mime
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
const uploadButton = /*#__PURE__*/React__default.createElement("div", null, loading ? /*#__PURE__*/React__default.createElement(LoadingOutlined, null) : /*#__PURE__*/React__default.createElement(PlusOutlined, null), children);
|
|
374
|
+
const beforeUpload = async file => {
|
|
375
|
+
return new Promise((resolve, reject) => {
|
|
376
|
+
const isJpgOrPng = imageType.indexOf(file.type) > -1;
|
|
377
|
+
if (!isJpgOrPng) {
|
|
378
|
+
onError(`只支持${imageType.map(str => str.replace("image/", "")).join("/")}格式图片!`, "typeError", {
|
|
379
|
+
type: imageType,
|
|
380
|
+
fileType: file.type
|
|
381
|
+
});
|
|
382
|
+
reject();
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
const isLt = file.size / 1024 / 1024 < size;
|
|
386
|
+
if (!isLt) {
|
|
387
|
+
onError(`图片不能超过${size}MB!`, "sizeError", {
|
|
388
|
+
size,
|
|
389
|
+
fileSize: file.size
|
|
390
|
+
});
|
|
391
|
+
reject();
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/*剪切图像*/
|
|
396
|
+
// editor:{open:false,width:250,height:250,borderRadius:0-100,text:'剪切'}
|
|
397
|
+
if (editor.open) {
|
|
398
|
+
createAvatarEditor({
|
|
399
|
+
editor,
|
|
400
|
+
file,
|
|
401
|
+
title: editor.title,
|
|
402
|
+
icon: "",
|
|
403
|
+
width: editor.width * 2,
|
|
404
|
+
cancelText: editor.cancelText,
|
|
405
|
+
okText: editor.text,
|
|
406
|
+
onComplete: base64 => {
|
|
407
|
+
setImageUrl(base64);
|
|
408
|
+
let blob = dataURLtoBlob(base64);
|
|
409
|
+
const files = new window.File([blob], file.name, {
|
|
410
|
+
type: file.type
|
|
411
|
+
});
|
|
412
|
+
onBeforeUpload && onBeforeUpload(files);
|
|
413
|
+
resolve(files);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
} else {
|
|
417
|
+
onBeforeUpload && onBeforeUpload(file);
|
|
418
|
+
resolve(file);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
const onChange = info => {
|
|
423
|
+
if (info.file.status === "uploading") {
|
|
424
|
+
setLoading(true);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (info.file.status === "done") {
|
|
428
|
+
setLoading(false);
|
|
429
|
+
const response = (transformResponse || avatarParams.transformResponse)(info.file.response);
|
|
430
|
+
if (response.code === 200) {
|
|
431
|
+
propsChange(response.results);
|
|
432
|
+
} else {
|
|
433
|
+
onError(response.msg, "xhrError", response);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
const headers = Object.assign({}, avatarParams.headers);
|
|
438
|
+
if (typeof avatarParams.getHeaders === 'function') {
|
|
439
|
+
Object.assign(headers, avatarParams.getHeaders());
|
|
440
|
+
}
|
|
441
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Upload, _extends({}, omit(avatarParams, ['action', 'transformResponse', 'headers', 'getHeaders']), {
|
|
442
|
+
headers: headers,
|
|
443
|
+
className: classnames(className, "react-form-avatar"),
|
|
444
|
+
listType: "picture-card",
|
|
445
|
+
showUploadList: false,
|
|
446
|
+
action: action || avatarParams.action,
|
|
447
|
+
beforeUpload: beforeUpload,
|
|
448
|
+
onChange: onChange
|
|
449
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
450
|
+
className: "react-form-avatar-inner"
|
|
451
|
+
}, previewImg && showImageUrl ? previewRender ? previewRender(showImageUrl) : /*#__PURE__*/React__default.createElement("div", {
|
|
452
|
+
className: "preview"
|
|
453
|
+
}, /*#__PURE__*/React__default.createElement("img", {
|
|
454
|
+
src: showImageUrl,
|
|
455
|
+
alt: "avatar"
|
|
456
|
+
})) : uploadButton, extraRender ? extraRender(showImageUrl) : '')));
|
|
457
|
+
};
|
|
458
|
+
_Avatar.defaultProps = {
|
|
459
|
+
imageType: ["image/jpeg", "image/png"],
|
|
460
|
+
fileSize: 2,
|
|
461
|
+
// 单位MB
|
|
462
|
+
children: /*#__PURE__*/React__default.createElement("div", {
|
|
463
|
+
className: "ant-upload-text"
|
|
464
|
+
}, "\u70B9\u51FB\u4E0A\u4F20"),
|
|
465
|
+
extraRender: null,
|
|
466
|
+
onError: info => message.error(info),
|
|
467
|
+
previewImg: true,
|
|
468
|
+
previewRender: null,
|
|
469
|
+
openEditor: false
|
|
470
|
+
};
|
|
471
|
+
const AvatarInput = props => {
|
|
472
|
+
const render = useOnChange$c(props);
|
|
473
|
+
return render(_Avatar);
|
|
474
|
+
};
|
|
475
|
+
AvatarInput.defaultProps = {
|
|
476
|
+
fieldName: 'avatar'
|
|
477
|
+
};
|
|
478
|
+
AvatarInput.field = _Avatar;
|
|
479
|
+
|
|
161
480
|
const _excluded$5 = ["action", "value", "onChange", "drag", "children", "displayFilename", "accept", "fileSize", "onError", "onUploadComplete", "onBeforeUpload", "maxLength", "transformResponse"];
|
|
162
481
|
const {
|
|
163
482
|
useOnChange: useOnChange$b
|
|
@@ -302,7 +621,7 @@ const _Upload = _ref => {
|
|
|
302
621
|
Object.assign(headers, uploadParams.getHeaders());
|
|
303
622
|
}
|
|
304
623
|
const UploadComponent = drag ? Dragger : Upload;
|
|
305
|
-
return /*#__PURE__*/
|
|
624
|
+
return /*#__PURE__*/React__default.createElement(UploadComponent, _extends({}, omit(uploadParams, ['action', 'transformResponse']), props, {
|
|
306
625
|
headers: headers,
|
|
307
626
|
action: action || uploadParams.action,
|
|
308
627
|
fileList: valueList,
|
|
@@ -320,9 +639,9 @@ _Upload.defaultProps = {
|
|
|
320
639
|
maxLength: 1,
|
|
321
640
|
children: ({
|
|
322
641
|
size
|
|
323
|
-
}) => /*#__PURE__*/
|
|
642
|
+
}) => /*#__PURE__*/React__default.createElement(Button, {
|
|
324
643
|
size: size
|
|
325
|
-
}, /*#__PURE__*/
|
|
644
|
+
}, /*#__PURE__*/React__default.createElement(UploadOutlined, null), "\u70B9\u51FB\u4E0A\u4F20"),
|
|
326
645
|
onError: info => message.error(info),
|
|
327
646
|
onUploadComplete: () => {}
|
|
328
647
|
};
|
|
@@ -333,7 +652,7 @@ const UploadInput = props => {
|
|
|
333
652
|
UploadInput.defaultProps = {
|
|
334
653
|
fieldName: 'upload'
|
|
335
654
|
};
|
|
336
|
-
UploadInput.field = _Upload;
|
|
655
|
+
UploadInput.field = AvatarInput.Field = _Upload;
|
|
337
656
|
|
|
338
657
|
const _excluded$4 = ["data", "setData", "send", "loadMore", "isComplete", "refresh", "reload", "fetchEmitter", "isLoading", "children", "onLoaded", "fetchProps", "requestParams"];
|
|
339
658
|
const {
|
|
@@ -376,7 +695,7 @@ const withFetch = WrappedComponent => {
|
|
|
376
695
|
useEffect(() => {
|
|
377
696
|
onLoaded && onLoaded(dataRef.current);
|
|
378
697
|
}, []);
|
|
379
|
-
return /*#__PURE__*/
|
|
698
|
+
return /*#__PURE__*/React__default.createElement(WrappedComponent, _extends({}, props, children({
|
|
380
699
|
data,
|
|
381
700
|
fetchProps,
|
|
382
701
|
loadMore,
|
|
@@ -410,7 +729,7 @@ const withFetch = WrappedComponent => {
|
|
|
410
729
|
});
|
|
411
730
|
Fetch.field = forwardRef((props, ref) => {
|
|
412
731
|
const emitter = useFetchEmitter(ref);
|
|
413
|
-
return /*#__PURE__*/
|
|
732
|
+
return /*#__PURE__*/React__default.createElement(FieldInner, _extends({}, props, {
|
|
414
733
|
fetchEmitter: emitter
|
|
415
734
|
}));
|
|
416
735
|
});
|
|
@@ -516,7 +835,7 @@ const RadioGroup = _ref => {
|
|
|
516
835
|
const handler = useCallback(e => {
|
|
517
836
|
onChange && onChange(e.target.value);
|
|
518
837
|
}, [onChange]);
|
|
519
|
-
return /*#__PURE__*/
|
|
838
|
+
return /*#__PURE__*/React__default.createElement(Radio.Group, _extends({}, props, {
|
|
520
839
|
onChange: handler
|
|
521
840
|
}));
|
|
522
841
|
};
|
|
@@ -606,7 +925,7 @@ const PickerToday = _ref => {
|
|
|
606
925
|
onChange([newData.start, v || '']);
|
|
607
926
|
};
|
|
608
927
|
const foot = () => {
|
|
609
|
-
return /*#__PURE__*/
|
|
928
|
+
return /*#__PURE__*/React__default.createElement(Button, {
|
|
610
929
|
type: newData.showZj ? 'primary' : 'default',
|
|
611
930
|
onClick: v => {
|
|
612
931
|
ref_d.current.blur();
|
|
@@ -614,20 +933,20 @@ const PickerToday = _ref => {
|
|
|
614
933
|
}
|
|
615
934
|
}, soFarText || '至今');
|
|
616
935
|
};
|
|
617
|
-
return /*#__PURE__*/
|
|
936
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
618
937
|
style: {
|
|
619
938
|
display: 'flex'
|
|
620
939
|
}
|
|
621
|
-
}, /*#__PURE__*/
|
|
940
|
+
}, /*#__PURE__*/React__default.createElement(DatePicker, _extends({}, _extends({
|
|
622
941
|
showToday: false
|
|
623
942
|
}, props, {
|
|
624
943
|
placeholder: newData.placeholder[0],
|
|
625
944
|
value: newData.start
|
|
626
945
|
}), {
|
|
627
946
|
onChange: startChange
|
|
628
|
-
})), /*#__PURE__*/
|
|
947
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
629
948
|
className: 'svg_box'
|
|
630
|
-
}, /*#__PURE__*/
|
|
949
|
+
}, /*#__PURE__*/React__default.createElement("svg", {
|
|
631
950
|
viewBox: "0 0 1024 1024",
|
|
632
951
|
focusable: "false",
|
|
633
952
|
"data-icon": "swap-right",
|
|
@@ -635,13 +954,13 @@ const PickerToday = _ref => {
|
|
|
635
954
|
height: "1em",
|
|
636
955
|
fill: "currentColor",
|
|
637
956
|
"aria-hidden": "true"
|
|
638
|
-
}, /*#__PURE__*/
|
|
957
|
+
}, /*#__PURE__*/React__default.createElement("path", {
|
|
639
958
|
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"
|
|
640
|
-
}))), /*#__PURE__*/
|
|
959
|
+
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
641
960
|
className: newData.showZj ? 'data_range_picker data_range_picker_dis' : 'data_range_picker'
|
|
642
|
-
}, /*#__PURE__*/
|
|
961
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
643
962
|
className: newData.showZj ? 'zhijin zhijin_show' : 'zhijin'
|
|
644
|
-
}, soFarText || '至今'), /*#__PURE__*/
|
|
963
|
+
}, soFarText || '至今'), /*#__PURE__*/React__default.createElement(DatePicker, _extends({}, _extends({
|
|
645
964
|
showToday: false
|
|
646
965
|
}, props, {
|
|
647
966
|
placeholder: newData.showZj ? '' : newData.placeholder[1],
|
|
@@ -757,7 +1076,7 @@ Cascader.defaultProps = {
|
|
|
757
1076
|
|
|
758
1077
|
const ResetButton = props => {
|
|
759
1078
|
const resetProps = useReset();
|
|
760
|
-
return /*#__PURE__*/
|
|
1079
|
+
return /*#__PURE__*/React__default.createElement(Button, _extends({}, resetProps, props));
|
|
761
1080
|
};
|
|
762
1081
|
|
|
763
1082
|
const _excluded$1 = ["realTime", "disabled"],
|
|
@@ -774,7 +1093,7 @@ const SubmitButton = _ref => {
|
|
|
774
1093
|
isLoading
|
|
775
1094
|
} = _useSubmit,
|
|
776
1095
|
submitProps = _objectWithoutPropertiesLoose(_useSubmit, _excluded2);
|
|
777
|
-
return /*#__PURE__*/
|
|
1096
|
+
return /*#__PURE__*/React__default.createElement(Button, _extends({
|
|
778
1097
|
loading: isLoading,
|
|
779
1098
|
disabled: disabled || (realTime ? !isPass : false)
|
|
780
1099
|
}, props, submitProps));
|
|
@@ -794,7 +1113,7 @@ const CancelButton = _ref => {
|
|
|
794
1113
|
} = _ref,
|
|
795
1114
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
796
1115
|
const remove = useCacheRemove();
|
|
797
|
-
return /*#__PURE__*/
|
|
1116
|
+
return /*#__PURE__*/React__default.createElement(Button, _extends({}, props, {
|
|
798
1117
|
onClick: (...args) => {
|
|
799
1118
|
remove();
|
|
800
1119
|
onClick && onClick(...args);
|
|
@@ -817,8 +1136,9 @@ const fields = {
|
|
|
817
1136
|
DatePicker: _DatePicker,
|
|
818
1137
|
CheckboxGroup,
|
|
819
1138
|
Checkbox,
|
|
820
|
-
Cascader
|
|
1139
|
+
Cascader,
|
|
1140
|
+
Avatar: AvatarInput
|
|
821
1141
|
};
|
|
822
1142
|
|
|
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 };
|
|
1143
|
+
export { AvatarInput as Avatar, 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 };
|
|
824
1144
|
//# sourceMappingURL=index.modern.js.map
|