source: trip-planner-front/node_modules/@angular/material/fesm2015/progress-bar.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 14.5 KB
Line 
1import { InjectionToken, inject, EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, NgZone, Optional, Inject, Input, ViewChild, Output, NgModule } from '@angular/core';
2import { DOCUMENT, CommonModule } from '@angular/common';
3import { mixinColor, MatCommonModule } from '@angular/material/core';
4import { coerceNumberProperty } from '@angular/cdk/coercion';
5import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
6import { Subscription, fromEvent } from 'rxjs';
7import { filter } from 'rxjs/operators';
8
9/**
10 * @license
11 * Copyright Google LLC All Rights Reserved.
12 *
13 * Use of this source code is governed by an MIT-style license that can be
14 * found in the LICENSE file at https://angular.io/license
15 */
16// Boilerplate for applying mixins to MatProgressBar.
17/** @docs-private */
18const _MatProgressBarBase = mixinColor(class {
19 constructor(_elementRef) {
20 this._elementRef = _elementRef;
21 }
22}, 'primary');
23/**
24 * Injection token used to provide the current location to `MatProgressBar`.
25 * Used to handle server-side rendering and to stub out during unit tests.
26 * @docs-private
27 */
28const MAT_PROGRESS_BAR_LOCATION = new InjectionToken('mat-progress-bar-location', { providedIn: 'root', factory: MAT_PROGRESS_BAR_LOCATION_FACTORY });
29/** @docs-private */
30function MAT_PROGRESS_BAR_LOCATION_FACTORY() {
31 const _document = inject(DOCUMENT);
32 const _location = _document ? _document.location : null;
33 return {
34 // Note that this needs to be a function, rather than a property, because Angular
35 // will only resolve it once, but we want the current path on each call.
36 getPathname: () => _location ? (_location.pathname + _location.search) : ''
37 };
38}
39/** Counter used to generate unique IDs for progress bars. */
40let progressbarId = 0;
41/**
42 * `<mat-progress-bar>` component.
43 */
44class MatProgressBar extends _MatProgressBarBase {
45 constructor(elementRef, _ngZone, _animationMode,
46 /**
47 * @deprecated `location` parameter to be made required.
48 * @breaking-change 8.0.0
49 */
50 location) {
51 super(elementRef);
52 this._ngZone = _ngZone;
53 this._animationMode = _animationMode;
54 /** Flag that indicates whether NoopAnimations mode is set to true. */
55 this._isNoopAnimation = false;
56 this._value = 0;
57 this._bufferValue = 0;
58 /**
59 * Event emitted when animation of the primary progress bar completes. This event will not
60 * be emitted when animations are disabled, nor will it be emitted for modes with continuous
61 * animations (indeterminate and query).
62 */
63 this.animationEnd = new EventEmitter();
64 /** Reference to animation end subscription to be unsubscribed on destroy. */
65 this._animationEndSubscription = Subscription.EMPTY;
66 /**
67 * Mode of the progress bar.
68 *
69 * Input must be one of these values: determinate, indeterminate, buffer, query, defaults to
70 * 'determinate'.
71 * Mirrored to mode attribute.
72 */
73 this.mode = 'determinate';
74 /** ID of the progress bar. */
75 this.progressbarId = `mat-progress-bar-${progressbarId++}`;
76 // We need to prefix the SVG reference with the current path, otherwise they won't work
77 // in Safari if the page has a `<base>` tag. Note that we need quotes inside the `url()`,
78 // because named route URLs can contain parentheses (see #12338). Also we don't use since
79 // we can't tell the difference between whether
80 // the consumer is using the hash location strategy or not, because `Location` normalizes
81 // both `/#/foo/bar` and `/foo/bar` to the same thing.
82 const path = location ? location.getPathname().split('#')[0] : '';
83 this._rectangleFillValue = `url('${path}#${this.progressbarId}')`;
84 this._isNoopAnimation = _animationMode === 'NoopAnimations';
85 }
86 /** Value of the progress bar. Defaults to zero. Mirrored to aria-valuenow. */
87 get value() { return this._value; }
88 set value(v) {
89 this._value = clamp(coerceNumberProperty(v) || 0);
90 }
91 /** Buffer value of the progress bar. Defaults to zero. */
92 get bufferValue() { return this._bufferValue; }
93 set bufferValue(v) { this._bufferValue = clamp(v || 0); }
94 /** Gets the current transform value for the progress bar's primary indicator. */
95 _primaryTransform() {
96 // We use a 3d transform to work around some rendering issues in iOS Safari. See #19328.
97 const scale = this.value / 100;
98 return { transform: `scale3d(${scale}, 1, 1)` };
99 }
100 /**
101 * Gets the current transform value for the progress bar's buffer indicator. Only used if the
102 * progress mode is set to buffer, otherwise returns an undefined, causing no transformation.
103 */
104 _bufferTransform() {
105 if (this.mode === 'buffer') {
106 // We use a 3d transform to work around some rendering issues in iOS Safari. See #19328.
107 const scale = this.bufferValue / 100;
108 return { transform: `scale3d(${scale}, 1, 1)` };
109 }
110 return null;
111 }
112 ngAfterViewInit() {
113 // Run outside angular so change detection didn't get triggered on every transition end
114 // instead only on the animation that we care about (primary value bar's transitionend)
115 this._ngZone.runOutsideAngular((() => {
116 const element = this._primaryValueBar.nativeElement;
117 this._animationEndSubscription =
118 fromEvent(element, 'transitionend')
119 .pipe(filter(((e) => e.target === element)))
120 .subscribe(() => {
121 if (this.mode === 'determinate' || this.mode === 'buffer') {
122 this._ngZone.run(() => this.animationEnd.next({ value: this.value }));
123 }
124 });
125 }));
126 }
127 ngOnDestroy() {
128 this._animationEndSubscription.unsubscribe();
129 }
130}
131MatProgressBar.decorators = [
132 { type: Component, args: [{
133 selector: 'mat-progress-bar',
134 exportAs: 'matProgressBar',
135 host: {
136 'role': 'progressbar',
137 'aria-valuemin': '0',
138 'aria-valuemax': '100',
139 // set tab index to -1 so screen readers will read the aria-label
140 // Note: there is a known issue with JAWS that does not read progressbar aria labels on FireFox
141 'tabindex': '-1',
142 '[attr.aria-valuenow]': '(mode === "indeterminate" || mode === "query") ? null : value',
143 '[attr.mode]': 'mode',
144 'class': 'mat-progress-bar',
145 '[class._mat-animation-noopable]': '_isNoopAnimation',
146 },
147 inputs: ['color'],
148 template: "<!--\n All children need to be hidden for screen readers in order to support ChromeVox.\n More context in the issue: https://github.com/angular/components/issues/22165.\n-->\n<div aria-hidden=\"true\">\n <svg width=\"100%\" height=\"4\" focusable=\"false\" class=\"mat-progress-bar-background mat-progress-bar-element\">\n <defs>\n <pattern [id]=\"progressbarId\" x=\"4\" y=\"0\" width=\"8\" height=\"4\" patternUnits=\"userSpaceOnUse\">\n <circle cx=\"2\" cy=\"2\" r=\"2\"/>\n </pattern>\n </defs>\n <rect [attr.fill]=\"_rectangleFillValue\" width=\"100%\" height=\"100%\"/>\n </svg>\n <!--\n The background div is named as such because it appears below the other divs and is not sized based\n on values.\n -->\n <div class=\"mat-progress-bar-buffer mat-progress-bar-element\" [ngStyle]=\"_bufferTransform()\"></div>\n <div class=\"mat-progress-bar-primary mat-progress-bar-fill mat-progress-bar-element\" [ngStyle]=\"_primaryTransform()\" #primaryValueBar></div>\n <div class=\"mat-progress-bar-secondary mat-progress-bar-fill mat-progress-bar-element\"></div>\n</div>\n",
149 changeDetection: ChangeDetectionStrategy.OnPush,
150 encapsulation: ViewEncapsulation.None,
151 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)}.cdk-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}.cdk-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}.cdk-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 2000ms 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 2000ms 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 2000ms 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 2000ms 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-fill,.mat-progress-bar._mat-animation-noopable .mat-progress-bar-fill::after,.mat-progress-bar._mat-animation-noopable .mat-progress-bar-buffer,.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,.mat-progress-bar._mat-animation-noopable .mat-progress-bar-background{animation:none;transition-duration:1ms}@keyframes mat-progress-bar-primary-indeterminate-translate{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(0.5, 0, 0.701732, 0.495819);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);transform:translateX(83.67142%)}100%{transform:translateX(200.611057%)}}@keyframes mat-progress-bar-primary-indeterminate-scale{0%{transform:scaleX(0.08)}36.65%{animation-timing-function:cubic-bezier(0.334731, 0.12482, 0.785844, 1);transform:scaleX(0.08)}69.15%{animation-timing-function:cubic-bezier(0.06, 0.11, 0.6, 1);transform:scaleX(0.661479)}100%{transform:scaleX(0.08)}}@keyframes mat-progress-bar-secondary-indeterminate-translate{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:translateX(37.651913%)}48.35%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:translateX(84.386165%)}100%{transform:translateX(160.277782%)}}@keyframes mat-progress-bar-secondary-indeterminate-scale{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:scaleX(0.08)}19.15%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:scaleX(0.457104)}44.15%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:scaleX(0.72796)}100%{transform:scaleX(0.08)}}@keyframes mat-progress-bar-background-scroll{to{transform:translateX(-8px)}}\n"]
152 },] }
153];
154MatProgressBar.ctorParameters = () => [
155 { type: ElementRef },
156 { type: NgZone },
157 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] },
158 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_PROGRESS_BAR_LOCATION,] }] }
159];
160MatProgressBar.propDecorators = {
161 value: [{ type: Input }],
162 bufferValue: [{ type: Input }],
163 _primaryValueBar: [{ type: ViewChild, args: ['primaryValueBar',] }],
164 animationEnd: [{ type: Output }],
165 mode: [{ type: Input }]
166};
167/** Clamps a value to be between two numbers, by default 0 and 100. */
168function clamp(v, min = 0, max = 100) {
169 return Math.max(min, Math.min(max, v));
170}
171
172/**
173 * @license
174 * Copyright Google LLC All Rights Reserved.
175 *
176 * Use of this source code is governed by an MIT-style license that can be
177 * found in the LICENSE file at https://angular.io/license
178 */
179class MatProgressBarModule {
180}
181MatProgressBarModule.decorators = [
182 { type: NgModule, args: [{
183 imports: [CommonModule, MatCommonModule],
184 exports: [MatProgressBar, MatCommonModule],
185 declarations: [MatProgressBar],
186 },] }
187];
188
189/**
190 * @license
191 * Copyright Google LLC All Rights Reserved.
192 *
193 * Use of this source code is governed by an MIT-style license that can be
194 * found in the LICENSE file at https://angular.io/license
195 */
196
197/**
198 * Generated bundle index. Do not edit.
199 */
200
201export { MAT_PROGRESS_BAR_LOCATION, MAT_PROGRESS_BAR_LOCATION_FACTORY, MatProgressBar, MatProgressBarModule };
202//# sourceMappingURL=progress-bar.js.map
Note: See TracBrowser for help on using the repository browser.