@dereekb/dbx-form 9.24.43 → 9.24.45

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.
@@ -4,7 +4,7 @@ import * as i1 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
5
  import * as i2$1 from '@dereekb/dbx-web';
6
6
  import { DbxActionTransitionSafetyDirective, DbxTextModule, DbxLoadingModule, DbxFlexLayoutModule, DbxSectionLayoutModule, DbxRouterAnchorModule, dbxValueListItemDecisionFunction, DbxButtonModule, DbxListLayoutModule, AbstractDbxSelectionListWrapperDirective, DEFAULT_LIST_WRAPPER_DIRECTIVE_TEMPLATE, AbstractDbxSelectionListViewDirective, addConfigToValueListItems, provideDbxListView, AbstractDbxValueListViewItemComponent, DbxActionModule, mapCompactModeObs, DbxBarLayoutModule } from '@dereekb/dbx-web';
7
- import { isPast, addSeconds, startOfDay, addMinutes, addDays } from 'date-fns';
7
+ import { isPast, addSeconds, startOfDay, addMinutes, addDays, isAfter } from 'date-fns';
8
8
  import { BehaviorSubject, switchMap, first, exhaustMap, of, catchError, delay, filter, combineLatest, map, distinctUntilChanged, shareReplay, Subject, tap, takeUntil, EMPTY, mergeMap, startWith, debounceTime, skipWhile, scan, combineLatestWith, throttleTime, interval, merge, timer } from 'rxjs';
9
9
  import { LockSet, SubscriptionObject, asObservable, cleanup, loadingStateHasFinishedLoading, switchMapMaybeObs, filterMaybe, switchMapMaybeDefault, SimpleLoadingContext, distinctUntilHasDifferentValues, startWithBeginLoading, mapLoadingStateResults, successResult, ListLoadingStateContextInstance, isListLoadingStateEmpty, LoadingStateContextInstance, loadingStateHasValue, loadingStateIsLoading, beginLoading, mapLoadingStateValueWithOperator, valueFromLoadingState, loadingStateContext, skipFirstMaybe, asObservableFromGetter, asyncPusherCache, scanCount } from '@dereekb/rxjs';
10
10
  import * as i2 from '@dereekb/dbx-core';
@@ -1925,7 +1925,7 @@ class DbxPickableListFieldItemListComponent extends AbstractDbxSelectionListWrap
1925
1925
  }
1926
1926
  }
1927
1927
  DbxPickableListFieldItemListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DbxPickableListFieldItemListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1928
- DbxPickableListFieldItemListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: DbxPickableListFieldItemListComponent, selector: "dbx-form-pickable-item-field-item-list", usesInheritance: true, ngImport: i0, template: "\n<dbx-list [state$]=\"state$\" [config]=\"config$ | async\" [disabled]=\"disabled\" [selectionMode]=\"selectionMode\">\n <ng-content top select=\"[top]\"></ng-content>\n <ng-content bottom select=\"[bottom]\"></ng-content>\n <ng-content empty select=\"[empty]\"></ng-content>\n</dbx-list>\n", isInline: true, dependencies: [{ kind: "component", type: i2$1.DbxListComponent, selector: "dbx-list", inputs: ["padded", "state$", "config", "disabled", "selectionMode"], outputs: ["contentScrolled"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }] });
1928
+ DbxPickableListFieldItemListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: DbxPickableListFieldItemListComponent, selector: "dbx-form-pickable-item-field-item-list", usesInheritance: true, ngImport: i0, template: "\n<dbx-list [state$]=\"state$\" [config]=\"config$ | async\" [disabled]=\"disabled\" [selectionMode]=\"selectionMode\">\n <ng-content top select=\"[top]\"></ng-content>\n <ng-content bottom select=\"[bottom]\"></ng-content>\n <ng-content empty select=\"[empty]\"></ng-content>\n <ng-content emptyLoading select=\"[emptyLoading]\"></ng-content>\n</dbx-list>\n", isInline: true, dependencies: [{ kind: "component", type: i2$1.DbxListComponent, selector: "dbx-list", inputs: ["padded", "state$", "config", "disabled", "selectionMode"], outputs: ["contentScrolled"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }] });
1929
1929
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DbxPickableListFieldItemListComponent, decorators: [{
1930
1930
  type: Component,
1931
1931
  args: [{
@@ -4253,6 +4253,7 @@ class DbxFixedDateRangeFieldComponent extends FieldType$1 {
4253
4253
  }
4254
4254
  dateRangeSelectionForMode(mode) {
4255
4255
  const result = combineLatest([this.dateRangeInput$, this.limitDateTimeInstance$]).pipe(switchMap(([dateRangeInput, limitInstance]) => {
4256
+ const hasDateRangeConfiguration = Boolean(dateRangeInput);
4256
4257
  const minMaxClamp = (dateRange) => limitInstance.clampDateRange(dateRange);
4257
4258
  if (mode === 'single') {
4258
4259
  // only use the start date.
@@ -4264,7 +4265,9 @@ class DbxFixedDateRangeFieldComponent extends FieldType$1 {
4264
4265
  else {
4265
4266
  // take the first date, then wait unless the date is outside of the range.
4266
4267
  return this.selectedDateRange$.pipe(scan((acc, nextDateRange) => {
4268
+ var _a, _b;
4267
4269
  let result;
4270
+ let pickType = 'start';
4268
4271
  if (nextDateRange && nextDateRange.start != null) {
4269
4272
  const { start: startOrNextDate, end } = nextDateRange;
4270
4273
  const potentialBoundary = dateRange(Object.assign(Object.assign({}, dateRangeInput), { date: startOrNextDate }));
@@ -4280,7 +4283,43 @@ class DbxFixedDateRangeFieldComponent extends FieldType$1 {
4280
4283
  else {
4281
4284
  let range = undefined;
4282
4285
  let boundary = potentialBoundary;
4283
- if (acc.boundary && isDateInDateRange(startOrNextDate, acc.boundary)) {
4286
+ if (mode === 'normal') {
4287
+ if (!hasDateRangeConfiguration) {
4288
+ // if there is no configured range/boundary, then just set the pick type based on the last type
4289
+ boundary = undefined;
4290
+ pickType = acc.lastPickType === 'start' ? 'end' : 'start';
4291
+ }
4292
+ else {
4293
+ // if the pick is outside the boundary, then consider it a start pick type.
4294
+ pickType = acc.lastPickType === 'start' && acc.boundary && isDateInDateRange(startOrNextDate, acc.boundary) ? 'end' : 'start';
4295
+ }
4296
+ // assert the start exists from the previous click, otherwise clear it.
4297
+ if (pickType === 'end') {
4298
+ const lastStart = (_a = acc.lastDateRange) === null || _a === void 0 ? void 0 : _a.start;
4299
+ if (!lastStart || !isAfter(startOrNextDate, lastStart)) {
4300
+ pickType = 'start';
4301
+ }
4302
+ }
4303
+ // react based on how this
4304
+ switch (pickType) {
4305
+ case 'end':
4306
+ // if we're picking the end then set the range.
4307
+ range = {
4308
+ start: (_b = acc.lastDateRange) === null || _b === void 0 ? void 0 : _b.start,
4309
+ end: startOrNextDate
4310
+ };
4311
+ boundary = range;
4312
+ break;
4313
+ case 'start':
4314
+ // retain the boundary as potential boundary, and set our new range from the single date.
4315
+ range = {
4316
+ start: startOrNextDate,
4317
+ end: startOrNextDate
4318
+ };
4319
+ break;
4320
+ }
4321
+ }
4322
+ else if (acc.boundary && isDateInDateRange(startOrNextDate, acc.boundary)) {
4284
4323
  // if in the date range, uses the pick as the last date.
4285
4324
  range = {
4286
4325
  start: acc.boundary.start,
@@ -4298,6 +4337,7 @@ class DbxFixedDateRangeFieldComponent extends FieldType$1 {
4298
4337
  }
4299
4338
  }
4300
4339
  else {
4340
+ // retain same boundary
4301
4341
  boundary = acc.boundary;
4302
4342
  }
4303
4343
  }
@@ -4318,6 +4358,7 @@ class DbxFixedDateRangeFieldComponent extends FieldType$1 {
4318
4358
  }
4319
4359
  if (result) {
4320
4360
  result = {
4361
+ lastPickType: pickType,
4321
4362
  lastDateRange: result.lastDateRange,
4322
4363
  boundary: result.boundary ? minMaxClamp(result.boundary) : undefined,
4323
4364
  range: result.range ? minMaxClamp(result.range) : undefined
@@ -4539,10 +4580,11 @@ class DbxFixedDateRangeFieldSelectionStrategy {
4539
4580
  return currentRange;
4540
4581
  }
4541
4582
  createPreview(activeDate, currentRange, event) {
4542
- if (activeDate != null && this.dbxFixedDateRangeFieldComponent.currentSelectionMode !== 'single') {
4583
+ const { currentSelectionMode } = this.dbxFixedDateRangeFieldComponent;
4584
+ if (activeDate != null && currentSelectionMode !== 'single') {
4543
4585
  const latestBoundary = this.dbxFixedDateRangeFieldComponent.latestBoundary;
4544
4586
  const date = this.dateFromAdapterDate(activeDate);
4545
- if (latestBoundary && isDateInDateRange(date, latestBoundary)) {
4587
+ if (latestBoundary && (currentSelectionMode === 'normal' || isDateInDateRange(date, latestBoundary))) {
4546
4588
  const exampleDateRange = this._createDateRange(latestBoundary);
4547
4589
  return exampleDateRange;
4548
4590
  }