mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
131 lines
2.9 KiB
131 lines
2.9 KiB
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
|
|
*/
|
|
|
|
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, Renderer2, ViewChild } from '@angular/core';
|
|
|
|
import { slideRightAnimation } from '@app/framework/internal';
|
|
|
|
import { PanelContainerDirective } from './panel-container.directive';
|
|
|
|
@Component({
|
|
selector: 'sqx-panel',
|
|
styleUrls: ['./panel.component.scss'],
|
|
templateUrl: './panel.component.html',
|
|
animations: [
|
|
slideRightAnimation
|
|
],
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
})
|
|
export class PanelComponent implements AfterViewInit, OnDestroy, OnInit {
|
|
private styleWidth: string;
|
|
|
|
@Output()
|
|
public close = new EventEmitter();
|
|
|
|
@Input()
|
|
public theme = 'light';
|
|
|
|
@Input()
|
|
public desiredWidth = '10rem';
|
|
|
|
@Input()
|
|
public minWidth?: string;
|
|
|
|
@Input()
|
|
public isBlank = false;
|
|
|
|
@Input()
|
|
public isFullSize = false;
|
|
|
|
@Input()
|
|
public isLazyLoaded = true;
|
|
|
|
@Input()
|
|
public scrollX = false;
|
|
|
|
@Input()
|
|
public showScrollbar = false;
|
|
|
|
@Input()
|
|
public showSecondHeader = false;
|
|
|
|
@Input()
|
|
public showSidebar = false;
|
|
|
|
@Input()
|
|
public showClose = true;
|
|
|
|
@Input()
|
|
public grid = false;
|
|
|
|
@Input()
|
|
public noPadding = false;
|
|
|
|
@Input()
|
|
public customClose = false;
|
|
|
|
@ViewChild('panel', { static: false })
|
|
public panel: ElementRef<HTMLElement>;
|
|
|
|
public renderWidth = 0;
|
|
|
|
public isViewInit = false;
|
|
|
|
constructor(
|
|
private readonly container: PanelContainerDirective,
|
|
private readonly renderer: Renderer2
|
|
) {
|
|
}
|
|
|
|
public ngOnDestroy() {
|
|
this.container.pop();
|
|
}
|
|
|
|
public ngOnInit() {
|
|
this.container.push(this);
|
|
}
|
|
|
|
public ngAfterViewInit() {
|
|
this.isViewInit = true;
|
|
|
|
this.container.invalidate();
|
|
}
|
|
|
|
public measure(size: string) {
|
|
if (this.styleWidth !== size && this.isViewInit) {
|
|
this.styleWidth = size;
|
|
|
|
const element = this.panel.nativeElement;
|
|
|
|
if (element) {
|
|
this.renderer.setStyle(element, 'width', size);
|
|
this.renderer.setStyle(element, 'minWidth', this.minWidth);
|
|
|
|
this.renderWidth = element.offsetWidth;
|
|
}
|
|
}
|
|
}
|
|
|
|
public arrange(left: any, layer: any) {
|
|
if (this.isViewInit) {
|
|
const element = this.panel.nativeElement;
|
|
|
|
if (element) {
|
|
this.renderer.setStyle(element, 'top', '0px');
|
|
this.renderer.setStyle(element, 'left', left);
|
|
this.renderer.setStyle(element, 'bottom', '0px');
|
|
this.renderer.setStyle(element, 'position', 'absolute');
|
|
|
|
this.renderer.setStyle(element, 'z-index', layer);
|
|
}
|
|
}
|
|
}
|
|
|
|
public emitClose() {
|
|
this.close.emit();
|
|
}
|
|
}
|