@guajiritos/image-picker 0.0.6 → 0.0.7

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