@hw-component/form 1.7.7 → 1.8.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/Form/Basic.d.ts +1 -1
- package/es/Input/InputNumberGroup.js +15 -7
- package/es/Select/hooks/changeHooks.js +52 -8
- package/es/index.css +15 -11
- package/lib/Form/Basic.d.ts +1 -1
- package/lib/Input/InputNumberGroup.js +15 -7
- package/lib/Select/hooks/changeHooks.js +52 -8
- package/lib/index.css +15 -11
- package/package.json +1 -1
- package/src/components/Form/Basic.tsx +3 -2
- package/src/components/Form/FormItem/hooks.tsx +1 -1
- package/src/components/Form/modal.ts +5 -5
- package/src/components/Input/InputNumberGroup.tsx +15 -4
- package/src/components/Input/index.less +11 -2
- package/src/components/Select/hooks/changeHooks.tsx +35 -9
- package/src/pages/Form/index.tsx +79 -70
- package/src/pages/Input/index.tsx +2 -0
- package/src/pages/Select/index.tsx +12 -61
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
2
4
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
3
5
|
import 'core-js/modules/es.array.map.js';
|
|
6
|
+
import 'core-js/modules/es.object.keys.js';
|
|
7
|
+
import 'core-js/modules/es.symbol.js';
|
|
8
|
+
import 'core-js/modules/es.array.filter.js';
|
|
9
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
10
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
11
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
12
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
4
13
|
import { useState, useEffect } from 'react';
|
|
5
14
|
import { itemOpProvider } from '../utils.js';
|
|
6
15
|
import { matchNotFind } from './util.js';
|
|
7
16
|
|
|
17
|
+
var _excluded = ["label", "value"];
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
8
20
|
var useValueChange = function useValueChange(params) {
|
|
9
21
|
var labelInValue = params.labelInValue,
|
|
10
22
|
onChange = params.onChange,
|
|
@@ -18,6 +30,28 @@ var useValueChange = function useValueChange(params) {
|
|
|
18
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
19
31
|
val = _useState2[0],
|
|
20
32
|
setVal = _useState2[1];
|
|
33
|
+
var labelInValueItemMaker = function labelInValueItemMaker(changeVal) {
|
|
34
|
+
var _objectSpread2;
|
|
35
|
+
var _fieldNames$value = fieldNames.value,
|
|
36
|
+
fieldValue = _fieldNames$value === void 0 ? "value" : _fieldNames$value,
|
|
37
|
+
_fieldNames$label = fieldNames.label,
|
|
38
|
+
fieldLabel = _fieldNames$label === void 0 ? "label" : _fieldNames$label;
|
|
39
|
+
var changeLabel = changeVal.label,
|
|
40
|
+
changeValue = changeVal.value,
|
|
41
|
+
oVal = _objectWithoutProperties(changeVal, _excluded);
|
|
42
|
+
return _objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, fieldValue, changeValue), _defineProperty(_objectSpread2, fieldLabel, changeLabel), _objectSpread2), oVal);
|
|
43
|
+
};
|
|
44
|
+
var labelInValueMaker = function labelInValueMaker(changeVal) {
|
|
45
|
+
if (!changeVal) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
if (!Array.isArray(changeVal)) {
|
|
49
|
+
return labelInValueItemMaker(changeVal);
|
|
50
|
+
}
|
|
51
|
+
return changeVal.map(function (item) {
|
|
52
|
+
return labelInValueItemMaker(item);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
21
55
|
var change = function change(changeVal, itemOps) {
|
|
22
56
|
if (!onChange) {
|
|
23
57
|
setVal(changeVal);
|
|
@@ -27,16 +61,17 @@ var useValueChange = function useValueChange(params) {
|
|
|
27
61
|
onChange(changeVal, itemOps);
|
|
28
62
|
return;
|
|
29
63
|
}
|
|
30
|
-
var
|
|
64
|
+
var subItemOps = itemOpProvider(itemOps, fieldNames);
|
|
31
65
|
if (labelInValue) {
|
|
32
|
-
|
|
66
|
+
onChange(labelInValueMaker(changeVal), itemOps);
|
|
67
|
+
return;
|
|
33
68
|
}
|
|
34
|
-
|
|
69
|
+
var newChangeVal = changeVal.value;
|
|
70
|
+
if (Array.isArray(changeVal) && !labelInValue) {
|
|
35
71
|
newChangeVal = changeVal.map(function (item) {
|
|
36
72
|
return item.value;
|
|
37
73
|
});
|
|
38
74
|
}
|
|
39
|
-
var subItemOps = itemOpProvider(itemOps, fieldNames);
|
|
40
75
|
onChange(newChangeVal, subItemOps);
|
|
41
76
|
};
|
|
42
77
|
useEffect(function () {
|
|
@@ -44,7 +79,7 @@ var useValueChange = function useValueChange(params) {
|
|
|
44
79
|
setVal(undefined);
|
|
45
80
|
return;
|
|
46
81
|
}
|
|
47
|
-
if (mode === "tags") {
|
|
82
|
+
if (mode === "tags" || labelInValue) {
|
|
48
83
|
setVal(value);
|
|
49
84
|
return;
|
|
50
85
|
}
|
|
@@ -58,6 +93,18 @@ var useValueChange = function useValueChange(params) {
|
|
|
58
93
|
var itemVal = item.value,
|
|
59
94
|
label = item.label,
|
|
60
95
|
noMatch = item.noMatch;
|
|
96
|
+
var _fieldNames$value2 = fieldNames.value,
|
|
97
|
+
fieldValue = _fieldNames$value2 === void 0 ? "value" : _fieldNames$value2,
|
|
98
|
+
_fieldNames$label2 = fieldNames.label,
|
|
99
|
+
fieldLabel = _fieldNames$label2 === void 0 ? "label" : _fieldNames$label2;
|
|
100
|
+
if (labelInValue) {
|
|
101
|
+
var changeVal = item[fieldValue],
|
|
102
|
+
changeLable = item[fieldLabel];
|
|
103
|
+
return {
|
|
104
|
+
value: changeVal,
|
|
105
|
+
label: changeLable
|
|
106
|
+
};
|
|
107
|
+
}
|
|
61
108
|
if (noMatch) {
|
|
62
109
|
return {
|
|
63
110
|
value: itemVal,
|
|
@@ -72,9 +119,6 @@ var useValueChange = function useValueChange(params) {
|
|
|
72
119
|
};
|
|
73
120
|
};
|
|
74
121
|
var valuesMaker = function valuesMaker() {
|
|
75
|
-
if (labelInValue) {
|
|
76
|
-
return val;
|
|
77
|
-
}
|
|
78
122
|
if (val === undefined || mode === "tags") {
|
|
79
123
|
return val;
|
|
80
124
|
}
|
package/es/index.css
CHANGED
|
@@ -83,15 +83,14 @@
|
|
|
83
83
|
.ant-hw-form-form-item .ant-form-item-label {
|
|
84
84
|
overflow: visible;
|
|
85
85
|
}
|
|
86
|
+
.ant-hw-input-group .ant-hw-input-group-disabled {
|
|
87
|
+
background-color: #f5f5f5;
|
|
88
|
+
}
|
|
86
89
|
.ant-hw-input-group {
|
|
87
90
|
display: -webkit-box !important;
|
|
88
91
|
display: -webkit-flex !important;
|
|
89
92
|
display: -ms-flexbox !important;
|
|
90
93
|
display: flex !important;
|
|
91
|
-
-webkit-box-align: center;
|
|
92
|
-
-webkit-align-items: center;
|
|
93
|
-
-ms-flex-align: center;
|
|
94
|
-
align-items: center;
|
|
95
94
|
width: 100%;
|
|
96
95
|
color: rgba(0, 0, 0, 0.25);
|
|
97
96
|
}
|
|
@@ -105,19 +104,15 @@
|
|
|
105
104
|
-webkit-flex: 1;
|
|
106
105
|
-ms-flex: 1;
|
|
107
106
|
flex: 1;
|
|
108
|
-
-webkit-box-align: center;
|
|
109
|
-
-webkit-align-items: center;
|
|
110
|
-
-ms-flex-align: center;
|
|
111
|
-
align-items: center;
|
|
112
107
|
border: 1px solid #d9d9d9;
|
|
113
108
|
}
|
|
114
|
-
.ant-hw-input-group .ant-hw-input-group-
|
|
109
|
+
.ant-hw-input-group .ant-hw-input-group-not-disabled:hover {
|
|
115
110
|
border-color: #40a9ff;
|
|
116
111
|
}
|
|
117
|
-
.ant-hw-input-group .ant-hw-input-group-
|
|
112
|
+
.ant-hw-input-group .ant-hw-input-group-not-disabled:hover .border {
|
|
118
113
|
display: block;
|
|
119
114
|
}
|
|
120
|
-
.ant-hw-input-group .ant-hw-input-group-
|
|
115
|
+
.ant-hw-input-group .ant-hw-input-group-not-disabled:active {
|
|
121
116
|
border-color: #40a9ff;
|
|
122
117
|
}
|
|
123
118
|
.ant-hw-input-group .ant-hw-input-group-no-handler-wrap .ant-input-number-handler-wrap {
|
|
@@ -132,7 +127,16 @@
|
|
|
132
127
|
background-color: #40a9ff;
|
|
133
128
|
}
|
|
134
129
|
.ant-hw-input-group .ant-hw-input-group-icon {
|
|
130
|
+
display: -webkit-box;
|
|
131
|
+
display: -webkit-flex;
|
|
132
|
+
display: -ms-flexbox;
|
|
133
|
+
display: flex;
|
|
134
|
+
-webkit-box-align: center;
|
|
135
|
+
-webkit-align-items: center;
|
|
136
|
+
-ms-flex-align: center;
|
|
137
|
+
align-items: center;
|
|
135
138
|
padding: 0 4px;
|
|
139
|
+
color: rgba(0, 0, 0, 0.25);
|
|
136
140
|
}
|
|
137
141
|
.ant-hw-input-group .ant-hw-input-group-one {
|
|
138
142
|
-webkit-box-flex: 1;
|
package/lib/Form/Basic.d.ts
CHANGED
|
@@ -55,7 +55,8 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
55
55
|
addonAfter = _ref.addonAfter,
|
|
56
56
|
_ref$noHandlerWrap = _ref.noHandlerWrap,
|
|
57
57
|
noHandlerWrap = _ref$noHandlerWrap === void 0 ? true : _ref$noHandlerWrap,
|
|
58
|
-
addFormat = _ref.addFormat
|
|
58
|
+
addFormat = _ref.addFormat,
|
|
59
|
+
disabled = _ref.disabled;
|
|
59
60
|
var min = valueMap.min,
|
|
60
61
|
max = valueMap.max;
|
|
61
62
|
var minVal = value[min],
|
|
@@ -78,6 +79,8 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
78
79
|
var borderClassname = index.useClassName(["hw-input-group-border"]);
|
|
79
80
|
var oneClassname = index.useClassName(["hw-input-group-one"]);
|
|
80
81
|
var iconClassname = index.useClassName(["hw-input-group-icon"]);
|
|
82
|
+
var disabledClassname = index.useClassName(["hw-input-group-disabled"]);
|
|
83
|
+
var notDisabledClassname = index.useClassName(["hw-input-group-not-disabled"]);
|
|
81
84
|
var noHandlerWrapClassname = index.useClassName(["hw-input-group-no-handler-wrap"]);
|
|
82
85
|
addFormat === null || addFormat === void 0 || addFormat({
|
|
83
86
|
float: {
|
|
@@ -119,10 +122,10 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
119
122
|
value: value,
|
|
120
123
|
onChange: onChange
|
|
121
124
|
}) : addonAfter, jsxRuntime.jsxs("div", {
|
|
122
|
-
className: "".concat(bodyClassname, " ").concat(focus ? activeClassname : "", " ").concat(noHandlerWrap ? noHandlerWrapClassname : ""),
|
|
125
|
+
className: "".concat(bodyClassname, " \n ").concat(focus ? activeClassname : "", " \n ").concat(noHandlerWrap ? noHandlerWrapClassname : "", "\n ").concat(disabled ? disabledClassname : notDisabledClassname, "\n "),
|
|
123
126
|
children: [jsxRuntime.jsx("span", {
|
|
124
127
|
className: borderClassname
|
|
125
|
-
}), jsxRuntime.jsx(antd.InputNumber, _objectSpread({
|
|
128
|
+
}), jsxRuntime.jsx(antd.InputNumber, _objectSpread(_objectSpread({
|
|
126
129
|
bordered: false,
|
|
127
130
|
value: minVal,
|
|
128
131
|
max: maxVal,
|
|
@@ -138,9 +141,12 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
138
141
|
change(min, val);
|
|
139
142
|
},
|
|
140
143
|
placeholder: fsPlaceholder
|
|
141
|
-
}, fsProps)
|
|
142
|
-
|
|
143
|
-
}), jsxRuntime.jsx(
|
|
144
|
+
}, fsProps), {}, {
|
|
145
|
+
disabled: disabled
|
|
146
|
+
})), jsxRuntime.jsx("div", {
|
|
147
|
+
className: iconClassname,
|
|
148
|
+
children: jsxRuntime.jsx(icons.SwapRightOutlined, {})
|
|
149
|
+
}), jsxRuntime.jsx(antd.InputNumber, _objectSpread(_objectSpread({
|
|
144
150
|
bordered: false,
|
|
145
151
|
value: maxVal,
|
|
146
152
|
className: oneClassname,
|
|
@@ -155,7 +161,9 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
155
161
|
onChange: function onChange(val) {
|
|
156
162
|
change(max, val);
|
|
157
163
|
}
|
|
158
|
-
}, edProps)
|
|
164
|
+
}, edProps), {}, {
|
|
165
|
+
disabled: disabled
|
|
166
|
+
}))]
|
|
159
167
|
})]
|
|
160
168
|
});
|
|
161
169
|
};
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
4
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
3
5
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
4
6
|
require('core-js/modules/es.array.map.js');
|
|
7
|
+
require('core-js/modules/es.object.keys.js');
|
|
8
|
+
require('core-js/modules/es.symbol.js');
|
|
9
|
+
require('core-js/modules/es.array.filter.js');
|
|
10
|
+
require('core-js/modules/es.object.to-string.js');
|
|
11
|
+
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
12
|
+
require('core-js/modules/web.dom-collections.for-each.js');
|
|
13
|
+
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
5
14
|
var React = require('react');
|
|
6
15
|
var utils = require('../utils.js');
|
|
7
16
|
var util = require('./util.js');
|
|
8
17
|
|
|
18
|
+
var _excluded = ["label", "value"];
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
9
21
|
var useValueChange = function useValueChange(params) {
|
|
10
22
|
var labelInValue = params.labelInValue,
|
|
11
23
|
onChange = params.onChange,
|
|
@@ -19,6 +31,28 @@ var useValueChange = function useValueChange(params) {
|
|
|
19
31
|
_useState2 = _slicedToArray(_useState, 2),
|
|
20
32
|
val = _useState2[0],
|
|
21
33
|
setVal = _useState2[1];
|
|
34
|
+
var labelInValueItemMaker = function labelInValueItemMaker(changeVal) {
|
|
35
|
+
var _objectSpread2;
|
|
36
|
+
var _fieldNames$value = fieldNames.value,
|
|
37
|
+
fieldValue = _fieldNames$value === void 0 ? "value" : _fieldNames$value,
|
|
38
|
+
_fieldNames$label = fieldNames.label,
|
|
39
|
+
fieldLabel = _fieldNames$label === void 0 ? "label" : _fieldNames$label;
|
|
40
|
+
var changeLabel = changeVal.label,
|
|
41
|
+
changeValue = changeVal.value,
|
|
42
|
+
oVal = _objectWithoutProperties(changeVal, _excluded);
|
|
43
|
+
return _objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, fieldValue, changeValue), _defineProperty(_objectSpread2, fieldLabel, changeLabel), _objectSpread2), oVal);
|
|
44
|
+
};
|
|
45
|
+
var labelInValueMaker = function labelInValueMaker(changeVal) {
|
|
46
|
+
if (!changeVal) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
if (!Array.isArray(changeVal)) {
|
|
50
|
+
return labelInValueItemMaker(changeVal);
|
|
51
|
+
}
|
|
52
|
+
return changeVal.map(function (item) {
|
|
53
|
+
return labelInValueItemMaker(item);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
22
56
|
var change = function change(changeVal, itemOps) {
|
|
23
57
|
if (!onChange) {
|
|
24
58
|
setVal(changeVal);
|
|
@@ -28,16 +62,17 @@ var useValueChange = function useValueChange(params) {
|
|
|
28
62
|
onChange(changeVal, itemOps);
|
|
29
63
|
return;
|
|
30
64
|
}
|
|
31
|
-
var
|
|
65
|
+
var subItemOps = utils.itemOpProvider(itemOps, fieldNames);
|
|
32
66
|
if (labelInValue) {
|
|
33
|
-
|
|
67
|
+
onChange(labelInValueMaker(changeVal), itemOps);
|
|
68
|
+
return;
|
|
34
69
|
}
|
|
35
|
-
|
|
70
|
+
var newChangeVal = changeVal.value;
|
|
71
|
+
if (Array.isArray(changeVal) && !labelInValue) {
|
|
36
72
|
newChangeVal = changeVal.map(function (item) {
|
|
37
73
|
return item.value;
|
|
38
74
|
});
|
|
39
75
|
}
|
|
40
|
-
var subItemOps = utils.itemOpProvider(itemOps, fieldNames);
|
|
41
76
|
onChange(newChangeVal, subItemOps);
|
|
42
77
|
};
|
|
43
78
|
React.useEffect(function () {
|
|
@@ -45,7 +80,7 @@ var useValueChange = function useValueChange(params) {
|
|
|
45
80
|
setVal(undefined);
|
|
46
81
|
return;
|
|
47
82
|
}
|
|
48
|
-
if (mode === "tags") {
|
|
83
|
+
if (mode === "tags" || labelInValue) {
|
|
49
84
|
setVal(value);
|
|
50
85
|
return;
|
|
51
86
|
}
|
|
@@ -59,6 +94,18 @@ var useValueChange = function useValueChange(params) {
|
|
|
59
94
|
var itemVal = item.value,
|
|
60
95
|
label = item.label,
|
|
61
96
|
noMatch = item.noMatch;
|
|
97
|
+
var _fieldNames$value2 = fieldNames.value,
|
|
98
|
+
fieldValue = _fieldNames$value2 === void 0 ? "value" : _fieldNames$value2,
|
|
99
|
+
_fieldNames$label2 = fieldNames.label,
|
|
100
|
+
fieldLabel = _fieldNames$label2 === void 0 ? "label" : _fieldNames$label2;
|
|
101
|
+
if (labelInValue) {
|
|
102
|
+
var changeVal = item[fieldValue],
|
|
103
|
+
changeLable = item[fieldLabel];
|
|
104
|
+
return {
|
|
105
|
+
value: changeVal,
|
|
106
|
+
label: changeLable
|
|
107
|
+
};
|
|
108
|
+
}
|
|
62
109
|
if (noMatch) {
|
|
63
110
|
return {
|
|
64
111
|
value: itemVal,
|
|
@@ -73,9 +120,6 @@ var useValueChange = function useValueChange(params) {
|
|
|
73
120
|
};
|
|
74
121
|
};
|
|
75
122
|
var valuesMaker = function valuesMaker() {
|
|
76
|
-
if (labelInValue) {
|
|
77
|
-
return val;
|
|
78
|
-
}
|
|
79
123
|
if (val === undefined || mode === "tags") {
|
|
80
124
|
return val;
|
|
81
125
|
}
|
package/lib/index.css
CHANGED
|
@@ -83,15 +83,14 @@
|
|
|
83
83
|
.ant-hw-form-form-item .ant-form-item-label {
|
|
84
84
|
overflow: visible;
|
|
85
85
|
}
|
|
86
|
+
.ant-hw-input-group .ant-hw-input-group-disabled {
|
|
87
|
+
background-color: #f5f5f5;
|
|
88
|
+
}
|
|
86
89
|
.ant-hw-input-group {
|
|
87
90
|
display: -webkit-box !important;
|
|
88
91
|
display: -webkit-flex !important;
|
|
89
92
|
display: -ms-flexbox !important;
|
|
90
93
|
display: flex !important;
|
|
91
|
-
-webkit-box-align: center;
|
|
92
|
-
-webkit-align-items: center;
|
|
93
|
-
-ms-flex-align: center;
|
|
94
|
-
align-items: center;
|
|
95
94
|
width: 100%;
|
|
96
95
|
color: rgba(0, 0, 0, 0.25);
|
|
97
96
|
}
|
|
@@ -105,19 +104,15 @@
|
|
|
105
104
|
-webkit-flex: 1;
|
|
106
105
|
-ms-flex: 1;
|
|
107
106
|
flex: 1;
|
|
108
|
-
-webkit-box-align: center;
|
|
109
|
-
-webkit-align-items: center;
|
|
110
|
-
-ms-flex-align: center;
|
|
111
|
-
align-items: center;
|
|
112
107
|
border: 1px solid #d9d9d9;
|
|
113
108
|
}
|
|
114
|
-
.ant-hw-input-group .ant-hw-input-group-
|
|
109
|
+
.ant-hw-input-group .ant-hw-input-group-not-disabled:hover {
|
|
115
110
|
border-color: #40a9ff;
|
|
116
111
|
}
|
|
117
|
-
.ant-hw-input-group .ant-hw-input-group-
|
|
112
|
+
.ant-hw-input-group .ant-hw-input-group-not-disabled:hover .border {
|
|
118
113
|
display: block;
|
|
119
114
|
}
|
|
120
|
-
.ant-hw-input-group .ant-hw-input-group-
|
|
115
|
+
.ant-hw-input-group .ant-hw-input-group-not-disabled:active {
|
|
121
116
|
border-color: #40a9ff;
|
|
122
117
|
}
|
|
123
118
|
.ant-hw-input-group .ant-hw-input-group-no-handler-wrap .ant-input-number-handler-wrap {
|
|
@@ -132,7 +127,16 @@
|
|
|
132
127
|
background-color: #40a9ff;
|
|
133
128
|
}
|
|
134
129
|
.ant-hw-input-group .ant-hw-input-group-icon {
|
|
130
|
+
display: -webkit-box;
|
|
131
|
+
display: -webkit-flex;
|
|
132
|
+
display: -ms-flexbox;
|
|
133
|
+
display: flex;
|
|
134
|
+
-webkit-box-align: center;
|
|
135
|
+
-webkit-align-items: center;
|
|
136
|
+
-ms-flex-align: center;
|
|
137
|
+
align-items: center;
|
|
135
138
|
padding: 0 4px;
|
|
139
|
+
color: rgba(0, 0, 0, 0.25);
|
|
136
140
|
}
|
|
137
141
|
.ant-hw-input-group .ant-hw-input-group-one {
|
|
138
142
|
-webkit-box-flex: 1;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {HFormProps, HItemProps, ItemPropsType} from "@/components/Form/modal";
|
|
1
|
+
import type {HFormProps, HItemProps, ItemPropsType} from "@/components/Form/modal";
|
|
2
2
|
import Item from "./FormItem";
|
|
3
3
|
import {Row} from "antd";
|
|
4
4
|
import {useFormContext} from "./Context";
|
|
5
5
|
import useInitConfigData from "./hooks/useInitConfigData";
|
|
6
6
|
import {useEffect} from "react";
|
|
7
7
|
|
|
8
|
-
export default ({configData,gutter}:HFormProps)=>{
|
|
8
|
+
export default ({configData,gutter}: HFormProps)=>{
|
|
9
9
|
const {form,itemProps:formItemProps,itemSpan,colon:formColon,setData}=useFormContext();
|
|
10
10
|
const { newConfigData, dispatchSourceData } = useInitConfigData({
|
|
11
11
|
configData,
|
|
@@ -33,6 +33,7 @@ export default ({configData,gutter}:HFormProps)=>{
|
|
|
33
33
|
...formItemProps,
|
|
34
34
|
...itemProps,
|
|
35
35
|
};
|
|
36
|
+
|
|
36
37
|
return (
|
|
37
38
|
<Item
|
|
38
39
|
{...itemData}
|
|
@@ -62,7 +62,7 @@ export interface HoverModal {
|
|
|
62
62
|
text?: string;
|
|
63
63
|
icon?: React.ReactNode;
|
|
64
64
|
}
|
|
65
|
-
export type HoverFn=(form: HFormInstance)=>string|HoverModal
|
|
65
|
+
export type HoverFn=(form: HFormInstance) => string|HoverModal
|
|
66
66
|
export type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
67
67
|
|
|
68
68
|
export type HideModal = (form: HFormInstance) => boolean;
|
|
@@ -133,12 +133,12 @@ export interface FormContextProps {
|
|
|
133
133
|
valueType?: string;
|
|
134
134
|
labelAlign?: LabelAlignModal;
|
|
135
135
|
labelWidth?: number;
|
|
136
|
-
formItemStyle?:React.CSSProperties;
|
|
137
|
-
hideLabel?:boolean;
|
|
138
|
-
colon?:boolean;
|
|
136
|
+
formItemStyle?: React.CSSProperties;
|
|
137
|
+
hideLabel?: boolean;
|
|
138
|
+
colon?: boolean;
|
|
139
139
|
itemProps?: ItemPropsType;
|
|
140
140
|
itemSpan?: ColProps;
|
|
141
|
-
setData?:(newData:any)=>void;
|
|
141
|
+
setData?: (newData: any) => void;
|
|
142
142
|
}
|
|
143
143
|
interface ConfigUploadProps {
|
|
144
144
|
exFiles?: string[];
|
|
@@ -18,6 +18,7 @@ interface IProps<T = any> {
|
|
|
18
18
|
onChange: (value: T) => void;
|
|
19
19
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
20
20
|
noHandlerWrap?: boolean;
|
|
21
|
+
disabled?:boolean;
|
|
21
22
|
}
|
|
22
23
|
const useArrayProps = (props: any) => {
|
|
23
24
|
return useMemo(() => {
|
|
@@ -36,6 +37,7 @@ const InputNumberGroup = ({
|
|
|
36
37
|
addonAfter,
|
|
37
38
|
noHandlerWrap = true,
|
|
38
39
|
addFormat,
|
|
40
|
+
disabled
|
|
39
41
|
}: IProps) => {
|
|
40
42
|
const { min, max } = valueMap;
|
|
41
43
|
const { [min]: minVal, [max]: maxVal } = value;
|
|
@@ -48,6 +50,9 @@ const InputNumberGroup = ({
|
|
|
48
50
|
const borderClassname = useClassName(["hw-input-group-border"]);
|
|
49
51
|
const oneClassname = useClassName(["hw-input-group-one"]);
|
|
50
52
|
const iconClassname = useClassName(["hw-input-group-icon"]);
|
|
53
|
+
const disabledClassname=useClassName(["hw-input-group-disabled"]);
|
|
54
|
+
const notDisabledClassname=useClassName(["hw-input-group-not-disabled"])
|
|
55
|
+
|
|
51
56
|
const noHandlerWrapClassname = useClassName([
|
|
52
57
|
"hw-input-group-no-handler-wrap",
|
|
53
58
|
]);
|
|
@@ -95,9 +100,11 @@ const InputNumberGroup = ({
|
|
|
95
100
|
? React.cloneElement(addonAfter as any, { value, onChange })
|
|
96
101
|
: addonAfter}
|
|
97
102
|
<div
|
|
98
|
-
className={`${bodyClassname}
|
|
99
|
-
|
|
100
|
-
}
|
|
103
|
+
className={`${bodyClassname}
|
|
104
|
+
${focus ? activeClassname : ""}
|
|
105
|
+
${noHandlerWrap ? noHandlerWrapClassname : ""}
|
|
106
|
+
${disabled?disabledClassname:notDisabledClassname}
|
|
107
|
+
`}
|
|
101
108
|
>
|
|
102
109
|
<span className={borderClassname} />
|
|
103
110
|
<InputNumber<number>
|
|
@@ -117,8 +124,11 @@ const InputNumberGroup = ({
|
|
|
117
124
|
}}
|
|
118
125
|
placeholder={fsPlaceholder}
|
|
119
126
|
{...fsProps}
|
|
127
|
+
disabled={disabled}
|
|
120
128
|
/>
|
|
121
|
-
|
|
129
|
+
<div className={iconClassname}>
|
|
130
|
+
<SwapRightOutlined />
|
|
131
|
+
</div>
|
|
122
132
|
<InputNumber<number>
|
|
123
133
|
bordered={false}
|
|
124
134
|
value={maxVal}
|
|
@@ -135,6 +145,7 @@ const InputNumberGroup = ({
|
|
|
135
145
|
change(max, val);
|
|
136
146
|
}}
|
|
137
147
|
{...edProps}
|
|
148
|
+
disabled={disabled}
|
|
138
149
|
/>
|
|
139
150
|
</div>
|
|
140
151
|
</Input.Group>
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
@import "../styles/local.less";
|
|
2
2
|
@all-input-group: ~"@{ant-prefix}-hw-input-group";
|
|
3
|
+
|
|
4
|
+
.@{all-input-group} {
|
|
5
|
+
.@{all-input-group}-disabled {
|
|
6
|
+
background-color: #f5f5f5;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
3
9
|
.@{all-input-group} {
|
|
4
10
|
display: flex !important;
|
|
5
|
-
align-items: center;
|
|
6
11
|
width: 100%;
|
|
7
12
|
color: rgba(0, 0, 0, 0.25);
|
|
8
13
|
.@{all-input-group}-body {
|
|
9
14
|
position: relative;
|
|
10
15
|
display: flex !important;
|
|
11
16
|
flex: 1;
|
|
12
|
-
align-items: center;
|
|
13
17
|
border: 1px solid #d9d9d9;
|
|
18
|
+
}
|
|
19
|
+
.@{all-input-group}-not-disabled {
|
|
14
20
|
&:hover {
|
|
15
21
|
border-color: #40a9ff;
|
|
16
22
|
.border {
|
|
@@ -35,7 +41,10 @@
|
|
|
35
41
|
background-color: #40a9ff;
|
|
36
42
|
}
|
|
37
43
|
.@{all-input-group}-icon {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
38
46
|
padding: 0 4px;
|
|
47
|
+
color:rgba(0, 0, 0, 0.25);
|
|
39
48
|
}
|
|
40
49
|
.@{all-input-group}-one {
|
|
41
50
|
flex: 1;
|
|
@@ -13,7 +13,26 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
13
13
|
fieldNames = {},
|
|
14
14
|
} = params;
|
|
15
15
|
const [val, setVal] = useState<any>();
|
|
16
|
-
|
|
16
|
+
const labelInValueItemMaker=(changeVal)=>{
|
|
17
|
+
const {value:fieldValue="value",label:fieldLabel="label"}=fieldNames;
|
|
18
|
+
const {label:changeLabel,value:changeValue,...oVal}=changeVal;
|
|
19
|
+
return {
|
|
20
|
+
[fieldValue]:changeValue,
|
|
21
|
+
[fieldLabel]:changeLabel,
|
|
22
|
+
...oVal
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const labelInValueMaker=(changeVal)=>{
|
|
26
|
+
if (!changeVal){
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
if (!Array.isArray(changeVal)){
|
|
30
|
+
return labelInValueItemMaker(changeVal)
|
|
31
|
+
}
|
|
32
|
+
return changeVal.map((item)=>{
|
|
33
|
+
return labelInValueItemMaker(item)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
17
36
|
const change = (changeVal, itemOps) => {
|
|
18
37
|
if (!onChange) {
|
|
19
38
|
setVal(changeVal);
|
|
@@ -23,16 +42,17 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
23
42
|
onChange(changeVal, itemOps);
|
|
24
43
|
return;
|
|
25
44
|
}
|
|
26
|
-
|
|
45
|
+
const subItemOps = itemOpProvider(itemOps, fieldNames);
|
|
27
46
|
if (labelInValue) {
|
|
28
|
-
|
|
47
|
+
onChange(labelInValueMaker(changeVal),itemOps);
|
|
48
|
+
return;
|
|
29
49
|
}
|
|
30
|
-
|
|
50
|
+
let newChangeVal = changeVal.value;
|
|
51
|
+
if (Array.isArray(changeVal)&&!labelInValue) {
|
|
31
52
|
newChangeVal = changeVal.map((item) => {
|
|
32
53
|
return item.value;
|
|
33
54
|
});
|
|
34
55
|
}
|
|
35
|
-
const subItemOps = itemOpProvider(itemOps, fieldNames);
|
|
36
56
|
onChange(newChangeVal, subItemOps);
|
|
37
57
|
};
|
|
38
58
|
useEffect(() => {
|
|
@@ -40,10 +60,11 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
40
60
|
setVal(undefined);
|
|
41
61
|
return;
|
|
42
62
|
}
|
|
43
|
-
if (mode === "tags") {
|
|
63
|
+
if (mode === "tags"||labelInValue) {
|
|
44
64
|
setVal(value);
|
|
45
65
|
return;
|
|
46
66
|
}
|
|
67
|
+
|
|
47
68
|
if (options) {
|
|
48
69
|
setVal((oldVale) => {
|
|
49
70
|
return matchNotFind(params, oldVale);
|
|
@@ -52,6 +73,14 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
52
73
|
}, [value, options, mode]);
|
|
53
74
|
const itemMaker = (item) => {
|
|
54
75
|
const { value: itemVal, label, noMatch } = item;
|
|
76
|
+
const {value:fieldValue="value",label:fieldLabel="label"}=fieldNames;
|
|
77
|
+
if (labelInValue){
|
|
78
|
+
const {[fieldValue]:changeVal,[fieldLabel]:changeLable}=item;
|
|
79
|
+
return {
|
|
80
|
+
value:changeVal,
|
|
81
|
+
label: changeLable
|
|
82
|
+
};
|
|
83
|
+
}
|
|
55
84
|
if (noMatch) {
|
|
56
85
|
return {
|
|
57
86
|
value: itemVal,
|
|
@@ -64,9 +93,6 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
64
93
|
};
|
|
65
94
|
};
|
|
66
95
|
const valuesMaker = () => {
|
|
67
|
-
if (labelInValue) {
|
|
68
|
-
return val;
|
|
69
|
-
}
|
|
70
96
|
if (val === undefined || mode === "tags") {
|
|
71
97
|
return val;
|
|
72
98
|
}
|