@dereekb/dbx-web 13.0.2 → 13.0.4

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.
@@ -2,10 +2,10 @@ import * as i0 from '@angular/core';
2
2
  import { Injectable, input, inject, effect, Directive, NgModule, Component, output, computed, HostListener, InjectionToken, signal, ChangeDetectionStrategy, ElementRef, Injector, DestroyRef, viewChild, makeEnvironmentProviders, TemplateRef, model, SecurityContext, forwardRef, ViewContainerRef, Optional, Inject, Renderer2 } from '@angular/core';
3
3
  import { DASH_CHARACTER_PREFIX_INSTANCE, asPromise, cssClassesSet, isDefinedAndNotFalse, spaceSeparatedCssClasses, objectHasNoKeys, getValueFromGetter, firstValue, filterUndefinedValues, separateValues, splitFront, asDecisionFunction, SLASH_PATH_FILE_TYPE_SEPARATOR, filterMaybeArrayValues, mapIterable, toReadableError, isDefaultReadableError, MS_IN_SECOND, mergeObjects, build, ServerErrorResponse, UnauthorizedServerErrorResponse, makeTimer, MS_IN_MINUTE, toggleTimerRunning, unixDateTimeSecondsNumberForNow, ModelRelationUtility, encodeModelKeyTypePair, useIterableOrValue, safeCompareEquality, addMilliseconds, isPast, asArray, slashPathDetails, mimeTypeForFileExtension, slashPathDirectoryTree, isMaybeNot, isNotFalse, modifier, combineMaps, addModifiers, removeModifiers, applyBestFit, findNext, maybeModifierMapToFunction, makeValuesGroupMap, compareWithMappedValuesFunction, invertMaybeBoolean, splitCommaSeparatedStringToSet, ZIP_FILE_MIME_TYPE, cachedGetter, sortByNumberFunction } from '@dereekb/util';
4
4
  import * as i1$2 from '@dereekb/dbx-core';
5
- import { completeOnDestroy, clean, cleanSubscription, AbstractTransitionWatcherDirective, DbxInjectionComponent, AbstractDbxActionValueGetterDirective, AbstractDbxButtonDirective, provideDbxButton, dbxActionWorkProgress, DbxCoreButtonModule, AbstractDbxActionHandlerDirective, FilterSourceDirective, provideActionStoreSource, isClickableFilterPreset, AbstractDbxAnchorDirective, expandClickableAnchorLinkTrees, DbxCoreFilterModule, DbxButton, DbxActionContextStoreSourceInstance, DBX_INJECTION_COMPONENT_DATA, checkNgContentWrapperHasContent, cleanLoadingContext, DbxActionSourceDirective, DbxActionSuccessHandlerDirective, DbxActionDirective, transformEmptyStringInputToUndefined, isIdleActionState, canTriggerAction, DbxCoreActionModule, DbxActionButtonDirective, onDbxAppAuth, SimpleStorageAccessorFactory, mergeStaticProviders, asSegueRef, AbstractTransitionDirective, DbxRouterService, AbstractIfDirective, isSegueRefActive, anchorTypeForAnchor } from '@dereekb/dbx-core';
5
+ import { completeOnDestroy, clean, cleanSubscription, AbstractTransitionWatcherDirective, DbxInjectionComponent, AbstractDbxActionValueGetterDirective, AbstractDbxButtonDirective, provideDbxButton, dbxActionWorkProgress, DbxCoreButtonModule, AbstractDbxActionHandlerDirective, FilterSourceDirective, provideActionStoreSource, isClickableFilterPreset, AbstractDbxAnchorDirective, expandClickableAnchorLinkTrees, DbxCoreFilterModule, DbxButton, DbxActionContextStoreSourceInstance, cleanSubscriptionWithLockSet, DBX_INJECTION_COMPONENT_DATA, checkNgContentWrapperHasContent, cleanLoadingContext, DbxActionSourceDirective, DbxActionSuccessHandlerDirective, DbxActionDirective, transformEmptyStringInputToUndefined, isIdleActionState, canTriggerAction, DbxCoreActionModule, DbxActionButtonDirective, onDbxAppAuth, SimpleStorageAccessorFactory, mergeStaticProviders, asSegueRef, AbstractTransitionDirective, DbxRouterService, AbstractIfDirective, isSegueRefActive, anchorTypeForAnchor } from '@dereekb/dbx-core';
6
6
  import { NgPopoverRef, NgOverlayContainerService } from 'ng-overlay-container';
7
7
  import { of, map, BehaviorSubject, distinctUntilChanged, shareReplay, delay, switchMap, combineLatest, Subject, first, startWith, filter, throttleTime, skip, defaultIfEmpty, delayWhen, timer, asyncScheduler, from, firstValueFrom, mergeMap, race, tap, catchError, distinct, merge, exhaustMap } from 'rxjs';
8
- import { filterMaybe, asObservable, LockSet, distinctUntilItemsHaveDifferentValues, skipAllInitialMaybe, maybeValueFromObservableOrValue, switchMapMaybeLoadingContextStream, LoadingStateType, loadingStateType, SubscriptionObject, successResult, valueFromFinishedLoadingState, loadingStateContext, initialize, isNot, mapForEach, switchMapMaybe, listLoadingStateContext, isLoadingStateFinishedLoading, startWithBeginLoading, loadingStateFromObs, errorResult, beginLoading, distinctUntilHasDifferentValues } from '@dereekb/rxjs';
8
+ import { filterMaybe, asObservable, LockSet, distinctUntilItemsHaveDifferentValues, skipAllInitialMaybe, maybeValueFromObservableOrValue, switchMapMaybeLoadingContextStream, LoadingStateType, loadingStateType, successResult, valueFromFinishedLoadingState, loadingStateContext, initialize, isNot, mapForEach, SubscriptionObject, switchMapMaybe, listLoadingStateContext, isLoadingStateFinishedLoading, startWithBeginLoading, loadingStateFromObs, errorResult, beginLoading, distinctUntilHasDifferentValues } from '@dereekb/rxjs';
9
9
  import { isBoolean } from 'class-validator';
10
10
  import { ComponentStore } from '@ngrx/component-store';
11
11
  import { toSignal, toObservable } from '@angular/core/rxjs-interop';
@@ -4117,12 +4117,18 @@ class DbxFileUploadActionSyncDirective {
4117
4117
  source = inject(DbxActionContextStoreSourceInstance);
4118
4118
  uploadCompatable = inject(DbxFileUploadActionCompatable);
4119
4119
  constructor() {
4120
- cleanSubscription(this.source.isWorkingOrWorkProgress$.subscribe((working) => {
4121
- this.uploadCompatable.setWorking(working);
4122
- }));
4123
- cleanSubscription(this.source.isDisabled$.subscribe((disabled) => {
4124
- this.uploadCompatable.setDisabled(disabled);
4125
- }));
4120
+ cleanSubscriptionWithLockSet({
4121
+ lockSet: this.source.lockSet,
4122
+ sub: this.source.isWorkingOrWorkProgress$.subscribe((working) => {
4123
+ this.uploadCompatable.setWorking(working);
4124
+ })
4125
+ });
4126
+ cleanSubscriptionWithLockSet({
4127
+ lockSet: this.source.lockSet,
4128
+ sub: this.source.isDisabled$.subscribe((disabled) => {
4129
+ this.uploadCompatable.setDisabled(disabled);
4130
+ })
4131
+ });
4126
4132
  }
4127
4133
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: DbxFileUploadActionSyncDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
4128
4134
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.0", type: DbxFileUploadActionSyncDirective, isStandalone: true, selector: "[dbxFileUploadActionSync]", ngImport: i0 });
@@ -5105,7 +5111,7 @@ class DbxActionSnackbarDirective {
5105
5111
  dbxActionSnackbarDefault = input(...(ngDevMode ? [undefined, { debugName: "dbxActionSnackbarDefault" }] : []));
5106
5112
  dbxActionSnackbarUndo = input(...(ngDevMode ? [undefined, { debugName: "dbxActionSnackbarUndo" }] : []));
5107
5113
  dbxActionSnackbar = input(undefined, { ...(ngDevMode ? { debugName: "dbxActionSnackbar" } : {}), transform: transformEmptyStringInputToUndefined });
5108
- _sub = cleanSubscription();
5114
+ _sub = cleanSubscriptionWithLockSet({ lockSet: this.source.lockSet });
5109
5115
  ngOnInit() {
5110
5116
  this._sub.setSub(this.source
5111
5117
  .pipeStore((store) => store.loadingState$)
@@ -5354,15 +5360,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
5354
5360
  class DbxActionConfirmDirective extends AbstractPromptConfirmDirective {
5355
5361
  source = inject((DbxActionContextStoreSourceInstance), { host: true });
5356
5362
  dbxActionConfirm = input(undefined, { ...(ngDevMode ? { debugName: "dbxActionConfirm" } : {}), transform: transformEmptyStringInputToUndefined });
5357
- _sourceSub = new SubscriptionObject();
5358
- ngOnInit() {
5359
- this._sourceSub.subscription = this.source.triggered$.subscribe(() => {
5360
- this.showDialog();
5363
+ constructor() {
5364
+ super();
5365
+ cleanSubscriptionWithLockSet({
5366
+ lockSet: this.source.lockSet,
5367
+ sub: this.source.triggered$.subscribe(() => {
5368
+ this.showDialog();
5369
+ })
5361
5370
  });
5362
5371
  }
5363
- ngOnDestroy() {
5364
- this._sourceSub.destroy();
5365
- }
5366
5372
  getDefaultDialogConfig() {
5367
5373
  return this.dbxActionConfirm();
5368
5374
  }
@@ -5375,7 +5381,7 @@ class DbxActionConfirmDirective extends AbstractPromptConfirmDirective {
5375
5381
  }
5376
5382
  return result;
5377
5383
  }
5378
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: DbxActionConfirmDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
5384
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: DbxActionConfirmDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
5379
5385
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.0", type: DbxActionConfirmDirective, isStandalone: true, selector: "[dbxActionConfirm]", inputs: { dbxActionConfirm: { classPropertyName: "dbxActionConfirm", publicName: "dbxActionConfirm", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0 });
5380
5386
  }
5381
5387
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: DbxActionConfirmDirective, decorators: [{
@@ -5384,7 +5390,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
5384
5390
  selector: '[dbxActionConfirm]',
5385
5391
  standalone: true
5386
5392
  }]
5387
- }], propDecorators: { dbxActionConfirm: [{ type: i0.Input, args: [{ isSignal: true, alias: "dbxActionConfirm", required: false }] }] } });
5393
+ }], ctorParameters: () => [], propDecorators: { dbxActionConfirm: [{ type: i0.Input, args: [{ isSignal: true, alias: "dbxActionConfirm", required: false }] }] } });
5388
5394
 
5389
5395
  const DEFAULT_ACTION_KEY_TRIGGER = 'enter';
5390
5396
  /**
@@ -5619,12 +5625,15 @@ class DbxActionSnackbarErrorDirective {
5619
5625
  source = inject(DbxActionContextStoreSourceInstance);
5620
5626
  config = input(undefined, { ...(ngDevMode ? { debugName: "config" } : {}), alias: 'dbxActionSnackbarError' });
5621
5627
  constructor() {
5622
- cleanSubscription(this.source.error$.pipe(filterMaybe()).subscribe((inputError) => {
5623
- const config = this.config();
5624
- const error = toReadableError(inputError);
5625
- const snackbarConfig = config ? (typeof config === 'number' ? { duration: config } : config) : undefined;
5626
- this.dbxErrorSnackbarService.showSnackbarError(error, snackbarConfig);
5627
- }));
5628
+ cleanSubscriptionWithLockSet({
5629
+ lockSet: this.source.lockSet,
5630
+ sub: this.source.error$.pipe(filterMaybe()).subscribe((inputError) => {
5631
+ const config = this.config();
5632
+ const error = toReadableError(inputError);
5633
+ const snackbarConfig = config ? (typeof config === 'number' ? { duration: config } : config) : undefined;
5634
+ this.dbxErrorSnackbarService.showSnackbarError(error, snackbarConfig);
5635
+ })
5636
+ });
5628
5637
  }
5629
5638
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: DbxActionSnackbarErrorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
5630
5639
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.0", type: DbxActionSnackbarErrorDirective, isStandalone: true, selector: "[dbxActionSnackbarError]", inputs: { config: { classPropertyName: "config", publicName: "dbxActionSnackbarError", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
@@ -7826,6 +7835,7 @@ var SideNavDisplayMode;
7826
7835
  * Navigation component that sits at the side of an app.
7827
7836
  */
7828
7837
  class DbxSidenavComponent extends AbstractTransitionWatcherDirective {
7838
+ _sidenavSub = cleanSubscription();
7829
7839
  _screenMediaService = inject(DbxScreenMediaService);
7830
7840
  color = input(undefined, ...(ngDevMode ? [{ debugName: "color" }] : []));
7831
7841
  sidenav = viewChild.required(MatSidenav);
@@ -7850,10 +7860,9 @@ class DbxSidenavComponent extends AbstractTransitionWatcherDirective {
7850
7860
  modeSignal = toSignal(this.mode$);
7851
7861
  disableBackdropSignal = computed(() => this.modeSignal() !== SideNavDisplayMode.MOBILE, ...(ngDevMode ? [{ debugName: "disableBackdropSignal" }] : []));
7852
7862
  sizeCssClassSignal = computed(() => `dbx-sidenav-${this.modeSignal()}`, ...(ngDevMode ? [{ debugName: "sizeCssClassSignal" }] : []));
7853
- stateSignal = computed(() => {
7854
- const mode = this.modeSignal();
7863
+ state$ = this.mode$.pipe(map((mode) => {
7855
7864
  let drawer = 'over';
7856
- let open = false;
7865
+ let open = true;
7857
7866
  switch (mode) {
7858
7867
  case SideNavDisplayMode.MOBILE:
7859
7868
  drawer = 'over';
@@ -7862,7 +7871,7 @@ class DbxSidenavComponent extends AbstractTransitionWatcherDirective {
7862
7871
  case SideNavDisplayMode.ICON:
7863
7872
  case SideNavDisplayMode.FULL:
7864
7873
  drawer = 'side';
7865
- open = true;
7874
+ open = true; // always show
7866
7875
  break;
7867
7876
  }
7868
7877
  return {
@@ -7870,14 +7879,17 @@ class DbxSidenavComponent extends AbstractTransitionWatcherDirective {
7870
7879
  drawer,
7871
7880
  open
7872
7881
  };
7873
- }, ...(ngDevMode ? [{ debugName: "stateSignal" }] : []));
7874
- drawerSignal = computed(() => this.stateSignal().drawer, ...(ngDevMode ? [{ debugName: "drawerSignal" }] : []));
7875
- _stateSignalToggleEffect = effect(() => {
7876
- const state = this.stateSignal();
7877
- if (state.open != null) {
7878
- this._toggleNav(state.open, true);
7879
- }
7880
- }, ...(ngDevMode ? [{ debugName: "_stateSignalToggleEffect" }] : []));
7882
+ }), distinctUntilChanged((a, b) => a.mode === b.mode && a.drawer === b.drawer && a.open === b.open), shareReplay(1));
7883
+ stateSignal = toSignal(this.state$);
7884
+ drawerSignal = computed(() => this.stateSignal()?.drawer ?? 'over', ...(ngDevMode ? [{ debugName: "drawerSignal" }] : []));
7885
+ ngOnInit() {
7886
+ // wait until the child sidenav has initialized
7887
+ this._sidenavSub.setSub(this.state$.subscribe((state) => {
7888
+ if (state?.open != null) {
7889
+ this._toggleNav(state.open, true);
7890
+ }
7891
+ }));
7892
+ }
7881
7893
  updateForSuccessfulTransition() {
7882
7894
  this.closeNav();
7883
7895
  }
@@ -7889,7 +7901,7 @@ class DbxSidenavComponent extends AbstractTransitionWatcherDirective {
7889
7901
  }
7890
7902
  _toggleNav(toggleOpen, forced = false) {
7891
7903
  toggleOpen = toggleOpen ?? !this.sidenav().opened;
7892
- const mode = this.stateSignal().mode;
7904
+ const mode = this.stateSignal()?.mode;
7893
7905
  let open;
7894
7906
  if (!forced) {
7895
7907
  switch (mode) {