@hw-component/form 0.0.6-beta-v3 → 0.0.6-beta-v5
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/es/DialogForm/hooks.js +2 -1
- package/es/Form/hooks/index.js +8 -7
- package/es/Form/hooks/useHForm.js +4 -0
- package/es/Upload/UrlUpload/index.js +13 -2
- package/lib/DialogForm/hooks.js +2 -1
- package/lib/Form/hooks/index.js +8 -7
- package/lib/Form/hooks/useHForm.js +4 -0
- package/lib/Upload/UrlUpload/index.js +13 -2
- package/package.json +1 -1
- package/src/components/DialogForm/hooks.ts +1 -1
- package/src/components/Form/hooks/index.ts +1 -0
- package/src/components/Form/hooks/useHForm.ts +4 -0
- package/src/components/Upload/UrlUpload/index.tsx +18 -4
- package/src/pages/DrawerForm/index.tsx +10 -2
- package/src/pages/Form/index.tsx +14 -13
- package/src/pages/ModalForm/index.tsx +14 -1
package/es/DialogForm/hooks.js
CHANGED
|
@@ -66,7 +66,8 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
66
66
|
dialogForm.show = function () {
|
|
67
67
|
var showParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
68
68
|
var changeConfigData = showParams.configData,
|
|
69
|
-
|
|
69
|
+
_showParams$initialVa = showParams.initialValues,
|
|
70
|
+
changeInitialValues = _showParams$initialVa === void 0 ? {} : _showParams$initialVa,
|
|
70
71
|
_showParams$params = showParams.params,
|
|
71
72
|
changeParams = _showParams$params === void 0 ? {} : _showParams$params,
|
|
72
73
|
changeTitle = showParams.title;
|
package/es/Form/hooks/index.js
CHANGED
|
@@ -72,23 +72,24 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
72
72
|
setValue = initialValues;
|
|
73
73
|
reqData.params = reqParams;
|
|
74
74
|
if (!(!initialValues && !infoRequest)) {
|
|
75
|
-
_context2.next =
|
|
75
|
+
_context2.next = 6;
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
|
+
form === null || form === void 0 || form.setFieldsValue({});
|
|
78
79
|
return _context2.abrupt("return", {});
|
|
79
|
-
case
|
|
80
|
+
case 6:
|
|
80
81
|
if (!infoRequest) {
|
|
81
|
-
_context2.next =
|
|
82
|
+
_context2.next = 10;
|
|
82
83
|
break;
|
|
83
84
|
}
|
|
84
|
-
_context2.next =
|
|
85
|
+
_context2.next = 9;
|
|
85
86
|
return infoRequest(reqParams);
|
|
86
|
-
case 8:
|
|
87
|
-
setValue = _context2.sent;
|
|
88
87
|
case 9:
|
|
88
|
+
setValue = _context2.sent;
|
|
89
|
+
case 10:
|
|
89
90
|
form === null || form === void 0 || form.setFieldsValue(setValue);
|
|
90
91
|
return _context2.abrupt("return", setValue || {});
|
|
91
|
-
case
|
|
92
|
+
case 12:
|
|
92
93
|
case "end":
|
|
93
94
|
return _context2.stop();
|
|
94
95
|
}
|
|
@@ -3,6 +3,7 @@ import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
|
3
3
|
import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
|
|
4
4
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
5
5
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
6
|
+
import 'core-js/modules/es.array.slice.js';
|
|
6
7
|
import 'core-js/modules/es.object.to-string.js';
|
|
7
8
|
import 'core-js/modules/es.regexp.to-string.js';
|
|
8
9
|
import 'core-js/modules/es.string.trim.js';
|
|
@@ -10,6 +11,7 @@ import 'core-js/modules/es.array.map.js';
|
|
|
10
11
|
import 'core-js/modules/es.array.from.js';
|
|
11
12
|
import 'core-js/modules/es.string.iterator.js';
|
|
12
13
|
import 'core-js/modules/es.function.name.js';
|
|
14
|
+
import 'core-js/modules/es.array.concat.js';
|
|
13
15
|
import 'core-js/modules/es.object.keys.js';
|
|
14
16
|
import 'core-js/modules/es.symbol.js';
|
|
15
17
|
import 'core-js/modules/es.array.filter.js';
|
|
@@ -26,6 +28,14 @@ import { useState, useRef } from 'react';
|
|
|
26
28
|
var _excluded = ["placeholder", "value", "onChange", "mediaType"];
|
|
27
29
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
28
30
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
31
|
+
var mkSubFileList = function mkSubFileList(fileList) {
|
|
32
|
+
var maxCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
33
|
+
var len = fileList.length;
|
|
34
|
+
if (len > maxCount) {
|
|
35
|
+
return fileList.slice(len - maxCount);
|
|
36
|
+
}
|
|
37
|
+
return fileList;
|
|
38
|
+
};
|
|
29
39
|
var Index = function Index(_ref) {
|
|
30
40
|
var _ref$placeholder = _ref.placeholder,
|
|
31
41
|
placeholder = _ref$placeholder === void 0 ? "请输入文件地址" : _ref$placeholder,
|
|
@@ -34,6 +44,7 @@ var Index = function Index(_ref) {
|
|
|
34
44
|
onChange = _ref.onChange,
|
|
35
45
|
mediaType = _ref.mediaType,
|
|
36
46
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
47
|
+
var maxCount = props.maxCount;
|
|
37
48
|
var _useState = useState(""),
|
|
38
49
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
50
|
url = _useState2[0],
|
|
@@ -55,7 +66,7 @@ var Index = function Index(_ref) {
|
|
|
55
66
|
url: url
|
|
56
67
|
}
|
|
57
68
|
});
|
|
58
|
-
onChange === null || onChange === void 0 || onChange(newFileList);
|
|
69
|
+
onChange === null || onChange === void 0 || onChange(mkSubFileList(newFileList, maxCount));
|
|
59
70
|
setUrl("");
|
|
60
71
|
setLoad(false);
|
|
61
72
|
};
|
|
@@ -91,7 +102,7 @@ var Index = function Index(_ref) {
|
|
|
91
102
|
};
|
|
92
103
|
});
|
|
93
104
|
(_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.change({
|
|
94
|
-
fileList: newFileList,
|
|
105
|
+
fileList: mkSubFileList([].concat(_toConsumableArray(value), _toConsumableArray(newFileList)), maxCount),
|
|
95
106
|
file: newFileList[0]
|
|
96
107
|
});
|
|
97
108
|
setUrl("");
|
package/lib/DialogForm/hooks.js
CHANGED
|
@@ -67,7 +67,8 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
67
67
|
dialogForm.show = function () {
|
|
68
68
|
var showParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
69
69
|
var changeConfigData = showParams.configData,
|
|
70
|
-
|
|
70
|
+
_showParams$initialVa = showParams.initialValues,
|
|
71
|
+
changeInitialValues = _showParams$initialVa === void 0 ? {} : _showParams$initialVa,
|
|
71
72
|
_showParams$params = showParams.params,
|
|
72
73
|
changeParams = _showParams$params === void 0 ? {} : _showParams$params,
|
|
73
74
|
changeTitle = showParams.title;
|
package/lib/Form/hooks/index.js
CHANGED
|
@@ -73,23 +73,24 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
73
73
|
setValue = initialValues;
|
|
74
74
|
reqData.params = reqParams;
|
|
75
75
|
if (!(!initialValues && !infoRequest)) {
|
|
76
|
-
_context2.next =
|
|
76
|
+
_context2.next = 6;
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
79
|
+
form === null || form === void 0 || form.setFieldsValue({});
|
|
79
80
|
return _context2.abrupt("return", {});
|
|
80
|
-
case
|
|
81
|
+
case 6:
|
|
81
82
|
if (!infoRequest) {
|
|
82
|
-
_context2.next =
|
|
83
|
+
_context2.next = 10;
|
|
83
84
|
break;
|
|
84
85
|
}
|
|
85
|
-
_context2.next =
|
|
86
|
+
_context2.next = 9;
|
|
86
87
|
return infoRequest(reqParams);
|
|
87
|
-
case 8:
|
|
88
|
-
setValue = _context2.sent;
|
|
89
88
|
case 9:
|
|
89
|
+
setValue = _context2.sent;
|
|
90
|
+
case 10:
|
|
90
91
|
form === null || form === void 0 || form.setFieldsValue(setValue);
|
|
91
92
|
return _context2.abrupt("return", setValue || {});
|
|
92
|
-
case
|
|
93
|
+
case 12:
|
|
93
94
|
case "end":
|
|
94
95
|
return _context2.stop();
|
|
95
96
|
}
|
|
@@ -6,6 +6,7 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
6
6
|
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
7
7
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
8
8
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
9
|
+
require('core-js/modules/es.array.slice.js');
|
|
9
10
|
require('core-js/modules/es.object.to-string.js');
|
|
10
11
|
require('core-js/modules/es.regexp.to-string.js');
|
|
11
12
|
require('core-js/modules/es.string.trim.js');
|
|
@@ -13,6 +14,7 @@ require('core-js/modules/es.array.map.js');
|
|
|
13
14
|
require('core-js/modules/es.array.from.js');
|
|
14
15
|
require('core-js/modules/es.string.iterator.js');
|
|
15
16
|
require('core-js/modules/es.function.name.js');
|
|
17
|
+
require('core-js/modules/es.array.concat.js');
|
|
16
18
|
require('core-js/modules/es.object.keys.js');
|
|
17
19
|
require('core-js/modules/es.symbol.js');
|
|
18
20
|
require('core-js/modules/es.array.filter.js');
|
|
@@ -29,6 +31,14 @@ var React = require('react');
|
|
|
29
31
|
var _excluded = ["placeholder", "value", "onChange", "mediaType"];
|
|
30
32
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
33
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
34
|
+
var mkSubFileList = function mkSubFileList(fileList) {
|
|
35
|
+
var maxCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
36
|
+
var len = fileList.length;
|
|
37
|
+
if (len > maxCount) {
|
|
38
|
+
return fileList.slice(len - maxCount);
|
|
39
|
+
}
|
|
40
|
+
return fileList;
|
|
41
|
+
};
|
|
32
42
|
var Index = function Index(_ref) {
|
|
33
43
|
var _ref$placeholder = _ref.placeholder,
|
|
34
44
|
placeholder = _ref$placeholder === void 0 ? "请输入文件地址" : _ref$placeholder,
|
|
@@ -37,6 +47,7 @@ var Index = function Index(_ref) {
|
|
|
37
47
|
onChange = _ref.onChange,
|
|
38
48
|
mediaType = _ref.mediaType,
|
|
39
49
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
50
|
+
var maxCount = props.maxCount;
|
|
40
51
|
var _useState = React.useState(""),
|
|
41
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
42
53
|
url = _useState2[0],
|
|
@@ -58,7 +69,7 @@ var Index = function Index(_ref) {
|
|
|
58
69
|
url: url
|
|
59
70
|
}
|
|
60
71
|
});
|
|
61
|
-
onChange === null || onChange === void 0 || onChange(newFileList);
|
|
72
|
+
onChange === null || onChange === void 0 || onChange(mkSubFileList(newFileList, maxCount));
|
|
62
73
|
setUrl("");
|
|
63
74
|
setLoad(false);
|
|
64
75
|
};
|
|
@@ -94,7 +105,7 @@ var Index = function Index(_ref) {
|
|
|
94
105
|
};
|
|
95
106
|
});
|
|
96
107
|
(_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.change({
|
|
97
|
-
fileList: newFileList,
|
|
108
|
+
fileList: mkSubFileList([].concat(_toConsumableArray(value), _toConsumableArray(newFileList)), maxCount),
|
|
98
109
|
file: newFileList[0]
|
|
99
110
|
});
|
|
100
111
|
setUrl("");
|
package/package.json
CHANGED
|
@@ -45,7 +45,7 @@ export const useModifyProps = ({
|
|
|
45
45
|
dialogForm.show = (showParams = {}) => {
|
|
46
46
|
const {
|
|
47
47
|
configData: changeConfigData,
|
|
48
|
-
initialValues: changeInitialValues,
|
|
48
|
+
initialValues: changeInitialValues={},
|
|
49
49
|
params: changeParams={},
|
|
50
50
|
title: changeTitle,
|
|
51
51
|
} = showParams;
|
|
@@ -5,6 +5,15 @@ import type { IUploadRefModal, IUrlUploadProps } from "../modal";
|
|
|
5
5
|
import TypeEle from "../MediaTypeEle/TypeEle";
|
|
6
6
|
import { useRef, useState } from "react";
|
|
7
7
|
import type { RcFile, UploadFile } from "antd/es/upload/interface";
|
|
8
|
+
|
|
9
|
+
const mkSubFileList=(fileList: UploadFile[],maxCount=1)=>{
|
|
10
|
+
const len=fileList.length;
|
|
11
|
+
if (len>maxCount){
|
|
12
|
+
return fileList.slice(len-maxCount);
|
|
13
|
+
}
|
|
14
|
+
return fileList;
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
const Index = ({
|
|
9
18
|
placeholder = "请输入文件地址",
|
|
10
19
|
value = [],
|
|
@@ -12,11 +21,12 @@ const Index = ({
|
|
|
12
21
|
mediaType,
|
|
13
22
|
...props
|
|
14
23
|
}: IUrlUploadProps) => {
|
|
24
|
+
const {maxCount}=props;
|
|
15
25
|
const [url, setUrl] = useState("");
|
|
16
26
|
const [load, setLoad] = useState<boolean>(false);
|
|
17
27
|
const ref = useRef<IUploadRefModal | null>(null);
|
|
18
28
|
const onReady = () => {
|
|
19
|
-
|
|
29
|
+
let newFileList = [...value];
|
|
20
30
|
newFileList.push({
|
|
21
31
|
url,
|
|
22
32
|
uid: new Date().valueOf().toString(),
|
|
@@ -27,7 +37,7 @@ const Index = ({
|
|
|
27
37
|
url,
|
|
28
38
|
},
|
|
29
39
|
});
|
|
30
|
-
onChange?.(newFileList);
|
|
40
|
+
onChange?.(mkSubFileList(newFileList,maxCount));
|
|
31
41
|
setUrl("");
|
|
32
42
|
setLoad(false);
|
|
33
43
|
};
|
|
@@ -59,7 +69,7 @@ const Index = ({
|
|
|
59
69
|
type,
|
|
60
70
|
};
|
|
61
71
|
});
|
|
62
|
-
ref.current?.change({ fileList:
|
|
72
|
+
ref.current?.change({ fileList:mkSubFileList([...value,...newFileList],maxCount), file: newFileList[0] });
|
|
63
73
|
setUrl("");
|
|
64
74
|
setLoad(false);
|
|
65
75
|
};
|
|
@@ -74,7 +84,11 @@ const Index = ({
|
|
|
74
84
|
setUrl(e.target.value);
|
|
75
85
|
}}
|
|
76
86
|
/>
|
|
77
|
-
<Upload {...props}
|
|
87
|
+
<Upload {...props}
|
|
88
|
+
ref={ref}
|
|
89
|
+
value={value}
|
|
90
|
+
onChange={onChange}
|
|
91
|
+
/>
|
|
78
92
|
{load && (
|
|
79
93
|
<div style={{ display: "none" }}>
|
|
80
94
|
<TypeEle
|
|
@@ -114,12 +114,20 @@ export default () => {
|
|
|
114
114
|
});
|
|
115
115
|
}}
|
|
116
116
|
>
|
|
117
|
-
|
|
117
|
+
显示
|
|
118
|
+
</Button>
|
|
119
|
+
<Button
|
|
120
|
+
onClick={() => {
|
|
121
|
+
modalForm.show();
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
打开
|
|
118
125
|
</Button>
|
|
119
126
|
<HDrawerForm
|
|
127
|
+
|
|
120
128
|
configData={data}
|
|
121
129
|
labelWidth={88}
|
|
122
|
-
|
|
130
|
+
dialogForm={modalForm}
|
|
123
131
|
title="测试"
|
|
124
132
|
/>
|
|
125
133
|
</>
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -114,6 +114,9 @@ const formData = (options) => {
|
|
|
114
114
|
label: "地址文件",
|
|
115
115
|
name: "urlUpload",
|
|
116
116
|
type: "urlUpload",
|
|
117
|
+
itemProps: {
|
|
118
|
+
maxCount:3
|
|
119
|
+
},
|
|
117
120
|
rules: [{ required: true }],
|
|
118
121
|
},
|
|
119
122
|
{
|
|
@@ -150,7 +153,9 @@ export default () => {
|
|
|
150
153
|
configData={formData(options)}
|
|
151
154
|
labelWidth={200}
|
|
152
155
|
form={form}
|
|
153
|
-
initialValues={{
|
|
156
|
+
initialValues={{
|
|
157
|
+
name:'fff'
|
|
158
|
+
}}
|
|
154
159
|
onFinish={(value) => {
|
|
155
160
|
console.log(value);
|
|
156
161
|
}}
|
|
@@ -182,22 +187,18 @@ export default () => {
|
|
|
182
187
|
</HFormConfigProvider>
|
|
183
188
|
<div
|
|
184
189
|
onClick={() => {
|
|
185
|
-
form.
|
|
186
|
-
{
|
|
187
|
-
name: "select",
|
|
188
|
-
key: "reload",
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
params: {
|
|
192
|
-
label: "更新",
|
|
193
|
-
value: 2,
|
|
194
|
-
},
|
|
195
|
-
}
|
|
196
|
-
);
|
|
190
|
+
form.setFieldsValue({name:"123"})
|
|
197
191
|
}}
|
|
198
192
|
>
|
|
199
193
|
点我
|
|
200
194
|
</div>
|
|
195
|
+
<div
|
|
196
|
+
onClick={() => {
|
|
197
|
+
form.resetFields();
|
|
198
|
+
}}
|
|
199
|
+
>
|
|
200
|
+
重置
|
|
201
|
+
</div>
|
|
201
202
|
</div>
|
|
202
203
|
);
|
|
203
204
|
};
|
|
@@ -107,7 +107,6 @@ const data = [
|
|
|
107
107
|
},
|
|
108
108
|
itemProps: {
|
|
109
109
|
request: (params = {}, values) => {
|
|
110
|
-
console.log(values, "paramsparamsparams");
|
|
111
110
|
const { label = "123", value = 1 } = params;
|
|
112
111
|
return Promise.resolve([{ label, value }]);
|
|
113
112
|
},
|
|
@@ -133,6 +132,20 @@ export default () => {
|
|
|
133
132
|
>
|
|
134
133
|
打开
|
|
135
134
|
</Button>
|
|
135
|
+
<Button
|
|
136
|
+
onClick={() => {
|
|
137
|
+
modalForm.show({
|
|
138
|
+
params: {
|
|
139
|
+
name: num,
|
|
140
|
+
},
|
|
141
|
+
initialValues:{
|
|
142
|
+
name:"name"
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}}
|
|
146
|
+
>
|
|
147
|
+
宣誓
|
|
148
|
+
</Button>
|
|
136
149
|
<HModalForm
|
|
137
150
|
configData={data}
|
|
138
151
|
labelWidth={88}
|