easy-drag-and-drop-file-upload
Version:
Drag and Drop based file upload for Angular
643 lines (626 loc) • 33.4 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/platform-browser'), require('@angular/forms'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('easy-drag-and-drop-file-upload', ['exports', '@angular/core', '@angular/platform-browser', '@angular/forms', '@angular/common'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['easy-drag-and-drop-file-upload'] = {}, global.ng.core, global.ng.platformBrowser, global.ng.forms, global.ng.common));
}(this, (function (exports, i0, platformBrowser, forms, common) { 'use strict';
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () {
return e[k];
}
});
}
});
}
n['default'] = e;
return Object.freeze(n);
}
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
var EasyDragAndDropFileUploadService = /** @class */ (function () {
function EasyDragAndDropFileUploadService() {
}
return EasyDragAndDropFileUploadService;
}());
/** @nocollapse */ EasyDragAndDropFileUploadService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function EasyDragAndDropFileUploadService_Factory() { return new EasyDragAndDropFileUploadService(); }, token: EasyDragAndDropFileUploadService, providedIn: "root" });
EasyDragAndDropFileUploadService.decorators = [
{ type: i0.Injectable, args: [{
providedIn: 'root'
},] }
];
/** @nocollapse */
EasyDragAndDropFileUploadService.ctorParameters = function () { return []; };
var EasyDragAndDropFileUploadComponent = /** @class */ (function () {
function EasyDragAndDropFileUploadComponent() {
}
EasyDragAndDropFileUploadComponent.prototype.ngOnInit = function () {
};
return EasyDragAndDropFileUploadComponent;
}());
EasyDragAndDropFileUploadComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'lib-easyDragAndDropFileUpload',
template: "\n <p>\n easy-drag-and-drop-file-upload works!\n </p>\n "
},] }
];
/** @nocollapse */
EasyDragAndDropFileUploadComponent.ctorParameters = function () { return []; };
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (Object.prototype.hasOwnProperty.call(b, p))
d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function () {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); };
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try {
step(generator.next(value));
}
catch (e) {
reject(e);
} }
function rejected(value) { try {
step(generator["throw"](value));
}
catch (e) {
reject(e);
} }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function () { if (t[0] & 1)
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f)
throw new TypeError("Generator is already executing.");
while (_)
try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
return t;
if (y = 0, t)
op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return { value: op[1], done: false };
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2])
_.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
}
catch (e) {
op = [6, e];
y = 0;
}
finally {
f = t = 0;
}
if (op[0] & 5)
throw op[1];
return { value: op[0] ? op[1] : void 0, done: true };
}
}
var __createBinding = Object.create ? (function (o, m, k, k2) {
if (k2 === undefined)
k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
}) : (function (o, m, k, k2) {
if (k2 === undefined)
k2 = k;
o[k2] = m[k];
});
function __exportStar(m, o) {
for (var p in m)
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
__createBinding(o, m, p);
}
function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m)
return m.call(o);
if (o && typeof o.length === "number")
return {
next: function () {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m)
return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
ar.push(r.value);
}
catch (error) {
e = { error: error };
}
finally {
try {
if (r && !r.done && (m = i["return"]))
m.call(i);
}
finally {
if (e)
throw e.error;
}
}
return ar;
}
/** @deprecated */
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
/** @deprecated */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2)
for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar)
ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || from);
}
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n])
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try {
step(g[n](v));
}
catch (e) {
settle(q[0][3], e);
} }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length)
resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) {
Object.defineProperty(cooked, "raw", { value: raw });
}
else {
cooked.raw = raw;
}
return cooked;
}
;
var __setModuleDefault = Object.create ? (function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function (o, v) {
o["default"] = v;
};
function __importStar(mod) {
if (mod && mod.__esModule)
return mod;
var result = {};
if (mod != null)
for (var k in mod)
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
__createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
function __classPrivateFieldGet(receiver, state, kind, f) {
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
}
function __classPrivateFieldSet(receiver, state, value, kind, f) {
if (kind === "m")
throw new TypeError("Private method is not writable");
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
}
var EasyDndUploadComponent = /** @class */ (function () {
function EasyDndUploadComponent() {
this.files = [];
/*************************************************************
* Input() memebrs
*************************************************************/
// Title
this._title = "Drag and Drop File Upload"; // default title
// Allow file types
this._allowedFiles = "*"; // Deafult allowed any type of file
// File Limit
this._fileLimit = -1; // Allow any size of file
// Multiple file
this._allowMultiple = true; // Allow multiple files by default
// Output
this.droppedFiles = new i0.EventEmitter();
}
Object.defineProperty(EasyDndUploadComponent.prototype, "title", {
get: function () {
return this._title;
},
set: function (value) {
this._title = value;
//console.log(`title is changed to ${value}`);
},
enumerable: false,
configurable: true
});
Object.defineProperty(EasyDndUploadComponent.prototype, "allowedFiles", {
get: function () {
return this._allowedFiles;
},
set: function (value) {
this._allowedFiles = value;
//console.log(`Allowed files is changed to ${value}`);
},
enumerable: false,
configurable: true
});
Object.defineProperty(EasyDndUploadComponent.prototype, "fileLimit", {
get: function () {
return this._fileLimit;
},
set: function (value) {
this._fileLimit = value;
//console.log(`file limit is changed to ${value}`);
},
enumerable: false,
configurable: true
});
Object.defineProperty(EasyDndUploadComponent.prototype, "allowMultiple", {
get: function () {
return this._allowMultiple;
},
set: function (value) {
this._allowMultiple = value;
//console.log(`allow multiple is changed to ${value}`);
},
enumerable: false,
configurable: true
});
EasyDndUploadComponent.prototype.ngOnInit = function () { };
/**
* on file drop handler
*/
EasyDndUploadComponent.prototype.onFileDropped = function ($event) {
this.prepareFilesList($event);
};
/**
* handle file from browsing
*/
EasyDndUploadComponent.prototype.fileBrowseHandler = function (files) {
this.prepareFilesList(files);
};
/**
* Delete file from files list
* @param index (File index)
*/
EasyDndUploadComponent.prototype.deleteFile = function (index) {
this.files.splice(index, 1);
this.droppedFiles.emit(this.files);
};
/**
* Simulate the upload process
*/
EasyDndUploadComponent.prototype.uploadFilesSimulator = function (index) {
var _this = this;
setTimeout(function () {
if (index === _this.files.length) {
return;
}
else {
var progressInterval_1 = setInterval(function () {
if (_this.files[index].progress === 100) {
clearInterval(progressInterval_1);
_this.uploadFilesSimulator(index + 1);
}
else {
_this.files[index].progress += 5;
}
}, 200);
_this.droppedFiles.emit(_this.files);
}
}, 1000);
};
/**
* Convert Files list to normal array list
* @param files (Files List)
*/
EasyDndUploadComponent.prototype.prepareFilesList = function (files) {
var e_1, _a;
try {
for (var files_1 = __values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
var item = files_1_1.value;
item.progress = 0;
this.files.push(item);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (files_1_1 && !files_1_1.done && (_a = files_1.return)) _a.call(files_1);
}
finally { if (e_1) throw e_1.error; }
}
this.uploadFilesSimulator(0);
};
/**
* format bytes
* @param bytes (File size in bytes)
* @param decimals (Decimals point)
*/
EasyDndUploadComponent.prototype.formatBytes = function (bytes, decimals) {
if (bytes === 0) {
return '0 Bytes';
}
var k = 1024;
var dm = decimals <= 0 ? 0 : decimals || 2;
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
var i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
};
return EasyDndUploadComponent;
}());
EasyDndUploadComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'ngx-easy-dnd-upload',
template: "<div style=\"text-align: center;\">\n\t<h4>{{title}}</h4>\n</div>\n<div class=\"container\" easyDnDFileUpload (fileDropped)=\"onFileDropped($event)\">\n\t<input type=\"file\" [accept]=\"allowedFiles\" #fileDropRef id=\"fileDropRef\" [multiple]=\"allowMultiple\" (change)=\"fileBrowseHandler($event.target.files)\" />\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"63\" height=\"64\" viewBox=\"0 0 63 64\">\n\t\t<g fill=\"#3B454F\" fill-rule=\"nonzero\">\n\t\t\t<path\n\t\t\t\td=\"M42.656 15.135a1.953 1.953 0 0 1-1.391-.578L31.5 4.795l-9.765 9.762a1.97 1.97 0 1 1-2.785-2.785L30.106.616a1.97 1.97 0 0 1 2.785 0l11.157 11.156a1.97 1.97 0 0 1-1.392 3.363z\" />\n\t\t\t<path\n\t\t\t\td=\"M31.5 36.791a1.97 1.97 0 0 1-1.969-1.969V2.01a1.97 1.97 0 0 1 3.938 0v32.812a1.97 1.97 0 0 1-1.969 1.969z\" />\n\t\t\t<path\n\t\t\t\td=\"M55.781 63.041H7.22A7.225 7.225 0 0 1 0 55.822V41.385a4.599 4.599 0 0 1 4.594-4.594h7.234a4.567 4.567 0 0 1 4.402 3.276l2.814 9.382a.658.658 0 0 0 .628.467h23.656a.658.658 0 0 0 .628-.467l2.814-9.385a4.572 4.572 0 0 1 4.402-3.273h7.234A4.599 4.599 0 0 1 63 41.385v14.437a7.225 7.225 0 0 1-7.219 7.219zM4.594 40.729a.656.656 0 0 0-.657.656v14.437a3.286 3.286 0 0 0 3.282 3.282H55.78a3.286 3.286 0 0 0 3.282-3.282V41.385a.656.656 0 0 0-.657-.656h-7.234a.65.65 0 0 0-.628.467L47.73 50.58a4.628 4.628 0 0 1-4.402 3.274H19.672a4.567 4.567 0 0 1-4.402-3.276l-2.814-9.382a.65.65 0 0 0-.628-.467H4.594z\" />\n\t\t</g>\n\t</svg>\n\n\t<h3>Drag and drop file/'s here</h3>\n\t<h3>or</h3>\n\t<label for=\"fileDropRef\">Browse File</label>\n</div>\n<div class=\"files-list\">\n\t<div class=\"single-file\" *ngFor=\"let file of files; let i = index\">\n\t\t<div class=\"file-icon\" style=\"width: 50px\">\n\t\t\t<svg version=\"1.1\" id=\"Capa_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n\t\t\t\tx=\"0px\" y=\"0px\" viewBox=\"0 0 58 58\" style=\"enable-background:new 0 0 58 58;\" xml:space=\"preserve\">\n\t\t\t\t<polygon style=\"fill:#EDEADA;\" points=\"51.5,14 37.5,0 6.5,0 6.5,58 51.5,58 \" />\n\t\t\t\t<g>\n\t\t\t\t\t<path style=\"fill:#CEC9AE;\"\n\t\t\t\t\t\td=\"M16.5,23h25c0.552,0,1-0.447,1-1s-0.448-1-1-1h-25c-0.552,0-1,0.447-1,1S15.948,23,16.5,23z\" />\n\t\t\t\t\t<path style=\"fill:#CEC9AE;\"\n\t\t\t\t\t\td=\"M16.5,15h10c0.552,0,1-0.447,1-1s-0.448-1-1-1h-10c-0.552,0-1,0.447-1,1S15.948,15,16.5,15z\" />\n\t\t\t\t\t<path style=\"fill:#CEC9AE;\"\n\t\t\t\t\t\td=\"M41.5,29h-25c-0.552,0-1,0.447-1,1s0.448,1,1,1h25c0.552,0,1-0.447,1-1S42.052,29,41.5,29z\" />\n\t\t\t\t\t<path style=\"fill:#CEC9AE;\"\n\t\t\t\t\t\td=\"M41.5,37h-25c-0.552,0-1,0.447-1,1s0.448,1,1,1h25c0.552,0,1-0.447,1-1S42.052,37,41.5,37z\" />\n\t\t\t\t\t<path style=\"fill:#CEC9AE;\"\n\t\t\t\t\t\td=\"M41.5,45h-25c-0.552,0-1,0.447-1,1s0.448,1,1,1h25c0.552,0,1-0.447,1-1S42.052,45,41.5,45z\" />\n\t\t\t\t</g>\n\t\t\t\t<polygon style=\"fill:#CEC9AE;\" points=\"37.5,0 37.5,14 51.5,14 \" />\n\t\t\t</svg>\n\t\t</div>\n\t\t<div class=\"info\">\n\t\t\t<h4 class=\"name\">\n\t\t\t\t{{ file?.name }}\n\t\t\t</h4>\n\t\t\t<p class=\"size\">\n\t\t\t\t{{ formatBytes(file?.size, 0) }}\n\t\t\t</p>\n\t\t\t<easy-progress [progress]=\"file?.progress\"></easy-progress>\n\t\t</div>\n\n\t\t<div class=\"delete\" (click)=\"deleteFile(i)\">\n\t\t\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"18\" viewBox=\"0 0 14 18\">\n\t\t\t\t<path fill=\"#B1B1B1\" fill-rule=\"nonzero\"\n\t\t\t\t\td=\"M1 16c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H3c-1.1 0-2 .9-2 2v10zm3.17-7.83a.996.996 0 0 1 1.41 0L7 9.59l1.42-1.42a.996.996 0 1 1 1.41 1.41L8.41 11l1.42 1.42a.996.996 0 1 1-1.41 1.41L7 12.41l-1.42 1.42a.996.996 0 1 1-1.41-1.41L5.59 11 4.17 9.58a.996.996 0 0 1 0-1.41zM10.5 1L9.79.29C9.61.11 9.35 0 9.09 0H4.91c-.26 0-.52.11-.7.29L3.5 1H1c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1h-2.5z\" />\n\t\t\t</svg>\n\t\t</div>\n\t</div>\n</div>\n",
styles: [".container{width:450px;height:200px;padding:2rem;text-align:center;border:dashed 1px #979797;position:relative;margin:0 auto}.container input{opacity:0;position:absolute;z-index:2;width:100%;height:100%;top:0;left:0}.container label{color:#fff;width:183px;height:44px;border-radius:21.5px;background-color:#db202f;padding:8px 16px}.container h3{font-size:20px;font-weight:600;color:#38424c}.fileover{-webkit-animation:shake 1s;animation:shake 1s;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite}.files-list{margin-top:1.5rem}.files-list .single-file{padding:.5rem;justify-content:space-between;align-items:center;border:dashed 1px #979797;margin-bottom:1rem;display:flex;flex-grow:1}.files-list .single-file .delete{display:flex;margin-left:.5rem;cursor:pointer;align-self:flex-end}.files-list .single-file .name{font-size:14px;font-weight:500;color:#353f4a;margin:0}.files-list .single-file .size{font-size:12px;font-weight:500;color:#a4a4a4;margin:0 0 .25rem}.files-list .single-file .info{width:100%}@-webkit-keyframes shake{0%{transform:translate(1px,1px) rotate(0)}10%{transform:translate(-1px,-2px) rotate(-1deg)}20%{transform:translate(-3px) rotate(1deg)}30%{transform:translate(3px,2px) rotate(0)}40%{transform:translate(1px,-1px) rotate(1deg)}50%{transform:translate(-1px,2px) rotate(-1deg)}60%{transform:translate(-3px,1px) rotate(0)}70%{transform:translate(3px,1px) rotate(-1deg)}80%{transform:translate(-1px,-1px) rotate(1deg)}90%{transform:translate(1px,2px) rotate(0)}to{transform:translate(1px,-2px) rotate(-1deg)}}@keyframes shake{0%{transform:translate(1px,1px) rotate(0)}10%{transform:translate(-1px,-2px) rotate(-1deg)}20%{transform:translate(-3px) rotate(1deg)}30%{transform:translate(3px,2px) rotate(0)}40%{transform:translate(1px,-1px) rotate(1deg)}50%{transform:translate(-1px,2px) rotate(-1deg)}60%{transform:translate(-3px,1px) rotate(0)}70%{transform:translate(3px,1px) rotate(-1deg)}80%{transform:translate(-1px,-1px) rotate(1deg)}90%{transform:translate(1px,2px) rotate(0)}to{transform:translate(1px,-2px) rotate(-1deg)}}\n"]
},] }
];
/** @nocollapse */
EasyDndUploadComponent.ctorParameters = function () { return []; };
EasyDndUploadComponent.propDecorators = {
title: [{ type: i0.Input }],
allowedFiles: [{ type: i0.Input }],
fileLimit: [{ type: i0.Input }],
allowMultiple: [{ type: i0.Input }],
droppedFiles: [{ type: i0.Output }]
};
var ProgressComponent = /** @class */ (function () {
function ProgressComponent() {
this.progress = 0;
}
ProgressComponent.prototype.ngOnInit = function () { };
return ProgressComponent;
}());
ProgressComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'easy-progress',
template: "<div class=\"progress-cont\">\n <div class=\"progress\" [style.width]=\"progress + '%'\">\n </div>\n</div>",
styles: [".progress-cont{height:7px;width:100%;border-radius:4px;background-color:#d0d0d0;position:relative}.progress-cont .progress{width:0;height:100%;position:absolute;z-index:1;top:0;left:0;border-radius:4px;background-color:#4c97cb;transition:.5s all}\n"]
},] }
];
/** @nocollapse */
ProgressComponent.ctorParameters = function () { return []; };
ProgressComponent.propDecorators = {
progress: [{ type: i0.Input }]
};
var EasyDragAndDropFileUploadDirective = /** @class */ (function () {
function EasyDragAndDropFileUploadDirective() {
this.fileDropped = new i0.EventEmitter();
}
// Dragover listener
EasyDragAndDropFileUploadDirective.prototype.onDragOver = function (evt) {
evt.preventDefault();
evt.stopPropagation();
this.fileOver = true;
};
// Dragleave listener
EasyDragAndDropFileUploadDirective.prototype.onDragLeave = function (evt) {
evt.preventDefault();
evt.stopPropagation();
this.fileOver = false;
};
// Drop listener
EasyDragAndDropFileUploadDirective.prototype.ondrop = function (evt) {
evt.preventDefault();
evt.stopPropagation();
this.fileOver = false;
var files = evt.dataTransfer.files;
if (files.length > 0) {
this.fileDropped.emit(files);
}
};
return EasyDragAndDropFileUploadDirective;
}());
EasyDragAndDropFileUploadDirective.decorators = [
{ type: i0.Directive, args: [{
selector: '[easyDnDFileUpload]'
},] }
];
EasyDragAndDropFileUploadDirective.propDecorators = {
fileOver: [{ type: i0.HostBinding, args: ['class.fileover',] }],
fileDropped: [{ type: i0.Output }],
onDragOver: [{ type: i0.HostListener, args: ['dragover', ['$event'],] }],
onDragLeave: [{ type: i0.HostListener, args: ['dragleave', ['$event'],] }],
ondrop: [{ type: i0.HostListener, args: ['drop', ['$event'],] }]
};
var EasyDragAndDropFileUploadModule = /** @class */ (function () {
function EasyDragAndDropFileUploadModule() {
}
return EasyDragAndDropFileUploadModule;
}());
EasyDragAndDropFileUploadModule.decorators = [
{ type: i0.NgModule, args: [{
declarations: [
EasyDndUploadComponent,
EasyDragAndDropFileUploadComponent,
EasyDragAndDropFileUploadDirective,
ProgressComponent
],
imports: [
common.CommonModule,
platformBrowser.BrowserModule,
forms.FormsModule
],
exports: [
EasyDragAndDropFileUploadComponent,
EasyDndUploadComponent
]
},] }
];
/*
* Public API Surface of easy-drag-and-drop-file-upload
*/
/**
* Generated bundle index. Do not edit.
*/
exports.EasyDndUploadComponent = EasyDndUploadComponent;
exports.EasyDragAndDropFileUploadComponent = EasyDragAndDropFileUploadComponent;
exports.EasyDragAndDropFileUploadModule = EasyDragAndDropFileUploadModule;
exports.EasyDragAndDropFileUploadService = EasyDragAndDropFileUploadService;
exports.ɵa = EasyDragAndDropFileUploadDirective;
exports.ɵb = ProgressComponent;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=easy-drag-and-drop-file-upload.umd.js.map