You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/input-number/index.jsx

75 lines
2.0 KiB

import PropTypes from '../_util/vue-types';
import { initDefaultProps, getOptionProps } from '../_util/props-util';
import classNames from 'classnames';
import Icon from '../icon';
import VcInputNumber from '../vc-input-number/src';
7 years ago
export const InputNumberProps = {
prefixCls: PropTypes.string,
min: PropTypes.number,
max: PropTypes.number,
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
step: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
7 years ago
defaultValue: PropTypes.number,
tabIndex: PropTypes.number,
disabled: PropTypes.bool,
size: PropTypes.oneOf(['large', 'small', 'default']),
formatter: PropTypes.func,
parser: PropTypes.func,
decimalSeparator: PropTypes.string,
7 years ago
placeholder: PropTypes.string,
name: PropTypes.string,
id: PropTypes.string,
precision: PropTypes.number,
autoFocus: PropTypes.bool,
};
7 years ago
const InputNumber = {
name: 'AInputNumber',
7 years ago
model: {
prop: 'value',
event: 'change',
},
props: initDefaultProps(InputNumberProps, {
prefixCls: 'ant-input-number',
step: 1,
}),
methods: {
focus() {
this.$refs.inputNumberRef.focus();
7 years ago
},
blur() {
this.$refs.inputNumberRef.blur();
7 years ago
},
},
render() {
const { size, ...others } = getOptionProps(this);
7 years ago
const inputNumberClass = classNames({
[`${this.prefixCls}-lg`]: size === 'large',
[`${this.prefixCls}-sm`]: size === 'small',
});
const upIcon = <Icon type="up" class={`${this.prefixCls}-handler-up-inner`} />;
const downIcon = <Icon type="down" class={`${this.prefixCls}-handler-down-inner`} />;
7 years ago
const vcInputNumberprops = {
props: {
upHandler: upIcon,
downHandler: downIcon,
7 years ago
...others,
},
class: inputNumberClass,
ref: 'inputNumberRef',
on: this.$listeners,
};
return <VcInputNumber {...vcInputNumberprops} />;
7 years ago
},
};
/* istanbul ignore next */
InputNumber.install = function(Vue) {
Vue.component(InputNumber.name, InputNumber);
};
export default InputNumber;