assui 2.1.29 → 2.1.32

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.
@@ -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,
@@ -92,7 +92,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
92
92
  var messages = useContext(LocaleContext);
93
93
  var dataSource = radioList !== null && radioList !== void 0 ? radioList : getDefaultRadioList(messages);
94
94
  useEffect(function () {
95
- var foundItem = dataSource.find(function (item) {
95
+ var filterItemList = dataSource.filter(function (item) {
96
96
  if (!date) return false;
97
97
 
98
98
  var _a = __read(item.value, 2),
@@ -109,8 +109,21 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
109
109
 
110
110
  return false;
111
111
  });
112
- var data = foundItem ? foundItem.key : null;
113
- setRadioKey(data);
112
+
113
+ if (filterItemList.length === 0) {
114
+ setRadioKey(null);
115
+ } else if (filterItemList.length > 1) {
116
+ var findItem = filterItemList.find(function (item) {
117
+ return item.key === radioKey;
118
+ });
119
+ var resutRadioKey = findItem ? findItem.key : filterItemList[0].key;
120
+ setRadioKey(resutRadioKey);
121
+ } else {
122
+ var _a = __read(filterItemList, 1),
123
+ item = _a[0];
124
+
125
+ setRadioKey(item.key);
126
+ }
114
127
  }, [date]);
115
128
 
116
129
  var onDiyTimeChange = function onDiyTimeChange(event) {
@@ -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,
@@ -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,
@@ -153,7 +153,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
153
153
  var messages = (0, react_1.useContext)(context_1["default"]);
154
154
  var dataSource = radioList !== null && radioList !== void 0 ? radioList : (0, defaultRadioList_1["default"])(messages);
155
155
  (0, react_1.useEffect)(function () {
156
- var foundItem = dataSource.find(function (item) {
156
+ var filterItemList = dataSource.filter(function (item) {
157
157
  if (!date) return false;
158
158
 
159
159
  var _a = __read(item.value, 2),
@@ -170,8 +170,21 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
170
170
 
171
171
  return false;
172
172
  });
173
- var data = foundItem ? foundItem.key : null;
174
- setRadioKey(data);
173
+
174
+ if (filterItemList.length === 0) {
175
+ setRadioKey(null);
176
+ } else if (filterItemList.length > 1) {
177
+ var findItem = filterItemList.find(function (item) {
178
+ return item.key === radioKey;
179
+ });
180
+ var resutRadioKey = findItem ? findItem.key : filterItemList[0].key;
181
+ setRadioKey(resutRadioKey);
182
+ } else {
183
+ var _a = __read(filterItemList, 1),
184
+ item = _a[0];
185
+
186
+ setRadioKey(item.key);
187
+ }
175
188
  }, [date]);
176
189
 
177
190
  var onDiyTimeChange = function onDiyTimeChange(event) {
@@ -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,
@@ -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.29",
3
+ "version": "2.1.32",
4
4
  "description": "react ui library",
5
5
  "author": "jason <usochen@gmail.com>",
6
6
  "main": "./lib/index.js",
@@ -34,8 +34,8 @@
34
34
  "@tinymce/tinymce-react": "^4.0.0",
35
35
  "@types/react-beautiful-dnd": "^13.1.2",
36
36
  "@types/react-resizable": "^3.0.0",
37
- "a-icons": "^1.0.76",
38
- "aa-utils": "^2.0.30",
37
+ "a-icons": "^1.0.77",
38
+ "aa-utils": "^2.0.31",
39
39
  "ahooks": "^3.0.8",
40
40
  "bignumber.js": "^9.0.1",
41
41
  "copy-to-clipboard": "^3.3.1",
@@ -72,5 +72,5 @@
72
72
  "node": ">=10.0.0"
73
73
  },
74
74
  "license": "MIT",
75
- "gitHead": "3b77552dd5b6cde1ca3da5aaaacc9f62bff36c95"
75
+ "gitHead": "522946669dc72275c25173889993140a9af4be81"
76
76
  }