forked from reactstrap/reactstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputGroupButton.js
More file actions
56 lines (47 loc) · 1.3 KB
/
InputGroupButton.js
File metadata and controls
56 lines (47 loc) · 1.3 KB
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
import React from 'react';
import PropTypes from 'prop-types';
import Button from './Button';
import InputGroupAddon from './InputGroupAddon';
import { warnOnce } from './utils';
const propTypes = {
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
addonType: PropTypes.oneOf(['prepend', 'append']).isRequired,
children: PropTypes.node,
groupClassName: PropTypes.string,
groupAttributes: PropTypes.object,
className: PropTypes.string,
cssModule: PropTypes.object,
};
const InputGroupButton = (props) => {
warnOnce('The "InputGroupButton" component has been deprecated.\nPlease use component "InputGroupAddon".');
let {
children,
groupClassName,
groupAttributes,
...propsWithoutGroup
} = props;
if (typeof children === 'string') {
let {
cssModule,
tag,
addonType,
...attributes
} = propsWithoutGroup;
const allGroupAttributes = {
...groupAttributes,
cssModule,
tag,
addonType
};
return (
<InputGroupAddon {...allGroupAttributes} className={groupClassName}>
<Button {...attributes} children={children} />
</InputGroupAddon>
);
}
return (
<InputGroupAddon {...props} children={children} />
);
};
InputGroupButton.propTypes = propTypes;
export default InputGroupButton;