@autobest-ui/components 2.6.1 → 2.6.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.
@@ -30,6 +30,10 @@ export interface InputProps extends Omit<AdornProps, 'prefixCls' | 'children' |
30
30
  * 失去焦点的回调函数
31
31
  */
32
32
  onBlur?: (value: InputValue, name?: string) => void;
33
+ /**
34
+ * 用户触发keydown时的回调,主要用于键盘监听
35
+ */
36
+ onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>, name?: string) => void;
33
37
  }
34
38
  interface InputStates {
35
39
  value: string | undefined;
@@ -59,6 +63,7 @@ export declare class InputNotRef extends React.Component<InputPropsWithRef, Inpu
59
63
  onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
60
64
  onFocus: (ev: React.FocusEvent<HTMLInputElement>) => void;
61
65
  onBlur: (ev: React.FocusEvent<HTMLInputElement>) => void;
66
+ onKeyDown: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
62
67
  render(): JSX.Element;
63
68
  }
64
69
  declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
@@ -103,6 +103,14 @@ var InputNotRef = /** @class */function (_super) {
103
103
  onBlur(value, name);
104
104
  }
105
105
  };
106
+ _this.onKeyDown = function (ev) {
107
+ var _a = _this.props,
108
+ name = _a.name,
109
+ onKeyDown = _a.onKeyDown;
110
+ if (onKeyDown) {
111
+ onKeyDown(ev, name);
112
+ }
113
+ };
106
114
  _this.state = {
107
115
  value: props.defaultValue || ''
108
116
  };
@@ -162,7 +170,8 @@ var InputNotRef = /** @class */function (_super) {
162
170
  accept: accept,
163
171
  style: style,
164
172
  value: isFileUpload ? undefined : value || '',
165
- onChange: this.onChange
173
+ onChange: this.onChange,
174
+ onKeyDown: this.onKeyDown
166
175
  }));
167
176
  };
168
177
  InputNotRef.defaultProps = {
@@ -33,6 +33,10 @@ export interface TextAreaProps extends Omit<AdornProps, 'prefixCls' | 'children'
33
33
  * 失去焦点的回调函数
34
34
  */
35
35
  onBlur?: (value: string | undefined, name?: string) => void;
36
+ /**
37
+ * 用户触发keydown时的回调,主要用于键盘监听
38
+ */
39
+ onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>, name?: string) => void;
36
40
  }
37
41
  interface TextareaStates {
38
42
  value: string | undefined;
@@ -61,6 +65,7 @@ export declare class TextAreaNotRef extends React.Component<TextAreaPropsWithRef
61
65
  onChange: (ev: React.ChangeEvent<HTMLTextAreaElement>) => void;
62
66
  onFocus: (ev: React.FocusEvent<HTMLTextAreaElement>) => void;
63
67
  onBlur: (ev: React.FocusEvent<HTMLTextAreaElement>) => void;
68
+ onKeyDown: (ev: React.KeyboardEvent<HTMLTextAreaElement>) => void;
64
69
  renderSuffix(): React.ReactElement;
65
70
  render(): JSX.Element;
66
71
  }
@@ -91,6 +91,14 @@ var TextAreaNotRef = /** @class */function (_super) {
91
91
  onBlur(value, name);
92
92
  }
93
93
  };
94
+ _this.onKeyDown = function (ev) {
95
+ var _a = _this.props,
96
+ name = _a.name,
97
+ onKeyDown = _a.onKeyDown;
98
+ if (onKeyDown) {
99
+ onKeyDown(ev, name);
100
+ }
101
+ };
94
102
  var value = props.defaultValue || '';
95
103
  _this.state = {
96
104
  value: value,
@@ -154,7 +162,8 @@ var TextAreaNotRef = /** @class */function (_super) {
154
162
  disabled: disabled,
155
163
  style: style,
156
164
  value: value || '',
157
- onChange: this.onChange
165
+ onChange: this.onChange,
166
+ onKeyDown: this.onKeyDown
158
167
  }));
159
168
  };
160
169
  TextAreaNotRef.defaultProps = {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  export interface ControlArrowProps {
3
3
  cls: string;
4
- onKeyup: (ev: React.MouseEvent) => void;
5
- onKeydown: (ev: React.MouseEvent) => void;
4
+ onUp: (ev: React.MouseEvent) => void;
5
+ onDown: (ev: React.MouseEvent) => void;
6
6
  }
7
7
  export default function ControlArrow(props: ControlArrowProps): JSX.Element;
@@ -18,12 +18,12 @@ function ArrowIcon(props) {
18
18
  export default function ControlArrow(props) {
19
19
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
20
20
  className: "".concat(props.cls, "-up"),
21
- onMouseDown: props.onKeyup
21
+ onMouseDown: props.onUp
22
22
  }, /*#__PURE__*/React.createElement(ArrowIcon, {
23
23
  rotateDeg: -90
24
24
  })), /*#__PURE__*/React.createElement("span", {
25
25
  className: "".concat(props.cls, "-down"),
26
- onMouseDown: props.onKeydown
26
+ onMouseDown: props.onDown
27
27
  }, /*#__PURE__*/React.createElement(ArrowIcon, {
28
28
  rotateDeg: 90
29
29
  })));
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { AddListenerEventHandler } from '@autobest-ui/utils';
3
3
  import { InputProps, InputValue } from '../input/Input';
4
- export interface InputNumberProps extends Omit<InputProps, 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'onFocus' | 'suffix'> {
4
+ export interface InputNumberProps extends Omit<InputProps, 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'onFocus' | 'suffix' | 'onKeyDown'> {
5
5
  /**
6
6
  * 输入框默认值,用于非受控组件,配合ref使用
7
7
  */
@@ -55,6 +55,10 @@ export interface InputNumberProps extends Omit<InputProps, 'value' | 'defaultVal
55
55
  * 失去焦点的回调函数
56
56
  */
57
57
  onBlur?: (parserValue: number | undefined, name?: string) => void;
58
+ /**
59
+ * 用户触发keydown时的回调,主要用于键盘监听
60
+ */
61
+ onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>, parserValue: number | undefined, name?: string) => void;
58
62
  }
59
63
  interface InputNumberStates {
60
64
  originalValueStr: string | undefined;
@@ -102,8 +106,9 @@ export declare class InputNumberNotRef extends React.Component<InputNumberPropsW
102
106
  * 在输入结束后(onBlur时),触发最后一次
103
107
  */
104
108
  onChange: (originalValueStr: InputValue, name?: string) => void;
105
- onKeyup: (ev: React.MouseEvent) => void;
106
- onKeydown: (ev: React.MouseEvent) => void;
109
+ onUp: (ev: React.MouseEvent) => void;
110
+ onDown: (ev: React.MouseEvent) => void;
111
+ onKeyDown: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
107
112
  render(): JSX.Element;
108
113
  }
109
114
  declare const InputNumber: React.ForwardRefExoticComponent<InputNumberProps & React.RefAttributes<HTMLInputElement>>;
@@ -191,7 +191,7 @@ var InputNumberNotRef = /** @class */function (_super) {
191
191
  parserValue: parserValue
192
192
  });
193
193
  };
194
- _this.onKeyup = function (ev) {
194
+ _this.onUp = function (ev) {
195
195
  ev.preventDefault();
196
196
  if (_this.props.disabled) {
197
197
  return;
@@ -199,7 +199,7 @@ var InputNumberNotRef = /** @class */function (_super) {
199
199
  _this.setInputFocus();
200
200
  _this.changeValueWithStep(true);
201
201
  };
202
- _this.onKeydown = function (ev) {
202
+ _this.onDown = function (ev) {
203
203
  ev.preventDefault();
204
204
  if (_this.props.disabled) {
205
205
  return;
@@ -207,6 +207,14 @@ var InputNumberNotRef = /** @class */function (_super) {
207
207
  _this.setInputFocus();
208
208
  _this.changeValueWithStep(false);
209
209
  };
210
+ _this.onKeyDown = function (ev) {
211
+ var _a = _this.props,
212
+ name = _a.name,
213
+ onKeyDown = _a.onKeyDown;
214
+ if (onKeyDown) {
215
+ onKeyDown(ev, _this.state.parserValue, name);
216
+ }
217
+ };
210
218
  var defaultValueStr = toFixed(props.defaultValue, props.precision);
211
219
  _this.state = {
212
220
  originalValueStr: defaultValueStr,
@@ -258,12 +266,13 @@ var InputNumberNotRef = /** @class */function (_super) {
258
266
  name: name,
259
267
  value: originalValueStr,
260
268
  onChange: this.onChange,
269
+ onKeyDown: this.onKeyDown,
261
270
  onBlur: this.onBlur,
262
271
  onFocus: this.onFocus,
263
272
  suffix: controls ? /*#__PURE__*/React.createElement(ControlArrow, {
264
273
  cls: cls,
265
- onKeyup: this.onKeyup,
266
- onKeydown: this.onKeydown
274
+ onUp: this.onUp,
275
+ onDown: this.onDown
267
276
  }) : null
268
277
  });
269
278
  };
@@ -30,6 +30,10 @@ export interface InputProps extends Omit<AdornProps, 'prefixCls' | 'children' |
30
30
  * 失去焦点的回调函数
31
31
  */
32
32
  onBlur?: (value: InputValue, name?: string) => void;
33
+ /**
34
+ * 用户触发keydown时的回调,主要用于键盘监听
35
+ */
36
+ onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>, name?: string) => void;
33
37
  }
34
38
  interface InputStates {
35
39
  value: string | undefined;
@@ -59,6 +63,7 @@ export declare class InputNotRef extends React.Component<InputPropsWithRef, Inpu
59
63
  onChange: (ev: React.ChangeEvent<HTMLInputElement>) => void;
60
64
  onFocus: (ev: React.FocusEvent<HTMLInputElement>) => void;
61
65
  onBlur: (ev: React.FocusEvent<HTMLInputElement>) => void;
66
+ onKeyDown: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
62
67
  render(): JSX.Element;
63
68
  }
64
69
  declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
@@ -110,6 +110,14 @@ var InputNotRef = /** @class */function (_super) {
110
110
  onBlur(value, name);
111
111
  }
112
112
  };
113
+ _this.onKeyDown = function (ev) {
114
+ var _a = _this.props,
115
+ name = _a.name,
116
+ onKeyDown = _a.onKeyDown;
117
+ if (onKeyDown) {
118
+ onKeyDown(ev, name);
119
+ }
120
+ };
113
121
  _this.state = {
114
122
  value: props.defaultValue || ''
115
123
  };
@@ -169,7 +177,8 @@ var InputNotRef = /** @class */function (_super) {
169
177
  accept: accept,
170
178
  style: style,
171
179
  value: isFileUpload ? undefined : value || '',
172
- onChange: this.onChange
180
+ onChange: this.onChange,
181
+ onKeyDown: this.onKeyDown
173
182
  }));
174
183
  };
175
184
  InputNotRef.defaultProps = {
@@ -33,6 +33,10 @@ export interface TextAreaProps extends Omit<AdornProps, 'prefixCls' | 'children'
33
33
  * 失去焦点的回调函数
34
34
  */
35
35
  onBlur?: (value: string | undefined, name?: string) => void;
36
+ /**
37
+ * 用户触发keydown时的回调,主要用于键盘监听
38
+ */
39
+ onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>, name?: string) => void;
36
40
  }
37
41
  interface TextareaStates {
38
42
  value: string | undefined;
@@ -61,6 +65,7 @@ export declare class TextAreaNotRef extends React.Component<TextAreaPropsWithRef
61
65
  onChange: (ev: React.ChangeEvent<HTMLTextAreaElement>) => void;
62
66
  onFocus: (ev: React.FocusEvent<HTMLTextAreaElement>) => void;
63
67
  onBlur: (ev: React.FocusEvent<HTMLTextAreaElement>) => void;
68
+ onKeyDown: (ev: React.KeyboardEvent<HTMLTextAreaElement>) => void;
64
69
  renderSuffix(): React.ReactElement;
65
70
  render(): JSX.Element;
66
71
  }
@@ -98,6 +98,14 @@ var TextAreaNotRef = /** @class */function (_super) {
98
98
  onBlur(value, name);
99
99
  }
100
100
  };
101
+ _this.onKeyDown = function (ev) {
102
+ var _a = _this.props,
103
+ name = _a.name,
104
+ onKeyDown = _a.onKeyDown;
105
+ if (onKeyDown) {
106
+ onKeyDown(ev, name);
107
+ }
108
+ };
101
109
  var value = props.defaultValue || '';
102
110
  _this.state = {
103
111
  value: value,
@@ -161,7 +169,8 @@ var TextAreaNotRef = /** @class */function (_super) {
161
169
  disabled: disabled,
162
170
  style: style,
163
171
  value: value || '',
164
- onChange: this.onChange
172
+ onChange: this.onChange,
173
+ onKeyDown: this.onKeyDown
165
174
  }));
166
175
  };
167
176
  TextAreaNotRef.defaultProps = {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  export interface ControlArrowProps {
3
3
  cls: string;
4
- onKeyup: (ev: React.MouseEvent) => void;
5
- onKeydown: (ev: React.MouseEvent) => void;
4
+ onUp: (ev: React.MouseEvent) => void;
5
+ onDown: (ev: React.MouseEvent) => void;
6
6
  }
7
7
  export default function ControlArrow(props: ControlArrowProps): JSX.Element;
@@ -25,12 +25,12 @@ function ArrowIcon(props) {
25
25
  function ControlArrow(props) {
26
26
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
27
27
  className: "".concat(props.cls, "-up"),
28
- onMouseDown: props.onKeyup
28
+ onMouseDown: props.onUp
29
29
  }, /*#__PURE__*/_react.default.createElement(ArrowIcon, {
30
30
  rotateDeg: -90
31
31
  })), /*#__PURE__*/_react.default.createElement("span", {
32
32
  className: "".concat(props.cls, "-down"),
33
- onMouseDown: props.onKeydown
33
+ onMouseDown: props.onDown
34
34
  }, /*#__PURE__*/_react.default.createElement(ArrowIcon, {
35
35
  rotateDeg: 90
36
36
  })));
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { AddListenerEventHandler } from '@autobest-ui/utils';
3
3
  import { InputProps, InputValue } from '../input/Input';
4
- export interface InputNumberProps extends Omit<InputProps, 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'onFocus' | 'suffix'> {
4
+ export interface InputNumberProps extends Omit<InputProps, 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'onFocus' | 'suffix' | 'onKeyDown'> {
5
5
  /**
6
6
  * 输入框默认值,用于非受控组件,配合ref使用
7
7
  */
@@ -55,6 +55,10 @@ export interface InputNumberProps extends Omit<InputProps, 'value' | 'defaultVal
55
55
  * 失去焦点的回调函数
56
56
  */
57
57
  onBlur?: (parserValue: number | undefined, name?: string) => void;
58
+ /**
59
+ * 用户触发keydown时的回调,主要用于键盘监听
60
+ */
61
+ onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>, parserValue: number | undefined, name?: string) => void;
58
62
  }
59
63
  interface InputNumberStates {
60
64
  originalValueStr: string | undefined;
@@ -102,8 +106,9 @@ export declare class InputNumberNotRef extends React.Component<InputNumberPropsW
102
106
  * 在输入结束后(onBlur时),触发最后一次
103
107
  */
104
108
  onChange: (originalValueStr: InputValue, name?: string) => void;
105
- onKeyup: (ev: React.MouseEvent) => void;
106
- onKeydown: (ev: React.MouseEvent) => void;
109
+ onUp: (ev: React.MouseEvent) => void;
110
+ onDown: (ev: React.MouseEvent) => void;
111
+ onKeyDown: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
107
112
  render(): JSX.Element;
108
113
  }
109
114
  declare const InputNumber: React.ForwardRefExoticComponent<InputNumberProps & React.RefAttributes<HTMLInputElement>>;
@@ -198,7 +198,7 @@ var InputNumberNotRef = /** @class */function (_super) {
198
198
  parserValue: parserValue
199
199
  });
200
200
  };
201
- _this.onKeyup = function (ev) {
201
+ _this.onUp = function (ev) {
202
202
  ev.preventDefault();
203
203
  if (_this.props.disabled) {
204
204
  return;
@@ -206,7 +206,7 @@ var InputNumberNotRef = /** @class */function (_super) {
206
206
  _this.setInputFocus();
207
207
  _this.changeValueWithStep(true);
208
208
  };
209
- _this.onKeydown = function (ev) {
209
+ _this.onDown = function (ev) {
210
210
  ev.preventDefault();
211
211
  if (_this.props.disabled) {
212
212
  return;
@@ -214,6 +214,14 @@ var InputNumberNotRef = /** @class */function (_super) {
214
214
  _this.setInputFocus();
215
215
  _this.changeValueWithStep(false);
216
216
  };
217
+ _this.onKeyDown = function (ev) {
218
+ var _a = _this.props,
219
+ name = _a.name,
220
+ onKeyDown = _a.onKeyDown;
221
+ if (onKeyDown) {
222
+ onKeyDown(ev, _this.state.parserValue, name);
223
+ }
224
+ };
217
225
  var defaultValueStr = (0, _utils.toFixed)(props.defaultValue, props.precision);
218
226
  _this.state = {
219
227
  originalValueStr: defaultValueStr,
@@ -265,12 +273,13 @@ var InputNumberNotRef = /** @class */function (_super) {
265
273
  name: name,
266
274
  value: originalValueStr,
267
275
  onChange: this.onChange,
276
+ onKeyDown: this.onKeyDown,
268
277
  onBlur: this.onBlur,
269
278
  onFocus: this.onFocus,
270
279
  suffix: controls ? /*#__PURE__*/_react.default.createElement(_ControlArrow.default, {
271
280
  cls: cls,
272
- onKeyup: this.onKeyup,
273
- onKeydown: this.onKeydown
281
+ onUp: this.onUp,
282
+ onDown: this.onDown
274
283
  }) : null
275
284
  });
276
285
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobest-ui/components",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
4
4
  "private": false,
5
5
  "description": "components common ui for React",
6
6
  "main": "lib/index.js",
@@ -52,5 +52,5 @@
52
52
  "dependencies": {
53
53
  "@autobest-ui/utils": "^2.1.0"
54
54
  },
55
- "gitHead": "566745071d550b3d75324bbce5f8f678a4ea7d41"
55
+ "gitHead": "f64d407139633d75ed431712909c7d255988efac"
56
56
  }