@elderbyte/ngx-starter 19.9.0 → 19.10.0

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.
@@ -81,7 +81,7 @@ import { MatTab } from '@angular/material/tabs';
81
81
  import { fetchEventSource, EventStreamContentType } from '@microsoft/fetch-event-source';
82
82
 
83
83
  class BytesFormat {
84
- static { this.units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB']; }
84
+ static { this.units = ['bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']; }
85
85
  static format(bytes, precision = 2) {
86
86
  if (isNaN(parseFloat(String(bytes))) || !isFinite(bytes)) {
87
87
  return '?';
@@ -884,6 +884,9 @@ class DurationFormat {
884
884
  else if (milliseconds <= 999) {
885
885
  return this.formatNumber(milliseconds, 0) + ' ms';
886
886
  }
887
+ else {
888
+ return undefined; // TODO: Maybe add way to format 1000+ milliseconds also
889
+ }
887
890
  }
888
891
  formatNumber(value, precision) {
889
892
  return +value.toFixed(precision);
@@ -1839,13 +1842,11 @@ class Objects {
1839
1842
  return src;
1840
1843
  }
1841
1844
  try {
1842
- const json = JSON.stringify(src);
1843
- return JSON.parse(json);
1845
+ return JSON.parse(JSON.stringify(src));
1844
1846
  }
1845
1847
  catch (err) {
1846
- if (err instanceof Error) {
1847
- throw new Error('Failed to clone object! ' + err.message);
1848
- }
1848
+ const errorMessage = err instanceof Error ? err.message : 'unknown error';
1849
+ throw new Error(`Failed to clone object: ${errorMessage}`);
1849
1850
  }
1850
1851
  }
1851
1852
  /**
@@ -2071,7 +2072,7 @@ function coerceInterval(value) {
2071
2072
  return Interval.parse(value);
2072
2073
  }
2073
2074
  else {
2074
- this.logger.warn('Unsupported value that cant be converted to Interval: "' + value + '"');
2075
+ LoggerFactory.getLogger('static: coerceInterval').warn(`Unsupported value that cant be converted to Interval: "${value}"`);
2075
2076
  }
2076
2077
  }
2077
2078
  return undefined;
@@ -2085,7 +2086,7 @@ function coerceIntervalIsoStr(value) {
2085
2086
  return coerceInterval(value)?.toInstantString();
2086
2087
  }
2087
2088
  else {
2088
- this.logger.warn('Unsupported value that cant be converted to Iso Interval Str: "' + value + '"');
2089
+ LoggerFactory.getLogger('static: coerceIntervalIsoStr').warn(`Unsupported value that cant be converted to Iso Interval Str: "${value}"`);
2089
2090
  }
2090
2091
  }
2091
2092
  return undefined;
@@ -3560,7 +3561,7 @@ class IndexedEntities {
3560
3561
  updated.forEach((update) => {
3561
3562
  const id = this.getItemId(update);
3562
3563
  const index = this.indexById(id);
3563
- if (index != -1) {
3564
+ if (index !== -1) {
3564
3565
  newData[index] = update;
3565
3566
  anyUpdated = true;
3566
3567
  }
@@ -3611,9 +3612,10 @@ class IndexedEntities {
3611
3612
  getById(id) {
3612
3613
  const entities = this.entitiesSnapshot;
3613
3614
  const index = this.indexById(id);
3614
- if (index != -1) {
3615
+ if (index !== -1) {
3615
3616
  return entities[index];
3616
3617
  }
3618
+ return undefined;
3617
3619
  }
3618
3620
  notify() {
3619
3621
  this._entities$.next(this._entities$.getValue());
@@ -5919,6 +5921,7 @@ class DataSourceAdapter {
5919
5921
  .findAllContinuable(TokenChunkRequest.first(filters, sorts, limit))
5920
5922
  .pipe(map((page) => page.content));
5921
5923
  }
5924
+ throw new Error('Unsupported data source type');
5922
5925
  }
5923
5926
  }
5924
5927
 
@@ -8379,6 +8382,7 @@ class DataTransferBase {
8379
8382
  if (state.hasFailed) {
8380
8383
  throw state.error ? state.error : 'Completion Failed due unknown error!';
8381
8384
  }
8385
+ return false; // Default return for unexpected state
8382
8386
  }), first());
8383
8387
  }
8384
8388
  /**
@@ -9516,7 +9520,7 @@ class ElderThemeService {
9516
9520
  activateTheme(themeId) {
9517
9521
  const theme = this.findTheme(themeId);
9518
9522
  if (theme) {
9519
- this.logger.info('Activating theme ' + themeId);
9523
+ this.logger.debug('Activating theme ' + themeId);
9520
9524
  this._activeTheme$.next(theme);
9521
9525
  }
9522
9526
  else {
@@ -9724,7 +9728,7 @@ class ElderThemeToggleComponent {
9724
9728
  this.activeToggleTheme$ = combineLatest([
9725
9729
  this.themeService.defaultTheme$,
9726
9730
  this.themeService.activeTheme$,
9727
- ]).pipe(map(([defaultTheme, activeTheme]) => this.decideToggleTheme(defaultTheme, activeTheme)), tap((tt) => this.logger.info('Active toggle theme: ' + tt)));
9731
+ ]).pipe(map(([defaultTheme, activeTheme]) => this.decideToggleTheme(defaultTheme, activeTheme)), tap((tt) => this.logger.debug('Active toggle theme: ' + tt)));
9728
9732
  }
9729
9733
  /***************************************************************************
9730
9734
  * *
@@ -10451,7 +10455,7 @@ class FileSystemApi {
10451
10455
  * *
10452
10456
  **************************************************************************/
10453
10457
  static isGetAsFileSystemHandleSupported(transferItem) {
10454
- // @ts-ignore
10458
+ // @ts-expect-error - getAsFileSystemHandle is not yet in TypeScript's lib.dom.d.ts
10455
10459
  return transferItem.getAsFileSystemHandle !== undefined;
10456
10460
  }
10457
10461
  /**
@@ -10459,7 +10463,7 @@ class FileSystemApi {
10459
10463
  * or `drop` event. Otherwise, it will return null!
10460
10464
  */
10461
10465
  static getAsFileSystemHandle(transferItem) {
10462
- // @ts-ignore
10466
+ // @ts-expect-error - getAsFileSystemHandle is not yet in TypeScript's lib.dom.d.ts
10463
10467
  return from(transferItem.getAsFileSystemHandle());
10464
10468
  }
10465
10469
  /***************************************************************************
@@ -10471,14 +10475,16 @@ class FileSystemApi {
10471
10475
  return 'showOpenFilePicker' in window;
10472
10476
  }
10473
10477
  static openFilePicker(pickerOpts) {
10478
+ if (!FileSystemApi.isFileSystemSupported()) {
10479
+ return throwError(() => new Error('File System API is not supported in this browser'));
10480
+ }
10474
10481
  try {
10475
- // @ts-ignore
10482
+ // @ts-expect-error - showOpenFilePicker is not yet in TypeScript's lib.dom.d.ts
10476
10483
  return from(window.showOpenFilePicker(pickerOpts));
10477
10484
  }
10478
10485
  catch (e) {
10479
- if (e instanceof Error) {
10480
- return throwError(() => e);
10481
- }
10486
+ const errorMessage = e instanceof Error ? e.message : 'unknown error';
10487
+ return throwError(() => new Error(`Error occurred while opening file picker: ${errorMessage}`));
10482
10488
  }
10483
10489
  }
10484
10490
  /***************************************************************************
@@ -10491,13 +10497,12 @@ class FileSystemApi {
10491
10497
  }
10492
10498
  static openDirectoryPicker(pickerOpts) {
10493
10499
  try {
10494
- // @ts-ignore
10500
+ // @ts-expect-error - showDirectoryPicker is not yet in TypeScript's lib.dom.d.ts
10495
10501
  return from(window.showDirectoryPicker(pickerOpts));
10496
10502
  }
10497
10503
  catch (e) {
10498
- if (e instanceof Error) {
10499
- return throwError(() => e);
10500
- }
10504
+ const errorMessage = e instanceof Error ? e.message : 'unknown error';
10505
+ return throwError(() => new Error(`Error occurred while opening directory picker: ${errorMessage}`));
10501
10506
  }
10502
10507
  }
10503
10508
  /***************************************************************************
@@ -10525,7 +10530,7 @@ class FileSystemApi {
10525
10530
  }
10526
10531
  static async getHandlesFromDirectoryAsync(dirHandle) {
10527
10532
  const handles = [];
10528
- // @ts-ignore
10533
+ // @ts-expect-error - values() is not yet in TypeScript's lib.dom.d.ts
10529
10534
  for await (const handle of dirHandle.values()) {
10530
10535
  handles.push(handle);
10531
10536
  }
@@ -18663,12 +18668,7 @@ class ElderTabFocusTrapDirective {
18663
18668
  return Array.from(elements);
18664
18669
  }
18665
18670
  isFocusableByTab(element) {
18666
- if (this.isFocusable(element)) {
18667
- if (element.tabIndex === -1) {
18668
- return false;
18669
- }
18670
- return true;
18671
- }
18671
+ return this.isFocusable(element) && element.tabIndex !== -1;
18672
18672
  }
18673
18673
  isFocusable(element) {
18674
18674
  if (element) {
@@ -19275,7 +19275,7 @@ class ElderTableSortDirective {
19275
19275
  this.logger.warn('[elderTableSort] directive is no longer required. Use matSort on ElderTableComponent directly.');
19276
19276
  }
19277
19277
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: ElderTableSortDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
19278
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.7", type: ElderTableSortDirective, isStandalone: true, selector: "[elderTableSort]", ngImport: i0 }); }
19278
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.7", type: ElderTableSortDirective, isStandalone: true, selector: "[elderTableSort]", inputs: { elderTableSort: "elderTableSort" }, ngImport: i0 }); }
19279
19279
  }
19280
19280
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: ElderTableSortDirective, decorators: [{
19281
19281
  type: Directive,
@@ -19283,7 +19283,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
19283
19283
  selector: '[elderTableSort]',
19284
19284
  standalone: true,
19285
19285
  }]
19286
- }], ctorParameters: () => [] });
19286
+ }], ctorParameters: () => [], propDecorators: { elderTableSort: [{
19287
+ type: Input
19288
+ }] } });
19287
19289
 
19288
19290
  /**
19289
19291
  * This directive is meant to be placed on table cells containing numbers.
@@ -19906,6 +19908,7 @@ class ElderTileComponent {
19906
19908
  if (currentSelection && currentSelection.length > 0) {
19907
19909
  return true;
19908
19910
  }
19911
+ return false;
19909
19912
  }
19910
19913
  bringToView() {
19911
19914
  const element = this.elderTileRef().nativeElement;
@@ -20298,7 +20301,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
20298
20301
  ElderCompositeSortComponent,
20299
20302
  ElderCompositeSortDcDirective,
20300
20303
  ElderTileComponent,
20301
- NgClass,
20302
20304
  ElderContinuatorComponent,
20303
20305
  ResizeObserverDirective,
20304
20306
  ], template: "<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->\n<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->\n<div class=\"full elder-grid-component\">\n @if (dc(); as dc) {\n <!-- Grid Browser -->\n <div\n class=\"layout-col full elder-grid-container\"\n [elderDataContextSelection]=\"dc\"\n #dataSelection=\"elderDataContextSelection\"\n [elderDataContextSelectionModel]=\"selectionModel\"\n >\n <!-- Toolbar Row -->\n @if (toolbarVisible()) {\n <div class=\"layout-row place-start-center flex-none elder-grid-toolbar\">\n @if (selectionVisible) {\n <div class=\"layout-col flex-none px-sm\">\n <elder-selection-master-checkbox class=\"flex-none\"></elder-selection-master-checkbox>\n </div>\n }\n\n <!-- Toolbar -->\n @if (toolbarTemplate) {\n <ng-template\n *ngTemplateOutlet=\"toolbarTemplate; context: { $implicit: this }\"\n ></ng-template>\n }\n\n @if (availableCompositeSorts && availableCompositeSorts.length > 0) {\n <elder-composite-sort\n class=\"flex-none\"\n [availableSorts]=\"availableCompositeSorts\"\n [translationPrefix]=\"sortTranslationPrefix\"\n [elderCompositeSortDc]=\"dc\"\n >\n </elder-composite-sort>\n }\n </div>\n\n <mat-divider></mat-divider>\n }\n\n <elder-data-context-state-indicator class=\"flex-none\" [dataContext]=\"dc\">\n </elder-data-context-state-indicator>\n\n <!-- [cdkDropListSortingDisabled]=\"true\" -->\n <!-- cdkDropList -->\n <cdk-virtual-scroll-viewport\n class=\"layout-col flex elder-grid-browser\"\n id=\"{{ scrollContainerId }}\"\n [itemSize]=\"itemHeight()\"\n [minBufferPx]=\"itemHeight() * 2\"\n [maxBufferPx]=\"itemHeight() * 3\"\n #virtualScrollViewPort\n elderInfiniteScroll\n [eventThrottle]=\"200\"\n [offsetFactor]=\"2\"\n [ignoreScrollEvent]=\"dcStatus()?.loading\"\n [containerId]=\"scrollContainerId\"\n [listenToHost]=\"false\"\n (closeToEnd)=\"requestMoreDataZoned($event)\"\n (elderResizeObserver)=\"containerDimensions$.next($event)\"\n >\n <!-- (scrolling)=\"onScrolling($event)\" -->\n\n <div\n *cdkVirtualFor=\"\n let gridRow of dataRows$;\n trackBy: TrackGridRowByIdFn;\n templateCacheSize: 50\n \"\n class=\"elder-grid-tile-row\"\n [style.height]=\"itemHeight() + 'px'\"\n [style.--elder-grid-column-count]=\"activeColumnCount()\"\n >\n @for (tile of gridRow.cells; track trackCellId($index, tile)) {\n <!-- Tile Cell -->\n @if (isTileVisible(tile)) {\n <elder-tile\n class=\"elder-grid-tile\"\n [value]=\"tile\"\n [selectionEnabled]=\"selectionVisible\"\n [selectionModel]=\"selectionModel\"\n [outlined]=\"tileOutlined()\"\n (click)=\"onItemClick(tile)\"\n (dblclick)=\"onItemDoubleClick(tile)\"\n >\n <ng-container\n *ngTemplateOutlet=\"\n tileTemplate || simpleTileTemplate;\n context: { $implicit: tile }\n \"\n ></ng-container>\n </elder-tile>\n } @else {\n <div class=\"elder-grid-tile-hidden\"></div>\n }\n }\n </div>\n </cdk-virtual-scroll-viewport>\n\n <mat-progress-bar\n class=\"flex-none\"\n [mode]=\"dcStatus()?.loading ? 'indeterminate' : 'determinate'\"\n [color]=\"dcStatus()?.hasError ? 'warn' : 'primary'\"\n >\n </mat-progress-bar>\n\n <!-- Footer -->\n @if (footerVisible()) {\n <div class=\"layout-row place-end-center gap-md flex-none elder-grid-footer\">\n <!-- Continuable -->\n @if (isContinuable) {\n <elder-continuator\n [loadedCount]=\"viewData()?.length\"\n [total]=\"total()\"\n [canLoadMore]=\"canLoadMore()\"\n [chunkSizeOptions]=\"pageSizeOptions()\"\n [chunkSize]=\"currentChunkSize()\"\n (loadMoreRequested)=\"dataSnapshot.loadMore()\"\n ></elder-continuator>\n } @else if (isActivePaged) {\n @if (currentPage(); as page) {\n <mat-paginator\n class=\"flex-none\"\n [length]=\"total()\"\n [pageIndex]=\"page?.index\"\n [pageSize]=\"page?.size\"\n [pageSizeOptions]=\"pageSizeOptions()\"\n >\n </mat-paginator>\n }\n } @else {\n <span class=\"mat-caption noselect pr-md\" style=\"color: var(--md-sys-color-outline)\">\n {{ viewData()?.length }}\n </span>\n }\n </div>\n }\n </div>\n }\n</div>\n\n<ng-template #simpleTileTemplate let-tile>\n @if (tile) {\n <div class=\"layout-col place-center-center flex\" style=\"background-color: lightblue\">\n <p class=\"noselect\">Tile: {{ tile }}</p>\n </div>\n }\n</ng-template>\n", styles: [".elder-grid-tile{width:100%;height:100%;cursor:pointer;overflow:hidden}.elder-grid-tile-row{display:grid;align-items:start;justify-items:start;overflow:hidden;--elder-grid-column-count: 1;padding:8px 16px;grid-template-columns:repeat(var(--elder-grid-column-count),minmax(0,1fr));column-gap:16px}.elder-grid-tile-row:first-child{padding-top:16px}.elder-grid-tile-hidden{flex:0 1 100%;margin:8px;width:100%;height:100%}.elder-grid-container{background-color:var(--elder-grid-background-color)}.elder-grid-flat{border:var(--elder-border-light)}.elder-grid-toolbar{min-height:44px}.elder-grid-footer{min-height:var(--elder-data-element-footer-height)}\n"] }]
@@ -22787,10 +22789,8 @@ class ElderSelectBase extends ElderFormFieldControlBase {
22787
22789
  return this.dataSourceOrThrow().getId(entity);
22788
22790
  }
22789
22791
  catch (e) {
22790
- if (e instanceof Error) {
22791
- throw new Error('Failed to extract id from entity since no dataSource is available! Caused by ' +
22792
- e?.message);
22793
- }
22792
+ const errorMessage = e instanceof Error ? e.message : 'unknown';
22793
+ throw new Error(`Failed to extract id from entity since no dataSource is available! Caused by ${errorMessage}`);
22794
22794
  }
22795
22795
  }
22796
22796
  /***************************************************************************
@@ -29676,6 +29676,7 @@ class ElderLocalDateInputComponent extends ElderFormFieldControlBase {
29676
29676
  }
29677
29677
  catch (err) {
29678
29678
  this.logger.warn('Failed to apply value to dateValue: ' + value, err);
29679
+ return undefined;
29679
29680
  }
29680
29681
  }
29681
29682
  mapIgnoreErrorObservable(date, conversionFn) {
@@ -31622,6 +31623,7 @@ class ElderOverlayComponent {
31622
31623
  if (!this.attached) {
31623
31624
  return this.attachOverlay();
31624
31625
  }
31626
+ return undefined;
31625
31627
  }
31626
31628
  /**
31627
31629
  * Hide this overlay
@@ -37620,7 +37622,7 @@ class ReactiveFetchEventSource {
37620
37622
  */
37621
37623
  streamEventsOfType(eventTypeRaw) {
37622
37624
  const eventType = this.eventTypeOrDefault(eventTypeRaw);
37623
- return this.streamEvents().pipe(filter((e) => e.event == eventType));
37625
+ return this.streamEvents().pipe(filter((e) => e.event === eventType));
37624
37626
  }
37625
37627
  /**
37626
37628
  * Get an event stream for all events no matter their type.
@@ -37699,7 +37701,6 @@ class ReactiveFetchEventSource {
37699
37701
  ', state: ' +
37700
37702
  response.status, response);
37701
37703
  this.updateState(ReactiveEventSourceState.OPEN);
37702
- return; // everything's good
37703
37704
  }
37704
37705
  else if (response.status >= 400 && response.status < 500 && response.status !== 429) {
37705
37706
  // client-side errors are usually non-retriable:
@@ -37711,6 +37712,7 @@ class ReactiveFetchEventSource {
37711
37712
  this.updateState(ReactiveEventSourceState.ERROR);
37712
37713
  this.tryReconnect();
37713
37714
  }
37715
+ return undefined; // TODO: Return a promise?
37714
37716
  }
37715
37717
  handleOnError(err) {
37716
37718
  this.updateState(ReactiveEventSourceState.ERROR);