@datarailsshared/datarailsshared 1.4.23 → 1.4.24-tigers

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.
Files changed (35) hide show
  1. package/bundles/datarailsshared-datarailsshared.umd.js +1420 -1297
  2. package/bundles/datarailsshared-datarailsshared.umd.js.map +1 -1
  3. package/datarailsshared-datarailsshared-1.4.24-tigers.tgz +0 -0
  4. package/datarailsshared-datarailsshared.d.ts +5 -3
  5. package/datarailsshared-datarailsshared.metadata.json +1 -1
  6. package/esm2015/datarailsshared-datarailsshared.js +6 -4
  7. package/esm2015/lib/dr-inputs/date-pickers/directives/dr-date-picker-format.directive.js +47 -0
  8. package/esm2015/lib/dr-inputs/date-pickers/dr-date-picker/dr-date-picker.component.js +152 -0
  9. package/esm2015/lib/dr-inputs/date-pickers/dr-date-picker-with-timeframe/dr-date-picker-with-timeframe.component.js +72 -0
  10. package/esm2015/lib/dr-inputs/date-pickers/dr-date-picker_custom-header/dr-date-picker_custom-header.component.js +128 -0
  11. package/esm2015/lib/dr-inputs/date-pickers/services/dr-date-picker.service.js +55 -0
  12. package/esm2015/lib/dr-inputs/dr-inputs.module.js +13 -9
  13. package/esm2015/lib/dr-tooltip/dr-tooltip.component.js +13 -3
  14. package/esm2015/lib/dr-tooltip/dr-tooltip.directive.js +43 -10
  15. package/esm2015/lib/models/datePicker.js +8 -1
  16. package/esm2015/public-api.js +3 -3
  17. package/fesm2015/datarailsshared-datarailsshared.js +624 -523
  18. package/fesm2015/datarailsshared-datarailsshared.js.map +1 -1
  19. package/lib/dr-inputs/{dr-date-picker → date-pickers/directives}/dr-date-picker-format.directive.d.ts +1 -1
  20. package/lib/dr-inputs/date-pickers/dr-date-picker/dr-date-picker.component.d.ts +55 -0
  21. package/lib/dr-inputs/date-pickers/dr-date-picker-with-timeframe/dr-date-picker-with-timeframe.component.d.ts +26 -0
  22. package/lib/dr-inputs/{dr-date-picker → date-pickers}/dr-date-picker_custom-header/dr-date-picker_custom-header.component.d.ts +4 -4
  23. package/lib/dr-inputs/date-pickers/services/dr-date-picker.service.d.ts +18 -0
  24. package/lib/dr-tooltip/dr-tooltip.component.d.ts +4 -0
  25. package/lib/dr-tooltip/dr-tooltip.directive.d.ts +4 -0
  26. package/lib/models/datePicker.d.ts +12 -0
  27. package/package.json +1 -1
  28. package/public-api.d.ts +1 -2
  29. package/datarailsshared-datarailsshared-1.4.23.tgz +0 -0
  30. package/esm2015/lib/dr-inputs/dr-date-picker/dr-date-picker-format.directive.js +0 -47
  31. package/esm2015/lib/dr-inputs/dr-date-picker/dr-date-picker.component.js +0 -183
  32. package/esm2015/lib/dr-inputs/dr-date-picker/dr-date-picker.service.js +0 -41
  33. package/esm2015/lib/dr-inputs/dr-date-picker/dr-date-picker_custom-header/dr-date-picker_custom-header.component.js +0 -129
  34. package/lib/dr-inputs/dr-date-picker/dr-date-picker.component.d.ts +0 -54
  35. package/lib/dr-inputs/dr-date-picker/dr-date-picker.service.d.ts +0 -12
@@ -1,17 +1,17 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Component, ViewEncapsulation, Input, Output, ChangeDetectionStrategy, ChangeDetectorRef, forwardRef, ElementRef, Inject, PLATFORM_ID, ContentChildren, Renderer2, HostBinding, ContentChild, Pipe, TemplateRef, Directive, HostListener, ComponentFactoryResolver, ViewContainerRef, ViewChild, Injectable, Optional, Injector, Host, NgModule } from '@angular/core';
3
- import { FormControl, NG_VALUE_ACCESSOR, NgControl, NgModel, FormsModule, ReactiveFormsModule } from '@angular/forms';
2
+ import { EventEmitter, Component, ViewEncapsulation, Input, Output, ChangeDetectionStrategy, ChangeDetectorRef, forwardRef, ElementRef, Inject, PLATFORM_ID, ContentChildren, Renderer2, HostBinding, ContentChild, Pipe, TemplateRef, HostListener, Directive, ComponentFactoryResolver, ViewContainerRef, ViewChild, Injector, Injectable, Host, NgModule, Optional } from '@angular/core';
3
+ import { FormControl, NG_VALUE_ACCESSOR, NgModel, FormsModule, ReactiveFormsModule, NgControl } from '@angular/forms';
4
4
  import { DateAdapter, MAT_DATE_LOCALE, MAT_DATE_FORMATS, MatNativeDateModule } from '@angular/material/core';
5
5
  import { MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS, MatMomentDateModule } from '@angular/material-moment-adapter';
6
6
  import * as momentImported from 'moment';
7
7
  import { isPlatformBrowser, DOCUMENT, CommonModule } from '@angular/common';
8
8
  import { Subject, from, merge, fromEvent, noop as noop$1, BehaviorSubject } from 'rxjs';
9
- import { startWith, switchMap, takeUntil, filter, take, first, skip, debounceTime, distinctUntilChanged } from 'rxjs/operators';
9
+ import { startWith, switchMap, takeUntil, filter, skip, first, debounceTime, distinctUntilChanged, take } from 'rxjs/operators';
10
10
  import { transition, style, animate, trigger, state } from '@angular/animations';
11
11
  import * as i1 from '@angular/cdk/overlay';
12
12
  import { Overlay, OverlayPositionBuilder, OverlayConfig } from '@angular/cdk/overlay';
13
13
  import { ComponentPortal } from '@angular/cdk/portal';
14
- import { MatCalendar, MatDatepickerModule } from '@angular/material/datepicker';
14
+ import { MatDatepickerModule, MatCalendar } from '@angular/material/datepicker';
15
15
  import { MatFormFieldModule } from '@angular/material/form-field';
16
16
  import { MatInputModule } from '@angular/material/input';
17
17
  import { MatSelectModule } from '@angular/material/select';
@@ -1489,10 +1489,17 @@ const POPUP_ANIMATION = [
1489
1489
  class TooltipComponent {
1490
1490
  constructor() {
1491
1491
  this.isContentTemplate = false;
1492
+ this.isMouseOn$ = new BehaviorSubject(false);
1492
1493
  }
1493
1494
  ngOnInit() {
1494
1495
  this.isContentTemplate = this.content instanceof TemplateRef;
1495
1496
  }
1497
+ setMouseOn() {
1498
+ this.isMouseOn$.next(true);
1499
+ }
1500
+ unsetMouseOn() {
1501
+ this.isMouseOn$.next(false);
1502
+ }
1496
1503
  }
1497
1504
  TooltipComponent.decorators = [
1498
1505
  { type: Component, args: [{
@@ -1510,7 +1517,9 @@ TooltipComponent.propDecorators = {
1510
1517
  contentContext: [{ type: Input }],
1511
1518
  position: [{ type: Input }],
1512
1519
  options: [{ type: Input }],
1513
- class: [{ type: Input }]
1520
+ class: [{ type: Input }],
1521
+ setMouseOn: [{ type: HostListener, args: ['mouseenter',] }],
1522
+ unsetMouseOn: [{ type: HostListener, args: ['mouseleave',] }]
1514
1523
  };
1515
1524
 
1516
1525
  class DrTooltipDirective {
@@ -1521,6 +1530,8 @@ class DrTooltipDirective {
1521
1530
  this.contentContext = {};
1522
1531
  this.position = 'top';
1523
1532
  this.class = '';
1533
+ // is used for preserve tooltip from being hidden for N milliseconds
1534
+ this.drTooltipMousleaveTimeout = 0;
1524
1535
  }
1525
1536
  set drTooltipOptions(options) {
1526
1537
  if (options === null || options === void 0 ? void 0 : options.indent) {
@@ -1553,16 +1564,36 @@ class DrTooltipDirective {
1553
1564
  if (this.overlayRef) {
1554
1565
  this.overlayRef.dispose();
1555
1566
  }
1567
+ if (this.tooltipMouseOnSubscription) {
1568
+ this.tooltipMouseOnSubscription.unsubscribe();
1569
+ }
1556
1570
  }
1557
1571
  show() {
1558
- if (this.manualHandling)
1572
+ if (this.manualHandling || this.overlayRef)
1559
1573
  return;
1560
1574
  this.renderTooltip();
1561
1575
  }
1562
1576
  hide() {
1563
- if (this.manualHandling)
1577
+ var _a;
1578
+ if (this.manualHandling || !this.tooltipRef || ((_a = this.tooltipRef) === null || _a === void 0 ? void 0 : _a.instance.isMouseOn$.getValue()))
1564
1579
  return;
1565
- this.destroyTooltip();
1580
+ // if this timeout value is set - then preserve
1581
+ // tooltip from being hidden N milliseconds and not hiding it
1582
+ // in case mouse is pointed on tooltip
1583
+ if (this.drTooltipMousleaveTimeout) {
1584
+ if (this.mouseleaveTimer) {
1585
+ clearTimeout(this.mouseleaveTimer);
1586
+ }
1587
+ this.mouseleaveTimer = setTimeout(() => {
1588
+ var _a;
1589
+ if (this.tooltipRef && !((_a = this.tooltipRef) === null || _a === void 0 ? void 0 : _a.instance.isMouseOn$.getValue())) {
1590
+ this.destroyTooltip();
1591
+ }
1592
+ }, this.drTooltipMousleaveTimeout);
1593
+ }
1594
+ else {
1595
+ this.destroyTooltip();
1596
+ }
1566
1597
  }
1567
1598
  createOverlay() {
1568
1599
  const positionStrategy = this.overlayPositionBuilder
@@ -1574,12 +1605,17 @@ class DrTooltipDirective {
1574
1605
  var _a;
1575
1606
  this.createOverlay();
1576
1607
  if (!((_a = this.overlayRef) === null || _a === void 0 ? void 0 : _a.hasAttached()) && this.content) {
1577
- const tooltipRef = this.overlayRef.attach(new ComponentPortal(TooltipComponent));
1578
- tooltipRef.instance.content = this.content;
1579
- tooltipRef.instance.contentContext = this.contentContext;
1580
- tooltipRef.instance.position = this.position;
1581
- tooltipRef.instance.options = this.options;
1582
- tooltipRef.instance.class = this.class + ' ' + this.position;
1608
+ this.tooltipRef = this.overlayRef.attach(new ComponentPortal(TooltipComponent));
1609
+ this.tooltipRef.instance.content = this.content;
1610
+ this.tooltipRef.instance.contentContext = this.contentContext;
1611
+ this.tooltipRef.instance.position = this.position;
1612
+ this.tooltipRef.instance.options = this.options;
1613
+ this.tooltipRef.instance.class = this.class + ' ' + this.position;
1614
+ this.tooltipMouseOnSubscription = this.tooltipRef.instance.isMouseOn$.pipe(skip(1)).subscribe((isMouseOn) => {
1615
+ if (!isMouseOn) {
1616
+ this.destroyTooltip();
1617
+ }
1618
+ });
1583
1619
  }
1584
1620
  }
1585
1621
  destroyTooltip() {
@@ -1587,6 +1623,10 @@ class DrTooltipDirective {
1587
1623
  this.overlayRef.dispose();
1588
1624
  }
1589
1625
  this.overlayRef = null;
1626
+ this.tooltipRef = null;
1627
+ if (this.tooltipMouseOnSubscription) {
1628
+ this.tooltipMouseOnSubscription.unsubscribe();
1629
+ }
1590
1630
  }
1591
1631
  }
1592
1632
  DrTooltipDirective.decorators = [
@@ -1604,6 +1644,7 @@ DrTooltipDirective.propDecorators = {
1604
1644
  contentContext: [{ type: Input, args: ['drTooltipContext',] }],
1605
1645
  position: [{ type: Input, args: ['drTooltipPosition',] }],
1606
1646
  class: [{ type: Input, args: ['drTooltipClass',] }],
1647
+ drTooltipMousleaveTimeout: [{ type: Input }],
1607
1648
  drTooltipOptions: [{ type: Input }],
1608
1649
  showTooltip: [{ type: Input, args: ['drTooltipShow',] }],
1609
1650
  show: [{ type: HostListener, args: ['mouseenter',] }],
@@ -1883,521 +1924,106 @@ DrButtonComponent.propDecorators = {
1883
1924
  <dr-button [isDisabled]="false" [theme]="'text-link'">Text Link</dr-button>
1884
1925
  */
1885
1926
 
1886
- const MAT_DEFAULT_DATE_FORMAT = 'MM/DD/yyyy';
1887
- const DATE_INPUT_FORMAT = 'YYYY/MM/DD';
1888
- const YEAR_FORMAT = 'yyyy';
1889
- const MONTH_YEAR_FORMAT = 'MM/yyyy';
1890
- const QUARTER_FORMAT = 'Q/yyyy';
1891
- class CustomDateFormat {
1892
- constructor() {
1893
- this._parse = {
1894
- dateInput: DATE_INPUT_FORMAT
1895
- };
1896
- this._display = {
1897
- dateInput: DATE_INPUT_FORMAT,
1898
- monthYearLabel: 'MMM YYYY',
1899
- dateA11yLabel: 'LL',
1900
- monthYearA11yLabel: 'MMM YYYY',
1901
- quarterYearLabel: 'Q/YYYY',
1902
- yearLabel: 'YYYY'
1903
- };
1904
- }
1905
- set parse(parse) {
1906
- this._parse = Object.assign({}, this._parse, parse);
1907
- }
1908
- get parse() {
1909
- return this._parse;
1910
- }
1911
- set display(display) {
1912
- this._display = Object.assign({}, this._display, display);
1913
- }
1914
- get display() {
1915
- return this._display;
1927
+ class DrPopoverRef {
1928
+ constructor(overlayRef) {
1929
+ this.overlayRef = overlayRef;
1930
+ this.onClose$ = new Subject();
1931
+ // FIXME: this decision was made because of the incompatible rxjs version
1932
+ /**
1933
+ * Correct type is @type {Observable<any>}
1934
+ */
1935
+ this.onClose = this.onClose$.asObservable();
1936
+ this.onBackdropClick = this.overlayRef.backdropClick();
1916
1937
  }
1917
- updateDateFormat(parse, display) {
1918
- this.parse = parse;
1919
- if (!display) {
1920
- display = parse;
1921
- }
1922
- this.display = display;
1938
+ close(res) {
1939
+ this.overlayRef.detach();
1940
+ this.overlayRef.dispose();
1941
+ this.onClose$.next(res);
1942
+ this.onClose$.complete();
1923
1943
  }
1924
1944
  }
1925
1945
 
1926
- const moment$2 = require('moment');
1927
- class DrDatePickerService {
1928
- constructor() {
1929
- this.timeframe = 'day';
1930
- this.format = new BehaviorSubject(MAT_DEFAULT_DATE_FORMAT);
1931
- this.updatedQuater = new Subject();
1932
- }
1933
- getQuarterDisplay(value, format) {
1934
- return 'Q' + moment$2(value).quarter() + format.charAt(1) + moment$2(value).year();
1935
- }
1936
- setTimeframe(format) {
1937
- const lowerCaseFormat = format.toLowerCase();
1938
- switch (true) {
1939
- case lowerCaseFormat.includes('q'):
1940
- this.timeframe = 'quarter';
1941
- break;
1942
- case lowerCaseFormat.includes('d'):
1943
- this.timeframe = 'day';
1944
- break;
1945
- case lowerCaseFormat.includes('m'):
1946
- this.timeframe = 'month';
1947
- break;
1948
- case lowerCaseFormat.includes('y'):
1949
- this.timeframe = 'year';
1950
- break;
1951
- default:
1952
- this.timeframe = 'day';
1953
- }
1946
+ var DrPopoverAlignmentDimension;
1947
+ (function (DrPopoverAlignmentDimension) {
1948
+ DrPopoverAlignmentDimension["Width"] = "width";
1949
+ DrPopoverAlignmentDimension["Height"] = "height";
1950
+ })(DrPopoverAlignmentDimension || (DrPopoverAlignmentDimension = {}));
1951
+ const DEFAULT_CONFIG = {
1952
+ hasBackdrop: false,
1953
+ closeOnBackdropClick: false,
1954
+ backdropClass: 'dr-popover-transparent-backdrop',
1955
+ };
1956
+ const DEFAULT_MODEL = {
1957
+ position: 'bottom',
1958
+ class: '',
1959
+ overlayConfig: {},
1960
+ manualClosing: { enabled: false },
1961
+ };
1962
+ function getAlignmentDimension(position) {
1963
+ if (!POPUP_POSITIONS[position])
1964
+ return DrPopoverAlignmentDimension.Width;
1965
+ if ((position === null || position === void 0 ? void 0 : position.includes('left')) || (position === null || position === void 0 ? void 0 : position.includes('right'))) {
1966
+ return DrPopoverAlignmentDimension.Height;
1954
1967
  }
1968
+ return DrPopoverAlignmentDimension.Width;
1955
1969
  }
1956
- DrDatePickerService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DrDatePickerService_Factory() { return new DrDatePickerService(); }, token: DrDatePickerService, providedIn: "root" });
1957
- DrDatePickerService.decorators = [
1958
- { type: Injectable, args: [{
1959
- providedIn: 'root',
1960
- },] }
1961
- ];
1962
1970
 
1963
- const moment$1 = require('moment');
1964
- class DrDatePickerCustomHeaderComponent {
1965
- constructor(_calendar, _dateAdapter, _dateFormats, cdr, datePickerService) {
1966
- this._calendar = _calendar;
1967
- this._dateAdapter = _dateAdapter;
1968
- this._dateFormats = _dateFormats;
1971
+ class DrPopoverComponent {
1972
+ constructor(cdr, componentFactoryResolver, viewContainerRef, elementRef, popoverRef) {
1969
1973
  this.cdr = cdr;
1970
- this.datePickerService = datePickerService;
1971
- this._destroyed = new Subject();
1972
- this.quarters = [1, 2, 3, 4];
1973
- this.selectedQuarter = 1;
1974
- this.timeframeOptions = [{
1975
- title: 'Day',
1976
- value: 'month',
1977
- format: MAT_DEFAULT_DATE_FORMAT,
1978
- periodLabel: () => this._dateAdapter
1979
- .format(this._calendar.activeDate, this._dateFormats.display.monthYearLabel)
1980
- .toLocaleUpperCase()
1981
- }, {
1982
- title: 'Month',
1983
- value: 'year',
1984
- format: MONTH_YEAR_FORMAT,
1985
- periodLabel: () => String(moment$1(this._calendar.activeDate).year())
1986
- }, {
1987
- title: 'Quarter',
1988
- value: 'none',
1989
- format: QUARTER_FORMAT,
1990
- periodLabel: () => String(moment$1(this._calendar.activeDate).year())
1991
- }, {
1992
- title: 'Year',
1993
- value: 'multi-year',
1994
- format: YEAR_FORMAT,
1995
- periodLabel: () => {
1996
- const currentYear = moment$1(this._calendar.activeDate).year();
1997
- const startPeriod = Math.floor(currentYear / 24) * 24;
1998
- return startPeriod + '-' + (startPeriod + 23);
1999
- }
2000
- }];
2001
- this.pagingSetup = {
2002
- 'year': (forward) => this.pagingDateChange('addCalendarYears', 1, forward),
2003
- 'none': (forward) => this.pagingDateChange('addCalendarYears', 1, forward),
2004
- 'month': (forward) => this.pagingDateChange('addCalendarMonths', 1, forward),
2005
- 'multi-year': (forward) => this.pagingDateChange('addCalendarYears', 24, forward)
2006
- };
2007
- this.selectedTimeframe = 'month';
2008
- this.timeframeSelection = false;
2009
- this.periodMonthLabel = '';
2010
- this.periodYearLabel = '';
2011
- _calendar.stateChanges.pipe(takeUntil(this._destroyed)).subscribe(() => this.setPeriodLabels());
2012
- this.datePickerService.format
2013
- .pipe(take(1))
2014
- .subscribe(value => {
2015
- this.selectedTimeframe = this.timeframeOptions.filter(option => option.format == value)[0].value;
2016
- this.setPeriodLabels();
2017
- });
2018
- _calendar.viewChanged.pipe(takeUntil(this._destroyed)).subscribe(() => this.setPeriodLabels());
2019
- }
2020
- ngOnDestroy() {
2021
- this._destroyed.next();
2022
- this._destroyed.complete();
1974
+ this.componentFactoryResolver = componentFactoryResolver;
1975
+ this.viewContainerRef = viewContainerRef;
1976
+ this.elementRef = elementRef;
1977
+ this.popoverRef = popoverRef;
1978
+ this.class = '';
1979
+ this.isContentTemplate = false;
1980
+ this.popover = true;
2023
1981
  }
2024
- setPeriodLabels() {
2025
- const currentTimeframeOption = this.timeframeOptions.filter(option => option.value === this._calendar.currentView)[0];
2026
- const fullPeriodLabel = currentTimeframeOption.periodLabel();
2027
- if (this._calendar.currentView === 'month') {
2028
- this.periodMonthLabel = fullPeriodLabel.slice(0, 3);
2029
- this.periodYearLabel = fullPeriodLabel.slice(4);
2030
- }
2031
- else {
2032
- this.periodMonthLabel = '';
2033
- this.periodYearLabel = fullPeriodLabel;
1982
+ clickOutside(e) {
1983
+ const isTargetHost = this.hostRef instanceof ElementRef && (this.hostRef.nativeElement === e.target || this.hostRef.nativeElement.contains(e.target));
1984
+ const isTargetInPopover = this.elementRef.nativeElement.contains(e.target);
1985
+ const isTargetInDatepicker = e.target.closest('mat-datepicker-popup');
1986
+ const isTargetInSelect = e.target.closest('ng-dropdown-panel');
1987
+ const isTargetInDatepickerContent = e.target.closest('mat-datepicker-content');
1988
+ if (!isTargetHost
1989
+ && !isTargetInPopover
1990
+ && !isTargetInDatepicker
1991
+ && !isTargetInSelect
1992
+ && !isTargetInDatepickerContent
1993
+ && !this.manualClosing.enabled) {
1994
+ this.popoverRef.close();
2034
1995
  }
2035
- this.cdr.markForCheck();
2036
1996
  }
2037
- setTimeframe() {
2038
- this.timeframeSelection = false;
2039
- this._calendar.currentView = this.selectedTimeframe;
2040
- const chosenTimeframeOption = this.timeframeOptions.filter(option => option.value === this.selectedTimeframe)[0];
2041
- this.datePickerService.format.next(chosenTimeframeOption.format);
2042
- this.datePickerService.setTimeframe(chosenTimeframeOption.format);
2043
- if (this.selectedTimeframe == 'none') {
2044
- this.selectedQuarter = moment$1(this._calendar.activeDate).quarter();
1997
+ ngOnInit() {
1998
+ this.isContentTemplate = this.content instanceof TemplateRef;
1999
+ if (!this.isContentTemplate) {
2000
+ this.componentRef = this.viewContainerRef.createComponent(this.componentFactoryResolver.resolveComponentFactory(this.content));
2001
+ Object.assign(this.componentRef.instance, this.contentContext);
2002
+ this.popoverContainer.nativeElement.appendChild(this.componentRef.location.nativeElement);
2045
2003
  }
2046
- }
2047
- get currentViewIsQuater() {
2048
- return !['month', 'year', 'multi-year'].includes(this._calendar.currentView);
2049
- }
2050
- switchViewOnClickOnPeriodLabel(view) {
2051
- this._calendar.currentView = view;
2052
- }
2053
- onSelectQuater(quarterNumber) {
2054
- const monthsInQuarter = 3;
2055
- this.selectedQuarter = moment$1(this._calendar.activeDate).quarter();
2056
- const unadaptedDate = this._dateAdapter.addCalendarMonths(this._calendar.activeDate, monthsInQuarter * (quarterNumber - this.selectedQuarter));
2057
- this._calendar.activeDate = unadaptedDate;
2058
- this.datePickerService.updatedQuater.next(moment$1(unadaptedDate));
2059
- this.datePickerService.calendarInstance.close();
2060
- }
2061
- pagingClicked(forward) {
2062
- this.pagingSetup[this._calendar.currentView] && this.pagingSetup[this._calendar.currentView](forward);
2063
- }
2064
- pagingDateChange(actionCall, amount, forward) {
2065
- this._calendar.activeDate = this._dateAdapter[actionCall](this._calendar.activeDate, forward ? amount : -amount);
2066
- this.setPeriodLabels();
2004
+ if (this.alignment === 'host') {
2005
+ this[getAlignmentDimension(this.position)] = '100%';
2006
+ }
2007
+ this.cdr.detectChanges();
2067
2008
  }
2068
2009
  }
2069
- DrDatePickerCustomHeaderComponent.decorators = [
2010
+ DrPopoverComponent.decorators = [
2070
2011
  { type: Component, args: [{
2071
- selector: 'dr-date-picker_custom-header.component',
2072
- template: "<div class=\"dr-datepicker__timeframe-select__wrapper\">\n <dr-select \n class=\"dr-datepicker__timeframe-select\"\n [(ngModel)]=\"selectedTimeframe\"\n [items]=\"timeframeOptions\"\n bindLabel=\"title\"\n bindValue=\"value\"\n (ngModelChange)=\"setTimeframe()\">\n </dr-select>\n</div>\n\n<div class=\"dr-date-paging\">\n <div class=\"dr-date-paging flip-page-button\"\n (click)=\"pagingClicked(false)\">\n <i class=\"dr-icon-arrow-left presentation_buttons-navigate_input\"></i> \n </div>\n <span class=\"example-header-label\">\n <span (click)=\"switchViewOnClickOnPeriodLabel('year')\">{{periodMonthLabel + ' '}}</span> \n <span (click)=\"switchViewOnClickOnPeriodLabel('multi-year')\">{{periodYearLabel}}</span>\n </span>\n <div class=\"dr-date-paging flip-page-button\"\n (click)=\"pagingClicked(true)\">\n <i class=\"dr-icon-arrow-right presentation_buttons-navigate_input\"></i>\n </div>\n</div>\n<div #quarterlyDatePicker class=\"dr-quarterly-datepicker\" *ngIf=\"currentViewIsQuater\">\n <div *ngFor=\"let quarter of quarters\" \n class=\"quarter-selector\" (click)=\"onSelectQuater(quarter)\"\n [class]=\"quarter == selectedQuarter ? 'selected' : ''\"\n >Q{{quarter}}</div>\n</div>\n\n",
2012
+ selector: 'dr-popover',
2013
+ template: "<div class=\"dr-popover\" [class]=\"class\" #popoverContainer>\n <ng-container *ngIf=\"isContentTemplate\">\n <ng-container *ngTemplateOutlet=\"content; context: contentContext\"></ng-container>\n </ng-container>\n</div>\n",
2014
+ animations: [
2015
+ trigger('popover', POPUP_ANIMATION),
2016
+ ],
2073
2017
  changeDetection: ChangeDetectionStrategy.OnPush,
2074
- styles: [":host{height:54px;align-items:center;font-family:\"Poppins\";font-style:normal;font-weight:600;font-size:14px;line-height:22px}.dr-datepicker__timeframe-select__wrapper{background-color:#f9faff;padding:16px 32px;border-radius:18px 18px 0 0}.dr-date-paging{display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding:16px 8px;grid-gap:4px;gap:4px}.dr-date-paging.flip-page-button{width:20px;height:20px;padding:0;color:#4e566c}.dr-date-paging.flip-page-button:hover{border-radius:50%;background:#F2F2FB;color:#4646ce}.example-header-label{cursor:pointer}.dr-quarterly-datepicker{display:flex;justify-content:space-between;padding:10px}.dr-quarterly-datepicker .quarter-selector{display:block;width:74px;height:40px;text-align:center;border-radius:40px;font-weight:400;padding-top:9px}.dr-quarterly-datepicker .quarter-selector:hover{background:#F2F2FB;color:#4646ce;font-weight:600;cursor:pointer}.dr-quarterly-datepicker .quarter-selector.selected{background-color:#4646ce;color:#f3f7ff;font-weight:600}\n"]
2018
+ styles: [".dr-popover{display:flex;background:#fff;border:1px solid #E5E5E5;border-radius:5px;box-sizing:border-box;box-shadow:0 4px 14px #0003;font-size:12px;color:#545a6b;max-height:100vh;max-width:100vw;overflow:auto}::ng-deep .dr-popover-transparent-backdrop{background-color:transparent}\n"]
2075
2019
  },] }
2076
2020
  ];
2077
- DrDatePickerCustomHeaderComponent.ctorParameters = () => [
2078
- { type: MatCalendar },
2079
- { type: DateAdapter },
2080
- { type: CustomDateFormat, decorators: [{ type: Inject, args: [MAT_DATE_FORMATS,] }] },
2021
+ DrPopoverComponent.ctorParameters = () => [
2081
2022
  { type: ChangeDetectorRef },
2082
- { type: DrDatePickerService }
2083
- ];
2084
-
2085
- const moment = require('moment');
2086
- const noop = () => { };
2087
- const ɵ0$1 = noop;
2088
- class DrDatePickerComponent {
2089
- constructor(cdr, _dateAdapter, datePickerService) {
2090
- this.cdr = cdr;
2091
- this._dateAdapter = _dateAdapter;
2092
- this.datePickerService = datePickerService;
2093
- this._destroyed = new Subject();
2094
- this.readonly = true;
2095
- this._format = MAT_DEFAULT_DATE_FORMAT;
2096
- this.customHeader = DrDatePickerCustomHeaderComponent;
2097
- this.onChangeFormat = new EventEmitter();
2098
- this.timeframeSelection = false;
2099
- this.takeEndOfPeriod = false;
2100
- this.placeholder = 'Select';
2101
- this.min = null;
2102
- this.max = null;
2103
- this.calendarViewSetup = {
2104
- 'year': (calendar) => calendar.currentView = 'multi-year',
2105
- 'month': (calendar) => calendar.currentView = 'year',
2106
- 'quarter': (calendar) => calendar.currentView = 'none',
2107
- 'day': (calendar) => calendar.currentView = 'month'
2108
- };
2109
- this.pagingSetup = {
2110
- 'year': (forward) => this.pagingDateChange('addCalendarYears', 1, forward),
2111
- 'quarter': (forward) => this.pagingDateChange('addCalendarMonths', 3, forward),
2112
- 'month': (forward) => this.pagingDateChange('addCalendarMonths', 1, forward),
2113
- 'day': (forward) => this.pagingDateChange('addCalendarDays', 1, forward)
2114
- };
2115
- this.innerValue = null;
2116
- this.onTouchedCallback = noop;
2117
- this.onChangeCallback = noop;
2118
- datePickerService.format
2119
- .pipe(takeUntil(this._destroyed))
2120
- .subscribe((value) => {
2121
- this._format = value;
2122
- this.onChangeFormat.emit(this.normalizeValue(value));
2123
- cdr.markForCheck();
2124
- });
2125
- datePickerService.updatedQuater
2126
- .pipe(takeUntil(this._destroyed))
2127
- .subscribe((value) => {
2128
- this.tryToNormalaizeTimeframe(value, 'quarter');
2129
- this.writeValue(value);
2130
- this.onChangeCallback(value);
2131
- });
2132
- }
2133
- set format(value) {
2134
- if (value) {
2135
- value = this.normalizeValue(value);
2136
- this._format = value;
2137
- this.datePickerService.format.next(value);
2138
- this.datePickerService.setTimeframe(value);
2139
- this.cdr.markForCheck();
2140
- }
2141
- }
2142
- ngAfterViewInit() {
2143
- this.datePickerService.calendarInstance = this.dp;
2144
- if (this._format === MAT_DEFAULT_DATE_FORMAT) {
2145
- return;
2146
- }
2147
- setTimeout(() => {
2148
- const popupInstance = this.dp._popupComponentRef.instance;
2149
- const calenderInstance = popupInstance._calendar._calendarHeaderPortal._attachedHost._attachedRef.instance;
2150
- calenderInstance.currentPeriodClicked = function () {
2151
- this.calendarViewSetup[this.datePickerService.timeframe] && this.calendarViewSetup[this.datePickerService.timeframe](this.calendar);
2152
- };
2153
- }, 1000);
2154
- }
2155
- tryToNormalaizeTimeframe(normalizedRef, timeframe) {
2156
- if (this.takeEndOfPeriod) {
2157
- normalizedRef.endOf(timeframe);
2158
- }
2159
- normalizedRef.set('hour', 12);
2160
- }
2161
- get value() {
2162
- return this.innerValue;
2163
- }
2164
- set value(v) {
2165
- if (v !== this.innerValue) {
2166
- this.innerValue = v;
2167
- this.onChangeCallback(v);
2168
- }
2169
- this.cdr.markForCheck();
2170
- }
2171
- registerOnChange(fn) {
2172
- this.onChangeCallback = fn;
2173
- }
2174
- registerOnTouched(fn) {
2175
- this.onTouchedCallback = fn;
2176
- }
2177
- writeValue(value) {
2178
- if (value !== this.innerValue) {
2179
- if (value && typeof value === 'number') {
2180
- this.innerValue = moment.unix(value);
2181
- }
2182
- else {
2183
- this.innerValue = value;
2184
- }
2185
- this.tryToNormalaizeTimeframe(this.innerValue, this.datePickerService.timeframe);
2186
- this.cdr.markForCheck();
2187
- }
2188
- }
2189
- get quarterDisplay() {
2190
- return this.datePickerService.getQuarterDisplay(this.value, this._format);
2191
- }
2192
- normalizeValue(value) {
2193
- if (value.includes('d')) {
2194
- value = value.replace(/d/g, 'D');
2195
- }
2196
- else if (value.includes('D')) {
2197
- value = value.replace(/D/g, 'd');
2198
- }
2199
- return value;
2200
- }
2201
- chosenMonthHandler(normalizedMonth, datepicker) {
2202
- if (this.datePickerService.timeframe === 'month') {
2203
- this.tryToNormalaizeTimeframe(normalizedMonth, 'month');
2204
- this.writeValue(normalizedMonth);
2205
- this.onChangeCallback(normalizedMonth);
2206
- datepicker.close();
2207
- }
2208
- }
2209
- chosenYearHandler(normalizedYear, datepicker) {
2210
- if (this.datePickerService.timeframe === 'year') {
2211
- this.tryToNormalaizeTimeframe(normalizedYear, 'year');
2212
- this.writeValue(normalizedYear);
2213
- this.onChangeCallback(normalizedYear);
2214
- datepicker.close();
2215
- }
2216
- }
2217
- pagingClicked(forward) {
2218
- this.pagingSetup[this.datePickerService.timeframe] && this.pagingSetup[this.datePickerService.timeframe](forward);
2219
- this.datePickerService.calendarInstance.close();
2220
- }
2221
- pagingDateChange(actionCall, amount, forward) {
2222
- const newValue = this._dateAdapter[actionCall](this.innerValue, forward ? amount : -amount);
2223
- this.writeValue(newValue);
2224
- this.onChangeCallback(newValue);
2225
- }
2226
- ngOnDestroy() {
2227
- this._destroyed.next();
2228
- this._destroyed.complete();
2229
- }
2230
- }
2231
- DrDatePickerComponent.decorators = [
2232
- { type: Component, args: [{
2233
- selector: 'dr-date-picker',
2234
- template: "<div class=\"dr-datepicker__with-timeframe-selection\"\n *ngIf=\"timeframeSelection;else noTimeframeSelection\">\n <div class=\"dr-input-date-paging__flip-page-button\"\n (click)=\"pagingClicked(false)\"\n >\n <i class=\"dr-icon-arrow-left presentation_buttons-navigate_input\"></i> \n </div>\n <div class=\"dr-input-date-paging__quarter-display\"\n *ngIf=\"_format.includes('Q')\"\n (click)=\"datePicker.open()\"\n >{{quarterDisplay}}</div>\n <input [(ngModel)]=\"value\"\n (click)=\"datePicker.open()\"\n [matDatepicker]=\"datePicker\"\n [placeholder]=\"placeholder\"\n [drDatePickerFormat]=\"_format\"\n [readonly]=\"readonly\"\n [class]=\"_format.includes('Q') ? 'when-quarter' : ''\"\n [min]=\"min\"\n [max]=\"max\"/>\n <div class=\"dr-input-date-paging__flip-page-button\"\n (click)=\"pagingClicked(true)\">\n <i class=\"dr-icon-arrow-right presentation_buttons-navigate_input\"></i>\n </div>\n <mat-datepicker #datePicker\n class=\"dr-timeframe-datepicker\"\n [calendarHeaderComponent]=\"customHeader\"\n (yearSelected)=\"chosenYearHandler($event, datePicker)\"\n (monthSelected)=\"chosenMonthHandler($event, datePicker)\">\n </mat-datepicker>\n</div>\n\n<ng-template class=\"dr-datepicker__no-timeframe-selection\"\n #noTimeframeSelection>\n <i class=\"dr-icon-schedule\"></i>\n <input [(ngModel)]=\"value\"\n (click)=\"datePicker.open()\"\n [matDatepicker]=\"datePicker\"\n [placeholder]=\"placeholder\"\n [drDatePickerFormat]=\"_format\"\n [readonly]=\"readonly\"\n [min]=\"min\"\n [max]=\"max\"/>\n <mat-datepicker #datePicker\n (yearSelected)=\"chosenYearHandler($event, datePicker)\"\n (monthSelected)=\"chosenMonthHandler($event, datePicker)\">\n </mat-datepicker>\n</ng-template>\n\n",
2235
- changeDetection: ChangeDetectionStrategy.OnPush,
2236
- providers: [
2237
- { provide: NG_VALUE_ACCESSOR, useExisting: DrDatePickerComponent, multi: true }
2238
- ],
2239
- styles: [":host{position:relative;width:100%;display:flex;flex-direction:row;min-height:32px;height:32px;font-size:14px;font-family:\"Poppins\",sans-serif;background-color:#fff;border:1px solid #C3C4CE;border-radius:6px;color:#85889c;overflow:hidden;outline:none;cursor:pointer}:host.period-datepicker{border:none}:host:hover{border-color:#85889c}:host:focus-within{border-color:#21b8f1!important;color:#151b3f}:host.disabled{pointer-events:none;border:none;color:#85889c;background:#E5E6EA}:host.ng-valid.ng-dirty{border-color:#03a678}:host.ng-invalid.ng-dirty:not(:focus-within){border-color:#de2833!important}:host.ng-untouched.ng-valid{border-color:#c3c4ce}:host:after,:host:before{position:absolute;display:flex;border-color:#999999 transparent transparent;color:#999}:host:after{content:\"\";height:0;width:0;border-style:solid;border-width:5px 5px 2.5px;right:11px;top:13px}:host i{position:absolute;color:#999;left:8px;top:3px}:host input{display:flex;flex-grow:1;height:100%;border:none;text-align:left;padding-left:35px;padding-right:25px;cursor:pointer!important;outline:none}:host input.when-quarter{position:absolute;visibility:hidden}:host input:disabled{border:none;color:#85889c;background:transparent}:host input::-webkit-search-decoration,:host input::-webkit-search-cancel-button,:host input::-webkit-search-results-button,:host input::-webkit-search-results-decoration{-webkit-appearance:none}:host .dr-datepicker__with-timeframe-selection{display:flex;align-items:center}:host .dr-datepicker__with-timeframe-selection .dr-input-date-paging__flip-page-button{width:25px;height:25px;border-radius:16px;padding:0;background-color:#fff}:host .dr-datepicker__with-timeframe-selection .dr-input-date-paging__flip-page-button i{position:relative;color:#0c142b;top:unset;left:unset}:host .dr-datepicker__with-timeframe-selection .dr-input-date-paging__flip-page-button:hover{background-color:#f2f2fb;color:#4646ce}:host .dr-datepicker__with-timeframe-selection input{width:90px;padding:0;border-radius:5px;text-decoration:underline;text-align:center}:host .dr-datepicker__with-timeframe-selection input:hover{background-color:#f2f2fb;color:#4646ce}:host .dr-input-date-paging__quarter-display{width:90px;height:22px;padding-left:0;text-align:center;line-height:22px;color:#0c142b;-webkit-text-decoration-line:underline;text-decoration-line:underline}:host .dr-input-date-paging__quarter-display:hover{background-color:#f2f2fb;border-radius:5px;cursor:pointer;-webkit-text-decoration-line:underline;text-decoration-line:underline;color:#4646ce}::ng-deep .mat-datepicker-content{margin:7px 0;box-shadow:0 4px 8px 1px #00000040;border-radius:12px!important}::ng-deep .mat-datepicker-content button[disabled]{border:inherit;color:inherit;background-color:inherit}::ng-deep .mat-datepicker-content button[disabled]:hover{border:inherit}::ng-deep .mat-calendar-body-cell:not(.mat-calendar-body-disabled):hover>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){background:#F2F2FB;color:#4646ce;font-weight:600}::ng-deep .mat-calendar-body-selected{background-color:#4646ce;color:#f2f2fb;font-weight:600}::ng-deep .mat-calendar-body-today.mat-calendar-body-selected{box-shadow:none}::ng-deep .mat-button-focus-overlay{background:#F3F7FF}::ng-deep .mat-calendar-controls .mat-icon-button:hover .mat-button-focus-overlay{opacity:1!important;background:#F3F7FF;transition:opacity .2s cubic-bezier(.35,0,.25,1)}::ng-deep .mat-calendar-controls .mat-calendar-period-button:hover{background:#F3F7FF;transition:background .2s cubic-bezier(.35,0,.25,1)}::ng-deep .mat-calendar-table-header th{font-size:14px;font-weight:600;color:#19181a}::ng-deep .mat-calendar-table-header-divider{display:none}::ng-deep .mat-calendar-body-label{color:#fff;padding:0}\n"]
2240
- },] }
2241
- ];
2242
- DrDatePickerComponent.ctorParameters = () => [
2243
- { type: ChangeDetectorRef },
2244
- { type: DateAdapter },
2245
- { type: DrDatePickerService }
2246
- ];
2247
- DrDatePickerComponent.propDecorators = {
2248
- _format: [{ type: Input }],
2249
- onChangeFormat: [{ type: Output }],
2250
- format: [{ type: Input }],
2251
- timeframeSelection: [{ type: Input }],
2252
- takeEndOfPeriod: [{ type: Input }],
2253
- placeholder: [{ type: Input }],
2254
- min: [{ type: Input }],
2255
- max: [{ type: Input }],
2256
- dp: [{ type: ViewChild, args: ['datePicker',] }]
2257
- };
2258
-
2259
- class DrDatePickerFormatDirective {
2260
- constructor(matDateFormat, ngControl) {
2261
- this.matDateFormat = matDateFormat;
2262
- this.ngControl = ngControl;
2263
- }
2264
- set datePickerFormat(format) {
2265
- var _a;
2266
- if (this.configDateParse) {
2267
- this.matDateFormat.updateDateFormat(this.configDateParse, this.configDateDisplay);
2268
- }
2269
- else {
2270
- this.matDateFormat.updateDateFormat({ dateInput: format });
2271
- }
2272
- const value = this.ngControl.value;
2273
- (_a = this.ngControl.valueAccessor) === null || _a === void 0 ? void 0 : _a.writeValue(value);
2274
- }
2275
- }
2276
- DrDatePickerFormatDirective.decorators = [
2277
- { type: Directive, args: [{
2278
- selector: '[drDatePickerFormat]',
2279
- providers: [
2280
- {
2281
- provide: DateAdapter,
2282
- useClass: MomentDateAdapter
2283
- },
2284
- {
2285
- provide: MAT_DATE_FORMATS,
2286
- useClass: CustomDateFormat
2287
- }
2288
- ]
2289
- },] }
2290
- ];
2291
- DrDatePickerFormatDirective.ctorParameters = () => [
2292
- { type: CustomDateFormat, decorators: [{ type: Inject, args: [MAT_DATE_FORMATS,] }] },
2293
- { type: NgControl, decorators: [{ type: Optional }] }
2294
- ];
2295
- DrDatePickerFormatDirective.propDecorators = {
2296
- configDateParse: [{ type: Input }],
2297
- configDateDisplay: [{ type: Input }],
2298
- datePickerFormat: [{ type: Input, args: ['drDatePickerFormat',] }]
2299
- };
2300
-
2301
- class DrPopoverRef {
2302
- constructor(overlayRef) {
2303
- this.overlayRef = overlayRef;
2304
- this.onClose$ = new Subject();
2305
- // FIXME: this decision was made because of the incompatible rxjs version
2306
- /**
2307
- * Correct type is @type {Observable<any>}
2308
- */
2309
- this.onClose = this.onClose$.asObservable();
2310
- this.onBackdropClick = this.overlayRef.backdropClick();
2311
- }
2312
- close(res) {
2313
- this.overlayRef.detach();
2314
- this.overlayRef.dispose();
2315
- this.onClose$.next(res);
2316
- this.onClose$.complete();
2317
- }
2318
- }
2319
-
2320
- var DrPopoverAlignmentDimension;
2321
- (function (DrPopoverAlignmentDimension) {
2322
- DrPopoverAlignmentDimension["Width"] = "width";
2323
- DrPopoverAlignmentDimension["Height"] = "height";
2324
- })(DrPopoverAlignmentDimension || (DrPopoverAlignmentDimension = {}));
2325
- const DEFAULT_CONFIG = {
2326
- hasBackdrop: false,
2327
- closeOnBackdropClick: false,
2328
- backdropClass: 'dr-popover-transparent-backdrop',
2329
- };
2330
- const DEFAULT_MODEL = {
2331
- position: 'bottom',
2332
- class: '',
2333
- overlayConfig: {},
2334
- manualClosing: { enabled: false },
2335
- };
2336
- function getAlignmentDimension(position) {
2337
- if (!POPUP_POSITIONS[position])
2338
- return DrPopoverAlignmentDimension.Width;
2339
- if ((position === null || position === void 0 ? void 0 : position.includes('left')) || (position === null || position === void 0 ? void 0 : position.includes('right'))) {
2340
- return DrPopoverAlignmentDimension.Height;
2341
- }
2342
- return DrPopoverAlignmentDimension.Width;
2343
- }
2344
-
2345
- class DrPopoverComponent {
2346
- constructor(cdr, componentFactoryResolver, viewContainerRef, elementRef, popoverRef) {
2347
- this.cdr = cdr;
2348
- this.componentFactoryResolver = componentFactoryResolver;
2349
- this.viewContainerRef = viewContainerRef;
2350
- this.elementRef = elementRef;
2351
- this.popoverRef = popoverRef;
2352
- this.class = '';
2353
- this.isContentTemplate = false;
2354
- this.popover = true;
2355
- }
2356
- clickOutside(e) {
2357
- const isTargetHost = this.hostRef instanceof ElementRef && (this.hostRef.nativeElement === e.target || this.hostRef.nativeElement.contains(e.target));
2358
- const isTargetInPopover = this.elementRef.nativeElement.contains(e.target);
2359
- const isTargetInDatepicker = e.target.closest('mat-datepicker-popup');
2360
- const isTargetInSelect = e.target.closest('ng-dropdown-panel');
2361
- const isTargetInDatepickerContent = e.target.closest('mat-datepicker-content');
2362
- if (!isTargetHost
2363
- && !isTargetInPopover
2364
- && !isTargetInDatepicker
2365
- && !isTargetInSelect
2366
- && !isTargetInDatepickerContent
2367
- && !this.manualClosing.enabled) {
2368
- this.popoverRef.close();
2369
- }
2370
- }
2371
- ngOnInit() {
2372
- this.isContentTemplate = this.content instanceof TemplateRef;
2373
- if (!this.isContentTemplate) {
2374
- this.componentRef = this.viewContainerRef.createComponent(this.componentFactoryResolver.resolveComponentFactory(this.content));
2375
- Object.assign(this.componentRef.instance, this.contentContext);
2376
- this.popoverContainer.nativeElement.appendChild(this.componentRef.location.nativeElement);
2377
- }
2378
- if (this.alignment === 'host') {
2379
- this[getAlignmentDimension(this.position)] = '100%';
2380
- }
2381
- this.cdr.detectChanges();
2382
- }
2383
- }
2384
- DrPopoverComponent.decorators = [
2385
- { type: Component, args: [{
2386
- selector: 'dr-popover',
2387
- template: "<div class=\"dr-popover\" [class]=\"class\" #popoverContainer>\n <ng-container *ngIf=\"isContentTemplate\">\n <ng-container *ngTemplateOutlet=\"content; context: contentContext\"></ng-container>\n </ng-container>\n</div>\n",
2388
- animations: [
2389
- trigger('popover', POPUP_ANIMATION),
2390
- ],
2391
- changeDetection: ChangeDetectionStrategy.OnPush,
2392
- styles: [".dr-popover{display:flex;background:#fff;border:1px solid #E5E5E5;border-radius:5px;box-sizing:border-box;box-shadow:0 4px 14px #0003;font-size:12px;color:#545a6b;max-height:100vh;max-width:100vw;overflow:auto}::ng-deep .dr-popover-transparent-backdrop{background-color:transparent}\n"]
2393
- },] }
2394
- ];
2395
- DrPopoverComponent.ctorParameters = () => [
2396
- { type: ChangeDetectorRef },
2397
- { type: ComponentFactoryResolver },
2398
- { type: ViewContainerRef },
2399
- { type: ElementRef },
2400
- { type: DrPopoverRef }
2023
+ { type: ComponentFactoryResolver },
2024
+ { type: ViewContainerRef },
2025
+ { type: ElementRef },
2026
+ { type: DrPopoverRef }
2401
2027
  ];
2402
2028
  DrPopoverComponent.propDecorators = {
2403
2029
  content: [{ type: Input }],
@@ -3263,15 +2889,62 @@ DrModelDebounceChangeDirective.propDecorators = {
3263
2889
  ngModelDebounceChange: [{ type: Output }]
3264
2890
  };
3265
2891
 
3266
- const components$2 = [DateTagComponent,
3267
- DayTagComponent,
3268
- WeekTagComponent,
3269
- MonthTagComponent,
3270
- QuarterTagComponent,
3271
- AnyTagComponent,
3272
- YearTagComponent,
2892
+ const MAT_DEFAULT_DATE_FORMAT = 'MM/DD/yyyy';
2893
+ const DATE_INPUT_FORMAT = 'YYYY/MM/DD';
2894
+ const YEAR_FORMAT = 'yyyy';
2895
+ const MONTH_YEAR_FORMAT = 'MM/yyyy';
2896
+ const QUARTER_FORMAT = 'Q/yyyy';
2897
+ class CustomDateFormat {
2898
+ constructor() {
2899
+ this._parse = {
2900
+ dateInput: DATE_INPUT_FORMAT
2901
+ };
2902
+ this._display = {
2903
+ dateInput: DATE_INPUT_FORMAT,
2904
+ monthYearLabel: 'MMM YYYY',
2905
+ dateA11yLabel: 'LL',
2906
+ monthYearA11yLabel: 'MMM YYYY',
2907
+ quarterYearLabel: 'Q/YYYY',
2908
+ yearLabel: 'YYYY'
2909
+ };
2910
+ }
2911
+ set parse(parse) {
2912
+ this._parse = Object.assign({}, this._parse, parse);
2913
+ }
2914
+ get parse() {
2915
+ return this._parse;
2916
+ }
2917
+ set display(display) {
2918
+ this._display = Object.assign({}, this._display, display);
2919
+ }
2920
+ get display() {
2921
+ return this._display;
2922
+ }
2923
+ updateDateFormat(parse, display) {
2924
+ this.parse = parse;
2925
+ if (!display) {
2926
+ display = parse;
2927
+ }
2928
+ this.display = display;
2929
+ }
2930
+ }
2931
+ var DatePickerPeriodPosition;
2932
+ (function (DatePickerPeriodPosition) {
2933
+ DatePickerPeriodPosition[DatePickerPeriodPosition["END_OF_PERIOD"] = 0] = "END_OF_PERIOD";
2934
+ DatePickerPeriodPosition[DatePickerPeriodPosition["MIDDLE_OF_PERIOD"] = 1] = "MIDDLE_OF_PERIOD";
2935
+ DatePickerPeriodPosition[DatePickerPeriodPosition["START_OF_PERIOD"] = 2] = "START_OF_PERIOD";
2936
+ DatePickerPeriodPosition[DatePickerPeriodPosition["DEFAULT"] = 3] = "DEFAULT";
2937
+ })(DatePickerPeriodPosition || (DatePickerPeriodPosition = {}));
2938
+
2939
+ const components$2 = [DateTagComponent,
2940
+ DayTagComponent,
2941
+ WeekTagComponent,
2942
+ MonthTagComponent,
2943
+ QuarterTagComponent,
2944
+ AnyTagComponent,
2945
+ YearTagComponent,
3273
2946
  ForecastTagComponent];
3274
- const ɵ0 = { useUtc: true };
2947
+ const ɵ0$1 = { useUtc: true };
3275
2948
  class DateTagModule {
3276
2949
  }
3277
2950
  DateTagModule.decorators = [
@@ -3289,7 +2962,7 @@ DateTagModule.decorators = [
3289
2962
  ],
3290
2963
  exports: components$2,
3291
2964
  providers: [
3292
- { provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: ɵ0 }
2965
+ { provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: ɵ0$1 }
3293
2966
  ],
3294
2967
  declarations: components$2,
3295
2968
  },] }
@@ -3334,6 +3007,436 @@ DrTagModule.decorators = [
3334
3007
  },] }
3335
3008
  ];
3336
3009
 
3010
+ const moment$2 = require('moment');
3011
+ class DrDatePickerService {
3012
+ constructor() {
3013
+ this.isTimeframeSelectionEnabled = false;
3014
+ this.timeframe = 'day';
3015
+ this.format$ = new BehaviorSubject(MAT_DEFAULT_DATE_FORMAT);
3016
+ this.updatedQuarter$ = new Subject();
3017
+ this.formatConfig = {
3018
+ day: MAT_DEFAULT_DATE_FORMAT,
3019
+ month: MONTH_YEAR_FORMAT,
3020
+ year: YEAR_FORMAT,
3021
+ quarter: QUARTER_FORMAT,
3022
+ };
3023
+ }
3024
+ getQuarterDisplay(value) {
3025
+ return 'Q' + moment$2(value).quarter() + this.format$.getValue().charAt(1) + moment$2(value).year();
3026
+ }
3027
+ getTimeframe(format) {
3028
+ const defaultFrame = 'day';
3029
+ if (!format) {
3030
+ return defaultFrame;
3031
+ }
3032
+ const lowerCaseFormat = format.toLowerCase();
3033
+ switch (true) {
3034
+ case lowerCaseFormat.includes('q'):
3035
+ return 'quarter';
3036
+ case lowerCaseFormat.includes('d'):
3037
+ return 'day';
3038
+ case lowerCaseFormat.includes('m'):
3039
+ return 'month';
3040
+ case lowerCaseFormat.includes('y'):
3041
+ return 'year';
3042
+ default:
3043
+ return defaultFrame;
3044
+ }
3045
+ }
3046
+ getConfiguredFormat(timeframe) {
3047
+ return this.formatConfig[timeframe];
3048
+ }
3049
+ updateTimeframeAndFormat(format) {
3050
+ const normalizedFormat = this.normalizeValue(format || this.format$.getValue());
3051
+ this.timeframe = this.getTimeframe(normalizedFormat);
3052
+ this.format$.next(this.getConfiguredFormat(this.timeframe));
3053
+ }
3054
+ normalizeValue(value) {
3055
+ return value.replace(/d/g, 'D');
3056
+ }
3057
+ }
3058
+ DrDatePickerService.decorators = [
3059
+ { type: Injectable }
3060
+ ];
3061
+
3062
+ const moment$1 = require('moment');
3063
+ class DrDatePickerCustomHeaderComponent {
3064
+ constructor(_calendar, _dateAdapter, _dateFormats, cdr, datePickerService) {
3065
+ this._calendar = _calendar;
3066
+ this._dateAdapter = _dateAdapter;
3067
+ this._dateFormats = _dateFormats;
3068
+ this.cdr = cdr;
3069
+ this.datePickerService = datePickerService;
3070
+ this._destroyed = new Subject();
3071
+ this.quarters = [1, 2, 3, 4];
3072
+ this.selectedQuarter = 1;
3073
+ this.timeframeOptions = [{
3074
+ title: 'Day',
3075
+ value: 'month',
3076
+ format: this.datePickerService.formatConfig.day,
3077
+ periodLabel: () => this._dateAdapter
3078
+ .format(this._calendar.activeDate, this._dateFormats.display.monthYearLabel)
3079
+ .toLocaleUpperCase()
3080
+ }, {
3081
+ title: 'Month',
3082
+ value: 'year',
3083
+ format: this.datePickerService.formatConfig.month,
3084
+ periodLabel: () => String(moment$1(this._calendar.activeDate).year())
3085
+ }, {
3086
+ title: 'Quarter',
3087
+ value: 'none',
3088
+ format: this.datePickerService.formatConfig.quarter,
3089
+ periodLabel: () => String(moment$1(this._calendar.activeDate).year())
3090
+ }, {
3091
+ title: 'Year',
3092
+ value: 'multi-year',
3093
+ format: this.datePickerService.formatConfig.year,
3094
+ periodLabel: () => {
3095
+ const currentYear = moment$1(this._calendar.activeDate).year();
3096
+ const startPeriod = Math.floor(currentYear / 24) * 24;
3097
+ return startPeriod + '-' + (startPeriod + 23);
3098
+ }
3099
+ }];
3100
+ this.pagingSetup = {
3101
+ 'year': (forward) => this.pagingDateChange('addCalendarYears', 1, forward),
3102
+ 'none': (forward) => this.pagingDateChange('addCalendarYears', 1, forward),
3103
+ 'month': (forward) => this.pagingDateChange('addCalendarMonths', 1, forward),
3104
+ 'multi-year': (forward) => this.pagingDateChange('addCalendarYears', 24, forward)
3105
+ };
3106
+ this.selectedTimeframe = 'month';
3107
+ this.timeframeSelection = false;
3108
+ this.periodMonthLabel = '';
3109
+ this.periodYearLabel = '';
3110
+ _calendar.stateChanges.pipe(takeUntil(this._destroyed)).subscribe(() => this.setPeriodLabels());
3111
+ this.datePickerService.format$
3112
+ .pipe(take(1))
3113
+ .subscribe(value => {
3114
+ this.selectedTimeframe = this.timeframeOptions.filter(option => option.format == value)[0].value;
3115
+ this.setPeriodLabels();
3116
+ });
3117
+ _calendar.viewChanged.pipe(takeUntil(this._destroyed)).subscribe(() => this.setPeriodLabels());
3118
+ }
3119
+ ngOnDestroy() {
3120
+ this._destroyed.next();
3121
+ this._destroyed.complete();
3122
+ }
3123
+ setPeriodLabels() {
3124
+ const currentTimeframeOption = this.timeframeOptions.filter(option => option.value === this._calendar.currentView)[0];
3125
+ const fullPeriodLabel = currentTimeframeOption.periodLabel();
3126
+ if (this._calendar.currentView === 'month') {
3127
+ this.periodMonthLabel = fullPeriodLabel.slice(0, 3);
3128
+ this.periodYearLabel = fullPeriodLabel.slice(4);
3129
+ }
3130
+ else {
3131
+ this.periodMonthLabel = '';
3132
+ this.periodYearLabel = fullPeriodLabel;
3133
+ }
3134
+ this.cdr.markForCheck();
3135
+ }
3136
+ setTimeframe() {
3137
+ this.timeframeSelection = false;
3138
+ this._calendar.currentView = this.selectedTimeframe;
3139
+ const chosenTimeframeOption = this.timeframeOptions.filter(option => option.value === this.selectedTimeframe)[0];
3140
+ this.datePickerService.updateTimeframeAndFormat(chosenTimeframeOption.format);
3141
+ if (this.selectedTimeframe == 'none') {
3142
+ this.selectedQuarter = moment$1(this._calendar.activeDate).quarter();
3143
+ }
3144
+ }
3145
+ get currentViewIsQuarter() {
3146
+ return !['month', 'year', 'multi-year'].includes(this._calendar.currentView);
3147
+ }
3148
+ switchViewOnClickOnPeriodLabel(view) {
3149
+ this._calendar.currentView = view;
3150
+ }
3151
+ onSelectQuarter(quarterNumber) {
3152
+ const monthsInQuarter = 3;
3153
+ this.selectedQuarter = moment$1(this._calendar.activeDate).quarter();
3154
+ const unadaptedDate = this._dateAdapter.addCalendarMonths(this._calendar.activeDate, monthsInQuarter * (quarterNumber - this.selectedQuarter));
3155
+ this._calendar.activeDate = unadaptedDate;
3156
+ this.datePickerService.updatedQuarter$.next(moment$1(unadaptedDate));
3157
+ this.datePickerService.calendarInstance.close();
3158
+ }
3159
+ pagingClicked(forward) {
3160
+ this.pagingSetup[this._calendar.currentView] && this.pagingSetup[this._calendar.currentView](forward);
3161
+ }
3162
+ pagingDateChange(actionCall, amount, forward) {
3163
+ this._calendar.activeDate = this._dateAdapter[actionCall](this._calendar.activeDate, forward ? amount : -amount);
3164
+ this.setPeriodLabels();
3165
+ }
3166
+ }
3167
+ DrDatePickerCustomHeaderComponent.decorators = [
3168
+ { type: Component, args: [{
3169
+ selector: 'dr-date-picker_custom-header.component',
3170
+ template: "<div *ngIf=\"datePickerService.isTimeframeSelectionEnabled\" class=\"dr-datepicker__timeframe-select__wrapper\">\n <dr-select\n class=\"dr-datepicker__timeframe-select\"\n [(ngModel)]=\"selectedTimeframe\"\n [items]=\"timeframeOptions\"\n bindLabel=\"title\"\n bindValue=\"value\"\n (ngModelChange)=\"setTimeframe()\">\n </dr-select>\n</div>\n\n<div class=\"dr-date-paging\">\n <div class=\"dr-date-paging flip-page-button\"\n (click)=\"pagingClicked(false)\">\n <i class=\"dr-icon-arrow-left presentation_buttons-navigate_input\"></i>\n </div>\n <span class=\"example-header-label\">\n <span (click)=\"switchViewOnClickOnPeriodLabel('year')\">{{periodMonthLabel + ' '}}</span>\n <span (click)=\"switchViewOnClickOnPeriodLabel('multi-year')\">{{periodYearLabel}}</span>\n </span>\n <div class=\"dr-date-paging flip-page-button\"\n (click)=\"pagingClicked(true)\">\n <i class=\"dr-icon-arrow-right presentation_buttons-navigate_input\"></i>\n </div>\n</div>\n<div #quarterlyDatePicker class=\"dr-quarterly-datepicker\" *ngIf=\"currentViewIsQuarter\">\n <div *ngFor=\"let quarter of quarters\"\n class=\"quarter-selector\" (click)=\"onSelectQuarter(quarter)\"\n [class]=\"quarter == selectedQuarter ? 'selected' : ''\"\n >Q{{quarter}}</div>\n</div>\n\n",
3171
+ changeDetection: ChangeDetectionStrategy.OnPush,
3172
+ styles: [":host{height:54px;align-items:center;font-family:\"Poppins\";font-style:normal;font-weight:600;font-size:14px;line-height:22px}.dr-datepicker__timeframe-select__wrapper{background-color:#f9faff;padding:16px 32px;border-radius:18px 18px 0 0}.dr-date-paging{display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding:16px 8px;grid-gap:4px;gap:4px}.dr-date-paging.flip-page-button{width:20px;height:20px;padding:0;color:#4e566c}.dr-date-paging.flip-page-button:hover{border-radius:50%;background:#F2F2FB;color:#4646ce}.example-header-label{cursor:pointer}.dr-quarterly-datepicker{display:flex;justify-content:space-between;padding:10px}.dr-quarterly-datepicker .quarter-selector{display:block;width:74px;height:40px;text-align:center;border-radius:40px;font-weight:400;padding-top:9px}.dr-quarterly-datepicker .quarter-selector:hover{background:#F2F2FB;color:#4646ce;font-weight:600;cursor:pointer}.dr-quarterly-datepicker .quarter-selector.selected{background-color:#4646ce;color:#f3f7ff;font-weight:600}\n"]
3173
+ },] }
3174
+ ];
3175
+ DrDatePickerCustomHeaderComponent.ctorParameters = () => [
3176
+ { type: MatCalendar },
3177
+ { type: DateAdapter },
3178
+ { type: CustomDateFormat, decorators: [{ type: Inject, args: [MAT_DATE_FORMATS,] }] },
3179
+ { type: ChangeDetectorRef },
3180
+ { type: DrDatePickerService }
3181
+ ];
3182
+
3183
+ const moment = require('moment');
3184
+ const noop = () => { };
3185
+ const ɵ0 = noop;
3186
+ class DrDatePickerComponent {
3187
+ constructor(cdr, dateAdapter, datePickerService) {
3188
+ this.cdr = cdr;
3189
+ this.dateAdapter = dateAdapter;
3190
+ this.datePickerService = datePickerService;
3191
+ // Whether to transform date, taking end, start, middle of preiod (i.e. set middle of month if timeframe='month')
3192
+ this.periodPosition = DatePickerPeriodPosition.DEFAULT;
3193
+ this.placeholder = 'Select';
3194
+ this.calendarViewsTimeframeMapping = {
3195
+ year: 'multi-year',
3196
+ month: 'year',
3197
+ quarter: 'none',
3198
+ day: 'month',
3199
+ };
3200
+ this.customHeader = DrDatePickerCustomHeaderComponent;
3201
+ this.readonly = true;
3202
+ this.innerValue = null;
3203
+ this.destroyed$ = new Subject();
3204
+ this.onTouchedCallback = noop;
3205
+ this.onChangeCallback = noop;
3206
+ datePickerService.updatedQuarter$
3207
+ .pipe(takeUntil(this.destroyed$))
3208
+ .subscribe((value) => {
3209
+ this.setValueFromMoment(value);
3210
+ });
3211
+ }
3212
+ set format(value) {
3213
+ this.datePickerService.updateTimeframeAndFormat(value);
3214
+ }
3215
+ set min(minDate) {
3216
+ this._min = moment.unix(minDate).utc();
3217
+ }
3218
+ set max(maxDate) {
3219
+ this._max = moment.unix(maxDate).utc();
3220
+ }
3221
+ get value() {
3222
+ return this.innerValue;
3223
+ }
3224
+ set value(v) {
3225
+ if (v !== this.innerValue) {
3226
+ this.setValueFromMoment(v);
3227
+ }
3228
+ this.cdr.markForCheck();
3229
+ }
3230
+ ngAfterViewInit() {
3231
+ this.datePickerService.calendarInstance = this.dp;
3232
+ this.dp.startView = this.calendarViewsTimeframeMapping[this.datePickerService.timeframe];
3233
+ }
3234
+ ngOnDestroy() {
3235
+ this.destroyed$.next();
3236
+ this.destroyed$.complete();
3237
+ }
3238
+ /**
3239
+ * Updating component inner value according to datepicker timeframe (day, month etc.)
3240
+ * and date position in period (start, end, middle)
3241
+ */
3242
+ tryToNormalaizeTimeframe() {
3243
+ const timeframe = this.datePickerService.timeframe;
3244
+ switch (this.periodPosition) {
3245
+ case DatePickerPeriodPosition.START_OF_PERIOD:
3246
+ this.innerValue.startOf(timeframe);
3247
+ break;
3248
+ case DatePickerPeriodPosition.END_OF_PERIOD:
3249
+ this.innerValue.endOf(timeframe);
3250
+ break;
3251
+ case DatePickerPeriodPosition.MIDDLE_OF_PERIOD:
3252
+ this.innerValue.startOf(timeframe);
3253
+ const endOfPeriod = this.innerValue.clone().endOf(timeframe);
3254
+ const diff = endOfPeriod.diff(this.innerValue, 'seconds');
3255
+ this.innerValue.add(diff / 2 + 1, 'seconds');
3256
+ break;
3257
+ default:
3258
+ this.innerValue.startOf(timeframe);
3259
+ break;
3260
+ }
3261
+ }
3262
+ chosenPeriodHandler(chosenDate, timeframe) {
3263
+ if (this.datePickerService.timeframe === timeframe) {
3264
+ this.setValueFromMoment(chosenDate);
3265
+ this.dp.close();
3266
+ }
3267
+ }
3268
+ /**
3269
+ * Setting value from outside of component via ngModel or formControl updates
3270
+ */
3271
+ writeValue(value) {
3272
+ this.innerValue = value ? moment.unix(value).utc() : value;
3273
+ if (this.innerValue) {
3274
+ this.tryToNormalaizeTimeframe();
3275
+ }
3276
+ this.cdr.markForCheck();
3277
+ }
3278
+ registerOnChange(fn) {
3279
+ this.onChangeCallback = fn;
3280
+ }
3281
+ registerOnTouched(fn) {
3282
+ this.onTouchedCallback = fn;
3283
+ }
3284
+ /**
3285
+ * Set inner value from Moment and propagate
3286
+ * @param momentDate
3287
+ */
3288
+ setValueFromMoment(momentDate) {
3289
+ this.setValue(momentDate.unix());
3290
+ }
3291
+ /**
3292
+ * Set inner value from timestamp and propagate
3293
+ * @param timestamp
3294
+ */
3295
+ setValue(timestamp) {
3296
+ this.writeValue(timestamp);
3297
+ this.onChangeCallback(this.innerValue.unix());
3298
+ }
3299
+ }
3300
+ DrDatePickerComponent.decorators = [
3301
+ { type: Component, args: [{
3302
+ selector: 'dr-date-picker',
3303
+ template: "<i class=\"dr-icon-schedule\"></i>\n<input [(ngModel)]=\"value\"\n (click)=\"datePicker.open()\"\n [matDatepicker]=\"datePicker\"\n [placeholder]=\"placeholder\"\n [drDatePickerFormat]=\"datePickerService.format$ | async\"\n [readonly]=\"readonly\"\n [min]=\"_min\"\n [max]=\"_max\"/>\n<mat-datepicker #datePicker\n [calendarHeaderComponent]=\"customHeader\"\n (yearSelected)=\"chosenPeriodHandler($event, 'year')\"\n (monthSelected)=\"chosenPeriodHandler($event, 'month')\">\n</mat-datepicker>\n",
3304
+ changeDetection: ChangeDetectionStrategy.OnPush,
3305
+ providers: [
3306
+ { provide: NG_VALUE_ACCESSOR, useExisting: DrDatePickerComponent, multi: true },
3307
+ { provide: DrDatePickerService }
3308
+ ],
3309
+ styles: [":host{position:relative;width:100%;display:flex;flex-direction:row;min-height:32px;height:32px;font-size:14px;font-family:\"Poppins\",sans-serif;background-color:#fff;border:1px solid #C3C4CE;border-radius:6px;color:#85889c;overflow:hidden;outline:none;cursor:pointer}:host:hover{border-color:#85889c}:host:focus-within{border-color:#21b8f1!important;color:#151b3f}:host.disabled{pointer-events:none;border:none;color:#85889c;background:#E5E6EA}:host.ng-valid.ng-dirty{border-color:#03a678}:host.ng-invalid.ng-dirty:not(:focus-within){border-color:#de2833!important}:host.ng-untouched.ng-valid{border-color:#c3c4ce}:host:after,:host:before{position:absolute;display:flex;border-color:#999999 transparent transparent;color:#999}:host:after{content:\"\";height:0;width:0;border-style:solid;border-width:5px 5px 2.5px;right:11px;top:13px}:host i{position:absolute;color:#999;left:8px;top:3px}:host input{display:flex;flex-grow:1;height:100%;border:none;text-align:left;padding-left:35px;padding-right:25px;cursor:pointer!important;outline:none}:host input.when-quarter{position:absolute;visibility:hidden}:host input:disabled{border:none;color:#85889c;background:transparent}:host input::-webkit-search-decoration,:host input::-webkit-search-cancel-button,:host input::-webkit-search-results-button,:host input::-webkit-search-results-decoration{-webkit-appearance:none}::ng-deep .mat-datepicker-content{margin:7px 0;box-shadow:0 4px 8px 1px #00000040;border-radius:12px!important}::ng-deep .mat-datepicker-content button[disabled]{border:inherit;color:inherit;background-color:inherit}::ng-deep .mat-datepicker-content button[disabled]:hover{border:inherit}::ng-deep .mat-calendar-body-cell:not(.mat-calendar-body-disabled):hover>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){background:#F2F2FB;color:#4646ce;font-weight:600}::ng-deep .mat-calendar-body-selected{background-color:#4646ce;color:#f2f2fb;font-weight:600}::ng-deep .mat-calendar-body-today.mat-calendar-body-selected{box-shadow:none}::ng-deep .mat-button-focus-overlay{background:#F3F7FF}::ng-deep .mat-calendar-controls .mat-icon-button:hover .mat-button-focus-overlay{opacity:1!important;background:#F3F7FF;transition:opacity .2s cubic-bezier(.35,0,.25,1)}::ng-deep .mat-calendar-controls .mat-calendar-period-button:hover{background:#F3F7FF;transition:background .2s cubic-bezier(.35,0,.25,1)}::ng-deep .mat-calendar-table-header th{font-size:14px;font-weight:600;color:#19181a}::ng-deep .mat-calendar-table-header-divider{display:none}::ng-deep .mat-calendar-body-label{color:#fff;padding:0}\n"]
3310
+ },] }
3311
+ ];
3312
+ DrDatePickerComponent.ctorParameters = () => [
3313
+ { type: ChangeDetectorRef },
3314
+ { type: DateAdapter },
3315
+ { type: DrDatePickerService }
3316
+ ];
3317
+ DrDatePickerComponent.propDecorators = {
3318
+ format: [{ type: Input }],
3319
+ min: [{ type: Input }],
3320
+ max: [{ type: Input }],
3321
+ periodPosition: [{ type: Input }],
3322
+ placeholder: [{ type: Input }],
3323
+ dp: [{ type: ViewChild, args: ['datePicker',] }]
3324
+ };
3325
+
3326
+ class DrDatePickerWithTimeframeComponent extends DrDatePickerComponent {
3327
+ constructor(cdr, dateAdapter, datePickerService) {
3328
+ super(cdr, dateAdapter, datePickerService);
3329
+ this.cdr = cdr;
3330
+ this.dateAdapter = dateAdapter;
3331
+ this.datePickerService = datePickerService;
3332
+ this.isDashboardDatepicker = false;
3333
+ this.onChangeFormat = new EventEmitter();
3334
+ this.pagingSetup = {
3335
+ 'year': (forward) => this.pagingDateChange('addCalendarYears', 1, forward),
3336
+ 'quarter': (forward) => this.pagingDateChange('addCalendarMonths', 3, forward),
3337
+ 'month': (forward) => this.pagingDateChange('addCalendarMonths', 1, forward),
3338
+ 'day': (forward) => this.pagingDateChange('addCalendarDays', 1, forward)
3339
+ };
3340
+ datePickerService.isTimeframeSelectionEnabled = true;
3341
+ datePickerService.format$
3342
+ .pipe(takeUntil(this.destroyed$))
3343
+ .subscribe((value) => {
3344
+ this.onChangeFormat.emit(datePickerService.normalizeValue(value));
3345
+ });
3346
+ }
3347
+ get isDashboardClassDisplayed() {
3348
+ return this.isDashboardDatepicker;
3349
+ }
3350
+ ;
3351
+ get quarterDisplay() {
3352
+ return this.datePickerService.getQuarterDisplay(this.value);
3353
+ }
3354
+ ngOnInit() {
3355
+ if (this.dateFormatConfig) {
3356
+ this.datePickerService.formatConfig = Object.assign(Object.assign({}, this.datePickerService.formatConfig), this.dateFormatConfig);
3357
+ }
3358
+ }
3359
+ pagingClicked(forward) {
3360
+ this.pagingSetup[this.datePickerService.timeframe] && this.pagingSetup[this.datePickerService.timeframe](forward);
3361
+ this.dp.close();
3362
+ }
3363
+ pagingDateChange(actionCall, amount, forward) {
3364
+ const newValue = this.dateAdapter[actionCall](this.innerValue, forward ? amount : -amount);
3365
+ this.setValueFromMoment(newValue);
3366
+ }
3367
+ }
3368
+ DrDatePickerWithTimeframeComponent.decorators = [
3369
+ { type: Component, args: [{
3370
+ selector: 'dr-date-picker-with-timeframe',
3371
+ template: "<div class=\"dr-input-date-paging__flip-page-button\"\n (click)=\"pagingClicked(false)\"\n>\n <i class=\"dr-icon-arrow-left presentation_buttons-navigate_input\"></i>\n</div>\n<div class=\"dr-datepicker__input-container\">\n <i *ngIf=\"isDashboardDatepicker\" class=\"dr-icon-date\"></i>\n <div\n class=\"dr-input-date-paging__formatted-value-display\"\n (click)=\"datepickerInput.click()\"\n >\n {{\n !value\n ? placeholder\n : (datePickerService.format$.getValue()?.includes('Q') ? quarterDisplay : value.format(datePickerService.format$.getValue()))\n }}\n </div>\n <input\n #datepickerInput\n [(ngModel)]=\"value\"\n (click)=\"datePicker.open()\"\n [matDatepicker]=\"datePicker\"\n [readonly]=\"readonly\"\n [min]=\"_min\"\n [max]=\"_max\"\n />\n</div>\n<div class=\"dr-input-date-paging__flip-page-button\"\n (click)=\"pagingClicked(true)\">\n <i class=\"dr-icon-arrow-right presentation_buttons-navigate_input\"></i>\n</div>\n<mat-datepicker #datePicker\n class=\"dr-timeframe-datepicker\"\n [calendarHeaderComponent]=\"customHeader\"\n (yearSelected)=\"chosenPeriodHandler($event, 'year')\"\n (monthSelected)=\"chosenPeriodHandler($event, 'month')\">\n</mat-datepicker>\n",
3372
+ changeDetection: ChangeDetectionStrategy.OnPush,
3373
+ providers: [
3374
+ { provide: NG_VALUE_ACCESSOR, useExisting: DrDatePickerWithTimeframeComponent, multi: true },
3375
+ { provide: DrDatePickerService }
3376
+ ],
3377
+ styles: [":host{position:relative;width:100%;display:flex;flex-direction:row;min-height:32px;height:32px;font-size:14px;font-family:\"Poppins\",sans-serif;background-color:#fff;border:1px solid #C3C4CE;border-radius:6px;color:#85889c;overflow:hidden;outline:none;cursor:pointer}:host:hover{border-color:#85889c}:host:focus-within{border-color:#21b8f1!important;color:#151b3f}:host.disabled{pointer-events:none;border:none;color:#85889c;background:#E5E6EA}:host.ng-valid.ng-dirty{border-color:#03a678}:host.ng-invalid.ng-dirty:not(:focus-within){border-color:#de2833!important}:host.ng-untouched.ng-valid{border-color:#c3c4ce}:host:after,:host:before{position:absolute;display:flex;border-color:#999999 transparent transparent;color:#999}:host:after{content:\"\";height:0;width:0;border-style:solid;border-width:5px 5px 2.5px;right:11px;top:13px}:host i{position:absolute;color:#999;left:8px;top:3px}:host input{display:flex;flex-grow:1;height:100%;border:none;text-align:left;padding-left:35px;padding-right:25px;cursor:pointer!important;outline:none}:host input.when-quarter{position:absolute;visibility:hidden}:host input:disabled{border:none;color:#85889c;background:transparent}:host input::-webkit-search-decoration,:host input::-webkit-search-cancel-button,:host input::-webkit-search-results-button,:host input::-webkit-search-results-decoration{-webkit-appearance:none}::ng-deep .mat-datepicker-content{margin:7px 0;box-shadow:0 4px 8px 1px #00000040;border-radius:12px!important}::ng-deep .mat-datepicker-content button[disabled]{border:inherit;color:inherit;background-color:inherit}::ng-deep .mat-datepicker-content button[disabled]:hover{border:inherit}::ng-deep .mat-calendar-body-cell:not(.mat-calendar-body-disabled):hover>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){background:#F2F2FB;color:#4646ce;font-weight:600}::ng-deep .mat-calendar-body-selected{background-color:#4646ce;color:#f2f2fb;font-weight:600}::ng-deep .mat-calendar-body-today.mat-calendar-body-selected{box-shadow:none}::ng-deep .mat-button-focus-overlay{background:#F3F7FF}::ng-deep .mat-calendar-controls .mat-icon-button:hover .mat-button-focus-overlay{opacity:1!important;background:#F3F7FF;transition:opacity .2s cubic-bezier(.35,0,.25,1)}::ng-deep .mat-calendar-controls .mat-calendar-period-button:hover{background:#F3F7FF;transition:background .2s cubic-bezier(.35,0,.25,1)}::ng-deep .mat-calendar-table-header th{font-size:14px;font-weight:600;color:#19181a}::ng-deep .mat-calendar-table-header-divider{display:none}::ng-deep .mat-calendar-body-label{color:#fff;padding:0}:host{border:none;display:flex;align-items:center}:host.dr-date-picker-on-dashboard{width:180px;justify-content:space-between}:host.dr-date-picker-on-dashboard mat-datepicker{position:absolute}:host.dr-date-picker-on-dashboard .dr-datepicker__input-container{display:flex;flex-direction:row;justify-content:center;align-items:center;margin-left:-10px}:host.dr-date-picker-on-dashboard .dr-datepicker__input-container .dr-input-date-paging__formatted-value-display{font-weight:600;width:auto;margin-left:5px}:host.dr-date-picker-on-dashboard .dr-datepicker__input-container .dr-icon-date{display:block;position:relative;top:0;margin-right:8px;color:#4e566c}:host .dr-input-date-paging__flip-page-button{width:25px;height:25px;border-radius:16px;padding:0;background-color:#fff}:host .dr-input-date-paging__flip-page-button i{position:relative;color:#0c142b;top:unset;left:unset}:host .dr-input-date-paging__flip-page-button:hover{background-color:#f2f2fb;color:#4646ce}:host input{visibility:hidden;position:absolute;width:100%}:host .dr-input-date-paging__formatted-value-display{width:90px;height:22px;padding-left:0;text-align:center;line-height:22px;color:#0c142b;-webkit-text-decoration-line:underline;text-decoration-line:underline}:host .dr-input-date-paging__formatted-value-display:hover{background-color:#f2f2fb;border-radius:5px;cursor:pointer;-webkit-text-decoration-line:underline;text-decoration-line:underline;color:#4646ce}\n"]
3378
+ },] }
3379
+ ];
3380
+ DrDatePickerWithTimeframeComponent.ctorParameters = () => [
3381
+ { type: ChangeDetectorRef },
3382
+ { type: DateAdapter },
3383
+ { type: DrDatePickerService }
3384
+ ];
3385
+ DrDatePickerWithTimeframeComponent.propDecorators = {
3386
+ isDashboardClassDisplayed: [{ type: HostBinding, args: ['class.dr-date-picker-on-dashboard',] }],
3387
+ isDashboardDatepicker: [{ type: Input }],
3388
+ dateFormatConfig: [{ type: Input }],
3389
+ onChangeFormat: [{ type: Output }]
3390
+ };
3391
+
3392
+ class DrDatePickerFormatDirective {
3393
+ constructor(matDateFormat, ngControl) {
3394
+ this.matDateFormat = matDateFormat;
3395
+ this.ngControl = ngControl;
3396
+ }
3397
+ set datePickerFormat(format) {
3398
+ var _a;
3399
+ if (this.configDateParse) {
3400
+ this.matDateFormat.updateDateFormat(this.configDateParse, this.configDateDisplay);
3401
+ }
3402
+ else {
3403
+ this.matDateFormat.updateDateFormat({ dateInput: format });
3404
+ }
3405
+ const value = this.ngControl.value;
3406
+ (_a = this.ngControl.valueAccessor) === null || _a === void 0 ? void 0 : _a.writeValue(value);
3407
+ }
3408
+ }
3409
+ DrDatePickerFormatDirective.decorators = [
3410
+ { type: Directive, args: [{
3411
+ selector: '[drDatePickerFormat]',
3412
+ providers: [
3413
+ {
3414
+ provide: DateAdapter,
3415
+ useClass: MomentDateAdapter
3416
+ },
3417
+ {
3418
+ provide: MAT_DATE_FORMATS,
3419
+ useClass: CustomDateFormat
3420
+ }
3421
+ ]
3422
+ },] }
3423
+ ];
3424
+ DrDatePickerFormatDirective.ctorParameters = () => [
3425
+ { type: CustomDateFormat, decorators: [{ type: Inject, args: [MAT_DATE_FORMATS,] }] },
3426
+ { type: NgControl, decorators: [{ type: Optional }] }
3427
+ ];
3428
+ DrDatePickerFormatDirective.propDecorators = {
3429
+ configDateParse: [{ type: Input }],
3430
+ configDateDisplay: [{ type: Input }],
3431
+ datePickerFormat: [{ type: Input, args: ['drDatePickerFormat',] }]
3432
+ };
3433
+
3434
+ // !!! Please do not use such approach in other places
3435
+ // Hard fix for 'none' calendar view selection
3436
+ MatCalendar.prototype.focusActiveCell = function () {
3437
+ var _a;
3438
+ (_a = this._getCurrentViewComponent()) === null || _a === void 0 ? void 0 : _a._focusActiveCell(false);
3439
+ };
3337
3440
  const components$1 = [
3338
3441
  DrButtonComponent,
3339
3442
  RadioButtonComponent,
@@ -3344,6 +3447,7 @@ const components$1 = [
3344
3447
  DrToggleComponent,
3345
3448
  DrToggleButtonComponent,
3346
3449
  DrDatePickerComponent,
3450
+ DrDatePickerWithTimeframeComponent,
3347
3451
  DrDatePickerFormatDirective,
3348
3452
  DrDatePickerCustomHeaderComponent,
3349
3453
  DrModelDebounceChangeDirective
@@ -3360,9 +3464,6 @@ DrInputsModule.decorators = [
3360
3464
  CommonModule,
3361
3465
  NgSelectModule,
3362
3466
  MatDatepickerModule
3363
- ],
3364
- providers: [
3365
- DrDatePickerService
3366
3467
  ]
3367
3468
  },] }
3368
3469
  ];
@@ -3511,5 +3612,5 @@ DrAccordionModule.decorators = [
3511
3612
  * Generated bundle index. Do not edit.
3512
3613
  */
3513
3614
 
3514
- export { AnyTagComponent, CheckboxComponent, DateTagComponent, DateTagModule, DayTagComponent, DrAccordionComponent, DrAccordionItemBodyComponent, DrAccordionItemComponent, DrAccordionItemHeaderComponent, DrAccordionModule, DrAvatarComponent, DrAvatarModule, DrAvatarPipe, DrButtonComponent, DrDatePickerComponent, DrDatePickerFormatDirective, DrDropdownComponent, DrDropdownDirective, DrDropdownItemShowPipe, DrDropdownModule, DrDropdownPositionDirective, DrDropdownService, DrInputComponent, DrInputsModule, DrModelDebounceChangeDirective, DrPopoverAlignmentDimension, DrPopoverComponent, DrPopoverDirective, DrPopoverModule, DrPopoverRef, DrPopoverService, DrSelectComponent, DrSpinnerComponent, DrSpinnerDirective, DrSpinnerModule, DrTabComponent, DrTabsComponent, DrTabsModule, DrTagComponent, DrTagModule, DrToggleButtonComponent, DrToggleComponent, DrTooltipDirective, DrTooltipModule, ForecastTagComponent, ISpinnerOptions, ListTagComponent, ListTagModule, MonthTagComponent, QuarterTagComponent, RadioButtonComponent, RadioGroupComponent, TooltipComponent, WeekTagComponent, YearTagComponent, components$2 as ɵa, POPUP_ANIMATION as ɵb, DrDatePickerService as ɵc, CustomDateFormat as ɵd, DrDatePickerCustomHeaderComponent as ɵe };
3615
+ export { AnyTagComponent, CheckboxComponent, CustomDateFormat, DATE_INPUT_FORMAT, DatePickerPeriodPosition, DateTagComponent, DateTagModule, DayTagComponent, DrAccordionComponent, DrAccordionItemBodyComponent, DrAccordionItemComponent, DrAccordionItemHeaderComponent, DrAccordionModule, DrAvatarComponent, DrAvatarModule, DrAvatarPipe, DrButtonComponent, DrDropdownComponent, DrDropdownDirective, DrDropdownItemShowPipe, DrDropdownModule, DrDropdownPositionDirective, DrDropdownService, DrInputComponent, DrInputsModule, DrModelDebounceChangeDirective, DrPopoverAlignmentDimension, DrPopoverComponent, DrPopoverDirective, DrPopoverModule, DrPopoverRef, DrPopoverService, DrSelectComponent, DrSpinnerComponent, DrSpinnerDirective, DrSpinnerModule, DrTabComponent, DrTabsComponent, DrTabsModule, DrTagComponent, DrTagModule, DrToggleButtonComponent, DrToggleComponent, DrTooltipDirective, DrTooltipModule, ForecastTagComponent, ISpinnerOptions, ListTagComponent, ListTagModule, MAT_DEFAULT_DATE_FORMAT, MONTH_YEAR_FORMAT, MonthTagComponent, QUARTER_FORMAT, QuarterTagComponent, RadioButtonComponent, RadioGroupComponent, TooltipComponent, WeekTagComponent, YEAR_FORMAT, YearTagComponent, components$2 as ɵa, POPUP_ANIMATION as ɵb, DrDatePickerComponent as ɵc, DrDatePickerService as ɵd, DrDatePickerWithTimeframeComponent as ɵe, DrDatePickerFormatDirective as ɵf, DrDatePickerCustomHeaderComponent as ɵg };
3515
3616
  //# sourceMappingURL=datarailsshared-datarailsshared.js.map