@angular/material 13.2.3 → 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.
Files changed (136) hide show
  1. package/autocomplete/autocomplete-trigger.d.ts +1 -0
  2. package/button-toggle/_button-toggle-theme.scss +14 -2
  3. package/checkbox/_checkbox-theme.scss +1 -1
  4. package/core/theming/_theming.scss +9 -0
  5. package/dialog/dialog-config.d.ts +2 -0
  6. package/dialog/dialog-container.d.ts +1 -4
  7. package/dialog/dialog.d.ts +12 -6
  8. package/dialog/testing/dialog-opener.d.ts +33 -0
  9. package/dialog/testing/public-api.d.ts +1 -0
  10. package/esm2020/autocomplete/autocomplete-trigger.mjs +19 -6
  11. package/esm2020/bottom-sheet/bottom-sheet-animations.mjs +10 -4
  12. package/esm2020/button/button.mjs +3 -3
  13. package/esm2020/button-toggle/button-toggle.mjs +2 -2
  14. package/esm2020/checkbox/checkbox.mjs +4 -2
  15. package/esm2020/core/version.mjs +1 -1
  16. package/esm2020/datepicker/calendar.mjs +9 -9
  17. package/esm2020/datepicker/datepicker-input-base.mjs +9 -4
  18. package/esm2020/dialog/dialog-animations.mjs +10 -4
  19. package/esm2020/dialog/dialog-config.mjs +3 -1
  20. package/esm2020/dialog/dialog-container.mjs +14 -14
  21. package/esm2020/dialog/dialog.mjs +15 -31
  22. package/esm2020/dialog/testing/dialog-opener.mjs +67 -0
  23. package/esm2020/dialog/testing/public-api.mjs +2 -1
  24. package/esm2020/expansion/expansion-panel.mjs +3 -3
  25. package/esm2020/form-field/form-field.mjs +3 -3
  26. package/esm2020/menu/menu-item.mjs +5 -1
  27. package/esm2020/menu/menu.mjs +17 -1
  28. package/esm2020/progress-spinner/progress-spinner-module.mjs +5 -5
  29. package/esm2020/progress-spinner/progress-spinner.mjs +8 -48
  30. package/esm2020/progress-spinner/public-api.mjs +10 -2
  31. package/esm2020/radio/radio.mjs +3 -3
  32. package/esm2020/select/select.mjs +14 -4
  33. package/esm2020/sidenav/drawer.mjs +3 -3
  34. package/esm2020/sidenav/sidenav.mjs +3 -3
  35. package/esm2020/slide-toggle/slide-toggle.mjs +3 -2
  36. package/esm2020/sort/sort-header.mjs +4 -4
  37. package/esm2020/tabs/tab-body.mjs +3 -3
  38. package/esm2020/tabs/tab-header.mjs +3 -3
  39. package/esm2020/tooltip/testing/tooltip-harness.mjs +12 -7
  40. package/esm2020/tooltip/tooltip.mjs +117 -42
  41. package/fesm2015/autocomplete.mjs +19 -6
  42. package/fesm2015/autocomplete.mjs.map +1 -1
  43. package/fesm2015/bottom-sheet.mjs +9 -3
  44. package/fesm2015/bottom-sheet.mjs.map +1 -1
  45. package/fesm2015/button-toggle.mjs +2 -2
  46. package/fesm2015/button.mjs +2 -2
  47. package/fesm2015/button.mjs.map +1 -1
  48. package/fesm2015/checkbox.mjs +3 -1
  49. package/fesm2015/checkbox.mjs.map +1 -1
  50. package/fesm2015/core.mjs +1 -1
  51. package/fesm2015/core.mjs.map +1 -1
  52. package/fesm2015/datepicker.mjs +15 -10
  53. package/fesm2015/datepicker.mjs.map +1 -1
  54. package/fesm2015/dialog/testing.mjs +65 -2
  55. package/fesm2015/dialog/testing.mjs.map +1 -1
  56. package/fesm2015/dialog.mjs +38 -46
  57. package/fesm2015/dialog.mjs.map +1 -1
  58. package/fesm2015/expansion.mjs +2 -2
  59. package/fesm2015/expansion.mjs.map +1 -1
  60. package/fesm2015/form-field.mjs +2 -2
  61. package/fesm2015/form-field.mjs.map +1 -1
  62. package/fesm2015/menu.mjs +21 -0
  63. package/fesm2015/menu.mjs.map +1 -1
  64. package/fesm2015/progress-spinner.mjs +22 -57
  65. package/fesm2015/progress-spinner.mjs.map +1 -1
  66. package/fesm2015/radio.mjs +2 -2
  67. package/fesm2015/radio.mjs.map +1 -1
  68. package/fesm2015/select.mjs +13 -3
  69. package/fesm2015/select.mjs.map +1 -1
  70. package/fesm2015/sidenav.mjs +4 -4
  71. package/fesm2015/sidenav.mjs.map +1 -1
  72. package/fesm2015/slide-toggle.mjs +2 -1
  73. package/fesm2015/slide-toggle.mjs.map +1 -1
  74. package/fesm2015/sort.mjs +3 -3
  75. package/fesm2015/sort.mjs.map +1 -1
  76. package/fesm2015/tabs.mjs +4 -4
  77. package/fesm2015/tabs.mjs.map +1 -1
  78. package/fesm2015/tooltip/testing.mjs +11 -8
  79. package/fesm2015/tooltip/testing.mjs.map +1 -1
  80. package/fesm2015/tooltip.mjs +141 -66
  81. package/fesm2015/tooltip.mjs.map +1 -1
  82. package/fesm2020/autocomplete.mjs +19 -6
  83. package/fesm2020/autocomplete.mjs.map +1 -1
  84. package/fesm2020/bottom-sheet.mjs +9 -3
  85. package/fesm2020/bottom-sheet.mjs.map +1 -1
  86. package/fesm2020/button-toggle.mjs +2 -2
  87. package/fesm2020/button.mjs +2 -2
  88. package/fesm2020/button.mjs.map +1 -1
  89. package/fesm2020/checkbox.mjs +3 -1
  90. package/fesm2020/checkbox.mjs.map +1 -1
  91. package/fesm2020/core.mjs +1 -1
  92. package/fesm2020/core.mjs.map +1 -1
  93. package/fesm2020/datepicker.mjs +15 -10
  94. package/fesm2020/datepicker.mjs.map +1 -1
  95. package/fesm2020/dialog/testing.mjs +65 -1
  96. package/fesm2020/dialog/testing.mjs.map +1 -1
  97. package/fesm2020/dialog.mjs +38 -46
  98. package/fesm2020/dialog.mjs.map +1 -1
  99. package/fesm2020/expansion.mjs +2 -2
  100. package/fesm2020/expansion.mjs.map +1 -1
  101. package/fesm2020/form-field.mjs +2 -2
  102. package/fesm2020/form-field.mjs.map +1 -1
  103. package/fesm2020/menu.mjs +20 -0
  104. package/fesm2020/menu.mjs.map +1 -1
  105. package/fesm2020/progress-spinner.mjs +22 -55
  106. package/fesm2020/progress-spinner.mjs.map +1 -1
  107. package/fesm2020/radio.mjs +2 -2
  108. package/fesm2020/radio.mjs.map +1 -1
  109. package/fesm2020/select.mjs +13 -3
  110. package/fesm2020/select.mjs.map +1 -1
  111. package/fesm2020/sidenav.mjs +4 -4
  112. package/fesm2020/sidenav.mjs.map +1 -1
  113. package/fesm2020/slide-toggle.mjs +2 -1
  114. package/fesm2020/slide-toggle.mjs.map +1 -1
  115. package/fesm2020/sort.mjs +3 -3
  116. package/fesm2020/sort.mjs.map +1 -1
  117. package/fesm2020/tabs.mjs +4 -4
  118. package/fesm2020/tabs.mjs.map +1 -1
  119. package/fesm2020/tooltip/testing.mjs +11 -6
  120. package/fesm2020/tooltip/testing.mjs.map +1 -1
  121. package/fesm2020/tooltip.mjs +134 -58
  122. package/fesm2020/tooltip.mjs.map +1 -1
  123. package/menu/menu-item.d.ts +3 -2
  124. package/package.json +2 -2
  125. package/prebuilt-themes/deeppurple-amber.css +1 -1
  126. package/prebuilt-themes/indigo-pink.css +1 -1
  127. package/prebuilt-themes/pink-bluegrey.css +1 -1
  128. package/prebuilt-themes/purple-green.css +1 -1
  129. package/progress-spinner/progress-spinner-module.d.ts +1 -1
  130. package/progress-spinner/progress-spinner.d.ts +1 -18
  131. package/progress-spinner/public-api.d.ts +8 -1
  132. package/schematics/ng-add/index.js +1 -1
  133. package/schematics/ng-add/index.mjs +1 -1
  134. package/select/select.d.ts +5 -0
  135. package/tooltip/testing/tooltip-harness.d.ts +6 -0
  136. package/tooltip/tooltip.d.ts +36 -8
@@ -4,34 +4,34 @@ import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
4
4
  class _MatTooltipHarnessBase extends ComponentHarness {
5
5
  /** Shows the tooltip. */
6
6
  show() {
7
- var _a;
8
7
  return __awaiter(this, void 0, void 0, function* () {
9
8
  const host = yield this.host();
10
9
  // We need to dispatch both `touchstart` and a hover event, because the tooltip binds
11
10
  // different events depending on the device. The `changedTouches` is there in case the
12
11
  // element has ripples.
13
- // @breaking-change 12.0.0 Remove null assertion from `dispatchEvent`.
14
- yield ((_a = host.dispatchEvent) === null || _a === void 0 ? void 0 : _a.call(host, 'touchstart', { changedTouches: [] }));
12
+ yield host.dispatchEvent('touchstart', { changedTouches: [] });
15
13
  yield host.hover();
14
+ const panel = yield this._optionalPanel();
15
+ yield (panel === null || panel === void 0 ? void 0 : panel.dispatchEvent('animationend', { animationName: this._showAnimationName }));
16
16
  });
17
17
  }
18
18
  /** Hides the tooltip. */
19
19
  hide() {
20
- var _a;
21
20
  return __awaiter(this, void 0, void 0, function* () {
22
21
  const host = yield this.host();
23
22
  // We need to dispatch both `touchstart` and a hover event, because
24
23
  // the tooltip binds different events depending on the device.
25
- // @breaking-change 12.0.0 Remove null assertion from `dispatchEvent`.
26
- yield ((_a = host.dispatchEvent) === null || _a === void 0 ? void 0 : _a.call(host, 'touchend'));
24
+ yield host.dispatchEvent('touchend');
27
25
  yield host.mouseAway();
28
- yield this.forceStabilize(); // Needed in order to flush the `hide` animation.
26
+ const panel = yield this._optionalPanel();
27
+ yield (panel === null || panel === void 0 ? void 0 : panel.dispatchEvent('animationend', { animationName: this._hideAnimationName }));
29
28
  });
30
29
  }
31
30
  /** Gets whether the tooltip is open. */
32
31
  isOpen() {
33
32
  return __awaiter(this, void 0, void 0, function* () {
34
- return !!(yield this._optionalPanel());
33
+ const panel = yield this._optionalPanel();
34
+ return !!panel && !(yield panel.hasClass(this._hiddenClass));
35
35
  });
36
36
  }
37
37
  /** Gets a promise for the tooltip panel's text. */
@@ -47,6 +47,9 @@ class MatTooltipHarness extends _MatTooltipHarnessBase {
47
47
  constructor() {
48
48
  super(...arguments);
49
49
  this._optionalPanel = this.documentRootLocatorFactory().locatorForOptional('.mat-tooltip');
50
+ this._hiddenClass = 'mat-tooltip-hide';
51
+ this._showAnimationName = 'mat-tooltip-show';
52
+ this._hideAnimationName = 'mat-tooltip-hide';
50
53
  }
51
54
  /**
52
55
  * 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/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 // @breaking-change 12.0.0 Remove null assertion from `dispatchEvent`.\n await host.dispatchEvent?.('touchstart', {changedTouches: []});\n await host.hover();\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 // @breaking-change 12.0.0 Remove null assertion from `dispatchEvent`.\n await host.dispatchEvent?.('touchend');\n await host.mouseAway();\n await this.forceStabilize(); // Needed in order to flush the `hide` animation.\n }\n\n /** Gets whether the tooltip is open. */\n async isOpen(): Promise<boolean> {\n return !!(await this._optionalPanel());\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 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\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":";;;MAgBsB,+BAA+B,gBAAgB;;IAI7D,IAAI;;;YACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;;;;;YAM/B,OAAM,MAAA,IAAI,CAAC,aAAa,+CAAlB,IAAI,EAAiB,YAAY,EAAE,EAAC,cAAc,EAAE,EAAE,EAAC,CAAC,CAAA,CAAC;YAC/D,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;;KACpB;;IAGK,IAAI;;;YACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;;;;YAK/B,OAAM,MAAA,IAAI,CAAC,aAAa,+CAAlB,IAAI,EAAiB,UAAU,CAAC,CAAA,CAAC;YACvC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;;KAC7B;;IAGK,MAAM;;YACV,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;SACxC;KAAA;;IAGK,cAAc;;YAClB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,OAAO,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC;SAClC;KAAA;CACF;AAED;MACa,0BAA0B,sBAAsB;IAA7D;;QACY,mBAAc,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;KAYjG;;;;;;;IAHC,OAAO,IAAI,CAAC,UAAiC,EAAE;QAC7C,OAAO,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;KACzD;;AAVM,8BAAY,GAAG,sBAAsB;;AC1D9C;;;;;;;;ACAA;;;;;;;;;;"}
1
+ {"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/tooltip/testing/tooltip-harness.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\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":";;;MAgBsB,+BAA+B,gBAAgB;;IAO7D,IAAI;;YACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;;;;YAK/B,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,EAAC,cAAc,EAAE,EAAE,EAAC,CAAC,CAAC;YAC7D,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,OAAM,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,aAAa,CAAC,cAAc,EAAE,EAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,EAAC,CAAC,CAAA,CAAC;SACtF;KAAA;;IAGK,IAAI;;YACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;;;YAI/B,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YACrC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,OAAM,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,aAAa,CAAC,cAAc,EAAE,EAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,EAAC,CAAC,CAAA,CAAC;SACtF;KAAA;;IAGK,MAAM;;YACV,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,MAAM,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;SAC9D;KAAA;;IAGK,cAAc;;YAClB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,OAAO,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC;SAClC;KAAA;CACF;AAED;MACa,0BAA0B,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;;;;;;;;;;"}
@@ -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';
@@ -16,35 +16,11 @@ import { Breakpoints } from '@angular/cdk/layout';
16
16
  import * as i3 from '@angular/cdk/platform';
17
17
  import { normalizePassiveListenerOptions } from '@angular/cdk/platform';
18
18
  import { ComponentPortal } from '@angular/cdk/portal';
19
+ import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
19
20
  import { Subject } from 'rxjs';
20
21
  import { takeUntil, take } from 'rxjs/operators';
21
- import { trigger, state, style, transition, animate, keyframes } from '@angular/animations';
22
22
  import * as i5 from '@angular/cdk/bidi';
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
- /**
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
- };
23
+ import { trigger, state, style, transition, animate, keyframes } from '@angular/animations';
48
24
 
49
25
  /** Time in ms to throttle repositioning after scroll events. */
50
26
  const SCROLL_THROTTLE_MS = 20;
@@ -192,6 +168,9 @@ class _MatTooltipBase {
192
168
  }
193
169
  set hideDelay(value) {
194
170
  this._hideDelay = coerceNumberProperty(value);
171
+ if (this._tooltipInstance) {
172
+ this._tooltipInstance._mouseLeaveHideDelay = this._hideDelay;
173
+ }
195
174
  }
196
175
  /** The message to be displayed in the tooltip */
197
176
  get message() {
@@ -280,14 +259,16 @@ class _MatTooltipBase {
280
259
  this._detach();
281
260
  this._portal =
282
261
  this._portal || new ComponentPortal(this._tooltipComponent, this._viewContainerRef);
283
- this._tooltipInstance = overlayRef.attach(this._portal).instance;
284
- this._tooltipInstance
262
+ const instance = (this._tooltipInstance = overlayRef.attach(this._portal).instance);
263
+ instance._triggerElement = this._elementRef.nativeElement;
264
+ instance._mouseLeaveHideDelay = this._hideDelay;
265
+ instance
285
266
  .afterHidden()
286
267
  .pipe(takeUntil(this._destroyed))
287
268
  .subscribe(() => this._detach());
288
269
  this._setTooltipClass(this._tooltipClass);
289
270
  this._updateTooltipMessage();
290
- this._tooltipInstance.show(delay);
271
+ instance.show(delay);
291
272
  }
292
273
  /** Hides the tooltip after the delay in ms, defaults to tooltip-delay-hide or 0ms if no input */
293
274
  hide(delay = this.hideDelay) {
@@ -305,6 +286,7 @@ class _MatTooltipBase {
305
286
  }
306
287
  /** Create the overlay config and position strategy */
307
288
  _createOverlay() {
289
+ var _a;
308
290
  if (this._overlayRef) {
309
291
  return this._overlayRef;
310
292
  }
@@ -352,6 +334,9 @@ class _MatTooltipBase {
352
334
  this._ngZone.run(() => this.hide(0));
353
335
  }
354
336
  });
337
+ if ((_a = this._defaultOptions) === null || _a === void 0 ? void 0 : _a.disableTooltipInteractivity) {
338
+ this._overlayRef.addPanelClass(`${this._cssClassPrefix}-tooltip-panel-non-interactive`);
339
+ }
355
340
  return this._overlayRef;
356
341
  }
357
342
  /** Detaches the currently-attached tooltip. */
@@ -548,7 +533,16 @@ class _MatTooltipBase {
548
533
  this._pointerExitEventsInitialized = true;
549
534
  const exitListeners = [];
550
535
  if (this._platformSupportsMouseEvents()) {
551
- exitListeners.push(['mouseleave', () => this.hide()], ['wheel', event => this._wheelListener(event)]);
536
+ exitListeners.push([
537
+ 'mouseleave',
538
+ event => {
539
+ var _a;
540
+ const newTarget = event.relatedTarget;
541
+ if (!newTarget || !((_a = this._overlayRef) === null || _a === void 0 ? void 0 : _a.overlayElement.contains(newTarget))) {
542
+ this.hide();
543
+ }
544
+ },
545
+ ], ['wheel', event => this._wheelListener(event)]);
552
546
  }
553
547
  else if (this.touchGestures !== 'off') {
554
548
  this._disableNativeGesturesIfNecessary();
@@ -679,14 +673,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImpor
679
673
  }] }];
680
674
  } });
681
675
  class _TooltipComponentBase {
682
- constructor(_changeDetectorRef) {
676
+ constructor(_changeDetectorRef, animationMode) {
683
677
  this._changeDetectorRef = _changeDetectorRef;
684
678
  /** Property watched by the animation framework to show or hide the tooltip */
685
679
  this._visibility = 'initial';
686
680
  /** Whether interactions on the page should close the tooltip */
687
681
  this._closeOnInteraction = false;
682
+ /** Whether the tooltip is currently visible. */
683
+ this._isVisible = false;
688
684
  /** Subject for notifying that the tooltip has been hidden from the view */
689
685
  this._onHide = new Subject();
686
+ this._animationsDisabled = animationMode === 'NoopAnimations';
690
687
  }
691
688
  /**
692
689
  * Shows the tooltip with an animation originating from the provided origin
@@ -695,15 +692,9 @@ class _TooltipComponentBase {
695
692
  show(delay) {
696
693
  // Cancel the delayed hide if it is scheduled
697
694
  clearTimeout(this._hideTimeoutId);
698
- // Body interactions should cancel the tooltip if there is a delay in showing.
699
- this._closeOnInteraction = true;
700
695
  this._showTimeoutId = setTimeout(() => {
701
- this._visibility = 'visible';
696
+ this._toggleVisibility(true);
702
697
  this._showTimeoutId = undefined;
703
- this._onShow();
704
- // Mark for check so if any parent component has set the
705
- // ChangeDetectionStrategy to OnPush it will be checked anyways
706
- this._markForCheck();
707
698
  }, delay);
708
699
  }
709
700
  /**
@@ -714,11 +705,8 @@ class _TooltipComponentBase {
714
705
  // Cancel the delayed show if it is scheduled
715
706
  clearTimeout(this._showTimeoutId);
716
707
  this._hideTimeoutId = setTimeout(() => {
717
- this._visibility = 'hidden';
708
+ this._toggleVisibility(false);
718
709
  this._hideTimeoutId = undefined;
719
- // Mark for check so if any parent component has set the
720
- // ChangeDetectionStrategy to OnPush it will be checked anyways
721
- this._markForCheck();
722
710
  }, delay);
723
711
  }
724
712
  /** Returns an observable that notifies when the tooltip has been hidden from view. */
@@ -727,24 +715,13 @@ class _TooltipComponentBase {
727
715
  }
728
716
  /** Whether the tooltip is being displayed. */
729
717
  isVisible() {
730
- return this._visibility === 'visible';
718
+ return this._isVisible;
731
719
  }
732
720
  ngOnDestroy() {
733
721
  clearTimeout(this._showTimeoutId);
734
722
  clearTimeout(this._hideTimeoutId);
735
723
  this._onHide.complete();
736
- }
737
- _animationStart() {
738
- this._closeOnInteraction = false;
739
- }
740
- _animationDone(event) {
741
- const toState = event.toState;
742
- if (toState === 'hidden' && !this.isVisible()) {
743
- this._onHide.next();
744
- }
745
- if (toState === 'visible' || toState === 'hidden') {
746
- this._closeOnInteraction = true;
747
- }
724
+ this._triggerElement = null;
748
725
  }
749
726
  /**
750
727
  * Interactions on the HTML body should close the tooltip immediately as defined in the
@@ -764,41 +741,114 @@ class _TooltipComponentBase {
764
741
  _markForCheck() {
765
742
  this._changeDetectorRef.markForCheck();
766
743
  }
744
+ _handleMouseLeave({ relatedTarget }) {
745
+ if (!relatedTarget || !this._triggerElement.contains(relatedTarget)) {
746
+ this.hide(this._mouseLeaveHideDelay);
747
+ }
748
+ }
767
749
  /**
768
750
  * Callback for when the timeout in this.show() gets completed.
769
751
  * This method is only needed by the mdc-tooltip, and so it is only implemented
770
752
  * in the mdc-tooltip, not here.
771
753
  */
772
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
+ }
773
799
  }
774
- _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 });
775
801
  _TooltipComponentBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.0", type: _TooltipComponentBase, ngImport: i0 });
776
802
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: _TooltipComponentBase, decorators: [{
777
803
  type: Directive
778
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
804
+ }], ctorParameters: function () {
805
+ return [{ type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
806
+ type: Optional
807
+ }, {
808
+ type: Inject,
809
+ args: [ANIMATION_MODULE_TYPE]
810
+ }] }];
811
+ } });
779
812
  /**
780
813
  * Internal component that wraps the tooltip's content.
781
814
  * @docs-private
782
815
  */
783
816
  class TooltipComponent extends _TooltipComponentBase {
784
- constructor(changeDetectorRef, _breakpointObserver) {
785
- super(changeDetectorRef);
817
+ constructor(changeDetectorRef, _breakpointObserver, animationMode) {
818
+ super(changeDetectorRef, animationMode);
786
819
  this._breakpointObserver = _breakpointObserver;
787
820
  /** Stream that emits whether the user has a handset-sized display. */
788
821
  this._isHandset = this._breakpointObserver.observe(Breakpoints.Handset);
822
+ this._showAnimation = 'mat-tooltip-show';
823
+ this._hideAnimation = 'mat-tooltip-hide';
789
824
  }
790
825
  }
791
- 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 });
792
- TooltipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.0", type: TooltipComponent, selector: "mat-tooltip-component", host: { attributes: { "aria-hidden": "true" }, properties: { "style.zoom": "_visibility === \"visible\" ? 1 : null" } }, usesInheritance: true, ngImport: i0, template: "<div class=\"mat-tooltip\"\n [ngClass]=\"tooltipClass\"\n [class.mat-tooltip-handset]=\"(_isHandset | async)?.matches\"\n [@state]=\"_visibility\"\n (@state.start)=\"_animationStart()\"\n (@state.done)=\"_animationDone($event)\">{{message}}</div>\n", styles: [".mat-tooltip-panel{pointer-events:none !important}.mat-tooltip{color:#fff;border-radius:4px;margin:14px;max-width:250px;padding-left:8px;padding-right:8px;overflow:hidden;text-overflow:ellipsis}.cdk-high-contrast-active .mat-tooltip{outline:solid 1px}.mat-tooltip-handset{margin:24px;padding-left:16px;padding-right:16px}\n"], directives: [{ type: i7.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], pipes: { "async": i7.AsyncPipe }, animations: [matTooltipAnimations.tooltipState], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
826
+ 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 });
827
+ 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 });
793
828
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImport: i0, type: TooltipComponent, decorators: [{
794
829
  type: Component,
795
- args: [{ selector: 'mat-tooltip-component', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, animations: [matTooltipAnimations.tooltipState], host: {
830
+ args: [{ selector: 'mat-tooltip-component', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: {
796
831
  // Forces the element to have a layout in IE and Edge. This fixes issues where the element
797
832
  // won't be rendered if the animations are disabled or there is no web animations polyfill.
798
- '[style.zoom]': '_visibility === "visible" ? 1 : null',
833
+ '[style.zoom]': 'isVisible() ? 1 : null',
834
+ '(mouseleave)': '_handleMouseLeave($event)',
799
835
  'aria-hidden': 'true',
800
- }, template: "<div class=\"mat-tooltip\"\n [ngClass]=\"tooltipClass\"\n [class.mat-tooltip-handset]=\"(_isHandset | async)?.matches\"\n [@state]=\"_visibility\"\n (@state.start)=\"_animationStart()\"\n (@state.done)=\"_animationDone($event)\">{{message}}</div>\n", styles: [".mat-tooltip-panel{pointer-events:none !important}.mat-tooltip{color:#fff;border-radius:4px;margin:14px;max-width:250px;padding-left:8px;padding-right:8px;overflow:hidden;text-overflow:ellipsis}.cdk-high-contrast-active .mat-tooltip{outline:solid 1px}.mat-tooltip-handset{margin:24px;padding-left:16px;padding-right:16px}\n"] }]
801
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i6.BreakpointObserver }]; } });
836
+ }, 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"] }]
837
+ }], ctorParameters: function () {
838
+ return [{ type: i0.ChangeDetectorRef }, { type: i6.BreakpointObserver }, { type: undefined, decorators: [{
839
+ type: Optional
840
+ }, {
841
+ type: Inject,
842
+ args: [ANIMATION_MODULE_TYPE]
843
+ }] }];
844
+ }, propDecorators: { _tooltip: [{
845
+ type: ViewChild,
846
+ args: ['tooltip', {
847
+ // Use a static query here since we interact directly with
848
+ // the DOM which can happen before `ngAfterViewInit`.
849
+ static: true,
850
+ }]
851
+ }] } });
802
852
 
803
853
  /**
804
854
  * @license
@@ -822,6 +872,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.0", ngImpor
822
872
  }]
823
873
  }] });
824
874
 
875
+ /**
876
+ * @license
877
+ * Copyright Google LLC All Rights Reserved.
878
+ *
879
+ * Use of this source code is governed by an MIT-style license that can be
880
+ * found in the LICENSE file at https://angular.io/license
881
+ */
882
+ /**
883
+ * Animations used by MatTooltip.
884
+ * @docs-private
885
+ */
886
+ const matTooltipAnimations = {
887
+ /** Animation that transitions a tooltip in and out. */
888
+ tooltipState: trigger('state', [
889
+ state('initial, void, hidden', style({ opacity: 0, transform: 'scale(0)' })),
890
+ state('visible', style({ transform: 'scale(1)' })),
891
+ transition('* => visible', animate('200ms cubic-bezier(0, 0, 0.2, 1)', keyframes([
892
+ style({ opacity: 0, transform: 'scale(0)', offset: 0 }),
893
+ style({ opacity: 0.5, transform: 'scale(0.99)', offset: 0.5 }),
894
+ style({ opacity: 1, transform: 'scale(1)', offset: 1 }),
895
+ ]))),
896
+ transition('* => hidden', animate('100ms cubic-bezier(0, 0, 0.2, 1)', style({ opacity: 0 }))),
897
+ ]),
898
+ };
899
+
825
900
  /**
826
901
  * @license
827
902
  * Copyright Google LLC All Rights Reserved.