@angular/material 13.2.5 → 13.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/checkbox/_checkbox-theme.scss +0 -6
- package/dialog/dialog-config.d.ts +2 -0
- package/dialog/dialog-container.d.ts +1 -4
- package/dialog/dialog.d.ts +12 -6
- package/dialog/testing/dialog-opener.d.ts +33 -0
- package/dialog/testing/public-api.d.ts +1 -0
- package/esm2020/bottom-sheet/bottom-sheet-animations.mjs +10 -4
- package/esm2020/button/button.mjs +3 -3
- package/esm2020/core/version.mjs +1 -1
- package/esm2020/dialog/dialog-animations.mjs +10 -4
- package/esm2020/dialog/dialog-config.mjs +3 -1
- package/esm2020/dialog/dialog-container.mjs +14 -14
- package/esm2020/dialog/dialog.mjs +14 -30
- package/esm2020/dialog/testing/dialog-opener.mjs +67 -0
- package/esm2020/dialog/testing/public-api.mjs +2 -1
- package/esm2020/expansion/expansion-panel.mjs +3 -3
- package/esm2020/select/select.mjs +12 -2
- package/esm2020/slide-toggle/slide-toggle.mjs +3 -2
- package/esm2020/tooltip/testing/tooltip-harness.mjs +12 -7
- package/esm2020/tooltip/tooltip.mjs +90 -38
- package/fesm2015/bottom-sheet.mjs +9 -3
- package/fesm2015/bottom-sheet.mjs.map +1 -1
- package/fesm2015/button.mjs +2 -2
- package/fesm2015/button.mjs.map +1 -1
- package/fesm2015/core.mjs +1 -1
- package/fesm2015/core.mjs.map +1 -1
- package/fesm2015/dialog/testing.mjs +65 -2
- package/fesm2015/dialog/testing.mjs.map +1 -1
- package/fesm2015/dialog.mjs +37 -45
- package/fesm2015/dialog.mjs.map +1 -1
- package/fesm2015/expansion.mjs +2 -2
- package/fesm2015/expansion.mjs.map +1 -1
- package/fesm2015/select.mjs +11 -1
- package/fesm2015/select.mjs.map +1 -1
- package/fesm2015/slide-toggle.mjs +2 -1
- package/fesm2015/slide-toggle.mjs.map +1 -1
- package/fesm2015/tooltip/testing.mjs +11 -8
- package/fesm2015/tooltip/testing.mjs.map +1 -1
- package/fesm2015/tooltip.mjs +112 -62
- package/fesm2015/tooltip.mjs.map +1 -1
- package/fesm2020/bottom-sheet.mjs +9 -3
- package/fesm2020/bottom-sheet.mjs.map +1 -1
- package/fesm2020/button.mjs +2 -2
- package/fesm2020/button.mjs.map +1 -1
- package/fesm2020/core.mjs +1 -1
- package/fesm2020/core.mjs.map +1 -1
- package/fesm2020/dialog/testing.mjs +65 -1
- package/fesm2020/dialog/testing.mjs.map +1 -1
- package/fesm2020/dialog.mjs +37 -45
- package/fesm2020/dialog.mjs.map +1 -1
- package/fesm2020/expansion.mjs +2 -2
- package/fesm2020/expansion.mjs.map +1 -1
- package/fesm2020/select.mjs +11 -1
- package/fesm2020/select.mjs.map +1 -1
- package/fesm2020/slide-toggle.mjs +2 -1
- package/fesm2020/slide-toggle.mjs.map +1 -1
- package/fesm2020/tooltip/testing.mjs +11 -6
- package/fesm2020/tooltip/testing.mjs.map +1 -1
- package/fesm2020/tooltip.mjs +107 -54
- package/fesm2020/tooltip.mjs.map +1 -1
- package/package.json +2 -2
- package/prebuilt-themes/deeppurple-amber.css +1 -1
- package/prebuilt-themes/indigo-pink.css +1 -1
- package/prebuilt-themes/pink-bluegrey.css +1 -1
- package/prebuilt-themes/purple-green.css +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
- package/select/select.d.ts +5 -0
- package/tooltip/testing/tooltip-harness.d.ts +6 -0
- package/tooltip/tooltip.d.ts +23 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slide-toggle.mjs","sources":["../../../../../../src/material/slide-toggle/slide-toggle-config.ts","../../../../../../src/material/slide-toggle/slide-toggle.ts","../../../../../../src/material/slide-toggle/slide-toggle.html","../../../../../../src/material/slide-toggle/slide-toggle-required-validator.ts","../../../../../../src/material/slide-toggle/slide-toggle-module.ts","../../../../../../src/material/slide-toggle/public-api.ts","../../../../../../src/material/slide-toggle/index.ts","../../../../../../src/material/slide-toggle/slide-toggle_public_index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {InjectionToken} from '@angular/core';\nimport {ThemePalette} from '@angular/material/core';\n\n/** Default `mat-slide-toggle` options that can be overridden. */\nexport interface MatSlideToggleDefaultOptions {\n /** Whether toggle action triggers value changes in slide toggle. */\n disableToggleValue?: boolean;\n\n /** Default color for slide toggles. */\n color?: ThemePalette;\n}\n\n/** Injection token to be used to override the default options for `mat-slide-toggle`. */\nexport const MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS = new InjectionToken<MatSlideToggleDefaultOptions>(\n 'mat-slide-toggle-default-options',\n {\n providedIn: 'root',\n factory: () => ({disableToggleValue: false}),\n },\n);\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {FocusMonitor, FocusOrigin} from '@angular/cdk/a11y';\nimport {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';\nimport {\n AfterContentInit,\n Attribute,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n ElementRef,\n EventEmitter,\n forwardRef,\n Input,\n OnDestroy,\n Output,\n ViewChild,\n ViewEncapsulation,\n Optional,\n Inject,\n} from '@angular/core';\nimport {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';\nimport {\n CanColor,\n CanDisable,\n CanDisableRipple,\n HasTabIndex,\n mixinColor,\n mixinDisabled,\n mixinDisableRipple,\n mixinTabIndex,\n} from '@angular/material/core';\nimport {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';\nimport {\n MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS,\n MatSlideToggleDefaultOptions,\n} from './slide-toggle-config';\n\n// Increasing integer for generating unique ids for slide-toggle components.\nlet nextUniqueId = 0;\n\n/** @docs-private */\nexport const MAT_SLIDE_TOGGLE_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => MatSlideToggle),\n multi: true,\n};\n\n/** Change event object emitted by a MatSlideToggle. */\nexport class MatSlideToggleChange {\n constructor(\n /** The source MatSlideToggle of the event. */\n public source: MatSlideToggle,\n /** The new `checked` value of the MatSlideToggle. */\n public checked: boolean,\n ) {}\n}\n\n// Boilerplate for applying mixins to MatSlideToggle.\n/** @docs-private */\nconst _MatSlideToggleBase = mixinTabIndex(\n mixinColor(\n mixinDisableRipple(\n mixinDisabled(\n class {\n constructor(public _elementRef: ElementRef) {}\n },\n ),\n ),\n ),\n);\n\n/** Represents a slidable \"switch\" toggle that can be moved between on and off. */\n@Component({\n selector: 'mat-slide-toggle',\n exportAs: 'matSlideToggle',\n host: {\n 'class': 'mat-slide-toggle',\n '[id]': 'id',\n // Needs to be removed since it causes some a11y issues (see #21266).\n '[attr.tabindex]': 'null',\n '[attr.aria-label]': 'null',\n '[attr.aria-labelledby]': 'null',\n '[class.mat-checked]': 'checked',\n '[class.mat-disabled]': 'disabled',\n '[class.mat-slide-toggle-label-before]': 'labelPosition == \"before\"',\n '[class._mat-animation-noopable]': '_noopAnimations',\n },\n templateUrl: 'slide-toggle.html',\n styleUrls: ['slide-toggle.css'],\n providers: [MAT_SLIDE_TOGGLE_VALUE_ACCESSOR],\n inputs: ['disabled', 'disableRipple', 'color', 'tabIndex'],\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class MatSlideToggle\n extends _MatSlideToggleBase\n implements\n OnDestroy,\n AfterContentInit,\n ControlValueAccessor,\n CanDisable,\n CanColor,\n HasTabIndex,\n CanDisableRipple\n{\n private _onChange = (_: any) => {};\n private _onTouched = () => {};\n\n private _uniqueId: string = `mat-slide-toggle-${++nextUniqueId}`;\n private _required: boolean = false;\n private _checked: boolean = false;\n\n /** Whether noop animations are enabled. */\n _noopAnimations: boolean;\n\n /** Reference to the thumb HTMLElement. */\n @ViewChild('thumbContainer') _thumbEl: ElementRef;\n\n /** Reference to the thumb bar HTMLElement. */\n @ViewChild('toggleBar') _thumbBarEl: ElementRef;\n\n /** Name value will be applied to the input element if present. */\n @Input() name: string | null = null;\n\n /** A unique id for the slide-toggle input. If none is supplied, it will be auto-generated. */\n @Input() id: string = this._uniqueId;\n\n /** Whether the label should appear after or before the slide-toggle. Defaults to 'after'. */\n @Input() labelPosition: 'before' | 'after' = 'after';\n\n /** Used to set the aria-label attribute on the underlying input element. */\n @Input('aria-label') ariaLabel: string | null = null;\n\n /** Used to set the aria-labelledby attribute on the underlying input element. */\n @Input('aria-labelledby') ariaLabelledby: string | null = null;\n\n /** Used to set the aria-describedby attribute on the underlying input element. */\n @Input('aria-describedby') ariaDescribedby: string;\n\n /** Whether the slide-toggle is required. */\n @Input()\n get required(): boolean {\n return this._required;\n }\n set required(value: BooleanInput) {\n this._required = coerceBooleanProperty(value);\n }\n\n /** Whether the slide-toggle element is checked or not. */\n @Input()\n get checked(): boolean {\n return this._checked;\n }\n set checked(value: BooleanInput) {\n this._checked = coerceBooleanProperty(value);\n this._changeDetectorRef.markForCheck();\n }\n /** An event will be dispatched each time the slide-toggle changes its value. */\n @Output() readonly change: EventEmitter<MatSlideToggleChange> =\n new EventEmitter<MatSlideToggleChange>();\n\n /**\n * An event will be dispatched each time the slide-toggle input is toggled.\n * This event is always emitted when the user toggles the slide toggle, but this does not mean\n * the slide toggle's value has changed.\n */\n @Output() readonly toggleChange: EventEmitter<void> = new EventEmitter<void>();\n\n /** Returns the unique id for the visual hidden input. */\n get inputId(): string {\n return `${this.id || this._uniqueId}-input`;\n }\n\n /** Reference to the underlying input element. */\n @ViewChild('input') _inputElement: ElementRef<HTMLInputElement>;\n\n constructor(\n elementRef: ElementRef,\n private _focusMonitor: FocusMonitor,\n private _changeDetectorRef: ChangeDetectorRef,\n @Attribute('tabindex') tabIndex: string,\n @Inject(MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS)\n public defaults: MatSlideToggleDefaultOptions,\n @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string,\n ) {\n super(elementRef);\n this.tabIndex = parseInt(tabIndex) || 0;\n this.color = this.defaultColor = defaults.color || 'accent';\n this._noopAnimations = animationMode === 'NoopAnimations';\n }\n\n ngAfterContentInit() {\n this._focusMonitor.monitor(this._elementRef, true).subscribe(focusOrigin => {\n if (!focusOrigin) {\n // When a focused element becomes disabled, the browser *immediately* fires a blur event.\n // Angular does not expect events to be raised during change detection, so any state\n // change (such as a form control's 'ng-touched') will cause a changed-after-checked\n // error. See https://github.com/angular/angular/issues/17793. To work around this,\n // we defer telling the form control it has been touched until the next tick.\n Promise.resolve().then(() => this._onTouched());\n }\n });\n }\n\n ngOnDestroy() {\n this._focusMonitor.stopMonitoring(this._elementRef);\n }\n\n /** Method being called whenever the underlying input emits a change event. */\n _onChangeEvent(event: Event) {\n // We always have to stop propagation on the change event.\n // Otherwise the change event, from the input element, will bubble up and\n // emit its event object to the component's `change` output.\n event.stopPropagation();\n this.toggleChange.emit();\n\n // When the slide toggle's config disables toggle change event by setting\n // `disableToggleValue: true`, the slide toggle's value does not change, and the\n // checked state of the underlying input needs to be changed back.\n if (this.defaults.disableToggleValue) {\n this._inputElement.nativeElement.checked = this.checked;\n return;\n }\n\n // Sync the value from the underlying input element with the component instance.\n this.checked = this._inputElement.nativeElement.checked;\n\n // Emit our custom change event only if the underlying input emitted one. This ensures that\n // there is no change event, when the checked state changes programmatically.\n this._emitChangeEvent();\n }\n\n /** Method being called whenever the slide-toggle has been clicked. */\n _onInputClick(event: Event) {\n // We have to stop propagation for click events on the visual hidden input element.\n // By default, when a user clicks on a label element, a generated click event will be\n // dispatched on the associated input element. Since we are using a label element as our\n // root container, the click event on the `slide-toggle` will be executed twice.\n // The real click event will bubble up, and the generated click event also tries to bubble up.\n // This will lead to multiple click events.\n // Preventing bubbling for the second event will solve that issue.\n event.stopPropagation();\n }\n\n /** Implemented as part of ControlValueAccessor. */\n writeValue(value: any): void {\n this.checked = !!value;\n }\n\n /** Implemented as part of ControlValueAccessor. */\n registerOnChange(fn: any): void {\n this._onChange = fn;\n }\n\n /** Implemented as part of ControlValueAccessor. */\n registerOnTouched(fn: any): void {\n this._onTouched = fn;\n }\n\n /** Implemented as a part of ControlValueAccessor. */\n setDisabledState(isDisabled: boolean): void {\n this.disabled = isDisabled;\n this._changeDetectorRef.markForCheck();\n }\n\n /** Focuses the slide-toggle. */\n focus(options?: FocusOptions, origin?: FocusOrigin): void {\n if (origin) {\n this._focusMonitor.focusVia(this._inputElement, origin, options);\n } else {\n this._inputElement.nativeElement.focus(options);\n }\n }\n\n /** Toggles the checked state of the slide-toggle. */\n toggle(): void {\n this.checked = !this.checked;\n this._onChange(this.checked);\n }\n\n /**\n * Emits a change event on the `change` output. Also notifies the FormControl about the change.\n */\n private _emitChangeEvent() {\n this._onChange(this.checked);\n this.change.emit(new MatSlideToggleChange(this, this.checked));\n }\n\n /** Method being called whenever the label text changes. */\n _onLabelTextChange() {\n // Since the event of the `cdkObserveContent` directive runs outside of the zone, the\n // slide-toggle component will be only marked for check, but no actual change detection runs\n // automatically. Instead of going back into the zone in order to trigger a change detection\n // which causes *all* components to be checked (if explicitly marked or not using OnPush),\n // we only trigger an explicit change detection for the slide-toggle view and its children.\n this._changeDetectorRef.detectChanges();\n }\n}\n","<label [attr.for]=\"inputId\" class=\"mat-slide-toggle-label\" #label>\n <span #toggleBar class=\"mat-slide-toggle-bar\"\n [class.mat-slide-toggle-bar-no-side-margin]=\"!labelContent.textContent || !labelContent.textContent.trim()\">\n\n <input #input class=\"mat-slide-toggle-input cdk-visually-hidden\" type=\"checkbox\"\n role=\"switch\"\n [id]=\"inputId\"\n [required]=\"required\"\n [tabIndex]=\"tabIndex\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n [attr.name]=\"name\"\n [attr.aria-checked]=\"checked\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-describedby]=\"ariaDescribedby\"\n (change)=\"_onChangeEvent($event)\"\n (click)=\"_onInputClick($event)\">\n\n <span class=\"mat-slide-toggle-thumb-container\" #thumbContainer>\n <span class=\"mat-slide-toggle-thumb\"></span>\n <span class=\"mat-slide-toggle-ripple mat-focus-indicator\" mat-ripple\n [matRippleTrigger]=\"label\"\n [matRippleDisabled]=\"disableRipple || disabled\"\n [matRippleCentered]=\"true\"\n [matRippleRadius]=\"20\"\n [matRippleAnimation]=\"{enterDuration: _noopAnimations ? 0 : 150}\">\n\n <span class=\"mat-ripple-element mat-slide-toggle-persistent-ripple\"></span>\n </span>\n </span>\n\n </span>\n\n <span class=\"mat-slide-toggle-content\" #labelContent (cdkObserveContent)=\"_onLabelTextChange()\">\n <!-- Add an invisible span so JAWS can read the label -->\n <span style=\"display:none\"> </span>\n <ng-content></ng-content>\n </span>\n</label>\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Directive, forwardRef, Provider} from '@angular/core';\nimport {CheckboxRequiredValidator, NG_VALIDATORS} from '@angular/forms';\n\nexport const MAT_SLIDE_TOGGLE_REQUIRED_VALIDATOR: Provider = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => MatSlideToggleRequiredValidator),\n multi: true,\n};\n\n/**\n * Validator for Material slide-toggle components with the required attribute in a\n * template-driven form. The default validator for required form controls asserts\n * that the control value is not undefined but that is not appropriate for a slide-toggle\n * where the value is always defined.\n *\n * Required slide-toggle form controls are valid when checked.\n */\n@Directive({\n selector: `mat-slide-toggle[required][formControlName],\n mat-slide-toggle[required][formControl], mat-slide-toggle[required][ngModel]`,\n providers: [MAT_SLIDE_TOGGLE_REQUIRED_VALIDATOR],\n})\nexport class MatSlideToggleRequiredValidator extends CheckboxRequiredValidator {}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {ObserversModule} from '@angular/cdk/observers';\nimport {NgModule} from '@angular/core';\nimport {MatCommonModule, MatRippleModule} from '@angular/material/core';\nimport {MatSlideToggle} from './slide-toggle';\nimport {MatSlideToggleRequiredValidator} from './slide-toggle-required-validator';\n\n/** This module is used by both original and MDC-based slide-toggle implementations. */\n@NgModule({\n exports: [MatSlideToggleRequiredValidator],\n declarations: [MatSlideToggleRequiredValidator],\n})\nexport class _MatSlideToggleRequiredValidatorModule {}\n\n@NgModule({\n imports: [\n _MatSlideToggleRequiredValidatorModule,\n MatRippleModule,\n MatCommonModule,\n ObserversModule,\n ],\n exports: [_MatSlideToggleRequiredValidatorModule, MatSlideToggle, MatCommonModule],\n declarations: [MatSlideToggle],\n})\nexport class MatSlideToggleModule {}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './slide-toggle-module';\nexport * from './slide-toggle';\nexport * from './slide-toggle-config';\nexport * from './slide-toggle-required-validator';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './public-api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;AAmBA;MACa,gCAAgC,GAAG,IAAI,cAAc,CAChE,kCAAkC,EAClC;IACE,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,OAAO,EAAC,kBAAkB,EAAE,KAAK,EAAC,CAAC;CAC7C;;ACzBH;;;;;;;AA4CA;AACA,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;MACa,+BAA+B,GAAQ;IAClD,OAAO,EAAE,iBAAiB;IAC1B,WAAW,EAAE,UAAU,CAAC,MAAM,cAAc,CAAC;IAC7C,KAAK,EAAE,IAAI;EAC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aa,+BAAgC,SAAQ,yBAAyB;;4HAAjE,+BAA+B;gHAA/B,+BAA+B,kKAF/B,CAAC,mCAAmC,CAAC;2FAErC,+BAA+B;kBAL3C,SAAS;mBAAC;oBACT,QAAQ,EAAE;0FAC8E;oBACxF,SAAS,EAAE,CAAC,mCAAmC,CAAC;iBACjD;;;AC7BD;;;;;;;AAcA;MAKa,sCAAsC;;mIAAtC,sCAAsC;oIAAtC,sCAAsC,iBAFlC,+BAA+B,aADpC,+BAA+B;oIAG9B,sCAAsC;2FAAtC,sCAAsC;kBAJlD,QAAQ;mBAAC;oBACR,OAAO,EAAE,CAAC,+BAA+B,CAAC;oBAC1C,YAAY,EAAE,CAAC,+BAA+B,CAAC;iBAChD;;MAaY,oBAAoB;;iHAApB,oBAAoB;kHAApB,oBAAoB,iBAFhB,cAAc,aAVlB,sCAAsC,EAK/C,eAAe;QACf,eAAe;QACf,eAAe,aAPN,sCAAsC,EASC,cAAc,EAAE,eAAe;kHAGtE,oBAAoB,YATtB;YACP,sCAAsC;YACtC,eAAe;YACf,eAAe;YACf,eAAe;SAChB,EARU,sCAAsC,EASiB,eAAe;2FAGtE,oBAAoB;kBAVhC,QAAQ;mBAAC;oBACR,OAAO,EAAE;wBACP,sCAAsC;wBACtC,eAAe;wBACf,eAAe;wBACf,eAAe;qBAChB;oBACD,OAAO,EAAE,CAAC,sCAAsC,EAAE,cAAc,EAAE,eAAe,CAAC;oBAClF,YAAY,EAAE,CAAC,cAAc,CAAC;iBAC/B;;;AC9BD;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"slide-toggle.mjs","sources":["../../../../../../src/material/slide-toggle/slide-toggle-config.ts","../../../../../../src/material/slide-toggle/slide-toggle.ts","../../../../../../src/material/slide-toggle/slide-toggle.html","../../../../../../src/material/slide-toggle/slide-toggle-required-validator.ts","../../../../../../src/material/slide-toggle/slide-toggle-module.ts","../../../../../../src/material/slide-toggle/public-api.ts","../../../../../../src/material/slide-toggle/index.ts","../../../../../../src/material/slide-toggle/slide-toggle_public_index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {InjectionToken} from '@angular/core';\nimport {ThemePalette} from '@angular/material/core';\n\n/** Default `mat-slide-toggle` options that can be overridden. */\nexport interface MatSlideToggleDefaultOptions {\n /** Whether toggle action triggers value changes in slide toggle. */\n disableToggleValue?: boolean;\n\n /** Default color for slide toggles. */\n color?: ThemePalette;\n}\n\n/** Injection token to be used to override the default options for `mat-slide-toggle`. */\nexport const MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS = new InjectionToken<MatSlideToggleDefaultOptions>(\n 'mat-slide-toggle-default-options',\n {\n providedIn: 'root',\n factory: () => ({disableToggleValue: false}),\n },\n);\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {FocusMonitor, FocusOrigin} from '@angular/cdk/a11y';\nimport {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';\nimport {\n AfterContentInit,\n Attribute,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n ElementRef,\n EventEmitter,\n forwardRef,\n Input,\n OnDestroy,\n Output,\n ViewChild,\n ViewEncapsulation,\n Optional,\n Inject,\n} from '@angular/core';\nimport {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';\nimport {\n CanColor,\n CanDisable,\n CanDisableRipple,\n HasTabIndex,\n mixinColor,\n mixinDisabled,\n mixinDisableRipple,\n mixinTabIndex,\n} from '@angular/material/core';\nimport {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';\nimport {\n MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS,\n MatSlideToggleDefaultOptions,\n} from './slide-toggle-config';\n\n// Increasing integer for generating unique ids for slide-toggle components.\nlet nextUniqueId = 0;\n\n/** @docs-private */\nexport const MAT_SLIDE_TOGGLE_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => MatSlideToggle),\n multi: true,\n};\n\n/** Change event object emitted by a MatSlideToggle. */\nexport class MatSlideToggleChange {\n constructor(\n /** The source MatSlideToggle of the event. */\n public source: MatSlideToggle,\n /** The new `checked` value of the MatSlideToggle. */\n public checked: boolean,\n ) {}\n}\n\n// Boilerplate for applying mixins to MatSlideToggle.\n/** @docs-private */\nconst _MatSlideToggleBase = mixinTabIndex(\n mixinColor(\n mixinDisableRipple(\n mixinDisabled(\n class {\n constructor(public _elementRef: ElementRef) {}\n },\n ),\n ),\n ),\n);\n\n/** Represents a slidable \"switch\" toggle that can be moved between on and off. */\n@Component({\n selector: 'mat-slide-toggle',\n exportAs: 'matSlideToggle',\n host: {\n 'class': 'mat-slide-toggle',\n '[id]': 'id',\n // Needs to be removed since it causes some a11y issues (see #21266).\n '[attr.tabindex]': 'null',\n '[attr.aria-label]': 'null',\n '[attr.aria-labelledby]': 'null',\n '[attr.name]': 'null',\n '[class.mat-checked]': 'checked',\n '[class.mat-disabled]': 'disabled',\n '[class.mat-slide-toggle-label-before]': 'labelPosition == \"before\"',\n '[class._mat-animation-noopable]': '_noopAnimations',\n },\n templateUrl: 'slide-toggle.html',\n styleUrls: ['slide-toggle.css'],\n providers: [MAT_SLIDE_TOGGLE_VALUE_ACCESSOR],\n inputs: ['disabled', 'disableRipple', 'color', 'tabIndex'],\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class MatSlideToggle\n extends _MatSlideToggleBase\n implements\n OnDestroy,\n AfterContentInit,\n ControlValueAccessor,\n CanDisable,\n CanColor,\n HasTabIndex,\n CanDisableRipple\n{\n private _onChange = (_: any) => {};\n private _onTouched = () => {};\n\n private _uniqueId: string = `mat-slide-toggle-${++nextUniqueId}`;\n private _required: boolean = false;\n private _checked: boolean = false;\n\n /** Whether noop animations are enabled. */\n _noopAnimations: boolean;\n\n /** Reference to the thumb HTMLElement. */\n @ViewChild('thumbContainer') _thumbEl: ElementRef;\n\n /** Reference to the thumb bar HTMLElement. */\n @ViewChild('toggleBar') _thumbBarEl: ElementRef;\n\n /** Name value will be applied to the input element if present. */\n @Input() name: string | null = null;\n\n /** A unique id for the slide-toggle input. If none is supplied, it will be auto-generated. */\n @Input() id: string = this._uniqueId;\n\n /** Whether the label should appear after or before the slide-toggle. Defaults to 'after'. */\n @Input() labelPosition: 'before' | 'after' = 'after';\n\n /** Used to set the aria-label attribute on the underlying input element. */\n @Input('aria-label') ariaLabel: string | null = null;\n\n /** Used to set the aria-labelledby attribute on the underlying input element. */\n @Input('aria-labelledby') ariaLabelledby: string | null = null;\n\n /** Used to set the aria-describedby attribute on the underlying input element. */\n @Input('aria-describedby') ariaDescribedby: string;\n\n /** Whether the slide-toggle is required. */\n @Input()\n get required(): boolean {\n return this._required;\n }\n set required(value: BooleanInput) {\n this._required = coerceBooleanProperty(value);\n }\n\n /** Whether the slide-toggle element is checked or not. */\n @Input()\n get checked(): boolean {\n return this._checked;\n }\n set checked(value: BooleanInput) {\n this._checked = coerceBooleanProperty(value);\n this._changeDetectorRef.markForCheck();\n }\n /** An event will be dispatched each time the slide-toggle changes its value. */\n @Output() readonly change: EventEmitter<MatSlideToggleChange> =\n new EventEmitter<MatSlideToggleChange>();\n\n /**\n * An event will be dispatched each time the slide-toggle input is toggled.\n * This event is always emitted when the user toggles the slide toggle, but this does not mean\n * the slide toggle's value has changed.\n */\n @Output() readonly toggleChange: EventEmitter<void> = new EventEmitter<void>();\n\n /** Returns the unique id for the visual hidden input. */\n get inputId(): string {\n return `${this.id || this._uniqueId}-input`;\n }\n\n /** Reference to the underlying input element. */\n @ViewChild('input') _inputElement: ElementRef<HTMLInputElement>;\n\n constructor(\n elementRef: ElementRef,\n private _focusMonitor: FocusMonitor,\n private _changeDetectorRef: ChangeDetectorRef,\n @Attribute('tabindex') tabIndex: string,\n @Inject(MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS)\n public defaults: MatSlideToggleDefaultOptions,\n @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string,\n ) {\n super(elementRef);\n this.tabIndex = parseInt(tabIndex) || 0;\n this.color = this.defaultColor = defaults.color || 'accent';\n this._noopAnimations = animationMode === 'NoopAnimations';\n }\n\n ngAfterContentInit() {\n this._focusMonitor.monitor(this._elementRef, true).subscribe(focusOrigin => {\n if (!focusOrigin) {\n // When a focused element becomes disabled, the browser *immediately* fires a blur event.\n // Angular does not expect events to be raised during change detection, so any state\n // change (such as a form control's 'ng-touched') will cause a changed-after-checked\n // error. See https://github.com/angular/angular/issues/17793. To work around this,\n // we defer telling the form control it has been touched until the next tick.\n Promise.resolve().then(() => this._onTouched());\n }\n });\n }\n\n ngOnDestroy() {\n this._focusMonitor.stopMonitoring(this._elementRef);\n }\n\n /** Method being called whenever the underlying input emits a change event. */\n _onChangeEvent(event: Event) {\n // We always have to stop propagation on the change event.\n // Otherwise the change event, from the input element, will bubble up and\n // emit its event object to the component's `change` output.\n event.stopPropagation();\n this.toggleChange.emit();\n\n // When the slide toggle's config disables toggle change event by setting\n // `disableToggleValue: true`, the slide toggle's value does not change, and the\n // checked state of the underlying input needs to be changed back.\n if (this.defaults.disableToggleValue) {\n this._inputElement.nativeElement.checked = this.checked;\n return;\n }\n\n // Sync the value from the underlying input element with the component instance.\n this.checked = this._inputElement.nativeElement.checked;\n\n // Emit our custom change event only if the underlying input emitted one. This ensures that\n // there is no change event, when the checked state changes programmatically.\n this._emitChangeEvent();\n }\n\n /** Method being called whenever the slide-toggle has been clicked. */\n _onInputClick(event: Event) {\n // We have to stop propagation for click events on the visual hidden input element.\n // By default, when a user clicks on a label element, a generated click event will be\n // dispatched on the associated input element. Since we are using a label element as our\n // root container, the click event on the `slide-toggle` will be executed twice.\n // The real click event will bubble up, and the generated click event also tries to bubble up.\n // This will lead to multiple click events.\n // Preventing bubbling for the second event will solve that issue.\n event.stopPropagation();\n }\n\n /** Implemented as part of ControlValueAccessor. */\n writeValue(value: any): void {\n this.checked = !!value;\n }\n\n /** Implemented as part of ControlValueAccessor. */\n registerOnChange(fn: any): void {\n this._onChange = fn;\n }\n\n /** Implemented as part of ControlValueAccessor. */\n registerOnTouched(fn: any): void {\n this._onTouched = fn;\n }\n\n /** Implemented as a part of ControlValueAccessor. */\n setDisabledState(isDisabled: boolean): void {\n this.disabled = isDisabled;\n this._changeDetectorRef.markForCheck();\n }\n\n /** Focuses the slide-toggle. */\n focus(options?: FocusOptions, origin?: FocusOrigin): void {\n if (origin) {\n this._focusMonitor.focusVia(this._inputElement, origin, options);\n } else {\n this._inputElement.nativeElement.focus(options);\n }\n }\n\n /** Toggles the checked state of the slide-toggle. */\n toggle(): void {\n this.checked = !this.checked;\n this._onChange(this.checked);\n }\n\n /**\n * Emits a change event on the `change` output. Also notifies the FormControl about the change.\n */\n private _emitChangeEvent() {\n this._onChange(this.checked);\n this.change.emit(new MatSlideToggleChange(this, this.checked));\n }\n\n /** Method being called whenever the label text changes. */\n _onLabelTextChange() {\n // Since the event of the `cdkObserveContent` directive runs outside of the zone, the\n // slide-toggle component will be only marked for check, but no actual change detection runs\n // automatically. Instead of going back into the zone in order to trigger a change detection\n // which causes *all* components to be checked (if explicitly marked or not using OnPush),\n // we only trigger an explicit change detection for the slide-toggle view and its children.\n this._changeDetectorRef.detectChanges();\n }\n}\n","<label [attr.for]=\"inputId\" class=\"mat-slide-toggle-label\" #label>\n <span #toggleBar class=\"mat-slide-toggle-bar\"\n [class.mat-slide-toggle-bar-no-side-margin]=\"!labelContent.textContent || !labelContent.textContent.trim()\">\n\n <input #input class=\"mat-slide-toggle-input cdk-visually-hidden\" type=\"checkbox\"\n role=\"switch\"\n [id]=\"inputId\"\n [required]=\"required\"\n [tabIndex]=\"tabIndex\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n [attr.name]=\"name\"\n [attr.aria-checked]=\"checked\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-describedby]=\"ariaDescribedby\"\n (change)=\"_onChangeEvent($event)\"\n (click)=\"_onInputClick($event)\">\n\n <span class=\"mat-slide-toggle-thumb-container\" #thumbContainer>\n <span class=\"mat-slide-toggle-thumb\"></span>\n <span class=\"mat-slide-toggle-ripple mat-focus-indicator\" mat-ripple\n [matRippleTrigger]=\"label\"\n [matRippleDisabled]=\"disableRipple || disabled\"\n [matRippleCentered]=\"true\"\n [matRippleRadius]=\"20\"\n [matRippleAnimation]=\"{enterDuration: _noopAnimations ? 0 : 150}\">\n\n <span class=\"mat-ripple-element mat-slide-toggle-persistent-ripple\"></span>\n </span>\n </span>\n\n </span>\n\n <span class=\"mat-slide-toggle-content\" #labelContent (cdkObserveContent)=\"_onLabelTextChange()\">\n <!-- Add an invisible span so JAWS can read the label -->\n <span style=\"display:none\"> </span>\n <ng-content></ng-content>\n </span>\n</label>\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Directive, forwardRef, Provider} from '@angular/core';\nimport {CheckboxRequiredValidator, NG_VALIDATORS} from '@angular/forms';\n\nexport const MAT_SLIDE_TOGGLE_REQUIRED_VALIDATOR: Provider = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => MatSlideToggleRequiredValidator),\n multi: true,\n};\n\n/**\n * Validator for Material slide-toggle components with the required attribute in a\n * template-driven form. The default validator for required form controls asserts\n * that the control value is not undefined but that is not appropriate for a slide-toggle\n * where the value is always defined.\n *\n * Required slide-toggle form controls are valid when checked.\n */\n@Directive({\n selector: `mat-slide-toggle[required][formControlName],\n mat-slide-toggle[required][formControl], mat-slide-toggle[required][ngModel]`,\n providers: [MAT_SLIDE_TOGGLE_REQUIRED_VALIDATOR],\n})\nexport class MatSlideToggleRequiredValidator extends CheckboxRequiredValidator {}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {ObserversModule} from '@angular/cdk/observers';\nimport {NgModule} from '@angular/core';\nimport {MatCommonModule, MatRippleModule} from '@angular/material/core';\nimport {MatSlideToggle} from './slide-toggle';\nimport {MatSlideToggleRequiredValidator} from './slide-toggle-required-validator';\n\n/** This module is used by both original and MDC-based slide-toggle implementations. */\n@NgModule({\n exports: [MatSlideToggleRequiredValidator],\n declarations: [MatSlideToggleRequiredValidator],\n})\nexport class _MatSlideToggleRequiredValidatorModule {}\n\n@NgModule({\n imports: [\n _MatSlideToggleRequiredValidatorModule,\n MatRippleModule,\n MatCommonModule,\n ObserversModule,\n ],\n exports: [_MatSlideToggleRequiredValidatorModule, MatSlideToggle, MatCommonModule],\n declarations: [MatSlideToggle],\n})\nexport class MatSlideToggleModule {}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './slide-toggle-module';\nexport * from './slide-toggle';\nexport * from './slide-toggle-config';\nexport * from './slide-toggle-required-validator';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './public-api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;AAmBA;MACa,gCAAgC,GAAG,IAAI,cAAc,CAChE,kCAAkC,EAClC;IACE,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,OAAO,EAAC,kBAAkB,EAAE,KAAK,EAAC,CAAC;CAC7C;;ACzBH;;;;;;;AA4CA;AACA,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;MACa,+BAA+B,GAAQ;IAClD,OAAO,EAAE,iBAAiB;IAC1B,WAAW,EAAE,UAAU,CAAC,MAAM,cAAc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,+BAA+B,CAAC;IAC9D,KAAK,EAAE,IAAI;EACX;AAEF;;;;;;;;MAaa,+BAAgC,SAAQ,yBAAyB;;4HAAjE,+BAA+B;gHAA/B,+BAA+B,kKAF/B,CAAC,mCAAmC,CAAC;2FAErC,+BAA+B;kBAL3C,SAAS;mBAAC;oBACT,QAAQ,EAAE;0FAC8E;oBACxF,SAAS,EAAE,CAAC,mCAAmC,CAAC;iBACjD;;;AC7BD;;;;;;;AAcA;MAKa,sCAAsC;;mIAAtC,sCAAsC;oIAAtC,sCAAsC,iBAFlC,+BAA+B,aADpC,+BAA+B;oIAG9B,sCAAsC;2FAAtC,sCAAsC;kBAJlD,QAAQ;mBAAC;oBACR,OAAO,EAAE,CAAC,+BAA+B,CAAC;oBAC1C,YAAY,EAAE,CAAC,+BAA+B,CAAC;iBAChD;;MAaY,oBAAoB;;iHAApB,oBAAoB;kHAApB,oBAAoB,iBAFhB,cAAc,aAVlB,sCAAsC,EAK/C,eAAe;QACf,eAAe;QACf,eAAe,aAPN,sCAAsC,EASC,cAAc,EAAE,eAAe;kHAGtE,oBAAoB,YATtB;YACP,sCAAsC;YACtC,eAAe;YACf,eAAe;YACf,eAAe;SAChB,EARU,sCAAsC,EASiB,eAAe;2FAGtE,oBAAoB;kBAVhC,QAAQ;mBAAC;oBACR,OAAO,EAAE;wBACP,sCAAsC;wBACtC,eAAe;wBACf,eAAe;wBACf,eAAe;qBAChB;oBACD,OAAO,EAAE,CAAC,sCAAsC,EAAE,cAAc,EAAE,eAAe,CAAC;oBAClF,YAAY,EAAE,CAAC,cAAc,CAAC;iBAC/B;;;AC9BD;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;"}
|
|
@@ -14,23 +14,25 @@ class _MatTooltipHarnessBase extends ComponentHarness {
|
|
|
14
14
|
// We need to dispatch both `touchstart` and a hover event, because the tooltip binds
|
|
15
15
|
// different events depending on the device. The `changedTouches` is there in case the
|
|
16
16
|
// element has ripples.
|
|
17
|
-
|
|
18
|
-
await host.dispatchEvent?.('touchstart', { changedTouches: [] });
|
|
17
|
+
await host.dispatchEvent('touchstart', { changedTouches: [] });
|
|
19
18
|
await host.hover();
|
|
19
|
+
const panel = await this._optionalPanel();
|
|
20
|
+
await panel?.dispatchEvent('animationend', { animationName: this._showAnimationName });
|
|
20
21
|
}
|
|
21
22
|
/** Hides the tooltip. */
|
|
22
23
|
async hide() {
|
|
23
24
|
const host = await this.host();
|
|
24
25
|
// We need to dispatch both `touchstart` and a hover event, because
|
|
25
26
|
// the tooltip binds different events depending on the device.
|
|
26
|
-
|
|
27
|
-
await host.dispatchEvent?.('touchend');
|
|
27
|
+
await host.dispatchEvent('touchend');
|
|
28
28
|
await host.mouseAway();
|
|
29
|
-
await this.
|
|
29
|
+
const panel = await this._optionalPanel();
|
|
30
|
+
await panel?.dispatchEvent('animationend', { animationName: this._hideAnimationName });
|
|
30
31
|
}
|
|
31
32
|
/** Gets whether the tooltip is open. */
|
|
32
33
|
async isOpen() {
|
|
33
|
-
|
|
34
|
+
const panel = await this._optionalPanel();
|
|
35
|
+
return !!panel && !(await panel.hasClass(this._hiddenClass));
|
|
34
36
|
}
|
|
35
37
|
/** Gets a promise for the tooltip panel's text. */
|
|
36
38
|
async getTooltipText() {
|
|
@@ -43,6 +45,9 @@ class MatTooltipHarness extends _MatTooltipHarnessBase {
|
|
|
43
45
|
constructor() {
|
|
44
46
|
super(...arguments);
|
|
45
47
|
this._optionalPanel = this.documentRootLocatorFactory().locatorForOptional('.mat-tooltip');
|
|
48
|
+
this._hiddenClass = 'mat-tooltip-hide';
|
|
49
|
+
this._showAnimationName = 'mat-tooltip-show';
|
|
50
|
+
this._hideAnimationName = 'mat-tooltip-hide';
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
48
53
|
* Gets a `HarnessPredicate` that can be used to search
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/tooltip/testing/tooltip-harness.ts","../../../../../../../src/material/tooltip/testing/tooltip-harness-filters.ts","../../../../../../../src/material/tooltip/testing/public-api.ts","../../../../../../../src/material/tooltip/testing/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {\n AsyncFactoryFn,\n ComponentHarness,\n HarnessPredicate,\n TestElement,\n} from '@angular/cdk/testing';\nimport {TooltipHarnessFilters} from './tooltip-harness-filters';\n\nexport abstract class _MatTooltipHarnessBase extends ComponentHarness {\n protected abstract _optionalPanel: AsyncFactoryFn<TestElement | null>;\n\n /** Shows the tooltip. */\n async show(): Promise<void> {\n const host = await this.host();\n\n // We need to dispatch both `touchstart` and a hover event, because the tooltip binds\n // different events depending on the device. The `changedTouches` is there in case the\n // element has ripples.\n
|
|
1
|
+
{"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/tooltip/testing/tooltip-harness.ts","../../../../../../../src/material/tooltip/testing/tooltip-harness-filters.ts","../../../../../../../src/material/tooltip/testing/public-api.ts","../../../../../../../src/material/tooltip/testing/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {\n AsyncFactoryFn,\n ComponentHarness,\n HarnessPredicate,\n TestElement,\n} from '@angular/cdk/testing';\nimport {TooltipHarnessFilters} from './tooltip-harness-filters';\n\nexport abstract class _MatTooltipHarnessBase extends ComponentHarness {\n protected abstract _optionalPanel: AsyncFactoryFn<TestElement | null>;\n protected abstract _hiddenClass: string;\n protected abstract _showAnimationName: string;\n protected abstract _hideAnimationName: string;\n\n /** Shows the tooltip. */\n async show(): Promise<void> {\n const host = await this.host();\n\n // We need to dispatch both `touchstart` and a hover event, because the tooltip binds\n // different events depending on the device. The `changedTouches` is there in case the\n // element has ripples.\n await host.dispatchEvent('touchstart', {changedTouches: []});\n await host.hover();\n const panel = await this._optionalPanel();\n await panel?.dispatchEvent('animationend', {animationName: this._showAnimationName});\n }\n\n /** Hides the tooltip. */\n async hide(): Promise<void> {\n const host = await this.host();\n\n // We need to dispatch both `touchstart` and a hover event, because\n // the tooltip binds different events depending on the device.\n await host.dispatchEvent('touchend');\n await host.mouseAway();\n const panel = await this._optionalPanel();\n await panel?.dispatchEvent('animationend', {animationName: this._hideAnimationName});\n }\n\n /** Gets whether the tooltip is open. */\n async isOpen(): Promise<boolean> {\n const panel = await this._optionalPanel();\n return !!panel && !(await panel.hasClass(this._hiddenClass));\n }\n\n /** Gets a promise for the tooltip panel's text. */\n async getTooltipText(): Promise<string> {\n const panel = await this._optionalPanel();\n return panel ? panel.text() : '';\n }\n}\n\n/** Harness for interacting with a standard mat-tooltip in tests. */\nexport class MatTooltipHarness extends _MatTooltipHarnessBase {\n protected _optionalPanel = this.documentRootLocatorFactory().locatorForOptional('.mat-tooltip');\n protected _hiddenClass = 'mat-tooltip-hide';\n protected _showAnimationName = 'mat-tooltip-show';\n protected _hideAnimationName = 'mat-tooltip-hide';\n static hostSelector = '.mat-tooltip-trigger';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search\n * for a tooltip trigger with specific attributes.\n * @param options Options for narrowing the search.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: TooltipHarnessFilters = {}): HarnessPredicate<MatTooltipHarness> {\n return new HarnessPredicate(MatTooltipHarness, options);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {BaseHarnessFilters} from '@angular/cdk/testing';\n\n/** A set of criteria that can be used to filter a list of `MatTooltipHarness` instances. */\nexport interface TooltipHarnessFilters extends BaseHarnessFilters {}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './tooltip-harness';\nexport * from './tooltip-harness-filters';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;;;MAgBsB,sBAAuB,SAAQ,gBAAgB;;IAOnE,MAAM,IAAI;QACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;;;;QAK/B,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,EAAC,cAAc,EAAE,EAAE,EAAC,CAAC,CAAC;QAC7D,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1C,MAAM,KAAK,EAAE,aAAa,CAAC,cAAc,EAAE,EAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,EAAC,CAAC,CAAC;KACtF;;IAGD,MAAM,IAAI;QACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;;;QAI/B,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACrC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1C,MAAM,KAAK,EAAE,aAAa,CAAC,cAAc,EAAE,EAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,EAAC,CAAC,CAAC;KACtF;;IAGD,MAAM,MAAM;QACV,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1C,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,MAAM,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;KAC9D;;IAGD,MAAM,cAAc;QAClB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1C,OAAO,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC;KAClC;CACF;AAED;MACa,iBAAkB,SAAQ,sBAAsB;IAA7D;;QACY,mBAAc,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QACtF,iBAAY,GAAG,kBAAkB,CAAC;QAClC,uBAAkB,GAAG,kBAAkB,CAAC;QACxC,uBAAkB,GAAG,kBAAkB,CAAC;KAYnD;;;;;;;IAHC,OAAO,IAAI,CAAC,UAAiC,EAAE;QAC7C,OAAO,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;KACzD;;AAVM,8BAAY,GAAG,sBAAsB;;AClE9C;;;;;;;;ACAA;;;;;;;;ACAA;;;;;;;;;;"}
|
package/fesm2020/tooltip.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { A11yModule } from '@angular/cdk/a11y';
|
|
|
5
5
|
import * as i7 from '@angular/common';
|
|
6
6
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
7
7
|
import * as i0 from '@angular/core';
|
|
8
|
-
import { InjectionToken, Directive, Inject, Input, Optional, Component, ViewEncapsulation, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
8
|
+
import { InjectionToken, Directive, Inject, Input, Optional, Component, ViewEncapsulation, ChangeDetectionStrategy, ViewChild, NgModule } from '@angular/core';
|
|
9
9
|
import { MatCommonModule } from '@angular/material/core';
|
|
10
10
|
import * as i2 from '@angular/cdk/scrolling';
|
|
11
11
|
import { CdkScrollableModule } from '@angular/cdk/scrolling';
|
|
@@ -17,6 +17,7 @@ import { Breakpoints } from '@angular/cdk/layout';
|
|
|
17
17
|
import * as i3 from '@angular/cdk/platform';
|
|
18
18
|
import { normalizePassiveListenerOptions } from '@angular/cdk/platform';
|
|
19
19
|
import { ComponentPortal } from '@angular/cdk/portal';
|
|
20
|
+
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
|
|
20
21
|
import { Subject } from 'rxjs';
|
|
21
22
|
import { takeUntil, take } from 'rxjs/operators';
|
|
22
23
|
import { trigger, state, style, transition, animate, keyframes } from '@angular/animations';
|
|
@@ -28,24 +29,6 @@ import { trigger, state, style, transition, animate, keyframes } from '@angular/
|
|
|
28
29
|
* Use of this source code is governed by an MIT-style license that can be
|
|
29
30
|
* found in the LICENSE file at https://angular.io/license
|
|
30
31
|
*/
|
|
31
|
-
/**
|
|
32
|
-
* Animations used by MatTooltip.
|
|
33
|
-
* @docs-private
|
|
34
|
-
*/
|
|
35
|
-
const matTooltipAnimations = {
|
|
36
|
-
/** Animation that transitions a tooltip in and out. */
|
|
37
|
-
tooltipState: trigger('state', [
|
|
38
|
-
state('initial, void, hidden', style({ opacity: 0, transform: 'scale(0)' })),
|
|
39
|
-
state('visible', style({ transform: 'scale(1)' })),
|
|
40
|
-
transition('* => visible', animate('200ms cubic-bezier(0, 0, 0.2, 1)', keyframes([
|
|
41
|
-
style({ opacity: 0, transform: 'scale(0)', offset: 0 }),
|
|
42
|
-
style({ opacity: 0.5, transform: 'scale(0.99)', offset: 0.5 }),
|
|
43
|
-
style({ opacity: 1, transform: 'scale(1)', offset: 1 }),
|
|
44
|
-
]))),
|
|
45
|
-
transition('* => hidden', animate('100ms cubic-bezier(0, 0, 0.2, 1)', style({ opacity: 0 }))),
|
|
46
|
-
]),
|
|
47
|
-
};
|
|
48
|
-
|
|
49
32
|
/** Time in ms to throttle repositioning after scroll events. */
|
|
50
33
|
const SCROLL_THROTTLE_MS = 20;
|
|
51
34
|
/**
|
|
@@ -690,14 +673,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImpor
|
|
|
690
673
|
args: [DOCUMENT]
|
|
691
674
|
}] }]; } });
|
|
692
675
|
class _TooltipComponentBase {
|
|
693
|
-
constructor(_changeDetectorRef) {
|
|
676
|
+
constructor(_changeDetectorRef, animationMode) {
|
|
694
677
|
this._changeDetectorRef = _changeDetectorRef;
|
|
695
678
|
/** Property watched by the animation framework to show or hide the tooltip */
|
|
696
679
|
this._visibility = 'initial';
|
|
697
680
|
/** Whether interactions on the page should close the tooltip */
|
|
698
681
|
this._closeOnInteraction = false;
|
|
682
|
+
/** Whether the tooltip is currently visible. */
|
|
683
|
+
this._isVisible = false;
|
|
699
684
|
/** Subject for notifying that the tooltip has been hidden from the view */
|
|
700
685
|
this._onHide = new Subject();
|
|
686
|
+
this._animationsDisabled = animationMode === 'NoopAnimations';
|
|
701
687
|
}
|
|
702
688
|
/**
|
|
703
689
|
* Shows the tooltip with an animation originating from the provided origin
|
|
@@ -706,15 +692,9 @@ class _TooltipComponentBase {
|
|
|
706
692
|
show(delay) {
|
|
707
693
|
// Cancel the delayed hide if it is scheduled
|
|
708
694
|
clearTimeout(this._hideTimeoutId);
|
|
709
|
-
// Body interactions should cancel the tooltip if there is a delay in showing.
|
|
710
|
-
this._closeOnInteraction = true;
|
|
711
695
|
this._showTimeoutId = setTimeout(() => {
|
|
712
|
-
this.
|
|
696
|
+
this._toggleVisibility(true);
|
|
713
697
|
this._showTimeoutId = undefined;
|
|
714
|
-
this._onShow();
|
|
715
|
-
// Mark for check so if any parent component has set the
|
|
716
|
-
// ChangeDetectionStrategy to OnPush it will be checked anyways
|
|
717
|
-
this._markForCheck();
|
|
718
698
|
}, delay);
|
|
719
699
|
}
|
|
720
700
|
/**
|
|
@@ -725,11 +705,8 @@ class _TooltipComponentBase {
|
|
|
725
705
|
// Cancel the delayed show if it is scheduled
|
|
726
706
|
clearTimeout(this._showTimeoutId);
|
|
727
707
|
this._hideTimeoutId = setTimeout(() => {
|
|
728
|
-
this.
|
|
708
|
+
this._toggleVisibility(false);
|
|
729
709
|
this._hideTimeoutId = undefined;
|
|
730
|
-
// Mark for check so if any parent component has set the
|
|
731
|
-
// ChangeDetectionStrategy to OnPush it will be checked anyways
|
|
732
|
-
this._markForCheck();
|
|
733
710
|
}, delay);
|
|
734
711
|
}
|
|
735
712
|
/** Returns an observable that notifies when the tooltip has been hidden from view. */
|
|
@@ -738,7 +715,7 @@ class _TooltipComponentBase {
|
|
|
738
715
|
}
|
|
739
716
|
/** Whether the tooltip is being displayed. */
|
|
740
717
|
isVisible() {
|
|
741
|
-
return this.
|
|
718
|
+
return this._isVisible;
|
|
742
719
|
}
|
|
743
720
|
ngOnDestroy() {
|
|
744
721
|
clearTimeout(this._showTimeoutId);
|
|
@@ -746,18 +723,6 @@ class _TooltipComponentBase {
|
|
|
746
723
|
this._onHide.complete();
|
|
747
724
|
this._triggerElement = null;
|
|
748
725
|
}
|
|
749
|
-
_animationStart() {
|
|
750
|
-
this._closeOnInteraction = false;
|
|
751
|
-
}
|
|
752
|
-
_animationDone(event) {
|
|
753
|
-
const toState = event.toState;
|
|
754
|
-
if (toState === 'hidden' && !this.isVisible()) {
|
|
755
|
-
this._onHide.next();
|
|
756
|
-
}
|
|
757
|
-
if (toState === 'visible' || toState === 'hidden') {
|
|
758
|
-
this._closeOnInteraction = true;
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
726
|
/**
|
|
762
727
|
* Interactions on the HTML body should close the tooltip immediately as defined in the
|
|
763
728
|
* material design spec.
|
|
@@ -787,36 +752,99 @@ class _TooltipComponentBase {
|
|
|
787
752
|
* in the mdc-tooltip, not here.
|
|
788
753
|
*/
|
|
789
754
|
_onShow() { }
|
|
755
|
+
/** Event listener dispatched when an animation on the tooltip finishes. */
|
|
756
|
+
_handleAnimationEnd({ animationName }) {
|
|
757
|
+
if (animationName === this._showAnimation || animationName === this._hideAnimation) {
|
|
758
|
+
this._finalizeAnimation(animationName === this._showAnimation);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
/** Handles the cleanup after an animation has finished. */
|
|
762
|
+
_finalizeAnimation(toVisible) {
|
|
763
|
+
if (toVisible) {
|
|
764
|
+
this._closeOnInteraction = true;
|
|
765
|
+
}
|
|
766
|
+
else if (!this.isVisible()) {
|
|
767
|
+
this._onHide.next();
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
/** Toggles the visibility of the tooltip element. */
|
|
771
|
+
_toggleVisibility(isVisible) {
|
|
772
|
+
// We set the classes directly here ourselves so that toggling the tooltip state
|
|
773
|
+
// isn't bound by change detection. This allows us to hide it even if the
|
|
774
|
+
// view ref has been detached from the CD tree.
|
|
775
|
+
const tooltip = this._tooltip.nativeElement;
|
|
776
|
+
const showClass = this._showAnimation;
|
|
777
|
+
const hideClass = this._hideAnimation;
|
|
778
|
+
tooltip.classList.remove(isVisible ? hideClass : showClass);
|
|
779
|
+
tooltip.classList.add(isVisible ? showClass : hideClass);
|
|
780
|
+
this._isVisible = isVisible;
|
|
781
|
+
// It's common for internal apps to disable animations using `* { animation: none !important }`
|
|
782
|
+
// which can break the opening sequence. Try to detect such cases and work around them.
|
|
783
|
+
if (isVisible && !this._animationsDisabled && typeof getComputedStyle === 'function') {
|
|
784
|
+
const styles = getComputedStyle(tooltip);
|
|
785
|
+
// Use `getPropertyValue` to avoid issues with property renaming.
|
|
786
|
+
if (styles.getPropertyValue('animation-duration') === '0s' ||
|
|
787
|
+
styles.getPropertyValue('animation-name') === 'none') {
|
|
788
|
+
this._animationsDisabled = true;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
if (isVisible) {
|
|
792
|
+
this._onShow();
|
|
793
|
+
}
|
|
794
|
+
if (this._animationsDisabled) {
|
|
795
|
+
tooltip.classList.add('_mat-animation-noopable');
|
|
796
|
+
this._finalizeAnimation(isVisible);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
790
799
|
}
|
|
791
|
-
_TooltipComponentBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: _TooltipComponentBase, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
800
|
+
_TooltipComponentBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: _TooltipComponentBase, deps: [{ token: i0.ChangeDetectorRef }, { token: ANIMATION_MODULE_TYPE, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
792
801
|
_TooltipComponentBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: _TooltipComponentBase, ngImport: i0 });
|
|
793
802
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: _TooltipComponentBase, decorators: [{
|
|
794
803
|
type: Directive
|
|
795
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }
|
|
804
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
|
|
805
|
+
type: Optional
|
|
806
|
+
}, {
|
|
807
|
+
type: Inject,
|
|
808
|
+
args: [ANIMATION_MODULE_TYPE]
|
|
809
|
+
}] }]; } });
|
|
796
810
|
/**
|
|
797
811
|
* Internal component that wraps the tooltip's content.
|
|
798
812
|
* @docs-private
|
|
799
813
|
*/
|
|
800
814
|
class TooltipComponent extends _TooltipComponentBase {
|
|
801
|
-
constructor(changeDetectorRef, _breakpointObserver) {
|
|
802
|
-
super(changeDetectorRef);
|
|
815
|
+
constructor(changeDetectorRef, _breakpointObserver, animationMode) {
|
|
816
|
+
super(changeDetectorRef, animationMode);
|
|
803
817
|
this._breakpointObserver = _breakpointObserver;
|
|
804
818
|
/** Stream that emits whether the user has a handset-sized display. */
|
|
805
819
|
this._isHandset = this._breakpointObserver.observe(Breakpoints.Handset);
|
|
820
|
+
this._showAnimation = 'mat-tooltip-show';
|
|
821
|
+
this._hideAnimation = 'mat-tooltip-hide';
|
|
806
822
|
}
|
|
807
823
|
}
|
|
808
|
-
TooltipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: TooltipComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i6.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Component });
|
|
809
|
-
TooltipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: TooltipComponent, selector: "mat-tooltip-component", host: { attributes: { "aria-hidden": "true" }, listeners: { "mouseleave": "_handleMouseLeave($event)" }, properties: { "style.zoom": "
|
|
824
|
+
TooltipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: TooltipComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i6.BreakpointObserver }, { token: ANIMATION_MODULE_TYPE, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
825
|
+
TooltipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: TooltipComponent, selector: "mat-tooltip-component", host: { attributes: { "aria-hidden": "true" }, listeners: { "mouseleave": "_handleMouseLeave($event)" }, properties: { "style.zoom": "isVisible() ? 1 : null" } }, viewQueries: [{ propertyName: "_tooltip", first: true, predicate: ["tooltip"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<div #tooltip\n class=\"mat-tooltip\"\n (animationend)=\"_handleAnimationEnd($event)\"\n [ngClass]=\"tooltipClass\"\n [class.mat-tooltip-handset]=\"(_isHandset | async)?.matches\">{{message}}</div>\n", styles: [".mat-tooltip{color:#fff;border-radius:4px;margin:14px;max-width:250px;padding-left:8px;padding-right:8px;overflow:hidden;text-overflow:ellipsis;transform:scale(0)}.mat-tooltip._mat-animation-noopable{animation:none;transform:scale(1)}.cdk-high-contrast-active .mat-tooltip{outline:solid 1px}.mat-tooltip-handset{margin:24px;padding-left:16px;padding-right:16px}.mat-tooltip-panel-non-interactive{pointer-events:none}@keyframes mat-tooltip-show{0%{opacity:0;transform:scale(0)}50%{opacity:.5;transform:scale(0.99)}100%{opacity:1;transform:scale(1)}}@keyframes mat-tooltip-hide{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(1)}}.mat-tooltip-show{animation:mat-tooltip-show 200ms cubic-bezier(0, 0, 0.2, 1) forwards}.mat-tooltip-hide{animation:mat-tooltip-hide 100ms cubic-bezier(0, 0, 0.2, 1) forwards}\n"], directives: [{ type: i7.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], pipes: { "async": i7.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
810
826
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: TooltipComponent, decorators: [{
|
|
811
827
|
type: Component,
|
|
812
|
-
args: [{ selector: 'mat-tooltip-component', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush,
|
|
828
|
+
args: [{ selector: 'mat-tooltip-component', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
813
829
|
// Forces the element to have a layout in IE and Edge. This fixes issues where the element
|
|
814
830
|
// won't be rendered if the animations are disabled or there is no web animations polyfill.
|
|
815
|
-
'[style.zoom]': '
|
|
831
|
+
'[style.zoom]': 'isVisible() ? 1 : null',
|
|
816
832
|
'(mouseleave)': '_handleMouseLeave($event)',
|
|
817
833
|
'aria-hidden': 'true',
|
|
818
|
-
}, template: "<div class=\"mat-tooltip\"\n [ngClass]=\"tooltipClass\"\n [class.mat-tooltip-handset]=\"(_isHandset | async)?.matches\"
|
|
819
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i6.BreakpointObserver }
|
|
834
|
+
}, template: "<div #tooltip\n class=\"mat-tooltip\"\n (animationend)=\"_handleAnimationEnd($event)\"\n [ngClass]=\"tooltipClass\"\n [class.mat-tooltip-handset]=\"(_isHandset | async)?.matches\">{{message}}</div>\n", styles: [".mat-tooltip{color:#fff;border-radius:4px;margin:14px;max-width:250px;padding-left:8px;padding-right:8px;overflow:hidden;text-overflow:ellipsis;transform:scale(0)}.mat-tooltip._mat-animation-noopable{animation:none;transform:scale(1)}.cdk-high-contrast-active .mat-tooltip{outline:solid 1px}.mat-tooltip-handset{margin:24px;padding-left:16px;padding-right:16px}.mat-tooltip-panel-non-interactive{pointer-events:none}@keyframes mat-tooltip-show{0%{opacity:0;transform:scale(0)}50%{opacity:.5;transform:scale(0.99)}100%{opacity:1;transform:scale(1)}}@keyframes mat-tooltip-hide{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(1)}}.mat-tooltip-show{animation:mat-tooltip-show 200ms cubic-bezier(0, 0, 0.2, 1) forwards}.mat-tooltip-hide{animation:mat-tooltip-hide 100ms cubic-bezier(0, 0, 0.2, 1) forwards}\n"] }]
|
|
835
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i6.BreakpointObserver }, { type: undefined, decorators: [{
|
|
836
|
+
type: Optional
|
|
837
|
+
}, {
|
|
838
|
+
type: Inject,
|
|
839
|
+
args: [ANIMATION_MODULE_TYPE]
|
|
840
|
+
}] }]; }, propDecorators: { _tooltip: [{
|
|
841
|
+
type: ViewChild,
|
|
842
|
+
args: ['tooltip', {
|
|
843
|
+
// Use a static query here since we interact directly with
|
|
844
|
+
// the DOM which can happen before `ngAfterViewInit`.
|
|
845
|
+
static: true,
|
|
846
|
+
}]
|
|
847
|
+
}] } });
|
|
820
848
|
|
|
821
849
|
/**
|
|
822
850
|
* @license
|
|
@@ -840,6 +868,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImpor
|
|
|
840
868
|
}]
|
|
841
869
|
}] });
|
|
842
870
|
|
|
871
|
+
/**
|
|
872
|
+
* @license
|
|
873
|
+
* Copyright Google LLC All Rights Reserved.
|
|
874
|
+
*
|
|
875
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
876
|
+
* found in the LICENSE file at https://angular.io/license
|
|
877
|
+
*/
|
|
878
|
+
/**
|
|
879
|
+
* Animations used by MatTooltip.
|
|
880
|
+
* @docs-private
|
|
881
|
+
*/
|
|
882
|
+
const matTooltipAnimations = {
|
|
883
|
+
/** Animation that transitions a tooltip in and out. */
|
|
884
|
+
tooltipState: trigger('state', [
|
|
885
|
+
state('initial, void, hidden', style({ opacity: 0, transform: 'scale(0)' })),
|
|
886
|
+
state('visible', style({ transform: 'scale(1)' })),
|
|
887
|
+
transition('* => visible', animate('200ms cubic-bezier(0, 0, 0.2, 1)', keyframes([
|
|
888
|
+
style({ opacity: 0, transform: 'scale(0)', offset: 0 }),
|
|
889
|
+
style({ opacity: 0.5, transform: 'scale(0.99)', offset: 0.5 }),
|
|
890
|
+
style({ opacity: 1, transform: 'scale(1)', offset: 1 }),
|
|
891
|
+
]))),
|
|
892
|
+
transition('* => hidden', animate('100ms cubic-bezier(0, 0, 0.2, 1)', style({ opacity: 0 }))),
|
|
893
|
+
]),
|
|
894
|
+
};
|
|
895
|
+
|
|
843
896
|
/**
|
|
844
897
|
* @license
|
|
845
898
|
* Copyright Google LLC All Rights Reserved.
|