@dereekb/dbx-core 1.2.0 → 2.0.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.
Files changed (72) hide show
  1. package/README.md +1 -1
  2. package/esm2020/lib/action/action.handler.mjs +3 -3
  3. package/esm2020/lib/action/action.holder.mjs +13 -4
  4. package/esm2020/lib/action/action.machine.mjs +12 -5
  5. package/esm2020/lib/action/action.mjs +37 -17
  6. package/esm2020/lib/action/action.module.mjs +11 -11
  7. package/esm2020/lib/action/action.reference.mjs +7 -0
  8. package/esm2020/lib/action/action.store.mjs +60 -23
  9. package/esm2020/lib/action/action.store.source.mjs +27 -13
  10. package/esm2020/lib/action/directive/auto/action.automodify.directive.mjs +5 -5
  11. package/esm2020/lib/action/directive/auto/action.autotrigger.directive.mjs +8 -7
  12. package/esm2020/lib/action/directive/auto/index.mjs +2 -2
  13. package/esm2020/lib/action/directive/context/action.directive.mjs +5 -5
  14. package/esm2020/lib/action/directive/debug/action.logger.directive.mjs +4 -4
  15. package/esm2020/lib/action/directive/map/action.map.working.disable.directive.mjs +5 -5
  16. package/esm2020/lib/action/directive/state/action.disabled.directive.mjs +7 -5
  17. package/esm2020/lib/action/directive/state/action.enforce.modified.directive.mjs +48 -0
  18. package/esm2020/lib/action/directive/state/action.handler.directive.mjs +5 -5
  19. package/esm2020/lib/action/directive/state/action.success.component.mjs +4 -4
  20. package/esm2020/lib/action/directive/state/action.success.directive.mjs +4 -4
  21. package/esm2020/lib/action/directive/state/action.value.directive.mjs +9 -7
  22. package/esm2020/lib/action/directive/state/action.value.stream.directive.mjs +80 -0
  23. package/esm2020/lib/action/directive/state/action.working.component.mjs +4 -4
  24. package/esm2020/lib/action/directive/state/index.mjs +2 -2
  25. package/esm2020/lib/action/index.mjs +2 -2
  26. package/esm2020/lib/button/action/action.button.directive.mjs +12 -11
  27. package/esm2020/lib/button/action/action.button.trigger.directive.mjs +4 -4
  28. package/esm2020/lib/button/button.directive.mjs +1 -1
  29. package/esm2020/lib/button/button.mjs +1 -1
  30. package/esm2020/lib/filter/action/action.filter.source.directive.mjs +4 -4
  31. package/fesm2015/dereekb-dbx-core.mjs +323 -240
  32. package/fesm2015/dereekb-dbx-core.mjs.map +1 -1
  33. package/fesm2020/dereekb-dbx-core.mjs +321 -238
  34. package/fesm2020/dereekb-dbx-core.mjs.map +1 -1
  35. package/lib/action/action.d.ts +14 -12
  36. package/lib/action/action.handler.d.ts +13 -5
  37. package/lib/action/action.holder.d.ts +9 -5
  38. package/lib/action/action.machine.d.ts +21 -8
  39. package/lib/action/action.module.d.ts +3 -3
  40. package/lib/action/action.reference.d.ts +11 -0
  41. package/lib/action/action.store.d.ts +33 -15
  42. package/lib/action/action.store.source.d.ts +20 -13
  43. package/lib/action/directive/auto/action.automodify.directive.d.ts +5 -4
  44. package/lib/action/directive/auto/action.autotrigger.directive.d.ts +6 -6
  45. package/lib/action/directive/auto/index.d.ts +1 -1
  46. package/lib/action/directive/context/action.directive.d.ts +3 -3
  47. package/lib/action/directive/debug/action.logger.directive.d.ts +3 -3
  48. package/lib/action/directive/map/action.map.working.disable.directive.d.ts +6 -6
  49. package/lib/action/directive/state/action.disabled.directive.d.ts +5 -4
  50. package/lib/action/directive/state/action.enforce.modified.directive.d.ts +19 -0
  51. package/lib/action/directive/state/action.handler.directive.d.ts +3 -3
  52. package/lib/action/directive/state/action.success.component.d.ts +3 -3
  53. package/lib/action/directive/state/action.success.directive.d.ts +3 -3
  54. package/lib/action/directive/state/action.value.directive.d.ts +3 -3
  55. package/lib/action/directive/state/action.value.stream.directive.d.ts +25 -0
  56. package/lib/action/directive/state/action.working.component.d.ts +3 -3
  57. package/lib/action/directive/state/index.d.ts +1 -1
  58. package/lib/action/index.d.ts +1 -1
  59. package/lib/button/action/action.button.directive.d.ts +4 -4
  60. package/lib/button/action/action.button.trigger.directive.d.ts +3 -3
  61. package/lib/button/button.d.ts +2 -2
  62. package/lib/button/button.directive.d.ts +2 -2
  63. package/lib/filter/action/action.filter.source.directive.d.ts +2 -2
  64. package/package.json +5 -4
  65. package/esm2020/lib/action/directive/auto/action.autotrigger.value.directive.mjs +0 -79
  66. package/esm2020/lib/action/directive/state/action.disabled.modified.directive.mjs +0 -35
  67. package/esm2020/lib/action/snackbar/index.mjs +0 -3
  68. package/esm2020/lib/action/snackbar/snackbar.mjs +0 -24
  69. package/lib/action/directive/auto/action.autotrigger.value.directive.d.ts +0 -25
  70. package/lib/action/directive/state/action.disabled.modified.directive.d.ts +0 -16
  71. package/lib/action/snackbar/index.d.ts +0 -1
  72. package/lib/action/snackbar/snackbar.d.ts +0 -50
@@ -1,16 +1,15 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Directive, forwardRef, Host, Input, Injectable, Optional, Component, NgModule, EventEmitter, Output, LOCALE_ID, Pipe, Inject, ViewChild, InjectionToken, Injector, ViewContainerRef } from '@angular/core';
2
+ import { Directive, Injectable, forwardRef, Host, Input, Optional, Component, NgModule, EventEmitter, Output, LOCALE_ID, Pipe, Inject, ViewChild, InjectionToken, Injector, ViewContainerRef } from '@angular/core';
3
3
  import * as i1$3 from '@dereekb/rxjs';
4
- import { SubscriptionObject, LockSet, filterMaybe, scanCount, combineLatestFromMapValuesObsFn, skipFirstMaybe, FilterSourceInstance, FilterSource, FilterSourceConnector, FilterMap } from '@dereekb/rxjs';
4
+ import { SubscriptionObject, LockSet, filterMaybe, LoadingStateType, beginLoading, idleLoadingState, errorResult, successResult, scanCount, combineLatestFromMapValuesObsFn, skipFirstMaybe, FilterSourceInstance, FilterSource, FilterSourceConnector, FilterMap } from '@dereekb/rxjs';
5
5
  import * as i1 from 'rxjs';
6
- import { BehaviorSubject, combineLatest, Subject, interval, EMPTY, of, isObservable, delay as delay$1, filter as filter$1, startWith as startWith$1, switchMap as switchMap$1, shareReplay as shareReplay$1, first as first$1, Observable, tap as tap$1 } from 'rxjs';
6
+ import { BehaviorSubject, combineLatest, Subject, interval, EMPTY, of, isObservable, delay as delay$1, tap as tap$1, filter as filter$1, startWith as startWith$1, switchMap as switchMap$1, shareReplay as shareReplay$1, first as first$1, Observable } from 'rxjs';
7
7
  import { switchMap, first, distinctUntilChanged, filter, debounce, throttle, exhaustMap, mergeMap, map, shareReplay, withLatestFrom, startWith, tap, delay } from 'rxjs/operators';
8
8
  import * as i1$4 from '@dereekb/util';
9
- import { hasValueOrNotEmpty, BooleanStringKeyArrayUtilityInstance, reduceBooleansWithOrFn, getValueFromObjectOrGetter, expandTreeFunction, flattenTreeToArrayFunction, expandFlattenTreeFunction, mergeArrayIntoArray, objectFlatMergeMatrix, mergeArrays, filterMaybeValues, mergeObjects, mergeArrayOrValueIntoArray, DataIsExpiredError, DataDoesNotExistError, filterMaybeValuesFn, StorageObjectUtility, SHARED_MEMORY_STORAGE } from '@dereekb/util';
9
+ import { isDefinedAndNotFalse, hasValueOrNotEmpty, BooleanStringKeyArrayUtilityInstance, reduceBooleansWithOrFn, isUndefinedAndNotFalse, getValueFromObjectOrGetter, expandTreeFunction, flattenTreeToArrayFunction, expandFlattenTreeFunction, mergeArrayIntoArray, objectFlatMergeMatrix, mergeArrays, filterMaybeValues, mergeObjects, mergeArrayOrValueIntoArray, DataIsExpiredError, DataDoesNotExistError, filterMaybeValuesFn, StorageObjectUtility, SHARED_MEMORY_STORAGE } from '@dereekb/util';
10
10
  import { ComponentStore } from '@ngrx/component-store';
11
11
  import * as i2 from '@angular/common';
12
12
  import { CommonModule, formatDate } from '@angular/common';
13
- import ms from 'ms';
14
13
  import * as i1$1 from '@angular/router';
15
14
  import { NavigationStart, NavigationEnd } from '@angular/router';
16
15
  import { isArray } from 'class-validator';
@@ -81,8 +80,10 @@ function pipeActionStore(source, pipeFn) {
81
80
  function useActionStore(source, useFn) {
82
81
  return source.store$.pipe(first()).subscribe(useFn);
83
82
  }
84
- // tslint:disable-next-line: directive-class-suffix
85
- class ActionContextStoreSourceInstance {
83
+ /**
84
+ * Service that wraps a ActionContextStoreSource.
85
+ */
86
+ class DbxActionContextStoreSourceInstance {
86
87
  constructor(source) {
87
88
  this.source = source;
88
89
  this.lockSet = new LockSet();
@@ -124,6 +125,9 @@ class ActionContextStoreSourceInstance {
124
125
  get isModified$() {
125
126
  return this.pipeStore(x => x.isModified$);
126
127
  }
128
+ get canTrigger$() {
129
+ return this.pipeStore(x => x.canTrigger$);
130
+ }
127
131
  get isModifiedAndCanTriggerUpdates$() {
128
132
  return this.pipeStore(x => x.isModifiedAndCanTriggerUpdates$);
129
133
  }
@@ -133,12 +137,21 @@ class ActionContextStoreSourceInstance {
133
137
  get actionState$() {
134
138
  return this.pipeStore(x => x.actionState$);
135
139
  }
140
+ get loadingState$() {
141
+ return this.pipeStore(x => x.loadingState$);
142
+ }
143
+ get loadingStateType$() {
144
+ return this.pipeStore(x => x.loadingStateType$);
145
+ }
136
146
  get isWorking$() {
137
147
  return this.pipeStore(x => x.isWorking$);
138
148
  }
139
149
  get isSuccess$() {
140
150
  return this.pipeStore(x => x.isSuccess$);
141
151
  }
152
+ get disabledKeys$() {
153
+ return this.pipeStore(x => x.disabledKeys$);
154
+ }
142
155
  get isDisabled$() {
143
156
  return this.pipeStore(x => x.isDisabled$);
144
157
  }
@@ -166,23 +179,23 @@ class ActionContextStoreSourceInstance {
166
179
  reject(error) {
167
180
  this.useStore((x) => x.reject(error));
168
181
  }
169
- success(value) {
170
- this.useStore((x) => x.success(value));
182
+ resolve(value) {
183
+ this.useStore((x) => x.resolve(value));
171
184
  }
172
185
  reset() {
173
186
  this.useStore((x) => x.reset());
174
187
  }
175
188
  }
176
- ActionContextStoreSourceInstance.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: ActionContextStoreSourceInstance, deps: [{ token: ActionContextStoreSource }], target: i0.ɵɵFactoryTarget.Directive });
177
- ActionContextStoreSourceInstancedir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: ActionContextStoreSourceInstance, ngImport: i0 });
178
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: ActionContextStoreSourceInstance, decorators: [{
179
- type: Directive
189
+ DbxActionContextStoreSourceInstance.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextStoreSourceInstance, deps: [{ token: ActionContextStoreSource }], target: i0.ɵɵFactoryTarget.Injectable });
190
+ DbxActionContextStoreSourceInstanceprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextStoreSourceInstance });
191
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextStoreSourceInstance, decorators: [{
192
+ type: Injectable
180
193
  }], ctorParameters: function () { return [{ type: ActionContextStoreSource }]; } });
181
194
  const actionContextStoreSourceInstanceFactory = (source) => {
182
- return new ActionContextStoreSourceInstance(source);
195
+ return new DbxActionContextStoreSourceInstance(source);
183
196
  };
184
197
  /**
185
- * Provides an ActionContextStoreSource, as well as an ActionContextStoreSourceInstance.
198
+ * Provides an ActionContextStoreSource, as well as an DbxActionContextStoreSourceInstance.
186
199
  */
187
200
  function ProvideActionStoreSource(sourceType) {
188
201
  return [{
@@ -190,7 +203,7 @@ function ProvideActionStoreSource(sourceType) {
190
203
  useExisting: forwardRef(() => sourceType)
191
204
  },
192
205
  {
193
- provide: ActionContextStoreSourceInstance,
206
+ provide: DbxActionContextStoreSourceInstance,
194
207
  useFactory: actionContextStoreSourceInstanceFactory,
195
208
  deps: [ActionContextStoreSource]
196
209
  }];
@@ -214,7 +227,7 @@ class DbxActionAutoModifyDirective extends AbstractSubscriptionDirective {
214
227
  return this._autoModifyEnabled.value;
215
228
  }
216
229
  set autoModifyEnabled(autoModifyEnabled) {
217
- this._autoModifyEnabled.next(autoModifyEnabled !== 'false');
230
+ this._autoModifyEnabled.next(autoModifyEnabled !== false);
218
231
  }
219
232
  ngOnInit() {
220
233
  const obs = combineLatest([
@@ -234,7 +247,7 @@ class DbxActionAutoModifyDirective extends AbstractSubscriptionDirective {
234
247
  });
235
248
  }
236
249
  }
237
- DbxActionAutoModifyDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoModifyDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
250
+ DbxActionAutoModifyDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoModifyDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
238
251
  DbxActionAutoModifyDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionAutoModifyDirective, selector: "[dbxActionAutoModify]", inputs: { autoModifyEnabled: ["dbxActionAutoModify", "autoModifyEnabled"] }, usesInheritance: true, ngImport: i0 });
239
252
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoModifyDirective, decorators: [{
240
253
  type: Directive,
@@ -242,7 +255,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
242
255
  selector: '[dbxActionAutoModify]',
243
256
  }]
244
257
  }], ctorParameters: function () {
245
- return [{ type: ActionContextStoreSourceInstance, decorators: [{
258
+ return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
246
259
  type: Host
247
260
  }] }];
248
261
  }, propDecorators: { autoModifyEnabled: [{
@@ -255,7 +268,7 @@ const DEFAULT_THROTTLE_MS = 10 * 1000;
255
268
  const DEFAULT_ERROR_THROTTLE_MS = 3 * 1000;
256
269
  const MAX_ERRORS_TO_THROTTLE_ON = 6;
257
270
  /**
258
- * Extension of DbxActionTransitionSafetyDirective that automatically triggers the action periodically when it is in a modified state.
271
+ * Directive that automatically triggers the action periodically when it is in a modified state.
259
272
  */
260
273
  class DbxActionAutoTriggerDirective extends AbstractSubscriptionDirective {
261
274
  constructor(source) {
@@ -307,7 +320,7 @@ class DbxActionAutoTriggerDirective extends AbstractSubscriptionDirective {
307
320
  * Used in forms that are simple.
308
321
  */
309
322
  set fastTrigger(fastTrigger) {
310
- if (fastTrigger) {
323
+ if (isDefinedAndNotFalse(fastTrigger)) {
311
324
  this.triggerDebounce = 200;
312
325
  this.triggerThrottle = 500;
313
326
  }
@@ -318,7 +331,7 @@ class DbxActionAutoTriggerDirective extends AbstractSubscriptionDirective {
318
331
  * Used in forms that generally return a single value.
319
332
  */
320
333
  set instantTrigger(instantTrigger) {
321
- if (instantTrigger) {
334
+ if (isDefinedAndNotFalse(instantTrigger)) {
322
335
  this.triggerDebounce = 10;
323
336
  this.triggerThrottle = 0;
324
337
  }
@@ -346,7 +359,7 @@ class DbxActionAutoTriggerDirective extends AbstractSubscriptionDirective {
346
359
  });
347
360
  }
348
361
  }
349
- DbxActionAutoTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoTriggerDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
362
+ DbxActionAutoTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoTriggerDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
350
363
  DbxActionAutoTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionAutoTriggerDirective, selector: "dbxActionAutoTrigger, [dbxActionAutoTrigger]", inputs: { triggerEnabled: ["dbxActionAutoTrigger", "triggerEnabled"], triggerDebounce: "triggerDebounce", triggerThrottle: "triggerThrottle", triggerErrorThrottle: "triggerErrorThrottle", fastTrigger: "fastTrigger", instantTrigger: "instantTrigger", triggerLimit: "triggerLimit" }, usesInheritance: true, ngImport: i0 });
351
364
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoTriggerDirective, decorators: [{
352
365
  type: Directive,
@@ -354,7 +367,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
354
367
  selector: 'dbxActionAutoTrigger, [dbxActionAutoTrigger]',
355
368
  }]
356
369
  }], ctorParameters: function () {
357
- return [{ type: ActionContextStoreSourceInstance, decorators: [{
370
+ return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
358
371
  type: Host
359
372
  }] }];
360
373
  }, propDecorators: { triggerEnabled: [{
@@ -375,19 +388,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
375
388
  }] } });
376
389
 
377
390
  /**
378
- * Directive that watches an observable for changes and sets the new value and modified states as necessary.
391
+ * Directive that watches a value observable for changes and sets the new value and modified states as necessary.
379
392
  */
380
- class DbxActionAutoTriggerValueDirective {
393
+ class dbxActionValueStreamDirective {
381
394
  constructor(source) {
382
395
  this.source = source;
383
396
  this._valueObs = new BehaviorSubject(EMPTY);
384
397
  this._isModifiedFn = new BehaviorSubject(undefined);
385
398
  this._modifiedSub = new SubscriptionObject();
386
399
  this._triggerSub = new SubscriptionObject();
387
- this.modifiedValue$ = this._valueObs.pipe(switchMap((obs) => obs.pipe(withLatestFrom(this._isModifiedFn), mergeMap(([value, dbxActionAutoTriggerModified]) => {
400
+ this.modifiedValue$ = this._valueObs.pipe(switchMap((obs) => obs.pipe(withLatestFrom(this._isModifiedFn), mergeMap(([value, dbxActionValueStreamModified]) => {
388
401
  let result;
389
- if (dbxActionAutoTriggerModified) {
390
- result = dbxActionAutoTriggerModified(value).pipe(map((isModified) => [isModified, value]));
402
+ if (dbxActionValueStreamModified) {
403
+ result = dbxActionValueStreamModified(value).pipe(map((isModified) => [isModified, value]));
391
404
  }
392
405
  else {
393
406
  result = of([true, value]);
@@ -395,18 +408,18 @@ class DbxActionAutoTriggerValueDirective {
395
408
  return result;
396
409
  }), shareReplay(1))));
397
410
  }
398
- set dbxActionAutoTriggerValue(dbxActionAutoTriggerValue) {
399
- this._valueObs.next(dbxActionAutoTriggerValue);
411
+ set dbxActionValueStream(dbxActionValueStream) {
412
+ this._valueObs.next(dbxActionValueStream);
400
413
  }
401
- set dbxActionAutoTriggerModifiedNonEmptyValue(requireNonEmpty) {
402
- if (requireNonEmpty) {
403
- this.dbxActionAutoTriggerModified = (value) => {
414
+ set dbxActionValueStreamIsNotEmpty(requireNonEmpty) {
415
+ if (isDefinedAndNotFalse(requireNonEmpty)) {
416
+ this.dbxActionValueStreamModified = (value) => {
404
417
  return of(hasValueOrNotEmpty(value));
405
418
  };
406
419
  }
407
420
  }
408
- set dbxActionAutoTriggerModified(dbxActionAutoTriggerModified) {
409
- this._isModifiedFn.next(dbxActionAutoTriggerModified);
421
+ set dbxActionValueStreamModified(dbxActionValueStreamModified) {
422
+ this._isModifiedFn.next(dbxActionValueStreamModified);
410
423
  }
411
424
  ngOnInit() {
412
425
  // Update Modified value.
@@ -414,89 +427,109 @@ class DbxActionAutoTriggerValueDirective {
414
427
  this.source.setIsModified(isModified);
415
428
  });
416
429
  // Set the value on triggers.
417
- this._triggerSub.subscription = this.source.triggered$.pipe(mergeMap(x => this.modifiedValue$)).subscribe(([isModified, value]) => {
418
- this.source.readyValue(value);
430
+ this._triggerSub.subscription = this.source.triggered$.pipe(switchMap(_ => this.modifiedValue$)).subscribe(([isModified, value]) => {
431
+ if (isModified) {
432
+ this.source.readyValue(value);
433
+ }
419
434
  });
420
435
  }
421
436
  ngOnDestroy() {
422
437
  this.source.lockSet.onNextUnlock(() => {
423
- this._isModifiedFn.complete();
424
438
  this._valueObs.complete();
439
+ this._isModifiedFn.complete();
425
440
  this._modifiedSub.destroy();
426
441
  this._triggerSub.destroy();
427
442
  });
428
443
  }
429
444
  }
430
- DbxActionAutoTriggerValueDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoTriggerValueDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
431
- DbxActionAutoTriggerValueDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionAutoTriggerValueDirective, selector: "[dbxActionAutoTriggerValue]", inputs: { dbxActionAutoTriggerValue: "dbxActionAutoTriggerValue", dbxActionAutoTriggerModifiedNonEmptyValue: "dbxActionAutoTriggerModifiedNonEmptyValue", dbxActionAutoTriggerModified: "dbxActionAutoTriggerModified" }, ngImport: i0 });
432
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionAutoTriggerValueDirective, decorators: [{
445
+ dbxActionValueStreamDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: dbxActionValueStreamDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
446
+ dbxActionValueStreamDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: dbxActionValueStreamDirective, selector: "[dbxActionValueStream]", inputs: { dbxActionValueStream: "dbxActionValueStream", dbxActionValueStreamIsNotEmpty: "dbxActionValueStreamIsNotEmpty", dbxActionValueStreamModified: "dbxActionValueStreamModified" }, ngImport: i0 });
447
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: dbxActionValueStreamDirective, decorators: [{
433
448
  type: Directive,
434
449
  args: [{
435
- selector: '[dbxActionAutoTriggerValue]',
450
+ selector: '[dbxActionValueStream]',
436
451
  }]
437
452
  }], ctorParameters: function () {
438
- return [{ type: ActionContextStoreSourceInstance, decorators: [{
453
+ return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
439
454
  type: Host
440
455
  }] }];
441
- }, propDecorators: { dbxActionAutoTriggerValue: [{
442
- type: Input,
443
- args: ['dbxActionAutoTriggerValue']
444
- }], dbxActionAutoTriggerModifiedNonEmptyValue: [{
456
+ }, propDecorators: { dbxActionValueStream: [{
457
+ type: Input
458
+ }], dbxActionValueStreamIsNotEmpty: [{
445
459
  type: Input
446
- }], dbxActionAutoTriggerModified: [{
460
+ }], dbxActionValueStreamModified: [{
447
461
  type: Input
448
462
  }] } });
449
463
 
450
464
  /**
451
465
  * Used by ActionContextState to denote what state the action is in.
452
466
  */
453
- var ActionState;
454
- (function (ActionState) {
467
+ var DbxActionState;
468
+ (function (DbxActionState) {
455
469
  /**
456
470
  * No action in progress. Waiting for the trigger.
457
471
  */
458
- ActionState["Idle"] = "idle";
472
+ DbxActionState["IDLE"] = "idle";
459
473
  /**
460
474
  * Idle state that can be set to show that the source is not yet ready.
461
475
  */
462
- ActionState["Disabled"] = "disabled";
476
+ DbxActionState["DISABLED"] = "disabled";
463
477
  /**
464
478
  * The action was triggered. We wait (and allow) the value to be updated.
465
479
  */
466
- ActionState["Triggered"] = "triggered";
480
+ DbxActionState["TRIGGERED"] = "triggered";
467
481
  /**
468
482
  * The trigger was accepted and the value is updated. It should begin working immediately.
469
483
  *
470
484
  * ValueReady cannot be set until triggered is set.
471
485
  */
472
- ActionState["ValueReady"] = "valueReady";
486
+ DbxActionState["VALUE_READY"] = "valueReady";
473
487
  /**
474
488
  * The action is in progress.
475
489
  */
476
- ActionState["Working"] = "working";
490
+ DbxActionState["WORKING"] = "working";
477
491
  /**
478
492
  * The trigger, action, or value was rejected due to an error or other issue.
479
493
  *
480
494
  * An error may be specified optionally.
481
495
  */
482
- ActionState["Rejected"] = "rejected";
496
+ DbxActionState["REJECTED"] = "rejected";
483
497
  /**
484
- * The action was successful.
498
+ * The action resolved without issue.
485
499
  */
486
- ActionState["Success"] = "success";
487
- })(ActionState || (ActionState = {}));
488
- const DEFAULT_ACTION_DISABLED_KEY = 'default';
500
+ DbxActionState["RESOLVED"] = "resolved";
501
+ })(DbxActionState || (DbxActionState = {}));
502
+ const DEFAULT_ACTION_DISABLED_KEY = 'dbx_action_disabled';
489
503
  function isIdleActionState(actionState) {
490
504
  switch (actionState) {
491
- case ActionState.Idle:
492
- case ActionState.Disabled:
493
- case ActionState.Rejected:
494
- case ActionState.Success:
505
+ case DbxActionState.IDLE:
506
+ case DbxActionState.DISABLED:
507
+ case DbxActionState.REJECTED:
508
+ case DbxActionState.RESOLVED:
495
509
  return true;
496
510
  default:
497
511
  return false;
498
512
  }
499
513
  }
514
+ function loadingStateTypeForActionState(actionState) {
515
+ let loadingStateType;
516
+ switch (actionState) {
517
+ case DbxActionState.RESOLVED:
518
+ loadingStateType = LoadingStateType.SUCCESS;
519
+ break;
520
+ case DbxActionState.REJECTED:
521
+ loadingStateType = LoadingStateType.ERROR;
522
+ break;
523
+ case DbxActionState.IDLE:
524
+ case DbxActionState.DISABLED:
525
+ loadingStateType = LoadingStateType.IDLE;
526
+ break;
527
+ default:
528
+ loadingStateType = LoadingStateType.LOADING;
529
+ break;
530
+ }
531
+ return loadingStateType;
532
+ }
500
533
 
501
534
  function isActionContextEnabled(state) {
502
535
  return BooleanStringKeyArrayUtilityInstance.isFalse(state.disabled);
@@ -511,13 +544,13 @@ function isWorkingActionState(actionState) {
511
544
  return !isIdleActionState(actionState);
512
545
  }
513
546
  function canTriggerActionState(actionState) {
514
- return actionState !== ActionState.Disabled && isIdleActionState(actionState);
547
+ return actionState !== DbxActionState.DISABLED && isIdleActionState(actionState);
515
548
  }
516
549
  function canTriggerAction(state) {
517
550
  return isActionContextEnabled(state) && isIdleActionState(state.actionState);
518
551
  }
519
552
  function canReadyValue(state) {
520
- return state.actionState === ActionState.Triggered;
553
+ return state.actionState === DbxActionState.TRIGGERED;
521
554
  }
522
555
  function actionContextIsModifiedAndCanTrigger(state) {
523
556
  // console.log('check: ', state, state.isModified, canTriggerAction(state));
@@ -526,20 +559,42 @@ function actionContextIsModifiedAndCanTrigger(state) {
526
559
  function actionContextHasNoErrorAndIsModifiedAndCanTrigger(state) {
527
560
  return !state.error && actionContextIsModifiedAndCanTrigger(state);
528
561
  }
562
+ function loadingStateForActionContextState(state) {
563
+ let loadingState;
564
+ switch (state.actionState) {
565
+ case DbxActionState.RESOLVED:
566
+ loadingState = successResult(state.result);
567
+ break;
568
+ case DbxActionState.REJECTED:
569
+ loadingState = errorResult(state.error);
570
+ break;
571
+ case DbxActionState.IDLE:
572
+ case DbxActionState.DISABLED:
573
+ loadingState = idleLoadingState();
574
+ break;
575
+ default:
576
+ loadingState = beginLoading();
577
+ break;
578
+ }
579
+ return loadingState;
580
+ }
581
+ function loadingStateTypeForActionContextState(state) {
582
+ return loadingStateTypeForActionState(state.actionState);
583
+ }
529
584
  const INITIAL_STATE = {
530
585
  isModified: false,
531
- actionState: ActionState.Idle
586
+ actionState: DbxActionState.IDLE
532
587
  };
533
588
  class ActionContextStore extends ComponentStore {
534
589
  constructor() {
535
590
  super(Object.assign({}, INITIAL_STATE));
536
591
  this.lockSet = new LockSet();
537
592
  // MARK: Accessors
538
- this.actionState$ = this.state$.pipe(map(x => isDisabledActionContextState(x) ? ActionState.Disabled : x.actionState), shareReplay(1));
593
+ this.actionState$ = this.state$.pipe(map(x => isDisabledActionContextState(x) ? DbxActionState.DISABLED : x.actionState), shareReplay(1));
539
594
  /**
540
- * Returns the current disabled reasons.
595
+ * Returns the current disabled reasons/keys.
541
596
  */
542
- this.disabled$ = this.state$.pipe(map(x => { var _a; return [...(_a = x.disabled) !== null && _a !== void 0 ? _a : []]; }), distinctUntilChanged(), shareReplay(1));
597
+ this.disabledKeys$ = this.state$.pipe(map(x => { var _a; return [...(_a = x.disabled) !== null && _a !== void 0 ? _a : []]; }), distinctUntilChanged(), shareReplay(1));
543
598
  /**
544
599
  * Maps the current state to true or not when the action state changes to/from disabled.
545
600
  */
@@ -551,19 +606,19 @@ class ActionContextStore extends ComponentStore {
551
606
  /**
552
607
  * Pipes true when triggered.
553
608
  */
554
- this.triggered$ = this.afterDistinctActionState(ActionState.Triggered, () => true);
609
+ this.triggered$ = this.afterDistinctActionState(DbxActionState.TRIGGERED, () => true);
555
610
  /**
556
611
  * Pipes the readied value on ValueReady.
557
612
  */
558
- this.valueReady$ = this.afterDistinctActionState(ActionState.ValueReady, x => x.value);
613
+ this.valueReady$ = this.afterDistinctActionState(DbxActionState.VALUE_READY, x => x.value);
559
614
  /**
560
615
  * Pipes the error on the rejection state.
561
616
  */
562
- this.rejected$ = this.afterDistinctActionState(ActionState.Rejected, x => x.error);
617
+ this.rejected$ = this.afterDistinctActionState(DbxActionState.REJECTED, x => x.error);
563
618
  /**
564
619
  * Pipes the result when the ActionState becomes working.
565
620
  */
566
- this.working$ = this.afterDistinctActionState(ActionState.Working, () => true);
621
+ this.working$ = this.afterDistinctActionState(DbxActionState.WORKING, () => true);
567
622
  /**
568
623
  * Whether or not it is currently in a working state.
569
624
  */
@@ -575,11 +630,19 @@ class ActionContextStore extends ComponentStore {
575
630
  /**
576
631
  * Pipes the result when the ActionState becomes success.
577
632
  */
578
- this.success$ = this.afterDistinctActionState(ActionState.Success, x => x.result);
633
+ this.success$ = this.afterDistinctActionState(DbxActionState.RESOLVED, x => x.result);
579
634
  /**
580
635
  * Whether or not it is currently in a success state.
581
636
  */
582
- this.isSuccess$ = this.afterDistinctBoolean(x => x.actionState === ActionState.Success);
637
+ this.isSuccess$ = this.afterDistinctBoolean(x => x.actionState === DbxActionState.RESOLVED);
638
+ /**
639
+ * Returns a loading state based on the current state.
640
+ */
641
+ this.loadingState$ = this.afterDistinctLoadingStateTypeChange().pipe(map(x => loadingStateForActionContextState(x)), shareReplay(1));
642
+ /**
643
+ * Returns the current LoadingStateType based on the current state.
644
+ */
645
+ this.loadingStateType$ = this.state$.pipe(map(x => loadingStateTypeForActionContextState(x)), distinctUntilChanged(), shareReplay(1));
583
646
  /**
584
647
  * Number of errors since last success.
585
648
  */
@@ -611,35 +674,35 @@ class ActionContextStore extends ComponentStore {
611
674
  /**
612
675
  * Triggers the modified state, if not disabled.
613
676
  */
614
- this.setIsModified = this.updater((state, isModified) => (Object.assign(Object.assign({}, state), { actionState: (state.actionState === ActionState.Success) ? ActionState.Idle : state.actionState, isModified: isModified !== null && isModified !== void 0 ? isModified : true })));
677
+ this.setIsModified = this.updater((state, isModified) => (Object.assign(Object.assign({}, state), { actionState: (state.actionState === DbxActionState.RESOLVED) ? DbxActionState.IDLE : state.actionState, isModified: isModified !== null && isModified !== void 0 ? isModified : true })));
615
678
  /**
616
679
  * Triggers the action if the state is currently not idle. The current state is cleared, but the error is retained (as we may need the error from the previous attempt).
617
680
  *
618
681
  * Will not fire if the action is disabled.
619
682
  */
620
683
  this.trigger = this.updater((state) => canTriggerAction(state)
621
- ? ({ isModified: state.isModified, actionState: ActionState.Triggered, error: state.error, value: undefined })
684
+ ? ({ isModified: state.isModified, actionState: DbxActionState.TRIGGERED, error: state.error, value: undefined })
622
685
  : state);
623
686
  /**
624
687
  * Updates the value, setting value ready. The current result is cleared.
625
688
  */
626
689
  this.readyValue = this.updater((state, value) => canReadyValue(state)
627
- ? (Object.assign(Object.assign({}, state), { actionState: ActionState.ValueReady, value, result: undefined }))
690
+ ? (Object.assign(Object.assign({}, state), { actionState: DbxActionState.VALUE_READY, value, result: undefined }))
628
691
  : state);
629
692
  /**
630
693
  * Notifys the context that the action is in progress.
631
694
  */
632
- this.startWorking = this.updater((state) => (Object.assign(Object.assign({}, state), { actionState: ActionState.Working })));
695
+ this.startWorking = this.updater((state) => (Object.assign(Object.assign({}, state), { actionState: DbxActionState.WORKING })));
633
696
  /**
634
697
  * Triggers rejection of the action. The value is cleared.
635
698
  */
636
- this.reject = this.updater((state, error) => { var _a; return ({ isModified: state.isModified, actionState: ActionState.Rejected, error, errorCount: ((_a = state.errorCount) !== null && _a !== void 0 ? _a : 0) + 1 }); });
699
+ this.reject = this.updater((state, error) => { var _a; return ({ isModified: state.isModified, actionState: DbxActionState.REJECTED, error, errorCount: ((_a = state.errorCount) !== null && _a !== void 0 ? _a : 0) + 1, disabled: state.disabled }); });
637
700
  /**
638
701
  * Updates the state to success, and optionally sets a result.
639
702
  *
640
703
  * Clears modified state, and any errors.
641
704
  */
642
- this.success = this.updater((state, result) => ({ isModified: false, actionState: ActionState.Success, value: state.value, result, error: undefined }));
705
+ this.resolve = this.updater((state, result) => ({ isModified: false, actionState: DbxActionState.RESOLVED, value: state.value, result, error: undefined, disabled: state.disabled }));
643
706
  /**
644
707
  * Completely resets the store.
645
708
  */
@@ -651,9 +714,16 @@ class ActionContextStore extends ComponentStore {
651
714
  return this.state$.pipe(map(x => fromState(x)), distinctUntilChanged(), shareReplay(1));
652
715
  }
653
716
  afterDistinctActionState(actionState, fromState) {
717
+ return this.afterDistinctActionStateChange().pipe(filter((x) => x.actionState === actionState), // Only pipe when the new action state matches.
718
+ map(x => fromState(x)), shareReplay(1));
719
+ }
720
+ afterDistinctActionStateChange() {
654
721
  return this.state$.pipe(map((x) => ([x, x.actionState])), distinctUntilChanged((a, b) => (a === null || a === void 0 ? void 0 : a[1]) === (b === null || b === void 0 ? void 0 : b[1])), // Filter out when the state remains the same.
655
- filter(([x, y]) => y === actionState), // Only pipe when the action state matches.
656
- map(x => fromState(x[0])), shareReplay(1));
722
+ map(x => x[0]), shareReplay(1));
723
+ }
724
+ afterDistinctLoadingStateTypeChange() {
725
+ return this.state$.pipe(map((x) => ([x, loadingStateForActionContextState(x)])), distinctUntilChanged((a, b) => (a === null || a === void 0 ? void 0 : a[1]) === (b === null || b === void 0 ? void 0 : b[1])), // Filter out when the loading state remains the same.
726
+ map(x => x[0]), shareReplay(1));
657
727
  }
658
728
  // MARK: Cleanup
659
729
  ngOnDestroy() {
@@ -672,7 +742,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
672
742
  /**
673
743
  * Abstract class that can either use SecondaryActionContextStoreSource or create it's own.
674
744
  */
675
- class ActionContextBaseSource {
745
+ class DbxActionContextBaseSource {
676
746
  constructor(inputSource) {
677
747
  this.inputSource = inputSource;
678
748
  if (this.inputSource) {
@@ -682,7 +752,7 @@ class ActionContextBaseSource {
682
752
  this._store = new ActionContextStore();
683
753
  this._store$ = of(this._store);
684
754
  }
685
- this._instance = new ActionContextStoreSourceInstance(this);
755
+ this._instance = new DbxActionContextStoreSourceInstance(this);
686
756
  this.isModified$ = this._instance.isModified$;
687
757
  this.triggered$ = this._instance.triggered$;
688
758
  this.success$ = this._instance.success$;
@@ -714,12 +784,21 @@ class ActionContextBaseSource {
714
784
  reset() {
715
785
  this._instance.reset();
716
786
  }
787
+ enable(key, enable) {
788
+ this._instance.enable(key, enable);
789
+ }
790
+ disable(key, disable) {
791
+ this._instance.disable(key, disable);
792
+ }
793
+ setIsModified(isModified) {
794
+ this._instance.setIsModified(isModified);
795
+ }
717
796
  }
718
797
 
719
798
  /**
720
799
  * Provides an DbxActionContext.
721
800
  */
722
- class DbxActionDirective extends ActionContextBaseSource {
801
+ class DbxActionDirective extends DbxActionContextBaseSource {
723
802
  constructor(inputSource) {
724
803
  super(inputSource);
725
804
  }
@@ -730,12 +809,12 @@ class DbxActionDirective extends ActionContextBaseSource {
730
809
  }
731
810
  }
732
811
  DbxActionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDirective, deps: [{ token: SecondaryActionContextStoreSource, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
733
- DbxActionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionDirective, selector: "dbx-action,[dbxAction],dbx-action-context,[dbxActionContext]", providers: ProvideActionStoreSource(DbxActionDirective), exportAs: ["action"], usesInheritance: true, ngImport: i0 });
812
+ DbxActionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionDirective, selector: "dbx-action,[dbxAction],dbx-action-context,[dbxActionContext]", providers: ProvideActionStoreSource(DbxActionDirective), exportAs: ["action", "dbxAction"], usesInheritance: true, ngImport: i0 });
734
813
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDirective, decorators: [{
735
814
  type: Directive,
736
815
  args: [{
737
816
  selector: 'dbx-action,[dbxAction],dbx-action-context,[dbxActionContext]',
738
- exportAs: 'action',
817
+ exportAs: 'action,dbxAction',
739
818
  providers: ProvideActionStoreSource(DbxActionDirective)
740
819
  }]
741
820
  }], ctorParameters: function () {
@@ -794,7 +873,7 @@ class DbxActionContextLoggerDirective extends AbstractSubscriptionDirective {
794
873
  });
795
874
  }
796
875
  }
797
- DbxActionContextLoggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextLoggerDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
876
+ DbxActionContextLoggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextLoggerDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
798
877
  DbxActionContextLoggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionContextLoggerDirective, selector: "[dbxActionLogger],[dbxActionContextLogger]", usesInheritance: true, ngImport: i0 });
799
878
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionContextLoggerDirective, decorators: [{
800
879
  type: Directive,
@@ -802,7 +881,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
802
881
  selector: '[dbxActionLogger],[dbxActionContextLogger]'
803
882
  }]
804
883
  }], ctorParameters: function () {
805
- return [{ type: ActionContextStoreSourceInstance, decorators: [{
884
+ return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
806
885
  type: Host
807
886
  }] }];
808
887
  } });
@@ -957,7 +1036,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
957
1036
  class ActionContextStoreSourceMap {
958
1037
  }
959
1038
 
960
- const DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY = '__disabled';
1039
+ const DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY = 'action_map_working_disable';
961
1040
  /**
962
1041
  * Used to communicate with an dbxActionMap and set the ActionContextStore to be disabled if any other element in the map is working.
963
1042
  */
@@ -977,7 +1056,7 @@ class DbxActionMapWorkingDisableDirective extends AbstractSubscriptionDirective
977
1056
  this.source.enable(this.disabledKey || DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY);
978
1057
  }
979
1058
  }
980
- DbxActionMapWorkingDisableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionMapWorkingDisableDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }, { token: DbxActionContextMapDirective }], target: i0.ɵɵFactoryTarget.Directive });
1059
+ DbxActionMapWorkingDisableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionMapWorkingDisableDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }, { token: DbxActionContextMapDirective }], target: i0.ɵɵFactoryTarget.Directive });
981
1060
  DbxActionMapWorkingDisableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionMapWorkingDisableDirective, selector: "[dbxActionMapWorkingDisable]", inputs: { disabledKey: ["dbxActionMapWorkingDisable", "disabledKey"] }, usesInheritance: true, ngImport: i0 });
982
1061
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionMapWorkingDisableDirective, decorators: [{
983
1062
  type: Directive,
@@ -985,7 +1064,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
985
1064
  selector: '[dbxActionMapWorkingDisable]'
986
1065
  }]
987
1066
  }], ctorParameters: function () {
988
- return [{ type: ActionContextStoreSourceInstance, decorators: [{
1067
+ return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
989
1068
  type: Host
990
1069
  }] }, { type: DbxActionContextMapDirective }];
991
1070
  }, propDecorators: { disabledKey: [{
@@ -1018,10 +1097,11 @@ class DbxActionDisabledDirective extends AbstractSubscriptionDirective {
1018
1097
  return this._disabled.value;
1019
1098
  }
1020
1099
  set disabled(disabled) {
1021
- this._disabled.next(disabled);
1100
+ const disable = isUndefinedAndNotFalse(disabled);
1101
+ this._disabled.next(disable);
1022
1102
  }
1023
1103
  }
1024
- DbxActionDisabledDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDisabledDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1104
+ DbxActionDisabledDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDisabledDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1025
1105
  DbxActionDisabledDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionDisabledDirective, selector: "[dbxActionDisabled]", inputs: { disabled: ["dbxActionDisabled", "disabled"] }, usesInheritance: true, ngImport: i0 });
1026
1106
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDisabledDirective, decorators: [{
1027
1107
  type: Directive,
@@ -1029,7 +1109,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
1029
1109
  selector: '[dbxActionDisabled]'
1030
1110
  }]
1031
1111
  }], ctorParameters: function () {
1032
- return [{ type: ActionContextStoreSourceInstance, decorators: [{
1112
+ return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
1033
1113
  type: Host
1034
1114
  }] }];
1035
1115
  }, propDecorators: { disabled: [{
@@ -1037,40 +1117,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
1037
1117
  args: ['dbxActionDisabled']
1038
1118
  }] } });
1039
1119
 
1040
- const APP_ACTION_DISABLED_UNTIL_MODIFIED_DIRECTIVE_KEY = 'dbx_action_is_not_modified';
1041
- /**
1042
- * Directive that sets the disabled state based on the current isModified state.
1043
- */
1044
- class DbxActionDisabledUntilModifiedDirective extends AbstractSubscriptionDirective {
1045
- constructor(source) {
1046
- super();
1047
- this.source = source;
1048
- }
1049
- ngOnInit() {
1050
- this.sub = this.source.isModified$.subscribe((x) => {
1051
- this.source.disable(APP_ACTION_DISABLED_UNTIL_MODIFIED_DIRECTIVE_KEY, !x);
1052
- });
1053
- }
1054
- ngOnDestroy() {
1055
- super.ngOnDestroy();
1056
- this.source.enable(APP_ACTION_DISABLED_UNTIL_MODIFIED_DIRECTIVE_KEY);
1057
- }
1058
- }
1059
- DbxActionDisabledUntilModifiedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDisabledUntilModifiedDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1060
- DbxActionDisabledUntilModifiedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionDisabledUntilModifiedDirective, selector: "[dbxActionDisabledUntilModified]", usesInheritance: true, ngImport: i0 });
1061
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionDisabledUntilModifiedDirective, decorators: [{
1062
- type: Directive,
1063
- args: [{
1064
- selector: '[dbxActionDisabledUntilModified]'
1065
- }]
1066
- }], ctorParameters: function () {
1067
- return [{ type: ActionContextStoreSourceInstance, decorators: [{
1068
- type: Host
1069
- }] }];
1070
- } });
1071
-
1072
1120
  /**
1073
- * WorkHandlerContextDelegate implementation using an ActionContextStoreSourceInstance.
1121
+ * WorkHandlerContextDelegate implementation using an DbxActionContextStoreSourceInstance.
1074
1122
  */
1075
1123
  class WorkHandlerContextSourceDelegate {
1076
1124
  constructor(source) {
@@ -1080,7 +1128,7 @@ class WorkHandlerContextSourceDelegate {
1080
1128
  this.source.startWorking();
1081
1129
  }
1082
1130
  success(result) {
1083
- this.source.success(result);
1131
+ this.source.resolve(result);
1084
1132
  }
1085
1133
  reject(error) {
1086
1134
  this.source.reject(error);
@@ -1231,7 +1279,7 @@ class DbxActionHandlerDirective extends AbstractSubscriptionDirective {
1231
1279
  const context = handleWorkValueReadyFn({ handlerFunction, delegate: this._delegate })(value);
1232
1280
  if (context) {
1233
1281
  // Add the action to the lockSet for the source to prevent it from being destroyed until the action completes.
1234
- this.source.lockSet.addLock('actionhandler', context.isComplete$.pipe(map(x => !x)));
1282
+ this.source.lockSet.addLock('dbxActionHandler', context.isComplete$.pipe(map(x => !x)));
1235
1283
  }
1236
1284
  })))).subscribe();
1237
1285
  }
@@ -1241,7 +1289,7 @@ class DbxActionHandlerDirective extends AbstractSubscriptionDirective {
1241
1289
  });
1242
1290
  }
1243
1291
  }
1244
- DbxActionHandlerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionHandlerDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1292
+ DbxActionHandlerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionHandlerDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1245
1293
  DbxActionHandlerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionHandlerDirective, selector: "[dbxActionHandler]", inputs: { handlerFunction: ["dbxActionHandler", "handlerFunction"] }, usesInheritance: true, ngImport: i0 });
1246
1294
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionHandlerDirective, decorators: [{
1247
1295
  type: Directive,
@@ -1249,7 +1297,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
1249
1297
  selector: '[dbxActionHandler]',
1250
1298
  }]
1251
1299
  }], ctorParameters: function () {
1252
- return [{ type: ActionContextStoreSourceInstance, decorators: [{
1300
+ return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
1253
1301
  type: Host
1254
1302
  }] }];
1255
1303
  }, propDecorators: { handlerFunction: [{
@@ -1280,7 +1328,7 @@ class DbxActionSuccessComponent {
1280
1328
  }), shareReplay(1));
1281
1329
  }
1282
1330
  }
1283
- DbxActionSuccessComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionSuccessComponent, deps: [{ token: ActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Component });
1331
+ DbxActionSuccessComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionSuccessComponent, deps: [{ token: DbxActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Component });
1284
1332
  DbxActionSuccessComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionSuccessComponent, selector: "dbx-action-success", inputs: { hideAfter: "hideAfter" }, ngImport: i0, template: `
1285
1333
  <ng-container *ngIf="show$ | async">
1286
1334
  <ng-content></ng-content>
@@ -1296,7 +1344,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
1296
1344
  </ng-container>
1297
1345
  `
1298
1346
  }]
1299
- }], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance }]; }, propDecorators: { hideAfter: [{
1347
+ }], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance }]; }, propDecorators: { hideAfter: [{
1300
1348
  type: Input
1301
1349
  }] } });
1302
1350
 
@@ -1326,7 +1374,7 @@ class DbxActionSuccessDirective extends AbstractSubscriptionDirective {
1326
1374
  this._successFunction.complete();
1327
1375
  }
1328
1376
  }
1329
- DbxActionSuccessDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionSuccessDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1377
+ DbxActionSuccessDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionSuccessDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1330
1378
  DbxActionSuccessDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionSuccessDirective, selector: "[dbxActionSuccess]", inputs: { successFunction: ["dbxActionSuccess", "successFunction"] }, usesInheritance: true, ngImport: i0 });
1331
1379
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionSuccessDirective, decorators: [{
1332
1380
  type: Directive,
@@ -1334,7 +1382,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
1334
1382
  selector: '[dbxActionSuccess]',
1335
1383
  }]
1336
1384
  }], ctorParameters: function () {
1337
- return [{ type: ActionContextStoreSourceInstance, decorators: [{
1385
+ return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
1338
1386
  type: Host
1339
1387
  }] }];
1340
1388
  }, propDecorators: { successFunction: [{
@@ -1358,7 +1406,7 @@ class DbxActionValueDirective extends AbstractSubscriptionDirective {
1358
1406
  return this._valueOrFunction.value;
1359
1407
  }
1360
1408
  set valueOrFunction(valueOrFunction) {
1361
- this._valueOrFunction.next(valueOrFunction);
1409
+ this._valueOrFunction.next(valueOrFunction || undefined);
1362
1410
  }
1363
1411
  ngOnInit() {
1364
1412
  this.sub = this.valueOrFunction$.pipe(switchMap(valueOrFunction => this.source.triggered$.pipe(tap(() => {
@@ -1367,11 +1415,13 @@ class DbxActionValueDirective extends AbstractSubscriptionDirective {
1367
1415
  })))).subscribe();
1368
1416
  }
1369
1417
  ngOnDestroy() {
1370
- super.ngOnDestroy();
1371
- this._valueOrFunction.complete();
1418
+ this.source.lockSet.onNextUnlock(() => {
1419
+ super.ngOnDestroy();
1420
+ this._valueOrFunction.complete();
1421
+ });
1372
1422
  }
1373
1423
  }
1374
- DbxActionValueDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionValueDirective, deps: [{ token: ActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1424
+ DbxActionValueDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionValueDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1375
1425
  DbxActionValueDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionValueDirective, selector: "[dbxActionValue]", inputs: { valueOrFunction: ["dbxActionValue", "valueOrFunction"] }, usesInheritance: true, ngImport: i0 });
1376
1426
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionValueDirective, decorators: [{
1377
1427
  type: Directive,
@@ -1379,7 +1429,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
1379
1429
  selector: '[dbxActionValue]',
1380
1430
  }]
1381
1431
  }], ctorParameters: function () {
1382
- return [{ type: ActionContextStoreSourceInstance, decorators: [{
1432
+ return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
1383
1433
  type: Host
1384
1434
  }] }];
1385
1435
  }, propDecorators: { valueOrFunction: [{
@@ -1396,7 +1446,7 @@ class DbxActionWorkingComponent {
1396
1446
  this.show$ = this.source.isWorking$;
1397
1447
  }
1398
1448
  }
1399
- DbxActionWorkingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionWorkingComponent, deps: [{ token: ActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Component });
1449
+ DbxActionWorkingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionWorkingComponent, deps: [{ token: DbxActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Component });
1400
1450
  DbxActionWorkingComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionWorkingComponent, selector: "dbx-action-working", ngImport: i0, template: `
1401
1451
  <ng-container *ngIf="show$ | async">
1402
1452
  <ng-content></ng-content>
@@ -1412,45 +1462,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
1412
1462
  </ng-container>
1413
1463
  `
1414
1464
  }]
1415
- }], ctorParameters: function () { return [{ type: ActionContextStoreSourceInstance }]; } });
1416
-
1417
- const DEFAULT_SNACKBAR_DIRECTIVE_DURATION = ms('4s');
1418
- const DEFAULT_SNACKBAR_UNDO_DIRECTIVE_DURATION = ms('30s');
1419
- var ActionSnackbarDefaultType;
1420
- (function (ActionSnackbarDefaultType) {
1421
- ActionSnackbarDefaultType["NONE"] = "none";
1422
- ActionSnackbarDefaultType["CREATE"] = "create";
1423
- ActionSnackbarDefaultType["SAVE"] = "save";
1424
- ActionSnackbarDefaultType["DELETE"] = "delete";
1425
- ActionSnackbarDefaultType["MERGE"] = "merge";
1426
- ActionSnackbarDefaultType["SEND"] = "send";
1427
- ActionSnackbarDefaultType["CANCEL"] = "cancel";
1428
- ActionSnackbarDefaultType["RESTORE"] = "restore";
1429
- ActionSnackbarDefaultType["REFRESH"] = "refresh";
1430
- ActionSnackbarDefaultType["MARK_READ"] = "read";
1431
- ActionSnackbarDefaultType["MARK_UNREAD"] = "unread";
1432
- })(ActionSnackbarDefaultType || (ActionSnackbarDefaultType = {}));
1433
- var ActionSnackbarEventType;
1434
- (function (ActionSnackbarEventType) {
1435
- ActionSnackbarEventType[ActionSnackbarEventType["WORKING"] = 0] = "WORKING";
1436
- ActionSnackbarEventType[ActionSnackbarEventType["SUCCESS"] = 1] = "SUCCESS";
1437
- ActionSnackbarEventType[ActionSnackbarEventType["REJECTED"] = 2] = "REJECTED";
1438
- })(ActionSnackbarEventType || (ActionSnackbarEventType = {}));
1439
-
1440
- // export * from './snackbar.directive';
1465
+ }], ctorParameters: function () { return [{ type: DbxActionContextStoreSourceInstance }]; } });
1466
+
1467
+ const APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY = 'dbx_action_enforce_modified';
1468
+ /**
1469
+ * Directive that toggles disabling an action if the action is not marked modified.
1470
+ */
1471
+ class DbxActionEnforceModifiedDirective extends AbstractSubscriptionDirective {
1472
+ constructor(source) {
1473
+ super();
1474
+ this.source = source;
1475
+ this._enabled = new BehaviorSubject(true);
1476
+ }
1477
+ ngOnInit() {
1478
+ this.sub = combineLatest([this.source.isModified$, this._enabled]).pipe(delay$1(0)).subscribe(([modified, enableDirective]) => {
1479
+ const disable = enableDirective && !modified;
1480
+ this.source.disable(APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY, disable);
1481
+ });
1482
+ }
1483
+ ngOnDestroy() {
1484
+ super.ngOnDestroy();
1485
+ this._enabled.complete();
1486
+ this.source.enable(APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY);
1487
+ }
1488
+ get enabled() {
1489
+ return this._enabled.value;
1490
+ }
1491
+ set enabled(enabled) {
1492
+ this._enabled.next(enabled !== null && enabled !== void 0 ? enabled : true);
1493
+ }
1494
+ }
1495
+ DbxActionEnforceModifiedDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionEnforceModifiedDirective, deps: [{ token: DbxActionContextStoreSourceInstance, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1496
+ DbxActionEnforceModifiedDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionEnforceModifiedDirective, selector: "[dbxActionEnforceModified]", inputs: { enabled: ["[dbxActionEnforceModified]", "enabled"] }, usesInheritance: true, ngImport: i0 });
1497
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionEnforceModifiedDirective, decorators: [{
1498
+ type: Directive,
1499
+ args: [{
1500
+ selector: '[dbxActionEnforceModified]'
1501
+ }]
1502
+ }], ctorParameters: function () {
1503
+ return [{ type: DbxActionContextStoreSourceInstance, decorators: [{
1504
+ type: Host
1505
+ }] }];
1506
+ }, propDecorators: { enabled: [{
1507
+ type: Input,
1508
+ args: ['[dbxActionEnforceModified]']
1509
+ }] } });
1441
1510
 
1442
1511
  /**
1443
1512
  * Configurable machine that handles components of the ActionContextStore lifecycle.
1513
+ *
1514
+ * It can be configured to activate only once before cleaning itself up. It can be used directly as a DbxActionContextSourceReference in cases where it is created as a one-off action.
1444
1515
  */
1445
- class ActionContextMachine extends ActionContextBaseSource {
1516
+ class DbxActionContextMachine extends DbxActionContextBaseSource {
1446
1517
  constructor(config, source) {
1447
1518
  super(source);
1448
1519
  this.config = config;
1449
1520
  this._isShutdown = true;
1450
1521
  this._handleValueReadySub = new SubscriptionObject();
1522
+ this._successSub = new SubscriptionObject();
1451
1523
  // Handle Value Ready
1452
1524
  this._handleValueReadySub.subscription = this.sourceInstance.valueReady$.subscribe((value) => {
1453
- handleWorkValueReadyFn({ handlerFunction: config.handleValueReady, delegate: new WorkHandlerContextSourceDelegate(this.sourceInstance) })(value);
1525
+ handleWorkValueReadyFn({
1526
+ handlerFunction: config.handleValueReady,
1527
+ delegate: new WorkHandlerContextSourceDelegate(this.sourceInstance)
1528
+ })(value);
1454
1529
  });
1455
1530
  // If this is a one-time use, then destroy it after the first success comes through.
1456
1531
  if (this.config.oneTimeUse) {
@@ -1459,12 +1534,13 @@ class ActionContextMachine extends ActionContextBaseSource {
1459
1534
  });
1460
1535
  }
1461
1536
  if (this.config.onSuccess) {
1462
- this.sourceInstance.success$.subscribe(this.config.onSuccess);
1537
+ this._successSub.subscription = this.sourceInstance.success$.subscribe(this.config.onSuccess);
1463
1538
  }
1464
1539
  }
1465
1540
  destroy() {
1466
1541
  super.destroy();
1467
1542
  this._handleValueReadySub.destroy();
1543
+ this._successSub.destroy();
1468
1544
  this._isShutdown = true;
1469
1545
  }
1470
1546
  get isShutdown() {
@@ -1476,11 +1552,11 @@ class DbxCoreActionModule {
1476
1552
  }
1477
1553
  DbxCoreActionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxCoreActionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1478
1554
  DbxCoreActionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxCoreActionModule, declarations: [DbxActionDirective, DbxActionContextMapDirective, DbxActionFromMapDirective, DbxActionMapSourceDirective,
1479
- DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionDisabledUntilModifiedDirective,
1480
- DbxActionAutoTriggerDirective, DbxActionAutoTriggerValueDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
1555
+ DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective,
1556
+ DbxActionAutoTriggerDirective, dbxActionValueStreamDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
1481
1557
  DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionWorkingComponent], imports: [CommonModule], exports: [DbxActionDirective, DbxActionContextMapDirective, DbxActionFromMapDirective, DbxActionMapSourceDirective,
1482
- DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionDisabledUntilModifiedDirective,
1483
- DbxActionAutoTriggerDirective, DbxActionAutoTriggerValueDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
1558
+ DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective,
1559
+ DbxActionAutoTriggerDirective, dbxActionValueStreamDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
1484
1560
  DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionWorkingComponent] });
1485
1561
  DbxCoreActionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxCoreActionModule, imports: [[
1486
1562
  CommonModule
@@ -1493,19 +1569,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
1493
1569
  ],
1494
1570
  declarations: [
1495
1571
  DbxActionDirective, DbxActionContextMapDirective, DbxActionFromMapDirective, DbxActionMapSourceDirective,
1496
- DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionDisabledUntilModifiedDirective,
1497
- DbxActionAutoTriggerDirective, DbxActionAutoTriggerValueDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
1498
- DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionWorkingComponent
1572
+ DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective,
1573
+ DbxActionAutoTriggerDirective, dbxActionValueStreamDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
1574
+ DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionWorkingComponent,
1499
1575
  ],
1500
1576
  exports: [
1501
1577
  DbxActionDirective, DbxActionContextMapDirective, DbxActionFromMapDirective, DbxActionMapSourceDirective,
1502
- DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionDisabledUntilModifiedDirective,
1503
- DbxActionAutoTriggerDirective, DbxActionAutoTriggerValueDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
1578
+ DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionHandlerDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective,
1579
+ DbxActionAutoTriggerDirective, dbxActionValueStreamDirective, DbxActionAutoModifyDirective, DbxActionValueDirective, DbxActionContextLoggerDirective,
1504
1580
  DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionWorkingComponent
1505
1581
  ]
1506
1582
  }]
1507
1583
  }] });
1508
1584
 
1585
+ function makeDbxActionContextSourceReference(sourceInstance) {
1586
+ return {
1587
+ sourceInstance,
1588
+ destroy: () => 0
1589
+ };
1590
+ }
1591
+
1592
+ /**
1593
+ * Convenience function used within observables for views that need to detect changes after a value changes.
1594
+ *
1595
+ * @param cdRef
1596
+ * @param timeout
1597
+ * @returns
1598
+ */
1599
+ function tapDetectChanges(cdRef, timeout = 0) {
1600
+ return tap$1(() => setTimeout(() => safeDetectChanges(cdRef), timeout));
1601
+ }
1602
+ /**
1603
+ * Triggers a detection change on the input view as long as the view has not been destroyed.
1604
+ *
1605
+ * @param cdRef
1606
+ */
1607
+ function safeDetectChanges(cdRef) {
1608
+ if (!cdRef.destroyed) {
1609
+ cdRef.detectChanges();
1610
+ }
1611
+ }
1612
+ /**
1613
+ * Used to check an injected ElementRef that wraps an ng-content injection point whether or not any content was injected,
1614
+ * or more specifically if the parent component passed any target content to the child. This will still return true if
1615
+ * passed content is empty.
1616
+ *
1617
+ * TS:
1618
+ * @ViewChild('customLoading', { static: false }) customCustom: ElementRef;
1619
+ *
1620
+ * HTML:
1621
+ * <div #customContent>
1622
+ * <ng-content select="[content]"></ng-content>
1623
+ * </div>
1624
+ */
1625
+ function checkNgContentWrapperHasContent(ref) {
1626
+ // https://github.com/angular/angular/issues/26083
1627
+ let hasContent = false;
1628
+ if (ref != null) {
1629
+ const childNodes = ref.nativeElement.childNodes;
1630
+ const hasChildNodes = childNodes && childNodes.length > 0;
1631
+ hasContent = Boolean(hasChildNodes);
1632
+ }
1633
+ return hasContent;
1634
+ }
1635
+
1509
1636
  class DbxButton {
1510
1637
  }
1511
1638
  function ProvideDbxButton(sourceType) {
@@ -1533,7 +1660,7 @@ class DbxActionButtonTriggerDirective extends AbstractSubscriptionDirective {
1533
1660
  this.source.trigger();
1534
1661
  }
1535
1662
  }
1536
- DbxActionButtonTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonTriggerDirective, deps: [{ token: DbxButton, host: true }, { token: ActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Directive });
1663
+ DbxActionButtonTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonTriggerDirective, deps: [{ token: DbxButton, host: true }, { token: DbxActionContextStoreSourceInstance }], target: i0.ɵɵFactoryTarget.Directive });
1537
1664
  DbxActionButtonTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionButtonTriggerDirective, selector: "[dbxActionButtonTrigger]", usesInheritance: true, ngImport: i0 });
1538
1665
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonTriggerDirective, decorators: [{
1539
1666
  type: Directive,
@@ -1543,28 +1670,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
1543
1670
  }], ctorParameters: function () {
1544
1671
  return [{ type: DbxButton, decorators: [{
1545
1672
  type: Host
1546
- }] }, { type: ActionContextStoreSourceInstance }];
1673
+ }] }, { type: DbxActionContextStoreSourceInstance }];
1547
1674
  } });
1548
1675
 
1549
1676
  /**
1550
1677
  * Context used for linking a button to an ActionContext.
1551
1678
  */
1552
1679
  class DbxActionButtonDirective extends DbxActionButtonTriggerDirective {
1553
- constructor(button, source, ngZone) {
1680
+ constructor(button, source, cdRef) {
1554
1681
  super(button, source);
1555
- this.ngZone = ngZone;
1682
+ this.cdRef = cdRef;
1556
1683
  this._workingSub = new SubscriptionObject();
1557
1684
  this._disabledSub = new SubscriptionObject();
1558
1685
  }
1559
1686
  ngOnInit() {
1560
1687
  super.ngOnInit();
1561
1688
  this._workingSub.subscription = this.source.isWorking$.subscribe((working) => {
1562
- // console.log('Working: ', working);
1563
- this.ngZone.run(() => this.button.working = working);
1689
+ this.button.working = working;
1690
+ safeDetectChanges(this.cdRef);
1564
1691
  });
1565
1692
  this._disabledSub.subscription = this.source.isDisabled$.subscribe((disabled) => {
1566
- // console.log('Disabled: ', disabled);
1567
- this.ngZone.run(() => this.button.disabled = disabled);
1693
+ this.button.disabled = disabled;
1694
+ safeDetectChanges(this.cdRef);
1568
1695
  });
1569
1696
  }
1570
1697
  ngOnDestroy() {
@@ -1573,7 +1700,7 @@ class DbxActionButtonDirective extends DbxActionButtonTriggerDirective {
1573
1700
  this._disabledSub.destroy();
1574
1701
  }
1575
1702
  }
1576
- DbxActionButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonDirective, deps: [{ token: DbxButton, host: true }, { token: ActionContextStoreSourceInstance }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
1703
+ DbxActionButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonDirective, deps: [{ token: DbxButton, host: true }, { token: DbxActionContextStoreSourceInstance }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1577
1704
  DbxActionButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: DbxActionButtonDirective, selector: "[dbxActionButton]", usesInheritance: true, ngImport: i0 });
1578
1705
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: DbxActionButtonDirective, decorators: [{
1579
1706
  type: Directive,
@@ -1583,7 +1710,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
1583
1710
  }], ctorParameters: function () {
1584
1711
  return [{ type: DbxButton, decorators: [{
1585
1712
  type: Host
1586
- }] }, { type: ActionContextStoreSourceInstance }, { type: i0.NgZone }];
1713
+ }] }, { type: DbxActionContextStoreSourceInstance }, { type: i0.ChangeDetectorRef }];
1587
1714
  } });
1588
1715
 
1589
1716
  const expandClickableAnchorLinkTreeNode = expandTreeFunction({
@@ -2467,12 +2594,12 @@ class AbstractActionFilterSourceDirective extends AbstractFilterSourceDirective
2467
2594
  }
2468
2595
  }
2469
2596
  AbstractActionFilterSourceDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AbstractActionFilterSourceDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2470
- AbstractActionFilterSourceDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: AbstractActionFilterSourceDirective, viewQueries: [{ propertyName: "filterAction", first: true, predicate: ActionContextStoreSourceInstance, descendants: true, read: ActionContextStoreSourceInstance, static: true }], usesInheritance: true, ngImport: i0 });
2597
+ AbstractActionFilterSourceDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.4", type: AbstractActionFilterSourceDirective, viewQueries: [{ propertyName: "filterAction", first: true, predicate: DbxActionContextStoreSourceInstance, descendants: true, read: DbxActionContextStoreSourceInstance, static: true }], usesInheritance: true, ngImport: i0 });
2471
2598
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AbstractActionFilterSourceDirective, decorators: [{
2472
2599
  type: Directive
2473
2600
  }], propDecorators: { filterAction: [{
2474
2601
  type: ViewChild,
2475
- args: [ActionContextStoreSourceInstance, { static: true, read: ActionContextStoreSourceInstance }]
2602
+ args: [DbxActionContextStoreSourceInstance, { static: true, read: DbxActionContextStoreSourceInstance }]
2476
2603
  }] } });
2477
2604
 
2478
2605
  /**
@@ -3251,53 +3378,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImpor
3251
3378
  type: NgModule
3252
3379
  }] });
3253
3380
 
3254
- /**
3255
- * Convenience function used within observables for views that need to detect changes after a value changes.
3256
- *
3257
- * @param cdRef
3258
- * @param timeout
3259
- * @returns
3260
- */
3261
- function tapDetectChanges(cdRef, timeout = 0) {
3262
- return tap$1(() => setTimeout(() => safeDetectChanges(cdRef), timeout));
3263
- }
3264
- /**
3265
- * Triggers a detection change on the input view as long as the view has not been destroyed.
3266
- *
3267
- * @param cdRef
3268
- */
3269
- function safeDetectChanges(cdRef) {
3270
- if (!cdRef.destroyed) {
3271
- cdRef.detectChanges();
3272
- }
3273
- }
3274
- /**
3275
- * Used to check an injected ElementRef that wraps an ng-content injection point whether or not any content was injected,
3276
- * or more specifically if the parent component passed any target content to the child. This will still return true if
3277
- * passed content is empty.
3278
- *
3279
- * TS:
3280
- * @ViewChild('customLoading', { static: false }) customCustom: ElementRef;
3281
- *
3282
- * HTML:
3283
- * <div #customContent>
3284
- * <ng-content select="[content]"></ng-content>
3285
- * </div>
3286
- */
3287
- function checkNgContentWrapperHasContent(ref) {
3288
- // https://github.com/angular/angular/issues/26083
3289
- let hasContent = false;
3290
- if (ref != null) {
3291
- const childNodes = ref.nativeElement.childNodes;
3292
- const hasChildNodes = childNodes && childNodes.length > 0;
3293
- hasContent = Boolean(hasChildNodes);
3294
- }
3295
- return hasContent;
3296
- }
3297
-
3298
3381
  /**
3299
3382
  * Generated bundle index. Do not edit.
3300
3383
  */
3301
3384
 
3302
- export { APP_ACTION_DISABLED_DIRECTIVE_KEY, APP_ACTION_DISABLED_UNTIL_MODIFIED_DIRECTIVE_KEY, AbstractActionFilterSourceDirective, AbstractDbxAnchorDirective, AbstractDbxButtonDirective, AbstractDbxFilterMapInstanceDirective, AbstractDbxInjectedDirective, AbstractFilterSourceConnectorDirective, AbstractFilterSourceDirective, AbstractLockSetSubscriptionDirective, AbstractSubscriptionDirective, AbstractTransitionDirective, AbstractTransitionWatcherDirective, ActionContextBaseSource, ActionContextMachine, ActionContextStore, ActionContextStoreSource, ActionContextStoreSourceInstance, ActionContextStoreSourceMap, ActionSnackbarDefaultType, ActionSnackbarEventType, ActionState, AnchorType, DBX_INJECTED_COMPONENT_DATA, DEFAULT_ACTION_DISABLED_KEY, DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY, DEFAULT_SNACKBAR_DIRECTIVE_DURATION, DEFAULT_SNACKBAR_UNDO_DIRECTIVE_DURATION, DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN, DEFAULT_STORAGE_OBJECT_TOKEN, DateDistancePipe, DateFormatDistancePipe, DateFromToTimePipe, DbxActionAutoModifyDirective, DbxActionAutoTriggerDirective, DbxActionAutoTriggerValueDirective, DbxActionButtonDirective, DbxActionButtonTriggerDirective, DbxActionContextLoggerDirective, DbxActionContextMapDirective, DbxActionContextMapDirectiveSourceInstance, DbxActionDirective, DbxActionDisabledDirective, DbxActionDisabledUntilModifiedDirective, DbxActionFromMapDirective, DbxActionHandlerDirective, DbxActionMapSourceDirective, DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionValueDirective, DbxActionWorkingComponent, DbxAnchor, DbxAngularRouterService, DbxButton, DbxButtonDirective, DbxButtonSegueDirective, DbxCoreActionModule, DbxCoreAngularRouterSegueModule, DbxCoreButtonModule, DbxCoreFilterModule, DbxCoreUIRouterSegueModule, DbxDatePipeModule, DbxFilterMapDirective, DbxFilterMapSourceConnectorDirective, DbxFilterMapSourceDirective, DbxFilterSourceConnectorDirective, DbxFilterSourceDirective, DbxInjectedComponent, DbxInjectedComponentInstance, DbxInjectedComponentModule, DbxLoadingButtonDirective, DbxRouterService, DbxRouterTransitionEventType, DbxRouterTransitionService, DbxStorageModule, DbxUIRouterService, FullLocalStorageObject, InstantStorageAccessor, LimitedStorageAccessor, MemoryStorageObject, MinutesStringPipe, ProvideActionStoreSource, ProvideDbxAnchor, ProvideDbxButton, ProvideFilterSource, ProvideFilterSourceConnector, ProvideSecondaryActionStoreSource, SecondaryActionContextStoreSource, SimpleStorageAccessor, SimpleStorageAccessorFactory, StorageAccessor, StringStorageAccessor, StringifySimpleStorageAccessorConverter, TimeDistanceCountdownPipe, TimeDistancePipe, ToJsDatePipe, ToMinutesPipe, WorkHandlerContext, WorkHandlerContextSourceDelegate, WrapperSimpleStorageAccessorDelegate, actionContextHasNoErrorAndIsModifiedAndCanTrigger, actionContextIsModifiedAndCanTrigger, actionContextStoreSourceInstanceFactory, actionContextStoreSourcePipe, anchorTypeForAnchor, canReadyValue, canTriggerAction, canTriggerActionState, checkNgContentWrapperHasContent, defaultStorageObjectFactory, expandClickableAnchorLinkTree, expandClickableAnchorLinkTreeNode, expandClickableAnchorLinkTrees, filterTransitionEvent, filterTransitionSuccess, flattenExpandedClickableAnchorLinkTree, flattenExpandedClickableAnchorLinkTreeToLinks, handleWorkValueReadyFn, handleWorkValueReadyWithConfigFn, isActionContextDisabled, isActionContextEnabled, isDisabledActionContextState, isIdleActionState, isWorkingActionState, mapRefStringObsToSegueRefObs, mergeDbxInjectedComponentConfigs, pipeActionStore, refStringToSegueRef, safeDetectChanges, successTransition, tapDetectChanges, useActionStore };
3385
+ export { APP_ACTION_DISABLED_DIRECTIVE_KEY, APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY, AbstractActionFilterSourceDirective, AbstractDbxAnchorDirective, AbstractDbxButtonDirective, AbstractDbxFilterMapInstanceDirective, AbstractDbxInjectedDirective, AbstractFilterSourceConnectorDirective, AbstractFilterSourceDirective, AbstractLockSetSubscriptionDirective, AbstractSubscriptionDirective, AbstractTransitionDirective, AbstractTransitionWatcherDirective, ActionContextStore, ActionContextStoreSource, ActionContextStoreSourceMap, AnchorType, DBX_INJECTED_COMPONENT_DATA, 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, DbxActionMapSourceDirective, DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionState, DbxActionSuccessComponent, DbxActionSuccessDirective, DbxActionValueDirective, DbxActionWorkingComponent, DbxAnchor, DbxAngularRouterService, DbxButton, DbxButtonDirective, DbxButtonSegueDirective, DbxCoreActionModule, DbxCoreAngularRouterSegueModule, DbxCoreButtonModule, DbxCoreFilterModule, DbxCoreUIRouterSegueModule, DbxDatePipeModule, DbxFilterMapDirective, DbxFilterMapSourceConnectorDirective, DbxFilterMapSourceDirective, DbxFilterSourceConnectorDirective, DbxFilterSourceDirective, DbxInjectedComponent, DbxInjectedComponentInstance, DbxInjectedComponentModule, DbxLoadingButtonDirective, DbxRouterService, DbxRouterTransitionEventType, DbxRouterTransitionService, DbxStorageModule, DbxUIRouterService, FullLocalStorageObject, InstantStorageAccessor, LimitedStorageAccessor, MemoryStorageObject, MinutesStringPipe, ProvideActionStoreSource, ProvideDbxAnchor, ProvideDbxButton, ProvideFilterSource, ProvideFilterSourceConnector, ProvideSecondaryActionStoreSource, SecondaryActionContextStoreSource, SimpleStorageAccessor, SimpleStorageAccessorFactory, StorageAccessor, StringStorageAccessor, StringifySimpleStorageAccessorConverter, TimeDistanceCountdownPipe, TimeDistancePipe, ToJsDatePipe, ToMinutesPipe, WorkHandlerContext, WorkHandlerContextSourceDelegate, WrapperSimpleStorageAccessorDelegate, actionContextHasNoErrorAndIsModifiedAndCanTrigger, actionContextIsModifiedAndCanTrigger, actionContextStoreSourceInstanceFactory, actionContextStoreSourcePipe, anchorTypeForAnchor, canReadyValue, canTriggerAction, canTriggerActionState, checkNgContentWrapperHasContent, dbxActionValueStreamDirective, defaultStorageObjectFactory, expandClickableAnchorLinkTree, expandClickableAnchorLinkTreeNode, expandClickableAnchorLinkTrees, filterTransitionEvent, filterTransitionSuccess, flattenExpandedClickableAnchorLinkTree, flattenExpandedClickableAnchorLinkTreeToLinks, handleWorkValueReadyFn, handleWorkValueReadyWithConfigFn, isActionContextDisabled, isActionContextEnabled, isDisabledActionContextState, isIdleActionState, isWorkingActionState, loadingStateForActionContextState, loadingStateTypeForActionContextState, loadingStateTypeForActionState, makeDbxActionContextSourceReference, mapRefStringObsToSegueRefObs, mergeDbxInjectedComponentConfigs, pipeActionStore, refStringToSegueRef, safeDetectChanges, successTransition, tapDetectChanges, useActionStore };
3303
3386
  //# sourceMappingURL=dereekb-dbx-core.mjs.map