@datarailsshared/datarailsshared 1.6.61 → 1.6.65

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.
@@ -9,10 +9,10 @@ import * as moment from 'moment';
9
9
  import moment__default from 'moment';
10
10
  import * as i1$2 from '@angular/forms';
11
11
  import { NG_VALUE_ACCESSOR, FormBuilder, FormGroup, FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
12
- import { Observable, BehaviorSubject, distinctUntilChanged, Subject, startWith, takeUntil, noop as noop$3, combineLatest, from, merge as merge$1, fromEvent, filter as filter$1, switchMap as switchMap$1, map as map$2, observeOn, asyncScheduler, withLatestFrom, first as first$1, interval, throwError, finalize as finalize$1, tap as tap$1, defer } from 'rxjs';
12
+ import { Observable, BehaviorSubject, distinctUntilChanged, map, Subject, startWith, takeUntil, noop as noop$3, combineLatest, from, merge as merge$1, fromEvent, filter as filter$1, switchMap as switchMap$1, observeOn, asyncScheduler, withLatestFrom, first as first$1, interval, throwError, finalize as finalize$1, tap as tap$1, defer } from 'rxjs';
13
13
  import * as _ from 'lodash';
14
- import { isNil, isObject, cloneDeep, find, indexOf, reduce, map as map$1, isNumber, merge, forEach, some, orderBy, filter as filter$2, includes, pull, concat, isString, isBoolean } from 'lodash';
15
- import { skip, debounceTime, filter, distinctUntilChanged as distinctUntilChanged$1, takeUntil as takeUntil$1, startWith as startWith$1, map, tap, shareReplay, switchMap, first, catchError, finalize, take } from 'rxjs/operators';
14
+ import { isNil, isObject, cloneDeep, find, indexOf, reduce, map as map$2, isNumber, merge, forEach, some, orderBy, filter as filter$2, includes, pull, concat, isString, isBoolean } from 'lodash';
15
+ import { skip, debounceTime, filter, distinctUntilChanged as distinctUntilChanged$1, takeUntil as takeUntil$1, startWith as startWith$1, map as map$1, tap, shareReplay, switchMap, first, catchError, finalize, take } from 'rxjs/operators';
16
16
  import * as i5 from '@angular/material/datepicker';
17
17
  import { MatCalendar, DateRange, MAT_DATE_RANGE_SELECTION_STRATEGY, MatDatepickerModule } from '@angular/material/datepicker';
18
18
  import { transition, style, animate, trigger, state } from '@angular/animations';
@@ -241,10 +241,7 @@ class DrDatePickerService {
241
241
  this.isTimeframeSelectionEnabled = false;
242
242
  this._timeframe$ = new BehaviorSubject(TimeframeOption.DAY);
243
243
  this.timeframe$ = this._timeframe$.asObservable().pipe(distinctUntilChanged());
244
- // TODO: here we can have inconsistency between format and timeframe
245
- // we need to get rid of a separate subject and use pipe from timeframe$ for it
246
- // making @Input() format in component just setting the timeframe
247
- this.format$ = new BehaviorSubject(DateFromats.MAT_DEFAULT_DATE_FORMAT);
244
+ this.format$ = this.timeframe$.pipe(map((timeframe) => this.getConfiguredFormat(timeframe)), distinctUntilChanged());
248
245
  this.updatedQuarter$ = new Subject();
249
246
  this.weekSelectionChange$ = new Subject();
250
247
  this.updatedDateAndClose$ = new Subject();
@@ -301,9 +298,8 @@ class DrDatePickerService {
301
298
  return this.formatConfig[timeframe];
302
299
  }
303
300
  updateTimeframeAndFormat(format) {
304
- const normalizedFormat = this.normalizeValue(format || this.format$.getValue());
301
+ const normalizedFormat = this.normalizeValue(format);
305
302
  this.timeframe = this.getTimeframe(normalizedFormat);
306
- this.format$.next(this.getConfiguredFormat(this.timeframe));
307
303
  }
308
304
  normalizeValue(value) {
309
305
  return value.replace(/d/g, 'D');
@@ -2309,7 +2305,7 @@ class DrDatePickerComponent {
2309
2305
  this.displayValue$ = combineLatest([
2310
2306
  this.datePickerService.innerValue$.pipe(distinctUntilChanged$1()),
2311
2307
  this.datePickerService.timeframe$.pipe(distinctUntilChanged$1()),
2312
- ]).pipe(startWith$1([null, null]), map(([value, timeframe]) => this.transformDisplayedValue(value, timeframe)), tap((value) => {
2308
+ ]).pipe(startWith$1([null, null]), map$1(([value, timeframe]) => this.transformDisplayedValue(value, timeframe)), tap((value) => {
2313
2309
  if (value && this.datePickerService.calendarInstance) {
2314
2310
  this.datePickerService.calendarInstance.activeDate = value;
2315
2311
  this.datePickerService.calendarInstance.selected = value;
@@ -2519,7 +2515,6 @@ class DrDatePickerComponent {
2519
2515
  timeframe = this.datePickerService.getTimeframe(format);
2520
2516
  }
2521
2517
  this.datePickerService.timeframe = timeframe;
2522
- this.datePickerService.format$.next(format);
2523
2518
  }
2524
2519
  onOpen() {
2525
2520
  this.opened$.next(true);
@@ -4058,7 +4053,7 @@ class DrDynamicTagComponent {
4058
4053
  return (valueFromConfig || currentValues[0]);
4059
4054
  }
4060
4055
  getParentValueKey() {
4061
- return map$1(this.connectedTags, (connectedTag) => {
4056
+ return map$2(this.connectedTags, (connectedTag) => {
4062
4057
  if (isNumber(connectedTag.value)) {
4063
4058
  const momentData = moment__default.unix(connectedTag.value);
4064
4059
  const convertedParentKey = this.parentKeyFormatterFn
@@ -4246,7 +4241,7 @@ class DrTagComponent {
4246
4241
  }
4247
4242
  onDynamicHandler(event) {
4248
4243
  const connectedDateTagConfig = find(this.tagsConfig, (tagConfig) => tagConfig.name === event.name);
4249
- this.connectedTags = map$1(this.connectedTags, (tag) => {
4244
+ this.connectedTags = map$2(this.connectedTags, (tag) => {
4250
4245
  if (tag.id === connectedDateTagConfig.id) {
4251
4246
  tag.value = event.value;
4252
4247
  tag.locked = event.locked;
@@ -5117,7 +5112,7 @@ class DrDatePickerWithTimeframeComponent extends DrDatePickerComponent {
5117
5112
  this.isNextDateDisabled = false;
5118
5113
  this.isPrevDateDisabled = false;
5119
5114
  this.onChangeDebounced$ = new Subject();
5120
- this.displayedFormattedValue$ = this.displayValue$.pipe(takeUntil$1(this.destroyed$), map((value) => {
5115
+ this.displayedFormattedValue$ = this.displayValue$.pipe(takeUntil$1(this.destroyed$), map$1((value) => {
5121
5116
  if (!value)
5122
5117
  return this.placeholder;
5123
5118
  return (this.datePickerService.getDisplayPrefix() +
@@ -5206,10 +5201,21 @@ class DrDatePickerWithTimeframeComponent extends DrDatePickerComponent {
5206
5201
  restrictPagination() {
5207
5202
  if (!this._min && !this._max)
5208
5203
  return;
5209
- const nextValue = this.pagingSetup[this.datePickerService.timeframe](true);
5210
- const prevValue = this.pagingSetup[this.datePickerService.timeframe](false);
5211
- this.isNextDateDisabled = this._max && nextValue && nextValue.unix() > this._max.unix();
5212
- this.isPrevDateDisabled = this._min && prevValue && prevValue.unix() < this._min.unix();
5204
+ const timeFrame = this.datePickerService.timeframe;
5205
+ const nextValue = this.pagingSetup[timeFrame](true);
5206
+ const prevValue = this.pagingSetup[timeFrame](false);
5207
+ const granularity = timeFrame;
5208
+ /* TODO: Take into account fiscal year start and back for cases where fiscal year and quarter is true - https://datarailsteam.atlassian.net/browse/DR-35528 and
5209
+ https://datarailsteam.atlassian.net/browse/DR-35568
5210
+ */
5211
+ if (this.fiscalYearBack || this.fiscalYearMonthsModifier !== 0) {
5212
+ this.isNextDateDisabled = this._max && nextValue && nextValue.unix() > this._max.unix();
5213
+ this.isPrevDateDisabled = this._min && prevValue && prevValue.unix() < this._min.unix();
5214
+ }
5215
+ else {
5216
+ this.isNextDateDisabled = !!(this._max && nextValue && !nextValue.isSameOrBefore(this._max, granularity));
5217
+ this.isPrevDateDisabled = !!(this._min && prevValue && !prevValue.isSameOrAfter(this._min, granularity));
5218
+ }
5213
5219
  }
5214
5220
  /** @nocollapse */ static { this.ɵfac = function DrDatePickerWithTimeframeComponent_Factory(t) { return new (t || DrDatePickerWithTimeframeComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i1$4.DateAdapter), i0.ɵɵdirectiveInject(DrDatePickerService)); }; }
5215
5221
  /** @nocollapse */ static { this.ɵcmp = /** @pureOrBreakMyCode */ i0.ɵɵdefineComponent({ type: DrDatePickerWithTimeframeComponent, selectors: [["dr-date-picker-with-timeframe"]], hostVars: 2, hostBindings: function DrDatePickerWithTimeframeComponent_HostBindings(rf, ctx) { if (rf & 2) {
@@ -7846,9 +7852,9 @@ class DrErrorComponent {
7846
7852
  this.displayAsLabel = false;
7847
7853
  this.noIcon = false;
7848
7854
  this.controlChange$ = new BehaviorSubject(null);
7849
- this.controlErrorStatus$ = this.controlChange$.pipe(filter$1(Boolean), switchMap$1((control) => control.statusChanges.pipe().pipe(map$2(() => control))), map$2((control) => control.status === 'INVALID' && !control.pristine));
7850
- this.error$ = this.controlErrorStatus$.pipe(observeOn(asyncScheduler), withLatestFrom(this.controlChange$), map$2(([show, control]) => [show, this.displayAsLabel ? this.errorString(control) : this.label]), map$2(([show, label]) => (show ? label : null)));
7851
- this.warning$ = this.controlChange$.pipe(map$2((control) => !!control.errors?.isWarning));
7855
+ this.controlErrorStatus$ = this.controlChange$.pipe(filter$1(Boolean), switchMap$1((control) => control.statusChanges.pipe().pipe(map(() => control))), map((control) => control.status === 'INVALID' && !control.pristine));
7856
+ this.error$ = this.controlErrorStatus$.pipe(observeOn(asyncScheduler), withLatestFrom(this.controlChange$), map(([show, control]) => [show, this.displayAsLabel ? this.errorString(control) : this.label]), map(([show, label]) => (show ? label : null)));
7857
+ this.warning$ = this.controlChange$.pipe(map((control) => !!control.errors?.isWarning));
7852
7858
  }
7853
7859
  set control(value) {
7854
7860
  if (value) {
@@ -8471,7 +8477,7 @@ class ScenarioService {
8471
8477
  return;
8472
8478
  if (!dateTag)
8473
8479
  return;
8474
- dateTag.subTags = map$1(dateTag.subTags, (subTag) => {
8480
+ dateTag.subTags = map$2(dateTag.subTags, (subTag) => {
8475
8481
  subTag.hidden = tag.toggle && !includes(tag.acceptableSubTags, subTag.subType);
8476
8482
  return subTag;
8477
8483
  });
@@ -9647,7 +9653,7 @@ class DropdownInstanceService {
9647
9653
  return this.instances.slice(this.instances.indexOf(ref));
9648
9654
  }
9649
9655
  inactive(ref) {
9650
- return this.instances$.pipe(map$2(() => this.getSequence(ref)), filter$1((value) => !!value.length), switchMap$1((value) => interval(200).pipe(map$2(() => value))), filter$1((emissions) => emissions.every((value) => !value.active())), takeUntil(this.destroy$));
9656
+ return this.instances$.pipe(map(() => this.getSequence(ref)), filter$1((value) => !!value.length), switchMap$1((value) => interval(200).pipe(map(() => value))), filter$1((emissions) => emissions.every((value) => !value.active())), takeUntil(this.destroy$));
9651
9657
  }
9652
9658
  }
9653
9659
 
@@ -13736,7 +13742,7 @@ class DrawerContainer extends CdkDialogContainer {
13736
13742
  }
13737
13743
  container.style.transition = 'transform 0.5s cubic-bezier(0.32, 0.72, 0, 1)';
13738
13744
  container.style.transform = `translate3d(0px, 0px, 0px)`;
13739
- }), takeUntil(mouseup$))), map$2((event) => this.positionStrategy.extractMousePosition(event)), distinctUntilChanged(), tap$1((position) => {
13745
+ }), takeUntil(mouseup$))), map((event) => this.positionStrategy.extractMousePosition(event)), distinctUntilChanged(), tap$1((position) => {
13740
13746
  let containerPosition = this.getContainerPosition(container);
13741
13747
  containerPosition = Math.min(containerPosition, lastPosition);
13742
13748
  lastPosition = Math.min(containerPosition, lastPosition);