@hw-component/form 1.4.8 → 1.5.0
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/.eslintcache +1 -1
- package/es/Input/InputNumberGroup.d.ts +2 -2
- package/es/Input/InputNumberGroup.js +46 -7
- package/es/Upload/hooks/customRequest.js +11 -6
- package/lib/Input/InputNumberGroup.d.ts +2 -2
- package/lib/Input/InputNumberGroup.js +46 -7
- package/lib/Upload/hooks/customRequest.js +11 -6
- package/package.json +1 -1
- package/src/components/Form/HFormConnect.tsx +6 -7
- package/src/components/Form/config.ts +2 -3
- package/src/components/Form/hooks/useHForm.ts +10 -7
- package/src/components/Input/InputNumberGroup.tsx +141 -100
- package/src/components/Input/index.less +5 -5
- package/src/components/Select/components/AllSelect.tsx +13 -13
- package/src/components/Select/components/CheckBoxOption.tsx +3 -3
- package/src/components/Select/defaultConfig.tsx +4 -2
- package/src/components/Select/hooks/changeHooks.tsx +2 -2
- package/src/components/Switch/index.tsx +1 -1
- package/src/components/Upload/hooks/customRequest.ts +7 -3
- package/src/components/Upload/index.tsx +1 -1
- package/src/pages/Form/index.tsx +49 -38
- package/src/pages/ModalForm/index.tsx +11 -10
- package/src/pages/Select/index.tsx +1 -1
- package/src/pages/Upload/index.tsx +13 -1
|
@@ -17,7 +17,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
17
17
|
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; }
|
|
18
18
|
var subReq = /*#__PURE__*/function () {
|
|
19
19
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
20
|
-
var request, file, _yield$request, url;
|
|
20
|
+
var request, file, _yield$request, url, thumbUrl;
|
|
21
21
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
22
|
while (1) switch (_context.prev = _context.next) {
|
|
23
23
|
case 0:
|
|
@@ -37,23 +37,25 @@ var subReq = /*#__PURE__*/function () {
|
|
|
37
37
|
case 6:
|
|
38
38
|
_yield$request = _context.sent;
|
|
39
39
|
url = _yield$request.url;
|
|
40
|
+
thumbUrl = _yield$request.thumbUrl;
|
|
40
41
|
return _context.abrupt("return", {
|
|
41
42
|
url: url,
|
|
43
|
+
thumbUrl: thumbUrl,
|
|
42
44
|
status: "done"
|
|
43
45
|
});
|
|
44
|
-
case
|
|
45
|
-
_context.prev =
|
|
46
|
+
case 12:
|
|
47
|
+
_context.prev = 12;
|
|
46
48
|
_context.t0 = _context["catch"](3);
|
|
47
49
|
message.error(_context.t0.message);
|
|
48
50
|
return _context.abrupt("return", {
|
|
49
51
|
url: "",
|
|
50
52
|
status: "error"
|
|
51
53
|
});
|
|
52
|
-
case
|
|
54
|
+
case 16:
|
|
53
55
|
case "end":
|
|
54
56
|
return _context.stop();
|
|
55
57
|
}
|
|
56
|
-
}, _callee, null, [[3,
|
|
58
|
+
}, _callee, null, [[3, 12]]);
|
|
57
59
|
}));
|
|
58
60
|
return function subReq(_x) {
|
|
59
61
|
return _ref2.apply(this, arguments);
|
|
@@ -62,19 +64,22 @@ var subReq = /*#__PURE__*/function () {
|
|
|
62
64
|
var fileListProvider = function fileListProvider(changeFile, files) {
|
|
63
65
|
var status = changeFile.status,
|
|
64
66
|
url = changeFile.url,
|
|
65
|
-
uid = changeFile.uid
|
|
67
|
+
uid = changeFile.uid,
|
|
68
|
+
thumbUrl = changeFile.thumbUrl;
|
|
66
69
|
if (status === "error") {
|
|
67
70
|
return files === null || files === void 0 ? void 0 : files.filter(function (item) {
|
|
68
71
|
return item.uid !== uid;
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
74
|
return files === null || files === void 0 ? void 0 : files.map(function (item) {
|
|
75
|
+
var fileDefaultThumbUrl = item.thumbUrl || thumbUrl;
|
|
72
76
|
var resultUrl = url || item.thumbUrl;
|
|
73
77
|
if (item.uid === uid) {
|
|
74
78
|
item.status = status;
|
|
75
79
|
item.response = {
|
|
76
80
|
url: resultUrl
|
|
77
81
|
};
|
|
82
|
+
item.thumbUrl = fileDefaultThumbUrl;
|
|
78
83
|
return item;
|
|
79
84
|
}
|
|
80
85
|
return item;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { HItemProps } from "@/components/Form/modal";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { HItemProps } from "@/components/Form/modal";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
Component: React.ForwardRefExoticComponent<import("@/components/Form/modal").HFormItemProps & React.RefAttributes<any>>;
|
|
5
5
|
placeholder: ({ label }: HItemProps) => string[];
|
|
@@ -9,8 +9,16 @@ require('core-js/modules/es.object.to-string.js');
|
|
|
9
9
|
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
10
10
|
require('core-js/modules/web.dom-collections.for-each.js');
|
|
11
11
|
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
12
|
+
require('core-js/modules/es.symbol.to-primitive.js');
|
|
13
|
+
require('core-js/modules/es.date.to-primitive.js');
|
|
14
|
+
require('core-js/modules/es.symbol.description.js');
|
|
15
|
+
require('core-js/modules/es.number.constructor.js');
|
|
16
|
+
var _typeof = require('@babel/runtime-corejs3/helpers/typeof');
|
|
17
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
12
18
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
13
19
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
20
|
+
require('core-js/modules/es.function.name.js');
|
|
21
|
+
require('core-js/modules/es.array.map.js');
|
|
14
22
|
require('core-js/modules/es.array.concat.js');
|
|
15
23
|
var jsxRuntime = require('react/jsx-runtime');
|
|
16
24
|
var antd = require('antd');
|
|
@@ -19,6 +27,8 @@ var React = require('react');
|
|
|
19
27
|
var index = require('../hooks/index.js');
|
|
20
28
|
var HFormConnect = require('../Form/HFormConnect.js');
|
|
21
29
|
|
|
30
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
31
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
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; }
|
|
23
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; }
|
|
24
34
|
var useArrayProps = function useArrayProps(props) {
|
|
@@ -34,17 +44,18 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
34
44
|
value = _ref$value === void 0 ? {} : _ref$value,
|
|
35
45
|
_ref$valueMap = _ref.valueMap,
|
|
36
46
|
valueMap = _ref$valueMap === void 0 ? {
|
|
37
|
-
min:
|
|
38
|
-
max:
|
|
47
|
+
min: "min",
|
|
48
|
+
max: "max"
|
|
39
49
|
} : _ref$valueMap,
|
|
40
50
|
onChange = _ref.onChange,
|
|
41
51
|
_ref$placeholder = _ref.placeholder,
|
|
42
|
-
placeholder = _ref$placeholder === void 0 ? [
|
|
52
|
+
placeholder = _ref$placeholder === void 0 ? ["请输入", "请输入"] : _ref$placeholder,
|
|
43
53
|
_ref$inputNumberProps = _ref.inputNumberProps,
|
|
44
54
|
inputNumberProps = _ref$inputNumberProps === void 0 ? {} : _ref$inputNumberProps,
|
|
45
55
|
addonAfter = _ref.addonAfter,
|
|
46
56
|
_ref$noHandlerWrap = _ref.noHandlerWrap,
|
|
47
|
-
noHandlerWrap = _ref$noHandlerWrap === void 0 ? true : _ref$noHandlerWrap
|
|
57
|
+
noHandlerWrap = _ref$noHandlerWrap === void 0 ? true : _ref$noHandlerWrap,
|
|
58
|
+
addFormat = _ref.addFormat;
|
|
48
59
|
var min = valueMap.min,
|
|
49
60
|
max = valueMap.max;
|
|
50
61
|
var minVal = value[min],
|
|
@@ -68,6 +79,34 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
68
79
|
var oneClassname = index.useClassName(["hw-input-group-one"]);
|
|
69
80
|
var iconClassname = index.useClassName(["hw-input-group-icon"]);
|
|
70
81
|
var noHandlerWrapClassname = index.useClassName(["hw-input-group-no-handler-wrap"]);
|
|
82
|
+
addFormat === null || addFormat === void 0 || addFormat({
|
|
83
|
+
float: {
|
|
84
|
+
inputValue: function inputValue(item, initValue) {
|
|
85
|
+
var _objectSpread2;
|
|
86
|
+
var _item$name = item.name,
|
|
87
|
+
valueName = _item$name === void 0 ? "" : _item$name;
|
|
88
|
+
var minKey = valueMap.min,
|
|
89
|
+
maxKey = valueMap.max;
|
|
90
|
+
var cuValue = initValue[valueName];
|
|
91
|
+
var minInitVal = initValue[minKey];
|
|
92
|
+
var maxInitVal = initValue[maxKey];
|
|
93
|
+
return _defineProperty({}, valueName, _objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, min, minInitVal), _defineProperty(_objectSpread2, max, maxInitVal), _objectSpread2), cuValue));
|
|
94
|
+
},
|
|
95
|
+
outputValue: function outputValue(item, _outputValue) {
|
|
96
|
+
var _ref3;
|
|
97
|
+
var _item$name2 = item.name,
|
|
98
|
+
valueName = _item$name2 === void 0 ? "" : _item$name2;
|
|
99
|
+
var _outputValue$valueNam = _outputValue[valueName],
|
|
100
|
+
itemVal = _outputValue$valueNam === void 0 ? {} : _outputValue$valueNam;
|
|
101
|
+
var minKey = valueMap.min,
|
|
102
|
+
maxKey = valueMap.max;
|
|
103
|
+
var minSubVal = itemVal[minKey],
|
|
104
|
+
maxSubVal = itemVal[maxKey],
|
|
105
|
+
oItemVal = _objectWithoutProperties(itemVal, [minKey, maxKey].map(_toPropertyKey));
|
|
106
|
+
return _ref3 = {}, _defineProperty(_ref3, maxKey, maxSubVal), _defineProperty(_ref3, minKey, minSubVal), _defineProperty(_ref3, valueName, oItemVal), _ref3;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
71
110
|
var change = function change(key, val) {
|
|
72
111
|
var newVal = _objectSpread({}, value);
|
|
73
112
|
newVal[key] = val;
|
|
@@ -80,7 +119,7 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
80
119
|
value: value,
|
|
81
120
|
onChange: onChange
|
|
82
121
|
}) : addonAfter, jsxRuntime.jsxs("div", {
|
|
83
|
-
className: "".concat(bodyClassname, " ").concat(focus ? activeClassname :
|
|
122
|
+
className: "".concat(bodyClassname, " ").concat(focus ? activeClassname : "", " ").concat(noHandlerWrap ? noHandlerWrapClassname : ""),
|
|
84
123
|
children: [jsxRuntime.jsx("span", {
|
|
85
124
|
className: borderClassname
|
|
86
125
|
}), jsxRuntime.jsx(antd.InputNumber, _objectSpread({
|
|
@@ -123,8 +162,8 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
123
162
|
var Index = HFormConnect.default(InputNumberGroup);
|
|
124
163
|
var HInputNumberGroup = {
|
|
125
164
|
Component: Index,
|
|
126
|
-
placeholder: function placeholder(
|
|
127
|
-
var label =
|
|
165
|
+
placeholder: function placeholder(_ref4) {
|
|
166
|
+
var label = _ref4.label;
|
|
128
167
|
return ["\u8BF7\u8F93\u5165".concat(label, "\u6700\u5C0F\u503C"), "\u8BF7\u8F93\u5165".concat(label, "\u6700\u5927\u503C")];
|
|
129
168
|
}
|
|
130
169
|
};
|
|
@@ -18,7 +18,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
18
18
|
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; }
|
|
19
19
|
var subReq = /*#__PURE__*/function () {
|
|
20
20
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
21
|
-
var request, file, _yield$request, url;
|
|
21
|
+
var request, file, _yield$request, url, thumbUrl;
|
|
22
22
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
23
23
|
while (1) switch (_context.prev = _context.next) {
|
|
24
24
|
case 0:
|
|
@@ -38,23 +38,25 @@ var subReq = /*#__PURE__*/function () {
|
|
|
38
38
|
case 6:
|
|
39
39
|
_yield$request = _context.sent;
|
|
40
40
|
url = _yield$request.url;
|
|
41
|
+
thumbUrl = _yield$request.thumbUrl;
|
|
41
42
|
return _context.abrupt("return", {
|
|
42
43
|
url: url,
|
|
44
|
+
thumbUrl: thumbUrl,
|
|
43
45
|
status: "done"
|
|
44
46
|
});
|
|
45
|
-
case
|
|
46
|
-
_context.prev =
|
|
47
|
+
case 12:
|
|
48
|
+
_context.prev = 12;
|
|
47
49
|
_context.t0 = _context["catch"](3);
|
|
48
50
|
antd.message.error(_context.t0.message);
|
|
49
51
|
return _context.abrupt("return", {
|
|
50
52
|
url: "",
|
|
51
53
|
status: "error"
|
|
52
54
|
});
|
|
53
|
-
case
|
|
55
|
+
case 16:
|
|
54
56
|
case "end":
|
|
55
57
|
return _context.stop();
|
|
56
58
|
}
|
|
57
|
-
}, _callee, null, [[3,
|
|
59
|
+
}, _callee, null, [[3, 12]]);
|
|
58
60
|
}));
|
|
59
61
|
return function subReq(_x) {
|
|
60
62
|
return _ref2.apply(this, arguments);
|
|
@@ -63,19 +65,22 @@ var subReq = /*#__PURE__*/function () {
|
|
|
63
65
|
var fileListProvider = function fileListProvider(changeFile, files) {
|
|
64
66
|
var status = changeFile.status,
|
|
65
67
|
url = changeFile.url,
|
|
66
|
-
uid = changeFile.uid
|
|
68
|
+
uid = changeFile.uid,
|
|
69
|
+
thumbUrl = changeFile.thumbUrl;
|
|
67
70
|
if (status === "error") {
|
|
68
71
|
return files === null || files === void 0 ? void 0 : files.filter(function (item) {
|
|
69
72
|
return item.uid !== uid;
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
return files === null || files === void 0 ? void 0 : files.map(function (item) {
|
|
76
|
+
var fileDefaultThumbUrl = item.thumbUrl || thumbUrl;
|
|
73
77
|
var resultUrl = url || item.thumbUrl;
|
|
74
78
|
if (item.uid === uid) {
|
|
75
79
|
item.status = status;
|
|
76
80
|
item.response = {
|
|
77
81
|
url: resultUrl
|
|
78
82
|
};
|
|
83
|
+
item.thumbUrl = fileDefaultThumbUrl;
|
|
79
84
|
return item;
|
|
80
85
|
}
|
|
81
86
|
return item;
|
package/package.json
CHANGED
|
@@ -43,26 +43,25 @@ export default (
|
|
|
43
43
|
props: HFormItemProps,
|
|
44
44
|
ref
|
|
45
45
|
) => {
|
|
46
|
-
|
|
47
46
|
const { form, valueType = "float" } = useFormContext();
|
|
48
47
|
|
|
49
48
|
useEffect(() => {
|
|
50
|
-
const {name}=props;
|
|
51
|
-
if (!name){
|
|
49
|
+
const { name } = props;
|
|
50
|
+
if (!name) {
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
53
|
form?.addFormat(name, formatMaker(props, format[valueType]));
|
|
55
54
|
}, [valueType, props]);
|
|
56
55
|
const addFormat = (aFormat: Record<string, addFormatItemModal>) => {
|
|
57
|
-
const {name}=props;
|
|
58
|
-
if (!name){
|
|
56
|
+
const { name } = props;
|
|
57
|
+
if (!name) {
|
|
59
58
|
return;
|
|
60
59
|
}
|
|
61
60
|
form?.addFormat(name, formatMaker(props, aFormat[valueType]));
|
|
62
61
|
};
|
|
63
62
|
const addDispatchListener = (key: string, fn: argsFn) => {
|
|
64
|
-
const { name
|
|
65
|
-
if (!name){
|
|
63
|
+
const { name, dispatch } = props;
|
|
64
|
+
if (!name) {
|
|
66
65
|
return;
|
|
67
66
|
}
|
|
68
67
|
form?.addDispatchListener({ key, name, dispatch }, fn);
|
|
@@ -19,7 +19,7 @@ import Cascader from "../Cascader";
|
|
|
19
19
|
import VerificationCodeInput from "../Input/VerificationCodeInput";
|
|
20
20
|
import TrimInput from "../Input/TrimInput";
|
|
21
21
|
import TrimTextArea from "../TextArea/TrimTextArea";
|
|
22
|
-
import HInputNumberGroup from
|
|
22
|
+
import HInputNumberGroup from "../Input/InputNumberGroup";
|
|
23
23
|
export const placeholderConfig = {
|
|
24
24
|
inputType: [
|
|
25
25
|
"input",
|
|
@@ -29,7 +29,7 @@ export const placeholderConfig = {
|
|
|
29
29
|
"verificationCodeInput",
|
|
30
30
|
"trimInput",
|
|
31
31
|
"urlUpload",
|
|
32
|
-
"textArea"
|
|
32
|
+
"textArea",
|
|
33
33
|
],
|
|
34
34
|
selectType: ["select", "datePicker", "timePicker", "colorInput"],
|
|
35
35
|
};
|
|
@@ -56,7 +56,6 @@ const componentConfig = {
|
|
|
56
56
|
trimInput: TrimInput,
|
|
57
57
|
trimTextArea: TrimTextArea,
|
|
58
58
|
inputNumberGroup: HInputNumberGroup,
|
|
59
|
-
|
|
60
59
|
};
|
|
61
60
|
|
|
62
61
|
export default componentConfig;
|
|
@@ -157,13 +157,16 @@ export default () => {
|
|
|
157
157
|
form.setFieldsValue(newValue);
|
|
158
158
|
},
|
|
159
159
|
validateFields(nameList) {
|
|
160
|
-
return new Promise((resolve,reject) => {
|
|
161
|
-
form
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
return new Promise((resolve, reject) => {
|
|
161
|
+
form
|
|
162
|
+
.validateFields(nameList)
|
|
163
|
+
.then((value) => {
|
|
164
|
+
const result = this.formatValues(value, "outputValue");
|
|
165
|
+
return resolve(result);
|
|
166
|
+
})
|
|
167
|
+
.catch((e) => {
|
|
168
|
+
reject(e);
|
|
169
|
+
});
|
|
167
170
|
});
|
|
168
171
|
},
|
|
169
172
|
resetFieldsInitValue: () => {
|
|
@@ -1,108 +1,149 @@
|
|
|
1
|
-
import { InputNumber, Input } from
|
|
2
|
-
import { SwapRightOutlined } from
|
|
3
|
-
import React, { useMemo, useState } from
|
|
4
|
-
import type { InputNumberProps } from
|
|
1
|
+
import { InputNumber, Input } from "antd";
|
|
2
|
+
import { SwapRightOutlined } from "@ant-design/icons";
|
|
3
|
+
import React, { useMemo, useState } from "react";
|
|
4
|
+
import type { InputNumberProps } from "antd/lib/input-number";
|
|
5
5
|
import { useClassName } from "../hooks";
|
|
6
|
-
import {addFormatItemModal, HItemProps} from "@/components/Form/modal";
|
|
6
|
+
import type { addFormatItemModal, HItemProps } from "@/components/Form/modal";
|
|
7
7
|
import HFormConnect from "../Form/HFormConnect";
|
|
8
8
|
|
|
9
|
-
interface IProps<T=any> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
interface IProps<T = any> {
|
|
10
|
+
placeholder?: [string, string] | string;
|
|
11
|
+
addonAfter?: React.ReactNode;
|
|
12
|
+
valueMap?: {
|
|
13
|
+
min: string;
|
|
14
|
+
max: string;
|
|
15
|
+
};
|
|
16
|
+
inputNumberProps?: [InputNumberProps, InputNumberProps] | InputNumberProps;
|
|
17
|
+
value?: T;
|
|
18
|
+
onChange: (value: T) => void;
|
|
19
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
20
|
+
noHandlerWrap?: boolean;
|
|
21
21
|
}
|
|
22
22
|
const useArrayProps = (props: any) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
return useMemo(() => {
|
|
24
|
+
if (Array.isArray(props)) {
|
|
25
|
+
return props;
|
|
26
|
+
}
|
|
27
|
+
return [props, props];
|
|
28
|
+
}, [props]);
|
|
29
29
|
};
|
|
30
|
-
const InputNumberGroup=({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
30
|
+
const InputNumberGroup = ({
|
|
31
|
+
value = {},
|
|
32
|
+
valueMap = { min: "min", max: "max" },
|
|
33
|
+
onChange,
|
|
34
|
+
placeholder = ["请输入", "请输入"],
|
|
35
|
+
inputNumberProps = {},
|
|
36
|
+
addonAfter,
|
|
37
|
+
noHandlerWrap = true,
|
|
38
|
+
addFormat,
|
|
39
|
+
}: IProps) => {
|
|
40
|
+
const { min, max } = valueMap;
|
|
41
|
+
const { [min]: minVal, [max]: maxVal } = value;
|
|
42
|
+
const [fsPlaceholder, edPlaceholder] = useArrayProps(placeholder);
|
|
43
|
+
const [fsProps, edProps] = useArrayProps(inputNumberProps);
|
|
44
|
+
const [focus, setFocus] = useState(false);
|
|
45
|
+
const contentClassname = useClassName(["hw-input-group"]);
|
|
46
|
+
const bodyClassname = useClassName(["hw-input-group-body"]);
|
|
47
|
+
const activeClassname = useClassName(["hw-input-group-active"]);
|
|
48
|
+
const borderClassname = useClassName(["hw-input-group-border"]);
|
|
49
|
+
const oneClassname = useClassName(["hw-input-group-one"]);
|
|
50
|
+
const iconClassname = useClassName(["hw-input-group-icon"]);
|
|
51
|
+
const noHandlerWrapClassname = useClassName([
|
|
52
|
+
"hw-input-group-no-handler-wrap",
|
|
53
|
+
]);
|
|
54
|
+
addFormat?.({
|
|
55
|
+
float: {
|
|
56
|
+
inputValue: (item, initValue) => {
|
|
57
|
+
const { name: valueName = "" } = item;
|
|
58
|
+
const { min: minKey, max: maxKey } = valueMap;
|
|
59
|
+
const cuValue = initValue[valueName];
|
|
60
|
+
const minInitVal = initValue[minKey];
|
|
61
|
+
const maxInitVal = initValue[maxKey];
|
|
62
|
+
return {
|
|
63
|
+
[valueName]: {
|
|
64
|
+
[min]: minInitVal,
|
|
65
|
+
[max]: maxInitVal,
|
|
66
|
+
...cuValue,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
outputValue: (item, outputValue) => {
|
|
71
|
+
const { name: valueName = "" } = item;
|
|
72
|
+
const { [valueName]: itemVal = {} } = outputValue;
|
|
73
|
+
const { min: minKey, max: maxKey } = valueMap;
|
|
74
|
+
const {
|
|
75
|
+
[minKey]: minSubVal,
|
|
76
|
+
[maxKey]: maxSubVal,
|
|
77
|
+
...oItemVal
|
|
78
|
+
} = itemVal;
|
|
79
|
+
return {
|
|
80
|
+
[maxKey]: maxSubVal,
|
|
81
|
+
[minKey]: minSubVal,
|
|
82
|
+
[valueName]: oItemVal,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
const change = (key: string, val: number | null) => {
|
|
88
|
+
const newVal = { ...value };
|
|
89
|
+
newVal[key] = val;
|
|
90
|
+
onChange?.(newVal);
|
|
91
|
+
};
|
|
92
|
+
return (
|
|
93
|
+
<Input.Group compact className={contentClassname}>
|
|
94
|
+
{addonAfter
|
|
95
|
+
? React.cloneElement(addonAfter as any, { value, onChange })
|
|
96
|
+
: addonAfter}
|
|
97
|
+
<div
|
|
98
|
+
className={`${bodyClassname} ${focus ? activeClassname : ""} ${
|
|
99
|
+
noHandlerWrap ? noHandlerWrapClassname : ""
|
|
100
|
+
}`}
|
|
101
|
+
>
|
|
102
|
+
<span className={borderClassname} />
|
|
103
|
+
<InputNumber<number>
|
|
104
|
+
bordered={false}
|
|
105
|
+
value={minVal}
|
|
106
|
+
max={maxVal}
|
|
107
|
+
min={0}
|
|
108
|
+
className={oneClassname}
|
|
109
|
+
onFocus={() => {
|
|
110
|
+
setFocus(true);
|
|
111
|
+
}}
|
|
112
|
+
onBlur={() => {
|
|
113
|
+
setFocus(false);
|
|
114
|
+
}}
|
|
115
|
+
onChange={(val) => {
|
|
116
|
+
change(min, val);
|
|
117
|
+
}}
|
|
118
|
+
placeholder={fsPlaceholder}
|
|
119
|
+
{...fsProps}
|
|
120
|
+
/>
|
|
121
|
+
<SwapRightOutlined className={iconClassname} />
|
|
122
|
+
<InputNumber<number>
|
|
123
|
+
bordered={false}
|
|
124
|
+
value={maxVal}
|
|
125
|
+
className={oneClassname}
|
|
126
|
+
placeholder={edPlaceholder}
|
|
127
|
+
min={minVal}
|
|
128
|
+
onFocus={() => {
|
|
129
|
+
setFocus(true);
|
|
130
|
+
}}
|
|
131
|
+
onBlur={() => {
|
|
132
|
+
setFocus(false);
|
|
133
|
+
}}
|
|
134
|
+
onChange={(val) => {
|
|
135
|
+
change(max, val);
|
|
136
|
+
}}
|
|
137
|
+
{...edProps}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
</Input.Group>
|
|
141
|
+
);
|
|
101
142
|
};
|
|
102
|
-
const Index=HFormConnect(InputNumberGroup)
|
|
143
|
+
const Index = HFormConnect(InputNumberGroup);
|
|
103
144
|
export default {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
};
|
|
145
|
+
Component: Index,
|
|
146
|
+
placeholder: ({ label }: HItemProps) => {
|
|
147
|
+
return [`请输入${label}最小值`, `请输入${label}最大值`];
|
|
148
|
+
},
|
|
149
|
+
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
align-items: center;
|
|
6
6
|
width: 100%;
|
|
7
7
|
color: rgba(0, 0, 0, 0.25);
|
|
8
|
-
.@{all-input-group}-body{
|
|
8
|
+
.@{all-input-group}-body {
|
|
9
9
|
position: relative;
|
|
10
10
|
display: flex !important;
|
|
11
11
|
flex: 1;
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
display: none;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
.@{all-input-group}-border{
|
|
29
|
+
.@{all-input-group}-border {
|
|
30
30
|
position: absolute;
|
|
31
31
|
left: -1px;
|
|
32
32
|
display: none;
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
height: 100%;
|
|
35
35
|
background-color: #40a9ff;
|
|
36
36
|
}
|
|
37
|
-
.@{all-input-group}-icon{
|
|
37
|
+
.@{all-input-group}-icon {
|
|
38
38
|
padding: 0 4px;
|
|
39
39
|
}
|
|
40
|
-
.@{all-input-group}-one{
|
|
40
|
+
.@{all-input-group}-one {
|
|
41
41
|
flex: 1;
|
|
42
42
|
}
|
|
43
|
-
.@{all-input-group}-active{
|
|
43
|
+
.@{all-input-group}-active {
|
|
44
44
|
border-color: #40a9ff;
|
|
45
45
|
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
|
46
46
|
}
|