@stemy/ngx-utils 19.1.1 → 19.1.3
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.
|
@@ -4,7 +4,7 @@ import 'reflect-metadata';
|
|
|
4
4
|
import * as i2 from '@angular/router';
|
|
5
5
|
import { ActivatedRouteSnapshot, Scroll, NavigationEnd, DefaultUrlSerializer, UrlTree, UrlSegmentGroup, UrlSegment, UrlSerializer } from '@angular/router';
|
|
6
6
|
import { BehaviorSubject, Observable, firstValueFrom, Subject, Subscription, from, TimeoutError, combineLatest } from 'rxjs';
|
|
7
|
-
import { skipWhile, debounceTime, distinctUntilChanged, map, filter,
|
|
7
|
+
import { skipWhile, debounceTime, distinctUntilChanged, map, filter, mergeMap, timeout } from 'rxjs/operators';
|
|
8
8
|
import * as i1$3 from '@angular/common';
|
|
9
9
|
import { isPlatformBrowser, isPlatformServer, DOCUMENT, APP_BASE_HREF, CommonModule } from '@angular/common';
|
|
10
10
|
import * as i1 from 'ngx-device-detector';
|
|
@@ -1507,11 +1507,12 @@ class DateUtils {
|
|
|
1507
1507
|
}
|
|
1508
1508
|
|
|
1509
1509
|
class FileUtils {
|
|
1510
|
+
static { this.base64 = /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/g; }
|
|
1510
1511
|
static getExtension(file) {
|
|
1511
|
-
return file ? file.name.
|
|
1512
|
+
return file ? file.name.substring(file.name.lastIndexOf(".")).toLowerCase() : null;
|
|
1512
1513
|
}
|
|
1513
1514
|
static getName(file) {
|
|
1514
|
-
return file ? file.name.
|
|
1515
|
+
return file ? file.name.substring(0, file.name.lastIndexOf(".")) : null;
|
|
1515
1516
|
}
|
|
1516
1517
|
static toFile(blob, fileName) {
|
|
1517
1518
|
const data = blob;
|
|
@@ -1556,31 +1557,37 @@ class FileUtils {
|
|
|
1556
1557
|
// @dynamic
|
|
1557
1558
|
reader => reader.readAsDataURL(file));
|
|
1558
1559
|
}
|
|
1559
|
-
static
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1560
|
+
static base64ToBlob(base64, mimeType = "application/octet-stream") {
|
|
1561
|
+
// Decode the Base64 string into a binary string
|
|
1562
|
+
const byteCharacters = atob(base64);
|
|
1563
|
+
// Convert the binary string into an array of bytes
|
|
1564
|
+
const byteNumbers = Array.from(byteCharacters, char => char.charCodeAt(0));
|
|
1565
|
+
const byteArray = new Uint8Array(byteNumbers);
|
|
1566
|
+
// Create a Blob with the byte array and the specified MIME type
|
|
1567
|
+
return new Blob([byteArray], { type: mimeType });
|
|
1568
|
+
}
|
|
1569
|
+
static async readBlobFromUrl(http, url) {
|
|
1570
|
+
if (!url) {
|
|
1571
|
+
throw new Error(`The URL is not specified for readBlobFromUrl`);
|
|
1572
|
+
}
|
|
1573
|
+
if (url.match(FileUtils.base64)) {
|
|
1574
|
+
return FileUtils.base64ToBlob(url);
|
|
1575
|
+
}
|
|
1576
|
+
return firstValueFrom(http.get(url, {
|
|
1577
|
+
responseType: "blob"
|
|
1578
|
+
}));
|
|
1579
|
+
}
|
|
1580
|
+
static async readDataFromUrl(http, url) {
|
|
1581
|
+
if (!url) {
|
|
1582
|
+
throw new Error(`The URL is not specified for readBlobFromUrl`);
|
|
1583
|
+
}
|
|
1584
|
+
if (url.match(FileUtils.base64)) {
|
|
1585
|
+
return url;
|
|
1586
|
+
}
|
|
1587
|
+
const blob = await firstValueFrom(http.get(url, {
|
|
1588
|
+
responseType: "blob"
|
|
1589
|
+
}));
|
|
1590
|
+
return FileUtils.readFileAsDataURL(blob);
|
|
1584
1591
|
}
|
|
1585
1592
|
static readFile(callback) {
|
|
1586
1593
|
return new Promise(
|
|
@@ -5383,8 +5390,8 @@ class DropListComponent {
|
|
|
5383
5390
|
this.prepareItem = () => { };
|
|
5384
5391
|
this.checkFn = () => false;
|
|
5385
5392
|
this.valueMap = {};
|
|
5386
|
-
this.remove =
|
|
5387
|
-
this.changeValue(this.value.filter(
|
|
5393
|
+
this.remove = index => {
|
|
5394
|
+
this.changeValue(this.value.filter((_, i) => i !== index));
|
|
5388
5395
|
};
|
|
5389
5396
|
}
|
|
5390
5397
|
onDragEnter(ev, elem, data) {
|
|
@@ -5457,7 +5464,7 @@ class DropListComponent {
|
|
|
5457
5464
|
provide: NG_VALUE_ACCESSOR,
|
|
5458
5465
|
useExisting: forwardRef(() => DropListComponent),
|
|
5459
5466
|
multi: true,
|
|
5460
|
-
}], queries: [{ propertyName: "itemTemplate", first: true, predicate: ["itemTemplate"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<ng-template #defaultTemplate let-item=\"item\">\n <div class=\"drop-list-item-label\">\n {{ item | getValue:labelField }}\n </div>\n</ng-template>\n<div class=\"drop-list\"\n #list\n (dragenter)=\"onDragEnter($event, list, this)\"\n (dragleave)=\"onDragLeave($event, list)\"\n (drop)=\"onDrop($event, list)\">\n <ng-container *ngFor=\"let id of value\">\n <div class=\"drop-list-item\">\n <ng-template #noItemTemplate>\n <div class=\"drop-list-item-label just-id\">\n {{ id }}\n </div>\n </ng-template>\n <ng-container [ngTemplateOutlet]=\"itemTemplate || defaultTemplate\"\n [ngTemplateOutletContext]=\"{item: valueMap[id], id: id, remove: remove}\"\n *ngIf=\"valueMap[id]; else noItemTemplate\"></ng-container>\n <div class=\"drop-list-item-delete\" (click)=\"remove(
|
|
5467
|
+
}], queries: [{ propertyName: "itemTemplate", first: true, predicate: ["itemTemplate"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<ng-template #defaultTemplate let-item=\"item\">\n <div class=\"drop-list-item-label\">\n {{ item | getValue:labelField }}\n </div>\n</ng-template>\n<div class=\"drop-list\"\n #list\n (dragenter)=\"onDragEnter($event, list, this)\"\n (dragleave)=\"onDragLeave($event, list)\"\n (drop)=\"onDrop($event, list)\">\n <ng-container *ngFor=\"let id of value; let ix = index\">\n <div class=\"drop-list-item\">\n <ng-template #noItemTemplate>\n <div class=\"drop-list-item-label just-id\">\n {{ id }}\n </div>\n </ng-template>\n <ng-container [ngTemplateOutlet]=\"itemTemplate || defaultTemplate\"\n [ngTemplateOutletContext]=\"{item: valueMap[id], id: id, remove: remove}\"\n *ngIf=\"valueMap[id]; else noItemTemplate\"></ng-container>\n <div class=\"drop-list-item-delete\" (click)=\"remove(ix)\">x</div>\n </div>\n </ng-container>\n</div>\n", styles: [".drop-list{min-height:100px;border:2px #bfbfbf dashed;border-radius:10px;padding:10px;display:flex;align-items:flex-start;justify-content:left;gap:10px;background-color:#0000000d;transition:.2s;flex-wrap:wrap}.drop-list.drop-allowed{background-color:#00000080;border-color:#a9a9a9}.drop-list .drop-list-item{position:relative;background:#0003;padding:7px 23px 7px 10px;border-radius:5px;-webkit-user-select:none;user-select:none}.drop-list .drop-list-item-label:not(.just-id){min-width:50px;text-align:center}.drop-list .drop-list-item-label.just-id{max-width:100px;overflow:hidden;text-overflow:ellipsis;color:gray}.drop-list .drop-list-item-delete{font-size:14px;line-height:14px;text-align:center;cursor:pointer;background:#fff;border-radius:2px;height:14px;width:15px;position:absolute;top:4px;right:4px}\n"], dependencies: [{ kind: "directive", type: i1$3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: GetValuePipe, name: "getValue" }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
5461
5468
|
}
|
|
5462
5469
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: DropListComponent, decorators: [{
|
|
5463
5470
|
type: Component,
|
|
@@ -5465,7 +5472,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
|
|
|
5465
5472
|
provide: NG_VALUE_ACCESSOR,
|
|
5466
5473
|
useExisting: forwardRef(() => DropListComponent),
|
|
5467
5474
|
multi: true,
|
|
5468
|
-
}], template: "<ng-template #defaultTemplate let-item=\"item\">\n <div class=\"drop-list-item-label\">\n {{ item | getValue:labelField }}\n </div>\n</ng-template>\n<div class=\"drop-list\"\n #list\n (dragenter)=\"onDragEnter($event, list, this)\"\n (dragleave)=\"onDragLeave($event, list)\"\n (drop)=\"onDrop($event, list)\">\n <ng-container *ngFor=\"let id of value\">\n <div class=\"drop-list-item\">\n <ng-template #noItemTemplate>\n <div class=\"drop-list-item-label just-id\">\n {{ id }}\n </div>\n </ng-template>\n <ng-container [ngTemplateOutlet]=\"itemTemplate || defaultTemplate\"\n [ngTemplateOutletContext]=\"{item: valueMap[id], id: id, remove: remove}\"\n *ngIf=\"valueMap[id]; else noItemTemplate\"></ng-container>\n <div class=\"drop-list-item-delete\" (click)=\"remove(
|
|
5475
|
+
}], template: "<ng-template #defaultTemplate let-item=\"item\">\n <div class=\"drop-list-item-label\">\n {{ item | getValue:labelField }}\n </div>\n</ng-template>\n<div class=\"drop-list\"\n #list\n (dragenter)=\"onDragEnter($event, list, this)\"\n (dragleave)=\"onDragLeave($event, list)\"\n (drop)=\"onDrop($event, list)\">\n <ng-container *ngFor=\"let id of value; let ix = index\">\n <div class=\"drop-list-item\">\n <ng-template #noItemTemplate>\n <div class=\"drop-list-item-label just-id\">\n {{ id }}\n </div>\n </ng-template>\n <ng-container [ngTemplateOutlet]=\"itemTemplate || defaultTemplate\"\n [ngTemplateOutletContext]=\"{item: valueMap[id], id: id, remove: remove}\"\n *ngIf=\"valueMap[id]; else noItemTemplate\"></ng-container>\n <div class=\"drop-list-item-delete\" (click)=\"remove(ix)\">x</div>\n </div>\n </ng-container>\n</div>\n", styles: [".drop-list{min-height:100px;border:2px #bfbfbf dashed;border-radius:10px;padding:10px;display:flex;align-items:flex-start;justify-content:left;gap:10px;background-color:#0000000d;transition:.2s;flex-wrap:wrap}.drop-list.drop-allowed{background-color:#00000080;border-color:#a9a9a9}.drop-list .drop-list-item{position:relative;background:#0003;padding:7px 23px 7px 10px;border-radius:5px;-webkit-user-select:none;user-select:none}.drop-list .drop-list-item-label:not(.just-id){min-width:50px;text-align:center}.drop-list .drop-list-item-label.just-id{max-width:100px;overflow:hidden;text-overflow:ellipsis;color:gray}.drop-list .drop-list-item-delete{font-size:14px;line-height:14px;text-align:center;cursor:pointer;background:#fff;border-radius:2px;height:14px;width:15px;position:absolute;top:4px;right:4px}\n"] }]
|
|
5469
5476
|
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { disabled: [{
|
|
5470
5477
|
type: Input
|
|
5471
5478
|
}], unique: [{
|