clr-angular-static-fix
Version:
1. Install Clarity Icons package through npm:
78 lines (70 loc) • 2.68 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, ContentChild, OnDestroy, Optional } from '@angular/core';
import { Subscription } from 'rxjs';
import { IfErrorService } from '../common/if-error/if-error.service';
import { NgControlService } from '../common/providers/ng-control.service';
import { LayoutService } from '../common/providers/layout.service';
import { DynamicWrapper } from '../../utils/host-wrapping/dynamic-wrapper';
import { ControlIdService } from '../common/providers/control-id.service';
import { ClrLabel } from '../common/label';
import { ControlClassService } from '../common/providers/control-class.service';
export class ClrInputContainer implements DynamicWrapper, OnDestroy {
subscription: Subscription;
invalid = false;
_dynamic = false;
label: ClrLabel;
constructor(
private ifErrorService: IfErrorService,
private layoutService: LayoutService,
private controlClassService: ControlClassService
) {
this.subscription = this.ifErrorService.statusChanges.subscribe(control => {
this.invalid = control.invalid;
});
}
controlClass() {
const controlClasses = [];
if (this.invalid) {
controlClasses.push('clr-error');
}
if (this.addGrid() && this.controlClassService.className.indexOf('clr-col') === -1) {
controlClasses.push('clr-col-md-10 clr-col-xs-12');
}
return controlClasses.join(' ');
}
addGrid() {
if (this.layoutService && !this.layoutService.isVertical()) {
return true;
}
return false;
}
ngOnDestroy() {
if (this.subscription) {
this.subscription.unsubscribe();
}
}
}