@dereekb/dbx-form 9.23.10 → 9.23.11
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/calendar/lib/calendar.schedule.selection.store.d.ts +13 -3
- package/calendar/lib/field/schedule/calendar.schedule.field.component.d.ts +5 -2
- package/esm2020/calendar/lib/calendar.schedule.selection.store.mjs +36 -6
- package/esm2020/calendar/lib/field/schedule/calendar.schedule.field.component.mjs +12 -3
- package/esm2020/calendar/lib/field/schedule/calendar.schedule.field.mjs +4 -3
- package/fesm2015/dereekb-dbx-form-calendar.mjs +47 -10
- package/fesm2015/dereekb-dbx-form-calendar.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-form-calendar.mjs +50 -10
- package/fesm2020/dereekb-dbx-form-calendar.mjs.map +1 -1
- package/mapbox/package.json +4 -4
- package/package.json +4 -4
|
@@ -5,8 +5,8 @@ import { Injectable, SkipSelf, Directive, Injector, Optional, Component, Inject,
|
|
|
5
5
|
import { FieldType } from '@ngx-formly/material';
|
|
6
6
|
import { map, distinctUntilChanged, shareReplay, BehaviorSubject, switchMap, of, startWith, filter, throttleTime, first } from 'rxjs';
|
|
7
7
|
import { filterMaybe, SubscriptionObject, asObservable } from '@dereekb/rxjs';
|
|
8
|
-
import { DateScheduleDayCode, expandDateScheduleDayCodesToDayOfWeekSet, dateTimingRelativeIndexFactory, dateBlockDayOfWeekFactory, findMaxDate, findMinDate, isSameDate, isSameDateRange, isSameDateScheduleRange, isSameDateDay, copyDateScheduleDateFilterConfig, dateScheduleDateFilter, expandDateScheduleDayCodes, isDateInDateRangeFunction, isDateWithinDateBlockRangeFunction, dateScheduleEncodedWeek, dateBlockTimingDateFactory, enabledDaysFromDateScheduleDayCodes, dateScheduleDayCodesFromEnabledDays, formatToMonthDayString } from '@dereekb/date';
|
|
9
|
-
import { setsAreEquivalent, range, iterableToArray, toggleInSet, addToSet, isIndexNumberInIndexRangeFunction, minAndMaxNumber, randomNumberFactory, getDaysOfWeekNames } from '@dereekb/util';
|
|
8
|
+
import { DateScheduleDayCode, expandDateScheduleDayCodesToDayOfWeekSet, dateTimingRelativeIndexFactory, dateBlockDayOfWeekFactory, findMaxDate, findMinDate, isSameDate, isSameDateRange, isSameDateScheduleRange, isSameDateDay, dateTimingRelativeIndexArrayFactory, copyDateScheduleDateFilterConfig, dateScheduleDateFilter, expandDateScheduleDayCodes, isDateInDateRangeFunction, isDateWithinDateBlockRangeFunction, dateScheduleEncodedWeek, dateBlockTimingDateFactory, enabledDaysFromDateScheduleDayCodes, dateScheduleDayCodesFromEnabledDays, formatToMonthDayString } from '@dereekb/date';
|
|
9
|
+
import { setsAreEquivalent, unique, mergeArrays, range, iterableToArray, toggleInSet, addToSet, isIndexNumberInIndexRangeFunction, minAndMaxNumber, randomNumberFactory, getDaysOfWeekNames } from '@dereekb/util';
|
|
10
10
|
import { ComponentStore } from '@ngrx/component-store';
|
|
11
11
|
import { startOfDay } from 'date-fns';
|
|
12
12
|
import * as i1$1 from '@dereekb/dbx-web';
|
|
@@ -37,12 +37,13 @@ import { FlexLayoutModule } from '@angular/flex-layout';
|
|
|
37
37
|
|
|
38
38
|
function dateScheduleRangeField(config = {}) {
|
|
39
39
|
var _a;
|
|
40
|
-
const { key = 'schedule', filter, initialSelectionState, computeSelectionResultRelativeToFilter } = config;
|
|
40
|
+
const { key = 'schedule', filter, initialSelectionState, computeSelectionResultRelativeToFilter, exclusions } = config;
|
|
41
41
|
const fieldConfig = Object.assign({}, formlyField(Object.assign({ key, type: 'date-schedule-range' }, propsAndConfigForFieldConfig(config, {
|
|
42
42
|
label: (_a = config.label) !== null && _a !== void 0 ? _a : 'Schedule',
|
|
43
43
|
filter,
|
|
44
44
|
computeSelectionResultRelativeToFilter,
|
|
45
|
-
initialSelectionState
|
|
45
|
+
initialSelectionState,
|
|
46
|
+
exclusions
|
|
46
47
|
}))));
|
|
47
48
|
return fieldConfig;
|
|
48
49
|
}
|
|
@@ -147,6 +148,7 @@ class DbxCalendarScheduleSelectionStore extends ComponentStore {
|
|
|
147
148
|
this.isCustomized$ = this.state$.pipe(map((x) => x.selectedIndexes.size > 0), distinctUntilChanged(), shareReplay(1));
|
|
148
149
|
// MARK: State Changes
|
|
149
150
|
this.setFilter = this.updater((state, filter) => updateStateWithFilter(state, filter));
|
|
151
|
+
this.setExclusions = this.updater((state, exclusions) => updateStateWithExclusions(state, exclusions));
|
|
150
152
|
this.setComputeSelectionResultRelativeToFilter = this.updater((state, computeSelectionResultRelativeToFilter) => updateStateWithComputeSelectionResultRelativeToFilter(state, computeSelectionResultRelativeToFilter));
|
|
151
153
|
this.clearFilter = this.updater((state) => updateStateWithFilter(state, undefined));
|
|
152
154
|
this.setTimezone = this.updater((state, timezone) => (Object.assign(Object.assign({}, state), { timezone })));
|
|
@@ -182,12 +184,38 @@ function updateStateWithComputeSelectionResultRelativeToFilter(currentState, com
|
|
|
182
184
|
}
|
|
183
185
|
return state;
|
|
184
186
|
}
|
|
187
|
+
function updateStateWithExclusions(state, inputExclusions) {
|
|
188
|
+
let computedExclusions;
|
|
189
|
+
if (inputExclusions) {
|
|
190
|
+
const { indexFactory } = state;
|
|
191
|
+
const indexArrayFactory = dateTimingRelativeIndexArrayFactory(indexFactory);
|
|
192
|
+
computedExclusions = indexArrayFactory(inputExclusions);
|
|
193
|
+
}
|
|
194
|
+
state = Object.assign(Object.assign({}, state), { inputExclusions, computedExclusions });
|
|
195
|
+
return updateStateWithFilter(state, state.filter);
|
|
196
|
+
}
|
|
185
197
|
function updateStateWithFilter(state, inputFilter) {
|
|
198
|
+
const { computedExclusions: exclusions } = state;
|
|
186
199
|
let isEnabledFilterDay = () => true;
|
|
187
200
|
let filter = null;
|
|
188
|
-
if (inputFilter) {
|
|
189
|
-
|
|
190
|
-
|
|
201
|
+
if (inputFilter || (exclusions === null || exclusions === void 0 ? void 0 : exclusions.length)) {
|
|
202
|
+
let enabledFilter;
|
|
203
|
+
if (inputFilter) {
|
|
204
|
+
filter = copyDateScheduleDateFilterConfig(inputFilter); // copy filter
|
|
205
|
+
if (exclusions === null || exclusions === void 0 ? void 0 : exclusions.length) {
|
|
206
|
+
enabledFilter = Object.assign(Object.assign({}, filter), { ex: unique(mergeArrays([filter.ex, exclusions])) });
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
enabledFilter = filter;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
enabledFilter = {
|
|
214
|
+
w: '89',
|
|
215
|
+
ex: exclusions
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
isEnabledFilterDay = dateScheduleDateFilter(enabledFilter);
|
|
191
219
|
}
|
|
192
220
|
state = Object.assign(Object.assign({}, state), { filter, isEnabledFilterDay });
|
|
193
221
|
// attempt to re-apply the initial selection state once filter is applied
|
|
@@ -894,6 +922,7 @@ class DbxFormCalendarDateScheduleRangeFieldComponent extends FieldType {
|
|
|
894
922
|
this._syncSub = new SubscriptionObject();
|
|
895
923
|
this._valueSub = new SubscriptionObject();
|
|
896
924
|
this._filterSub = new SubscriptionObject();
|
|
925
|
+
this._exclusionsSub = new SubscriptionObject();
|
|
897
926
|
this._formControlObs = new BehaviorSubject(undefined);
|
|
898
927
|
this.formControl$ = this._formControlObs.pipe(filterMaybe());
|
|
899
928
|
this.value$ = this.formControl$.pipe(switchMap((control) => control.valueChanges.pipe(startWith(control.value))), shareReplay(1));
|
|
@@ -920,6 +949,9 @@ class DbxFormCalendarDateScheduleRangeFieldComponent extends FieldType {
|
|
|
920
949
|
get filter() {
|
|
921
950
|
return this.props.filter;
|
|
922
951
|
}
|
|
952
|
+
get exclusions() {
|
|
953
|
+
return this.props.exclusions;
|
|
954
|
+
}
|
|
923
955
|
get initialSelectionState() {
|
|
924
956
|
return this.props.initialSelectionState;
|
|
925
957
|
}
|
|
@@ -934,23 +966,28 @@ class DbxFormCalendarDateScheduleRangeFieldComponent extends FieldType {
|
|
|
934
966
|
this._valueSub.subscription = this.dbxCalendarScheduleSelectionStore.currentDateScheduleRangeValue$.subscribe((x) => {
|
|
935
967
|
this.formControl.setValue(x);
|
|
936
968
|
});
|
|
937
|
-
const filter = this
|
|
969
|
+
const { filter, exclusions } = this;
|
|
938
970
|
if (filter != null) {
|
|
939
971
|
this._filterSub.subscription = this.dbxCalendarScheduleSelectionStore.setFilter(asObservable(filter));
|
|
940
972
|
}
|
|
973
|
+
if (exclusions != null) {
|
|
974
|
+
this._exclusionsSub.subscription = this.dbxCalendarScheduleSelectionStore.setExclusions(asObservable(exclusions));
|
|
975
|
+
}
|
|
941
976
|
if (this.initialSelectionState !== undefined) {
|
|
942
977
|
this.dbxCalendarScheduleSelectionStore.setInitialSelectionState(this.initialSelectionState);
|
|
943
978
|
}
|
|
944
979
|
if (this.computeSelectionResultRelativeToFilter != null) {
|
|
945
980
|
this.dbxCalendarScheduleSelectionStore.setComputeSelectionResultRelativeToFilter(this.computeSelectionResultRelativeToFilter);
|
|
946
981
|
}
|
|
982
|
+
// TODO: Also add ability to set min/max dates independent of the filter
|
|
947
983
|
}
|
|
948
984
|
ngOnDestroy() {
|
|
949
985
|
super.ngOnDestroy();
|
|
950
986
|
this._syncSub.destroy();
|
|
951
987
|
this._valueSub.destroy();
|
|
952
|
-
this._formControlObs.complete();
|
|
953
988
|
this._filterSub.destroy();
|
|
989
|
+
this._exclusionsSub.destroy();
|
|
990
|
+
this._formControlObs.complete();
|
|
954
991
|
}
|
|
955
992
|
}
|
|
956
993
|
DbxFormCalendarDateScheduleRangeFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DbxFormCalendarDateScheduleRangeFieldComponent, deps: [{ token: i1$1.CompactContextStore, optional: true }, { token: DbxCalendarScheduleSelectionStore }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -1144,5 +1181,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
1144
1181
|
* Generated bundle index. Do not edit.
|
|
1145
1182
|
*/
|
|
1146
1183
|
|
|
1147
|
-
export { CalendarScheduleSelectionDayState, DEFAULT_SCHEDULE_SELECTION_CALENDAR_DATE_POPOVER_KEY, DbxCalendarScheduleSelectionStore, DbxCalendarScheduleSelectionStoreInjectionBlockDirective, DbxCalendarScheduleSelectionStoreProviderBlock, DbxFormCalendarDateScheduleRangeFieldComponent, DbxFormCalendarModule, DbxFormDateScheduleRangeFieldModule, DbxScheduleSelectionCalendarCellComponent, DbxScheduleSelectionCalendarComponent, DbxScheduleSelectionCalendarDateDaysComponent, DbxScheduleSelectionCalendarDateDaysFormComponent, DbxScheduleSelectionCalendarDateDialogButtonComponent, DbxScheduleSelectionCalendarDateDialogComponent, DbxScheduleSelectionCalendarDatePopoverButtonComponent, DbxScheduleSelectionCalendarDatePopoverComponent, DbxScheduleSelectionCalendarDatePopoverContentComponent, DbxScheduleSelectionCalendarDateRangeComponent, calendarScheduleMaxDate, calendarScheduleMinAndMaxDate, calendarScheduleMinDate, computeCalendarScheduleSelectionDateBlockRange, computeCalendarScheduleSelectionRange, computeScheduleSelectionRangeAndExclusion, computeScheduleSelectionValue, dateScheduleRangeField, dbxScheduleSelectionCalendarDateDaysFormDayFields, dbxScheduleSelectionCalendarDateDaysFormFields, defaultCalendarScheduleSelectionCellContentFactory, finalizeNewCalendarScheduleSelectionState, initialCalendarScheduleSelectionState, isEnabledDayInCalendarScheduleSelectionState, noSelectionCalendarScheduleSelectionState, provideCalendarScheduleSelectionStoreIfParentIsUnavailable, updateStateWithChangedDates, updateStateWithChangedRange, updateStateWithChangedScheduleDays, updateStateWithComputeSelectionResultRelativeToFilter, updateStateWithDateScheduleRangeValue, updateStateWithFilter, updateStateWithInitialSelectionState };
|
|
1184
|
+
export { CalendarScheduleSelectionDayState, DEFAULT_SCHEDULE_SELECTION_CALENDAR_DATE_POPOVER_KEY, DbxCalendarScheduleSelectionStore, DbxCalendarScheduleSelectionStoreInjectionBlockDirective, DbxCalendarScheduleSelectionStoreProviderBlock, DbxFormCalendarDateScheduleRangeFieldComponent, DbxFormCalendarModule, DbxFormDateScheduleRangeFieldModule, DbxScheduleSelectionCalendarCellComponent, DbxScheduleSelectionCalendarComponent, DbxScheduleSelectionCalendarDateDaysComponent, DbxScheduleSelectionCalendarDateDaysFormComponent, DbxScheduleSelectionCalendarDateDialogButtonComponent, DbxScheduleSelectionCalendarDateDialogComponent, DbxScheduleSelectionCalendarDatePopoverButtonComponent, DbxScheduleSelectionCalendarDatePopoverComponent, DbxScheduleSelectionCalendarDatePopoverContentComponent, DbxScheduleSelectionCalendarDateRangeComponent, calendarScheduleMaxDate, calendarScheduleMinAndMaxDate, calendarScheduleMinDate, computeCalendarScheduleSelectionDateBlockRange, computeCalendarScheduleSelectionRange, computeScheduleSelectionRangeAndExclusion, computeScheduleSelectionValue, dateScheduleRangeField, dbxScheduleSelectionCalendarDateDaysFormDayFields, dbxScheduleSelectionCalendarDateDaysFormFields, defaultCalendarScheduleSelectionCellContentFactory, finalizeNewCalendarScheduleSelectionState, initialCalendarScheduleSelectionState, isEnabledDayInCalendarScheduleSelectionState, noSelectionCalendarScheduleSelectionState, provideCalendarScheduleSelectionStoreIfParentIsUnavailable, updateStateWithChangedDates, updateStateWithChangedRange, updateStateWithChangedScheduleDays, updateStateWithComputeSelectionResultRelativeToFilter, updateStateWithDateScheduleRangeValue, updateStateWithExclusions, updateStateWithFilter, updateStateWithInitialSelectionState };
|
|
1148
1185
|
//# sourceMappingURL=dereekb-dbx-form-calendar.mjs.map
|