ztxkui 2.7.0 → 2.7.1
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/dist/DemoCom/BasicDemo.js +1 -1
- package/dist/DemoCom/TableDemo.js +8 -6
- package/dist/components/InputNumber/input-number.d.ts +12 -0
- package/dist/components/InputNumber/input-number.js +34 -3
- package/dist/components/Table/table-enhance-cell.d.ts +4 -0
- package/dist/components/Table/table-enhance-cell.js +17 -4
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ function BasicDemo() {
|
|
|
7
7
|
React.createElement(InputNumber, { value: value, onChange: function (value) {
|
|
8
8
|
console.log(value);
|
|
9
9
|
setValue(value);
|
|
10
|
-
}, formatterType: "percent" }),
|
|
10
|
+
}, min: 0, max: 10, formatterType: "percent" }),
|
|
11
11
|
React.createElement("div", null,
|
|
12
12
|
React.createElement(Tag, null, "\u4F60\u597D"),
|
|
13
13
|
React.createElement(Tag, { type: "normal" }, "\u4F60\u597D"),
|
|
@@ -568,14 +568,16 @@ var TableDemo = function () {
|
|
|
568
568
|
type: 'inputNumber',
|
|
569
569
|
// min: 0,
|
|
570
570
|
minHandle: function (record) {
|
|
571
|
-
return
|
|
572
|
-
|
|
573
|
-
|
|
571
|
+
return 0;
|
|
572
|
+
},
|
|
573
|
+
overMaxTip: function (record, index) {
|
|
574
|
+
return "\u7B2C" + (index + 1) + "\u884C\uFF0C\u8D85\u51FA\u6700\u5927\u503C\uFF0C\u5DF2\u4FEE\u6539\u6210\u6700\u5927\u503C";
|
|
574
575
|
},
|
|
575
576
|
maxHandle: function (record) {
|
|
576
|
-
return
|
|
577
|
-
|
|
578
|
-
|
|
577
|
+
return 10;
|
|
578
|
+
},
|
|
579
|
+
lowMinTip: function (record, index) {
|
|
580
|
+
return "\u7B2C" + (index + 1) + "\u884C\uFF0C\u4F4E\u4E8E\u6700\u5C0F\u503C\uFF0C\u5DF2\u4FEE\u6539\u6210\u6700\u5C0F\u503C";
|
|
579
581
|
},
|
|
580
582
|
precision: 3,
|
|
581
583
|
},
|
|
@@ -13,6 +13,18 @@ interface IProps extends InputNumberProps {
|
|
|
13
13
|
* 货币转换符号
|
|
14
14
|
*/
|
|
15
15
|
currencySymbol?: ICurrencySymbol;
|
|
16
|
+
/**
|
|
17
|
+
* 超出最大值提示
|
|
18
|
+
*/
|
|
19
|
+
overMaxTip?: string;
|
|
20
|
+
/**
|
|
21
|
+
* 低于最小值提示
|
|
22
|
+
*/
|
|
23
|
+
lowMinTip?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 超出最大值或最小值触发得事件
|
|
26
|
+
*/
|
|
27
|
+
onOverRange?: (type: 'maxType' | 'minType') => void;
|
|
16
28
|
}
|
|
17
29
|
declare function InputNumber(props: IProps): JSX.Element;
|
|
18
30
|
export default InputNumber;
|
|
@@ -20,12 +20,43 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import React from 'react';
|
|
23
|
+
import React, { useRef } from 'react';
|
|
24
24
|
import { InputNumber as AntInputNumber } from 'antd';
|
|
25
|
+
import { message } from '../../index';
|
|
25
26
|
import useFormatter from '../../hooks/useFormatter';
|
|
26
27
|
function InputNumber(props) {
|
|
27
|
-
var formatterType = props.formatterType, currencySymbol = props.currencySymbol, formatter = props.formatter, parser = props.parser, precision = props.precision, restProps = __rest(props, ["formatterType", "currencySymbol", "formatter", "parser", "precision"]);
|
|
28
|
+
var formatterType = props.formatterType, currencySymbol = props.currencySymbol, formatter = props.formatter, parser = props.parser, precision = props.precision, max = props.max, min = props.min, onChange = props.onChange, onBlur = props.onBlur, onPressEnter = props.onPressEnter, onOverRange = props.onOverRange, overMaxTip = props.overMaxTip, lowMinTip = props.lowMinTip, restProps = __rest(props, ["formatterType", "currencySymbol", "formatter", "parser", "precision", "max", "min", "onChange", "onBlur", "onPressEnter", "onOverRange", "overMaxTip", "lowMinTip"]);
|
|
29
|
+
var selfValue = useRef();
|
|
28
30
|
var _a = useFormatter(formatterType, currencySymbol), _formatter = _a.formatter, _parser = _a.parser, _precision = _a.precision;
|
|
29
|
-
|
|
31
|
+
var onChangeHandle = function (value) {
|
|
32
|
+
selfValue.current = value;
|
|
33
|
+
onChange && onChange(value);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* 超出范围触发得事件
|
|
37
|
+
*/
|
|
38
|
+
var onOverRangeHandle = function () {
|
|
39
|
+
if (typeof min === 'number' && selfValue.current < min) {
|
|
40
|
+
selfValue.current = min;
|
|
41
|
+
onChange && onChange(min);
|
|
42
|
+
onOverRange && onOverRange('minType');
|
|
43
|
+
message.info(lowMinTip || '低于最小值,已修改成最小值!');
|
|
44
|
+
}
|
|
45
|
+
if (typeof max === 'number' && selfValue.current > max) {
|
|
46
|
+
selfValue.current = max;
|
|
47
|
+
onChange && onChange(max);
|
|
48
|
+
onOverRange && onOverRange('maxType');
|
|
49
|
+
message.info(overMaxTip || '高于最大值,已修改成最大值!');
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var onBlurHandle = function (e) {
|
|
53
|
+
onOverRangeHandle();
|
|
54
|
+
onBlur && onBlur(e);
|
|
55
|
+
};
|
|
56
|
+
var onPressEnterHandle = function (e) {
|
|
57
|
+
onOverRangeHandle();
|
|
58
|
+
onPressEnter && onPressEnter(e);
|
|
59
|
+
};
|
|
60
|
+
return (React.createElement(AntInputNumber, __assign({ formatter: formatter || _formatter, parser: parser || _parser, precision: precision || _precision, onChange: onChangeHandle, onBlur: onBlurHandle, onPressEnter: onPressEnterHandle }, restProps)));
|
|
30
61
|
}
|
|
31
62
|
export default InputNumber;
|
|
@@ -10,6 +10,10 @@ export interface IEditableConfig {
|
|
|
10
10
|
};
|
|
11
11
|
maxHandle?: (record: any) => any;
|
|
12
12
|
minHandle?: (record: any) => any;
|
|
13
|
+
/** 超出最大值提示 */
|
|
14
|
+
overMaxTip?: string | ((record: any, index: any) => string);
|
|
15
|
+
/** 低于最小值提示 */
|
|
16
|
+
lowMinTip?: string | ((record: any, index: any) => string);
|
|
13
17
|
/**是否禁用 */
|
|
14
18
|
disabledHandle?: (record: any, index?: number) => boolean;
|
|
15
19
|
/**数字输入框的转换类型:内置 货币和百分比 */
|
|
@@ -124,7 +124,7 @@ var TableEnhanceCell = memo(function (_a) {
|
|
|
124
124
|
}
|
|
125
125
|
} })));
|
|
126
126
|
}
|
|
127
|
-
var type = editableConfig.type, data = editableConfig.data, keyValue = editableConfig.keyValue, maxHandle = editableConfig.maxHandle, minHandle = editableConfig.minHandle, disabledHandle = editableConfig.disabledHandle, editableProps = __rest(editableConfig, ["type", "data", "keyValue", "maxHandle", "minHandle", "disabledHandle"]);
|
|
127
|
+
var type = editableConfig.type, data = editableConfig.data, keyValue = editableConfig.keyValue, maxHandle = editableConfig.maxHandle, minHandle = editableConfig.minHandle, overMaxTip = editableConfig.overMaxTip, lowMinTip = editableConfig.lowMinTip, disabledHandle = editableConfig.disabledHandle, editableProps = __rest(editableConfig, ["type", "data", "keyValue", "maxHandle", "minHandle", "overMaxTip", "lowMinTip", "disabledHandle"]);
|
|
128
128
|
var selectData = data; // 下拉框使用到得数据
|
|
129
129
|
// 下拉框键值对对象
|
|
130
130
|
var selectKeyValue = keyValue || {
|
|
@@ -144,7 +144,7 @@ var TableEnhanceCell = memo(function (_a) {
|
|
|
144
144
|
inputNumMaxMin.max = result;
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
147
|
-
|
|
147
|
+
inputNumMaxMin.max = result === null || result === void 0 ? void 0 : result.number;
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
if (minHandle && minHandle instanceof Function) {
|
|
@@ -153,9 +153,22 @@ var TableEnhanceCell = memo(function (_a) {
|
|
|
153
153
|
inputNumMaxMin.min = result;
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
156
|
-
|
|
156
|
+
inputNumMaxMin.min = result === null || result === void 0 ? void 0 : result.number;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
+
var inputNumberRangeTip = {};
|
|
160
|
+
if (typeof overMaxTip === 'string') {
|
|
161
|
+
inputNumberRangeTip.overMaxTip = overMaxTip;
|
|
162
|
+
}
|
|
163
|
+
else if (typeof overMaxTip === 'function') {
|
|
164
|
+
inputNumberRangeTip.overMaxTip = overMaxTip(record, index);
|
|
165
|
+
}
|
|
166
|
+
if (typeof lowMinTip === 'string') {
|
|
167
|
+
inputNumberRangeTip.lowMinTip = lowMinTip;
|
|
168
|
+
}
|
|
169
|
+
else if (typeof lowMinTip === 'function') {
|
|
170
|
+
inputNumberRangeTip.lowMinTip = lowMinTip(record, index);
|
|
171
|
+
}
|
|
159
172
|
if (disabledHandle && disabledHandle instanceof Function) {
|
|
160
173
|
disabledResult = disabledHandle(record, index);
|
|
161
174
|
}
|
|
@@ -167,7 +180,7 @@ var TableEnhanceCell = memo(function (_a) {
|
|
|
167
180
|
}
|
|
168
181
|
else if (type === 'inputNumber') {
|
|
169
182
|
return (React.createElement(Form.Item, { className: "zt-table__enhance-cell", name: dataIndex },
|
|
170
|
-
React.createElement(InputNumber, __assign({ autoComplete: "new-password", maxLength: 50 }, inputNumMaxMin, editableProps, { disabled: disabledResult, onPressEnter: function () { return save({ maxResult: maxResult, minResult: minResult }); }, onBlur: function () { return save({ maxResult: maxResult, minResult: minResult }); } }))));
|
|
183
|
+
React.createElement(InputNumber, __assign({ autoComplete: "new-password", maxLength: 50 }, inputNumMaxMin, editableProps, inputNumberRangeTip, { disabled: disabledResult, onPressEnter: function () { return save({ maxResult: maxResult, minResult: minResult }); }, onBlur: function () { return save({ maxResult: maxResult, minResult: minResult }); } }))));
|
|
171
184
|
}
|
|
172
185
|
else if (type === 'textArea') {
|
|
173
186
|
return (React.createElement(Form.Item, { className: "zt-table__enhance-cell", name: dataIndex },
|