material-progress-bar.umd.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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/core'), require('rxjs'), require('rxjs/operators'), require('@angular/platform-browser/animations'), require('@angular/material/core'), require('@angular/common')) :
  10. typeof define === 'function' && define.amd ? define('@angular/material/progress-bar', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/platform-browser/animations', '@angular/material/core', '@angular/common'], factory) :
  11. (factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.progressBar = {}),global.ng.core,global.rxjs,global.rxjs.operators,global.ng.platformBrowser.animations,global.ng.material.core,global.ng.common));
  12. }(this, (function (exports,core,rxjs,operators,animations,core$1,common) { '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 MatProgressBar.
  42. /**
  43. * \@docs-private
  44. */
  45. var
  46. // Boilerplate for applying mixins to MatProgressBar.
  47. /**
  48. * \@docs-private
  49. */
  50. MatProgressBarBase = /** @class */ (function () {
  51. function MatProgressBarBase(_elementRef) {
  52. this._elementRef = _elementRef;
  53. }
  54. return MatProgressBarBase;
  55. }());
  56. /** @type {?} */
  57. var _MatProgressBarMixinBase = core$1.mixinColor(MatProgressBarBase, 'primary');
  58. /**
  59. * Injection token used to provide the current location to `MatProgressBar`.
  60. * Used to handle server-side rendering and to stub out during unit tests.
  61. * \@docs-private
  62. * @type {?}
  63. */
  64. var MAT_PROGRESS_BAR_LOCATION = new core.InjectionToken('mat-progress-bar-location', { providedIn: 'root', factory: MAT_PROGRESS_BAR_LOCATION_FACTORY });
  65. /**
  66. * \@docs-private
  67. * @return {?}
  68. */
  69. function MAT_PROGRESS_BAR_LOCATION_FACTORY() {
  70. /** @type {?} */
  71. var _document = core.inject(common.DOCUMENT);
  72. /** @type {?} */
  73. var _location = _document ? _document.location : null;
  74. return {
  75. // Note that this needs to be a function, rather than a property, because Angular
  76. // will only resolve it once, but we want the current path on each call.
  77. getPathname: (/**
  78. * @return {?}
  79. */
  80. function () { return _location ? (_location.pathname + _location.search) : ''; })
  81. };
  82. }
  83. /**
  84. * Counter used to generate unique IDs for progress bars.
  85. * @type {?}
  86. */
  87. var progressbarId = 0;
  88. /**
  89. * `<mat-progress-bar>` component.
  90. */
  91. var MatProgressBar = /** @class */ (function (_super) {
  92. __extends(MatProgressBar, _super);
  93. function MatProgressBar(_elementRef, _ngZone, _animationMode,
  94. /**
  95. * @deprecated `location` parameter to be made required.
  96. * @breaking-change 8.0.0
  97. */
  98. location) {
  99. var _this = _super.call(this, _elementRef) || this;
  100. _this._elementRef = _elementRef;
  101. _this._ngZone = _ngZone;
  102. _this._animationMode = _animationMode;
  103. /**
  104. * Flag that indicates whether NoopAnimations mode is set to true.
  105. */
  106. _this._isNoopAnimation = false;
  107. _this._value = 0;
  108. _this._bufferValue = 0;
  109. /**
  110. * Event emitted when animation of the primary progress bar completes. This event will not
  111. * be emitted when animations are disabled, nor will it be emitted for modes with continuous
  112. * animations (indeterminate and query).
  113. */
  114. _this.animationEnd = new core.EventEmitter();
  115. /**
  116. * Reference to animation end subscription to be unsubscribed on destroy.
  117. */
  118. _this._animationEndSubscription = rxjs.Subscription.EMPTY;
  119. /**
  120. * Mode of the progress bar.
  121. *
  122. * Input must be one of these values: determinate, indeterminate, buffer, query, defaults to
  123. * 'determinate'.
  124. * Mirrored to mode attribute.
  125. */
  126. _this.mode = 'determinate';
  127. /**
  128. * ID of the progress bar.
  129. */
  130. _this.progressbarId = "mat-progress-bar-" + progressbarId++;
  131. // We need to prefix the SVG reference with the current path, otherwise they won't work
  132. // in Safari if the page has a `<base>` tag. Note that we need quotes inside the `url()`,
  133. // because named route URLs can contain parentheses (see #12338). Also we don't use since
  134. // we can't tell the difference between whether
  135. // the consumer is using the hash location strategy or not, because `Location` normalizes
  136. // both `/#/foo/bar` and `/foo/bar` to the same thing.
  137. /** @type {?} */
  138. var path = location ? location.getPathname().split('#')[0] : '';
  139. _this._rectangleFillValue = "url('" + path + "#" + _this.progressbarId + "')";
  140. _this._isNoopAnimation = _animationMode === 'NoopAnimations';
  141. return _this;
  142. }
  143. Object.defineProperty(MatProgressBar.prototype, "value", {
  144. /** Value of the progress bar. Defaults to zero. Mirrored to aria-valuenow. */
  145. get: /**
  146. * Value of the progress bar. Defaults to zero. Mirrored to aria-valuenow.
  147. * @return {?}
  148. */
  149. function () { return this._value; },
  150. set: /**
  151. * @param {?} v
  152. * @return {?}
  153. */
  154. function (v) {
  155. this._value = clamp(v || 0);
  156. // When noop animation is set to true, trigger animationEnd directly.
  157. if (this._isNoopAnimation) {
  158. this._emitAnimationEnd();
  159. }
  160. },
  161. enumerable: true,
  162. configurable: true
  163. });
  164. Object.defineProperty(MatProgressBar.prototype, "bufferValue", {
  165. /** Buffer value of the progress bar. Defaults to zero. */
  166. get: /**
  167. * Buffer value of the progress bar. Defaults to zero.
  168. * @return {?}
  169. */
  170. function () { return this._bufferValue; },
  171. set: /**
  172. * @param {?} v
  173. * @return {?}
  174. */
  175. function (v) { this._bufferValue = clamp(v || 0); },
  176. enumerable: true,
  177. configurable: true
  178. });
  179. /** Gets the current transform value for the progress bar's primary indicator. */
  180. /**
  181. * Gets the current transform value for the progress bar's primary indicator.
  182. * @return {?}
  183. */
  184. MatProgressBar.prototype._primaryTransform = /**
  185. * Gets the current transform value for the progress bar's primary indicator.
  186. * @return {?}
  187. */
  188. function () {
  189. /** @type {?} */
  190. var scale = this.value / 100;
  191. return { transform: "scaleX(" + scale + ")" };
  192. };
  193. /**
  194. * Gets the current transform value for the progress bar's buffer indicator. Only used if the
  195. * progress mode is set to buffer, otherwise returns an undefined, causing no transformation.
  196. */
  197. /**
  198. * Gets the current transform value for the progress bar's buffer indicator. Only used if the
  199. * progress mode is set to buffer, otherwise returns an undefined, causing no transformation.
  200. * @return {?}
  201. */
  202. MatProgressBar.prototype._bufferTransform = /**
  203. * Gets the current transform value for the progress bar's buffer indicator. Only used if the
  204. * progress mode is set to buffer, otherwise returns an undefined, causing no transformation.
  205. * @return {?}
  206. */
  207. function () {
  208. if (this.mode === 'buffer') {
  209. /** @type {?} */
  210. var scale = this.bufferValue / 100;
  211. return { transform: "scaleX(" + scale + ")" };
  212. }
  213. return undefined;
  214. };
  215. /**
  216. * @return {?}
  217. */
  218. MatProgressBar.prototype.ngAfterViewInit = /**
  219. * @return {?}
  220. */
  221. function () {
  222. var _this = this;
  223. if (!this._isNoopAnimation) {
  224. // Run outside angular so change detection didn't get triggered on every transition end
  225. // instead only on the animation that we care about (primary value bar's transitionend)
  226. this._ngZone.runOutsideAngular(((/**
  227. * @return {?}
  228. */
  229. function () {
  230. /** @type {?} */
  231. var element = _this._primaryValueBar.nativeElement;
  232. _this._animationEndSubscription =
  233. ((/** @type {?} */ (rxjs.fromEvent(element, 'transitionend'))))
  234. .pipe(operators.filter(((/**
  235. * @param {?} e
  236. * @return {?}
  237. */
  238. function (e) { return e.target === element; }))))
  239. .subscribe((/**
  240. * @return {?}
  241. */
  242. function () { return _this._ngZone.run((/**
  243. * @return {?}
  244. */
  245. function () { return _this._emitAnimationEnd(); })); }));
  246. })));
  247. }
  248. };
  249. /**
  250. * @return {?}
  251. */
  252. MatProgressBar.prototype.ngOnDestroy = /**
  253. * @return {?}
  254. */
  255. function () {
  256. this._animationEndSubscription.unsubscribe();
  257. };
  258. /** Emit an animationEnd event if in determinate or buffer mode. */
  259. /**
  260. * Emit an animationEnd event if in determinate or buffer mode.
  261. * @private
  262. * @return {?}
  263. */
  264. MatProgressBar.prototype._emitAnimationEnd = /**
  265. * Emit an animationEnd event if in determinate or buffer mode.
  266. * @private
  267. * @return {?}
  268. */
  269. function () {
  270. if (this.mode === 'determinate' || this.mode === 'buffer') {
  271. this.animationEnd.next({ value: this.value });
  272. }
  273. };
  274. MatProgressBar.decorators = [
  275. { type: core.Component, args: [{selector: 'mat-progress-bar',
  276. exportAs: 'matProgressBar',
  277. host: {
  278. 'role': 'progressbar',
  279. 'aria-valuemin': '0',
  280. 'aria-valuemax': '100',
  281. '[attr.aria-valuenow]': '(mode === "indeterminate" || mode === "query") ? null : value',
  282. '[attr.mode]': 'mode',
  283. 'class': 'mat-progress-bar',
  284. '[class._mat-animation-noopable]': '_isNoopAnimation',
  285. },
  286. inputs: ['color'],
  287. template: "<svg width=\"100%\" height=\"4\" focusable=\"false\" class=\"mat-progress-bar-background mat-progress-bar-element\"><defs><pattern [id]=\"progressbarId\" x=\"4\" y=\"0\" width=\"8\" height=\"4\" patternUnits=\"userSpaceOnUse\"><circle cx=\"2\" cy=\"2\" r=\"2\"/></pattern></defs><rect [attr.fill]=\"_rectangleFillValue\" width=\"100%\" height=\"100%\"/></svg><div class=\"mat-progress-bar-buffer mat-progress-bar-element\" [ngStyle]=\"_bufferTransform()\"></div><div class=\"mat-progress-bar-primary mat-progress-bar-fill mat-progress-bar-element\" [ngStyle]=\"_primaryTransform()\" #primaryValueBar></div><div class=\"mat-progress-bar-secondary mat-progress-bar-fill mat-progress-bar-element\"></div>",
  288. styles: [".mat-progress-bar{display:block;height:4px;overflow:hidden;position:relative;transition:opacity 250ms linear;width:100%}._mat-animation-noopable.mat-progress-bar{transition:none;animation:none}.mat-progress-bar .mat-progress-bar-element,.mat-progress-bar .mat-progress-bar-fill::after{height:100%;position:absolute;width:100%}.mat-progress-bar .mat-progress-bar-background{width:calc(100% + 10px)}@media (-ms-high-contrast:active){.mat-progress-bar .mat-progress-bar-background{display:none}}.mat-progress-bar .mat-progress-bar-buffer{transform-origin:top left;transition:transform 250ms ease}@media (-ms-high-contrast:active){.mat-progress-bar .mat-progress-bar-buffer{border-top:solid 5px;opacity:.5}}.mat-progress-bar .mat-progress-bar-secondary{display:none}.mat-progress-bar .mat-progress-bar-fill{animation:none;transform-origin:top left;transition:transform 250ms ease}@media (-ms-high-contrast:active){.mat-progress-bar .mat-progress-bar-fill{border-top:solid 4px}}.mat-progress-bar .mat-progress-bar-fill::after{animation:none;content:'';display:inline-block;left:0}.mat-progress-bar[dir=rtl],[dir=rtl] .mat-progress-bar{transform:rotateY(180deg)}.mat-progress-bar[mode=query]{transform:rotateZ(180deg)}.mat-progress-bar[mode=query][dir=rtl],[dir=rtl] .mat-progress-bar[mode=query]{transform:rotateZ(180deg) rotateY(180deg)}.mat-progress-bar[mode=indeterminate] .mat-progress-bar-fill,.mat-progress-bar[mode=query] .mat-progress-bar-fill{transition:none}.mat-progress-bar[mode=indeterminate] .mat-progress-bar-primary,.mat-progress-bar[mode=query] .mat-progress-bar-primary{-webkit-backface-visibility:hidden;backface-visibility:hidden;animation:mat-progress-bar-primary-indeterminate-translate 2s infinite linear;left:-145.166611%}.mat-progress-bar[mode=indeterminate] .mat-progress-bar-primary.mat-progress-bar-fill::after,.mat-progress-bar[mode=query] .mat-progress-bar-primary.mat-progress-bar-fill::after{-webkit-backface-visibility:hidden;backface-visibility:hidden;animation:mat-progress-bar-primary-indeterminate-scale 2s infinite linear}.mat-progress-bar[mode=indeterminate] .mat-progress-bar-secondary,.mat-progress-bar[mode=query] .mat-progress-bar-secondary{-webkit-backface-visibility:hidden;backface-visibility:hidden;animation:mat-progress-bar-secondary-indeterminate-translate 2s infinite linear;left:-54.888891%;display:block}.mat-progress-bar[mode=indeterminate] .mat-progress-bar-secondary.mat-progress-bar-fill::after,.mat-progress-bar[mode=query] .mat-progress-bar-secondary.mat-progress-bar-fill::after{-webkit-backface-visibility:hidden;backface-visibility:hidden;animation:mat-progress-bar-secondary-indeterminate-scale 2s infinite linear}.mat-progress-bar[mode=buffer] .mat-progress-bar-background{-webkit-backface-visibility:hidden;backface-visibility:hidden;animation:mat-progress-bar-background-scroll 250ms infinite linear;display:block}.mat-progress-bar._mat-animation-noopable .mat-progress-bar-background,.mat-progress-bar._mat-animation-noopable .mat-progress-bar-buffer,.mat-progress-bar._mat-animation-noopable .mat-progress-bar-fill,.mat-progress-bar._mat-animation-noopable .mat-progress-bar-fill::after,.mat-progress-bar._mat-animation-noopable .mat-progress-bar-primary,.mat-progress-bar._mat-animation-noopable .mat-progress-bar-primary.mat-progress-bar-fill::after,.mat-progress-bar._mat-animation-noopable .mat-progress-bar-secondary,.mat-progress-bar._mat-animation-noopable .mat-progress-bar-secondary.mat-progress-bar-fill::after{animation:none;transition:none}@keyframes mat-progress-bar-primary-indeterminate-translate{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(.5,0,.70173,.49582);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(.30244,.38135,.55,.95635);transform:translateX(83.67142%)}100%{transform:translateX(200.61106%)}}@keyframes mat-progress-bar-primary-indeterminate-scale{0%{transform:scaleX(.08)}36.65%{animation-timing-function:cubic-bezier(.33473,.12482,.78584,1);transform:scaleX(.08)}69.15%{animation-timing-function:cubic-bezier(.06,.11,.6,1);transform:scaleX(.66148)}100%{transform:scaleX(.08)}}@keyframes mat-progress-bar-secondary-indeterminate-translate{0%{animation-timing-function:cubic-bezier(.15,0,.51506,.40969);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(.31033,.28406,.8,.73371);transform:translateX(37.65191%)}48.35%{animation-timing-function:cubic-bezier(.4,.62704,.6,.90203);transform:translateX(84.38617%)}100%{transform:translateX(160.27778%)}}@keyframes mat-progress-bar-secondary-indeterminate-scale{0%{animation-timing-function:cubic-bezier(.15,0,.51506,.40969);transform:scaleX(.08)}19.15%{animation-timing-function:cubic-bezier(.31033,.28406,.8,.73371);transform:scaleX(.4571)}44.15%{animation-timing-function:cubic-bezier(.4,.62704,.6,.90203);transform:scaleX(.72796)}100%{transform:scaleX(.08)}}@keyframes mat-progress-bar-background-scroll{to{transform:translateX(-8px)}}"],
  289. changeDetection: core.ChangeDetectionStrategy.OnPush,
  290. encapsulation: core.ViewEncapsulation.None,
  291. },] },
  292. ];
  293. /** @nocollapse */
  294. MatProgressBar.ctorParameters = function () { return [
  295. { type: core.ElementRef },
  296. { type: core.NgZone },
  297. { type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [animations.ANIMATION_MODULE_TYPE,] }] },
  298. { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [MAT_PROGRESS_BAR_LOCATION,] }] }
  299. ]; };
  300. MatProgressBar.propDecorators = {
  301. value: [{ type: core.Input }],
  302. bufferValue: [{ type: core.Input }],
  303. _primaryValueBar: [{ type: core.ViewChild, args: ['primaryValueBar', { static: false },] }],
  304. animationEnd: [{ type: core.Output }],
  305. mode: [{ type: core.Input }]
  306. };
  307. return MatProgressBar;
  308. }(_MatProgressBarMixinBase));
  309. /**
  310. * Clamps a value to be between two numbers, by default 0 and 100.
  311. * @param {?} v
  312. * @param {?=} min
  313. * @param {?=} max
  314. * @return {?}
  315. */
  316. function clamp(v, min, max) {
  317. if (min === void 0) { min = 0; }
  318. if (max === void 0) { max = 100; }
  319. return Math.max(min, Math.min(max, v));
  320. }
  321. /**
  322. * @fileoverview added by tsickle
  323. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  324. */
  325. var MatProgressBarModule = /** @class */ (function () {
  326. function MatProgressBarModule() {
  327. }
  328. MatProgressBarModule.decorators = [
  329. { type: core.NgModule, args: [{
  330. imports: [common.CommonModule, core$1.MatCommonModule],
  331. exports: [MatProgressBar, core$1.MatCommonModule],
  332. declarations: [MatProgressBar],
  333. },] },
  334. ];
  335. return MatProgressBarModule;
  336. }());
  337. exports.MatProgressBarModule = MatProgressBarModule;
  338. exports.MAT_PROGRESS_BAR_LOCATION_FACTORY = MAT_PROGRESS_BAR_LOCATION_FACTORY;
  339. exports.MAT_PROGRESS_BAR_LOCATION = MAT_PROGRESS_BAR_LOCATION;
  340. exports.MatProgressBar = MatProgressBar;
  341. Object.defineProperty(exports, '__esModule', { value: true });
  342. })));
  343. //# sourceMappingURL=material-progress-bar.umd.js.map