material-toolbar.umd.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. (function (global, factory) {
  9. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/platform'), require('@angular/common'), require('@angular/core'), require('@angular/material/core')) :
  10. typeof define === 'function' && define.amd ? define('@angular/material/toolbar', ['exports', '@angular/cdk/platform', '@angular/common', '@angular/core', '@angular/material/core'], factory) :
  11. (factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.toolbar = {}),global.ng.cdk.platform,global.ng.common,global.ng.core,global.ng.material.core));
  12. }(this, (function (exports,platform,common,core,core$1) { 'use strict';
  13. /*! *****************************************************************************
  14. Copyright (c) Microsoft Corporation. All rights reserved.
  15. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  16. this file except in compliance with the License. You may obtain a copy of the
  17. License at http://www.apache.org/licenses/LICENSE-2.0
  18. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  20. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  21. MERCHANTABLITY OR NON-INFRINGEMENT.
  22. See the Apache Version 2.0 License for specific language governing permissions
  23. and limitations under the License.
  24. ***************************************************************************** */
  25. /* global Reflect, Promise */
  26. var extendStatics = function(d, b) {
  27. extendStatics = Object.setPrototypeOf ||
  28. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  29. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  30. return extendStatics(d, b);
  31. };
  32. function __extends(d, b) {
  33. extendStatics(d, b);
  34. function __() { this.constructor = d; }
  35. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36. }
  37. /**
  38. * @fileoverview added by tsickle
  39. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  40. */
  41. // Boilerplate for applying mixins to MatToolbar.
  42. /**
  43. * \@docs-private
  44. */
  45. var
  46. // Boilerplate for applying mixins to MatToolbar.
  47. /**
  48. * \@docs-private
  49. */
  50. MatToolbarBase = /** @class */ (function () {
  51. function MatToolbarBase(_elementRef) {
  52. this._elementRef = _elementRef;
  53. }
  54. return MatToolbarBase;
  55. }());
  56. /** @type {?} */
  57. var _MatToolbarMixinBase = core$1.mixinColor(MatToolbarBase);
  58. var MatToolbarRow = /** @class */ (function () {
  59. function MatToolbarRow() {
  60. }
  61. MatToolbarRow.decorators = [
  62. { type: core.Directive, args: [{
  63. selector: 'mat-toolbar-row',
  64. exportAs: 'matToolbarRow',
  65. host: { 'class': 'mat-toolbar-row' },
  66. },] },
  67. ];
  68. return MatToolbarRow;
  69. }());
  70. var MatToolbar = /** @class */ (function (_super) {
  71. __extends(MatToolbar, _super);
  72. function MatToolbar(elementRef, _platform, document) {
  73. var _this = _super.call(this, elementRef) || this;
  74. _this._platform = _platform;
  75. // TODO: make the document a required param when doing breaking changes.
  76. _this._document = document;
  77. return _this;
  78. }
  79. /**
  80. * @return {?}
  81. */
  82. MatToolbar.prototype.ngAfterViewInit = /**
  83. * @return {?}
  84. */
  85. function () {
  86. var _this = this;
  87. if (!core.isDevMode() || !this._platform.isBrowser) {
  88. return;
  89. }
  90. this._checkToolbarMixedModes();
  91. this._toolbarRows.changes.subscribe((/**
  92. * @return {?}
  93. */
  94. function () { return _this._checkToolbarMixedModes(); }));
  95. };
  96. /**
  97. * Throws an exception when developers are attempting to combine the different toolbar row modes.
  98. */
  99. /**
  100. * Throws an exception when developers are attempting to combine the different toolbar row modes.
  101. * @private
  102. * @return {?}
  103. */
  104. MatToolbar.prototype._checkToolbarMixedModes = /**
  105. * Throws an exception when developers are attempting to combine the different toolbar row modes.
  106. * @private
  107. * @return {?}
  108. */
  109. function () {
  110. var _this = this;
  111. if (!this._toolbarRows.length) {
  112. return;
  113. }
  114. // Check if there are any other DOM nodes that can display content but aren't inside of
  115. // a <mat-toolbar-row> element.
  116. /** @type {?} */
  117. var isCombinedUsage = Array.from(this._elementRef.nativeElement.childNodes)
  118. .filter((/**
  119. * @param {?} node
  120. * @return {?}
  121. */
  122. function (node) { return !(node.classList && node.classList.contains('mat-toolbar-row')); }))
  123. .filter((/**
  124. * @param {?} node
  125. * @return {?}
  126. */
  127. function (node) { return node.nodeType !== (_this._document ? _this._document.COMMENT_NODE : 8); }))
  128. .some((/**
  129. * @param {?} node
  130. * @return {?}
  131. */
  132. function (node) { return !!(node.textContent && node.textContent.trim()); }));
  133. if (isCombinedUsage) {
  134. throwToolbarMixedModesError();
  135. }
  136. };
  137. MatToolbar.decorators = [
  138. { type: core.Component, args: [{selector: 'mat-toolbar',
  139. exportAs: 'matToolbar',
  140. template: "<ng-content></ng-content><ng-content select=\"mat-toolbar-row\"></ng-content>",
  141. styles: ["@media (-ms-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%}.mat-toolbar-multiple-rows{min-height:64px}.mat-toolbar-row,.mat-toolbar-single-row{height:64px}@media (max-width:599px){.mat-toolbar-multiple-rows{min-height:56px}.mat-toolbar-row,.mat-toolbar-single-row{height:56px}}"],
  142. inputs: ['color'],
  143. host: {
  144. 'class': 'mat-toolbar',
  145. '[class.mat-toolbar-multiple-rows]': '_toolbarRows.length > 0',
  146. '[class.mat-toolbar-single-row]': '_toolbarRows.length === 0',
  147. },
  148. changeDetection: core.ChangeDetectionStrategy.OnPush,
  149. encapsulation: core.ViewEncapsulation.None,
  150. },] },
  151. ];
  152. /** @nocollapse */
  153. MatToolbar.ctorParameters = function () { return [
  154. { type: core.ElementRef },
  155. { type: platform.Platform },
  156. { type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] }
  157. ]; };
  158. MatToolbar.propDecorators = {
  159. _toolbarRows: [{ type: core.ContentChildren, args: [MatToolbarRow,] }]
  160. };
  161. return MatToolbar;
  162. }(_MatToolbarMixinBase));
  163. /**
  164. * Throws an exception when attempting to combine the different toolbar row modes.
  165. * \@docs-private
  166. * @return {?}
  167. */
  168. function throwToolbarMixedModesError() {
  169. throw Error('MatToolbar: Attempting to combine different toolbar modes. ' +
  170. 'Either specify multiple `<mat-toolbar-row>` elements explicitly or just place content ' +
  171. 'inside of a `<mat-toolbar>` for a single row.');
  172. }
  173. /**
  174. * @fileoverview added by tsickle
  175. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  176. */
  177. var MatToolbarModule = /** @class */ (function () {
  178. function MatToolbarModule() {
  179. }
  180. MatToolbarModule.decorators = [
  181. { type: core.NgModule, args: [{
  182. imports: [core$1.MatCommonModule],
  183. exports: [MatToolbar, MatToolbarRow, core$1.MatCommonModule],
  184. declarations: [MatToolbar, MatToolbarRow],
  185. },] },
  186. ];
  187. return MatToolbarModule;
  188. }());
  189. exports.MatToolbarModule = MatToolbarModule;
  190. exports.throwToolbarMixedModesError = throwToolbarMixedModesError;
  191. exports.MatToolbarRow = MatToolbarRow;
  192. exports.MatToolbar = MatToolbar;
  193. Object.defineProperty(exports, '__esModule', { value: true });
  194. })));
  195. //# sourceMappingURL=material-toolbar.umd.js.map