@clr/angular
Version:
Angular components for Clarity
101 lines (95 loc) • 4.96 kB
JavaScript
import * as i0 from '@angular/core';
import { Directive, NgModule } from '@angular/core';
import * as i1 from '@clr/angular/layout/nav';
import { ResponsiveNavCodes } from '@clr/angular/layout/nav';
import { CommonModule } from '@angular/common';
import { ClrIcon } from '@clr/angular/icon';
/*
* Copyright (c) 2016-2026 Broadcom. All Rights Reserved.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
class ClrMainContainer {
constructor(elRef, responsiveNavService) {
this.elRef = elRef;
this.responsiveNavService = responsiveNavService;
}
ngOnInit() {
this._classList = this.elRef.nativeElement.classList;
this._subscription = this.responsiveNavService.navControl.subscribe({
next: (message) => {
this.processMessage(message);
},
});
}
processMessage(message) {
let navClass = ResponsiveNavCodes.NAV_CLASS_HAMBURGER_MENU;
if (message.controlCode === ResponsiveNavCodes.NAV_CLOSE_ALL) {
this._classList.remove(ResponsiveNavCodes.NAV_CLASS_HAMBURGER_MENU);
this._classList.remove(ResponsiveNavCodes.NAV_CLASS_OVERFLOW_MENU);
}
else if (message.navLevel === ResponsiveNavCodes.NAV_LEVEL_1) {
this.controlNav(message.controlCode, navClass);
}
else if (message.navLevel === ResponsiveNavCodes.NAV_LEVEL_2) {
navClass = ResponsiveNavCodes.NAV_CLASS_OVERFLOW_MENU;
this.controlNav(message.controlCode, navClass);
}
}
controlNav(controlCode, navClass) {
if (controlCode === ResponsiveNavCodes.NAV_OPEN) {
this._classList.add(navClass);
}
else if (controlCode === ResponsiveNavCodes.NAV_CLOSE) {
this._classList.remove(navClass);
}
else if (controlCode === ResponsiveNavCodes.NAV_TOGGLE) {
this._classList.toggle(navClass);
}
}
ngOnDestroy() {
this._subscription.unsubscribe();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ClrMainContainer, deps: [{ token: i0.ElementRef }, { token: i1.ResponsiveNavigationService }], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.3", type: ClrMainContainer, isStandalone: false, selector: "clr-main-container", host: { properties: { "class.main-container": "true" } }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ClrMainContainer, decorators: [{
type: Directive,
args: [{
selector: 'clr-main-container',
host: { '[class.main-container]': 'true' },
standalone: false,
}]
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i1.ResponsiveNavigationService }] });
/*
* Copyright (c) 2016-2026 Broadcom. All Rights Reserved.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
const CLR_LAYOUT_DIRECTIVES = [ClrMainContainer];
class ClrMainContainerModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ClrMainContainerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: ClrMainContainerModule, declarations: [ClrMainContainer], imports: [CommonModule, ClrIcon], exports: [ClrMainContainer] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ClrMainContainerModule, imports: [CommonModule, ClrIcon] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ClrMainContainerModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule, ClrIcon],
declarations: [CLR_LAYOUT_DIRECTIVES],
exports: [CLR_LAYOUT_DIRECTIVES],
}]
}] });
/*
* Copyright (c) 2016-2026 Broadcom. All Rights Reserved.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
/**
* Generated bundle index. Do not edit.
*/
export { CLR_LAYOUT_DIRECTIVES, ClrMainContainer, ClrMainContainerModule };
//# sourceMappingURL=clr-angular-layout-main-container.mjs.map