Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// HOC to integrate mosaic drag functionality into any other component
class MosaicDragHandle extends Component {
static contextTypes = {
mosaicWindowActions: PropTypes.any,
mosaicActions: PropTypes.any,
mosaicId: PropTypes.any,
};
render() {
const { children, connectDragSource } = this.props;
return connectDragSource(children);
}
}
// connect the drag handle to react dnd
const ConnectedDragHandle = DragSource(MosaicDragType.WINDOW, dragSource, (connect, monitor) => ({
connectDragSource: connect.dragSource(),
}))(MosaicDragHandle);
export default ConnectedDragHandle;
const { position, path } = dropResult;
// dropping outside mosiac does nothing
if (!position || !path) {
return;
}
props.onDrop({
panelType: props.panel.type,
panelConfig: props.panel.panelConfig,
position,
path,
});
},
};
// boilerplate required by react-dnd
const DraggablePanelItem = DragSource(MosaicDragType.WINDOW, dragConfig, (connect, monitor) => {
return {
connectDragSource: connect.dragSource(),
};
})(PanelItem);
type OwnProps = {|
onPanelSelect: (panelType: string, panelConfig?: PanelConfig) => void,
selectedPanelType?: string,
|};
type Props = {
...OwnProps,
mosaicId: string,
mosaicLayout: any, // this is the opaque mosiac layout config object
changePanelLayout: (panelLayout: any) => void,
savePanelConfig: (SaveConfigPayload) => void,
};