ant-design/components/input-number/index.tsx

36 lines
930 B
TypeScript
Raw Normal View History

2016-09-21 11:54:53 +08:00
import React from 'react';
import classNames from 'classnames';
import RcInputNumber from 'rc-input-number';
2015-07-01 14:48:47 +08:00
export interface InputNumberProps {
prefixCls?: string;
min?: number;
max?: number;
value?: number;
step?: number | string;
defaultValue?: number;
onChange?: (value: number) => void;
disabled?: boolean;
size?: 'large' | 'small' | 'default';
placeholder?: string;
style?: React.CSSProperties;
className?: string;
}
export default class InputNumber extends React.Component<InputNumberProps, any> {
static defaultProps = {
prefixCls: 'ant-input-number',
step: 1,
2016-07-13 11:14:24 +08:00
};
2015-07-01 14:48:47 +08:00
render() {
2016-12-19 15:19:15 +08:00
const { className, size, ...others } = this.props;
const inputNumberClass = classNames({
2016-03-30 10:58:37 +08:00
[`${this.props.prefixCls}-lg`]: size === 'large',
[`${this.props.prefixCls}-sm`]: size === 'small',
}, className);
2016-06-22 13:18:43 +08:00
return <RcInputNumber className={inputNumberClass} {...others} />;
2015-07-01 14:48:47 +08:00
}
}