ztxkui 2.6.9 → 2.7.2

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/Demo.js CHANGED
@@ -86,7 +86,7 @@ function Demo() {
86
86
  React.createElement(EnhanceSelect, { style: selectStyle, defaultList: [
87
87
  { id: 1, empName: '21' },
88
88
  { id: 2, empName: '33' },
89
- ], placeholder: "\u53EF\u8FDC\u7A0B\u6A21\u7CCA\u641C\u7D22", url: "http://192.168.0.83:8000/api/zmdms-system/employee/page", request: request, remoteSearch: true, dataKey: "id", titleKey: "empName", value: value, showAll: true, onChange: function (value, option, fullData) {
89
+ ], placeholder: "\u53EF\u8FDC\u7A0B\u6A21\u7CCA\u641C\u7D22", url: "http://192.168.0.83:8000/api/zmdms-system/employee/page", request: request, remoteSearch: true, isRemoteSearchDataKey: false, dataKey: "id", titleKey: "empName", value: value, showAll: true, onChange: function (value, option, fullData) {
90
90
  setValue(value);
91
91
  }, params: JSON.stringify(params),
92
92
  // value={value}
@@ -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
- number: 0,
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
- number: 10,
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
  },
@@ -76,7 +76,7 @@ function getData(request, options) {
76
76
  * 如果数据不能在接口层面满足以上形式,那么组件提供transformData属性,转换接口数据格式
77
77
  */
78
78
  function EnhanceSelect(_a) {
79
- var list = _a.list, defaultList = _a.defaultList, params = _a.params, url = _a.url, _b = _a.method, method = _b === void 0 ? 'GET' : _b, _c = _a.timeout, timeout = _c === void 0 ? 10000 : _c, _d = _a.dataKey, dataKey = _d === void 0 ? 'id' : _d, componentKey = _a.componentKey, _e = _a.titleKey, titleKey = _e === void 0 ? 'name' : _e, showAll = _a.showAll, isCatch = _a.isCatch, onCompleted = _a.onCompleted, onChange = _a.onChange, request = _a.request, remoteSearch = _a.remoteSearch, remoteSearchKey = _a.remoteSearchKey, remoteSearchDataKey = _a.remoteSearchDataKey, _f = _a.isRemoteSearchDataKey, isRemoteSearchDataKey = _f === void 0 ? true : _f, transformData = _a.transformData, joinKey = _a.joinKey, _g = _a.joinStr, joinStr = _g === void 0 ? '-' : _g, mustHasParams = _a.mustHasParams, disabledValues = _a.disabledValues, restProps = __rest(_a, ["list", "defaultList", "params", "url", "method", "timeout", "dataKey", "componentKey", "titleKey", "showAll", "isCatch", "onCompleted", "onChange", "request", "remoteSearch", "remoteSearchKey", "remoteSearchDataKey", "isRemoteSearchDataKey", "transformData", "joinKey", "joinStr", "mustHasParams", "disabledValues"]);
79
+ var list = _a.list, defaultList = _a.defaultList, params = _a.params, url = _a.url, _b = _a.method, method = _b === void 0 ? 'GET' : _b, _c = _a.timeout, timeout = _c === void 0 ? 30000 : _c, _d = _a.dataKey, dataKey = _d === void 0 ? 'id' : _d, componentKey = _a.componentKey, _e = _a.titleKey, titleKey = _e === void 0 ? 'name' : _e, showAll = _a.showAll, isCatch = _a.isCatch, onCompleted = _a.onCompleted, onChange = _a.onChange, request = _a.request, remoteSearch = _a.remoteSearch, remoteSearchKey = _a.remoteSearchKey, remoteSearchDataKey = _a.remoteSearchDataKey, _f = _a.isRemoteSearchDataKey, isRemoteSearchDataKey = _f === void 0 ? true : _f, transformData = _a.transformData, joinKey = _a.joinKey, _g = _a.joinStr, joinStr = _g === void 0 ? '-' : _g, mustHasParams = _a.mustHasParams, disabledValues = _a.disabledValues, restProps = __rest(_a, ["list", "defaultList", "params", "url", "method", "timeout", "dataKey", "componentKey", "titleKey", "showAll", "isCatch", "onCompleted", "onChange", "request", "remoteSearch", "remoteSearchKey", "remoteSearchDataKey", "isRemoteSearchDataKey", "transformData", "joinKey", "joinStr", "mustHasParams", "disabledValues"]);
80
80
  var currentClick = useRef(true);
81
81
  // 下拉数据源
82
82
  var _h = useFetchState([]), selectList = _h[0], setSelectList = _h[1];
@@ -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
- return (React.createElement(AntInputNumber, __assign({ formatter: formatter || _formatter, parser: parser || _parser, precision: precision || _precision }, restProps)));
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;
@@ -20,20 +20,59 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import React, { useState } from 'react';
23
+ import React, { useState, useRef } from 'react';
24
24
  import { Select as AntSelect } from 'antd';
25
25
  function Select(props) {
26
- var children = props.children, restProps = __rest(props, ["children"]);
26
+ var children = props.children, onChange = props.onChange, restProps = __rest(props, ["children", "onChange"]);
27
27
  // 获得焦点选中
28
28
  var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];
29
+ var currentClick = useRef(true);
30
+ var onChangeHandle = function (value, option) {
31
+ if ((Array.isArray(value) && value.length === 0) || !value) {
32
+ currentClick.current = true;
33
+ }
34
+ else {
35
+ currentClick.current = false;
36
+ }
37
+ onChange && onChange(value, option);
38
+ };
29
39
  // 焦点事件
30
- var onFocusHandle = function () {
40
+ var onFocusHandle = function (e) {
41
+ // console.log('焦点事件');
31
42
  setIsOpen(true);
43
+ currentClick.current = false;
32
44
  };
33
45
  var onBlurHandle = function () {
46
+ // console.log('失去焦点事件');
47
+ setIsOpen(false);
48
+ currentClick.current = false;
49
+ };
50
+ // 清空数据时
51
+ var onClearHandle = function () {
52
+ // console.log('清空数据事件');
34
53
  setIsOpen(false);
35
54
  };
36
- return (React.createElement(AntSelect, __assign({ onFocus: onFocusHandle, onBlur: onBlurHandle, open: isOpen }, restProps), children));
55
+ // 选中时
56
+ var onSelectHandle = function () {
57
+ // console.log('选中数据事件');
58
+ if (!restProps.mode) {
59
+ setIsOpen(false);
60
+ }
61
+ };
62
+ // 点击时
63
+ var onClickHandle = function (e) {
64
+ // console.log('点击事件', currentClick.current);
65
+ if (currentClick.current) {
66
+ if (isOpen) {
67
+ setIsOpen(false);
68
+ }
69
+ else {
70
+ setIsOpen(true);
71
+ }
72
+ }
73
+ currentClick.current = true;
74
+ };
75
+ return (React.createElement(AntSelect, __assign({ onChange: onChangeHandle, onFocus: onFocusHandle, onBlur: onBlurHandle, onClear: onClearHandle, onSelect: onSelectHandle, onClick: onClickHandle, open: isOpen }, restProps), children));
37
76
  }
38
77
  Select.Option = AntSelect.Option;
39
78
  Select.OptGroup = AntSelect.OptGroup;
@@ -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
- maxResult = result;
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
- minResult = result;
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 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "2.6.9",
3
+ "version": "2.7.2",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",