@guajiritos/image-picker 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,646 @@
1
+ import { __awaiter } from 'tslib';
2
+ import * as i0 from '@angular/core';
3
+ import { Pipe, EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, ViewChild, Output, NgModule } from '@angular/core';
4
+ import { ResizeObserver } from 'resize-observer';
5
+ import * as i1 from '@angular/common';
6
+ import { CommonModule } from '@angular/common';
7
+ import * as i2 from '@angular/material/icon';
8
+ import { MatIconModule } from '@angular/material/icon';
9
+ import * as i3 from '@angular/material/legacy-button';
10
+ import { MatLegacyButtonModule } from '@angular/material/legacy-button';
11
+ import * as i4 from '@angular/material/legacy-tooltip';
12
+ import { MatLegacyTooltipModule } from '@angular/material/legacy-tooltip';
13
+ import * as i5 from '@angular/material/legacy-slider';
14
+ import { MatLegacySliderModule } from '@angular/material/legacy-slider';
15
+ import * as i6 from '@angular/forms';
16
+ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
17
+ import * as i7 from '@angular/material/legacy-form-field';
18
+ import { MatLegacyFormFieldModule } from '@angular/material/legacy-form-field';
19
+ import * as i8 from '@angular/material/legacy-select';
20
+ import { MatLegacySelectModule } from '@angular/material/legacy-select';
21
+ import * as i9 from '@angular/material/legacy-core';
22
+ import * as i10 from '@angular/material/legacy-input';
23
+ import { MatLegacyInputModule } from '@angular/material/legacy-input';
24
+ import * as i11 from '@angular/material/legacy-checkbox';
25
+ import { MatLegacyCheckboxModule } from '@angular/material/legacy-checkbox';
26
+
27
+ class CalculateSizePipe {
28
+ transform(imageLength) {
29
+ if (!imageLength) {
30
+ return;
31
+ }
32
+ if (imageLength) {
33
+ return Math.ceil(((3 / 4) * imageLength) / 1024);
34
+ }
35
+ else {
36
+ return;
37
+ }
38
+ }
39
+ }
40
+ CalculateSizePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: CalculateSizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
41
+ CalculateSizePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.1.4", ngImport: i0, type: CalculateSizePipe, name: "calculateSize" });
42
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: CalculateSizePipe, decorators: [{
43
+ type: Pipe,
44
+ args: [{
45
+ name: 'calculateSize'
46
+ }]
47
+ }] });
48
+
49
+ class GuajiritosImagePickerComponent {
50
+ constructor(_cdRef) {
51
+ this._cdRef = _cdRef;
52
+ this.observer = null;
53
+ this.labelEn = {
54
+ 'Upload a image': 'Upload a image',
55
+ 'You must edit the image in order to resize it': 'You must edit the image in order to resize it',
56
+ 'too large': 'too large',
57
+ 'Open the editor panel': 'Open the editor panel',
58
+ 'Download the image': 'Download the image',
59
+ 'Control Panel': 'Control Panel',
60
+ Quality: 'Quality',
61
+ 'Max dimensions': 'Max dimensions',
62
+ 'aspect-ratio': 'aspect-ratio',
63
+ 'max-width(px)': 'max-width(px)',
64
+ 'max-height(px)': 'max-height(px)',
65
+ Format: 'Format',
66
+ Crop: 'Crop',
67
+ 'width(px)': 'width(px)',
68
+ 'height(px)': 'height(px)',
69
+ Remove: 'Remove',
70
+ };
71
+ this.labelEs = {
72
+ 'Upload a image': 'Suba una imagen',
73
+ 'You must edit the image in order to resize it': 'Debe editar la imagen para disminuir su tamaño',
74
+ 'too large': 'muy grande',
75
+ 'Open the editor panel': 'Abra el panel de edición',
76
+ 'Download the image': 'Descarge la imagen',
77
+ 'Control Panel': 'Panel de control',
78
+ Remove: 'Quitar',
79
+ Quality: 'Calidad',
80
+ 'Max dimensions': 'Dimensiones',
81
+ 'aspect-ratio': 'relación-aspecto',
82
+ 'max-width(px)': 'max. ancho',
83
+ 'max-height(px)': 'max. alto',
84
+ Format: 'Formato',
85
+ Crop: 'Recortar',
86
+ 'width(px)': 'ancho(px)',
87
+ 'height(px)': 'altura(px)',
88
+ };
89
+ this.labelFr = {
90
+ 'Upload a image': 'Charger une image',
91
+ 'You must edit the image in order to resize it': 'Vous devez éditer l\'image pour changer sa taille',
92
+ 'too large': 'Trop grande',
93
+ 'Open the editor panel': 'Ouvrir le panneau d\'édition',
94
+ 'Download the image': 'Télécharger l\'image',
95
+ 'Control Panel': 'Panneau de commande',
96
+ Remove: 'Supprimer',
97
+ Quality: 'Qualité',
98
+ 'Max dimensions': 'Dimensions maximales',
99
+ 'aspect-ratio': 'rapport de forme',
100
+ 'max-width(px)': 'largeur max.',
101
+ 'max-height(px)': 'hauteur max',
102
+ Format: 'Format',
103
+ Crop: 'Recadrer',
104
+ 'width(px)': 'largeur(px)',
105
+ 'height(px)': 'hauteur(px)',
106
+ };
107
+ this.arrayCopiedImages = [];
108
+ this.config = {
109
+ height: '240px',
110
+ width: '320px',
111
+ borderRadius: '16px',
112
+ compressInitial: true,
113
+ language: 'en',
114
+ hideDeleteBtn: false,
115
+ hideDownloadBtn: false,
116
+ hideEditBtn: false,
117
+ hideAddBtn: false,
118
+ };
119
+ this.showCrop = false;
120
+ this.loadImage = false;
121
+ this.uuidFilePicker = Date.now().toString(20);
122
+ this.showEditPanel = false;
123
+ this.quality = 92;
124
+ this.format = 'jpeg';
125
+ this.allFormats = ['webp', 'jpeg', 'png'];
126
+ this.maxHeight = 2000;
127
+ this.maxWidth = 2000;
128
+ this.cropHeight = 150;
129
+ this.cropWidth = 150;
130
+ this.maintainAspectRatio = true;
131
+ this.imageName = 'download';
132
+ this.appearance = 'outline';
133
+ this.color = 'primary';
134
+ this.imagesAllowed = 'image/*';
135
+ this.$imageChanged = new EventEmitter();
136
+ this.$imageOriginal = new EventEmitter();
137
+ this.labels = this.labelEn;
138
+ }
139
+ set _imageSrc(value) {
140
+ if (value) {
141
+ this.parseToBase64(value).then((dataUri) => {
142
+ this.imageSrc = dataUri;
143
+ this.arrayCopiedImages = [];
144
+ this.arrayCopiedImages.push(this.imageSrc);
145
+ this.originImageSrc = value;
146
+ this.lastOriginSrc = value;
147
+ this.$imageOriginal.next(this.originImageSrc);
148
+ this.loadImage = true;
149
+ this._cdRef.markForCheck();
150
+ });
151
+ }
152
+ else {
153
+ this.imageSrc = null;
154
+ this.originImageSrc = null;
155
+ this.loadImage = false;
156
+ this.arrayCopiedImages = [];
157
+ this.lastOriginSrc = null;
158
+ this.$imageOriginal.next(null);
159
+ this.format = 'jpeg';
160
+ this.maxHeight = 2000;
161
+ this.maxWidth = 2000;
162
+ this.cropHeight = 150;
163
+ this.cropWidth = 150;
164
+ this.maintainAspectRatio = true;
165
+ this.showEditPanel = false;
166
+ this._cdRef.markForCheck();
167
+ }
168
+ }
169
+ set _config(value) {
170
+ if (value && value.constructor == Object) {
171
+ this.config = Object.assign(Object.assign({}, this.config), value);
172
+ if ((value === null || value === void 0 ? void 0 : value.language) !== undefined) {
173
+ if (value.language === 'en') {
174
+ this.labels = Object.assign({}, this.labelEn);
175
+ }
176
+ if (value.language === 'es') {
177
+ this.labels = Object.assign({}, this.labelEs);
178
+ }
179
+ if (value.language === 'fr') {
180
+ this.labels = Object.assign({}, this.labelFr);
181
+ }
182
+ }
183
+ }
184
+ }
185
+ handleReaderLoaded(readerEvt) {
186
+ var _a;
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ const binaryString = readerEvt.target.result;
189
+ const base64textString = btoa(binaryString);
190
+ this.originImageSrc = this.urlImage + base64textString;
191
+ this.lastOriginSrc = this.urlImage + base64textString;
192
+ if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.compressInitial) {
193
+ this.quality = 92;
194
+ const input = {
195
+ dataType: this.format,
196
+ quality: 0.92,
197
+ maintainRatio: true,
198
+ };
199
+ this.imageSrc = yield this.resizeDataURL(this.urlImage + base64textString, input);
200
+ }
201
+ else {
202
+ this.imageSrc = this.urlImage + base64textString;
203
+ this.arrayCopiedImages = [];
204
+ this.arrayCopiedImages.push({
205
+ lastImage: this.imageSrc,
206
+ width: this.maxWidth,
207
+ height: this.maxHeight,
208
+ quality: this.quality,
209
+ });
210
+ this.$imageOriginal.next(this.imageSrc);
211
+ }
212
+ this.$imageChanged.next(this.imageSrc);
213
+ this.loadImage = true;
214
+ });
215
+ }
216
+ parseToBase64(imageUrl) {
217
+ let types = imageUrl.split('.');
218
+ let type = types[types.length - 1];
219
+ if (!type || (type !== 'png' && type !== 'jpeg' && type !== 'webp')) {
220
+ type = 'jpeg';
221
+ }
222
+ this.format = type;
223
+ return new Promise((resolve) => {
224
+ let img = document.createElement('img');
225
+ img.crossOrigin = 'Anonymous';
226
+ img.src = imageUrl;
227
+ this.maxHeight = img === null || img === void 0 ? void 0 : img.height;
228
+ this.maxWidth = img === null || img === void 0 ? void 0 : img.width;
229
+ img.onload = function () {
230
+ let canvas = document.createElement('canvas');
231
+ let ctx = canvas.getContext('2d');
232
+ let ratio = 1.0;
233
+ canvas.width = (img === null || img === void 0 ? void 0 : img.width) * ratio;
234
+ canvas.height = (img === null || img === void 0 ? void 0 : img.height) * ratio;
235
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
236
+ let dataURI = canvas.toDataURL(`image/${type}`, 0.92);
237
+ return resolve({
238
+ dataUri: dataURI,
239
+ width: canvas.width,
240
+ height: canvas.height,
241
+ });
242
+ };
243
+ }).then((data) => {
244
+ this.maxHeight = data === null || data === void 0 ? void 0 : data.height;
245
+ this.maxWidth = data === null || data === void 0 ? void 0 : data.width;
246
+ return data === null || data === void 0 ? void 0 : data.dataUri;
247
+ });
248
+ }
249
+ resizeDataURL(datas, input) {
250
+ return __awaiter(this, void 0, void 0, function* () {
251
+ return yield new Promise(function (resolve) {
252
+ return __awaiter(this, void 0, void 0, function* () {
253
+ let img = document.createElement('img');
254
+ img.src = datas + '';
255
+ img.crossOrigin = 'Anonymous';
256
+ let quality = input.quality ? input.quality : 1.0;
257
+ let maintainRatio = input.maintainRatio != undefined ? input.maintainRatio : true;
258
+ img.onload = function () {
259
+ const canvas = document.createElement('canvas');
260
+ const ctx = canvas.getContext('2d');
261
+ let ratio = img.width / img.height;
262
+ let width = input.width ? input.width : img.width;
263
+ let height = input.height ? input.height : img.height;
264
+ if (maintainRatio) {
265
+ if (input.changeHeight) {
266
+ canvas.width = height * ratio;
267
+ canvas.height = height;
268
+ }
269
+ else {
270
+ canvas.width = width;
271
+ canvas.height = width / ratio;
272
+ }
273
+ }
274
+ else {
275
+ canvas.width = width;
276
+ canvas.height = height;
277
+ }
278
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
279
+ let type = input.dataType ? input.dataType : 'webp';
280
+ const dataURI = canvas.toDataURL(`image/${type}`, quality);
281
+ resolve({
282
+ dataUri: dataURI,
283
+ width: canvas.width,
284
+ height: canvas.height,
285
+ });
286
+ };
287
+ });
288
+ }).then((data) => {
289
+ var _a;
290
+ this.maxHeight = data === null || data === void 0 ? void 0 : data.height;
291
+ this.maxWidth = data === null || data === void 0 ? void 0 : data.width;
292
+ if (((_a = this.arrayCopiedImages) === null || _a === void 0 ? void 0 : _a.length) <= 20) {
293
+ this.arrayCopiedImages.push({
294
+ lastImage: data === null || data === void 0 ? void 0 : data.dataUri,
295
+ width: this.maxWidth,
296
+ height: this.maxHeight,
297
+ quality: this.quality,
298
+ });
299
+ }
300
+ return data.dataUri;
301
+ });
302
+ });
303
+ }
304
+ wait(ms) {
305
+ ms = ms ? ms : 1000;
306
+ return new Promise((resolve) => {
307
+ setTimeout(() => {
308
+ return resolve(true);
309
+ }, ms);
310
+ });
311
+ }
312
+ dragElement(element) {
313
+ let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
314
+ if (document.getElementById(element.id + '-header')) {
315
+ document.getElementById(element.id + '-header').onmousedown = dragMouseDown;
316
+ document.getElementById(element.id + '-header').ontouchstart = dragMouseDown;
317
+ }
318
+ else {
319
+ element.onmousedown = dragMouseDown;
320
+ element.ontouchstart = dragMouseDown;
321
+ }
322
+ function dragMouseDown(e) {
323
+ e = e || window.event;
324
+ e.preventDefault();
325
+ pos3 = e.clientX;
326
+ pos4 = e.clientY;
327
+ document.onmouseup = closeDragElement;
328
+ document.ontouchend = closeDragElement;
329
+ document.onmousemove = elementDrag;
330
+ document.ontouchmove = elementDrag;
331
+ }
332
+ function elementDrag(e) {
333
+ let holderImage = document.getElementById('image-full');
334
+ e = e || window.event;
335
+ e.preventDefault();
336
+ pos1 = pos3 - e.clientX;
337
+ pos2 = pos4 - e.clientY;
338
+ pos3 = e.clientX;
339
+ pos4 = e.clientY;
340
+ const newTop = element.offsetTop - pos2;
341
+ const newLeft = element.offsetLeft - pos1;
342
+ const rectHolder = holderImage.getBoundingClientRect();
343
+ const rectElement = element.getBoundingClientRect();
344
+ if (newTop >= rectHolder.y + 8) {
345
+ element.style.top = Math.min(newTop, rectHolder.y + rectHolder.height - rectElement.height - 4) + 'px';
346
+ }
347
+ if (newLeft > rectHolder.x + 4 && rectHolder.x + rectHolder.width > rectElement.x + rectElement.width + 2) {
348
+ element.style.left = Math.min(newLeft, rectHolder.x + rectHolder.width - rectElement.width - 4) + 'px';
349
+ }
350
+ }
351
+ function closeDragElement() {
352
+ document.onmouseup = null;
353
+ document.onmousemove = null;
354
+ document.ontouchend = null;
355
+ document.ontouchmove = null;
356
+ }
357
+ }
358
+ onUpload(event) {
359
+ event.preventDefault();
360
+ this.imagePicker.nativeElement.click();
361
+ }
362
+ handleFileSelect(evt) {
363
+ var _a;
364
+ const files = (_a = evt.target) === null || _a === void 0 ? void 0 : _a.files;
365
+ if (files) {
366
+ const file = files[0];
367
+ this.imageName = file.name.split('.')[0];
368
+ this.fileType = file.type;
369
+ this.urlImage = `data:${file.type};base64,`;
370
+ if (files && file) {
371
+ const reader = new FileReader();
372
+ reader.onload = this.handleReaderLoaded.bind(this);
373
+ reader.readAsBinaryString(file);
374
+ }
375
+ }
376
+ }
377
+ onCloseEditPanel() {
378
+ if (this.observer instanceof ResizeObserver) {
379
+ this.observer.unobserve(document.getElementById('image-cropper'));
380
+ this.observer.unobserve(document.getElementById('image-full'));
381
+ }
382
+ this.showCrop = false;
383
+ this.showEditPanel = false;
384
+ }
385
+ onChangeQuality() {
386
+ return __awaiter(this, void 0, void 0, function* () {
387
+ const qualityItem = this.quality / 100;
388
+ this.maxHeight = this.maxHeight && +this.maxHeight ? this.maxHeight : 2000;
389
+ this.maxWidth = this.maxWidth && +this.maxWidth ? this.maxWidth : 2000;
390
+ yield this.wait(250);
391
+ try {
392
+ const input = {
393
+ height: this.maxHeight,
394
+ width: this.maxWidth,
395
+ dataType: this.format,
396
+ quality: qualityItem,
397
+ maintainRatio: this.maintainAspectRatio,
398
+ };
399
+ this.imageSrc = yield this.resizeDataURL(this.originImageSrc, input);
400
+ this.$imageChanged.next(this.imageSrc);
401
+ this.loadImage = true;
402
+ }
403
+ catch (error) {
404
+ this.loadImage = true;
405
+ }
406
+ });
407
+ }
408
+ onChangeFormat() {
409
+ return __awaiter(this, void 0, void 0, function* () {
410
+ let qualityItem = this.quality / 100;
411
+ this.maxHeight = this.maxHeight && +this.maxHeight ? this.maxHeight : 2000;
412
+ this.maxWidth = this.maxWidth && +this.maxWidth ? this.maxWidth : 2000;
413
+ yield this.wait(250);
414
+ try {
415
+ let input = {
416
+ height: this.maxHeight,
417
+ width: this.maxWidth,
418
+ dataType: this.format,
419
+ quality: qualityItem,
420
+ maintainRatio: this.maintainAspectRatio,
421
+ };
422
+ this.imageSrc = yield this.resizeDataURL(this.originImageSrc, input);
423
+ this.$imageChanged.next(this.imageSrc);
424
+ this.loadImage = true;
425
+ }
426
+ catch (error) {
427
+ this.loadImage = true;
428
+ }
429
+ });
430
+ }
431
+ onChangeSize(changeWidth, changeHeight) {
432
+ return __awaiter(this, void 0, void 0, function* () {
433
+ let qualityItem = this.quality / 100;
434
+ this.maxHeight = this.maxHeight && +this.maxHeight ? this.maxHeight : 2000;
435
+ this.maxWidth = this.maxWidth && +this.maxWidth ? this.maxWidth : 2000;
436
+ yield this.wait(500);
437
+ try {
438
+ let input = {
439
+ height: this.maxHeight,
440
+ width: this.maxWidth,
441
+ dataType: this.format,
442
+ quality: qualityItem,
443
+ maintainRatio: this.maintainAspectRatio,
444
+ changeHeight: changeHeight,
445
+ changeWidth: changeWidth,
446
+ };
447
+ this.imageSrc = yield this.resizeDataURL(this.originImageSrc, input);
448
+ this.$imageChanged.next(this.imageSrc);
449
+ this.loadImage = true;
450
+ }
451
+ catch (error) {
452
+ this.loadImage = true;
453
+ }
454
+ });
455
+ }
456
+ onChangeCrop() {
457
+ const cropper = document.getElementById('image-cropper');
458
+ cropper.style.width = this.cropWidth + 'px';
459
+ cropper.style.height = this.cropHeight + 'px';
460
+ }
461
+ onCropStateChange() {
462
+ const cropper = document.getElementById('image-cropper');
463
+ if (this.showCrop) {
464
+ cropper.style.opacity = '1.0';
465
+ this.dragElement(cropper);
466
+ this.observer = new ResizeObserver((entries) => {
467
+ entries.forEach((entry) => {
468
+ if (this.showEditPanel) {
469
+ const elementCropper = document.getElementById('image-cropper');
470
+ const rectHolder = document.getElementById('image-full').getBoundingClientRect();
471
+ const rectElemnt = elementCropper.getBoundingClientRect();
472
+ const maxWidth = rectHolder.x + rectHolder.width - rectElemnt.x - 4;
473
+ const maxHeight = rectHolder.y + rectHolder.height - rectElemnt.y - 4;
474
+ elementCropper.style.maxWidth = maxWidth + 'px';
475
+ elementCropper.style.maxHeight = maxHeight + 'px';
476
+ this.cropWidth = rectElemnt.width;
477
+ this.cropHeight = rectElemnt.height;
478
+ if (entry.target.id == 'image-full') {
479
+ if (rectHolder.top > 0) {
480
+ elementCropper.style.top = rectHolder.top + 4 + 'px';
481
+ }
482
+ elementCropper.style.left = rectHolder.left + 4 + 'px';
483
+ }
484
+ }
485
+ });
486
+ });
487
+ this.observer.observe(document.getElementById('image-cropper'));
488
+ this.observer.observe(document.getElementById('image-full'));
489
+ }
490
+ else {
491
+ cropper.style.opacity = '0.0';
492
+ if (this.observer instanceof ResizeObserver) {
493
+ this.observer.unobserve(document.getElementById('image-cropper'));
494
+ this.observer.unobserve(document.getElementById('image-full'));
495
+ }
496
+ }
497
+ }
498
+ onCrop(type) {
499
+ type = type ? type : this.format;
500
+ const cropper = document.getElementById('image-cropper');
501
+ const rectCropper = cropper.getBoundingClientRect();
502
+ const dataHolderRect = document.getElementById('image-full').getBoundingClientRect();
503
+ const canvas = document.createElement('canvas');
504
+ new Promise((resolve, reject) => {
505
+ let ctx = canvas.getContext('2d');
506
+ let image = new Image();
507
+ image.src = this.imageSrc;
508
+ image.onload = () => {
509
+ let ratio = image.height / dataHolderRect.height;
510
+ let newWidth = rectCropper.width * ratio;
511
+ let newHeight = rectCropper.height * ratio;
512
+ canvas.height = newHeight;
513
+ canvas.width = newWidth;
514
+ ctx.drawImage(image, Math.abs(rectCropper.x * ratio) - Math.abs(dataHolderRect.x * ratio), Math.abs(rectCropper.y * ratio) - Math.abs(dataHolderRect.y * ratio), newWidth, newHeight, 0, 0, newWidth, newHeight);
515
+ // ctx.drawImage(image, 90, 130, 50, 60, 10, 10, 50, 60);
516
+ resolve(canvas.toDataURL(`image/${type}`, 0.98));
517
+ };
518
+ image.onerror = (e) => {
519
+ reject(e);
520
+ };
521
+ })
522
+ .then((dataUri) => {
523
+ this.imageSrc = dataUri;
524
+ this.showCrop = false;
525
+ this.onCropStateChange();
526
+ this.maxWidth = canvas.width;
527
+ this.maxHeight = canvas.height;
528
+ this.lastOriginSrc = this.originImageSrc + '';
529
+ this.originImageSrc = dataUri;
530
+ this.$imageChanged.next(this.imageSrc);
531
+ })
532
+ .catch((e) => {
533
+ console.log(e);
534
+ });
535
+ }
536
+ onRestore() {
537
+ if (this.arrayCopiedImages.length) {
538
+ let lastState = this.arrayCopiedImages.pop();
539
+ this.imageSrc = lastState.lastImage;
540
+ this.maxWidth = lastState.width;
541
+ this.maxHeight = lastState.height;
542
+ this.originImageSrc = this.lastOriginSrc + '';
543
+ }
544
+ else {
545
+ this.imageSrc = this.lastOriginSrc;
546
+ this.originImageSrc = this.lastOriginSrc + '';
547
+ }
548
+ this.$imageChanged.next(this.imageSrc);
549
+ }
550
+ onRemove() {
551
+ this.imageSrc = null;
552
+ this.originImageSrc = null;
553
+ this.loadImage = false;
554
+ this.arrayCopiedImages = [];
555
+ this.lastOriginSrc = null;
556
+ this.$imageOriginal.next(null);
557
+ this.$imageChanged.next(null);
558
+ this.format = 'jpeg';
559
+ this.maxHeight = 2000;
560
+ this.maxWidth = 2000;
561
+ this.cropHeight = 150;
562
+ this.cropWidth = 150;
563
+ this.maintainAspectRatio = true;
564
+ this.showEditPanel = false;
565
+ }
566
+ }
567
+ GuajiritosImagePickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GuajiritosImagePickerComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
568
+ GuajiritosImagePickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GuajiritosImagePickerComponent, selector: "guajiritos-image-picker", inputs: { appearance: "appearance", color: "color", imagesAllowed: "imagesAllowed", _imageSrc: "_imageSrc", _config: "_config" }, outputs: { $imageChanged: "$imageChanged", $imageOriginal: "$imageOriginal" }, viewQueries: [{ propertyName: "imagePicker", first: true, predicate: ["imagePicker"], descendants: true }], ngImport: i0, template: "<div *ngIf='!loadImage' class='place-image'>\r\n <div class='image-holder'\r\n [ngStyle]='{ width: config?.width,height: config?.height,borderRadius: config?.borderRadius}'>\r\n <button [matTooltip]=\"labels['Upload a image']\" class='image-upload-btn' mat-icon-button (click)='onUpload($event)'>\r\n <mat-icon class='mat-18'>add_a_photo</mat-icon>\r\n </button>\r\n <input #imagePicker type='file' style='display: none' [id]=\"'filePicker-' + uuidFilePicker\"\r\n (change)='handleFileSelect($event)' [accept]='imagesAllowed'>\r\n </div>\r\n</div>\r\n<div *ngIf='loadImage' class='place-image'>\r\n <div class='image-holder-loaded'\r\n [ngStyle]='{width: config?.width,height: config?.height,borderRadius: config?.borderRadius}'>\r\n <img [src]='imageSrc' alt='image-loaded' [ngStyle]='{ borderRadius: config.borderRadius }'>\r\n <input #imagePicker type='file' style='display: none' [id]=\"'filePicker-' + uuidFilePicker\"\r\n (change)='handleFileSelect($event)' [accept]='imagesAllowed'>\r\n </div>\r\n <p *ngIf='imageSrc?.length' class='mat-caption image-caption'\r\n [ngStyle]=\"{color: (imageSrc?.length | calculateSize) > 120 ? '#f44336' : 'unset',fontWeight: (imageSrc?.length | calculateSize) > 120 ? '500' : 'unset'}\">\r\n size: {{ (imageSrc?.length | calculateSize) }}Kb &nbsp; {{ format }}\r\n </p>\r\n\r\n <div class='editing-bar-btn'\r\n style='flex-direction: row; box-sizing: border-box; display: flex; place-content: flex-start; align-items: flex-start'>\r\n <button id='upload-img' *ngIf='!config.hideAddBtn' mat-icon-button [matTooltip]=\"labels['Upload a image']\"\r\n (click)='onUpload($event)'>\r\n <mat-icon class='mat-18'>add_a_photo</mat-icon>\r\n </button>\r\n <button id='edit-img' *ngIf='!config.hideEditBtn' mat-icon-button [matTooltip]=\"labels['Open the editor panel']\"\r\n (click)='showEditPanel = true'>\r\n <mat-icon class='mat-18'>edit</mat-icon>\r\n </button>\r\n <a id='download-img' *ngIf='!config.hideDownloadBtn' [matTooltip]=\"labels['Download the image']\"\r\n [href]='imageSrc' mat-icon-button [download]='imageName'>\r\n <mat-icon class='mat-18'>cloud_download</mat-icon>\r\n </a>\r\n <button id='delete-img' *ngIf='!config.hideDeleteBtn' mat-icon-button [matTooltip]=\"labels['Remove']\"\r\n (click)='onRemove()'>\r\n <mat-icon class='mat-18'>delete</mat-icon>\r\n </button>\r\n </div>\r\n</div>\r\n\r\n<div *ngIf='showEditPanel' id='popup' class='popup'>\r\n <div\r\n style='flex-direction: row; box-sizing: border-box; display: flex; place-content: center flex-end; align-items: center'>\r\n <button mat-icon-button (click)='onCloseEditPanel()'>\r\n <mat-icon class='mat-18'>clear</mat-icon>\r\n </button>\r\n </div>\r\n\r\n <div class='image-container'>\r\n <div class='image-holder-full'>\r\n <img id='image-full' [src]='imageSrc' alt=''>\r\n <div id='image-cropper' class='image-cropper'>\r\n <div id='image-cropper-header'>\r\n <mat-icon>drag_indicator</mat-icon>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class='control-panel'>\r\n <p class='title-panel'>{{ labels['Control Panel'] }}</p>\r\n\r\n <p class='item-panel'>{{ labels['Quality'] }}</p>\r\n <div\r\n style='flex-direction: row; box-sizing: border-box; display: flex; place-content: flex-start; align-items: flex-start'>\r\n <mat-slider [color]='color' style='max-width: 100%; width: 100%' (change)='onChangeQuality()'\r\n [(ngModel)]='quality' [min]='0' [max]='100' [step]='1' [thumbLabel]='true'>\r\n </mat-slider>\r\n </div>\r\n\r\n <p class='item-panel'>\r\n {{ labels['Max dimensions'] }}\r\n <mat-checkbox style='float: right' [(ngModel)]='maintainAspectRatio' [color]='color'>\r\n <span class='mat-caption'>{{ labels['aspect-ratio'] }}</span>\r\n </mat-checkbox>\r\n </p>\r\n <div\r\n style='margin-top: 8px !important; flex-flow: row wrap; box-sizing: border-box; display: flex; place-content: flex-start space-between; align-items: flex-start'>\r\n <mat-form-field class='no-input-style' style='max-width: 48%; width: 48%' [appearance]='appearance'\r\n [color]='color'>\r\n <mat-label>{{ labels['max-width(px)'] }}</mat-label>\r\n <input (change)='onChangeSize(true, false)' matInput [placeholder]=\"labels['max-width(px)']\"\r\n [(ngModel)]='maxWidth' type='number' [min]='0' [max]='2000'>\r\n </mat-form-field>\r\n\r\n <mat-form-field class='no-input-style' style='max-width: 48%; width: 48%' [appearance]='appearance'\r\n [color]='color'>\r\n <mat-label>{{ labels['max-height(px)'] }}</mat-label>\r\n <input (change)='onChangeSize(false, true)' matInput [placeholder]=\"labels['max-height(px)']\"\r\n [(ngModel)]='maxHeight' type='number' [min]='0' [max]='2000'>\r\n </mat-form-field>\r\n </div>\r\n\r\n <p class='item-panel'>{{ labels['Format'] }}</p>\r\n <div\r\n style='margin-top: 8px !important; flex-direction: row; box-sizing: border-box; display: flex; place-content: flex-start; align-items: flex-start'>\r\n <mat-form-field class='no-input-style' style='max-width: 100%; width: 100%' [appearance]='appearance'\r\n [color]='color'>\r\n <mat-select [(ngModel)]='format' (selectionChange)='onChangeFormat()'>\r\n <mat-option *ngFor='let format of allFormats' [value]='format'>\r\n {{ format }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-checkbox (change)='onCropStateChange()' [(ngModel)]='showCrop' [color]='color'>\r\n <p class='item-panel'>{{ labels['Crop'] }}</p>\r\n </mat-checkbox>\r\n <button style='float: right' mat-icon-button [color]='color' (click)='onRestore()'>\r\n <mat-icon>refresh</mat-icon>\r\n </button>\r\n </div>\r\n\r\n <ng-container *ngIf='showCrop'>\r\n <div\r\n style='margin-top: 8px !important; flex-flow: row wrap; box-sizing: border-box; display: flex; place-content: flex-start space-between; align-items: flex-start'>\r\n <mat-form-field class='no-input-style' style='max-width: 48%; width: 48%' [appearance]='appearance'\r\n [color]='color'>\r\n <mat-label>{{ labels['width(px)'] }}</mat-label>\r\n <input (change)='onChangeCrop()' matInput [placeholder]=\"labels['width(px)']\"\r\n [(ngModel)]='cropWidth' type='number' [min]='0' [max]='2000'>\r\n </mat-form-field>\r\n <mat-form-field class='no-input-style' style='max-width: 48%; width: 48%' [appearance]='appearance'\r\n [color]='color'>\r\n <mat-label>{{ labels['height(px)'] }}</mat-label>\r\n <input (change)='onChangeCrop()' matInput\r\n [placeholder]=\"labels['height(px)']\" [(ngModel)]='cropHeight' type='number' [min]='0' [max]='2000'>\r\n </mat-form-field>\r\n </div>\r\n\r\n <p style='margin-bottom: 4px !important'>\r\n <button mat-icon-button [color]='color' (click)='onCrop()'>\r\n <mat-icon> crop</mat-icon>\r\n </button>\r\n </p>\r\n </ng-container>\r\n\r\n <div\r\n style='flex-direction: row; box-sizing: border-box; display: flex; place-content: center space-between; align-items: center'>\r\n <button mat-flat-button (click)='onCloseEditPanel()' [color]='color'\r\n style='padding: 0 8px; height: 34px; box-sizing: border-box;'>\r\n Guardar\r\n </button>\r\n\r\n <p *ngIf='imageSrc?.length' class='mat-caption image-caption'\r\n [ngStyle]=\"{color: (imageSrc?.length | calculateSize) > 120 ? '#f44336' : 'unset',fontWeight: (imageSrc?.length | calculateSize) > 120 ? '500' : 'unset'}\">\r\n size: {{ (imageSrc?.length | calculateSize) }}Kb &nbsp; {{ format }}\r\n </p>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n", styles: ["guachos-image-picker p{margin:0!important;padding:0!important}guachos-image-picker .place-image{flex-direction:column;box-sizing:border-box;display:flex;place-content:flex-start;align-items:center}guachos-image-picker .place-image .image-holder{flex-direction:column;box-sizing:border-box;display:flex;place-content:center;align-items:center;position:relative;width:320px;height:240px;border-radius:16px;max-width:100%!important;border:2px rgba(0,0,0,.3) solid;background-color:#fcfcfc}@media (max-width: 599px){guachos-image-picker .place-image .image-holder{max-width:100%!important;max-height:250px!important}}guachos-image-picker .place-image .image-holder .image-upload-btn{transition:all .5s ease;position:relative;opacity:.85;width:50px;height:50px;color:#424242}guachos-image-picker .place-image .image-holder .image-upload-btn mat-icon{font-size:50px;width:50px;height:50px;line-height:50px;color:#424242}@media (max-width: 599px){guachos-image-picker .place-image .image-holder .image-upload-btn{opacity:1;width:30px;height:30px}guachos-image-picker .place-image .image-holder .image-upload-btn mat-icon{font-size:30px;width:30px;height:30px;line-height:30px}}guachos-image-picker .place-image .image-holder:hover .image-upload-btn{opacity:1;transition:all .5s ease}guachos-image-picker .place-image .image-holder-loaded{flex-direction:column;box-sizing:border-box;display:flex;place-content:center;align-items:center;position:relative;max-width:100%!important;width:320px;height:240px;border-radius:4px;padding:2px}guachos-image-picker .place-image .image-holder-loaded .image-caption{position:absolute;right:0;bottom:-22px}guachos-image-picker .place-image .image-holder-loaded img{height:100%;max-height:100%;width:100%;max-width:100%;object-fit:cover;object-position:center}@media (max-width: 599px){guachos-image-picker .place-image .image-holder-loaded{max-height:195px!important}}guachos-image-picker .place-image .image-holder-loaded .image-upload-btn{transition:all .5s ease;position:relative;opacity:.85;width:50px;height:50px;color:#424242}guachos-image-picker .place-image .image-holder-loaded .image-upload-btn mat-icon{font-size:50px;width:50px;height:50px;line-height:50px;color:#424242}@media (max-width: 599px){guachos-image-picker .place-image .image-holder-loaded .image-upload-btn{opacity:1;width:30px;height:30px}guachos-image-picker .place-image .image-holder-loaded .image-upload-btn mat-icon{font-size:30px;width:30px;height:30px;line-height:30px}}guachos-image-picker .place-image .image-holder-loaded:hover .image-upload-btn{opacity:1;transition:all .5s ease}guachos-image-picker .place-image .editing-bar-btn{margin-top:2px}guachos-image-picker .place-image .editing-bar-btn .mat-icon-button{height:20px;line-height:20px;width:24px}guachos-image-picker .place-image .editing-bar-btn mat-icon{line-height:20px!important;font-size:20px!important;width:20px!important;height:20px!important}guachos-image-picker .place-image .editing-bar-btn button{margin:4px;color:#424242;transition:all .5s ease}guachos-image-picker .place-image .editing-bar-btn button:hover{transform:scale(1.25);margin:4px 8px;transition:all .25s ease-in}guachos-image-picker .place-image .editing-bar-btn a{margin:4px;color:#424242;transition:all .5s ease}guachos-image-picker .place-image .editing-bar-btn a:hover{transform:scale(1.25);margin:4px 8px;transition:all .25s ease-in}guachos-image-picker .popup{width:100vw;max-height:100%;height:100%;overflow:auto;position:fixed;top:0;left:0;background-color:#000c;z-index:1000;padding:24px;color:#fff;box-sizing:border-box;animation-name:show;animation-duration:.4s}guachos-image-picker .popup .image-container{margin-top:50px;margin-bottom:50px;height:100%;min-height:100%;min-width:100%;width:100%;flex-flow:row wrap;box-sizing:border-box;display:flex;place-content:flex-start center;align-items:flex-start}guachos-image-picker .popup .image-container .image-holder-full{height:auto;width:auto;position:relative;display:contents}guachos-image-picker .popup img{max-height:600px;max-width:100%;object-fit:cover;object-position:center;margin:8px;transition:all .5s ease}@media (max-width: 1024px){guachos-image-picker .popup{background-color:#000000d9;padding:8px}guachos-image-picker .popup img{max-height:100%;max-width:100%}}@media (max-width: 599px){guachos-image-picker .popup img{margin:0}}guachos-image-picker .popup .control-panel{color:#fff;background-color:#000000eb;margin:8px;padding:16px;max-width:100%;width:18rem;border-radius:8px;flex-direction:column;box-sizing:border-box;display:flex;place-content:stretch flex-start;align-items:stretch}@media (max-width: 599px){guachos-image-picker .popup .control-panel{margin:8px 0;width:100%}}guachos-image-picker .popup .control-panel .title-panel{padding:0 4px;font-size:17px;font-weight:500;margin-bottom:16px!important}guachos-image-picker .popup .control-panel .item-panel{padding:0 4px;font-size:14px;font-weight:500}@keyframes show{0%{top:-100vh;opacity:0}to{top:0;opacity:1}}guachos-image-picker .mat-form-field-appearance-fill .mat-form-field-flex{background-color:#fafafa!important}guachos-image-picker .mat-select-panel{background:#fafafa!important}guachos-image-picker input.mat-input-element{color:#000000d9}guachos-image-picker .mat-checkbox-background{background-color:#fff}guachos-image-picker .image-cropper{position:absolute;width:150px;height:150px;border:2.5px solid #fafafa;box-sizing:border-box;resize:both;overflow:auto;opacity:0}guachos-image-picker .image-cropper #image-cropper-header{padding:10px;cursor:move;z-index:10;background-color:transparent;height:85%}guachos-image-picker .image-cropper #image-cropper-header mat-icon{color:#fff}guachos-image-picker .btn{padding:4px 8px;border-radius:4px;cursor:pointer}guachos-image-picker .btn mat-icon{color:#000000d1}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i3.MatLegacyButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i3.MatLegacyAnchor, selector: "a[mat-button], a[mat-raised-button], a[mat-icon-button], a[mat-fab], a[mat-mini-fab], a[mat-stroked-button], a[mat-flat-button]", inputs: ["disabled", "disableRipple", "color", "tabIndex"], exportAs: ["matButton", "matAnchor"] }, { kind: "directive", type: i4.MatLegacyTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "component", type: i5.MatLegacySlider, selector: "mat-slider", inputs: ["disabled", "color", "tabIndex", "invert", "max", "min", "step", "thumbLabel", "tickInterval", "value", "displayWith", "valueText", "vertical"], outputs: ["change", "input", "valueChange"], exportAs: ["matSlider"] }, { kind: "directive", type: i6.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i6.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i6.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { kind: "directive", type: i6.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i7.MatLegacyFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i7.MatLegacyLabel, selector: "mat-label" }, { kind: "component", type: i8.MatLegacySelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "component", type: i9.MatLegacyOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "directive", type: i10.MatLegacyInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", exportAs: ["matInput"] }, { kind: "component", type: i11.MatLegacyCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "pipe", type: CalculateSizePipe, name: "calculateSize" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
569
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GuajiritosImagePickerComponent, decorators: [{
570
+ type: Component,
571
+ args: [{ selector: 'guajiritos-image-picker', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div *ngIf='!loadImage' class='place-image'>\r\n <div class='image-holder'\r\n [ngStyle]='{ width: config?.width,height: config?.height,borderRadius: config?.borderRadius}'>\r\n <button [matTooltip]=\"labels['Upload a image']\" class='image-upload-btn' mat-icon-button (click)='onUpload($event)'>\r\n <mat-icon class='mat-18'>add_a_photo</mat-icon>\r\n </button>\r\n <input #imagePicker type='file' style='display: none' [id]=\"'filePicker-' + uuidFilePicker\"\r\n (change)='handleFileSelect($event)' [accept]='imagesAllowed'>\r\n </div>\r\n</div>\r\n<div *ngIf='loadImage' class='place-image'>\r\n <div class='image-holder-loaded'\r\n [ngStyle]='{width: config?.width,height: config?.height,borderRadius: config?.borderRadius}'>\r\n <img [src]='imageSrc' alt='image-loaded' [ngStyle]='{ borderRadius: config.borderRadius }'>\r\n <input #imagePicker type='file' style='display: none' [id]=\"'filePicker-' + uuidFilePicker\"\r\n (change)='handleFileSelect($event)' [accept]='imagesAllowed'>\r\n </div>\r\n <p *ngIf='imageSrc?.length' class='mat-caption image-caption'\r\n [ngStyle]=\"{color: (imageSrc?.length | calculateSize) > 120 ? '#f44336' : 'unset',fontWeight: (imageSrc?.length | calculateSize) > 120 ? '500' : 'unset'}\">\r\n size: {{ (imageSrc?.length | calculateSize) }}Kb &nbsp; {{ format }}\r\n </p>\r\n\r\n <div class='editing-bar-btn'\r\n style='flex-direction: row; box-sizing: border-box; display: flex; place-content: flex-start; align-items: flex-start'>\r\n <button id='upload-img' *ngIf='!config.hideAddBtn' mat-icon-button [matTooltip]=\"labels['Upload a image']\"\r\n (click)='onUpload($event)'>\r\n <mat-icon class='mat-18'>add_a_photo</mat-icon>\r\n </button>\r\n <button id='edit-img' *ngIf='!config.hideEditBtn' mat-icon-button [matTooltip]=\"labels['Open the editor panel']\"\r\n (click)='showEditPanel = true'>\r\n <mat-icon class='mat-18'>edit</mat-icon>\r\n </button>\r\n <a id='download-img' *ngIf='!config.hideDownloadBtn' [matTooltip]=\"labels['Download the image']\"\r\n [href]='imageSrc' mat-icon-button [download]='imageName'>\r\n <mat-icon class='mat-18'>cloud_download</mat-icon>\r\n </a>\r\n <button id='delete-img' *ngIf='!config.hideDeleteBtn' mat-icon-button [matTooltip]=\"labels['Remove']\"\r\n (click)='onRemove()'>\r\n <mat-icon class='mat-18'>delete</mat-icon>\r\n </button>\r\n </div>\r\n</div>\r\n\r\n<div *ngIf='showEditPanel' id='popup' class='popup'>\r\n <div\r\n style='flex-direction: row; box-sizing: border-box; display: flex; place-content: center flex-end; align-items: center'>\r\n <button mat-icon-button (click)='onCloseEditPanel()'>\r\n <mat-icon class='mat-18'>clear</mat-icon>\r\n </button>\r\n </div>\r\n\r\n <div class='image-container'>\r\n <div class='image-holder-full'>\r\n <img id='image-full' [src]='imageSrc' alt=''>\r\n <div id='image-cropper' class='image-cropper'>\r\n <div id='image-cropper-header'>\r\n <mat-icon>drag_indicator</mat-icon>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class='control-panel'>\r\n <p class='title-panel'>{{ labels['Control Panel'] }}</p>\r\n\r\n <p class='item-panel'>{{ labels['Quality'] }}</p>\r\n <div\r\n style='flex-direction: row; box-sizing: border-box; display: flex; place-content: flex-start; align-items: flex-start'>\r\n <mat-slider [color]='color' style='max-width: 100%; width: 100%' (change)='onChangeQuality()'\r\n [(ngModel)]='quality' [min]='0' [max]='100' [step]='1' [thumbLabel]='true'>\r\n </mat-slider>\r\n </div>\r\n\r\n <p class='item-panel'>\r\n {{ labels['Max dimensions'] }}\r\n <mat-checkbox style='float: right' [(ngModel)]='maintainAspectRatio' [color]='color'>\r\n <span class='mat-caption'>{{ labels['aspect-ratio'] }}</span>\r\n </mat-checkbox>\r\n </p>\r\n <div\r\n style='margin-top: 8px !important; flex-flow: row wrap; box-sizing: border-box; display: flex; place-content: flex-start space-between; align-items: flex-start'>\r\n <mat-form-field class='no-input-style' style='max-width: 48%; width: 48%' [appearance]='appearance'\r\n [color]='color'>\r\n <mat-label>{{ labels['max-width(px)'] }}</mat-label>\r\n <input (change)='onChangeSize(true, false)' matInput [placeholder]=\"labels['max-width(px)']\"\r\n [(ngModel)]='maxWidth' type='number' [min]='0' [max]='2000'>\r\n </mat-form-field>\r\n\r\n <mat-form-field class='no-input-style' style='max-width: 48%; width: 48%' [appearance]='appearance'\r\n [color]='color'>\r\n <mat-label>{{ labels['max-height(px)'] }}</mat-label>\r\n <input (change)='onChangeSize(false, true)' matInput [placeholder]=\"labels['max-height(px)']\"\r\n [(ngModel)]='maxHeight' type='number' [min]='0' [max]='2000'>\r\n </mat-form-field>\r\n </div>\r\n\r\n <p class='item-panel'>{{ labels['Format'] }}</p>\r\n <div\r\n style='margin-top: 8px !important; flex-direction: row; box-sizing: border-box; display: flex; place-content: flex-start; align-items: flex-start'>\r\n <mat-form-field class='no-input-style' style='max-width: 100%; width: 100%' [appearance]='appearance'\r\n [color]='color'>\r\n <mat-select [(ngModel)]='format' (selectionChange)='onChangeFormat()'>\r\n <mat-option *ngFor='let format of allFormats' [value]='format'>\r\n {{ format }}\r\n </mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-checkbox (change)='onCropStateChange()' [(ngModel)]='showCrop' [color]='color'>\r\n <p class='item-panel'>{{ labels['Crop'] }}</p>\r\n </mat-checkbox>\r\n <button style='float: right' mat-icon-button [color]='color' (click)='onRestore()'>\r\n <mat-icon>refresh</mat-icon>\r\n </button>\r\n </div>\r\n\r\n <ng-container *ngIf='showCrop'>\r\n <div\r\n style='margin-top: 8px !important; flex-flow: row wrap; box-sizing: border-box; display: flex; place-content: flex-start space-between; align-items: flex-start'>\r\n <mat-form-field class='no-input-style' style='max-width: 48%; width: 48%' [appearance]='appearance'\r\n [color]='color'>\r\n <mat-label>{{ labels['width(px)'] }}</mat-label>\r\n <input (change)='onChangeCrop()' matInput [placeholder]=\"labels['width(px)']\"\r\n [(ngModel)]='cropWidth' type='number' [min]='0' [max]='2000'>\r\n </mat-form-field>\r\n <mat-form-field class='no-input-style' style='max-width: 48%; width: 48%' [appearance]='appearance'\r\n [color]='color'>\r\n <mat-label>{{ labels['height(px)'] }}</mat-label>\r\n <input (change)='onChangeCrop()' matInput\r\n [placeholder]=\"labels['height(px)']\" [(ngModel)]='cropHeight' type='number' [min]='0' [max]='2000'>\r\n </mat-form-field>\r\n </div>\r\n\r\n <p style='margin-bottom: 4px !important'>\r\n <button mat-icon-button [color]='color' (click)='onCrop()'>\r\n <mat-icon> crop</mat-icon>\r\n </button>\r\n </p>\r\n </ng-container>\r\n\r\n <div\r\n style='flex-direction: row; box-sizing: border-box; display: flex; place-content: center space-between; align-items: center'>\r\n <button mat-flat-button (click)='onCloseEditPanel()' [color]='color'\r\n style='padding: 0 8px; height: 34px; box-sizing: border-box;'>\r\n Guardar\r\n </button>\r\n\r\n <p *ngIf='imageSrc?.length' class='mat-caption image-caption'\r\n [ngStyle]=\"{color: (imageSrc?.length | calculateSize) > 120 ? '#f44336' : 'unset',fontWeight: (imageSrc?.length | calculateSize) > 120 ? '500' : 'unset'}\">\r\n size: {{ (imageSrc?.length | calculateSize) }}Kb &nbsp; {{ format }}\r\n </p>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n", styles: ["guachos-image-picker p{margin:0!important;padding:0!important}guachos-image-picker .place-image{flex-direction:column;box-sizing:border-box;display:flex;place-content:flex-start;align-items:center}guachos-image-picker .place-image .image-holder{flex-direction:column;box-sizing:border-box;display:flex;place-content:center;align-items:center;position:relative;width:320px;height:240px;border-radius:16px;max-width:100%!important;border:2px rgba(0,0,0,.3) solid;background-color:#fcfcfc}@media (max-width: 599px){guachos-image-picker .place-image .image-holder{max-width:100%!important;max-height:250px!important}}guachos-image-picker .place-image .image-holder .image-upload-btn{transition:all .5s ease;position:relative;opacity:.85;width:50px;height:50px;color:#424242}guachos-image-picker .place-image .image-holder .image-upload-btn mat-icon{font-size:50px;width:50px;height:50px;line-height:50px;color:#424242}@media (max-width: 599px){guachos-image-picker .place-image .image-holder .image-upload-btn{opacity:1;width:30px;height:30px}guachos-image-picker .place-image .image-holder .image-upload-btn mat-icon{font-size:30px;width:30px;height:30px;line-height:30px}}guachos-image-picker .place-image .image-holder:hover .image-upload-btn{opacity:1;transition:all .5s ease}guachos-image-picker .place-image .image-holder-loaded{flex-direction:column;box-sizing:border-box;display:flex;place-content:center;align-items:center;position:relative;max-width:100%!important;width:320px;height:240px;border-radius:4px;padding:2px}guachos-image-picker .place-image .image-holder-loaded .image-caption{position:absolute;right:0;bottom:-22px}guachos-image-picker .place-image .image-holder-loaded img{height:100%;max-height:100%;width:100%;max-width:100%;object-fit:cover;object-position:center}@media (max-width: 599px){guachos-image-picker .place-image .image-holder-loaded{max-height:195px!important}}guachos-image-picker .place-image .image-holder-loaded .image-upload-btn{transition:all .5s ease;position:relative;opacity:.85;width:50px;height:50px;color:#424242}guachos-image-picker .place-image .image-holder-loaded .image-upload-btn mat-icon{font-size:50px;width:50px;height:50px;line-height:50px;color:#424242}@media (max-width: 599px){guachos-image-picker .place-image .image-holder-loaded .image-upload-btn{opacity:1;width:30px;height:30px}guachos-image-picker .place-image .image-holder-loaded .image-upload-btn mat-icon{font-size:30px;width:30px;height:30px;line-height:30px}}guachos-image-picker .place-image .image-holder-loaded:hover .image-upload-btn{opacity:1;transition:all .5s ease}guachos-image-picker .place-image .editing-bar-btn{margin-top:2px}guachos-image-picker .place-image .editing-bar-btn .mat-icon-button{height:20px;line-height:20px;width:24px}guachos-image-picker .place-image .editing-bar-btn mat-icon{line-height:20px!important;font-size:20px!important;width:20px!important;height:20px!important}guachos-image-picker .place-image .editing-bar-btn button{margin:4px;color:#424242;transition:all .5s ease}guachos-image-picker .place-image .editing-bar-btn button:hover{transform:scale(1.25);margin:4px 8px;transition:all .25s ease-in}guachos-image-picker .place-image .editing-bar-btn a{margin:4px;color:#424242;transition:all .5s ease}guachos-image-picker .place-image .editing-bar-btn a:hover{transform:scale(1.25);margin:4px 8px;transition:all .25s ease-in}guachos-image-picker .popup{width:100vw;max-height:100%;height:100%;overflow:auto;position:fixed;top:0;left:0;background-color:#000c;z-index:1000;padding:24px;color:#fff;box-sizing:border-box;animation-name:show;animation-duration:.4s}guachos-image-picker .popup .image-container{margin-top:50px;margin-bottom:50px;height:100%;min-height:100%;min-width:100%;width:100%;flex-flow:row wrap;box-sizing:border-box;display:flex;place-content:flex-start center;align-items:flex-start}guachos-image-picker .popup .image-container .image-holder-full{height:auto;width:auto;position:relative;display:contents}guachos-image-picker .popup img{max-height:600px;max-width:100%;object-fit:cover;object-position:center;margin:8px;transition:all .5s ease}@media (max-width: 1024px){guachos-image-picker .popup{background-color:#000000d9;padding:8px}guachos-image-picker .popup img{max-height:100%;max-width:100%}}@media (max-width: 599px){guachos-image-picker .popup img{margin:0}}guachos-image-picker .popup .control-panel{color:#fff;background-color:#000000eb;margin:8px;padding:16px;max-width:100%;width:18rem;border-radius:8px;flex-direction:column;box-sizing:border-box;display:flex;place-content:stretch flex-start;align-items:stretch}@media (max-width: 599px){guachos-image-picker .popup .control-panel{margin:8px 0;width:100%}}guachos-image-picker .popup .control-panel .title-panel{padding:0 4px;font-size:17px;font-weight:500;margin-bottom:16px!important}guachos-image-picker .popup .control-panel .item-panel{padding:0 4px;font-size:14px;font-weight:500}@keyframes show{0%{top:-100vh;opacity:0}to{top:0;opacity:1}}guachos-image-picker .mat-form-field-appearance-fill .mat-form-field-flex{background-color:#fafafa!important}guachos-image-picker .mat-select-panel{background:#fafafa!important}guachos-image-picker input.mat-input-element{color:#000000d9}guachos-image-picker .mat-checkbox-background{background-color:#fff}guachos-image-picker .image-cropper{position:absolute;width:150px;height:150px;border:2.5px solid #fafafa;box-sizing:border-box;resize:both;overflow:auto;opacity:0}guachos-image-picker .image-cropper #image-cropper-header{padding:10px;cursor:move;z-index:10;background-color:transparent;height:85%}guachos-image-picker .image-cropper #image-cropper-header mat-icon{color:#fff}guachos-image-picker .btn{padding:4px 8px;border-radius:4px;cursor:pointer}guachos-image-picker .btn mat-icon{color:#000000d1}\n"] }]
572
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { appearance: [{
573
+ type: Input
574
+ }], color: [{
575
+ type: Input
576
+ }], imagesAllowed: [{
577
+ type: Input
578
+ }], imagePicker: [{
579
+ type: ViewChild,
580
+ args: ['imagePicker', { static: false }]
581
+ }], $imageChanged: [{
582
+ type: Output
583
+ }], $imageOriginal: [{
584
+ type: Output
585
+ }], _imageSrc: [{
586
+ type: Input
587
+ }], _config: [{
588
+ type: Input
589
+ }] } });
590
+
591
+ class GuajiritosImagePickerModule {
592
+ }
593
+ GuajiritosImagePickerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GuajiritosImagePickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
594
+ GuajiritosImagePickerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.4", ngImport: i0, type: GuajiritosImagePickerModule, declarations: [GuajiritosImagePickerComponent, CalculateSizePipe], imports: [CommonModule,
595
+ MatIconModule,
596
+ MatLegacyButtonModule,
597
+ MatLegacyTooltipModule,
598
+ MatLegacySliderModule,
599
+ FormsModule,
600
+ ReactiveFormsModule,
601
+ MatLegacyFormFieldModule,
602
+ MatLegacySelectModule,
603
+ MatLegacyInputModule,
604
+ MatLegacyCheckboxModule], exports: [GuajiritosImagePickerComponent] });
605
+ GuajiritosImagePickerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GuajiritosImagePickerModule, imports: [CommonModule,
606
+ MatIconModule,
607
+ MatLegacyButtonModule,
608
+ MatLegacyTooltipModule,
609
+ MatLegacySliderModule,
610
+ FormsModule,
611
+ ReactiveFormsModule,
612
+ MatLegacyFormFieldModule,
613
+ MatLegacySelectModule,
614
+ MatLegacyInputModule,
615
+ MatLegacyCheckboxModule] });
616
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GuajiritosImagePickerModule, decorators: [{
617
+ type: NgModule,
618
+ args: [{
619
+ declarations: [GuajiritosImagePickerComponent, CalculateSizePipe],
620
+ imports: [
621
+ CommonModule,
622
+ MatIconModule,
623
+ MatLegacyButtonModule,
624
+ MatLegacyTooltipModule,
625
+ MatLegacySliderModule,
626
+ FormsModule,
627
+ ReactiveFormsModule,
628
+ MatLegacyFormFieldModule,
629
+ MatLegacySelectModule,
630
+ MatLegacyInputModule,
631
+ MatLegacyCheckboxModule,
632
+ ],
633
+ exports: [GuajiritosImagePickerComponent],
634
+ }]
635
+ }] });
636
+
637
+ /*
638
+ * Public API Surface of guachos-image-picker
639
+ */
640
+
641
+ /**
642
+ * Generated bundle index. Do not edit.
643
+ */
644
+
645
+ export { GuajiritosImagePickerComponent, GuajiritosImagePickerModule };
646
+ //# sourceMappingURL=guajiritos-image-picker.mjs.map