@dereekb/dbx-form 9.25.5 → 9.25.6

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,7 +5,7 @@ import { Injectable, SkipSelf, Directive, Injector, Optional, Component, Inject,
5
5
  import { FieldType } from '@ngx-formly/material';
6
6
  import { switchMap, first, tap, map, distinctUntilChanged, shareReplay, of, combineLatestWith, BehaviorSubject, filter, combineLatest, EMPTY, startWith, throttleTime } from 'rxjs';
7
7
  import { filterMaybe, distinctUntilHasDifferentValues, SubscriptionObject, asObservableFromGetter, asObservable } from '@dereekb/rxjs';
8
- import { DateCellScheduleDayCode, expandDateCellScheduleDayCodesToDayOfWeekSet, dateCellTimingStartsAtForStartOfDay, dateCellTimingRelativeIndexFactory, dateCellDayOfWeekFactory, findMaxDate, findMinDate, isSameDateRange, isSameDateDay, isSameDate, dateCellTimingDateFactory, expandDateCellScheduleRange, formatToISO8601DayString, changeDateCellScheduleDateRangeToTimezone, isSameDateCellScheduleDateRange, dateCellTimingRelativeIndexArrayFactory, isInfiniteDateRange, copyDateCellScheduleDateFilterConfig, SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE, dateTimezoneUtcNormal, dateCellScheduleDateFilter, fullDateCellScheduleRange, dateCellTimingTimezoneNormalInstance, expandDateCellScheduleDayCodes, fullWeekDateCellScheduleDayCodes, dateCellScheduleDayCodesAreSetsEquivalent, simplifyDateCellScheduleDayCodes, isDateInDateRangeFunction, isDateWithinDateCellRangeFunction, dateCellScheduleEncodedWeek, dateCellTimingStartDateFactory, enabledDaysFromDateCellScheduleDayCodes, dateCellScheduleDayCodesFromEnabledDays, formatToMonthDayString, dateRange, DateRangeType } from '@dereekb/date';
8
+ import { DateCellScheduleDayCode, expandDateCellScheduleDayCodesToDayOfWeekSet, dateCellTimingStartsAtForStartOfDay, dateCellTimingRelativeIndexFactory, dateCellDayOfWeekFactory, dateTimezoneUtcNormal, findMaxDate, findMinDate, isSameDateRange, isSameDateDay, isSameDate, dateCellTimingDateFactory, expandDateCellScheduleRange, formatToISO8601DayString, changeDateCellScheduleDateRangeToTimezone, isSameDateCellScheduleDateRange, dateCellTimingRelativeIndexArrayFactory, isInfiniteDateRange, copyDateCellScheduleDateFilterConfig, SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE, dateCellScheduleDateFilter, fullDateCellScheduleRange, dateCellTimingTimezoneNormalInstance, expandDateCellScheduleDayCodes, fullWeekDateCellScheduleDayCodes, dateCellScheduleDayCodesAreSetsEquivalent, simplifyDateCellScheduleDayCodes, isDateInDateRangeFunction, isDateWithinDateCellRangeFunction, dateCellScheduleEncodedWeek, dateCellTimingStartDateFactory, enabledDaysFromDateCellScheduleDayCodes, dateCellScheduleDayCodesFromEnabledDays, formatToMonthDayString, dateRange, DateRangeType } from '@dereekb/date';
9
9
  import { isInAllowedDaysOfWeekSet, mapValuesToSet, unique, mergeArrays, iterableToArray, range, toggleInSet, removeFromSet, addToSet, isIndexNumberInIndexRangeFunction, minAndMaxNumber, getDaysOfWeekNames, reduceBooleansWithAnd, mergeObjects, KeyValueTypleValueFilter } from '@dereekb/util';
10
10
  import { ComponentStore } from '@ngrx/component-store';
11
11
  import { startOfDay, endOfDay, isBefore, endOfWeek } from 'date-fns';
@@ -112,6 +112,36 @@ function initialCalendarScheduleSelectionState() {
112
112
  cellContentFactory: defaultCalendarScheduleSelectionCellContentFactory
113
113
  };
114
114
  }
115
+ /**
116
+ * This is used in cases where the dates in the min/max date range need to be shifted to the filter's timezone.
117
+ *
118
+ * This is because the index factory is always in system timezone, but when selecting all/none with a filter we need to use the filter's timezone.
119
+ *
120
+ * @param x
121
+ * @returns
122
+ */
123
+ function calendarScheduleMinAndMaxDateRangeRelativeToFilter(x) {
124
+ var _a;
125
+ let input = x;
126
+ if (((_a = x.filter) === null || _a === void 0 ? void 0 : _a.timezone) && x.minMaxDateRange != null) {
127
+ const filterNormal = dateTimezoneUtcNormal(x.filter.timezone);
128
+ const transformFn = filterNormal.transformFunction('systemDateToTargetDate');
129
+ input = {
130
+ filter: x.filter,
131
+ minMaxDateRange: {
132
+ start: x.minMaxDateRange.start ? transformFn(x.minMaxDateRange.start) : undefined,
133
+ end: x.minMaxDateRange.end ? transformFn(x.minMaxDateRange.end) : undefined
134
+ }
135
+ };
136
+ }
137
+ return calendarScheduleMinAndMaxDateRange(input);
138
+ }
139
+ function calendarScheduleMinAndMaxDateRange(x) {
140
+ return {
141
+ start: calendarScheduleMinDate(x) || undefined,
142
+ end: calendarScheduleMaxDate(x) || undefined
143
+ };
144
+ }
115
145
  function calendarScheduleMinDate(x) {
116
146
  var _a, _b;
117
147
  return findMaxDate([(_a = x.filter) === null || _a === void 0 ? void 0 : _a.start, (_b = x.minMaxDateRange) === null || _b === void 0 ? void 0 : _b.start]);
@@ -120,12 +150,6 @@ function calendarScheduleMaxDate(x) {
120
150
  var _a, _b;
121
151
  return findMinDate([(_a = x.filter) === null || _a === void 0 ? void 0 : _a.end, (_b = x.minMaxDateRange) === null || _b === void 0 ? void 0 : _b.end]);
122
152
  }
123
- function calendarScheduleMinAndMaxDateRange(x) {
124
- return {
125
- start: calendarScheduleMinDate(x) || undefined,
126
- end: calendarScheduleMaxDate(x) || undefined
127
- };
128
- }
129
153
  function calendarScheduleStartBeingUsedFromFilter(x) {
130
154
  var _a;
131
155
  return x.computeSelectionResultRelativeToFilter && ((_a = x.filter) === null || _a === void 0 ? void 0 : _a.start) != null; // may be using either
@@ -538,7 +562,7 @@ function finalizeUpdateStateWithChangedScheduleDays(previousState, nextState) {
538
562
  function updateStateWithChangedDates(state, change) {
539
563
  var _a;
540
564
  const { allowedDaysOfWeek, indexFactory, indexDayOfWeek, inputStart: currentInputStart, inputEnd: currentInputEnd, minMaxDateRange, filter } = state;
541
- const { start: minDate, end: maxDate } = calendarScheduleMinAndMaxDateRange(state);
565
+ const { start: minDate, end: maxDate } = calendarScheduleMinAndMaxDateRangeRelativeToFilter(state);
542
566
  let inputStart = currentInputStart;
543
567
  let inputEnd = currentInputEnd;
544
568
  /**
@@ -623,8 +647,8 @@ function noSelectionCalendarScheduleSelectionState(state) {
623
647
  return finalizeNewCalendarScheduleSelectionState(Object.assign(Object.assign({}, state), { toggledIndexes: new Set(), inputStart: null, inputEnd: null }));
624
648
  }
625
649
  function updateStateWithChangedRange(state, change) {
626
- const { inputStart: currentInputStart, inputEnd: currentInputEnd, indexFactory, minMaxDateRange } = state;
627
- const { start: minDate, end: maxDate } = minMaxDateRange !== null && minMaxDateRange !== void 0 ? minMaxDateRange : {};
650
+ const { inputStart: currentInputStart, inputEnd: currentInputEnd, indexFactory } = state;
651
+ const { start: minDate, end: maxDate } = calendarScheduleMinAndMaxDateRange(state);
628
652
  const inputStart = startOfDay(change.inputStart);
629
653
  const inputEnd = startOfDay(change.inputEnd); // midnight of the last day
630
654
  const isValidRange = minDate != null || maxDate != null ? isDateInDateRangeFunction({ start: minDate !== null && minDate !== void 0 ? minDate : undefined, end: maxDate !== null && maxDate !== void 0 ? maxDate : undefined }) : () => true;