@datarailsshared/datarailsshared 1.4.22-tigers → 1.4.23

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 (36) hide show
  1. package/bundles/datarailsshared-datarailsshared.umd.js +1280 -1403
  2. package/bundles/datarailsshared-datarailsshared.umd.js.map +1 -1
  3. package/datarailsshared-datarailsshared-1.4.23.tgz +0 -0
  4. package/datarailsshared-datarailsshared.d.ts +3 -5
  5. package/datarailsshared-datarailsshared.metadata.json +1 -1
  6. package/esm2015/datarailsshared-datarailsshared.js +4 -6
  7. package/esm2015/lib/dr-avatar/dr-avatar.component.js +1 -1
  8. package/esm2015/lib/dr-inputs/dr-date-picker/dr-date-picker-format.directive.js +47 -0
  9. package/esm2015/lib/dr-inputs/dr-date-picker/dr-date-picker.component.js +183 -0
  10. package/esm2015/lib/dr-inputs/dr-date-picker/dr-date-picker.service.js +41 -0
  11. package/esm2015/lib/dr-inputs/dr-date-picker/dr-date-picker_custom-header/dr-date-picker_custom-header.component.js +129 -0
  12. package/esm2015/lib/dr-inputs/dr-inputs.module.js +9 -13
  13. package/esm2015/lib/dr-tooltip/dr-tooltip.component.js +3 -13
  14. package/esm2015/lib/dr-tooltip/dr-tooltip.directive.js +10 -43
  15. package/esm2015/lib/models/datePicker.js +1 -8
  16. package/esm2015/public-api.js +3 -3
  17. package/fesm2015/datarailsshared-datarailsshared.js +1256 -1357
  18. package/fesm2015/datarailsshared-datarailsshared.js.map +1 -1
  19. package/lib/dr-inputs/{date-pickers/directives → dr-date-picker}/dr-date-picker-format.directive.d.ts +1 -1
  20. package/lib/dr-inputs/dr-date-picker/dr-date-picker.component.d.ts +54 -0
  21. package/lib/dr-inputs/dr-date-picker/dr-date-picker.service.d.ts +12 -0
  22. package/lib/dr-inputs/{date-pickers → dr-date-picker}/dr-date-picker_custom-header/dr-date-picker_custom-header.component.d.ts +4 -4
  23. package/lib/dr-tooltip/dr-tooltip.component.d.ts +0 -4
  24. package/lib/dr-tooltip/dr-tooltip.directive.d.ts +0 -4
  25. package/lib/models/datePicker.d.ts +0 -12
  26. package/package.json +1 -1
  27. package/public-api.d.ts +2 -1
  28. package/datarailsshared-datarailsshared-1.4.22-tigers.tgz +0 -0
  29. package/esm2015/lib/dr-inputs/date-pickers/directives/dr-date-picker-format.directive.js +0 -47
  30. package/esm2015/lib/dr-inputs/date-pickers/dr-date-picker/dr-date-picker.component.js +0 -152
  31. package/esm2015/lib/dr-inputs/date-pickers/dr-date-picker-with-timeframe/dr-date-picker-with-timeframe.component.js +0 -72
  32. package/esm2015/lib/dr-inputs/date-pickers/dr-date-picker_custom-header/dr-date-picker_custom-header.component.js +0 -128
  33. package/esm2015/lib/dr-inputs/date-pickers/services/dr-date-picker.service.js +0 -55
  34. package/lib/dr-inputs/date-pickers/dr-date-picker/dr-date-picker.component.d.ts +0 -55
  35. package/lib/dr-inputs/date-pickers/dr-date-picker-with-timeframe/dr-date-picker-with-timeframe.component.d.ts +0 -26
  36. package/lib/dr-inputs/date-pickers/services/dr-date-picker.service.d.ts +0 -18
@@ -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, 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';
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';
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, skip, first, debounceTime, distinctUntilChanged, take } from 'rxjs/operators';
9
+ import { startWith, switchMap, takeUntil, filter, take, first, skip, debounceTime, distinctUntilChanged } 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 { MatDatepickerModule, MatCalendar } from '@angular/material/datepicker';
14
+ import { MatCalendar, MatDatepickerModule } 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,17 +1489,10 @@ const POPUP_ANIMATION = [
1489
1489
  class TooltipComponent {
1490
1490
  constructor() {
1491
1491
  this.isContentTemplate = false;
1492
- this.isMouseOn$ = new BehaviorSubject(false);
1493
1492
  }
1494
1493
  ngOnInit() {
1495
1494
  this.isContentTemplate = this.content instanceof TemplateRef;
1496
1495
  }
1497
- setMouseOn() {
1498
- this.isMouseOn$.next(true);
1499
- }
1500
- unsetMouseOn() {
1501
- this.isMouseOn$.next(false);
1502
- }
1503
1496
  }
1504
1497
  TooltipComponent.decorators = [
1505
1498
  { type: Component, args: [{
@@ -1517,9 +1510,7 @@ TooltipComponent.propDecorators = {
1517
1510
  contentContext: [{ type: Input }],
1518
1511
  position: [{ type: Input }],
1519
1512
  options: [{ type: Input }],
1520
- class: [{ type: Input }],
1521
- setMouseOn: [{ type: HostListener, args: ['mouseenter',] }],
1522
- unsetMouseOn: [{ type: HostListener, args: ['mouseleave',] }]
1513
+ class: [{ type: Input }]
1523
1514
  };
1524
1515
 
1525
1516
  class DrTooltipDirective {
@@ -1530,8 +1521,6 @@ class DrTooltipDirective {
1530
1521
  this.contentContext = {};
1531
1522
  this.position = 'top';
1532
1523
  this.class = '';
1533
- // is used for preserve tooltip from being hidden for N milliseconds
1534
- this.drTooltipMousleaveTimeout = 0;
1535
1524
  }
1536
1525
  set drTooltipOptions(options) {
1537
1526
  if (options === null || options === void 0 ? void 0 : options.indent) {
@@ -1564,36 +1553,16 @@ class DrTooltipDirective {
1564
1553
  if (this.overlayRef) {
1565
1554
  this.overlayRef.dispose();
1566
1555
  }
1567
- if (this.tooltipMouseOnSubscription) {
1568
- this.tooltipMouseOnSubscription.unsubscribe();
1569
- }
1570
1556
  }
1571
1557
  show() {
1572
- if (this.manualHandling || this.overlayRef)
1558
+ if (this.manualHandling)
1573
1559
  return;
1574
1560
  this.renderTooltip();
1575
1561
  }
1576
1562
  hide() {
1577
- var _a;
1578
- if (this.manualHandling || !this.tooltipRef || ((_a = this.tooltipRef) === null || _a === void 0 ? void 0 : _a.instance.isMouseOn$.getValue()))
1563
+ if (this.manualHandling)
1579
1564
  return;
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
- }
1565
+ this.destroyTooltip();
1597
1566
  }
1598
1567
  createOverlay() {
1599
1568
  const positionStrategy = this.overlayPositionBuilder
@@ -1605,17 +1574,12 @@ class DrTooltipDirective {
1605
1574
  var _a;
1606
1575
  this.createOverlay();
1607
1576
  if (!((_a = this.overlayRef) === null || _a === void 0 ? void 0 : _a.hasAttached()) && this.content) {
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
- });
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;
1619
1583
  }
1620
1584
  }
1621
1585
  destroyTooltip() {
@@ -1623,10 +1587,6 @@ class DrTooltipDirective {
1623
1587
  this.overlayRef.dispose();
1624
1588
  }
1625
1589
  this.overlayRef = null;
1626
- this.tooltipRef = null;
1627
- if (this.tooltipMouseOnSubscription) {
1628
- this.tooltipMouseOnSubscription.unsubscribe();
1629
- }
1630
1590
  }
1631
1591
  }
1632
1592
  DrTooltipDirective.decorators = [
@@ -1644,7 +1604,6 @@ DrTooltipDirective.propDecorators = {
1644
1604
  contentContext: [{ type: Input, args: ['drTooltipContext',] }],
1645
1605
  position: [{ type: Input, args: ['drTooltipPosition',] }],
1646
1606
  class: [{ type: Input, args: ['drTooltipClass',] }],
1647
- drTooltipMousleaveTimeout: [{ type: Input }],
1648
1607
  drTooltipOptions: [{ type: Input }],
1649
1608
  showTooltip: [{ type: Input, args: ['drTooltipShow',] }],
1650
1609
  show: [{ type: HostListener, args: ['mouseenter',] }],
@@ -1924,1519 +1883,1457 @@ DrButtonComponent.propDecorators = {
1924
1883
  <dr-button [isDisabled]="false" [theme]="'text-link'">Text Link</dr-button>
1925
1884
  */
1926
1885
 
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();
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
+ };
1937
1904
  }
1938
- close(res) {
1939
- this.overlayRef.detach();
1940
- this.overlayRef.dispose();
1941
- this.onClose$.next(res);
1942
- this.onClose$.complete();
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;
1916
+ }
1917
+ updateDateFormat(parse, display) {
1918
+ this.parse = parse;
1919
+ if (!display) {
1920
+ display = parse;
1921
+ }
1922
+ this.display = display;
1943
1923
  }
1944
1924
  }
1945
1925
 
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;
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
+ }
1967
1954
  }
1968
- return DrPopoverAlignmentDimension.Width;
1969
1955
  }
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
+ ];
1970
1962
 
1971
- class DrPopoverComponent {
1972
- constructor(cdr, componentFactoryResolver, viewContainerRef, elementRef, popoverRef) {
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;
1973
1969
  this.cdr = cdr;
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;
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());
1981
2019
  }
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();
1995
- }
2020
+ ngOnDestroy() {
2021
+ this._destroyed.next();
2022
+ this._destroyed.complete();
1996
2023
  }
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);
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);
2003
2030
  }
2004
- if (this.alignment === 'host') {
2005
- this[getAlignmentDimension(this.position)] = '100%';
2031
+ else {
2032
+ this.periodMonthLabel = '';
2033
+ this.periodYearLabel = fullPeriodLabel;
2006
2034
  }
2007
- this.cdr.detectChanges();
2035
+ this.cdr.markForCheck();
2036
+ }
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();
2045
+ }
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();
2008
2067
  }
2009
2068
  }
2010
- DrPopoverComponent.decorators = [
2069
+ DrDatePickerCustomHeaderComponent.decorators = [
2011
2070
  { type: Component, args: [{
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
- ],
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",
2017
2073
  changeDetection: ChangeDetectionStrategy.OnPush,
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"]
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"]
2019
2075
  },] }
2020
2076
  ];
2021
- DrPopoverComponent.ctorParameters = () => [
2077
+ DrDatePickerCustomHeaderComponent.ctorParameters = () => [
2078
+ { type: MatCalendar },
2079
+ { type: DateAdapter },
2080
+ { type: CustomDateFormat, decorators: [{ type: Inject, args: [MAT_DATE_FORMATS,] }] },
2022
2081
  { type: ChangeDetectorRef },
2023
- { type: ComponentFactoryResolver },
2024
- { type: ViewContainerRef },
2025
- { type: ElementRef },
2026
- { type: DrPopoverRef }
2082
+ { type: DrDatePickerService }
2027
2083
  ];
2028
- DrPopoverComponent.propDecorators = {
2029
- content: [{ type: Input }],
2030
- contentContext: [{ type: Input }],
2031
- class: [{ type: Input }],
2032
- hostRef: [{ type: Input }],
2033
- manualClosing: [{ type: Input }],
2034
- alignment: [{ type: Input }],
2035
- position: [{ type: Input }],
2036
- popoverContainer: [{ type: ViewChild, args: ['popoverContainer', { read: ElementRef, static: true },] }],
2037
- width: [{ type: HostBinding, args: ['style.width',] }],
2038
- height: [{ type: HostBinding, args: ['style.height',] }],
2039
- popover: [{ type: HostBinding, args: ['@popover',] }],
2040
- clickOutside: [{ type: HostListener, args: ['document:mouseup', ['$event'],] }]
2041
- };
2042
2084
 
2043
- class DrPopoverService {
2044
- constructor(overlay, overlayPositionBuilder, injector) {
2045
- this.overlay = overlay;
2046
- this.overlayPositionBuilder = overlayPositionBuilder;
2047
- this.injector = injector;
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
+ });
2048
2132
  }
2049
- open(content, popoverModel) {
2050
- if (!content)
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) {
2051
2145
  return;
2052
- const model = Object.assign(Object.assign({}, DEFAULT_MODEL), popoverModel);
2053
- const overlayRef = this.createOverlay(model);
2054
- const popoverRef = new DrPopoverRef(overlayRef);
2055
- this.attachOverlayContainer(content, model, overlayRef, popoverRef);
2056
- this.registerListeners(model, overlayRef, popoverRef);
2057
- return popoverRef;
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);
2058
2154
  }
2059
- attachOverlayContainer(content, { contentContext, position, class: elementClass, manualClosing, hostRef, alignment }, overlayRef, popoverRef) {
2060
- const componentPortal = new ComponentPortal(DrPopoverComponent, null, this.createInjector(popoverRef));
2061
- const contentRef = overlayRef.attach(componentPortal);
2062
- popoverRef.componentRef = contentRef;
2063
- contentRef.instance.content = content;
2064
- contentRef.instance.contentContext = Object.assign(Object.assign({}, contentContext), { closePopover: popoverRef.close.bind(popoverRef) });
2065
- contentRef.instance.class = elementClass + ' ' + position;
2066
- contentRef.instance.manualClosing = manualClosing;
2067
- contentRef.instance.hostRef = hostRef;
2068
- contentRef.instance.alignment = alignment;
2069
- contentRef.instance.position = position;
2155
+ tryToNormalaizeTimeframe(normalizedRef, timeframe) {
2156
+ if (this.takeEndOfPeriod) {
2157
+ normalizedRef.endOf(timeframe);
2158
+ }
2159
+ normalizedRef.set('hour', 12);
2070
2160
  }
2071
- createOverlay(popoverModel) {
2072
- const overlayConfig = this.getOverlayConfig(popoverModel);
2073
- return this.overlay.create(overlayConfig);
2161
+ get value() {
2162
+ return this.innerValue;
2074
2163
  }
2075
- getOverlayConfig(popoverModel) {
2076
- if (!POPUP_POSITIONS[popoverModel.position])
2077
- throw new Error(`DrPopover does not support the '${popoverModel === null || popoverModel === void 0 ? void 0 : popoverModel.position}' position!`);
2078
- const config = Object.assign(Object.assign({}, DEFAULT_CONFIG), popoverModel.overlayConfig || {});
2079
- const hostElement = this.getHostElement(popoverModel.hostRef);
2080
- const positionStrategy = this.overlayPositionBuilder
2081
- .flexibleConnectedTo(popoverModel.hostRef)
2082
- .withPositions([POPUP_POSITIONS[popoverModel.position]]);
2083
- const overlayConfig = new OverlayConfig(Object.assign({ scrollStrategy: this.overlay.scrollStrategies.noop(), positionStrategy }, config));
2084
- if (popoverModel.alignment === 'host' && hostElement) {
2085
- const alignmentDimension = getAlignmentDimension(popoverModel.position);
2086
- overlayConfig[alignmentDimension] = hostElement.getBoundingClientRect()[alignmentDimension];
2164
+ set value(v) {
2165
+ if (v !== this.innerValue) {
2166
+ this.innerValue = v;
2167
+ this.onChangeCallback(v);
2087
2168
  }
2088
- return overlayConfig;
2169
+ this.cdr.markForCheck();
2089
2170
  }
2090
- createInjector(popoverRef) {
2091
- const injectionTokens = [
2092
- { provide: DrPopoverRef, useValue: popoverRef },
2093
- ];
2094
- return Injector.create({ providers: injectionTokens, parent: this.injector });
2171
+ registerOnChange(fn) {
2172
+ this.onChangeCallback = fn;
2095
2173
  }
2096
- registerListeners(popoverModel, overlayRef, popoverRef) {
2097
- const config = popoverModel.overlayConfig || {};
2098
- const targetElement = popoverModel.targetElement;
2099
- const hostElement = this.getHostElement(popoverModel.hostRef);
2100
- if ((config === null || config === void 0 ? void 0 : config.closeOnBackdropClick) && (config === null || config === void 0 ? void 0 : config.hasBackdrop)) {
2101
- overlayRef.backdropClick().subscribe(() => popoverRef.close());
2102
- }
2103
- if (targetElement) {
2104
- targetElement.addEventListener('mouseup', () => popoverRef.close(), { once: true });
2105
- }
2106
- if (popoverModel.alignment === 'host' && hostElement) {
2107
- const alignmentDimension = getAlignmentDimension(popoverModel.position);
2108
- const resizeObserver = new ResizeObserver(entries => {
2109
- entries.forEach(host => overlayRef.updateSize({ [alignmentDimension]: host.target.getBoundingClientRect()[alignmentDimension] }));
2110
- });
2111
- resizeObserver.observe(hostElement);
2112
- popoverRef.onClose.pipe(first()).subscribe(() => resizeObserver.unobserve(hostElement));
2113
- }
2174
+ registerOnTouched(fn) {
2175
+ this.onTouchedCallback = fn;
2114
2176
  }
2115
- getHostElement(hostRef) {
2116
- if (!hostRef || hostRef.x)
2117
- return null;
2118
- if (hostRef.nativeElement)
2119
- return hostRef.nativeElement;
2120
- return hostRef;
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
+ }
2121
2188
  }
2122
- }
2123
- DrPopoverService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DrPopoverService_Factory() { return new DrPopoverService(i0.ɵɵinject(i1.Overlay), i0.ɵɵinject(i1.OverlayPositionBuilder), i0.ɵɵinject(i0.INJECTOR)); }, token: DrPopoverService, providedIn: "root" });
2124
- DrPopoverService.decorators = [
2125
- { type: Injectable, args: [{
2126
- providedIn: 'root',
2127
- },] }
2128
- ];
2129
- DrPopoverService.ctorParameters = () => [
2130
- { type: Overlay },
2131
- { type: OverlayPositionBuilder },
2132
- { type: Injector }
2133
- ];
2134
-
2135
- class DrPopoverDirective {
2136
- constructor(elementRef, drPopoverService) {
2137
- this.elementRef = elementRef;
2138
- this.drPopoverService = drPopoverService;
2139
- this.contentContext = {};
2140
- this.position = 'bottom';
2141
- this.class = '';
2142
- this.overlayConfig = {};
2143
- this.manualClosing = { enabled: false };
2144
- this.popoverClose = new EventEmitter();
2145
- this.showStateChange = new EventEmitter();
2189
+ get quarterDisplay() {
2190
+ return this.datePickerService.getQuarterDisplay(this.value, this._format);
2146
2191
  }
2147
- togglePopover() {
2148
- if (this.popoverRef) {
2149
- this.closePopover();
2192
+ normalizeValue(value) {
2193
+ if (value.includes('d')) {
2194
+ value = value.replace(/d/g, 'D');
2150
2195
  }
2151
- else {
2152
- this.renderPopover();
2153
- this.showStateChange.emit({ isShown: !!this.popoverRef });
2196
+ else if (value.includes('D')) {
2197
+ value = value.replace(/D/g, 'd');
2154
2198
  }
2199
+ return value;
2155
2200
  }
2156
- closePopover(res) {
2157
- if (this.popoverRef) {
2158
- this.popoverRef.close(res);
2159
- this.popoverRef = null;
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();
2160
2207
  }
2161
2208
  }
2162
- renderPopover() {
2163
- const popoverRef = this.popoverRef = this.drPopoverService.open(this.content, {
2164
- hostRef: this.elementRef,
2165
- overlayConfig: this.overlayConfig,
2166
- class: this.class,
2167
- manualClosing: this.manualClosing,
2168
- position: this.position,
2169
- contentContext: this.contentContext,
2170
- alignment: this.alignment,
2171
- });
2172
- popoverRef.onClose.pipe(first()).subscribe((res) => {
2173
- this.closePopover();
2174
- this.popoverClose.emit(res);
2175
- this.showStateChange.emit({ isShown: !!this.popoverRef });
2176
- });
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);
2177
2225
  }
2178
2226
  ngOnDestroy() {
2179
- this.closePopover();
2227
+ this._destroyed.next();
2228
+ this._destroyed.complete();
2180
2229
  }
2181
2230
  }
2182
- DrPopoverDirective.decorators = [
2183
- { type: Directive, args: [{
2184
- selector: '[drPopover]'
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"]
2185
2240
  },] }
2186
2241
  ];
2187
- DrPopoverDirective.ctorParameters = () => [
2188
- { type: ElementRef },
2189
- { type: DrPopoverService }
2242
+ DrDatePickerComponent.ctorParameters = () => [
2243
+ { type: ChangeDetectorRef },
2244
+ { type: DateAdapter },
2245
+ { type: DrDatePickerService }
2190
2246
  ];
2191
- DrPopoverDirective.propDecorators = {
2192
- content: [{ type: Input, args: ['drPopover',] }],
2193
- contentContext: [{ type: Input, args: ['drPopoverContext',] }],
2194
- position: [{ type: Input, args: ['drPopoverPosition',] }],
2195
- class: [{ type: Input, args: ['drPopoverClass',] }],
2196
- overlayConfig: [{ type: Input, args: ['drPopoverOverlayConfig',] }],
2197
- manualClosing: [{ type: Input, args: ['drPopoverManualClosing',] }],
2198
- alignment: [{ type: Input, args: ['drPopoverAlignment',] }],
2199
- popoverClose: [{ type: Output, args: ['drPopoverClose',] }],
2200
- showStateChange: [{ type: Output, args: ['drPopoverShowStateChange',] }],
2201
- togglePopover: [{ type: HostListener, args: ['click',] }]
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',] }]
2202
2257
  };
2203
2258
 
2204
- class DrDropdownService {
2205
- constructor() {
2206
- this.actionItem = new Subject();
2207
- }
2208
- set addMenu(item) {
2209
- this.menuInView = item;
2259
+ class DrDatePickerFormatDirective {
2260
+ constructor(matDateFormat, ngControl) {
2261
+ this.matDateFormat = matDateFormat;
2262
+ this.ngControl = ngControl;
2210
2263
  }
2211
- destroy() {
2212
- if (this.menuInView) {
2213
- this.menuInView.destroy();
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 });
2214
2271
  }
2272
+ const value = this.ngControl.value;
2273
+ (_a = this.ngControl.valueAccessor) === null || _a === void 0 ? void 0 : _a.writeValue(value);
2215
2274
  }
2216
2275
  }
2217
- DrDropdownService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DrDropdownService_Factory() { return new DrDropdownService(); }, token: DrDropdownService, providedIn: "root" });
2218
- DrDropdownService.decorators = [
2219
- { type: Injectable, args: [{
2220
- providedIn: 'root'
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
+ ]
2221
2289
  },] }
2222
2290
  ];
2223
- DrDropdownService.ctorParameters = () => [];
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
+ };
2224
2300
 
2225
- class DrDropdownComponent {
2226
- constructor(menuService, cdr) {
2227
- this.menuService = menuService;
2228
- this.cdr = cdr;
2229
- this.position = 'left';
2230
- }
2231
- set options(data) {
2232
- if (data) {
2233
- this.option = data.option;
2234
- this.position = data.position;
2235
- this.drDropdownInHover = data.drDropdownInHover;
2236
- this.containerClass = data.class;
2237
- this.list = data.list || [];
2238
- this.list.forEach(item => {
2239
- var _a, _b;
2240
- if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
2241
- item.childOptions = {
2242
- list: item.children,
2243
- class: ((_b = item === null || item === void 0 ? void 0 : item.childOptions) === null || _b === void 0 ? void 0 : _b.class) || '',
2244
- position: 'child'
2245
- };
2246
- }
2247
- });
2248
- this.cdr.markForCheck();
2249
- }
2250
- }
2251
- onMouseLeave() {
2252
- if (this.drDropdownInHover)
2253
- this.menuService.destroy();
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();
2254
2311
  }
2255
- onClickedOutside() {
2256
- if (this.firstInit) {
2257
- this.menuService.destroy();
2258
- }
2259
- else {
2260
- this.firstInit = true;
2261
- }
2312
+ close(res) {
2313
+ this.overlayRef.detach();
2314
+ this.overlayRef.dispose();
2315
+ this.onClose$.next(res);
2316
+ this.onClose$.complete();
2262
2317
  }
2263
- hide() {
2264
- this.menuService.destroy();
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;
2265
2341
  }
2266
- disabled(act) {
2267
- if (!act.disabled) {
2268
- return false;
2269
- }
2270
- if (typeof act.disabled === 'boolean') {
2271
- return act.disabled;
2272
- }
2273
- else {
2274
- return act.disabled(act.data);
2275
- }
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;
2276
2355
  }
2277
- selected(act) {
2278
- if (!act.selected) {
2279
- return false;
2280
- }
2281
- if (typeof act.selected === 'boolean') {
2282
- return act.selected;
2283
- }
2284
- else {
2285
- return act.selected(act.data);
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();
2286
2369
  }
2287
2370
  }
2288
- tooltipToShow(act) {
2289
- if (act.toolTipIfDisabled && !this.disabled(act))
2290
- return '';
2291
- return act.toolTip;
2292
- }
2293
- tooltipPosition(widthMoreRight) {
2294
- return widthMoreRight ? 'right' : 'left';
2295
- }
2296
- action(act) {
2297
- if (!this.disabled(act)) {
2298
- if (act.action) {
2299
- act.action(act.data);
2300
- }
2301
- else {
2302
- this.menuService.actionItem.next({ event: act.event || act.title || 'default', data: act.data });
2303
- }
2304
- this.hide();
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);
2305
2377
  }
2306
- }
2307
- onActionIconClick($event, actionIcon, data) {
2308
- $event.stopPropagation();
2309
- if (!this.disabled(actionIcon)) {
2310
- actionIcon.action(data);
2311
- this.hide();
2378
+ if (this.alignment === 'host') {
2379
+ this[getAlignmentDimension(this.position)] = '100%';
2312
2380
  }
2381
+ this.cdr.detectChanges();
2313
2382
  }
2314
2383
  }
2315
- DrDropdownComponent.decorators = [
2384
+ DrPopoverComponent.decorators = [
2316
2385
  { type: Component, args: [{
2317
- selector: 'dr-dropdown',
2318
- template: "<div #menuContainer\n (mouseleave)=\"onMouseLeave()\"\n (clickOutside)=\"onClickedOutside()\"\n [drDropdownPosition]=\"option\"\n #dropdownPosition=\"dropdownPosition\"\n [position]=\"position\"\n [class]=\"containerClass\"\n class=\"dr-dropdown\">\n <div class=\"dr-dropdown__container\">\n <div *ngFor=\"let act of list | drDropdownItemShowPipe\"\n (click)=\"action(act)\"\n [drTooltip]=\"tooltipToShow(act)\"\n [drTooltipPosition]=\"tooltipPosition(dropdownPosition.widthMoreRight)\"\n [drTooltipOptions]=\"{ withoutArrow: true }\"\n [drTooltipClass]=\"'dr-dropdown__tooltip'\"\n class=\"dr-dropdown__container__item\"\n [class.item-disabled]=\"disabled(act)\"\n [class.item-selected]=\"selected(act)\">\n <i *ngIf=\"act.icon\" [class]=\"act.icon\"></i>\n <span class=\"dr-dropdown__container__item__text\">{{act.title}}</span>\n <i *ngFor=\"let actionIcon of act.actionIcons\"\n [class]=\"actionIcon.icon\"\n [class.showOnHover]=\"actionIcon.showOnHover\"\n (click)=\"onActionIconClick($event, actionIcon, act.data)\"></i>\n <i *ngIf=\"act.children?.length\" class=\"dr-icon-arrow-right\"></i>\n <dr-dropdown *ngIf=\"act.children?.length\" [options]=\"act.childOptions\"></dr-dropdown>\n </div>\n </div>\n</div>\n",
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
+ ],
2319
2391
  changeDetection: ChangeDetectionStrategy.OnPush,
2320
- styles: ["::ng-deep .dr-dropdown__container__item .dr-dropdown{visibility:hidden;transition-delay:.2s}::ng-deep .dr-dropdown__container__item:hover>*>.dr-dropdown{visibility:visible;transition-delay:0s}::ng-deep .dr-dropdown__tooltip>.default-content{max-width:300px;white-space:normal!important}.dr-dropdown{position:absolute;z-index:-1;top:0;left:0;width:auto}.dr-dropdown__container{display:flex;flex-direction:column;background:#fff;border-radius:4px;box-shadow:0 4px 8px 1px #00000040;padding:8px 0;overflow-y:auto;max-height:60vh}.dr-dropdown__container__item{display:flex;align-items:center;justify-content:flex-start;cursor:pointer;min-width:15rem;font-style:normal;font-weight:400;font-size:14px;line-height:24px;clear:both;width:100%;white-space:nowrap;padding:0 12px;height:36px;flex-shrink:0}.dr-dropdown__container__item:hover{background-color:#f9faff}.dr-dropdown__container__item:hover .showOnHover{visibility:visible}.dr-dropdown__container__item.item-selected{background:#F3F7FF}.dr-dropdown__container__item.item-disabled,.dr-dropdown__container__item.item-disabled i,.dr-dropdown__container__item.item-disabled .dr-dropdown__container__item__text{color:#bcbcbc}.dr-dropdown__container__item i:first-child{margin-right:8px}.dr-dropdown__container__item__text{margin-right:auto;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.dr-dropdown__container__item i,.dr-dropdown__container__item__text{color:#151b3f}.dr-dropdown__container__item i{color:#4e566c}.dr-dropdown__container__item i:hover{color:#4646ce}.dr-dropdown__container__item .showOnHover{visibility:hidden}.dr-dropdown.content-top{transform:translate(-50%,-100%)}.dr-dropdown.content-top-left{transform:translate(-100%,-100%)}.dr-dropdown.content-bottom{transform:translate(-50%,50%)}.dr-dropdown.content-bottom-left{transform:translate(-90%,35%)}.dr-dropdown.content-bottom-right{transform:translateY(15%)}.dr-dropdown.content-left{transform:translate(-100%)}.dr-dropdown.content-left-center{transform:translate(-100%,-50%)}.dr-dropdown.content-right{transform:translate(5%)}\n"]
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"]
2321
2393
  },] }
2322
2394
  ];
2323
- DrDropdownComponent.ctorParameters = () => [
2324
- { type: DrDropdownService },
2325
- { type: ChangeDetectorRef }
2395
+ DrPopoverComponent.ctorParameters = () => [
2396
+ { type: ChangeDetectorRef },
2397
+ { type: ComponentFactoryResolver },
2398
+ { type: ViewContainerRef },
2399
+ { type: ElementRef },
2400
+ { type: DrPopoverRef }
2326
2401
  ];
2327
- DrDropdownComponent.propDecorators = {
2328
- viewMenu: [{ type: ViewChild, args: ['listMenu',] }],
2329
- menuContainer: [{ type: ViewChild, args: ['menuContainer',] }],
2330
- options: [{ type: Input }]
2402
+ DrPopoverComponent.propDecorators = {
2403
+ content: [{ type: Input }],
2404
+ contentContext: [{ type: Input }],
2405
+ class: [{ type: Input }],
2406
+ hostRef: [{ type: Input }],
2407
+ manualClosing: [{ type: Input }],
2408
+ alignment: [{ type: Input }],
2409
+ position: [{ type: Input }],
2410
+ popoverContainer: [{ type: ViewChild, args: ['popoverContainer', { read: ElementRef, static: true },] }],
2411
+ width: [{ type: HostBinding, args: ['style.width',] }],
2412
+ height: [{ type: HostBinding, args: ['style.height',] }],
2413
+ popover: [{ type: HostBinding, args: ['@popover',] }],
2414
+ clickOutside: [{ type: HostListener, args: ['document:mouseup', ['$event'],] }]
2331
2415
  };
2332
2416
 
2333
- class DrDropdownDirective {
2334
- constructor(componentFactoryResolver, viewContainerRef, service, el, _document) {
2335
- this.componentFactoryResolver = componentFactoryResolver;
2336
- this.viewContainerRef = viewContainerRef;
2337
- this.service = service;
2338
- this.el = el;
2339
- this._document = _document;
2340
- this.position = 'left';
2417
+ class DrPopoverService {
2418
+ constructor(overlay, overlayPositionBuilder, injector) {
2419
+ this.overlay = overlay;
2420
+ this.overlayPositionBuilder = overlayPositionBuilder;
2421
+ this.injector = injector;
2341
2422
  }
2342
- elementHover() {
2343
- if (!this.drDropdownInHover)
2423
+ open(content, popoverModel) {
2424
+ if (!content)
2344
2425
  return;
2345
- this.openDropdown();
2426
+ const model = Object.assign(Object.assign({}, DEFAULT_MODEL), popoverModel);
2427
+ const overlayRef = this.createOverlay(model);
2428
+ const popoverRef = new DrPopoverRef(overlayRef);
2429
+ this.attachOverlayContainer(content, model, overlayRef, popoverRef);
2430
+ this.registerListeners(model, overlayRef, popoverRef);
2431
+ return popoverRef;
2346
2432
  }
2347
- elementClick() {
2348
- this.openDropdown();
2433
+ attachOverlayContainer(content, { contentContext, position, class: elementClass, manualClosing, hostRef, alignment }, overlayRef, popoverRef) {
2434
+ const componentPortal = new ComponentPortal(DrPopoverComponent, null, this.createInjector(popoverRef));
2435
+ const contentRef = overlayRef.attach(componentPortal);
2436
+ popoverRef.componentRef = contentRef;
2437
+ contentRef.instance.content = content;
2438
+ contentRef.instance.contentContext = Object.assign(Object.assign({}, contentContext), { closePopover: popoverRef.close.bind(popoverRef) });
2439
+ contentRef.instance.class = elementClass + ' ' + position;
2440
+ contentRef.instance.manualClosing = manualClosing;
2441
+ contentRef.instance.hostRef = hostRef;
2442
+ contentRef.instance.alignment = alignment;
2443
+ contentRef.instance.position = position;
2349
2444
  }
2350
- documentClick(e) {
2351
- this.closeDropdown(e);
2445
+ createOverlay(popoverModel) {
2446
+ const overlayConfig = this.getOverlayConfig(popoverModel);
2447
+ return this.overlay.create(overlayConfig);
2352
2448
  }
2353
- openDropdown() {
2354
- const option = this.el.nativeElement.getBoundingClientRect();
2355
- this._document.querySelectorAll('dr-dropdown').forEach(item => item.remove());
2356
- if (this.contentCmpRef && this.contentCmpRef.destroyCbs) {
2357
- this.contentCmpRef.destroy();
2358
- this.contentCmpRef = null;
2359
- }
2360
- else {
2361
- this.service.destroy();
2362
- this.showMenu({
2363
- option,
2364
- drDropdownInHover: this.drDropdownInHover,
2365
- position: this.position,
2366
- list: this.drDropdown,
2367
- class: this.drDropdownClass
2368
- });
2449
+ getOverlayConfig(popoverModel) {
2450
+ if (!POPUP_POSITIONS[popoverModel.position])
2451
+ throw new Error(`DrPopover does not support the '${popoverModel === null || popoverModel === void 0 ? void 0 : popoverModel.position}' position!`);
2452
+ const config = Object.assign(Object.assign({}, DEFAULT_CONFIG), popoverModel.overlayConfig || {});
2453
+ const hostElement = this.getHostElement(popoverModel.hostRef);
2454
+ const positionStrategy = this.overlayPositionBuilder
2455
+ .flexibleConnectedTo(popoverModel.hostRef)
2456
+ .withPositions([POPUP_POSITIONS[popoverModel.position]]);
2457
+ const overlayConfig = new OverlayConfig(Object.assign({ scrollStrategy: this.overlay.scrollStrategies.noop(), positionStrategy }, config));
2458
+ if (popoverModel.alignment === 'host' && hostElement) {
2459
+ const alignmentDimension = getAlignmentDimension(popoverModel.position);
2460
+ overlayConfig[alignmentDimension] = hostElement.getBoundingClientRect()[alignmentDimension];
2369
2461
  }
2462
+ return overlayConfig;
2370
2463
  }
2371
- closeDropdown(e) {
2372
- const menuItem = e.target.classList;
2373
- if (menuItem.contains('dr-dropdown__container__item') || menuItem.contains('dr-dropdown__container__item__text')) {
2374
- return;
2464
+ createInjector(popoverRef) {
2465
+ const injectionTokens = [
2466
+ { provide: DrPopoverRef, useValue: popoverRef },
2467
+ ];
2468
+ return Injector.create({ providers: injectionTokens, parent: this.injector });
2469
+ }
2470
+ registerListeners(popoverModel, overlayRef, popoverRef) {
2471
+ const config = popoverModel.overlayConfig || {};
2472
+ const targetElement = popoverModel.targetElement;
2473
+ const hostElement = this.getHostElement(popoverModel.hostRef);
2474
+ if ((config === null || config === void 0 ? void 0 : config.closeOnBackdropClick) && (config === null || config === void 0 ? void 0 : config.hasBackdrop)) {
2475
+ overlayRef.backdropClick().subscribe(() => popoverRef.close());
2375
2476
  }
2376
- const elems = this._document.querySelectorAll('dr-dropdown');
2377
- if (!e.target.contains(this.el.nativeElement) && this.contentCmpRef || elems.length && !e.target.contains(this.el.nativeElement)) {
2378
- setTimeout(() => elems.forEach(item => item.remove()), 100);
2477
+ if (targetElement) {
2478
+ targetElement.addEventListener('mouseup', () => popoverRef.close(), { once: true });
2379
2479
  }
2380
- }
2381
- showMenu(options) {
2382
- let componentFactory;
2383
- componentFactory = this.componentFactoryResolver.resolveComponentFactory(DrDropdownComponent);
2384
- this.contentCmpRef = this.viewContainerRef.createComponent(componentFactory);
2385
- this.service.addMenu = this.contentCmpRef;
2386
- this._document.querySelector('nb-layout').appendChild(this.contentCmpRef.location.nativeElement);
2387
- this.contentCmpRef.instance.options = options;
2388
- }
2389
- ngOnDestroy() {
2390
- if (this.contentCmpRef) {
2391
- this.contentCmpRef.destroy();
2480
+ if (popoverModel.alignment === 'host' && hostElement) {
2481
+ const alignmentDimension = getAlignmentDimension(popoverModel.position);
2482
+ const resizeObserver = new ResizeObserver(entries => {
2483
+ entries.forEach(host => overlayRef.updateSize({ [alignmentDimension]: host.target.getBoundingClientRect()[alignmentDimension] }));
2484
+ });
2485
+ resizeObserver.observe(hostElement);
2486
+ popoverRef.onClose.pipe(first()).subscribe(() => resizeObserver.unobserve(hostElement));
2392
2487
  }
2393
2488
  }
2489
+ getHostElement(hostRef) {
2490
+ if (!hostRef || hostRef.x)
2491
+ return null;
2492
+ if (hostRef.nativeElement)
2493
+ return hostRef.nativeElement;
2494
+ return hostRef;
2495
+ }
2394
2496
  }
2395
- DrDropdownDirective.decorators = [
2396
- { type: Directive, args: [{
2397
- selector: '[drDropdown]'
2497
+ DrPopoverService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DrPopoverService_Factory() { return new DrPopoverService(i0.ɵɵinject(i1.Overlay), i0.ɵɵinject(i1.OverlayPositionBuilder), i0.ɵɵinject(i0.INJECTOR)); }, token: DrPopoverService, providedIn: "root" });
2498
+ DrPopoverService.decorators = [
2499
+ { type: Injectable, args: [{
2500
+ providedIn: 'root',
2398
2501
  },] }
2399
2502
  ];
2400
- DrDropdownDirective.ctorParameters = () => [
2401
- { type: ComponentFactoryResolver },
2402
- { type: ViewContainerRef },
2403
- { type: DrDropdownService },
2404
- { type: ElementRef },
2405
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
2503
+ DrPopoverService.ctorParameters = () => [
2504
+ { type: Overlay },
2505
+ { type: OverlayPositionBuilder },
2506
+ { type: Injector }
2406
2507
  ];
2407
- DrDropdownDirective.propDecorators = {
2408
- position: [{ type: Input }],
2409
- drDropdown: [{ type: Input }],
2410
- drDropdownClass: [{ type: Input }],
2411
- drDropdownInHover: [{ type: Input }],
2412
- contentCmpRef: [{ type: ViewChild, args: [DrDropdownComponent, { static: true, read: ViewContainerRef },] }],
2413
- elementHover: [{ type: HostListener, args: ['mouseenter',] }],
2414
- elementClick: [{ type: HostListener, args: ['click',] }],
2415
- documentClick: [{ type: HostListener, args: ['document:mouseup', ['$event'],] }]
2416
- };
2417
2508
 
2418
- class DrDropdownPositionDirective {
2419
- constructor(el, renderer) {
2420
- this.el = el;
2421
- this.renderer = renderer;
2422
- this.position = 'left';
2423
- }
2424
- ngOnInit() {
2425
- setTimeout(this.calculatePosition.bind(this), 1);
2509
+ class DrPopoverDirective {
2510
+ constructor(elementRef, drPopoverService) {
2511
+ this.elementRef = elementRef;
2512
+ this.drPopoverService = drPopoverService;
2513
+ this.contentContext = {};
2514
+ this.position = 'bottom';
2515
+ this.class = '';
2516
+ this.overlayConfig = {};
2517
+ this.manualClosing = { enabled: false };
2518
+ this.popoverClose = new EventEmitter();
2519
+ this.showStateChange = new EventEmitter();
2426
2520
  }
2427
- calculatePosition() {
2428
- let xDifference = 0;
2429
- let defaultDelta = 10;
2430
- let defaultPadding = 0;
2431
- let originalPosition = this.position;
2432
- if (this.position === 'child') {
2433
- defaultDelta = 0;
2434
- defaultPadding = 10;
2435
- xDifference = this.el.nativeElement.parentElement.parentElement.offsetWidth - this.el.nativeElement.offsetWidth;
2436
- const parentRect = this.el.nativeElement.parentElement.parentElement.getBoundingClientRect();
2437
- this.position = {
2438
- x: this.el.nativeElement.offsetWidth,
2439
- y: this.el.nativeElement.parentElement.parentElement.offsetTop - 9,
2440
- clientX: parentRect.x + this.el.nativeElement.parentElement.parentElement.offsetWidth,
2441
- clientY: parentRect.y
2442
- };
2443
- }
2444
- if (typeof this.position === 'string') {
2445
- this.renderer.setStyle(this.el.nativeElement, 'top', this.position === 'bottom' ?
2446
- this.drDropdownPosition.y - this.drDropdownPosition.height + 'px' :
2447
- this.drDropdownPosition.y + 'px');
2448
- this.renderer.setStyle(this.el.nativeElement, 'left', this.position === 'right' ?
2449
- this.drDropdownPosition.x + this.drDropdownPosition.width + 'px' :
2450
- this.drDropdownPosition.x + 'px');
2451
- const menuHeight = this.el.nativeElement.offsetHeight;
2452
- const heightMoreWindowBottom = menuHeight + this.drDropdownPosition.y > window.innerHeight;
2453
- const heightMoreWindowTop = menuHeight - this.drDropdownPosition.y + this.drDropdownPosition.height / 2 > 48; // header height;
2454
- const widthMoreWindowRight = this.drDropdownPosition.x + 250 > window.innerWidth;
2455
- const spaceBetweenElAndRightBorder = window.innerWidth - (this.drDropdownPosition.x + this.el.nativeElement.offsetWidth);
2456
- this.widthMoreRight = this.drDropdownPosition.x < spaceBetweenElAndRightBorder;
2457
- if (heightMoreWindowBottom) {
2458
- this.position = 'top';
2459
- }
2460
- if (heightMoreWindowBottom && widthMoreWindowRight && !heightMoreWindowTop || this.position === 'top-left') {
2461
- this.position = 'top-left';
2462
- this.renderer.setStyle(this.el.nativeElement, 'transform', 'translate(-100%, calc(-100% + ' + this.drDropdownPosition.height + 'px))');
2463
- }
2464
- if (heightMoreWindowTop && heightMoreWindowBottom) {
2465
- this.position = 'left-center';
2466
- }
2467
- if (this.position === 'bottom-left') {
2468
- this.renderer.setStyle(this.el.nativeElement, 'transform', `translate(calc(-100% + ${this.drDropdownPosition.width}px), ${this.drDropdownPosition.height + 8}px)`);
2469
- }
2470
- const className = this.position === 'top' ? 'content-top'
2471
- : this.position === 'top-left' ? 'content-top-left'
2472
- : this.position === 'bottom' ? 'content-bottom'
2473
- : this.position === 'bottom-left' ? 'content-bottom-left'
2474
- : this.position === 'left' ? 'content-left'
2475
- : this.position === 'left-center' ? 'content-left-center'
2476
- : this.position === 'right' ? 'content-right'
2477
- : this.position === 'bottom-right' ? 'content-bottom-right' : '';
2478
- this.renderer.addClass(this.el.nativeElement, className);
2479
- this.renderer.setStyle(this.el.nativeElement, 'z-index', '10010');
2521
+ togglePopover() {
2522
+ if (this.popoverRef) {
2523
+ this.closePopover();
2480
2524
  }
2481
2525
  else {
2482
- const defaultChildPadding = 3;
2483
- const widthMoreWindowRight = originalPosition !== 'child'
2484
- ? window.innerWidth - (this.position.clientX - this.el.nativeElement.offsetWidth - defaultPadding)
2485
- : window.innerWidth - this.position.clientX - this.el.nativeElement.offsetWidth - defaultPadding;
2486
- const widthMoreWindowBottom = originalPosition !== 'child'
2487
- ? window.innerHeight - (this.position.clientY - this.el.nativeElement.offsetHeight - defaultPadding)
2488
- : window.innerHeight - this.position.clientY - this.el.nativeElement.offsetHeight - defaultPadding;
2489
- const spaceRightAmount = window.innerWidth - (this.position.clientX + this.el.nativeElement.offsetWidth + defaultPadding);
2490
- this.widthMoreRight = !(widthMoreWindowRight < 0);
2491
- let calculatedHorizantallyPos = widthMoreWindowRight < 0
2492
- ? -this.position.x + -defaultChildPadding
2493
- : this.position.x + defaultChildPadding + xDifference;
2494
- if (spaceRightAmount <= 0 && originalPosition !== 'child') {
2495
- calculatedHorizantallyPos -= this.el.nativeElement.offsetWidth;
2496
- }
2497
- const deltaHeight = widthMoreWindowBottom < 0 ? widthMoreWindowBottom : defaultDelta;
2498
- this.renderer.setStyle(this.el.nativeElement, 'top', (this.position.y + deltaHeight) + 'px');
2499
- this.renderer.setStyle(this.el.nativeElement, 'left', (calculatedHorizantallyPos) + 'px');
2500
- this.renderer.setStyle(this.el.nativeElement, 'z-index', '10010');
2526
+ this.renderPopover();
2527
+ this.showStateChange.emit({ isShown: !!this.popoverRef });
2528
+ }
2529
+ }
2530
+ closePopover(res) {
2531
+ if (this.popoverRef) {
2532
+ this.popoverRef.close(res);
2533
+ this.popoverRef = null;
2501
2534
  }
2502
2535
  }
2536
+ renderPopover() {
2537
+ const popoverRef = this.popoverRef = this.drPopoverService.open(this.content, {
2538
+ hostRef: this.elementRef,
2539
+ overlayConfig: this.overlayConfig,
2540
+ class: this.class,
2541
+ manualClosing: this.manualClosing,
2542
+ position: this.position,
2543
+ contentContext: this.contentContext,
2544
+ alignment: this.alignment,
2545
+ });
2546
+ popoverRef.onClose.pipe(first()).subscribe((res) => {
2547
+ this.closePopover();
2548
+ this.popoverClose.emit(res);
2549
+ this.showStateChange.emit({ isShown: !!this.popoverRef });
2550
+ });
2551
+ }
2552
+ ngOnDestroy() {
2553
+ this.closePopover();
2554
+ }
2503
2555
  }
2504
- DrDropdownPositionDirective.decorators = [
2556
+ DrPopoverDirective.decorators = [
2505
2557
  { type: Directive, args: [{
2506
- selector: '[drDropdownPosition]',
2507
- exportAs: 'dropdownPosition'
2558
+ selector: '[drPopover]'
2508
2559
  },] }
2509
2560
  ];
2510
- DrDropdownPositionDirective.ctorParameters = () => [
2561
+ DrPopoverDirective.ctorParameters = () => [
2511
2562
  { type: ElementRef },
2512
- { type: Renderer2 }
2563
+ { type: DrPopoverService }
2513
2564
  ];
2514
- DrDropdownPositionDirective.propDecorators = {
2515
- drDropdownPosition: [{ type: Input }],
2516
- position: [{ type: Input }]
2565
+ DrPopoverDirective.propDecorators = {
2566
+ content: [{ type: Input, args: ['drPopover',] }],
2567
+ contentContext: [{ type: Input, args: ['drPopoverContext',] }],
2568
+ position: [{ type: Input, args: ['drPopoverPosition',] }],
2569
+ class: [{ type: Input, args: ['drPopoverClass',] }],
2570
+ overlayConfig: [{ type: Input, args: ['drPopoverOverlayConfig',] }],
2571
+ manualClosing: [{ type: Input, args: ['drPopoverManualClosing',] }],
2572
+ alignment: [{ type: Input, args: ['drPopoverAlignment',] }],
2573
+ popoverClose: [{ type: Output, args: ['drPopoverClose',] }],
2574
+ showStateChange: [{ type: Output, args: ['drPopoverShowStateChange',] }],
2575
+ togglePopover: [{ type: HostListener, args: ['click',] }]
2517
2576
  };
2518
2577
 
2519
- class DrDropdownItemShowPipe {
2520
- transform(arr) {
2521
- return arr.filter(item => item.show ? item.show(item.data) : true);
2578
+ class DrDropdownService {
2579
+ constructor() {
2580
+ this.actionItem = new Subject();
2522
2581
  }
2523
- }
2524
- DrDropdownItemShowPipe.decorators = [
2525
- { type: Pipe, args: [{
2526
- name: 'drDropdownItemShowPipe'
2527
- },] }
2528
- ];
2529
-
2530
- class DrTabComponent {
2531
- constructor() { }
2532
- ngOnInit() {
2582
+ set addMenu(item) {
2583
+ this.menuInView = item;
2584
+ }
2585
+ destroy() {
2586
+ if (this.menuInView) {
2587
+ this.menuInView.destroy();
2588
+ }
2533
2589
  }
2534
2590
  }
2535
- DrTabComponent.decorators = [
2536
- { type: Component, args: [{
2537
- selector: 'dr-tab',
2538
- template: `
2539
- <ng-template>
2540
- <ng-content></ng-content>
2541
- </ng-template>
2542
- `
2591
+ DrDropdownService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DrDropdownService_Factory() { return new DrDropdownService(); }, token: DrDropdownService, providedIn: "root" });
2592
+ DrDropdownService.decorators = [
2593
+ { type: Injectable, args: [{
2594
+ providedIn: 'root'
2543
2595
  },] }
2544
2596
  ];
2545
- DrTabComponent.ctorParameters = () => [];
2546
- DrTabComponent.propDecorators = {
2547
- label: [{ type: Input }],
2548
- disabled: [{ type: Input }],
2549
- contentTemplate: [{ type: ViewChild, args: [TemplateRef,] }]
2550
- };
2597
+ DrDropdownService.ctorParameters = () => [];
2551
2598
 
2552
- class DrTabsComponent {
2553
- constructor() {
2554
- this.selectedTab = 0;
2555
- this.selectedTabChange = new EventEmitter();
2599
+ class DrDropdownComponent {
2600
+ constructor(menuService, cdr) {
2601
+ this.menuService = menuService;
2602
+ this.cdr = cdr;
2603
+ this.position = 'left';
2556
2604
  }
2557
- selectedIndexChange($event) {
2558
- this.selectedTab = $event;
2559
- this.selectedTabChange.emit($event);
2605
+ set options(data) {
2606
+ if (data) {
2607
+ this.option = data.option;
2608
+ this.position = data.position;
2609
+ this.drDropdownInHover = data.drDropdownInHover;
2610
+ this.containerClass = data.class;
2611
+ this.list = data.list || [];
2612
+ this.list.forEach(item => {
2613
+ var _a, _b;
2614
+ if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
2615
+ item.childOptions = {
2616
+ list: item.children,
2617
+ class: ((_b = item === null || item === void 0 ? void 0 : item.childOptions) === null || _b === void 0 ? void 0 : _b.class) || '',
2618
+ position: 'child'
2619
+ };
2620
+ }
2621
+ });
2622
+ this.cdr.markForCheck();
2623
+ }
2560
2624
  }
2561
- }
2562
- DrTabsComponent.decorators = [
2563
- { type: Component, args: [{
2564
- selector: 'dr-tabs',
2565
- template: "<mat-tab-group disableRipple [selectedIndex]=\"selectedTab\"\n (selectedIndexChange)=\"selectedIndexChange($event)\"\n [class.with-radio]=\"withRadio\"\n [class.vertical]=\"vertical\"\n [animationDuration]=\" vertical ? '0ms' : '500ms'\">\n <mat-tab *ngFor=\"let tab of tabsContentList; let index = index\" label=\"{{tab.label}}\" [disabled]=\"tab.disabled\" >\n <ng-container *ngIf=\"withRadio\">\n <ng-template mat-tab-label>\n <dr-radio-button [value]=\"index\"\n [(ngModel)]=\"selectedTab\">\n </dr-radio-button>\n {{tab.label}}\n </ng-template>\n </ng-container>\n\n <ng-container *ngTemplateOutlet=\"tab.contentTemplate\" ></ng-container>\n </mat-tab>\n</mat-tab-group>\n",
2566
- styles: [":host{width:100%}:host ::ng-deep .mat-tab-group,:host ::ng-deep .mat-tab-body-wrapper{height:100%}:host ::ng-deep .mat-tab-nav-bar,:host ::ng-deep .mat-tab-header{border-bottom:1px solid #D5DAE5}:host ::ng-deep .mat-tab-labels{padding:0 17px}:host ::ng-deep .mat-tab-label{padding:0 8px;min-width:0;height:38px;opacity:1}:host ::ng-deep .mat-tab-label:not(:last-child){margin-right:21px}:host ::ng-deep .mat-tab-label-active .mat-tab-label-content{color:#579bf2;font-weight:700}:host ::ng-deep .mat-tab-label-content{font-weight:400;font-size:14px;line-height:22px;color:#51566f;font-family:\"Poppins\",sans-serif}:host ::ng-deep .mat-ink-bar{height:3px;border-radius:5px;background-color:#579bf2!important}:host ::ng-deep .with-radio .mat-tab-labels{padding:0;margin-bottom:8px}:host ::ng-deep .with-radio .mat-tab-label{padding:8px 16px;min-width:0;flex-grow:1;justify-content:start;height:38px;opacity:1}:host ::ng-deep .with-radio .mat-tab-label:not(:last-child){margin-right:8px}:host ::ng-deep .with-radio .mat-tab-label-active{background:#F6F7F8;border-radius:3px}:host ::ng-deep .with-radio .mat-tab-label-active .mat-tab-label-content{color:#0c142b;font-weight:600}:host ::ng-deep .with-radio .mat-ink-bar{display:none!important}:host ::ng-deep .vertical.mat-tab-group{flex-direction:row}:host ::ng-deep .vertical .mat-tab-header{border-bottom:none}:host ::ng-deep .vertical .mat-tab-labels{flex-direction:column;padding:0;border-right:1px solid #D5DAE5}:host ::ng-deep .vertical .mat-ink-bar{display:none!important}:host ::ng-deep .vertical .mat-tab-label{border-bottom:1px solid #D5DAE5;margin:0!important}:host ::ng-deep .vertical .mat-tab-label:before{content:\"\";width:2px;height:100%;display:flex;position:absolute;top:0;left:0}:host ::ng-deep .vertical .mat-tab-label-active{background-color:#f3f7ff}:host ::ng-deep .vertical .mat-tab-label-active:before{background-color:#151a41}:host ::ng-deep .vertical .mat-tab-label-active .mat-tab-label-content{font-weight:normal;color:#151a41}:host ::ng-deep .vertical .mat-tab-body-wrapper{width:100%;padding:16px}\n"]
2567
- },] }
2568
- ];
2569
- DrTabsComponent.ctorParameters = () => [];
2570
- DrTabsComponent.propDecorators = {
2571
- selectedTab: [{ type: Input }],
2572
- withRadio: [{ type: Input }],
2573
- vertical: [{ type: Input }],
2574
- selectedTabChange: [{ type: Output }],
2575
- tabsContentList: [{ type: ContentChildren, args: [DrTabComponent,] }]
2576
- };
2577
-
2578
- class DrAccordionComponent {
2579
- constructor() {
2580
- this.openCloseItems = new Subject();
2581
- this.multiValue = false;
2625
+ onMouseLeave() {
2626
+ if (this.drDropdownInHover)
2627
+ this.menuService.destroy();
2582
2628
  }
2583
- /**
2584
- * Allow multiple items to be expanded at the same time.
2585
- */
2586
- get multi() {
2587
- return this.multiValue;
2629
+ onClickedOutside() {
2630
+ if (this.firstInit) {
2631
+ this.menuService.destroy();
2632
+ }
2633
+ else {
2634
+ this.firstInit = true;
2635
+ }
2588
2636
  }
2589
- set multi(val) {
2590
- this.multiValue = !!val;
2637
+ hide() {
2638
+ this.menuService.destroy();
2591
2639
  }
2592
- /**
2593
- * Opens all enabled accordion items.
2594
- */
2595
- openAll() {
2596
- if (this.multi) {
2597
- this.openCloseItems.next(false);
2640
+ disabled(act) {
2641
+ if (!act.disabled) {
2642
+ return false;
2643
+ }
2644
+ if (typeof act.disabled === 'boolean') {
2645
+ return act.disabled;
2646
+ }
2647
+ else {
2648
+ return act.disabled(act.data);
2598
2649
  }
2599
2650
  }
2600
- /**
2601
- * Closes all enabled accordion items.
2602
- */
2603
- closeAll() {
2604
- this.openCloseItems.next(true);
2651
+ selected(act) {
2652
+ if (!act.selected) {
2653
+ return false;
2654
+ }
2655
+ if (typeof act.selected === 'boolean') {
2656
+ return act.selected;
2657
+ }
2658
+ else {
2659
+ return act.selected(act.data);
2660
+ }
2661
+ }
2662
+ tooltipToShow(act) {
2663
+ if (act.toolTipIfDisabled && !this.disabled(act))
2664
+ return '';
2665
+ return act.toolTip;
2666
+ }
2667
+ tooltipPosition(widthMoreRight) {
2668
+ return widthMoreRight ? 'right' : 'left';
2669
+ }
2670
+ action(act) {
2671
+ if (!this.disabled(act)) {
2672
+ if (act.action) {
2673
+ act.action(act.data);
2674
+ }
2675
+ else {
2676
+ this.menuService.actionItem.next({ event: act.event || act.title || 'default', data: act.data });
2677
+ }
2678
+ this.hide();
2679
+ }
2680
+ }
2681
+ onActionIconClick($event, actionIcon, data) {
2682
+ $event.stopPropagation();
2683
+ if (!this.disabled(actionIcon)) {
2684
+ actionIcon.action(data);
2685
+ this.hide();
2686
+ }
2605
2687
  }
2606
2688
  }
2607
- DrAccordionComponent.decorators = [
2689
+ DrDropdownComponent.decorators = [
2608
2690
  { type: Component, args: [{
2609
- selector: 'dr-accordion',
2610
- template: '<ng-content select="dr-accordion-item"></ng-content>',
2691
+ selector: 'dr-dropdown',
2692
+ template: "<div #menuContainer\n (mouseleave)=\"onMouseLeave()\"\n (clickOutside)=\"onClickedOutside()\"\n [drDropdownPosition]=\"option\"\n #dropdownPosition=\"dropdownPosition\"\n [position]=\"position\"\n [class]=\"containerClass\"\n class=\"dr-dropdown\">\n <div class=\"dr-dropdown__container\">\n <div *ngFor=\"let act of list | drDropdownItemShowPipe\"\n (click)=\"action(act)\"\n [drTooltip]=\"tooltipToShow(act)\"\n [drTooltipPosition]=\"tooltipPosition(dropdownPosition.widthMoreRight)\"\n [drTooltipOptions]=\"{ withoutArrow: true }\"\n [drTooltipClass]=\"'dr-dropdown__tooltip'\"\n class=\"dr-dropdown__container__item\"\n [class.item-disabled]=\"disabled(act)\"\n [class.item-selected]=\"selected(act)\">\n <i *ngIf=\"act.icon\" [class]=\"act.icon\"></i>\n <span class=\"dr-dropdown__container__item__text\">{{act.title}}</span>\n <i *ngFor=\"let actionIcon of act.actionIcons\"\n [class]=\"actionIcon.icon\"\n [class.showOnHover]=\"actionIcon.showOnHover\"\n (click)=\"onActionIconClick($event, actionIcon, act.data)\"></i>\n <i *ngIf=\"act.children?.length\" class=\"dr-icon-arrow-right\"></i>\n <dr-dropdown *ngIf=\"act.children?.length\" [options]=\"act.childOptions\"></dr-dropdown>\n </div>\n </div>\n</div>\n",
2611
2693
  changeDetection: ChangeDetectionStrategy.OnPush,
2612
- styles: [":host{display:block;box-shadow:#2c33491a 0 5px 10px}\n"]
2694
+ styles: ["::ng-deep .dr-dropdown__container__item .dr-dropdown{visibility:hidden;transition-delay:.2s}::ng-deep .dr-dropdown__container__item:hover>*>.dr-dropdown{visibility:visible;transition-delay:0s}::ng-deep .dr-dropdown__tooltip>.default-content{max-width:300px;white-space:normal!important}.dr-dropdown{position:absolute;z-index:-1;top:0;left:0;width:auto}.dr-dropdown__container{display:flex;flex-direction:column;background:#fff;border-radius:4px;box-shadow:0 4px 8px 1px #00000040;padding:8px 0;overflow-y:auto;max-height:60vh}.dr-dropdown__container__item{display:flex;align-items:center;justify-content:flex-start;cursor:pointer;min-width:15rem;font-style:normal;font-weight:400;font-size:14px;line-height:24px;clear:both;width:100%;white-space:nowrap;padding:0 12px;height:36px;flex-shrink:0}.dr-dropdown__container__item:hover{background-color:#f9faff}.dr-dropdown__container__item:hover .showOnHover{visibility:visible}.dr-dropdown__container__item.item-selected{background:#F3F7FF}.dr-dropdown__container__item.item-disabled,.dr-dropdown__container__item.item-disabled i,.dr-dropdown__container__item.item-disabled .dr-dropdown__container__item__text{color:#bcbcbc}.dr-dropdown__container__item i:first-child{margin-right:8px}.dr-dropdown__container__item__text{margin-right:auto;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.dr-dropdown__container__item i,.dr-dropdown__container__item__text{color:#151b3f}.dr-dropdown__container__item i{color:#4e566c}.dr-dropdown__container__item i:hover{color:#4646ce}.dr-dropdown__container__item .showOnHover{visibility:hidden}.dr-dropdown.content-top{transform:translate(-50%,-100%)}.dr-dropdown.content-top-left{transform:translate(-100%,-100%)}.dr-dropdown.content-bottom{transform:translate(-50%,50%)}.dr-dropdown.content-bottom-left{transform:translate(-90%,35%)}.dr-dropdown.content-bottom-right{transform:translateY(15%)}.dr-dropdown.content-left{transform:translate(-100%)}.dr-dropdown.content-left-center{transform:translate(-100%,-50%)}.dr-dropdown.content-right{transform:translate(5%)}\n"]
2613
2695
  },] }
2614
2696
  ];
2615
- DrAccordionComponent.propDecorators = {
2616
- multi: [{ type: Input, args: ['multi',] }]
2697
+ DrDropdownComponent.ctorParameters = () => [
2698
+ { type: DrDropdownService },
2699
+ { type: ChangeDetectorRef }
2700
+ ];
2701
+ DrDropdownComponent.propDecorators = {
2702
+ viewMenu: [{ type: ViewChild, args: ['listMenu',] }],
2703
+ menuContainer: [{ type: ViewChild, args: ['menuContainer',] }],
2704
+ options: [{ type: Input }]
2617
2705
  };
2618
2706
 
2619
- class DrAccordionItemComponent {
2620
- constructor(accordion, cd) {
2621
- this.accordion = accordion;
2622
- this.cd = cd;
2623
- /**
2624
- * Emits whenever the expanded state of the accordion changes.
2625
- * Primarily used to facilitate two-way binding.
2626
- */
2627
- this.collapsedChange = new EventEmitter();
2628
- this.accordionItemInvalidate = new Subject();
2629
- this.collapsedValue = true;
2630
- this.disabledValue = false;
2631
- this.destroy$ = new Subject();
2707
+ class DrDropdownDirective {
2708
+ constructor(componentFactoryResolver, viewContainerRef, service, el, _document) {
2709
+ this.componentFactoryResolver = componentFactoryResolver;
2710
+ this.viewContainerRef = viewContainerRef;
2711
+ this.service = service;
2712
+ this.el = el;
2713
+ this._document = _document;
2714
+ this.position = 'left';
2632
2715
  }
2633
- /**
2634
- * Item is collapse (`true` by default)
2635
- * @type {boolean}
2636
- */
2637
- get collapsed() {
2638
- return this.collapsedValue;
2716
+ elementHover() {
2717
+ if (!this.drDropdownInHover)
2718
+ return;
2719
+ this.openDropdown();
2639
2720
  }
2640
- set collapsed(val) {
2641
- this.collapsedValue = !!val;
2642
- this.collapsedChange.emit(this.collapsedValue);
2643
- this.invalidate();
2721
+ elementClick() {
2722
+ this.openDropdown();
2644
2723
  }
2645
- /**
2646
- * Item is expanded (`false` by default)
2647
- */
2648
- get expanded() {
2649
- return !this.collapsed;
2724
+ documentClick(e) {
2725
+ this.closeDropdown(e);
2650
2726
  }
2651
- set expanded(val) {
2652
- this.collapsedValue = !val;
2727
+ openDropdown() {
2728
+ const option = this.el.nativeElement.getBoundingClientRect();
2729
+ this._document.querySelectorAll('dr-dropdown').forEach(item => item.remove());
2730
+ if (this.contentCmpRef && this.contentCmpRef.destroyCbs) {
2731
+ this.contentCmpRef.destroy();
2732
+ this.contentCmpRef = null;
2733
+ }
2734
+ else {
2735
+ this.service.destroy();
2736
+ this.showMenu({
2737
+ option,
2738
+ drDropdownInHover: this.drDropdownInHover,
2739
+ position: this.position,
2740
+ list: this.drDropdown,
2741
+ class: this.drDropdownClass
2742
+ });
2743
+ }
2653
2744
  }
2654
- /**
2655
- * Item is disabled and cannot be opened.
2656
- * @type {boolean}
2657
- */
2658
- get disabled() {
2659
- return this.disabledValue;
2745
+ closeDropdown(e) {
2746
+ const menuItem = e.target.classList;
2747
+ if (menuItem.contains('dr-dropdown__container__item') || menuItem.contains('dr-dropdown__container__item__text')) {
2748
+ return;
2749
+ }
2750
+ const elems = this._document.querySelectorAll('dr-dropdown');
2751
+ if (!e.target.contains(this.el.nativeElement) && this.contentCmpRef || elems.length && !e.target.contains(this.el.nativeElement)) {
2752
+ setTimeout(() => elems.forEach(item => item.remove()), 100);
2753
+ }
2660
2754
  }
2661
- set disabled(val) {
2662
- this.disabledValue = !!val;
2663
- this.invalidate();
2664
- }
2665
- /**
2666
- * Open/close the item
2667
- */
2668
- toggle() {
2669
- if (!this.disabled) {
2670
- // we need this temporary variable as `openCloseItems.next` will change current value we need to save
2671
- const willSet = !this.collapsed;
2672
- if (!this.accordion.multi) {
2673
- this.accordion.openCloseItems.next(true);
2674
- }
2675
- this.collapsed = willSet;
2676
- }
2677
- }
2678
- /**
2679
- * Open the item.
2680
- */
2681
- open() {
2682
- if (!this.disabled) {
2683
- this.collapsed = false;
2684
- }
2685
- }
2686
- /**
2687
- * Collapse the item.
2688
- */
2689
- close() {
2690
- if (!this.disabled) {
2691
- this.collapsed = true;
2692
- }
2693
- }
2694
- ngOnInit() {
2695
- this.accordion.openCloseItems
2696
- .pipe(takeUntil(this.destroy$))
2697
- .subscribe(collapsed => {
2698
- if (!this.disabled) {
2699
- this.collapsed = collapsed;
2700
- }
2701
- });
2702
- }
2703
- ngOnChanges(changes) {
2704
- this.accordionItemInvalidate.next(true);
2755
+ showMenu(options) {
2756
+ let componentFactory;
2757
+ componentFactory = this.componentFactoryResolver.resolveComponentFactory(DrDropdownComponent);
2758
+ this.contentCmpRef = this.viewContainerRef.createComponent(componentFactory);
2759
+ this.service.addMenu = this.contentCmpRef;
2760
+ this._document.querySelector('nb-layout').appendChild(this.contentCmpRef.location.nativeElement);
2761
+ this.contentCmpRef.instance.options = options;
2705
2762
  }
2706
2763
  ngOnDestroy() {
2707
- this.destroy$.next();
2708
- this.destroy$.complete();
2709
- this.accordionItemInvalidate.complete();
2710
- }
2711
- invalidate() {
2712
- this.accordionItemInvalidate.next(true);
2713
- this.cd.markForCheck();
2764
+ if (this.contentCmpRef) {
2765
+ this.contentCmpRef.destroy();
2766
+ }
2714
2767
  }
2715
2768
  }
2716
- DrAccordionItemComponent.decorators = [
2717
- { type: Component, args: [{
2718
- selector: 'dr-accordion-item',
2719
- template: `
2720
- <ng-content select="dr-accordion-item-header"></ng-content>
2721
- <ng-content select="dr-accordion-item-body"></ng-content>
2722
- `,
2723
- changeDetection: ChangeDetectionStrategy.OnPush,
2724
- styles: [":host{background-color:#fff;color:#222b45;font-family:\"Poppins\",sans-serif;font-size:16px;font-weight:400;line-height:1.25rem;display:flex;flex-direction:column}\n"]
2769
+ DrDropdownDirective.decorators = [
2770
+ { type: Directive, args: [{
2771
+ selector: '[drDropdown]'
2725
2772
  },] }
2726
2773
  ];
2727
- DrAccordionItemComponent.ctorParameters = () => [
2728
- { type: DrAccordionComponent, decorators: [{ type: Host }] },
2729
- { type: ChangeDetectorRef }
2774
+ DrDropdownDirective.ctorParameters = () => [
2775
+ { type: ComponentFactoryResolver },
2776
+ { type: ViewContainerRef },
2777
+ { type: DrDropdownService },
2778
+ { type: ElementRef },
2779
+ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
2730
2780
  ];
2731
- DrAccordionItemComponent.propDecorators = {
2732
- collapsed: [{ type: Input, args: ['collapsed',] }, { type: HostBinding, args: ['class.collapsed',] }],
2733
- expanded: [{ type: Input, args: ['expanded',] }, { type: HostBinding, args: ['class.expanded',] }],
2734
- disabled: [{ type: Input, args: ['disabled',] }, { type: HostBinding, args: ['class.disabled',] }],
2735
- collapsedChange: [{ type: Output }]
2781
+ DrDropdownDirective.propDecorators = {
2782
+ position: [{ type: Input }],
2783
+ drDropdown: [{ type: Input }],
2784
+ drDropdownClass: [{ type: Input }],
2785
+ drDropdownInHover: [{ type: Input }],
2786
+ contentCmpRef: [{ type: ViewChild, args: [DrDropdownComponent, { static: true, read: ViewContainerRef },] }],
2787
+ elementHover: [{ type: HostListener, args: ['mouseenter',] }],
2788
+ elementClick: [{ type: HostListener, args: ['click',] }],
2789
+ documentClick: [{ type: HostListener, args: ['document:mouseup', ['$event'],] }]
2736
2790
  };
2737
2791
 
2738
- class DrAccordionItemHeaderComponent {
2739
- constructor(accordionItem, cd) {
2740
- this.accordionItem = accordionItem;
2741
- this.cd = cd;
2742
- this.destroy$ = new Subject();
2743
- }
2744
- get isCollapsed() {
2745
- return this.accordionItem.collapsed;
2746
- }
2747
- get expanded() {
2748
- return !this.accordionItem.collapsed;
2749
- }
2750
- get tabbable() {
2751
- return this.accordionItem.disabled ? '-1' : '0';
2752
- }
2753
- get disabled() {
2754
- return this.accordionItem.disabled;
2755
- }
2756
- toggle() {
2757
- this.accordionItem.toggle();
2758
- }
2759
- get state() {
2760
- if (this.isCollapsed) {
2761
- return 'collapsed';
2762
- }
2763
- return 'expanded';
2792
+ class DrDropdownPositionDirective {
2793
+ constructor(el, renderer) {
2794
+ this.el = el;
2795
+ this.renderer = renderer;
2796
+ this.position = 'left';
2764
2797
  }
2765
2798
  ngOnInit() {
2766
- this.accordionItem.accordionItemInvalidate
2767
- .pipe(takeUntil(this.destroy$))
2768
- .subscribe(() => this.cd.markForCheck());
2799
+ setTimeout(this.calculatePosition.bind(this), 1);
2769
2800
  }
2770
- ngOnDestroy() {
2771
- this.destroy$.next();
2772
- this.destroy$.complete();
2801
+ calculatePosition() {
2802
+ let xDifference = 0;
2803
+ let defaultDelta = 10;
2804
+ let defaultPadding = 0;
2805
+ let originalPosition = this.position;
2806
+ if (this.position === 'child') {
2807
+ defaultDelta = 0;
2808
+ defaultPadding = 10;
2809
+ xDifference = this.el.nativeElement.parentElement.parentElement.offsetWidth - this.el.nativeElement.offsetWidth;
2810
+ const parentRect = this.el.nativeElement.parentElement.parentElement.getBoundingClientRect();
2811
+ this.position = {
2812
+ x: this.el.nativeElement.offsetWidth,
2813
+ y: this.el.nativeElement.parentElement.parentElement.offsetTop - 9,
2814
+ clientX: parentRect.x + this.el.nativeElement.parentElement.parentElement.offsetWidth,
2815
+ clientY: parentRect.y
2816
+ };
2817
+ }
2818
+ if (typeof this.position === 'string') {
2819
+ this.renderer.setStyle(this.el.nativeElement, 'top', this.position === 'bottom' ?
2820
+ this.drDropdownPosition.y - this.drDropdownPosition.height + 'px' :
2821
+ this.drDropdownPosition.y + 'px');
2822
+ this.renderer.setStyle(this.el.nativeElement, 'left', this.position === 'right' ?
2823
+ this.drDropdownPosition.x + this.drDropdownPosition.width + 'px' :
2824
+ this.drDropdownPosition.x + 'px');
2825
+ const menuHeight = this.el.nativeElement.offsetHeight;
2826
+ const heightMoreWindowBottom = menuHeight + this.drDropdownPosition.y > window.innerHeight;
2827
+ const heightMoreWindowTop = menuHeight - this.drDropdownPosition.y + this.drDropdownPosition.height / 2 > 48; // header height;
2828
+ const widthMoreWindowRight = this.drDropdownPosition.x + 250 > window.innerWidth;
2829
+ const spaceBetweenElAndRightBorder = window.innerWidth - (this.drDropdownPosition.x + this.el.nativeElement.offsetWidth);
2830
+ this.widthMoreRight = this.drDropdownPosition.x < spaceBetweenElAndRightBorder;
2831
+ if (heightMoreWindowBottom) {
2832
+ this.position = 'top';
2833
+ }
2834
+ if (heightMoreWindowBottom && widthMoreWindowRight && !heightMoreWindowTop || this.position === 'top-left') {
2835
+ this.position = 'top-left';
2836
+ this.renderer.setStyle(this.el.nativeElement, 'transform', 'translate(-100%, calc(-100% + ' + this.drDropdownPosition.height + 'px))');
2837
+ }
2838
+ if (heightMoreWindowTop && heightMoreWindowBottom) {
2839
+ this.position = 'left-center';
2840
+ }
2841
+ if (this.position === 'bottom-left') {
2842
+ this.renderer.setStyle(this.el.nativeElement, 'transform', `translate(calc(-100% + ${this.drDropdownPosition.width}px), ${this.drDropdownPosition.height + 8}px)`);
2843
+ }
2844
+ const className = this.position === 'top' ? 'content-top'
2845
+ : this.position === 'top-left' ? 'content-top-left'
2846
+ : this.position === 'bottom' ? 'content-bottom'
2847
+ : this.position === 'bottom-left' ? 'content-bottom-left'
2848
+ : this.position === 'left' ? 'content-left'
2849
+ : this.position === 'left-center' ? 'content-left-center'
2850
+ : this.position === 'right' ? 'content-right'
2851
+ : this.position === 'bottom-right' ? 'content-bottom-right' : '';
2852
+ this.renderer.addClass(this.el.nativeElement, className);
2853
+ this.renderer.setStyle(this.el.nativeElement, 'z-index', '10010');
2854
+ }
2855
+ else {
2856
+ const defaultChildPadding = 3;
2857
+ const widthMoreWindowRight = originalPosition !== 'child'
2858
+ ? window.innerWidth - (this.position.clientX - this.el.nativeElement.offsetWidth - defaultPadding)
2859
+ : window.innerWidth - this.position.clientX - this.el.nativeElement.offsetWidth - defaultPadding;
2860
+ const widthMoreWindowBottom = originalPosition !== 'child'
2861
+ ? window.innerHeight - (this.position.clientY - this.el.nativeElement.offsetHeight - defaultPadding)
2862
+ : window.innerHeight - this.position.clientY - this.el.nativeElement.offsetHeight - defaultPadding;
2863
+ const spaceRightAmount = window.innerWidth - (this.position.clientX + this.el.nativeElement.offsetWidth + defaultPadding);
2864
+ this.widthMoreRight = !(widthMoreWindowRight < 0);
2865
+ let calculatedHorizantallyPos = widthMoreWindowRight < 0
2866
+ ? -this.position.x + -defaultChildPadding
2867
+ : this.position.x + defaultChildPadding + xDifference;
2868
+ if (spaceRightAmount <= 0 && originalPosition !== 'child') {
2869
+ calculatedHorizantallyPos -= this.el.nativeElement.offsetWidth;
2870
+ }
2871
+ const deltaHeight = widthMoreWindowBottom < 0 ? widthMoreWindowBottom : defaultDelta;
2872
+ this.renderer.setStyle(this.el.nativeElement, 'top', (this.position.y + deltaHeight) + 'px');
2873
+ this.renderer.setStyle(this.el.nativeElement, 'left', (calculatedHorizantallyPos) + 'px');
2874
+ this.renderer.setStyle(this.el.nativeElement, 'z-index', '10010');
2875
+ }
2773
2876
  }
2774
2877
  }
2775
- DrAccordionItemHeaderComponent.decorators = [
2776
- { type: Component, args: [{
2777
- selector: 'dr-accordion-item-header',
2778
- template: `
2779
- <ng-content select="dr-accordion-item-title"></ng-content>
2780
- <ng-content select="dr-accordion-item-description"></ng-content>
2781
- <ng-content></ng-content>
2782
- <i class="dr-icon-arrow-down expansion-indicator"
2783
- [@expansionIndicator]="state"
2784
- *ngIf="!disabled">
2785
- </i>
2786
- `,
2787
- animations: [
2788
- trigger('expansionIndicator', [
2789
- state('expanded', style({
2790
- transform: 'rotate(180deg)',
2791
- })),
2792
- transition('collapsed => expanded', animate('100ms ease-in')),
2793
- transition('expanded => collapsed', animate('100ms ease-out')),
2794
- ]),
2795
- ],
2796
- changeDetection: ChangeDetectionStrategy.OnPush,
2797
- styles: [":host{display:flex;align-items:center;cursor:pointer;position:relative;border-bottom:1px solid #edf1f7;color:#222b45;font-family:\"Poppins\",sans-serif;font-size:13px;font-weight:600;line-height:1.5rem;padding:1.25rem;text-transform:capitalize}:host:focus{outline:0}:host .expansion-indicator{font-size:24px;position:absolute;right:10px;font-weight:700}\n"]
2878
+ DrDropdownPositionDirective.decorators = [
2879
+ { type: Directive, args: [{
2880
+ selector: '[drDropdownPosition]',
2881
+ exportAs: 'dropdownPosition'
2798
2882
  },] }
2799
2883
  ];
2800
- DrAccordionItemHeaderComponent.ctorParameters = () => [
2801
- { type: DrAccordionItemComponent, decorators: [{ type: Host }] },
2802
- { type: ChangeDetectorRef }
2884
+ DrDropdownPositionDirective.ctorParameters = () => [
2885
+ { type: ElementRef },
2886
+ { type: Renderer2 }
2803
2887
  ];
2804
- DrAccordionItemHeaderComponent.propDecorators = {
2805
- isCollapsed: [{ type: HostBinding, args: ['class.accordion-item-header-collapsed',] }],
2806
- expanded: [{ type: HostBinding, args: ['class.accordion-item-header-expanded',] }, { type: HostBinding, args: ['attr.aria-expanded',] }],
2807
- tabbable: [{ type: HostBinding, args: ['attr.tabindex',] }],
2808
- disabled: [{ type: HostBinding, args: ['attr.aria-disabled',] }],
2809
- toggle: [{ type: HostListener, args: ['click',] }, { type: HostListener, args: ['keydown.space',] }, { type: HostListener, args: ['keydown.enter',] }]
2888
+ DrDropdownPositionDirective.propDecorators = {
2889
+ drDropdownPosition: [{ type: Input }],
2890
+ position: [{ type: Input }]
2810
2891
  };
2811
2892
 
2812
- const accordionItemBodyTrigger = trigger('accordionItemBody', [
2813
- state('collapsed', style({
2814
- overflow: 'hidden',
2815
- visibility: 'hidden',
2816
- height: 0,
2817
- })),
2818
- state('expanded', style({
2819
- overflow: 'hidden',
2820
- visibility: 'visible',
2821
- })),
2822
- transition('collapsed => expanded', animate('100ms ease-in')),
2823
- transition('expanded => collapsed', animate('100ms ease-out')),
2824
- ]);
2825
- class DrAccordionItemBodyComponent {
2826
- constructor(accordionItem, cd) {
2827
- this.accordionItem = accordionItem;
2828
- this.cd = cd;
2829
- this.destroy$ = new Subject();
2830
- }
2831
- get state() {
2832
- return this.accordionItem.collapsed ? 'collapsed' : 'expanded';
2833
- }
2834
- ngOnInit() {
2835
- this.accordionItem.accordionItemInvalidate
2836
- .pipe(takeUntil(this.destroy$))
2837
- .subscribe(() => this.cd.markForCheck());
2838
- }
2839
- ngOnDestroy() {
2840
- this.destroy$.next();
2841
- this.destroy$.complete();
2842
- }
2843
- }
2844
- DrAccordionItemBodyComponent.decorators = [
2845
- { type: Component, args: [{
2846
- selector: 'dr-accordion-item-body',
2847
- template: `
2848
- <div [@accordionItemBody]="{ value: state }">
2849
- <div class="item-body">
2850
- <ng-content></ng-content>
2851
- </div>
2852
- </div>
2853
- `,
2854
- animations: [accordionItemBodyTrigger],
2855
- changeDetection: ChangeDetectionStrategy.OnPush,
2856
- styles: [".item-body{flex:1;-ms-flex:1 1 auto;overflow:auto;position:relative}\n"]
2857
- },] }
2858
- ];
2859
- DrAccordionItemBodyComponent.ctorParameters = () => [
2860
- { type: DrAccordionItemComponent, decorators: [{ type: Host }] },
2861
- { type: ChangeDetectorRef }
2862
- ];
2863
-
2864
- class DrModelDebounceChangeDirective {
2865
- constructor(ngModel) {
2866
- this.ngModel = ngModel;
2867
- this.debounce = 200;
2868
- this.ngModelDebounceChange = new EventEmitter();
2869
- }
2870
- ngOnInit() {
2871
- this.subscription = this.ngModel.control.valueChanges
2872
- .pipe(skip(1), debounceTime(this.debounce), distinctUntilChanged())
2873
- .subscribe(value => this.ngModelDebounceChange.emit(value));
2874
- }
2875
- ngOnDestroy() {
2876
- this.subscription.unsubscribe();
2877
- }
2878
- }
2879
- DrModelDebounceChangeDirective.decorators = [
2880
- { type: Directive, args: [{
2881
- selector: '[ngModelDebounceChange]'
2882
- },] }
2883
- ];
2884
- DrModelDebounceChangeDirective.ctorParameters = () => [
2885
- { type: NgModel }
2886
- ];
2887
- DrModelDebounceChangeDirective.propDecorators = {
2888
- debounce: [{ type: Input }],
2889
- ngModelDebounceChange: [{ type: Output }]
2890
- };
2891
-
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;
2893
+ class DrDropdownItemShowPipe {
2894
+ transform(arr) {
2895
+ return arr.filter(item => item.show ? item.show(item.data) : true);
2929
2896
  }
2930
2897
  }
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,
2946
- ForecastTagComponent];
2947
- const ɵ0$1 = { useUtc: true };
2948
- class DateTagModule {
2949
- }
2950
- DateTagModule.decorators = [
2951
- { type: NgModule, args: [{
2952
- imports: [
2953
- CommonModule,
2954
- MatNativeDateModule,
2955
- MatDatepickerModule,
2956
- FormsModule,
2957
- MatFormFieldModule,
2958
- ReactiveFormsModule,
2959
- MatInputModule,
2960
- MatMomentDateModule,
2961
- MatSelectModule
2962
- ],
2963
- exports: components$2,
2964
- providers: [
2965
- { provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: ɵ0$1 }
2966
- ],
2967
- declarations: components$2,
2968
- },] }
2969
- ];
2970
- ;
2971
-
2972
- class ListTagModule {
2973
- }
2974
- ListTagModule.decorators = [
2975
- { type: NgModule, args: [{
2976
- imports: [
2977
- CommonModule,
2978
- FormsModule,
2979
- MatFormFieldModule,
2980
- ReactiveFormsModule,
2981
- MatMomentDateModule,
2982
- MatSelectModule,
2983
- MatButtonToggleModule,
2984
- ],
2985
- exports: [ListTagComponent],
2986
- providers: [],
2987
- declarations: [
2988
- ListTagComponent
2989
- ],
2990
- },] }
2991
- ];
2992
-
2993
- class DrTagModule {
2994
- }
2995
- DrTagModule.decorators = [
2996
- { type: NgModule, args: [{
2997
- imports: [
2998
- CommonModule,
2999
- DateTagModule,
3000
- ListTagModule
3001
- ],
3002
- exports: [DrTagComponent],
3003
- providers: [],
3004
- declarations: [
3005
- DrTagComponent
3006
- ],
2898
+ DrDropdownItemShowPipe.decorators = [
2899
+ { type: Pipe, args: [{
2900
+ name: 'drDropdownItemShowPipe'
3007
2901
  },] }
3008
2902
  ];
3009
2903
 
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();
2904
+ class DrTabComponent {
2905
+ constructor() { }
2906
+ ngOnInit() {
3135
2907
  }
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
- }
2908
+ }
2909
+ DrTabComponent.decorators = [
2910
+ { type: Component, args: [{
2911
+ selector: 'dr-tab',
2912
+ template: `
2913
+ <ng-template>
2914
+ <ng-content></ng-content>
2915
+ </ng-template>
2916
+ `
2917
+ },] }
2918
+ ];
2919
+ DrTabComponent.ctorParameters = () => [];
2920
+ DrTabComponent.propDecorators = {
2921
+ label: [{ type: Input }],
2922
+ disabled: [{ type: Input }],
2923
+ contentTemplate: [{ type: ViewChild, args: [TemplateRef,] }]
2924
+ };
2925
+
2926
+ class DrTabsComponent {
2927
+ constructor() {
2928
+ this.selectedTab = 0;
2929
+ this.selectedTabChange = new EventEmitter();
3144
2930
  }
3145
- get currentViewIsQuarter() {
3146
- return !['month', 'year', 'multi-year'].includes(this._calendar.currentView);
2931
+ selectedIndexChange($event) {
2932
+ this.selectedTab = $event;
2933
+ this.selectedTabChange.emit($event);
3147
2934
  }
3148
- switchViewOnClickOnPeriodLabel(view) {
3149
- this._calendar.currentView = view;
2935
+ }
2936
+ DrTabsComponent.decorators = [
2937
+ { type: Component, args: [{
2938
+ selector: 'dr-tabs',
2939
+ template: "<mat-tab-group disableRipple [selectedIndex]=\"selectedTab\"\n (selectedIndexChange)=\"selectedIndexChange($event)\"\n [class.with-radio]=\"withRadio\"\n [class.vertical]=\"vertical\"\n [animationDuration]=\" vertical ? '0ms' : '500ms'\">\n <mat-tab *ngFor=\"let tab of tabsContentList; let index = index\" label=\"{{tab.label}}\" [disabled]=\"tab.disabled\" >\n <ng-container *ngIf=\"withRadio\">\n <ng-template mat-tab-label>\n <dr-radio-button [value]=\"index\"\n [(ngModel)]=\"selectedTab\">\n </dr-radio-button>\n {{tab.label}}\n </ng-template>\n </ng-container>\n\n <ng-container *ngTemplateOutlet=\"tab.contentTemplate\" ></ng-container>\n </mat-tab>\n</mat-tab-group>\n",
2940
+ styles: [":host{width:100%}:host ::ng-deep .mat-tab-group,:host ::ng-deep .mat-tab-body-wrapper{height:100%}:host ::ng-deep .mat-tab-nav-bar,:host ::ng-deep .mat-tab-header{border-bottom:1px solid #D5DAE5}:host ::ng-deep .mat-tab-labels{padding:0 17px}:host ::ng-deep .mat-tab-label{padding:0 8px;min-width:0;height:38px;opacity:1}:host ::ng-deep .mat-tab-label:not(:last-child){margin-right:21px}:host ::ng-deep .mat-tab-label-active .mat-tab-label-content{color:#579bf2;font-weight:700}:host ::ng-deep .mat-tab-label-content{font-weight:400;font-size:14px;line-height:22px;color:#51566f;font-family:\"Poppins\",sans-serif}:host ::ng-deep .mat-ink-bar{height:3px;border-radius:5px;background-color:#579bf2!important}:host ::ng-deep .with-radio .mat-tab-labels{padding:0;margin-bottom:8px}:host ::ng-deep .with-radio .mat-tab-label{padding:8px 16px;min-width:0;flex-grow:1;justify-content:start;height:38px;opacity:1}:host ::ng-deep .with-radio .mat-tab-label:not(:last-child){margin-right:8px}:host ::ng-deep .with-radio .mat-tab-label-active{background:#F6F7F8;border-radius:3px}:host ::ng-deep .with-radio .mat-tab-label-active .mat-tab-label-content{color:#0c142b;font-weight:600}:host ::ng-deep .with-radio .mat-ink-bar{display:none!important}:host ::ng-deep .vertical.mat-tab-group{flex-direction:row}:host ::ng-deep .vertical .mat-tab-header{border-bottom:none}:host ::ng-deep .vertical .mat-tab-labels{flex-direction:column;padding:0;border-right:1px solid #D5DAE5}:host ::ng-deep .vertical .mat-ink-bar{display:none!important}:host ::ng-deep .vertical .mat-tab-label{border-bottom:1px solid #D5DAE5;margin:0!important}:host ::ng-deep .vertical .mat-tab-label:before{content:\"\";width:2px;height:100%;display:flex;position:absolute;top:0;left:0}:host ::ng-deep .vertical .mat-tab-label-active{background-color:#f3f7ff}:host ::ng-deep .vertical .mat-tab-label-active:before{background-color:#151a41}:host ::ng-deep .vertical .mat-tab-label-active .mat-tab-label-content{font-weight:normal;color:#151a41}:host ::ng-deep .vertical .mat-tab-body-wrapper{width:100%;padding:16px}\n"]
2941
+ },] }
2942
+ ];
2943
+ DrTabsComponent.ctorParameters = () => [];
2944
+ DrTabsComponent.propDecorators = {
2945
+ selectedTab: [{ type: Input }],
2946
+ withRadio: [{ type: Input }],
2947
+ vertical: [{ type: Input }],
2948
+ selectedTabChange: [{ type: Output }],
2949
+ tabsContentList: [{ type: ContentChildren, args: [DrTabComponent,] }]
2950
+ };
2951
+
2952
+ class DrAccordionComponent {
2953
+ constructor() {
2954
+ this.openCloseItems = new Subject();
2955
+ this.multiValue = false;
3150
2956
  }
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();
2957
+ /**
2958
+ * Allow multiple items to be expanded at the same time.
2959
+ */
2960
+ get multi() {
2961
+ return this.multiValue;
3158
2962
  }
3159
- pagingClicked(forward) {
3160
- this.pagingSetup[this._calendar.currentView] && this.pagingSetup[this._calendar.currentView](forward);
2963
+ set multi(val) {
2964
+ this.multiValue = !!val;
3161
2965
  }
3162
- pagingDateChange(actionCall, amount, forward) {
3163
- this._calendar.activeDate = this._dateAdapter[actionCall](this._calendar.activeDate, forward ? amount : -amount);
3164
- this.setPeriodLabels();
2966
+ /**
2967
+ * Opens all enabled accordion items.
2968
+ */
2969
+ openAll() {
2970
+ if (this.multi) {
2971
+ this.openCloseItems.next(false);
2972
+ }
2973
+ }
2974
+ /**
2975
+ * Closes all enabled accordion items.
2976
+ */
2977
+ closeAll() {
2978
+ this.openCloseItems.next(true);
3165
2979
  }
3166
2980
  }
3167
- DrDatePickerCustomHeaderComponent.decorators = [
2981
+ DrAccordionComponent.decorators = [
3168
2982
  { 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",
2983
+ selector: 'dr-accordion',
2984
+ template: '<ng-content select="dr-accordion-item"></ng-content>',
3171
2985
  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"]
2986
+ styles: [":host{display:block;box-shadow:#2c33491a 0 5px 10px}\n"]
3173
2987
  },] }
3174
2988
  ];
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
- ];
2989
+ DrAccordionComponent.propDecorators = {
2990
+ multi: [{ type: Input, args: ['multi',] }]
2991
+ };
3182
2992
 
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);
2993
+ class DrAccordionItemComponent {
2994
+ constructor(accordion, cd) {
2995
+ this.accordion = accordion;
2996
+ this.cd = cd;
2997
+ /**
2998
+ * Emits whenever the expanded state of the accordion changes.
2999
+ * Primarily used to facilitate two-way binding.
3000
+ */
3001
+ this.collapsedChange = new EventEmitter();
3002
+ this.accordionItemInvalidate = new Subject();
3003
+ this.collapsedValue = true;
3004
+ this.disabledValue = false;
3005
+ this.destroy$ = new Subject();
3214
3006
  }
3215
- set min(minDate) {
3216
- this._min = moment.unix(minDate).utc();
3007
+ /**
3008
+ * Item is collapse (`true` by default)
3009
+ * @type {boolean}
3010
+ */
3011
+ get collapsed() {
3012
+ return this.collapsedValue;
3217
3013
  }
3218
- set max(maxDate) {
3219
- this._max = moment.unix(maxDate).utc();
3014
+ set collapsed(val) {
3015
+ this.collapsedValue = !!val;
3016
+ this.collapsedChange.emit(this.collapsedValue);
3017
+ this.invalidate();
3220
3018
  }
3221
- get value() {
3222
- return this.innerValue;
3019
+ /**
3020
+ * Item is expanded (`false` by default)
3021
+ */
3022
+ get expanded() {
3023
+ return !this.collapsed;
3223
3024
  }
3224
- set value(v) {
3225
- if (v !== this.innerValue) {
3226
- this.setValueFromMoment(v);
3227
- }
3228
- this.cdr.markForCheck();
3025
+ set expanded(val) {
3026
+ this.collapsedValue = !val;
3229
3027
  }
3230
- ngAfterViewInit() {
3231
- this.datePickerService.calendarInstance = this.dp;
3232
- this.dp.startView = this.calendarViewsTimeframeMapping[this.datePickerService.timeframe];
3028
+ /**
3029
+ * Item is disabled and cannot be opened.
3030
+ * @type {boolean}
3031
+ */
3032
+ get disabled() {
3033
+ return this.disabledValue;
3233
3034
  }
3234
- ngOnDestroy() {
3235
- this.destroyed$.next();
3236
- this.destroyed$.complete();
3035
+ set disabled(val) {
3036
+ this.disabledValue = !!val;
3037
+ this.invalidate();
3237
3038
  }
3238
3039
  /**
3239
- * Updating component inner value according to datepicker timeframe (day, month etc.)
3240
- * and date position in period (start, end, middle)
3040
+ * Open/close the item
3241
3041
  */
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;
3042
+ toggle() {
3043
+ if (!this.disabled) {
3044
+ // we need this temporary variable as `openCloseItems.next` will change current value we need to save
3045
+ const willSet = !this.collapsed;
3046
+ if (!this.accordion.multi) {
3047
+ this.accordion.openCloseItems.next(true);
3048
+ }
3049
+ this.collapsed = willSet;
3260
3050
  }
3261
3051
  }
3262
- chosenPeriodHandler(chosenDate, timeframe) {
3263
- if (this.datePickerService.timeframe === timeframe) {
3264
- this.setValueFromMoment(chosenDate);
3265
- this.dp.close();
3052
+ /**
3053
+ * Open the item.
3054
+ */
3055
+ open() {
3056
+ if (!this.disabled) {
3057
+ this.collapsed = false;
3266
3058
  }
3267
3059
  }
3268
3060
  /**
3269
- * Setting value from outside of component via ngModel or formControl updates
3061
+ * Collapse the item.
3270
3062
  */
3271
- writeValue(value) {
3272
- this.innerValue = value ? moment.unix(value).utc() : value;
3273
- if (this.innerValue) {
3274
- this.tryToNormalaizeTimeframe();
3063
+ close() {
3064
+ if (!this.disabled) {
3065
+ this.collapsed = true;
3275
3066
  }
3276
- this.cdr.markForCheck();
3277
3067
  }
3278
- registerOnChange(fn) {
3279
- this.onChangeCallback = fn;
3068
+ ngOnInit() {
3069
+ this.accordion.openCloseItems
3070
+ .pipe(takeUntil(this.destroy$))
3071
+ .subscribe(collapsed => {
3072
+ if (!this.disabled) {
3073
+ this.collapsed = collapsed;
3074
+ }
3075
+ });
3076
+ }
3077
+ ngOnChanges(changes) {
3078
+ this.accordionItemInvalidate.next(true);
3079
+ }
3080
+ ngOnDestroy() {
3081
+ this.destroy$.next();
3082
+ this.destroy$.complete();
3083
+ this.accordionItemInvalidate.complete();
3084
+ }
3085
+ invalidate() {
3086
+ this.accordionItemInvalidate.next(true);
3087
+ this.cd.markForCheck();
3088
+ }
3089
+ }
3090
+ DrAccordionItemComponent.decorators = [
3091
+ { type: Component, args: [{
3092
+ selector: 'dr-accordion-item',
3093
+ template: `
3094
+ <ng-content select="dr-accordion-item-header"></ng-content>
3095
+ <ng-content select="dr-accordion-item-body"></ng-content>
3096
+ `,
3097
+ changeDetection: ChangeDetectionStrategy.OnPush,
3098
+ styles: [":host{background-color:#fff;color:#222b45;font-family:\"Poppins\",sans-serif;font-size:16px;font-weight:400;line-height:1.25rem;display:flex;flex-direction:column}\n"]
3099
+ },] }
3100
+ ];
3101
+ DrAccordionItemComponent.ctorParameters = () => [
3102
+ { type: DrAccordionComponent, decorators: [{ type: Host }] },
3103
+ { type: ChangeDetectorRef }
3104
+ ];
3105
+ DrAccordionItemComponent.propDecorators = {
3106
+ collapsed: [{ type: Input, args: ['collapsed',] }, { type: HostBinding, args: ['class.collapsed',] }],
3107
+ expanded: [{ type: Input, args: ['expanded',] }, { type: HostBinding, args: ['class.expanded',] }],
3108
+ disabled: [{ type: Input, args: ['disabled',] }, { type: HostBinding, args: ['class.disabled',] }],
3109
+ collapsedChange: [{ type: Output }]
3110
+ };
3111
+
3112
+ class DrAccordionItemHeaderComponent {
3113
+ constructor(accordionItem, cd) {
3114
+ this.accordionItem = accordionItem;
3115
+ this.cd = cd;
3116
+ this.destroy$ = new Subject();
3117
+ }
3118
+ get isCollapsed() {
3119
+ return this.accordionItem.collapsed;
3120
+ }
3121
+ get expanded() {
3122
+ return !this.accordionItem.collapsed;
3123
+ }
3124
+ get tabbable() {
3125
+ return this.accordionItem.disabled ? '-1' : '0';
3126
+ }
3127
+ get disabled() {
3128
+ return this.accordionItem.disabled;
3129
+ }
3130
+ toggle() {
3131
+ this.accordionItem.toggle();
3280
3132
  }
3281
- registerOnTouched(fn) {
3282
- this.onTouchedCallback = fn;
3133
+ get state() {
3134
+ if (this.isCollapsed) {
3135
+ return 'collapsed';
3136
+ }
3137
+ return 'expanded';
3283
3138
  }
3284
- /**
3285
- * Set inner value from Moment and propagate
3286
- * @param momentDate
3287
- */
3288
- setValueFromMoment(momentDate) {
3289
- this.setValue(momentDate.unix());
3139
+ ngOnInit() {
3140
+ this.accordionItem.accordionItemInvalidate
3141
+ .pipe(takeUntil(this.destroy$))
3142
+ .subscribe(() => this.cd.markForCheck());
3290
3143
  }
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());
3144
+ ngOnDestroy() {
3145
+ this.destroy$.next();
3146
+ this.destroy$.complete();
3298
3147
  }
3299
3148
  }
3300
- DrDatePickerComponent.decorators = [
3149
+ DrAccordionItemHeaderComponent.decorators = [
3301
3150
  { 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 }
3151
+ selector: 'dr-accordion-item-header',
3152
+ template: `
3153
+ <ng-content select="dr-accordion-item-title"></ng-content>
3154
+ <ng-content select="dr-accordion-item-description"></ng-content>
3155
+ <ng-content></ng-content>
3156
+ <i class="dr-icon-arrow-down expansion-indicator"
3157
+ [@expansionIndicator]="state"
3158
+ *ngIf="!disabled">
3159
+ </i>
3160
+ `,
3161
+ animations: [
3162
+ trigger('expansionIndicator', [
3163
+ state('expanded', style({
3164
+ transform: 'rotate(180deg)',
3165
+ })),
3166
+ transition('collapsed => expanded', animate('100ms ease-in')),
3167
+ transition('expanded => collapsed', animate('100ms ease-out')),
3168
+ ]),
3308
3169
  ],
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"]
3170
+ changeDetection: ChangeDetectionStrategy.OnPush,
3171
+ styles: [":host{display:flex;align-items:center;cursor:pointer;position:relative;border-bottom:1px solid #edf1f7;color:#222b45;font-family:\"Poppins\",sans-serif;font-size:13px;font-weight:600;line-height:1.5rem;padding:1.25rem;text-transform:capitalize}:host:focus{outline:0}:host .expansion-indicator{font-size:24px;position:absolute;right:10px;font-weight:700}\n"]
3310
3172
  },] }
3311
3173
  ];
3312
- DrDatePickerComponent.ctorParameters = () => [
3313
- { type: ChangeDetectorRef },
3314
- { type: DateAdapter },
3315
- { type: DrDatePickerService }
3174
+ DrAccordionItemHeaderComponent.ctorParameters = () => [
3175
+ { type: DrAccordionItemComponent, decorators: [{ type: Host }] },
3176
+ { type: ChangeDetectorRef }
3316
3177
  ];
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',] }]
3178
+ DrAccordionItemHeaderComponent.propDecorators = {
3179
+ isCollapsed: [{ type: HostBinding, args: ['class.accordion-item-header-collapsed',] }],
3180
+ expanded: [{ type: HostBinding, args: ['class.accordion-item-header-expanded',] }, { type: HostBinding, args: ['attr.aria-expanded',] }],
3181
+ tabbable: [{ type: HostBinding, args: ['attr.tabindex',] }],
3182
+ disabled: [{ type: HostBinding, args: ['attr.aria-disabled',] }],
3183
+ toggle: [{ type: HostListener, args: ['click',] }, { type: HostListener, args: ['keydown.space',] }, { type: HostListener, args: ['keydown.enter',] }]
3324
3184
  };
3325
3185
 
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;
3186
+ const accordionItemBodyTrigger = trigger('accordionItemBody', [
3187
+ state('collapsed', style({
3188
+ overflow: 'hidden',
3189
+ visibility: 'hidden',
3190
+ height: 0,
3191
+ })),
3192
+ state('expanded', style({
3193
+ overflow: 'hidden',
3194
+ visibility: 'visible',
3195
+ })),
3196
+ transition('collapsed => expanded', animate('100ms ease-in')),
3197
+ transition('expanded => collapsed', animate('100ms ease-out')),
3198
+ ]);
3199
+ class DrAccordionItemBodyComponent {
3200
+ constructor(accordionItem, cd) {
3201
+ this.accordionItem = accordionItem;
3202
+ this.cd = cd;
3203
+ this.destroy$ = new Subject();
3349
3204
  }
3350
- ;
3351
- get quarterDisplay() {
3352
- return this.datePickerService.getQuarterDisplay(this.value);
3205
+ get state() {
3206
+ return this.accordionItem.collapsed ? 'collapsed' : 'expanded';
3353
3207
  }
3354
3208
  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();
3209
+ this.accordionItem.accordionItemInvalidate
3210
+ .pipe(takeUntil(this.destroy$))
3211
+ .subscribe(() => this.cd.markForCheck());
3362
3212
  }
3363
- pagingDateChange(actionCall, amount, forward) {
3364
- const newValue = this.dateAdapter[actionCall](this.innerValue, forward ? amount : -amount);
3365
- this.setValueFromMoment(newValue);
3213
+ ngOnDestroy() {
3214
+ this.destroy$.next();
3215
+ this.destroy$.complete();
3366
3216
  }
3367
3217
  }
3368
- DrDatePickerWithTimeframeComponent.decorators = [
3218
+ DrAccordionItemBodyComponent.decorators = [
3369
3219
  { 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",
3220
+ selector: 'dr-accordion-item-body',
3221
+ template: `
3222
+ <div [@accordionItemBody]="{ value: state }">
3223
+ <div class="item-body">
3224
+ <ng-content></ng-content>
3225
+ </div>
3226
+ </div>
3227
+ `,
3228
+ animations: [accordionItemBodyTrigger],
3372
3229
  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"]
3230
+ styles: [".item-body{flex:1;-ms-flex:1 1 auto;overflow:auto;position:relative}\n"]
3378
3231
  },] }
3379
3232
  ];
3380
- DrDatePickerWithTimeframeComponent.ctorParameters = () => [
3381
- { type: ChangeDetectorRef },
3382
- { type: DateAdapter },
3383
- { type: DrDatePickerService }
3233
+ DrAccordionItemBodyComponent.ctorParameters = () => [
3234
+ { type: DrAccordionItemComponent, decorators: [{ type: Host }] },
3235
+ { type: ChangeDetectorRef }
3384
3236
  ];
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
3237
 
3392
- class DrDatePickerFormatDirective {
3393
- constructor(matDateFormat, ngControl) {
3394
- this.matDateFormat = matDateFormat;
3395
- this.ngControl = ngControl;
3238
+ class DrModelDebounceChangeDirective {
3239
+ constructor(ngModel) {
3240
+ this.ngModel = ngModel;
3241
+ this.debounce = 200;
3242
+ this.ngModelDebounceChange = new EventEmitter();
3396
3243
  }
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);
3244
+ ngOnInit() {
3245
+ this.subscription = this.ngModel.control.valueChanges
3246
+ .pipe(skip(1), debounceTime(this.debounce), distinctUntilChanged())
3247
+ .subscribe(value => this.ngModelDebounceChange.emit(value));
3248
+ }
3249
+ ngOnDestroy() {
3250
+ this.subscription.unsubscribe();
3407
3251
  }
3408
3252
  }
3409
- DrDatePickerFormatDirective.decorators = [
3253
+ DrModelDebounceChangeDirective.decorators = [
3410
3254
  { 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
- ]
3255
+ selector: '[ngModelDebounceChange]'
3422
3256
  },] }
3423
3257
  ];
3424
- DrDatePickerFormatDirective.ctorParameters = () => [
3425
- { type: CustomDateFormat, decorators: [{ type: Inject, args: [MAT_DATE_FORMATS,] }] },
3426
- { type: NgControl, decorators: [{ type: Optional }] }
3258
+ DrModelDebounceChangeDirective.ctorParameters = () => [
3259
+ { type: NgModel }
3427
3260
  ];
3428
- DrDatePickerFormatDirective.propDecorators = {
3429
- configDateParse: [{ type: Input }],
3430
- configDateDisplay: [{ type: Input }],
3431
- datePickerFormat: [{ type: Input, args: ['drDatePickerFormat',] }]
3261
+ DrModelDebounceChangeDirective.propDecorators = {
3262
+ debounce: [{ type: Input }],
3263
+ ngModelDebounceChange: [{ type: Output }]
3432
3264
  };
3433
3265
 
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
- };
3266
+ const components$2 = [DateTagComponent,
3267
+ DayTagComponent,
3268
+ WeekTagComponent,
3269
+ MonthTagComponent,
3270
+ QuarterTagComponent,
3271
+ AnyTagComponent,
3272
+ YearTagComponent,
3273
+ ForecastTagComponent];
3274
+ const ɵ0 = { useUtc: true };
3275
+ class DateTagModule {
3276
+ }
3277
+ DateTagModule.decorators = [
3278
+ { type: NgModule, args: [{
3279
+ imports: [
3280
+ CommonModule,
3281
+ MatNativeDateModule,
3282
+ MatDatepickerModule,
3283
+ FormsModule,
3284
+ MatFormFieldModule,
3285
+ ReactiveFormsModule,
3286
+ MatInputModule,
3287
+ MatMomentDateModule,
3288
+ MatSelectModule
3289
+ ],
3290
+ exports: components$2,
3291
+ providers: [
3292
+ { provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: ɵ0 }
3293
+ ],
3294
+ declarations: components$2,
3295
+ },] }
3296
+ ];
3297
+ ;
3298
+
3299
+ class ListTagModule {
3300
+ }
3301
+ ListTagModule.decorators = [
3302
+ { type: NgModule, args: [{
3303
+ imports: [
3304
+ CommonModule,
3305
+ FormsModule,
3306
+ MatFormFieldModule,
3307
+ ReactiveFormsModule,
3308
+ MatMomentDateModule,
3309
+ MatSelectModule,
3310
+ MatButtonToggleModule,
3311
+ ],
3312
+ exports: [ListTagComponent],
3313
+ providers: [],
3314
+ declarations: [
3315
+ ListTagComponent
3316
+ ],
3317
+ },] }
3318
+ ];
3319
+
3320
+ class DrTagModule {
3321
+ }
3322
+ DrTagModule.decorators = [
3323
+ { type: NgModule, args: [{
3324
+ imports: [
3325
+ CommonModule,
3326
+ DateTagModule,
3327
+ ListTagModule
3328
+ ],
3329
+ exports: [DrTagComponent],
3330
+ providers: [],
3331
+ declarations: [
3332
+ DrTagComponent
3333
+ ],
3334
+ },] }
3335
+ ];
3336
+
3440
3337
  const components$1 = [
3441
3338
  DrButtonComponent,
3442
3339
  RadioButtonComponent,
@@ -3447,7 +3344,6 @@ const components$1 = [
3447
3344
  DrToggleComponent,
3448
3345
  DrToggleButtonComponent,
3449
3346
  DrDatePickerComponent,
3450
- DrDatePickerWithTimeframeComponent,
3451
3347
  DrDatePickerFormatDirective,
3452
3348
  DrDatePickerCustomHeaderComponent,
3453
3349
  DrModelDebounceChangeDirective
@@ -3464,6 +3360,9 @@ DrInputsModule.decorators = [
3464
3360
  CommonModule,
3465
3361
  NgSelectModule,
3466
3362
  MatDatepickerModule
3363
+ ],
3364
+ providers: [
3365
+ DrDatePickerService
3467
3366
  ]
3468
3367
  },] }
3469
3368
  ];
@@ -3612,5 +3511,5 @@ DrAccordionModule.decorators = [
3612
3511
  * Generated bundle index. Do not edit.
3613
3512
  */
3614
3513
 
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 };
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 };
3616
3515
  //# sourceMappingURL=datarailsshared-datarailsshared.js.map