A "file" explorer component for Vue.
Yarn: yarn add v-explorer
NPM: npm i v-explorer --save
import Vue from 'vue'
import {Explorer, renameOption, File} from 'v-explorer'
Vue.component('v-explorer', Explorer); //for global usage
new Vue({
el: '#app',
data: {
files: [],
options: []
},
mounted() {
this.options.push(renameOption);
this.files = [
new File(1, "Folder 1", 10, 'folder'),
];
this.files[0].dir = true;
setTimeout(function() {
this.files.push(new File(2, "Folder 2", 8, 'folder', 1, false, 0, true));
}.bind(this), 3000);
},
methods: {
contextmenu(e) {}, //handle context menu events
uploadCanceled(file) {}, //handle cancel events
fileRename(file) {}, //handle rename events
drop(files) {}, //handle drop events
move(e) {} //handle move events
}
});
<div id="app" style="height: 480px; width: 800px; border: 1px solid red; position: relative; top: 30px;">
<v-explorer height="50%"
:files="files" :options="options" @contextmenu="contextmenu"
@upload-canceled="uploadCanceled"
@file-rename="fileRename" @drop="drop" @move="move"></v-explorer>
</div>
Will render something like this: You can see the whole code of this example in dist/index.html and assets/js/app.js.
It will pass the selected file(s), if any, when a right click is executed.
It will pass the selected file when a left click is executed.
It will pass the selected file when a file is dragged.
It will pass the file that the upload has been canceled
It will pass the file that has been renamed
It will pass the file that has been dropped
It will pass the file that has been moved (after it's dropped)
It will pass the file that has been double clicked
The files that are going to be displayed
Checkout the File class.
The context menu options
Checkout the Option class.
The container's width (default: 100%|string)
The container's height (default: 100%|string)
The root letter (default C:|string)
Set if the user can rename the files (default: true|boolean)
You can also disable this options individually, checkout the Option class.
Explorer will try to resize the context menu options that don't fit will. It may have some unwanted behaviour so you can disable it by passing false to this option. (default: true|boolean)