@dotglitch/ngx-common 1.0.25 → 1.0.27
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 +15 -14
- package/components/lazy-loader/lazy-loader.component.d.ts +5 -3
- package/esm2020/components/lazy-loader/lazy-loader.component.mjs +29 -23
- package/fesm2015/dotglitch-ngx-common.mjs +33 -27
- package/fesm2015/dotglitch-ngx-common.mjs.map +1 -1
- package/fesm2020/dotglitch-ngx-common.mjs +28 -22
- package/fesm2020/dotglitch-ngx-common.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1400,9 +1400,23 @@ class LazyLoaderComponent {
|
|
|
1400
1400
|
*/
|
|
1401
1401
|
this.componentLoaded = new EventEmitter();
|
|
1402
1402
|
// Force 500ms delay before revealing the spinner
|
|
1403
|
-
this.
|
|
1404
|
-
this.clearLoader$ = this.
|
|
1405
|
-
this.
|
|
1403
|
+
this.clearEmitter = new EventEmitter();
|
|
1404
|
+
this.clearLoader$ = this.clearEmitter.pipe(debounceTime(300));
|
|
1405
|
+
this.showEmitter = new EventEmitter();
|
|
1406
|
+
this.showLoader$ = this.showEmitter.pipe(debounceTime(1));
|
|
1407
|
+
this.subscriptions = [
|
|
1408
|
+
this.clearLoader$.subscribe(() => {
|
|
1409
|
+
this.isClearingLoader = true;
|
|
1410
|
+
setTimeout(() => {
|
|
1411
|
+
this.renderSpinner = false;
|
|
1412
|
+
}, 300);
|
|
1413
|
+
}),
|
|
1414
|
+
this.showLoader$.subscribe(() => {
|
|
1415
|
+
this.isClearingLoader = false;
|
|
1416
|
+
this.renderSpinner = true;
|
|
1417
|
+
})
|
|
1418
|
+
];
|
|
1419
|
+
this.renderSpinner = true; // whether we render the DOM for the spinner
|
|
1406
1420
|
this.isClearingLoader = false; // should the spinner start fading out
|
|
1407
1421
|
this.initialized = false;
|
|
1408
1422
|
this.config = LazyLoaderService.config;
|
|
@@ -1416,14 +1430,11 @@ class LazyLoaderComponent {
|
|
|
1416
1430
|
this.id = this.dialogArguments.id;
|
|
1417
1431
|
this.group = this.dialogArguments.group;
|
|
1418
1432
|
}
|
|
1419
|
-
this.loaderSub = this.clearLoader$.subscribe(() => {
|
|
1420
|
-
this.showLoader = false;
|
|
1421
|
-
});
|
|
1422
1433
|
}
|
|
1423
1434
|
async ngAfterViewInit() {
|
|
1424
1435
|
this.ngOnDestroy(false);
|
|
1425
1436
|
this.isClearingLoader = false;
|
|
1426
|
-
this.
|
|
1437
|
+
this.renderSpinner = true;
|
|
1427
1438
|
this.initialized = true;
|
|
1428
1439
|
if (!this._id) {
|
|
1429
1440
|
this.warn("No component was specified!");
|
|
@@ -1480,22 +1491,15 @@ class LazyLoaderComponent {
|
|
|
1480
1491
|
const isLoading$ = instance['ngxShowDistractor$'];
|
|
1481
1492
|
if (isLoading$ && typeof isLoading$.subscribe == "function") {
|
|
1482
1493
|
this.distractorSubscription = isLoading$.subscribe(loading => {
|
|
1483
|
-
|
|
1484
|
-
this.isClearingLoader = true;
|
|
1485
|
-
this.loaderEmitter.emit();
|
|
1486
|
-
}
|
|
1487
|
-
else {
|
|
1488
|
-
this.showLoader = true;
|
|
1489
|
-
this.isClearingLoader = false;
|
|
1490
|
-
}
|
|
1494
|
+
loading ? this.showEmitter.emit() : this.clearEmitter.emit();
|
|
1491
1495
|
});
|
|
1492
1496
|
}
|
|
1493
1497
|
else {
|
|
1494
|
-
this.
|
|
1498
|
+
this.clearEmitter.emit();
|
|
1495
1499
|
}
|
|
1496
1500
|
const name = Object.keys(bundle)[0];
|
|
1497
1501
|
this.log(`Loaded '${name}'`);
|
|
1498
|
-
this.
|
|
1502
|
+
this.clearEmitter.emit();
|
|
1499
1503
|
return componentRef;
|
|
1500
1504
|
}
|
|
1501
1505
|
catch (ex) {
|
|
@@ -1520,7 +1524,9 @@ class LazyLoaderComponent {
|
|
|
1520
1524
|
this.outputSubscriptions = {};
|
|
1521
1525
|
// Clear all things
|
|
1522
1526
|
if (clearAll) {
|
|
1523
|
-
this.
|
|
1527
|
+
Object.entries(this.subscriptions).forEach(([key, sub]) => {
|
|
1528
|
+
sub.unsubscribe();
|
|
1529
|
+
});
|
|
1524
1530
|
}
|
|
1525
1531
|
this.distractorSubscription?.unsubscribe();
|
|
1526
1532
|
// Clear target container
|
|
@@ -1589,7 +1595,7 @@ class LazyLoaderComponent {
|
|
|
1589
1595
|
loadDefault() {
|
|
1590
1596
|
if (this.config.notFoundComponent)
|
|
1591
1597
|
this.targetContainer.createComponent(this.config.notFoundComponent);
|
|
1592
|
-
this.
|
|
1598
|
+
this.clearEmitter.emit();
|
|
1593
1599
|
}
|
|
1594
1600
|
/**
|
|
1595
1601
|
* Load the "Error" component.
|
|
@@ -1600,14 +1606,14 @@ class LazyLoaderComponent {
|
|
|
1600
1606
|
loadError() {
|
|
1601
1607
|
if (this.config.errorComponent)
|
|
1602
1608
|
this.targetContainer.createComponent(this.config.errorComponent);
|
|
1603
|
-
this.
|
|
1609
|
+
this.clearEmitter.emit();
|
|
1604
1610
|
}
|
|
1605
1611
|
}
|
|
1606
1612
|
LazyLoaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LazyLoaderComponent, deps: [{ token: LazyLoaderService }, { token: i0.ViewContainerRef, optional: true }, { token: i2$1.DialogRef, optional: true }, { token: MAT_DIALOG_DATA, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
1607
|
-
LazyLoaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: LazyLoaderComponent, isStandalone: true, selector: "ngx-lazy-loader", inputs: { id: ["component", "id"], group: "group", inputs: "inputs", outputs: "outputs" }, outputs: { componentLoadError: "componentLoadError", componentLoaded: "componentLoaded" }, viewQueries: [{ propertyName: "targetContainer", first: true, predicate: ["content"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: "<ng-container #content></ng-container>\n\n<div
|
|
1613
|
+
LazyLoaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: LazyLoaderComponent, isStandalone: true, selector: "ngx-lazy-loader", inputs: { id: ["component", "id"], group: "group", inputs: "inputs", outputs: "outputs" }, outputs: { componentLoadError: "componentLoadError", componentLoaded: "componentLoaded" }, viewQueries: [{ propertyName: "targetContainer", first: true, predicate: ["content"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: "<ng-container #content></ng-container>\n\n<div\n *ngIf=\"renderSpinner\"\n class=\"ngx-lazy-loader-distractor\"\n [class.destroying]=\"isClearingLoader\"\n>\n <ng-container *ngIf=\"config.loaderDistractorComponent\" [ngComponentOutlet]=\"config.loaderDistractorComponent\"></ng-container>\n <ng-container *ngIf=\"config.loaderDistractorTemplate\" [ngTemplateOutlet]=\"config.loaderDistractorTemplate\" [ngTemplateOutletContext]=\"{ '$implicit': inputs }\"></ng-container>\n</div>\n", styles: [":host{display:contents;contain:content;z-index:1;position:relative}.ngx-lazy-loader-distractor{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;flex-direction:column;background-color:var(--background-color, #212121);opacity:1;transition:opacity .3s ease;z-index:999999;animation:fade-in .3s ease}.ngx-lazy-loader-distractor.destroying{opacity:0;pointer-events:none}@keyframes fade-in{0%{opacity:0;pointer-events:none}to{opacity:1;pointer-events:all}}\n"], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
1608
1614
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LazyLoaderComponent, decorators: [{
|
|
1609
1615
|
type: Component,
|
|
1610
|
-
args: [{ selector: 'ngx-lazy-loader', imports: [NgIf, NgComponentOutlet, NgTemplateOutlet], standalone: true, template: "<ng-container #content></ng-container>\n\n<div
|
|
1616
|
+
args: [{ selector: 'ngx-lazy-loader', imports: [NgIf, NgComponentOutlet, NgTemplateOutlet], standalone: true, template: "<ng-container #content></ng-container>\n\n<div\n *ngIf=\"renderSpinner\"\n class=\"ngx-lazy-loader-distractor\"\n [class.destroying]=\"isClearingLoader\"\n>\n <ng-container *ngIf=\"config.loaderDistractorComponent\" [ngComponentOutlet]=\"config.loaderDistractorComponent\"></ng-container>\n <ng-container *ngIf=\"config.loaderDistractorTemplate\" [ngTemplateOutlet]=\"config.loaderDistractorTemplate\" [ngTemplateOutletContext]=\"{ '$implicit': inputs }\"></ng-container>\n</div>\n", styles: [":host{display:contents;contain:content;z-index:1;position:relative}.ngx-lazy-loader-distractor{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;flex-direction:column;background-color:var(--background-color, #212121);opacity:1;transition:opacity .3s ease;z-index:999999;animation:fade-in .3s ease}.ngx-lazy-loader-distractor.destroying{opacity:0;pointer-events:none}@keyframes fade-in{0%{opacity:0;pointer-events:none}to{opacity:1;pointer-events:all}}\n"] }]
|
|
1611
1617
|
}], ctorParameters: function () { return [{ type: LazyLoaderService }, { type: i0.ViewContainerRef, decorators: [{
|
|
1612
1618
|
type: Optional
|
|
1613
1619
|
}] }, { type: i2$1.DialogRef, decorators: [{
|