@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.
- package/esm2020/lib/form/action/form.action.directive.mjs +3 -2
- package/esm2020/lib/formly/field/value/array/array.field.mjs +3 -2
- package/esm2020/lib/formly/field/wrapper/expandable.wrapper.component.mjs +4 -4
- package/esm2020/lib/formly/field/wrapper/expandable.wrapper.delegate.mjs +6 -6
- package/esm2020/lib/formly/field/wrapper/flex.wrapper.component.mjs +4 -4
- package/esm2020/lib/formly/field/wrapper/info.wrapper.component.mjs +2 -2
- package/esm2020/lib/formly/field/wrapper/section.wrapper.component.mjs +3 -3
- package/esm2020/lib/formly/field/wrapper/subsection.wrapper.component.mjs +3 -3
- package/esm2020/lib/formly/field/wrapper/wrapper.mjs +3 -5
- package/esm2020/lib/formly/formly.form.component.mjs +34 -18
- package/fesm2015/dereekb-dbx-form.mjs +59 -49
- package/fesm2015/dereekb-dbx-form.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-form.mjs +53 -38
- package/fesm2020/dereekb-dbx-form.mjs.map +1 -1
- package/lib/formly/field/value/array/_array.scss +2 -0
- package/lib/formly/field/value/array/array.field.d.ts +3 -2
- package/lib/formly/field/wrapper/expandable.wrapper.delegate.d.ts +3 -6
- package/lib/formly/field/wrapper/flex.wrapper.component.d.ts +2 -6
- package/lib/formly/field/wrapper/info.wrapper.component.d.ts +2 -5
- package/lib/formly/field/wrapper/section.wrapper.component.d.ts +1 -4
- package/lib/formly/field/wrapper/subsection.wrapper.component.d.ts +1 -4
- package/lib/formly/field/wrapper/wrapper.d.ts +2 -2
- package/package.json +3 -3
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
685
|
+
return this.props;
|
|
687
686
|
}
|
|
688
687
|
get breakpoint() {
|
|
689
|
-
|
|
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
|
|
694
|
-
return (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
757
|
+
return this.props;
|
|
762
758
|
}
|
|
763
759
|
get hasValueFn() {
|
|
764
|
-
var _a
|
|
765
|
-
return (
|
|
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
|
|
769
|
-
let 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 = (
|
|
767
|
+
const firstFieldGroup = (_c = this.field.fieldGroup) === null || _c === void 0 ? void 0 : _c[0];
|
|
772
768
|
if (firstFieldGroup) {
|
|
773
|
-
label = (
|
|
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
|
|
801
|
-
return (
|
|
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-
|
|
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-
|
|
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
|
-
|
|
1037
|
-
|
|
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
|
-
}),
|
|
3974
|
-
const
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
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
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
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);
|