@dereekb/dbx-form 10.1.16 → 10.1.18

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.
@@ -10,7 +10,7 @@ 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, throttleTime, mergeMap, startWith, debounceTime, skipWhile, scan, combineLatestWith, interval, merge, timer } from '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, skip, combineLatestWith, interval, merge, timer } from 'rxjs';
14
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';
@@ -3911,6 +3911,9 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
3911
3911
  get showClearButton() {
3912
3912
  return this.field.props.showClearButton;
3913
3913
  }
3914
+ get minuteStep() {
3915
+ return this.field.props.minuteStep ?? this.field.props.step ?? 5;
3916
+ }
3914
3917
  constructor(cdRef, dbxDateTimeFieldConfigService) {
3915
3918
  super();
3916
3919
  this.cdRef = cdRef;
@@ -3918,6 +3921,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
3918
3921
  this._sub = new SubscriptionObject();
3919
3922
  this._valueSub = new SubscriptionObject();
3920
3923
  this._config = new BehaviorSubject(undefined);
3924
+ this.latestConfig$ = this._config.pipe(switchMapMaybeDefault(), distinctUntilChanged(), shareReplay(1));
3921
3925
  this._syncConfigObs = new BehaviorSubject(undefined);
3922
3926
  this._defaultTimezone = new BehaviorSubject(undefined);
3923
3927
  this._timeDate = new BehaviorSubject(undefined);
@@ -3929,6 +3933,9 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
3929
3933
  this.formControl$ = this._formControlObs.pipe(filterMaybe());
3930
3934
  this._cleared = new Subject();
3931
3935
  this._updateTime = new Subject();
3936
+ this._configUpdateTimeSync = new SubscriptionObject(this.latestConfig$.pipe(skip(1)).subscribe((x) => {
3937
+ this._updateTime.next();
3938
+ }));
3932
3939
  this.timezone$ = this._defaultTimezone.pipe(switchMapMaybeDefault(), distinctUntilChanged()).pipe(map((defaultTimezone) => {
3933
3940
  return defaultTimezone ?? guessCurrentTimezone();
3934
3941
  }), distinctUntilChanged(), shareReplay(1));
@@ -4034,7 +4041,10 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
4034
4041
  }) ?? date;
4035
4042
  }
4036
4043
  else if (!this.timeOnly) {
4037
- result = date;
4044
+ if (this.timeMode !== DbxDateTimeFieldTimeMode.REQUIRED) {
4045
+ // only autofill the date if the time is marked as required (and the time string is empty)
4046
+ result = date;
4047
+ }
4038
4048
  }
4039
4049
  }
4040
4050
  }
@@ -4069,7 +4079,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
4069
4079
  }
4070
4080
  }), shareReplay(1));
4071
4081
  this.defaultPickerFilter = () => true;
4072
- this.timeOutput$ = combineLatest([this.rawDateTime$, this._offset, this.dateTimePickerConfig$]).pipe(throttleTime(TIME_OUTPUT_THROTTLE_TIME$1, undefined, { leading: false, trailing: true }), distinctUntilChanged((current, next) => current[0] === next[0] && next[1] === 0), tap(([, stepsOffset]) => (stepsOffset ? this._offset.next(0) : 0)), map(([date, stepsOffset, config]) => {
4082
+ this.timeOutput$ = combineLatest([this.rawDateTime$, this._offset, this.dateTimePickerConfig$]).pipe(throttleTime(TIME_OUTPUT_THROTTLE_TIME$1, undefined, { leading: false, trailing: true }), distinctUntilChanged((current, next) => current[0] === next[0] && next[1] === 0 && current[2] === next[2]), tap(([, stepsOffset]) => (stepsOffset ? this._offset.next(0) : 0)), map(([date, stepsOffset, config]) => {
4073
4083
  if (date != null) {
4074
4084
  const instance = new DateTimeMinuteInstance({
4075
4085
  date,
@@ -4077,7 +4087,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
4077
4087
  roundDownToMinute: true
4078
4088
  });
4079
4089
  date = instance.clamp(date);
4080
- const minutes = stepsOffset * 5;
4090
+ const minutes = stepsOffset * this.minuteStep;
4081
4091
  if (minutes != 0) {
4082
4092
  date = addMinutes(date, minutes);
4083
4093
  date = instance.clamp(date); // clamp the date again
@@ -4180,6 +4190,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
4180
4190
  this._sub.destroy();
4181
4191
  this._valueSub.destroy();
4182
4192
  this._config.complete();
4193
+ this._configUpdateTimeSync.destroy();
4183
4194
  this._defaultTimezone.complete();
4184
4195
  this._timeDate.complete();
4185
4196
  this._presets.complete();
@@ -4956,7 +4967,7 @@ function timeOnlyField(config = {}) {
4956
4967
  });
4957
4968
  }
4958
4969
  function dateTimeField(config = {}) {
4959
- const { key = 'date', showClearButton, dateLabel, timeLabel, allDayLabel, atTimeLabel, timeDate, timezone, showTimezone, timeMode = DbxDateTimeFieldTimeMode.REQUIRED, valueMode, fullDayInUTC, fullDayFieldName, pickerConfig, getSyncFieldsObs, hideDatePicker, hideDateHint, timeOnly = false, presets, materialFormField } = config;
4970
+ const { key = 'date', showClearButton, dateLabel, timeLabel, allDayLabel, atTimeLabel, timeDate, timezone, minuteStep, showTimezone, timeMode = DbxDateTimeFieldTimeMode.REQUIRED, valueMode, fullDayInUTC, fullDayFieldName, pickerConfig, getSyncFieldsObs, hideDatePicker, hideDateHint, timeOnly = false, presets, materialFormField } = config;
4960
4971
  const classGetter = 'dbx-mat-form-field-disable-underline dbx-mat-form-date-time-field-wrapper';
4961
4972
  const fieldConfig = formlyField({
4962
4973
  key,
@@ -4972,6 +4983,7 @@ function dateTimeField(config = {}) {
4972
4983
  valueMode,
4973
4984
  timeOnly,
4974
4985
  presets,
4986
+ minuteStep,
4975
4987
  timeMode: timeOnly ? DbxDateTimeFieldTimeMode.REQUIRED : timeMode,
4976
4988
  timezone,
4977
4989
  timeDate,
@@ -4987,7 +4999,7 @@ function dateTimeField(config = {}) {
4987
4999
  return fieldConfig;
4988
5000
  }
4989
5001
  function dateRangeField(config = {}) {
4990
- const { required: inputRequired, start, end, timeDate, timezone, showTimezone, presets } = config;
5002
+ const { required: inputRequired, start, end, timeDate, timezone, showTimezone, presets, valueMode, minuteStep } = config;
4991
5003
  const required = inputRequired ?? start?.required ?? false;
4992
5004
  const startFieldKey = start?.key ?? 'start';
4993
5005
  const endFieldKey = end?.key ?? 'end';
@@ -5000,6 +5012,8 @@ function dateRangeField(config = {}) {
5000
5012
  timeDate,
5001
5013
  timezone,
5002
5014
  showTimezone,
5015
+ valueMode,
5016
+ minuteStep,
5003
5017
  ...start,
5004
5018
  required,
5005
5019
  key: startFieldKey
@@ -5013,6 +5027,8 @@ function dateRangeField(config = {}) {
5013
5027
  timeDate,
5014
5028
  timezone,
5015
5029
  showTimezone,
5030
+ valueMode,
5031
+ minuteStep,
5016
5032
  ...end,
5017
5033
  required,
5018
5034
  key: endFieldKey
@@ -5023,14 +5039,15 @@ function dateRangeField(config = {}) {
5023
5039
  };
5024
5040
  }
5025
5041
  function dateTimeRangeField(inputConfig = {}) {
5026
- const { required = false, start: inputStart, end: inputEnd, timezone, timeDate, showTimezone, presets, valueMode } = inputConfig;
5042
+ const { required = false, start: inputStart, end: inputEnd, timezone, timeDate, showTimezone, presets, valueMode, minuteStep } = inputConfig;
5027
5043
  function dateTimeRangeFieldConfig(config) {
5028
5044
  return {
5045
+ valueMode,
5046
+ minuteStep,
5029
5047
  ...config,
5030
5048
  required,
5031
5049
  timeMode: DbxDateTimeFieldTimeMode.REQUIRED,
5032
5050
  getSyncFieldsObs: undefined,
5033
- valueMode,
5034
5051
  timeOnly: true,
5035
5052
  hideDateHint: true
5036
5053
  };