@dotglitch/ngx-common 1.0.17 → 1.0.18

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.
@@ -6,7 +6,7 @@ import * as i2 from '@angular/common';
6
6
  import { CommonModule, NgTemplateOutlet, NgIf, NgForOf, DOCUMENT, NgComponentOutlet } from '@angular/common';
7
7
  import * as i1$1 from '@angular/platform-browser';
8
8
  import { createApplication } from '@angular/platform-browser';
9
- import { firstValueFrom, of, Subject, debounceTime } from 'rxjs';
9
+ import { firstValueFrom, of, Subject, BehaviorSubject, debounceTime } from 'rxjs';
10
10
  import * as i4 from '@angular/material/icon';
11
11
  import { MatIconModule } from '@angular/material/icon';
12
12
  import * as i5 from '@angular/material/progress-spinner';
@@ -1028,7 +1028,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1028
1028
  args: [DOCUMENT]
1029
1029
  }] }]; } });
1030
1030
 
1031
- const { log, warn, err } = Logger("DialogService", "#607d8b");
1031
+ const { log: log$1, warn: warn$1, err: err$1 } = Logger("DialogService", "#607d8b");
1032
1032
  class DialogService {
1033
1033
  constructor(dialog, lazyLoader) {
1034
1034
  this.dialog = dialog;
@@ -1065,7 +1065,7 @@ class DialogService {
1065
1065
  dialog['idx'] = name;
1066
1066
  this.dialogs.push(dialog);
1067
1067
  dialog.afterClosed().subscribe(result => {
1068
- log("Dialog closed " + name, result);
1068
+ log$1("Dialog closed " + name, result);
1069
1069
  resolve(result);
1070
1070
  });
1071
1071
  });
@@ -1322,6 +1322,72 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1322
1322
  }]
1323
1323
  }], ctorParameters: function () { return [{ type: Fetch }]; } });
1324
1324
 
1325
+ class ThemeService extends BehaviorSubject {
1326
+ constructor() {
1327
+ super("dark");
1328
+ this.subscribe(t => {
1329
+ document.body.classList.remove("dark");
1330
+ document.body.classList.remove("light");
1331
+ document.body.classList.add(t);
1332
+ });
1333
+ }
1334
+ setTheme(t) {
1335
+ this.next(t);
1336
+ }
1337
+ }
1338
+ ThemeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1339
+ ThemeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ThemeService, providedIn: 'root' });
1340
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ThemeService, decorators: [{
1341
+ type: Injectable,
1342
+ args: [{
1343
+ providedIn: 'root'
1344
+ }]
1345
+ }], ctorParameters: function () { return []; } });
1346
+
1347
+ const { log, warn, err } = Logger("NavigationService", "#ff9800");
1348
+ class NavigationService {
1349
+ constructor(lazyLoader) {
1350
+ this.lazyLoader = lazyLoader;
1351
+ this.virtualPath$ = new BehaviorSubject(null);
1352
+ window.onhashchange = () => this.loadRootPageFromUrl();
1353
+ this.loadRootPageFromUrl();
1354
+ }
1355
+ loadRootPageFromUrl() {
1356
+ const hash = location.hash.split("?")[0];
1357
+ // If the URL is imprecisely set, we restore it to the landing page
1358
+ if (!this.lazyLoader.isComponentRegistered(hash))
1359
+ return this.loadRootPage("#/Landing");
1360
+ this.loadRootPage(location.hash);
1361
+ }
1362
+ loadRootPage(url, data = {}) {
1363
+ const [path, query] = url.split('?');
1364
+ const hash = path.replace(/^\/?#\/?/, '');
1365
+ const chunks = hash.split('/');
1366
+ // Get query params and pass them as @Input arguments.
1367
+ const params = query?.split('&')
1368
+ .reduce((pars, par) => {
1369
+ const [key, value] = par.split("=");
1370
+ const decoded = decodeURIComponent(value);
1371
+ pars[key] = decoded;
1372
+ return pars;
1373
+ }, {}) || {};
1374
+ log(`Root page navigate to '${hash}'`, { params, chunks });
1375
+ this.virtualPath$.next({
1376
+ root: chunks[0],
1377
+ chunks: chunks,
1378
+ args: params
1379
+ });
1380
+ }
1381
+ }
1382
+ NavigationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NavigationService, deps: [{ token: LazyLoaderService }], target: i0.ɵɵFactoryTarget.Injectable });
1383
+ NavigationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NavigationService, providedIn: 'root' });
1384
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NavigationService, decorators: [{
1385
+ type: Injectable,
1386
+ args: [{
1387
+ providedIn: 'root'
1388
+ }]
1389
+ }], ctorParameters: function () { return [{ type: LazyLoaderService }]; } });
1390
+
1325
1391
  var ComponentResolveStrategy;
1326
1392
  (function (ComponentResolveStrategy) {
1327
1393
  /**
@@ -2076,5 +2142,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2076
2142
  * Generated bundle index. Do not edit.
2077
2143
  */
2078
2144
 
2079
- export { ComponentResolveStrategy, DependencyService, DialogService, DynamicHTMLComponent, DynamicHTMLOptions, DynamicHTMLRenderer, Fetch, FileService, HtmlBypass, KeyboardService, LazyLoaderComponent, LazyLoaderModule, LazyLoaderService, MenuDirective, NGX_DYNAMIC_CONFIG, NGX_LAZY_LOADER_CONFIG, NgxDynamicHTMLModule, OnMount, ResourceBypass, ScriptBypass, StyleBypass, TooltipDirective, UrlBypass, openMenu, openTooltip };
2145
+ export { ComponentResolveStrategy, DependencyService, DialogService, DynamicHTMLComponent, DynamicHTMLOptions, DynamicHTMLRenderer, Fetch, FileService, HtmlBypass, KeyboardService, LazyLoaderComponent, LazyLoaderModule, LazyLoaderService, MenuDirective, NGX_DYNAMIC_CONFIG, NGX_LAZY_LOADER_CONFIG, NavigationService, NgxDynamicHTMLModule, OnMount, ResourceBypass, ScriptBypass, StyleBypass, ThemeService, TooltipDirective, UrlBypass, openMenu, openTooltip };
2080
2146
  //# sourceMappingURL=dotglitch-ngx-common.mjs.map