@dereekb/dbx-form 9.24.3 → 9.24.5
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/LICENSE +1 -1
- package/calendar/lib/calendar.schedule.selection.component.d.ts +20 -6
- package/calendar/lib/calendar.schedule.selection.store.d.ts +18 -4
- package/esm2020/calendar/lib/calendar.schedule.selection.component.mjs +57 -32
- package/esm2020/calendar/lib/calendar.schedule.selection.dialog.component.mjs +3 -3
- package/esm2020/calendar/lib/calendar.schedule.selection.store.mjs +72 -31
- package/fesm2015/dereekb-dbx-form-calendar.mjs +129 -64
- package/fesm2015/dereekb-dbx-form-calendar.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-form-calendar.mjs +129 -64
- package/fesm2020/dereekb-dbx-form-calendar.mjs.map +1 -1
- package/mapbox/package.json +4 -4
- package/package.json +4 -4
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as i4$1 from '@dereekb/dbx-form';
|
|
2
2
|
import { formlyField, propsAndConfigForFieldConfig, flexLayoutWrapper, toggleField, AbstractSyncFormlyFormDirective, provideFormlyContext, DbxFormModule, DbxFormlyModule } from '@dereekb/dbx-form';
|
|
3
3
|
import * as i1$1 from '@dereekb/dbx-web';
|
|
4
|
-
import { AbstractPopoverDirective, AbstractDialogDirective, DbxActionModule, DbxButtonModule, DbxDialogInteractionModule, DbxPopoverInteractionModule, DbxTextModule } from '@dereekb/dbx-web';
|
|
4
|
+
import { AbstractPopoverDirective, AbstractDialogDirective, sanitizeDbxDialogContentConfig, DbxActionModule, DbxButtonModule, DbxDialogInteractionModule, DbxPopoverInteractionModule, DbxTextModule } from '@dereekb/dbx-web';
|
|
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';
|
|
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';
|
|
11
|
-
import { setsAreEquivalent, unique, mergeArrays, iterableToArray, toggleInSet, addToSet, isIndexNumberInIndexRangeFunction,
|
|
8
|
+
import { switchMap, first, tap, map, distinctUntilChanged, shareReplay, combineLatestWith, BehaviorSubject, of, startWith, filter, throttleTime, combineLatest } from 'rxjs';
|
|
9
|
+
import { filterMaybe, distinctUntilHasDifferentValues, SubscriptionObject, asObservable } from '@dereekb/rxjs';
|
|
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
|
+
import { setsAreEquivalent, unique, mergeArrays, iterableToArray, range, toggleInSet, removeFromSet, addToSet, isIndexNumberInIndexRangeFunction, minAndMaxNumber, getDaysOfWeekNames, mergeObjects, KeyValueTypleValueFilter } from '@dereekb/util';
|
|
12
12
|
import { ComponentStore } from '@ngrx/component-store';
|
|
13
13
|
import { startOfDay, endOfDay, isBefore } from 'date-fns';
|
|
14
14
|
import * as i1 from '@dereekb/dbx-web/calendar';
|
|
@@ -100,7 +100,7 @@ function initialCalendarScheduleSelectionState() {
|
|
|
100
100
|
return {
|
|
101
101
|
start,
|
|
102
102
|
indexFactory,
|
|
103
|
-
|
|
103
|
+
toggledIndexes: new Set(),
|
|
104
104
|
scheduleDays,
|
|
105
105
|
allowedDaysOfWeek,
|
|
106
106
|
indexDayOfWeek,
|
|
@@ -151,7 +151,10 @@ class DbxCalendarScheduleSelectionStore extends ComponentStore {
|
|
|
151
151
|
}
|
|
152
152
|
}), shareReplay(1));
|
|
153
153
|
this.inputRange$ = this.currentInputRange$.pipe(filterMaybe(), shareReplay(1));
|
|
154
|
-
|
|
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
|
+
*/
|
|
157
|
+
this.selectedDates$ = this.state$.pipe(map((x) => x.toggledIndexes), 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));
|
|
157
160
|
this.currentDateRange$ = this.state$.pipe(map(computeCalendarScheduleSelectionRange), distinctUntilChanged((a, b) => isSameDateRange(a, b)), shareReplay(1));
|
|
@@ -165,6 +168,9 @@ class DbxCalendarScheduleSelectionStore extends ComponentStore {
|
|
|
165
168
|
this.effectiveTimezone$ = this.state$.pipe(map((x) => (!calendarScheduleStartBeingUsedFromFilter(x) && x.timezone ? x.timezone : undefined)), distinctUntilChanged(), shareReplay(1));
|
|
166
169
|
this.effectiveTimezoneNormal$ = this.state$.pipe(map((x) => (!calendarScheduleStartBeingUsedFromFilter(x) && x.timezoneNormal ? x.timezoneNormal : undefined)), distinctUntilChanged(), shareReplay(1));
|
|
167
170
|
this.currentSelectionValue$ = this.state$.pipe(map((x) => x.currentSelectionValue), shareReplay(1));
|
|
171
|
+
this.currentSelectionValueDateBlockDurationSpan$ = this.currentSelectionValue$.pipe(map((x) => (x ? expandDateScheduleRange(x) : [])), shareReplay(1));
|
|
172
|
+
this.selectionValueSelectedIndexes$ = this.currentSelectionValueDateBlockDurationSpan$.pipe(map((x) => new Set(x.map((y) => y.i))), distinctUntilHasDifferentValues(), shareReplay(1));
|
|
173
|
+
this.selectionValue$ = this.currentSelectionValue$.pipe(filterMaybe(), shareReplay(1));
|
|
168
174
|
this.currentSelectionValueWithTimezone$ = this.currentSelectionValue$.pipe(combineLatestWith(this.effectiveTimezoneNormal$), map(([x, timezoneNormal]) => {
|
|
169
175
|
if (x && timezoneNormal) {
|
|
170
176
|
x = {
|
|
@@ -177,6 +183,8 @@ class DbxCalendarScheduleSelectionStore extends ComponentStore {
|
|
|
177
183
|
}
|
|
178
184
|
return x;
|
|
179
185
|
}), distinctUntilChanged(), shareReplay(1));
|
|
186
|
+
this.selectionValueWithTimezone$ = this.currentSelectionValueWithTimezone$.pipe(filterMaybe(), shareReplay(1));
|
|
187
|
+
this.selectionValueWithTimezoneDateBlockDurationSpan$ = this.selectionValueWithTimezone$.pipe(map((x) => expandDateScheduleRange(x)), shareReplay(1));
|
|
180
188
|
this.nextToggleSelection$ = this.hasConfiguredMinMaxRange$.pipe(switchMap((hasConfiguredMinMaxRange) => {
|
|
181
189
|
let obs;
|
|
182
190
|
if (hasConfiguredMinMaxRange) {
|
|
@@ -187,11 +195,10 @@ class DbxCalendarScheduleSelectionStore extends ComponentStore {
|
|
|
187
195
|
}
|
|
188
196
|
return obs;
|
|
189
197
|
}), shareReplay(1));
|
|
190
|
-
this.selectionValue$ = this.currentSelectionValueWithTimezone$.pipe(filterMaybe(), shareReplay(1));
|
|
191
198
|
this.currentDateScheduleRangeValue$ = this.currentSelectionValueWithTimezone$.pipe(map((x) => x?.dateScheduleRange), distinctUntilChanged(isSameDateScheduleRange), shareReplay(1));
|
|
192
199
|
this.dateScheduleRangeValue$ = this.currentDateScheduleRangeValue$.pipe(filterMaybe(), shareReplay(1));
|
|
193
200
|
this.cellContentFactory$ = this.state$.pipe(map((x) => x.cellContentFactory), distinctUntilChanged(), shareReplay(1));
|
|
194
|
-
this.isCustomized$ = this.state$.pipe(map((x) => x.
|
|
201
|
+
this.isCustomized$ = this.state$.pipe(map((x) => x.toggledIndexes.size > 0), distinctUntilChanged(), shareReplay(1));
|
|
195
202
|
// MARK: State Changes
|
|
196
203
|
this.setMinMaxDateRange = this.updater(updateStateWithMinMaxDateRange);
|
|
197
204
|
this.setFilter = this.updater(updateStateWithFilter);
|
|
@@ -200,10 +207,13 @@ class DbxCalendarScheduleSelectionStore extends ComponentStore {
|
|
|
200
207
|
this.clearFilter = this.updater((state) => updateStateWithFilter(state, undefined));
|
|
201
208
|
this.setTimezone = this.updater(updateStateWithTimezoneValue);
|
|
202
209
|
this.setInputRange = this.updater(updateStateWithChangedRange);
|
|
210
|
+
// NOTE: Selected dates are NOT selected indexes. They are the internal selected dates that are excluded from the selection.
|
|
203
211
|
this.toggleSelectedDates = this.updater((state, toggle) => updateStateWithChangedDates(state, { toggle }));
|
|
204
212
|
this.addSelectedDates = this.updater((state, add) => updateStateWithChangedDates(state, { add }));
|
|
205
213
|
this.removeSelectedDates = this.updater((state, remove) => updateStateWithChangedDates(state, { remove }));
|
|
206
214
|
this.setSelectedDates = this.updater((state, set) => updateStateWithChangedDates(state, { set }));
|
|
215
|
+
// NOTE: Selected indexes are the typical/expected indexes that are selected or not.
|
|
216
|
+
this.setSelectedIndexes = this.updater((state, set) => updateStateWithChangedDates(state, { set, invertSetBehavior: true }));
|
|
207
217
|
this.selectAllDates = this.updater((state, selectAll = 'all') => updateStateWithChangedDates(state, { selectAll }));
|
|
208
218
|
this.setInitialSelectionState = this.updater(updateStateWithInitialSelectionState);
|
|
209
219
|
this.setScheduleDays = this.updater(updateStateWithChangedScheduleDays);
|
|
@@ -218,8 +228,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
218
228
|
type: Injectable
|
|
219
229
|
}], ctorParameters: function () { return []; } });
|
|
220
230
|
function updateStateWithInitialSelectionState(state, initialSelectionState) {
|
|
221
|
-
const {
|
|
222
|
-
if (
|
|
231
|
+
const { toggledIndexes } = state;
|
|
232
|
+
if (toggledIndexes.size === 0 && initialSelectionState === 'all') {
|
|
223
233
|
state = updateStateWithChangedDates(state, { selectAll: initialSelectionState });
|
|
224
234
|
}
|
|
225
235
|
return { ...state, initialSelectionState };
|
|
@@ -349,7 +359,7 @@ function updateStateWithDateScheduleRangeValue(state, change) {
|
|
|
349
359
|
}
|
|
350
360
|
else {
|
|
351
361
|
if (change != null) {
|
|
352
|
-
const nextState = { ...state, inputStart: change.start, inputEnd: change.end,
|
|
362
|
+
const nextState = { ...state, inputStart: change.start, inputEnd: change.end, toggledIndexes: new Set(change.ex) };
|
|
353
363
|
return updateStateWithChangedScheduleDays(finalizeNewCalendarScheduleSelectionState(nextState), expandDateScheduleDayCodes(change.w || '89'));
|
|
354
364
|
}
|
|
355
365
|
else {
|
|
@@ -370,12 +380,20 @@ function updateStateWithChangedScheduleDays(state, change) {
|
|
|
370
380
|
}
|
|
371
381
|
}
|
|
372
382
|
function updateStateWithChangedDates(state, change) {
|
|
373
|
-
const { indexFactory, allowedDaysOfWeek, indexDayOfWeek, inputStart: currentInputStart, inputEnd: currentInputEnd, minMaxDateRange } = state;
|
|
383
|
+
const { indexFactory, allowedDaysOfWeek, indexDayOfWeek, inputStart: currentInputStart, inputEnd: currentInputEnd, minMaxDateRange, filter } = state;
|
|
374
384
|
const { start: minDate, end: maxDate } = calendarScheduleMinAndMaxDateRange(state);
|
|
375
385
|
let inputStart = currentInputStart;
|
|
376
386
|
let inputEnd = currentInputEnd;
|
|
377
|
-
|
|
378
|
-
|
|
387
|
+
/**
|
|
388
|
+
* This is a set of indexes that are internally "selected" so that they are excluded from the inputStart/inputEnd date range.
|
|
389
|
+
*
|
|
390
|
+
* Do not confuse this with the actual indexes that are selected.
|
|
391
|
+
*/
|
|
392
|
+
let toggledIndexes;
|
|
393
|
+
function asIndexes(indexes) {
|
|
394
|
+
return iterableToArray(indexes).map(indexFactory);
|
|
395
|
+
}
|
|
396
|
+
if (change.reset || change.selectAll != null || change.set != null) {
|
|
379
397
|
let set = change.set ?? [];
|
|
380
398
|
const selectAll = change.reset === true ? state.initialSelectionState : change.selectAll;
|
|
381
399
|
switch (selectAll) {
|
|
@@ -392,29 +410,52 @@ function updateStateWithChangedDates(state, change) {
|
|
|
392
410
|
set = [];
|
|
393
411
|
break;
|
|
394
412
|
}
|
|
395
|
-
|
|
413
|
+
toggledIndexes = new Set(asIndexes(set));
|
|
414
|
+
if (change.invertSetBehavior && minDate && maxDate && !selectAll) {
|
|
415
|
+
const minIndex = indexFactory(minDate);
|
|
416
|
+
const maxIndex = indexFactory(maxDate);
|
|
417
|
+
inputStart = minDate;
|
|
418
|
+
inputEnd = maxDate;
|
|
419
|
+
toggledIndexes = new Set(range(minIndex, maxIndex + 1).filter((x) => !toggledIndexes.has(x)));
|
|
420
|
+
}
|
|
396
421
|
}
|
|
397
422
|
else {
|
|
398
|
-
|
|
423
|
+
toggledIndexes = new Set(state.toggledIndexes);
|
|
399
424
|
if (change.toggle) {
|
|
400
|
-
const allowedToToggle =
|
|
401
|
-
|
|
402
|
-
.filter((i) => allowedDaysOfWeek.has(indexDayOfWeek(i)));
|
|
403
|
-
toggleInSet(selectedIndexes, allowedToToggle);
|
|
425
|
+
const allowedToToggle = asIndexes(change.toggle).filter((i) => allowedDaysOfWeek.has(indexDayOfWeek(i)));
|
|
426
|
+
toggleInSet(toggledIndexes, allowedToToggle);
|
|
404
427
|
}
|
|
428
|
+
let addToExclusion;
|
|
429
|
+
let removeFromExclusion;
|
|
405
430
|
if (change.add) {
|
|
406
|
-
|
|
431
|
+
if (change.invertSetBehavior) {
|
|
432
|
+
addToExclusion = change.add;
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
removeFromExclusion = change.add;
|
|
436
|
+
}
|
|
407
437
|
}
|
|
408
438
|
if (change.remove) {
|
|
409
|
-
|
|
439
|
+
if (change.invertSetBehavior) {
|
|
440
|
+
removeFromExclusion = change.remove;
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
addToExclusion = change.remove;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
if (addToExclusion) {
|
|
447
|
+
removeFromSet(toggledIndexes, asIndexes(addToExclusion));
|
|
448
|
+
}
|
|
449
|
+
if (removeFromExclusion) {
|
|
450
|
+
addToSet(toggledIndexes, asIndexes(removeFromExclusion));
|
|
410
451
|
}
|
|
411
452
|
}
|
|
412
|
-
const nextState = { ...state, inputStart, inputEnd,
|
|
453
|
+
const nextState = { ...state, inputStart, inputEnd, toggledIndexes };
|
|
413
454
|
nextState.isEnabledDay = isEnabledDayInCalendarScheduleSelectionState(nextState);
|
|
414
455
|
// Recalculate the range and simplified to exclusions
|
|
415
456
|
const rangeAndExclusion = computeScheduleSelectionRangeAndExclusion(nextState);
|
|
416
457
|
if (rangeAndExclusion) {
|
|
417
|
-
return finalizeNewCalendarScheduleSelectionState({ ...nextState,
|
|
458
|
+
return finalizeNewCalendarScheduleSelectionState({ ...nextState, toggledIndexes: new Set(rangeAndExclusion.excluded), inputStart: rangeAndExclusion.start, inputEnd: rangeAndExclusion.end });
|
|
418
459
|
}
|
|
419
460
|
else {
|
|
420
461
|
// no selected days
|
|
@@ -422,7 +463,7 @@ function updateStateWithChangedDates(state, change) {
|
|
|
422
463
|
}
|
|
423
464
|
}
|
|
424
465
|
function noSelectionCalendarScheduleSelectionState(state) {
|
|
425
|
-
return finalizeNewCalendarScheduleSelectionState({ ...state,
|
|
466
|
+
return finalizeNewCalendarScheduleSelectionState({ ...state, toggledIndexes: new Set(), inputStart: null, inputEnd: null });
|
|
426
467
|
}
|
|
427
468
|
function updateStateWithChangedRange(state, change) {
|
|
428
469
|
const { inputStart: currentInputStart, inputEnd: currentInputEnd, indexFactory, minMaxDateRange } = state;
|
|
@@ -436,11 +477,11 @@ function updateStateWithChangedRange(state, change) {
|
|
|
436
477
|
// retain all indexes that are within the new range
|
|
437
478
|
const minIndex = indexFactory(inputStart);
|
|
438
479
|
const maxIndex = indexFactory(inputEnd) + 1;
|
|
439
|
-
const currentIndexes = Array.from(state.
|
|
480
|
+
const currentIndexes = Array.from(state.toggledIndexes);
|
|
440
481
|
const isInCurrentRange = isIndexNumberInIndexRangeFunction({ minIndex, maxIndex });
|
|
441
482
|
const excludedIndexesInNewRange = currentIndexes.filter(isInCurrentRange);
|
|
442
|
-
const
|
|
443
|
-
const nextState = { ...state,
|
|
483
|
+
const toggledIndexes = new Set(excludedIndexesInNewRange);
|
|
484
|
+
const nextState = { ...state, toggledIndexes, inputStart, inputEnd };
|
|
444
485
|
return finalizeNewCalendarScheduleSelectionState(nextState);
|
|
445
486
|
}
|
|
446
487
|
function finalizeNewCalendarScheduleSelectionState(nextState) {
|
|
@@ -461,7 +502,7 @@ function isEnabledDayInCalendarScheduleSelectionState(state) {
|
|
|
461
502
|
const index = indexFactory(input);
|
|
462
503
|
const dayOfWeek = indexDayOfWeek(index);
|
|
463
504
|
const isInSelectedRange = isInStartAndEndRange(input);
|
|
464
|
-
const isSelected = state.
|
|
505
|
+
const isSelected = state.toggledIndexes.has(index);
|
|
465
506
|
const isAllowedDayOfWeek = allowedDaysOfWeek.has(dayOfWeek);
|
|
466
507
|
const result = isAllowedDayOfWeek && ((isInSelectedRange && !isSelected) || (isSelected && !isInSelectedRange));
|
|
467
508
|
return result;
|
|
@@ -543,8 +584,8 @@ function computeCalendarScheduleSelectionRange(state) {
|
|
|
543
584
|
}
|
|
544
585
|
function computeCalendarScheduleSelectionDateBlockRange(state) {
|
|
545
586
|
const { indexFactory, inputStart, inputEnd, allowedDaysOfWeek, indexDayOfWeek, isEnabledDay, isEnabledFilterDay } = state;
|
|
546
|
-
const
|
|
547
|
-
const minAndMaxSelectedValues = minAndMaxNumber(
|
|
587
|
+
const enabledExclusionIndexes = Array.from(state.toggledIndexes).filter((i) => allowedDaysOfWeek.has(indexDayOfWeek(i)));
|
|
588
|
+
const minAndMaxSelectedValues = minAndMaxNumber(enabledExclusionIndexes);
|
|
548
589
|
let startRange;
|
|
549
590
|
let endRange;
|
|
550
591
|
if (minAndMaxSelectedValues) {
|
|
@@ -999,6 +1040,46 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
999
1040
|
}]
|
|
1000
1041
|
}], ctorParameters: function () { return [{ type: i1$1.DbxPopoverService }, { type: DbxCalendarScheduleSelectionStore }, { type: i0.Injector }]; } });
|
|
1001
1042
|
|
|
1043
|
+
function dbxScheduleSelectionCalendarBeforeMonthViewRenderFactory(inputModifyFn) {
|
|
1044
|
+
const modifyFn = inputModifyFn || (() => { });
|
|
1045
|
+
return (state$) => {
|
|
1046
|
+
return (renderEvent) => {
|
|
1047
|
+
const { body } = renderEvent;
|
|
1048
|
+
// use latest/current state
|
|
1049
|
+
state$.pipe(first()).subscribe((calendarScheduleState) => {
|
|
1050
|
+
const { isEnabledDay, indexFactory, isEnabledFilterDay, allowedDaysOfWeek } = calendarScheduleState;
|
|
1051
|
+
body.forEach((viewDay) => {
|
|
1052
|
+
const { date } = viewDay;
|
|
1053
|
+
const i = indexFactory(date);
|
|
1054
|
+
const day = date.getDay();
|
|
1055
|
+
let state;
|
|
1056
|
+
if (!isEnabledFilterDay(i)) {
|
|
1057
|
+
viewDay.cssClass = 'cal-day-not-applicable';
|
|
1058
|
+
state = CalendarScheduleSelectionDayState.NOT_APPLICABLE;
|
|
1059
|
+
}
|
|
1060
|
+
else if (!allowedDaysOfWeek.has(day)) {
|
|
1061
|
+
viewDay.cssClass = 'cal-day-disabled';
|
|
1062
|
+
state = CalendarScheduleSelectionDayState.DISABLED;
|
|
1063
|
+
}
|
|
1064
|
+
else if (isEnabledDay(i)) {
|
|
1065
|
+
viewDay.cssClass = 'cal-day-selected';
|
|
1066
|
+
state = CalendarScheduleSelectionDayState.SELECTED;
|
|
1067
|
+
}
|
|
1068
|
+
else {
|
|
1069
|
+
viewDay.cssClass = 'cal-day-not-selected';
|
|
1070
|
+
state = CalendarScheduleSelectionDayState.NOT_SELECTED;
|
|
1071
|
+
}
|
|
1072
|
+
const meta = {
|
|
1073
|
+
state,
|
|
1074
|
+
i
|
|
1075
|
+
};
|
|
1076
|
+
viewDay.meta = meta;
|
|
1077
|
+
modifyFn(viewDay, calendarScheduleState);
|
|
1078
|
+
});
|
|
1079
|
+
});
|
|
1080
|
+
};
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1002
1083
|
class DbxScheduleSelectionCalendarComponent {
|
|
1003
1084
|
constructor(calendarStore, dbxCalendarScheduleSelectionStore) {
|
|
1004
1085
|
this.calendarStore = calendarStore;
|
|
@@ -1009,7 +1090,17 @@ class DbxScheduleSelectionCalendarComponent {
|
|
|
1009
1090
|
this.clickEvent = new EventEmitter();
|
|
1010
1091
|
// refresh any time the selected day function updates
|
|
1011
1092
|
this.state$ = this.dbxCalendarScheduleSelectionStore.state$;
|
|
1012
|
-
this.
|
|
1093
|
+
this.beforeMonthViewRender$ = this._config.pipe(switchMap((x) => {
|
|
1094
|
+
let factory;
|
|
1095
|
+
if (x.beforeMonthViewRenderFunctionFactory) {
|
|
1096
|
+
factory = asObservable(x.beforeMonthViewRenderFunctionFactory);
|
|
1097
|
+
}
|
|
1098
|
+
else {
|
|
1099
|
+
factory = asObservable(x.customizeDay).pipe(map((x) => dbxScheduleSelectionCalendarBeforeMonthViewRenderFactory(x)));
|
|
1100
|
+
}
|
|
1101
|
+
return factory.pipe(map((x) => x(this.state$)));
|
|
1102
|
+
}), shareReplay(1));
|
|
1103
|
+
this.refresh$ = combineLatest([this.state$, this.beforeMonthViewRender$]).pipe(throttleTime(100), map(() => undefined));
|
|
1013
1104
|
this.events$ = this.calendarStore.visibleEvents$.pipe(map(prepareAndSortCalendarEvents), shareReplay(1));
|
|
1014
1105
|
this.viewDate$ = this.calendarStore.date$;
|
|
1015
1106
|
}
|
|
@@ -1025,7 +1116,7 @@ class DbxScheduleSelectionCalendarComponent {
|
|
|
1025
1116
|
return this._config.value;
|
|
1026
1117
|
}
|
|
1027
1118
|
set config(config) {
|
|
1028
|
-
this._config.next(config);
|
|
1119
|
+
this._config.next(config ?? {});
|
|
1029
1120
|
}
|
|
1030
1121
|
dayClicked({ date }) {
|
|
1031
1122
|
this.dbxCalendarScheduleSelectionStore.toggleSelectedDates(date);
|
|
@@ -1034,34 +1125,8 @@ class DbxScheduleSelectionCalendarComponent {
|
|
|
1034
1125
|
this.clickEvent.emit({ action, event });
|
|
1035
1126
|
}
|
|
1036
1127
|
beforeMonthViewRender(renderEvent) {
|
|
1037
|
-
|
|
1038
|
-
|
|
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
|
-
});
|
|
1128
|
+
this.beforeMonthViewRender$.pipe(first()).subscribe((x) => {
|
|
1129
|
+
x(renderEvent);
|
|
1065
1130
|
});
|
|
1066
1131
|
}
|
|
1067
1132
|
}
|
|
@@ -1105,7 +1170,7 @@ class DbxScheduleSelectionCalendarDateDialogComponent extends AbstractDialogDire
|
|
|
1105
1170
|
width: '80vw',
|
|
1106
1171
|
minHeight: 400,
|
|
1107
1172
|
minWidth: 360,
|
|
1108
|
-
...contentConfig.dialogConfig,
|
|
1173
|
+
...sanitizeDbxDialogContentConfig(contentConfig.dialogConfig),
|
|
1109
1174
|
injector,
|
|
1110
1175
|
data: {
|
|
1111
1176
|
config,
|
|
@@ -1462,5 +1527,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
1462
1527
|
* Generated bundle index. Do not edit.
|
|
1463
1528
|
*/
|
|
1464
1529
|
|
|
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 };
|
|
1530
|
+
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
1531
|
//# sourceMappingURL=dereekb-dbx-form-calendar.mjs.map
|