clr-angular-static-fix
Version:
1. Install Clarity Icons package through npm:
91 lines (81 loc) • 2.83 kB
text/typescript
/*
* Copyright (c) 2016-2018 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
import { Component, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs';
import { IfOpenService } from '../../utils/conditional/if-open.service';
import { DynamicWrapper } from '../../utils/host-wrapping';
import { ControlIdService } from '../common/providers/control-id.service';
import { DateFormControlService } from './providers/date-form-control.service';
import { DateIOService } from './providers/date-io.service';
import { DateNavigationService } from './providers/date-navigation.service';
import { DatepickerEnabledService } from './providers/datepicker-enabled.service';
import { LocaleHelperService } from './providers/locale-helper.service';
export class ClrDateContainer implements DynamicWrapper, OnDestroy {
// Unused but have to add it :-(
_dynamic: boolean = false;
private _sub: Subscription;
constructor(
private _ifOpenService: IfOpenService,
private _dateNavigationService: DateNavigationService,
private _datepickerEnabledService: DatepickerEnabledService,
private dateFormControlService: DateFormControlService
) {
this._sub = this._ifOpenService.openChange.subscribe(open => {
if (open) {
this.initializeCalendar();
}
});
}
/**
* Returns if the Datepicker is enabled or not. If disabled, hides the datepicker trigger.
*/
get isEnabled(): boolean {
return this._datepickerEnabledService.isEnabled;
}
/**
* Processes the user input and Initializes the Calendar everytime the datepicker popover is open.
*/
private initializeCalendar(): void {
this._dateNavigationService.initializeCalendar();
}
/**
* Toggles the Datepicker Popover.
*/
toggleDatepicker(event: MouseEvent) {
this._ifOpenService.toggleWithEvent(event);
this.dateFormControlService.markAsTouched();
}
/**
* Unsubscribe from subscriptions.
*/
ngOnDestroy() {
this._sub.unsubscribe();
}
}