{"version":3,"file":"progress-bar.js","sources":["../../../../../../src/material/progress-bar/progress-bar.ts","../../../../../../src/material/progress-bar/progress-bar-module.ts","../../../../../../src/material/progress-bar/public-api.ts","../../../../../../src/material/progress-bar/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion';\nimport {DOCUMENT} from '@angular/common';\nimport {\n AfterViewInit,\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n EventEmitter,\n Inject,\n inject,\n InjectionToken,\n Input,\n NgZone,\n OnDestroy,\n Optional,\n Output,\n ViewChild,\n ViewEncapsulation,\n} from '@angular/core';\nimport {CanColor, mixinColor} from '@angular/material/core';\nimport {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';\nimport {fromEvent, Observable, Subscription} from 'rxjs';\nimport {filter} from 'rxjs/operators';\n\n\n// TODO(josephperrott): Benchpress tests.\n// TODO(josephperrott): Add ARIA attributes for progress bar \"for\".\n\n/** Last animation end data. */\nexport interface ProgressAnimationEnd {\n value: number;\n}\n\n// Boilerplate for applying mixins to MatProgressBar.\n/** @docs-private */\nconst _MatProgressBarBase = mixinColor(class {\n constructor(public _elementRef: ElementRef) {}\n}, 'primary');\n\n/**\n * Injection token used to provide the current location to `MatProgressBar`.\n * Used to handle server-side rendering and to stub out during unit tests.\n * @docs-private\n */\nexport const MAT_PROGRESS_BAR_LOCATION = new InjectionToken(\n 'mat-progress-bar-location',\n {providedIn: 'root', factory: MAT_PROGRESS_BAR_LOCATION_FACTORY}\n);\n\n/**\n * Stubbed out location for `MatProgressBar`.\n * @docs-private\n */\nexport interface MatProgressBarLocation {\n getPathname: () => string;\n}\n\n/** @docs-private */\nexport function MAT_PROGRESS_BAR_LOCATION_FACTORY(): MatProgressBarLocation {\n const _document = inject(DOCUMENT);\n const _location = _document ? _document.location : null;\n\n return {\n // Note that this needs to be a function, rather than a property, because Angular\n // will only resolve it once, but we want the current path on each call.\n getPathname: () => _location ? (_location.pathname + _location.search) : ''\n };\n}\n\nexport type ProgressBarMode = 'determinate' | 'indeterminate' | 'buffer' | 'query';\n\n/** Counter used to generate unique IDs for progress bars. */\nlet progressbarId = 0;\n\n/**\n * `` component.\n */\n@Component({\n selector: 'mat-progress-bar',\n exportAs: 'matProgressBar',\n host: {\n 'role': 'progressbar',\n 'aria-valuemin': '0',\n 'aria-valuemax': '100',\n // set tab index to -1 so screen readers will read the aria-label\n // Note: there is a known issue with JAWS that does not read progressbar aria labels on FireFox\n 'tabindex': '-1',\n '[attr.aria-valuenow]': '(mode === \"indeterminate\" || mode === \"query\") ? null : value',\n '[attr.mode]': 'mode',\n 'class': 'mat-progress-bar',\n '[class._mat-animation-noopable]': '_isNoopAnimation',\n },\n inputs: ['color'],\n templateUrl: 'progress-bar.html',\n styleUrls: ['progress-bar.css'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n})\nexport class MatProgressBar extends _MatProgressBarBase implements CanColor,\n AfterViewInit, OnDestroy {\n constructor(elementRef: ElementRef, private _ngZone: NgZone,\n @Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string,\n /**\n * @deprecated `location` parameter to be made required.\n * @breaking-change 8.0.0\n */\n @Optional() @Inject(MAT_PROGRESS_BAR_LOCATION) location?: MatProgressBarLocation) {\n super(elementRef);\n\n // We need to prefix the SVG reference with the current path, otherwise they won't work\n // in Safari if the page has a `` tag. Note that we need quotes inside the `url()`,\n\n // because named route URLs can contain parentheses (see #12338). Also we don't use since\n // we can't tell the difference between whether\n // the consumer is using the hash location strategy or not, because `Location` normalizes\n // both `/#/foo/bar` and `/foo/bar` to the same thing.\n const path = location ? location.getPathname().split('#')[0] : '';\n this._rectangleFillValue = `url('${path}#${this.progressbarId}')`;\n this._isNoopAnimation = _animationMode === 'NoopAnimations';\n }\n\n /** Flag that indicates whether NoopAnimations mode is set to true. */\n _isNoopAnimation = false;\n\n /** Value of the progress bar. Defaults to zero. Mirrored to aria-valuenow. */\n @Input()\n get value(): number { return this._value; }\n set value(v: number) {\n this._value = clamp(coerceNumberProperty(v) || 0);\n }\n private _value: number = 0;\n\n /** Buffer value of the progress bar. Defaults to zero. */\n @Input()\n get bufferValue(): number { return this._bufferValue; }\n set bufferValue(v: number) { this._bufferValue = clamp(v || 0); }\n private _bufferValue: number = 0;\n\n @ViewChild('primaryValueBar') _primaryValueBar: ElementRef;\n\n /**\n * Event emitted when animation of the primary progress bar completes. This event will not\n * be emitted when animations are disabled, nor will it be emitted for modes with continuous\n * animations (indeterminate and query).\n */\n @Output() readonly animationEnd = new EventEmitter();\n\n /** Reference to animation end subscription to be unsubscribed on destroy. */\n private _animationEndSubscription: Subscription = Subscription.EMPTY;\n\n /**\n * Mode of the progress bar.\n *\n * Input must be one of these values: determinate, indeterminate, buffer, query, defaults to\n * 'determinate'.\n * Mirrored to mode attribute.\n */\n @Input() mode: ProgressBarMode = 'determinate';\n\n /** ID of the progress bar. */\n progressbarId = `mat-progress-bar-${progressbarId++}`;\n\n /** Attribute to be used for the `fill` attribute on the internal `rect` element. */\n _rectangleFillValue: string;\n\n /** Gets the current transform value for the progress bar's primary indicator. */\n _primaryTransform() {\n // We use a 3d transform to work around some rendering issues in iOS Safari. See #19328.\n const scale = this.value / 100;\n return {transform: `scale3d(${scale}, 1, 1)`};\n }\n\n /**\n * Gets the current transform value for the progress bar's buffer indicator. Only used if the\n * progress mode is set to buffer, otherwise returns an undefined, causing no transformation.\n */\n _bufferTransform() {\n if (this.mode === 'buffer') {\n // We use a 3d transform to work around some rendering issues in iOS Safari. See #19328.\n const scale = this.bufferValue / 100;\n return {transform: `scale3d(${scale}, 1, 1)`};\n }\n return null;\n }\n\n ngAfterViewInit() {\n // Run outside angular so change detection didn't get triggered on every transition end\n // instead only on the animation that we care about (primary value bar's transitionend)\n this._ngZone.runOutsideAngular((() => {\n const element = this._primaryValueBar.nativeElement;\n\n this._animationEndSubscription =\n (fromEvent(element, 'transitionend') as Observable)\n .pipe(filter(((e: TransitionEvent) => e.target === element)))\n .subscribe(() => {\n if (this.mode === 'determinate' || this.mode === 'buffer') {\n this._ngZone.run(() => this.animationEnd.next({value: this.value}));\n }\n });\n }));\n }\n\n ngOnDestroy() {\n this._animationEndSubscription.unsubscribe();\n }\n\n static ngAcceptInputType_value: NumberInput;\n}\n\n/** Clamps a value to be between two numbers, by default 0 and 100. */\nfunction clamp(v: number, min = 0, max = 100) {\n return Math.max(min, Math.min(max, v));\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {NgModule} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {MatCommonModule} from '@angular/material/core';\nimport {MatProgressBar} from './progress-bar';\n\n\n@NgModule({\n imports: [CommonModule, MatCommonModule],\n exports: [MatProgressBar, MatCommonModule],\n declarations: [MatProgressBar],\n})\nexport class MatProgressBarModule {}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './progress-bar-module';\nexport * from './progress-bar';\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;;AAwCA;AACA;AACA,MAAM,mBAAmB,GAAG,UAAU,CAAC;IACrC,YAAmB,WAAuB;QAAvB,gBAAW,GAAX,WAAW,CAAY;KAAI;CAC/C,EAAE,SAAS,CAAC,CAAC;AAEd;;;;;MAKa,yBAAyB,GAAG,IAAI,cAAc,CACzD,2BAA2B,EAC3B,EAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iCAAiC,EAAC,EAChE;AAUF;SACgB,iCAAiC;IAC/C,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnC,M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