@evg-b/evg-ui
Version:
EVG-UI library inspired by Material Design.
81 lines (72 loc) • 2.47 kB
JavaScript
import _extends from '@babel/runtime/helpers/extends';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import '@babel/runtime/helpers/slicedToArray';
import withStyles from '../styles/withStyles.js';
import '@babel/runtime/helpers/construct';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/defineProperty';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
var styles = {
base: {
zIndex: 1
},
start: {
order: -1,
marginLeft: 0,
marginRight: '32px'
},
end: {
order: 1
}
};
/**
* Компонент для правильного позиционирования и отображения action в list.
* Таких как Button, Checkbox, Radio, Switch и др.
*/
var ListItemAction = /*#__PURE__*/React.forwardRef(function ListItemAction(props, ref) {
var classes = props.classes,
className = props.className,
children = props.children,
component = props.component,
position = props.position,
otherProps = _objectWithoutProperties(props, ["classes", "className", "children", "component", "position"]);
var Component = component;
return /*#__PURE__*/React.createElement(Component, _extends({
className: classNames(classes.base, classes[position], className)
}, otherProps, {
ref: ref
}), children);
});
ListItemAction.propTypes = {
/**
* Это контент между открывающим и закрывающим тегом компонента.
*/
children: PropTypes.node,
/**
* Объект содержит jss стили компонента.
*/
classes: PropTypes.object,
/**
* Чтобы указать CSS классы, используйте этот атрибут.
*/
className: PropTypes.string,
/**
* Корневой узел. Это HTML элемент или компонент.
*/
component: PropTypes.elementType,
/**
* Позиционирование внутри родительского компонента.
*/
position: PropTypes.oneOf(['start', 'end'])
};
ListItemAction.defaultProps = {
component: 'span',
position: 'end'
};
ListItemAction.displayName = 'ListItemActionEVG';
var ListItemAction$1 = withStyles(styles)(ListItemAction);
export default ListItemAction$1;