Browse Source

Add formatter prop for InputNumber (#5178)

pull/5183/head
偏右 8 years ago
committed by Wei Zhu
parent
commit
43280ea790
  1. 32
      components/input-number/__tests__/__snapshots__/demo.test.js.snap
  2. 26
      components/input-number/demo/formatter.md
  3. 5
      components/input-number/index.en-US.md
  4. 1
      components/input-number/index.zh-CN.md
  5. 2
      package.json

32
components/input-number/__tests__/__snapshots__/demo.test.js.snap

@ -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

26
components/input-number/demo/formatter.md

@ -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);
````

5
components/input-number/index.en-US.md

@ -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 | - |

1
components/input-number/index.zh-CN.md

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

2
package.json

@ -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",

Loading…
Cancel
Save