| /** |
| * @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 { __extends } from 'tslib'; |
| import { Component, ChangeDetectionStrategy, ElementRef, Inject, Input, Output, EventEmitter, Optional, NgZone, ViewEncapsulation, ViewChild, InjectionToken, inject, NgModule } from '@angular/core'; |
| import { fromEvent, Subscription } from 'rxjs'; |
| import { filter } from 'rxjs/operators'; |
| import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations'; |
| import { mixinColor, MatCommonModule } from '@angular/material/core'; |
| import { DOCUMENT, CommonModule } from '@angular/common'; |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| // Boilerplate for applying mixins to MatProgressBar. |
| /** |
| * \@docs-private |
| */ |
| var |
| // Boilerplate for applying mixins to MatProgressBar. |
| /** |
| * \@docs-private |
| */ |
| MatProgressBarBase = /** @class */ (function () { |
| function MatProgressBarBase(_elementRef) { |
| this._elementRef = _elementRef; |
| } |
| return MatProgressBarBase; |
| }()); |
| /** @type {?} */ |
| var _MatProgressBarMixinBase = mixinColor(MatProgressBarBase, 'primary'); |
| /** |
| * Injection token used to provide the current location to `MatProgressBar`. |
| * Used to handle server-side rendering and to stub out during unit tests. |
| * \@docs-private |
| * @type {?} |
| */ |
| var MAT_PROGRESS_BAR_LOCATION = new InjectionToken('mat-progress-bar-location', { providedIn: 'root', factory: MAT_PROGRESS_BAR_LOCATION_FACTORY }); |
| /** |
| * \@docs-private |
| * @return {?} |
| */ |
| function MAT_PROGRESS_BAR_LOCATION_FACTORY() { |
| /** @type {?} */ |
| var _document = inject(DOCUMENT); |
| /** @type {?} */ |
| var _location = _document ? _document.location : null; |
| return { |
| // Note that this needs to be a function, rather than a property, because Angular |
| // will only resolve it once, but we want the current path on each call. |
| getPathname: (/** |
| * @return {?} |
| */ |
| function () { return _location ? (_location.pathname + _location.search) : ''; }) |
| }; |
| } |
| /** |
| * Counter used to generate unique IDs for progress bars. |
| * @type {?} |
| */ |
| var progressbarId = 0; |
| /** |
| * `<mat-progress-bar>` component. |
| */ |
| var MatProgressBar = /** @class */ (function (_super) { |
| __extends(MatProgressBar, _super); |
| function MatProgressBar(_elementRef, _ngZone, _animationMode, |
| /** |
| * @deprecated `location` parameter to be made required. |
| * @breaking-change 8.0.0 |
| */ |
| location) { |
| var _this = _super.call(this, _elementRef) || this; |
| _this._elementRef = _elementRef; |
| _this._ngZone = _ngZone; |
| _this._animationMode = _animationMode; |
| /** |
| * Flag that indicates whether NoopAnimations mode is set to true. |
| */ |
| _this._isNoopAnimation = false; |
| _this._value = 0; |
| _this._bufferValue = 0; |
| /** |
| * Event emitted when animation of the primary progress bar completes. This event will not |
| * be emitted when animations are disabled, nor will it be emitted for modes with continuous |
| * animations (indeterminate and query). |
| */ |
| _this.animationEnd = new EventEmitter(); |
| /** |
| * Reference to animation end subscription to be unsubscribed on destroy. |
| */ |
| _this._animationEndSubscription = Subscription.EMPTY; |
| /** |
| * Mode of the progress bar. |
| * |
| * Input must be one of these values: determinate, indeterminate, buffer, query, defaults to |
| * 'determinate'. |
| * Mirrored to mode attribute. |
| */ |
| _this.mode = 'determinate'; |
| /** |
| * ID of the progress bar. |
| */ |
| _this.progressbarId = "mat-progress-bar-" + progressbarId++; |
| // We need to prefix the SVG reference with the current path, otherwise they won't work |
| // in Safari if the page has a `<base>` tag. Note that we need quotes inside the `url()`, |
| // because named route URLs can contain parentheses (see #12338). Also we don't use since |
| // we can't tell the difference between whether |
| // the consumer is using the hash location strategy or not, because `Location` normalizes |
| // both `/#/foo/bar` and `/foo/bar` to the same thing. |
| /** @type {?} */ |
| var path = location ? location.getPathname().split('#')[0] : ''; |
| _this._rectangleFillValue = "url('" + path + "#" + _this.progressbarId + "')"; |
| _this._isNoopAnimation = _animationMode === 'NoopAnimations'; |
| return _this; |
| } |
| Object.defineProperty(MatProgressBar.prototype, "value", { |
| /** Value of the progress bar. Defaults to zero. Mirrored to aria-valuenow. */ |
| get: /** |
| * Value of the progress bar. Defaults to zero. Mirrored to aria-valuenow. |
| * @return {?} |
| */ |
| function () { return this._value; }, |
| set: /** |
| * @param {?} v |
| * @return {?} |
| */ |
| function (v) { |
| this._value = clamp(v || 0); |
| // When noop animation is set to true, trigger animationEnd directly. |
| if (this._isNoopAnimation) { |
| this._emitAnimationEnd(); |
| } |
| }, |
| enumerable: true, |
| configurable: true |
| }); |
| Object.defineProperty(MatProgressBar.prototype, "bufferValue", { |
| /** Buffer value of the progress bar. Defaults to zero. */ |
| get: /** |
| * Buffer value of the progress bar. Defaults to zero. |
| * @return {?} |
| */ |
| function () { return this._bufferValue; }, |
| set: /** |
| * @param {?} v |
| * @return {?} |
| */ |
| function (v) { this._bufferValue = clamp(v || 0); }, |
| enumerable: true, |
| configurable: true |
| }); |
| /** Gets the current transform value for the progress bar's primary indicator. */ |
| /** |
| * Gets the current transform value for the progress bar's primary indicator. |
| * @return {?} |
| */ |
| MatProgressBar.prototype._primaryTransform = /** |
| * Gets the current transform value for the progress bar's primary indicator. |
| * @return {?} |
| */ |
| function () { |
| /** @type {?} */ |
| var scale = this.value / 100; |
| return { transform: "scaleX(" + scale + ")" }; |
| }; |
| /** |
| * Gets the current transform value for the progress bar's buffer indicator. Only used if the |
| * progress mode is set to buffer, otherwise returns an undefined, causing no transformation. |
| */ |
| /** |
| * Gets the current transform value for the progress bar's buffer indicator. Only used if the |
| * progress mode is set to buffer, otherwise returns an undefined, causing no transformation. |
| * @return {?} |
| */ |
| MatProgressBar.prototype._bufferTransform = /** |
| * Gets the current transform value for the progress bar's buffer indicator. Only used if the |
| * progress mode is set to buffer, otherwise returns an undefined, causing no transformation. |
| * @return {?} |
| */ |
| function () { |
| if (this.mode === 'buffer') { |
| /** @type {?} */ |
| var scale = this.bufferValue / 100; |
| return { transform: "scaleX(" + scale + ")" }; |
| } |
| }; |
| /** |
| * @return {?} |
| */ |
| MatProgressBar.prototype.ngAfterViewInit = /** |
| * @return {?} |
| */ |
| function () { |
| var _this = this; |
| if (!this._isNoopAnimation) { |
| // Run outside angular so change detection didn't get triggered on every transition end |
| // instead only on the animation that we care about (primary value bar's transitionend) |
| this._ngZone.runOutsideAngular(((/** |
| * @return {?} |
| */ |
| function () { |
| /** @type {?} */ |
| var element = _this._primaryValueBar.nativeElement; |
| _this._animationEndSubscription = |
| ((/** @type {?} */ (fromEvent(element, 'transitionend')))) |
| .pipe(filter(((/** |
| * @param {?} e |
| * @return {?} |
| */ |
| function (e) { return e.target === element; })))) |
| .subscribe((/** |
| * @return {?} |
| */ |
| function () { return _this._ngZone.run((/** |
| * @return {?} |
| */ |
| function () { return _this._emitAnimationEnd(); })); })); |
| }))); |
| } |
| }; |
| /** |
| * @return {?} |
| */ |
| MatProgressBar.prototype.ngOnDestroy = /** |
| * @return {?} |
| */ |
| function () { |
| this._animationEndSubscription.unsubscribe(); |
| }; |
| /** Emit an animationEnd event if in determinate or buffer mode. */ |
| /** |
| * Emit an animationEnd event if in determinate or buffer mode. |
| * @private |
| * @return {?} |
| */ |
| MatProgressBar.prototype._emitAnimationEnd = /** |
| * Emit an animationEnd event if in determinate or buffer mode. |
| * @private |
| * @return {?} |
| */ |
| function () { |
| if (this.mode === 'determinate' || this.mode === 'buffer') { |
| this.animationEnd.next({ value: this.value }); |
| } |
| }; |
| MatProgressBar.decorators = [ |
| { type: Component, args: [{selector: 'mat-progress-bar', |
| exportAs: 'matProgressBar', |
| host: { |
| 'role': 'progressbar', |
| 'aria-valuemin': '0', |
| 'aria-valuemax': '100', |
| '[attr.aria-valuenow]': '(mode === "indeterminate" || mode === "query") ? null : value', |
| '[attr.mode]': 'mode', |
| 'class': 'mat-progress-bar', |
| '[class._mat-animation-noopable]': '_isNoopAnimation', |
| }, |
| inputs: ['color'], |
| 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>", |
| 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)}}"], |
| changeDetection: ChangeDetectionStrategy.OnPush, |
| encapsulation: ViewEncapsulation.None, |
| },] }, |
| ]; |
| /** @nocollapse */ |
| MatProgressBar.ctorParameters = function () { return [ |
| { type: ElementRef }, |
| { type: NgZone }, |
| { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }, |
| { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_PROGRESS_BAR_LOCATION,] }] } |
| ]; }; |
| MatProgressBar.propDecorators = { |
| value: [{ type: Input }], |
| bufferValue: [{ type: Input }], |
| _primaryValueBar: [{ type: ViewChild, args: ['primaryValueBar', { static: false },] }], |
| animationEnd: [{ type: Output }], |
| mode: [{ type: Input }] |
| }; |
| return MatProgressBar; |
| }(_MatProgressBarMixinBase)); |
| /** |
| * Clamps a value to be between two numbers, by default 0 and 100. |
| * @param {?} v |
| * @param {?=} min |
| * @param {?=} max |
| * @return {?} |
| */ |
| function clamp(v, min, max) { |
| if (min === void 0) { min = 0; } |
| if (max === void 0) { max = 100; } |
| return Math.max(min, Math.min(max, v)); |
| } |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| var MatProgressBarModule = /** @class */ (function () { |
| function MatProgressBarModule() { |
| } |
| MatProgressBarModule.decorators = [ |
| { type: NgModule, args: [{ |
| imports: [CommonModule, MatCommonModule], |
| exports: [MatProgressBar, MatCommonModule], |
| declarations: [MatProgressBar], |
| },] }, |
| ]; |
| return MatProgressBarModule; |
| }()); |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| |
| export { MatProgressBarModule, MAT_PROGRESS_BAR_LOCATION_FACTORY, MAT_PROGRESS_BAR_LOCATION, MatProgressBar }; |
| //# sourceMappingURL=progress-bar.es5.js.map |