1 | import React from 'react';
|
2 | import PropTypes from 'prop-types';
|
3 |
|
4 | import getUID from '../global/get-uid';
|
5 |
|
6 | import Shortcuts from './shortcuts';
|
7 |
|
8 | export default function shortcutsHOC(ComposedComponent) {
|
9 |
|
10 | return class WithShortcuts extends React.Component {
|
11 | static propTypes = {
|
12 | rgShortcutsOptions: PropTypes.object,
|
13 | rgShortcutsMap: PropTypes.object
|
14 | };
|
15 |
|
16 | _shortcutsScopeUid = getUID('rg-shortcuts-');
|
17 |
|
18 | render() {
|
19 | const {rgShortcutsOptions, rgShortcutsMap, ...props} = this.props;
|
20 |
|
21 | return (
|
22 | <Shortcuts
|
23 | scope={this._shortcutsScopeUid}
|
24 | map={rgShortcutsMap}
|
25 | options={rgShortcutsOptions}
|
26 | disabled={rgShortcutsOptions.disabled}
|
27 | >
|
28 | <ComposedComponent {...props}/>
|
29 | </Shortcuts>
|
30 | );
|
31 | }
|
32 | };
|
33 | }
|