@dereekb/dbx-form 10.1.1 → 10.1.3
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/esm2022/calendar/lib/calendar.schedule.selection.store.mjs +3 -3
- package/esm2022/lib/form/io/form.input.directive.mjs +14 -4
- package/esm2022/lib/formly/field/value/date/date.value.mjs +3 -3
- package/esm2022/lib/formly/field/value/date/datetime.field.component.mjs +16 -11
- package/esm2022/lib/formly/field/value/date/datetime.field.mjs +1 -1
- package/esm2022/lib/formly/field/value/date/fixeddaterange.field.component.mjs +3 -3
- package/fesm2022/dereekb-dbx-form-calendar.mjs +2 -2
- package/fesm2022/dereekb-dbx-form-calendar.mjs.map +1 -1
- package/fesm2022/dereekb-dbx-form.mjs +30 -15
- package/fesm2022/dereekb-dbx-form.mjs.map +1 -1
- package/lib/form/io/form.input.directive.d.ts +3 -2
- package/lib/formly/field/value/date/datetime.field.component.d.ts +27 -22
- package/lib/formly/field/value/date/datetime.field.d.ts +1 -1
- package/mapbox/package.json +1 -1
- package/package.json +1 -1
|
@@ -10,8 +10,8 @@ import { AbstractSubscriptionDirective, safeDetectChanges, DbxInjectionComponent
|
|
|
10
10
|
import * as i2$1 from '@dereekb/dbx-web';
|
|
11
11
|
import { DbxActionTransitionSafetyDirective, DbxTextModule, DbxLoadingModule, DbxFlexLayoutModule, DbxSectionLayoutModule, DbxRouterAnchorModule, dbxValueListItemDecisionFunction, DbxButtonModule, DbxListLayoutModule, AbstractDbxSelectionListWrapperDirective, DEFAULT_LIST_WRAPPER_DIRECTIVE_TEMPLATE, AbstractDbxSelectionListViewDirective, addConfigToValueListItems, provideDbxListView, AbstractDbxValueListViewItemComponent, DbxActionModule, mapCompactModeObs, DbxBarLayoutModule } from '@dereekb/dbx-web';
|
|
12
12
|
import { isPast, addSeconds, startOfDay, addMinutes, addDays, isAfter } from 'date-fns';
|
|
13
|
-
import { BehaviorSubject, switchMap, first, exhaustMap, of, catchError, delay, filter, combineLatest, map, distinctUntilChanged, shareReplay, Subject, tap, takeUntil, EMPTY, mergeMap, startWith, debounceTime, skipWhile, scan, combineLatestWith,
|
|
14
|
-
import { LockSet, SubscriptionObject, asObservable, cleanup, loadingStateHasFinishedLoading, switchMapMaybeObs, filterMaybe, switchMapMaybeDefault, SimpleLoadingContext, distinctUntilHasDifferentValues, startWithBeginLoading, mapLoadingStateResults, successResult, ListLoadingStateContextInstance, isListLoadingStateEmpty, LoadingStateContextInstance, loadingStateHasValue, loadingStateIsLoading, beginLoading, mapLoadingStateValueWithOperator, valueFromLoadingState, loadingStateContext, skipFirstMaybe, asObservableFromGetter, asyncPusherCache, scanCount } from '@dereekb/rxjs';
|
|
13
|
+
import { BehaviorSubject, switchMap, first, exhaustMap, of, catchError, delay, filter, combineLatest, map, distinctUntilChanged, shareReplay, Subject, tap, takeUntil, EMPTY, throttleTime, mergeMap, startWith, debounceTime, skipWhile, scan, combineLatestWith, interval, merge, timer } from 'rxjs';
|
|
14
|
+
import { LockSet, SubscriptionObject, asObservable, cleanup, errorOnEmissionsInPeriod, loadingStateHasFinishedLoading, switchMapMaybeObs, filterMaybe, switchMapMaybeDefault, SimpleLoadingContext, distinctUntilHasDifferentValues, startWithBeginLoading, mapLoadingStateResults, successResult, ListLoadingStateContextInstance, isListLoadingStateEmpty, LoadingStateContextInstance, loadingStateHasValue, loadingStateIsLoading, beginLoading, mapLoadingStateValueWithOperator, valueFromLoadingState, loadingStateContext, skipFirstMaybe, asObservableFromGetter, asyncPusherCache, scanCount } from '@dereekb/rxjs';
|
|
15
15
|
import * as i1$1 from '@ngx-formly/core';
|
|
16
16
|
import { FieldType, FieldWrapper, FormlyModule, FieldArrayType } from '@ngx-formly/core';
|
|
17
17
|
import * as i3$1 from '@angular/forms';
|
|
@@ -44,7 +44,7 @@ import * as i6 from '@angular/material/chips';
|
|
|
44
44
|
import { MatChipsModule } from '@angular/material/chips';
|
|
45
45
|
import { MatListModule } from '@angular/material/list';
|
|
46
46
|
import { ENTER, COMMA } from '@angular/cdk/keycodes';
|
|
47
|
-
import { skipUntilTimeElapsedAfterLastEmission, toJsDate, parseISO8601DayStringToDate, formatToISO8601DateString,
|
|
47
|
+
import { skipUntilTimeElapsedAfterLastEmission, toJsDate, parseISO8601DayStringToDate, formatToISO8601DateString, formatToISO8601DayStringForSystem, isSameDateHoursAndMinutes, safeToJsDate, guessCurrentTimezone, dateTimezoneUtcNormal, toJsDayDate, isSameDateDay, toLocalReadableTimeString, getTimezoneAbbreviation, utcDayForDate, readableTimeStringToDate, findMinDate, dateFromLogicalDate, findMaxDate, isSameDate, dateTimeMinuteWholeDayDecisionFunction, DateTimeMinuteInstance, isSameDateDayRange, dateRange, clampDateRangeToDateRange, isDateInDateRange, isSameDateRange, limitDateTimeInstance, allTimezoneInfos, timezoneInfoForSystem, searchTimezoneInfos } from '@dereekb/date';
|
|
48
48
|
import { FieldType as FieldType$2, FormlyMatFormFieldModule } from '@ngx-formly/material/form-field';
|
|
49
49
|
import * as i3$3 from '@angular/material/select';
|
|
50
50
|
import { MatSelectModule } from '@angular/material/select';
|
|
@@ -340,7 +340,17 @@ function dbxFormSourceObservableFromStream(stream$, inputObs, mode$) {
|
|
|
340
340
|
return EMPTY;
|
|
341
341
|
}
|
|
342
342
|
else {
|
|
343
|
-
|
|
343
|
+
let valueObs = value$;
|
|
344
|
+
if (mode === 'always') {
|
|
345
|
+
valueObs = valueObs.pipe(throttleTime(10, undefined, { leading: true, trailing: true }), errorOnEmissionsInPeriod({
|
|
346
|
+
period: 1000,
|
|
347
|
+
maxEmissionsPerPeriod: 50,
|
|
348
|
+
onError: () => {
|
|
349
|
+
console.error('dbxFormSourceObservableFromStream: Error thrown due to too many emissions. There may be an unintentional loop being triggered by dbxFormSource. Typically this can occur in cases where the dbxFormSource directive is used at the same time as dbxFormValueChange directive and the same value is being pushed.');
|
|
350
|
+
}
|
|
351
|
+
}));
|
|
352
|
+
}
|
|
353
|
+
return valueObs;
|
|
344
354
|
}
|
|
345
355
|
}));
|
|
346
356
|
}
|
|
@@ -3708,7 +3718,7 @@ function dbxDateTimeOutputValueFactory(mode, timezoneInstance) {
|
|
|
3708
3718
|
let useTimezoneInstance = true;
|
|
3709
3719
|
switch (mode) {
|
|
3710
3720
|
case DbxDateTimeValueMode.DAY_STRING:
|
|
3711
|
-
factory = (x) => (x != null ?
|
|
3721
|
+
factory = (x) => (x != null ? formatToISO8601DayStringForSystem(x) : x);
|
|
3712
3722
|
useTimezoneInstance = false; // day strings do not use timezones
|
|
3713
3723
|
break;
|
|
3714
3724
|
case DbxDateTimeValueMode.DATE_STRING:
|
|
@@ -3868,12 +3878,15 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3868
3878
|
}), distinctUntilChanged(isSameDateDay), shareReplay(1));
|
|
3869
3879
|
this.valueInSystemTimezone$ = this.formControl$.pipe(map((control) => control.valueChanges.pipe(startWith(control.value), shareReplay(1))), combineLatestWith(this.timezoneInstance$), switchMap(([x, timezoneInstance]) => {
|
|
3870
3880
|
return x.pipe(map(dbxDateTimeInputValueParseFactory(this.valueMode, timezoneInstance)));
|
|
3871
|
-
}), throttleTime(20, undefined, { leading:
|
|
3881
|
+
}), throttleTime(20, undefined, { leading: true, trailing: true }), // throttle incoming values and timezone changes
|
|
3872
3882
|
distinctUntilChanged(isSameDateHoursAndMinutes), shareReplay(1));
|
|
3883
|
+
this.refreshInteral$ = interval(10 * 1000);
|
|
3873
3884
|
/**
|
|
3874
3885
|
* Used to trigger/display visual updates (specifically on timeDistance, etc.).
|
|
3875
3886
|
*/
|
|
3876
|
-
this.displayValue$ =
|
|
3887
|
+
this.displayValue$ = this.refreshInteral$.pipe(
|
|
3888
|
+
// every 10 seconds, refresh w/interval
|
|
3889
|
+
startWith(0), map(() => new Date().getMinutes()), distinctUntilChanged(), tap(() => this.cdRef.markForCheck()), switchMap(() => this.valueInSystemTimezone$), shareReplay(1));
|
|
3877
3890
|
this.timeString$ = this.valueInSystemTimezone$.pipe(map((x) => (x ? toLocalReadableTimeString(x) : '')), distinctUntilChanged(), shareReplay(1));
|
|
3878
3891
|
this.dateInputCtrl = new FormControl(new Date(), {
|
|
3879
3892
|
validators: []
|
|
@@ -3912,9 +3925,6 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3912
3925
|
}), shareReplay(1));
|
|
3913
3926
|
this.syncConfigBeforeValue$ = syncConfigValueObs(this.parsedSyncConfigs$, 'before');
|
|
3914
3927
|
this.syncConfigAfterValue$ = syncConfigValueObs(this.parsedSyncConfigs$, 'after');
|
|
3915
|
-
// TODO: Get min/max using the DateTimePickerConfiguration too
|
|
3916
|
-
this.dateInputMin$ = this.syncConfigBeforeValue$;
|
|
3917
|
-
this.dateInputMax$ = this.syncConfigAfterValue$;
|
|
3918
3928
|
this.rawDateTime$ = combineLatest([this.dateValue$, this.timeInput$.pipe(startWith(null)), this.fullDay$, this.timeDate$]).pipe(map(([date, timeString, fullDay, timeDate]) => {
|
|
3919
3929
|
let result;
|
|
3920
3930
|
if (!date || this.timeOnly) {
|
|
@@ -3942,7 +3952,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3942
3952
|
}
|
|
3943
3953
|
return result;
|
|
3944
3954
|
}), distinctUntilChanged(isSameDateHoursAndMinutes), shareReplay(1));
|
|
3945
|
-
this.config$ = combineLatest([this._config.pipe(
|
|
3955
|
+
this.config$ = combineLatest([this._config.pipe(switchMapMaybeObs()), this.syncConfigBeforeValue$, this.syncConfigAfterValue$]).pipe(map(([x, dateInputMin, dateInputMax]) => {
|
|
3946
3956
|
let result = x;
|
|
3947
3957
|
if (dateInputMin != null || dateInputMax != null) {
|
|
3948
3958
|
const { min: limitMin, max: limitMax } = x?.limits ?? {};
|
|
@@ -3959,9 +3969,11 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3959
3969
|
}
|
|
3960
3970
|
return result;
|
|
3961
3971
|
}), distinctUntilChanged(), shareReplay(1));
|
|
3972
|
+
this.dateInputMin$ = this.config$.pipe(map((x) => (x?.limits?.min ?? null)), distinctUntilChanged(isSameDate), shareReplay(1));
|
|
3973
|
+
this.dateInputMax$ = this.config$.pipe(map((x) => (x?.limits?.max ?? null)), distinctUntilChanged(isSameDate), shareReplay(1));
|
|
3962
3974
|
this.pickerFilter$ = this.config$.pipe(distinctUntilChanged(), map((x) => {
|
|
3963
3975
|
if (x) {
|
|
3964
|
-
const filter =
|
|
3976
|
+
const filter = dateTimeMinuteWholeDayDecisionFunction(x, false);
|
|
3965
3977
|
return (x) => (x != null ? filter(x) : true);
|
|
3966
3978
|
}
|
|
3967
3979
|
else {
|
|
@@ -3978,7 +3990,10 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3978
3990
|
});
|
|
3979
3991
|
date = instance.clamp(date);
|
|
3980
3992
|
const minutes = stepsOffset * 5;
|
|
3981
|
-
|
|
3993
|
+
if (minutes != 0) {
|
|
3994
|
+
date = addMinutes(date, minutes);
|
|
3995
|
+
date = instance.clamp(date); // clamp the date again
|
|
3996
|
+
}
|
|
3982
3997
|
}
|
|
3983
3998
|
return date;
|
|
3984
3999
|
}), distinctUntilChanged(isSameDateHoursAndMinutes), shareReplay(1));
|
|
@@ -3987,7 +4002,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3987
4002
|
ngOnInit() {
|
|
3988
4003
|
this._formControlObs.next(this.formControl);
|
|
3989
4004
|
const inputPickerConfig = this.dateTimeField.pickerConfig;
|
|
3990
|
-
this._config.next(inputPickerConfig ? asObservableFromGetter(inputPickerConfig) :
|
|
4005
|
+
this._config.next(inputPickerConfig ? asObservableFromGetter(inputPickerConfig) : of({}));
|
|
3991
4006
|
this._syncConfigObs.next(this.dateTimeField.getSyncFieldsObs?.());
|
|
3992
4007
|
this._sub.subscription = this.valueInSystemTimezone$
|
|
3993
4008
|
.pipe(combineLatestWith(this.timezoneInstance$.pipe(map((timezoneInstance) => dbxDateTimeOutputValueFactory(this.valueMode, timezoneInstance)))), throttleTime(TIME_OUTPUT_THROTTLE_TIME$1, undefined, { leading: false, trailing: true }), switchMap(([currentValue, valueFactory]) => {
|
|
@@ -4449,7 +4464,7 @@ class DbxFixedDateRangeFieldComponent extends FieldType$1 {
|
|
|
4449
4464
|
this.max$ = this.minMaxRange$.pipe(map((x) => x?.end ?? null), distinctUntilChanged(), shareReplay(1));
|
|
4450
4465
|
this.pickerFilter$ = this.config$.pipe(distinctUntilChanged(), map((x) => {
|
|
4451
4466
|
if (x) {
|
|
4452
|
-
const filter =
|
|
4467
|
+
const filter = dateTimeMinuteWholeDayDecisionFunction(x, false);
|
|
4453
4468
|
return (x) => (x != null ? filter(x) : true);
|
|
4454
4469
|
}
|
|
4455
4470
|
else {
|