@autobest-ui/components 2.9.2-alpha.0 → 2.10.0-alpha.0

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 (81) hide show
  1. package/esm/affix/index.d.ts +3 -3
  2. package/esm/affix/index.js +2 -2
  3. package/esm/carousel/index.d.ts +2 -2
  4. package/esm/carousel/index.js +1 -1
  5. package/esm/checkbox/CheckboxGroup.d.ts +1 -0
  6. package/esm/index.d.ts +2 -0
  7. package/esm/index.js +2 -1
  8. package/esm/input-number/getParserOriginalValue.d.ts +26 -0
  9. package/esm/input-number/getParserOriginalValue.js +73 -0
  10. package/esm/input-number/index.d.ts +20 -7
  11. package/esm/input-number/index.js +57 -48
  12. package/esm/loading-icon/index.d.ts +1 -2
  13. package/esm/loading-icon/index.js +2 -4
  14. package/esm/modal/index.d.ts +3 -3
  15. package/esm/modal/index.js +2 -2
  16. package/esm/move/index.d.ts +6 -6
  17. package/esm/move/index.js +5 -5
  18. package/esm/popover/index.d.ts +1 -1
  19. package/esm/popover/index.js +7 -2
  20. package/esm/radio/Radio.d.ts +4 -0
  21. package/esm/radio/Radio.js +80 -0
  22. package/esm/radio/RadioGroup.d.ts +16 -0
  23. package/esm/radio/RadioGroup.js +106 -0
  24. package/esm/radio/context.d.ts +5 -0
  25. package/esm/radio/context.js +4 -0
  26. package/esm/radio/index.d.ts +3 -0
  27. package/esm/radio/index.js +2 -0
  28. package/esm/radio/interface.d.ts +17 -0
  29. package/esm/radio/interface.js +1 -0
  30. package/esm/radio/style/index.css +1 -0
  31. package/esm/select/index.d.ts +2 -2
  32. package/esm/select/index.js +1 -1
  33. package/esm/select/style/index.css +1 -1
  34. package/esm/style.css +1 -1
  35. package/esm/table/index.d.ts +2 -2
  36. package/esm/table/index.js +1 -1
  37. package/esm/tabs/index.d.ts +2 -2
  38. package/esm/tabs/index.js +1 -1
  39. package/esm/trigger/index.d.ts +5 -5
  40. package/esm/trigger/index.js +5 -5
  41. package/lib/affix/index.d.ts +3 -3
  42. package/lib/affix/index.js +2 -2
  43. package/lib/carousel/index.d.ts +2 -2
  44. package/lib/carousel/index.js +1 -1
  45. package/lib/checkbox/CheckboxGroup.d.ts +1 -0
  46. package/lib/index.d.ts +2 -0
  47. package/lib/index.js +13 -0
  48. package/lib/input-number/getParserOriginalValue.d.ts +26 -0
  49. package/lib/input-number/getParserOriginalValue.js +79 -0
  50. package/lib/input-number/index.d.ts +20 -7
  51. package/lib/input-number/index.js +55 -46
  52. package/lib/loading-icon/index.d.ts +1 -2
  53. package/lib/loading-icon/index.js +2 -4
  54. package/lib/modal/index.d.ts +3 -3
  55. package/lib/modal/index.js +2 -2
  56. package/lib/move/index.d.ts +6 -6
  57. package/lib/move/index.js +5 -5
  58. package/lib/popover/index.d.ts +1 -1
  59. package/lib/popover/index.js +7 -2
  60. package/lib/radio/Radio.d.ts +4 -0
  61. package/lib/radio/Radio.js +91 -0
  62. package/lib/radio/RadioGroup.d.ts +16 -0
  63. package/lib/radio/RadioGroup.js +117 -0
  64. package/lib/radio/context.d.ts +5 -0
  65. package/lib/radio/context.js +15 -0
  66. package/lib/radio/index.d.ts +3 -0
  67. package/lib/radio/index.js +20 -0
  68. package/lib/radio/interface.d.ts +17 -0
  69. package/lib/radio/interface.js +5 -0
  70. package/lib/radio/style/index.css +1 -0
  71. package/lib/select/index.d.ts +2 -2
  72. package/lib/select/index.js +1 -1
  73. package/lib/select/style/index.css +1 -1
  74. package/lib/style.css +1 -1
  75. package/lib/table/index.d.ts +2 -2
  76. package/lib/table/index.js +1 -1
  77. package/lib/tabs/index.d.ts +2 -2
  78. package/lib/tabs/index.js +1 -1
  79. package/lib/trigger/index.d.ts +5 -5
  80. package/lib/trigger/index.js +5 -5
  81. package/package.json +5 -4
@@ -0,0 +1,26 @@
1
+ interface GetParserOriginalValueParams {
2
+ originalValue: string | number;
3
+ prevParserValue: string | number;
4
+ trimStartZero?: boolean;
5
+ precision?: number;
6
+ isRounding?: boolean;
7
+ min?: number;
8
+ max?: number;
9
+ skipError?: boolean;
10
+ }
11
+ /**
12
+ *
13
+ * @param originalValueParam
14
+ * @param trimStartZero
15
+ * @param prevParserValue
16
+ * @param precision
17
+ * @param isRounding
18
+ * @param min
19
+ * @param max
20
+ * @param skipError 遇到首位0、小于最小值、大于最大值问题,不对value进行处理,输出控制台警告
21
+ */
22
+ export default function ({ originalValue: originalValueParam, trimStartZero, prevParserValue, precision, isRounding, min, max, skipError }: GetParserOriginalValueParams): {
23
+ parserValueStr: string | undefined;
24
+ parserValue: string | number | undefined;
25
+ };
26
+ export {};
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = _default;
7
+ var _utils = require("@autobest-ui/utils");
8
+ var _constants = require("./constants");
9
+ function consoleError(msg) {
10
+ if (process.env.NODE_ENV === 'development') {
11
+ // eslint-disable-next-line no-console
12
+ console.error(msg);
13
+ }
14
+ }
15
+ function getValueBetweenMinAndMax(value, min, max, skipError) {
16
+ var currentValue = parseFloat(value);
17
+ if (!(0, _utils.isBlank)(min) && currentValue < min) {
18
+ if (!skipError) {
19
+ return min;
20
+ }
21
+ consoleError('Value is smaller than min');
22
+ }
23
+ if (!(0, _utils.isBlank)(max) && currentValue > max) {
24
+ if (!skipError) {
25
+ return max;
26
+ }
27
+ consoleError('Value is greater than max');
28
+ }
29
+ return currentValue;
30
+ }
31
+ /**
32
+ *
33
+ * @param originalValueParam
34
+ * @param trimStartZero
35
+ * @param prevParserValue
36
+ * @param precision
37
+ * @param isRounding
38
+ * @param min
39
+ * @param max
40
+ * @param skipError 遇到首位0、小于最小值、大于最大值问题,不对value进行处理,输出控制台警告
41
+ */
42
+ function _default(_a) {
43
+ var originalValueParam = _a.originalValue,
44
+ trimStartZero = _a.trimStartZero,
45
+ prevParserValue = _a.prevParserValue,
46
+ precision = _a.precision,
47
+ isRounding = _a.isRounding,
48
+ min = _a.min,
49
+ max = _a.max,
50
+ skipError = _a.skipError;
51
+ // 输入为空
52
+ if ((0, _utils.isBlank)(originalValueParam)) {
53
+ return {
54
+ parserValueStr: undefined,
55
+ parserValue: undefined
56
+ };
57
+ }
58
+ var originalValue = typeof originalValueParam === 'number' ? originalValueParam.toString() : originalValueParam;
59
+ var hasFirstZero = _constants.FirstZeroReg.test(originalValue);
60
+ if (!_constants.NumberReg.test(originalValue) || trimStartZero && hasFirstZero) {
61
+ if (!skipError) {
62
+ return {
63
+ parserValueStr: (0, _utils.isBlank)(prevParserValue) ? undefined : prevParserValue.toString(),
64
+ parserValue: prevParserValue
65
+ };
66
+ }
67
+ consoleError('Value has first 0');
68
+ }
69
+ var currentValue = getValueBetweenMinAndMax(originalValue, min, max, skipError);
70
+ var parserString = (0, _utils.toFixed)(currentValue, precision, isRounding);
71
+ if (hasFirstZero) {
72
+ // 补齐首位0
73
+ parserString = parserString.padStart(originalValue.split('.')[0].length, '0');
74
+ }
75
+ return {
76
+ parserValueStr: parserString,
77
+ parserValue: hasFirstZero ? parserString : (0, _utils.getNumberFromString)(parserString)
78
+ };
79
+ }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { AddListenerEventHandler } from '@autobest-ui/utils';
2
+ import { AddListenerEventRemoveHandler } from '@autobest-ui/utils';
3
3
  import { InputProps, InputValue } from '../input/Input';
4
- export interface InputNumberProps extends Omit<InputProps<number>, 'value' | 'defaultValue' | 'suffix' | 'onKeyDown'> {
4
+ export interface InputNumberProps extends Omit<InputProps<number | string>, 'value' | 'defaultValue' | 'suffix' | 'onKeyDown'> {
5
5
  /**
6
6
  * 输入框默认值,用于非受控组件,配合ref使用
7
7
  */
@@ -42,15 +42,23 @@ export interface InputNumberProps extends Omit<InputProps<number>, 'value' | 'de
42
42
  * 值发生改变将会触发,onChange是不合法将不在触发,只在最后onBlur时再触发一次
43
43
  * 该方法主要用在用户输入内容判断上,不要在此方法中执行修改value的操作
44
44
  */
45
- onContinualChange?: (originalValue: string | number | undefined, parserValue: number | undefined, name?: string) => void;
45
+ onContinualChange?: (originalValue: string | number | undefined, parserValue: string | number | undefined, name?: string) => void;
46
46
  /**
47
47
  * 用户触发keydown时的回调,主要用于键盘监听
48
48
  */
49
- onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>, parserValue: number | undefined, name?: string) => void;
49
+ onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>, parserValue: string | number | undefined, name?: string) => void;
50
+ /**
51
+ * 是否过滤开头的0,默认true过滤
52
+ */
53
+ trimStartZero?: boolean;
54
+ /**
55
+ * 处理用户输入值时是否要四舍五入,默认true
56
+ */
57
+ isRounding?: boolean;
50
58
  }
51
59
  interface InputNumberStates {
52
60
  originalValueStr: string | undefined;
53
- parserValue: number | undefined;
61
+ parserValue: string | number | undefined;
54
62
  }
55
63
  interface InputNumberPropsWithRef extends InputNumberProps {
56
64
  /**
@@ -61,12 +69,14 @@ interface InputNumberPropsWithRef extends InputNumberProps {
61
69
  export declare class InputNumberNotRef extends React.Component<InputNumberPropsWithRef, InputNumberStates> {
62
70
  prefixCls: string;
63
71
  inputRef: React.RefObject<HTMLInputElement>;
64
- keyboardHandler: AddListenerEventHandler;
72
+ keyboardHandler: AddListenerEventRemoveHandler;
65
73
  static defaultProps: {
66
74
  defaultValue: string;
67
75
  controls: boolean;
68
76
  step: number;
69
77
  keyboard: boolean;
78
+ trimStartZero: boolean;
79
+ isRounding: boolean;
70
80
  };
71
81
  constructor(props: InputNumberPropsWithRef);
72
82
  static getDerivedStateFromProps(nextProps: InputNumberPropsWithRef, prevStates: InputNumberStates): InputNumberStates;
@@ -75,7 +85,10 @@ export declare class InputNumberNotRef extends React.Component<InputNumberPropsW
75
85
  * 解析用户输入的内容,并返回解析后的结果
76
86
  * @param originalValue
77
87
  */
78
- getParserOriginalValue: (originalValue: string) => string | undefined;
88
+ getParserOriginalValue: (originalValue: string) => {
89
+ parserValueStr: string;
90
+ parserValue: string | number;
91
+ };
79
92
  /**
80
93
  * 键盘和点击上下按钮更新value值
81
94
  * @param isUp
@@ -12,6 +12,7 @@ var _utils = require("@autobest-ui/utils");
12
12
  var _Input = _interopRequireDefault(require("../input/Input"));
13
13
  var _constants = require("./constants");
14
14
  var _ControlArrow = _interopRequireDefault(require("./ControlArrow"));
15
+ var _getParserOriginalValue = _interopRequireDefault(require("./getParserOriginalValue"));
15
16
  var __extends = void 0 && (void 0).__extends || function () {
16
17
  var _extendStatics = function extendStatics(d, b) {
17
18
  _extendStatics = Object.setPrototypeOf || {
@@ -57,25 +58,10 @@ var InputNumberNotRef = /** @class */function (_super) {
57
58
  * @param originalValue
58
59
  */
59
60
  _this.getParserOriginalValue = function (originalValue) {
60
- // 输入为空
61
- if ((0, _utils.isBlank)(originalValue)) {
62
- return undefined;
63
- }
64
- if (!_constants.NumberReg.test(originalValue) || _constants.FirstZeroReg.test(originalValue)) {
65
- return (0, _utils.isBlank)(_this.state.parserValue) ? undefined : _this.state.parserValue.toString();
66
- }
67
- var _a = _this.props,
68
- min = _a.min,
69
- max = _a.max,
70
- precision = _a.precision;
71
- var currentValue = parseFloat(originalValue);
72
- if (!(0, _utils.isBlank)(min) && currentValue < min) {
73
- currentValue = min;
74
- }
75
- if (!(0, _utils.isBlank)(max) && currentValue > max) {
76
- currentValue = max;
77
- }
78
- return (0, _utils.toFixed)(currentValue, precision);
61
+ return (0, _getParserOriginalValue.default)(__assign(__assign({}, _this.props), {
62
+ originalValue: originalValue,
63
+ prevParserValue: _this.state.parserValue
64
+ }));
79
65
  };
80
66
  /**
81
67
  * 键盘和点击上下按钮更新value值
@@ -83,14 +69,20 @@ var InputNumberNotRef = /** @class */function (_super) {
83
69
  */
84
70
  _this.changeValueWithStep = function (isUp) {
85
71
  var step = _this.props.step;
86
- var prevValue = _this.state.parserValue ? _this.state.parserValue : 0;
72
+ var prevParserValue = _this.state.parserValue;
73
+ var prevValue = prevParserValue ? typeof prevParserValue === 'number' ? prevParserValue : parseFloat(prevParserValue) : 0;
87
74
  var keyboardValue = isUp ? prevValue + step : prevValue - step;
88
- var parserValueStr = _this.getParserOriginalValue(keyboardValue.toString());
89
- var parserValue = (0, _utils.getNumberFromString)(parserValueStr);
90
- var _a = _this.props,
91
- name = _a.name,
92
- onChange = _a.onChange,
93
- onContinualChange = _a.onContinualChange;
75
+ var keyboardValueStr = keyboardValue.toString();
76
+ if (typeof prevParserValue === 'string' && _constants.FirstZeroReg.test(prevParserValue)) {
77
+ keyboardValueStr = keyboardValueStr.padStart(prevParserValue.length, '0');
78
+ }
79
+ var _a = _this.getParserOriginalValue(keyboardValueStr),
80
+ parserValueStr = _a.parserValueStr,
81
+ parserValue = _a.parserValue;
82
+ var _b = _this.props,
83
+ name = _b.name,
84
+ onChange = _b.onChange,
85
+ onContinualChange = _b.onContinualChange;
94
86
  if (prevValue !== parserValue) {
95
87
  if (onContinualChange) {
96
88
  onContinualChange(parserValueStr, parserValue, name);
@@ -131,14 +123,13 @@ var InputNumberNotRef = /** @class */function (_super) {
131
123
  }
132
124
  var onFocus = _this.props.onFocus;
133
125
  if (onFocus) {
134
- var parserValueStr = _this.getParserOriginalValue(originalValueStr);
135
- var parserValue = (0, _utils.getNumberFromString)(parserValueStr);
126
+ var parserValue = _this.getParserOriginalValue(originalValueStr).parserValue;
136
127
  onFocus(parserValue, name);
137
128
  }
138
129
  };
139
130
  _this.onBlur = function (originalValueStr, name) {
140
131
  if (_this.keyboardHandler) {
141
- _this.keyboardHandler.remove();
132
+ _this.keyboardHandler();
142
133
  _this.keyboardHandler = null;
143
134
  }
144
135
  if (_this.props.disabled) {
@@ -148,8 +139,9 @@ var InputNumberNotRef = /** @class */function (_super) {
148
139
  onBlur = _a.onBlur,
149
140
  onChange = _a.onChange,
150
141
  onContinualChange = _a.onContinualChange;
151
- var parserValueStr = _this.getParserOriginalValue(originalValueStr);
152
- var parserValue = (0, _utils.getNumberFromString)(parserValueStr);
142
+ var _b = _this.getParserOriginalValue(originalValueStr),
143
+ parserValueStr = _b.parserValueStr,
144
+ parserValue = _b.parserValue;
153
145
  _this.setState({
154
146
  originalValueStr: parserValueStr
155
147
  });
@@ -179,11 +171,12 @@ var InputNumberNotRef = /** @class */function (_super) {
179
171
  if (_this.props.disabled) {
180
172
  return;
181
173
  }
182
- var parserValueStr = _this.getParserOriginalValue(originalValueStr);
183
- var parserValue = (0, _utils.getNumberFromString)(parserValueStr);
184
- var _a = _this.props,
185
- onChange = _a.onChange,
186
- onContinualChange = _a.onContinualChange;
174
+ var _a = _this.getParserOriginalValue(originalValueStr),
175
+ parserValueStr = _a.parserValueStr,
176
+ parserValue = _a.parserValue;
177
+ var _b = _this.props,
178
+ onChange = _b.onChange,
179
+ onContinualChange = _b.onContinualChange;
187
180
  if (onContinualChange) {
188
181
  onContinualChange(originalValueStr, parserValue, name);
189
182
  }
@@ -227,10 +220,16 @@ var InputNumberNotRef = /** @class */function (_super) {
227
220
  onKeyDown(ev, _this.state.parserValue, name);
228
221
  }
229
222
  };
230
- var defaultValueStr = (0, _utils.toFixed)(props.defaultValue, props.precision);
223
+ var _a = (0, _getParserOriginalValue.default)(__assign(__assign({}, props), {
224
+ originalValue: props.defaultValue,
225
+ prevParserValue: undefined,
226
+ skipError: true
227
+ })),
228
+ parserValueStr = _a.parserValueStr,
229
+ parserValue = _a.parserValue;
231
230
  _this.state = {
232
- originalValueStr: defaultValueStr,
233
- parserValue: (0, _utils.getNumberFromString)(defaultValueStr)
231
+ originalValueStr: parserValueStr,
232
+ parserValue: parserValue
234
233
  };
235
234
  return _this;
236
235
  }
@@ -241,9 +240,15 @@ var InputNumberNotRef = /** @class */function (_super) {
241
240
  if (nextProps.value !== prevStates.parserValue && (
242
241
  // 兼容外部传入空string/null的情况, 只有当一个值非空时,才会重新重置State信息
243
242
  !(0, _utils.isBlank)(nextProps.value) || !(0, _utils.isBlank)(prevStates.parserValue))) {
244
- var fixedValueStr = (0, _utils.toFixed)(nextProps.value, nextProps.precision);
245
- nextState.parserValue = (0, _utils.getNumberFromString)(fixedValueStr);
246
- nextState.originalValueStr = fixedValueStr;
243
+ var _a = (0, _getParserOriginalValue.default)(__assign(__assign({}, nextProps), {
244
+ originalValue: nextProps.value,
245
+ prevParserValue: prevStates.parserValue,
246
+ skipError: true
247
+ })),
248
+ parserValueStr = _a.parserValueStr,
249
+ parserValue = _a.parserValue;
250
+ nextState.parserValue = parserValue;
251
+ nextState.originalValueStr = parserValueStr;
247
252
  }
248
253
  }
249
254
  if ((0, _utils.isEmptyObject)(nextState)) {
@@ -253,7 +258,7 @@ var InputNumberNotRef = /** @class */function (_super) {
253
258
  };
254
259
  InputNumberNotRef.prototype.componentWillUnmount = function () {
255
260
  if (this.keyboardHandler) {
256
- this.keyboardHandler.remove();
261
+ this.keyboardHandler();
257
262
  this.keyboardHandler = null;
258
263
  }
259
264
  };
@@ -269,7 +274,8 @@ var InputNumberNotRef = /** @class */function (_super) {
269
274
  style = _b.style,
270
275
  prefix = _b.prefix,
271
276
  controls = _b.controls,
272
- checkValueOnMounted = _b.checkValueOnMounted;
277
+ checkValueOnMounted = _b.checkValueOnMounted,
278
+ maxLength = _b.maxLength;
273
279
  var originalValueStr = this.state.originalValueStr;
274
280
  return /*#__PURE__*/_react.default.createElement(_Input.default, {
275
281
  ref: (0, _components.composeRef)(this.inputRef, upperRef),
@@ -289,14 +295,17 @@ var InputNumberNotRef = /** @class */function (_super) {
289
295
  onUp: this.onUp,
290
296
  onDown: this.onDown
291
297
  }) : null,
292
- checkValueOnMounted: checkValueOnMounted
298
+ checkValueOnMounted: checkValueOnMounted,
299
+ maxLength: maxLength
293
300
  });
294
301
  };
295
302
  InputNumberNotRef.defaultProps = {
296
303
  defaultValue: '',
297
304
  controls: true,
298
305
  step: 1,
299
- keyboard: true
306
+ keyboard: true,
307
+ trimStartZero: true,
308
+ isRounding: true
300
309
  };
301
310
  return InputNumberNotRef;
302
311
  }(_react.default.Component);
@@ -1,7 +1,6 @@
1
- import React, { CSSProperties } from 'react';
1
+ import React from 'react';
2
2
  export interface LoadingIconProps {
3
3
  className?: string;
4
- style?: CSSProperties;
5
4
  }
6
5
  declare const _default: React.MemoExoticComponent<(props: LoadingIconProps) => JSX.Element>;
7
6
  export default _default;
@@ -9,11 +9,9 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _classnames = _interopRequireDefault(require("classnames"));
10
10
  var cls = 'ab-svg-loading';
11
11
  var LoadingIcon = function LoadingIcon(props) {
12
- var className = props.className,
13
- style = props.style;
12
+ var className = props.className;
14
13
  return /*#__PURE__*/_react.default.createElement("span", {
15
- className: (0, _classnames.default)(className, cls),
16
- style: style
14
+ className: (0, _classnames.default)(className, cls)
17
15
  }, /*#__PURE__*/_react.default.createElement("svg", {
18
16
  xmlns: "http://www.w3.org/2000/svg",
19
17
  width: "24",
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { AddListenerEventHandler } from '@autobest-ui/utils';
2
+ import { AddListenerEventRemoveHandler } from '@autobest-ui/utils';
3
3
  declare type PrevPopupSize = {
4
4
  width: number;
5
5
  height: number;
@@ -92,8 +92,8 @@ declare class Modal extends React.Component<ModalProps, ModalStates> {
92
92
  maskClosable: boolean;
93
93
  hiddenScroll: boolean;
94
94
  };
95
- clickOutsideHandler: AddListenerEventHandler | null;
96
- touchOutsideHandler: AddListenerEventHandler | null;
95
+ clickOutsideHandler: AddListenerEventRemoveHandler;
96
+ touchOutsideHandler: AddListenerEventRemoveHandler;
97
97
  popupTimer: any;
98
98
  affixTimer: any;
99
99
  popupRef: React.RefObject<HTMLDivElement>;
@@ -265,11 +265,11 @@ var Modal = /** @class */function (_super) {
265
265
  Modal.prototype.clearOutsideHandler = function () {
266
266
  this.clearPopupTimer();
267
267
  if (this.clickOutsideHandler) {
268
- this.clickOutsideHandler.remove();
268
+ this.clickOutsideHandler();
269
269
  this.clickOutsideHandler = null;
270
270
  }
271
271
  if (this.touchOutsideHandler) {
272
- this.touchOutsideHandler.remove();
272
+ this.touchOutsideHandler();
273
273
  this.touchOutsideHandler = null;
274
274
  }
275
275
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { AddListenerEventHandler } from '@autobest-ui/utils';
2
+ import { AddListenerEventRemoveHandler } from '@autobest-ui/utils';
3
3
  import { Position } from './utils';
4
4
  export interface MoveProps {
5
5
  /**
@@ -82,11 +82,11 @@ declare class Move extends React.Component<MoveProps> {
82
82
  isTouchScale: boolean;
83
83
  isForceUpdatePlacement: boolean;
84
84
  moveRef: React.RefObject<HTMLElement>;
85
- resizeHandler: AddListenerEventHandler | null;
86
- startHandler: AddListenerEventHandler | null;
87
- mousewheelHandler: AddListenerEventHandler | null;
88
- moveHandler: AddListenerEventHandler | null;
89
- endHandler: AddListenerEventHandler | null;
85
+ resizeHandler: AddListenerEventRemoveHandler;
86
+ startHandler: AddListenerEventRemoveHandler;
87
+ mousewheelHandler: AddListenerEventRemoveHandler;
88
+ moveHandler: AddListenerEventRemoveHandler;
89
+ endHandler: AddListenerEventRemoveHandler;
90
90
  updateTimer: any;
91
91
  componentDidMount(): void;
92
92
  componentDidUpdate(prevProps?: MoveProps): void;
package/lib/move/index.js CHANGED
@@ -320,26 +320,26 @@ var Move = /** @class */function (_super) {
320
320
  Move.prototype.componentWillUnmount = function () {
321
321
  clearTimeout(this.updateTimer);
322
322
  if (this.startHandler) {
323
- this.startHandler.remove();
323
+ this.startHandler();
324
324
  this.startHandler = null;
325
325
  }
326
326
  if (this.mousewheelHandler) {
327
- this.mousewheelHandler.remove();
327
+ this.mousewheelHandler();
328
328
  this.mousewheelHandler = null;
329
329
  }
330
330
  if (this.resizeHandler) {
331
- this.resizeHandler.remove();
331
+ this.resizeHandler();
332
332
  this.resizeHandler = null;
333
333
  }
334
334
  this.clearHandler();
335
335
  };
336
336
  Move.prototype.clearHandler = function () {
337
337
  if (this.moveHandler) {
338
- this.moveHandler.remove();
338
+ this.moveHandler();
339
339
  this.moveHandler = null;
340
340
  }
341
341
  if (this.endHandler) {
342
- this.endHandler.remove();
342
+ this.endHandler();
343
343
  this.endHandler = null;
344
344
  }
345
345
  };
@@ -32,7 +32,7 @@ export interface PopoverProps extends Pick<TriggerProps, Exclude<keyof TriggerPr
32
32
  }
33
33
  export declare type PopoverPlacement = TriggerPlacement;
34
34
  export declare type PopoverTriggerType = TriggerType;
35
- declare function Popover({ theme, innerClassName, closeClassName, arrowClassName, hiddenClose, tip, closeIcon, ...extraProps }: PopoverProps): JSX.Element;
35
+ declare function Popover({ theme, innerClassName, closeClassName, arrowClassName, hiddenClose, tip, closeIcon, maxHeight, ...extraProps }: PopoverProps): JSX.Element;
36
36
  declare namespace Popover {
37
37
  var defaultProps: {
38
38
  hiddenClose: boolean;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _utils = require("@autobest-ui/utils");
10
11
  var _trigger = _interopRequireDefault(require("../trigger"));
11
12
  var __assign = void 0 && (void 0).__assign || function () {
12
13
  __assign = Object.assign || function (t) {
@@ -40,7 +41,8 @@ function Popover(_a) {
40
41
  hiddenClose = _a.hiddenClose,
41
42
  tip = _a.tip,
42
43
  closeIcon = _a.closeIcon,
43
- extraProps = __rest(_a, ["theme", "innerClassName", "closeClassName", "arrowClassName", "hiddenClose", "tip", "closeIcon"]);
44
+ maxHeight = _a.maxHeight,
45
+ extraProps = __rest(_a, ["theme", "innerClassName", "closeClassName", "arrowClassName", "hiddenClose", "tip", "closeIcon", "maxHeight"]);
44
46
  var triggerEl = _react.default.useRef(null);
45
47
  var _c = _react.default.useState({}),
46
48
  arrowStyle = _c[0],
@@ -78,7 +80,10 @@ function Popover(_a) {
78
80
  className: (0, _classnames.default)("".concat(cls, "-arrow"), arrowClassName),
79
81
  style: arrowStyle
80
82
  }), /*#__PURE__*/_react.default.createElement("div", {
81
- className: innerClass
83
+ className: innerClass,
84
+ style: !(0, _utils.isBlank)(maxHeight) ? {
85
+ maxHeight: "".concat(maxHeight, "px")
86
+ } : undefined
82
87
  }, tip));
83
88
  }
84
89
  return /*#__PURE__*/_react.default.createElement(_trigger.default, __assign({}, extraProps, {
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { RadioProps } from './interface';
3
+ declare const Radio: FC<RadioProps>;
4
+ export default Radio;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ var _utils = require("@autobest-ui/utils");
12
+ var _context = _interopRequireDefault(require("./context"));
13
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+ var __assign = void 0 && (void 0).__assign || function () {
16
+ __assign = Object.assign || function (t) {
17
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
18
+ s = arguments[i];
19
+ for (var p in s) {
20
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
21
+ }
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ var cls = 'ab-radio';
28
+ var Radio = function Radio(props) {
29
+ var _a;
30
+ var _b = props.checked,
31
+ propsChecked = _b === void 0 ? false : _b,
32
+ name = props.name,
33
+ onChange = props.onChange,
34
+ children = props.children,
35
+ disabled = props.disabled,
36
+ value = props.value,
37
+ className = props.className;
38
+ var _c = (0, _react.useState)(propsChecked),
39
+ checked = _c[0],
40
+ setChecked = _c[1];
41
+ var groupContext = (0, _react.useContext)(_context.default);
42
+ var mergedProps = (0, _utils.isEmptyObject)(groupContext) ? {
43
+ name: name,
44
+ disabled: disabled
45
+ } : {
46
+ name: groupContext.name,
47
+ disabled: 'disabled' in props ? disabled : groupContext.disabled
48
+ };
49
+ if ('checked' in props && propsChecked !== checked) {
50
+ setChecked(propsChecked);
51
+ }
52
+ (0, _react.useEffect)(function () {
53
+ // radioGroup
54
+ if ('value' in groupContext) {
55
+ setChecked(groupContext.value === value);
56
+ }
57
+ }, [groupContext, value]);
58
+ var onRadioChange = function onRadioChange(e) {
59
+ if (mergedProps.disabled) {
60
+ return;
61
+ }
62
+ if (onChange) {
63
+ onChange(e, mergedProps.name);
64
+ return;
65
+ }
66
+ // radioGroup
67
+ if (groupContext.onChange) {
68
+ groupContext.onChange(e.target.value, mergedProps.name);
69
+ return;
70
+ }
71
+ setChecked(!checked);
72
+ };
73
+ var onClick = function onClick(e) {
74
+ e.stopPropagation();
75
+ };
76
+ return /*#__PURE__*/_react.default.createElement("label", {
77
+ onClick: onClick,
78
+ className: (0, _classnames.default)(cls, (_a = {}, _a["".concat(cls, "-disabled")] = mergedProps.disabled, _a["".concat(cls, "-checked")] = checked, _a), groupContext.className, className)
79
+ }, /*#__PURE__*/_react.default.createElement("input", __assign({
80
+ type: "radio",
81
+ checked: checked,
82
+ value: value,
83
+ onChange: onRadioChange
84
+ }, mergedProps)), /*#__PURE__*/_react.default.createElement("span", {
85
+ className: "".concat(cls, "-control")
86
+ }), /*#__PURE__*/_react.default.createElement("span", {
87
+ className: "".concat(cls, "-child")
88
+ }, children));
89
+ };
90
+ var _default = Radio;
91
+ exports.default = _default;
@@ -0,0 +1,16 @@
1
+ import { Component } from 'react';
2
+ import { RadioGroupProps, RadioValue } from './interface';
3
+ interface RadioGroupState {
4
+ value: RadioValue;
5
+ }
6
+ declare class RadioGroup extends Component<RadioGroupProps, RadioGroupState> {
7
+ constructor(props: any);
8
+ static getDerivedStateFromProps(nextProps: RadioGroupProps, prevState: RadioGroupState): {
9
+ value: RadioValue;
10
+ };
11
+ onRadioChange: (v: RadioValue, n: string) => void;
12
+ renderRadioGroup: () => JSX.Element;
13
+ renderRadioList: () => JSX.Element;
14
+ render(): JSX.Element;
15
+ }
16
+ export default RadioGroup;