@hw-component/form 1.9.65 → 1.9.67
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/Basic.js +3 -0
- package/es/Upload/hooks/change.js +13 -3
- package/es/index.css +6 -0
- package/lib/Form/Basic.js +5 -2
- package/lib/Upload/hooks/change.js +13 -3
- package/lib/index.css +6 -0
- package/package.json +1 -1
- package/src/components/Form/Basic.tsx +3 -1
- package/src/components/Form/index.less +5 -0
- package/src/components/Upload/hooks/change.ts +9 -3
- package/src/pages/Select/index.tsx +3 -2
- package/src/pages/Upload/index.tsx +0 -1
package/es/Form/Basic.js
CHANGED
|
@@ -6,6 +6,7 @@ import Item from './FormItem/index.js';
|
|
|
6
6
|
import { Row } from 'antd';
|
|
7
7
|
import { useFormContext } from './Context/index.js';
|
|
8
8
|
import useInitConfigData from './hooks/useInitConfigData.js';
|
|
9
|
+
import { useClassName } from '../hooks/index.js';
|
|
9
10
|
|
|
10
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -29,6 +30,7 @@ var Basic = (function (_ref) {
|
|
|
29
30
|
}),
|
|
30
31
|
newConfigData = _useInitConfigData.newConfigData,
|
|
31
32
|
dispatchSourceData = _useInitConfigData.dispatchSourceData;
|
|
33
|
+
var rowClassname = useClassName("hw-form-item-row");
|
|
32
34
|
useEffect(function () {
|
|
33
35
|
setData === null || setData === void 0 || setData(dispatchSourceData);
|
|
34
36
|
}, []);
|
|
@@ -41,6 +43,7 @@ var Basic = (function (_ref) {
|
|
|
41
43
|
style: {
|
|
42
44
|
width: "100%"
|
|
43
45
|
},
|
|
46
|
+
className: rowClassname,
|
|
44
47
|
children: newConfigData.map(function (itemData, index) {
|
|
45
48
|
var _itemData$labelWidth = itemData.labelWidth,
|
|
46
49
|
itemLabelWidth = _itemData$labelWidth === void 0 ? labelWidth : _itemData$labelWidth,
|
|
@@ -58,6 +58,13 @@ var useChange = function useChange(_ref) {
|
|
|
58
58
|
onChange: onChange,
|
|
59
59
|
value: value
|
|
60
60
|
});
|
|
61
|
+
var checkGo = function checkGo(errList) {
|
|
62
|
+
var len = errList.length;
|
|
63
|
+
if (len) {
|
|
64
|
+
message.error(errList[0].message);
|
|
65
|
+
}
|
|
66
|
+
return !(maxCount === 1 && len > 0);
|
|
67
|
+
};
|
|
61
68
|
var _useRequest = useRequest(/*#__PURE__*/function () {
|
|
62
69
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
|
|
63
70
|
var fileList, _matchFile, addFile, newFileList, errList, changeFile;
|
|
@@ -73,9 +80,12 @@ var useChange = function useChange(_ref) {
|
|
|
73
80
|
return _context.abrupt("return");
|
|
74
81
|
case 4:
|
|
75
82
|
_matchFile = matchFile(fileList, value, exFiles, maxSize), addFile = _matchFile.addFile, newFileList = _matchFile.fileList, errList = _matchFile.errList;
|
|
76
|
-
if (errList
|
|
77
|
-
|
|
83
|
+
if (checkGo(errList)) {
|
|
84
|
+
_context.next = 7;
|
|
85
|
+
break;
|
|
78
86
|
}
|
|
87
|
+
return _context.abrupt("return");
|
|
88
|
+
case 7:
|
|
79
89
|
changeFile = newFileList === null || newFileList === void 0 ? void 0 : newFileList.map(function (item) {
|
|
80
90
|
return _objectSpread({
|
|
81
91
|
thumbUrl: thumbUrl
|
|
@@ -83,7 +93,7 @@ var useChange = function useChange(_ref) {
|
|
|
83
93
|
});
|
|
84
94
|
onChange === null || onChange === void 0 || onChange(changeFile);
|
|
85
95
|
customRequest(addFile);
|
|
86
|
-
case
|
|
96
|
+
case 10:
|
|
87
97
|
case "end":
|
|
88
98
|
return _context.stop();
|
|
89
99
|
}
|
package/es/index.css
CHANGED
|
@@ -160,6 +160,12 @@
|
|
|
160
160
|
.ant-hw-form-form-item .ant-form-item-label {
|
|
161
161
|
overflow: visible;
|
|
162
162
|
}
|
|
163
|
+
.ant-hw-form-item-row .ant-form-item-control-input-content > .ant-space-vertical {
|
|
164
|
+
display: -webkit-box;
|
|
165
|
+
display: -webkit-flex;
|
|
166
|
+
display: -ms-flexbox;
|
|
167
|
+
display: flex;
|
|
168
|
+
}
|
|
163
169
|
.ant-hw-input-group .ant-hw-input-group-disabled {
|
|
164
170
|
background-color: #f5f5f5;
|
|
165
171
|
}
|
package/lib/Form/Basic.js
CHANGED
|
@@ -5,10 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
|
-
var index$
|
|
8
|
+
var index$2 = require('./FormItem/index.js');
|
|
9
9
|
var antd = require('antd');
|
|
10
10
|
var index = require('./Context/index.js');
|
|
11
11
|
var useInitConfigData = require('./hooks/useInitConfigData.js');
|
|
12
|
+
var index$1 = require('../hooks/index.js');
|
|
12
13
|
|
|
13
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -32,6 +33,7 @@ var Basic = (function (_ref) {
|
|
|
32
33
|
}),
|
|
33
34
|
newConfigData = _useInitConfigData.newConfigData,
|
|
34
35
|
dispatchSourceData = _useInitConfigData.dispatchSourceData;
|
|
36
|
+
var rowClassname = index$1.useClassName("hw-form-item-row");
|
|
35
37
|
React.useEffect(function () {
|
|
36
38
|
setData === null || setData === void 0 || setData(dispatchSourceData);
|
|
37
39
|
}, []);
|
|
@@ -44,6 +46,7 @@ var Basic = (function (_ref) {
|
|
|
44
46
|
style: {
|
|
45
47
|
width: "100%"
|
|
46
48
|
},
|
|
49
|
+
className: rowClassname,
|
|
47
50
|
children: newConfigData.map(function (itemData, index) {
|
|
48
51
|
var _itemData$labelWidth = itemData.labelWidth,
|
|
49
52
|
itemLabelWidth = _itemData$labelWidth === void 0 ? labelWidth : _itemData$labelWidth,
|
|
@@ -62,7 +65,7 @@ var Basic = (function (_ref) {
|
|
|
62
65
|
var arrayName = Array.isArray(name) ? name.join(".") : name;
|
|
63
66
|
var key = arrayName || nameKey;
|
|
64
67
|
var itemStyle = style || formItemStyle;
|
|
65
|
-
return /*#__PURE__*/React.createElement(index$
|
|
68
|
+
return /*#__PURE__*/React.createElement(index$2.default, _objectSpread(_objectSpread({}, itemData), {}, {
|
|
66
69
|
labelAlign: labelAlign,
|
|
67
70
|
key: key || index,
|
|
68
71
|
style: itemStyle,
|
|
@@ -59,6 +59,13 @@ var useChange = function useChange(_ref) {
|
|
|
59
59
|
onChange: onChange,
|
|
60
60
|
value: value
|
|
61
61
|
});
|
|
62
|
+
var checkGo = function checkGo(errList) {
|
|
63
|
+
var len = errList.length;
|
|
64
|
+
if (len) {
|
|
65
|
+
antd.message.error(errList[0].message);
|
|
66
|
+
}
|
|
67
|
+
return !(maxCount === 1 && len > 0);
|
|
68
|
+
};
|
|
62
69
|
var _useRequest = ahooks.useRequest(/*#__PURE__*/function () {
|
|
63
70
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
|
|
64
71
|
var fileList, _matchFile, addFile, newFileList, errList, changeFile;
|
|
@@ -74,9 +81,12 @@ var useChange = function useChange(_ref) {
|
|
|
74
81
|
return _context.abrupt("return");
|
|
75
82
|
case 4:
|
|
76
83
|
_matchFile = matchFile(fileList, value, exFiles, maxSize), addFile = _matchFile.addFile, newFileList = _matchFile.fileList, errList = _matchFile.errList;
|
|
77
|
-
if (errList
|
|
78
|
-
|
|
84
|
+
if (checkGo(errList)) {
|
|
85
|
+
_context.next = 7;
|
|
86
|
+
break;
|
|
79
87
|
}
|
|
88
|
+
return _context.abrupt("return");
|
|
89
|
+
case 7:
|
|
80
90
|
changeFile = newFileList === null || newFileList === void 0 ? void 0 : newFileList.map(function (item) {
|
|
81
91
|
return _objectSpread({
|
|
82
92
|
thumbUrl: thumbUrl
|
|
@@ -84,7 +94,7 @@ var useChange = function useChange(_ref) {
|
|
|
84
94
|
});
|
|
85
95
|
onChange === null || onChange === void 0 || onChange(changeFile);
|
|
86
96
|
customRequest$1(addFile);
|
|
87
|
-
case
|
|
97
|
+
case 10:
|
|
88
98
|
case "end":
|
|
89
99
|
return _context.stop();
|
|
90
100
|
}
|
package/lib/index.css
CHANGED
|
@@ -160,6 +160,12 @@
|
|
|
160
160
|
.ant-hw-form-form-item .ant-form-item-label {
|
|
161
161
|
overflow: visible;
|
|
162
162
|
}
|
|
163
|
+
.ant-hw-form-item-row .ant-form-item-control-input-content > .ant-space-vertical {
|
|
164
|
+
display: -webkit-box;
|
|
165
|
+
display: -webkit-flex;
|
|
166
|
+
display: -ms-flexbox;
|
|
167
|
+
display: flex;
|
|
168
|
+
}
|
|
163
169
|
.ant-hw-input-group .ant-hw-input-group-disabled {
|
|
164
170
|
background-color: #f5f5f5;
|
|
165
171
|
}
|
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ import { Row } from "antd";
|
|
|
8
8
|
import { useFormContext } from "./Context";
|
|
9
9
|
import useInitConfigData from "./hooks/useInitConfigData";
|
|
10
10
|
import { useEffect } from "react";
|
|
11
|
+
import {useClassName} from "../hooks";
|
|
11
12
|
|
|
12
13
|
export default ({
|
|
13
14
|
configData,
|
|
@@ -28,6 +29,7 @@ export default ({
|
|
|
28
29
|
configData,
|
|
29
30
|
form,
|
|
30
31
|
});
|
|
32
|
+
const rowClassname=useClassName("hw-form-item-row");
|
|
31
33
|
useEffect(() => {
|
|
32
34
|
setData?.(dispatchSourceData);
|
|
33
35
|
}, []);
|
|
@@ -36,7 +38,7 @@ export default ({
|
|
|
36
38
|
};
|
|
37
39
|
const globalItemSpan = itemSpan || formItemSpan;
|
|
38
40
|
return (
|
|
39
|
-
<Row gutter={gutter} style={{ width: "100%" }}>
|
|
41
|
+
<Row gutter={gutter} style={{ width: "100%" }} className={rowClassname}>
|
|
40
42
|
{newConfigData.map((itemData: HItemProps, index) => {
|
|
41
43
|
const {
|
|
42
44
|
labelWidth: itemLabelWidth = labelWidth,
|
|
@@ -10,7 +10,6 @@ const checkFile = (item: UploadFile, oldFile: UploadFile[] = []) => {
|
|
|
10
10
|
return item.uid !== oldItem.uid;
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
|
-
|
|
14
13
|
const matchFile = (
|
|
15
14
|
newFile: UploadFile[],
|
|
16
15
|
oldFile: UploadFile[] = [],
|
|
@@ -53,7 +52,14 @@ export const useChange = ({
|
|
|
53
52
|
thumbUrl,
|
|
54
53
|
}: IUpLoadProps) => {
|
|
55
54
|
const customRequest = useCustomRequest({ request, onChange, value });
|
|
55
|
+
const checkGo=(errList:Error[])=>{
|
|
56
|
+
const len=errList.length;
|
|
57
|
+
if (len) {
|
|
58
|
+
message.error(errList[0].message);
|
|
59
|
+
}
|
|
60
|
+
return !(maxCount === 1 && len > 0);//为1时存在错误不调用onChange
|
|
56
61
|
|
|
62
|
+
}
|
|
57
63
|
const { run } = useRequest(
|
|
58
64
|
async ({ fileList }: UploadChangeParam<UploadFile>) => {
|
|
59
65
|
if (fileList.length > maxCount) {
|
|
@@ -65,8 +71,8 @@ export const useChange = ({
|
|
|
65
71
|
fileList: newFileList,
|
|
66
72
|
errList,
|
|
67
73
|
} = matchFile(fileList, value, exFiles, maxSize);
|
|
68
|
-
if (errList
|
|
69
|
-
|
|
74
|
+
if (!checkGo(errList)) {
|
|
75
|
+
return;
|
|
70
76
|
}
|
|
71
77
|
const changeFile = newFileList?.map((item) => {
|
|
72
78
|
return {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { HSelect } from "../../components";
|
|
2
|
-
import { Space
|
|
3
|
-
import { useState
|
|
2
|
+
import {Form, Space} from "antd";
|
|
3
|
+
import {useEffect, useState} from "react";
|
|
4
4
|
export default () => {
|
|
5
5
|
const [selectVal, setSelectVal] = useState([{ name: "11", id: -100 }]);
|
|
6
6
|
const [op, setOp] = useState([{ label: "1", value: 1 }]);
|
|
7
7
|
const [val, setVal] = useState([2, 3]);
|
|
8
|
+
|
|
8
9
|
return (
|
|
9
10
|
<Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
|
|
10
11
|
<HSelect
|