Skip Navigation

Drag and Drop

Allows creating Drag-and-Drop File Uploader. You can also define button to open local file system from the application and upload file for handling data from it.

drag and drop


In order to be used, the DragAndDropComponent has to be imported:

import {DragAndDropComponent} from "sabre-ngv-UIComponents/dragAndDropFileInput/DragAndDropComponent";

This component does not take any parameters, it is just the body which contains the obligatory dependencies for the proper works of the drag-and-drop functionality. Inside this component you need to put code defining support for drag-and-drop functionality:

        onDragStart={e => this.onDragEvent(e)}
        onDragEnter={e => this.onDragEvent(e)}
        onDragOver={e => this.onDragEvent(e)}
        onDragLeave={e => this.onDragEvent(e)}
        onDrop={e => this.onDragEvent(e)}
        <div className="contents">
            <span className="fileName">{fileName}</span>
            <span>Drag & Drop File</span>
                className="btn-success select-file-button"
                Select File

Adding <Button> inside component is optional. It performs manually opening file system to choose file from and uploading file. For this button to work properly you also need to add invisible input on which select action can be performed:

        onChange={e => this.uploadFile(e)}

Keep in mind that you need to define handling of DragEvent methods. A 'drop' event is used to handle dropping files into the designated area. The other events are used to visualize the dragging action.

You can read more about possible events here: DragEvent.