fileupload.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. "use strict";
  2. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  4. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5. 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;
  6. return c > 3 && r && Object.defineProperty(target, key, r), r;
  7. };
  8. var __metadata = (this && this.__metadata) || function (k, v) {
  9. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var core_1 = require("@angular/core");
  13. var common_1 = require("@angular/common");
  14. var platform_browser_1 = require("@angular/platform-browser");
  15. var button_1 = require("../button/button");
  16. var messages_1 = require("../messages/messages");
  17. var progressbar_1 = require("../progressbar/progressbar");
  18. var domhandler_1 = require("../dom/domhandler");
  19. var shared_1 = require("../common/shared");
  20. var http_1 = require("@angular/common/http");
  21. var FileUpload = /** @class */ (function () {
  22. function FileUpload(el, sanitizer, zone, http) {
  23. this.el = el;
  24. this.sanitizer = sanitizer;
  25. this.zone = zone;
  26. this.http = http;
  27. this.method = 'POST';
  28. this.invalidFileSizeMessageSummary = '{0}: Invalid file size, ';
  29. this.invalidFileSizeMessageDetail = 'maximum upload size is {0}.';
  30. this.invalidFileTypeMessageSummary = '{0}: Invalid file type, ';
  31. this.invalidFileTypeMessageDetail = 'allowed file types: {0}.';
  32. this.invalidFileLimitMessageDetail = 'limit is {0} at most.';
  33. this.invalidFileLimitMessageSummary = 'Maximum number of files exceeded, ';
  34. this.previewWidth = 50;
  35. this.chooseLabel = 'Choose';
  36. this.uploadLabel = 'Upload';
  37. this.cancelLabel = 'Cancel';
  38. this.showUploadButton = true;
  39. this.showCancelButton = true;
  40. this.mode = 'advanced';
  41. this.onBeforeUpload = new core_1.EventEmitter();
  42. this.onSend = new core_1.EventEmitter();
  43. this.onUpload = new core_1.EventEmitter();
  44. this.onError = new core_1.EventEmitter();
  45. this.onClear = new core_1.EventEmitter();
  46. this.onRemove = new core_1.EventEmitter();
  47. this.onSelect = new core_1.EventEmitter();
  48. this.onProgress = new core_1.EventEmitter();
  49. this.uploadHandler = new core_1.EventEmitter();
  50. this._files = [];
  51. this.progress = 0;
  52. this.uploadedFileCount = 0;
  53. }
  54. Object.defineProperty(FileUpload.prototype, "files", {
  55. get: function () {
  56. return this._files;
  57. },
  58. set: function (files) {
  59. this._files = [];
  60. for (var i = 0; i < files.length; i++) {
  61. var file = files[i];
  62. if (this.validate(file)) {
  63. if (this.isImage(file)) {
  64. file.objectURL = this.sanitizer.bypassSecurityTrustUrl((window.URL.createObjectURL(files[i])));
  65. }
  66. this._files.push(files[i]);
  67. }
  68. }
  69. },
  70. enumerable: true,
  71. configurable: true
  72. });
  73. FileUpload.prototype.ngAfterContentInit = function () {
  74. var _this = this;
  75. this.templates.forEach(function (item) {
  76. switch (item.getType()) {
  77. case 'file':
  78. _this.fileTemplate = item.template;
  79. break;
  80. case 'content':
  81. _this.contentTemplate = item.template;
  82. break;
  83. case 'toolbar':
  84. _this.toolbarTemplate = item.template;
  85. break;
  86. default:
  87. _this.fileTemplate = item.template;
  88. break;
  89. }
  90. });
  91. };
  92. FileUpload.prototype.ngAfterViewInit = function () {
  93. var _this = this;
  94. if (this.mode === 'advanced') {
  95. this.zone.runOutsideAngular(function () {
  96. if (_this.content)
  97. _this.content.nativeElement.addEventListener('dragover', _this.onDragOver.bind(_this));
  98. });
  99. }
  100. };
  101. FileUpload.prototype.onFileSelect = function (event) {
  102. if (event.type !== 'drop' && this.isIE11() && this.duplicateIEEvent) {
  103. this.duplicateIEEvent = false;
  104. return;
  105. }
  106. this.msgs = [];
  107. if (!this.multiple) {
  108. this.files = [];
  109. }
  110. var files = event.dataTransfer ? event.dataTransfer.files : event.target.files;
  111. for (var i = 0; i < files.length; i++) {
  112. var file = files[i];
  113. if (!this.isFileSelected(file)) {
  114. if (this.validate(file)) {
  115. if (this.isImage(file)) {
  116. file.objectURL = this.sanitizer.bypassSecurityTrustUrl((window.URL.createObjectURL(files[i])));
  117. }
  118. this.files.push(files[i]);
  119. }
  120. }
  121. }
  122. this.onSelect.emit({ originalEvent: event, files: files });
  123. if (this.fileLimit && this.mode == "advanced") {
  124. this.checkFileLimit();
  125. }
  126. if (this.hasFiles() && this.auto && (!(this.mode === "advanced") || !this.isFileLimitExceeded())) {
  127. this.upload();
  128. }
  129. if (event.type !== 'drop' && this.isIE11()) {
  130. this.clearIEInput();
  131. }
  132. else {
  133. this.clearInputElement();
  134. }
  135. };
  136. FileUpload.prototype.isFileSelected = function (file) {
  137. for (var _i = 0, _a = this.files; _i < _a.length; _i++) {
  138. var sFile = _a[_i];
  139. if ((sFile.name + sFile.type + sFile.size) === (file.name + file.type + file.size)) {
  140. return true;
  141. }
  142. }
  143. return false;
  144. };
  145. FileUpload.prototype.isIE11 = function () {
  146. return !!window['MSInputMethodContext'] && !!document['documentMode'];
  147. };
  148. FileUpload.prototype.validate = function (file) {
  149. if (this.accept && !this.isFileTypeValid(file)) {
  150. this.msgs.push({
  151. severity: 'error',
  152. summary: this.invalidFileTypeMessageSummary.replace('{0}', file.name),
  153. detail: this.invalidFileTypeMessageDetail.replace('{0}', this.accept)
  154. });
  155. return false;
  156. }
  157. if (this.maxFileSize && file.size > this.maxFileSize) {
  158. this.msgs.push({
  159. severity: 'error',
  160. summary: this.invalidFileSizeMessageSummary.replace('{0}', file.name),
  161. detail: this.invalidFileSizeMessageDetail.replace('{0}', this.formatSize(this.maxFileSize))
  162. });
  163. return false;
  164. }
  165. return true;
  166. };
  167. FileUpload.prototype.isFileTypeValid = function (file) {
  168. var acceptableTypes = this.accept.split(',').map(function (type) { return type.trim(); });
  169. for (var _i = 0, acceptableTypes_1 = acceptableTypes; _i < acceptableTypes_1.length; _i++) {
  170. var type = acceptableTypes_1[_i];
  171. var acceptable = this.isWildcard(type) ? this.getTypeClass(file.type) === this.getTypeClass(type)
  172. : file.type == type || this.getFileExtension(file).toLowerCase() === type.toLowerCase();
  173. if (acceptable) {
  174. return true;
  175. }
  176. }
  177. return false;
  178. };
  179. FileUpload.prototype.getTypeClass = function (fileType) {
  180. return fileType.substring(0, fileType.indexOf('/'));
  181. };
  182. FileUpload.prototype.isWildcard = function (fileType) {
  183. return fileType.indexOf('*') !== -1;
  184. };
  185. FileUpload.prototype.getFileExtension = function (file) {
  186. return '.' + file.name.split('.').pop();
  187. };
  188. FileUpload.prototype.isImage = function (file) {
  189. return /^image\//.test(file.type);
  190. };
  191. FileUpload.prototype.onImageLoad = function (img) {
  192. window.URL.revokeObjectURL(img.src);
  193. };
  194. FileUpload.prototype.upload = function () {
  195. var _this = this;
  196. if (this.customUpload) {
  197. if (this.fileLimit) {
  198. this.uploadedFileCount += this.files.length;
  199. }
  200. this.uploadHandler.emit({
  201. files: this.files
  202. });
  203. }
  204. else {
  205. this.uploading = true;
  206. this.msgs = [];
  207. var formData_1 = new FormData();
  208. this.onBeforeUpload.emit({
  209. 'formData': formData_1
  210. });
  211. for (var i = 0; i < this.files.length; i++) {
  212. formData_1.append(this.name, this.files[i], this.files[i].name);
  213. }
  214. this.http.post(this.url, formData_1, {
  215. headers: this.headers, reportProgress: true, observe: 'events', withCredentials: this.withCredentials
  216. }).subscribe(function (event) {
  217. switch (event.type) {
  218. case http_1.HttpEventType.Sent:
  219. _this.onSend.emit({
  220. originalEvent: event,
  221. 'formData': formData_1
  222. });
  223. break;
  224. case http_1.HttpEventType.Response:
  225. _this.uploading = false;
  226. _this.progress = 0;
  227. if (event['status'] >= 200 && event['status'] < 300) {
  228. if (_this.fileLimit) {
  229. _this.uploadedFileCount += _this.files.length;
  230. }
  231. _this.onUpload.emit({ originalEvent: event, files: _this.files });
  232. }
  233. else {
  234. _this.onError.emit({ files: _this.files });
  235. }
  236. _this.clear();
  237. break;
  238. case http_1.HttpEventType.UploadProgress: {
  239. if (event['loaded']) {
  240. _this.progress = Math.round((event['loaded'] * 100) / event['total']);
  241. }
  242. _this.onProgress.emit({ originalEvent: event, progress: _this.progress });
  243. break;
  244. }
  245. }
  246. }, function (error) {
  247. _this.uploading = false;
  248. _this.onError.emit({ files: _this.files, error: error });
  249. });
  250. }
  251. };
  252. FileUpload.prototype.clear = function () {
  253. this.files = [];
  254. this.onClear.emit();
  255. this.clearInputElement();
  256. };
  257. FileUpload.prototype.remove = function (event, index) {
  258. this.clearInputElement();
  259. this.onRemove.emit({ originalEvent: event, file: this.files[index] });
  260. this.files.splice(index, 1);
  261. };
  262. FileUpload.prototype.isFileLimitExceeded = function () {
  263. if (this.fileLimit && this.fileLimit <= this.files.length + this.uploadedFileCount && this.focus) {
  264. this.focus = false;
  265. }
  266. return this.fileLimit && this.fileLimit < this.files.length + this.uploadedFileCount;
  267. };
  268. FileUpload.prototype.isChooseDisabled = function () {
  269. return this.fileLimit && this.fileLimit <= this.files.length + this.uploadedFileCount;
  270. };
  271. FileUpload.prototype.checkFileLimit = function () {
  272. if (this.isFileLimitExceeded()) {
  273. this.msgs.push({
  274. severity: 'error',
  275. summary: this.invalidFileLimitMessageSummary.replace('{0}', this.fileLimit.toString()),
  276. detail: this.invalidFileLimitMessageDetail.replace('{0}', this.fileLimit.toString())
  277. });
  278. }
  279. };
  280. FileUpload.prototype.clearInputElement = function () {
  281. if (this.advancedFileInput && this.advancedFileInput.nativeElement) {
  282. this.advancedFileInput.nativeElement.value = '';
  283. }
  284. if (this.basicFileInput && this.basicFileInput.nativeElement) {
  285. this.basicFileInput.nativeElement.value = '';
  286. }
  287. };
  288. FileUpload.prototype.clearIEInput = function () {
  289. if (this.advancedFileInput && this.advancedFileInput.nativeElement) {
  290. this.duplicateIEEvent = true; //IE11 fix to prevent onFileChange trigger again
  291. this.advancedFileInput.nativeElement.value = '';
  292. }
  293. };
  294. FileUpload.prototype.hasFiles = function () {
  295. return this.files && this.files.length > 0;
  296. };
  297. FileUpload.prototype.onDragEnter = function (e) {
  298. if (!this.disabled) {
  299. e.stopPropagation();
  300. e.preventDefault();
  301. }
  302. };
  303. FileUpload.prototype.onDragOver = function (e) {
  304. if (!this.disabled) {
  305. domhandler_1.DomHandler.addClass(this.content.nativeElement, 'ui-fileupload-highlight');
  306. this.dragHighlight = true;
  307. e.stopPropagation();
  308. e.preventDefault();
  309. }
  310. };
  311. FileUpload.prototype.onDragLeave = function (event) {
  312. if (!this.disabled) {
  313. domhandler_1.DomHandler.removeClass(this.content.nativeElement, 'ui-fileupload-highlight');
  314. }
  315. };
  316. FileUpload.prototype.onDrop = function (event) {
  317. if (!this.disabled) {
  318. domhandler_1.DomHandler.removeClass(this.content.nativeElement, 'ui-fileupload-highlight');
  319. event.stopPropagation();
  320. event.preventDefault();
  321. var files = event.dataTransfer ? event.dataTransfer.files : event.target.files;
  322. var allowDrop = this.multiple || (files && files.length === 1);
  323. if (allowDrop) {
  324. this.onFileSelect(event);
  325. }
  326. }
  327. };
  328. FileUpload.prototype.onFocus = function () {
  329. this.focus = true;
  330. };
  331. FileUpload.prototype.onBlur = function () {
  332. this.focus = false;
  333. };
  334. FileUpload.prototype.formatSize = function (bytes) {
  335. if (bytes == 0) {
  336. return '0 B';
  337. }
  338. var k = 1000, dm = 3, sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], i = Math.floor(Math.log(bytes) / Math.log(k));
  339. return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
  340. };
  341. FileUpload.prototype.onSimpleUploaderClick = function (event) {
  342. if (this.hasFiles()) {
  343. this.upload();
  344. }
  345. };
  346. FileUpload.prototype.getBlockableElement = function () {
  347. return this.el.nativeElement.children[0];
  348. };
  349. FileUpload.prototype.ngOnDestroy = function () {
  350. if (this.content && this.content.nativeElement) {
  351. this.content.nativeElement.removeEventListener('dragover', this.onDragOver);
  352. }
  353. };
  354. __decorate([
  355. core_1.Input(),
  356. __metadata("design:type", String)
  357. ], FileUpload.prototype, "name", void 0);
  358. __decorate([
  359. core_1.Input(),
  360. __metadata("design:type", String)
  361. ], FileUpload.prototype, "url", void 0);
  362. __decorate([
  363. core_1.Input(),
  364. __metadata("design:type", String)
  365. ], FileUpload.prototype, "method", void 0);
  366. __decorate([
  367. core_1.Input(),
  368. __metadata("design:type", Boolean)
  369. ], FileUpload.prototype, "multiple", void 0);
  370. __decorate([
  371. core_1.Input(),
  372. __metadata("design:type", String)
  373. ], FileUpload.prototype, "accept", void 0);
  374. __decorate([
  375. core_1.Input(),
  376. __metadata("design:type", Boolean)
  377. ], FileUpload.prototype, "disabled", void 0);
  378. __decorate([
  379. core_1.Input(),
  380. __metadata("design:type", Boolean)
  381. ], FileUpload.prototype, "auto", void 0);
  382. __decorate([
  383. core_1.Input(),
  384. __metadata("design:type", Boolean)
  385. ], FileUpload.prototype, "withCredentials", void 0);
  386. __decorate([
  387. core_1.Input(),
  388. __metadata("design:type", Number)
  389. ], FileUpload.prototype, "maxFileSize", void 0);
  390. __decorate([
  391. core_1.Input(),
  392. __metadata("design:type", String)
  393. ], FileUpload.prototype, "invalidFileSizeMessageSummary", void 0);
  394. __decorate([
  395. core_1.Input(),
  396. __metadata("design:type", String)
  397. ], FileUpload.prototype, "invalidFileSizeMessageDetail", void 0);
  398. __decorate([
  399. core_1.Input(),
  400. __metadata("design:type", String)
  401. ], FileUpload.prototype, "invalidFileTypeMessageSummary", void 0);
  402. __decorate([
  403. core_1.Input(),
  404. __metadata("design:type", String)
  405. ], FileUpload.prototype, "invalidFileTypeMessageDetail", void 0);
  406. __decorate([
  407. core_1.Input(),
  408. __metadata("design:type", String)
  409. ], FileUpload.prototype, "invalidFileLimitMessageDetail", void 0);
  410. __decorate([
  411. core_1.Input(),
  412. __metadata("design:type", String)
  413. ], FileUpload.prototype, "invalidFileLimitMessageSummary", void 0);
  414. __decorate([
  415. core_1.Input(),
  416. __metadata("design:type", Object)
  417. ], FileUpload.prototype, "style", void 0);
  418. __decorate([
  419. core_1.Input(),
  420. __metadata("design:type", String)
  421. ], FileUpload.prototype, "styleClass", void 0);
  422. __decorate([
  423. core_1.Input(),
  424. __metadata("design:type", Number)
  425. ], FileUpload.prototype, "previewWidth", void 0);
  426. __decorate([
  427. core_1.Input(),
  428. __metadata("design:type", String)
  429. ], FileUpload.prototype, "chooseLabel", void 0);
  430. __decorate([
  431. core_1.Input(),
  432. __metadata("design:type", String)
  433. ], FileUpload.prototype, "uploadLabel", void 0);
  434. __decorate([
  435. core_1.Input(),
  436. __metadata("design:type", String)
  437. ], FileUpload.prototype, "cancelLabel", void 0);
  438. __decorate([
  439. core_1.Input(),
  440. __metadata("design:type", Boolean)
  441. ], FileUpload.prototype, "showUploadButton", void 0);
  442. __decorate([
  443. core_1.Input(),
  444. __metadata("design:type", Boolean)
  445. ], FileUpload.prototype, "showCancelButton", void 0);
  446. __decorate([
  447. core_1.Input(),
  448. __metadata("design:type", String)
  449. ], FileUpload.prototype, "mode", void 0);
  450. __decorate([
  451. core_1.Input(),
  452. __metadata("design:type", http_1.HttpHeaders)
  453. ], FileUpload.prototype, "headers", void 0);
  454. __decorate([
  455. core_1.Input(),
  456. __metadata("design:type", Boolean)
  457. ], FileUpload.prototype, "customUpload", void 0);
  458. __decorate([
  459. core_1.Input(),
  460. __metadata("design:type", Number)
  461. ], FileUpload.prototype, "fileLimit", void 0);
  462. __decorate([
  463. core_1.Output(),
  464. __metadata("design:type", core_1.EventEmitter)
  465. ], FileUpload.prototype, "onBeforeUpload", void 0);
  466. __decorate([
  467. core_1.Output(),
  468. __metadata("design:type", core_1.EventEmitter)
  469. ], FileUpload.prototype, "onSend", void 0);
  470. __decorate([
  471. core_1.Output(),
  472. __metadata("design:type", core_1.EventEmitter)
  473. ], FileUpload.prototype, "onUpload", void 0);
  474. __decorate([
  475. core_1.Output(),
  476. __metadata("design:type", core_1.EventEmitter)
  477. ], FileUpload.prototype, "onError", void 0);
  478. __decorate([
  479. core_1.Output(),
  480. __metadata("design:type", core_1.EventEmitter)
  481. ], FileUpload.prototype, "onClear", void 0);
  482. __decorate([
  483. core_1.Output(),
  484. __metadata("design:type", core_1.EventEmitter)
  485. ], FileUpload.prototype, "onRemove", void 0);
  486. __decorate([
  487. core_1.Output(),
  488. __metadata("design:type", core_1.EventEmitter)
  489. ], FileUpload.prototype, "onSelect", void 0);
  490. __decorate([
  491. core_1.Output(),
  492. __metadata("design:type", core_1.EventEmitter)
  493. ], FileUpload.prototype, "onProgress", void 0);
  494. __decorate([
  495. core_1.Output(),
  496. __metadata("design:type", core_1.EventEmitter)
  497. ], FileUpload.prototype, "uploadHandler", void 0);
  498. __decorate([
  499. core_1.ContentChildren(shared_1.PrimeTemplate),
  500. __metadata("design:type", core_1.QueryList)
  501. ], FileUpload.prototype, "templates", void 0);
  502. __decorate([
  503. core_1.ViewChild('advancedfileinput', { static: false }),
  504. __metadata("design:type", core_1.ElementRef)
  505. ], FileUpload.prototype, "advancedFileInput", void 0);
  506. __decorate([
  507. core_1.ViewChild('basicfileinput', { static: false }),
  508. __metadata("design:type", core_1.ElementRef)
  509. ], FileUpload.prototype, "basicFileInput", void 0);
  510. __decorate([
  511. core_1.ViewChild('content', { static: false }),
  512. __metadata("design:type", core_1.ElementRef)
  513. ], FileUpload.prototype, "content", void 0);
  514. __decorate([
  515. core_1.Input(),
  516. __metadata("design:type", Array),
  517. __metadata("design:paramtypes", [Object])
  518. ], FileUpload.prototype, "files", null);
  519. FileUpload = __decorate([
  520. core_1.Component({
  521. selector: 'p-fileUpload',
  522. template: "\n <div [ngClass]=\"'ui-fileupload ui-widget'\" [ngStyle]=\"style\" [class]=\"styleClass\" *ngIf=\"mode === 'advanced'\">\n <div class=\"ui-fileupload-buttonbar ui-widget-header ui-corner-top\">\n <span class=\"ui-fileupload-choose\" [label]=\"chooseLabel\" icon=\"pi pi-plus\" pButton [ngClass]=\"{'ui-state-focus': focus, 'ui-state-disabled':disabled || isChooseDisabled()}\"> \n <input #advancedfileinput type=\"file\" (change)=\"onFileSelect($event)\" [multiple]=\"multiple\" [accept]=\"accept\" [disabled]=\"disabled || isChooseDisabled()\" (focus)=\"onFocus()\" (blur)=\"onBlur()\">\n </span>\n\n <p-button *ngIf=\"!auto&&showUploadButton\" type=\"button\" [label]=\"uploadLabel\" icon=\"pi pi-upload\" (onClick)=\"upload()\" [disabled]=\"!hasFiles() || isFileLimitExceeded()\"></p-button>\n <p-button *ngIf=\"!auto&&showCancelButton\" type=\"button\" [label]=\"cancelLabel\" icon=\"pi pi-times\" (onClick)=\"clear()\" [disabled]=\"!hasFiles() ||\u00A0uploading\"></p-button>\n\n <ng-container *ngTemplateOutlet=\"toolbarTemplate\"></ng-container>\n </div>\n <div #content [ngClass]=\"{'ui-fileupload-content ui-widget-content ui-corner-bottom':true}\"\n (dragenter)=\"onDragEnter($event)\" (dragleave)=\"onDragLeave($event)\" (drop)=\"onDrop($event)\">\n <p-progressBar [value]=\"progress\" [showValue]=\"false\" *ngIf=\"hasFiles()\"></p-progressBar>\n\n <p-messages [value]=\"msgs\" [enableService]=\"false\"></p-messages>\n\n <div class=\"ui-fileupload-files\" *ngIf=\"hasFiles()\">\n <div *ngIf=\"!fileTemplate\">\n <div class=\"ui-fileupload-row\" *ngFor=\"let file of files; let i = index;\">\n <div><img [src]=\"file.objectURL\" *ngIf=\"isImage(file)\" [width]=\"previewWidth\" /></div>\n <div>{{file.name}}</div>\n <div>{{formatSize(file.size)}}</div>\n <div>\n <button type=\"button\" icon=\"pi pi-times\" pButton (click)=\"remove($event,i)\" [disabled]=\"uploading\"></button>\n </div>\n </div>\n </div>\n <div *ngIf=\"fileTemplate\">\n <ng-template ngFor [ngForOf]=\"files\" [ngForTemplate]=\"fileTemplate\"></ng-template>\n </div>\n </div>\n <ng-container *ngTemplateOutlet=\"contentTemplate\"></ng-container>\n </div>\n </div>\n <span *ngIf=\"mode === 'basic'\" [ngClass]=\"{'ui-button ui-fileupload-choose ui-widget ui-state-default ui-corner-all ui-button-text-icon-left': true, \n 'ui-fileupload-choose-selected': hasFiles(),'ui-state-focus': focus, 'ui-state-disabled':disabled}\"\n [ngStyle]=\"style\" [class]=\"styleClass\" (mouseup)=\"onSimpleUploaderClick($event)\">\n <span class=\"ui-button-icon-left pi\" [ngClass]=\"{'pi-plus': !hasFiles()||auto, 'pi-upload': hasFiles()&&!auto}\"></span>\n <span class=\"ui-button-text ui-clickable\">{{auto ? chooseLabel : hasFiles() ? files[0].name : chooseLabel}}</span>\n <input #basicfileinput type=\"file\" [accept]=\"accept\" [multiple]=\"multiple\" [disabled]=\"disabled\"\n (change)=\"onFileSelect($event)\" *ngIf=\"!hasFiles()\" (focus)=\"onFocus()\" (blur)=\"onBlur()\">\n </span>\n "
  523. }),
  524. __metadata("design:paramtypes", [core_1.ElementRef, platform_browser_1.DomSanitizer, core_1.NgZone, http_1.HttpClient])
  525. ], FileUpload);
  526. return FileUpload;
  527. }());
  528. exports.FileUpload = FileUpload;
  529. var FileUploadModule = /** @class */ (function () {
  530. function FileUploadModule() {
  531. }
  532. FileUploadModule = __decorate([
  533. core_1.NgModule({
  534. imports: [common_1.CommonModule, shared_1.SharedModule, button_1.ButtonModule, progressbar_1.ProgressBarModule, messages_1.MessagesModule],
  535. exports: [FileUpload, shared_1.SharedModule, button_1.ButtonModule, progressbar_1.ProgressBarModule, messages_1.MessagesModule],
  536. declarations: [FileUpload]
  537. })
  538. ], FileUploadModule);
  539. return FileUploadModule;
  540. }());
  541. exports.FileUploadModule = FileUploadModule;
  542. //# sourceMappingURL=fileupload.js.map