/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { Platform } from '@angular/cdk/platform'; import { DOCUMENT } from '@angular/common'; import { ChangeDetectionStrategy, Component, ContentChildren, Directive, ElementRef, Inject, QueryList, ViewEncapsulation, } from '@angular/core'; import { mixinColor } from '@angular/material/core'; // Boilerplate for applying mixins to MatToolbar. /** @docs-private */ const _MatToolbarBase = mixinColor(class { constructor(_elementRef) { this._elementRef = _elementRef; } }); export class MatToolbarRow { } MatToolbarRow.decorators = [ { type: Directive, args: [{ selector: 'mat-toolbar-row', exportAs: 'matToolbarRow', host: { 'class': 'mat-toolbar-row' }, },] } ]; export class MatToolbar extends _MatToolbarBase { constructor(elementRef, _platform, document) { super(elementRef); this._platform = _platform; // TODO: make the document a required param when doing breaking changes. this._document = document; } ngAfterViewInit() { if (this._platform.isBrowser) { this._checkToolbarMixedModes(); this._toolbarRows.changes.subscribe(() => this._checkToolbarMixedModes()); } } /** * Throws an exception when developers are attempting to combine the different toolbar row modes. */ _checkToolbarMixedModes() { if (this._toolbarRows.length && (typeof ngDevMode === 'undefined' || ngDevMode)) { // Check if there are any other DOM nodes that can display content but aren't inside of // a element. const isCombinedUsage = Array.from(this._elementRef.nativeElement.childNodes) .filter(node => !(node.classList && node.classList.contains('mat-toolbar-row'))) .filter(node => node.nodeType !== (this._document ? this._document.COMMENT_NODE : 8)) .some(node => !!(node.textContent && node.textContent.trim())); if (isCombinedUsage) { throwToolbarMixedModesError(); } } } } MatToolbar.decorators = [ { type: Component, args: [{ selector: 'mat-toolbar', exportAs: 'matToolbar', template: "\n\n", inputs: ['color'], host: { 'class': 'mat-toolbar', '[class.mat-toolbar-multiple-rows]': '_toolbarRows.length > 0', '[class.mat-toolbar-single-row]': '_toolbarRows.length === 0', }, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: [".cdk-high-contrast-active .mat-toolbar{outline:solid 1px}.mat-toolbar-row,.mat-toolbar-single-row{display:flex;box-sizing:border-box;padding:0 16px;width:100%;flex-direction:row;align-items:center;white-space:nowrap}.mat-toolbar-multiple-rows{display:flex;box-sizing:border-box;flex-direction:column;width:100%}\n"] },] } ]; MatToolbar.ctorParameters = () => [ { type: ElementRef }, { type: Platform }, { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] } ]; MatToolbar.propDecorators = { _toolbarRows: [{ type: ContentChildren, args: [MatToolbarRow, { descendants: true },] }] }; /** * Throws an exception when attempting to combine the different toolbar row modes. * @docs-private */ export function throwToolbarMixedModesError() { throw Error('MatToolbar: Attempting to combine different toolbar modes. ' + 'Either specify multiple `` elements explicitly or just place content ' + 'inside of a `` for a single row.'); } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9vbGJhci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC90b29sYmFyL3Rvb2xiYXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLFFBQVEsRUFBQyxNQUFNLHVCQUF1QixDQUFDO0FBQy9DLE9BQU8sRUFBQyxRQUFRLEVBQUMsTUFBTSxpQkFBaUIsQ0FBQztBQUN6QyxPQUFPLEVBRUwsdUJBQXVCLEVBQ3ZCLFNBQVMsRUFDVCxlQUFlLEVBQ2YsU0FBUyxFQUNULFVBQVUsRUFDVixNQUFNLEVBQ04sU0FBUyxFQUNULGlCQUFpQixHQUNsQixNQUFNLGVBQWUsQ0FBQztBQUN2QixPQUFPLEVBQVcsVUFBVSxFQUFDLE1BQU0sd0JBQXdCLENBQUM7QUFHNUQsaURBQWlEO0FBQ2pELG9CQUFvQjtBQUNwQixNQUFNLGVBQWUsR0FBRyxVQUFVLENBQUM7SUFDakMsWUFBbUIsV0FBdUI7UUFBdkIsZ0JBQVcsR0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