@hw-component/form 0.0.1 → 0.0.2-bate
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/LICENSE +201 -0
- package/es/CheckboxGroup/CheckBox/index.d.ts +4 -0
- package/es/CheckboxGroup/CheckBox/index.js +40 -0
- package/es/CheckboxGroup/hooks.d.ts +5 -0
- package/es/CheckboxGroup/hooks.js +123 -0
- package/es/CheckboxGroup/index.d.ts +3 -0
- package/es/CheckboxGroup/index.js +89 -0
- package/es/CheckboxGroup/modal.d.ts +13 -0
- package/es/Form/Context/FormConfigProvider.d.ts +5 -0
- package/es/Form/Context/FormConfigProvider.js +47 -0
- package/es/Form/Context/index.d.ts +5 -0
- package/es/Form/Context/index.js +11 -0
- package/es/Form/FormItem/BasicItem.d.ts +4 -0
- package/es/Form/FormItem/BasicItem.js +73 -0
- package/es/Form/FormItem/Helper.d.ts +7 -0
- package/es/Form/FormItem/Helper.js +24 -0
- package/es/Form/FormItem/RegularFormItem.d.ts +4 -0
- package/es/Form/FormItem/RegularFormItem.js +15 -0
- package/es/Form/FormItem/UpFormItem.d.ts +4 -0
- package/es/Form/FormItem/UpFormItem.js +31 -0
- package/es/Form/FormItem/hooks.d.ts +10 -0
- package/es/Form/FormItem/hooks.js +38 -0
- package/es/Form/FormItem/index.d.ts +4 -0
- package/es/Form/FormItem/index.js +11 -0
- package/es/Form/HFormConnect.d.ts +6 -0
- package/es/Form/HFormConnect.js +54 -0
- package/es/Form/InitSet.d.ts +6 -0
- package/es/Form/InitSet.js +16 -0
- package/es/Form/Label.d.ts +10 -0
- package/es/Form/Label.js +46 -0
- package/es/Form/config.d.ts +28 -0
- package/es/Form/config.js +43 -0
- package/es/Form/hooks/index.d.ts +12 -0
- package/es/Form/hooks/index.js +77 -0
- package/es/Form/hooks/useHForm.d.ts +3 -0
- package/es/Form/hooks/useHForm.js +111 -0
- package/es/Form/hooks/useInitConfigData.d.ts +4 -0
- package/es/Form/hooks/useInitConfigData.js +124 -0
- package/es/Form/index.d.ts +4 -0
- package/es/Form/index.js +73 -0
- package/es/Form/modal.d.ts +92 -0
- package/es/Input/ButtonInput.d.ts +4 -0
- package/es/Input/ButtonInput.js +80 -0
- package/es/Input/InputNumber.d.ts +4 -0
- package/es/Input/InputNumber.js +20 -0
- package/es/Input/SelectInput.d.ts +9 -0
- package/es/Input/SelectInput.js +94 -0
- package/es/Input/defaultConfig.d.ts +7 -0
- package/es/Input/defaultConfig.js +11 -0
- package/es/Input/index.d.ts +4 -0
- package/es/Input/index.js +13 -0
- package/es/Input/modal.d.ts +25 -0
- package/es/PageHandler/ErrorComponent.d.ts +4 -0
- package/es/PageHandler/ErrorComponent.js +33 -0
- package/es/PageHandler/LoadingComponent.d.ts +3 -0
- package/es/PageHandler/LoadingComponent.js +18 -0
- package/es/PageHandler/index.d.ts +4 -0
- package/es/PageHandler/index.js +24 -0
- package/es/PageHandler/modal.d.ts +6 -0
- package/es/RadioGroup/index.d.ts +9 -0
- package/es/RadioGroup/index.js +48 -0
- package/es/Select/components/AllSelect.d.ts +3 -3
- package/es/Select/components/AllSelect.js +31 -15
- package/es/Select/components/CheckBoxOption.js +2 -2
- package/es/Select/components/DropdownComponent.js +2 -2
- package/es/Select/components/NoFindItem.js +2 -2
- package/es/Select/components/NotFoundContent.js +3 -5
- package/es/Select/defaultConfig.d.ts +0 -1
- package/es/Select/defaultConfig.js +3 -7
- package/es/Select/hooks/changeHooks.d.ts +1 -1
- package/es/Select/hooks/changeHooks.js +9 -5
- package/es/Select/hooks/norHooks.d.ts +4 -6
- package/es/Select/hooks/norHooks.js +20 -37
- package/es/Select/index.d.ts +1 -1
- package/es/Select/index.js +31 -19
- package/es/Select/modal.d.ts +2 -2
- package/es/Select/utils.d.ts +2 -0
- package/es/Select/utils.js +39 -0
- package/es/Submit/index.d.ts +8 -0
- package/es/Submit/index.js +28 -0
- package/es/Switch/index.d.ts +11 -0
- package/es/Switch/index.js +45 -0
- package/es/TDPicker/RangePicker.d.ts +8 -0
- package/es/TDPicker/RangePicker.js +119 -0
- package/es/TDPicker/TimePicker.d.ts +4 -0
- package/es/TDPicker/TimePicker.js +31 -0
- package/es/TDPicker/hooks.d.ts +33 -0
- package/es/TDPicker/hooks.js +132 -0
- package/es/TDPicker/index.d.ts +4 -0
- package/es/TDPicker/index.js +33 -0
- package/es/TDPicker/modal.d.ts +28 -0
- package/es/TextArea/index.d.ts +4 -0
- package/es/Upload/Btn.d.ts +4 -0
- package/es/Upload/Btn.js +31 -0
- package/es/Upload/MediaTypeEle/TypeEle.d.ts +10 -0
- package/es/Upload/MediaTypeEle/TypeEle.js +40 -0
- package/es/Upload/MediaTypeEle/index.d.ts +4 -0
- package/es/Upload/MediaTypeEle/index.js +36 -0
- package/es/Upload/Preview/index.d.ts +6 -0
- package/es/Upload/Preview/index.js +21 -0
- package/es/Upload/UrlUpload/index.d.ts +4 -0
- package/es/Upload/UrlUpload/index.js +119 -0
- package/es/Upload/enums.d.ts +5 -0
- package/es/Upload/enums.js +10 -0
- package/es/Upload/hooks/change.d.ts +3 -0
- package/es/Upload/hooks/change.js +109 -0
- package/es/Upload/hooks/customRequest.d.ts +3 -0
- package/es/Upload/hooks/customRequest.js +69 -0
- package/es/Upload/hooks/propsMaker.d.ts +2 -0
- package/es/Upload/hooks/propsMaker.js +37 -0
- package/es/Upload/index.d.ts +4 -0
- package/es/Upload/index.js +106 -0
- package/es/Upload/modal.d.ts +28 -0
- package/es/Upload/util.d.ts +5 -0
- package/es/Upload/util.js +34 -0
- package/es/config.d.ts +2 -0
- package/es/config.js +64 -0
- package/es/hooks/index.d.ts +13 -0
- package/es/hooks/index.js +75 -0
- package/es/index.css +33 -1
- package/es/index.d.ts +20 -1
- package/es/index.js +25 -3
- package/es/modal.d.ts +15 -0
- package/lib/CheckboxGroup/CheckBox/index.d.ts +4 -0
- package/lib/CheckboxGroup/CheckBox/index.js +43 -0
- package/lib/CheckboxGroup/hooks.d.ts +5 -0
- package/lib/CheckboxGroup/hooks.js +124 -0
- package/lib/CheckboxGroup/index.d.ts +3 -0
- package/lib/CheckboxGroup/index.js +92 -0
- package/lib/CheckboxGroup/modal.d.ts +13 -0
- package/lib/Form/Context/FormConfigProvider.d.ts +5 -0
- package/lib/Form/Context/FormConfigProvider.js +51 -0
- package/lib/Form/Context/index.d.ts +5 -0
- package/lib/Form/Context/index.js +14 -0
- package/lib/Form/FormItem/BasicItem.d.ts +4 -0
- package/lib/Form/FormItem/BasicItem.js +76 -0
- package/lib/Form/FormItem/Helper.d.ts +7 -0
- package/lib/Form/FormItem/Helper.js +27 -0
- package/lib/Form/FormItem/RegularFormItem.d.ts +4 -0
- package/lib/Form/FormItem/RegularFormItem.js +18 -0
- package/lib/Form/FormItem/UpFormItem.d.ts +4 -0
- package/lib/Form/FormItem/UpFormItem.js +34 -0
- package/lib/Form/FormItem/hooks.d.ts +10 -0
- package/lib/Form/FormItem/hooks.js +41 -0
- package/lib/Form/FormItem/index.d.ts +4 -0
- package/lib/Form/FormItem/index.js +14 -0
- package/lib/Form/HFormConnect.d.ts +6 -0
- package/lib/Form/HFormConnect.js +57 -0
- package/lib/Form/InitSet.d.ts +6 -0
- package/lib/Form/InitSet.js +19 -0
- package/lib/Form/Label.d.ts +10 -0
- package/lib/Form/Label.js +49 -0
- package/lib/Form/config.d.ts +28 -0
- package/lib/Form/config.js +47 -0
- package/lib/Form/hooks/index.d.ts +12 -0
- package/lib/Form/hooks/index.js +80 -0
- package/lib/Form/hooks/useHForm.d.ts +3 -0
- package/lib/Form/hooks/useHForm.js +114 -0
- package/lib/Form/hooks/useInitConfigData.d.ts +4 -0
- package/lib/Form/hooks/useInitConfigData.js +127 -0
- package/lib/Form/index.d.ts +4 -0
- package/lib/Form/index.js +76 -0
- package/lib/Form/modal.d.ts +92 -0
- package/lib/Input/ButtonInput.d.ts +4 -0
- package/lib/Input/ButtonInput.js +83 -0
- package/lib/Input/InputNumber.d.ts +4 -0
- package/lib/Input/InputNumber.js +23 -0
- package/lib/Input/SelectInput.d.ts +9 -0
- package/lib/Input/SelectInput.js +98 -0
- package/lib/Input/defaultConfig.d.ts +7 -0
- package/lib/Input/defaultConfig.js +13 -0
- package/lib/Input/index.d.ts +4 -0
- package/lib/Input/index.js +16 -0
- package/lib/Input/modal.d.ts +25 -0
- package/lib/PageHandler/ErrorComponent.d.ts +4 -0
- package/lib/PageHandler/ErrorComponent.js +36 -0
- package/lib/PageHandler/LoadingComponent.d.ts +3 -0
- package/lib/PageHandler/LoadingComponent.js +21 -0
- package/lib/PageHandler/index.d.ts +4 -0
- package/lib/PageHandler/index.js +27 -0
- package/lib/PageHandler/modal.d.ts +6 -0
- package/lib/RadioGroup/index.d.ts +9 -0
- package/lib/RadioGroup/index.js +51 -0
- package/lib/Select/components/AllSelect.d.ts +3 -3
- package/lib/Select/components/AllSelect.js +29 -13
- package/lib/Select/components/NotFoundContent.js +1 -3
- package/lib/Select/defaultConfig.d.ts +0 -1
- package/lib/Select/defaultConfig.js +0 -5
- package/lib/Select/hooks/changeHooks.d.ts +1 -1
- package/lib/Select/hooks/changeHooks.js +7 -3
- package/lib/Select/hooks/norHooks.d.ts +4 -6
- package/lib/Select/hooks/norHooks.js +18 -35
- package/lib/Select/index.d.ts +1 -1
- package/lib/Select/index.js +26 -14
- package/lib/Select/modal.d.ts +2 -2
- package/lib/Select/utils.d.ts +2 -0
- package/lib/Select/utils.js +41 -0
- package/lib/Submit/index.d.ts +8 -0
- package/lib/Submit/index.js +31 -0
- package/lib/Switch/index.d.ts +11 -0
- package/lib/Switch/index.js +48 -0
- package/lib/TDPicker/RangePicker.d.ts +8 -0
- package/lib/TDPicker/RangePicker.js +122 -0
- package/lib/TDPicker/TimePicker.d.ts +4 -0
- package/lib/TDPicker/TimePicker.js +34 -0
- package/lib/TDPicker/hooks.d.ts +33 -0
- package/lib/TDPicker/hooks.js +139 -0
- package/lib/TDPicker/index.d.ts +4 -0
- package/lib/TDPicker/index.js +36 -0
- package/lib/TDPicker/modal.d.ts +28 -0
- package/lib/TextArea/index.d.ts +4 -0
- package/lib/Upload/Btn.d.ts +4 -0
- package/lib/Upload/Btn.js +34 -0
- package/lib/Upload/MediaTypeEle/TypeEle.d.ts +10 -0
- package/lib/Upload/MediaTypeEle/TypeEle.js +43 -0
- package/lib/Upload/MediaTypeEle/index.d.ts +4 -0
- package/lib/Upload/MediaTypeEle/index.js +39 -0
- package/lib/Upload/Preview/index.d.ts +6 -0
- package/lib/Upload/Preview/index.js +24 -0
- package/lib/Upload/UrlUpload/index.d.ts +4 -0
- package/lib/Upload/UrlUpload/index.js +122 -0
- package/lib/Upload/enums.d.ts +5 -0
- package/lib/Upload/enums.js +9 -0
- package/lib/Upload/hooks/change.d.ts +3 -0
- package/lib/Upload/hooks/change.js +110 -0
- package/lib/Upload/hooks/customRequest.d.ts +3 -0
- package/lib/Upload/hooks/customRequest.js +70 -0
- package/lib/Upload/hooks/propsMaker.d.ts +2 -0
- package/lib/Upload/hooks/propsMaker.js +38 -0
- package/lib/Upload/index.d.ts +4 -0
- package/lib/Upload/index.js +109 -0
- package/lib/Upload/modal.d.ts +28 -0
- package/lib/Upload/util.d.ts +5 -0
- package/lib/Upload/util.js +38 -0
- package/lib/config.d.ts +2 -0
- package/lib/config.js +65 -0
- package/lib/hooks/index.d.ts +13 -0
- package/lib/hooks/index.js +78 -0
- package/lib/index.css +33 -1
- package/lib/index.d.ts +20 -1
- package/lib/index.js +38 -3
- package/lib/modal.d.ts +15 -0
- package/package.json +4 -3
- package/scripts/rollup.config.js +3 -8
- package/scripts/webpack.config.js +6 -2
- package/src/Layout.tsx +4 -4
- package/src/components/CheckboxGroup/CheckBox/index.tsx +38 -0
- package/src/components/CheckboxGroup/hooks.ts +102 -0
- package/src/components/CheckboxGroup/index.tsx +79 -0
- package/src/components/CheckboxGroup/modal.ts +15 -0
- package/src/components/Form/Context/FormConfigProvider.tsx +38 -0
- package/src/components/Form/Context/index.tsx +14 -0
- package/src/components/Form/FormItem/BasicItem.tsx +70 -0
- package/src/components/Form/FormItem/Helper.tsx +26 -0
- package/src/components/Form/FormItem/RegularFormItem.tsx +7 -0
- package/src/components/Form/FormItem/UpFormItem.tsx +20 -0
- package/src/components/Form/FormItem/hooks.tsx +44 -0
- package/src/components/Form/FormItem/index.tsx +8 -0
- package/src/components/Form/HFormConnect.tsx +49 -0
- package/src/components/Form/InitSet.tsx +12 -0
- package/src/components/Form/Label.tsx +50 -0
- package/src/components/Form/config.ts +40 -0
- package/src/components/Form/hooks/index.ts +42 -0
- package/src/components/Form/hooks/useHForm.ts +89 -0
- package/src/components/Form/hooks/useInitConfigData.tsx +100 -0
- package/src/components/Form/index.less +22 -0
- package/src/components/Form/index.tsx +61 -0
- package/src/components/Form/modal.ts +142 -0
- package/src/components/Input/ButtonInput.tsx +41 -0
- package/src/components/Input/InputNumber.tsx +5 -0
- package/src/components/Input/SelectInput.tsx +74 -0
- package/src/components/Input/defaultConfig.ts +8 -0
- package/src/components/Input/index.tsx +6 -0
- package/src/components/Input/modal.ts +31 -0
- package/src/components/PageHandler/ErrorComponent.tsx +20 -0
- package/src/components/PageHandler/LoadingComponent.tsx +9 -0
- package/src/components/PageHandler/index.tsx +14 -0
- package/src/components/PageHandler/modal.ts +6 -0
- package/src/components/RadioGroup/index.tsx +45 -0
- package/src/components/Select/components/AllSelect.tsx +32 -16
- package/src/components/Select/components/DropdownComponent.tsx +1 -0
- package/src/components/Select/components/NotFoundContent.tsx +1 -1
- package/src/components/Select/defaultConfig.tsx +0 -5
- package/src/components/Select/hooks/changeHooks.tsx +14 -4
- package/src/components/Select/hooks/norHooks.ts +8 -19
- package/src/components/Select/index.less +20 -3
- package/src/components/Select/index.tsx +29 -17
- package/src/components/Select/modal.ts +9 -9
- package/src/components/Select/utils.ts +18 -0
- package/src/components/Submit/index.tsx +28 -0
- package/src/components/Switch/index.tsx +52 -0
- package/src/components/TDPicker/RangePicker.tsx +106 -0
- package/src/components/TDPicker/TimePicker.tsx +15 -0
- package/src/components/TDPicker/hooks.ts +150 -0
- package/src/components/TDPicker/index.tsx +22 -0
- package/src/components/TDPicker/modal.ts +30 -0
- package/src/components/TextArea/index.tsx +8 -0
- package/src/components/Upload/Btn.tsx +24 -0
- package/src/components/Upload/MediaTypeEle/TypeEle.tsx +26 -0
- package/src/components/Upload/MediaTypeEle/index.tsx +34 -0
- package/src/components/Upload/Preview/index.tsx +14 -0
- package/src/components/Upload/UrlUpload/index.tsx +91 -0
- package/src/components/Upload/enums.ts +5 -0
- package/src/components/Upload/hooks/change.ts +79 -0
- package/src/components/Upload/hooks/customRequest.ts +44 -0
- package/src/components/Upload/hooks/propsMaker.ts +20 -0
- package/src/components/Upload/index.tsx +85 -0
- package/src/components/Upload/modal.ts +31 -0
- package/src/components/Upload/util.ts +27 -0
- package/src/components/config.ts +40 -0
- package/src/components/hooks/index.ts +53 -0
- package/src/components/index.tsx +21 -1
- package/src/components/modal.ts +15 -0
- package/src/components/styles/index.less +2 -0
- package/src/components/styles/local.less +1 -0
- package/src/pages/Checkbox/index.tsx +15 -0
- package/src/pages/DatePicker/index.tsx +33 -0
- package/src/pages/Form/index.tsx +146 -0
- package/src/pages/Input/index.tsx +22 -0
- package/src/pages/Radio/index.tsx +18 -0
- package/src/pages/Select/index.tsx +7 -4
- package/src/pages/Switch/index.tsx +18 -0
- package/src/pages/Upload/index.tsx +14 -0
- package/src/routes.tsx +45 -12
- package/es/Select/index.less.js +0 -5
- package/lib/Select/index.less.js +0 -8
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import React, { useState, useRef } from 'react';
|
|
3
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
4
|
+
import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
|
|
5
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
6
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
7
|
+
import _trimInstanceProperty from '@babel/runtime-corejs3/core-js/instance/trim';
|
|
8
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
|
|
9
|
+
import _Array$from from '@babel/runtime-corejs3/core-js/array/from';
|
|
10
|
+
import { Space, message } from 'antd';
|
|
11
|
+
import Input from 'antd/es/input/Input';
|
|
12
|
+
import HUpload from '../index.js';
|
|
13
|
+
import TypeEle from '../MediaTypeEle/TypeEle.js';
|
|
14
|
+
|
|
15
|
+
var _excluded = ["placeholder", "value", "onChange", "mediaType"];
|
|
16
|
+
var HUrlUpload = (function (_ref) {
|
|
17
|
+
var _ref$placeholder = _ref.placeholder,
|
|
18
|
+
placeholder = _ref$placeholder === void 0 ? "请输入文件地址" : _ref$placeholder,
|
|
19
|
+
_ref$value = _ref.value,
|
|
20
|
+
value = _ref$value === void 0 ? [] : _ref$value,
|
|
21
|
+
onChange = _ref.onChange,
|
|
22
|
+
mediaType = _ref.mediaType,
|
|
23
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
+
var _useState = useState(""),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
url = _useState2[0],
|
|
27
|
+
setUrl = _useState2[1];
|
|
28
|
+
var _useState3 = useState(false),
|
|
29
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
30
|
+
load = _useState4[0],
|
|
31
|
+
setLoad = _useState4[1];
|
|
32
|
+
var ref = useRef(null);
|
|
33
|
+
var onReady = function onReady() {
|
|
34
|
+
var newFileList = _toConsumableArray(value);
|
|
35
|
+
newFileList.push({
|
|
36
|
+
url: url,
|
|
37
|
+
uid: new Date().valueOf().toString(),
|
|
38
|
+
name: url,
|
|
39
|
+
fileName: url,
|
|
40
|
+
thumbUrl: url,
|
|
41
|
+
response: {
|
|
42
|
+
url: url
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newFileList);
|
|
46
|
+
setUrl("");
|
|
47
|
+
setLoad(false);
|
|
48
|
+
};
|
|
49
|
+
var onError = function onError() {
|
|
50
|
+
message.error("文件错误!");
|
|
51
|
+
setUrl("");
|
|
52
|
+
setLoad(false);
|
|
53
|
+
};
|
|
54
|
+
var onBlur = function onBlur(e) {
|
|
55
|
+
var _context;
|
|
56
|
+
if (_trimInstanceProperty(_context = e.target.value).call(_context) === "") {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
setLoad(true);
|
|
60
|
+
};
|
|
61
|
+
var onPaste = function onPaste(e) {
|
|
62
|
+
var _context2, _ref$current;
|
|
63
|
+
var files = e.clipboardData.files;
|
|
64
|
+
if (!files.length) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
var newFileList = _mapInstanceProperty(_context2 = _Array$from(files)).call(_context2, function (item) {
|
|
69
|
+
var name = item.name,
|
|
70
|
+
size = item.size,
|
|
71
|
+
type = item.type;
|
|
72
|
+
return {
|
|
73
|
+
name: name,
|
|
74
|
+
size: size,
|
|
75
|
+
status: "uploading",
|
|
76
|
+
uid: new Date().valueOf().toString(),
|
|
77
|
+
originFileObj: item,
|
|
78
|
+
type: type
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.change({
|
|
82
|
+
fileList: newFileList,
|
|
83
|
+
file: newFileList[0]
|
|
84
|
+
});
|
|
85
|
+
setUrl("");
|
|
86
|
+
setLoad(false);
|
|
87
|
+
};
|
|
88
|
+
return /*#__PURE__*/React.createElement(Space, {
|
|
89
|
+
direction: "vertical",
|
|
90
|
+
style: {
|
|
91
|
+
width: "100%"
|
|
92
|
+
},
|
|
93
|
+
size: "middle"
|
|
94
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
95
|
+
placeholder: placeholder,
|
|
96
|
+
onBlur: onBlur,
|
|
97
|
+
value: url,
|
|
98
|
+
onPaste: onPaste,
|
|
99
|
+
onChange: function onChange(e) {
|
|
100
|
+
setUrl(e.target.value);
|
|
101
|
+
}
|
|
102
|
+
}), /*#__PURE__*/React.createElement(HUpload, _extends({}, props, {
|
|
103
|
+
ref: ref,
|
|
104
|
+
value: value,
|
|
105
|
+
onChange: onChange
|
|
106
|
+
})), load && /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
style: {
|
|
108
|
+
display: "none"
|
|
109
|
+
}
|
|
110
|
+
}, /*#__PURE__*/React.createElement(TypeEle, {
|
|
111
|
+
url: url,
|
|
112
|
+
mediaType: mediaType,
|
|
113
|
+
onReady: onReady,
|
|
114
|
+
onError: onError
|
|
115
|
+
})));
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
export { HUrlUpload as default };
|
|
119
|
+
// powered by hdj
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
var MediaTypeEnum;
|
|
3
|
+
(function (MediaTypeEnum) {
|
|
4
|
+
MediaTypeEnum[MediaTypeEnum["video"] = 0] = "video";
|
|
5
|
+
MediaTypeEnum[MediaTypeEnum["audio"] = 1] = "audio";
|
|
6
|
+
MediaTypeEnum[MediaTypeEnum["img"] = 2] = "img";
|
|
7
|
+
})(MediaTypeEnum || (MediaTypeEnum = {}));
|
|
8
|
+
|
|
9
|
+
export { MediaTypeEnum };
|
|
10
|
+
// powered by hdj
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IUpLoadProps } from "../modal";
|
|
2
|
+
import type { UploadChangeParam, UploadFile } from "antd/lib/upload/interface";
|
|
3
|
+
export declare const useChange: ({ value, onChange, maxCount, request, exFiles, maxSize, }: IUpLoadProps) => (info: UploadChangeParam<UploadFile>) => void;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
3
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
4
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
5
|
+
import _everyInstanceProperty from '@babel/runtime-corejs3/core-js/instance/every';
|
|
6
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
7
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
8
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
9
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
10
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
11
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
12
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
13
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
14
|
+
import { useRequest } from 'ahooks';
|
|
15
|
+
import { useCustomRequest } from './customRequest.js';
|
|
16
|
+
import { checkFileSize, checkFileType } from '../util.js';
|
|
17
|
+
import { message } from 'antd';
|
|
18
|
+
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
var checkFile = function checkFile(item) {
|
|
22
|
+
var oldFile = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
23
|
+
return _everyInstanceProperty(oldFile).call(oldFile, function (oldItem) {
|
|
24
|
+
return item.uid !== oldItem.uid;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
var matchFile = function matchFile(newFile) {
|
|
28
|
+
var oldFile = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
29
|
+
var exFiles = arguments.length > 2 ? arguments[2] : undefined;
|
|
30
|
+
var maxSize = arguments.length > 3 ? arguments[3] : undefined;
|
|
31
|
+
var newResultFileList = [];
|
|
32
|
+
var addFile = [];
|
|
33
|
+
var errList = [];
|
|
34
|
+
_forEachInstanceProperty(newFile).call(newFile, function (item) {
|
|
35
|
+
if (!checkFileSize(item, maxSize)) {
|
|
36
|
+
return errList.push(new Error("超出限制大小!"));
|
|
37
|
+
}
|
|
38
|
+
if (!checkFileType(item, exFiles)) {
|
|
39
|
+
return errList.push(new Error("文件格式错误!"));
|
|
40
|
+
}
|
|
41
|
+
if (checkFile(item, oldFile)) {
|
|
42
|
+
addFile.push(item);
|
|
43
|
+
newResultFileList.push(_objectSpread(_objectSpread({}, item), {}, {
|
|
44
|
+
status: "uploading"
|
|
45
|
+
}));
|
|
46
|
+
} else {
|
|
47
|
+
newResultFileList.push(item);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
addFile: addFile,
|
|
52
|
+
fileList: newResultFileList,
|
|
53
|
+
errList: errList
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
var useChange = function useChange(_ref) {
|
|
57
|
+
var value = _ref.value,
|
|
58
|
+
onChange = _ref.onChange,
|
|
59
|
+
_ref$maxCount = _ref.maxCount,
|
|
60
|
+
maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
|
|
61
|
+
request = _ref.request,
|
|
62
|
+
exFiles = _ref.exFiles,
|
|
63
|
+
maxSize = _ref.maxSize;
|
|
64
|
+
var customRequest = useCustomRequest({
|
|
65
|
+
request: request,
|
|
66
|
+
onChange: onChange,
|
|
67
|
+
value: value
|
|
68
|
+
});
|
|
69
|
+
var _useRequest = useRequest( /*#__PURE__*/function () {
|
|
70
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
|
|
71
|
+
var fileList, _matchFile, addFile, newFileList, errList;
|
|
72
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
73
|
+
while (1) switch (_context.prev = _context.next) {
|
|
74
|
+
case 0:
|
|
75
|
+
fileList = _ref2.fileList;
|
|
76
|
+
if (!(fileList.length > maxCount)) {
|
|
77
|
+
_context.next = 4;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
message.error("超出最多文件限制!");
|
|
81
|
+
return _context.abrupt("return");
|
|
82
|
+
case 4:
|
|
83
|
+
_matchFile = matchFile(fileList, value, exFiles, maxSize), addFile = _matchFile.addFile, newFileList = _matchFile.fileList, errList = _matchFile.errList;
|
|
84
|
+
if (errList.length) {
|
|
85
|
+
message.error(errList[0].message);
|
|
86
|
+
}
|
|
87
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newFileList);
|
|
88
|
+
customRequest(addFile);
|
|
89
|
+
case 8:
|
|
90
|
+
case "end":
|
|
91
|
+
return _context.stop();
|
|
92
|
+
}
|
|
93
|
+
}, _callee);
|
|
94
|
+
}));
|
|
95
|
+
return function (_x) {
|
|
96
|
+
return _ref3.apply(this, arguments);
|
|
97
|
+
};
|
|
98
|
+
}(), {
|
|
99
|
+
manual: true,
|
|
100
|
+
debounceInterval: 100
|
|
101
|
+
}),
|
|
102
|
+
run = _useRequest.run;
|
|
103
|
+
return function (info) {
|
|
104
|
+
run(info);
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export { useChange };
|
|
109
|
+
// powered by hdj
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
3
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
4
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
|
|
5
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
6
|
+
import { useMemo, useEffect } from 'react';
|
|
7
|
+
|
|
8
|
+
var useCustomRequest = function useCustomRequest(_ref) {
|
|
9
|
+
var value = _ref.value,
|
|
10
|
+
request = _ref.request,
|
|
11
|
+
onChange = _ref.onChange;
|
|
12
|
+
var valObj = useMemo(function () {
|
|
13
|
+
return {
|
|
14
|
+
value: value
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
useEffect(function () {
|
|
18
|
+
valObj.value = value;
|
|
19
|
+
}, [value]);
|
|
20
|
+
var sendFile = /*#__PURE__*/function () {
|
|
21
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file) {
|
|
22
|
+
var _valObj$value;
|
|
23
|
+
var uid, url, result, fileList;
|
|
24
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
25
|
+
while (1) switch (_context.prev = _context.next) {
|
|
26
|
+
case 0:
|
|
27
|
+
uid = file.uid;
|
|
28
|
+
url = "";
|
|
29
|
+
if (!request) {
|
|
30
|
+
_context.next = 7;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
_context.next = 5;
|
|
34
|
+
return request(file);
|
|
35
|
+
case 5:
|
|
36
|
+
result = _context.sent;
|
|
37
|
+
url = result.url;
|
|
38
|
+
case 7:
|
|
39
|
+
fileList = valObj === null || valObj === void 0 ? void 0 : (_valObj$value = valObj.value) === null || _valObj$value === void 0 ? void 0 : _mapInstanceProperty(_valObj$value).call(_valObj$value, function (item) {
|
|
40
|
+
var resultUrl = url || item.thumbUrl;
|
|
41
|
+
if (item.uid === uid) {
|
|
42
|
+
item.status = "done";
|
|
43
|
+
item.response = {
|
|
44
|
+
url: resultUrl
|
|
45
|
+
};
|
|
46
|
+
return item;
|
|
47
|
+
}
|
|
48
|
+
return item;
|
|
49
|
+
});
|
|
50
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(fileList || []);
|
|
51
|
+
case 9:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context.stop();
|
|
54
|
+
}
|
|
55
|
+
}, _callee);
|
|
56
|
+
}));
|
|
57
|
+
return function sendFile(_x) {
|
|
58
|
+
return _ref2.apply(this, arguments);
|
|
59
|
+
};
|
|
60
|
+
}();
|
|
61
|
+
return function (fileList) {
|
|
62
|
+
_forEachInstanceProperty(fileList).call(fileList, function (item) {
|
|
63
|
+
sendFile(item);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { useCustomRequest };
|
|
69
|
+
// powered by hdj
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
3
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
4
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
5
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
6
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
7
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
8
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
9
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
10
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
11
|
+
import { useFormConfigContext } from '../../Form/Context/FormConfigProvider.js';
|
|
12
|
+
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
+
var useProps = function useProps(_ref) {
|
|
16
|
+
var request = _ref.request,
|
|
17
|
+
exFiles = _ref.exFiles,
|
|
18
|
+
maxSize = _ref.maxSize;
|
|
19
|
+
var configUploadProps = useFormConfigContext("uploadProps");
|
|
20
|
+
var inputProps = {
|
|
21
|
+
request: request,
|
|
22
|
+
exFiles: exFiles,
|
|
23
|
+
maxSize: maxSize
|
|
24
|
+
};
|
|
25
|
+
var keys = _Object$keys(inputProps);
|
|
26
|
+
var resultProps = _objectSpread({}, configUploadProps);
|
|
27
|
+
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
28
|
+
if (inputProps[key]) {
|
|
29
|
+
resultProps[key] = inputProps[key];
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return resultProps;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { useProps };
|
|
37
|
+
// powered by hdj
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
|
|
3
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
|
|
4
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
|
|
5
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
|
|
6
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
|
|
7
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
|
|
8
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
|
|
9
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
|
|
10
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
11
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
12
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
13
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
14
|
+
import { Upload } from 'antd';
|
|
15
|
+
import Btn from './Btn.js';
|
|
16
|
+
import React, { useState, useImperativeHandle, useMemo } from 'react';
|
|
17
|
+
import Preview from './Preview/index.js';
|
|
18
|
+
import { useChange } from './hooks/change.js';
|
|
19
|
+
import { useProps } from './hooks/propsMaker.js';
|
|
20
|
+
|
|
21
|
+
var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize"];
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
24
|
+
var Index = function Index(_ref, ref) {
|
|
25
|
+
var _ref$value = _ref.value,
|
|
26
|
+
value = _ref$value === void 0 ? [] : _ref$value,
|
|
27
|
+
onChange = _ref.onChange,
|
|
28
|
+
_ref$listType = _ref.listType,
|
|
29
|
+
listType = _ref$listType === void 0 ? "picture-card" : _ref$listType,
|
|
30
|
+
exFiles = _ref.exFiles,
|
|
31
|
+
_ref$maxCount = _ref.maxCount,
|
|
32
|
+
maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
|
|
33
|
+
_ref$maxRowNum = _ref.maxRowNum,
|
|
34
|
+
maxRowNum = _ref$maxRowNum === void 0 ? 3 : _ref$maxRowNum,
|
|
35
|
+
onPreview = _ref.onPreview,
|
|
36
|
+
request = _ref.request,
|
|
37
|
+
maxSize = _ref.maxSize,
|
|
38
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
39
|
+
var matchProps = useProps({
|
|
40
|
+
request: request,
|
|
41
|
+
exFiles: exFiles,
|
|
42
|
+
maxSize: maxSize
|
|
43
|
+
});
|
|
44
|
+
var _useState = useState({}),
|
|
45
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
46
|
+
previewModal = _useState2[0],
|
|
47
|
+
setPreviewModal = _useState2[1];
|
|
48
|
+
var change = useChange(_objectSpread(_objectSpread({}, matchProps), {}, {
|
|
49
|
+
value: value,
|
|
50
|
+
maxCount: maxCount,
|
|
51
|
+
onChange: onChange
|
|
52
|
+
}));
|
|
53
|
+
useImperativeHandle(ref, function () {
|
|
54
|
+
return {
|
|
55
|
+
change: change
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
var contentStyle = useMemo(function () {
|
|
59
|
+
if (listType !== "picture-card") {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
width: 112 * maxRowNum,
|
|
64
|
+
maxWidth: "100%"
|
|
65
|
+
};
|
|
66
|
+
}, [maxRowNum, listType]);
|
|
67
|
+
var preview = function preview(file) {
|
|
68
|
+
if (onPreview) {
|
|
69
|
+
onPreview(file);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
setPreviewModal({
|
|
73
|
+
visible: true,
|
|
74
|
+
file: file
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
var maxNum = maxCount === 1 ? maxCount : Number.MAX_VALUE;
|
|
78
|
+
var visible = previewModal.visible,
|
|
79
|
+
previewFile = previewModal.file;
|
|
80
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
81
|
+
style: contentStyle
|
|
82
|
+
}, /*#__PURE__*/React.createElement(Upload, _extends({
|
|
83
|
+
listType: listType,
|
|
84
|
+
maxCount: maxNum,
|
|
85
|
+
fileList: value,
|
|
86
|
+
onPreview: preview,
|
|
87
|
+
onChange: change,
|
|
88
|
+
beforeUpload: function beforeUpload() {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}, props), /*#__PURE__*/React.createElement(Btn, {
|
|
92
|
+
value: value,
|
|
93
|
+
maxCount: maxCount,
|
|
94
|
+
listType: listType
|
|
95
|
+
})), /*#__PURE__*/React.createElement(Preview, {
|
|
96
|
+
visible: visible,
|
|
97
|
+
file: previewFile,
|
|
98
|
+
onCancel: function onCancel() {
|
|
99
|
+
setPreviewModal({});
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
};
|
|
103
|
+
var HUpload = /*#__PURE__*/React.forwardRef(Index);
|
|
104
|
+
|
|
105
|
+
export { HUpload as default };
|
|
106
|
+
// powered by hdj
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { UploadProps } from "antd";
|
|
2
|
+
import type { UploadFile } from "antd/es/upload/interface";
|
|
3
|
+
import type { BeforeUploadFileType, RcFile } from "rc-upload/lib/interface";
|
|
4
|
+
import type { UploadChangeParam } from "antd/lib/upload/interface";
|
|
5
|
+
import type { MediaTypeEnum } from "@/components/Upload/enums";
|
|
6
|
+
export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
7
|
+
exFiles?: string[];
|
|
8
|
+
request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
|
|
9
|
+
url: string;
|
|
10
|
+
}>;
|
|
11
|
+
errorType?: "alert" | "show";
|
|
12
|
+
onChange?: (fileList: UploadFile[]) => void;
|
|
13
|
+
value?: UploadFile[];
|
|
14
|
+
maxRowNum?: number;
|
|
15
|
+
maxSize?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface IMediaTypeEleProps {
|
|
18
|
+
file?: UploadFile;
|
|
19
|
+
onReady?: VoidFunction;
|
|
20
|
+
onError?: VoidFunction;
|
|
21
|
+
}
|
|
22
|
+
export interface IUploadRefModal {
|
|
23
|
+
change: (info: UploadChangeParam<UploadFile>) => void;
|
|
24
|
+
}
|
|
25
|
+
export interface IUrlUploadProps extends IUpLoadProps {
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
mediaType?: MediaTypeEnum;
|
|
28
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UploadFile } from "antd/es/upload/interface";
|
|
2
|
+
export declare const getFileExt: (file: UploadFile) => string;
|
|
3
|
+
export declare const checkFileType: (file: UploadFile, exFiles?: string[]) => boolean;
|
|
4
|
+
export declare const checkFileSize: (file: UploadFile, maxSize?: number) => boolean;
|
|
5
|
+
export declare const fileToBase64: (file: any) => Promise<unknown>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _lastIndexOfInstanceProperty from '@babel/runtime-corejs3/core-js/instance/last-index-of';
|
|
3
|
+
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js/instance/index-of';
|
|
4
|
+
import _Promise from '@babel/runtime-corejs3/core-js/promise';
|
|
5
|
+
|
|
6
|
+
var getFileExt = function getFileExt(file) {
|
|
7
|
+
var name = file.name;
|
|
8
|
+
var index = _lastIndexOfInstanceProperty(name).call(name, ".");
|
|
9
|
+
return name.substring(index + 1).toUpperCase();
|
|
10
|
+
};
|
|
11
|
+
var checkFileType = function checkFileType(file) {
|
|
12
|
+
var exFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
13
|
+
var exName = getFileExt(file);
|
|
14
|
+
return _indexOfInstanceProperty(exFiles).call(exFiles, exName) !== -1;
|
|
15
|
+
};
|
|
16
|
+
var checkFileSize = function checkFileSize(file) {
|
|
17
|
+
var maxSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
18
|
+
var _file$size = file.size,
|
|
19
|
+
size = _file$size === void 0 ? 0 : _file$size;
|
|
20
|
+
return size <= maxSize;
|
|
21
|
+
};
|
|
22
|
+
var fileToBase64 = function fileToBase64(file) {
|
|
23
|
+
return new _Promise(function (resolve) {
|
|
24
|
+
var reader = new FileReader();
|
|
25
|
+
reader.readAsDataURL(file === null || file === void 0 ? void 0 : file.originFileObj);
|
|
26
|
+
reader.onload = function (e) {
|
|
27
|
+
var _e$target;
|
|
28
|
+
resolve((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.result);
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { checkFileSize, checkFileType, fileToBase64, getFileExt };
|
|
34
|
+
// powered by hdj
|
package/es/config.d.ts
ADDED
package/es/config.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
3
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
import { fileToBase64 } from './Upload/util.js';
|
|
6
|
+
|
|
7
|
+
var baseConfig = {
|
|
8
|
+
fieldNames: {
|
|
9
|
+
label: "label",
|
|
10
|
+
value: "value"
|
|
11
|
+
},
|
|
12
|
+
valueCheckMap: {
|
|
13
|
+
checked: true,
|
|
14
|
+
noChecked: false
|
|
15
|
+
},
|
|
16
|
+
valueSwitchMap: {
|
|
17
|
+
open: true,
|
|
18
|
+
close: false
|
|
19
|
+
},
|
|
20
|
+
valueRangePickerValueMap: {
|
|
21
|
+
start: function start(name) {
|
|
22
|
+
return "".concat(name, "StartTime");
|
|
23
|
+
},
|
|
24
|
+
end: function end(name) {
|
|
25
|
+
return "".concat(name, "EndTime");
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
dateRanges: {
|
|
29
|
+
最近三天: [moment().subtract(2, "days").startOf("days"), moment()],
|
|
30
|
+
最近七天: [moment().subtract(6, "days").startOf("days"), moment()],
|
|
31
|
+
最近三十天: [moment().subtract(29, "days").startOf("days"), moment()]
|
|
32
|
+
},
|
|
33
|
+
uploadProps: {
|
|
34
|
+
exFiles: ["JPG", "PNG", "JPEG", "GIF"],
|
|
35
|
+
request: function () {
|
|
36
|
+
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file) {
|
|
37
|
+
var url;
|
|
38
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
39
|
+
while (1) switch (_context.prev = _context.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
_context.next = 2;
|
|
42
|
+
return fileToBase64(file);
|
|
43
|
+
case 2:
|
|
44
|
+
url = _context.sent;
|
|
45
|
+
return _context.abrupt("return", {
|
|
46
|
+
url: url
|
|
47
|
+
});
|
|
48
|
+
case 4:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
51
|
+
}
|
|
52
|
+
}, _callee);
|
|
53
|
+
}));
|
|
54
|
+
function request(_x) {
|
|
55
|
+
return _request.apply(this, arguments);
|
|
56
|
+
}
|
|
57
|
+
return request;
|
|
58
|
+
}(),
|
|
59
|
+
maxSize: 1024 * 1024 * 1.8
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export { baseConfig };
|
|
64
|
+
// powered by hdj
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SelectProps } from "antd";
|
|
2
|
+
import type { IFormConfigContextProps } from "../Form/modal";
|
|
3
|
+
interface UseChangeOptionsParams {
|
|
4
|
+
options?: Record<string, any>[];
|
|
5
|
+
fieldNames?: SelectProps["fieldNames"];
|
|
6
|
+
}
|
|
7
|
+
export declare const useChangeOptions: ({ options, fieldNames, }: UseChangeOptionsParams) => {
|
|
8
|
+
label: any;
|
|
9
|
+
value: any;
|
|
10
|
+
}[] | undefined;
|
|
11
|
+
export declare const useClassName: (className: string | string[]) => string;
|
|
12
|
+
export declare const useMatchConfigProps: (matchProps: IFormConfigContextProps) => IFormConfigContextProps;
|
|
13
|
+
export {};
|