From 4c0e0180fcb325f47c79f084d6fc691c6f411e32 Mon Sep 17 00:00:00 2001 From: bindoon Date: Tue, 9 Jul 2019 16:55:00 +0800 Subject: [PATCH] fix(NumberPicker): support innerAfter. Close #860 --- docs/number-picker/demo/format.md | 6 ++- docs/number-picker/index.md | 1 + src/number-picker/main.scss | 12 +++++ src/number-picker/number-picker.jsx | 70 ++++++++++++++++------------- 4 files changed, 58 insertions(+), 31 deletions(-) diff --git a/docs/number-picker/demo/format.md b/docs/number-picker/demo/format.md index 61a6710b43..bd7504bdf0 100644 --- a/docs/number-picker/demo/format.md +++ b/docs/number-picker/demo/format.md @@ -17,7 +17,11 @@ const intlize = val => Intl.NumberFormat('en-US').format(val); ReactDOM.render(
- + +

+ `${val}%`} defaultValue={85} /> +

+
, mountNode ); diff --git a/docs/number-picker/index.md b/docs/number-picker/index.md index 4ec43942ae..b847facc4c 100644 --- a/docs/number-picker/index.md +++ b/docs/number-picker/index.md @@ -49,6 +49,7 @@ | format | 格式化当前值

**签名**:
Function(value: Number) => String/Number
**参数**:
_value_: {Number} null
**返回值**:
{String/Number} null
| Function | - | | upBtnProps | 增加按钮的props | Object | - | | downBtnProps | 减少按钮的props | Object | - | +| label | label | ReactNode | - | ## ARIA and KeyBoard diff --git a/src/number-picker/main.scss b/src/number-picker/main.scss index 0a82634a0b..8006aaad61 100644 --- a/src/number-picker/main.scss +++ b/src/number-picker/main.scss @@ -24,6 +24,10 @@ input { padding-right: 2px; } + + .#{$css-prefix}input-control { + padding-right: 0; + } } .#{$css-prefix}btn { @@ -57,6 +61,7 @@ opacity: 0; transition: opacity .24s linear .1s; height: 100%; + display: block; } &:hover #{$number-picker-prefix}-handler { @@ -167,6 +172,7 @@ } } #{$number-picker-prefix}-inline[dir="rtl"] { + .#{$css-prefix}btn { border-radius: 0; } @@ -180,3 +186,9 @@ border-bottom-left-radius: $form-element-medium-corner !important; } } +#{$number-picker-prefix}-normal[dir="rtl"] { + .#{$css-prefix}input .#{$css-prefix}input-control { + padding-left: 0; + } +} + diff --git a/src/number-picker/number-picker.jsx b/src/number-picker/number-picker.jsx index c68865fadf..5f82abe391 100644 --- a/src/number-picker/number-picker.jsx +++ b/src/number-picker/number-picker.jsx @@ -106,6 +106,14 @@ class NumberPicker extends React.Component { * 减少按钮的props */ downBtnProps: PropTypes.object, + /** + * 内联 label + */ + label: PropTypes.node, + /** + * inner after + */ + innerAfter: PropTypes.node, rtl: PropTypes.bool, }; @@ -422,8 +430,10 @@ class NumberPicker extends React.Component { autoFocus, editable, state, + label, upBtnProps = {}, downBtnProps = {}, + innerAfter, } = this.props; const prefixCls = `${prefix}number-picker`; @@ -448,38 +458,37 @@ class NumberPicker extends React.Component { } } - let innerAfter = null, + let extra = null, innerAfterClassName = null, addonBefore = null, addonAfter = null; if (type === 'normal') { - innerAfter = [ - , - , - ]; - innerAfterClassName = `${prefixCls}-handler`; + extra = ( + + + + + ); } else { addonBefore = (