Add formatter prop for InputNumber (#5178)

This commit is contained in:
偏右 2017-03-06 11:40:23 +08:00 committed by Wei Zhu
parent d09d6672b8
commit 43280ea790
5 changed files with 63 additions and 3 deletions

View File

@ -107,6 +107,38 @@ exports[`test renders ./components/input-number/demo/disabled.md correctly 1`] =
</div>
`;
exports[`test renders ./components/input-number/demo/formatter.md correctly 1`] = `
<div
class="ant-input-number">
<div
class="ant-input-number-handler-wrap">
<span
class="ant-input-number-handler ant-input-number-handler-up "
unselectable="unselectable">
<span
class="ant-input-number-handler-up-inner"
unselectable="unselectable" />
</span>
<span
class="ant-input-number-handler ant-input-number-handler-down "
unselectable="unselectable">
<span
class="ant-input-number-handler-down-inner"
unselectable="unselectable" />
</span>
</div>
<div
class="ant-input-number-input-wrap">
<input
autocomplete="off"
class="ant-input-number-input"
max="Infinity"
min="-Infinity"
value="$ 100" />
</div>
</div>
`;
exports[`test renders ./components/input-number/demo/size.md correctly 1`] = `
<div>
<div

View File

@ -0,0 +1,26 @@
---
order: 4
title:
zh-CN: 格式化展示
en-US: Formatter
---
## zh-CN
展示具有具体含义的数据。
## en-US
Display value within it's situation.
````jsx
import { InputNumber } from 'antd';
function onChange(value) {
console.log('changed', value);
}
ReactDOM.render(
<InputNumber formatter={value => `$ ${value}`} defaultValue={100} onChange={onChange} />
, mountNode);
````

View File

@ -19,6 +19,7 @@ When a numeric value needs to be provided.
| value | current value | number | |
| step | The number to which the current value is increased or decreased. It can be an integer or decimal. | number\|string | 1 |
| defaultValue | initial value | number | |
| onChange | The callback triggered when the value is changed. | Function(value: number | string) | |
| onChange | The callback triggered when the value is changed. | function(value: number | string) | |
| disabled | disable the input | boolean | false |
| size | width of input box | string | none |
| size | width of input box | string | - |
| formatter | Specifies the format of the value presented | function(value: number | string): string | - |

View File

@ -25,3 +25,4 @@ title: InputNumber
| onChange | 变化回调 | Function(value: number | string) | |
| disabled | 禁用 | boolean | false |
| size | 输入框大小 | string | 无 |
| formatter | 指定输入框展示值的格式 | function(value: number | string): string | - |

View File

@ -50,7 +50,7 @@
"rc-dropdown": "~1.4.8",
"rc-editor-mention": "~0.6.0",
"rc-form": "~1.3.0",
"rc-input-number": "~3.2.1",
"rc-input-number": "~3.3.0",
"rc-menu": "~5.0.9",
"rc-notification": "~1.4.0",
"rc-pagination": "~1.7.0",