@dereekb/dbx-form 13.6.0 → 13.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,10 +3,10 @@ import { forwardRef, inject, input, Directive, effect, Injectable, viewChild, si
|
|
|
3
3
|
import * as i1$2 from '@dereekb/dbx-web';
|
|
4
4
|
import { DbxActionTransitionSafetyDirective, AbstractDialogDirective, DbxDialogContentDirective, DbxActionModule, DbxButtonModule, DbxDialogContentCloseComponent, DbxAnchorComponent, DbxSectionLayoutModule, DbxFlexGroupDirective, DbxSubSectionComponent, DbxLoadingComponent, dbxValueListItemDecisionFunction, DbxListModifierModule, AbstractDbxSelectionListWrapperDirective, DbxListWrapperComponentImportsModule, provideDbxListViewWrapper, DEFAULT_LIST_WRAPPER_COMPONENT_CONFIGURATION_TEMPLATE, AbstractDbxSelectionListViewDirective, addConfigToValueListItems, DbxSelectionValueListViewContentComponent, provideDbxListView, AbstractDbxValueListViewItemComponent, DbxLoadingModule, DbxButtonComponent, DbxButtonSpacerDirective, CompactContextStore, mapCompactModeObs, DbxBarDirective } from '@dereekb/dbx-web';
|
|
5
5
|
import { isPast, addSeconds, startOfDay, addMinutes, addDays, isBefore } from 'date-fns';
|
|
6
|
-
import { map, of, shareReplay, switchMap, first, exhaustMap, catchError, delay, filter, combineLatest, distinctUntilChanged, BehaviorSubject, Subject, startWith, throttleTime, scan, timer, merge,
|
|
6
|
+
import { map, of, shareReplay, switchMap, first, exhaustMap, catchError, delay, filter, combineLatest, distinctUntilChanged, BehaviorSubject, Subject, startWith, throttleTime, scan, timer, merge, EMPTY, mergeMap, debounceTime, tap, skip, combineLatestWith, interval } from 'rxjs';
|
|
7
7
|
import * as i2 from '@dereekb/dbx-core';
|
|
8
8
|
import { DbxActionContextStoreSourceInstance, cleanLockSet, cleanWithLockSet, cleanSubscription, DbxInjectionComponent, mergeDbxInjectionComponentConfigs, GetValuePipe, DateDistancePipe, TimeDistancePipe } from '@dereekb/dbx-core';
|
|
9
|
-
import { makeIsModifiedFunctionObservable, SubscriptionObject, asObservable, LockSet, filterMaybe, switchMapFilterMaybe, scanCount,
|
|
9
|
+
import { makeIsModifiedFunctionObservable, SubscriptionObject, asObservable, LockSet, filterMaybe, switchMapFilterMaybe, scanCount, errorOnEmissionsInPeriod, asObservableFromGetter, maybeValueFromObservableOrValue, valueFromFinishedLoadingState, switchMapMaybeDefault, SimpleLoadingContext, distinctUntilHasDifferentValues, startWithBeginLoading, mapLoadingStateResults, successResult, listLoadingStateContext, mapIsListLoadingStateWithEmptyValue, isLoadingStateInLoadingState, skipUntilTimeElapsedAfterLastEmission, isLoadingStateWithDefinedValue, isLoadingStateLoading, beginLoading, mapLoadingStateValueWithOperator, loadingStateContext, skipAllInitialMaybe, asyncPusherCache } from '@dereekb/rxjs';
|
|
10
10
|
import { toObservable, toSignal } from '@angular/core/rxjs-interop';
|
|
11
11
|
import { BooleanStringKeyArrayUtility, iterablesAreSetEquivalent, objectIsEmpty, mergeObjectsFunction, filterFromPOJOFunction, mergeObjects, filterFromPOJO, asArray, objectHasNoKeys, addPlusPrefixToNumber, convertMaybeToArray, isSelectedDecisionFunctionFactory, readKeysFrom, hasDifferentValues, makeValuesGroupMap, separateValues, filterUniqueValues, searchStringFilterFunction, caseInsensitiveFilterByIndexOfDecisionFactory, sortByStringFunction, mergeArraysIntoArray, lastValue, arrayToMap, setContainsAllValues, addToSetCopy, setsAreEquivalent, filterMaybeArrayValues, mergeArrays, firstValue, cachedGetter, makeGetter, asDecisionFunction, getValueFromGetter, asGetter, dateFromMinuteOfDay, dateToMinuteOfDay, isISO8601DayStringStart, mapIdentityFunction, MS_IN_MINUTE, isMonthDaySlashDate, HAS_WEBSITE_DOMAIN_NAME_REGEX, KeyValueTypleValueFilter, valuesFromPOJO, allObjectsAreEqual, isNumberDivisibleBy, nearestDivisibleValues, isE164PhoneNumber as isE164PhoneNumber$1, isValidPhoneExtensionNumber, e164PhoneNumberExtensionPair, isWebsiteUrlWithPrefix, websiteUrlDetails, mapMaybeFunction, transformNumberFunction, concatArrays, DOLLAR_AMOUNT_PRECISION, e164PhoneNumberFromE164PhoneNumberExtensionPair, transformStringFunction, US_STATE_CODE_STRING_REGEX, ZIP_CODE_STRING_REGEX, LAT_LNG_PATTERN, capitalizeFirstLetter } from '@dereekb/util';
|
|
12
12
|
import * as i1 from '@angular/forms';
|
|
@@ -659,26 +659,11 @@ function dbxFormSourceObservableFromStream(streamObs, inputObs, modeObs) {
|
|
|
659
659
|
const mode$ = asObservable(modeObs).pipe(distinctUntilChanged());
|
|
660
660
|
return combineLatest([mode$, value$]).pipe(map((x) => x[0]), distinctUntilChanged(), switchMap((mode) => {
|
|
661
661
|
if (mode === 'reset') {
|
|
662
|
-
//
|
|
662
|
+
// Reset mode: forward exactly one value each time the form enters RESET state,
|
|
663
|
+
// then ignore subsequent source changes until the next reset.
|
|
663
664
|
return state$.pipe(exhaustMap((state) => {
|
|
664
665
|
if (state === DbxFormState.RESET) {
|
|
665
|
-
|
|
666
|
-
const doneSubject = new Subject();
|
|
667
|
-
return combineLatest([value$, state$]).pipe(map(([value, state]) => {
|
|
668
|
-
if (!firstValueSent || state === DbxFormState.RESET) {
|
|
669
|
-
return [value, true]; // always forward the first value.
|
|
670
|
-
}
|
|
671
|
-
else {
|
|
672
|
-
return [value, false];
|
|
673
|
-
}
|
|
674
|
-
}), tap(([_, send]) => {
|
|
675
|
-
firstValueSent = true;
|
|
676
|
-
if (!send) {
|
|
677
|
-
doneSubject.next(undefined);
|
|
678
|
-
}
|
|
679
|
-
}), filter(([_, send]) => send), map(([value, _]) => value), takeUntil(doneSubject), cleanup(() => {
|
|
680
|
-
doneSubject.complete();
|
|
681
|
-
}));
|
|
666
|
+
return value$.pipe(first());
|
|
682
667
|
}
|
|
683
668
|
else {
|
|
684
669
|
return EMPTY;
|
|
@@ -736,8 +721,16 @@ class DbxFormSourceDirective {
|
|
|
736
721
|
const mode = this.dbxFormSourceMode() ?? 'reset';
|
|
737
722
|
let subscription;
|
|
738
723
|
if (formSource) {
|
|
739
|
-
|
|
724
|
+
// Guard against the feedback loop where setValue() calls resetForm() internally,
|
|
725
|
+
// which triggers a new RESET state on stream$, causing another value to be forwarded.
|
|
726
|
+
// The flag is set before setValue and cleared on the next microtask, so the synchronous
|
|
727
|
+
// stream$ emissions from the feedback reset are filtered out.
|
|
728
|
+
let isSettingValue = false;
|
|
729
|
+
const guardedStream$ = this.form.stream$.pipe(filter(() => !isSettingValue));
|
|
730
|
+
subscription = dbxFormSourceObservableFromStream(guardedStream$, formSource, mode).subscribe((x) => {
|
|
731
|
+
isSettingValue = true;
|
|
740
732
|
this.form.setValue(x);
|
|
733
|
+
Promise.resolve().then(() => (isSettingValue = false));
|
|
741
734
|
});
|
|
742
735
|
}
|
|
743
736
|
this._effectSub.setSub(subscription);
|