summaryrefslogtreecommitdiffstats
path: root/src/react/PopupMenuItem.js
blob: 98e3f49c6327e83a78fe17a910997155902c0395 (plain)
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
import React from 'react';
import PropTypes from 'prop-types';

class PopupMenuItem extends React.Component {
	render() {
		const {itemId, value, onClick, selected, disabled} = this.props;
		const additionalClasses = selected ? 'selected' : disabled ? 'disabled' : '';
		return (
			<li
			    className={`sdc-menu-item ${additionalClasses}`}
			    onClick={event => {
				    event.stopPropagation();
			        onClick && !disabled && onClick(itemId);
			    }}>
				{value}
			</li>
		);
	}
}

PopupMenuItem.propTypes = {
	itemId: PropTypes.any,
	value: PropTypes.any,
	selected: PropTypes.bool,
	onClick: PropTypes.func,
	disabled: PropTypes.bool
};

PopupMenuItem.defaultProps = {
	selected: false,
	disabled: false
};

export default PopupMenuItem;