@m3e/tooltip 1.1.11 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,12 +3,12 @@
3
3
  * Copyright (c) 2025 matraic
4
4
  * See LICENSE file in the project root for full license text.
5
5
  */
6
- import { LitElement, html, unsafeCSS, css } from 'lit';
7
- import { M3eAriaDescriber } from '@m3e/core/a11y';
6
+ import { ActionElementBase, HtmlFor, HoverController, LongPressController, isDisabledMixin, DesignToken, hasAssignedNodes, getTextContent } from '@m3e/core';
7
+ import { LitElement, unsafeCSS, css, html } from 'lit';
8
+ import { M3eInteractivityChecker, M3eAriaDescriber } from '@m3e/core/a11y';
9
+ import { M3eDirectionality } from '@m3e/core/bidi';
8
10
  import { M3ePlatform } from '@m3e/core/platform';
9
11
  import { positionAnchor } from '@m3e/core/anchoring';
10
- import { M3eDirectionality } from '@m3e/core/bidi';
11
- import { HtmlFor, AttachInternals, HoverController, LongPressController, isDisabledMixin, DesignToken } from '@m3e/core';
12
12
 
13
13
  /******************************************************************************
14
14
  Copyright (c) Microsoft Corporation.
@@ -54,7 +54,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
54
54
  * Copyright 2017 Google LLC
55
55
  * SPDX-License-Identifier: BSD-3-Clause
56
56
  */
57
- const t$1 = t => (e, o) => {
57
+ const t$2 = t => (e, o) => {
58
58
  void 0 !== o ? o.addInitializer(() => {
59
59
  customElements.define(t, e);
60
60
  }) : customElements.define(t, e);
@@ -65,21 +65,21 @@ const t$1 = t => (e, o) => {
65
65
  * Copyright 2019 Google LLC
66
66
  * SPDX-License-Identifier: BSD-3-Clause
67
67
  */
68
- const t = globalThis,
69
- e$3 = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype,
70
- s = Symbol(),
71
- o$2 = new WeakMap();
72
- let n$2 = class n {
68
+ const t$1 = globalThis,
69
+ e$4 = t$1.ShadowRoot && (void 0 === t$1.ShadyCSS || t$1.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype,
70
+ s$1 = Symbol(),
71
+ o$4 = new WeakMap();
72
+ let n$3 = class n {
73
73
  constructor(t, e, o) {
74
- if (this._$cssResult$ = true, o !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
74
+ if (this._$cssResult$ = true, o !== s$1) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
75
75
  this.cssText = t, this.t = e;
76
76
  }
77
77
  get styleSheet() {
78
78
  let t = this.o;
79
79
  const s = this.t;
80
- if (e$3 && void 0 === t) {
80
+ if (e$4 && void 0 === t) {
81
81
  const e = void 0 !== s && 1 === s.length;
82
- e && (t = o$2.get(s)), void 0 === t && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), e && o$2.set(s, t));
82
+ e && (t = o$4.get(s)), void 0 === t && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), e && o$4.set(s, t));
83
83
  }
84
84
  return t;
85
85
  }
@@ -87,18 +87,18 @@ let n$2 = class n {
87
87
  return this.cssText;
88
88
  }
89
89
  };
90
- const r$2 = t => new n$2("string" == typeof t ? t : t + "", void 0, s),
91
- S = (s, o) => {
92
- if (e$3) s.adoptedStyleSheets = o.map(t => t instanceof CSSStyleSheet ? t : t.styleSheet);else for (const e of o) {
90
+ const r$4 = t => new n$3("string" == typeof t ? t : t + "", void 0, s$1),
91
+ S$1 = (s, o) => {
92
+ if (e$4) s.adoptedStyleSheets = o.map(t => t instanceof CSSStyleSheet ? t : t.styleSheet);else for (const e of o) {
93
93
  const o = document.createElement("style"),
94
- n = t.litNonce;
94
+ n = t$1.litNonce;
95
95
  void 0 !== n && o.setAttribute("nonce", n), o.textContent = e.cssText, s.appendChild(o);
96
96
  }
97
97
  },
98
- c$1 = e$3 ? t => t : t => t instanceof CSSStyleSheet ? (t => {
98
+ c$2 = e$4 ? t => t : t => t instanceof CSSStyleSheet ? (t => {
99
99
  let e = "";
100
100
  for (const s of t.cssRules) e += s.cssText;
101
- return r$2(e);
101
+ return r$4(e);
102
102
  })(t) : t;
103
103
 
104
104
  /**
@@ -107,23 +107,23 @@ const r$2 = t => new n$2("string" == typeof t ? t : t + "", void 0, s),
107
107
  * SPDX-License-Identifier: BSD-3-Clause
108
108
  */
109
109
  const {
110
- is: i,
111
- defineProperty: e$2,
112
- getOwnPropertyDescriptor: h,
113
- getOwnPropertyNames: r$1,
114
- getOwnPropertySymbols: o$1,
115
- getPrototypeOf: n$1
110
+ is: i$1,
111
+ defineProperty: e$3,
112
+ getOwnPropertyDescriptor: h$1,
113
+ getOwnPropertyNames: r$3,
114
+ getOwnPropertySymbols: o$3,
115
+ getPrototypeOf: n$2
116
116
  } = Object,
117
- a = globalThis,
118
- c = a.trustedTypes,
119
- l = c ? c.emptyScript : "",
120
- p = a.reactiveElementPolyfillSupport,
121
- d = (t, s) => t,
122
- u = {
117
+ a$1 = globalThis,
118
+ c$1 = a$1.trustedTypes,
119
+ l$1 = c$1 ? c$1.emptyScript : "",
120
+ p$1 = a$1.reactiveElementPolyfillSupport,
121
+ d$1 = (t, s) => t,
122
+ u$1 = {
123
123
  toAttribute(t, s) {
124
124
  switch (s) {
125
125
  case Boolean:
126
- t = t ? l : null;
126
+ t = t ? l$1 : null;
127
127
  break;
128
128
  case Object:
129
129
  case Array:
@@ -151,16 +151,16 @@ const {
151
151
  return i;
152
152
  }
153
153
  },
154
- f = (t, s) => !i(t, s),
154
+ f$1 = (t, s) => !i$1(t, s),
155
155
  b = {
156
156
  attribute: true,
157
157
  type: String,
158
- converter: u,
158
+ converter: u$1,
159
159
  reflect: false,
160
160
  useDefault: false,
161
- hasChanged: f
161
+ hasChanged: f$1
162
162
  };
163
- Symbol.metadata ??= Symbol("metadata"), a.litPropertyMetadata ??= new WeakMap();
163
+ Symbol.metadata ??= Symbol("metadata"), a$1.litPropertyMetadata ??= new WeakMap();
164
164
  class y extends HTMLElement {
165
165
  static addInitializer(t) {
166
166
  this._$Ei(), (this.l ??= []).push(t);
@@ -172,14 +172,14 @@ class y extends HTMLElement {
172
172
  if (s.state && (s.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t) && ((s = Object.create(s)).wrapped = true), this.elementProperties.set(t, s), !s.noAccessor) {
173
173
  const i = Symbol(),
174
174
  h = this.getPropertyDescriptor(t, i, s);
175
- void 0 !== h && e$2(this.prototype, t, h);
175
+ void 0 !== h && e$3(this.prototype, t, h);
176
176
  }
177
177
  }
178
178
  static getPropertyDescriptor(t, s, i) {
179
179
  const {
180
180
  get: e,
181
181
  set: r
182
- } = h(this.prototype, t) ?? {
182
+ } = h$1(this.prototype, t) ?? {
183
183
  get() {
184
184
  return this[s];
185
185
  },
@@ -201,15 +201,15 @@ class y extends HTMLElement {
201
201
  return this.elementProperties.get(t) ?? b;
202
202
  }
203
203
  static _$Ei() {
204
- if (this.hasOwnProperty(d("elementProperties"))) return;
205
- const t = n$1(this);
204
+ if (this.hasOwnProperty(d$1("elementProperties"))) return;
205
+ const t = n$2(this);
206
206
  t.finalize(), void 0 !== t.l && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
207
207
  }
208
208
  static finalize() {
209
- if (this.hasOwnProperty(d("finalized"))) return;
210
- if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d("properties"))) {
209
+ if (this.hasOwnProperty(d$1("finalized"))) return;
210
+ if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d$1("properties"))) {
211
211
  const t = this.properties,
212
- s = [...r$1(t), ...o$1(t)];
212
+ s = [...r$3(t), ...o$3(t)];
213
213
  for (const i of s) this.createProperty(i, t[i]);
214
214
  }
215
215
  const t = this[Symbol.metadata];
@@ -228,8 +228,8 @@ class y extends HTMLElement {
228
228
  const i = [];
229
229
  if (Array.isArray(s)) {
230
230
  const e = new Set(s.flat(1 / 0).reverse());
231
- for (const s of e) i.unshift(c$1(s));
232
- } else void 0 !== s && i.push(c$1(s));
231
+ for (const s of e) i.unshift(c$2(s));
232
+ } else void 0 !== s && i.push(c$2(s));
233
233
  return i;
234
234
  }
235
235
  static _$Eu(t, s) {
@@ -256,7 +256,7 @@ class y extends HTMLElement {
256
256
  }
257
257
  createRenderRoot() {
258
258
  const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
259
- return S(t, this.constructor.elementStyles), t;
259
+ return S$1(t, this.constructor.elementStyles), t;
260
260
  }
261
261
  connectedCallback() {
262
262
  this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach(t => t.hostConnected?.());
@@ -272,7 +272,7 @@ class y extends HTMLElement {
272
272
  const i = this.constructor.elementProperties.get(t),
273
273
  e = this.constructor._$Eu(t, i);
274
274
  if (void 0 !== e && true === i.reflect) {
275
- const h = (void 0 !== i.converter?.toAttribute ? i.converter : u).toAttribute(s, i.type);
275
+ const h = (void 0 !== i.converter?.toAttribute ? i.converter : u$1).toAttribute(s, i.type);
276
276
  this._$Em = t, null == h ? this.removeAttribute(e) : this.setAttribute(e, h), this._$Em = null;
277
277
  }
278
278
  }
@@ -283,7 +283,7 @@ class y extends HTMLElement {
283
283
  const t = i.getPropertyOptions(e),
284
284
  h = "function" == typeof t.converter ? {
285
285
  fromAttribute: t.converter
286
- } : void 0 !== t.converter?.fromAttribute ? t.converter : u;
286
+ } : void 0 !== t.converter?.fromAttribute ? t.converter : u$1;
287
287
  this._$Em = e;
288
288
  const r = h.fromAttribute(s, t.type);
289
289
  this[e] = r ?? this._$Ej?.get(e) ?? r, this._$Em = null;
@@ -293,7 +293,7 @@ class y extends HTMLElement {
293
293
  if (void 0 !== t) {
294
294
  const e = this.constructor,
295
295
  h = this[t];
296
- if (i ??= e.getPropertyOptions(t), !((i.hasChanged ?? f)(h, s) || i.useDefault && i.reflect && h === this._$Ej?.get(t) && !this.hasAttribute(e._$Eu(t, i)))) return;
296
+ if (i ??= e.getPropertyOptions(t), !((i.hasChanged ?? f$1)(h, s) || i.useDefault && i.reflect && h === this._$Ej?.get(t) && !this.hasAttribute(e._$Eu(t, i)))) return;
297
297
  this.C(t, s, i);
298
298
  }
299
299
  false === this.isUpdatePending && (this._$ES = this._$EP());
@@ -367,23 +367,23 @@ class y extends HTMLElement {
367
367
  }
368
368
  y.elementStyles = [], y.shadowRootOptions = {
369
369
  mode: "open"
370
- }, y[d("elementProperties")] = new Map(), y[d("finalized")] = new Map(), p?.({
370
+ }, y[d$1("elementProperties")] = new Map(), y[d$1("finalized")] = new Map(), p$1?.({
371
371
  ReactiveElement: y
372
- }), (a.reactiveElementVersions ??= []).push("2.1.1");
372
+ }), (a$1.reactiveElementVersions ??= []).push("2.1.1");
373
373
 
374
374
  /**
375
375
  * @license
376
376
  * Copyright 2017 Google LLC
377
377
  * SPDX-License-Identifier: BSD-3-Clause
378
378
  */
379
- const o = {
379
+ const o$2 = {
380
380
  attribute: true,
381
381
  type: String,
382
- converter: u,
382
+ converter: u$1,
383
383
  reflect: false,
384
- hasChanged: f
384
+ hasChanged: f$1
385
385
  },
386
- r = (t = o, e, r) => {
386
+ r$2 = (t = o$2, e, r) => {
387
387
  const {
388
388
  kind: n,
389
389
  metadata: i
@@ -414,8 +414,8 @@ const o = {
414
414
  }
415
415
  throw Error("Unsupported decorator location: " + n);
416
416
  };
417
- function n(t) {
418
- return (e, o) => "object" == typeof o ? r(t, e, o) : ((t, e, o) => {
417
+ function n$1(t) {
418
+ return (e, o) => "object" == typeof o ? r$2(t, e, o) : ((t, e, o) => {
419
419
  const r = e.hasOwnProperty(o);
420
420
  return e.constructor.createProperty(o, t), r ? Object.getOwnPropertyDescriptor(e, o) : void 0;
421
421
  })(t, e, o);
@@ -426,17 +426,30 @@ function n(t) {
426
426
  * Copyright 2017 Google LLC
427
427
  * SPDX-License-Identifier: BSD-3-Clause
428
428
  */
429
- const e$1 = (e, t, c) => (c.configurable = true, c.enumerable = true, Reflect.decorate && "object" != typeof t && Object.defineProperty(e, t, c), c);
429
+ function r$1(r) {
430
+ return n$1({
431
+ ...r,
432
+ state: true,
433
+ attribute: false
434
+ });
435
+ }
430
436
 
431
437
  /**
432
438
  * @license
433
439
  * Copyright 2017 Google LLC
434
440
  * SPDX-License-Identifier: BSD-3-Clause
435
441
  */
436
- function e(e, r) {
442
+ const e$2 = (e, t, c) => (c.configurable = true, c.enumerable = true, Reflect.decorate && "object" != typeof t && Object.defineProperty(e, t, c), c);
443
+
444
+ /**
445
+ * @license
446
+ * Copyright 2017 Google LLC
447
+ * SPDX-License-Identifier: BSD-3-Clause
448
+ */
449
+ function e$1(e, r) {
437
450
  return (n, s, i) => {
438
451
  const o = t => t.renderRoot?.querySelector(e) ?? null;
439
- return e$1(n, s, {
452
+ return e$2(n, s, {
440
453
  get() {
441
454
  return o(this);
442
455
  }
@@ -444,81 +457,371 @@ function e(e, r) {
444
457
  };
445
458
  }
446
459
 
447
- var _M3eTooltipElement_instances, _M3eTooltipElement_message, _M3eTooltipElement_for, _M3eTooltipElement_anchorCleanup, _M3eTooltipElement_clickHandler, _M3eTooltipElement_hoverController, _M3eTooltipElement_longPressController, _M3eTooltipElement_handleSlotChange, _M3eTooltipElement_handleToggle, _M3eTooltipElement_disableNativeGesturesIfNecessary;
448
- var M3eTooltipElement_1;
449
- /** The space, in pixels, between the tooltip and anchor. */
450
- const TOOLTIP_OFFSET = 4;
451
- /** The default time, in milliseconds, before hiding a tooltip. */
452
- const TOOLTIP_HIDE_DELAY = 200;
453
460
  /**
454
- * Adds additional context to a button or other UI element.
461
+ * An element, nested within a clickable element, used to dismiss a parenting rich tooltip.
462
+ * @tag m3e-rich-tooltip-action
455
463
  *
456
- * @description
457
- * The `m3e-tooltip` component provides contextual information in response to user interaction, enhancing comprehension
458
- * and reducing ambiguity. Tooltips are positioned relative to a target element and support configurable delays for
459
- * show and hide behavior. The component is designed to reinforce accessibility and usability, especially in dense or
460
- * icon-driven interfaces. Use the `for` attribute to designate the element for which to provide a tooltip.
464
+ * @slot - Renders the content of the action.
461
465
  *
462
- * @example
463
- * The following example illustrates connecting a tooltip to a button using the `for` attribute.
464
- * ```html
465
- * <m3e-icon-button id="button" aria-label="Back">
466
- * <m3e-icon name="arrow_back"></m3e-icon>
467
- * </m3e-icon-button>
468
- * <m3e-tooltip for="button">Go Back</m3e-tooltip>
469
- * ```
470
- *
471
- * @tag m3e-tooltip
472
- *
473
- * @slot - Renders the content of the tooltip.
474
- *
475
- * @attr disabled - Whether the element is disabled.
476
- * @attr for - The identifier of the interactive control to which this element is attached.
477
- * @attr hide-delay - The amount of time, in milliseconds, before hiding the tooltip.
478
- * @attr position - The position of the tooltip.
479
- * @attr show-delay - The amount of time, in milliseconds, before showing the tooltip.
480
- *
481
- * @cssprop --m3e-tooltip-padding - Internal spacing of the tooltip container.
482
- * @cssprop --m3e-tooltip-min-width - Minimum width of the tooltip.
483
- * @cssprop --m3e-tooltip-max-width - Maximum width of the tooltip.
484
- * @cssprop --m3e-tooltip-min-height - Minimum height of the tooltip container.
485
- * @cssprop --m3e-tooltip-max-height - Maximum height of the tooltip.
486
- * @cssprop --m3e-tooltip-shape - Border radius of the tooltip container.
487
- * @cssprop --m3e-tooltip-container-color - Background color of the tooltip.
488
- * @cssprop --m3e-tooltip-supporting-text-color - Text color of supporting text.
489
- * @cssprop --m3e-tooltip-supporting-text-font-size - Font size of supporting text.
490
- * @cssprop --m3e-tooltip-supporting-text-font-weight - Font weight of supporting text.
491
- * @cssprop --m3e-tooltip-supporting-text-line-height - Line height of supporting text.
492
- * @cssprop --m3e-tooltip-supporting-text-tracking - Letter spacing of supporting text.
466
+ * @attr disable-restore-focus - Whether to focus should not be restored to the trigger when activated.
493
467
  */
494
- let M3eTooltipElement = M3eTooltipElement_1 = class M3eTooltipElement extends HtmlFor(AttachInternals(LitElement)) {
468
+ let M3eRichTooltipActionElement = class M3eRichTooltipActionElement extends ActionElementBase {
495
469
  constructor() {
496
470
  super(...arguments);
497
- _M3eTooltipElement_instances.add(this);
471
+ /** Whether to focus should not be restored to the trigger when activated. */
472
+ this.disableRestoreFocus = false;
473
+ }
474
+ /** @inheritdoc */
475
+ _onClick() {
476
+ this.closest("m3e-rich-tooltip")?.hide(!this.disableRestoreFocus);
477
+ }
478
+ };
479
+ __decorate([n$1({
480
+ attribute: "disable-restore-focus",
481
+ type: Boolean
482
+ })], M3eRichTooltipActionElement.prototype, "disableRestoreFocus", void 0);
483
+ M3eRichTooltipActionElement = __decorate([t$2("m3e-rich-tooltip-action")], M3eRichTooltipActionElement);
484
+
485
+ /**
486
+ * @license
487
+ * Copyright 2017 Google LLC
488
+ * SPDX-License-Identifier: BSD-3-Clause
489
+ */
490
+ const t = globalThis,
491
+ i = t.trustedTypes,
492
+ s = i ? i.createPolicy("lit-html", {
493
+ createHTML: t => t
494
+ }) : void 0,
495
+ e = "$lit$",
496
+ h = `lit$${Math.random().toFixed(9).slice(2)}$`,
497
+ o$1 = "?" + h,
498
+ n = `<${o$1}>`,
499
+ r = document,
500
+ l = () => r.createComment(""),
501
+ c = t => null === t || "object" != typeof t && "function" != typeof t,
502
+ a = Array.isArray,
503
+ u = t => a(t) || "function" == typeof t?.[Symbol.iterator],
504
+ d = "[ \t\n\f\r]",
505
+ f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
506
+ v = /-->/g,
507
+ _ = />/g,
508
+ m = RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`, "g"),
509
+ p = /'/g,
510
+ g = /"/g,
511
+ $ = /^(?:script|style|textarea|title)$/i,
512
+ T = Symbol.for("lit-noChange"),
513
+ E = Symbol.for("lit-nothing"),
514
+ A = new WeakMap(),
515
+ C = r.createTreeWalker(r, 129);
516
+ function P(t, i) {
517
+ if (!a(t) || !t.hasOwnProperty("raw")) throw Error("invalid template strings array");
518
+ return void 0 !== s ? s.createHTML(i) : i;
519
+ }
520
+ const V = (t, i) => {
521
+ const s = t.length - 1,
522
+ o = [];
523
+ let r,
524
+ l = 2 === i ? "<svg>" : 3 === i ? "<math>" : "",
525
+ c = f;
526
+ for (let i = 0; i < s; i++) {
527
+ const s = t[i];
528
+ let a,
529
+ u,
530
+ d = -1,
531
+ y = 0;
532
+ for (; y < s.length && (c.lastIndex = y, u = c.exec(s), null !== u);) y = c.lastIndex, c === f ? "!--" === u[1] ? c = v : void 0 !== u[1] ? c = _ : void 0 !== u[2] ? ($.test(u[2]) && (r = RegExp("</" + u[2], "g")), c = m) : void 0 !== u[3] && (c = m) : c === m ? ">" === u[0] ? (c = r ?? f, d = -1) : void 0 === u[1] ? d = -2 : (d = c.lastIndex - u[2].length, a = u[1], c = void 0 === u[3] ? m : '"' === u[3] ? g : p) : c === g || c === p ? c = m : c === v || c === _ ? c = f : (c = m, r = void 0);
533
+ const x = c === m && t[i + 1].startsWith("/>") ? " " : "";
534
+ l += c === f ? s + n : d >= 0 ? (o.push(a), s.slice(0, d) + e + s.slice(d) + h + x) : s + h + (-2 === d ? i : x);
535
+ }
536
+ return [P(t, l + (t[s] || "<?>") + (2 === i ? "</svg>" : 3 === i ? "</math>" : "")), o];
537
+ };
538
+ class N {
539
+ constructor({
540
+ strings: t,
541
+ _$litType$: s
542
+ }, n) {
543
+ let r;
544
+ this.parts = [];
545
+ let c = 0,
546
+ a = 0;
547
+ const u = t.length - 1,
548
+ d = this.parts,
549
+ [f, v] = V(t, s);
550
+ if (this.el = N.createElement(f, n), C.currentNode = this.el.content, 2 === s || 3 === s) {
551
+ const t = this.el.content.firstChild;
552
+ t.replaceWith(...t.childNodes);
553
+ }
554
+ for (; null !== (r = C.nextNode()) && d.length < u;) {
555
+ if (1 === r.nodeType) {
556
+ if (r.hasAttributes()) for (const t of r.getAttributeNames()) if (t.endsWith(e)) {
557
+ const i = v[a++],
558
+ s = r.getAttribute(t).split(h),
559
+ e = /([.?@])?(.*)/.exec(i);
560
+ d.push({
561
+ type: 1,
562
+ index: c,
563
+ name: e[2],
564
+ strings: s,
565
+ ctor: "." === e[1] ? H : "?" === e[1] ? I : "@" === e[1] ? L : k
566
+ }), r.removeAttribute(t);
567
+ } else t.startsWith(h) && (d.push({
568
+ type: 6,
569
+ index: c
570
+ }), r.removeAttribute(t));
571
+ if ($.test(r.tagName)) {
572
+ const t = r.textContent.split(h),
573
+ s = t.length - 1;
574
+ if (s > 0) {
575
+ r.textContent = i ? i.emptyScript : "";
576
+ for (let i = 0; i < s; i++) r.append(t[i], l()), C.nextNode(), d.push({
577
+ type: 2,
578
+ index: ++c
579
+ });
580
+ r.append(t[s], l());
581
+ }
582
+ }
583
+ } else if (8 === r.nodeType) if (r.data === o$1) d.push({
584
+ type: 2,
585
+ index: c
586
+ });else {
587
+ let t = -1;
588
+ for (; -1 !== (t = r.data.indexOf(h, t + 1));) d.push({
589
+ type: 7,
590
+ index: c
591
+ }), t += h.length - 1;
592
+ }
593
+ c++;
594
+ }
595
+ }
596
+ static createElement(t, i) {
597
+ const s = r.createElement("template");
598
+ return s.innerHTML = t, s;
599
+ }
600
+ }
601
+ function S(t, i, s = t, e) {
602
+ if (i === T) return i;
603
+ let h = void 0 !== e ? s._$Co?.[e] : s._$Cl;
604
+ const o = c(i) ? void 0 : i._$litDirective$;
605
+ return h?.constructor !== o && (h?._$AO?.(false), void 0 === o ? h = void 0 : (h = new o(t), h._$AT(t, s, e)), void 0 !== e ? (s._$Co ??= [])[e] = h : s._$Cl = h), void 0 !== h && (i = S(t, h._$AS(t, i.values), h, e)), i;
606
+ }
607
+ class M {
608
+ constructor(t, i) {
609
+ this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = i;
610
+ }
611
+ get parentNode() {
612
+ return this._$AM.parentNode;
613
+ }
614
+ get _$AU() {
615
+ return this._$AM._$AU;
616
+ }
617
+ u(t) {
618
+ const {
619
+ el: {
620
+ content: i
621
+ },
622
+ parts: s
623
+ } = this._$AD,
624
+ e = (t?.creationScope ?? r).importNode(i, true);
625
+ C.currentNode = e;
626
+ let h = C.nextNode(),
627
+ o = 0,
628
+ n = 0,
629
+ l = s[0];
630
+ for (; void 0 !== l;) {
631
+ if (o === l.index) {
632
+ let i;
633
+ 2 === l.type ? i = new R(h, h.nextSibling, this, t) : 1 === l.type ? i = new l.ctor(h, l.name, l.strings, this, t) : 6 === l.type && (i = new z(h, this, t)), this._$AV.push(i), l = s[++n];
634
+ }
635
+ o !== l?.index && (h = C.nextNode(), o++);
636
+ }
637
+ return C.currentNode = r, e;
638
+ }
639
+ p(t) {
640
+ let i = 0;
641
+ for (const s of this._$AV) void 0 !== s && (void 0 !== s.strings ? (s._$AI(t, s, i), i += s.strings.length - 2) : s._$AI(t[i])), i++;
642
+ }
643
+ }
644
+ class R {
645
+ get _$AU() {
646
+ return this._$AM?._$AU ?? this._$Cv;
647
+ }
648
+ constructor(t, i, s, e) {
649
+ this.type = 2, this._$AH = E, this._$AN = void 0, this._$AA = t, this._$AB = i, this._$AM = s, this.options = e, this._$Cv = e?.isConnected ?? true;
650
+ }
651
+ get parentNode() {
652
+ let t = this._$AA.parentNode;
653
+ const i = this._$AM;
654
+ return void 0 !== i && 11 === t?.nodeType && (t = i.parentNode), t;
655
+ }
656
+ get startNode() {
657
+ return this._$AA;
658
+ }
659
+ get endNode() {
660
+ return this._$AB;
661
+ }
662
+ _$AI(t, i = this) {
663
+ t = S(this, t, i), c(t) ? t === E || null == t || "" === t ? (this._$AH !== E && this._$AR(), this._$AH = E) : t !== this._$AH && t !== T && this._(t) : void 0 !== t._$litType$ ? this.$(t) : void 0 !== t.nodeType ? this.T(t) : u(t) ? this.k(t) : this._(t);
664
+ }
665
+ O(t) {
666
+ return this._$AA.parentNode.insertBefore(t, this._$AB);
667
+ }
668
+ T(t) {
669
+ this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
670
+ }
671
+ _(t) {
672
+ this._$AH !== E && c(this._$AH) ? this._$AA.nextSibling.data = t : this.T(r.createTextNode(t)), this._$AH = t;
673
+ }
674
+ $(t) {
675
+ const {
676
+ values: i,
677
+ _$litType$: s
678
+ } = t,
679
+ e = "number" == typeof s ? this._$AC(t) : (void 0 === s.el && (s.el = N.createElement(P(s.h, s.h[0]), this.options)), s);
680
+ if (this._$AH?._$AD === e) this._$AH.p(i);else {
681
+ const t = new M(e, this),
682
+ s = t.u(this.options);
683
+ t.p(i), this.T(s), this._$AH = t;
684
+ }
685
+ }
686
+ _$AC(t) {
687
+ let i = A.get(t.strings);
688
+ return void 0 === i && A.set(t.strings, i = new N(t)), i;
689
+ }
690
+ k(t) {
691
+ a(this._$AH) || (this._$AH = [], this._$AR());
692
+ const i = this._$AH;
693
+ let s,
694
+ e = 0;
695
+ for (const h of t) e === i.length ? i.push(s = new R(this.O(l()), this.O(l()), this, this.options)) : s = i[e], s._$AI(h), e++;
696
+ e < i.length && (this._$AR(s && s._$AB.nextSibling, e), i.length = e);
697
+ }
698
+ _$AR(t = this._$AA.nextSibling, i) {
699
+ for (this._$AP?.(false, true, i); t !== this._$AB;) {
700
+ const i = t.nextSibling;
701
+ t.remove(), t = i;
702
+ }
703
+ }
704
+ setConnected(t) {
705
+ void 0 === this._$AM && (this._$Cv = t, this._$AP?.(t));
706
+ }
707
+ }
708
+ class k {
709
+ get tagName() {
710
+ return this.element.tagName;
711
+ }
712
+ get _$AU() {
713
+ return this._$AM._$AU;
714
+ }
715
+ constructor(t, i, s, e, h) {
716
+ this.type = 1, this._$AH = E, this._$AN = void 0, this.element = t, this.name = i, this._$AM = e, this.options = h, s.length > 2 || "" !== s[0] || "" !== s[1] ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = E;
717
+ }
718
+ _$AI(t, i = this, s, e) {
719
+ const h = this.strings;
720
+ let o = false;
721
+ if (void 0 === h) t = S(this, t, i, 0), o = !c(t) || t !== this._$AH && t !== T, o && (this._$AH = t);else {
722
+ const e = t;
723
+ let n, r;
724
+ for (t = h[0], n = 0; n < h.length - 1; n++) r = S(this, e[s + n], i, n), r === T && (r = this._$AH[n]), o ||= !c(r) || r !== this._$AH[n], r === E ? t = E : t !== E && (t += (r ?? "") + h[n + 1]), this._$AH[n] = r;
725
+ }
726
+ o && !e && this.j(t);
727
+ }
728
+ j(t) {
729
+ t === E ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
730
+ }
731
+ }
732
+ class H extends k {
733
+ constructor() {
734
+ super(...arguments), this.type = 3;
735
+ }
736
+ j(t) {
737
+ this.element[this.name] = t === E ? void 0 : t;
738
+ }
739
+ }
740
+ class I extends k {
741
+ constructor() {
742
+ super(...arguments), this.type = 4;
743
+ }
744
+ j(t) {
745
+ this.element.toggleAttribute(this.name, !!t && t !== E);
746
+ }
747
+ }
748
+ class L extends k {
749
+ constructor(t, i, s, e, h) {
750
+ super(t, i, s, e, h), this.type = 5;
751
+ }
752
+ _$AI(t, i = this) {
753
+ if ((t = S(this, t, i, 0) ?? E) === T) return;
754
+ const s = this._$AH,
755
+ e = t === E && s !== E || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive,
756
+ h = t !== E && (s === E || e);
757
+ e && this.element.removeEventListener(this.name, this, s), h && this.element.addEventListener(this.name, this, t), this._$AH = t;
758
+ }
759
+ handleEvent(t) {
760
+ "function" == typeof this._$AH ? this._$AH.call(this.options?.host ?? this.element, t) : this._$AH.handleEvent(t);
761
+ }
762
+ }
763
+ class z {
764
+ constructor(t, i, s) {
765
+ this.element = t, this.type = 6, this._$AN = void 0, this._$AM = i, this.options = s;
766
+ }
767
+ get _$AU() {
768
+ return this._$AM._$AU;
769
+ }
770
+ _$AI(t) {
771
+ S(this, t);
772
+ }
773
+ }
774
+ const j = t.litHtmlPolyfillSupport;
775
+ j?.(N, R), (t.litHtmlVersions ??= []).push("3.3.1");
776
+
777
+ /**
778
+ * @license
779
+ * Copyright 2018 Google LLC
780
+ * SPDX-License-Identifier: BSD-3-Clause
781
+ */
782
+ const o = o => o ?? E;
783
+
784
+ var _TooltipElementBase_instances, _a, _TooltipElementBase_for, _TooltipElementBase_anchorCleanup, _TooltipElementBase_tooltipHovering, _TooltipElementBase_controlClickHandler, _TooltipElementBase_hoverController, _TooltipElementBase_longPressController, _TooltipElementBase_handleControlClick, _TooltipElementBase_disableNativeGesturesIfNecessary;
785
+ /** The space, in pixels, between the tooltip and anchor. */
786
+ const TOOLTIP_OFFSET = 4;
787
+ /** The default time, in milliseconds, before hiding a tooltip. */
788
+ const TOOLTIP_HIDE_DELAY = 200;
789
+ /** Provides a base implementation for a tooltip. This class must be inherited. */
790
+ class TooltipElementBase extends HtmlFor(LitElement) {
791
+ constructor() {
792
+ super(...arguments);
793
+ _TooltipElementBase_instances.add(this);
498
794
  /** @private */
499
- _M3eTooltipElement_message.set(this, void 0);
795
+ _TooltipElementBase_for.set(this, null);
500
796
  /** @private */
501
- _M3eTooltipElement_for.set(this, null);
797
+ _TooltipElementBase_anchorCleanup.set(this, void 0);
502
798
  /** @private */
503
- _M3eTooltipElement_anchorCleanup.set(this, void 0);
799
+ _TooltipElementBase_tooltipHovering.set(this, false);
504
800
  /** @private */
505
- _M3eTooltipElement_clickHandler.set(this, () => this.hide());
801
+ _TooltipElementBase_controlClickHandler.set(this, () => __classPrivateFieldGet(this, _TooltipElementBase_instances, "m", _TooltipElementBase_handleControlClick).call(this));
506
802
  /** @private */
507
- _M3eTooltipElement_hoverController.set(this, new HoverController(this, {
803
+ _TooltipElementBase_hoverController.set(this, new HoverController(this, {
508
804
  target: null,
509
805
  endDelay: TOOLTIP_HIDE_DELAY,
510
- callback: hovering => {
806
+ callback: (hovering, target) => {
807
+ if (this._isInteractive) return;
511
808
  if (hovering) {
809
+ if (target === this._base) {
810
+ __classPrivateFieldSet(this, _TooltipElementBase_tooltipHovering, true, "f");
811
+ return;
812
+ }
512
813
  this.show();
513
- } else {
814
+ } else if (!__classPrivateFieldGet(this, _TooltipElementBase_tooltipHovering, "f") || target === this._base) {
815
+ __classPrivateFieldSet(this, _TooltipElementBase_tooltipHovering, false, "f");
514
816
  this.hide();
515
817
  }
516
818
  }
517
819
  }));
518
820
  /** @private */
519
- _M3eTooltipElement_longPressController.set(this, new LongPressController(this, {
821
+ _TooltipElementBase_longPressController.set(this, new LongPressController(this, {
520
822
  target: null,
521
823
  callback: pressed => {
824
+ if (this._isInteractive) return;
522
825
  if (pressed) {
523
826
  this.show();
524
827
  } else {
@@ -531,11 +834,6 @@ let M3eTooltipElement = M3eTooltipElement_1 = class M3eTooltipElement extends Ht
531
834
  * @default false
532
835
  */
533
836
  this.disabled = false;
534
- /**
535
- * The position of the tooltip.
536
- * @default "below"
537
- */
538
- this.position = "below";
539
837
  /**
540
838
  * The mode in which to handle touch gestures.
541
839
  * @default "auto"
@@ -547,54 +845,54 @@ let M3eTooltipElement = M3eTooltipElement_1 = class M3eTooltipElement extends Ht
547
845
  * @default 0
548
846
  */
549
847
  get showDelay() {
550
- return __classPrivateFieldGet(this, _M3eTooltipElement_hoverController, "f").startDelay;
848
+ return __classPrivateFieldGet(this, _TooltipElementBase_hoverController, "f").startDelay;
551
849
  }
552
850
  set showDelay(value) {
553
- __classPrivateFieldGet(this, _M3eTooltipElement_hoverController, "f").startDelay = value;
851
+ __classPrivateFieldGet(this, _TooltipElementBase_hoverController, "f").startDelay = value;
554
852
  }
555
853
  /**
556
854
  * The amount of time, in milliseconds, before hiding the tooltip.
557
855
  * @default 200
558
856
  */
559
857
  get hideDelay() {
560
- return __classPrivateFieldGet(this, _M3eTooltipElement_hoverController, "f").endDelay;
858
+ return __classPrivateFieldGet(this, _TooltipElementBase_hoverController, "f").endDelay;
561
859
  }
562
860
  set hideDelay(value) {
563
- __classPrivateFieldGet(this, _M3eTooltipElement_hoverController, "f").endDelay = value;
861
+ __classPrivateFieldGet(this, _TooltipElementBase_hoverController, "f").endDelay = value;
862
+ }
863
+ /** Whether the tooltip is currently open. */
864
+ get isOpen() {
865
+ return _a.__openTooltips.includes(this);
866
+ }
867
+ /**
868
+ * Whether the tooltip is interactive.
869
+ * @internal
870
+ */
871
+ get _isInteractive() {
872
+ return false;
564
873
  }
565
874
  /** @inheritdoc */
566
875
  attach(control) {
567
876
  super.attach(control);
568
- if (__classPrivateFieldGet(this, _M3eTooltipElement_message, "f")) {
569
- M3eAriaDescriber.describe(control, __classPrivateFieldGet(this, _M3eTooltipElement_message, "f"));
570
- }
571
877
  if (M3ePlatform.iOS || M3ePlatform.Android) {
572
- __classPrivateFieldGet(this, _M3eTooltipElement_longPressController, "f").observe(control);
573
- __classPrivateFieldGet(this, _M3eTooltipElement_instances, "m", _M3eTooltipElement_disableNativeGesturesIfNecessary).call(this);
878
+ __classPrivateFieldGet(this, _TooltipElementBase_longPressController, "f").observe(control);
879
+ __classPrivateFieldGet(this, _TooltipElementBase_instances, "m", _TooltipElementBase_disableNativeGesturesIfNecessary).call(this);
574
880
  } else {
575
- __classPrivateFieldGet(this, _M3eTooltipElement_hoverController, "f").observe(control);
881
+ __classPrivateFieldGet(this, _TooltipElementBase_hoverController, "f").observe(control);
576
882
  }
577
- control.addEventListener("click", __classPrivateFieldGet(this, _M3eTooltipElement_clickHandler, "f"));
883
+ control.addEventListener("click", __classPrivateFieldGet(this, _TooltipElementBase_controlClickHandler, "f"));
578
884
  }
579
885
  /** @inheritdoc */
580
886
  detach() {
581
887
  if (this.control) {
582
- if (__classPrivateFieldGet(this, _M3eTooltipElement_message, "f")) {
583
- M3eAriaDescriber.removeDescription(this.control, __classPrivateFieldGet(this, _M3eTooltipElement_message, "f"));
584
- }
585
- __classPrivateFieldGet(this, _M3eTooltipElement_hoverController, "f").unobserve(this.control);
586
- __classPrivateFieldGet(this, _M3eTooltipElement_longPressController, "f").observe(this.control);
587
- this.control.removeEventListener("click", __classPrivateFieldGet(this, _M3eTooltipElement_clickHandler, "f"));
888
+ __classPrivateFieldGet(this, _TooltipElementBase_hoverController, "f").unobserve(this.control);
889
+ __classPrivateFieldGet(this, _TooltipElementBase_longPressController, "f").observe(this.control);
890
+ this.control.removeEventListener("click", __classPrivateFieldGet(this, _TooltipElementBase_controlClickHandler, "f"));
588
891
  this.hide();
589
892
  }
590
893
  super.detach();
591
894
  }
592
895
  /** @inheritdoc */
593
- connectedCallback() {
594
- super.connectedCallback();
595
- this.ariaHidden = "true";
596
- }
597
- /** @inheritdoc */
598
896
  update(changedProperties) {
599
897
  super.update(changedProperties);
600
898
  if (changedProperties.has("disabled") && this.disabled) {
@@ -602,8 +900,11 @@ let M3eTooltipElement = M3eTooltipElement_1 = class M3eTooltipElement extends Ht
602
900
  }
603
901
  }
604
902
  /** @inheritdoc */
605
- render() {
606
- return html`<div class="base" popover="manual" @toggle="${__classPrivateFieldGet(this, _M3eTooltipElement_instances, "m", _M3eTooltipElement_handleToggle)}"><slot @slotchange="${__classPrivateFieldGet(this, _M3eTooltipElement_instances, "m", _M3eTooltipElement_handleSlotChange)}"></slot></div>`;
903
+ firstUpdated(_changedProperties) {
904
+ super.firstUpdated(_changedProperties);
905
+ if (this._base) {
906
+ __classPrivateFieldGet(this, _TooltipElementBase_hoverController, "f").observe(this._base);
907
+ }
607
908
  }
608
909
  /**
609
910
  * Manually shows the tooltip.
@@ -611,103 +912,467 @@ let M3eTooltipElement = M3eTooltipElement_1 = class M3eTooltipElement extends Ht
611
912
  */
612
913
  async show() {
613
914
  if (!this.control || this.disabled || isDisabledMixin(this.control) && this.control.disabled) return;
614
- M3eTooltipElement_1.__openTooltips.filter(x => x !== this).forEach(x => x.hide());
615
- this._base.showPopover();
616
- __classPrivateFieldSet(this, _M3eTooltipElement_anchorCleanup, await positionAnchor(this._base, this.control, {
617
- position: this.position === "above" ? "top" : this.position === "below" ? "bottom" : this.position === "before" ? M3eDirectionality.current === "ltr" ? "left" : "right" : M3eDirectionality.current === "ltr" ? "right" : "left",
915
+ _a.__openTooltips.filter(x => x !== this).forEach(x => x.hide());
916
+ __classPrivateFieldSet(this, _TooltipElementBase_anchorCleanup, await positionAnchor(this._base, this.control, {
917
+ position: this._anchorPosition,
618
918
  inline: true,
619
919
  flip: true,
620
920
  shift: true,
621
921
  offset: TOOLTIP_OFFSET
622
- }, (x, y) => {
623
- if (M3eDirectionality.current === "rtl") {
624
- this._base.style.right = `${window.innerWidth - x - this._base.clientWidth}px`;
625
- this._base.style.left = "";
626
- } else {
627
- this._base.style.left = `${x}px`;
628
- this._base.style.right = "";
629
- }
630
- this._base.style.top = `${y}px`;
631
- }), "f");
632
- if (!M3eTooltipElement_1.__openTooltips.includes(this)) {
633
- M3eTooltipElement_1.__openTooltips.push(this);
922
+ }, (x, y) => this._updatePosition(this._base, x, y)), "f");
923
+ this._base.showPopover();
924
+ if (!_a.__openTooltips.includes(this)) {
925
+ _a.__openTooltips.push(this);
634
926
  }
635
927
  }
636
928
  /** Manually hides the tooltip. */
637
929
  hide() {
638
930
  this._base.hidePopover();
639
- __classPrivateFieldGet(this, _M3eTooltipElement_anchorCleanup, "f")?.call(this);
640
- __classPrivateFieldSet(this, _M3eTooltipElement_anchorCleanup, undefined, "f");
641
- __classPrivateFieldGet(this, _M3eTooltipElement_hoverController, "f").clearDelays();
642
- }
643
- };
644
- _M3eTooltipElement_message = new WeakMap();
645
- _M3eTooltipElement_for = new WeakMap();
646
- _M3eTooltipElement_anchorCleanup = new WeakMap();
647
- _M3eTooltipElement_clickHandler = new WeakMap();
648
- _M3eTooltipElement_hoverController = new WeakMap();
649
- _M3eTooltipElement_longPressController = new WeakMap();
650
- _M3eTooltipElement_instances = new WeakSet();
651
- _M3eTooltipElement_handleSlotChange = function _M3eTooltipElement_handleSlotChange() {
652
- if (this.isConnected && this.control) {
653
- if (__classPrivateFieldGet(this, _M3eTooltipElement_message, "f")) {
654
- M3eAriaDescriber.removeDescription(this.control, __classPrivateFieldGet(this, _M3eTooltipElement_message, "f"));
655
- }
656
- __classPrivateFieldSet(this, _M3eTooltipElement_message, this.textContent, "f");
657
- if (__classPrivateFieldGet(this, _M3eTooltipElement_message, "f")) {
658
- M3eAriaDescriber.describe(this.control, __classPrivateFieldGet(this, _M3eTooltipElement_message, "f"));
931
+ __classPrivateFieldGet(this, _TooltipElementBase_anchorCleanup, "f")?.call(this);
932
+ __classPrivateFieldSet(this, _TooltipElementBase_anchorCleanup, undefined, "f");
933
+ __classPrivateFieldGet(this, _TooltipElementBase_hoverController, "f").clearDelays();
934
+ if (_a.__openTooltips.includes(this)) {
935
+ _a.__openTooltips = _a.__openTooltips.filter(x => x !== this);
659
936
  }
660
937
  }
661
- };
662
- _M3eTooltipElement_handleToggle = function _M3eTooltipElement_handleToggle(e) {
663
- if (e.newState === "open") {
664
- const multiline = this._base.getBoundingClientRect().height > parseFloat(getComputedStyle(this._base).minHeight);
665
- this.classList.toggle("-multiline", multiline);
938
+ }
939
+ _a = TooltipElementBase, _TooltipElementBase_for = new WeakMap(), _TooltipElementBase_anchorCleanup = new WeakMap(), _TooltipElementBase_tooltipHovering = new WeakMap(), _TooltipElementBase_controlClickHandler = new WeakMap(), _TooltipElementBase_hoverController = new WeakMap(), _TooltipElementBase_longPressController = new WeakMap(), _TooltipElementBase_instances = new WeakSet(), _TooltipElementBase_handleControlClick = function _TooltipElementBase_handleControlClick() {
940
+ if (this._isInteractive) {
941
+ if (_a.__openTooltips.includes(this)) {
942
+ this.hide();
943
+ } else {
944
+ this.show();
945
+ }
946
+ } else {
947
+ this.hide();
666
948
  }
667
- };
668
- _M3eTooltipElement_disableNativeGesturesIfNecessary = function _M3eTooltipElement_disableNativeGesturesIfNecessary() {
669
- if (this.touchGestures !== "off" && __classPrivateFieldGet(this, _M3eTooltipElement_for, "f")) {
949
+ }, _TooltipElementBase_disableNativeGesturesIfNecessary = function _TooltipElementBase_disableNativeGesturesIfNecessary() {
950
+ if (this.touchGestures !== "off" && __classPrivateFieldGet(this, _TooltipElementBase_for, "f")) {
670
951
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
671
- const style = __classPrivateFieldGet(this, _M3eTooltipElement_for, "f").style;
952
+ const style = __classPrivateFieldGet(this, _TooltipElementBase_for, "f").style;
672
953
  // If gestures are set to `auto`, we don't disable text selection on inputs and
673
954
  // textareas, because it prevents the user from typing into them on iOS Safari.
674
- if (this.touchGestures === "on" || __classPrivateFieldGet(this, _M3eTooltipElement_for, "f").nodeName !== "INPUT" && __classPrivateFieldGet(this, _M3eTooltipElement_for, "f").nodeName !== "TEXTAREA") {
955
+ if (this.touchGestures === "on" || __classPrivateFieldGet(this, _TooltipElementBase_for, "f").nodeName !== "INPUT" && __classPrivateFieldGet(this, _TooltipElementBase_for, "f").nodeName !== "TEXTAREA") {
675
956
  style.userSelect = style.msUserSelect = style.webkitUserSelect = style.MozUserSelect = "none";
676
957
  }
677
958
  // If we have `auto` gestures and the element uses native HTML dragging,
678
959
  // we don't set `-webkit-user-drag` because it prevents the native behavior.
679
- if (this.touchGestures === "on" || !__classPrivateFieldGet(this, _M3eTooltipElement_for, "f").draggable) {
960
+ if (this.touchGestures === "on" || !__classPrivateFieldGet(this, _TooltipElementBase_for, "f").draggable) {
680
961
  style.webkitUserDrag = "none";
681
962
  }
682
963
  style.touchAction = "none";
683
964
  style.webkitTapHighlightColor = "transparent";
684
965
  }
685
966
  };
686
- /** The styles of the element. */
687
- M3eTooltipElement.styles = css`:host { display: contents; } .base { position: absolute; pointer-events: none; margin: unset; border: unset; word-break: normal; overflow-wrap: anywhere; padding: var(--m3e-tooltip-padding, 0.25rem 0.5rem); min-width: var(--m3e-tooltip-min-width, 2.5rem); max-width: var(--m3e-tooltip-max-width, 12.5rem); min-height: var(--m3e-tooltip-min-height, 1.5rem); max-height: var(--m3e-tooltip-max-height, 40vh); box-sizing: border-box; overflow: hidden; text-align: center; border-radius: var(--m3e-tooltip-shape, ${DesignToken.shape.corner.extraSmall}); background-color: var(--m3e-tooltip-container-color, ${DesignToken.color.inverseSurface}); color: var(--m3e-tooltip-supporting-text-color, ${DesignToken.color.inverseOnSurface}); font-size: var(--m3e-tooltip-supporting-text-font-size, ${DesignToken.typescale.standard.body.small.fontSize}); font-weight: var( --m3e-tooltip-supporting-text-font-weight, ${DesignToken.typescale.standard.body.small.fontWeight} ); line-height: var( --m3e-tooltip-supporting-text-line-height, ${DesignToken.typescale.standard.body.small.lineHeight} ); letter-spacing: var( --m3e-tooltip-supporting-text-tracking, ${DesignToken.typescale.standard.body.small.tracking} ); visibility: hidden; opacity: 0; transform: scale(0.8); transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard},
688
- transform ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard},
689
- overlay ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete,
690
- visibility ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete`)}; } :host(.-multiline) .base { text-align: start; } .base::backdrop { background-color: transparent; } .base:not(:popover-open) { visibility: hidden; opacity: 0; transform: scale(0.8); } .base:popover-open { visibility: visible; opacity: 1; transform: scale(1); } @starting-style { .base:popover-open { opacity: 0; transform: scale(0.8); } } @media (prefers-reduced-motion) { .base { transition: none; } } @media (forced-colors: active) { .base { background-color: Canvas; color: CanvasText; box-sizing: border-box; border: 1px solid CanvasText; } }`;
691
967
  /** @private */
692
- M3eTooltipElement.__openTooltips = new Array();
693
- __decorate([e(".base")], M3eTooltipElement.prototype, "_base", void 0);
694
- __decorate([n({
968
+ TooltipElementBase.__openTooltips = new Array();
969
+ __decorate([e$1(".base")], TooltipElementBase.prototype, "_base", void 0);
970
+ __decorate([n$1({
695
971
  type: Boolean,
696
972
  reflect: true
697
- })], M3eTooltipElement.prototype, "disabled", void 0);
698
- __decorate([n()], M3eTooltipElement.prototype, "position", void 0);
699
- __decorate([n({
973
+ })], TooltipElementBase.prototype, "disabled", void 0);
974
+ __decorate([n$1({
700
975
  attribute: "show-delay",
701
976
  type: Number
702
- })], M3eTooltipElement.prototype, "showDelay", null);
703
- __decorate([n({
977
+ })], TooltipElementBase.prototype, "showDelay", null);
978
+ __decorate([n$1({
704
979
  attribute: "hide-delay",
705
980
  type: Number
706
- })], M3eTooltipElement.prototype, "hideDelay", null);
707
- __decorate([n({
981
+ })], TooltipElementBase.prototype, "hideDelay", null);
982
+ __decorate([n$1({
708
983
  attribute: "touch-gestures"
709
- })], M3eTooltipElement.prototype, "touchGestures", void 0);
710
- M3eTooltipElement = M3eTooltipElement_1 = __decorate([t$1("m3e-tooltip")], M3eTooltipElement);
984
+ })], TooltipElementBase.prototype, "touchGestures", void 0);
985
+
986
+ var _M3eRichTooltipElement_instances, _M3eRichTooltipElement_id, _M3eRichTooltipElement_subheadText, _M3eRichTooltipElement_contentText, _M3eRichTooltipElement_message, _M3eRichTooltipElement_messageRegistered, _M3eRichTooltipElement_documentClickHandler, _M3eRichTooltipElement_handleBeforeToggle, _M3eRichTooltipElement_handleToggle, _M3eRichTooltipElement_handleDocumentClick, _M3eRichTooltipElement_handleKeyDown, _M3eRichTooltipElement_handleSubheadSlotChange, _M3eRichTooltipElement_handleContentSlotChange, _M3eRichTooltipElement_handleActionsSlotChange, _M3eRichTooltipElement_updateMessage;
987
+ var M3eRichTooltipElement_1;
988
+ /**
989
+ * Provides contextual details for a control, such as explaining the value or purpose of a feature.
990
+ *
991
+ * @description
992
+ * The `m3e-rich-tooltip` component provides contextual guidance for a control. It supports an optional
993
+ * subhead, multi-line supporting text, and optional action elements. When non‑interactive, it behaves
994
+ * as a standard tooltip and contributes an `aria-describedby` message to its control. When interactive,
995
+ * it becomes a lightweight anchored dialog with manual popover behavior, keyboard dismissal, and
996
+ * click‑outside light‑dismiss.
997
+ *
998
+ * @example
999
+ * The following example illustrates connecting an interactive rich tooltip to a button using the `for` attribute.
1000
+ * ```html
1001
+ * <m3e-icon-button id="btnSettings">
1002
+ * <m3e-icon name="settings"></m3e-icon>
1003
+ * </m3e-icon-button>
1004
+ * <m3e-rich-tooltip for="btnSettings">
1005
+ * <span slot="subhead">New settings available</span>
1006
+ * Now you can adjust the uploaded image quality, and upgrade your available storage space.
1007
+ * <div slot="actions">
1008
+ * <m3e-button>
1009
+ * <m3e-rich-tooltip-action>Learn more</m3e-rich-tooltip-action>
1010
+ * </m3e-button>
1011
+ * </div>
1012
+ * </m3e-rich-tooltip>
1013
+ * ```
1014
+ *
1015
+ * @tag m3e-rich-tooltip
1016
+ *
1017
+ * @slot - The main supporting text of the tooltip.
1018
+ * @slot subhead - Optional subhead text displayed above the supporting content.
1019
+ * @slot actions - Optional action elements displayed at the bottom of the tooltip.
1020
+ *
1021
+ * @attr disabled - Whether the element is disabled.
1022
+ * @attr for - The identifier of the interactive control to which this element is attached.
1023
+ * @attr hide-delay - The amount of time, in milliseconds, before hiding the tooltip.
1024
+ * @attr position - The position of the tooltip.
1025
+ * @attr show-delay - The amount of time, in milliseconds, before showing the tooltip.
1026
+ *
1027
+ * @fires beforetoggle - Dispatched before the toggle state changes.
1028
+ * @fires toggle - Dispatched after the toggle state has changed.
1029
+ *
1030
+ * @cssprop --m3e-rich-tooltip-padding-top - Top padding of the tooltip container.
1031
+ * @cssprop --m3e-rich-tooltip-padding-bottom - Bottom padding of the tooltip container (when no actions are present).
1032
+ * @cssprop --m3e-rich-tooltip-padding-inline - Horizontal padding of the tooltip container.
1033
+ * @cssprop --m3e-rich-tooltip-max-width - Maximum width of the tooltip surface.
1034
+ * @cssprop --m3e-rich-tooltip-shape - Border‑radius of the tooltip container.
1035
+ * @cssprop --m3e-rich-tooltip-container-color - Background color of the tooltip surface.
1036
+ * @cssprop --m3e-rich-tooltip-subhead-color - Color of the subhead text.
1037
+ * @cssprop --m3e-rich-tooltip-subhead-font-size - Font size of the subhead text.
1038
+ * @cssprop --m3e-rich-tooltip-subhead-font-weight - Font weight of the subhead text.
1039
+ * @cssprop --m3e-rich-tooltip-subhead-line-height - Line height of the subhead text.
1040
+ * @cssprop --m3e-rich-tooltip-subhead-tracking - Letter‑spacing of the subhead text.
1041
+ * @cssprop --m3e-rich-tooltip-subhead-bottom-space - Space below the subhead before the supporting text.
1042
+ * @cssprop --m3e-rich-tooltip-supporting-text-color - Color of the supporting text.
1043
+ * @cssprop --m3e-rich-tooltip-supporting-text-font-size - Font size of the supporting text.
1044
+ * @cssprop --m3e-rich-tooltip-supporting-text-font-weight - Font weight of the supporting text.
1045
+ * @cssprop --m3e-rich-tooltip-supporting-text-line-height - Line height of the supporting text.
1046
+ * @cssprop --m3e-rich-tooltip-supporting-text-tracking - Letter‑spacing of the supporting text.
1047
+ * @cssprop --m3e-rich-tooltip-actions-padding-inline - Horizontal padding applied to the actions slot area.
1048
+ * @cssprop --m3e-rich-tooltip-actions-top-space - Space above the actions slot.
1049
+ * @cssprop --m3e-rich-tooltip-actions-bottom-space - Space below the actions slot.
1050
+ */
1051
+ let M3eRichTooltipElement = M3eRichTooltipElement_1 = class M3eRichTooltipElement extends TooltipElementBase {
1052
+ constructor() {
1053
+ super(...arguments);
1054
+ _M3eRichTooltipElement_instances.add(this);
1055
+ /** @private */
1056
+ _M3eRichTooltipElement_id.set(this, M3eRichTooltipElement_1.__nextId++);
1057
+ /** @private */
1058
+ _M3eRichTooltipElement_subheadText.set(this, "");
1059
+ /** @private */
1060
+ _M3eRichTooltipElement_contentText.set(this, "");
1061
+ /** @private */
1062
+ _M3eRichTooltipElement_message.set(this, "");
1063
+ /** @private */
1064
+ _M3eRichTooltipElement_messageRegistered.set(this, false);
1065
+ /** @private */
1066
+ this._hasSubhead = false;
1067
+ /** @private */
1068
+ this._interactive = false;
1069
+ /** @private */
1070
+ _M3eRichTooltipElement_documentClickHandler.set(this, e => __classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_handleDocumentClick).call(this, e));
1071
+ /**
1072
+ * The position of the tooltip.
1073
+ * @default "below-after"
1074
+ */
1075
+ this.position = "below-after";
1076
+ }
1077
+ /** @inheritdoc */
1078
+ get _isInteractive() {
1079
+ return this._interactive;
1080
+ }
1081
+ /** @inheritdoc */
1082
+ get _anchorPosition() {
1083
+ switch (this.position) {
1084
+ case "above":
1085
+ return "top";
1086
+ case "above-after":
1087
+ return M3eDirectionality.current === "rtl" ? "top-start" : "top-end";
1088
+ case "above-before":
1089
+ return M3eDirectionality.current === "rtl" ? "top-end" : "top-start";
1090
+ case "after":
1091
+ return M3eDirectionality.current === "rtl" ? "left" : "right";
1092
+ case "before":
1093
+ return M3eDirectionality.current === "rtl" ? "right" : "left";
1094
+ case "below":
1095
+ return "bottom";
1096
+ case "below-after":
1097
+ return M3eDirectionality.current === "rtl" ? "bottom-start" : "bottom-end";
1098
+ case "below-before":
1099
+ return M3eDirectionality.current === "rtl" ? "bottom-end" : "bottom-start";
1100
+ }
1101
+ }
1102
+ /** @inheritdoc */
1103
+ render() {
1104
+ const subheadId = this._interactive && this._hasSubhead ? `m3e-rich-tooltip-${__classPrivateFieldGet(this, _M3eRichTooltipElement_id, "f")}-subhead` : undefined;
1105
+ return html`<div class="base" popover="manual" role="${o(this._interactive ? "dialog" : undefined)}" aria-labelledby="${o(subheadId)}" @keydown="${__classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_handleKeyDown)}" @beforetoggle="${__classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_handleBeforeToggle)}" @toggle="${__classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_handleToggle)}"><m3e-elevation level="3"></m3e-elevation><div class="subhead" id="${o(subheadId)}"><slot name="subhead" @slotchange="${__classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_handleSubheadSlotChange)}"></slot></div><div class="content"><slot @slotchange="${__classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_handleContentSlotChange)}"></slot></div><div class="actions"><slot name="actions" @slotchange="${__classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_handleActionsSlotChange)}"></slot></div></div>`;
1106
+ }
1107
+ /** @inheritdoc */
1108
+ show() {
1109
+ if (this._interactive) {
1110
+ document.addEventListener("click", __classPrivateFieldGet(this, _M3eRichTooltipElement_documentClickHandler, "f"));
1111
+ }
1112
+ return super.show();
1113
+ }
1114
+ /**
1115
+ * Manually hides the tooltip.
1116
+ * @param [restoreFocus=true] Whether to restore focus to the element that triggered the interactive tooltip.
1117
+ */
1118
+ hide(restoreFocus = true) {
1119
+ if (this._interactive) {
1120
+ document.removeEventListener("click", __classPrivateFieldGet(this, _M3eRichTooltipElement_documentClickHandler, "f"));
1121
+ }
1122
+ super.hide();
1123
+ if (restoreFocus && this._interactive && this.control && M3eInteractivityChecker.isFocusable(this.control)) {
1124
+ this.control.focus();
1125
+ }
1126
+ }
1127
+ /** @inheritdoc */
1128
+ attach(control) {
1129
+ super.attach(control);
1130
+ __classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_updateMessage).call(this);
1131
+ if (this._interactive) {
1132
+ control.ariaHasPopup = "dialog";
1133
+ }
1134
+ }
1135
+ /** @inheritdoc */
1136
+ update(changedProperties) {
1137
+ super.update(changedProperties);
1138
+ if (changedProperties.has("_interactive")) {
1139
+ this.ariaHidden = this._interactive ? null : "true";
1140
+ __classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_updateMessage).call(this);
1141
+ if (this.control && this._interactive) {
1142
+ this.control.ariaHasPopup = "dialog";
1143
+ }
1144
+ }
1145
+ }
1146
+ /** @inheritdoc */
1147
+ _updatePosition(base, x, y) {
1148
+ if (this.position.includes("before") && this.position !== "before") {
1149
+ if (M3eDirectionality.current === "rtl") {
1150
+ x += this.control?.clientWidth ?? 0;
1151
+ } else {
1152
+ x -= this.control?.clientWidth ?? 0;
1153
+ }
1154
+ }
1155
+ if (this.position.includes("after") && this.position !== "after") {
1156
+ if (M3eDirectionality.current === "rtl") {
1157
+ x -= this.control?.clientWidth ?? 0;
1158
+ } else {
1159
+ x += this.control?.clientWidth ?? 0;
1160
+ }
1161
+ }
1162
+ if (M3eDirectionality.current === "rtl") {
1163
+ base.style.right = `${window.innerWidth - x - base.clientWidth}px`;
1164
+ base.style.left = "";
1165
+ } else {
1166
+ base.style.left = `${x}px`;
1167
+ base.style.right = "";
1168
+ }
1169
+ base.style.top = `${y}px`;
1170
+ }
1171
+ };
1172
+ _M3eRichTooltipElement_id = new WeakMap();
1173
+ _M3eRichTooltipElement_subheadText = new WeakMap();
1174
+ _M3eRichTooltipElement_contentText = new WeakMap();
1175
+ _M3eRichTooltipElement_message = new WeakMap();
1176
+ _M3eRichTooltipElement_messageRegistered = new WeakMap();
1177
+ _M3eRichTooltipElement_documentClickHandler = new WeakMap();
1178
+ _M3eRichTooltipElement_instances = new WeakSet();
1179
+ _M3eRichTooltipElement_handleBeforeToggle = function _M3eRichTooltipElement_handleBeforeToggle(e) {
1180
+ const forwarded = new ToggleEvent("beforetoggle", {
1181
+ oldState: e.oldState,
1182
+ newState: e.newState,
1183
+ bubbles: true,
1184
+ composed: true,
1185
+ cancelable: e.cancelable
1186
+ });
1187
+ if (!this.dispatchEvent(forwarded)) {
1188
+ e.preventDefault();
1189
+ this.hide();
1190
+ }
1191
+ };
1192
+ _M3eRichTooltipElement_handleToggle = function _M3eRichTooltipElement_handleToggle(e) {
1193
+ const forwarded = new ToggleEvent("toggle", {
1194
+ oldState: e.oldState,
1195
+ newState: e.newState,
1196
+ bubbles: true,
1197
+ composed: true
1198
+ });
1199
+ this.dispatchEvent(forwarded);
1200
+ };
1201
+ _M3eRichTooltipElement_handleDocumentClick = function _M3eRichTooltipElement_handleDocumentClick(e) {
1202
+ if (!e.composedPath().some(x => x instanceof M3eRichTooltipElement_1 || x === this.control)) {
1203
+ this.hide();
1204
+ }
1205
+ };
1206
+ _M3eRichTooltipElement_handleKeyDown = function _M3eRichTooltipElement_handleKeyDown(e) {
1207
+ if (e.key === "Escape" && !e.shiftKey && !e.ctrlKey) {
1208
+ e.preventDefault();
1209
+ this.hide();
1210
+ }
1211
+ };
1212
+ _M3eRichTooltipElement_handleSubheadSlotChange = function _M3eRichTooltipElement_handleSubheadSlotChange(e) {
1213
+ this._hasSubhead = hasAssignedNodes(e.target);
1214
+ this.shadowRoot?.querySelector(".base")?.classList.toggle("has-subhead", this._hasSubhead);
1215
+ __classPrivateFieldSet(this, _M3eRichTooltipElement_subheadText, this._hasSubhead ? getTextContent(e.target, true) : "", "f");
1216
+ __classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_updateMessage).call(this);
1217
+ };
1218
+ _M3eRichTooltipElement_handleContentSlotChange = function _M3eRichTooltipElement_handleContentSlotChange(e) {
1219
+ this._interactive = M3eInteractivityChecker.findInteractiveElements(this).length > 0;
1220
+ __classPrivateFieldSet(this, _M3eRichTooltipElement_contentText, getTextContent(e.target, true), "f");
1221
+ __classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_updateMessage).call(this);
1222
+ };
1223
+ _M3eRichTooltipElement_handleActionsSlotChange = function _M3eRichTooltipElement_handleActionsSlotChange(e) {
1224
+ this.shadowRoot?.querySelector(".base")?.classList.toggle("has-actions", hasAssignedNodes(e.target));
1225
+ this._interactive = M3eInteractivityChecker.findInteractiveElements(this).length > 0;
1226
+ __classPrivateFieldGet(this, _M3eRichTooltipElement_instances, "m", _M3eRichTooltipElement_updateMessage).call(this);
1227
+ };
1228
+ _M3eRichTooltipElement_updateMessage = function _M3eRichTooltipElement_updateMessage() {
1229
+ const message = __classPrivateFieldGet(this, _M3eRichTooltipElement_subheadText, "f") ? `${__classPrivateFieldGet(this, _M3eRichTooltipElement_subheadText, "f")}/n${__classPrivateFieldGet(this, _M3eRichTooltipElement_contentText, "f")}` : __classPrivateFieldGet(this, _M3eRichTooltipElement_contentText, "f");
1230
+ if (this.isConnected && this.control) {
1231
+ if (__classPrivateFieldGet(this, _M3eRichTooltipElement_message, "f") && __classPrivateFieldGet(this, _M3eRichTooltipElement_messageRegistered, "f")) {
1232
+ M3eAriaDescriber.removeDescription(this.control, __classPrivateFieldGet(this, _M3eRichTooltipElement_message, "f"));
1233
+ __classPrivateFieldSet(this, _M3eRichTooltipElement_messageRegistered, false, "f");
1234
+ }
1235
+ __classPrivateFieldSet(this, _M3eRichTooltipElement_message, message, "f");
1236
+ if (__classPrivateFieldGet(this, _M3eRichTooltipElement_message, "f") && !this._interactive) {
1237
+ M3eAriaDescriber.describe(this.control, __classPrivateFieldGet(this, _M3eRichTooltipElement_message, "f"));
1238
+ __classPrivateFieldSet(this, _M3eRichTooltipElement_messageRegistered, true, "f");
1239
+ }
1240
+ }
1241
+ };
1242
+ /** The styles of the element. */
1243
+ M3eRichTooltipElement.styles = css`:host { display: contents; } .base { display: flex; flex-direction: column; position: absolute; padding: unset; margin: unset; border: unset; padding-block-start: var(--m3e-rich-tooltip-padding-top, 0.75rem); padding-inline: var(--m3e-rich-tooltip-padding-inline, 1rem); max-width: var(--m3e-rich-tooltip-max-width, 20rem); box-sizing: border-box; overflow: visible; border-radius: var(--m3e-rich-tooltip-shape, ${DesignToken.shape.corner.medium}); background-color: var(--m3e-rich-tooltip-container-color, ${DesignToken.color.surfaceContainer}); visibility: hidden; opacity: 0; transform: scale(0.8); transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard},
1244
+ transform ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard},
1245
+ overlay ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete,
1246
+ visibility ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete`)}; } .base:not(.has-actions) { padding-block-end: var(--m3e-rich-tooltip-padding-bottom, 0.75rem); } .base::backdrop { background-color: transparent; } .base:not(:popover-open) { visibility: hidden; opacity: 0; transform: scale(0.8); } .base:popover-open { visibility: visible; opacity: 1; transform: scale(1); } .base:not(.has-subhead) .subhead, .base:not(.has-actions) .actions { display: none; } .subhead { color: var(--m3e-rich-tooltip-subhead-color, ${DesignToken.color.onSurfaceVariant}); font-size: var(--m3e-rich-tooltip-subhead-font-size, ${DesignToken.typescale.standard.title.small.fontSize}); font-weight: var( --m3e-rich-tooltip-subhead-font-weight, ${DesignToken.typescale.standard.title.small.fontWeight} ); line-height: var( --m3e-rich-tooltip-subhead-line-height, ${DesignToken.typescale.standard.title.small.lineHeight} ); letter-spacing: var(--m3e-rich-tooltip-subhead-tracking, ${DesignToken.typescale.standard.title.small.tracking}); padding-block-end: var(--m3e-rich-tooltip-subhead-bottom-space, 0.25rem); } .content { color: var(--m3e-rich-tooltip-supporting-text-color, ${DesignToken.color.onSurfaceVariant}); font-size: var( --m3e-rich-tooltip-supporting-text-font-size, ${DesignToken.typescale.standard.body.medium.fontSize} ); font-weight: var( --m3e-rich-tooltip-supporting-text-font-weight, ${DesignToken.typescale.standard.body.medium.fontWeight} ); line-height: var( --m3e-rich-tooltip-supporting-text-line-height, ${DesignToken.typescale.standard.body.medium.lineHeight} ); letter-spacing: var( --m3e-rich-tooltip-supporting-text-tracking, ${DesignToken.typescale.standard.body.medium.tracking} ); } .actions { margin-inline: calc( 0px - calc( var(--m3e-rich-tooltip-padding-inline, 1rem) - var(--m3e-rich-tooltip-actions-padding-inline, 0.25rem) ) ); padding-block-start: var(--m3e-rich-tooltip-actions-top-space, 0.75rem); padding-block-end: var(--m3e-rich-tooltip-actions-bottom-space, 0.5rem); } ::slotted([slot="actions"]) { flex: none; display: flex; align-items: center; min-height: 1.5rem; column-gap: 0.5rem; } ::slotted([slot="actions"][end]) { justify-content: flex-end; } @starting-style { .base:popover-open { opacity: 0; transform: scale(0.8); } } @media (prefers-reduced-motion) { .base { transition: none; } } @media (forced-colors: active) { .base { background-color: Canvas; color: CanvasText; box-sizing: border-box; border: 1px solid CanvasText; } }`;
1247
+ /** @private */
1248
+ M3eRichTooltipElement.__nextId = 0;
1249
+ __decorate([r$1()], M3eRichTooltipElement.prototype, "_hasSubhead", void 0);
1250
+ __decorate([r$1()], M3eRichTooltipElement.prototype, "_interactive", void 0);
1251
+ __decorate([n$1()], M3eRichTooltipElement.prototype, "position", void 0);
1252
+ M3eRichTooltipElement = M3eRichTooltipElement_1 = __decorate([t$2("m3e-rich-tooltip")], M3eRichTooltipElement);
1253
+
1254
+ var _M3eTooltipElement_instances, _M3eTooltipElement_message, _M3eTooltipElement_handleSlotChange, _M3eTooltipElement_handleToggle;
1255
+ /**
1256
+ * Adds additional context to a button or other UI element.
1257
+ *
1258
+ * @description
1259
+ * The `m3e-tooltip` component provides contextual information in response to user interaction, enhancing comprehension
1260
+ * and reducing ambiguity. Tooltips are positioned relative to a target element and support configurable delays for
1261
+ * show and hide behavior. The component is designed to reinforce accessibility and usability, especially in dense or
1262
+ * icon-driven interfaces. Use the `for` attribute to designate the element for which to provide a tooltip.
1263
+ *
1264
+ * @example
1265
+ * The following example illustrates connecting a tooltip to a button using the `for` attribute.
1266
+ * ```html
1267
+ * <m3e-icon-button id="button" aria-label="Back">
1268
+ * <m3e-icon name="arrow_back"></m3e-icon>
1269
+ * </m3e-icon-button>
1270
+ * <m3e-tooltip for="button">Go Back</m3e-tooltip>
1271
+ * ```
1272
+ *
1273
+ * @tag m3e-tooltip
1274
+ *
1275
+ * @slot - Renders the content of the tooltip.
1276
+ *
1277
+ * @attr disabled - Whether the element is disabled.
1278
+ * @attr for - The identifier of the interactive control to which this element is attached.
1279
+ * @attr hide-delay - The amount of time, in milliseconds, before hiding the tooltip.
1280
+ * @attr position - The position of the tooltip.
1281
+ * @attr show-delay - The amount of time, in milliseconds, before showing the tooltip.
1282
+ *
1283
+ * @cssprop --m3e-tooltip-padding - Internal spacing of the tooltip container.
1284
+ * @cssprop --m3e-tooltip-min-width - Minimum width of the tooltip.
1285
+ * @cssprop --m3e-tooltip-max-width - Maximum width of the tooltip.
1286
+ * @cssprop --m3e-tooltip-min-height - Minimum height of the tooltip container.
1287
+ * @cssprop --m3e-tooltip-max-height - Maximum height of the tooltip.
1288
+ * @cssprop --m3e-tooltip-shape - Border radius of the tooltip container.
1289
+ * @cssprop --m3e-tooltip-container-color - Background color of the tooltip.
1290
+ * @cssprop --m3e-tooltip-supporting-text-color - Text color of supporting text.
1291
+ * @cssprop --m3e-tooltip-supporting-text-font-size - Font size of supporting text.
1292
+ * @cssprop --m3e-tooltip-supporting-text-font-weight - Font weight of supporting text.
1293
+ * @cssprop --m3e-tooltip-supporting-text-line-height - Line height of supporting text.
1294
+ * @cssprop --m3e-tooltip-supporting-text-tracking - Letter spacing of supporting text.
1295
+ */
1296
+ let M3eTooltipElement = class M3eTooltipElement extends TooltipElementBase {
1297
+ constructor() {
1298
+ super(...arguments);
1299
+ _M3eTooltipElement_instances.add(this);
1300
+ /** @private */
1301
+ _M3eTooltipElement_message.set(this, void 0);
1302
+ /**
1303
+ * The position of the tooltip.
1304
+ * @default "below"
1305
+ */
1306
+ this.position = "below";
1307
+ }
1308
+ /** @inheritdoc */
1309
+ get _anchorPosition() {
1310
+ return this.position === "above" ? "top" : this.position === "below" ? "bottom" : this.position === "before" ? M3eDirectionality.current === "ltr" ? "left" : "right" : M3eDirectionality.current === "ltr" ? "right" : "left";
1311
+ }
1312
+ /** @inheritdoc */
1313
+ attach(control) {
1314
+ super.attach(control);
1315
+ if (__classPrivateFieldGet(this, _M3eTooltipElement_message, "f")) {
1316
+ M3eAriaDescriber.describe(control, __classPrivateFieldGet(this, _M3eTooltipElement_message, "f"));
1317
+ }
1318
+ }
1319
+ /** @inheritdoc */
1320
+ detach() {
1321
+ if (this.control && __classPrivateFieldGet(this, _M3eTooltipElement_message, "f")) {
1322
+ M3eAriaDescriber.removeDescription(this.control, __classPrivateFieldGet(this, _M3eTooltipElement_message, "f"));
1323
+ }
1324
+ super.detach();
1325
+ }
1326
+ /** @inheritdoc */
1327
+ connectedCallback() {
1328
+ super.connectedCallback();
1329
+ this.ariaHidden = "true";
1330
+ }
1331
+ /** @inheritdoc */
1332
+ render() {
1333
+ return html`<div class="base" popover="manual" @toggle="${__classPrivateFieldGet(this, _M3eTooltipElement_instances, "m", _M3eTooltipElement_handleToggle)}"><slot @slotchange="${__classPrivateFieldGet(this, _M3eTooltipElement_instances, "m", _M3eTooltipElement_handleSlotChange)}"></slot></div>`;
1334
+ }
1335
+ /** @inheritdoc */
1336
+ _updatePosition(base, x, y) {
1337
+ if (M3eDirectionality.current === "rtl") {
1338
+ base.style.right = `${window.innerWidth - x - base.clientWidth}px`;
1339
+ base.style.left = "";
1340
+ } else {
1341
+ base.style.left = `${x}px`;
1342
+ base.style.right = "";
1343
+ }
1344
+ base.style.top = `${y}px`;
1345
+ }
1346
+ };
1347
+ _M3eTooltipElement_message = new WeakMap();
1348
+ _M3eTooltipElement_instances = new WeakSet();
1349
+ _M3eTooltipElement_handleSlotChange = function _M3eTooltipElement_handleSlotChange(e) {
1350
+ const message = getTextContent(e.target, true);
1351
+ if (this.isConnected && this.control) {
1352
+ if (__classPrivateFieldGet(this, _M3eTooltipElement_message, "f")) {
1353
+ M3eAriaDescriber.removeDescription(this.control, __classPrivateFieldGet(this, _M3eTooltipElement_message, "f"));
1354
+ }
1355
+ __classPrivateFieldSet(this, _M3eTooltipElement_message, message, "f");
1356
+ if (__classPrivateFieldGet(this, _M3eTooltipElement_message, "f")) {
1357
+ M3eAriaDescriber.describe(this.control, __classPrivateFieldGet(this, _M3eTooltipElement_message, "f"));
1358
+ }
1359
+ } else {
1360
+ __classPrivateFieldSet(this, _M3eTooltipElement_message, message, "f");
1361
+ }
1362
+ };
1363
+ _M3eTooltipElement_handleToggle = function _M3eTooltipElement_handleToggle(e) {
1364
+ if (e.newState === "open") {
1365
+ const multiline = this._base.getBoundingClientRect().height > parseFloat(getComputedStyle(this._base).minHeight);
1366
+ this.classList.toggle("-multiline", multiline);
1367
+ }
1368
+ };
1369
+ /** The styles of the element. */
1370
+ M3eTooltipElement.styles = css`:host { display: contents; } .base { position: absolute; pointer-events: none; margin: unset; border: unset; word-break: normal; overflow-wrap: anywhere; padding: var(--m3e-tooltip-padding, 0.25rem 0.5rem); min-width: var(--m3e-tooltip-min-width, 2.5rem); max-width: var(--m3e-tooltip-max-width, 12.5rem); min-height: var(--m3e-tooltip-min-height, 1.5rem); max-height: var(--m3e-tooltip-max-height, 40vh); box-sizing: border-box; overflow: hidden; text-align: center; border-radius: var(--m3e-tooltip-shape, ${DesignToken.shape.corner.extraSmall}); background-color: var(--m3e-tooltip-container-color, ${DesignToken.color.inverseSurface}); color: var(--m3e-tooltip-supporting-text-color, ${DesignToken.color.inverseOnSurface}); font-size: var(--m3e-tooltip-supporting-text-font-size, ${DesignToken.typescale.standard.body.small.fontSize}); font-weight: var( --m3e-tooltip-supporting-text-font-weight, ${DesignToken.typescale.standard.body.small.fontWeight} ); line-height: var( --m3e-tooltip-supporting-text-line-height, ${DesignToken.typescale.standard.body.small.lineHeight} ); letter-spacing: var( --m3e-tooltip-supporting-text-tracking, ${DesignToken.typescale.standard.body.small.tracking} ); visibility: hidden; opacity: 0; transform: scale(0.8); transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard},
1371
+ transform ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard},
1372
+ overlay ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete,
1373
+ visibility ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete`)}; } :host(.-multiline) .base { text-align: start; } .base::backdrop { background-color: transparent; } .base:not(:popover-open) { visibility: hidden; opacity: 0; transform: scale(0.8); } .base:popover-open { visibility: visible; opacity: 1; transform: scale(1); } @starting-style { .base:popover-open { opacity: 0; transform: scale(0.8); } } @media (prefers-reduced-motion) { .base { transition: none; } } @media (forced-colors: active) { .base { background-color: Canvas; color: CanvasText; box-sizing: border-box; border: 1px solid CanvasText; } }`;
1374
+ __decorate([n$1()], M3eTooltipElement.prototype, "position", void 0);
1375
+ M3eTooltipElement = __decorate([t$2("m3e-tooltip")], M3eTooltipElement);
711
1376
 
712
- export { M3eTooltipElement };
1377
+ export { M3eRichTooltipActionElement, M3eRichTooltipElement, M3eTooltipElement, TooltipElementBase };
713
1378
  //# sourceMappingURL=index.js.map