@dereekb/dbx-core 8.1.0 → 8.2.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.
@@ -3,9 +3,9 @@ import { Directive, Injectable, forwardRef, Host, Input, Optional, NgModule, Inj
3
3
  import * as i1 from 'rxjs';
4
4
  import { switchMap, first, BehaviorSubject, combineLatest, distinctUntilChanged, filter, Subject, debounce, interval, throttle, exhaustMap, mergeMap, map, shareReplay, EMPTY, withLatestFrom, of, startWith, tap, delay, catchError, firstValueFrom, takeUntil, Observable } from 'rxjs';
5
5
  import * as i1$5 from '@dereekb/rxjs';
6
- import { SubscriptionObject, LockSet, filterMaybe, LoadingStateType, beginLoading, idleLoadingState, errorResult, successResult, scanCount, combineLatestFromMapValuesObsFn, workFactory, emitDelayObs, asObservable, returnIfIs, skipFirstMaybe, onFalseToTrue, onTrueToFalse, setContainsAllValuesFrom, FilterSourceInstance, FilterSource, FilterSourceConnector, FilterMap } from '@dereekb/rxjs';
6
+ import { SubscriptionObject, LockSet, filterMaybe, LoadingStateType, beginLoading, idleLoadingState, errorResult, successResult, scanCount, combineLatestFromMapValuesObsFn, workFactory, emitDelayObs, asObservable, returnIfIs, skipFirstMaybe, maybeValueFromObservableOrValueGetter, switchMapToDefault, onFalseToTrue, onTrueToFalse, setContainsAllValuesFrom, FilterSourceInstance, FilterSource, FilterSourceConnector, FilterMap } from '@dereekb/rxjs';
7
7
  import * as i1$6 from '@dereekb/util';
8
- import { isDefinedAndNotFalse, hasValueOrNotEmpty, BooleanStringKeyArrayUtilityInstance, reduceBooleansWithOrFn, getValueFromGetter, toReadableError, isGetter, setIncludes, maybeSet, isAllowed, expandTreeFunction, flattenTreeToArrayFunction, expandFlattenTreeFunction, mergeArrays, filterMaybeValues, mergeObjects, mergeArrayOrValueIntoArray, promiseReference, DataIsExpiredError, DataDoesNotExistError, hasNonNullValue, StorageObjectUtility, SHARED_MEMORY_STORAGE } from '@dereekb/util';
8
+ import { isDefinedAndNotFalse, hasValueOrNotEmpty, BooleanStringKeyArrayUtilityInstance, reduceBooleansWithOrFn, getValueFromGetter, toReadableError, isGetter, setIncludes, maybeSet, isAllowed, expandTreeFunction, flattenTreeToArrayFunction, expandFlattenTreeFunction, mergeObjects, KeyValueTypleValueFilter, defaultForwardFunctionFactory, mergeArrays, filterMaybeValues, mergeArrayOrValueIntoArray, promiseReference, DataIsExpiredError, DataDoesNotExistError, hasNonNullValue, StorageObjectUtility, SHARED_MEMORY_STORAGE } from '@dereekb/util';
9
9
  import { ComponentStore } from '@ngrx/component-store';
10
10
  import { CommonModule, formatDate } from '@angular/common';
11
11
  import * as i1$3 from '@ngrx/effects';
@@ -2239,19 +2239,36 @@ class DbxAngularRouterService {
2239
2239
  }), filterMaybe());
2240
2240
  }
2241
2241
  go(input) {
2242
- const segueRef = asSegueRef(input);
2243
- const ref = segueRef.ref;
2244
- if (isArray(ref)) {
2245
- return this.router.navigate(ref, {
2246
- ...segueRef.refOptions,
2247
- queryParams: segueRef.refParams
2248
- });
2249
- }
2250
- else {
2251
- return this.router.navigateByUrl(ref, {
2252
- ...segueRef.refOptions
2253
- });
2254
- }
2242
+ const inputObs = asObservable(input);
2243
+ return firstValueFrom(inputObs).then((inputSegueRef) => {
2244
+ const segueRef = asSegueRef(inputSegueRef);
2245
+ const ref = segueRef.ref;
2246
+ if (isArray(ref)) {
2247
+ return this.router.navigate(ref, {
2248
+ ...segueRef.refOptions,
2249
+ queryParams: segueRef.refParams
2250
+ });
2251
+ }
2252
+ else {
2253
+ return this.router.navigateByUrl(ref, {
2254
+ ...segueRef.refOptions
2255
+ });
2256
+ }
2257
+ });
2258
+ }
2259
+ updateParams(inputParams) {
2260
+ const segueUpdate = combineLatest([this.activatedRoute.params, asObservable(inputParams)]).pipe(map$1(([currentParams, params]) => {
2261
+ const refParams = mergeObjects([currentParams, params], KeyValueTypleValueFilter.UNDEFINED);
2262
+ const segueRef = {
2263
+ ref: this.activatedRoute.pathFromRoot,
2264
+ refParams,
2265
+ refOptions: {
2266
+ replaceUrl: true
2267
+ }
2268
+ };
2269
+ return segueRef;
2270
+ }));
2271
+ return this.go(segueUpdate);
2255
2272
  }
2256
2273
  isActive(segueRef) {
2257
2274
  return false; // TODO!
@@ -2348,12 +2365,31 @@ class DbxUIRouterService {
2348
2365
  return this.uiRouterGlobals.params;
2349
2366
  }
2350
2367
  go(input) {
2351
- const segueRef = asSegueRef(input);
2352
- const params = { ...this.uiRouterGlobals.current.params, ...segueRef.refParams };
2353
- return this.state
2354
- .go(segueRef.ref, params, segueRef.refOptions)
2355
- .then(() => true)
2356
- .catch(() => false);
2368
+ const inputObs = asObservable(input);
2369
+ return firstValueFrom(inputObs).then((inputSegueRef) => {
2370
+ const segueRef = asSegueRef(inputSegueRef);
2371
+ const params = { ...this.uiRouterGlobals.current.params, ...segueRef.refParams };
2372
+ return this.state
2373
+ .go(segueRef.ref, params, segueRef.refOptions)
2374
+ .then(() => true)
2375
+ .catch(() => false);
2376
+ });
2377
+ }
2378
+ updateParams(inputParams) {
2379
+ const segueUpdate = asObservable(inputParams).pipe(map((params) => {
2380
+ const currentParams = this.uiRouterGlobals.params;
2381
+ const refParams = mergeObjects([currentParams, params], KeyValueTypleValueFilter.UNDEFINED);
2382
+ const ref = {
2383
+ ref: '.',
2384
+ refParams,
2385
+ refOptions: {
2386
+ location: 'replace',
2387
+ inherit: true
2388
+ }
2389
+ };
2390
+ return ref;
2391
+ }));
2392
+ return this.go(segueUpdate);
2357
2393
  }
2358
2394
  isActive(input) {
2359
2395
  const segueRef = asSegueRef(input);
@@ -2463,6 +2499,97 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
2463
2499
  type: Directive
2464
2500
  }], ctorParameters: function () { return [{ type: DbxRouterTransitionService }, { type: i0.NgZone }]; } });
2465
2501
 
2502
+ /**
2503
+ * Utility class used for reading a single value from the DbxRouterService.
2504
+ */
2505
+ class DbxRouteParamReaderInstance {
2506
+ constructor(dbxRouterService, defaultParamKey, defaultValue) {
2507
+ this.dbxRouterService = dbxRouterService;
2508
+ this.defaultParamKey = defaultParamKey;
2509
+ this.defaultValue = defaultValue;
2510
+ this._paramKey = new BehaviorSubject(this.defaultParamKey);
2511
+ this.paramKey$ = this._paramKey.asObservable();
2512
+ this._defaultValue = new BehaviorSubject(this.defaultValue);
2513
+ this.paramValue$ = combineLatest([this.paramKey$, this.dbxRouterService.params$]).pipe(map(([key, params]) => {
2514
+ return params[key] ?? undefined;
2515
+ }), distinctUntilChanged(), shareReplay(1));
2516
+ this.nextDefaultValue$ = this._defaultValue.pipe(maybeValueFromObservableOrValueGetter(), shareReplay(1));
2517
+ this.defaultValue$ = this._defaultValue.pipe(maybeValueFromObservableOrValueGetter(), shareReplay(1));
2518
+ this.value$ = this.paramValue$.pipe(switchMapToDefault(this.defaultValue$), shareReplay(1));
2519
+ }
2520
+ destroy() {
2521
+ this._paramKey.complete();
2522
+ }
2523
+ get paramKey() {
2524
+ return this._paramKey.value;
2525
+ }
2526
+ set paramKey(paramKey) {
2527
+ this._paramKey.next(paramKey || this.defaultParamKey);
2528
+ }
2529
+ setDefaultValue(defaultValue) {
2530
+ this._defaultValue.next(defaultValue ?? this.defaultValue);
2531
+ }
2532
+ }
2533
+
2534
+ const DEFAULT_REDIRECT_INSTANCE_FORWARD_FACTORY = defaultForwardFunctionFactory((value) => of(value == null));
2535
+ /**
2536
+ * Utility class used in conjuction with a DbxRouteParamReaderInstance to redirect when the default param does not equal the
2537
+ */
2538
+ class DbxRouteParamDefaultRedirectInstance {
2539
+ constructor(instance) {
2540
+ this.instance = instance;
2541
+ this._enabled = new BehaviorSubject(true);
2542
+ this._useDefaultFilter = new BehaviorSubject(undefined);
2543
+ this._sub = new SubscriptionObject();
2544
+ }
2545
+ init() {
2546
+ this._sub.subscription = this._enabled
2547
+ .pipe(switchMap((enabled) => {
2548
+ if (enabled) {
2549
+ return this.instance.paramValue$.pipe(switchMapToDefault(this.instance.defaultValue$, (value) => {
2550
+ return this._useDefaultFilter.pipe(switchMap((fn) => DEFAULT_REDIRECT_INSTANCE_FORWARD_FACTORY(fn)(value)));
2551
+ }), filterMaybe(), // do not redirect on MaybeNot values
2552
+ switchMap((defaultValue) => {
2553
+ return this.redirectWithDefaultValue(defaultValue);
2554
+ }));
2555
+ }
2556
+ else {
2557
+ return EMPTY;
2558
+ }
2559
+ }))
2560
+ .subscribe();
2561
+ }
2562
+ destroy() {
2563
+ this._enabled.complete();
2564
+ this._useDefaultFilter.complete();
2565
+ this._sub.destroy();
2566
+ }
2567
+ redirectWithDefaultValue(value) {
2568
+ if (value != null) {
2569
+ // perform a segue once
2570
+ return this.redirectWithValue(value);
2571
+ }
2572
+ else {
2573
+ // do nothing
2574
+ return Promise.resolve(false);
2575
+ }
2576
+ }
2577
+ redirectWithValue(value) {
2578
+ return this.instance.dbxRouterService.updateParams({
2579
+ [this.instance.paramKey]: value
2580
+ });
2581
+ }
2582
+ get enabled() {
2583
+ return this._enabled.value;
2584
+ }
2585
+ set enabled(enabled) {
2586
+ this._enabled.next(enabled);
2587
+ }
2588
+ setUseDefaultFilter(useValueFilter) {
2589
+ this._useDefaultFilter.next(useValueFilter);
2590
+ }
2591
+ }
2592
+
2466
2593
  /**
2467
2594
  * Auth routes configurations for an app.
2468
2595
  */
@@ -4481,5 +4608,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
4481
4608
  * Generated bundle index. Do not edit.
4482
4609
  */
4483
4610
 
4484
- export { APP_ACTION_DISABLED_DIRECTIVE_KEY, APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY, AbstractActionFilterSourceDirective, AbstractDbxActionValueOnTriggerDirective, AbstractDbxAnchorDirective, AbstractDbxButtonDirective, AbstractDbxFilterMapInstanceDirective, AbstractDbxInjectionDirective, AbstractFilterSourceConnectorDirective, AbstractFilterSourceDirective, AbstractForwardDbxInjectionContextDirective, AbstractIfDirective, AbstractLockSetSubscriptionDirective, AbstractSubscriptionDirective, AbstractTransitionDirective, AbstractTransitionWatcherDirective, ActionContextStore, ActionContextStoreSource, ActionContextStoreSourceMap, AnchorType, DBX_APP_APP_CONTEXT_STATE, DBX_APP_AUTH_ROUTER_EFFECTS_TOKEN, DBX_AUTH_APP_CONTEXT_STATE, DBX_INIT_APP_CONTEXT_STATE, DBX_INJECTION_COMPONENT_DATA, DBX_KNOWN_APP_CONTEXT_STATES, DBX_ONBOARDING_APP_CONTEXT_STATE, DBX_PUBLIC_APP_CONTEXT_STATE, DEFAULT_ACTION_DISABLED_KEY, DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY, DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN, DEFAULT_STORAGE_OBJECT_TOKEN, DateDistancePipe, DateFormatDistancePipe, DateFromToTimePipe, DbxActionAutoModifyDirective, DbxActionAutoTriggerDirective, DbxActionButtonDirective, DbxActionButtonTriggerDirective, DbxActionContextBaseSource, DbxActionContextLoggerDirective, DbxActionContextMachine, DbxActionContextMapDirective, DbxActionContextMapDirectiveSourceInstance, DbxActionContextStoreSourceInstance, DbxActionDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective, DbxActionFromMapDirective, DbxActionHandlerDirective, DbxActionHasSuccessDirective, DbxActionIsWorkingDirective, DbxActionMapSourceDirective, DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionState, DbxActionSuccessHandlerDirective, DbxActionValueDirective, DbxActionValueOnTriggerInstance, DbxActionValueTriggerDirective, DbxActionWorkInstanceDelegate, DbxAnchor, DbxAngularRouterService, DbxAppAuthRouterEffects, DbxAppAuthRouterModule, DbxAppAuthRouterService, DbxAppAuthRouterStateModule, DbxAppAuthRoutes, DbxAppAuthStateModule, DbxAppAuthStateService, DbxAppContextService, DbxAppContextStateDirective, DbxAppContextStateModule, DbxAuthHasAnyRoleDirective, DbxAuthHasRolesDirective, DbxAuthService, DbxButton, DbxButtonDirective, DbxButtonSegueDirective, DbxCoreActionModule, DbxCoreAngularRouterSegueModule, DbxCoreAuthModule, DbxCoreButtonModule, DbxCoreFilterModule, DbxCoreUIRouterSegueModule, DbxDatePipeModule, DbxFilterMapDirective, DbxFilterMapSourceConnectorDirective, DbxFilterMapSourceDirective, DbxFilterSourceConnectorDirective, DbxFilterSourceDirective, DbxInjectionComponent, DbxInjectionComponentModule, DbxInjectionContext, DbxInjectionContextDirective, DbxInjectionInstance, DbxLoadingButtonDirective, DbxMiscPipeModule, DbxPipesModule, DbxRouterService, DbxRouterTransitionEventType, DbxRouterTransitionService, DbxStorageModule, DbxUIRouterService, FullLocalStorageObject, InstantStorageAccessor, LimitedStorageAccessor, LockSetComponentStore, MemoryStorageObject, MinutesStringPipe, NO_AUTH_USER_IDENTIFIER, PrettyJsonPipe, SecondaryActionContextStoreSource, SimpleStorageAccessor, SimpleStorageAccessorFactory, StorageAccessor, StringStorageAccessor, StringifySimpleStorageAccessorConverter, TimeDistanceCountdownPipe, TimeDistancePipe, ToJsDatePipe, ToMinutesPipe, WrapperSimpleStorageAccessorDelegate, actionContextHasNoErrorAndIsModifiedAndCanTrigger, actionContextIsModifiedAndCanTrigger, actionContextStoreSourceInstanceFactory, actionContextStoreSourcePipe, anchorTypeForAnchor, asSegueRef, asSegueRefString, authRolesSetContainsAllRolesFrom, authRolesSetContainsAnyRoleFrom, authUserIdentifier, canReadyValue, canTriggerAction, canTriggerActionState, checkNgContentWrapperHasContent, dbxActionValueStreamDirective, defaultStorageObjectFactory, enableHasAuthRoleHook, enableHasAuthStateHook, enableIsLoggedInHook, expandClickableAnchorLinkTree, expandClickableAnchorLinkTreeNode, expandClickableAnchorLinkTrees, filterTransitionEvent, filterTransitionSuccess, flattenExpandedClickableAnchorLinkTree, flattenExpandedClickableAnchorLinkTreeToLinks, index as fromDbxAppAuth, index$2 as fromDbxAppContext, goWithRouter, isActionContextDisabled, isActionContextEnabled, isDisabledActionContextState, isIdleActionState, isSegueRef, isWorkingActionState, loadingStateForActionContextState, loadingStateTypeForActionContextState, loadingStateTypeForActionState, loggedInObsFromIsLoggedIn, loggedOutObsFromIsLoggedIn, makeAuthTransitionHook, makeDbxActionContextSourceReference, mapRefStringObsToSegueRefObs, mergeDbxInjectionComponentConfigs, index$1 as onDbxAppAuth, index$3 as onDbxAppContext, pipeActionStore, provideActionStoreSource, provideDbxAnchor, provideDbxButton, provideDbxInjectionContext, provideFilterSource, provideFilterSourceConnector, provideSecondaryActionStoreSource, redirectBasedOnAuthUserState, refStringToSegueRef, safeDetectChanges, safeMarkForCheck, safeUseCdRef, successTransition, tapDetectChanges, useActionStore };
4611
+ export { APP_ACTION_DISABLED_DIRECTIVE_KEY, APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY, AbstractActionFilterSourceDirective, AbstractDbxActionValueOnTriggerDirective, AbstractDbxAnchorDirective, AbstractDbxButtonDirective, AbstractDbxFilterMapInstanceDirective, AbstractDbxInjectionDirective, AbstractFilterSourceConnectorDirective, AbstractFilterSourceDirective, AbstractForwardDbxInjectionContextDirective, AbstractIfDirective, AbstractLockSetSubscriptionDirective, AbstractSubscriptionDirective, AbstractTransitionDirective, AbstractTransitionWatcherDirective, ActionContextStore, ActionContextStoreSource, ActionContextStoreSourceMap, AnchorType, DBX_APP_APP_CONTEXT_STATE, DBX_APP_AUTH_ROUTER_EFFECTS_TOKEN, DBX_AUTH_APP_CONTEXT_STATE, DBX_INIT_APP_CONTEXT_STATE, DBX_INJECTION_COMPONENT_DATA, DBX_KNOWN_APP_CONTEXT_STATES, DBX_ONBOARDING_APP_CONTEXT_STATE, DBX_PUBLIC_APP_CONTEXT_STATE, DEFAULT_ACTION_DISABLED_KEY, DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY, DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN, DEFAULT_STORAGE_OBJECT_TOKEN, DateDistancePipe, DateFormatDistancePipe, DateFromToTimePipe, DbxActionAutoModifyDirective, DbxActionAutoTriggerDirective, DbxActionButtonDirective, DbxActionButtonTriggerDirective, DbxActionContextBaseSource, DbxActionContextLoggerDirective, DbxActionContextMachine, DbxActionContextMapDirective, DbxActionContextMapDirectiveSourceInstance, DbxActionContextStoreSourceInstance, DbxActionDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective, DbxActionFromMapDirective, DbxActionHandlerDirective, DbxActionHasSuccessDirective, DbxActionIsWorkingDirective, DbxActionMapSourceDirective, DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionState, DbxActionSuccessHandlerDirective, DbxActionValueDirective, DbxActionValueOnTriggerInstance, DbxActionValueTriggerDirective, DbxActionWorkInstanceDelegate, DbxAnchor, DbxAngularRouterService, DbxAppAuthRouterEffects, DbxAppAuthRouterModule, DbxAppAuthRouterService, DbxAppAuthRouterStateModule, DbxAppAuthRoutes, DbxAppAuthStateModule, DbxAppAuthStateService, DbxAppContextService, DbxAppContextStateDirective, DbxAppContextStateModule, DbxAuthHasAnyRoleDirective, DbxAuthHasRolesDirective, DbxAuthService, DbxButton, DbxButtonDirective, DbxButtonSegueDirective, DbxCoreActionModule, DbxCoreAngularRouterSegueModule, DbxCoreAuthModule, DbxCoreButtonModule, DbxCoreFilterModule, DbxCoreUIRouterSegueModule, DbxDatePipeModule, DbxFilterMapDirective, DbxFilterMapSourceConnectorDirective, DbxFilterMapSourceDirective, DbxFilterSourceConnectorDirective, DbxFilterSourceDirective, DbxInjectionComponent, DbxInjectionComponentModule, DbxInjectionContext, DbxInjectionContextDirective, DbxInjectionInstance, DbxLoadingButtonDirective, DbxMiscPipeModule, DbxPipesModule, DbxRouteParamDefaultRedirectInstance, DbxRouteParamReaderInstance, DbxRouterService, DbxRouterTransitionEventType, DbxRouterTransitionService, DbxStorageModule, DbxUIRouterService, FullLocalStorageObject, InstantStorageAccessor, LimitedStorageAccessor, LockSetComponentStore, MemoryStorageObject, MinutesStringPipe, NO_AUTH_USER_IDENTIFIER, PrettyJsonPipe, SecondaryActionContextStoreSource, SimpleStorageAccessor, SimpleStorageAccessorFactory, StorageAccessor, StringStorageAccessor, StringifySimpleStorageAccessorConverter, TimeDistanceCountdownPipe, TimeDistancePipe, ToJsDatePipe, ToMinutesPipe, WrapperSimpleStorageAccessorDelegate, actionContextHasNoErrorAndIsModifiedAndCanTrigger, actionContextIsModifiedAndCanTrigger, actionContextStoreSourceInstanceFactory, actionContextStoreSourcePipe, anchorTypeForAnchor, asSegueRef, asSegueRefString, authRolesSetContainsAllRolesFrom, authRolesSetContainsAnyRoleFrom, authUserIdentifier, canReadyValue, canTriggerAction, canTriggerActionState, checkNgContentWrapperHasContent, dbxActionValueStreamDirective, defaultStorageObjectFactory, enableHasAuthRoleHook, enableHasAuthStateHook, enableIsLoggedInHook, expandClickableAnchorLinkTree, expandClickableAnchorLinkTreeNode, expandClickableAnchorLinkTrees, filterTransitionEvent, filterTransitionSuccess, flattenExpandedClickableAnchorLinkTree, flattenExpandedClickableAnchorLinkTreeToLinks, index as fromDbxAppAuth, index$2 as fromDbxAppContext, goWithRouter, isActionContextDisabled, isActionContextEnabled, isDisabledActionContextState, isIdleActionState, isSegueRef, isWorkingActionState, loadingStateForActionContextState, loadingStateTypeForActionContextState, loadingStateTypeForActionState, loggedInObsFromIsLoggedIn, loggedOutObsFromIsLoggedIn, makeAuthTransitionHook, makeDbxActionContextSourceReference, mapRefStringObsToSegueRefObs, mergeDbxInjectionComponentConfigs, index$1 as onDbxAppAuth, index$3 as onDbxAppContext, pipeActionStore, provideActionStoreSource, provideDbxAnchor, provideDbxButton, provideDbxInjectionContext, provideFilterSource, provideFilterSourceConnector, provideSecondaryActionStoreSource, redirectBasedOnAuthUserState, refStringToSegueRef, safeDetectChanges, safeMarkForCheck, safeUseCdRef, successTransition, tapDetectChanges, useActionStore };
4485
4612
  //# sourceMappingURL=dereekb-dbx-core.mjs.map