forked from alibaba-fusion/next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
group.jsx
89 lines (80 loc) · 2.25 KB
/
group.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import ConfigProvider from '../config-provider';
/**
* Input.Group
*/
class Group extends React.Component {
static propTypes = {
/**
* 样式前缀
*/
prefix: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
children: PropTypes.node,
/**
* 输入框前附加内容
*/
addonBefore: PropTypes.node,
/**
* 输入框前附加内容css
*/
addonBeforeClassName: PropTypes.string,
/**
* 输入框后附加内容
*/
addonAfter: PropTypes.node,
/**
* 输入框后额外css
*/
addonAfterClassName: PropTypes.string,
/**
* rtl
*/
rtl: PropTypes.bool,
};
static defaultProps = {
prefix: 'next-',
};
render() {
const {
className,
style,
children,
prefix,
addonBefore,
addonAfter,
addonBeforeClassName,
addonAfterClassName,
rtl,
disabled,
...others
} = this.props;
const cls = classNames({
[`${prefix}input-group`]: true,
[`${prefix}disabled`]: disabled,
[className]: !!className,
});
const addonCls = `${prefix}input-group-addon`;
const beforeCls = classNames(addonCls, {
[`${prefix}before`]: true,
[addonBeforeClassName]: addonBeforeClassName,
});
const afterCls = classNames(addonCls, {
[`${prefix}after`]: true,
[addonAfterClassName]: addonAfterClassName,
});
const before = addonBefore ? <span className={beforeCls}>{addonBefore}</span> : null;
const after = addonAfter ? <span className={afterCls}>{addonAfter}</span> : null;
return (
<span {...others} disabled={disabled} dir={rtl ? 'rtl' : undefined} className={cls} style={style}>
{before}
{children}
{after}
</span>
);
}
}
export default ConfigProvider.config(Group);