forked from vkbansal/react-contextmenu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu-item.js
More file actions
62 lines (49 loc) · 1.48 KB
/
Copy pathmenu-item.js
File metadata and controls
62 lines (49 loc) · 1.48 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
57
58
59
60
61
62
import React from "react";
import classnames from "classnames";
import assign from "object-assign";
import monitor from "./monitor";
let { PropTypes } = React;
const MenuItem = React.createClass({
displayName: "MenuItem",
propTypes: {
onClick: PropTypes.func.isRequired,
data: PropTypes.object,
disabled: PropTypes.bool,
preventClose: PropTypes.bool
},
getDefaultProps() {
return {
disabled: false,
data: {},
attributes: {}
};
},
handleClick(event) {
let { disabled, onClick, data, preventClose } = this.props;
event.preventDefault();
if (disabled) return;
var newData = {}
assign(newData, data, monitor.getItem());
if (typeof onClick === "function") {
onClick(event, newData);
}
if (preventClose) return;
monitor.hideMenu();
},
render() {
let { disabled, children, attributes: { className = "", ...props } } = this.props,
menuItemClassNames = `react-context-menu-item ${className}`;
const classes = classnames({
"react-context-menu-link": true,
disabled
});
return (
<div className={menuItemClassNames} {...props}>
<a href="#" className={classes} onClick={this.handleClick}>
{children}
</a>
</div>
);
}
});
export default MenuItem;