@guajiritos/image-picker 0.0.6 → 0.0.8

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,616 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Pipe, NgModule, signal, EventEmitter, Component, ChangeDetectionStrategy, Input, ViewChild, Output } from '@angular/core';
3
+ import { ResizeObserver } from 'resize-observer';
4
+ import { Subject } from 'rxjs';
5
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
6
+ import * as i3 from '@angular/material/icon';
7
+ import { MatIconModule } from '@angular/material/icon';
8
+ import * as i9 from '@angular/forms';
9
+ import { UntypedFormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
10
+ import * as i2 from '@angular/material/tooltip';
11
+ import { MatTooltipModule } from '@angular/material/tooltip';
12
+ import * as i5 from '@angular/material/checkbox';
13
+ import { MatCheckboxModule } from '@angular/material/checkbox';
14
+ import * as i6 from '@angular/material/slider';
15
+ import { MatSliderModule } from '@angular/material/slider';
16
+ import * as i4 from '@angular/material/button';
17
+ import { MatButtonModule } from '@angular/material/button';
18
+ import * as i7 from '@angular/material/form-field';
19
+ import { MatFormFieldModule } from '@angular/material/form-field';
20
+ import * as i8 from '@angular/material/input';
21
+ import { MatInputModule } from '@angular/material/input';
22
+ import * as i10 from '@angular/material/select';
23
+ import { MatSelectModule } from '@angular/material/select';
24
+ import * as i1 from '@angular/common';
25
+ import { CommonModule } from '@angular/common';
26
+ import * as i11 from '@angular/material/core';
27
+
28
+ class I18nPipe {
29
+ en = {
30
+ UPLOAD_A_IMAGE: 'Upload an image',
31
+ MUST_EDIT: 'You must edit the image in order to resize it',
32
+ TOO_LARGE: 'too large',
33
+ OPEN_EDITOR_PANEL: 'Open the editor panel',
34
+ DOWNLOAD: 'Download the image',
35
+ CONTROL_PANEL: 'Control Panel',
36
+ QUALITY: 'Quality',
37
+ SAVE: 'Save',
38
+ MAX_DIMENSIONS: 'Max dimensions',
39
+ ASPECT_RATIO: 'Aspect ratio',
40
+ MAX_WIDTH_PX: 'max-width(px)',
41
+ MAX_HEIGHT_PX: 'max-height(px)',
42
+ FORMAT: 'Format',
43
+ CROP: 'Crop',
44
+ WIDTH_PX: 'width(px)',
45
+ HEIGHT_PX: 'height(px)',
46
+ REMOVE: 'Remove',
47
+ SIZE: 'Size'
48
+ };
49
+ es = {
50
+ UPLOAD_A_IMAGE: 'Suba una imagen',
51
+ MUST_EDIT: 'Debe editar la imagen para disminuir su tamaño',
52
+ TOO_LARGE: 'muy grande',
53
+ OPEN_EDITOR_PANEL: 'Abra el panel de edición',
54
+ DOWNLOAD: 'Descargue la imagen',
55
+ CONTROL_PANEL: 'Panel de control',
56
+ REMOVE: 'Eliminar',
57
+ SAVE: 'Guardar',
58
+ QUALITY: 'Calidad',
59
+ MAX_DIMENSIONS: 'Dimensiones',
60
+ ASPECT_RATIO: 'Relación-Aspecto',
61
+ MAX_WIDTH_PX: 'max. ancho',
62
+ MAX_HEIGHT_PX: 'max. alto',
63
+ FORMAT: 'Formato',
64
+ CROP: 'Recortar',
65
+ WIDTH_PX: 'ancho(px)',
66
+ HEIGHT_PX: 'altura(px)',
67
+ SIZE: 'Tamaño'
68
+ };
69
+ transform(key, language) {
70
+ return language === 'en' ? this.en?.[key] : this.es?.[key];
71
+ }
72
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: I18nPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
73
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.4", ngImport: i0, type: I18nPipe, name: "i18n" });
74
+ }
75
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: I18nPipe, decorators: [{
76
+ type: Pipe,
77
+ args: [{
78
+ name: 'i18n'
79
+ }]
80
+ }] });
81
+
82
+ class CalculateSizePipe {
83
+ transform(imageLength) {
84
+ if (!imageLength) {
85
+ return 0;
86
+ }
87
+ if (imageLength) {
88
+ return Math.ceil(((3 / 4) * imageLength) / 1024);
89
+ }
90
+ else {
91
+ return 0;
92
+ }
93
+ }
94
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: CalculateSizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
95
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.4", ngImport: i0, type: CalculateSizePipe, name: "calculateSize" });
96
+ }
97
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: CalculateSizePipe, decorators: [{
98
+ type: Pipe,
99
+ args: [{
100
+ name: 'calculateSize'
101
+ }]
102
+ }] });
103
+
104
+ class PipesModule {
105
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: PipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
106
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.4", ngImport: i0, type: PipesModule, declarations: [I18nPipe, CalculateSizePipe], exports: [I18nPipe, CalculateSizePipe] });
107
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: PipesModule });
108
+ }
109
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: PipesModule, decorators: [{
110
+ type: NgModule,
111
+ args: [{
112
+ declarations: [I18nPipe, CalculateSizePipe],
113
+ exports: [I18nPipe, CalculateSizePipe],
114
+ }]
115
+ }] });
116
+
117
+ class GuajiritosImagePicker {
118
+ constructor() {
119
+ }
120
+ unsubscribeAll$ = new Subject();
121
+ observer = null;
122
+ originImageSrc;
123
+ fileType;
124
+ urlImage;
125
+ lastOriginSrc;
126
+ arrayCopiedImages = [];
127
+ uuidFilePicker = Date.now().toString(20);
128
+ allFormats = ['webp', 'jpeg', 'png'];
129
+ config = signal({
130
+ height: '240px',
131
+ width: '320px',
132
+ borderRadius: '16px',
133
+ compressInitial: true,
134
+ language: 'es',
135
+ hideDeleteBtn: false,
136
+ hideDownloadBtn: false,
137
+ hideEditBtn: false,
138
+ hideAddBtn: false,
139
+ });
140
+ imageSrc = signal(null);
141
+ showCrop = new UntypedFormControl({ value: false, disabled: false });
142
+ loadImage = signal(false);
143
+ noEdit = signal(false);
144
+ showEditPanel = signal(false);
145
+ maintainAspectRatio = new UntypedFormControl({ value: true, disabled: false });
146
+ quality = new UntypedFormControl({ value: 70, disabled: false });
147
+ format = new UntypedFormControl({ value: 'webp', disabled: false });
148
+ maxHeight = signal(2000);
149
+ maxWidth = signal(2000);
150
+ cropHeight = new UntypedFormControl({ value: 150, disabled: false });
151
+ cropWidth = new UntypedFormControl({ value: 150, disabled: false });
152
+ imageName = signal('download');
153
+ currentLanguage = signal('es');
154
+ appearance = 'outline';
155
+ color = 'primary';
156
+ imagesAllowed = 'image/*';
157
+ imagePicker;
158
+ $imageChanged = new EventEmitter();
159
+ $imageOriginal = new EventEmitter();
160
+ set _imageSrc(image) {
161
+ if (image) {
162
+ let types = image.split('.');
163
+ this.format.setValue(types[types.length - 1]);
164
+ if (!this.format.value || (this.format.value !== 'png' && this.format.value !== 'jpeg' && this.format.value !== 'webp')) {
165
+ this.format.setValue('jpeg');
166
+ }
167
+ this.imageSrc.set(image);
168
+ this.arrayCopiedImages = [];
169
+ this.arrayCopiedImages.push(this.imageSrc);
170
+ this.originImageSrc = image;
171
+ this.lastOriginSrc = image;
172
+ this.$imageOriginal.next(this.originImageSrc);
173
+ this.loadImage.set(true);
174
+ this.noEdit.set(true);
175
+ }
176
+ else {
177
+ this.imageSrc.set(null);
178
+ this.originImageSrc = null;
179
+ this.loadImage.set(false);
180
+ this.noEdit.set(false);
181
+ this.arrayCopiedImages = [];
182
+ this.lastOriginSrc = null;
183
+ this.$imageOriginal.next(null);
184
+ this.format.setValue('jpeg');
185
+ this.maxHeight.set(2000);
186
+ this.maxWidth.set(2000);
187
+ this.cropHeight.setValue(150);
188
+ this.cropWidth.setValue(150);
189
+ this.maintainAspectRatio.setValue(true);
190
+ this.showEditPanel.set(false);
191
+ }
192
+ }
193
+ set _config(value) {
194
+ if (value && value.constructor == Object) {
195
+ this.config.set({
196
+ ...this.config(),
197
+ ...value,
198
+ });
199
+ }
200
+ }
201
+ async handleReaderLoaded(readerEvt) {
202
+ const binaryString = readerEvt.target.result;
203
+ const base64textString = btoa(binaryString);
204
+ this.originImageSrc = this.urlImage + base64textString;
205
+ this.lastOriginSrc = this.urlImage + base64textString;
206
+ if (this.config()?.compressInitial) {
207
+ this.quality.setValue(70);
208
+ const input = {
209
+ dataType: this.format.value,
210
+ quality: 0.70,
211
+ maintainRatio: true,
212
+ };
213
+ this.imageSrc.set(await this.resizeDataURL(this.urlImage + base64textString, input));
214
+ }
215
+ else {
216
+ this.imageSrc.set(this.urlImage + base64textString);
217
+ this.arrayCopiedImages = [];
218
+ this.arrayCopiedImages.push({
219
+ lastImage: this.imageSrc(),
220
+ width: this.maxWidth(),
221
+ height: this.maxHeight(),
222
+ quality: this.quality.value,
223
+ });
224
+ this.$imageOriginal.next(this.imageSrc());
225
+ }
226
+ this.$imageChanged.next(this.imageSrc());
227
+ this.loadImage.set(true);
228
+ }
229
+ async resizeDataURL(datas, input) {
230
+ return await new Promise(async function (resolve) {
231
+ let img = document.createElement('img');
232
+ img.src = datas + '';
233
+ img.crossOrigin = 'Anonymous';
234
+ let quality = input?.quality ?? 1.0;
235
+ let maintainRatio = input.maintainRatio !== undefined ? input.maintainRatio : true;
236
+ img.onload = function () {
237
+ const canvas = document.createElement('canvas');
238
+ const ctx = canvas.getContext('2d');
239
+ let ratio = img.width / img.height;
240
+ let width = input?.width ?? img.width;
241
+ let height = input?.height ?? img.height;
242
+ if (maintainRatio) {
243
+ if (input.changeHeight) {
244
+ canvas.width = height * ratio;
245
+ canvas.height = height;
246
+ }
247
+ else {
248
+ canvas.width = width;
249
+ canvas.height = width / ratio;
250
+ }
251
+ }
252
+ else {
253
+ canvas.width = width;
254
+ canvas.height = height;
255
+ }
256
+ ctx?.drawImage(img, 0, 0, canvas.width, canvas.height);
257
+ let type = input?.dataType ?? 'webp';
258
+ const dataURI = canvas.toDataURL(`image/${type}`, quality);
259
+ resolve({
260
+ dataUri: dataURI,
261
+ width: canvas.width,
262
+ height: canvas.height,
263
+ });
264
+ };
265
+ }).then((data) => {
266
+ this.maxHeight = data?.height;
267
+ this.maxWidth = data?.width;
268
+ if (this.arrayCopiedImages?.length <= 20) {
269
+ this.arrayCopiedImages.push({
270
+ lastImage: data?.dataUri,
271
+ width: this.maxWidth,
272
+ height: this.maxHeight,
273
+ quality: this.quality.value,
274
+ });
275
+ }
276
+ return data.dataUri;
277
+ });
278
+ }
279
+ wait(ms) {
280
+ ms = ms ?? 1000;
281
+ return new Promise((resolve) => {
282
+ setTimeout(() => {
283
+ return resolve(true);
284
+ }, ms);
285
+ });
286
+ }
287
+ dragElement(element) {
288
+ let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
289
+ let el = document.getElementById(element.id + '-header');
290
+ if (el) {
291
+ el.onmousedown = dragMouseDown;
292
+ el.ontouchstart = dragMouseDown;
293
+ }
294
+ else {
295
+ element.onmousedown = dragMouseDown;
296
+ element.ontouchstart = dragMouseDown;
297
+ }
298
+ function dragMouseDown(e) {
299
+ e = e || window.event;
300
+ e?.preventDefault();
301
+ pos3 = e?.clientX;
302
+ pos4 = e?.clientY;
303
+ document.onmouseup = closeDragElement;
304
+ document.ontouchend = closeDragElement;
305
+ document.onmousemove = elementDrag;
306
+ document.ontouchmove = elementDrag;
307
+ }
308
+ function elementDrag(e) {
309
+ let holderImage = document.getElementById('image-full');
310
+ e = e || window.event;
311
+ e?.preventDefault();
312
+ pos1 = pos3 - e?.clientX;
313
+ pos2 = pos4 - e?.clientY;
314
+ pos3 = e?.clientX;
315
+ pos4 = e?.clientY;
316
+ const newTop = element.offsetTop - pos2;
317
+ const newLeft = element.offsetLeft - pos1;
318
+ const rectHolder = holderImage.getBoundingClientRect();
319
+ const rectElement = element.getBoundingClientRect();
320
+ if (newTop >= rectHolder.y + 8) {
321
+ element.style.top = Math.min(newTop, rectHolder.y + rectHolder.height - rectElement.height - 4) + 'px';
322
+ }
323
+ if (newLeft > rectHolder.x + 4 && rectHolder.x + rectHolder.width > rectElement.x + rectElement.width + 2) {
324
+ element.style.left = Math.min(newLeft, rectHolder.x + rectHolder.width - rectElement.width - 4) + 'px';
325
+ }
326
+ }
327
+ function closeDragElement() {
328
+ document.onmouseup = null;
329
+ document.onmousemove = null;
330
+ document.ontouchend = null;
331
+ document.ontouchmove = null;
332
+ }
333
+ }
334
+ onUpload(event) {
335
+ event.preventDefault();
336
+ this.imagePicker?.nativeElement.click();
337
+ }
338
+ handleFileSelect(evt) {
339
+ const files = evt?.target?.files;
340
+ if (files) {
341
+ const file = files[0];
342
+ this.imageName.set(file?.name?.split('.')[0]);
343
+ this.fileType = file?.type;
344
+ this.urlImage = `data:${file?.type};base64,`;
345
+ this.noEdit.set(false);
346
+ if (files && file) {
347
+ const reader = new FileReader();
348
+ reader.onload = this.handleReaderLoaded.bind(this);
349
+ reader.readAsBinaryString(file);
350
+ }
351
+ }
352
+ }
353
+ onCloseEditPanel() {
354
+ if (this.observer instanceof ResizeObserver) {
355
+ let imageCropper = document.getElementById('image-cropper');
356
+ let imageFull = document.getElementById('image-full');
357
+ this.observer.unobserve(imageCropper);
358
+ this.observer.unobserve(imageFull);
359
+ }
360
+ this.showCrop.setValue(false);
361
+ this.showEditPanel.set(false);
362
+ }
363
+ async onChangeQuality() {
364
+ const qualityItem = this.quality.value / 100;
365
+ this.maxHeight.set(this.maxHeight() ?? 2000);
366
+ this.maxWidth.set(this.maxWidth() ?? 2000);
367
+ await this.wait(250);
368
+ try {
369
+ const input = {
370
+ height: this.maxHeight(),
371
+ width: this.maxWidth(),
372
+ dataType: this.format.value,
373
+ quality: qualityItem,
374
+ maintainRatio: this.maintainAspectRatio.value,
375
+ };
376
+ this.imageSrc.set(await this.resizeDataURL(this.originImageSrc, input));
377
+ this.$imageChanged.next(this.imageSrc());
378
+ this.loadImage.set(true);
379
+ }
380
+ catch (error) {
381
+ this.loadImage.set(true);
382
+ }
383
+ }
384
+ async onChangeFormat() {
385
+ let qualityItem = this.quality.value / 100;
386
+ this.maxHeight.set(this.maxHeight() ?? 2000);
387
+ this.maxWidth.set(this.maxWidth() ?? 2000);
388
+ await this.wait(250);
389
+ try {
390
+ let input = {
391
+ height: this.maxHeight(),
392
+ width: this.maxWidth(),
393
+ dataType: this.format.value,
394
+ quality: qualityItem,
395
+ maintainRatio: this.maintainAspectRatio.value,
396
+ };
397
+ this.imageSrc.set(await this.resizeDataURL(this.originImageSrc, input));
398
+ this.$imageChanged.next(this.imageSrc());
399
+ this.loadImage.set(true);
400
+ }
401
+ catch (error) {
402
+ this.loadImage.set(true);
403
+ }
404
+ }
405
+ async onChangeSize(changeWidth, changeHeight) {
406
+ let qualityItem = this.quality.value / 100;
407
+ this.maxHeight.set(this.maxHeight() ?? 2000);
408
+ this.maxWidth.set(this.maxWidth() ?? 2000);
409
+ await this.wait(500);
410
+ try {
411
+ let input = {
412
+ height: this.maxHeight(),
413
+ width: this.maxWidth(),
414
+ dataType: this.format.value,
415
+ quality: qualityItem,
416
+ maintainRatio: this.maintainAspectRatio.value,
417
+ changeHeight: changeHeight,
418
+ changeWidth: changeWidth,
419
+ };
420
+ this.imageSrc.set(await this.resizeDataURL(this.originImageSrc, input));
421
+ this.$imageChanged.next(this.imageSrc());
422
+ this.loadImage.set(true);
423
+ }
424
+ catch (error) {
425
+ this.loadImage.set(true);
426
+ }
427
+ }
428
+ onChangeCrop() {
429
+ const cropper = document.getElementById('image-cropper');
430
+ cropper.style.width = this.cropWidth.value + 'px';
431
+ cropper.style.height = this.cropHeight.value + 'px';
432
+ }
433
+ onCropStateChange() {
434
+ const cropper = document.getElementById('image-cropper');
435
+ const fullImage = document.getElementById('image-full');
436
+ const aspectRatio = fullImage.offsetWidth / fullImage.offsetHeight;
437
+ if (this.showCrop.value) {
438
+ cropper.style.opacity = '1.0';
439
+ this.dragElement(cropper);
440
+ this.observer = new ResizeObserver((entries) => {
441
+ entries.forEach((entry) => {
442
+ if (this.showEditPanel()) {
443
+ const elementCropper = document.getElementById('image-cropper');
444
+ const elementFull = document.getElementById('image-full');
445
+ const rectHolder = elementFull.getBoundingClientRect();
446
+ const rectElement = elementCropper.getBoundingClientRect();
447
+ const maxWidth = rectHolder.x + rectHolder.width - rectElement.x - 4;
448
+ const maxHeight = rectHolder.y + rectHolder.height - rectElement.y - 4;
449
+ // Obtener el tamaño del área de recorte seleccionada por el usuario
450
+ const cropWidth = elementCropper.offsetWidth;
451
+ const cropHeight = elementCropper.offsetHeight;
452
+ // Calcular el ancho y el alto del área de recorte manteniendo la relación de aspecto de la imagen original
453
+ let newWidth = cropWidth;
454
+ let newHeight = cropHeight;
455
+ if (this.maintainAspectRatio.value) {
456
+ if (cropWidth / cropHeight > aspectRatio) {
457
+ newHeight = cropWidth / aspectRatio;
458
+ }
459
+ else {
460
+ newWidth = cropHeight * aspectRatio;
461
+ }
462
+ }
463
+ // Ajustar el ancho y el alto del área de recorte si supera los límites
464
+ newWidth = Math.min(newWidth, maxWidth);
465
+ newHeight = Math.min(newHeight, maxHeight);
466
+ // Establecer el tamaño y la posición del área de recorte
467
+ elementCropper.style.width = `${newWidth}px`;
468
+ elementCropper.style.height = `${newHeight}px`;
469
+ this.cropWidth.setValue(rectElement.width);
470
+ this.cropHeight.setValue(rectElement.height);
471
+ if (entry.target.id == 'image-full') {
472
+ if (rectHolder.top > 0) {
473
+ elementCropper.style.top = rectHolder.top + 4 + 'px';
474
+ }
475
+ elementCropper.style.left = rectHolder.left + 4 + 'px';
476
+ }
477
+ }
478
+ });
479
+ });
480
+ this.observer.observe(document.getElementById('image-cropper'));
481
+ this.observer.observe(document.getElementById('image-full'));
482
+ }
483
+ else {
484
+ cropper.style.opacity = '0.0';
485
+ if (this.observer instanceof ResizeObserver) {
486
+ const elementCropper = document.getElementById('image-cropper');
487
+ const elementFull = document.getElementById('image-full');
488
+ this.observer.unobserve(elementCropper);
489
+ this.observer.unobserve(elementFull);
490
+ }
491
+ }
492
+ }
493
+ onCrop(type) {
494
+ type = type ?? this.format.value;
495
+ const cropper = document.getElementById('image-cropper');
496
+ const elementFull = document.getElementById('image-full');
497
+ const rectCropper = cropper.getBoundingClientRect();
498
+ const dataHolderRect = elementFull.getBoundingClientRect();
499
+ const canvas = document.createElement('canvas');
500
+ new Promise((resolve, reject) => {
501
+ let ctx = canvas.getContext('2d');
502
+ let image = new Image();
503
+ image.src = this.imageSrc();
504
+ image.onload = () => {
505
+ let ratio = image.height / dataHolderRect.height;
506
+ let newWidth = rectCropper.width * ratio;
507
+ let newHeight = rectCropper.height * ratio;
508
+ canvas.width = newWidth;
509
+ canvas.height = newHeight;
510
+ 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);
511
+ resolve(canvas.toDataURL(`image/${type}`, this.quality.value));
512
+ };
513
+ image.onerror = (e) => {
514
+ reject(e);
515
+ };
516
+ })
517
+ .then((dataUri) => {
518
+ this.imageSrc.set(dataUri);
519
+ this.showCrop.setValue(false);
520
+ this.onCropStateChange();
521
+ this.maxWidth.set(canvas?.width);
522
+ this.maxHeight.set(canvas?.height);
523
+ this.lastOriginSrc = this.originImageSrc + '';
524
+ this.originImageSrc = dataUri;
525
+ this.$imageChanged.next(this.imageSrc());
526
+ })
527
+ .catch((e) => {
528
+ console.log(e);
529
+ });
530
+ }
531
+ onRestore() {
532
+ if (this.arrayCopiedImages.length) {
533
+ let lastState = this.arrayCopiedImages.pop();
534
+ this.imageSrc.set(lastState.lastImage);
535
+ this.maxWidth.set(lastState.width);
536
+ this.maxHeight.set(lastState.height);
537
+ this.originImageSrc = this.lastOriginSrc + '';
538
+ this.noEdit.set(false);
539
+ }
540
+ else {
541
+ this.imageSrc.set(this.lastOriginSrc);
542
+ this.originImageSrc = this.lastOriginSrc + '';
543
+ this.noEdit.set(false);
544
+ }
545
+ this.$imageChanged.next(this.imageSrc());
546
+ }
547
+ onRemove() {
548
+ this.imageSrc.set(null);
549
+ this.originImageSrc = null;
550
+ this.loadImage.set(false);
551
+ this.arrayCopiedImages = [];
552
+ this.lastOriginSrc = null;
553
+ this.$imageOriginal.next(null);
554
+ this.$imageChanged.next(null);
555
+ this.format.setValue('jpeg');
556
+ this.maxHeight.set(2000);
557
+ this.maxWidth.set(2000);
558
+ this.cropHeight.setValue(150);
559
+ this.cropWidth.setValue(150);
560
+ this.maintainAspectRatio.setValue(true);
561
+ this.showEditPanel.set(false);
562
+ this.noEdit.set(false);
563
+ }
564
+ ngOnDestroy() {
565
+ this.unsubscribeAll$.next();
566
+ this.unsubscribeAll$.complete();
567
+ }
568
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: GuajiritosImagePicker, deps: [], target: i0.ɵɵFactoryTarget.Component });
569
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.4", type: GuajiritosImagePicker, isStandalone: true, 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'>\n <div class='image-holder'\n [ngStyle]='{ width: config()?.width,height: config()?.height,borderRadius: config()?.borderRadius}'>\n <button [matTooltip]=\"'UPLOAD_A_IMAGE' | i18n: config()?.language\" class='image-upload-btn' mat-icon-button\n (click)='onUpload($event)'>\n <mat-icon class='mat-18'>add_a_photo</mat-icon>\n </button>\n <input #imagePicker type='file' class='d-none' [id]=\"'filePicker-' + uuidFilePicker\"\n (change)='handleFileSelect($event)' [accept]='imagesAllowed'>\n </div>\n</div>\n\n<div *ngIf='loadImage()' class='place-image'>\n <div class='image-holder-loaded'\n [ngStyle]='{width: config()?.width,height: config()?.height,borderRadius: config()?.borderRadius}'>\n <img [src]='imageSrc()' alt='image-loaded' [ngStyle]='{ borderRadius: config()?.borderRadius }'>\n <input #imagePicker type='file' class='d-none' [id]=\"'filePicker-' + uuidFilePicker\"\n (change)='handleFileSelect($event)' [accept]='imagesAllowed'>\n </div>\n <p *ngIf='imageSrc()?.length' class='mat-caption image-caption' [class.warn]='(imageSrc()?.length | calculateSize) > 200'\n [class.fw-600]='(imageSrc()?.length | calculateSize) > 200'>\n {{\"SIZE\" | i18n: currentLanguage()}}: {{ (imageSrc()?.length | calculateSize) }}Kb &nbsp; {{ format.value }}\n </p>\n\n <div class='editing-bar-btn'>\n <button id='upload-img' *ngIf='!config()?.hideAddBtn' mat-icon-button (click)='onUpload($event)'\n [matTooltip]=\"'UPLOAD_A_IMAGE' | i18n: config()?.language\">\n <mat-icon class='mat-18'>add_a_photo</mat-icon>\n </button>\n <button id='edit-img' *ngIf='!config()?.hideEditBtn && !noEdit()' mat-icon-button (click)='showEditPanel.set(true)'\n [matTooltip]=\"'OPEN_EDITOR_PANEL' | i18n: config()?.language\">\n <mat-icon class='mat-18'>edit</mat-icon>\n </button>\n <a id='download-img' *ngIf='!config()?.hideDownloadBtn' [matTooltip]=\"'DOWNLOAD' | i18n: config()?.language\"\n [href]='imageSrc()' mat-icon-button [download]='imageName'>\n <mat-icon class='mat-18'>cloud_download</mat-icon>\n </a>\n <button id='delete-img' *ngIf='!config()?.hideDeleteBtn' mat-icon-button (click)='onRemove()'\n [matTooltip]=\"'REMOVE' | i18n: config()?.language\">\n <mat-icon class='mat-18'>delete</mat-icon>\n </button>\n </div>\n</div>\n\n<div *ngIf='showEditPanel()' id='popup' class='popup'>\n <div class='popup-clear'>\n <button mat-icon-button (click)='onCloseEditPanel()'>\n <mat-icon class='mat-18'>clear</mat-icon>\n </button>\n </div>\n\n <div class='image-container'>\n <div class='image-holder-full'>\n <img id='image-full' [src]='imageSrc()' alt=''>\n <div id='image-cropper' class='image-cropper'>\n <div id='image-cropper-header'>\n <mat-icon>drag_indicator</mat-icon>\n </div>\n </div>\n </div>\n\n <div class='control-panel'>\n <p class='item-panel fw-600'>{{ 'QUALITY' | i18n: config()?.language }}</p>\n <div class='quality-container'>\n <mat-slider ngDefaultControl [color]='color' class='w-100 mw-100' (change)='onChangeQuality()'\n [max]='100' [min]='0' [step]='1' [discrete]='true' [showTickMarks]='true'>\n <input matSliderThumb [formControl]='quality'>\n </mat-slider>\n </div>\n\n <div class='item-panel'>\n <span class='fw-600'>{{ 'MAX_DIMENSIONS' | i18n: config()?.language }}</span>\n <mat-checkbox class='float-right' [formControl]='maintainAspectRatio' [color]='color'>\n <span>{{ 'ASPECT_RATIO' | i18n: config()?.language }}</span>\n </mat-checkbox>\n </div>\n\n <div class='max-dimension-container'>\n <mat-form-field class='w-48' [appearance]='appearance' [color]='color'>\n <mat-label>{{ 'MAX_WIDTH_PX' | i18n: config()?.language }}</mat-label>\n <input (change)='onChangeSize(true, false)' matInput [placeholder]=\"'MAX_WIDTH_PX' | i18n: config()?.language\"\n [(ngModel)]='maxWidth' type='number' [min]='0' [max]='2000'>\n </mat-form-field>\n\n <mat-form-field class='w-48' [appearance]='appearance' [color]='color'>\n <mat-label>{{ 'MAX_HEIGHT_PX' | i18n: config()?.language }}</mat-label>\n <input (change)='onChangeSize(false, true)' matInput [placeholder]=\"'MAX_HEIGHT_PX' | i18n: config()?.language\"\n [(ngModel)]='maxHeight' type='number' [min]='0' [max]='2000'>\n </mat-form-field>\n </div>\n\n <p class='item-panel fw-600'>{{ 'FORMAT' | i18n: config()?.language }}</p>\n <div class='formats-selection'>\n <mat-form-field class='w-100 mw-100' [appearance]='appearance' [color]='color'>\n <mat-select [formControl]='format' (selectionChange)='onChangeFormat()'>\n <mat-option *ngFor='let format of allFormats' [value]='format'>\n {{ format }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n\n <div class='refresh-container'>\n <mat-checkbox (change)='onCropStateChange()' [formControl]='showCrop' [color]='color'>\n <p class='item-panel fw-600'>{{ 'CROP' | i18n: config()?.language }}</p>\n </mat-checkbox>\n <div class='d-flex '>\n <button class='float-right' mat-icon-button [color]='color' (click)='onRestore()'>\n <mat-icon>refresh</mat-icon>\n </button>\n <p *ngIf='showCrop.value'>\n <button mat-icon-button [color]='color' (click)='onCrop()'>\n <mat-icon>crop</mat-icon>\n </button>\n </p>\n </div>\n </div>\n\n <ng-container *ngIf='showCrop.value'>\n <div class='dimension-container'>\n <mat-form-field class='w-48 mw-48' [appearance]='appearance' [color]='color'>\n <mat-label>{{ 'WIDTH_PX' | i18n: config()?.language }}</mat-label>\n <input (change)='onChangeCrop()' matInput [placeholder]=\"'WIDTH_PX' | i18n: config()?.language\"\n [formControl]='cropWidth' type='number' [min]='0' [max]='2000'>\n </mat-form-field>\n <mat-form-field class='w-48 mw-48' [appearance]='appearance' [color]='color'>\n <mat-label>{{ 'HEIGHT_PX' | i18n: config()?.language }}</mat-label>\n <input (change)='onChangeCrop()' matInput [placeholder]=\"'HEIGHT_PX' | i18n: config()?.language\"\n [formControl]='cropHeight' type='number' [min]='0' [max]='2000'>\n </mat-form-field>\n </div>\n </ng-container>\n\n <div class='save-container'>\n <button mat-flat-button (click)='onCloseEditPanel()' [color]='color' class='save-button'>\n {{ 'SAVE' | i18n: config()?.language}}\n </button>\n\n <p *ngIf='imageSrc()?.length' class='mat-caption image-caption'\n [class.warn]='(imageSrc()?.length | calculateSize) > 200'\n [class.fw-600]='(imageSrc()?.length | calculateSize) > 200'>\n {{\"SIZE\" | i18n: currentLanguage()}}: {{ (imageSrc()?.length | calculateSize) }}Kb &nbsp; {{ format.value }}\n </p>\n </div>\n </div>\n </div>\n</div>\n", styles: [".d-none{display:none}.d-flex{display:flex}.fw-600{font-weight:600}.w-100{width:100%}.mw-100{max-width:100%}.w-48{width:48%}.mw-48{max-width:48%}.float-right{float:right}p{margin:0!important;padding:0!important}.place-image{flex-direction:column;box-sizing:border-box;display:flex;place-content:flex-start;align-items:center}.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;background-color:#fff}@media (max-width: 599px){.place-image .image-holder{max-width:100%!important;max-height:250px!important}}.place-image .image-holder .image-upload-btn{transition:all .5s ease;position:relative;opacity:.85;width:50px;height:50px;box-sizing:content-box}.place-image .image-holder .image-upload-btn mat-icon{font-size:50px;width:50px;height:50px;line-height:50px}@media (max-width: 599px){.place-image .image-holder .image-upload-btn{opacity:1;width:30px;height:30px}.place-image .image-holder .image-upload-btn mat-icon{font-size:30px;width:30px;height:30px;line-height:30px}}.place-image .image-holder:hover .image-upload-btn{opacity:1;transition:all .5s ease}.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}.place-image .image-holder-loaded .image-caption{position:absolute;right:0;bottom:-22px}.place-image .image-holder-loaded img{height:100%;max-height:100%;width:100%;max-width:100%;object-fit:contain;object-position:center}@media (max-width: 599px){.place-image .image-holder-loaded{max-height:195px!important}}.place-image .image-holder-loaded .image-upload-btn{transition:all .5s ease;position:relative;opacity:.85;width:50px;height:50px;box-sizing:content-box}.place-image .image-holder-loaded .image-upload-btn mat-icon{font-size:50px;width:50px;height:50px;line-height:50px}@media (max-width: 599px){.place-image .image-holder-loaded .image-upload-btn{opacity:1;width:30px;height:30px}.place-image .image-holder-loaded .image-upload-btn mat-icon{font-size:30px;width:30px;height:30px;line-height:30px}}.place-image .image-holder-loaded:hover .image-upload-btn{opacity:1;transition:all .5s ease}.place-image .editing-bar-btn{margin-top:2px;display:flex;flex-direction:row;box-sizing:border-box;place-content:flex-start;align-items:flex-start}.place-image .editing-bar-btn .mat-icon-button{height:20px;line-height:20px;width:24px}.place-image .editing-bar-btn mat-icon{line-height:20px!important;font-size:20px!important;width:20px!important;height:20px!important}.place-image .editing-bar-btn button{margin:4px;transition:all .5s ease}.place-image .editing-bar-btn button:hover{transform:scale(1.25);margin:4px 8px;transition:all .25s ease-in}.place-image .editing-bar-btn a{margin:4px;transition:all .5s ease}.place-image .editing-bar-btn a:hover{transform:scale(1.25);margin:4px 8px;transition:all .25s ease-in}.popup{width:100vw;max-height:100%;height:100%;overflow:auto;position:fixed;top:0;left:0;z-index:1000;padding:24px;color:#fff;box-sizing:border-box;animation-name:show;animation-duration:.4s}.popup .popup-clear{flex-direction:row;box-sizing:border-box;display:flex;place-content:center flex-end;align-items:center}.popup .image-container{margin-top:50px;margin-bottom:50px;height:calc(100vh - 188px);min-height:calc(100vh - 188px);min-width:100%;width:100%;flex-flow:row wrap;box-sizing:border-box;display:flex;place-content:flex-start center;align-items:flex-start}.popup .image-container .image-holder-full{height:auto;width:auto;position:relative;display:contents}.popup img{max-height:600px;max-width:100%;object-fit:contain;object-position:center;margin:8px;transition:all .5s ease}@media (max-width: 1024px){.popup{background-color:#000000d9;padding:8px}.popup img{max-height:100%;max-width:100%}}@media (max-width: 599px){.popup img{margin:0}}.popup .control-panel{color:#000;background-color:#fff;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){.popup .control-panel{margin:8px 0;width:100%}}.popup .control-panel .title-panel{padding:0 4px;font-size:16px;margin-bottom:16px!important}.popup .control-panel .item-panel{padding:0 4px!important;font-size:12px;display:flex;justify-content:space-between;align-items:center;gap:4px}.popup .control-panel .formats-selection{margin-top:8px!important;flex-direction:row;box-sizing:border-box;display:flex;place-content:flex-start;align-items:flex-start}.popup .control-panel .max-dimension-container{margin-top:16px!important;flex-flow:row;box-sizing:border-box;display:flex;place-content:flex-start space-between;align-items:flex-start}.popup .control-panel .dimension-container{margin-top:8px!important;flex-flow:row wrap;box-sizing:border-box;display:flex;place-content:flex-start space-between;align-items:flex-start}.popup .control-panel .save-container{flex-direction:row;box-sizing:border-box;display:flex;place-content:center space-between;align-items:center}.popup .control-panel .save-container .save-button{padding:0 8px;height:34px;box-sizing:border-box;font-weight:600}.popup .control-panel .quality-container{flex-direction:row;box-sizing:border-box;display:flex;place-content:flex-start;align-items:flex-start}.popup .control-panel .refresh-container{display:flex;justify-content:space-between;align-items:center}.popup .control-panel .refresh-container div{display:flex;align-items:center}@keyframes show{0%{top:-100vh;opacity:0}to{top:0;opacity:1}}.mat-form-field-appearance-fill .mat-form-field-flex{background-color:#fff!important}.mat-select-panel{background:white!important}input.mat-input-element{color:#000000d9}.mat-checkbox-background{background-color:#fff}.image-cropper{position:absolute;width:150px;height:150px;border:2.5px solid white;box-sizing:border-box;resize:both;overflow:auto;opacity:0}.image-cropper #image-cropper-header{padding:10px;cursor:move;z-index:10;background-color:transparent;height:85%}.image-cropper #image-cropper-header mat-icon{color:#fff}.btn{padding:4px 8px;border-radius:4px;cursor:pointer}.btn mat-icon{color:#000000d1}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { 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: "ngmodule", type: BrowserAnimationsModule }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i2.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i4.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i4.MatIconAnchor, selector: "a[mat-icon-button]", inputs: ["disabled", "disableRipple", "color", "tabIndex"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i4.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i5.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatSliderModule }, { kind: "component", type: i6.MatSlider, selector: "mat-slider", inputs: ["color", "disableRipple", "disabled", "discrete", "showTickMarks", "min", "max", "step", "displayWith"], exportAs: ["matSlider"] }, { kind: "directive", type: i6.MatSliderThumb, selector: "input[matSliderThumb]", inputs: ["value"], outputs: ["valueChange", "dragStart", "dragEnd"], exportAs: ["matSliderThumb"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i7.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i7.MatLabel, selector: "mat-label" }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i9.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: i9.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i9.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i9.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i9.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { kind: "directive", type: i9.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i10.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex", "panelWidth", "hideSingleSelectionIndicator"], exportAs: ["matSelect"] }, { kind: "component", type: i11.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i9.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: PipesModule }, { kind: "pipe", type: I18nPipe, name: "i18n" }, { kind: "pipe", type: CalculateSizePipe, name: "calculateSize" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
570
+ }
571
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: GuajiritosImagePicker, decorators: [{
572
+ type: Component,
573
+ args: [{ selector: 'guajiritos-image-picker', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [
574
+ CommonModule,
575
+ BrowserAnimationsModule,
576
+ MatTooltipModule,
577
+ MatIconModule,
578
+ MatButtonModule,
579
+ MatCheckboxModule,
580
+ MatSliderModule,
581
+ MatFormFieldModule,
582
+ MatInputModule,
583
+ FormsModule,
584
+ MatSelectModule,
585
+ ReactiveFormsModule,
586
+ PipesModule
587
+ ], template: "<div *ngIf='!loadImage()' class='place-image'>\n <div class='image-holder'\n [ngStyle]='{ width: config()?.width,height: config()?.height,borderRadius: config()?.borderRadius}'>\n <button [matTooltip]=\"'UPLOAD_A_IMAGE' | i18n: config()?.language\" class='image-upload-btn' mat-icon-button\n (click)='onUpload($event)'>\n <mat-icon class='mat-18'>add_a_photo</mat-icon>\n </button>\n <input #imagePicker type='file' class='d-none' [id]=\"'filePicker-' + uuidFilePicker\"\n (change)='handleFileSelect($event)' [accept]='imagesAllowed'>\n </div>\n</div>\n\n<div *ngIf='loadImage()' class='place-image'>\n <div class='image-holder-loaded'\n [ngStyle]='{width: config()?.width,height: config()?.height,borderRadius: config()?.borderRadius}'>\n <img [src]='imageSrc()' alt='image-loaded' [ngStyle]='{ borderRadius: config()?.borderRadius }'>\n <input #imagePicker type='file' class='d-none' [id]=\"'filePicker-' + uuidFilePicker\"\n (change)='handleFileSelect($event)' [accept]='imagesAllowed'>\n </div>\n <p *ngIf='imageSrc()?.length' class='mat-caption image-caption' [class.warn]='(imageSrc()?.length | calculateSize) > 200'\n [class.fw-600]='(imageSrc()?.length | calculateSize) > 200'>\n {{\"SIZE\" | i18n: currentLanguage()}}: {{ (imageSrc()?.length | calculateSize) }}Kb &nbsp; {{ format.value }}\n </p>\n\n <div class='editing-bar-btn'>\n <button id='upload-img' *ngIf='!config()?.hideAddBtn' mat-icon-button (click)='onUpload($event)'\n [matTooltip]=\"'UPLOAD_A_IMAGE' | i18n: config()?.language\">\n <mat-icon class='mat-18'>add_a_photo</mat-icon>\n </button>\n <button id='edit-img' *ngIf='!config()?.hideEditBtn && !noEdit()' mat-icon-button (click)='showEditPanel.set(true)'\n [matTooltip]=\"'OPEN_EDITOR_PANEL' | i18n: config()?.language\">\n <mat-icon class='mat-18'>edit</mat-icon>\n </button>\n <a id='download-img' *ngIf='!config()?.hideDownloadBtn' [matTooltip]=\"'DOWNLOAD' | i18n: config()?.language\"\n [href]='imageSrc()' mat-icon-button [download]='imageName'>\n <mat-icon class='mat-18'>cloud_download</mat-icon>\n </a>\n <button id='delete-img' *ngIf='!config()?.hideDeleteBtn' mat-icon-button (click)='onRemove()'\n [matTooltip]=\"'REMOVE' | i18n: config()?.language\">\n <mat-icon class='mat-18'>delete</mat-icon>\n </button>\n </div>\n</div>\n\n<div *ngIf='showEditPanel()' id='popup' class='popup'>\n <div class='popup-clear'>\n <button mat-icon-button (click)='onCloseEditPanel()'>\n <mat-icon class='mat-18'>clear</mat-icon>\n </button>\n </div>\n\n <div class='image-container'>\n <div class='image-holder-full'>\n <img id='image-full' [src]='imageSrc()' alt=''>\n <div id='image-cropper' class='image-cropper'>\n <div id='image-cropper-header'>\n <mat-icon>drag_indicator</mat-icon>\n </div>\n </div>\n </div>\n\n <div class='control-panel'>\n <p class='item-panel fw-600'>{{ 'QUALITY' | i18n: config()?.language }}</p>\n <div class='quality-container'>\n <mat-slider ngDefaultControl [color]='color' class='w-100 mw-100' (change)='onChangeQuality()'\n [max]='100' [min]='0' [step]='1' [discrete]='true' [showTickMarks]='true'>\n <input matSliderThumb [formControl]='quality'>\n </mat-slider>\n </div>\n\n <div class='item-panel'>\n <span class='fw-600'>{{ 'MAX_DIMENSIONS' | i18n: config()?.language }}</span>\n <mat-checkbox class='float-right' [formControl]='maintainAspectRatio' [color]='color'>\n <span>{{ 'ASPECT_RATIO' | i18n: config()?.language }}</span>\n </mat-checkbox>\n </div>\n\n <div class='max-dimension-container'>\n <mat-form-field class='w-48' [appearance]='appearance' [color]='color'>\n <mat-label>{{ 'MAX_WIDTH_PX' | i18n: config()?.language }}</mat-label>\n <input (change)='onChangeSize(true, false)' matInput [placeholder]=\"'MAX_WIDTH_PX' | i18n: config()?.language\"\n [(ngModel)]='maxWidth' type='number' [min]='0' [max]='2000'>\n </mat-form-field>\n\n <mat-form-field class='w-48' [appearance]='appearance' [color]='color'>\n <mat-label>{{ 'MAX_HEIGHT_PX' | i18n: config()?.language }}</mat-label>\n <input (change)='onChangeSize(false, true)' matInput [placeholder]=\"'MAX_HEIGHT_PX' | i18n: config()?.language\"\n [(ngModel)]='maxHeight' type='number' [min]='0' [max]='2000'>\n </mat-form-field>\n </div>\n\n <p class='item-panel fw-600'>{{ 'FORMAT' | i18n: config()?.language }}</p>\n <div class='formats-selection'>\n <mat-form-field class='w-100 mw-100' [appearance]='appearance' [color]='color'>\n <mat-select [formControl]='format' (selectionChange)='onChangeFormat()'>\n <mat-option *ngFor='let format of allFormats' [value]='format'>\n {{ format }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n </div>\n\n <div class='refresh-container'>\n <mat-checkbox (change)='onCropStateChange()' [formControl]='showCrop' [color]='color'>\n <p class='item-panel fw-600'>{{ 'CROP' | i18n: config()?.language }}</p>\n </mat-checkbox>\n <div class='d-flex '>\n <button class='float-right' mat-icon-button [color]='color' (click)='onRestore()'>\n <mat-icon>refresh</mat-icon>\n </button>\n <p *ngIf='showCrop.value'>\n <button mat-icon-button [color]='color' (click)='onCrop()'>\n <mat-icon>crop</mat-icon>\n </button>\n </p>\n </div>\n </div>\n\n <ng-container *ngIf='showCrop.value'>\n <div class='dimension-container'>\n <mat-form-field class='w-48 mw-48' [appearance]='appearance' [color]='color'>\n <mat-label>{{ 'WIDTH_PX' | i18n: config()?.language }}</mat-label>\n <input (change)='onChangeCrop()' matInput [placeholder]=\"'WIDTH_PX' | i18n: config()?.language\"\n [formControl]='cropWidth' type='number' [min]='0' [max]='2000'>\n </mat-form-field>\n <mat-form-field class='w-48 mw-48' [appearance]='appearance' [color]='color'>\n <mat-label>{{ 'HEIGHT_PX' | i18n: config()?.language }}</mat-label>\n <input (change)='onChangeCrop()' matInput [placeholder]=\"'HEIGHT_PX' | i18n: config()?.language\"\n [formControl]='cropHeight' type='number' [min]='0' [max]='2000'>\n </mat-form-field>\n </div>\n </ng-container>\n\n <div class='save-container'>\n <button mat-flat-button (click)='onCloseEditPanel()' [color]='color' class='save-button'>\n {{ 'SAVE' | i18n: config()?.language}}\n </button>\n\n <p *ngIf='imageSrc()?.length' class='mat-caption image-caption'\n [class.warn]='(imageSrc()?.length | calculateSize) > 200'\n [class.fw-600]='(imageSrc()?.length | calculateSize) > 200'>\n {{\"SIZE\" | i18n: currentLanguage()}}: {{ (imageSrc()?.length | calculateSize) }}Kb &nbsp; {{ format.value }}\n </p>\n </div>\n </div>\n </div>\n</div>\n", styles: [".d-none{display:none}.d-flex{display:flex}.fw-600{font-weight:600}.w-100{width:100%}.mw-100{max-width:100%}.w-48{width:48%}.mw-48{max-width:48%}.float-right{float:right}p{margin:0!important;padding:0!important}.place-image{flex-direction:column;box-sizing:border-box;display:flex;place-content:flex-start;align-items:center}.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;background-color:#fff}@media (max-width: 599px){.place-image .image-holder{max-width:100%!important;max-height:250px!important}}.place-image .image-holder .image-upload-btn{transition:all .5s ease;position:relative;opacity:.85;width:50px;height:50px;box-sizing:content-box}.place-image .image-holder .image-upload-btn mat-icon{font-size:50px;width:50px;height:50px;line-height:50px}@media (max-width: 599px){.place-image .image-holder .image-upload-btn{opacity:1;width:30px;height:30px}.place-image .image-holder .image-upload-btn mat-icon{font-size:30px;width:30px;height:30px;line-height:30px}}.place-image .image-holder:hover .image-upload-btn{opacity:1;transition:all .5s ease}.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}.place-image .image-holder-loaded .image-caption{position:absolute;right:0;bottom:-22px}.place-image .image-holder-loaded img{height:100%;max-height:100%;width:100%;max-width:100%;object-fit:contain;object-position:center}@media (max-width: 599px){.place-image .image-holder-loaded{max-height:195px!important}}.place-image .image-holder-loaded .image-upload-btn{transition:all .5s ease;position:relative;opacity:.85;width:50px;height:50px;box-sizing:content-box}.place-image .image-holder-loaded .image-upload-btn mat-icon{font-size:50px;width:50px;height:50px;line-height:50px}@media (max-width: 599px){.place-image .image-holder-loaded .image-upload-btn{opacity:1;width:30px;height:30px}.place-image .image-holder-loaded .image-upload-btn mat-icon{font-size:30px;width:30px;height:30px;line-height:30px}}.place-image .image-holder-loaded:hover .image-upload-btn{opacity:1;transition:all .5s ease}.place-image .editing-bar-btn{margin-top:2px;display:flex;flex-direction:row;box-sizing:border-box;place-content:flex-start;align-items:flex-start}.place-image .editing-bar-btn .mat-icon-button{height:20px;line-height:20px;width:24px}.place-image .editing-bar-btn mat-icon{line-height:20px!important;font-size:20px!important;width:20px!important;height:20px!important}.place-image .editing-bar-btn button{margin:4px;transition:all .5s ease}.place-image .editing-bar-btn button:hover{transform:scale(1.25);margin:4px 8px;transition:all .25s ease-in}.place-image .editing-bar-btn a{margin:4px;transition:all .5s ease}.place-image .editing-bar-btn a:hover{transform:scale(1.25);margin:4px 8px;transition:all .25s ease-in}.popup{width:100vw;max-height:100%;height:100%;overflow:auto;position:fixed;top:0;left:0;z-index:1000;padding:24px;color:#fff;box-sizing:border-box;animation-name:show;animation-duration:.4s}.popup .popup-clear{flex-direction:row;box-sizing:border-box;display:flex;place-content:center flex-end;align-items:center}.popup .image-container{margin-top:50px;margin-bottom:50px;height:calc(100vh - 188px);min-height:calc(100vh - 188px);min-width:100%;width:100%;flex-flow:row wrap;box-sizing:border-box;display:flex;place-content:flex-start center;align-items:flex-start}.popup .image-container .image-holder-full{height:auto;width:auto;position:relative;display:contents}.popup img{max-height:600px;max-width:100%;object-fit:contain;object-position:center;margin:8px;transition:all .5s ease}@media (max-width: 1024px){.popup{background-color:#000000d9;padding:8px}.popup img{max-height:100%;max-width:100%}}@media (max-width: 599px){.popup img{margin:0}}.popup .control-panel{color:#000;background-color:#fff;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){.popup .control-panel{margin:8px 0;width:100%}}.popup .control-panel .title-panel{padding:0 4px;font-size:16px;margin-bottom:16px!important}.popup .control-panel .item-panel{padding:0 4px!important;font-size:12px;display:flex;justify-content:space-between;align-items:center;gap:4px}.popup .control-panel .formats-selection{margin-top:8px!important;flex-direction:row;box-sizing:border-box;display:flex;place-content:flex-start;align-items:flex-start}.popup .control-panel .max-dimension-container{margin-top:16px!important;flex-flow:row;box-sizing:border-box;display:flex;place-content:flex-start space-between;align-items:flex-start}.popup .control-panel .dimension-container{margin-top:8px!important;flex-flow:row wrap;box-sizing:border-box;display:flex;place-content:flex-start space-between;align-items:flex-start}.popup .control-panel .save-container{flex-direction:row;box-sizing:border-box;display:flex;place-content:center space-between;align-items:center}.popup .control-panel .save-container .save-button{padding:0 8px;height:34px;box-sizing:border-box;font-weight:600}.popup .control-panel .quality-container{flex-direction:row;box-sizing:border-box;display:flex;place-content:flex-start;align-items:flex-start}.popup .control-panel .refresh-container{display:flex;justify-content:space-between;align-items:center}.popup .control-panel .refresh-container div{display:flex;align-items:center}@keyframes show{0%{top:-100vh;opacity:0}to{top:0;opacity:1}}.mat-form-field-appearance-fill .mat-form-field-flex{background-color:#fff!important}.mat-select-panel{background:white!important}input.mat-input-element{color:#000000d9}.mat-checkbox-background{background-color:#fff}.image-cropper{position:absolute;width:150px;height:150px;border:2.5px solid white;box-sizing:border-box;resize:both;overflow:auto;opacity:0}.image-cropper #image-cropper-header{padding:10px;cursor:move;z-index:10;background-color:transparent;height:85%}.image-cropper #image-cropper-header mat-icon{color:#fff}.btn{padding:4px 8px;border-radius:4px;cursor:pointer}.btn mat-icon{color:#000000d1}\n"] }]
588
+ }], ctorParameters: function () { return []; }, propDecorators: { appearance: [{
589
+ type: Input
590
+ }], color: [{
591
+ type: Input
592
+ }], imagesAllowed: [{
593
+ type: Input
594
+ }], imagePicker: [{
595
+ type: ViewChild,
596
+ args: ['imagePicker', { static: false }]
597
+ }], $imageChanged: [{
598
+ type: Output
599
+ }], $imageOriginal: [{
600
+ type: Output
601
+ }], _imageSrc: [{
602
+ type: Input
603
+ }], _config: [{
604
+ type: Input
605
+ }] } });
606
+
607
+ /*
608
+ * Public API Surface of guachos-image-picker
609
+ */
610
+
611
+ /**
612
+ * Generated bundle index. Do not edit.
613
+ */
614
+
615
+ export { GuajiritosImagePicker };
616
+ //# sourceMappingURL=guajiritos-image-picker.mjs.map