mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-29 03:45:15 +00:00
45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
||
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||
|
import React from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import classNames from 'classnames';
|
||
|
import { mapToCssModules, tagPropType } from './utils';
|
||
|
import InputGroupText from './InputGroupText';
|
||
|
var propTypes = {
|
||
|
tag: tagPropType,
|
||
|
addonType: PropTypes.oneOf(['prepend', 'append']).isRequired,
|
||
|
children: PropTypes.node,
|
||
|
className: PropTypes.string,
|
||
|
cssModule: PropTypes.object
|
||
|
};
|
||
|
var defaultProps = {
|
||
|
tag: 'div'
|
||
|
};
|
||
|
|
||
|
var InputGroupAddon = function InputGroupAddon(props) {
|
||
|
var className = props.className,
|
||
|
cssModule = props.cssModule,
|
||
|
Tag = props.tag,
|
||
|
addonType = props.addonType,
|
||
|
children = props.children,
|
||
|
attributes = _objectWithoutPropertiesLoose(props, ["className", "cssModule", "tag", "addonType", "children"]);
|
||
|
|
||
|
var classes = mapToCssModules(classNames(className, 'input-group-' + addonType), cssModule); // Convenience to assist with transition
|
||
|
|
||
|
if (typeof children === 'string') {
|
||
|
return /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, {
|
||
|
className: classes
|
||
|
}), /*#__PURE__*/React.createElement(InputGroupText, {
|
||
|
children: children
|
||
|
}));
|
||
|
}
|
||
|
|
||
|
return /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, {
|
||
|
className: classes,
|
||
|
children: children
|
||
|
}));
|
||
|
};
|
||
|
|
||
|
InputGroupAddon.propTypes = propTypes;
|
||
|
InputGroupAddon.defaultProps = defaultProps;
|
||
|
export default InputGroupAddon;
|