@hw-component/form 0.0.2-beta-v1 → 0.0.2-beta-v3
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/Form/hooks/useHForm.js +6 -1
- package/es/Upload/index.js +3 -2
- package/lib/Form/hooks/useHForm.js +6 -1
- package/lib/Upload/index.js +3 -2
- package/package.json +1 -1
- package/src/components/Form/hooks/useHForm.ts +6 -1
- package/src/components/Upload/index.tsx +3 -2
- package/src/pages/DrawerForm/index.tsx +2 -2
- package/src/pages/Form/index.tsx +1 -3
- package/src/pages/ModalForm/index.tsx +2 -2
|
@@ -27,6 +27,7 @@ var useHForm = (function () {
|
|
|
27
27
|
var formatSourceData = {};
|
|
28
28
|
var dispatchSourceData = {};
|
|
29
29
|
var cacheValues = {};
|
|
30
|
+
var isLoading = false;
|
|
30
31
|
var norAddItemDispatch = function norAddItemDispatch(name, fn) {
|
|
31
32
|
if (!name) {
|
|
32
33
|
return {
|
|
@@ -45,6 +46,7 @@ var useHForm = (function () {
|
|
|
45
46
|
var newValue = this.formatValues(cacheValues);
|
|
46
47
|
form.setFieldsValue(newValue);
|
|
47
48
|
}
|
|
49
|
+
isLoading = true;
|
|
48
50
|
},
|
|
49
51
|
addFormat: function addFormat(name, format) {
|
|
50
52
|
if (!format) {
|
|
@@ -147,8 +149,11 @@ var useHForm = (function () {
|
|
|
147
149
|
}
|
|
148
150
|
}, form), {}, {
|
|
149
151
|
setFieldsValue: function setFieldsValue(values) {
|
|
152
|
+
if (!isLoading) {
|
|
153
|
+
cacheValues = values;
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
150
156
|
var newValue = this.formatValues(values);
|
|
151
|
-
cacheValues = values;
|
|
152
157
|
form.setFieldsValue(newValue);
|
|
153
158
|
},
|
|
154
159
|
validateFields: function validateFields(nameList) {
|
package/es/Upload/index.js
CHANGED
|
@@ -86,7 +86,8 @@ var Index = function Index(_ref, ref) {
|
|
|
86
86
|
var _item$name = item.name,
|
|
87
87
|
name = _item$name === void 0 ? "" : _item$name;
|
|
88
88
|
var initFileList = initValue[name] || [];
|
|
89
|
-
var
|
|
89
|
+
var relInitFileList = typeof initFileList === "string" ? [initFileList] : initFileList;
|
|
90
|
+
var fileList = _mapInstanceProperty(relInitFileList).call(relInitFileList, function (url, index) {
|
|
90
91
|
return {
|
|
91
92
|
name: url,
|
|
92
93
|
response: {
|
|
@@ -107,7 +108,7 @@ var Index = function Index(_ref, ref) {
|
|
|
107
108
|
var urls = _mapInstanceProperty(itemVal).call(itemVal, function (fileItem) {
|
|
108
109
|
return fileItem.response.url;
|
|
109
110
|
});
|
|
110
|
-
return _defineProperty({}, valueName, urls);
|
|
111
|
+
return _defineProperty({}, valueName, maxCount === 1 ? urls[0] : urls);
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
});
|
|
@@ -30,6 +30,7 @@ var useHForm = (function () {
|
|
|
30
30
|
var formatSourceData = {};
|
|
31
31
|
var dispatchSourceData = {};
|
|
32
32
|
var cacheValues = {};
|
|
33
|
+
var isLoading = false;
|
|
33
34
|
var norAddItemDispatch = function norAddItemDispatch(name, fn) {
|
|
34
35
|
if (!name) {
|
|
35
36
|
return {
|
|
@@ -48,6 +49,7 @@ var useHForm = (function () {
|
|
|
48
49
|
var newValue = this.formatValues(cacheValues);
|
|
49
50
|
form.setFieldsValue(newValue);
|
|
50
51
|
}
|
|
52
|
+
isLoading = true;
|
|
51
53
|
},
|
|
52
54
|
addFormat: function addFormat(name, format) {
|
|
53
55
|
if (!format) {
|
|
@@ -150,8 +152,11 @@ var useHForm = (function () {
|
|
|
150
152
|
}
|
|
151
153
|
}, form), {}, {
|
|
152
154
|
setFieldsValue: function setFieldsValue(values) {
|
|
155
|
+
if (!isLoading) {
|
|
156
|
+
cacheValues = values;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
153
159
|
var newValue = this.formatValues(values);
|
|
154
|
-
cacheValues = values;
|
|
155
160
|
form.setFieldsValue(newValue);
|
|
156
161
|
},
|
|
157
162
|
validateFields: function validateFields(nameList) {
|
package/lib/Upload/index.js
CHANGED
|
@@ -89,7 +89,8 @@ var Index = function Index(_ref, ref) {
|
|
|
89
89
|
var _item$name = item.name,
|
|
90
90
|
name = _item$name === void 0 ? "" : _item$name;
|
|
91
91
|
var initFileList = initValue[name] || [];
|
|
92
|
-
var
|
|
92
|
+
var relInitFileList = typeof initFileList === "string" ? [initFileList] : initFileList;
|
|
93
|
+
var fileList = _mapInstanceProperty(relInitFileList).call(relInitFileList, function (url, index) {
|
|
93
94
|
return {
|
|
94
95
|
name: url,
|
|
95
96
|
response: {
|
|
@@ -110,7 +111,7 @@ var Index = function Index(_ref, ref) {
|
|
|
110
111
|
var urls = _mapInstanceProperty(itemVal).call(itemVal, function (fileItem) {
|
|
111
112
|
return fileItem.response.url;
|
|
112
113
|
});
|
|
113
|
-
return _defineProperty({}, valueName, urls);
|
|
114
|
+
return _defineProperty({}, valueName, maxCount === 1 ? urls[0] : urls);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
});
|
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ export default () => {
|
|
|
14
14
|
const formatSourceData: Record<string, FormatItemModal> = {};
|
|
15
15
|
let dispatchSourceData: Record<string, DispatchItemData> = {};
|
|
16
16
|
let cacheValues: Record<string, any> = {};
|
|
17
|
+
let isLoading=false;
|
|
17
18
|
const norAddItemDispatch = (name, fn) => {
|
|
18
19
|
if (!name) {
|
|
19
20
|
return {
|
|
@@ -34,6 +35,7 @@ export default () => {
|
|
|
34
35
|
const newValue = this.formatValues(cacheValues);
|
|
35
36
|
form.setFieldsValue(newValue);
|
|
36
37
|
}
|
|
38
|
+
isLoading=true;
|
|
37
39
|
},
|
|
38
40
|
addFormat(name: string, format?: FormatItemModal) {
|
|
39
41
|
if (!format) {
|
|
@@ -125,8 +127,11 @@ export default () => {
|
|
|
125
127
|
},
|
|
126
128
|
...form,
|
|
127
129
|
setFieldsValue(values) {
|
|
130
|
+
if (!isLoading){
|
|
131
|
+
cacheValues = values;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
128
134
|
const newValue = this.formatValues(values);
|
|
129
|
-
cacheValues = values;
|
|
130
135
|
form.setFieldsValue(newValue);
|
|
131
136
|
},
|
|
132
137
|
validateFields(nameList) {
|
|
@@ -61,7 +61,8 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
61
61
|
inputValue: (item, initValue) => {
|
|
62
62
|
const { name = "" } = item;
|
|
63
63
|
const initFileList = initValue[name] || [];
|
|
64
|
-
const
|
|
64
|
+
const relInitFileList=typeof initFileList==="string"?[initFileList]:initFileList;
|
|
65
|
+
const fileList = relInitFileList.map((url, index) => {
|
|
65
66
|
return {
|
|
66
67
|
name: url,
|
|
67
68
|
response: {
|
|
@@ -83,7 +84,7 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
|
|
|
83
84
|
return fileItem.response.url;
|
|
84
85
|
});
|
|
85
86
|
return {
|
|
86
|
-
[valueName]: urls,
|
|
87
|
+
[valueName]: maxCount===1?urls[0]:urls,
|
|
87
88
|
};
|
|
88
89
|
},
|
|
89
90
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button } from "antd";
|
|
2
|
-
import { HDrawerForm,
|
|
2
|
+
import { HDrawerForm, useHDialogForm } from "../../components";
|
|
3
3
|
const data = [
|
|
4
4
|
{
|
|
5
5
|
label: "输入框",
|
|
@@ -98,7 +98,7 @@ const data = [
|
|
|
98
98
|
},
|
|
99
99
|
];
|
|
100
100
|
export default () => {
|
|
101
|
-
const modalForm =
|
|
101
|
+
const modalForm = useHDialogForm();
|
|
102
102
|
return (
|
|
103
103
|
<>
|
|
104
104
|
<Button
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -128,9 +128,7 @@ export default () => {
|
|
|
128
128
|
testEnd: "1693538359",
|
|
129
129
|
op: 1,
|
|
130
130
|
opInput: "12121",
|
|
131
|
-
upload:
|
|
132
|
-
"https://img2.baidu.com/it/u=2048195462,703560066&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=333",
|
|
133
|
-
],
|
|
131
|
+
upload: "https://img2.baidu.com/it/u=2048195462,703560066&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=333",
|
|
134
132
|
});
|
|
135
133
|
}, 3000);
|
|
136
134
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button } from "antd";
|
|
2
|
-
import { HModalForm,
|
|
2
|
+
import { HModalForm, useHDialogForm } from "../../components";
|
|
3
3
|
const data = [
|
|
4
4
|
{
|
|
5
5
|
label: "输入框",
|
|
@@ -98,7 +98,7 @@ const data = [
|
|
|
98
98
|
},
|
|
99
99
|
];
|
|
100
100
|
export default () => {
|
|
101
|
-
const modalForm =
|
|
101
|
+
const modalForm = useHDialogForm();
|
|
102
102
|
return (
|
|
103
103
|
<>
|
|
104
104
|
<Button
|