1 | import * as i0 from '@angular/core';
|
---|
2 | import { Version, InjectionToken, isDevMode, NgModule, Optional, Inject, inject, LOCALE_ID, Injectable, Directive, ElementRef, NgZone, Input, Component, ViewEncapsulation, ChangeDetectionStrategy, EventEmitter, ChangeDetectorRef, Output } from '@angular/core';
|
---|
3 | import { HighContrastModeDetector, isFakeMousedownFromScreenReader, isFakeTouchstartFromScreenReader } from '@angular/cdk/a11y';
|
---|
4 | import { BidiModule } from '@angular/cdk/bidi';
|
---|
5 | import { VERSION as VERSION$2 } from '@angular/cdk';
|
---|
6 | import { DOCUMENT, CommonModule } from '@angular/common';
|
---|
7 | import { _isTestEnvironment, Platform, PlatformModule, normalizePassiveListenerOptions } from '@angular/cdk/platform';
|
---|
8 | import { coerceBooleanProperty, coerceNumberProperty, coerceElement } from '@angular/cdk/coercion';
|
---|
9 | import { Subject, Observable } from 'rxjs';
|
---|
10 | import { startWith } from 'rxjs/operators';
|
---|
11 | import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
|
---|
12 | import { ENTER, SPACE, hasModifierKey } from '@angular/cdk/keycodes';
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * @license
|
---|
16 | * Copyright Google LLC All Rights Reserved.
|
---|
17 | *
|
---|
18 | * Use of this source code is governed by an MIT-style license that can be
|
---|
19 | * found in the LICENSE file at https://angular.io/license
|
---|
20 | */
|
---|
21 | /** Current version of Angular Material. */
|
---|
22 | const VERSION$1 = new Version('12.2.13');
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * @license
|
---|
26 | * Copyright Google LLC All Rights Reserved.
|
---|
27 | *
|
---|
28 | * Use of this source code is governed by an MIT-style license that can be
|
---|
29 | * found in the LICENSE file at https://angular.io/license
|
---|
30 | */
|
---|
31 | /** @docs-private */
|
---|
32 | class AnimationCurves {
|
---|
33 | }
|
---|
34 | AnimationCurves.STANDARD_CURVE = 'cubic-bezier(0.4,0.0,0.2,1)';
|
---|
35 | AnimationCurves.DECELERATION_CURVE = 'cubic-bezier(0.0,0.0,0.2,1)';
|
---|
36 | AnimationCurves.ACCELERATION_CURVE = 'cubic-bezier(0.4,0.0,1,1)';
|
---|
37 | AnimationCurves.SHARP_CURVE = 'cubic-bezier(0.4,0.0,0.6,1)';
|
---|
38 | /** @docs-private */
|
---|
39 | class AnimationDurations {
|
---|
40 | }
|
---|
41 | AnimationDurations.COMPLEX = '375ms';
|
---|
42 | AnimationDurations.ENTERING = '225ms';
|
---|
43 | AnimationDurations.EXITING = '195ms';
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * @license
|
---|
47 | * Copyright Google LLC All Rights Reserved.
|
---|
48 | *
|
---|
49 | * Use of this source code is governed by an MIT-style license that can be
|
---|
50 | * found in the LICENSE file at https://angular.io/license
|
---|
51 | */
|
---|
52 | // Private version constant to circumvent test/build issues,
|
---|
53 | // i.e. avoid core to depend on the @angular/material primary entry-point
|
---|
54 | // Can be removed once the Material primary entry-point no longer
|
---|
55 | // re-exports all secondary entry-points
|
---|
56 | const VERSION = new Version('12.2.13');
|
---|
57 | /** @docs-private */
|
---|
58 | function MATERIAL_SANITY_CHECKS_FACTORY() {
|
---|
59 | return true;
|
---|
60 | }
|
---|
61 | /** Injection token that configures whether the Material sanity checks are enabled. */
|
---|
62 | const MATERIAL_SANITY_CHECKS = new InjectionToken('mat-sanity-checks', {
|
---|
63 | providedIn: 'root',
|
---|
64 | factory: MATERIAL_SANITY_CHECKS_FACTORY,
|
---|
65 | });
|
---|
66 | /**
|
---|
67 | * Module that captures anything that should be loaded and/or run for *all* Angular Material
|
---|
68 | * components. This includes Bidi, etc.
|
---|
69 | *
|
---|
70 | * This module should be imported to each top-level component module (e.g., MatTabsModule).
|
---|
71 | */
|
---|
72 | class MatCommonModule {
|
---|
73 | constructor(highContrastModeDetector, sanityChecks, document) {
|
---|
74 | /** Whether we've done the global sanity checks (e.g. a theme is loaded, there is a doctype). */
|
---|
75 | this._hasDoneGlobalChecks = false;
|
---|
76 | this._document = document;
|
---|
77 | // While A11yModule also does this, we repeat it here to avoid importing A11yModule
|
---|
78 | // in MatCommonModule.
|
---|
79 | highContrastModeDetector._applyBodyHighContrastModeCssClasses();
|
---|
80 | // Note that `_sanityChecks` is typed to `any`, because AoT
|
---|
81 | // throws an error if we use the `SanityChecks` type directly.
|
---|
82 | this._sanityChecks = sanityChecks;
|
---|
83 | if (!this._hasDoneGlobalChecks) {
|
---|
84 | this._checkDoctypeIsDefined();
|
---|
85 | this._checkThemeIsPresent();
|
---|
86 | this._checkCdkVersionMatch();
|
---|
87 | this._hasDoneGlobalChecks = true;
|
---|
88 | }
|
---|
89 | }
|
---|
90 | /** Gets whether a specific sanity check is enabled. */
|
---|
91 | _checkIsEnabled(name) {
|
---|
92 | // TODO(crisbeto): we can't use `ngDevMode` here yet, because ViewEngine apps might not support
|
---|
93 | // it. Since these checks can have performance implications and they aren't tree shakeable
|
---|
94 | // in their current form, we can leave the `isDevMode` check in for now.
|
---|
95 | // tslint:disable-next-line:ban
|
---|
96 | if (!isDevMode() || _isTestEnvironment()) {
|
---|
97 | return false;
|
---|
98 | }
|
---|
99 | if (typeof this._sanityChecks === 'boolean') {
|
---|
100 | return this._sanityChecks;
|
---|
101 | }
|
---|
102 | return !!this._sanityChecks[name];
|
---|
103 | }
|
---|
104 | _checkDoctypeIsDefined() {
|
---|
105 | if (this._checkIsEnabled('doctype') && !this._document.doctype) {
|
---|
106 | console.warn('Current document does not have a doctype. This may cause ' +
|
---|
107 | 'some Angular Material components not to behave as expected.');
|
---|
108 | }
|
---|
109 | }
|
---|
110 | _checkThemeIsPresent() {
|
---|
111 | // We need to assert that the `body` is defined, because these checks run very early
|
---|
112 | // and the `body` won't be defined if the consumer put their scripts in the `head`.
|
---|
113 | if (!this._checkIsEnabled('theme') || !this._document.body ||
|
---|
114 | typeof getComputedStyle !== 'function') {
|
---|
115 | return;
|
---|
116 | }
|
---|
117 | const testElement = this._document.createElement('div');
|
---|
118 | testElement.classList.add('mat-theme-loaded-marker');
|
---|
119 | this._document.body.appendChild(testElement);
|
---|
120 | const computedStyle = getComputedStyle(testElement);
|
---|
121 | // In some situations the computed style of the test element can be null. For example in
|
---|
122 | // Firefox, the computed style is null if an application is running inside of a hidden iframe.
|
---|
123 | // See: https://bugzilla.mozilla.org/show_bug.cgi?id=548397
|
---|
124 | if (computedStyle && computedStyle.display !== 'none') {
|
---|
125 | console.warn('Could not find Angular Material core theme. Most Material ' +
|
---|
126 | 'components may not work as expected. For more info refer ' +
|
---|
127 | 'to the theming guide: https://material.angular.io/guide/theming');
|
---|
128 | }
|
---|
129 | this._document.body.removeChild(testElement);
|
---|
130 | }
|
---|
131 | /** Checks whether the material version matches the cdk version */
|
---|
132 | _checkCdkVersionMatch() {
|
---|
133 | if (this._checkIsEnabled('version') && VERSION.full !== VERSION$2.full) {
|
---|
134 | console.warn('The Angular Material version (' + VERSION.full + ') does not match ' +
|
---|
135 | 'the Angular CDK version (' + VERSION$2.full + ').\n' +
|
---|
136 | 'Please ensure the versions of these two packages exactly match.');
|
---|
137 | }
|
---|
138 | }
|
---|
139 | }
|
---|
140 | MatCommonModule.decorators = [
|
---|
141 | { type: NgModule, args: [{
|
---|
142 | imports: [BidiModule],
|
---|
143 | exports: [BidiModule],
|
---|
144 | },] }
|
---|
145 | ];
|
---|
146 | MatCommonModule.ctorParameters = () => [
|
---|
147 | { type: HighContrastModeDetector },
|
---|
148 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MATERIAL_SANITY_CHECKS,] }] },
|
---|
149 | { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
|
---|
150 | ];
|
---|
151 |
|
---|
152 | /**
|
---|
153 | * @license
|
---|
154 | * Copyright Google LLC All Rights Reserved.
|
---|
155 | *
|
---|
156 | * Use of this source code is governed by an MIT-style license that can be
|
---|
157 | * found in the LICENSE file at https://angular.io/license
|
---|
158 | */
|
---|
159 | function mixinDisabled(base) {
|
---|
160 | return class extends base {
|
---|
161 | constructor(...args) {
|
---|
162 | super(...args);
|
---|
163 | this._disabled = false;
|
---|
164 | }
|
---|
165 | get disabled() { return this._disabled; }
|
---|
166 | set disabled(value) { this._disabled = coerceBooleanProperty(value); }
|
---|
167 | };
|
---|
168 | }
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * @license
|
---|
172 | * Copyright Google LLC All Rights Reserved.
|
---|
173 | *
|
---|
174 | * Use of this source code is governed by an MIT-style license that can be
|
---|
175 | * found in the LICENSE file at https://angular.io/license
|
---|
176 | */
|
---|
177 | function mixinColor(base, defaultColor) {
|
---|
178 | return class extends base {
|
---|
179 | constructor(...args) {
|
---|
180 | super(...args);
|
---|
181 | this.defaultColor = defaultColor;
|
---|
182 | // Set the default color that can be specified from the mixin.
|
---|
183 | this.color = defaultColor;
|
---|
184 | }
|
---|
185 | get color() { return this._color; }
|
---|
186 | set color(value) {
|
---|
187 | const colorPalette = value || this.defaultColor;
|
---|
188 | if (colorPalette !== this._color) {
|
---|
189 | if (this._color) {
|
---|
190 | this._elementRef.nativeElement.classList.remove(`mat-${this._color}`);
|
---|
191 | }
|
---|
192 | if (colorPalette) {
|
---|
193 | this._elementRef.nativeElement.classList.add(`mat-${colorPalette}`);
|
---|
194 | }
|
---|
195 | this._color = colorPalette;
|
---|
196 | }
|
---|
197 | }
|
---|
198 | };
|
---|
199 | }
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * @license
|
---|
203 | * Copyright Google LLC All Rights Reserved.
|
---|
204 | *
|
---|
205 | * Use of this source code is governed by an MIT-style license that can be
|
---|
206 | * found in the LICENSE file at https://angular.io/license
|
---|
207 | */
|
---|
208 | function mixinDisableRipple(base) {
|
---|
209 | return class extends base {
|
---|
210 | constructor(...args) {
|
---|
211 | super(...args);
|
---|
212 | this._disableRipple = false;
|
---|
213 | }
|
---|
214 | /** Whether the ripple effect is disabled or not. */
|
---|
215 | get disableRipple() { return this._disableRipple; }
|
---|
216 | set disableRipple(value) { this._disableRipple = coerceBooleanProperty(value); }
|
---|
217 | };
|
---|
218 | }
|
---|
219 |
|
---|
220 | /**
|
---|
221 | * @license
|
---|
222 | * Copyright Google LLC All Rights Reserved.
|
---|
223 | *
|
---|
224 | * Use of this source code is governed by an MIT-style license that can be
|
---|
225 | * found in the LICENSE file at https://angular.io/license
|
---|
226 | */
|
---|
227 | function mixinTabIndex(base, defaultTabIndex = 0) {
|
---|
228 | return class extends base {
|
---|
229 | constructor(...args) {
|
---|
230 | super(...args);
|
---|
231 | this._tabIndex = defaultTabIndex;
|
---|
232 | this.defaultTabIndex = defaultTabIndex;
|
---|
233 | }
|
---|
234 | get tabIndex() { return this.disabled ? -1 : this._tabIndex; }
|
---|
235 | set tabIndex(value) {
|
---|
236 | // If the specified tabIndex value is null or undefined, fall back to the default value.
|
---|
237 | this._tabIndex = value != null ? coerceNumberProperty(value) : this.defaultTabIndex;
|
---|
238 | }
|
---|
239 | };
|
---|
240 | }
|
---|
241 |
|
---|
242 | /**
|
---|
243 | * @license
|
---|
244 | * Copyright Google LLC All Rights Reserved.
|
---|
245 | *
|
---|
246 | * Use of this source code is governed by an MIT-style license that can be
|
---|
247 | * found in the LICENSE file at https://angular.io/license
|
---|
248 | */
|
---|
249 | function mixinErrorState(base) {
|
---|
250 | return class extends base {
|
---|
251 | constructor(...args) {
|
---|
252 | super(...args);
|
---|
253 | // This class member exists as an interop with `MatFormFieldControl` which expects
|
---|
254 | // a public `stateChanges` observable to emit whenever the form field should be updated.
|
---|
255 | // The description is not specifically mentioning the error state, as classes using this
|
---|
256 | // mixin can/should emit an event in other cases too.
|
---|
257 | /** Emits whenever the component state changes. */
|
---|
258 | this.stateChanges = new Subject();
|
---|
259 | /** Whether the component is in an error state. */
|
---|
260 | this.errorState = false;
|
---|
261 | }
|
---|
262 | /** Updates the error state based on the provided error state matcher. */
|
---|
263 | updateErrorState() {
|
---|
264 | const oldState = this.errorState;
|
---|
265 | const parent = this._parentFormGroup || this._parentForm;
|
---|
266 | const matcher = this.errorStateMatcher || this._defaultErrorStateMatcher;
|
---|
267 | const control = this.ngControl ? this.ngControl.control : null;
|
---|
268 | const newState = matcher.isErrorState(control, parent);
|
---|
269 | if (newState !== oldState) {
|
---|
270 | this.errorState = newState;
|
---|
271 | this.stateChanges.next();
|
---|
272 | }
|
---|
273 | }
|
---|
274 | };
|
---|
275 | }
|
---|
276 |
|
---|
277 | /**
|
---|
278 | * @license
|
---|
279 | * Copyright Google LLC All Rights Reserved.
|
---|
280 | *
|
---|
281 | * Use of this source code is governed by an MIT-style license that can be
|
---|
282 | * found in the LICENSE file at https://angular.io/license
|
---|
283 | */
|
---|
284 | /** Mixin to augment a directive with an initialized property that will emits when ngOnInit ends. */
|
---|
285 | function mixinInitialized(base) {
|
---|
286 | return class extends base {
|
---|
287 | constructor(...args) {
|
---|
288 | super(...args);
|
---|
289 | /** Whether this directive has been marked as initialized. */
|
---|
290 | this._isInitialized = false;
|
---|
291 | /**
|
---|
292 | * List of subscribers that subscribed before the directive was initialized. Should be notified
|
---|
293 | * during _markInitialized. Set to null after pending subscribers are notified, and should
|
---|
294 | * not expect to be populated after.
|
---|
295 | */
|
---|
296 | this._pendingSubscribers = [];
|
---|
297 | /**
|
---|
298 | * Observable stream that emits when the directive initializes. If already initialized, the
|
---|
299 | * subscriber is stored to be notified once _markInitialized is called.
|
---|
300 | */
|
---|
301 | this.initialized = new Observable(subscriber => {
|
---|
302 | // If initialized, immediately notify the subscriber. Otherwise store the subscriber to notify
|
---|
303 | // when _markInitialized is called.
|
---|
304 | if (this._isInitialized) {
|
---|
305 | this._notifySubscriber(subscriber);
|
---|
306 | }
|
---|
307 | else {
|
---|
308 | this._pendingSubscribers.push(subscriber);
|
---|
309 | }
|
---|
310 | });
|
---|
311 | }
|
---|
312 | /**
|
---|
313 | * Marks the state as initialized and notifies pending subscribers. Should be called at the end
|
---|
314 | * of ngOnInit.
|
---|
315 | * @docs-private
|
---|
316 | */
|
---|
317 | _markInitialized() {
|
---|
318 | if (this._isInitialized && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
319 | throw Error('This directive has already been marked as initialized and ' +
|
---|
320 | 'should not be called twice.');
|
---|
321 | }
|
---|
322 | this._isInitialized = true;
|
---|
323 | this._pendingSubscribers.forEach(this._notifySubscriber);
|
---|
324 | this._pendingSubscribers = null;
|
---|
325 | }
|
---|
326 | /** Emits and completes the subscriber stream (should only emit once). */
|
---|
327 | _notifySubscriber(subscriber) {
|
---|
328 | subscriber.next();
|
---|
329 | subscriber.complete();
|
---|
330 | }
|
---|
331 | };
|
---|
332 | }
|
---|
333 |
|
---|
334 | /**
|
---|
335 | * @license
|
---|
336 | * Copyright Google LLC All Rights Reserved.
|
---|
337 | *
|
---|
338 | * Use of this source code is governed by an MIT-style license that can be
|
---|
339 | * found in the LICENSE file at https://angular.io/license
|
---|
340 | */
|
---|
341 |
|
---|
342 | /**
|
---|
343 | * @license
|
---|
344 | * Copyright Google LLC All Rights Reserved.
|
---|
345 | *
|
---|
346 | * Use of this source code is governed by an MIT-style license that can be
|
---|
347 | * found in the LICENSE file at https://angular.io/license
|
---|
348 | */
|
---|
349 | /** InjectionToken for datepicker that can be used to override default locale code. */
|
---|
350 | const MAT_DATE_LOCALE = new InjectionToken('MAT_DATE_LOCALE', {
|
---|
351 | providedIn: 'root',
|
---|
352 | factory: MAT_DATE_LOCALE_FACTORY,
|
---|
353 | });
|
---|
354 | /** @docs-private */
|
---|
355 | function MAT_DATE_LOCALE_FACTORY() {
|
---|
356 | return inject(LOCALE_ID);
|
---|
357 | }
|
---|
358 | /** Adapts type `D` to be usable as a date by cdk-based components that work with dates. */
|
---|
359 | class DateAdapter {
|
---|
360 | constructor() {
|
---|
361 | this._localeChanges = new Subject();
|
---|
362 | /** A stream that emits when the locale changes. */
|
---|
363 | this.localeChanges = this._localeChanges;
|
---|
364 | }
|
---|
365 | /**
|
---|
366 | * Given a potential date object, returns that same date object if it is
|
---|
367 | * a valid date, or `null` if it's not a valid date.
|
---|
368 | * @param obj The object to check.
|
---|
369 | * @returns A date or `null`.
|
---|
370 | */
|
---|
371 | getValidDateOrNull(obj) {
|
---|
372 | return this.isDateInstance(obj) && this.isValid(obj) ? obj : null;
|
---|
373 | }
|
---|
374 | /**
|
---|
375 | * Attempts to deserialize a value to a valid date object. This is different from parsing in that
|
---|
376 | * deserialize should only accept non-ambiguous, locale-independent formats (e.g. a ISO 8601
|
---|
377 | * string). The default implementation does not allow any deserialization, it simply checks that
|
---|
378 | * the given value is already a valid date object or null. The `<mat-datepicker>` will call this
|
---|
379 | * method on all of its `@Input()` properties that accept dates. It is therefore possible to
|
---|
380 | * support passing values from your backend directly to these properties by overriding this method
|
---|
381 | * to also deserialize the format used by your backend.
|
---|
382 | * @param value The value to be deserialized into a date object.
|
---|
383 | * @returns The deserialized date object, either a valid date, null if the value can be
|
---|
384 | * deserialized into a null date (e.g. the empty string), or an invalid date.
|
---|
385 | */
|
---|
386 | deserialize(value) {
|
---|
387 | if (value == null || this.isDateInstance(value) && this.isValid(value)) {
|
---|
388 | return value;
|
---|
389 | }
|
---|
390 | return this.invalid();
|
---|
391 | }
|
---|
392 | /**
|
---|
393 | * Sets the locale used for all dates.
|
---|
394 | * @param locale The new locale.
|
---|
395 | */
|
---|
396 | setLocale(locale) {
|
---|
397 | this.locale = locale;
|
---|
398 | this._localeChanges.next();
|
---|
399 | }
|
---|
400 | /**
|
---|
401 | * Compares two dates.
|
---|
402 | * @param first The first date to compare.
|
---|
403 | * @param second The second date to compare.
|
---|
404 | * @returns 0 if the dates are equal, a number less than 0 if the first date is earlier,
|
---|
405 | * a number greater than 0 if the first date is later.
|
---|
406 | */
|
---|
407 | compareDate(first, second) {
|
---|
408 | return this.getYear(first) - this.getYear(second) ||
|
---|
409 | this.getMonth(first) - this.getMonth(second) ||
|
---|
410 | this.getDate(first) - this.getDate(second);
|
---|
411 | }
|
---|
412 | /**
|
---|
413 | * Checks if two dates are equal.
|
---|
414 | * @param first The first date to check.
|
---|
415 | * @param second The second date to check.
|
---|
416 | * @returns Whether the two dates are equal.
|
---|
417 | * Null dates are considered equal to other null dates.
|
---|
418 | */
|
---|
419 | sameDate(first, second) {
|
---|
420 | if (first && second) {
|
---|
421 | let firstValid = this.isValid(first);
|
---|
422 | let secondValid = this.isValid(second);
|
---|
423 | if (firstValid && secondValid) {
|
---|
424 | return !this.compareDate(first, second);
|
---|
425 | }
|
---|
426 | return firstValid == secondValid;
|
---|
427 | }
|
---|
428 | return first == second;
|
---|
429 | }
|
---|
430 | /**
|
---|
431 | * Clamp the given date between min and max dates.
|
---|
432 | * @param date The date to clamp.
|
---|
433 | * @param min The minimum value to allow. If null or omitted no min is enforced.
|
---|
434 | * @param max The maximum value to allow. If null or omitted no max is enforced.
|
---|
435 | * @returns `min` if `date` is less than `min`, `max` if date is greater than `max`,
|
---|
436 | * otherwise `date`.
|
---|
437 | */
|
---|
438 | clampDate(date, min, max) {
|
---|
439 | if (min && this.compareDate(date, min) < 0) {
|
---|
440 | return min;
|
---|
441 | }
|
---|
442 | if (max && this.compareDate(date, max) > 0) {
|
---|
443 | return max;
|
---|
444 | }
|
---|
445 | return date;
|
---|
446 | }
|
---|
447 | }
|
---|
448 |
|
---|
449 | /**
|
---|
450 | * @license
|
---|
451 | * Copyright Google LLC All Rights Reserved.
|
---|
452 | *
|
---|
453 | * Use of this source code is governed by an MIT-style license that can be
|
---|
454 | * found in the LICENSE file at https://angular.io/license
|
---|
455 | */
|
---|
456 | const MAT_DATE_FORMATS = new InjectionToken('mat-date-formats');
|
---|
457 |
|
---|
458 | /**
|
---|
459 | * @license
|
---|
460 | * Copyright Google LLC All Rights Reserved.
|
---|
461 | *
|
---|
462 | * Use of this source code is governed by an MIT-style license that can be
|
---|
463 | * found in the LICENSE file at https://angular.io/license
|
---|
464 | */
|
---|
465 | // TODO(mmalerba): Remove when we no longer support safari 9.
|
---|
466 | /** Whether the browser supports the Intl API. */
|
---|
467 | let SUPPORTS_INTL_API;
|
---|
468 | // We need a try/catch around the reference to `Intl`, because accessing it in some cases can
|
---|
469 | // cause IE to throw. These cases are tied to particular versions of Windows and can happen if
|
---|
470 | // the consumer is providing a polyfilled `Map`. See:
|
---|
471 | // https://github.com/Microsoft/ChakraCore/issues/3189
|
---|
472 | // https://github.com/angular/components/issues/15687
|
---|
473 | try {
|
---|
474 | SUPPORTS_INTL_API = typeof Intl != 'undefined';
|
---|
475 | }
|
---|
476 | catch (_a) {
|
---|
477 | SUPPORTS_INTL_API = false;
|
---|
478 | }
|
---|
479 | /** The default month names to use if Intl API is not available. */
|
---|
480 | const DEFAULT_MONTH_NAMES = {
|
---|
481 | 'long': [
|
---|
482 | 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September',
|
---|
483 | 'October', 'November', 'December'
|
---|
484 | ],
|
---|
485 | 'short': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
---|
486 | 'narrow': ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D']
|
---|
487 | };
|
---|
488 | const ɵ0$1 = i => String(i + 1);
|
---|
489 | /** The default date names to use if Intl API is not available. */
|
---|
490 | const DEFAULT_DATE_NAMES = range(31, ɵ0$1);
|
---|
491 | /** The default day of the week names to use if Intl API is not available. */
|
---|
492 | const DEFAULT_DAY_OF_WEEK_NAMES = {
|
---|
493 | 'long': ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
---|
494 | 'short': ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
---|
495 | 'narrow': ['S', 'M', 'T', 'W', 'T', 'F', 'S']
|
---|
496 | };
|
---|
497 | /**
|
---|
498 | * Matches strings that have the form of a valid RFC 3339 string
|
---|
499 | * (https://tools.ietf.org/html/rfc3339). Note that the string may not actually be a valid date
|
---|
500 | * because the regex will match strings an with out of bounds month, date, etc.
|
---|
501 | */
|
---|
502 | const ISO_8601_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;
|
---|
503 | /** Creates an array and fills it with values. */
|
---|
504 | function range(length, valueFunction) {
|
---|
505 | const valuesArray = Array(length);
|
---|
506 | for (let i = 0; i < length; i++) {
|
---|
507 | valuesArray[i] = valueFunction(i);
|
---|
508 | }
|
---|
509 | return valuesArray;
|
---|
510 | }
|
---|
511 | /** Adapts the native JS Date for use with cdk-based components that work with dates. */
|
---|
512 | class NativeDateAdapter extends DateAdapter {
|
---|
513 | constructor(matDateLocale, platform) {
|
---|
514 | super();
|
---|
515 | /**
|
---|
516 | * Whether to use `timeZone: 'utc'` with `Intl.DateTimeFormat` when formatting dates.
|
---|
517 | * Without this `Intl.DateTimeFormat` sometimes chooses the wrong timeZone, which can throw off
|
---|
518 | * the result. (e.g. in the en-US locale `new Date(1800, 7, 14).toLocaleDateString()`
|
---|
519 | * will produce `'8/13/1800'`.
|
---|
520 | *
|
---|
521 | * TODO(mmalerba): drop this variable. It's not being used in the code right now. We're now
|
---|
522 | * getting the string representation of a Date object from its utc representation. We're keeping
|
---|
523 | * it here for sometime, just for precaution, in case we decide to revert some of these changes
|
---|
524 | * though.
|
---|
525 | */
|
---|
526 | this.useUtcForDisplay = true;
|
---|
527 | super.setLocale(matDateLocale);
|
---|
528 | // IE does its own time zone correction, so we disable this on IE.
|
---|
529 | this.useUtcForDisplay = !platform.TRIDENT;
|
---|
530 | this._clampDate = platform.TRIDENT || platform.EDGE;
|
---|
531 | }
|
---|
532 | getYear(date) {
|
---|
533 | return date.getFullYear();
|
---|
534 | }
|
---|
535 | getMonth(date) {
|
---|
536 | return date.getMonth();
|
---|
537 | }
|
---|
538 | getDate(date) {
|
---|
539 | return date.getDate();
|
---|
540 | }
|
---|
541 | getDayOfWeek(date) {
|
---|
542 | return date.getDay();
|
---|
543 | }
|
---|
544 | getMonthNames(style) {
|
---|
545 | if (SUPPORTS_INTL_API) {
|
---|
546 | const dtf = new Intl.DateTimeFormat(this.locale, { month: style, timeZone: 'utc' });
|
---|
547 | return range(12, i => this._stripDirectionalityCharacters(this._format(dtf, new Date(2017, i, 1))));
|
---|
548 | }
|
---|
549 | return DEFAULT_MONTH_NAMES[style];
|
---|
550 | }
|
---|
551 | getDateNames() {
|
---|
552 | if (SUPPORTS_INTL_API) {
|
---|
553 | const dtf = new Intl.DateTimeFormat(this.locale, { day: 'numeric', timeZone: 'utc' });
|
---|
554 | return range(31, i => this._stripDirectionalityCharacters(this._format(dtf, new Date(2017, 0, i + 1))));
|
---|
555 | }
|
---|
556 | return DEFAULT_DATE_NAMES;
|
---|
557 | }
|
---|
558 | getDayOfWeekNames(style) {
|
---|
559 | if (SUPPORTS_INTL_API) {
|
---|
560 | const dtf = new Intl.DateTimeFormat(this.locale, { weekday: style, timeZone: 'utc' });
|
---|
561 | return range(7, i => this._stripDirectionalityCharacters(this._format(dtf, new Date(2017, 0, i + 1))));
|
---|
562 | }
|
---|
563 | return DEFAULT_DAY_OF_WEEK_NAMES[style];
|
---|
564 | }
|
---|
565 | getYearName(date) {
|
---|
566 | if (SUPPORTS_INTL_API) {
|
---|
567 | const dtf = new Intl.DateTimeFormat(this.locale, { year: 'numeric', timeZone: 'utc' });
|
---|
568 | return this._stripDirectionalityCharacters(this._format(dtf, date));
|
---|
569 | }
|
---|
570 | return String(this.getYear(date));
|
---|
571 | }
|
---|
572 | getFirstDayOfWeek() {
|
---|
573 | // We can't tell using native JS Date what the first day of the week is, we default to Sunday.
|
---|
574 | return 0;
|
---|
575 | }
|
---|
576 | getNumDaysInMonth(date) {
|
---|
577 | return this.getDate(this._createDateWithOverflow(this.getYear(date), this.getMonth(date) + 1, 0));
|
---|
578 | }
|
---|
579 | clone(date) {
|
---|
580 | return new Date(date.getTime());
|
---|
581 | }
|
---|
582 | createDate(year, month, date) {
|
---|
583 | if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
---|
584 | // Check for invalid month and date (except upper bound on date which we have to check after
|
---|
585 | // creating the Date).
|
---|
586 | if (month < 0 || month > 11) {
|
---|
587 | throw Error(`Invalid month index "${month}". Month index has to be between 0 and 11.`);
|
---|
588 | }
|
---|
589 | if (date < 1) {
|
---|
590 | throw Error(`Invalid date "${date}". Date has to be greater than 0.`);
|
---|
591 | }
|
---|
592 | }
|
---|
593 | let result = this._createDateWithOverflow(year, month, date);
|
---|
594 | // Check that the date wasn't above the upper bound for the month, causing the month to overflow
|
---|
595 | if (result.getMonth() != month && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
596 | throw Error(`Invalid date "${date}" for month with index "${month}".`);
|
---|
597 | }
|
---|
598 | return result;
|
---|
599 | }
|
---|
600 | today() {
|
---|
601 | return new Date();
|
---|
602 | }
|
---|
603 | parse(value) {
|
---|
604 | // We have no way using the native JS Date to set the parse format or locale, so we ignore these
|
---|
605 | // parameters.
|
---|
606 | if (typeof value == 'number') {
|
---|
607 | return new Date(value);
|
---|
608 | }
|
---|
609 | return value ? new Date(Date.parse(value)) : null;
|
---|
610 | }
|
---|
611 | format(date, displayFormat) {
|
---|
612 | if (!this.isValid(date)) {
|
---|
613 | throw Error('NativeDateAdapter: Cannot format invalid date.');
|
---|
614 | }
|
---|
615 | if (SUPPORTS_INTL_API) {
|
---|
616 | // On IE and Edge the i18n API will throw a hard error that can crash the entire app
|
---|
617 | // if we attempt to format a date whose year is less than 1 or greater than 9999.
|
---|
618 | if (this._clampDate && (date.getFullYear() < 1 || date.getFullYear() > 9999)) {
|
---|
619 | date = this.clone(date);
|
---|
620 | date.setFullYear(Math.max(1, Math.min(9999, date.getFullYear())));
|
---|
621 | }
|
---|
622 | displayFormat = Object.assign(Object.assign({}, displayFormat), { timeZone: 'utc' });
|
---|
623 | const dtf = new Intl.DateTimeFormat(this.locale, displayFormat);
|
---|
624 | return this._stripDirectionalityCharacters(this._format(dtf, date));
|
---|
625 | }
|
---|
626 | return this._stripDirectionalityCharacters(date.toDateString());
|
---|
627 | }
|
---|
628 | addCalendarYears(date, years) {
|
---|
629 | return this.addCalendarMonths(date, years * 12);
|
---|
630 | }
|
---|
631 | addCalendarMonths(date, months) {
|
---|
632 | let newDate = this._createDateWithOverflow(this.getYear(date), this.getMonth(date) + months, this.getDate(date));
|
---|
633 | // It's possible to wind up in the wrong month if the original month has more days than the new
|
---|
634 | // month. In this case we want to go to the last day of the desired month.
|
---|
635 | // Note: the additional + 12 % 12 ensures we end up with a positive number, since JS % doesn't
|
---|
636 | // guarantee this.
|
---|
637 | if (this.getMonth(newDate) != ((this.getMonth(date) + months) % 12 + 12) % 12) {
|
---|
638 | newDate = this._createDateWithOverflow(this.getYear(newDate), this.getMonth(newDate), 0);
|
---|
639 | }
|
---|
640 | return newDate;
|
---|
641 | }
|
---|
642 | addCalendarDays(date, days) {
|
---|
643 | return this._createDateWithOverflow(this.getYear(date), this.getMonth(date), this.getDate(date) + days);
|
---|
644 | }
|
---|
645 | toIso8601(date) {
|
---|
646 | return [
|
---|
647 | date.getUTCFullYear(),
|
---|
648 | this._2digit(date.getUTCMonth() + 1),
|
---|
649 | this._2digit(date.getUTCDate())
|
---|
650 | ].join('-');
|
---|
651 | }
|
---|
652 | /**
|
---|
653 | * Returns the given value if given a valid Date or null. Deserializes valid ISO 8601 strings
|
---|
654 | * (https://www.ietf.org/rfc/rfc3339.txt) into valid Dates and empty string into null. Returns an
|
---|
655 | * invalid date for all other values.
|
---|
656 | */
|
---|
657 | deserialize(value) {
|
---|
658 | if (typeof value === 'string') {
|
---|
659 | if (!value) {
|
---|
660 | return null;
|
---|
661 | }
|
---|
662 | // The `Date` constructor accepts formats other than ISO 8601, so we need to make sure the
|
---|
663 | // string is the right format first.
|
---|
664 | if (ISO_8601_REGEX.test(value)) {
|
---|
665 | let date = new Date(value);
|
---|
666 | if (this.isValid(date)) {
|
---|
667 | return date;
|
---|
668 | }
|
---|
669 | }
|
---|
670 | }
|
---|
671 | return super.deserialize(value);
|
---|
672 | }
|
---|
673 | isDateInstance(obj) {
|
---|
674 | return obj instanceof Date;
|
---|
675 | }
|
---|
676 | isValid(date) {
|
---|
677 | return !isNaN(date.getTime());
|
---|
678 | }
|
---|
679 | invalid() {
|
---|
680 | return new Date(NaN);
|
---|
681 | }
|
---|
682 | /** Creates a date but allows the month and date to overflow. */
|
---|
683 | _createDateWithOverflow(year, month, date) {
|
---|
684 | // Passing the year to the constructor causes year numbers <100 to be converted to 19xx.
|
---|
685 | // To work around this we use `setFullYear` and `setHours` instead.
|
---|
686 | const d = new Date();
|
---|
687 | d.setFullYear(year, month, date);
|
---|
688 | d.setHours(0, 0, 0, 0);
|
---|
689 | return d;
|
---|
690 | }
|
---|
691 | /**
|
---|
692 | * Pads a number to make it two digits.
|
---|
693 | * @param n The number to pad.
|
---|
694 | * @returns The padded number.
|
---|
695 | */
|
---|
696 | _2digit(n) {
|
---|
697 | return ('00' + n).slice(-2);
|
---|
698 | }
|
---|
699 | /**
|
---|
700 | * Strip out unicode LTR and RTL characters. Edge and IE insert these into formatted dates while
|
---|
701 | * other browsers do not. We remove them to make output consistent and because they interfere with
|
---|
702 | * date parsing.
|
---|
703 | * @param str The string to strip direction characters from.
|
---|
704 | * @returns The stripped string.
|
---|
705 | */
|
---|
706 | _stripDirectionalityCharacters(str) {
|
---|
707 | return str.replace(/[\u200e\u200f]/g, '');
|
---|
708 | }
|
---|
709 | /**
|
---|
710 | * When converting Date object to string, javascript built-in functions may return wrong
|
---|
711 | * results because it applies its internal DST rules. The DST rules around the world change
|
---|
712 | * very frequently, and the current valid rule is not always valid in previous years though.
|
---|
713 | * We work around this problem building a new Date object which has its internal UTC
|
---|
714 | * representation with the local date and time.
|
---|
715 | * @param dtf Intl.DateTimeFormat object, containg the desired string format. It must have
|
---|
716 | * timeZone set to 'utc' to work fine.
|
---|
717 | * @param date Date from which we want to get the string representation according to dtf
|
---|
718 | * @returns A Date object with its UTC representation based on the passed in date info
|
---|
719 | */
|
---|
720 | _format(dtf, date) {
|
---|
721 | // Passing the year to the constructor causes year numbers <100 to be converted to 19xx.
|
---|
722 | // To work around this we use `setUTCFullYear` and `setUTCHours` instead.
|
---|
723 | const d = new Date();
|
---|
724 | d.setUTCFullYear(date.getFullYear(), date.getMonth(), date.getDate());
|
---|
725 | d.setUTCHours(date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
---|
726 | return dtf.format(d);
|
---|
727 | }
|
---|
728 | }
|
---|
729 | NativeDateAdapter.decorators = [
|
---|
730 | { type: Injectable }
|
---|
731 | ];
|
---|
732 | NativeDateAdapter.ctorParameters = () => [
|
---|
733 | { type: String, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DATE_LOCALE,] }] },
|
---|
734 | { type: Platform }
|
---|
735 | ];
|
---|
736 |
|
---|
737 | /**
|
---|
738 | * @license
|
---|
739 | * Copyright Google LLC All Rights Reserved.
|
---|
740 | *
|
---|
741 | * Use of this source code is governed by an MIT-style license that can be
|
---|
742 | * found in the LICENSE file at https://angular.io/license
|
---|
743 | */
|
---|
744 | const MAT_NATIVE_DATE_FORMATS = {
|
---|
745 | parse: {
|
---|
746 | dateInput: null,
|
---|
747 | },
|
---|
748 | display: {
|
---|
749 | dateInput: { year: 'numeric', month: 'numeric', day: 'numeric' },
|
---|
750 | monthYearLabel: { year: 'numeric', month: 'short' },
|
---|
751 | dateA11yLabel: { year: 'numeric', month: 'long', day: 'numeric' },
|
---|
752 | monthYearA11yLabel: { year: 'numeric', month: 'long' },
|
---|
753 | }
|
---|
754 | };
|
---|
755 |
|
---|
756 | /**
|
---|
757 | * @license
|
---|
758 | * Copyright Google LLC All Rights Reserved.
|
---|
759 | *
|
---|
760 | * Use of this source code is governed by an MIT-style license that can be
|
---|
761 | * found in the LICENSE file at https://angular.io/license
|
---|
762 | */
|
---|
763 | class NativeDateModule {
|
---|
764 | }
|
---|
765 | NativeDateModule.decorators = [
|
---|
766 | { type: NgModule, args: [{
|
---|
767 | imports: [PlatformModule],
|
---|
768 | providers: [
|
---|
769 | { provide: DateAdapter, useClass: NativeDateAdapter },
|
---|
770 | ],
|
---|
771 | },] }
|
---|
772 | ];
|
---|
773 | const ɵ0 = MAT_NATIVE_DATE_FORMATS;
|
---|
774 | class MatNativeDateModule {
|
---|
775 | }
|
---|
776 | MatNativeDateModule.decorators = [
|
---|
777 | { type: NgModule, args: [{
|
---|
778 | imports: [NativeDateModule],
|
---|
779 | providers: [{ provide: MAT_DATE_FORMATS, useValue: ɵ0 }],
|
---|
780 | },] }
|
---|
781 | ];
|
---|
782 |
|
---|
783 | /**
|
---|
784 | * @license
|
---|
785 | * Copyright Google LLC All Rights Reserved.
|
---|
786 | *
|
---|
787 | * Use of this source code is governed by an MIT-style license that can be
|
---|
788 | * found in the LICENSE file at https://angular.io/license
|
---|
789 | */
|
---|
790 | /** Error state matcher that matches when a control is invalid and dirty. */
|
---|
791 | class ShowOnDirtyErrorStateMatcher {
|
---|
792 | isErrorState(control, form) {
|
---|
793 | return !!(control && control.invalid && (control.dirty || (form && form.submitted)));
|
---|
794 | }
|
---|
795 | }
|
---|
796 | ShowOnDirtyErrorStateMatcher.decorators = [
|
---|
797 | { type: Injectable }
|
---|
798 | ];
|
---|
799 | /** Provider that defines how form controls behave with regards to displaying error messages. */
|
---|
800 | class ErrorStateMatcher {
|
---|
801 | isErrorState(control, form) {
|
---|
802 | return !!(control && control.invalid && (control.touched || (form && form.submitted)));
|
---|
803 | }
|
---|
804 | }
|
---|
805 | ErrorStateMatcher.ɵprov = i0.ɵɵdefineInjectable({ factory: function ErrorStateMatcher_Factory() { return new ErrorStateMatcher(); }, token: ErrorStateMatcher, providedIn: "root" });
|
---|
806 | ErrorStateMatcher.decorators = [
|
---|
807 | { type: Injectable, args: [{ providedIn: 'root' },] }
|
---|
808 | ];
|
---|
809 |
|
---|
810 | /**
|
---|
811 | * @license
|
---|
812 | * Copyright Google LLC All Rights Reserved.
|
---|
813 | *
|
---|
814 | * Use of this source code is governed by an MIT-style license that can be
|
---|
815 | * found in the LICENSE file at https://angular.io/license
|
---|
816 | */
|
---|
817 | /**
|
---|
818 | * Shared directive to count lines inside a text area, such as a list item.
|
---|
819 | * Line elements can be extracted with a @ContentChildren(MatLine) query, then
|
---|
820 | * counted by checking the query list's length.
|
---|
821 | */
|
---|
822 | class MatLine {
|
---|
823 | }
|
---|
824 | MatLine.decorators = [
|
---|
825 | { type: Directive, args: [{
|
---|
826 | selector: '[mat-line], [matLine]',
|
---|
827 | host: { 'class': 'mat-line' }
|
---|
828 | },] }
|
---|
829 | ];
|
---|
830 | /**
|
---|
831 | * Helper that takes a query list of lines and sets the correct class on the host.
|
---|
832 | * @docs-private
|
---|
833 | */
|
---|
834 | function setLines(lines, element, prefix = 'mat') {
|
---|
835 | // Note: doesn't need to unsubscribe, because `changes`
|
---|
836 | // gets completed by Angular when the view is destroyed.
|
---|
837 | lines.changes.pipe(startWith(lines)).subscribe(({ length }) => {
|
---|
838 | setClass(element, `${prefix}-2-line`, false);
|
---|
839 | setClass(element, `${prefix}-3-line`, false);
|
---|
840 | setClass(element, `${prefix}-multi-line`, false);
|
---|
841 | if (length === 2 || length === 3) {
|
---|
842 | setClass(element, `${prefix}-${length}-line`, true);
|
---|
843 | }
|
---|
844 | else if (length > 3) {
|
---|
845 | setClass(element, `${prefix}-multi-line`, true);
|
---|
846 | }
|
---|
847 | });
|
---|
848 | }
|
---|
849 | /** Adds or removes a class from an element. */
|
---|
850 | function setClass(element, className, isAdd) {
|
---|
851 | const classList = element.nativeElement.classList;
|
---|
852 | isAdd ? classList.add(className) : classList.remove(className);
|
---|
853 | }
|
---|
854 | class MatLineModule {
|
---|
855 | }
|
---|
856 | MatLineModule.decorators = [
|
---|
857 | { type: NgModule, args: [{
|
---|
858 | imports: [MatCommonModule],
|
---|
859 | exports: [MatLine, MatCommonModule],
|
---|
860 | declarations: [MatLine],
|
---|
861 | },] }
|
---|
862 | ];
|
---|
863 |
|
---|
864 | /**
|
---|
865 | * @license
|
---|
866 | * Copyright Google LLC All Rights Reserved.
|
---|
867 | *
|
---|
868 | * Use of this source code is governed by an MIT-style license that can be
|
---|
869 | * found in the LICENSE file at https://angular.io/license
|
---|
870 | */
|
---|
871 | /**
|
---|
872 | * Reference to a previously launched ripple element.
|
---|
873 | */
|
---|
874 | class RippleRef {
|
---|
875 | constructor(_renderer,
|
---|
876 | /** Reference to the ripple HTML element. */
|
---|
877 | element,
|
---|
878 | /** Ripple configuration used for the ripple. */
|
---|
879 | config) {
|
---|
880 | this._renderer = _renderer;
|
---|
881 | this.element = element;
|
---|
882 | this.config = config;
|
---|
883 | /** Current state of the ripple. */
|
---|
884 | this.state = 3 /* HIDDEN */;
|
---|
885 | }
|
---|
886 | /** Fades out the ripple element. */
|
---|
887 | fadeOut() {
|
---|
888 | this._renderer.fadeOutRipple(this);
|
---|
889 | }
|
---|
890 | }
|
---|
891 |
|
---|
892 | // TODO: import these values from `@material/ripple` eventually.
|
---|
893 | /**
|
---|
894 | * Default ripple animation configuration for ripples without an explicit
|
---|
895 | * animation config specified.
|
---|
896 | */
|
---|
897 | const defaultRippleAnimationConfig = {
|
---|
898 | enterDuration: 225,
|
---|
899 | exitDuration: 150
|
---|
900 | };
|
---|
901 | /**
|
---|
902 | * Timeout for ignoring mouse events. Mouse events will be temporary ignored after touch
|
---|
903 | * events to avoid synthetic mouse events.
|
---|
904 | */
|
---|
905 | const ignoreMouseEventsTimeout = 800;
|
---|
906 | /** Options that apply to all the event listeners that are bound by the ripple renderer. */
|
---|
907 | const passiveEventOptions = normalizePassiveListenerOptions({ passive: true });
|
---|
908 | /** Events that signal that the pointer is down. */
|
---|
909 | const pointerDownEvents = ['mousedown', 'touchstart'];
|
---|
910 | /** Events that signal that the pointer is up. */
|
---|
911 | const pointerUpEvents = ['mouseup', 'mouseleave', 'touchend', 'touchcancel'];
|
---|
912 | /**
|
---|
913 | * Helper service that performs DOM manipulations. Not intended to be used outside this module.
|
---|
914 | * The constructor takes a reference to the ripple directive's host element and a map of DOM
|
---|
915 | * event handlers to be installed on the element that triggers ripple animations.
|
---|
916 | * This will eventually become a custom renderer once Angular support exists.
|
---|
917 | * @docs-private
|
---|
918 | */
|
---|
919 | class RippleRenderer {
|
---|
920 | constructor(_target, _ngZone, elementOrElementRef, platform) {
|
---|
921 | this._target = _target;
|
---|
922 | this._ngZone = _ngZone;
|
---|
923 | /** Whether the pointer is currently down or not. */
|
---|
924 | this._isPointerDown = false;
|
---|
925 | /** Set of currently active ripple references. */
|
---|
926 | this._activeRipples = new Set();
|
---|
927 | /** Whether pointer-up event listeners have been registered. */
|
---|
928 | this._pointerUpEventsRegistered = false;
|
---|
929 | // Only do anything if we're on the browser.
|
---|
930 | if (platform.isBrowser) {
|
---|
931 | this._containerElement = coerceElement(elementOrElementRef);
|
---|
932 | }
|
---|
933 | }
|
---|
934 | /**
|
---|
935 | * Fades in a ripple at the given coordinates.
|
---|
936 | * @param x Coordinate within the element, along the X axis at which to start the ripple.
|
---|
937 | * @param y Coordinate within the element, along the Y axis at which to start the ripple.
|
---|
938 | * @param config Extra ripple options.
|
---|
939 | */
|
---|
940 | fadeInRipple(x, y, config = {}) {
|
---|
941 | const containerRect = this._containerRect =
|
---|
942 | this._containerRect || this._containerElement.getBoundingClientRect();
|
---|
943 | const animationConfig = Object.assign(Object.assign({}, defaultRippleAnimationConfig), config.animation);
|
---|
944 | if (config.centered) {
|
---|
945 | x = containerRect.left + containerRect.width / 2;
|
---|
946 | y = containerRect.top + containerRect.height / 2;
|
---|
947 | }
|
---|
948 | const radius = config.radius || distanceToFurthestCorner(x, y, containerRect);
|
---|
949 | const offsetX = x - containerRect.left;
|
---|
950 | const offsetY = y - containerRect.top;
|
---|
951 | const duration = animationConfig.enterDuration;
|
---|
952 | const ripple = document.createElement('div');
|
---|
953 | ripple.classList.add('mat-ripple-element');
|
---|
954 | ripple.style.left = `${offsetX - radius}px`;
|
---|
955 | ripple.style.top = `${offsetY - radius}px`;
|
---|
956 | ripple.style.height = `${radius * 2}px`;
|
---|
957 | ripple.style.width = `${radius * 2}px`;
|
---|
958 | // If a custom color has been specified, set it as inline style. If no color is
|
---|
959 | // set, the default color will be applied through the ripple theme styles.
|
---|
960 | if (config.color != null) {
|
---|
961 | ripple.style.backgroundColor = config.color;
|
---|
962 | }
|
---|
963 | ripple.style.transitionDuration = `${duration}ms`;
|
---|
964 | this._containerElement.appendChild(ripple);
|
---|
965 | // By default the browser does not recalculate the styles of dynamically created
|
---|
966 | // ripple elements. This is critical because then the `scale` would not animate properly.
|
---|
967 | enforceStyleRecalculation(ripple);
|
---|
968 | ripple.style.transform = 'scale(1)';
|
---|
969 | // Exposed reference to the ripple that will be returned.
|
---|
970 | const rippleRef = new RippleRef(this, ripple, config);
|
---|
971 | rippleRef.state = 0 /* FADING_IN */;
|
---|
972 | // Add the ripple reference to the list of all active ripples.
|
---|
973 | this._activeRipples.add(rippleRef);
|
---|
974 | if (!config.persistent) {
|
---|
975 | this._mostRecentTransientRipple = rippleRef;
|
---|
976 | }
|
---|
977 | // Wait for the ripple element to be completely faded in.
|
---|
978 | // Once it's faded in, the ripple can be hidden immediately if the mouse is released.
|
---|
979 | this._runTimeoutOutsideZone(() => {
|
---|
980 | const isMostRecentTransientRipple = rippleRef === this._mostRecentTransientRipple;
|
---|
981 | rippleRef.state = 1 /* VISIBLE */;
|
---|
982 | // When the timer runs out while the user has kept their pointer down, we want to
|
---|
983 | // keep only the persistent ripples and the latest transient ripple. We do this,
|
---|
984 | // because we don't want stacked transient ripples to appear after their enter
|
---|
985 | // animation has finished.
|
---|
986 | if (!config.persistent && (!isMostRecentTransientRipple || !this._isPointerDown)) {
|
---|
987 | rippleRef.fadeOut();
|
---|
988 | }
|
---|
989 | }, duration);
|
---|
990 | return rippleRef;
|
---|
991 | }
|
---|
992 | /** Fades out a ripple reference. */
|
---|
993 | fadeOutRipple(rippleRef) {
|
---|
994 | const wasActive = this._activeRipples.delete(rippleRef);
|
---|
995 | if (rippleRef === this._mostRecentTransientRipple) {
|
---|
996 | this._mostRecentTransientRipple = null;
|
---|
997 | }
|
---|
998 | // Clear out the cached bounding rect if we have no more ripples.
|
---|
999 | if (!this._activeRipples.size) {
|
---|
1000 | this._containerRect = null;
|
---|
1001 | }
|
---|
1002 | // For ripples that are not active anymore, don't re-run the fade-out animation.
|
---|
1003 | if (!wasActive) {
|
---|
1004 | return;
|
---|
1005 | }
|
---|
1006 | const rippleEl = rippleRef.element;
|
---|
1007 | const animationConfig = Object.assign(Object.assign({}, defaultRippleAnimationConfig), rippleRef.config.animation);
|
---|
1008 | rippleEl.style.transitionDuration = `${animationConfig.exitDuration}ms`;
|
---|
1009 | rippleEl.style.opacity = '0';
|
---|
1010 | rippleRef.state = 2 /* FADING_OUT */;
|
---|
1011 | // Once the ripple faded out, the ripple can be safely removed from the DOM.
|
---|
1012 | this._runTimeoutOutsideZone(() => {
|
---|
1013 | rippleRef.state = 3 /* HIDDEN */;
|
---|
1014 | rippleEl.parentNode.removeChild(rippleEl);
|
---|
1015 | }, animationConfig.exitDuration);
|
---|
1016 | }
|
---|
1017 | /** Fades out all currently active ripples. */
|
---|
1018 | fadeOutAll() {
|
---|
1019 | this._activeRipples.forEach(ripple => ripple.fadeOut());
|
---|
1020 | }
|
---|
1021 | /** Fades out all currently active non-persistent ripples. */
|
---|
1022 | fadeOutAllNonPersistent() {
|
---|
1023 | this._activeRipples.forEach(ripple => {
|
---|
1024 | if (!ripple.config.persistent) {
|
---|
1025 | ripple.fadeOut();
|
---|
1026 | }
|
---|
1027 | });
|
---|
1028 | }
|
---|
1029 | /** Sets up the trigger event listeners */
|
---|
1030 | setupTriggerEvents(elementOrElementRef) {
|
---|
1031 | const element = coerceElement(elementOrElementRef);
|
---|
1032 | if (!element || element === this._triggerElement) {
|
---|
1033 | return;
|
---|
1034 | }
|
---|
1035 | // Remove all previously registered event listeners from the trigger element.
|
---|
1036 | this._removeTriggerEvents();
|
---|
1037 | this._triggerElement = element;
|
---|
1038 | this._registerEvents(pointerDownEvents);
|
---|
1039 | }
|
---|
1040 | /**
|
---|
1041 | * Handles all registered events.
|
---|
1042 | * @docs-private
|
---|
1043 | */
|
---|
1044 | handleEvent(event) {
|
---|
1045 | if (event.type === 'mousedown') {
|
---|
1046 | this._onMousedown(event);
|
---|
1047 | }
|
---|
1048 | else if (event.type === 'touchstart') {
|
---|
1049 | this._onTouchStart(event);
|
---|
1050 | }
|
---|
1051 | else {
|
---|
1052 | this._onPointerUp();
|
---|
1053 | }
|
---|
1054 | // If pointer-up events haven't been registered yet, do so now.
|
---|
1055 | // We do this on-demand in order to reduce the total number of event listeners
|
---|
1056 | // registered by the ripples, which speeds up the rendering time for large UIs.
|
---|
1057 | if (!this._pointerUpEventsRegistered) {
|
---|
1058 | this._registerEvents(pointerUpEvents);
|
---|
1059 | this._pointerUpEventsRegistered = true;
|
---|
1060 | }
|
---|
1061 | }
|
---|
1062 | /** Function being called whenever the trigger is being pressed using mouse. */
|
---|
1063 | _onMousedown(event) {
|
---|
1064 | // Screen readers will fire fake mouse events for space/enter. Skip launching a
|
---|
1065 | // ripple in this case for consistency with the non-screen-reader experience.
|
---|
1066 | const isFakeMousedown = isFakeMousedownFromScreenReader(event);
|
---|
1067 | const isSyntheticEvent = this._lastTouchStartEvent &&
|
---|
1068 | Date.now() < this._lastTouchStartEvent + ignoreMouseEventsTimeout;
|
---|
1069 | if (!this._target.rippleDisabled && !isFakeMousedown && !isSyntheticEvent) {
|
---|
1070 | this._isPointerDown = true;
|
---|
1071 | this.fadeInRipple(event.clientX, event.clientY, this._target.rippleConfig);
|
---|
1072 | }
|
---|
1073 | }
|
---|
1074 | /** Function being called whenever the trigger is being pressed using touch. */
|
---|
1075 | _onTouchStart(event) {
|
---|
1076 | if (!this._target.rippleDisabled && !isFakeTouchstartFromScreenReader(event)) {
|
---|
1077 | // Some browsers fire mouse events after a `touchstart` event. Those synthetic mouse
|
---|
1078 | // events will launch a second ripple if we don't ignore mouse events for a specific
|
---|
1079 | // time after a touchstart event.
|
---|
1080 | this._lastTouchStartEvent = Date.now();
|
---|
1081 | this._isPointerDown = true;
|
---|
1082 | // Use `changedTouches` so we skip any touches where the user put
|
---|
1083 | // their finger down, but used another finger to tap the element again.
|
---|
1084 | const touches = event.changedTouches;
|
---|
1085 | for (let i = 0; i < touches.length; i++) {
|
---|
1086 | this.fadeInRipple(touches[i].clientX, touches[i].clientY, this._target.rippleConfig);
|
---|
1087 | }
|
---|
1088 | }
|
---|
1089 | }
|
---|
1090 | /** Function being called whenever the trigger is being released. */
|
---|
1091 | _onPointerUp() {
|
---|
1092 | if (!this._isPointerDown) {
|
---|
1093 | return;
|
---|
1094 | }
|
---|
1095 | this._isPointerDown = false;
|
---|
1096 | // Fade-out all ripples that are visible and not persistent.
|
---|
1097 | this._activeRipples.forEach(ripple => {
|
---|
1098 | // By default, only ripples that are completely visible will fade out on pointer release.
|
---|
1099 | // If the `terminateOnPointerUp` option is set, ripples that still fade in will also fade out.
|
---|
1100 | const isVisible = ripple.state === 1 /* VISIBLE */ ||
|
---|
1101 | ripple.config.terminateOnPointerUp && ripple.state === 0 /* FADING_IN */;
|
---|
1102 | if (!ripple.config.persistent && isVisible) {
|
---|
1103 | ripple.fadeOut();
|
---|
1104 | }
|
---|
1105 | });
|
---|
1106 | }
|
---|
1107 | /** Runs a timeout outside of the Angular zone to avoid triggering the change detection. */
|
---|
1108 | _runTimeoutOutsideZone(fn, delay = 0) {
|
---|
1109 | this._ngZone.runOutsideAngular(() => setTimeout(fn, delay));
|
---|
1110 | }
|
---|
1111 | /** Registers event listeners for a given list of events. */
|
---|
1112 | _registerEvents(eventTypes) {
|
---|
1113 | this._ngZone.runOutsideAngular(() => {
|
---|
1114 | eventTypes.forEach((type) => {
|
---|
1115 | this._triggerElement.addEventListener(type, this, passiveEventOptions);
|
---|
1116 | });
|
---|
1117 | });
|
---|
1118 | }
|
---|
1119 | /** Removes previously registered event listeners from the trigger element. */
|
---|
1120 | _removeTriggerEvents() {
|
---|
1121 | if (this._triggerElement) {
|
---|
1122 | pointerDownEvents.forEach((type) => {
|
---|
1123 | this._triggerElement.removeEventListener(type, this, passiveEventOptions);
|
---|
1124 | });
|
---|
1125 | if (this._pointerUpEventsRegistered) {
|
---|
1126 | pointerUpEvents.forEach((type) => {
|
---|
1127 | this._triggerElement.removeEventListener(type, this, passiveEventOptions);
|
---|
1128 | });
|
---|
1129 | }
|
---|
1130 | }
|
---|
1131 | }
|
---|
1132 | }
|
---|
1133 | /** Enforces a style recalculation of a DOM element by computing its styles. */
|
---|
1134 | function enforceStyleRecalculation(element) {
|
---|
1135 | // Enforce a style recalculation by calling `getComputedStyle` and accessing any property.
|
---|
1136 | // Calling `getPropertyValue` is important to let optimizers know that this is not a noop.
|
---|
1137 | // See: https://gist.github.com/paulirish/5d52fb081b3570c81e3a
|
---|
1138 | window.getComputedStyle(element).getPropertyValue('opacity');
|
---|
1139 | }
|
---|
1140 | /**
|
---|
1141 | * Returns the distance from the point (x, y) to the furthest corner of a rectangle.
|
---|
1142 | */
|
---|
1143 | function distanceToFurthestCorner(x, y, rect) {
|
---|
1144 | const distX = Math.max(Math.abs(x - rect.left), Math.abs(x - rect.right));
|
---|
1145 | const distY = Math.max(Math.abs(y - rect.top), Math.abs(y - rect.bottom));
|
---|
1146 | return Math.sqrt(distX * distX + distY * distY);
|
---|
1147 | }
|
---|
1148 |
|
---|
1149 | /**
|
---|
1150 | * @license
|
---|
1151 | * Copyright Google LLC All Rights Reserved.
|
---|
1152 | *
|
---|
1153 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1154 | * found in the LICENSE file at https://angular.io/license
|
---|
1155 | */
|
---|
1156 | /** Injection token that can be used to specify the global ripple options. */
|
---|
1157 | const MAT_RIPPLE_GLOBAL_OPTIONS = new InjectionToken('mat-ripple-global-options');
|
---|
1158 | class MatRipple {
|
---|
1159 | constructor(_elementRef, ngZone, platform, globalOptions, _animationMode) {
|
---|
1160 | this._elementRef = _elementRef;
|
---|
1161 | this._animationMode = _animationMode;
|
---|
1162 | /**
|
---|
1163 | * If set, the radius in pixels of foreground ripples when fully expanded. If unset, the radius
|
---|
1164 | * will be the distance from the center of the ripple to the furthest corner of the host element's
|
---|
1165 | * bounding rectangle.
|
---|
1166 | */
|
---|
1167 | this.radius = 0;
|
---|
1168 | this._disabled = false;
|
---|
1169 | /** Whether ripple directive is initialized and the input bindings are set. */
|
---|
1170 | this._isInitialized = false;
|
---|
1171 | this._globalOptions = globalOptions || {};
|
---|
1172 | this._rippleRenderer = new RippleRenderer(this, ngZone, _elementRef, platform);
|
---|
1173 | }
|
---|
1174 | /**
|
---|
1175 | * Whether click events will not trigger the ripple. Ripples can be still launched manually
|
---|
1176 | * by using the `launch()` method.
|
---|
1177 | */
|
---|
1178 | get disabled() { return this._disabled; }
|
---|
1179 | set disabled(value) {
|
---|
1180 | if (value) {
|
---|
1181 | this.fadeOutAllNonPersistent();
|
---|
1182 | }
|
---|
1183 | this._disabled = value;
|
---|
1184 | this._setupTriggerEventsIfEnabled();
|
---|
1185 | }
|
---|
1186 | /**
|
---|
1187 | * The element that triggers the ripple when click events are received.
|
---|
1188 | * Defaults to the directive's host element.
|
---|
1189 | */
|
---|
1190 | get trigger() { return this._trigger || this._elementRef.nativeElement; }
|
---|
1191 | set trigger(trigger) {
|
---|
1192 | this._trigger = trigger;
|
---|
1193 | this._setupTriggerEventsIfEnabled();
|
---|
1194 | }
|
---|
1195 | ngOnInit() {
|
---|
1196 | this._isInitialized = true;
|
---|
1197 | this._setupTriggerEventsIfEnabled();
|
---|
1198 | }
|
---|
1199 | ngOnDestroy() {
|
---|
1200 | this._rippleRenderer._removeTriggerEvents();
|
---|
1201 | }
|
---|
1202 | /** Fades out all currently showing ripple elements. */
|
---|
1203 | fadeOutAll() {
|
---|
1204 | this._rippleRenderer.fadeOutAll();
|
---|
1205 | }
|
---|
1206 | /** Fades out all currently showing non-persistent ripple elements. */
|
---|
1207 | fadeOutAllNonPersistent() {
|
---|
1208 | this._rippleRenderer.fadeOutAllNonPersistent();
|
---|
1209 | }
|
---|
1210 | /**
|
---|
1211 | * Ripple configuration from the directive's input values.
|
---|
1212 | * @docs-private Implemented as part of RippleTarget
|
---|
1213 | */
|
---|
1214 | get rippleConfig() {
|
---|
1215 | return {
|
---|
1216 | centered: this.centered,
|
---|
1217 | radius: this.radius,
|
---|
1218 | color: this.color,
|
---|
1219 | animation: Object.assign(Object.assign(Object.assign({}, this._globalOptions.animation), (this._animationMode === 'NoopAnimations' ? { enterDuration: 0, exitDuration: 0 } : {})), this.animation),
|
---|
1220 | terminateOnPointerUp: this._globalOptions.terminateOnPointerUp,
|
---|
1221 | };
|
---|
1222 | }
|
---|
1223 | /**
|
---|
1224 | * Whether ripples on pointer-down are disabled or not.
|
---|
1225 | * @docs-private Implemented as part of RippleTarget
|
---|
1226 | */
|
---|
1227 | get rippleDisabled() {
|
---|
1228 | return this.disabled || !!this._globalOptions.disabled;
|
---|
1229 | }
|
---|
1230 | /** Sets up the trigger event listeners if ripples are enabled. */
|
---|
1231 | _setupTriggerEventsIfEnabled() {
|
---|
1232 | if (!this.disabled && this._isInitialized) {
|
---|
1233 | this._rippleRenderer.setupTriggerEvents(this.trigger);
|
---|
1234 | }
|
---|
1235 | }
|
---|
1236 | /** Launches a manual ripple at the specified coordinated or just by the ripple config. */
|
---|
1237 | launch(configOrX, y = 0, config) {
|
---|
1238 | if (typeof configOrX === 'number') {
|
---|
1239 | return this._rippleRenderer.fadeInRipple(configOrX, y, Object.assign(Object.assign({}, this.rippleConfig), config));
|
---|
1240 | }
|
---|
1241 | else {
|
---|
1242 | return this._rippleRenderer.fadeInRipple(0, 0, Object.assign(Object.assign({}, this.rippleConfig), configOrX));
|
---|
1243 | }
|
---|
1244 | }
|
---|
1245 | }
|
---|
1246 | MatRipple.decorators = [
|
---|
1247 | { type: Directive, args: [{
|
---|
1248 | selector: '[mat-ripple], [matRipple]',
|
---|
1249 | exportAs: 'matRipple',
|
---|
1250 | host: {
|
---|
1251 | 'class': 'mat-ripple',
|
---|
1252 | '[class.mat-ripple-unbounded]': 'unbounded'
|
---|
1253 | }
|
---|
1254 | },] }
|
---|
1255 | ];
|
---|
1256 | MatRipple.ctorParameters = () => [
|
---|
1257 | { type: ElementRef },
|
---|
1258 | { type: NgZone },
|
---|
1259 | { type: Platform },
|
---|
1260 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_RIPPLE_GLOBAL_OPTIONS,] }] },
|
---|
1261 | { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
|
---|
1262 | ];
|
---|
1263 | MatRipple.propDecorators = {
|
---|
1264 | color: [{ type: Input, args: ['matRippleColor',] }],
|
---|
1265 | unbounded: [{ type: Input, args: ['matRippleUnbounded',] }],
|
---|
1266 | centered: [{ type: Input, args: ['matRippleCentered',] }],
|
---|
1267 | radius: [{ type: Input, args: ['matRippleRadius',] }],
|
---|
1268 | animation: [{ type: Input, args: ['matRippleAnimation',] }],
|
---|
1269 | disabled: [{ type: Input, args: ['matRippleDisabled',] }],
|
---|
1270 | trigger: [{ type: Input, args: ['matRippleTrigger',] }]
|
---|
1271 | };
|
---|
1272 |
|
---|
1273 | /**
|
---|
1274 | * @license
|
---|
1275 | * Copyright Google LLC All Rights Reserved.
|
---|
1276 | *
|
---|
1277 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1278 | * found in the LICENSE file at https://angular.io/license
|
---|
1279 | */
|
---|
1280 | class MatRippleModule {
|
---|
1281 | }
|
---|
1282 | MatRippleModule.decorators = [
|
---|
1283 | { type: NgModule, args: [{
|
---|
1284 | imports: [MatCommonModule, PlatformModule],
|
---|
1285 | exports: [MatRipple, MatCommonModule],
|
---|
1286 | declarations: [MatRipple],
|
---|
1287 | },] }
|
---|
1288 | ];
|
---|
1289 |
|
---|
1290 | /**
|
---|
1291 | * @license
|
---|
1292 | * Copyright Google LLC All Rights Reserved.
|
---|
1293 | *
|
---|
1294 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1295 | * found in the LICENSE file at https://angular.io/license
|
---|
1296 | */
|
---|
1297 | /**
|
---|
1298 | * Component that shows a simplified checkbox without including any kind of "real" checkbox.
|
---|
1299 | * Meant to be used when the checkbox is purely decorative and a large number of them will be
|
---|
1300 | * included, such as for the options in a multi-select. Uses no SVGs or complex animations.
|
---|
1301 | * Note that theming is meant to be handled by the parent element, e.g.
|
---|
1302 | * `mat-primary .mat-pseudo-checkbox`.
|
---|
1303 | *
|
---|
1304 | * Note that this component will be completely invisible to screen-reader users. This is *not*
|
---|
1305 | * interchangeable with `<mat-checkbox>` and should *not* be used if the user would directly
|
---|
1306 | * interact with the checkbox. The pseudo-checkbox should only be used as an implementation detail
|
---|
1307 | * of more complex components that appropriately handle selected / checked state.
|
---|
1308 | * @docs-private
|
---|
1309 | */
|
---|
1310 | class MatPseudoCheckbox {
|
---|
1311 | constructor(_animationMode) {
|
---|
1312 | this._animationMode = _animationMode;
|
---|
1313 | /** Display state of the checkbox. */
|
---|
1314 | this.state = 'unchecked';
|
---|
1315 | /** Whether the checkbox is disabled. */
|
---|
1316 | this.disabled = false;
|
---|
1317 | }
|
---|
1318 | }
|
---|
1319 | MatPseudoCheckbox.decorators = [
|
---|
1320 | { type: Component, args: [{
|
---|
1321 | encapsulation: ViewEncapsulation.None,
|
---|
1322 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
1323 | selector: 'mat-pseudo-checkbox',
|
---|
1324 | template: '',
|
---|
1325 | host: {
|
---|
1326 | 'class': 'mat-pseudo-checkbox',
|
---|
1327 | '[class.mat-pseudo-checkbox-indeterminate]': 'state === "indeterminate"',
|
---|
1328 | '[class.mat-pseudo-checkbox-checked]': 'state === "checked"',
|
---|
1329 | '[class.mat-pseudo-checkbox-disabled]': 'disabled',
|
---|
1330 | '[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
|
---|
1331 | },
|
---|
1332 | styles: [".mat-pseudo-checkbox{width:16px;height:16px;border:2px solid;border-radius:2px;cursor:pointer;display:inline-block;vertical-align:middle;box-sizing:border-box;position:relative;flex-shrink:0;transition:border-color 90ms cubic-bezier(0, 0, 0.2, 0.1),background-color 90ms cubic-bezier(0, 0, 0.2, 0.1)}.mat-pseudo-checkbox::after{position:absolute;opacity:0;content:\"\";border-bottom:2px solid currentColor;transition:opacity 90ms cubic-bezier(0, 0, 0.2, 0.1)}.mat-pseudo-checkbox.mat-pseudo-checkbox-checked,.mat-pseudo-checkbox.mat-pseudo-checkbox-indeterminate{border-color:transparent}._mat-animation-noopable.mat-pseudo-checkbox{transition:none;animation:none}._mat-animation-noopable.mat-pseudo-checkbox::after{transition:none}.mat-pseudo-checkbox-disabled{cursor:default}.mat-pseudo-checkbox-indeterminate::after{top:5px;left:1px;width:10px;opacity:1;border-radius:2px}.mat-pseudo-checkbox-checked::after{top:2.4px;left:1px;width:8px;height:3px;border-left:2px solid currentColor;transform:rotate(-45deg);opacity:1;box-sizing:content-box}\n"]
|
---|
1333 | },] }
|
---|
1334 | ];
|
---|
1335 | MatPseudoCheckbox.ctorParameters = () => [
|
---|
1336 | { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
|
---|
1337 | ];
|
---|
1338 | MatPseudoCheckbox.propDecorators = {
|
---|
1339 | state: [{ type: Input }],
|
---|
1340 | disabled: [{ type: Input }]
|
---|
1341 | };
|
---|
1342 |
|
---|
1343 | /**
|
---|
1344 | * @license
|
---|
1345 | * Copyright Google LLC All Rights Reserved.
|
---|
1346 | *
|
---|
1347 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1348 | * found in the LICENSE file at https://angular.io/license
|
---|
1349 | */
|
---|
1350 | class MatPseudoCheckboxModule {
|
---|
1351 | }
|
---|
1352 | MatPseudoCheckboxModule.decorators = [
|
---|
1353 | { type: NgModule, args: [{
|
---|
1354 | imports: [MatCommonModule],
|
---|
1355 | exports: [MatPseudoCheckbox],
|
---|
1356 | declarations: [MatPseudoCheckbox]
|
---|
1357 | },] }
|
---|
1358 | ];
|
---|
1359 |
|
---|
1360 | /**
|
---|
1361 | * @license
|
---|
1362 | * Copyright Google LLC All Rights Reserved.
|
---|
1363 | *
|
---|
1364 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1365 | * found in the LICENSE file at https://angular.io/license
|
---|
1366 | */
|
---|
1367 | /**
|
---|
1368 | * Injection token used to provide the parent component to options.
|
---|
1369 | */
|
---|
1370 | const MAT_OPTION_PARENT_COMPONENT = new InjectionToken('MAT_OPTION_PARENT_COMPONENT');
|
---|
1371 |
|
---|
1372 | /**
|
---|
1373 | * @license
|
---|
1374 | * Copyright Google LLC All Rights Reserved.
|
---|
1375 | *
|
---|
1376 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1377 | * found in the LICENSE file at https://angular.io/license
|
---|
1378 | */
|
---|
1379 | // Notes on the accessibility pattern used for `mat-optgroup`.
|
---|
1380 | // The option group has two different "modes": regular and inert. The regular mode uses the
|
---|
1381 | // recommended a11y pattern which has `role="group"` on the group element with `aria-labelledby`
|
---|
1382 | // pointing to the label. This works for `mat-select`, but it seems to hit a bug for autocomplete
|
---|
1383 | // under VoiceOver where the group doesn't get read out at all. The bug appears to be that if
|
---|
1384 | // there's __any__ a11y-related attribute on the group (e.g. `role` or `aria-labelledby`),
|
---|
1385 | // VoiceOver on Safari won't read it out.
|
---|
1386 | // We've introduced the `inert` mode as a workaround. Under this mode, all a11y attributes are
|
---|
1387 | // removed from the group, and we get the screen reader to read out the group label by mirroring it
|
---|
1388 | // inside an invisible element in the option. This is sub-optimal, because the screen reader will
|
---|
1389 | // repeat the group label on each navigation, whereas the default pattern only reads the group when
|
---|
1390 | // the user enters a new group. The following alternate approaches were considered:
|
---|
1391 | // 1. Reading out the group label using the `LiveAnnouncer` solves the problem, but we can't control
|
---|
1392 | // when the text will be read out so sometimes it comes in too late or never if the user
|
---|
1393 | // navigates quickly.
|
---|
1394 | // 2. `<mat-option aria-describedby="groupLabel"` - This works on Safari, but VoiceOver in Chrome
|
---|
1395 | // won't read out the description at all.
|
---|
1396 | // 3. `<mat-option aria-labelledby="optionLabel groupLabel"` - This works on Chrome, but Safari
|
---|
1397 | // doesn't read out the text at all. Furthermore, on
|
---|
1398 | // Boilerplate for applying mixins to MatOptgroup.
|
---|
1399 | /** @docs-private */
|
---|
1400 | const _MatOptgroupMixinBase = mixinDisabled(class {
|
---|
1401 | });
|
---|
1402 | // Counter for unique group ids.
|
---|
1403 | let _uniqueOptgroupIdCounter = 0;
|
---|
1404 | class _MatOptgroupBase extends _MatOptgroupMixinBase {
|
---|
1405 | constructor(parent) {
|
---|
1406 | var _a;
|
---|
1407 | super();
|
---|
1408 | /** Unique id for the underlying label. */
|
---|
1409 | this._labelId = `mat-optgroup-label-${_uniqueOptgroupIdCounter++}`;
|
---|
1410 | this._inert = (_a = parent === null || parent === void 0 ? void 0 : parent.inertGroups) !== null && _a !== void 0 ? _a : false;
|
---|
1411 | }
|
---|
1412 | }
|
---|
1413 | _MatOptgroupBase.decorators = [
|
---|
1414 | { type: Directive }
|
---|
1415 | ];
|
---|
1416 | _MatOptgroupBase.ctorParameters = () => [
|
---|
1417 | { type: undefined, decorators: [{ type: Inject, args: [MAT_OPTION_PARENT_COMPONENT,] }, { type: Optional }] }
|
---|
1418 | ];
|
---|
1419 | _MatOptgroupBase.propDecorators = {
|
---|
1420 | label: [{ type: Input }]
|
---|
1421 | };
|
---|
1422 | /**
|
---|
1423 | * Injection token that can be used to reference instances of `MatOptgroup`. It serves as
|
---|
1424 | * alternative token to the actual `MatOptgroup` class which could cause unnecessary
|
---|
1425 | * retention of the class and its component metadata.
|
---|
1426 | */
|
---|
1427 | const MAT_OPTGROUP = new InjectionToken('MatOptgroup');
|
---|
1428 | /**
|
---|
1429 | * Component that is used to group instances of `mat-option`.
|
---|
1430 | */
|
---|
1431 | class MatOptgroup extends _MatOptgroupBase {
|
---|
1432 | }
|
---|
1433 | MatOptgroup.decorators = [
|
---|
1434 | { type: Component, args: [{
|
---|
1435 | selector: 'mat-optgroup',
|
---|
1436 | exportAs: 'matOptgroup',
|
---|
1437 | template: "<span class=\"mat-optgroup-label\" aria-hidden=\"true\" [id]=\"_labelId\">{{ label }} <ng-content></ng-content></span>\n<ng-content select=\"mat-option, ng-container\"></ng-content>\n",
|
---|
1438 | encapsulation: ViewEncapsulation.None,
|
---|
1439 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
1440 | inputs: ['disabled'],
|
---|
1441 | host: {
|
---|
1442 | 'class': 'mat-optgroup',
|
---|
1443 | '[attr.role]': '_inert ? null : "group"',
|
---|
1444 | '[attr.aria-disabled]': '_inert ? null : disabled.toString()',
|
---|
1445 | '[attr.aria-labelledby]': '_inert ? null : _labelId',
|
---|
1446 | '[class.mat-optgroup-disabled]': 'disabled',
|
---|
1447 | },
|
---|
1448 | providers: [{ provide: MAT_OPTGROUP, useExisting: MatOptgroup }],
|
---|
1449 | styles: [".mat-optgroup-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;line-height:48px;height:48px;padding:0 16px;text-align:left;text-decoration:none;max-width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.mat-optgroup-label[disabled]{cursor:default}[dir=rtl] .mat-optgroup-label{text-align:right}.mat-optgroup-label .mat-icon{margin-right:16px;vertical-align:middle}.mat-optgroup-label .mat-icon svg{vertical-align:top}[dir=rtl] .mat-optgroup-label .mat-icon{margin-left:16px;margin-right:0}\n"]
|
---|
1450 | },] }
|
---|
1451 | ];
|
---|
1452 |
|
---|
1453 | /**
|
---|
1454 | * @license
|
---|
1455 | * Copyright Google LLC All Rights Reserved.
|
---|
1456 | *
|
---|
1457 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1458 | * found in the LICENSE file at https://angular.io/license
|
---|
1459 | */
|
---|
1460 | /**
|
---|
1461 | * Option IDs need to be unique across components, so this counter exists outside of
|
---|
1462 | * the component definition.
|
---|
1463 | */
|
---|
1464 | let _uniqueIdCounter = 0;
|
---|
1465 | /** Event object emitted by MatOption when selected or deselected. */
|
---|
1466 | class MatOptionSelectionChange {
|
---|
1467 | constructor(
|
---|
1468 | /** Reference to the option that emitted the event. */
|
---|
1469 | source,
|
---|
1470 | /** Whether the change in the option's value was a result of a user action. */
|
---|
1471 | isUserInput = false) {
|
---|
1472 | this.source = source;
|
---|
1473 | this.isUserInput = isUserInput;
|
---|
1474 | }
|
---|
1475 | }
|
---|
1476 | class _MatOptionBase {
|
---|
1477 | constructor(_element, _changeDetectorRef, _parent, group) {
|
---|
1478 | this._element = _element;
|
---|
1479 | this._changeDetectorRef = _changeDetectorRef;
|
---|
1480 | this._parent = _parent;
|
---|
1481 | this.group = group;
|
---|
1482 | this._selected = false;
|
---|
1483 | this._active = false;
|
---|
1484 | this._disabled = false;
|
---|
1485 | this._mostRecentViewValue = '';
|
---|
1486 | /** The unique ID of the option. */
|
---|
1487 | this.id = `mat-option-${_uniqueIdCounter++}`;
|
---|
1488 | /** Event emitted when the option is selected or deselected. */
|
---|
1489 | // tslint:disable-next-line:no-output-on-prefix
|
---|
1490 | this.onSelectionChange = new EventEmitter();
|
---|
1491 | /** Emits when the state of the option changes and any parents have to be notified. */
|
---|
1492 | this._stateChanges = new Subject();
|
---|
1493 | }
|
---|
1494 | /** Whether the wrapping component is in multiple selection mode. */
|
---|
1495 | get multiple() { return this._parent && this._parent.multiple; }
|
---|
1496 | /** Whether or not the option is currently selected. */
|
---|
1497 | get selected() { return this._selected; }
|
---|
1498 | /** Whether the option is disabled. */
|
---|
1499 | get disabled() { return (this.group && this.group.disabled) || this._disabled; }
|
---|
1500 | set disabled(value) { this._disabled = coerceBooleanProperty(value); }
|
---|
1501 | /** Whether ripples for the option are disabled. */
|
---|
1502 | get disableRipple() { return this._parent && this._parent.disableRipple; }
|
---|
1503 | /**
|
---|
1504 | * Whether or not the option is currently active and ready to be selected.
|
---|
1505 | * An active option displays styles as if it is focused, but the
|
---|
1506 | * focus is actually retained somewhere else. This comes in handy
|
---|
1507 | * for components like autocomplete where focus must remain on the input.
|
---|
1508 | */
|
---|
1509 | get active() {
|
---|
1510 | return this._active;
|
---|
1511 | }
|
---|
1512 | /**
|
---|
1513 | * The displayed value of the option. It is necessary to show the selected option in the
|
---|
1514 | * select's trigger.
|
---|
1515 | */
|
---|
1516 | get viewValue() {
|
---|
1517 | // TODO(kara): Add input property alternative for node envs.
|
---|
1518 | return (this._getHostElement().textContent || '').trim();
|
---|
1519 | }
|
---|
1520 | /** Selects the option. */
|
---|
1521 | select() {
|
---|
1522 | if (!this._selected) {
|
---|
1523 | this._selected = true;
|
---|
1524 | this._changeDetectorRef.markForCheck();
|
---|
1525 | this._emitSelectionChangeEvent();
|
---|
1526 | }
|
---|
1527 | }
|
---|
1528 | /** Deselects the option. */
|
---|
1529 | deselect() {
|
---|
1530 | if (this._selected) {
|
---|
1531 | this._selected = false;
|
---|
1532 | this._changeDetectorRef.markForCheck();
|
---|
1533 | this._emitSelectionChangeEvent();
|
---|
1534 | }
|
---|
1535 | }
|
---|
1536 | /** Sets focus onto this option. */
|
---|
1537 | focus(_origin, options) {
|
---|
1538 | // Note that we aren't using `_origin`, but we need to keep it because some internal consumers
|
---|
1539 | // use `MatOption` in a `FocusKeyManager` and we need it to match `FocusableOption`.
|
---|
1540 | const element = this._getHostElement();
|
---|
1541 | if (typeof element.focus === 'function') {
|
---|
1542 | element.focus(options);
|
---|
1543 | }
|
---|
1544 | }
|
---|
1545 | /**
|
---|
1546 | * This method sets display styles on the option to make it appear
|
---|
1547 | * active. This is used by the ActiveDescendantKeyManager so key
|
---|
1548 | * events will display the proper options as active on arrow key events.
|
---|
1549 | */
|
---|
1550 | setActiveStyles() {
|
---|
1551 | if (!this._active) {
|
---|
1552 | this._active = true;
|
---|
1553 | this._changeDetectorRef.markForCheck();
|
---|
1554 | }
|
---|
1555 | }
|
---|
1556 | /**
|
---|
1557 | * This method removes display styles on the option that made it appear
|
---|
1558 | * active. This is used by the ActiveDescendantKeyManager so key
|
---|
1559 | * events will display the proper options as active on arrow key events.
|
---|
1560 | */
|
---|
1561 | setInactiveStyles() {
|
---|
1562 | if (this._active) {
|
---|
1563 | this._active = false;
|
---|
1564 | this._changeDetectorRef.markForCheck();
|
---|
1565 | }
|
---|
1566 | }
|
---|
1567 | /** Gets the label to be used when determining whether the option should be focused. */
|
---|
1568 | getLabel() {
|
---|
1569 | return this.viewValue;
|
---|
1570 | }
|
---|
1571 | /** Ensures the option is selected when activated from the keyboard. */
|
---|
1572 | _handleKeydown(event) {
|
---|
1573 | if ((event.keyCode === ENTER || event.keyCode === SPACE) && !hasModifierKey(event)) {
|
---|
1574 | this._selectViaInteraction();
|
---|
1575 | // Prevent the page from scrolling down and form submits.
|
---|
1576 | event.preventDefault();
|
---|
1577 | }
|
---|
1578 | }
|
---|
1579 | /**
|
---|
1580 | * `Selects the option while indicating the selection came from the user. Used to
|
---|
1581 | * determine if the select's view -> model callback should be invoked.`
|
---|
1582 | */
|
---|
1583 | _selectViaInteraction() {
|
---|
1584 | if (!this.disabled) {
|
---|
1585 | this._selected = this.multiple ? !this._selected : true;
|
---|
1586 | this._changeDetectorRef.markForCheck();
|
---|
1587 | this._emitSelectionChangeEvent(true);
|
---|
1588 | }
|
---|
1589 | }
|
---|
1590 | /**
|
---|
1591 | * Gets the `aria-selected` value for the option. We explicitly omit the `aria-selected`
|
---|
1592 | * attribute from single-selection, unselected options. Including the `aria-selected="false"`
|
---|
1593 | * attributes adds a significant amount of noise to screen-reader users without providing useful
|
---|
1594 | * information.
|
---|
1595 | */
|
---|
1596 | _getAriaSelected() {
|
---|
1597 | return this.selected || (this.multiple ? false : null);
|
---|
1598 | }
|
---|
1599 | /** Returns the correct tabindex for the option depending on disabled state. */
|
---|
1600 | _getTabIndex() {
|
---|
1601 | return this.disabled ? '-1' : '0';
|
---|
1602 | }
|
---|
1603 | /** Gets the host DOM element. */
|
---|
1604 | _getHostElement() {
|
---|
1605 | return this._element.nativeElement;
|
---|
1606 | }
|
---|
1607 | ngAfterViewChecked() {
|
---|
1608 | // Since parent components could be using the option's label to display the selected values
|
---|
1609 | // (e.g. `mat-select`) and they don't have a way of knowing if the option's label has changed
|
---|
1610 | // we have to check for changes in the DOM ourselves and dispatch an event. These checks are
|
---|
1611 | // relatively cheap, however we still limit them only to selected options in order to avoid
|
---|
1612 | // hitting the DOM too often.
|
---|
1613 | if (this._selected) {
|
---|
1614 | const viewValue = this.viewValue;
|
---|
1615 | if (viewValue !== this._mostRecentViewValue) {
|
---|
1616 | this._mostRecentViewValue = viewValue;
|
---|
1617 | this._stateChanges.next();
|
---|
1618 | }
|
---|
1619 | }
|
---|
1620 | }
|
---|
1621 | ngOnDestroy() {
|
---|
1622 | this._stateChanges.complete();
|
---|
1623 | }
|
---|
1624 | /** Emits the selection change event. */
|
---|
1625 | _emitSelectionChangeEvent(isUserInput = false) {
|
---|
1626 | this.onSelectionChange.emit(new MatOptionSelectionChange(this, isUserInput));
|
---|
1627 | }
|
---|
1628 | }
|
---|
1629 | _MatOptionBase.decorators = [
|
---|
1630 | { type: Directive }
|
---|
1631 | ];
|
---|
1632 | _MatOptionBase.ctorParameters = () => [
|
---|
1633 | { type: ElementRef },
|
---|
1634 | { type: ChangeDetectorRef },
|
---|
1635 | { type: undefined },
|
---|
1636 | { type: _MatOptgroupBase }
|
---|
1637 | ];
|
---|
1638 | _MatOptionBase.propDecorators = {
|
---|
1639 | value: [{ type: Input }],
|
---|
1640 | id: [{ type: Input }],
|
---|
1641 | disabled: [{ type: Input }],
|
---|
1642 | onSelectionChange: [{ type: Output }]
|
---|
1643 | };
|
---|
1644 | /**
|
---|
1645 | * Single option inside of a `<mat-select>` element.
|
---|
1646 | */
|
---|
1647 | class MatOption extends _MatOptionBase {
|
---|
1648 | constructor(element, changeDetectorRef, parent, group) {
|
---|
1649 | super(element, changeDetectorRef, parent, group);
|
---|
1650 | }
|
---|
1651 | }
|
---|
1652 | MatOption.decorators = [
|
---|
1653 | { type: Component, args: [{
|
---|
1654 | selector: 'mat-option',
|
---|
1655 | exportAs: 'matOption',
|
---|
1656 | host: {
|
---|
1657 | 'role': 'option',
|
---|
1658 | '[attr.tabindex]': '_getTabIndex()',
|
---|
1659 | '[class.mat-selected]': 'selected',
|
---|
1660 | '[class.mat-option-multiple]': 'multiple',
|
---|
1661 | '[class.mat-active]': 'active',
|
---|
1662 | '[id]': 'id',
|
---|
1663 | '[attr.aria-selected]': '_getAriaSelected()',
|
---|
1664 | '[attr.aria-disabled]': 'disabled.toString()',
|
---|
1665 | '[class.mat-option-disabled]': 'disabled',
|
---|
1666 | '(click)': '_selectViaInteraction()',
|
---|
1667 | '(keydown)': '_handleKeydown($event)',
|
---|
1668 | 'class': 'mat-option mat-focus-indicator',
|
---|
1669 | },
|
---|
1670 | template: "<mat-pseudo-checkbox *ngIf=\"multiple\" class=\"mat-option-pseudo-checkbox\"\n [state]=\"selected ? 'checked' : 'unchecked'\" [disabled]=\"disabled\"></mat-pseudo-checkbox>\n\n<span class=\"mat-option-text\"><ng-content></ng-content></span>\n\n<!-- See a11y notes inside optgroup.ts for context behind this element. -->\n<span class=\"cdk-visually-hidden\" *ngIf=\"group && group._inert\">({{ group.label }})</span>\n\n<div class=\"mat-option-ripple\" mat-ripple\n [matRippleTrigger]=\"_getHostElement()\"\n [matRippleDisabled]=\"disabled || disableRipple\">\n</div>\n",
|
---|
1671 | encapsulation: ViewEncapsulation.None,
|
---|
1672 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
1673 | styles: [".mat-option{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;line-height:48px;height:48px;padding:0 16px;text-align:left;text-decoration:none;max-width:100%;position:relative;cursor:pointer;outline:none;display:flex;flex-direction:row;max-width:100%;box-sizing:border-box;align-items:center;-webkit-tap-highlight-color:transparent}.mat-option[disabled]{cursor:default}[dir=rtl] .mat-option{text-align:right}.mat-option .mat-icon{margin-right:16px;vertical-align:middle}.mat-option .mat-icon svg{vertical-align:top}[dir=rtl] .mat-option .mat-icon{margin-left:16px;margin-right:0}.mat-option[aria-disabled=true]{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.mat-optgroup .mat-option:not(.mat-option-multiple){padding-left:32px}[dir=rtl] .mat-optgroup .mat-option:not(.mat-option-multiple){padding-left:16px;padding-right:32px}.cdk-high-contrast-active .mat-option{margin:0 1px}.cdk-high-contrast-active .mat-option.mat-active{border:solid 1px currentColor;margin:0}.cdk-high-contrast-active .mat-option[aria-disabled=true]{opacity:.5}.mat-option-text{display:inline-block;flex-grow:1;overflow:hidden;text-overflow:ellipsis}.mat-option .mat-option-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none}.mat-option-pseudo-checkbox{margin-right:8px}[dir=rtl] .mat-option-pseudo-checkbox{margin-left:8px;margin-right:0}\n"]
|
---|
1674 | },] }
|
---|
1675 | ];
|
---|
1676 | MatOption.ctorParameters = () => [
|
---|
1677 | { type: ElementRef },
|
---|
1678 | { type: ChangeDetectorRef },
|
---|
1679 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_OPTION_PARENT_COMPONENT,] }] },
|
---|
1680 | { type: MatOptgroup, decorators: [{ type: Optional }, { type: Inject, args: [MAT_OPTGROUP,] }] }
|
---|
1681 | ];
|
---|
1682 | /**
|
---|
1683 | * Counts the amount of option group labels that precede the specified option.
|
---|
1684 | * @param optionIndex Index of the option at which to start counting.
|
---|
1685 | * @param options Flat list of all of the options.
|
---|
1686 | * @param optionGroups Flat list of all of the option groups.
|
---|
1687 | * @docs-private
|
---|
1688 | */
|
---|
1689 | function _countGroupLabelsBeforeOption(optionIndex, options, optionGroups) {
|
---|
1690 | if (optionGroups.length) {
|
---|
1691 | let optionsArray = options.toArray();
|
---|
1692 | let groups = optionGroups.toArray();
|
---|
1693 | let groupCounter = 0;
|
---|
1694 | for (let i = 0; i < optionIndex + 1; i++) {
|
---|
1695 | if (optionsArray[i].group && optionsArray[i].group === groups[groupCounter]) {
|
---|
1696 | groupCounter++;
|
---|
1697 | }
|
---|
1698 | }
|
---|
1699 | return groupCounter;
|
---|
1700 | }
|
---|
1701 | return 0;
|
---|
1702 | }
|
---|
1703 | /**
|
---|
1704 | * Determines the position to which to scroll a panel in order for an option to be into view.
|
---|
1705 | * @param optionOffset Offset of the option from the top of the panel.
|
---|
1706 | * @param optionHeight Height of the options.
|
---|
1707 | * @param currentScrollPosition Current scroll position of the panel.
|
---|
1708 | * @param panelHeight Height of the panel.
|
---|
1709 | * @docs-private
|
---|
1710 | */
|
---|
1711 | function _getOptionScrollPosition(optionOffset, optionHeight, currentScrollPosition, panelHeight) {
|
---|
1712 | if (optionOffset < currentScrollPosition) {
|
---|
1713 | return optionOffset;
|
---|
1714 | }
|
---|
1715 | if (optionOffset + optionHeight > currentScrollPosition + panelHeight) {
|
---|
1716 | return Math.max(0, optionOffset - panelHeight + optionHeight);
|
---|
1717 | }
|
---|
1718 | return currentScrollPosition;
|
---|
1719 | }
|
---|
1720 |
|
---|
1721 | /**
|
---|
1722 | * @license
|
---|
1723 | * Copyright Google LLC All Rights Reserved.
|
---|
1724 | *
|
---|
1725 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1726 | * found in the LICENSE file at https://angular.io/license
|
---|
1727 | */
|
---|
1728 | class MatOptionModule {
|
---|
1729 | }
|
---|
1730 | MatOptionModule.decorators = [
|
---|
1731 | { type: NgModule, args: [{
|
---|
1732 | imports: [MatRippleModule, CommonModule, MatCommonModule, MatPseudoCheckboxModule],
|
---|
1733 | exports: [MatOption, MatOptgroup],
|
---|
1734 | declarations: [MatOption, MatOptgroup]
|
---|
1735 | },] }
|
---|
1736 | ];
|
---|
1737 |
|
---|
1738 | /**
|
---|
1739 | * @license
|
---|
1740 | * Copyright Google LLC All Rights Reserved.
|
---|
1741 | *
|
---|
1742 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1743 | * found in the LICENSE file at https://angular.io/license
|
---|
1744 | */
|
---|
1745 |
|
---|
1746 | /**
|
---|
1747 | * Generated bundle index. Do not edit.
|
---|
1748 | */
|
---|
1749 |
|
---|
1750 | export { AnimationCurves, AnimationDurations, DateAdapter, ErrorStateMatcher, MATERIAL_SANITY_CHECKS, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MAT_DATE_LOCALE_FACTORY, MAT_NATIVE_DATE_FORMATS, MAT_OPTGROUP, MAT_OPTION_PARENT_COMPONENT, MAT_RIPPLE_GLOBAL_OPTIONS, MatCommonModule, MatLine, MatLineModule, MatNativeDateModule, MatOptgroup, MatOption, MatOptionModule, MatOptionSelectionChange, MatPseudoCheckbox, MatPseudoCheckboxModule, MatRipple, MatRippleModule, NativeDateAdapter, NativeDateModule, RippleRef, RippleRenderer, ShowOnDirtyErrorStateMatcher, VERSION$1 as VERSION, _MatOptgroupBase, _MatOptionBase, _countGroupLabelsBeforeOption, _getOptionScrollPosition, defaultRippleAnimationConfig, mixinColor, mixinDisableRipple, mixinDisabled, mixinErrorState, mixinInitialized, mixinTabIndex, setLines, ɵ0, MATERIAL_SANITY_CHECKS_FACTORY as ɵangular_material_src_material_core_core_a };
|
---|
1751 | //# sourceMappingURL=core.js.map
|
---|