-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (41 loc) · 995 Bytes
/
index.js
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
exports.decorateConfig = (config) => {
config.hyperTabClose = Object.assign({
stopActiveClose: false,
}, config.hyperTabClose);
return config;
};
exports.decorateTab = (Tab, { React }) => {
const style = {
display: 'inline-block',
height: '100%',
width: 'calc(100% + 48px)',
marginLeft: '-24px',
};
return class extends React.Component {
constructor(props, context) {
super(props, context);
this.handleKeyClick = this.handleKeyClick.bind(this);
this.config = config.getConfig().hyperTabClose;
}
handleKeyClick(e) {
if (!e.altKey) return;
if (this.config.stopActiveClose && this.props.isActive) return;
e.stopPropagation();
this.props.onClose();
}
render() {
const currentText = this.props.text;
const props = Object.assign({}, this.props, {
text: React.createElement(
'span',
{
onClick: this.handleKeyClick,
style,
},
currentText,
)
});
return React.createElement(Tab, props);
}
};
};