@seniorsistemas/angular-components 17.3.6 → 17.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/seniorsistemas-angular-components.umd.js +36 -8
- package/bundles/seniorsistemas-angular-components.umd.js.map +1 -1
- package/bundles/seniorsistemas-angular-components.umd.min.js +1 -1
- package/bundles/seniorsistemas-angular-components.umd.min.js.map +1 -1
- package/components/utils/image-utils.d.ts +4 -0
- package/esm2015/components/image-cropper/image-cropper.component.js +13 -9
- package/esm2015/components/utils/image-utils.js +25 -0
- package/esm5/components/image-cropper/image-cropper.component.js +14 -9
- package/esm5/components/utils/image-utils.js +25 -0
- package/fesm2015/seniorsistemas-angular-components.js +36 -9
- package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
- package/fesm5/seniorsistemas-angular-components.js +37 -9
- package/fesm5/seniorsistemas-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/seniorsistemas-angular-components.metadata.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __extends, __spread, __assign, __awaiter, __generator, __param, __values, __rest, __read } from 'tslib';
|
|
2
2
|
import { EventEmitter, Input, Output, Component, ContentChildren, ViewChild, HostListener, forwardRef, NgModule, ɵɵdefineInjectable, Injectable, ElementRef, ApplicationRef, ComponentFactoryResolver, Injector, Directive, HostBinding, Renderer2, InjectionToken, Inject, Pipe, ViewEncapsulation, TemplateRef, ViewContainerRef, ChangeDetectorRef, Optional, ContentChild } from '@angular/core';
|
|
3
3
|
import { trigger, transition, style as style$7, animate, state, group, query, animateChild } from '@angular/animations';
|
|
4
|
-
import { Subject, ReplaySubject, of, from, throwError, forkJoin } from 'rxjs';
|
|
4
|
+
import { Subject, ReplaySubject, of, from, throwError, forkJoin, Observable } from 'rxjs';
|
|
5
5
|
import { takeUntil, filter, take, tap, map, switchMap, catchError, delay, debounceTime, repeat, finalize } from 'rxjs/operators';
|
|
6
6
|
import { CommonModule } from '@angular/common';
|
|
7
7
|
import { NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule, FormControl, FormGroup, NG_VALIDATORS, FormBuilder, Validators, FormArray, ControlContainer } from '@angular/forms';
|
|
@@ -12657,6 +12657,30 @@ var StructureModule = /** @class */ (function () {
|
|
|
12657
12657
|
return StructureModule;
|
|
12658
12658
|
}());
|
|
12659
12659
|
|
|
12660
|
+
var ImageUtils;
|
|
12661
|
+
(function (ImageUtils) {
|
|
12662
|
+
function adjustAspectRatio(imageBase64) {
|
|
12663
|
+
return new Observable(function (observer) {
|
|
12664
|
+
var image = new Image();
|
|
12665
|
+
image.src = imageBase64;
|
|
12666
|
+
image.onload = function () {
|
|
12667
|
+
var canvas = document.createElement('canvas');
|
|
12668
|
+
var context = canvas.getContext('2d');
|
|
12669
|
+
var size = Math.max(image.naturalWidth, image.naturalHeight);
|
|
12670
|
+
canvas.width = size;
|
|
12671
|
+
canvas.height = size;
|
|
12672
|
+
context.fillStyle = 'rgba(0, 0, 0, 0)';
|
|
12673
|
+
context.fillRect(0, 0, size, size);
|
|
12674
|
+
context.drawImage(image, (size - image.naturalWidth) / 2, (size - image.naturalHeight) / 2);
|
|
12675
|
+
var adjustedImageBase64 = canvas.toDataURL();
|
|
12676
|
+
observer.next(adjustedImageBase64);
|
|
12677
|
+
observer.complete();
|
|
12678
|
+
};
|
|
12679
|
+
});
|
|
12680
|
+
}
|
|
12681
|
+
ImageUtils.adjustAspectRatio = adjustAspectRatio;
|
|
12682
|
+
})(ImageUtils || (ImageUtils = {}));
|
|
12683
|
+
|
|
12660
12684
|
var ImageCropperComponent = /** @class */ (function () {
|
|
12661
12685
|
function ImageCropperComponent() {
|
|
12662
12686
|
this.id = "s-image-cropper-" + ImageCropperComponent_1.nextId++;
|
|
@@ -12692,16 +12716,20 @@ var ImageCropperComponent = /** @class */ (function () {
|
|
|
12692
12716
|
}
|
|
12693
12717
|
};
|
|
12694
12718
|
ImageCropperComponent.prototype.initCropper = function () {
|
|
12719
|
+
var _this = this;
|
|
12695
12720
|
if (this.cropper)
|
|
12696
12721
|
this.cropper.destroy();
|
|
12697
|
-
|
|
12698
|
-
|
|
12699
|
-
|
|
12700
|
-
|
|
12701
|
-
|
|
12702
|
-
|
|
12703
|
-
|
|
12704
|
-
|
|
12722
|
+
ImageUtils.adjustAspectRatio(this.imageSource)
|
|
12723
|
+
.subscribe(function (imageBase64) {
|
|
12724
|
+
_this.image.nativeElement.src = imageBase64;
|
|
12725
|
+
_this.cropper = new Cropper(_this.image.nativeElement, {
|
|
12726
|
+
aspectRatio: _this.rounded ? 1 : _this.aspectRatio,
|
|
12727
|
+
guides: false,
|
|
12728
|
+
dragMode: "move",
|
|
12729
|
+
minCropBoxHeight: 2,
|
|
12730
|
+
minCropBoxWidth: 2,
|
|
12731
|
+
toggleDragModeOnDblclick: false,
|
|
12732
|
+
});
|
|
12705
12733
|
});
|
|
12706
12734
|
};
|
|
12707
12735
|
ImageCropperComponent.prototype.getRoundedCanvas = function (sourceCanvas) {
|