@dereekb/dbx-form 8.7.2 → 8.7.5

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.
@@ -5,7 +5,7 @@ import { CommonModule } from '@angular/common';
5
5
  import * as i1$1 from '@dereekb/dbx-web';
6
6
  import { DbxActionTransitionSafetyDirective, DbxTextModule, DbxLoadingModule, DbxFlexLayoutModule, DbxSectionLayoutModule, DbxRouterAnchorModule, AbstractDbxSelectionListWrapperDirective, DEFAULT_LIST_WRAPPER_DIRECTIVE_TEMPLATE, AbstractDbxSelectionListViewDirective, addConfigToValueListItems, provideDbxListView, AbstractDbxValueListViewItemComponent, DbxButtonModule, DbxListLayoutModule, mapCompactModeObs, DbxBarLayoutModule } from '@dereekb/dbx-web';
7
7
  import { isPast, addSeconds, isSameMinute, startOfDay, isSameDay, addMinutes } from 'date-fns';
8
- import { BehaviorSubject, switchMap, first, exhaustMap, of, catchError, delay, filter, combineLatest, map, distinctUntilChanged, mergeMap, shareReplay, startWith, debounceTime, Subject, skipWhile, interval, tap, merge, throttleTime, scan } from 'rxjs';
8
+ import { BehaviorSubject, switchMap, first, exhaustMap, of, catchError, delay, filter, combineLatest, map, distinctUntilChanged, mergeMap, shareReplay, startWith, debounceTime, Subject, skipWhile, interval, tap, merge, throttleTime, scan, timer } from 'rxjs';
9
9
  import { LockSet, SubscriptionObject, asObservable, loadingStateHasFinishedLoading, switchMapMaybeObs, filterMaybe, switchMapMaybeDefault, SimpleLoadingContext, startWithBeginLoading, mapLoadingStateResults, successResult, ListLoadingStateContextInstance, isListLoadingStateEmpty, LoadingStateContextInstance, skipFirstMaybe, asyncPusherCache, scanCount } from '@dereekb/rxjs';
10
10
  import * as i2 from '@dereekb/dbx-core';
11
11
  import { AbstractSubscriptionDirective, safeDetectChanges, DbxInjectionComponentModule, DbxDatePipeModule, mergeDbxInjectionComponentConfigs, tapDetectChanges } from '@dereekb/dbx-core';
@@ -160,7 +160,8 @@ class DbxActionFormDirective {
160
160
  var _a, _b;
161
161
  // Use both changes count and whether or not something was in the past to guage whether or not the item has been touched.
162
162
  // Angular Form's untouched is whether or not focus has been lost but we can still receive value updates.
163
- // More than a certain amount of updates implies that it is being typed into.
163
+ // More than a certain amount of updates implies that it is being typed into/used.
164
+ // 3 changes and 2 seconds are arbitrary values derived from guesses about any slow/late changes that may come from external directives for setup.
164
165
  const isProbablyTouched = !event.untouched || (((_a = event.changesCount) !== null && _a !== void 0 ? _a : 0) > 3 && isPast(addSeconds((_b = event.lastResetAt) !== null && _b !== void 0 ? _b : new Date(), 2)));
165
166
  let validatorObs;
166
167
  const initialIsValidCheck = event.isComplete;
@@ -617,7 +618,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
617
618
 
618
619
  class DbxFormInfoWrapperComponent extends FieldWrapper {
619
620
  get infoWrapper() {
620
- return this.props.infoWrapper;
621
+ return this.props;
621
622
  }
622
623
  onInfoClick() {
623
624
  this.infoWrapper.onInfoClick();
@@ -656,12 +657,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
656
657
 
657
658
  class DbxFormSectionWrapperComponent extends FieldWrapper {
658
659
  get header() {
659
- var _a;
660
- return (_a = this.props.sectionWrapper) === null || _a === void 0 ? void 0 : _a.header;
660
+ return this.props.header;
661
661
  }
662
662
  get hint() {
663
- var _a;
664
- return (_a = this.props.sectionWrapper) === null || _a === void 0 ? void 0 : _a.hint;
663
+ return this.props.hint;
665
664
  }
666
665
  }
667
666
  DbxFormSectionWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFormSectionWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
@@ -683,15 +682,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
683
682
 
684
683
  class DbxFormFlexWrapperComponent extends FieldWrapper {
685
684
  get flexWrapper() {
686
- return this.props.flexWrapper;
685
+ return this.props;
687
686
  }
688
687
  get breakpoint() {
689
- var _a;
690
- return (_a = this.flexWrapper) === null || _a === void 0 ? void 0 : _a.breakpoint;
688
+ return this.flexWrapper.breakpoint;
691
689
  }
692
690
  get relative() {
693
- var _a, _b;
694
- return (_b = (_a = this.flexWrapper) === null || _a === void 0 ? void 0 : _a.relative) !== null && _b !== void 0 ? _b : false;
691
+ var _a;
692
+ return (_a = this.flexWrapper.relative) !== null && _a !== void 0 ? _a : false;
695
693
  }
696
694
  }
697
695
  DbxFormFlexWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFormFlexWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
@@ -713,12 +711,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
713
711
 
714
712
  class DbxFormSubsectionWrapperComponent extends FieldWrapper {
715
713
  get header() {
716
- var _a;
717
- return (_a = this.props.subsectionWrapper) === null || _a === void 0 ? void 0 : _a.header;
714
+ return this.props.header;
718
715
  }
719
716
  get hint() {
720
- var _a;
721
- return (_a = this.props.subsectionWrapper) === null || _a === void 0 ? void 0 : _a.hint;
717
+ return this.props.hint;
722
718
  }
723
719
  }
724
720
  DbxFormSubsectionWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFormSubsectionWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
@@ -752,25 +748,25 @@ class AbstractFormExpandableSectionWrapperDirective extends FieldWrapper {
752
748
  else {
753
749
  return this.hasValue$;
754
750
  }
755
- }), shareReplay(1));
751
+ }), distinctUntilChanged(), shareReplay(1));
756
752
  this.hasValue$ = this.formControl$.pipe(switchMap((x) => x.valueChanges.pipe(startWith(x.value), map((value) => {
757
753
  return this.hasValueFn(value);
758
754
  }), shareReplay(1))));
759
755
  }
760
756
  get expandableSection() {
761
- return this.props.expandWrapper;
757
+ return this.props;
762
758
  }
763
759
  get hasValueFn() {
764
- var _a, _b;
765
- return (_b = (_a = this.expandableSection) === null || _a === void 0 ? void 0 : _a.hasValueFn) !== null && _b !== void 0 ? _b : DEFAULT_HAS_VALUE_FN;
760
+ var _a;
761
+ return (_a = this.expandableSection.hasValueFn) !== null && _a !== void 0 ? _a : DEFAULT_HAS_VALUE_FN;
766
762
  }
767
763
  get expandLabel() {
768
- var _a, _b, _c, _d, _e, _f, _g;
769
- let label = (_b = (_a = this.expandableSection) === null || _a === void 0 ? void 0 : _a.expandLabel) !== null && _b !== void 0 ? _b : (_d = (_c = this.field) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.label;
764
+ var _a, _b, _c, _d, _e;
765
+ let label = (_a = this.expandableSection.expandLabel) !== null && _a !== void 0 ? _a : (_b = this.field.props) === null || _b === void 0 ? void 0 : _b.label;
770
766
  if (label == null) {
771
- const firstFieldGroup = (_e = this.field.fieldGroup) === null || _e === void 0 ? void 0 : _e[0];
767
+ const firstFieldGroup = (_c = this.field.fieldGroup) === null || _c === void 0 ? void 0 : _c[0];
772
768
  if (firstFieldGroup) {
773
- label = (_g = (_f = firstFieldGroup.props) === null || _f === void 0 ? void 0 : _f.label) !== null && _g !== void 0 ? _g : firstFieldGroup.key;
769
+ label = (_e = (_d = firstFieldGroup.props) === null || _d === void 0 ? void 0 : _d.label) !== null && _e !== void 0 ? _e : firstFieldGroup.key;
774
770
  }
775
771
  }
776
772
  return label;
@@ -797,8 +793,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
797
793
  */
798
794
  class DbxFormExpandWrapperComponent extends AbstractFormExpandableSectionWrapperDirective {
799
795
  get buttonType() {
800
- var _a, _b;
801
- return (_b = (_a = this.expandableSection) === null || _a === void 0 ? void 0 : _a.buttonType) !== null && _b !== void 0 ? _b : 'button';
796
+ var _a;
797
+ return (_a = this.expandableSection.buttonType) !== null && _a !== void 0 ? _a : 'button';
802
798
  }
803
799
  }
804
800
  DbxFormExpandWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFormExpandWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
@@ -808,7 +804,7 @@ DbxFormExpandWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "1
808
804
  <ng-container #fieldComponent></ng-container>
809
805
  </ng-container>
810
806
  <ng-container *ngSwitchCase="false">
811
- <span class="dbx-form-expandable-section-button" (click)="open()">{{ expandLabel }}</span>
807
+ <span class="dbx-form-expand-wrapper-button" (click)="open()">{{ expandLabel }}</span>
812
808
  </ng-container>
813
809
  </ng-container>
814
810
  `, isInline: true, directives: [{ type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }], pipes: { "async": i5.AsyncPipe } });
@@ -821,7 +817,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
821
817
  <ng-container #fieldComponent></ng-container>
822
818
  </ng-container>
823
819
  <ng-container *ngSwitchCase="false">
824
- <span class="dbx-form-expandable-section-button" (click)="open()">{{ expandLabel }}</span>
820
+ <span class="dbx-form-expand-wrapper-button" (click)="open()">{{ expandLabel }}</span>
825
821
  </ng-container>
826
822
  </ng-container>
827
823
  `
@@ -1033,10 +1029,8 @@ function flexLayoutWrapper(fieldConfigs, { relative, breakpoint, size: defaultSi
1033
1029
  fieldGroupClassName: 'dbx-flex-group',
1034
1030
  // fieldGroupClassName: 'field-layout-group',
1035
1031
  props: {
1036
- flexWrapper: {
1037
- breakpoint,
1038
- relative
1039
- }
1032
+ breakpoint,
1033
+ relative
1040
1034
  },
1041
1035
  fieldGroup: fieldConfigs.map((inputConfig) => {
1042
1036
  const fieldConfig = checkIsFieldFlexLayoutGroupFieldConfig(inputConfig)
@@ -2757,7 +2751,7 @@ function repeatArrayField(config) {
2757
2751
  addText,
2758
2752
  removeText
2759
2753
  })), { fieldArray: {
2760
- fieldGroup: repeatFieldGroup
2754
+ fieldGroup: asArray(repeatFieldGroup)
2761
2755
  } }));
2762
2756
  }
2763
2757
 
@@ -3970,23 +3964,39 @@ class DbxFormlyFormComponent extends AbstractSubscriptionDirective {
3970
3964
  changesSinceLastResetCount: 0,
3971
3965
  isFormValid: false,
3972
3966
  isFormDisabled: false
3973
- }), map(({ changesSinceLastResetCount, isFormValid, isFormDisabled }) => {
3974
- const isReset = changesSinceLastResetCount <= 1; // first emission after reset is the first value.
3975
- const complete = isFormValid;
3976
- const nextState = {
3977
- isComplete: complete,
3978
- state: isReset ? DbxFormState.RESET : DbxFormState.USED,
3979
- status: this.form.status,
3980
- untouched: this.form.untouched,
3981
- pristine: this.form.pristine,
3982
- changesCount: changesSinceLastResetCount,
3983
- lastResetAt,
3984
- disabled: this.disabled,
3985
- isDisabled: isFormDisabled
3967
+ }), switchMap(({ changesSinceLastResetCount, isFormValid, isFormDisabled }) => {
3968
+ const nextState = () => {
3969
+ const isReset = changesSinceLastResetCount <= 1; // first emission after reset is the first value.
3970
+ const complete = isFormValid;
3971
+ const nextState = {
3972
+ isComplete: complete,
3973
+ state: isReset ? DbxFormState.RESET : DbxFormState.USED,
3974
+ status: this.form.status,
3975
+ untouched: this.form.untouched,
3976
+ pristine: this.form.pristine,
3977
+ changesCount: changesSinceLastResetCount,
3978
+ lastResetAt,
3979
+ disabled: this.disabled,
3980
+ isDisabled: isFormDisabled
3981
+ };
3982
+ return nextState;
3986
3983
  };
3987
- // console.log('Change: ', nextState);
3988
- return nextState;
3989
- }))), shareReplay(1));
3984
+ const state = nextState();
3985
+ if (isFormValid && this.form.untouched) {
3986
+ return timer(150, 200).pipe(
3987
+ // every 200 ms check if the form is now marked touched, then push a new state
3988
+ filter(() => this.form.touched), map(() => nextState()),
3989
+ // only push the new state once
3990
+ first(),
3991
+ // send the first value immediately
3992
+ startWith(state));
3993
+ }
3994
+ else {
3995
+ return of(state);
3996
+ }
3997
+ })
3998
+ // tapLog('Change: ')
3999
+ )), shareReplay(1));
3990
4000
  }
3991
4001
  ngOnInit() {
3992
4002
  this.context.setDelegate(this);