@dereekb/dbx-form 9.25.7 → 9.25.8
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/calendar/lib/calendar.schedule.selection.days.component.mjs +1 -1
- package/esm2020/lib/formly/field/value/date/datetime.field.component.mjs +39 -13
- package/esm2020/lib/formly/field/value/date/datetime.field.mjs +10 -6
- package/fesm2015/dereekb-dbx-form-calendar.mjs.map +1 -1
- package/fesm2015/dereekb-dbx-form.mjs +49 -21
- package/fesm2015/dereekb-dbx-form.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-form-calendar.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-form.mjs +47 -17
- package/fesm2020/dereekb-dbx-form.mjs.map +1 -1
- package/lib/formly/field/value/date/datetime.field.component.d.ts +10 -1
- package/lib/formly/field/value/date/datetime.field.d.ts +4 -4
- package/mapbox/package.json +4 -4
- package/package.json +4 -4
|
@@ -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, formatToISO8601DayString, isSameDateHoursAndMinutes, safeToJsDate, guessCurrentTimezone, dateTimezoneUtcNormal, toLocalReadableTimeString, getTimezoneAbbreviation,
|
|
47
|
+
import { skipUntilTimeElapsedAfterLastEmission, toJsDate, parseISO8601DayStringToDate, formatToISO8601DateString, formatToISO8601DayString, isSameDateHoursAndMinutes, safeToJsDate, guessCurrentTimezone, dateTimezoneUtcNormal, toJsDayDate, isSameDateDay, toLocalReadableTimeString, getTimezoneAbbreviation, utcDayForDate, readableTimeStringToDate, findMinDate, dateFromLogicalDate, findMaxDate, dateTimeMinuteDecisionFunction, DateTimeMinuteInstance, isSameDate, limitDateTimeInstance, isSameDateDayRange, dateRange, clampDateRangeToDateRange, isDateInDateRange, isSameDateRange, 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';
|
|
@@ -3756,6 +3756,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3756
3756
|
this._config = new BehaviorSubject(undefined);
|
|
3757
3757
|
this._syncConfigObs = new BehaviorSubject(undefined);
|
|
3758
3758
|
this._defaultTimezone = new BehaviorSubject(undefined);
|
|
3759
|
+
this._timeDate = new BehaviorSubject(undefined);
|
|
3759
3760
|
this._presets = new BehaviorSubject(of([]));
|
|
3760
3761
|
this._fullDayControlObs = new BehaviorSubject(undefined);
|
|
3761
3762
|
this.fullDayControl$ = this._fullDayControlObs.pipe(filterMaybe());
|
|
@@ -3767,6 +3768,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3767
3768
|
return defaultTimezone !== null && defaultTimezone !== void 0 ? defaultTimezone : guessCurrentTimezone();
|
|
3768
3769
|
}), distinctUntilChanged(), shareReplay(1));
|
|
3769
3770
|
this.timezoneInstance$ = this.timezone$.pipe(map((timezone) => (timezone ? dateTimezoneUtcNormal({ timezone }) : undefined)), shareReplay(1));
|
|
3771
|
+
this.timeDate$ = this._timeDate.pipe(switchMapMaybeDefault(), map((x) => (x ? toJsDayDate(x) : undefined)), distinctUntilChanged(isSameDateDay), shareReplay(1));
|
|
3770
3772
|
this.valueInSystemTimezone$ = this.formControl$.pipe(map((control) => control.valueChanges.pipe(startWith(control.value), shareReplay(1))), combineLatestWith(this.timezoneInstance$), switchMap(([x, timezoneInstance]) => {
|
|
3771
3773
|
return x.pipe(map(dbxDateTimeInputValueParseFactory(this.valueMode, timezoneInstance)));
|
|
3772
3774
|
}), throttleTime(20, undefined, { leading: false, trailing: true }), // throttle incoming values and timezone changes
|
|
@@ -3786,7 +3788,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3786
3788
|
this.showTimeInput$ = this.fullDay$.pipe(map((x) => !x && this.timeMode !== DbxDateTimeFieldTimeMode.NONE));
|
|
3787
3789
|
this.showAddTime$ = this.showTimeInput$.pipe(map((x) => !x && this.timeMode === DbxDateTimeFieldTimeMode.OPTIONAL), shareReplay(1));
|
|
3788
3790
|
this.date$ = this.dateInputCtrl.valueChanges.pipe(startWith(this.dateInputCtrl.value), filterMaybe(), shareReplay(1));
|
|
3789
|
-
this.timezoneAbbreviation$ = combineLatest([this.date$, this.timezone$]).pipe(map(([date, timezone]) => getTimezoneAbbreviation(timezone, date)), distinctUntilChanged(), shareReplay(1));
|
|
3791
|
+
this.timezoneAbbreviation$ = combineLatest([this.date$, this.timezone$, this.timeDate$]).pipe(map(([date, timezone, timeDate]) => getTimezoneAbbreviation(timezone, timeDate !== null && timeDate !== void 0 ? timeDate : date)), distinctUntilChanged(), shareReplay(1));
|
|
3790
3792
|
this.dateValue$ = merge(this.date$, this.valueInSystemTimezone$.pipe(skipFirstMaybe())).pipe(map((x) => (x ? startOfDay(x) : null)), distinctUntilChanged(isSameDateDay), shareReplay(1));
|
|
3791
3793
|
this.timeInput$ = this._updateTime.pipe(debounceTime(5), map(() => this.timeInputCtrl.value || ''), distinctUntilChanged());
|
|
3792
3794
|
this.syncConfigObs$ = this._syncConfigObs.pipe(switchMapMaybeDefault(), shareReplay(1));
|
|
@@ -3813,11 +3815,11 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3813
3815
|
// TODO: Get min/max using the DateTimePickerConfiguration too
|
|
3814
3816
|
this.dateInputMin$ = this.syncConfigBeforeValue$;
|
|
3815
3817
|
this.dateInputMax$ = this.syncConfigAfterValue$;
|
|
3816
|
-
this.rawDateTime$ = combineLatest([this.dateValue$, this.timeInput$.pipe(startWith(null)), this.fullDay$]).pipe(map(([date, timeString, fullDay]) => {
|
|
3818
|
+
this.rawDateTime$ = combineLatest([this.dateValue$, this.timeInput$.pipe(startWith(null)), this.fullDay$, this.timeDate$]).pipe(map(([date, timeString, fullDay, timeDate]) => {
|
|
3817
3819
|
var _a;
|
|
3818
3820
|
let result;
|
|
3819
|
-
if (!date
|
|
3820
|
-
date = new Date();
|
|
3821
|
+
if (!date || this.timeOnly) {
|
|
3822
|
+
date = timeDate !== null && timeDate !== void 0 ? timeDate : new Date(); // use the time date, or default to the current day
|
|
3821
3823
|
}
|
|
3822
3824
|
if (date) {
|
|
3823
3825
|
if (fullDay) {
|
|
@@ -3835,7 +3837,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3835
3837
|
useSystemTimezone: true
|
|
3836
3838
|
})) !== null && _a !== void 0 ? _a : date;
|
|
3837
3839
|
}
|
|
3838
|
-
else {
|
|
3840
|
+
else if (!this.timeOnly) {
|
|
3839
3841
|
result = date;
|
|
3840
3842
|
}
|
|
3841
3843
|
}
|
|
@@ -3866,7 +3868,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3866
3868
|
this.timeOutput$ = combineLatest([this.rawDateTime$, this._offset, this.config$]).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]) => {
|
|
3867
3869
|
if (date != null) {
|
|
3868
3870
|
const instance = new DateTimeMinuteInstance(Object.assign(Object.assign({ date }, config), { roundDownToMinute: true }));
|
|
3869
|
-
date = instance.
|
|
3871
|
+
date = instance.clamp(date);
|
|
3870
3872
|
const minutes = stepsOffset * 5;
|
|
3871
3873
|
date = addMinutes(date, minutes);
|
|
3872
3874
|
}
|
|
@@ -3930,6 +3932,9 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3930
3932
|
get timezone() {
|
|
3931
3933
|
return this.field.props.timezone;
|
|
3932
3934
|
}
|
|
3935
|
+
get timeDate() {
|
|
3936
|
+
return this.field.props.timeDate;
|
|
3937
|
+
}
|
|
3933
3938
|
get showTimezone() {
|
|
3934
3939
|
var _a;
|
|
3935
3940
|
return (_a = this.field.props.showTimezone) !== null && _a !== void 0 ? _a : true;
|
|
@@ -3952,17 +3957,35 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
3952
3957
|
this.formControl.markAsDirty();
|
|
3953
3958
|
this.formControl.markAsTouched();
|
|
3954
3959
|
});
|
|
3960
|
+
let hasSetMidnightFromInput = false;
|
|
3961
|
+
/*
|
|
3955
3962
|
this._valueSub.subscription = this.timeString$.subscribe((x) => {
|
|
3956
|
-
|
|
3957
|
-
|
|
3963
|
+
this.setTime(x);
|
|
3964
|
+
});
|
|
3965
|
+
*/
|
|
3966
|
+
this._valueSub.subscription = this.valueInSystemTimezone$
|
|
3967
|
+
.pipe(map((x) => (x ? isSameDate(x, startOfDay(x)) : false)), distinctUntilChanged(), switchMap((isInputValueAtMidnight) => {
|
|
3968
|
+
hasSetMidnightFromInput = false;
|
|
3969
|
+
return this.timeString$.pipe(
|
|
3970
|
+
// skip(1),
|
|
3971
|
+
map((timeString) => [timeString, isInputValueAtMidnight]));
|
|
3972
|
+
}))
|
|
3973
|
+
.subscribe(([x, isInputValueAtMidnight]) => {
|
|
3974
|
+
// Skip events where the timeInput value is cleared, unless the input value is at midnight and we've already processed it being at midnight
|
|
3975
|
+
if (!this.timeInputCtrl.value && x === '12:00AM' && (!isInputValueAtMidnight || (isInputValueAtMidnight && hasSetMidnightFromInput))) {
|
|
3958
3976
|
return;
|
|
3959
3977
|
}
|
|
3978
|
+
// update the has set flag
|
|
3979
|
+
if (x === '12:00AM' && isInputValueAtMidnight) {
|
|
3980
|
+
hasSetMidnightFromInput = true;
|
|
3981
|
+
}
|
|
3960
3982
|
this.setTime(x);
|
|
3961
3983
|
});
|
|
3962
3984
|
// Set default timezone if provided.
|
|
3963
3985
|
if (this.timezone && !this.dateTimeField.fullDayInUTC) {
|
|
3964
3986
|
this._defaultTimezone.next(asObservableFromGetter(this.timezone));
|
|
3965
3987
|
}
|
|
3988
|
+
this._timeDate.next(asObservableFromGetter(this.timeDate));
|
|
3966
3989
|
// Watch for disabled changes so we can propogate them properly.
|
|
3967
3990
|
this.formControl.registerOnDisabledChange((disabled) => {
|
|
3968
3991
|
if (disabled) {
|
|
@@ -4012,6 +4035,7 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
4012
4035
|
this._valueSub.destroy();
|
|
4013
4036
|
this._config.complete();
|
|
4014
4037
|
this._defaultTimezone.complete();
|
|
4038
|
+
this._timeDate.complete();
|
|
4015
4039
|
this._presets.complete();
|
|
4016
4040
|
this._fullDayControlObs.complete();
|
|
4017
4041
|
this._offset.complete();
|
|
@@ -4049,9 +4073,11 @@ class DbxDateTimeFieldComponent extends FieldType$1 {
|
|
|
4049
4073
|
this.setTime(timeString);
|
|
4050
4074
|
}
|
|
4051
4075
|
setTime(time) {
|
|
4052
|
-
this.timeInputCtrl.
|
|
4053
|
-
|
|
4054
|
-
|
|
4076
|
+
if (this.timeInputCtrl.value !== time) {
|
|
4077
|
+
this.timeInputCtrl.setValue(time);
|
|
4078
|
+
this._offset.next(0);
|
|
4079
|
+
this._updateTime.next();
|
|
4080
|
+
}
|
|
4055
4081
|
}
|
|
4056
4082
|
keydownOnDateInput(event) {
|
|
4057
4083
|
var _a;
|
|
@@ -4712,7 +4738,7 @@ function timeOnlyField(config = {}) {
|
|
|
4712
4738
|
return dateTimeField(Object.assign(Object.assign({}, config), { timeMode: DbxDateTimeFieldTimeMode.REQUIRED, timeOnly: true }));
|
|
4713
4739
|
}
|
|
4714
4740
|
function dateTimeField(config = {}) {
|
|
4715
|
-
const { key = 'date', dateLabel, timeLabel, allDayLabel, atTimeLabel, timezone, showTimezone, timeMode = DbxDateTimeFieldTimeMode.REQUIRED, valueMode, fullDayInUTC, fullDayFieldName, pickerConfig, getConfigObs, getSyncFieldsObs, hideDatePicker, hideDateHint, timeOnly = false, presets, materialFormField } = config;
|
|
4741
|
+
const { key = 'date', dateLabel, timeLabel, allDayLabel, atTimeLabel, timeDate, timezone, showTimezone, timeMode = DbxDateTimeFieldTimeMode.REQUIRED, valueMode, fullDayInUTC, fullDayFieldName, pickerConfig, getConfigObs, getSyncFieldsObs, hideDatePicker, hideDateHint, timeOnly = false, presets, materialFormField } = config;
|
|
4716
4742
|
const fieldConfig = formlyField(Object.assign({ key, type: 'datetime' }, propsAndConfigForFieldConfig(config, Object.assign(Object.assign({}, materialFormField), { appearance: 'standard', dateLabel,
|
|
4717
4743
|
timeLabel,
|
|
4718
4744
|
allDayLabel,
|
|
@@ -4720,6 +4746,7 @@ function dateTimeField(config = {}) {
|
|
|
4720
4746
|
valueMode,
|
|
4721
4747
|
timeOnly,
|
|
4722
4748
|
presets, timeMode: timeOnly ? DbxDateTimeFieldTimeMode.REQUIRED : timeMode, timezone,
|
|
4749
|
+
timeDate,
|
|
4723
4750
|
showTimezone,
|
|
4724
4751
|
fullDayFieldName,
|
|
4725
4752
|
fullDayInUTC,
|
|
@@ -4734,16 +4761,16 @@ function dateTimeField(config = {}) {
|
|
|
4734
4761
|
}
|
|
4735
4762
|
function dateRangeField(config = {}) {
|
|
4736
4763
|
var _a, _b, _c;
|
|
4737
|
-
const { required: inputRequired, start, end, timezone, showTimezone, presets } = config;
|
|
4764
|
+
const { required: inputRequired, start, end, timeDate, timezone, showTimezone, presets } = config;
|
|
4738
4765
|
const required = (_a = inputRequired !== null && inputRequired !== void 0 ? inputRequired : start === null || start === void 0 ? void 0 : start.required) !== null && _a !== void 0 ? _a : false;
|
|
4739
4766
|
const startFieldKey = (_b = start === null || start === void 0 ? void 0 : start.key) !== null && _b !== void 0 ? _b : 'start';
|
|
4740
4767
|
const endFieldKey = (_c = end === null || end === void 0 ? void 0 : end.key) !== null && _c !== void 0 ? _c : 'end';
|
|
4741
|
-
const startField = dateTimeField(Object.assign(Object.assign({ dateLabel: 'Start', timeMode: DbxDateTimeFieldTimeMode.NONE, getSyncFieldsObs: () => of([{ syncWith: endFieldKey, syncType: 'after' }]), presets, allDayLabel: ''
|
|
4742
|
-
|
|
4743
|
-
required, key: startFieldKey }));
|
|
4744
|
-
const endField = dateTimeField(Object.assign(Object.assign({ dateLabel: 'End', timeMode: DbxDateTimeFieldTimeMode.NONE, getSyncFieldsObs: () => of([{ syncWith: startFieldKey, syncType: 'before' }]), presets, allDayLabel: ''
|
|
4745
|
-
|
|
4746
|
-
required, key: endFieldKey }));
|
|
4768
|
+
const startField = dateTimeField(Object.assign(Object.assign({ dateLabel: 'Start', timeMode: DbxDateTimeFieldTimeMode.NONE, getSyncFieldsObs: () => of([{ syncWith: endFieldKey, syncType: 'after' }]), presets, allDayLabel: '', timeDate,
|
|
4769
|
+
timezone,
|
|
4770
|
+
showTimezone }, start), { required, key: startFieldKey }));
|
|
4771
|
+
const endField = dateTimeField(Object.assign(Object.assign({ dateLabel: 'End', timeMode: DbxDateTimeFieldTimeMode.NONE, getSyncFieldsObs: () => of([{ syncWith: startFieldKey, syncType: 'before' }]), presets, allDayLabel: '', timeDate,
|
|
4772
|
+
timezone,
|
|
4773
|
+
showTimezone }, end), { required, key: endFieldKey }));
|
|
4747
4774
|
return {
|
|
4748
4775
|
key: undefined,
|
|
4749
4776
|
fieldGroup: [flexLayoutWrapper([startField, endField], { size: 1, relative: true })]
|
|
@@ -4751,7 +4778,7 @@ function dateRangeField(config = {}) {
|
|
|
4751
4778
|
}
|
|
4752
4779
|
function dateTimeRangeField(inputConfig = {}) {
|
|
4753
4780
|
var _a, _b;
|
|
4754
|
-
const { required = false, start: inputStart, end: inputEnd, timezone, showTimezone, presets } = inputConfig;
|
|
4781
|
+
const { required = false, start: inputStart, end: inputEnd, timezone, timeDate, showTimezone, presets } = inputConfig;
|
|
4755
4782
|
function dateTimeRangeFieldConfig(config) {
|
|
4756
4783
|
return Object.assign(Object.assign({}, config), { required, timeMode: DbxDateTimeFieldTimeMode.REQUIRED, getSyncFieldsObs: undefined, timeOnly: true, hideDateHint: true });
|
|
4757
4784
|
}
|
|
@@ -4761,6 +4788,7 @@ function dateTimeRangeField(inputConfig = {}) {
|
|
|
4761
4788
|
const end = Object.assign(Object.assign({ label: 'End Time' }, dateTimeRangeFieldConfig(inputEnd)), { key: endKey });
|
|
4762
4789
|
const config = {
|
|
4763
4790
|
timezone,
|
|
4791
|
+
timeDate,
|
|
4764
4792
|
showTimezone,
|
|
4765
4793
|
presets,
|
|
4766
4794
|
start,
|