@dereekb/dbx-form 8.7.3 → 8.7.6
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.component.mjs +3 -2
- package/esm2020/lib/formly/field/value/array/array.field.mjs +3 -2
- package/esm2020/lib/formly/field/value/text/text.field.mjs +5 -4
- 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 +65 -53
- package/fesm2015/dereekb-dbx-form.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-form.mjs +59 -42
- 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/value/text/text.field.d.ts +5 -3
- 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
|
@@ -10,7 +10,7 @@ import { AbstractSubscriptionDirective, safeDetectChanges, DbxInjectionComponent
|
|
|
10
10
|
import * as i1$1 from '@dereekb/dbx-web';
|
|
11
11
|
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';
|
|
12
12
|
import { isPast, addSeconds, isSameMinute, startOfDay, isSameDay, addMinutes } from 'date-fns';
|
|
13
|
-
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';
|
|
13
|
+
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';
|
|
14
14
|
import { LockSet, SubscriptionObject, asObservable, loadingStateHasFinishedLoading, switchMapMaybeObs, filterMaybe, switchMapMaybeDefault, SimpleLoadingContext, startWithBeginLoading, mapLoadingStateResults, successResult, ListLoadingStateContextInstance, isListLoadingStateEmpty, LoadingStateContextInstance, skipFirstMaybe, asyncPusherCache, scanCount } from '@dereekb/rxjs';
|
|
15
15
|
import * as i1$4 from '@ngx-formly/core';
|
|
16
16
|
import { FieldType, FieldWrapper, FormlyModule, FieldArrayType } from '@ngx-formly/core';
|
|
@@ -159,7 +159,8 @@ class DbxActionFormDirective {
|
|
|
159
159
|
return this.form.getValue().pipe(first(), exhaustMap((value) => {
|
|
160
160
|
// Use both changes count and whether or not something was in the past to guage whether or not the item has been touched.
|
|
161
161
|
// Angular Form's untouched is whether or not focus has been lost but we can still receive value updates.
|
|
162
|
-
// More than a certain amount of updates implies that it is being typed into.
|
|
162
|
+
// More than a certain amount of updates implies that it is being typed into/used.
|
|
163
|
+
// 3 changes and 2 seconds are arbitrary values derived from guesses about any slow/late changes that may come from external directives for setup.
|
|
163
164
|
const isProbablyTouched = !event.untouched || ((event.changesCount ?? 0) > 3 && isPast(addSeconds(event.lastResetAt ?? new Date(), 2)));
|
|
164
165
|
let validatorObs;
|
|
165
166
|
const initialIsValidCheck = event.isComplete;
|
|
@@ -601,7 +602,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
601
602
|
|
|
602
603
|
class DbxFormInfoWrapperComponent extends FieldWrapper {
|
|
603
604
|
get infoWrapper() {
|
|
604
|
-
return this.props
|
|
605
|
+
return this.props;
|
|
605
606
|
}
|
|
606
607
|
onInfoClick() {
|
|
607
608
|
this.infoWrapper.onInfoClick();
|
|
@@ -640,10 +641,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
640
641
|
|
|
641
642
|
class DbxFormSectionWrapperComponent extends FieldWrapper {
|
|
642
643
|
get header() {
|
|
643
|
-
return this.props.
|
|
644
|
+
return this.props.header;
|
|
644
645
|
}
|
|
645
646
|
get hint() {
|
|
646
|
-
return this.props.
|
|
647
|
+
return this.props.hint;
|
|
647
648
|
}
|
|
648
649
|
}
|
|
649
650
|
DbxFormSectionWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFormSectionWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -665,13 +666,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
665
666
|
|
|
666
667
|
class DbxFormFlexWrapperComponent extends FieldWrapper {
|
|
667
668
|
get flexWrapper() {
|
|
668
|
-
return this.props
|
|
669
|
+
return this.props;
|
|
669
670
|
}
|
|
670
671
|
get breakpoint() {
|
|
671
|
-
return this.flexWrapper
|
|
672
|
+
return this.flexWrapper.breakpoint;
|
|
672
673
|
}
|
|
673
674
|
get relative() {
|
|
674
|
-
return this.flexWrapper
|
|
675
|
+
return this.flexWrapper.relative ?? false;
|
|
675
676
|
}
|
|
676
677
|
}
|
|
677
678
|
DbxFormFlexWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFormFlexWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -693,10 +694,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
693
694
|
|
|
694
695
|
class DbxFormSubsectionWrapperComponent extends FieldWrapper {
|
|
695
696
|
get header() {
|
|
696
|
-
return this.props.
|
|
697
|
+
return this.props.header;
|
|
697
698
|
}
|
|
698
699
|
get hint() {
|
|
699
|
-
return this.props.
|
|
700
|
+
return this.props.hint;
|
|
700
701
|
}
|
|
701
702
|
}
|
|
702
703
|
DbxFormSubsectionWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFormSubsectionWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -730,19 +731,19 @@ class AbstractFormExpandableSectionWrapperDirective extends FieldWrapper {
|
|
|
730
731
|
else {
|
|
731
732
|
return this.hasValue$;
|
|
732
733
|
}
|
|
733
|
-
}), shareReplay(1));
|
|
734
|
+
}), distinctUntilChanged(), shareReplay(1));
|
|
734
735
|
this.hasValue$ = this.formControl$.pipe(switchMap((x) => x.valueChanges.pipe(startWith(x.value), map((value) => {
|
|
735
736
|
return this.hasValueFn(value);
|
|
736
737
|
}), shareReplay(1))));
|
|
737
738
|
}
|
|
738
739
|
get expandableSection() {
|
|
739
|
-
return this.props
|
|
740
|
+
return this.props;
|
|
740
741
|
}
|
|
741
742
|
get hasValueFn() {
|
|
742
|
-
return this.expandableSection
|
|
743
|
+
return this.expandableSection.hasValueFn ?? DEFAULT_HAS_VALUE_FN;
|
|
743
744
|
}
|
|
744
745
|
get expandLabel() {
|
|
745
|
-
let label = this.expandableSection
|
|
746
|
+
let label = this.expandableSection.expandLabel ?? this.field.props?.label;
|
|
746
747
|
if (label == null) {
|
|
747
748
|
const firstFieldGroup = this.field.fieldGroup?.[0];
|
|
748
749
|
if (firstFieldGroup) {
|
|
@@ -773,7 +774,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
773
774
|
*/
|
|
774
775
|
class DbxFormExpandWrapperComponent extends AbstractFormExpandableSectionWrapperDirective {
|
|
775
776
|
get buttonType() {
|
|
776
|
-
return this.expandableSection
|
|
777
|
+
return this.expandableSection.buttonType ?? 'button';
|
|
777
778
|
}
|
|
778
779
|
}
|
|
779
780
|
DbxFormExpandWrapperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFormExpandWrapperComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -783,7 +784,7 @@ DbxFormExpandWrapperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "1
|
|
|
783
784
|
<ng-container #fieldComponent></ng-container>
|
|
784
785
|
</ng-container>
|
|
785
786
|
<ng-container *ngSwitchCase="false">
|
|
786
|
-
<span class="dbx-form-
|
|
787
|
+
<span class="dbx-form-expand-wrapper-button" (click)="open()">{{ expandLabel }}</span>
|
|
787
788
|
</ng-container>
|
|
788
789
|
</ng-container>
|
|
789
790
|
`, isInline: true, directives: [{ type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }], pipes: { "async": i5.AsyncPipe } });
|
|
@@ -796,7 +797,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
796
797
|
<ng-container #fieldComponent></ng-container>
|
|
797
798
|
</ng-container>
|
|
798
799
|
<ng-container *ngSwitchCase="false">
|
|
799
|
-
<span class="dbx-form-
|
|
800
|
+
<span class="dbx-form-expand-wrapper-button" (click)="open()">{{ expandLabel }}</span>
|
|
800
801
|
</ng-container>
|
|
801
802
|
</ng-container>
|
|
802
803
|
`
|
|
@@ -1009,10 +1010,8 @@ function flexLayoutWrapper(fieldConfigs, { relative, breakpoint, size: defaultSi
|
|
|
1009
1010
|
fieldGroupClassName: 'dbx-flex-group',
|
|
1010
1011
|
// fieldGroupClassName: 'field-layout-group',
|
|
1011
1012
|
props: {
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
relative
|
|
1015
|
-
}
|
|
1013
|
+
breakpoint,
|
|
1014
|
+
relative
|
|
1016
1015
|
},
|
|
1017
1016
|
fieldGroup: fieldConfigs.map((inputConfig) => {
|
|
1018
1017
|
const fieldConfig = checkIsFieldFlexLayoutGroupFieldConfig(inputConfig)
|
|
@@ -2664,7 +2663,8 @@ class DbxFormRepeatArrayTypeComponent extends FieldArrayType {
|
|
|
2664
2663
|
return;
|
|
2665
2664
|
}
|
|
2666
2665
|
this.remove(currentIndex);
|
|
2667
|
-
this.add(targetIndex, targetValue);
|
|
2666
|
+
this.add(targetIndex, targetValue, { markAsDirty: true });
|
|
2667
|
+
this.formControl.markAsTouched();
|
|
2668
2668
|
}
|
|
2669
2669
|
drop(event) {
|
|
2670
2670
|
this.swapIndexes(event.previousIndex, event.currentIndex);
|
|
@@ -2797,7 +2797,7 @@ function repeatArrayField(config) {
|
|
|
2797
2797
|
removeText
|
|
2798
2798
|
}),
|
|
2799
2799
|
fieldArray: {
|
|
2800
|
-
fieldGroup: repeatFieldGroup
|
|
2800
|
+
fieldGroup: asArray(repeatFieldGroup)
|
|
2801
2801
|
}
|
|
2802
2802
|
});
|
|
2803
2803
|
}
|
|
@@ -3451,7 +3451,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
3451
3451
|
}] });
|
|
3452
3452
|
|
|
3453
3453
|
function textField(config) {
|
|
3454
|
-
const { key, pattern, minLength, maxLength
|
|
3454
|
+
const { key, pattern, minLength, maxLength, inputType: type = 'text' } = config;
|
|
3455
3455
|
return formlyField({
|
|
3456
3456
|
key,
|
|
3457
3457
|
type: 'input',
|
|
@@ -3464,14 +3464,15 @@ function textField(config) {
|
|
|
3464
3464
|
});
|
|
3465
3465
|
}
|
|
3466
3466
|
function textAreaField(config) {
|
|
3467
|
-
const { key, rows = 3, minLength, maxLength
|
|
3467
|
+
const { key, rows = 3, pattern, minLength, maxLength } = config;
|
|
3468
3468
|
return formlyField({
|
|
3469
3469
|
key,
|
|
3470
3470
|
type: 'textarea',
|
|
3471
3471
|
...propsForFieldConfig(config, {
|
|
3472
3472
|
rows,
|
|
3473
3473
|
minLength,
|
|
3474
|
-
maxLength
|
|
3474
|
+
maxLength,
|
|
3475
|
+
pattern
|
|
3475
3476
|
})
|
|
3476
3477
|
});
|
|
3477
3478
|
}
|
|
@@ -4079,23 +4080,39 @@ class DbxFormlyFormComponent extends AbstractSubscriptionDirective {
|
|
|
4079
4080
|
changesSinceLastResetCount: 0,
|
|
4080
4081
|
isFormValid: false,
|
|
4081
4082
|
isFormDisabled: false
|
|
4082
|
-
}),
|
|
4083
|
-
const
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4083
|
+
}), switchMap(({ changesSinceLastResetCount, isFormValid, isFormDisabled }) => {
|
|
4084
|
+
const nextState = () => {
|
|
4085
|
+
const isReset = changesSinceLastResetCount <= 1; // first emission after reset is the first value.
|
|
4086
|
+
const complete = isFormValid;
|
|
4087
|
+
const nextState = {
|
|
4088
|
+
isComplete: complete,
|
|
4089
|
+
state: isReset ? DbxFormState.RESET : DbxFormState.USED,
|
|
4090
|
+
status: this.form.status,
|
|
4091
|
+
untouched: this.form.untouched,
|
|
4092
|
+
pristine: this.form.pristine,
|
|
4093
|
+
changesCount: changesSinceLastResetCount,
|
|
4094
|
+
lastResetAt,
|
|
4095
|
+
disabled: this.disabled,
|
|
4096
|
+
isDisabled: isFormDisabled
|
|
4097
|
+
};
|
|
4098
|
+
return nextState;
|
|
4095
4099
|
};
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4100
|
+
const state = nextState();
|
|
4101
|
+
if (isFormValid && this.form.untouched) {
|
|
4102
|
+
return timer(150, 200).pipe(
|
|
4103
|
+
// every 200 ms check if the form is now marked touched, then push a new state
|
|
4104
|
+
filter(() => this.form.touched), map(() => nextState()),
|
|
4105
|
+
// only push the new state once
|
|
4106
|
+
first(),
|
|
4107
|
+
// send the first value immediately
|
|
4108
|
+
startWith(state));
|
|
4109
|
+
}
|
|
4110
|
+
else {
|
|
4111
|
+
return of(state);
|
|
4112
|
+
}
|
|
4113
|
+
})
|
|
4114
|
+
// tapLog('Change: ')
|
|
4115
|
+
)), shareReplay(1));
|
|
4099
4116
|
}
|
|
4100
4117
|
ngOnInit() {
|
|
4101
4118
|
this.context.setDelegate(this);
|