Revert codestyle changes (#40)

* Revert "7f7efbb94bab8574e42d942ad82d414e007b2970"

Code style changes should probably be part of a PR
This commit is contained in:
Eliot Partridge
2019-08-30 10:53:14 -05:00
committed by GitHub
parent eefd9e9a2c
commit caf70a864f
446 changed files with 70667 additions and 70655 deletions
+66 -66
View File
@@ -1,93 +1,93 @@
import {
Component, Directive, TemplateRef, Input, ContentChild, ContentChildren, QueryList, Output, EventEmitter
Component, Directive, TemplateRef, Input, ContentChild, ContentChildren, QueryList, Output, EventEmitter
} from '@angular/core';
import { uniqueId } from 'lodash';
import { Key } from '../../../client/input/input';
@Directive({
selector: '[tabTitle]'
selector: '[tabTitle]'
})
export class TabTitle {
constructor(public templateRef: TemplateRef<any>) {
}
constructor(public templateRef: TemplateRef<any>) {
}
}
@Directive({
selector: '[tabContent]',
selector: '[tabContent]',
})
export class TabContent {
constructor(public templateRef: TemplateRef<any>) {
}
constructor(public templateRef: TemplateRef<any>) {
}
}
@Directive({
selector: 'tab',
selector: 'tab',
})
export class Tab {
@Input() id = uniqueId(`tabset-tab`);
@Input() title?: string;
@Input() icon?: any;
@Input() disabled = false;
@ContentChild(TabContent, { static: false }) contentTpl?: TabContent;
@ContentChild(TabTitle, { static: false }) titleTpl?: TabTitle;
@Input() id = uniqueId(`tabset-tab`);
@Input() title?: string;
@Input() icon?: any;
@Input() disabled = false;
@ContentChild(TabContent, { static: false }) contentTpl?: TabContent;
@ContentChild(TabTitle, { static: false }) titleTpl?: TabTitle;
}
@Component({
selector: 'tabset',
templateUrl: 'tabset.pug',
selector: 'tabset',
templateUrl: 'tabset.pug',
})
export class Tabset {
justifyClass?: string;
@ContentChildren(Tab) tabs!: QueryList<Tab>;
@Input() label = '';
@Input() destroyOnHide = true;
@Input()
set justify(className: 'start' | 'center' | 'end' | 'fill' | 'justified') {
if (className === 'fill' || className === 'justified') {
this.justifyClass = `nav-${className}`;
} else {
this.justifyClass = `justify-content-${className}`;
}
}
@Input() orientation: 'horizontal' | 'vertical' = 'horizontal';
@Input() type: 'tabs' | 'pills' = 'tabs';
@Input() activeIndex = 0;
@Output() activeIndexChange = new EventEmitter<number>();
constructor() {
this.justify = 'start';
}
get navClass() {
return `nav-${this.type}${this.orientation === 'horizontal' ? ` ${this.justifyClass}` : ' flex-column'}`;
}
select(index: number) {
if (this.activeIndex !== index) {
this.activeIndex = index;
this.activeIndexChange.emit(index);
}
}
keydown(e: KeyboardEvent) {
const index = this.handleKey(e.keyCode);
justifyClass?: string;
@ContentChildren(Tab) tabs!: QueryList<Tab>;
@Input() label = '';
@Input() destroyOnHide = true;
@Input()
set justify(className: 'start' | 'center' | 'end' | 'fill' | 'justified') {
if (className === 'fill' || className === 'justified') {
this.justifyClass = `nav-${className}`;
} else {
this.justifyClass = `justify-content-${className}`;
}
}
@Input() orientation: 'horizontal' | 'vertical' = 'horizontal';
@Input() type: 'tabs' | 'pills' = 'tabs';
@Input() activeIndex = 0;
@Output() activeIndexChange = new EventEmitter<number>();
constructor() {
this.justify = 'start';
}
get navClass() {
return `nav-${this.type}${this.orientation === 'horizontal' ? ` ${this.justifyClass}` : ' flex-column'}`;
}
select(index: number) {
if (this.activeIndex !== index) {
this.activeIndex = index;
this.activeIndexChange.emit(index);
}
}
keydown(e: KeyboardEvent) {
const index = this.handleKey(e.keyCode);
if (index !== undefined) {
e.preventDefault();
const element = document.getElementById(this.tabs.toArray()[index].id);
element && element.focus();
this.select(index);
}
}
private handleKey(keyCode: number) {
if (keyCode === Key.LEFT) {
return this.activeIndex === 0 ? this.tabs.length - 1 : this.activeIndex - 1;
} else if (keyCode === Key.RIGHT) {
return this.activeIndex === this.tabs.length - 1 ? 0 : this.activeIndex + 1;
} else if (keyCode === Key.HOME) {
return 0;
} else if (keyCode === Key.END) {
return this.tabs.length - 1;
} else {
return undefined;
}
}
if (index !== undefined) {
e.preventDefault();
const element = document.getElementById(this.tabs.toArray()[index].id);
element && element.focus();
this.select(index);
}
}
private handleKey(keyCode: number) {
if (keyCode === Key.LEFT) {
return this.activeIndex === 0 ? this.tabs.length - 1 : this.activeIndex - 1;
} else if (keyCode === Key.RIGHT) {
return this.activeIndex === this.tabs.length - 1 ? 0 : this.activeIndex + 1;
} else if (keyCode === Key.HOME) {
return 0;
} else if (keyCode === Key.END) {
return this.tabs.length - 1;
} else {
return undefined;
}
}
}
export const tabsetComponents = [TabContent, TabTitle, Tabset, Tab];