(backendOrModule)
| 28 | }; |
| 29 | |
| 30 | export default function DragDropContext(backendOrModule) { |
| 31 | checkDecoratorArguments('DragDropContext', 'backend', ...arguments); // eslint-disable-line prefer-rest-params |
| 32 | |
| 33 | const backend = unpackBackendForEs5Users(backendOrModule); |
| 34 | const childContext = createChildContext(backend); |
| 35 | |
| 36 | return function decorateContext(DecoratedComponent) { |
| 37 | const displayName = |
| 38 | DecoratedComponent.displayName || |
| 39 | DecoratedComponent.name || |
| 40 | 'Component'; |
| 41 | |
| 42 | class DragDropContextContainer extends Component { |
| 43 | static DecoratedComponent = DecoratedComponent; |
| 44 | |
| 45 | static displayName = `DragDropContext(${displayName})`; |
| 46 | |
| 47 | static childContextTypes = CHILD_CONTEXT_TYPES; |
| 48 | |
| 49 | getDecoratedComponentInstance() { |
| 50 | invariant( |
| 51 | this.child, |
| 52 | 'In order to access an instance of the decorated component it can ' + |
| 53 | 'not be a stateless component.', |
| 54 | ); |
| 55 | return this.child; |
| 56 | } |
| 57 | |
| 58 | getManager() { |
| 59 | return childContext.dragDropManager; |
| 60 | } |
| 61 | |
| 62 | getChildContext() { |
| 63 | return childContext; |
| 64 | } |
| 65 | |
| 66 | render() { |
| 67 | return ( |
| 68 | <DecoratedComponent |
| 69 | {...this.props} |
| 70 | ref={child => (this.child = child)} |
| 71 | /> |
| 72 | ); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | return hoistStatics(DragDropContextContainer, DecoratedComponent); |
| 77 | }; |
| 78 | } |
no test coverage detected