@dereekb/dbx-form 9.24.3 → 9.24.4

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.
@@ -5,9 +5,9 @@ import { AbstractPopoverDirective, AbstractDialogDirective, DbxActionModule, Dbx
5
5
  import * as i0 from '@angular/core';
6
6
  import { Injectable, SkipSelf, Directive, Injector, Optional, Component, Inject, Input, ElementRef, ViewChild, ChangeDetectionStrategy, EventEmitter, Output, InjectionToken, NgModule } from '@angular/core';
7
7
  import { FieldType } from '@ngx-formly/material';
8
- import { switchMap, first, tap, map, distinctUntilChanged, shareReplay, combineLatestWith, BehaviorSubject, of, startWith, filter, throttleTime } from 'rxjs';
8
+ import { switchMap, first, tap, map, distinctUntilChanged, shareReplay, combineLatestWith, BehaviorSubject, of, startWith, filter, throttleTime, combineLatest } from 'rxjs';
9
9
  import { filterMaybe, SubscriptionObject, asObservable } from '@dereekb/rxjs';
10
- import { DateScheduleDayCode, expandDateScheduleDayCodesToDayOfWeekSet, dateTimingRelativeIndexFactory, dateBlockDayOfWeekFactory, findMaxDate, findMinDate, isSameDateRange, isSameDateDay, isSameDate, isSameDateScheduleRange, dateTimingRelativeIndexArrayFactory, isInfiniteDateRange, copyDateScheduleDateFilterConfig, dateScheduleDateFilter, dateTimezoneUtcNormal, expandDateScheduleDayCodes, isDateInDateRangeFunction, isDateWithinDateBlockRangeFunction, copyHoursAndMinutesFromDate, dateScheduleEncodedWeek, dateBlockTimingDateFactory, enabledDaysFromDateScheduleDayCodes, dateScheduleDayCodesFromEnabledDays, formatToMonthDayString } from '@dereekb/date';
10
+ import { DateScheduleDayCode, expandDateScheduleDayCodesToDayOfWeekSet, dateTimingRelativeIndexFactory, dateBlockDayOfWeekFactory, findMaxDate, findMinDate, isSameDateRange, isSameDateDay, isSameDate, expandDateScheduleRange, isSameDateScheduleRange, dateTimingRelativeIndexArrayFactory, isInfiniteDateRange, copyDateScheduleDateFilterConfig, dateScheduleDateFilter, dateTimezoneUtcNormal, expandDateScheduleDayCodes, isDateInDateRangeFunction, isDateWithinDateBlockRangeFunction, copyHoursAndMinutesFromDate, dateScheduleEncodedWeek, dateBlockTimingDateFactory, enabledDaysFromDateScheduleDayCodes, dateScheduleDayCodesFromEnabledDays, formatToMonthDayString } from '@dereekb/date';
11
11
  import { setsAreEquivalent, unique, mergeArrays, iterableToArray, toggleInSet, addToSet, isIndexNumberInIndexRangeFunction, range, minAndMaxNumber, getDaysOfWeekNames, mergeObjects, KeyValueTypleValueFilter } from '@dereekb/util';
12
12
  import { ComponentStore } from '@ngrx/component-store';
13
13
  import { startOfDay, endOfDay, isBefore } from 'date-fns';
@@ -151,6 +151,9 @@ class DbxCalendarScheduleSelectionStore extends ComponentStore {
151
151
  }
152
152
  }), shareReplay(1));
153
153
  this.inputRange$ = this.currentInputRange$.pipe(filterMaybe(), shareReplay(1));
154
+ /**
155
+ * @deprecated This is not the same as the current selection value. This is the set of manually togged off dates. It will be removed in a future update.
156
+ */
154
157
  this.selectedDates$ = this.state$.pipe(map((x) => x.selectedIndexes), distinctUntilChanged(), shareReplay(1));
155
158
  this.isEnabledFilterDayFunction$ = this.state$.pipe(map((x) => x.isEnabledFilterDay), shareReplay(1));
156
159
  this.isEnabledDayFunction$ = this.state$.pipe(map((x) => x.isEnabledDay), shareReplay(1));
@@ -188,6 +191,8 @@ class DbxCalendarScheduleSelectionStore extends ComponentStore {
188
191
  return obs;
189
192
  }), shareReplay(1));
190
193
  this.selectionValue$ = this.currentSelectionValueWithTimezone$.pipe(filterMaybe(), shareReplay(1));
194
+ this.selectionValueDateBlockDurationSpan$ = this.selectionValue$.pipe(map((x) => expandDateScheduleRange(x)), shareReplay(1));
195
+ this.selectionValueSelectedIndexes$ = this.selectionValueDateBlockDurationSpan$.pipe(map((x) => new Set(x.map((y) => y.i))), shareReplay(1));
191
196
  this.currentDateScheduleRangeValue$ = this.currentSelectionValueWithTimezone$.pipe(map((x) => x?.dateScheduleRange), distinctUntilChanged(isSameDateScheduleRange), shareReplay(1));
192
197
  this.dateScheduleRangeValue$ = this.currentDateScheduleRangeValue$.pipe(filterMaybe(), shareReplay(1));
193
198
  this.cellContentFactory$ = this.state$.pipe(map((x) => x.cellContentFactory), distinctUntilChanged(), shareReplay(1));
@@ -999,6 +1004,46 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
999
1004
  }]
1000
1005
  }], ctorParameters: function () { return [{ type: i1$1.DbxPopoverService }, { type: DbxCalendarScheduleSelectionStore }, { type: i0.Injector }]; } });
1001
1006
 
1007
+ function dbxScheduleSelectionCalendarBeforeMonthViewRenderFactory(inputModifyFn) {
1008
+ const modifyFn = inputModifyFn || (() => { });
1009
+ return (state$) => {
1010
+ return (renderEvent) => {
1011
+ const { body } = renderEvent;
1012
+ // use latest/current state
1013
+ state$.pipe(first()).subscribe((calendarScheduleState) => {
1014
+ const { isEnabledDay, indexFactory, isEnabledFilterDay, allowedDaysOfWeek } = calendarScheduleState;
1015
+ body.forEach((viewDay) => {
1016
+ const { date } = viewDay;
1017
+ const i = indexFactory(date);
1018
+ const day = date.getDay();
1019
+ let state;
1020
+ if (!isEnabledFilterDay(i)) {
1021
+ viewDay.cssClass = 'cal-day-not-applicable';
1022
+ state = CalendarScheduleSelectionDayState.NOT_APPLICABLE;
1023
+ }
1024
+ else if (!allowedDaysOfWeek.has(day)) {
1025
+ viewDay.cssClass = 'cal-day-disabled';
1026
+ state = CalendarScheduleSelectionDayState.DISABLED;
1027
+ }
1028
+ else if (isEnabledDay(i)) {
1029
+ viewDay.cssClass = 'cal-day-selected';
1030
+ state = CalendarScheduleSelectionDayState.SELECTED;
1031
+ }
1032
+ else {
1033
+ viewDay.cssClass = 'cal-day-not-selected';
1034
+ state = CalendarScheduleSelectionDayState.NOT_SELECTED;
1035
+ }
1036
+ const meta = {
1037
+ state,
1038
+ i
1039
+ };
1040
+ viewDay.meta = meta;
1041
+ modifyFn(viewDay, calendarScheduleState);
1042
+ });
1043
+ });
1044
+ };
1045
+ };
1046
+ }
1002
1047
  class DbxScheduleSelectionCalendarComponent {
1003
1048
  constructor(calendarStore, dbxCalendarScheduleSelectionStore) {
1004
1049
  this.calendarStore = calendarStore;
@@ -1009,7 +1054,17 @@ class DbxScheduleSelectionCalendarComponent {
1009
1054
  this.clickEvent = new EventEmitter();
1010
1055
  // refresh any time the selected day function updates
1011
1056
  this.state$ = this.dbxCalendarScheduleSelectionStore.state$;
1012
- this.refresh$ = this.state$.pipe(throttleTime(100), map(() => undefined));
1057
+ this.beforeMonthViewRender$ = this._config.pipe(switchMap((x) => {
1058
+ let factory;
1059
+ if (x.beforeMonthViewRenderFunctionFactory) {
1060
+ factory = asObservable(x.beforeMonthViewRenderFunctionFactory);
1061
+ }
1062
+ else {
1063
+ factory = asObservable(x.customizeDay).pipe(map((x) => dbxScheduleSelectionCalendarBeforeMonthViewRenderFactory(x)));
1064
+ }
1065
+ return factory.pipe(map((x) => x(this.state$)));
1066
+ }), shareReplay(1));
1067
+ this.refresh$ = combineLatest([this.state$, this.beforeMonthViewRender$]).pipe(throttleTime(100), map(() => undefined));
1013
1068
  this.events$ = this.calendarStore.visibleEvents$.pipe(map(prepareAndSortCalendarEvents), shareReplay(1));
1014
1069
  this.viewDate$ = this.calendarStore.date$;
1015
1070
  }
@@ -1025,7 +1080,7 @@ class DbxScheduleSelectionCalendarComponent {
1025
1080
  return this._config.value;
1026
1081
  }
1027
1082
  set config(config) {
1028
- this._config.next(config);
1083
+ this._config.next(config ?? {});
1029
1084
  }
1030
1085
  dayClicked({ date }) {
1031
1086
  this.dbxCalendarScheduleSelectionStore.toggleSelectedDates(date);
@@ -1034,34 +1089,8 @@ class DbxScheduleSelectionCalendarComponent {
1034
1089
  this.clickEvent.emit({ action, event });
1035
1090
  }
1036
1091
  beforeMonthViewRender(renderEvent) {
1037
- const { body } = renderEvent;
1038
- this.state$.pipe(first()).subscribe(({ isEnabledDay, indexFactory, isEnabledFilterDay, allowedDaysOfWeek }) => {
1039
- body.forEach((viewDay) => {
1040
- const { date } = viewDay;
1041
- const i = indexFactory(date);
1042
- const day = date.getDay();
1043
- let state;
1044
- if (!isEnabledFilterDay(i)) {
1045
- viewDay.cssClass = 'cal-day-not-applicable';
1046
- state = CalendarScheduleSelectionDayState.NOT_APPLICABLE;
1047
- }
1048
- else if (!allowedDaysOfWeek.has(day)) {
1049
- viewDay.cssClass = 'cal-day-disabled';
1050
- state = CalendarScheduleSelectionDayState.DISABLED;
1051
- }
1052
- else if (isEnabledDay(i)) {
1053
- viewDay.cssClass = 'cal-day-selected';
1054
- state = CalendarScheduleSelectionDayState.SELECTED;
1055
- }
1056
- else {
1057
- viewDay.cssClass = 'cal-day-not-selected';
1058
- state = CalendarScheduleSelectionDayState.NOT_SELECTED;
1059
- }
1060
- viewDay.meta = {
1061
- state,
1062
- i
1063
- };
1064
- });
1092
+ this.beforeMonthViewRender$.pipe(first()).subscribe((x) => {
1093
+ x(renderEvent);
1065
1094
  });
1066
1095
  }
1067
1096
  }
@@ -1462,5 +1491,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
1462
1491
  * Generated bundle index. Do not edit.
1463
1492
  */
1464
1493
 
1465
- export { CalendarScheduleSelectionDayState, DEFAULT_DBX_SCHEDULE_SELECTION_CALENDAR_DATE_POPUP_CLOSE_CONFIG_TOKEN, DEFAULT_DBX_SCHEDULE_SELECTION_CALENDAR_DATE_POPUP_CONTENT_CONFIG_TOKEN, DEFAULT_SCHEDULE_SELECTION_CALENDAR_DATE_POPOVER_KEY, DbxCalendarScheduleSelectionStore, DbxCalendarScheduleSelectionStoreInjectionBlockDirective, DbxCalendarScheduleSelectionStoreProviderBlock, DbxFormCalendarDateScheduleRangeFieldComponent, DbxFormCalendarModule, DbxFormDateScheduleRangeFieldModule, DbxScheduleSelectionCalendarCellComponent, DbxScheduleSelectionCalendarComponent, DbxScheduleSelectionCalendarDateDaysComponent, DbxScheduleSelectionCalendarDateDaysFormComponent, DbxScheduleSelectionCalendarDateDialogButtonComponent, DbxScheduleSelectionCalendarDateDialogComponent, DbxScheduleSelectionCalendarDatePopoverButtonComponent, DbxScheduleSelectionCalendarDatePopoverComponent, DbxScheduleSelectionCalendarDatePopoverContentComponent, DbxScheduleSelectionCalendarDateRangeComponent, DbxScheduleSelectionCalendarSelectionToggleButtonComponent, calendarScheduleMaxDate, calendarScheduleMinAndMaxDateRange, calendarScheduleMinDate, calendarScheduleStartBeingUsedFromFilter, computeCalendarScheduleSelectionDateBlockRange, computeCalendarScheduleSelectionRange, computeScheduleSelectionRangeAndExclusion, computeScheduleSelectionValue, dateScheduleRangeField, dbxScheduleSelectionCalendarDateDaysFormDayFields, dbxScheduleSelectionCalendarDateDaysFormFields, defaultCalendarScheduleSelectionCellContentFactory, finalizeNewCalendarScheduleSelectionState, initialCalendarScheduleSelectionState, isEnabledDayInCalendarScheduleSelectionState, noSelectionCalendarScheduleSelectionState, provideCalendarScheduleSelectionStoreIfParentIsUnavailable, updateStateWithChangedDates, updateStateWithChangedRange, updateStateWithChangedScheduleDays, updateStateWithComputeSelectionResultRelativeToFilter, updateStateWithDateScheduleRangeValue, updateStateWithExclusions, updateStateWithFilter, updateStateWithInitialSelectionState, updateStateWithMinMaxDateRange, updateStateWithTimezoneValue };
1494
+ export { CalendarScheduleSelectionDayState, DEFAULT_DBX_SCHEDULE_SELECTION_CALENDAR_DATE_POPUP_CLOSE_CONFIG_TOKEN, DEFAULT_DBX_SCHEDULE_SELECTION_CALENDAR_DATE_POPUP_CONTENT_CONFIG_TOKEN, DEFAULT_SCHEDULE_SELECTION_CALENDAR_DATE_POPOVER_KEY, DbxCalendarScheduleSelectionStore, DbxCalendarScheduleSelectionStoreInjectionBlockDirective, DbxCalendarScheduleSelectionStoreProviderBlock, DbxFormCalendarDateScheduleRangeFieldComponent, DbxFormCalendarModule, DbxFormDateScheduleRangeFieldModule, DbxScheduleSelectionCalendarCellComponent, DbxScheduleSelectionCalendarComponent, DbxScheduleSelectionCalendarDateDaysComponent, DbxScheduleSelectionCalendarDateDaysFormComponent, DbxScheduleSelectionCalendarDateDialogButtonComponent, DbxScheduleSelectionCalendarDateDialogComponent, DbxScheduleSelectionCalendarDatePopoverButtonComponent, DbxScheduleSelectionCalendarDatePopoverComponent, DbxScheduleSelectionCalendarDatePopoverContentComponent, DbxScheduleSelectionCalendarDateRangeComponent, DbxScheduleSelectionCalendarSelectionToggleButtonComponent, calendarScheduleMaxDate, calendarScheduleMinAndMaxDateRange, calendarScheduleMinDate, calendarScheduleStartBeingUsedFromFilter, computeCalendarScheduleSelectionDateBlockRange, computeCalendarScheduleSelectionRange, computeScheduleSelectionRangeAndExclusion, computeScheduleSelectionValue, dateScheduleRangeField, dbxScheduleSelectionCalendarBeforeMonthViewRenderFactory, dbxScheduleSelectionCalendarDateDaysFormDayFields, dbxScheduleSelectionCalendarDateDaysFormFields, defaultCalendarScheduleSelectionCellContentFactory, finalizeNewCalendarScheduleSelectionState, initialCalendarScheduleSelectionState, isEnabledDayInCalendarScheduleSelectionState, noSelectionCalendarScheduleSelectionState, provideCalendarScheduleSelectionStoreIfParentIsUnavailable, updateStateWithChangedDates, updateStateWithChangedRange, updateStateWithChangedScheduleDays, updateStateWithComputeSelectionResultRelativeToFilter, updateStateWithDateScheduleRangeValue, updateStateWithExclusions, updateStateWithFilter, updateStateWithInitialSelectionState, updateStateWithMinMaxDateRange, updateStateWithTimezoneValue };
1466
1495
  //# sourceMappingURL=dereekb-dbx-form-calendar.mjs.map