assui 2.1.30 → 2.1.33

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.
Files changed (39) hide show
  1. package/es/button-modal/index.js +2 -8
  2. package/es/label-auto-complete/index.js +1 -3
  3. package/es/label-condition-input/index.d.ts +3 -1
  4. package/es/label-condition-input/index.js +5 -7
  5. package/es/label-customize-range-picker/index.d.ts +2 -0
  6. package/es/label-customize-range-picker/index.js +71 -7
  7. package/es/label-customize-range-picker/style/index.css +6 -0
  8. package/es/label-customize-range-picker/style/index.less +8 -0
  9. package/es/label-date-picker/index.js +1 -3
  10. package/es/label-input/index.js +1 -3
  11. package/es/label-number-input/index.js +4 -6
  12. package/es/label-range-picker/index.js +1 -0
  13. package/es/label-select/index.js +2 -4
  14. package/es/label-text-area/index.js +1 -3
  15. package/es/messages/zh_CN.js +1 -1
  16. package/es/number-input/utils.d.ts +3 -3
  17. package/es/number-input/utils.js +6 -5
  18. package/es/step-number-input/index.d.ts +1 -1
  19. package/es/step-number-input/index.js +27 -55
  20. package/lib/button-modal/index.js +2 -8
  21. package/lib/label-auto-complete/index.js +1 -3
  22. package/lib/label-condition-input/index.d.ts +3 -1
  23. package/lib/label-condition-input/index.js +5 -7
  24. package/lib/label-customize-range-picker/index.d.ts +2 -0
  25. package/lib/label-customize-range-picker/index.js +73 -7
  26. package/lib/label-customize-range-picker/style/index.css +6 -0
  27. package/lib/label-customize-range-picker/style/index.less +8 -0
  28. package/lib/label-date-picker/index.js +1 -3
  29. package/lib/label-input/index.js +1 -3
  30. package/lib/label-number-input/index.js +4 -6
  31. package/lib/label-range-picker/index.js +1 -0
  32. package/lib/label-select/index.js +2 -4
  33. package/lib/label-text-area/index.js +1 -3
  34. package/lib/messages/zh_CN.js +1 -1
  35. package/lib/number-input/utils.d.ts +3 -3
  36. package/lib/number-input/utils.js +6 -5
  37. package/lib/step-number-input/index.d.ts +1 -1
  38. package/lib/step-number-input/index.js +28 -55
  39. package/package.json +2 -2
@@ -72,19 +72,13 @@ var ButtonModal = function ButtonModal(props, ref) {
72
72
  restModalProps = __rest(props, ["children", "trigger", "onOpen", "onClose", "onOk", "onCancel"]);
73
73
 
74
74
  var openModal = function openModal() {
75
- if (onOpen) {
76
- onOpen();
77
- }
78
-
79
75
  setModalVisible(true);
76
+ onOpen === null || onOpen === void 0 ? void 0 : onOpen();
80
77
  };
81
78
 
82
79
  var closeModal = function closeModal() {
83
- if (onClose) {
84
- onClose();
85
- }
86
-
87
80
  setModalVisible(false);
81
+ onClose === null || onClose === void 0 ? void 0 : onClose();
88
82
  };
89
83
 
90
84
  var modalActionRef = React.useRef({
@@ -74,13 +74,11 @@ var LabelAutoComplete = function LabelAutoComplete(props) {
74
74
  };
75
75
 
76
76
  var handleLabelClick = function handleLabelClick() {
77
- var _a;
78
-
79
77
  if (!open) {
80
78
  setOpen(!open);
81
79
  }
82
80
 
83
- (_a = autoComplete.current) === null || _a === void 0 ? void 0 : _a.focus();
81
+ autoComplete.current.focus();
84
82
  };
85
83
 
86
84
  var onDropdownVisibleChange = function onDropdownVisibleChange(nextOpen) {
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { ConditionInputProps } from '../condition-input';
3
- export interface LabelConditionInputProps extends ConditionInputProps {
3
+ export interface LabelConditionInputProps extends Omit<ConditionInputProps, 'onBlur' | 'onChange'> {
4
4
  /** label 标签的文本 */
5
5
  label?: React.ReactNode;
6
6
  /** 输入框内容变化时的回调 */
7
7
  onChange?: (value: string) => void;
8
+ /** 输入框失去焦点的回调 */
9
+ onBlur?: (value: string) => void;
8
10
  /** 输入框除去label之后的最小末尾宽度 */
9
11
  baseMinWidth?: number;
10
12
  /** 组件dom id */
@@ -70,10 +70,8 @@ var LabelConditionInput = function LabelConditionInput(props) {
70
70
  setFocused = _c[1];
71
71
 
72
72
  var handleLabelClick = function handleLabelClick() {
73
- var _a;
74
-
75
73
  setFocused(true);
76
- (_a = InputDomRef.current) === null || _a === void 0 ? void 0 : _a.focus();
74
+ InputDomRef.current.focus();
77
75
  };
78
76
 
79
77
  var handleFocus = function handleFocus() {
@@ -81,9 +79,9 @@ var LabelConditionInput = function LabelConditionInput(props) {
81
79
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(value);
82
80
  };
83
81
 
84
- var handleBlur = function handleBlur(e) {
82
+ var handleBlur = function handleBlur() {
85
83
  setFocused(false);
86
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
84
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(value);
87
85
  };
88
86
 
89
87
  var controlMinWidth = (labelSize === null || labelSize === void 0 ? void 0 : labelSize.width) ? labelSize.width + baseMinWidth : undefined;
@@ -95,9 +93,9 @@ var LabelConditionInput = function LabelConditionInput(props) {
95
93
  }
96
94
  }, /*#__PURE__*/React.createElement("div", {
97
95
  className: classNames('label-condition-input-field', {
98
- 'label-condition-input-focused': focused || value
96
+ 'label-condition-input-focused': focused
99
97
  })
100
- }, /*#__PURE__*/React.createElement(ConditionInput, __assign({}, omit(props, ['onChange', 'onBlur', 'onFocus', 'className', 'label', 'placeholder']), {
98
+ }, /*#__PURE__*/React.createElement(ConditionInput, __assign({}, omit(props, ['onChange', 'onBlur', 'onFocus', 'className', 'label', 'placeholder', 'baseMinWidth']), {
101
99
  ref: InputDomRef,
102
100
  "data-value": value ? value.length : 0,
103
101
  value: value,
@@ -12,6 +12,8 @@ export interface LabelCustomizeRangePickerProps extends Omit<LabelRangePickerPro
12
12
  customizeTimeList?: dateTypeEnum[];
13
13
  rangePickerType?: 'label' | 'origin';
14
14
  label?: React.ReactNode;
15
+ /** 最大时间范围 */
16
+ maxScope?: number;
15
17
  }
16
18
  declare const LabelCustomizeRangePicker: (props: LabelCustomizeRangePickerProps) => JSX.Element;
17
19
  export default LabelCustomizeRangePicker;
@@ -59,6 +59,8 @@ import Radio from 'antd/lib/radio';
59
59
  import Checkbox from 'antd/lib/checkbox';
60
60
  import DatePicker from 'antd/lib/date-picker';
61
61
  import useControllableValue from 'ahooks/lib/useControllableValue';
62
+ import moment from 'moment';
63
+ import omit from 'lodash/omit';
62
64
  import getDefaultRadioList from './defaultRadioList';
63
65
  import LabelRangePicker from '../label-range-picker';
64
66
  import LocaleContext from '../config-provider/context';
@@ -71,7 +73,8 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
71
73
  _a = props.rangePickerType,
72
74
  rangePickerType = _a === void 0 ? 'label' : _a,
73
75
  label = props.label,
74
- options = __rest(props, ["customizeTimeList", "radioList", "rangePickerType", "label"]);
76
+ maxScope = props.maxScope,
77
+ options = __rest(props, ["customizeTimeList", "radioList", "rangePickerType", "label", "maxScope"]);
75
78
 
76
79
  var _b = __read(useControllableValue(props), 2),
77
80
  date = _b[0],
@@ -92,7 +95,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
92
95
  var messages = useContext(LocaleContext);
93
96
  var dataSource = radioList !== null && radioList !== void 0 ? radioList : getDefaultRadioList(messages);
94
97
  useEffect(function () {
95
- var foundItem = dataSource.find(function (item) {
98
+ var filterItemList = dataSource.filter(function (item) {
96
99
  if (!date) return false;
97
100
 
98
101
  var _a = __read(item.value, 2),
@@ -109,8 +112,21 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
109
112
 
110
113
  return false;
111
114
  });
112
- var data = foundItem ? foundItem.key : null;
113
- setRadioKey(data);
115
+
116
+ if (filterItemList.length === 0) {
117
+ setRadioKey(null);
118
+ } else if (filterItemList.length > 1) {
119
+ var findItem = filterItemList.find(function (item) {
120
+ return item.key === radioKey;
121
+ });
122
+ var resutRadioKey = findItem ? findItem.key : filterItemList[0].key;
123
+ setRadioKey(resutRadioKey);
124
+ } else {
125
+ var _a = __read(filterItemList, 1),
126
+ item = _a[0];
127
+
128
+ setRadioKey(item.key);
129
+ }
114
130
  }, [date]);
115
131
 
116
132
  var onDiyTimeChange = function onDiyTimeChange(event) {
@@ -119,7 +135,47 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
119
135
  };
120
136
 
121
137
  var onDateChange = function onDateChange(nextValue) {
122
- setDate(nextValue);
138
+ var _a, _b;
139
+
140
+ var _c = __read(nextValue || [], 2),
141
+ start = _c[0],
142
+ end = _c[1];
143
+
144
+ var nextStartDate = (_a = start === null || start === void 0 ? void 0 : start.clone().startOf('day')) !== null && _a !== void 0 ? _a : null;
145
+ var nextEndDate = (_b = end === null || end === void 0 ? void 0 : end.clone().endOf('day')) !== null && _b !== void 0 ? _b : null;
146
+
147
+ if (!nextStartDate && !nextEndDate) {
148
+ return setDate(undefined);
149
+ }
150
+
151
+ if (!maxScope) {
152
+ return setDate([nextStartDate, nextEndDate]);
153
+ }
154
+
155
+ var _d = __read(date || [], 1),
156
+ startDate = _d[0];
157
+
158
+ if (nextStartDate && nextEndDate) {
159
+ var isChangeStartData = !(startDate === null || startDate === void 0 ? void 0 : startDate.clone().isSame(nextStartDate, 'day'));
160
+
161
+ if (isChangeStartData) {
162
+ if (nextEndDate.diff(nextStartDate, 'day') > maxScope) {
163
+ nextEndDate = nextStartDate.clone().add(maxScope - 1, 'day');
164
+ }
165
+ } else if (nextEndDate.diff(nextStartDate, 'day') > maxScope) {
166
+ nextStartDate = nextEndDate.clone().subtract(maxScope - 1, 'day');
167
+ }
168
+ } else if (!nextStartDate && nextEndDate) {
169
+ nextStartDate = nextEndDate.clone().subtract(maxScope - 1, 'day');
170
+ } else if (nextStartDate && !nextEndDate) {
171
+ nextEndDate = nextStartDate.clone().add(maxScope - 1, 'day');
172
+ }
173
+
174
+ if (nextStartDate && nextEndDate) {
175
+ return setDate([nextStartDate, nextEndDate]);
176
+ }
177
+
178
+ return setDate([nextStartDate, nextEndDate]);
123
179
  };
124
180
 
125
181
  var onRadioChange = function onRadioChange(event) {
@@ -135,6 +191,14 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
135
191
  var list = radioList !== null && radioList !== void 0 ? radioList : getDefaultRadioList(messages).filter(function (item) {
136
192
  return customizeTimeList ? customizeTimeList.includes(item.key) : true;
137
193
  });
194
+ var resultList = maxScope ? list.filter(function (item) {
195
+ var _a = __read(item.value, 2),
196
+ startTime = _a[0],
197
+ entTime = _a[1];
198
+
199
+ var space = moment.duration(entTime.diff(startTime)).asDays();
200
+ return space <= maxScope;
201
+ }) : list;
138
202
 
139
203
  var panelRender = function panelRender(panel) {
140
204
  return /*#__PURE__*/React.createElement("div", {
@@ -154,7 +218,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
154
218
  }, /*#__PURE__*/React.createElement(Radio.Group, {
155
219
  onChange: onRadioChange,
156
220
  value: radioKey
157
- }, list.map(function (_a) {
221
+ }, resultList.map(function (_a) {
158
222
  var key = _a.key,
159
223
  text = _a.text;
160
224
  return /*#__PURE__*/React.createElement(Radio, {
@@ -179,7 +243,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
179
243
  };
180
244
  return rangePickerType === 'label' ? /*#__PURE__*/React.createElement(LabelRangePicker, __assign({
181
245
  label: label
182
- }, baseOptions, options)) : /*#__PURE__*/React.createElement(RangePicker, __assign({}, baseOptions, options));
246
+ }, baseOptions, omit(options, 'onChange'))) : /*#__PURE__*/React.createElement(RangePicker, __assign({}, baseOptions, omit(options, 'onChange')));
183
247
  };
184
248
 
185
249
  export default LabelCustomizeRangePicker;
@@ -1793,6 +1793,12 @@ html {
1793
1793
  padding: 8px 11px 6px;
1794
1794
  border-bottom: 1px solid #f5f6fa;
1795
1795
  }
1796
+ .label-customize-range-picker-panel .check-wrapper .ant-checkbox-wrapper {
1797
+ pointer-events: none;
1798
+ }
1799
+ .label-customize-range-picker-panel .check-wrapper .ant-checkbox-input {
1800
+ pointer-events: auto;
1801
+ }
1796
1802
  .label-customize-range-picker-panel .pick-box {
1797
1803
  display: flex;
1798
1804
  justify-content: space-between;
@@ -8,6 +8,14 @@
8
8
  .check-wrapper {
9
9
  padding: 8px 11px 6px;
10
10
  border-bottom: 1px solid #f5f6fa;
11
+
12
+ .@{ant-prefix}-checkbox-wrapper {
13
+ pointer-events: none;
14
+ }
15
+
16
+ .@{ant-prefix}-checkbox-input {
17
+ pointer-events: auto;
18
+ }
11
19
  }
12
20
 
13
21
  .pick-box {
@@ -68,13 +68,11 @@ var LabelDatePicker = function LabelDatePicker(props) {
68
68
  };
69
69
 
70
70
  var handleLabelClick = function handleLabelClick() {
71
- var _a;
72
-
73
71
  if (!open) {
74
72
  setOpen(!open);
75
73
  }
76
74
 
77
- (_a = datePickerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
75
+ datePickerRef.current.focus();
78
76
  };
79
77
 
80
78
  var onBlur = function onBlur() {
@@ -97,9 +97,7 @@ var LabelInput = function LabelInput(props) {
97
97
  };
98
98
 
99
99
  var handleLabelClick = function handleLabelClick() {
100
- var _a;
101
-
102
- (_a = InputDomRef.current) === null || _a === void 0 ? void 0 : _a.focus();
100
+ InputDomRef.current.focus();
103
101
  };
104
102
 
105
103
  var onChangeInputType = React.useCallback(function (nextInputType) {
@@ -70,10 +70,8 @@ var LabelNumberInput = function LabelNumberInput(props) {
70
70
  setFocused = _c[1];
71
71
 
72
72
  var handleLabelClick = function handleLabelClick() {
73
- var _a;
74
-
75
73
  setFocused(true);
76
- (_a = numberInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
74
+ numberInputRef.current.focus();
77
75
  };
78
76
 
79
77
  var handleFocus = function handleFocus() {
@@ -81,9 +79,9 @@ var LabelNumberInput = function LabelNumberInput(props) {
81
79
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(value);
82
80
  };
83
81
 
84
- var handleBlur = function handleBlur(e) {
82
+ var handleBlur = function handleBlur() {
85
83
  setFocused(false);
86
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
84
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(value);
87
85
  };
88
86
 
89
87
  var controlMinWidth = (labelSize === null || labelSize === void 0 ? void 0 : labelSize.width) ? labelSize.width + baseMinWidth : undefined;
@@ -97,7 +95,7 @@ var LabelNumberInput = function LabelNumberInput(props) {
97
95
  className: classNames('label-number-input-field', {
98
96
  'label-number-input-focused': focused
99
97
  })
100
- }, /*#__PURE__*/React.createElement(NumberInput, __assign({}, omit(props, ['onChange', 'onBlur', 'onFocus', 'className', 'label', 'placeholder']), {
98
+ }, /*#__PURE__*/React.createElement(NumberInput, __assign({}, omit(props, ['onChange', 'onBlur', 'onFocus', 'className', 'label', 'placeholder', 'baseMinWidth']), {
101
99
  ref: numberInputRef,
102
100
  "data-value": !isUndefined(value) ? "".concat(value).length : 0,
103
101
  value: value,
@@ -80,6 +80,7 @@ var LabelDatePicker = function LabelDatePicker(props) {
80
80
  };
81
81
 
82
82
  var handleOpenChange = function handleOpenChange(nextOpen) {
83
+ console.log('--');
83
84
  onOpenChange(nextOpen);
84
85
  };
85
86
 
@@ -72,13 +72,11 @@ var LabelSelect = function LabelSelect(props) {
72
72
  };
73
73
 
74
74
  var handleLabelClick = function handleLabelClick() {
75
- var _a;
76
-
77
75
  if (!open) {
78
76
  setOpen(!open);
79
77
  }
80
78
 
81
- (_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.focus();
79
+ selectRef.current.focus();
82
80
  };
83
81
 
84
82
  var onDropdownVisibleChange = function onDropdownVisibleChange(nextOpen) {
@@ -93,7 +91,7 @@ var LabelSelect = function LabelSelect(props) {
93
91
  }, /*#__PURE__*/React.createElement(Select, __assign({
94
92
  maxTagCount: 3,
95
93
  showSearch: false
96
- }, omit(props, ['open', 'onChange', 'className', 'label']), {
94
+ }, omit(props, ['open', 'onChange', 'className', 'label', 'setOpen']), {
97
95
  open: open,
98
96
  ref: selectRef,
99
97
  size: "large",
@@ -89,9 +89,7 @@ var LabelTextArea = function LabelTextArea(props) {
89
89
  };
90
90
 
91
91
  var handleLabelClick = function handleLabelClick() {
92
- var _a;
93
-
94
- (_a = TextAreaDomRef.current) === null || _a === void 0 ? void 0 : _a.focus();
92
+ TextAreaDomRef.current.focus();
95
93
  };
96
94
 
97
95
  var handleChange = function handleChange(e) {
@@ -9,7 +9,7 @@ var locale = {
9
9
  lastWeek: '上周',
10
10
  month: '本月',
11
11
  lastMonth: '上月',
12
- quarter: '季度',
12
+ quarter: '本季度',
13
13
  lastQuarter: '上季度',
14
14
  last7days: '最近7天',
15
15
  last14days: '最近14天',
@@ -1,10 +1,10 @@
1
1
  export interface FilterIntType {
2
2
  value: string;
3
3
  enableMinus?: boolean;
4
- preValue: string;
4
+ preValue?: string;
5
5
  }
6
6
  export declare const filterInt: ({ value, enableMinus, preValue }: FilterIntType) => string;
7
7
  export interface FilterFloatType extends FilterIntType {
8
- precision: number;
8
+ precision?: number;
9
9
  }
10
- export declare const filterFloat: ({ value, preValue, precision, enableMinus }: FilterFloatType) => string;
10
+ export declare const filterFloat: ({ value, preValue, precision, enableMinus, }: FilterFloatType) => string;
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable no-useless-escape */
2
+ var intNumberReg = /^-?\d+$/;
2
3
  export var filterInt = function filterInt(_a) {
3
4
  var value = _a.value,
4
5
  enableMinus = _a.enableMinus,
@@ -9,18 +10,18 @@ export var filterInt = function filterInt(_a) {
9
10
  nextValue = value.replace(/\D/g, '');
10
11
  }
11
12
 
12
- var intNumberReg = /^-?\d+$/;
13
-
14
13
  if (nextValue && nextValue.length > 1 && !intNumberReg.test(nextValue)) {
15
- return preValue;
14
+ return preValue !== null && preValue !== void 0 ? preValue : '';
16
15
  }
17
16
 
18
17
  return nextValue;
19
18
  };
20
19
  export var filterFloat = function filterFloat(_a) {
21
20
  var value = _a.value,
22
- preValue = _a.preValue,
23
- precision = _a.precision,
21
+ _b = _a.preValue,
22
+ preValue = _b === void 0 ? '' : _b,
23
+ _c = _a.precision,
24
+ precision = _c === void 0 ? 2 : _c,
24
25
  enableMinus = _a.enableMinus;
25
26
  var nextValue = value.replace(/[^\d.\-]/g, '');
26
27
  var matchDecimalPoint = nextValue.match(/\./g) || [];
@@ -7,7 +7,7 @@ export interface StepNumberInputProps {
7
7
  /** 精度,只对float有效 */
8
8
  precision: number;
9
9
  /** 内容最大长度 */
10
- maxLength: number;
10
+ maxLength?: number;
11
11
  /** 指定输入框展示值的格式 */
12
12
  formatter?: (value: string) => string;
13
13
  /** 指定从 formatter 里转换回数字的方式,和 formatter 搭配使用 */
@@ -58,41 +58,36 @@ import * as React from 'react';
58
58
  import classNames from 'classnames';
59
59
  import BigNumber from 'bignumber.js';
60
60
  import isUndefined from 'lodash/isUndefined';
61
+ import useControllableValue from 'ahooks/lib/useControllableValue';
61
62
  import { INT } from './const/numberType';
62
63
  import { PLUS, MINUS } from './const/countType';
63
64
  import NumberInput from '../number-input';
64
65
 
65
66
  var StepNumberInput = function StepNumberInput(props) {
66
- var value = props.value,
67
- onChange = props.onChange,
67
+ var _a = __read(useControllableValue(props, {
68
+ defaultValue: ''
69
+ }), 2),
70
+ value = _a[0],
71
+ setValue = _a[1];
72
+
73
+ var onChange = props.onChange,
68
74
  onBlur = props.onBlur,
69
75
  numberType = props.numberType,
70
76
  precision = props.precision,
71
77
  step = props.step,
72
78
  max = props.max,
73
79
  min = props.min,
74
- restProps = __rest(props, ["value", "onChange", "onBlur", "numberType", "precision", "step", "max", "min"]);
75
-
76
- var _a = __read(React.useState(''), 2),
77
- inputValue = _a[0],
78
- setInputValue = _a[1];
80
+ restProps = __rest(props, ["onChange", "onBlur", "numberType", "precision", "step", "max", "min"]);
79
81
 
80
- var resultValue = isUndefined(value) ? inputValue : value;
81
- var isEmpty = isUndefined(resultValue) || resultValue === '';
82
- var plusNumber = new BigNumber(resultValue).plus(step).toString();
83
- var minusNumber = new BigNumber(resultValue).minus(step).toString();
84
- var maxCondition = isUndefined(max) ? false : max === Number(resultValue) || Number(max) < Number(plusNumber);
85
- var minCondition = isUndefined(min) ? false : min === Number(resultValue) || Number(min) > Number(minusNumber);
82
+ var isEmpty = isUndefined(value) || value === '';
83
+ var plusNumber = new BigNumber(value).plus(step).toString();
84
+ var minusNumber = new BigNumber(value).minus(step).toString();
85
+ var maxCondition = isUndefined(max) ? false : max === Number(value) || Number(max) < Number(plusNumber);
86
+ var minCondition = isUndefined(min) ? false : min === Number(value) || Number(min) > Number(minusNumber);
86
87
 
87
88
  var onNumberChange = function onNumberChange(lastValue) {
88
- if (resultValue !== lastValue) {
89
- if (isUndefined(value)) {
90
- setInputValue(lastValue);
91
- }
92
-
93
- if (onChange) {
94
- onChange(lastValue);
95
- }
89
+ if (value !== lastValue) {
90
+ setValue(lastValue);
96
91
  }
97
92
  };
98
93
 
@@ -109,49 +104,26 @@ var StepNumberInput = function StepNumberInput(props) {
109
104
  newNumber = minCondition ? "".concat(min) : minusNumber;
110
105
  }
111
106
 
112
- if (value === undefined) {
113
- setInputValue(newNumber);
114
- }
115
-
116
- if (onChange) {
117
- onChange(newNumber);
118
- }
107
+ setValue(newNumber);
119
108
  };
120
109
 
121
110
  var onNumberBlur = function onNumberBlur() {
122
- if (resultValue === '-' || resultValue === '.') {
123
- if (value === undefined) {
124
- setInputValue('');
125
- }
111
+ var resultValue = value;
126
112
 
127
- if (onChange) {
128
- onChange('');
129
- }
113
+ if (value === '-' || value === '.') {
114
+ resultValue = '';
130
115
  }
131
116
 
132
- if (!isUndefined(max) && Number(resultValue) > max) {
133
- if (isUndefined(value)) {
134
- setInputValue("".concat(max));
135
- }
136
-
137
- if (onChange) {
138
- onChange("".concat(max));
139
- }
117
+ if (!isUndefined(max) && Number(value) > max) {
118
+ resultValue = "".concat(max);
140
119
  }
141
120
 
142
- if (!isUndefined(min) && Number(resultValue) < min) {
143
- if (isUndefined(value)) {
144
- setInputValue("".concat(min));
145
- }
146
-
147
- if (onChange) {
148
- onChange("".concat(min));
149
- }
121
+ if (!isUndefined(min) && Number(value) < min) {
122
+ resultValue = "".concat(min);
150
123
  }
151
124
 
152
- if (onBlur) {
153
- onBlur("".concat(resultValue) || '');
154
- }
125
+ setValue(resultValue);
126
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(resultValue);
155
127
  };
156
128
 
157
129
  return /*#__PURE__*/React.createElement("div", {
@@ -173,7 +145,7 @@ var StepNumberInput = function StepNumberInput(props) {
173
145
  'disabled-btn': isEmpty || maxCondition
174
146
  })
175
147
  }, "+"),
176
- value: "".concat(resultValue),
148
+ value: "".concat(value),
177
149
  onChange: onNumberChange,
178
150
  onBlur: onNumberBlur,
179
151
  numberType: numberType,
@@ -126,19 +126,13 @@ var ButtonModal = function ButtonModal(props, ref) {
126
126
  restModalProps = __rest(props, ["children", "trigger", "onOpen", "onClose", "onOk", "onCancel"]);
127
127
 
128
128
  var openModal = function openModal() {
129
- if (onOpen) {
130
- onOpen();
131
- }
132
-
133
129
  setModalVisible(true);
130
+ onOpen === null || onOpen === void 0 ? void 0 : onOpen();
134
131
  };
135
132
 
136
133
  var closeModal = function closeModal() {
137
- if (onClose) {
138
- onClose();
139
- }
140
-
141
134
  setModalVisible(false);
135
+ onClose === null || onClose === void 0 ? void 0 : onClose();
142
136
  };
143
137
 
144
138
  var modalActionRef = React.useRef({
@@ -91,13 +91,11 @@ var LabelAutoComplete = function LabelAutoComplete(props) {
91
91
  };
92
92
 
93
93
  var handleLabelClick = function handleLabelClick() {
94
- var _a;
95
-
96
94
  if (!open) {
97
95
  setOpen(!open);
98
96
  }
99
97
 
100
- (_a = autoComplete.current) === null || _a === void 0 ? void 0 : _a.focus();
98
+ autoComplete.current.focus();
101
99
  };
102
100
 
103
101
  var onDropdownVisibleChange = function onDropdownVisibleChange(nextOpen) {
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { ConditionInputProps } from '../condition-input';
3
- export interface LabelConditionInputProps extends ConditionInputProps {
3
+ export interface LabelConditionInputProps extends Omit<ConditionInputProps, 'onBlur' | 'onChange'> {
4
4
  /** label 标签的文本 */
5
5
  label?: React.ReactNode;
6
6
  /** 输入框内容变化时的回调 */
7
7
  onChange?: (value: string) => void;
8
+ /** 输入框失去焦点的回调 */
9
+ onBlur?: (value: string) => void;
8
10
  /** 输入框除去label之后的最小末尾宽度 */
9
11
  baseMinWidth?: number;
10
12
  /** 组件dom id */
@@ -87,10 +87,8 @@ var LabelConditionInput = function LabelConditionInput(props) {
87
87
  setFocused = _c[1];
88
88
 
89
89
  var handleLabelClick = function handleLabelClick() {
90
- var _a;
91
-
92
90
  setFocused(true);
93
- (_a = InputDomRef.current) === null || _a === void 0 ? void 0 : _a.focus();
91
+ InputDomRef.current.focus();
94
92
  };
95
93
 
96
94
  var handleFocus = function handleFocus() {
@@ -98,9 +96,9 @@ var LabelConditionInput = function LabelConditionInput(props) {
98
96
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(value);
99
97
  };
100
98
 
101
- var handleBlur = function handleBlur(e) {
99
+ var handleBlur = function handleBlur() {
102
100
  setFocused(false);
103
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
101
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(value);
104
102
  };
105
103
 
106
104
  var controlMinWidth = (labelSize === null || labelSize === void 0 ? void 0 : labelSize.width) ? labelSize.width + baseMinWidth : undefined;
@@ -112,9 +110,9 @@ var LabelConditionInput = function LabelConditionInput(props) {
112
110
  }
113
111
  }, react_1["default"].createElement("div", {
114
112
  className: (0, classnames_1["default"])('label-condition-input-field', {
115
- 'label-condition-input-focused': focused || value
113
+ 'label-condition-input-focused': focused
116
114
  })
117
- }, react_1["default"].createElement(condition_input_1["default"], __assign({}, (0, omit_1["default"])(props, ['onChange', 'onBlur', 'onFocus', 'className', 'label', 'placeholder']), {
115
+ }, react_1["default"].createElement(condition_input_1["default"], __assign({}, (0, omit_1["default"])(props, ['onChange', 'onBlur', 'onFocus', 'className', 'label', 'placeholder', 'baseMinWidth']), {
118
116
  ref: InputDomRef,
119
117
  "data-value": value ? value.length : 0,
120
118
  value: value,
@@ -12,6 +12,8 @@ export interface LabelCustomizeRangePickerProps extends Omit<LabelRangePickerPro
12
12
  customizeTimeList?: dateTypeEnum[];
13
13
  rangePickerType?: 'label' | 'origin';
14
14
  label?: React.ReactNode;
15
+ /** 最大时间范围 */
16
+ maxScope?: number;
15
17
  }
16
18
  declare const LabelCustomizeRangePicker: (props: LabelCustomizeRangePickerProps) => JSX.Element;
17
19
  export default LabelCustomizeRangePicker;
@@ -116,6 +116,10 @@ var date_picker_1 = __importDefault(require("antd/lib/date-picker"));
116
116
 
117
117
  var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
118
118
 
119
+ var moment_1 = __importDefault(require("moment"));
120
+
121
+ var omit_1 = __importDefault(require("lodash/omit"));
122
+
119
123
  var defaultRadioList_1 = __importDefault(require("./defaultRadioList"));
120
124
 
121
125
  var label_range_picker_1 = __importDefault(require("../label-range-picker"));
@@ -132,7 +136,8 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
132
136
  _a = props.rangePickerType,
133
137
  rangePickerType = _a === void 0 ? 'label' : _a,
134
138
  label = props.label,
135
- options = __rest(props, ["customizeTimeList", "radioList", "rangePickerType", "label"]);
139
+ maxScope = props.maxScope,
140
+ options = __rest(props, ["customizeTimeList", "radioList", "rangePickerType", "label", "maxScope"]);
136
141
 
137
142
  var _b = __read((0, useControllableValue_1["default"])(props), 2),
138
143
  date = _b[0],
@@ -153,7 +158,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
153
158
  var messages = (0, react_1.useContext)(context_1["default"]);
154
159
  var dataSource = radioList !== null && radioList !== void 0 ? radioList : (0, defaultRadioList_1["default"])(messages);
155
160
  (0, react_1.useEffect)(function () {
156
- var foundItem = dataSource.find(function (item) {
161
+ var filterItemList = dataSource.filter(function (item) {
157
162
  if (!date) return false;
158
163
 
159
164
  var _a = __read(item.value, 2),
@@ -170,8 +175,21 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
170
175
 
171
176
  return false;
172
177
  });
173
- var data = foundItem ? foundItem.key : null;
174
- setRadioKey(data);
178
+
179
+ if (filterItemList.length === 0) {
180
+ setRadioKey(null);
181
+ } else if (filterItemList.length > 1) {
182
+ var findItem = filterItemList.find(function (item) {
183
+ return item.key === radioKey;
184
+ });
185
+ var resutRadioKey = findItem ? findItem.key : filterItemList[0].key;
186
+ setRadioKey(resutRadioKey);
187
+ } else {
188
+ var _a = __read(filterItemList, 1),
189
+ item = _a[0];
190
+
191
+ setRadioKey(item.key);
192
+ }
175
193
  }, [date]);
176
194
 
177
195
  var onDiyTimeChange = function onDiyTimeChange(event) {
@@ -180,7 +198,47 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
180
198
  };
181
199
 
182
200
  var onDateChange = function onDateChange(nextValue) {
183
- setDate(nextValue);
201
+ var _a, _b;
202
+
203
+ var _c = __read(nextValue || [], 2),
204
+ start = _c[0],
205
+ end = _c[1];
206
+
207
+ var nextStartDate = (_a = start === null || start === void 0 ? void 0 : start.clone().startOf('day')) !== null && _a !== void 0 ? _a : null;
208
+ var nextEndDate = (_b = end === null || end === void 0 ? void 0 : end.clone().endOf('day')) !== null && _b !== void 0 ? _b : null;
209
+
210
+ if (!nextStartDate && !nextEndDate) {
211
+ return setDate(undefined);
212
+ }
213
+
214
+ if (!maxScope) {
215
+ return setDate([nextStartDate, nextEndDate]);
216
+ }
217
+
218
+ var _d = __read(date || [], 1),
219
+ startDate = _d[0];
220
+
221
+ if (nextStartDate && nextEndDate) {
222
+ var isChangeStartData = !(startDate === null || startDate === void 0 ? void 0 : startDate.clone().isSame(nextStartDate, 'day'));
223
+
224
+ if (isChangeStartData) {
225
+ if (nextEndDate.diff(nextStartDate, 'day') > maxScope) {
226
+ nextEndDate = nextStartDate.clone().add(maxScope - 1, 'day');
227
+ }
228
+ } else if (nextEndDate.diff(nextStartDate, 'day') > maxScope) {
229
+ nextStartDate = nextEndDate.clone().subtract(maxScope - 1, 'day');
230
+ }
231
+ } else if (!nextStartDate && nextEndDate) {
232
+ nextStartDate = nextEndDate.clone().subtract(maxScope - 1, 'day');
233
+ } else if (nextStartDate && !nextEndDate) {
234
+ nextEndDate = nextStartDate.clone().add(maxScope - 1, 'day');
235
+ }
236
+
237
+ if (nextStartDate && nextEndDate) {
238
+ return setDate([nextStartDate, nextEndDate]);
239
+ }
240
+
241
+ return setDate([nextStartDate, nextEndDate]);
184
242
  };
185
243
 
186
244
  var onRadioChange = function onRadioChange(event) {
@@ -196,6 +254,14 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
196
254
  var list = radioList !== null && radioList !== void 0 ? radioList : (0, defaultRadioList_1["default"])(messages).filter(function (item) {
197
255
  return customizeTimeList ? customizeTimeList.includes(item.key) : true;
198
256
  });
257
+ var resultList = maxScope ? list.filter(function (item) {
258
+ var _a = __read(item.value, 2),
259
+ startTime = _a[0],
260
+ entTime = _a[1];
261
+
262
+ var space = moment_1["default"].duration(entTime.diff(startTime)).asDays();
263
+ return space <= maxScope;
264
+ }) : list;
199
265
 
200
266
  var panelRender = function panelRender(panel) {
201
267
  return react_1["default"].createElement("div", {
@@ -215,7 +281,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
215
281
  }, react_1["default"].createElement(radio_1["default"].Group, {
216
282
  onChange: onRadioChange,
217
283
  value: radioKey
218
- }, list.map(function (_a) {
284
+ }, resultList.map(function (_a) {
219
285
  var key = _a.key,
220
286
  text = _a.text;
221
287
  return react_1["default"].createElement(radio_1["default"], {
@@ -240,7 +306,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
240
306
  };
241
307
  return rangePickerType === 'label' ? react_1["default"].createElement(label_range_picker_1["default"], __assign({
242
308
  label: label
243
- }, baseOptions, options)) : react_1["default"].createElement(RangePicker, __assign({}, baseOptions, options));
309
+ }, baseOptions, (0, omit_1["default"])(options, 'onChange'))) : react_1["default"].createElement(RangePicker, __assign({}, baseOptions, (0, omit_1["default"])(options, 'onChange')));
244
310
  };
245
311
 
246
312
  exports["default"] = LabelCustomizeRangePicker;
@@ -1793,6 +1793,12 @@ html {
1793
1793
  padding: 8px 11px 6px;
1794
1794
  border-bottom: 1px solid #f5f6fa;
1795
1795
  }
1796
+ .label-customize-range-picker-panel .check-wrapper .ant-checkbox-wrapper {
1797
+ pointer-events: none;
1798
+ }
1799
+ .label-customize-range-picker-panel .check-wrapper .ant-checkbox-input {
1800
+ pointer-events: auto;
1801
+ }
1796
1802
  .label-customize-range-picker-panel .pick-box {
1797
1803
  display: flex;
1798
1804
  justify-content: space-between;
@@ -8,6 +8,14 @@
8
8
  .check-wrapper {
9
9
  padding: 8px 11px 6px;
10
10
  border-bottom: 1px solid #f5f6fa;
11
+
12
+ .@{ant-prefix}-checkbox-wrapper {
13
+ pointer-events: none;
14
+ }
15
+
16
+ .@{ant-prefix}-checkbox-input {
17
+ pointer-events: auto;
18
+ }
11
19
  }
12
20
 
13
21
  .pick-box {
@@ -84,13 +84,11 @@ var LabelDatePicker = function LabelDatePicker(props) {
84
84
  };
85
85
 
86
86
  var handleLabelClick = function handleLabelClick() {
87
- var _a;
88
-
89
87
  if (!open) {
90
88
  setOpen(!open);
91
89
  }
92
90
 
93
- (_a = datePickerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
91
+ datePickerRef.current.focus();
94
92
  };
95
93
 
96
94
  var onBlur = function onBlur() {
@@ -116,9 +116,7 @@ var LabelInput = function LabelInput(props) {
116
116
  };
117
117
 
118
118
  var handleLabelClick = function handleLabelClick() {
119
- var _a;
120
-
121
- (_a = InputDomRef.current) === null || _a === void 0 ? void 0 : _a.focus();
119
+ InputDomRef.current.focus();
122
120
  };
123
121
 
124
122
  var onChangeInputType = react_1["default"].useCallback(function (nextInputType) {
@@ -88,10 +88,8 @@ var LabelNumberInput = function LabelNumberInput(props) {
88
88
  setFocused = _c[1];
89
89
 
90
90
  var handleLabelClick = function handleLabelClick() {
91
- var _a;
92
-
93
91
  setFocused(true);
94
- (_a = numberInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
92
+ numberInputRef.current.focus();
95
93
  };
96
94
 
97
95
  var handleFocus = function handleFocus() {
@@ -99,9 +97,9 @@ var LabelNumberInput = function LabelNumberInput(props) {
99
97
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(value);
100
98
  };
101
99
 
102
- var handleBlur = function handleBlur(e) {
100
+ var handleBlur = function handleBlur() {
103
101
  setFocused(false);
104
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
102
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(value);
105
103
  };
106
104
 
107
105
  var controlMinWidth = (labelSize === null || labelSize === void 0 ? void 0 : labelSize.width) ? labelSize.width + baseMinWidth : undefined;
@@ -115,7 +113,7 @@ var LabelNumberInput = function LabelNumberInput(props) {
115
113
  className: (0, classnames_1["default"])('label-number-input-field', {
116
114
  'label-number-input-focused': focused
117
115
  })
118
- }, react_1["default"].createElement(number_input_1["default"], __assign({}, (0, omit_1["default"])(props, ['onChange', 'onBlur', 'onFocus', 'className', 'label', 'placeholder']), {
116
+ }, react_1["default"].createElement(number_input_1["default"], __assign({}, (0, omit_1["default"])(props, ['onChange', 'onBlur', 'onFocus', 'className', 'label', 'placeholder', 'baseMinWidth']), {
119
117
  ref: numberInputRef,
120
118
  "data-value": !(0, isUndefined_1["default"])(value) ? "".concat(value).length : 0,
121
119
  value: value,
@@ -98,6 +98,7 @@ var LabelDatePicker = function LabelDatePicker(props) {
98
98
  };
99
99
 
100
100
  var handleOpenChange = function handleOpenChange(nextOpen) {
101
+ console.log('--');
101
102
  onOpenChange(nextOpen);
102
103
  };
103
104
 
@@ -92,13 +92,11 @@ var LabelSelect = function LabelSelect(props) {
92
92
  };
93
93
 
94
94
  var handleLabelClick = function handleLabelClick() {
95
- var _a;
96
-
97
95
  if (!open) {
98
96
  setOpen(!open);
99
97
  }
100
98
 
101
- (_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.focus();
99
+ selectRef.current.focus();
102
100
  };
103
101
 
104
102
  var onDropdownVisibleChange = function onDropdownVisibleChange(nextOpen) {
@@ -113,7 +111,7 @@ var LabelSelect = function LabelSelect(props) {
113
111
  }, react_1["default"].createElement(select_1["default"], __assign({
114
112
  maxTagCount: 3,
115
113
  showSearch: false
116
- }, (0, omit_1["default"])(props, ['open', 'onChange', 'className', 'label']), {
114
+ }, (0, omit_1["default"])(props, ['open', 'onChange', 'className', 'label', 'setOpen']), {
117
115
  open: open,
118
116
  ref: selectRef,
119
117
  size: "large",
@@ -104,9 +104,7 @@ var LabelTextArea = function LabelTextArea(props) {
104
104
  };
105
105
 
106
106
  var handleLabelClick = function handleLabelClick() {
107
- var _a;
108
-
109
- (_a = TextAreaDomRef.current) === null || _a === void 0 ? void 0 : _a.focus();
107
+ TextAreaDomRef.current.focus();
110
108
  };
111
109
 
112
110
  var handleChange = function handleChange(e) {
@@ -14,7 +14,7 @@ var locale = {
14
14
  lastWeek: '上周',
15
15
  month: '本月',
16
16
  lastMonth: '上月',
17
- quarter: '季度',
17
+ quarter: '本季度',
18
18
  lastQuarter: '上季度',
19
19
  last7days: '最近7天',
20
20
  last14days: '最近14天',
@@ -1,10 +1,10 @@
1
1
  export interface FilterIntType {
2
2
  value: string;
3
3
  enableMinus?: boolean;
4
- preValue: string;
4
+ preValue?: string;
5
5
  }
6
6
  export declare const filterInt: ({ value, enableMinus, preValue }: FilterIntType) => string;
7
7
  export interface FilterFloatType extends FilterIntType {
8
- precision: number;
8
+ precision?: number;
9
9
  }
10
- export declare const filterFloat: ({ value, preValue, precision, enableMinus }: FilterFloatType) => string;
10
+ export declare const filterFloat: ({ value, preValue, precision, enableMinus, }: FilterFloatType) => string;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.filterFloat = exports.filterInt = void 0;
8
+ var intNumberReg = /^-?\d+$/;
8
9
 
9
10
  var filterInt = function filterInt(_a) {
10
11
  var value = _a.value,
@@ -16,10 +17,8 @@ var filterInt = function filterInt(_a) {
16
17
  nextValue = value.replace(/\D/g, '');
17
18
  }
18
19
 
19
- var intNumberReg = /^-?\d+$/;
20
-
21
20
  if (nextValue && nextValue.length > 1 && !intNumberReg.test(nextValue)) {
22
- return preValue;
21
+ return preValue !== null && preValue !== void 0 ? preValue : '';
23
22
  }
24
23
 
25
24
  return nextValue;
@@ -29,8 +28,10 @@ exports.filterInt = filterInt;
29
28
 
30
29
  var filterFloat = function filterFloat(_a) {
31
30
  var value = _a.value,
32
- preValue = _a.preValue,
33
- precision = _a.precision,
31
+ _b = _a.preValue,
32
+ preValue = _b === void 0 ? '' : _b,
33
+ _c = _a.precision,
34
+ precision = _c === void 0 ? 2 : _c,
34
35
  enableMinus = _a.enableMinus;
35
36
  var nextValue = value.replace(/[^\d.\-]/g, '');
36
37
  var matchDecimalPoint = nextValue.match(/\./g) || [];
@@ -7,7 +7,7 @@ export interface StepNumberInputProps {
7
7
  /** 精度,只对float有效 */
8
8
  precision: number;
9
9
  /** 内容最大长度 */
10
- maxLength: number;
10
+ maxLength?: number;
11
11
  /** 指定输入框展示值的格式 */
12
12
  formatter?: (value: string) => string;
13
13
  /** 指定从 formatter 里转换回数字的方式,和 formatter 搭配使用 */
@@ -114,6 +114,8 @@ var bignumber_js_1 = __importDefault(require("bignumber.js"));
114
114
 
115
115
  var isUndefined_1 = __importDefault(require("lodash/isUndefined"));
116
116
 
117
+ var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
118
+
117
119
  var numberType_1 = require("./const/numberType");
118
120
 
119
121
  var countType_1 = require("./const/countType");
@@ -121,36 +123,30 @@ var countType_1 = require("./const/countType");
121
123
  var number_input_1 = __importDefault(require("../number-input"));
122
124
 
123
125
  var StepNumberInput = function StepNumberInput(props) {
124
- var value = props.value,
125
- onChange = props.onChange,
126
+ var _a = __read((0, useControllableValue_1["default"])(props, {
127
+ defaultValue: ''
128
+ }), 2),
129
+ value = _a[0],
130
+ setValue = _a[1];
131
+
132
+ var onChange = props.onChange,
126
133
  onBlur = props.onBlur,
127
134
  numberType = props.numberType,
128
135
  precision = props.precision,
129
136
  step = props.step,
130
137
  max = props.max,
131
138
  min = props.min,
132
- restProps = __rest(props, ["value", "onChange", "onBlur", "numberType", "precision", "step", "max", "min"]);
133
-
134
- var _a = __read(React.useState(''), 2),
135
- inputValue = _a[0],
136
- setInputValue = _a[1];
139
+ restProps = __rest(props, ["onChange", "onBlur", "numberType", "precision", "step", "max", "min"]);
137
140
 
138
- var resultValue = (0, isUndefined_1["default"])(value) ? inputValue : value;
139
- var isEmpty = (0, isUndefined_1["default"])(resultValue) || resultValue === '';
140
- var plusNumber = new bignumber_js_1["default"](resultValue).plus(step).toString();
141
- var minusNumber = new bignumber_js_1["default"](resultValue).minus(step).toString();
142
- var maxCondition = (0, isUndefined_1["default"])(max) ? false : max === Number(resultValue) || Number(max) < Number(plusNumber);
143
- var minCondition = (0, isUndefined_1["default"])(min) ? false : min === Number(resultValue) || Number(min) > Number(minusNumber);
141
+ var isEmpty = (0, isUndefined_1["default"])(value) || value === '';
142
+ var plusNumber = new bignumber_js_1["default"](value).plus(step).toString();
143
+ var minusNumber = new bignumber_js_1["default"](value).minus(step).toString();
144
+ var maxCondition = (0, isUndefined_1["default"])(max) ? false : max === Number(value) || Number(max) < Number(plusNumber);
145
+ var minCondition = (0, isUndefined_1["default"])(min) ? false : min === Number(value) || Number(min) > Number(minusNumber);
144
146
 
145
147
  var onNumberChange = function onNumberChange(lastValue) {
146
- if (resultValue !== lastValue) {
147
- if ((0, isUndefined_1["default"])(value)) {
148
- setInputValue(lastValue);
149
- }
150
-
151
- if (onChange) {
152
- onChange(lastValue);
153
- }
148
+ if (value !== lastValue) {
149
+ setValue(lastValue);
154
150
  }
155
151
  };
156
152
 
@@ -167,49 +163,26 @@ var StepNumberInput = function StepNumberInput(props) {
167
163
  newNumber = minCondition ? "".concat(min) : minusNumber;
168
164
  }
169
165
 
170
- if (value === undefined) {
171
- setInputValue(newNumber);
172
- }
173
-
174
- if (onChange) {
175
- onChange(newNumber);
176
- }
166
+ setValue(newNumber);
177
167
  };
178
168
 
179
169
  var onNumberBlur = function onNumberBlur() {
180
- if (resultValue === '-' || resultValue === '.') {
181
- if (value === undefined) {
182
- setInputValue('');
183
- }
170
+ var resultValue = value;
184
171
 
185
- if (onChange) {
186
- onChange('');
187
- }
172
+ if (value === '-' || value === '.') {
173
+ resultValue = '';
188
174
  }
189
175
 
190
- if (!(0, isUndefined_1["default"])(max) && Number(resultValue) > max) {
191
- if ((0, isUndefined_1["default"])(value)) {
192
- setInputValue("".concat(max));
193
- }
194
-
195
- if (onChange) {
196
- onChange("".concat(max));
197
- }
176
+ if (!(0, isUndefined_1["default"])(max) && Number(value) > max) {
177
+ resultValue = "".concat(max);
198
178
  }
199
179
 
200
- if (!(0, isUndefined_1["default"])(min) && Number(resultValue) < min) {
201
- if ((0, isUndefined_1["default"])(value)) {
202
- setInputValue("".concat(min));
203
- }
204
-
205
- if (onChange) {
206
- onChange("".concat(min));
207
- }
180
+ if (!(0, isUndefined_1["default"])(min) && Number(value) < min) {
181
+ resultValue = "".concat(min);
208
182
  }
209
183
 
210
- if (onBlur) {
211
- onBlur("".concat(resultValue) || '');
212
- }
184
+ setValue(resultValue);
185
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(resultValue);
213
186
  };
214
187
 
215
188
  return React.createElement("div", {
@@ -231,7 +204,7 @@ var StepNumberInput = function StepNumberInput(props) {
231
204
  'disabled-btn': isEmpty || maxCondition
232
205
  })
233
206
  }, "+"),
234
- value: "".concat(resultValue),
207
+ value: "".concat(value),
235
208
  onChange: onNumberChange,
236
209
  onBlur: onNumberBlur,
237
210
  numberType: numberType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assui",
3
- "version": "2.1.30",
3
+ "version": "2.1.33",
4
4
  "description": "react ui library",
5
5
  "author": "jason <usochen@gmail.com>",
6
6
  "main": "./lib/index.js",
@@ -72,5 +72,5 @@
72
72
  "node": ">=10.0.0"
73
73
  },
74
74
  "license": "MIT",
75
- "gitHead": "2eba46555ad72daf70aa5c31b1179c416c2bce13"
75
+ "gitHead": "7330af2e067f21810cd803f0ddaef53539f4b157"
76
76
  }