1 | (function (global, factory) {
|
---|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/overlay'), require('@angular/cdk/a11y'), require('@angular/common'), require('@angular/core'), require('@angular/material/core'), require('@angular/cdk/scrolling'), require('@angular/cdk/bidi'), require('@angular/cdk/coercion'), require('@angular/cdk/keycodes'), require('@angular/cdk/layout'), require('@angular/cdk/platform'), require('@angular/cdk/portal'), require('rxjs'), require('rxjs/operators'), require('@angular/animations')) :
|
---|
3 | typeof define === 'function' && define.amd ? define('@angular/material/tooltip', ['exports', '@angular/cdk/overlay', '@angular/cdk/a11y', '@angular/common', '@angular/core', '@angular/material/core', '@angular/cdk/scrolling', '@angular/cdk/bidi', '@angular/cdk/coercion', '@angular/cdk/keycodes', '@angular/cdk/layout', '@angular/cdk/platform', '@angular/cdk/portal', 'rxjs', 'rxjs/operators', '@angular/animations'], factory) :
|
---|
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.tooltip = {}), global.ng.cdk.overlay, global.ng.cdk.a11y, global.ng.common, global.ng.core, global.ng.material.core, global.ng.cdk.scrolling, global.ng.cdk.bidi, global.ng.cdk.coercion, global.ng.cdk.keycodes, global.ng.cdk.layout, global.ng.cdk.platform, global.ng.cdk.portal, global.rxjs, global.rxjs.operators, global.ng.animations));
|
---|
5 | }(this, (function (exports, overlay, a11y, common, core, core$1, scrolling, bidi, coercion, keycodes, layout, platform, portal, rxjs, operators, animations) { 'use strict';
|
---|
6 |
|
---|
7 | /*! *****************************************************************************
|
---|
8 | Copyright (c) Microsoft Corporation.
|
---|
9 |
|
---|
10 | Permission to use, copy, modify, and/or distribute this software for any
|
---|
11 | purpose with or without fee is hereby granted.
|
---|
12 |
|
---|
13 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
---|
14 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
15 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
---|
16 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
---|
17 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
---|
18 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
---|
19 | PERFORMANCE OF THIS SOFTWARE.
|
---|
20 | ***************************************************************************** */
|
---|
21 | /* global Reflect, Promise */
|
---|
22 | var extendStatics = function (d, b) {
|
---|
23 | extendStatics = Object.setPrototypeOf ||
|
---|
24 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
---|
25 | function (d, b) { for (var p in b)
|
---|
26 | if (Object.prototype.hasOwnProperty.call(b, p))
|
---|
27 | d[p] = b[p]; };
|
---|
28 | return extendStatics(d, b);
|
---|
29 | };
|
---|
30 | function __extends(d, b) {
|
---|
31 | if (typeof b !== "function" && b !== null)
|
---|
32 | throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
---|
33 | extendStatics(d, b);
|
---|
34 | function __() { this.constructor = d; }
|
---|
35 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
---|
36 | }
|
---|
37 | var __assign = function () {
|
---|
38 | __assign = Object.assign || function __assign(t) {
|
---|
39 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
---|
40 | s = arguments[i];
|
---|
41 | for (var p in s)
|
---|
42 | if (Object.prototype.hasOwnProperty.call(s, p))
|
---|
43 | t[p] = s[p];
|
---|
44 | }
|
---|
45 | return t;
|
---|
46 | };
|
---|
47 | return __assign.apply(this, arguments);
|
---|
48 | };
|
---|
49 | function __rest(s, e) {
|
---|
50 | var t = {};
|
---|
51 | for (var p in s)
|
---|
52 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
---|
53 | t[p] = s[p];
|
---|
54 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
---|
55 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
---|
56 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
---|
57 | t[p[i]] = s[p[i]];
|
---|
58 | }
|
---|
59 | return t;
|
---|
60 | }
|
---|
61 | function __decorate(decorators, target, key, desc) {
|
---|
62 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
---|
63 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
---|
64 | r = Reflect.decorate(decorators, target, key, desc);
|
---|
65 | else
|
---|
66 | for (var i = decorators.length - 1; i >= 0; i--)
|
---|
67 | if (d = decorators[i])
|
---|
68 | r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
---|
69 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
---|
70 | }
|
---|
71 | function __param(paramIndex, decorator) {
|
---|
72 | return function (target, key) { decorator(target, key, paramIndex); };
|
---|
73 | }
|
---|
74 | function __metadata(metadataKey, metadataValue) {
|
---|
75 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
---|
76 | return Reflect.metadata(metadataKey, metadataValue);
|
---|
77 | }
|
---|
78 | function __awaiter(thisArg, _arguments, P, generator) {
|
---|
79 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
---|
80 | return new (P || (P = Promise))(function (resolve, reject) {
|
---|
81 | function fulfilled(value) { try {
|
---|
82 | step(generator.next(value));
|
---|
83 | }
|
---|
84 | catch (e) {
|
---|
85 | reject(e);
|
---|
86 | } }
|
---|
87 | function rejected(value) { try {
|
---|
88 | step(generator["throw"](value));
|
---|
89 | }
|
---|
90 | catch (e) {
|
---|
91 | reject(e);
|
---|
92 | } }
|
---|
93 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
---|
94 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
---|
95 | });
|
---|
96 | }
|
---|
97 | function __generator(thisArg, body) {
|
---|
98 | var _ = { label: 0, sent: function () { if (t[0] & 1)
|
---|
99 | throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
---|
100 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
---|
101 | function verb(n) { return function (v) { return step([n, v]); }; }
|
---|
102 | function step(op) {
|
---|
103 | if (f)
|
---|
104 | throw new TypeError("Generator is already executing.");
|
---|
105 | while (_)
|
---|
106 | try {
|
---|
107 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
---|
108 | return t;
|
---|
109 | if (y = 0, t)
|
---|
110 | op = [op[0] & 2, t.value];
|
---|
111 | switch (op[0]) {
|
---|
112 | case 0:
|
---|
113 | case 1:
|
---|
114 | t = op;
|
---|
115 | break;
|
---|
116 | case 4:
|
---|
117 | _.label++;
|
---|
118 | return { value: op[1], done: false };
|
---|
119 | case 5:
|
---|
120 | _.label++;
|
---|
121 | y = op[1];
|
---|
122 | op = [0];
|
---|
123 | continue;
|
---|
124 | case 7:
|
---|
125 | op = _.ops.pop();
|
---|
126 | _.trys.pop();
|
---|
127 | continue;
|
---|
128 | default:
|
---|
129 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
---|
130 | _ = 0;
|
---|
131 | continue;
|
---|
132 | }
|
---|
133 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
---|
134 | _.label = op[1];
|
---|
135 | break;
|
---|
136 | }
|
---|
137 | if (op[0] === 6 && _.label < t[1]) {
|
---|
138 | _.label = t[1];
|
---|
139 | t = op;
|
---|
140 | break;
|
---|
141 | }
|
---|
142 | if (t && _.label < t[2]) {
|
---|
143 | _.label = t[2];
|
---|
144 | _.ops.push(op);
|
---|
145 | break;
|
---|
146 | }
|
---|
147 | if (t[2])
|
---|
148 | _.ops.pop();
|
---|
149 | _.trys.pop();
|
---|
150 | continue;
|
---|
151 | }
|
---|
152 | op = body.call(thisArg, _);
|
---|
153 | }
|
---|
154 | catch (e) {
|
---|
155 | op = [6, e];
|
---|
156 | y = 0;
|
---|
157 | }
|
---|
158 | finally {
|
---|
159 | f = t = 0;
|
---|
160 | }
|
---|
161 | if (op[0] & 5)
|
---|
162 | throw op[1];
|
---|
163 | return { value: op[0] ? op[1] : void 0, done: true };
|
---|
164 | }
|
---|
165 | }
|
---|
166 | var __createBinding = Object.create ? (function (o, m, k, k2) {
|
---|
167 | if (k2 === undefined)
|
---|
168 | k2 = k;
|
---|
169 | Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
---|
170 | }) : (function (o, m, k, k2) {
|
---|
171 | if (k2 === undefined)
|
---|
172 | k2 = k;
|
---|
173 | o[k2] = m[k];
|
---|
174 | });
|
---|
175 | function __exportStar(m, o) {
|
---|
176 | for (var p in m)
|
---|
177 | if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
---|
178 | __createBinding(o, m, p);
|
---|
179 | }
|
---|
180 | function __values(o) {
|
---|
181 | var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
---|
182 | if (m)
|
---|
183 | return m.call(o);
|
---|
184 | if (o && typeof o.length === "number")
|
---|
185 | return {
|
---|
186 | next: function () {
|
---|
187 | if (o && i >= o.length)
|
---|
188 | o = void 0;
|
---|
189 | return { value: o && o[i++], done: !o };
|
---|
190 | }
|
---|
191 | };
|
---|
192 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
---|
193 | }
|
---|
194 | function __read(o, n) {
|
---|
195 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
---|
196 | if (!m)
|
---|
197 | return o;
|
---|
198 | var i = m.call(o), r, ar = [], e;
|
---|
199 | try {
|
---|
200 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
---|
201 | ar.push(r.value);
|
---|
202 | }
|
---|
203 | catch (error) {
|
---|
204 | e = { error: error };
|
---|
205 | }
|
---|
206 | finally {
|
---|
207 | try {
|
---|
208 | if (r && !r.done && (m = i["return"]))
|
---|
209 | m.call(i);
|
---|
210 | }
|
---|
211 | finally {
|
---|
212 | if (e)
|
---|
213 | throw e.error;
|
---|
214 | }
|
---|
215 | }
|
---|
216 | return ar;
|
---|
217 | }
|
---|
218 | /** @deprecated */
|
---|
219 | function __spread() {
|
---|
220 | for (var ar = [], i = 0; i < arguments.length; i++)
|
---|
221 | ar = ar.concat(__read(arguments[i]));
|
---|
222 | return ar;
|
---|
223 | }
|
---|
224 | /** @deprecated */
|
---|
225 | function __spreadArrays() {
|
---|
226 | for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
---|
227 | s += arguments[i].length;
|
---|
228 | for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
---|
229 | for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
---|
230 | r[k] = a[j];
|
---|
231 | return r;
|
---|
232 | }
|
---|
233 | function __spreadArray(to, from, pack) {
|
---|
234 | if (pack || arguments.length === 2)
|
---|
235 | for (var i = 0, l = from.length, ar; i < l; i++) {
|
---|
236 | if (ar || !(i in from)) {
|
---|
237 | if (!ar)
|
---|
238 | ar = Array.prototype.slice.call(from, 0, i);
|
---|
239 | ar[i] = from[i];
|
---|
240 | }
|
---|
241 | }
|
---|
242 | return to.concat(ar || from);
|
---|
243 | }
|
---|
244 | function __await(v) {
|
---|
245 | return this instanceof __await ? (this.v = v, this) : new __await(v);
|
---|
246 | }
|
---|
247 | function __asyncGenerator(thisArg, _arguments, generator) {
|
---|
248 | if (!Symbol.asyncIterator)
|
---|
249 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
---|
250 | var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
---|
251 | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
---|
252 | function verb(n) { if (g[n])
|
---|
253 | i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
---|
254 | function resume(n, v) { try {
|
---|
255 | step(g[n](v));
|
---|
256 | }
|
---|
257 | catch (e) {
|
---|
258 | settle(q[0][3], e);
|
---|
259 | } }
|
---|
260 | function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
---|
261 | function fulfill(value) { resume("next", value); }
|
---|
262 | function reject(value) { resume("throw", value); }
|
---|
263 | function settle(f, v) { if (f(v), q.shift(), q.length)
|
---|
264 | resume(q[0][0], q[0][1]); }
|
---|
265 | }
|
---|
266 | function __asyncDelegator(o) {
|
---|
267 | var i, p;
|
---|
268 | return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
---|
269 | function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
---|
270 | }
|
---|
271 | function __asyncValues(o) {
|
---|
272 | if (!Symbol.asyncIterator)
|
---|
273 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
---|
274 | var m = o[Symbol.asyncIterator], i;
|
---|
275 | return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
---|
276 | function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
---|
277 | function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
---|
278 | }
|
---|
279 | function __makeTemplateObject(cooked, raw) {
|
---|
280 | if (Object.defineProperty) {
|
---|
281 | Object.defineProperty(cooked, "raw", { value: raw });
|
---|
282 | }
|
---|
283 | else {
|
---|
284 | cooked.raw = raw;
|
---|
285 | }
|
---|
286 | return cooked;
|
---|
287 | }
|
---|
288 | ;
|
---|
289 | var __setModuleDefault = Object.create ? (function (o, v) {
|
---|
290 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
---|
291 | }) : function (o, v) {
|
---|
292 | o["default"] = v;
|
---|
293 | };
|
---|
294 | function __importStar(mod) {
|
---|
295 | if (mod && mod.__esModule)
|
---|
296 | return mod;
|
---|
297 | var result = {};
|
---|
298 | if (mod != null)
|
---|
299 | for (var k in mod)
|
---|
300 | if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
---|
301 | __createBinding(result, mod, k);
|
---|
302 | __setModuleDefault(result, mod);
|
---|
303 | return result;
|
---|
304 | }
|
---|
305 | function __importDefault(mod) {
|
---|
306 | return (mod && mod.__esModule) ? mod : { default: mod };
|
---|
307 | }
|
---|
308 | function __classPrivateFieldGet(receiver, state, kind, f) {
|
---|
309 | if (kind === "a" && !f)
|
---|
310 | throw new TypeError("Private accessor was defined without a getter");
|
---|
311 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
---|
312 | throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
---|
313 | return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
---|
314 | }
|
---|
315 | function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
---|
316 | if (kind === "m")
|
---|
317 | throw new TypeError("Private method is not writable");
|
---|
318 | if (kind === "a" && !f)
|
---|
319 | throw new TypeError("Private accessor was defined without a setter");
|
---|
320 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
---|
321 | throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
---|
322 | return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
---|
323 | }
|
---|
324 |
|
---|
325 | /**
|
---|
326 | * @license
|
---|
327 | * Copyright Google LLC All Rights Reserved.
|
---|
328 | *
|
---|
329 | * Use of this source code is governed by an MIT-style license that can be
|
---|
330 | * found in the LICENSE file at https://angular.io/license
|
---|
331 | */
|
---|
332 | /**
|
---|
333 | * Animations used by MatTooltip.
|
---|
334 | * @docs-private
|
---|
335 | */
|
---|
336 | var matTooltipAnimations = {
|
---|
337 | /** Animation that transitions a tooltip in and out. */
|
---|
338 | tooltipState: animations.trigger('state', [
|
---|
339 | animations.state('initial, void, hidden', animations.style({ opacity: 0, transform: 'scale(0)' })),
|
---|
340 | animations.state('visible', animations.style({ transform: 'scale(1)' })),
|
---|
341 | animations.transition('* => visible', animations.animate('200ms cubic-bezier(0, 0, 0.2, 1)', animations.keyframes([
|
---|
342 | animations.style({ opacity: 0, transform: 'scale(0)', offset: 0 }),
|
---|
343 | animations.style({ opacity: 0.5, transform: 'scale(0.99)', offset: 0.5 }),
|
---|
344 | animations.style({ opacity: 1, transform: 'scale(1)', offset: 1 })
|
---|
345 | ]))),
|
---|
346 | animations.transition('* => hidden', animations.animate('100ms cubic-bezier(0, 0, 0.2, 1)', animations.style({ opacity: 0 }))),
|
---|
347 | ])
|
---|
348 | };
|
---|
349 |
|
---|
350 | /** Time in ms to throttle repositioning after scroll events. */
|
---|
351 | var SCROLL_THROTTLE_MS = 20;
|
---|
352 | /**
|
---|
353 | * CSS class that will be attached to the overlay panel.
|
---|
354 | * @deprecated
|
---|
355 | * @breaking-change 13.0.0 remove this variable
|
---|
356 | */
|
---|
357 | var TOOLTIP_PANEL_CLASS = 'mat-tooltip-panel';
|
---|
358 | var PANEL_CLASS = 'tooltip-panel';
|
---|
359 | /** Options used to bind passive event listeners. */
|
---|
360 | var passiveListenerOptions = platform.normalizePassiveListenerOptions({ passive: true });
|
---|
361 | /**
|
---|
362 | * Time between the user putting the pointer on a tooltip
|
---|
363 | * trigger and the long press event being fired.
|
---|
364 | */
|
---|
365 | var LONGPRESS_DELAY = 500;
|
---|
366 | /**
|
---|
367 | * Creates an error to be thrown if the user supplied an invalid tooltip position.
|
---|
368 | * @docs-private
|
---|
369 | */
|
---|
370 | function getMatTooltipInvalidPositionError(position) {
|
---|
371 | return Error("Tooltip position \"" + position + "\" is invalid.");
|
---|
372 | }
|
---|
373 | /** Injection token that determines the scroll handling while a tooltip is visible. */
|
---|
374 | var MAT_TOOLTIP_SCROLL_STRATEGY = new core.InjectionToken('mat-tooltip-scroll-strategy');
|
---|
375 | /** @docs-private */
|
---|
376 | function MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY(overlay) {
|
---|
377 | return function () { return overlay.scrollStrategies.reposition({ scrollThrottle: SCROLL_THROTTLE_MS }); };
|
---|
378 | }
|
---|
379 | /** @docs-private */
|
---|
380 | var MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER = {
|
---|
381 | provide: MAT_TOOLTIP_SCROLL_STRATEGY,
|
---|
382 | deps: [overlay.Overlay],
|
---|
383 | useFactory: MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY,
|
---|
384 | };
|
---|
385 | /** Injection token to be used to override the default options for `matTooltip`. */
|
---|
386 | var MAT_TOOLTIP_DEFAULT_OPTIONS = new core.InjectionToken('mat-tooltip-default-options', {
|
---|
387 | providedIn: 'root',
|
---|
388 | factory: MAT_TOOLTIP_DEFAULT_OPTIONS_FACTORY
|
---|
389 | });
|
---|
390 | /** @docs-private */
|
---|
391 | function MAT_TOOLTIP_DEFAULT_OPTIONS_FACTORY() {
|
---|
392 | return {
|
---|
393 | showDelay: 0,
|
---|
394 | hideDelay: 0,
|
---|
395 | touchendHideDelay: 1500,
|
---|
396 | };
|
---|
397 | }
|
---|
398 | var _MatTooltipBase = /** @class */ (function () {
|
---|
399 | function _MatTooltipBase(_overlay, _elementRef, _scrollDispatcher, _viewContainerRef, _ngZone, _platform, _ariaDescriber, _focusMonitor, scrollStrategy, _dir, _defaultOptions, _document) {
|
---|
400 | var _this = this;
|
---|
401 | this._overlay = _overlay;
|
---|
402 | this._elementRef = _elementRef;
|
---|
403 | this._scrollDispatcher = _scrollDispatcher;
|
---|
404 | this._viewContainerRef = _viewContainerRef;
|
---|
405 | this._ngZone = _ngZone;
|
---|
406 | this._platform = _platform;
|
---|
407 | this._ariaDescriber = _ariaDescriber;
|
---|
408 | this._focusMonitor = _focusMonitor;
|
---|
409 | this._dir = _dir;
|
---|
410 | this._defaultOptions = _defaultOptions;
|
---|
411 | this._position = 'below';
|
---|
412 | this._disabled = false;
|
---|
413 | this._viewInitialized = false;
|
---|
414 | this._pointerExitEventsInitialized = false;
|
---|
415 | this._viewportMargin = 8;
|
---|
416 | this._cssClassPrefix = 'mat';
|
---|
417 | /** The default delay in ms before showing the tooltip after show is called */
|
---|
418 | this.showDelay = this._defaultOptions.showDelay;
|
---|
419 | /** The default delay in ms before hiding the tooltip after hide is called */
|
---|
420 | this.hideDelay = this._defaultOptions.hideDelay;
|
---|
421 | /**
|
---|
422 | * How touch gestures should be handled by the tooltip. On touch devices the tooltip directive
|
---|
423 | * uses a long press gesture to show and hide, however it can conflict with the native browser
|
---|
424 | * gestures. To work around the conflict, Angular Material disables native gestures on the
|
---|
425 | * trigger, but that might not be desirable on particular elements (e.g. inputs and draggable
|
---|
426 | * elements). The different values for this option configure the touch event handling as follows:
|
---|
427 | * - `auto` - Enables touch gestures for all elements, but tries to avoid conflicts with native
|
---|
428 | * browser gestures on particular elements. In particular, it allows text selection on inputs
|
---|
429 | * and textareas, and preserves the native browser dragging on elements marked as `draggable`.
|
---|
430 | * - `on` - Enables touch gestures for all elements and disables native
|
---|
431 | * browser gestures with no exceptions.
|
---|
432 | * - `off` - Disables touch gestures. Note that this will prevent the tooltip from
|
---|
433 | * showing on touch devices.
|
---|
434 | */
|
---|
435 | this.touchGestures = 'auto';
|
---|
436 | this._message = '';
|
---|
437 | /** Manually-bound passive event listeners. */
|
---|
438 | this._passiveListeners = [];
|
---|
439 | /** Emits when the component is destroyed. */
|
---|
440 | this._destroyed = new rxjs.Subject();
|
---|
441 | /**
|
---|
442 | * Handles the keydown events on the host element.
|
---|
443 | * Needs to be an arrow function so that we can use it in addEventListener.
|
---|
444 | */
|
---|
445 | this._handleKeydown = function (event) {
|
---|
446 | if (_this._isTooltipVisible() && event.keyCode === keycodes.ESCAPE && !keycodes.hasModifierKey(event)) {
|
---|
447 | event.preventDefault();
|
---|
448 | event.stopPropagation();
|
---|
449 | _this._ngZone.run(function () { return _this.hide(0); });
|
---|
450 | }
|
---|
451 | };
|
---|
452 | this._scrollStrategy = scrollStrategy;
|
---|
453 | this._document = _document;
|
---|
454 | if (_defaultOptions) {
|
---|
455 | if (_defaultOptions.position) {
|
---|
456 | this.position = _defaultOptions.position;
|
---|
457 | }
|
---|
458 | if (_defaultOptions.touchGestures) {
|
---|
459 | this.touchGestures = _defaultOptions.touchGestures;
|
---|
460 | }
|
---|
461 | }
|
---|
462 | _dir.change.pipe(operators.takeUntil(this._destroyed)).subscribe(function () {
|
---|
463 | if (_this._overlayRef) {
|
---|
464 | _this._updatePosition(_this._overlayRef);
|
---|
465 | }
|
---|
466 | });
|
---|
467 | _ngZone.runOutsideAngular(function () {
|
---|
468 | _elementRef.nativeElement.addEventListener('keydown', _this._handleKeydown);
|
---|
469 | });
|
---|
470 | }
|
---|
471 | Object.defineProperty(_MatTooltipBase.prototype, "position", {
|
---|
472 | /** Allows the user to define the position of the tooltip relative to the parent element */
|
---|
473 | get: function () { return this._position; },
|
---|
474 | set: function (value) {
|
---|
475 | var _a;
|
---|
476 | if (value !== this._position) {
|
---|
477 | this._position = value;
|
---|
478 | if (this._overlayRef) {
|
---|
479 | this._updatePosition(this._overlayRef);
|
---|
480 | (_a = this._tooltipInstance) === null || _a === void 0 ? void 0 : _a.show(0);
|
---|
481 | this._overlayRef.updatePosition();
|
---|
482 | }
|
---|
483 | }
|
---|
484 | },
|
---|
485 | enumerable: false,
|
---|
486 | configurable: true
|
---|
487 | });
|
---|
488 | Object.defineProperty(_MatTooltipBase.prototype, "disabled", {
|
---|
489 | /** Disables the display of the tooltip. */
|
---|
490 | get: function () { return this._disabled; },
|
---|
491 | set: function (value) {
|
---|
492 | this._disabled = coercion.coerceBooleanProperty(value);
|
---|
493 | // If tooltip is disabled, hide immediately.
|
---|
494 | if (this._disabled) {
|
---|
495 | this.hide(0);
|
---|
496 | }
|
---|
497 | else {
|
---|
498 | this._setupPointerEnterEventsIfNeeded();
|
---|
499 | }
|
---|
500 | },
|
---|
501 | enumerable: false,
|
---|
502 | configurable: true
|
---|
503 | });
|
---|
504 | Object.defineProperty(_MatTooltipBase.prototype, "message", {
|
---|
505 | /** The message to be displayed in the tooltip */
|
---|
506 | get: function () { return this._message; },
|
---|
507 | set: function (value) {
|
---|
508 | var _this = this;
|
---|
509 | this._ariaDescriber.removeDescription(this._elementRef.nativeElement, this._message, 'tooltip');
|
---|
510 | // If the message is not a string (e.g. number), convert it to a string and trim it.
|
---|
511 | // Must convert with `String(value)`, not `${value}`, otherwise Closure Compiler optimises
|
---|
512 | // away the string-conversion: https://github.com/angular/components/issues/20684
|
---|
513 | this._message = value != null ? String(value).trim() : '';
|
---|
514 | if (!this._message && this._isTooltipVisible()) {
|
---|
515 | this.hide(0);
|
---|
516 | }
|
---|
517 | else {
|
---|
518 | this._setupPointerEnterEventsIfNeeded();
|
---|
519 | this._updateTooltipMessage();
|
---|
520 | this._ngZone.runOutsideAngular(function () {
|
---|
521 | // The `AriaDescriber` has some functionality that avoids adding a description if it's the
|
---|
522 | // same as the `aria-label` of an element, however we can't know whether the tooltip trigger
|
---|
523 | // has a data-bound `aria-label` or when it'll be set for the first time. We can avoid the
|
---|
524 | // issue by deferring the description by a tick so Angular has time to set the `aria-label`.
|
---|
525 | Promise.resolve().then(function () {
|
---|
526 | _this._ariaDescriber.describe(_this._elementRef.nativeElement, _this.message, 'tooltip');
|
---|
527 | });
|
---|
528 | });
|
---|
529 | }
|
---|
530 | },
|
---|
531 | enumerable: false,
|
---|
532 | configurable: true
|
---|
533 | });
|
---|
534 | Object.defineProperty(_MatTooltipBase.prototype, "tooltipClass", {
|
---|
535 | /** Classes to be passed to the tooltip. Supports the same syntax as `ngClass`. */
|
---|
536 | get: function () { return this._tooltipClass; },
|
---|
537 | set: function (value) {
|
---|
538 | this._tooltipClass = value;
|
---|
539 | if (this._tooltipInstance) {
|
---|
540 | this._setTooltipClass(this._tooltipClass);
|
---|
541 | }
|
---|
542 | },
|
---|
543 | enumerable: false,
|
---|
544 | configurable: true
|
---|
545 | });
|
---|
546 | _MatTooltipBase.prototype.ngAfterViewInit = function () {
|
---|
547 | var _this = this;
|
---|
548 | // This needs to happen after view init so the initial values for all inputs have been set.
|
---|
549 | this._viewInitialized = true;
|
---|
550 | this._setupPointerEnterEventsIfNeeded();
|
---|
551 | this._focusMonitor.monitor(this._elementRef)
|
---|
552 | .pipe(operators.takeUntil(this._destroyed))
|
---|
553 | .subscribe(function (origin) {
|
---|
554 | // Note that the focus monitor runs outside the Angular zone.
|
---|
555 | if (!origin) {
|
---|
556 | _this._ngZone.run(function () { return _this.hide(0); });
|
---|
557 | }
|
---|
558 | else if (origin === 'keyboard') {
|
---|
559 | _this._ngZone.run(function () { return _this.show(); });
|
---|
560 | }
|
---|
561 | });
|
---|
562 | };
|
---|
563 | /**
|
---|
564 | * Dispose the tooltip when destroyed.
|
---|
565 | */
|
---|
566 | _MatTooltipBase.prototype.ngOnDestroy = function () {
|
---|
567 | var nativeElement = this._elementRef.nativeElement;
|
---|
568 | clearTimeout(this._touchstartTimeout);
|
---|
569 | if (this._overlayRef) {
|
---|
570 | this._overlayRef.dispose();
|
---|
571 | this._tooltipInstance = null;
|
---|
572 | }
|
---|
573 | // Clean up the event listeners set in the constructor
|
---|
574 | nativeElement.removeEventListener('keydown', this._handleKeydown);
|
---|
575 | this._passiveListeners.forEach(function (_b) {
|
---|
576 | var _c = __read(_b, 2), event = _c[0], listener = _c[1];
|
---|
577 | nativeElement.removeEventListener(event, listener, passiveListenerOptions);
|
---|
578 | });
|
---|
579 | this._passiveListeners.length = 0;
|
---|
580 | this._destroyed.next();
|
---|
581 | this._destroyed.complete();
|
---|
582 | this._ariaDescriber.removeDescription(nativeElement, this.message, 'tooltip');
|
---|
583 | this._focusMonitor.stopMonitoring(nativeElement);
|
---|
584 | };
|
---|
585 | /** Shows the tooltip after the delay in ms, defaults to tooltip-delay-show or 0ms if no input */
|
---|
586 | _MatTooltipBase.prototype.show = function (delay) {
|
---|
587 | var _this = this;
|
---|
588 | if (delay === void 0) { delay = this.showDelay; }
|
---|
589 | if (this.disabled || !this.message || (this._isTooltipVisible() &&
|
---|
590 | !this._tooltipInstance._showTimeoutId && !this._tooltipInstance._hideTimeoutId)) {
|
---|
591 | return;
|
---|
592 | }
|
---|
593 | var overlayRef = this._createOverlay();
|
---|
594 | this._detach();
|
---|
595 | this._portal = this._portal ||
|
---|
596 | new portal.ComponentPortal(this._tooltipComponent, this._viewContainerRef);
|
---|
597 | this._tooltipInstance = overlayRef.attach(this._portal).instance;
|
---|
598 | this._tooltipInstance.afterHidden()
|
---|
599 | .pipe(operators.takeUntil(this._destroyed))
|
---|
600 | .subscribe(function () { return _this._detach(); });
|
---|
601 | this._setTooltipClass(this._tooltipClass);
|
---|
602 | this._updateTooltipMessage();
|
---|
603 | this._tooltipInstance.show(delay);
|
---|
604 | };
|
---|
605 | /** Hides the tooltip after the delay in ms, defaults to tooltip-delay-hide or 0ms if no input */
|
---|
606 | _MatTooltipBase.prototype.hide = function (delay) {
|
---|
607 | if (delay === void 0) { delay = this.hideDelay; }
|
---|
608 | if (this._tooltipInstance) {
|
---|
609 | this._tooltipInstance.hide(delay);
|
---|
610 | }
|
---|
611 | };
|
---|
612 | /** Shows/hides the tooltip */
|
---|
613 | _MatTooltipBase.prototype.toggle = function () {
|
---|
614 | this._isTooltipVisible() ? this.hide() : this.show();
|
---|
615 | };
|
---|
616 | /** Returns true if the tooltip is currently visible to the user */
|
---|
617 | _MatTooltipBase.prototype._isTooltipVisible = function () {
|
---|
618 | return !!this._tooltipInstance && this._tooltipInstance.isVisible();
|
---|
619 | };
|
---|
620 | /** Create the overlay config and position strategy */
|
---|
621 | _MatTooltipBase.prototype._createOverlay = function () {
|
---|
622 | var _this = this;
|
---|
623 | if (this._overlayRef) {
|
---|
624 | return this._overlayRef;
|
---|
625 | }
|
---|
626 | var scrollableAncestors = this._scrollDispatcher.getAncestorScrollContainers(this._elementRef);
|
---|
627 | // Create connected position strategy that listens for scroll events to reposition.
|
---|
628 | var strategy = this._overlay.position()
|
---|
629 | .flexibleConnectedTo(this._elementRef)
|
---|
630 | .withTransformOriginOn("." + this._cssClassPrefix + "-tooltip")
|
---|
631 | .withFlexibleDimensions(false)
|
---|
632 | .withViewportMargin(this._viewportMargin)
|
---|
633 | .withScrollableContainers(scrollableAncestors);
|
---|
634 | strategy.positionChanges.pipe(operators.takeUntil(this._destroyed)).subscribe(function (change) {
|
---|
635 | _this._updateCurrentPositionClass(change.connectionPair);
|
---|
636 | if (_this._tooltipInstance) {
|
---|
637 | if (change.scrollableViewProperties.isOverlayClipped && _this._tooltipInstance.isVisible()) {
|
---|
638 | // After position changes occur and the overlay is clipped by
|
---|
639 | // a parent scrollable then close the tooltip.
|
---|
640 | _this._ngZone.run(function () { return _this.hide(0); });
|
---|
641 | }
|
---|
642 | }
|
---|
643 | });
|
---|
644 | this._overlayRef = this._overlay.create({
|
---|
645 | direction: this._dir,
|
---|
646 | positionStrategy: strategy,
|
---|
647 | panelClass: this._cssClassPrefix + "-" + PANEL_CLASS,
|
---|
648 | scrollStrategy: this._scrollStrategy()
|
---|
649 | });
|
---|
650 | this._updatePosition(this._overlayRef);
|
---|
651 | this._overlayRef.detachments()
|
---|
652 | .pipe(operators.takeUntil(this._destroyed))
|
---|
653 | .subscribe(function () { return _this._detach(); });
|
---|
654 | this._overlayRef.outsidePointerEvents()
|
---|
655 | .pipe(operators.takeUntil(this._destroyed))
|
---|
656 | .subscribe(function () { var _a; return (_a = _this._tooltipInstance) === null || _a === void 0 ? void 0 : _a._handleBodyInteraction(); });
|
---|
657 | return this._overlayRef;
|
---|
658 | };
|
---|
659 | /** Detaches the currently-attached tooltip. */
|
---|
660 | _MatTooltipBase.prototype._detach = function () {
|
---|
661 | if (this._overlayRef && this._overlayRef.hasAttached()) {
|
---|
662 | this._overlayRef.detach();
|
---|
663 | }
|
---|
664 | this._tooltipInstance = null;
|
---|
665 | };
|
---|
666 | /** Updates the position of the current tooltip. */
|
---|
667 | _MatTooltipBase.prototype._updatePosition = function (overlayRef) {
|
---|
668 | var position = overlayRef.getConfig().positionStrategy;
|
---|
669 | var origin = this._getOrigin();
|
---|
670 | var overlay = this._getOverlayPosition();
|
---|
671 | position.withPositions([
|
---|
672 | this._addOffset(Object.assign(Object.assign({}, origin.main), overlay.main)),
|
---|
673 | this._addOffset(Object.assign(Object.assign({}, origin.fallback), overlay.fallback))
|
---|
674 | ]);
|
---|
675 | };
|
---|
676 | /** Adds the configured offset to a position. Used as a hook for child classes. */
|
---|
677 | _MatTooltipBase.prototype._addOffset = function (position) {
|
---|
678 | return position;
|
---|
679 | };
|
---|
680 | /**
|
---|
681 | * Returns the origin position and a fallback position based on the user's position preference.
|
---|
682 | * The fallback position is the inverse of the origin (e.g. `'below' -> 'above'`).
|
---|
683 | */
|
---|
684 | _MatTooltipBase.prototype._getOrigin = function () {
|
---|
685 | var isLtr = !this._dir || this._dir.value == 'ltr';
|
---|
686 | var position = this.position;
|
---|
687 | var originPosition;
|
---|
688 | if (position == 'above' || position == 'below') {
|
---|
689 | originPosition = { originX: 'center', originY: position == 'above' ? 'top' : 'bottom' };
|
---|
690 | }
|
---|
691 | else if (position == 'before' ||
|
---|
692 | (position == 'left' && isLtr) ||
|
---|
693 | (position == 'right' && !isLtr)) {
|
---|
694 | originPosition = { originX: 'start', originY: 'center' };
|
---|
695 | }
|
---|
696 | else if (position == 'after' ||
|
---|
697 | (position == 'right' && isLtr) ||
|
---|
698 | (position == 'left' && !isLtr)) {
|
---|
699 | originPosition = { originX: 'end', originY: 'center' };
|
---|
700 | }
|
---|
701 | else if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
---|
702 | throw getMatTooltipInvalidPositionError(position);
|
---|
703 | }
|
---|
704 | var _b = this._invertPosition(originPosition.originX, originPosition.originY), x = _b.x, y = _b.y;
|
---|
705 | return {
|
---|
706 | main: originPosition,
|
---|
707 | fallback: { originX: x, originY: y }
|
---|
708 | };
|
---|
709 | };
|
---|
710 | /** Returns the overlay position and a fallback position based on the user's preference */
|
---|
711 | _MatTooltipBase.prototype._getOverlayPosition = function () {
|
---|
712 | var isLtr = !this._dir || this._dir.value == 'ltr';
|
---|
713 | var position = this.position;
|
---|
714 | var overlayPosition;
|
---|
715 | if (position == 'above') {
|
---|
716 | overlayPosition = { overlayX: 'center', overlayY: 'bottom' };
|
---|
717 | }
|
---|
718 | else if (position == 'below') {
|
---|
719 | overlayPosition = { overlayX: 'center', overlayY: 'top' };
|
---|
720 | }
|
---|
721 | else if (position == 'before' ||
|
---|
722 | (position == 'left' && isLtr) ||
|
---|
723 | (position == 'right' && !isLtr)) {
|
---|
724 | overlayPosition = { overlayX: 'end', overlayY: 'center' };
|
---|
725 | }
|
---|
726 | else if (position == 'after' ||
|
---|
727 | (position == 'right' && isLtr) ||
|
---|
728 | (position == 'left' && !isLtr)) {
|
---|
729 | overlayPosition = { overlayX: 'start', overlayY: 'center' };
|
---|
730 | }
|
---|
731 | else if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
---|
732 | throw getMatTooltipInvalidPositionError(position);
|
---|
733 | }
|
---|
734 | var _b = this._invertPosition(overlayPosition.overlayX, overlayPosition.overlayY), x = _b.x, y = _b.y;
|
---|
735 | return {
|
---|
736 | main: overlayPosition,
|
---|
737 | fallback: { overlayX: x, overlayY: y }
|
---|
738 | };
|
---|
739 | };
|
---|
740 | /** Updates the tooltip message and repositions the overlay according to the new message length */
|
---|
741 | _MatTooltipBase.prototype._updateTooltipMessage = function () {
|
---|
742 | var _this = this;
|
---|
743 | // Must wait for the message to be painted to the tooltip so that the overlay can properly
|
---|
744 | // calculate the correct positioning based on the size of the text.
|
---|
745 | if (this._tooltipInstance) {
|
---|
746 | this._tooltipInstance.message = this.message;
|
---|
747 | this._tooltipInstance._markForCheck();
|
---|
748 | this._ngZone.onMicrotaskEmpty.pipe(operators.take(1), operators.takeUntil(this._destroyed)).subscribe(function () {
|
---|
749 | if (_this._tooltipInstance) {
|
---|
750 | _this._overlayRef.updatePosition();
|
---|
751 | }
|
---|
752 | });
|
---|
753 | }
|
---|
754 | };
|
---|
755 | /** Updates the tooltip class */
|
---|
756 | _MatTooltipBase.prototype._setTooltipClass = function (tooltipClass) {
|
---|
757 | if (this._tooltipInstance) {
|
---|
758 | this._tooltipInstance.tooltipClass = tooltipClass;
|
---|
759 | this._tooltipInstance._markForCheck();
|
---|
760 | }
|
---|
761 | };
|
---|
762 | /** Inverts an overlay position. */
|
---|
763 | _MatTooltipBase.prototype._invertPosition = function (x, y) {
|
---|
764 | if (this.position === 'above' || this.position === 'below') {
|
---|
765 | if (y === 'top') {
|
---|
766 | y = 'bottom';
|
---|
767 | }
|
---|
768 | else if (y === 'bottom') {
|
---|
769 | y = 'top';
|
---|
770 | }
|
---|
771 | }
|
---|
772 | else {
|
---|
773 | if (x === 'end') {
|
---|
774 | x = 'start';
|
---|
775 | }
|
---|
776 | else if (x === 'start') {
|
---|
777 | x = 'end';
|
---|
778 | }
|
---|
779 | }
|
---|
780 | return { x: x, y: y };
|
---|
781 | };
|
---|
782 | /** Updates the class on the overlay panel based on the current position of the tooltip. */
|
---|
783 | _MatTooltipBase.prototype._updateCurrentPositionClass = function (connectionPair) {
|
---|
784 | var overlayY = connectionPair.overlayY, originX = connectionPair.originX, originY = connectionPair.originY;
|
---|
785 | var newPosition;
|
---|
786 | // If the overlay is in the middle along the Y axis,
|
---|
787 | // it means that it's either before or after.
|
---|
788 | if (overlayY === 'center') {
|
---|
789 | // Note that since this information is used for styling, we want to
|
---|
790 | // resolve `start` and `end` to their real values, otherwise consumers
|
---|
791 | // would have to remember to do it themselves on each consumption.
|
---|
792 | if (this._dir && this._dir.value === 'rtl') {
|
---|
793 | newPosition = originX === 'end' ? 'left' : 'right';
|
---|
794 | }
|
---|
795 | else {
|
---|
796 | newPosition = originX === 'start' ? 'left' : 'right';
|
---|
797 | }
|
---|
798 | }
|
---|
799 | else {
|
---|
800 | newPosition = overlayY === 'bottom' && originY === 'top' ? 'above' : 'below';
|
---|
801 | }
|
---|
802 | if (newPosition !== this._currentPosition) {
|
---|
803 | var overlayRef = this._overlayRef;
|
---|
804 | if (overlayRef) {
|
---|
805 | var classPrefix = this._cssClassPrefix + "-" + PANEL_CLASS + "-";
|
---|
806 | overlayRef.removePanelClass(classPrefix + this._currentPosition);
|
---|
807 | overlayRef.addPanelClass(classPrefix + newPosition);
|
---|
808 | }
|
---|
809 | this._currentPosition = newPosition;
|
---|
810 | }
|
---|
811 | };
|
---|
812 | /** Binds the pointer events to the tooltip trigger. */
|
---|
813 | _MatTooltipBase.prototype._setupPointerEnterEventsIfNeeded = function () {
|
---|
814 | var _this = this;
|
---|
815 | // Optimization: Defer hooking up events if there's no message or the tooltip is disabled.
|
---|
816 | if (this._disabled || !this.message || !this._viewInitialized ||
|
---|
817 | this._passiveListeners.length) {
|
---|
818 | return;
|
---|
819 | }
|
---|
820 | // The mouse events shouldn't be bound on mobile devices, because they can prevent the
|
---|
821 | // first tap from firing its click event or can cause the tooltip to open for clicks.
|
---|
822 | if (this._platformSupportsMouseEvents()) {
|
---|
823 | this._passiveListeners
|
---|
824 | .push(['mouseenter', function () {
|
---|
825 | _this._setupPointerExitEventsIfNeeded();
|
---|
826 | _this.show();
|
---|
827 | }]);
|
---|
828 | }
|
---|
829 | else if (this.touchGestures !== 'off') {
|
---|
830 | this._disableNativeGesturesIfNecessary();
|
---|
831 | this._passiveListeners
|
---|
832 | .push(['touchstart', function () {
|
---|
833 | // Note that it's important that we don't `preventDefault` here,
|
---|
834 | // because it can prevent click events from firing on the element.
|
---|
835 | _this._setupPointerExitEventsIfNeeded();
|
---|
836 | clearTimeout(_this._touchstartTimeout);
|
---|
837 | _this._touchstartTimeout = setTimeout(function () { return _this.show(); }, LONGPRESS_DELAY);
|
---|
838 | }]);
|
---|
839 | }
|
---|
840 | this._addListeners(this._passiveListeners);
|
---|
841 | };
|
---|
842 | _MatTooltipBase.prototype._setupPointerExitEventsIfNeeded = function () {
|
---|
843 | var _b;
|
---|
844 | var _this = this;
|
---|
845 | if (this._pointerExitEventsInitialized) {
|
---|
846 | return;
|
---|
847 | }
|
---|
848 | this._pointerExitEventsInitialized = true;
|
---|
849 | var exitListeners = [];
|
---|
850 | if (this._platformSupportsMouseEvents()) {
|
---|
851 | exitListeners.push(['mouseleave', function () { return _this.hide(); }], ['wheel', function (event) { return _this._wheelListener(event); }]);
|
---|
852 | }
|
---|
853 | else if (this.touchGestures !== 'off') {
|
---|
854 | this._disableNativeGesturesIfNecessary();
|
---|
855 | var touchendListener = function () {
|
---|
856 | clearTimeout(_this._touchstartTimeout);
|
---|
857 | _this.hide(_this._defaultOptions.touchendHideDelay);
|
---|
858 | };
|
---|
859 | exitListeners.push(['touchend', touchendListener], ['touchcancel', touchendListener]);
|
---|
860 | }
|
---|
861 | this._addListeners(exitListeners);
|
---|
862 | (_b = this._passiveListeners).push.apply(_b, __spreadArray([], __read(exitListeners)));
|
---|
863 | };
|
---|
864 | _MatTooltipBase.prototype._addListeners = function (listeners) {
|
---|
865 | var _this = this;
|
---|
866 | listeners.forEach(function (_b) {
|
---|
867 | var _c = __read(_b, 2), event = _c[0], listener = _c[1];
|
---|
868 | _this._elementRef.nativeElement.addEventListener(event, listener, passiveListenerOptions);
|
---|
869 | });
|
---|
870 | };
|
---|
871 | _MatTooltipBase.prototype._platformSupportsMouseEvents = function () {
|
---|
872 | return !this._platform.IOS && !this._platform.ANDROID;
|
---|
873 | };
|
---|
874 | /** Listener for the `wheel` event on the element. */
|
---|
875 | _MatTooltipBase.prototype._wheelListener = function (event) {
|
---|
876 | if (this._isTooltipVisible()) {
|
---|
877 | var elementUnderPointer = this._document.elementFromPoint(event.clientX, event.clientY);
|
---|
878 | var element = this._elementRef.nativeElement;
|
---|
879 | // On non-touch devices we depend on the `mouseleave` event to close the tooltip, but it
|
---|
880 | // won't fire if the user scrolls away using the wheel without moving their cursor. We
|
---|
881 | // work around it by finding the element under the user's cursor and closing the tooltip
|
---|
882 | // if it's not the trigger.
|
---|
883 | if (elementUnderPointer !== element && !element.contains(elementUnderPointer)) {
|
---|
884 | this.hide();
|
---|
885 | }
|
---|
886 | }
|
---|
887 | };
|
---|
888 | /** Disables the native browser gestures, based on how the tooltip has been configured. */
|
---|
889 | _MatTooltipBase.prototype._disableNativeGesturesIfNecessary = function () {
|
---|
890 | var gestures = this.touchGestures;
|
---|
891 | if (gestures !== 'off') {
|
---|
892 | var element = this._elementRef.nativeElement;
|
---|
893 | var style = element.style;
|
---|
894 | // If gestures are set to `auto`, we don't disable text selection on inputs and
|
---|
895 | // textareas, because it prevents the user from typing into them on iOS Safari.
|
---|
896 | if (gestures === 'on' || (element.nodeName !== 'INPUT' && element.nodeName !== 'TEXTAREA')) {
|
---|
897 | style.userSelect = style.msUserSelect = style.webkitUserSelect =
|
---|
898 | style.MozUserSelect = 'none';
|
---|
899 | }
|
---|
900 | // If we have `auto` gestures and the element uses native HTML dragging,
|
---|
901 | // we don't set `-webkit-user-drag` because it prevents the native behavior.
|
---|
902 | if (gestures === 'on' || !element.draggable) {
|
---|
903 | style.webkitUserDrag = 'none';
|
---|
904 | }
|
---|
905 | style.touchAction = 'none';
|
---|
906 | style.webkitTapHighlightColor = 'transparent';
|
---|
907 | }
|
---|
908 | };
|
---|
909 | return _MatTooltipBase;
|
---|
910 | }());
|
---|
911 | _MatTooltipBase.decorators = [
|
---|
912 | { type: core.Directive }
|
---|
913 | ];
|
---|
914 | _MatTooltipBase.ctorParameters = function () { return [
|
---|
915 | { type: overlay.Overlay },
|
---|
916 | { type: core.ElementRef },
|
---|
917 | { type: scrolling.ScrollDispatcher },
|
---|
918 | { type: core.ViewContainerRef },
|
---|
919 | { type: core.NgZone },
|
---|
920 | { type: platform.Platform },
|
---|
921 | { type: a11y.AriaDescriber },
|
---|
922 | { type: a11y.FocusMonitor },
|
---|
923 | { type: undefined },
|
---|
924 | { type: bidi.Directionality },
|
---|
925 | { type: undefined },
|
---|
926 | { type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] }
|
---|
927 | ]; };
|
---|
928 | _MatTooltipBase.propDecorators = {
|
---|
929 | position: [{ type: core.Input, args: ['matTooltipPosition',] }],
|
---|
930 | disabled: [{ type: core.Input, args: ['matTooltipDisabled',] }],
|
---|
931 | showDelay: [{ type: core.Input, args: ['matTooltipShowDelay',] }],
|
---|
932 | hideDelay: [{ type: core.Input, args: ['matTooltipHideDelay',] }],
|
---|
933 | touchGestures: [{ type: core.Input, args: ['matTooltipTouchGestures',] }],
|
---|
934 | message: [{ type: core.Input, args: ['matTooltip',] }],
|
---|
935 | tooltipClass: [{ type: core.Input, args: ['matTooltipClass',] }]
|
---|
936 | };
|
---|
937 | /**
|
---|
938 | * Directive that attaches a material design tooltip to the host element. Animates the showing and
|
---|
939 | * hiding of a tooltip provided position (defaults to below the element).
|
---|
940 | *
|
---|
941 | * https://material.io/design/components/tooltips.html
|
---|
942 | */
|
---|
943 | var MatTooltip = /** @class */ (function (_super) {
|
---|
944 | __extends(MatTooltip, _super);
|
---|
945 | function MatTooltip(overlay, elementRef, scrollDispatcher, viewContainerRef, ngZone, platform, ariaDescriber, focusMonitor, scrollStrategy, dir, defaultOptions, _document) {
|
---|
946 | var _this = _super.call(this, overlay, elementRef, scrollDispatcher, viewContainerRef, ngZone, platform, ariaDescriber, focusMonitor, scrollStrategy, dir, defaultOptions, _document) || this;
|
---|
947 | _this._tooltipComponent = TooltipComponent;
|
---|
948 | return _this;
|
---|
949 | }
|
---|
950 | return MatTooltip;
|
---|
951 | }(_MatTooltipBase));
|
---|
952 | MatTooltip.decorators = [
|
---|
953 | { type: core.Directive, args: [{
|
---|
954 | selector: '[matTooltip]',
|
---|
955 | exportAs: 'matTooltip',
|
---|
956 | host: {
|
---|
957 | 'class': 'mat-tooltip-trigger'
|
---|
958 | }
|
---|
959 | },] }
|
---|
960 | ];
|
---|
961 | MatTooltip.ctorParameters = function () { return [
|
---|
962 | { type: overlay.Overlay },
|
---|
963 | { type: core.ElementRef },
|
---|
964 | { type: scrolling.ScrollDispatcher },
|
---|
965 | { type: core.ViewContainerRef },
|
---|
966 | { type: core.NgZone },
|
---|
967 | { type: platform.Platform },
|
---|
968 | { type: a11y.AriaDescriber },
|
---|
969 | { type: a11y.FocusMonitor },
|
---|
970 | { type: undefined, decorators: [{ type: core.Inject, args: [MAT_TOOLTIP_SCROLL_STRATEGY,] }] },
|
---|
971 | { type: bidi.Directionality, decorators: [{ type: core.Optional }] },
|
---|
972 | { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [MAT_TOOLTIP_DEFAULT_OPTIONS,] }] },
|
---|
973 | { type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] }
|
---|
974 | ]; };
|
---|
975 | var _TooltipComponentBase = /** @class */ (function () {
|
---|
976 | function _TooltipComponentBase(_changeDetectorRef) {
|
---|
977 | this._changeDetectorRef = _changeDetectorRef;
|
---|
978 | /** Property watched by the animation framework to show or hide the tooltip */
|
---|
979 | this._visibility = 'initial';
|
---|
980 | /** Whether interactions on the page should close the tooltip */
|
---|
981 | this._closeOnInteraction = false;
|
---|
982 | /** Subject for notifying that the tooltip has been hidden from the view */
|
---|
983 | this._onHide = new rxjs.Subject();
|
---|
984 | }
|
---|
985 | /**
|
---|
986 | * Shows the tooltip with an animation originating from the provided origin
|
---|
987 | * @param delay Amount of milliseconds to the delay showing the tooltip.
|
---|
988 | */
|
---|
989 | _TooltipComponentBase.prototype.show = function (delay) {
|
---|
990 | var _this = this;
|
---|
991 | // Cancel the delayed hide if it is scheduled
|
---|
992 | clearTimeout(this._hideTimeoutId);
|
---|
993 | // Body interactions should cancel the tooltip if there is a delay in showing.
|
---|
994 | this._closeOnInteraction = true;
|
---|
995 | this._showTimeoutId = setTimeout(function () {
|
---|
996 | _this._visibility = 'visible';
|
---|
997 | _this._showTimeoutId = undefined;
|
---|
998 | _this._onShow();
|
---|
999 | // Mark for check so if any parent component has set the
|
---|
1000 | // ChangeDetectionStrategy to OnPush it will be checked anyways
|
---|
1001 | _this._markForCheck();
|
---|
1002 | }, delay);
|
---|
1003 | };
|
---|
1004 | /**
|
---|
1005 | * Begins the animation to hide the tooltip after the provided delay in ms.
|
---|
1006 | * @param delay Amount of milliseconds to delay showing the tooltip.
|
---|
1007 | */
|
---|
1008 | _TooltipComponentBase.prototype.hide = function (delay) {
|
---|
1009 | var _this = this;
|
---|
1010 | // Cancel the delayed show if it is scheduled
|
---|
1011 | clearTimeout(this._showTimeoutId);
|
---|
1012 | this._hideTimeoutId = setTimeout(function () {
|
---|
1013 | _this._visibility = 'hidden';
|
---|
1014 | _this._hideTimeoutId = undefined;
|
---|
1015 | // Mark for check so if any parent component has set the
|
---|
1016 | // ChangeDetectionStrategy to OnPush it will be checked anyways
|
---|
1017 | _this._markForCheck();
|
---|
1018 | }, delay);
|
---|
1019 | };
|
---|
1020 | /** Returns an observable that notifies when the tooltip has been hidden from view. */
|
---|
1021 | _TooltipComponentBase.prototype.afterHidden = function () {
|
---|
1022 | return this._onHide;
|
---|
1023 | };
|
---|
1024 | /** Whether the tooltip is being displayed. */
|
---|
1025 | _TooltipComponentBase.prototype.isVisible = function () {
|
---|
1026 | return this._visibility === 'visible';
|
---|
1027 | };
|
---|
1028 | _TooltipComponentBase.prototype.ngOnDestroy = function () {
|
---|
1029 | clearTimeout(this._showTimeoutId);
|
---|
1030 | clearTimeout(this._hideTimeoutId);
|
---|
1031 | this._onHide.complete();
|
---|
1032 | };
|
---|
1033 | _TooltipComponentBase.prototype._animationStart = function () {
|
---|
1034 | this._closeOnInteraction = false;
|
---|
1035 | };
|
---|
1036 | _TooltipComponentBase.prototype._animationDone = function (event) {
|
---|
1037 | var toState = event.toState;
|
---|
1038 | if (toState === 'hidden' && !this.isVisible()) {
|
---|
1039 | this._onHide.next();
|
---|
1040 | }
|
---|
1041 | if (toState === 'visible' || toState === 'hidden') {
|
---|
1042 | this._closeOnInteraction = true;
|
---|
1043 | }
|
---|
1044 | };
|
---|
1045 | /**
|
---|
1046 | * Interactions on the HTML body should close the tooltip immediately as defined in the
|
---|
1047 | * material design spec.
|
---|
1048 | * https://material.io/design/components/tooltips.html#behavior
|
---|
1049 | */
|
---|
1050 | _TooltipComponentBase.prototype._handleBodyInteraction = function () {
|
---|
1051 | if (this._closeOnInteraction) {
|
---|
1052 | this.hide(0);
|
---|
1053 | }
|
---|
1054 | };
|
---|
1055 | /**
|
---|
1056 | * Marks that the tooltip needs to be checked in the next change detection run.
|
---|
1057 | * Mainly used for rendering the initial text before positioning a tooltip, which
|
---|
1058 | * can be problematic in components with OnPush change detection.
|
---|
1059 | */
|
---|
1060 | _TooltipComponentBase.prototype._markForCheck = function () {
|
---|
1061 | this._changeDetectorRef.markForCheck();
|
---|
1062 | };
|
---|
1063 | /**
|
---|
1064 | * Callback for when the timeout in this.show() gets completed.
|
---|
1065 | * This method is only needed by the mdc-tooltip, and so it is only implemented
|
---|
1066 | * in the mdc-tooltip, not here.
|
---|
1067 | */
|
---|
1068 | _TooltipComponentBase.prototype._onShow = function () { };
|
---|
1069 | return _TooltipComponentBase;
|
---|
1070 | }());
|
---|
1071 | _TooltipComponentBase.decorators = [
|
---|
1072 | { type: core.Directive }
|
---|
1073 | ];
|
---|
1074 | _TooltipComponentBase.ctorParameters = function () { return [
|
---|
1075 | { type: core.ChangeDetectorRef }
|
---|
1076 | ]; };
|
---|
1077 | /**
|
---|
1078 | * Internal component that wraps the tooltip's content.
|
---|
1079 | * @docs-private
|
---|
1080 | */
|
---|
1081 | var TooltipComponent = /** @class */ (function (_super) {
|
---|
1082 | __extends(TooltipComponent, _super);
|
---|
1083 | function TooltipComponent(changeDetectorRef, _breakpointObserver) {
|
---|
1084 | var _this = _super.call(this, changeDetectorRef) || this;
|
---|
1085 | _this._breakpointObserver = _breakpointObserver;
|
---|
1086 | /** Stream that emits whether the user has a handset-sized display. */
|
---|
1087 | _this._isHandset = _this._breakpointObserver.observe(layout.Breakpoints.Handset);
|
---|
1088 | return _this;
|
---|
1089 | }
|
---|
1090 | return TooltipComponent;
|
---|
1091 | }(_TooltipComponentBase));
|
---|
1092 | TooltipComponent.decorators = [
|
---|
1093 | { type: core.Component, args: [{
|
---|
1094 | selector: 'mat-tooltip-component',
|
---|
1095 | 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",
|
---|
1096 | encapsulation: core.ViewEncapsulation.None,
|
---|
1097 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
---|
1098 | animations: [matTooltipAnimations.tooltipState],
|
---|
1099 | host: {
|
---|
1100 | // Forces the element to have a layout in IE and Edge. This fixes issues where the element
|
---|
1101 | // won't be rendered if the animations are disabled or there is no web animations polyfill.
|
---|
1102 | '[style.zoom]': '_visibility === "visible" ? 1 : null',
|
---|
1103 | 'aria-hidden': 'true',
|
---|
1104 | },
|
---|
1105 | 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"]
|
---|
1106 | },] }
|
---|
1107 | ];
|
---|
1108 | TooltipComponent.ctorParameters = function () { return [
|
---|
1109 | { type: core.ChangeDetectorRef },
|
---|
1110 | { type: layout.BreakpointObserver }
|
---|
1111 | ]; };
|
---|
1112 |
|
---|
1113 | /**
|
---|
1114 | * @license
|
---|
1115 | * Copyright Google LLC All Rights Reserved.
|
---|
1116 | *
|
---|
1117 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1118 | * found in the LICENSE file at https://angular.io/license
|
---|
1119 | */
|
---|
1120 | var MatTooltipModule = /** @class */ (function () {
|
---|
1121 | function MatTooltipModule() {
|
---|
1122 | }
|
---|
1123 | return MatTooltipModule;
|
---|
1124 | }());
|
---|
1125 | MatTooltipModule.decorators = [
|
---|
1126 | { type: core.NgModule, args: [{
|
---|
1127 | imports: [
|
---|
1128 | a11y.A11yModule,
|
---|
1129 | common.CommonModule,
|
---|
1130 | overlay.OverlayModule,
|
---|
1131 | core$1.MatCommonModule,
|
---|
1132 | ],
|
---|
1133 | exports: [MatTooltip, TooltipComponent, core$1.MatCommonModule, scrolling.CdkScrollableModule],
|
---|
1134 | declarations: [MatTooltip, TooltipComponent],
|
---|
1135 | entryComponents: [TooltipComponent],
|
---|
1136 | providers: [MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER]
|
---|
1137 | },] }
|
---|
1138 | ];
|
---|
1139 |
|
---|
1140 | /**
|
---|
1141 | * @license
|
---|
1142 | * Copyright Google LLC All Rights Reserved.
|
---|
1143 | *
|
---|
1144 | * Use of this source code is governed by an MIT-style license that can be
|
---|
1145 | * found in the LICENSE file at https://angular.io/license
|
---|
1146 | */
|
---|
1147 |
|
---|
1148 | /**
|
---|
1149 | * Generated bundle index. Do not edit.
|
---|
1150 | */
|
---|
1151 |
|
---|
1152 | exports.MAT_TOOLTIP_DEFAULT_OPTIONS = MAT_TOOLTIP_DEFAULT_OPTIONS;
|
---|
1153 | exports.MAT_TOOLTIP_DEFAULT_OPTIONS_FACTORY = MAT_TOOLTIP_DEFAULT_OPTIONS_FACTORY;
|
---|
1154 | exports.MAT_TOOLTIP_SCROLL_STRATEGY = MAT_TOOLTIP_SCROLL_STRATEGY;
|
---|
1155 | exports.MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY = MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY;
|
---|
1156 | exports.MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER = MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER;
|
---|
1157 | exports.MatTooltip = MatTooltip;
|
---|
1158 | exports.MatTooltipModule = MatTooltipModule;
|
---|
1159 | exports.SCROLL_THROTTLE_MS = SCROLL_THROTTLE_MS;
|
---|
1160 | exports.TOOLTIP_PANEL_CLASS = TOOLTIP_PANEL_CLASS;
|
---|
1161 | exports.TooltipComponent = TooltipComponent;
|
---|
1162 | exports._MatTooltipBase = _MatTooltipBase;
|
---|
1163 | exports._TooltipComponentBase = _TooltipComponentBase;
|
---|
1164 | exports.getMatTooltipInvalidPositionError = getMatTooltipInvalidPositionError;
|
---|
1165 | exports.matTooltipAnimations = matTooltipAnimations;
|
---|
1166 |
|
---|
1167 | Object.defineProperty(exports, '__esModule', { value: true });
|
---|
1168 |
|
---|
1169 | })));
|
---|
1170 | //# sourceMappingURL=material-tooltip.umd.js.map
|
---|