@mgdis/mg-components 6.4.0 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/cjs/{index-911898e4.js → index-1a5a1081.js} +266 -241
  2. package/dist/cjs/index-1a5a1081.js.map +1 -0
  3. package/dist/cjs/{index-a3269bfc.js → index-ede3b3dc.js} +3 -3
  4. package/dist/cjs/{index-a3269bfc.js.map → index-ede3b3dc.js.map} +1 -1
  5. package/dist/cjs/{index.es-325100d7.js → index.es-a112f649.js} +36 -36
  6. package/dist/cjs/index.es-a112f649.js.map +1 -0
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/cjs/mg-action-more_36.cjs.entry.js +2260 -1872
  9. package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
  10. package/dist/cjs/mg-alert.cjs.entry.js +7 -7
  11. package/dist/cjs/mg-components.cjs.js +3 -3
  12. package/dist/cjs/mg-components.cjs.js.map +1 -1
  13. package/dist/cjs/mg-loader.cjs.entry.js +5 -5
  14. package/dist/cjs/mg-progress.cjs.entry.js +11 -11
  15. package/dist/collection/collection-manifest.json +1 -1
  16. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +1 -0
  17. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -1
  18. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +68 -38
  19. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
  20. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +14 -6
  21. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
  22. package/dist/collection/components/molecules/mg-details/mg-details.js +6 -1
  23. package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
  24. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +2 -0
  25. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js.map +1 -0
  26. package/dist/collection/components/molecules/mg-popover/mg-popover.js +90 -46
  27. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  28. package/dist/collection/utils/floating-ui.utils.js +33 -0
  29. package/dist/collection/utils/floating-ui.utils.js.map +1 -0
  30. package/dist/components/floating-ui.utils.js +2099 -0
  31. package/dist/components/floating-ui.utils.js.map +1 -0
  32. package/dist/components/index.es.js +29 -29
  33. package/dist/components/index.es.js.map +1 -1
  34. package/dist/components/index2.js +2 -2
  35. package/dist/components/mg-action-more.js +6 -6
  36. package/dist/components/mg-alert.js +5 -5
  37. package/dist/components/mg-badge2.js +6 -6
  38. package/dist/components/mg-button2.js +6 -6
  39. package/dist/components/mg-card2.js +1 -1
  40. package/dist/components/mg-card2.js.map +1 -1
  41. package/dist/components/mg-character-left2.js +4 -4
  42. package/dist/components/mg-details.js +8 -3
  43. package/dist/components/mg-details.js.map +1 -1
  44. package/dist/components/mg-form.js +7 -7
  45. package/dist/components/mg-icon2.js +6 -6
  46. package/dist/components/mg-illustrated-message.js +2 -2
  47. package/dist/components/mg-input-checkbox.js +9 -9
  48. package/dist/components/mg-input-date.js +13 -13
  49. package/dist/components/mg-input-numeric.js +12 -12
  50. package/dist/components/mg-input-password.js +3 -3
  51. package/dist/components/mg-input-radio.js +7 -7
  52. package/dist/components/mg-input-select2.js +7 -7
  53. package/dist/components/mg-input-text2.js +9 -9
  54. package/dist/components/mg-input-textarea.js +7 -7
  55. package/dist/components/mg-input-title2.js +4 -4
  56. package/dist/components/mg-input-toggle.js +6 -6
  57. package/dist/components/mg-input2.js +8 -8
  58. package/dist/components/mg-item-more2.js +8 -8
  59. package/dist/components/mg-item-more2.js.map +1 -1
  60. package/dist/components/mg-loader.js +3 -3
  61. package/dist/components/mg-menu-item2.js +24 -16
  62. package/dist/components/mg-menu-item2.js.map +1 -1
  63. package/dist/components/mg-message2.js +5 -5
  64. package/dist/components/mg-message2.js.map +1 -1
  65. package/dist/components/mg-modal.js +9 -9
  66. package/dist/components/mg-modal.js.map +1 -1
  67. package/dist/components/mg-pagination2.js +6 -6
  68. package/dist/components/mg-panel.js +10 -10
  69. package/dist/components/mg-panel.js.map +1 -1
  70. package/dist/components/mg-popover-content2.js +4 -4
  71. package/dist/components/mg-popover-content2.js.map +1 -1
  72. package/dist/components/mg-popover2.js +89 -47
  73. package/dist/components/mg-popover2.js.map +1 -1
  74. package/dist/components/mg-progress.js +10 -10
  75. package/dist/components/mg-skip-links.js +2 -2
  76. package/dist/components/mg-tabs.js +12 -12
  77. package/dist/components/mg-tag.js +4 -4
  78. package/dist/components/mg-tooltip-content2.js +1 -1
  79. package/dist/components/mg-tooltip-content2.js.map +1 -1
  80. package/dist/components/mg-tooltip2.js +71 -42
  81. package/dist/components/mg-tooltip2.js.map +1 -1
  82. package/dist/esm/{index-1f32332a.js → index-5059254f.js} +266 -241
  83. package/dist/esm/index-5059254f.js.map +1 -0
  84. package/dist/esm/{index-9bd10f5d.js → index-a7c3b5c5.js} +3 -3
  85. package/dist/esm/{index-9bd10f5d.js.map → index-a7c3b5c5.js.map} +1 -1
  86. package/dist/esm/{index.es-a2587b72.js → index.es-5e0101ac.js} +30 -30
  87. package/dist/esm/index.es-5e0101ac.js.map +1 -0
  88. package/dist/esm/loader.js +3 -3
  89. package/dist/esm/mg-action-more_36.entry.js +2260 -1872
  90. package/dist/esm/mg-action-more_36.entry.js.map +1 -1
  91. package/dist/esm/mg-alert.entry.js +7 -7
  92. package/dist/esm/mg-components.js +4 -4
  93. package/dist/esm/mg-components.js.map +1 -1
  94. package/dist/esm/mg-loader.entry.js +5 -5
  95. package/dist/esm/mg-progress.entry.js +11 -11
  96. package/dist/mg-components/mg-components.esm.js +1 -1
  97. package/dist/mg-components/mg-components.esm.js.map +1 -1
  98. package/dist/mg-components/{p-0ead5317.entry.js → p-1a162791.entry.js} +2 -2
  99. package/dist/mg-components/{p-f48d964f.entry.js → p-2403e01d.entry.js} +2 -2
  100. package/dist/mg-components/p-6c831a83.entry.js +2 -0
  101. package/dist/mg-components/p-6c831a83.entry.js.map +1 -0
  102. package/dist/mg-components/{p-3b052ac0.entry.js → p-ad64ab4a.entry.js} +2 -2
  103. package/dist/mg-components/{p-b986c107.js → p-b6c1a6ce.js} +2 -2
  104. package/dist/mg-components/p-b6c1a6ce.js.map +1 -0
  105. package/dist/mg-components/{p-dc436f3c.js → p-d9731ebc.js} +2 -2
  106. package/dist/mg-components/p-e39791fa.js +3 -0
  107. package/dist/mg-components/p-e39791fa.js.map +1 -0
  108. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +6 -0
  109. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +7 -6
  110. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +10 -4
  111. package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
  112. package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +6 -0
  113. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +13 -8
  114. package/dist/types/components.d.ts +8 -6
  115. package/dist/types/utils/floating-ui.utils.d.ts +19 -0
  116. package/ide/intellij/web-types.json +1 -1
  117. package/package.json +21 -21
  118. package/dist/cjs/index-911898e4.js.map +0 -1
  119. package/dist/cjs/index.es-325100d7.js.map +0 -1
  120. package/dist/components/popper.js +0 -1794
  121. package/dist/components/popper.js.map +0 -1
  122. package/dist/esm/index-1f32332a.js.map +0 -1
  123. package/dist/esm/index.es-a2587b72.js.map +0 -1
  124. package/dist/mg-components/p-35898742.js +0 -3
  125. package/dist/mg-components/p-35898742.js.map +0 -1
  126. package/dist/mg-components/p-6810a565.entry.js +0 -2
  127. package/dist/mg-components/p-6810a565.entry.js.map +0 -1
  128. package/dist/mg-components/p-b986c107.js.map +0 -1
  129. /package/dist/mg-components/{p-0ead5317.entry.js.map → p-1a162791.entry.js.map} +0 -0
  130. /package/dist/mg-components/{p-f48d964f.entry.js.map → p-2403e01d.entry.js.map} +0 -0
  131. /package/dist/mg-components/{p-3b052ac0.entry.js.map → p-ad64ab4a.entry.js.map} +0 -0
  132. /package/dist/mg-components/{p-dc436f3c.js.map → p-d9731ebc.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { z as ze, G as Ge, e as et, I as Ie, J as Je, y as ye, X as Xe } from './index.es.js';
2
+ import { G as Ge, K as Ke, s as st, X as Xe, V as Ve, m as me, Q as Qe } from './index.es.js';
3
3
  import { d as defineCustomElement$3 } from './mg-badge2.js';
4
4
  import { d as defineCustomElement$2 } from './mg-icon2.js';
5
5
 
@@ -43,7 +43,7 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class MgTabs extends HTMLEleme
43
43
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
44
44
  * If not set, it will be created.
45
45
  */
46
- this.identifier = ze('mg-tabs');
46
+ this.identifier = Ge('mg-tabs');
47
47
  /**
48
48
  * Define tabs size
49
49
  */
@@ -55,7 +55,7 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class MgTabs extends HTMLEleme
55
55
  /**
56
56
  * Component classes
57
57
  */
58
- this.classCollection = new Ge(['mg-c-tabs']);
58
+ this.classCollection = new Ke(['mg-c-tabs']);
59
59
  /**
60
60
  * Validate that new tab status can be `Status.ACTIVE`
61
61
  * @param tab - tab item
@@ -153,7 +153,7 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class MgTabs extends HTMLEleme
153
153
  */
154
154
  this.resetFocus = () => {
155
155
  // update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
156
- et(() => {
156
+ st(() => {
157
157
  this.tabFocus = undefined;
158
158
  Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {
159
159
  tab.setAttribute('tabindex', this.activeTab - this.startIndex !== index ? '-1' : '0');
@@ -170,30 +170,30 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class MgTabs extends HTMLEleme
170
170
  };
171
171
  }
172
172
  watchIdentifier(newValue) {
173
- if (!Ie(newValue)) {
174
- console.error(`<mg-tabs> prop "identifier" value is invalid. Passed value: ${Je(newValue)}.`);
173
+ if (!Xe(newValue)) {
174
+ console.error(`<mg-tabs> prop "identifier" value is invalid. Passed value: ${Ve(newValue)}.`);
175
175
  }
176
176
  }
177
177
  validateLabel(newValue) {
178
- if (!ye(newValue)) {
179
- throw new Error(`<mg-tabs> prop "label" is required and must be a string. Passed value: ${Je(newValue)}.`);
178
+ if (!me(newValue)) {
179
+ throw new Error(`<mg-tabs> prop "label" is required and must be a string. Passed value: ${Ve(newValue)}.`);
180
180
  }
181
181
  }
182
182
  validateSize(newValue) {
183
183
  if (!sizes.includes(newValue)) {
184
- throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}. Passed value: ${Je(newValue)}.`);
184
+ throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}. Passed value: ${Ve(newValue)}.`);
185
185
  }
186
186
  this.classCollection.add(`mg-c-tabs--size-${this.size}`);
187
187
  }
188
188
  validateItems(newValue) {
189
189
  // String array
190
- if (Xe(newValue))
190
+ if (Qe(newValue))
191
191
  this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
192
192
  // Object array
193
193
  else if (Array.isArray(newValue) && newValue.length > 0 && newValue.every(isTabItem))
194
194
  this.tabs = newValue;
195
195
  else
196
- throw new Error(`<mg-tabs> prop "items" is required and all items must be the same type: TabItem. Passed value: ${Je(newValue)}.`);
196
+ throw new Error(`<mg-tabs> prop "items" is required and all items must be the same type: TabItem. Passed value: ${Ve(newValue)}.`);
197
197
  }
198
198
  validateActiveTab(newValue) {
199
199
  // when `active-tab` is undefined we set default value by searching an item with `Status.ACTIVE` or we use the `startIndex` has fallback value
@@ -218,7 +218,7 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class MgTabs extends HTMLEleme
218
218
  this.activeTabChange.emit(newValue);
219
219
  }
220
220
  else {
221
- throw new Error(`<mg-tabs> prop "activeTab" must be a number between ${this.startIndex} and ${this.tabs.length} and new value must be "activable". Passed value: ${Je(newValue)}.`);
221
+ throw new Error(`<mg-tabs> prop "activeTab" must be a number between ${this.startIndex} and ${this.tabs.length} and new value must be "activable". Passed value: ${Ve(newValue)}.`);
222
222
  }
223
223
  }
224
224
  /*************
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
- import { G as Ge, J as Je, y as ye } from './index.es.js';
2
+ import { K as Ke, V as Ve, m as me } from './index.es.js';
3
3
 
4
4
  /**
5
5
  * List of all possibles variants
@@ -27,11 +27,11 @@ const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class MgTag extends HTMLElement
27
27
  /**
28
28
  * Component classes
29
29
  */
30
- this.classCollection = new Ge(['mg-c-tag']);
30
+ this.classCollection = new Ke(['mg-c-tag']);
31
31
  }
32
32
  validateVariant(newValue, oldValue) {
33
33
  if (!variants.includes(newValue)) {
34
- throw new Error(`<mg-tag> prop "variant" must be one of: ${variants.join(', ')}. Passed value: ${Je(newValue)}.`);
34
+ throw new Error(`<mg-tag> prop "variant" must be one of: ${variants.join(', ')}. Passed value: ${Ve(newValue)}.`);
35
35
  }
36
36
  else {
37
37
  if (oldValue !== undefined) {
@@ -64,7 +64,7 @@ const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class MgTag extends HTMLElement
64
64
  * @param textContent - html element textContent property
65
65
  */
66
66
  validateTextContent(textContent) {
67
- if (!ye(textContent))
67
+ if (!me(textContent))
68
68
  throw new Error('<mg-tag> slot must contain a text content.');
69
69
  }
70
70
  /*************
@@ -1,6 +1,6 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
2
 
3
- const mgTooltipContentCss = ":host{z-index:1000;display:none;max-width:var(--mg-b-size-floating-element-max-width);box-sizing:border-box;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-radius:var(--mg-c-tooltip-border-radius);background-color:var(--mg-c-tooltip-color-background);color:var(--mg-c-tooltip-color-text);font-family:var(--mg-b-font-family);font-size:var(--mg-b-font-size);font-weight:400;text-align:start}:host([data-show]){display:block}::slotted([slot=arrow]){visibility:hidden}::slotted([slot=arrow])::before{content:\"\";transform:rotate(45deg);visibility:visible}::slotted([slot=arrow]),::slotted([slot=arrow])::before{position:absolute;z-index:9999;width:var(--mg-b-size-8);height:var(--mg-b-size-8);background-color:var(--mg-c-tooltip-color-background)}:host([data-popper-placement^=top])>::slotted([slot=arrow]){bottom:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=bottom])>::slotted([slot=arrow]){top:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=left])>::slotted([slot=arrow]){right:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=right])>::slotted([slot=arrow]){left:calc(-1*var(--mg-b-size-4))}";
3
+ const mgTooltipContentCss = ":host{z-index:1000;display:none;max-width:var(--mg-b-size-floating-element-max-width);box-sizing:border-box;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-radius:var(--mg-c-tooltip-border-radius);background-color:var(--mg-c-tooltip-color-background);color:var(--mg-c-tooltip-color-text);font-family:var(--mg-b-font-family);font-size:var(--mg-b-font-size);font-weight:400;text-align:start}:host([data-show]){display:block}::slotted([slot=arrow]){visibility:hidden}::slotted([slot=arrow])::before{content:\"\";transform:rotate(45deg);visibility:visible}::slotted([slot=arrow]),::slotted([slot=arrow])::before{position:absolute;z-index:9999;width:var(--mg-b-size-8);height:var(--mg-b-size-8);background-color:var(--mg-c-tooltip-color-background)}:host([data-placement^=top])>::slotted([slot=arrow]){bottom:calc(-1*var(--mg-b-size-4))}:host([data-placement^=bottom])>::slotted([slot=arrow]){top:calc(-1*var(--mg-b-size-4))}:host([data-placement^=left])>::slotted([slot=arrow]){right:calc(-1*var(--mg-b-size-4))}:host([data-placement^=right])>::slotted([slot=arrow]){left:calc(-1*var(--mg-b-size-4))}";
4
4
  const MgTooltipContentStyle0 = mgTooltipContentCss;
5
5
 
6
6
  const MgTooltipContent = /*@__PURE__*/ proxyCustomElement(class MgTooltipContent extends HTMLElement {
@@ -1 +1 @@
1
- {"file":"mg-tooltip-content2.js","mappings":";;AAAA,MAAM,mBAAmB,GAAG,2mCAA2mC,CAAC;AACxoC,+BAAe,mBAAmB;;MCSrB,gBAAgB;;;;;;;;;;;;;IAc3B,MAAM;QACJ,QACE,EAAC,IAAI,qDAAC,IAAI,EAAC,SAAS,IAClB,6DAAM,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAC,6BAA6B,GAAQ,EAC1E,6DAAM,IAAI,EAAC,OAAO,GAAQ,CACrB,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["../styles/dist/components/mg-tooltip-content.css?tag=mg-tooltip-content&encapsulation=shadow","src/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.tsx"],"sourcesContent":[":host{z-index:1000;display:none;max-width:var(--mg-b-size-floating-element-max-width);box-sizing:border-box;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-radius:var(--mg-c-tooltip-border-radius);background-color:var(--mg-c-tooltip-color-background);color:var(--mg-c-tooltip-color-text);font-family:var(--mg-b-font-family);font-size:var(--mg-b-font-size);font-weight:400;text-align:start}:host([data-show]){display:block}::slotted([slot=arrow]){visibility:hidden}::slotted([slot=arrow])::before{content:\"\";transform:rotate(45deg);visibility:visible}::slotted([slot=arrow]),::slotted([slot=arrow])::before{position:absolute;z-index:9999;width:var(--mg-b-size-8);height:var(--mg-b-size-8);background-color:var(--mg-c-tooltip-color-background)}:host([data-popper-placement^=top])>::slotted([slot=arrow]){bottom:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=bottom])>::slotted([slot=arrow]){top:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=left])>::slotted([slot=arrow]){right:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=right])>::slotted([slot=arrow]){left:calc(-1*var(--mg-b-size-4))}/*# sourceMappingURL=mg-tooltip-content.css.map */\n","import { Component, h, Host, Prop } from '@stencil/core';\n\n/**\n * @internal\n */\n@Component({\n tag: 'mg-tooltip-content',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-tooltip-content.css',\n shadow: true,\n})\nexport class MgTooltipContent {\n /**\n * Displayed message in the tooltip\n */\n @Prop() message!: string;\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"tooltip\">\n <span innerHTML={this.message} class=\"mg-tooltip-content__message\"></span>\n <slot name=\"arrow\"></slot>\n </Host>\n );\n }\n}\n"],"version":3}
1
+ {"file":"mg-tooltip-content2.js","mappings":";;AAAA,MAAM,mBAAmB,GAAG,+kCAA+kC,CAAC;AAC5mC,+BAAe,mBAAmB;;MCSrB,gBAAgB;;;;;;;;;;;;;IAc3B,MAAM;QACJ,QACE,EAAC,IAAI,qDAAC,IAAI,EAAC,SAAS,IAClB,6DAAM,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAC,6BAA6B,GAAQ,EAC1E,6DAAM,IAAI,EAAC,OAAO,GAAQ,CACrB,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["../styles/dist/components/mg-tooltip-content.css?tag=mg-tooltip-content&encapsulation=shadow","src/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.tsx"],"sourcesContent":[":host{z-index:1000;display:none;max-width:var(--mg-b-size-floating-element-max-width);box-sizing:border-box;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-radius:var(--mg-c-tooltip-border-radius);background-color:var(--mg-c-tooltip-color-background);color:var(--mg-c-tooltip-color-text);font-family:var(--mg-b-font-family);font-size:var(--mg-b-font-size);font-weight:400;text-align:start}:host([data-show]){display:block}::slotted([slot=arrow]){visibility:hidden}::slotted([slot=arrow])::before{content:\"\";transform:rotate(45deg);visibility:visible}::slotted([slot=arrow]),::slotted([slot=arrow])::before{position:absolute;z-index:9999;width:var(--mg-b-size-8);height:var(--mg-b-size-8);background-color:var(--mg-c-tooltip-color-background)}:host([data-placement^=top])>::slotted([slot=arrow]){bottom:calc(-1*var(--mg-b-size-4))}:host([data-placement^=bottom])>::slotted([slot=arrow]){top:calc(-1*var(--mg-b-size-4))}:host([data-placement^=left])>::slotted([slot=arrow]){right:calc(-1*var(--mg-b-size-4))}:host([data-placement^=right])>::slotted([slot=arrow]){left:calc(-1*var(--mg-b-size-4))}/*# sourceMappingURL=mg-tooltip-content.css.map */\n","import { Component, h, Host, Prop } from '@stencil/core';\n\n/**\n * @internal\n */\n@Component({\n tag: 'mg-tooltip-content',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-tooltip-content.css',\n shadow: true,\n})\nexport class MgTooltipContent {\n /**\n * Displayed message in the tooltip\n */\n @Prop() message!: string;\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"tooltip\">\n <span innerHTML={this.message} class=\"mg-tooltip-content__message\"></span>\n <slot name=\"arrow\"></slot>\n </Host>\n );\n }\n}\n"],"version":3}
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
- import { z as ze, e as et, I as Ie, J as Je, y as ye, Z as Ze, Q as Qe } from './index.es.js';
2
+ import { G as Ge, s as st, X as Xe, V as Ve, m as me, Y as Ye, J as Je } from './index.es.js';
3
+ import { a as autoUpdate, c as computePosition, o as offset, f as flip, b as shift, l as limitShift, d as arrow, i as isFloatingUIPlacement } from './floating-ui.utils.js';
3
4
  import { d as defineCustomElement$1 } from './mg-tooltip-content2.js';
4
- import { c as createPopper } from './popper.js';
5
5
 
6
6
  const Guard = {
7
7
  FOCUS: 'focus',
@@ -28,7 +28,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
28
28
  * Sets an `id` attribute.
29
29
  * Needed by the input for accessibility `aria-decribedby`.
30
30
  */
31
- this.identifier = ze('mg-tooltip');
31
+ this.identifier = Ge('mg-tooltip');
32
32
  /**
33
33
  * Tooltip placement
34
34
  */
@@ -47,10 +47,8 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
47
47
  this.show = () => {
48
48
  // Make the tooltip visible
49
49
  this.mgTooltipContent.dataset.show = '';
50
- // Enable the event listeners
51
- this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
52
50
  // hide when click outside on nextTick to prevent event to trigger after creation
53
- et(() => {
51
+ st(() => {
54
52
  this.windows.forEach((localWindow) => {
55
53
  localWindow.addEventListener('click', this.handleClickOutside, false);
56
54
  localWindow.addEventListener('keydown', this.handlePressEscape, false);
@@ -63,8 +61,6 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
63
61
  this.hide = () => {
64
62
  // Hide the tooltip
65
63
  this.mgTooltipContent.removeAttribute('data-show');
66
- // Disable the event listeners
67
- this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
68
64
  // Remove event listener
69
65
  this.windows.forEach((localWindow) => {
70
66
  localWindow.removeEventListener('click', this.handleClickOutside, false);
@@ -154,28 +150,50 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
154
150
  }
155
151
  };
156
152
  /**
157
- * Set popper instance
158
- * @param strategy - popper strategy to apply on instance
153
+ * Set Floating UI instance
154
+ * @param strategy - Floating UI strategy to apply on instance
159
155
  */
160
- this.setPopper = (strategy) => {
161
- // Create popperjs tooltip
162
- this.popper = createPopper(this.tooltipedElement, this.mgTooltipContent, {
163
- placement: this.placement,
164
- strategy,
165
- modifiers: [
166
- {
167
- name: 'offset',
168
- options: {
169
- offset: [0, 8],
170
- },
171
- },
172
- {
173
- name: 'flip',
174
- options: {
175
- fallbackPlacements: ['auto'],
176
- },
177
- },
178
- ],
156
+ this.setFloatingUI = (strategy) => {
157
+ // Initial styles configuration
158
+ Object.assign(this.mgTooltipContent.style, {
159
+ position: strategy,
160
+ top: '0',
161
+ left: '0',
162
+ transform: 'translate(0, 0)',
163
+ });
164
+ // Create Floating UI instance with autoUpdate
165
+ this.floatingUICleanup = autoUpdate(this.tooltipedElement, this.mgTooltipContent, () => {
166
+ computePosition(this.tooltipedElement, this.mgTooltipContent, {
167
+ placement: this.placement,
168
+ strategy,
169
+ middleware: [offset(8), flip(), shift({ limiter: limitShift() }), arrow({ element: this.mgTooltipContent.querySelector('[data-floating-arrow]') })],
170
+ }).then(({ x, y, placement, middlewareData }) => {
171
+ Object.assign(this.mgTooltipContent.style, {
172
+ transform: !isNaN(x) && !isNaN(y) ? `translate(${x}px, ${y}px)` : undefined,
173
+ });
174
+ // Update arrow style
175
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
176
+ const staticSide = {
177
+ top: 'bottom',
178
+ right: 'left',
179
+ bottom: 'top',
180
+ left: 'right',
181
+ }[placement.split('-')[0]];
182
+ const arrowElement = this.mgTooltipContent.querySelector('[data-floating-arrow]');
183
+ // https://floating-ui.com/docs/arrow
184
+ // Unlike the floating element, which has both coordinates defined at all times, the arrow only has one defined.
185
+ // Due to this, either x or y will be undefined, depending on the side of placement.
186
+ // The above code uses `isNaN` to check for null and undefined simultaneously.
187
+ // Don’t remove `isNaN`, because either value can be falsy (0), causing a bug!
188
+ const numberToPx = (number) => !isNaN(number) ? `${number}px` : '';
189
+ Object.assign(arrowElement.style, {
190
+ left: numberToPx(arrowX),
191
+ top: numberToPx(arrowY),
192
+ [staticSide]: '-4px',
193
+ position: 'absolute',
194
+ });
195
+ this.mgTooltipContent.setAttribute('data-placement', placement);
196
+ });
179
197
  });
180
198
  };
181
199
  /**
@@ -228,8 +246,9 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
228
246
  // Since Firefox doesn't trigger a "blur" event when the "disabled" attribute is added or removed from a button
229
247
  // we have to manually unlock the guard because the "blur" handler of the tooltipedElement won't do it.
230
248
  this.resetGuard();
231
- // update popper instance
232
- this.popper.update();
249
+ // update Floating UI instance
250
+ this.floatingUICleanup();
251
+ this.setFloatingUI(this.element.closest('mg-popover') !== null ? 'absolute' : 'fixed');
233
252
  }).observe(mgButton, { attributes: true });
234
253
  };
235
254
  /**
@@ -248,19 +267,23 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
248
267
  };
249
268
  }
250
269
  watchIdentifier(newValue) {
251
- if (!Ie(newValue)) {
252
- throw new Error(`<mg-tooltip> prop "identifier" value is invalid. Passed value: ${Je(newValue)}.`);
270
+ if (!Xe(newValue)) {
271
+ throw new Error(`<mg-tooltip> prop "identifier" value is invalid. Passed value: ${Ve(newValue)}.`);
253
272
  }
254
273
  // use renderTooltipContent to update tooltip-content id
255
274
  this.renderTooltipContent();
256
275
  }
257
276
  watchMessage(newValue) {
258
- if (!ye(newValue)) {
259
- throw new Error(`<mg-tooltip> prop "message" is required and must be a string. Passed value: ${Je(newValue)}.`);
277
+ if (!me(newValue)) {
278
+ throw new Error(`<mg-tooltip> prop "message" is required and must be a string. Passed value: ${Ve(newValue)}.`);
260
279
  }
261
280
  if (this.mgTooltipContent !== undefined)
262
281
  this.mgTooltipContent.message = newValue;
263
282
  }
283
+ watchPlacement(newValue) {
284
+ if (!isFloatingUIPlacement(newValue))
285
+ this.placement = 'bottom';
286
+ }
264
287
  watchDisplay(newValue) {
265
288
  if (newValue) {
266
289
  this.show();
@@ -290,7 +313,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
290
313
  this.mgTooltipContent.setAttribute('id', this.identifier);
291
314
  const arrow = document.createElement('div');
292
315
  arrow.setAttribute('slot', 'arrow');
293
- arrow.dataset.popperArrow = '';
316
+ arrow.dataset.floatingArrow = '';
294
317
  this.mgTooltipContent.appendChild(arrow);
295
318
  // manage tooltipElement & tooltipedElement mouseenter/mouseleave events
296
319
  this.mgTooltipContent.addEventListener('mouseenter', () => {
@@ -311,10 +334,11 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
311
334
  */
312
335
  componentWillLoad() {
313
336
  // Get windows to attach events
314
- this.windows = Ze(window);
337
+ this.windows = Ye(window);
315
338
  // Get tooltip element
316
339
  this.renderTooltipContent();
317
340
  //validate properties
341
+ this.watchPlacement(this.placement);
318
342
  this.watchDisabled(this.disabled);
319
343
  this.watchMessage(this.message);
320
344
  this.watchIdentifier(this.identifier);
@@ -329,7 +353,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
329
353
  // get slotted element wich is not the tooltip
330
354
  const slotElement = this.element.querySelector(`*:not(#${this.identifier})`);
331
355
  // Get interactive element
332
- const interactiveElement = slotElement.matches(Qe) ? slotElement : (_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(Qe);
356
+ const interactiveElement = slotElement.matches(Je) ? slotElement : (_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(Je);
333
357
  this.setTooltipedElement(interactiveElement || slotElement);
334
358
  // Check if slotted element is a disabled mg-button
335
359
  // In this case we wrap the mg-button into a div to enable the tooltip
@@ -347,7 +371,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
347
371
  // apply a11y aria
348
372
  this.setAriaDescribedby(slotElement);
349
373
  // set Tooltip
350
- this.setPopper(this.element.closest('mg-popover') !== null ? 'absolute' : 'fixed');
374
+ this.setFloatingUI(this.element.closest('mg-popover') !== null ? 'absolute' : 'fixed');
351
375
  // add document keyboard handler
352
376
  document.addEventListener('keydown', this.handlePressEscape);
353
377
  // check props
@@ -357,7 +381,8 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
357
381
  * update popper position after props change on component did update hook to benefit from render ended
358
382
  */
359
383
  componentDidUpdate() {
360
- this.popper.update();
384
+ this.floatingUICleanup();
385
+ this.setFloatingUI(this.element.closest('mg-popover') !== null ? 'absolute' : 'fixed');
361
386
  }
362
387
  /**
363
388
  * remove listeners
@@ -369,18 +394,21 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
369
394
  localWindow.removeEventListener('click', this.handleClickOutside, false);
370
395
  localWindow.removeEventListener('keydown', this.handlePressEscape, false);
371
396
  });
397
+ // cleanup Floating UI
398
+ this.floatingUICleanup();
372
399
  }
373
400
  /**
374
401
  * Render
375
402
  * @returns HTML Element
376
403
  */
377
404
  render() {
378
- return (h(Host, { key: '7868f7704c0f1ccd9d0d67d45eac6aa8901f4d5d' }, h("slot", { key: '4f865f9e153c5d01259ca83b81772dce302f5c05' }), h("slot", { key: '2032e81f60a7b7818a7220f0b00cec81ca0a84ed', name: "content" })));
405
+ return (h(Host, { key: '5ab2260a76ea88edb968c61b7a6d0aa00b77a2d1' }, h("slot", { key: '685bcf972152416df76bb776f600a224a7943964' }), h("slot", { key: '019018c8e63801909248b6ec478c2af294319259', name: "content" })));
379
406
  }
380
407
  get element() { return this; }
381
408
  static get watchers() { return {
382
409
  "identifier": ["watchIdentifier"],
383
410
  "message": ["watchMessage"],
411
+ "placement": ["watchPlacement"],
384
412
  "display": ["watchDisplay"],
385
413
  "disabled": ["watchDisabled"]
386
414
  }; }
@@ -388,12 +416,13 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
388
416
  }, [1, "mg-tooltip", {
389
417
  "identifier": [1],
390
418
  "message": [1],
391
- "placement": [1],
419
+ "placement": [1025],
392
420
  "display": [1028],
393
421
  "disabled": [4]
394
422
  }, undefined, {
395
423
  "identifier": ["watchIdentifier"],
396
424
  "message": ["watchMessage"],
425
+ "placement": ["watchPlacement"],
397
426
  "display": ["watchDisplay"],
398
427
  "disabled": ["watchDisabled"]
399
428
  }]);
@@ -1 +1 @@
1
- {"file":"mg-tooltip2.js","mappings":";;;;;AAEO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IAKD,oBAAoB;;QAClB,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChE,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAC,CAAC,WAAmB;YACxC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;YACzE,WAAW,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;SAC3E,CAAC,CAAC;KACJ;;;;;IAMD,MAAM;QACJ,QACE,EAAC,IAAI,uDACH,8DAAa,EACb,6DAAM,IAAI,EAAC,SAAS,GAAQ,CACvB,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["createID","nextTick","isValideID","toString","isValidString","getWindows","focusableElements"],"sources":["src/components/atoms/mg-tooltip/mg-tooltip.conf.tsx","../styles/dist/components/mg-tooltip.css?tag=mg-tooltip&encapsulation=shadow","src/components/atoms/mg-tooltip/mg-tooltip.tsx"],"sourcesContent":["export type GuardType = 'focus' | 'hoverTooltip' | 'hoverTooltiped' | 'disableOnClick';\n\nexport const Guard: Record<string, GuardType> = {\n FOCUS: 'focus',\n HOVER_TOOLTIP_ELEMENT: 'hoverTooltip',\n HOVER_TOOLTIPED_ELEMENT: 'hoverTooltiped',\n DISABLE_ON_CLICK: 'disableOnClick',\n};\n","/*!\n * @prop --mg-c-tooltip-border-radius: Defines the border radius of the tooltip. Default value: `--mg-b-size-radius`.\n * @prop --mg-c-tooltip-color-background: Defines the background color of the tooltip. Default value: `--mg-b-color-dark`.\n * @prop --mg-c-tooltip-color-text: Defines the font color of the tooltip. Default value: `--mg-b-color-light`.\n */:host{display:inline-block}/*# sourceMappingURL=mg-tooltip.css.map */\n","import { Component, Element, h, Host, Prop, Watch } from '@stencil/core';\nimport { createID, focusableElements, getWindows, isValideID, isValidString, nextTick, toString } from '@mgdis/stencil-helpers';\nimport { Instance as PopperInstance, createPopper, Placement, PositioningStrategy } from '@popperjs/core';\nimport { type GuardType, Guard } from './mg-tooltip.conf';\n\n/**\n * HTMLMgButtonElement type guard\n * @param element - element to check\n * @returns return true if type is HTMLMgButtonElement\n */\nconst isButton = (element: unknown): element is HTMLMgButtonElement => typeof element === 'object' && ['MG-BUTTON', 'BUTTON'].includes((element as Element).tagName);\n\n/**\n * @slot - Element that will display the tooltip\n * @slot content - Tooltip content\n */\n@Component({\n tag: 'mg-tooltip',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-tooltip.css',\n shadow: true,\n})\nexport class MgTooltip {\n /************\n * Internal *\n ************/\n\n private popper: PopperInstance;\n private mgTooltipContent: HTMLMgTooltipContentElement;\n private tooltipedElement: HTMLElement;\n private windows: Window[];\n private hasCustomTabIndex: boolean;\n\n // tooltip actions guards\n private guard: GuardType;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTooltipElement;\n\n /**\n * Sets an `id` attribute.\n * Needed by the input for accessibility `aria-decribedby`.\n */\n @Prop() identifier: string = createID('mg-tooltip');\n @Watch('identifier')\n watchIdentifier(newValue: MgTooltip['identifier']): void {\n if (!isValideID(newValue)) {\n throw new Error(`<mg-tooltip> prop \"identifier\" value is invalid. Passed value: ${toString(newValue)}.`);\n }\n // use renderTooltipContent to update tooltip-content id\n this.renderTooltipContent();\n }\n\n /**\n * Displayed message in the tooltip\n */\n @Prop() message!: string;\n @Watch('message')\n watchMessage(newValue: MgTooltip['message']): void {\n if (!isValidString(newValue)) {\n throw new Error(`<mg-tooltip> prop \"message\" is required and must be a string. Passed value: ${toString(newValue)}.`);\n }\n if (this.mgTooltipContent !== undefined) this.mgTooltipContent.message = newValue;\n }\n\n /**\n * Tooltip placement\n */\n @Prop() placement: Placement = 'bottom';\n\n /**\n * Display tooltip\n */\n @Prop({ mutable: true }) display = false;\n @Watch('display')\n watchDisplay(newValue: MgTooltip['display']): void {\n if (newValue) {\n this.show();\n } else {\n this.hide();\n }\n }\n\n /**\n * Disable tooltip\n */\n @Prop() disabled = false;\n @Watch('disabled')\n watchDisabled(newValue: MgTooltip['disabled']): void {\n if (this.hasCustomTabIndex) {\n if (newValue) this.tooltipedElement.removeAttribute('tabindex');\n else if (!this.tooltipedElement.hasAttribute('tabindex')) this.tooltipedElement.setAttribute('tabindex', '0');\n }\n }\n\n /**\n * Show tooltip\n */\n private show = (): void => {\n // Make the tooltip visible\n this.mgTooltipContent.dataset.show = '';\n // Enable the event listeners\n this.popper.setOptions(options => ({\n ...options,\n modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }],\n }));\n // hide when click outside on nextTick to prevent event to trigger after creation\n nextTick(() => {\n this.windows.forEach((localWindow: Window) => {\n localWindow.addEventListener('click', this.handleClickOutside, false);\n localWindow.addEventListener('keydown', this.handlePressEscape, false);\n });\n });\n };\n\n /**\n * Hide tooltip\n */\n private hide = (): void => {\n // Hide the tooltip\n this.mgTooltipContent.removeAttribute('data-show');\n // Disable the event listeners\n this.popper.setOptions(options => ({\n ...options,\n modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }],\n }));\n // Remove event listener\n this.windows.forEach((localWindow: Window) => {\n localWindow.removeEventListener('click', this.handleClickOutside, false);\n localWindow.removeEventListener('keyboard', this.handlePressEscape, false);\n });\n };\n\n /**\n * Check if clicked outside of component and hide tooltip\n * @param event - mouse event\n */\n private handleClickOutside = (event: MouseEvent & { target: HTMLElement }): void => {\n if (event.target.closest('mg-tooltip') !== this.element) this.setDisplay(false);\n };\n\n /**\n * Check if 'Escape' key is pressed of component and hide tooltip\n * @param event - keyboard event\n */\n private handlePressEscape = (event: KeyboardEvent): void => {\n if (event.code === 'Escape') {\n this.setDisplay(false);\n this.resetGuard();\n }\n };\n\n /**\n * Method to set display prop\n * @param newValue - display prop new value\n * @param condition - additionnal condition to apply display prop newValue\n */\n private setDisplay = (newValue: MgTooltip['display'], condition = true): void => {\n if (!this.disabled && condition) this.display = newValue;\n };\n\n /**\n * Action for tooltip element and tooltiped element mouse listener\n * @param elementGuard - tooltip element guard\n * @param eventName - event name\n * @param conditionalGuard - guard condition\n */\n private tooltipMouseListenerAction = (elementGuard: GuardType, eventName: 'mouseenter' | 'mouseleave', conditionalGuard: GuardType): void => {\n // active FOCUS guard cancel process\n if ([Guard.FOCUS, Guard.DISABLE_ON_CLICK].includes(this.guard)) {\n return;\n }\n\n // Update guard by element guard\n this.guard = elementGuard;\n\n if (eventName !== 'mouseenter') {\n // process action in the next event loop macro task\n setTimeout(() => {\n this.setDisplay(false, this.guard !== conditionalGuard);\n this.resetGuard();\n }, 100);\n } else if (this.guard === Guard.HOVER_TOOLTIPED_ELEMENT) {\n this.setDisplay(true);\n }\n };\n\n /**\n * Method to reset guard value\n */\n private resetGuard = (): void => {\n this.guard = undefined;\n };\n\n /**\n * Update slot content when it is a mg-button\n * @param mgButton - slotted mg-button\n */\n private setMgButtonWrapper = (mgButton: HTMLMgButtonElement): void => {\n const buttonWrapperClass = 'mg-c-tooltip__mg-button-wrapper';\n const hasButtonWrapper = mgButton.parentElement.classList.contains(buttonWrapperClass);\n // For disabled mg-button, we need to wrap it in a new element\n // We bind handlers to this new element to keep listener features as workaround to disabled mg-button `pointer-events: none`\n // AND to prevent multiple nested wrappers from rendering when a new render is called with a disabled mg-button\n if (mgButton.disabled && !hasButtonWrapper) {\n // wrap mg-button in a div\n const div = document.createElement('div');\n div.classList.add(buttonWrapperClass);\n mgButton.parentNode.insertBefore(div, mgButton);\n div.appendChild(mgButton);\n\n // update tooltipElement\n this.setTooltipedElement(div);\n } else if (!mgButton.disabled && hasButtonWrapper) {\n this.element.firstElementChild.replaceWith(mgButton);\n\n // update tooltipElement\n this.setTooltipedElement(mgButton);\n }\n };\n\n /**\n * Set popper instance\n * @param strategy - popper strategy to apply on instance\n */\n private setPopper = (strategy: PositioningStrategy): void => {\n // Create popperjs tooltip\n this.popper = createPopper(this.tooltipedElement, this.mgTooltipContent, {\n placement: this.placement,\n strategy,\n modifiers: [\n {\n name: 'offset',\n options: {\n offset: [0, 8],\n },\n },\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['auto'],\n },\n },\n ],\n });\n };\n\n /**\n * Define selected element to become tooltip selector and init listeners\n * @param element - tooltiped element\n */\n private setTooltipedElement = (element: HTMLElement): void => {\n this.tooltipedElement = element;\n\n // Manage tooltipedElement focus events\n this.tooltipedElement.addEventListener('focus', () => {\n this.guard = Guard.FOCUS;\n this.setDisplay(true);\n });\n\n // as `click` event is the composition of `mousedown` and `mouseup` event,\n // and `click` event trigger `focus` event after a success `mousedown` wich set the `guard` to `Guard.FOCUS`\n // we reset the guard on `mouseup` event to unlock tooltip\n this.tooltipedElement.addEventListener('mouseup', () => {\n this.resetGuard();\n });\n\n this.tooltipedElement.addEventListener('blur', () => {\n this.resetGuard();\n this.setDisplay(false);\n });\n\n // manage tooltipElement & tooltipedElement mouseenter/mouseleave events\n this.tooltipedElement.addEventListener('mouseenter', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, 'mouseenter', Guard.HOVER_TOOLTIP_ELEMENT);\n });\n\n this.tooltipedElement.addEventListener('mouseleave', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, 'mouseleave', Guard.HOVER_TOOLTIP_ELEMENT);\n });\n };\n\n /**\n * Set button mutation observer\n * @param mgButton - mg-button to observe\n */\n private setMgButtonMutationObserver = (mgButton: HTMLMgButtonElement): void => {\n new MutationObserver(mutationList => {\n // stop process when none of mutations attributed is disabled\n if (!mutationList.some(mutation => ['aria-disabled', 'disabled'].includes(mutation.attributeName))) return;\n\n // set guard when one of mutations is for a disabled with disabled-on-click\n if (mutationList.some((mutation: MutationRecord & { target: HTMLMgButtonElement }) => mutation.target.disabled && mutation.target.disableOnClick)) {\n this.guard = Guard.DISABLE_ON_CLICK;\n }\n\n // when the disabled-on-click guard is running we stop process\n if (this.guard === Guard.DISABLE_ON_CLICK) return;\n\n // update button wrapper\n this.setMgButtonWrapper(mgButton);\n\n // Since Firefox doesn't trigger a \"blur\" event when the \"disabled\" attribute is added or removed from a button\n // we have to manually unlock the guard because the \"blur\" handler of the tooltipedElement won't do it.\n this.resetGuard();\n\n // update popper instance\n this.popper.update();\n }).observe(mgButton, { attributes: true });\n };\n\n /**\n * Set tooltiped element aria-describedby\n * @param element - element to update\n */\n private setAriaDescribedby = (element: HTMLElement): void => {\n // Set aria-describedby\n if (!element.hasAttribute('aria-describedby')) {\n this.tooltipedElement.setAttribute('aria-describedby', this.identifier);\n } else {\n // We ensure to have uniq ids\n element.setAttribute('aria-describedby', `${[...new Set([...element.getAttribute('aria-describedby').split(' '), this.identifier])].join(' ')}`);\n }\n };\n\n /**\n * Render tooltip content element and init listeners\n */\n private renderTooltipContent(): void {\n if (this.mgTooltipContent !== undefined) {\n this.mgTooltipContent.setAttribute('id', this.identifier);\n } else {\n this.mgTooltipContent = document.createElement('mg-tooltip-content');\n this.mgTooltipContent.setAttribute('slot', 'content');\n this.mgTooltipContent.setAttribute('id', this.identifier);\n\n const arrow = document.createElement('div');\n arrow.setAttribute('slot', 'arrow');\n arrow.dataset.popperArrow = '';\n this.mgTooltipContent.appendChild(arrow);\n\n // manage tooltipElement & tooltipedElement mouseenter/mouseleave events\n this.mgTooltipContent.addEventListener('mouseenter', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, 'mouseenter', Guard.HOVER_TOOLTIPED_ELEMENT);\n });\n this.mgTooltipContent.addEventListener('mouseleave', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, 'mouseleave', Guard.HOVER_TOOLTIPED_ELEMENT);\n });\n\n // append tooltip element to component\n this.element.appendChild(this.mgTooltipContent);\n }\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * set variables\n */\n componentWillLoad(): void {\n // Get windows to attach events\n this.windows = getWindows(window);\n\n // Get tooltip element\n this.renderTooltipContent();\n\n //validate properties\n this.watchDisabled(this.disabled);\n this.watchMessage(this.message);\n this.watchIdentifier(this.identifier);\n }\n\n /**\n * Get slotted element\n * Check if it already contain an interactive element, if not we need to add a tabIndex attribute\n * We need to attach the focused element to the tooltip (aria-describedby)\n */\n componentDidLoad(): void {\n // get slotted element wich is not the tooltip\n const slotElement: HTMLElement = this.element.querySelector(`*:not(#${this.identifier})`);\n\n // Get interactive element\n const interactiveElement: HTMLElement = slotElement.matches(focusableElements) ? slotElement : slotElement.shadowRoot?.querySelector(focusableElements);\n\n this.setTooltipedElement(interactiveElement || slotElement);\n\n // Check if slotted element is a disabled mg-button\n // In this case we wrap the mg-button into a div to enable the tooltip\n if (isButton(slotElement)) {\n this.setMgButtonMutationObserver(slotElement);\n this.setMgButtonWrapper(slotElement);\n }\n\n // Add tabindex to slotted element if we can't find any interactive element\n if (!this.disabled && [undefined, null].includes(interactiveElement)) {\n this.hasCustomTabIndex = true;\n slotElement.tabIndex = 0;\n // Add role on non-interactive element to work with \"aria-describedby\" for screen readers\n slotElement.setAttribute('role', 'button');\n }\n\n // apply a11y aria\n this.setAriaDescribedby(slotElement);\n\n // set Tooltip\n this.setPopper(this.element.closest('mg-popover') !== null ? 'absolute' : 'fixed');\n\n // add document keyboard handler\n document.addEventListener('keydown', this.handlePressEscape);\n\n // check props\n this.watchDisplay(this.display);\n }\n\n /**\n * update popper position after props change on component did update hook to benefit from render ended\n */\n componentDidUpdate(): void {\n this.popper.update();\n }\n\n /**\n * remove listeners\n */\n disconnectedCallback(): void {\n document.removeEventListener('keydown', this.handlePressEscape);\n this.windows?.forEach((localWindow: Window) => {\n localWindow.removeEventListener('click', this.handleClickOutside, false);\n localWindow.removeEventListener('keydown', this.handlePressEscape, false);\n });\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host>\n <slot></slot>\n <slot name=\"content\"></slot>\n </Host>\n );\n }\n}\n"],"version":3}
1
+ {"file":"mg-tooltip2.js","mappings":";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O,CAAC,CAAC;KACjC;;;;IAKD,kBAAkB;QAChB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,GAAG,UAAU,GAAG,OAAO,CAAC,CAAC;KACxF;;;;IAKD,oBAAoB;;QAClB,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChE,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAC,CAAC,WAAmB;YACxC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;YACzE,WAAW,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;SAC3E,CAAC,CAAC;;QAEH,IAAI,CAAC,iBAAiB,EAAE,CAAC;KAC1B;;;;;IAMD,MAAM;QACJ,QACE,EAAC,IAAI,uDACH,8DAAa,EACb,6DAAM,IAAI,EAAC,SAAS,GAAQ,CACvB,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["createID","nextTick","isValideID","toString","isValidString","getWindows","focusableElements"],"sources":["src/components/atoms/mg-tooltip/mg-tooltip.conf.tsx","../styles/dist/components/mg-tooltip.css?tag=mg-tooltip&encapsulation=shadow","src/components/atoms/mg-tooltip/mg-tooltip.tsx"],"sourcesContent":["import { type ExtendedPlacement, placements } from '../../../utils/floating-ui.utils'\nexport * from '../../../utils/floating-ui.utils'\n\nexport type GuardType = 'focus' | 'hoverTooltip' | 'hoverTooltiped' | 'disableOnClick';\n\nexport const Guard: Record<string, GuardType> = {\n FOCUS: 'focus',\n HOVER_TOOLTIP_ELEMENT: 'hoverTooltip',\n HOVER_TOOLTIPED_ELEMENT: 'hoverTooltiped',\n DISABLE_ON_CLICK: 'disableOnClick',\n};\n\n/**\n * Placement type from placements\n */\nexport type TooltipPlacementType = ExtendedPlacement & (typeof placements)[number];","/*!\n * @prop --mg-c-tooltip-border-radius: Defines the border radius of the tooltip. Default value: `--mg-b-size-radius`.\n * @prop --mg-c-tooltip-color-background: Defines the background color of the tooltip. Default value: `--mg-b-color-dark`.\n * @prop --mg-c-tooltip-color-text: Defines the font color of the tooltip. Default value: `--mg-b-color-light`.\n */:host{display:inline-block}/*# sourceMappingURL=mg-tooltip.css.map */\n","import { Component, Element, h, Host, Prop, Watch } from '@stencil/core';\nimport { createID, focusableElements, getWindows, isValideID, isValidString, nextTick, toString } from '@mgdis/stencil-helpers';\nimport { computePosition, autoUpdate, flip, shift, limitShift, offset, arrow, type Strategy, type Placement } from '@floating-ui/dom';\nimport { type GuardType, Guard, type TooltipPlacementType, isFloatingUIPlacement } from './mg-tooltip.conf';\n\n/**\n * HTMLMgButtonElement type guard\n * @param element - element to check\n * @returns return true if type is HTMLMgButtonElement\n */\nconst isButton = (element: unknown): element is HTMLMgButtonElement => typeof element === 'object' && ['MG-BUTTON', 'BUTTON'].includes((element as Element).tagName);\n\n/**\n * @slot - Element that will display the tooltip\n * @slot content - Tooltip content\n */\n@Component({\n tag: 'mg-tooltip',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-tooltip.css',\n shadow: true,\n})\nexport class MgTooltip {\n /************\n * Internal *\n ************/\n\n private floatingUICleanup: ReturnType<typeof autoUpdate>;\n private mgTooltipContent: HTMLMgTooltipContentElement;\n private tooltipedElement: HTMLElement;\n private windows: Window[];\n private hasCustomTabIndex: boolean;\n\n // tooltip actions guards\n private guard: GuardType;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTooltipElement;\n\n /**\n * Sets an `id` attribute.\n * Needed by the input for accessibility `aria-decribedby`.\n */\n @Prop() identifier: string = createID('mg-tooltip');\n @Watch('identifier')\n watchIdentifier(newValue: MgTooltip['identifier']): void {\n if (!isValideID(newValue)) {\n throw new Error(`<mg-tooltip> prop \"identifier\" value is invalid. Passed value: ${toString(newValue)}.`);\n }\n // use renderTooltipContent to update tooltip-content id\n this.renderTooltipContent();\n }\n\n /**\n * Displayed message in the tooltip\n */\n @Prop() message!: string;\n @Watch('message')\n watchMessage(newValue: MgTooltip['message']): void {\n if (!isValidString(newValue)) {\n throw new Error(`<mg-tooltip> prop \"message\" is required and must be a string. Passed value: ${toString(newValue)}.`);\n }\n if (this.mgTooltipContent !== undefined) this.mgTooltipContent.message = newValue;\n }\n\n /**\n * Tooltip placement\n */\n @Prop({ mutable: true }) placement: TooltipPlacementType = 'bottom';\n @Watch('placement')\n watchPlacement(newValue) :void {\n if(!isFloatingUIPlacement(newValue)) this.placement = 'bottom';\n }\n\n /**\n * Display tooltip\n */\n @Prop({ mutable: true }) display = false;\n @Watch('display')\n watchDisplay(newValue: MgTooltip['display']): void {\n if (newValue) {\n this.show();\n } else {\n this.hide();\n }\n }\n\n /**\n * Disable tooltip\n */\n @Prop() disabled = false;\n @Watch('disabled')\n watchDisabled(newValue: MgTooltip['disabled']): void {\n if (this.hasCustomTabIndex) {\n if (newValue) this.tooltipedElement.removeAttribute('tabindex');\n else if (!this.tooltipedElement.hasAttribute('tabindex')) this.tooltipedElement.setAttribute('tabindex', '0');\n }\n }\n\n /**\n * Show tooltip\n */\n private show = (): void => {\n // Make the tooltip visible\n this.mgTooltipContent.dataset.show = '';\n // hide when click outside on nextTick to prevent event to trigger after creation\n nextTick(() => {\n this.windows.forEach((localWindow: Window) => {\n localWindow.addEventListener('click', this.handleClickOutside, false);\n localWindow.addEventListener('keydown', this.handlePressEscape, false);\n });\n });\n };\n\n /**\n * Hide tooltip\n */\n private hide = (): void => {\n // Hide the tooltip\n this.mgTooltipContent.removeAttribute('data-show');\n // Remove event listener\n this.windows.forEach((localWindow: Window) => {\n localWindow.removeEventListener('click', this.handleClickOutside, false);\n localWindow.removeEventListener('keyboard', this.handlePressEscape, false);\n });\n };\n\n /**\n * Check if clicked outside of component and hide tooltip\n * @param event - mouse event\n */\n private handleClickOutside = (event: MouseEvent & { target: HTMLElement }): void => {\n if (event.target.closest('mg-tooltip') !== this.element) this.setDisplay(false);\n };\n\n /**\n * Check if 'Escape' key is pressed of component and hide tooltip\n * @param event - keyboard event\n */\n private handlePressEscape = (event: KeyboardEvent): void => {\n if (event.code === 'Escape') {\n this.setDisplay(false);\n this.resetGuard();\n }\n };\n\n /**\n * Method to set display prop\n * @param newValue - display prop new value\n * @param condition - additionnal condition to apply display prop newValue\n */\n private setDisplay = (newValue: MgTooltip['display'], condition = true): void => {\n if (!this.disabled && condition) this.display = newValue;\n };\n\n /**\n * Action for tooltip element and tooltiped element mouse listener\n * @param elementGuard - tooltip element guard\n * @param eventName - event name\n * @param conditionalGuard - guard condition\n */\n private tooltipMouseListenerAction = (elementGuard: GuardType, eventName: 'mouseenter' | 'mouseleave', conditionalGuard: GuardType): void => {\n // active FOCUS guard cancel process\n if ([Guard.FOCUS, Guard.DISABLE_ON_CLICK].includes(this.guard)) {\n return;\n }\n\n // Update guard by element guard\n this.guard = elementGuard;\n\n if (eventName !== 'mouseenter') {\n // process action in the next event loop macro task\n setTimeout(() => {\n this.setDisplay(false, this.guard !== conditionalGuard);\n this.resetGuard();\n }, 100);\n } else if (this.guard === Guard.HOVER_TOOLTIPED_ELEMENT) {\n this.setDisplay(true);\n }\n };\n\n /**\n * Method to reset guard value\n */\n private resetGuard = (): void => {\n this.guard = undefined;\n };\n\n /**\n * Update slot content when it is a mg-button\n * @param mgButton - slotted mg-button\n */\n private setMgButtonWrapper = (mgButton: HTMLMgButtonElement): void => {\n const buttonWrapperClass = 'mg-c-tooltip__mg-button-wrapper';\n const hasButtonWrapper = mgButton.parentElement.classList.contains(buttonWrapperClass);\n // For disabled mg-button, we need to wrap it in a new element\n // We bind handlers to this new element to keep listener features as workaround to disabled mg-button `pointer-events: none`\n // AND to prevent multiple nested wrappers from rendering when a new render is called with a disabled mg-button\n if (mgButton.disabled && !hasButtonWrapper) {\n // wrap mg-button in a div\n const div = document.createElement('div');\n div.classList.add(buttonWrapperClass);\n mgButton.parentNode.insertBefore(div, mgButton);\n div.appendChild(mgButton);\n\n // update tooltipElement\n this.setTooltipedElement(div);\n } else if (!mgButton.disabled && hasButtonWrapper) {\n this.element.firstElementChild.replaceWith(mgButton);\n\n // update tooltipElement\n this.setTooltipedElement(mgButton);\n }\n };\n\n /**\n * Set Floating UI instance\n * @param strategy - Floating UI strategy to apply on instance\n */\n private setFloatingUI = (strategy: Strategy): void => {\n // Initial styles configuration\n Object.assign(this.mgTooltipContent.style, {\n position: strategy,\n top: '0',\n left: '0',\n transform: 'translate(0, 0)',\n });\n\n // Create Floating UI instance with autoUpdate\n this.floatingUICleanup = autoUpdate(this.tooltipedElement, this.mgTooltipContent, () => {\n computePosition(this.tooltipedElement, this.mgTooltipContent, {\n placement: this.placement as Placement,\n strategy,\n middleware: [offset(8), flip(), shift({ limiter: limitShift() }), arrow({ element: this.mgTooltipContent.querySelector('[data-floating-arrow]') })],\n }).then(({ x, y, placement, middlewareData }) => {\n Object.assign(this.mgTooltipContent.style, {\n transform: !isNaN(x) && !isNaN(y) ? `translate(${x}px, ${y}px)` : undefined,\n });\n\n // Update arrow style\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n const staticSide = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n }[placement.split('-')[0]];\n\n const arrowElement: HTMLElement = this.mgTooltipContent.querySelector('[data-floating-arrow]');\n // https://floating-ui.com/docs/arrow \n // Unlike the floating element, which has both coordinates defined at all times, the arrow only has one defined.\n // Due to this, either x or y will be undefined, depending on the side of placement.\n // The above code uses `isNaN` to check for null and undefined simultaneously.\n // Don’t remove `isNaN`, because either value can be falsy (0), causing a bug!\n const numberToPx = (number: number): string => !isNaN(number) ? `${number}px` : '';\n\n Object.assign(arrowElement.style, {\n left: numberToPx(arrowX),\n top: numberToPx(arrowY),\n [staticSide]: '-4px',\n position: 'absolute',\n });\n\n this.mgTooltipContent.setAttribute('data-placement', placement);\n });\n });\n };\n\n /**\n * Define selected element to become tooltip selector and init listeners\n * @param element - tooltiped element\n */\n private setTooltipedElement = (element: HTMLElement): void => {\n this.tooltipedElement = element;\n\n // Manage tooltipedElement focus events\n this.tooltipedElement.addEventListener('focus', () => {\n this.guard = Guard.FOCUS;\n this.setDisplay(true);\n });\n\n // as `click` event is the composition of `mousedown` and `mouseup` event,\n // and `click` event trigger `focus` event after a success `mousedown` wich set the `guard` to `Guard.FOCUS`\n // we reset the guard on `mouseup` event to unlock tooltip\n this.tooltipedElement.addEventListener('mouseup', () => {\n this.resetGuard();\n });\n\n this.tooltipedElement.addEventListener('blur', () => {\n this.resetGuard();\n this.setDisplay(false);\n });\n\n // manage tooltipElement & tooltipedElement mouseenter/mouseleave events\n this.tooltipedElement.addEventListener('mouseenter', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, 'mouseenter', Guard.HOVER_TOOLTIP_ELEMENT);\n });\n\n this.tooltipedElement.addEventListener('mouseleave', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, 'mouseleave', Guard.HOVER_TOOLTIP_ELEMENT);\n });\n };\n\n /**\n * Set button mutation observer\n * @param mgButton - mg-button to observe\n */\n private setMgButtonMutationObserver = (mgButton: HTMLMgButtonElement): void => {\n new MutationObserver(mutationList => {\n // stop process when none of mutations attributed is disabled\n if (!mutationList.some(mutation => ['aria-disabled', 'disabled'].includes(mutation.attributeName))) return;\n\n // set guard when one of mutations is for a disabled with disabled-on-click\n if (mutationList.some((mutation: MutationRecord & { target: HTMLMgButtonElement }) => mutation.target.disabled && mutation.target.disableOnClick)) {\n this.guard = Guard.DISABLE_ON_CLICK;\n }\n\n // when the disabled-on-click guard is running we stop process\n if (this.guard === Guard.DISABLE_ON_CLICK) return;\n\n // update button wrapper\n this.setMgButtonWrapper(mgButton);\n\n // Since Firefox doesn't trigger a \"blur\" event when the \"disabled\" attribute is added or removed from a button\n // we have to manually unlock the guard because the \"blur\" handler of the tooltipedElement won't do it.\n this.resetGuard();\n\n // update Floating UI instance\n this.floatingUICleanup();\n this.setFloatingUI(this.element.closest('mg-popover') !== null ? 'absolute' : 'fixed');\n }).observe(mgButton, { attributes: true });\n };\n\n /**\n * Set tooltiped element aria-describedby\n * @param element - element to update\n */\n private setAriaDescribedby = (element: HTMLElement): void => {\n // Set aria-describedby\n if (!element.hasAttribute('aria-describedby')) {\n this.tooltipedElement.setAttribute('aria-describedby', this.identifier);\n } else {\n // We ensure to have uniq ids\n element.setAttribute('aria-describedby', `${[...new Set([...element.getAttribute('aria-describedby').split(' '), this.identifier])].join(' ')}`);\n }\n };\n\n /**\n * Render tooltip content element and init listeners\n */\n private renderTooltipContent(): void {\n if (this.mgTooltipContent !== undefined) {\n this.mgTooltipContent.setAttribute('id', this.identifier);\n } else {\n this.mgTooltipContent = document.createElement('mg-tooltip-content');\n this.mgTooltipContent.setAttribute('slot', 'content');\n this.mgTooltipContent.setAttribute('id', this.identifier);\n\n const arrow = document.createElement('div');\n arrow.setAttribute('slot', 'arrow');\n arrow.dataset.floatingArrow = '';\n this.mgTooltipContent.appendChild(arrow);\n\n // manage tooltipElement & tooltipedElement mouseenter/mouseleave events\n this.mgTooltipContent.addEventListener('mouseenter', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, 'mouseenter', Guard.HOVER_TOOLTIPED_ELEMENT);\n });\n this.mgTooltipContent.addEventListener('mouseleave', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, 'mouseleave', Guard.HOVER_TOOLTIPED_ELEMENT);\n });\n\n // append tooltip element to component\n this.element.appendChild(this.mgTooltipContent);\n }\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * set variables\n */\n componentWillLoad(): void {\n // Get windows to attach events\n this.windows = getWindows(window);\n\n // Get tooltip element\n this.renderTooltipContent();\n\n //validate properties\n this.watchPlacement(this.placement);\n this.watchDisabled(this.disabled);\n this.watchMessage(this.message);\n this.watchIdentifier(this.identifier);\n }\n\n /**\n * Get slotted element\n * Check if it already contain an interactive element, if not we need to add a tabIndex attribute\n * We need to attach the focused element to the tooltip (aria-describedby)\n */\n componentDidLoad(): void {\n // get slotted element wich is not the tooltip\n const slotElement: HTMLElement = this.element.querySelector(`*:not(#${this.identifier})`);\n\n // Get interactive element\n const interactiveElement: HTMLElement = slotElement.matches(focusableElements) ? slotElement : slotElement.shadowRoot?.querySelector(focusableElements);\n\n this.setTooltipedElement(interactiveElement || slotElement);\n\n // Check if slotted element is a disabled mg-button\n // In this case we wrap the mg-button into a div to enable the tooltip\n if (isButton(slotElement)) {\n this.setMgButtonMutationObserver(slotElement);\n this.setMgButtonWrapper(slotElement);\n }\n\n // Add tabindex to slotted element if we can't find any interactive element\n if (!this.disabled && [undefined, null].includes(interactiveElement)) {\n this.hasCustomTabIndex = true;\n slotElement.tabIndex = 0;\n // Add role on non-interactive element to work with \"aria-describedby\" for screen readers\n slotElement.setAttribute('role', 'button');\n }\n\n // apply a11y aria\n this.setAriaDescribedby(slotElement);\n\n // set Tooltip\n this.setFloatingUI(this.element.closest('mg-popover') !== null ? 'absolute' : 'fixed');\n\n // add document keyboard handler\n document.addEventListener('keydown', this.handlePressEscape);\n\n // check props\n this.watchDisplay(this.display);\n }\n\n /**\n * update popper position after props change on component did update hook to benefit from render ended\n */\n componentDidUpdate(): void {\n this.floatingUICleanup();\n this.setFloatingUI(this.element.closest('mg-popover') !== null ? 'absolute' : 'fixed');\n }\n\n /**\n * remove listeners\n */\n disconnectedCallback(): void {\n document.removeEventListener('keydown', this.handlePressEscape);\n this.windows?.forEach((localWindow: Window) => {\n localWindow.removeEventListener('click', this.handleClickOutside, false);\n localWindow.removeEventListener('keydown', this.handlePressEscape, false);\n });\n // cleanup Floating UI\n this.floatingUICleanup();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host>\n <slot></slot>\n <slot name=\"content\"></slot>\n </Host>\n );\n }\n}\n"],"version":3}