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