/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import 'vs/css!./flexContainer'; import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ComponentFactoryResolver, ViewChild, ViewChildren, ElementRef, Injector, OnDestroy, QueryList, } from '@angular/core'; import { IComponent, IComponentDescriptor, IModelStore } from 'sql/parts/modelComponents/interfaces'; import { FlexLayout, FlexItemLayout } from 'sqlops'; import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; import { ContainerBase } from 'sql/parts/modelComponents/componentBase'; import { ModelComponentWrapper } from 'sql/parts/modelComponents/modelComponentWrapper.component'; import types = require('vs/base/common/types'); class FlexItem { constructor(public descriptor: IComponentDescriptor, public config: FlexItemLayout) { } } @Component({ template: `
` }) export default class FlexContainer extends ContainerBase implements IComponent, OnDestroy { @Input() descriptor: IComponentDescriptor; @Input() modelStore: IModelStore; private _flexFlow: string; private _justifyContent: string; private _alignItems: string; private _alignContent: string; private _textAlign: string; private _height: string; private _width: string; constructor(@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { super(changeRef); this._flexFlow = ''; // default this._justifyContent = ''; // default } ngOnInit(): void { this.baseInit(); } ngOnDestroy(): void { this.baseDestroy(); } /// IComponent implementation public setLayout(layout: FlexLayout): void { this._flexFlow = layout.flexFlow ? layout.flexFlow : ''; this._justifyContent = layout.justifyContent ? layout.justifyContent : ''; this._alignItems = layout.alignItems ? layout.alignItems : ''; this._alignContent = layout.alignContent ? layout.alignContent : ''; this._textAlign = layout.textAlign ? layout.textAlign : ''; this._height = this.convertSize(layout.height); this._width = this.convertSize(layout.width); this.layout(); } // CSS-bound properties public get flexFlow(): string { return this._flexFlow; } public get justifyContent(): string { return this._justifyContent; } public get alignItems(): string { return this._alignItems; } public get height(): string { return this._height; } public get width(): string { return this._width; } public get alignContent(): string { return this._alignContent; } public get textAlign(): string { return this._textAlign; } private getItemFlex(item: FlexItem): string { return item.config ? item.config.flex : '1 1 auto'; } private getItemOrder(item: FlexItem): number { return item.config ? item.config.order : 0; } }