@mgdis/mg-components 6.10.0 → 6.10.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.
Files changed (114) hide show
  1. package/dist/cjs/{index-CfIlskRh.js → index-CL_COdxv.js} +4 -4
  2. package/dist/cjs/{index-CfIlskRh.js.map → index-CL_COdxv.js.map} +1 -1
  3. package/dist/cjs/{index.es-BCLy9yYb.js → index.es-DaPqByCe.js} +82 -82
  4. package/dist/cjs/index.es-DaPqByCe.js.map +1 -0
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/mg-action-more_37.cjs.entry.js +1881 -1874
  7. package/dist/cjs/mg-action-more_37.cjs.entry.js.map +1 -1
  8. package/dist/cjs/mg-alert.cjs.entry.js +6 -6
  9. package/dist/cjs/mg-components.cjs.js +1 -1
  10. package/dist/cjs/mg-input-combobox.cjs.entry.js +33 -33
  11. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +12 -12
  12. package/dist/cjs/mg-loader.cjs.entry.js +4 -4
  13. package/dist/cjs/mg-progress.cjs.entry.js +10 -10
  14. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +0 -1
  15. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -1
  16. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +43 -63
  17. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
  18. package/dist/collection/components/molecules/mg-popover/mg-popover.js +47 -97
  19. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  20. package/dist/components/index.es.js +71 -71
  21. package/dist/components/index.es.js.map +1 -1
  22. package/dist/components/index2.js +2 -2
  23. package/dist/components/mg-action-more.js +6 -6
  24. package/dist/components/mg-alert.js +5 -5
  25. package/dist/components/mg-badge2.js +6 -6
  26. package/dist/components/mg-button2.js +6 -6
  27. package/dist/components/mg-character-left2.js +4 -4
  28. package/dist/components/mg-details.js +2 -2
  29. package/dist/components/mg-form.js +7 -7
  30. package/dist/components/mg-icon2.js +6 -6
  31. package/dist/components/mg-illustrated-message.js +5 -5
  32. package/dist/components/mg-input-checkbox.js +9 -9
  33. package/dist/components/mg-input-combobox.js +32 -32
  34. package/dist/components/mg-input-date.js +17 -17
  35. package/dist/components/mg-input-numeric.js +13 -13
  36. package/dist/components/mg-input-password.js +3 -3
  37. package/dist/components/mg-input-radio.js +7 -7
  38. package/dist/components/mg-input-rich-text-editor.js +11 -11
  39. package/dist/components/mg-input-select2.js +7 -7
  40. package/dist/components/mg-input-text2.js +9 -9
  41. package/dist/components/mg-input-textarea.js +7 -7
  42. package/dist/components/mg-input-title2.js +4 -4
  43. package/dist/components/mg-input-toggle.js +6 -6
  44. package/dist/components/mg-input2.js +8 -8
  45. package/dist/components/mg-item-more2.js +7 -7
  46. package/dist/components/mg-loader2.js +3 -3
  47. package/dist/components/mg-menu-item2.js +11 -11
  48. package/dist/components/mg-message2.js +4 -4
  49. package/dist/components/mg-modal.js +8 -8
  50. package/dist/components/mg-pagination2.js +6 -6
  51. package/dist/components/mg-panel.js +9 -9
  52. package/dist/components/mg-popover-content2.js +4 -4
  53. package/dist/components/mg-popover-content2.js.map +1 -1
  54. package/dist/components/mg-popover2.js +48 -96
  55. package/dist/components/mg-popover2.js.map +1 -1
  56. package/dist/components/mg-progress.js +10 -10
  57. package/dist/components/mg-skip-links.js +2 -2
  58. package/dist/components/mg-table.js +6 -6
  59. package/dist/components/mg-tabs.js +12 -12
  60. package/dist/components/mg-tag.js +4 -4
  61. package/dist/components/mg-tooltip-content2.js +1 -1
  62. package/dist/components/mg-tooltip-content2.js.map +1 -1
  63. package/dist/components/mg-tooltip2.js +47 -66
  64. package/dist/components/mg-tooltip2.js.map +1 -1
  65. package/dist/components/popper.js +1793 -0
  66. package/dist/components/popper.js.map +1 -0
  67. package/dist/esm/{index-DmsGewMC.js → index-DALWFL9i.js} +4 -4
  68. package/dist/esm/{index-DmsGewMC.js.map → index-DALWFL9i.js.map} +1 -1
  69. package/dist/esm/{index.es-rLV3KFPd.js → index.es-hNwGkhG6.js} +73 -73
  70. package/dist/esm/index.es-hNwGkhG6.js.map +1 -0
  71. package/dist/esm/loader.js +1 -1
  72. package/dist/esm/mg-action-more_37.entry.js +1881 -1874
  73. package/dist/esm/mg-action-more_37.entry.js.map +1 -1
  74. package/dist/esm/mg-alert.entry.js +6 -6
  75. package/dist/esm/mg-components.js +1 -1
  76. package/dist/esm/mg-input-combobox.entry.js +33 -33
  77. package/dist/esm/mg-input-rich-text-editor.entry.js +12 -12
  78. package/dist/esm/mg-loader.entry.js +4 -4
  79. package/dist/esm/mg-progress.entry.js +10 -10
  80. package/dist/mg-components/mg-components.esm.js +1 -1
  81. package/dist/mg-components/{p-88f77de2.entry.js → p-352cfc01.entry.js} +2 -2
  82. package/dist/mg-components/{p-0f761c6c.entry.js → p-68f7de47.entry.js} +2 -2
  83. package/dist/mg-components/{p-DK9teKTo.js → p-Cg3R_y_o.js} +2 -2
  84. package/dist/mg-components/{p-DK9teKTo.js.map → p-Cg3R_y_o.js.map} +1 -1
  85. package/dist/mg-components/{p-cdbe689e.entry.js → p-a52a168c.entry.js} +2 -2
  86. package/dist/mg-components/{p-ad66e7b3.entry.js → p-bf5de898.entry.js} +2 -2
  87. package/dist/mg-components/{p-d3a868f0.entry.js → p-dcefa0b0.entry.js} +2 -2
  88. package/dist/mg-components/p-dcefa0b0.entry.js.map +1 -0
  89. package/dist/mg-components/{p-73099ed7.entry.js → p-e33557f9.entry.js} +2 -2
  90. package/dist/mg-components/{p-rLV3KFPd.js → p-hNwGkhG6.js} +2 -2
  91. package/dist/mg-components/p-hNwGkhG6.js.map +1 -0
  92. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +0 -6
  93. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +6 -8
  94. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +8 -22
  95. package/dist/types/components.d.ts +6 -8
  96. package/ide/intellij/web-types.json +1 -1
  97. package/package.json +9 -9
  98. package/dist/cjs/index.es-BCLy9yYb.js.map +0 -1
  99. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +0 -2
  100. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js.map +0 -1
  101. package/dist/collection/utils/floating-ui.utils.js +0 -74
  102. package/dist/collection/utils/floating-ui.utils.js.map +0 -1
  103. package/dist/components/floating-ui.utils.js +0 -1721
  104. package/dist/components/floating-ui.utils.js.map +0 -1
  105. package/dist/esm/index.es-rLV3KFPd.js.map +0 -1
  106. package/dist/mg-components/p-d3a868f0.entry.js.map +0 -1
  107. package/dist/mg-components/p-rLV3KFPd.js.map +0 -1
  108. package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +0 -6
  109. package/dist/types/utils/floating-ui.utils.d.ts +0 -28
  110. /package/dist/mg-components/{p-88f77de2.entry.js.map → p-352cfc01.entry.js.map} +0 -0
  111. /package/dist/mg-components/{p-0f761c6c.entry.js.map → p-68f7de47.entry.js.map} +0 -0
  112. /package/dist/mg-components/{p-cdbe689e.entry.js.map → p-a52a168c.entry.js.map} +0 -0
  113. /package/dist/mg-components/{p-ad66e7b3.entry.js.map → p-bf5de898.entry.js.map} +0 -0
  114. /package/dist/mg-components/{p-73099ed7.entry.js.map → p-e33557f9.entry.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { h, Host } from "@stencil/core";
2
2
  import { createID, focusableElements, getWindows, isValideID, isValidString, nextTick, toString } from "@mgdis/stencil-helpers";
3
- import { computePosition, autoUpdate, flip, shift, limitShift, offset, arrow } from "@floating-ui/dom";
4
- import { Guard, isFloatingUIPlacement, getTransformation, numberToPx } from "./mg-tooltip.conf";
3
+ import { createPopper } from "@popperjs/core";
4
+ import { Guard } from "./mg-tooltip.conf";
5
5
  /**
6
6
  * HTMLMgButtonElement type guard
7
7
  * @param element - element to check
@@ -36,6 +36,8 @@ export class MgTooltip {
36
36
  this.show = () => {
37
37
  // Make the tooltip visible
38
38
  this.mgTooltipContent.dataset.show = '';
39
+ // Enable the event listeners
40
+ this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
39
41
  // hide when click outside on nextTick to prevent event to trigger after creation
40
42
  nextTick(() => {
41
43
  this.windows.forEach((localWindow) => {
@@ -43,7 +45,6 @@ export class MgTooltip {
43
45
  localWindow.addEventListener('keydown', this.handlePressEscape, false);
44
46
  });
45
47
  });
46
- this.updateTooltip();
47
48
  };
48
49
  /**
49
50
  * Hide tooltip
@@ -51,6 +52,8 @@ export class MgTooltip {
51
52
  this.hide = () => {
52
53
  // Hide the tooltip
53
54
  this.mgTooltipContent.removeAttribute('data-show');
55
+ // Disable the event listeners
56
+ this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
54
57
  // Remove event listener
55
58
  this.windows.forEach((localWindow) => {
56
59
  localWindow.removeEventListener('click', this.handleClickOutside, false);
@@ -81,9 +84,8 @@ export class MgTooltip {
81
84
  * @param condition - additionnal condition to apply display prop newValue
82
85
  */
83
86
  this.setDisplay = (newValue, condition = true) => {
84
- if (!this.disabled && condition && this.display !== newValue) {
87
+ if (!this.disabled && condition)
85
88
  this.display = newValue;
86
- }
87
89
  };
88
90
  /**
89
91
  * Action for tooltip element and tooltiped element mouse listener
@@ -141,43 +143,30 @@ export class MgTooltip {
141
143
  }
142
144
  };
143
145
  /**
144
- * Update tooltip position
145
- * @returns autoUpdate function
146
+ * Set popper instance
147
+ * @param strategy - popper strategy to apply on instance
146
148
  */
147
- this.updateTooltip = () => autoUpdate(this.tooltipedElement, this.mgTooltipContent, async () => {
148
- // Placement
149
- const { x, y, placement, middlewareData } = await computePosition(this.tooltipedElement, this.mgTooltipContent, {
149
+ this.setPopper = (strategy) => {
150
+ // Create popperjs tooltip
151
+ this.popper = createPopper(this.tooltipedElement, this.mgTooltipContent, {
150
152
  placement: this.placement,
151
- strategy: this.tooltipStrategy,
152
- middleware: [
153
- offset(8),
154
- flip(),
155
- shift({
156
- limiter: limitShift(),
157
- }),
158
- arrow({ element: this.arrowElement }),
153
+ strategy,
154
+ modifiers: [
155
+ {
156
+ name: 'offset',
157
+ options: {
158
+ offset: [0, 8],
159
+ },
160
+ },
161
+ {
162
+ name: 'flip',
163
+ options: {
164
+ fallbackPlacements: ['auto'],
165
+ },
166
+ },
159
167
  ],
160
168
  });
161
- // Positioning
162
- Object.assign(this.mgTooltipContent.style, {
163
- position: this.tooltipStrategy,
164
- transform: getTransformation(x, y),
165
- });
166
- // Arrow positioning
167
- const { x: arrowX, y: arrowY } = middlewareData.arrow;
168
- const staticSide = {
169
- top: 'bottom',
170
- right: 'left',
171
- bottom: 'top',
172
- left: 'right',
173
- }[placement.split('-')[0]];
174
- Object.assign(this.arrowElement.style, {
175
- left: numberToPx(arrowX),
176
- top: numberToPx(arrowY),
177
- [staticSide]: '-4px',
178
- });
179
- this.mgTooltipContent.setAttribute('data-placement', placement);
180
- });
169
+ };
181
170
  /**
182
171
  * Define selected element to become tooltip selector and init listeners
183
172
  * @param element - tooltiped element
@@ -219,15 +208,17 @@ export class MgTooltip {
219
208
  // set guard when one of mutations is for a disabled with disabled-on-click
220
209
  if (mutationList.some((mutation) => mutation.target.disabled && mutation.target.disableOnClick)) {
221
210
  this.guard = Guard.DISABLE_ON_CLICK;
222
- return;
223
211
  }
212
+ // when the disabled-on-click guard is running we stop process
213
+ if (this.guard === Guard.DISABLE_ON_CLICK)
214
+ return;
224
215
  // update button wrapper
225
216
  this.setMgButtonWrapper(mgButton);
226
217
  // Since Firefox doesn't trigger a "blur" event when the "disabled" attribute is added or removed from a button
227
218
  // we have to manually unlock the guard because the "blur" handler of the tooltipedElement won't do it.
228
219
  this.resetGuard();
229
- // update Floating UI instance
230
- this.updateTooltip();
220
+ // update popper instance
221
+ this.popper.update();
231
222
  }).observe(mgButton, { attributes: true });
232
223
  };
233
224
  /**
@@ -259,10 +250,6 @@ export class MgTooltip {
259
250
  if (this.mgTooltipContent !== undefined)
260
251
  this.mgTooltipContent.message = newValue;
261
252
  }
262
- watchPlacement(newValue) {
263
- if (!isFloatingUIPlacement(newValue))
264
- this.placement = 'bottom';
265
- }
266
253
  watchDisplay(newValue) {
267
254
  if (newValue) {
268
255
  this.show();
@@ -292,7 +279,7 @@ export class MgTooltip {
292
279
  this.mgTooltipContent.setAttribute('id', this.identifier);
293
280
  const arrow = document.createElement('div');
294
281
  arrow.setAttribute('slot', 'arrow');
295
- arrow.dataset.floatingArrow = '';
282
+ arrow.dataset.popperArrow = '';
296
283
  this.mgTooltipContent.appendChild(arrow);
297
284
  // manage tooltipElement & tooltipedElement mouseenter/mouseleave events
298
285
  this.mgTooltipContent.addEventListener('mouseenter', () => {
@@ -317,12 +304,9 @@ export class MgTooltip {
317
304
  // Get tooltip element
318
305
  this.renderTooltipContent();
319
306
  //validate properties
320
- this.watchPlacement(this.placement);
321
307
  this.watchDisabled(this.disabled);
322
308
  this.watchMessage(this.message);
323
309
  this.watchIdentifier(this.identifier);
324
- // define if the tooltip is inside a popover
325
- this.tooltipStrategy = this.element.closest('mg-popover') !== null ? 'absolute' : 'fixed';
326
310
  }
327
311
  /**
328
312
  * Get slotted element
@@ -336,8 +320,6 @@ export class MgTooltip {
336
320
  // Get interactive element
337
321
  const interactiveElement = slotElement.matches(focusableElements) ? slotElement : (_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(focusableElements);
338
322
  this.setTooltipedElement(interactiveElement || slotElement);
339
- // Set arrow element
340
- this.arrowElement = this.mgTooltipContent.querySelector('[data-floating-arrow]');
341
323
  // Check if slotted element is a disabled mg-button
342
324
  // In this case we wrap the mg-button into a div to enable the tooltip
343
325
  if (isButton(slotElement)) {
@@ -353,6 +335,8 @@ export class MgTooltip {
353
335
  }
354
336
  // apply a11y aria
355
337
  this.setAriaDescribedby(slotElement);
338
+ // set Tooltip
339
+ this.setPopper(this.element.closest('mg-popover') !== null ? 'absolute' : 'fixed');
356
340
  // add document keyboard handler
357
341
  document.addEventListener('keydown', this.handlePressEscape);
358
342
  // check props
@@ -362,26 +346,25 @@ export class MgTooltip {
362
346
  * update popper position after props change on component did update hook to benefit from render ended
363
347
  */
364
348
  componentDidUpdate() {
365
- this.updateTooltip();
349
+ this.popper.update();
366
350
  }
367
351
  /**
368
352
  * remove listeners
369
353
  */
370
354
  disconnectedCallback() {
371
- var _a, _b;
355
+ var _a;
372
356
  document.removeEventListener('keydown', this.handlePressEscape);
373
357
  (_a = this.windows) === null || _a === void 0 ? void 0 : _a.forEach((localWindow) => {
374
358
  localWindow.removeEventListener('click', this.handleClickOutside, false);
375
359
  localWindow.removeEventListener('keydown', this.handlePressEscape, false);
376
360
  });
377
- (_b = this.updateTooltip) === null || _b === void 0 ? void 0 : _b.call(this);
378
361
  }
379
362
  /**
380
363
  * Render
381
364
  * @returns HTML Element
382
365
  */
383
366
  render() {
384
- return (h(Host, { key: 'dab470c730b1541ab5be487222da8ba3643501ae' }, h("slot", { key: 'a6f5d444e3521d93cf9f39ccffcd68cfde4f8101' }), h("slot", { key: 'ba4d98f953453a710379cb4ce28f1c468a34ffc4', name: "content" })));
367
+ return (h(Host, { key: '9aae13f15c5c93d3a2e887a75e1ad54fd823f79e' }, h("slot", { key: 'd7a42dac1c0e43c1fddc08f80ba36ce5db65af0a' }), h("slot", { key: 'a89fc2e61a82de8d41d1231f5ba0136cd801f1f3', name: "content" })));
385
368
  }
386
369
  static get is() { return "mg-tooltip"; }
387
370
  static get encapsulation() { return "shadow"; }
@@ -438,15 +421,15 @@ export class MgTooltip {
438
421
  },
439
422
  "placement": {
440
423
  "type": "string",
441
- "mutable": true,
424
+ "mutable": false,
442
425
  "complexType": {
443
- "original": "TooltipPlacementType",
426
+ "original": "Placement",
444
427
  "resolved": "\"auto\" | \"auto-end\" | \"auto-start\" | \"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
445
428
  "references": {
446
- "TooltipPlacementType": {
429
+ "Placement": {
447
430
  "location": "import",
448
- "path": "./mg-tooltip.conf",
449
- "id": "src/components/atoms/mg-tooltip/mg-tooltip.conf.tsx::TooltipPlacementType"
431
+ "path": "@popperjs/core",
432
+ "id": "../../node_modules/.pnpm/@popperjs+core@2.11.8/node_modules/@popperjs/core/index.d.ts::Placement"
450
433
  }
451
434
  }
452
435
  },
@@ -512,9 +495,6 @@ export class MgTooltip {
512
495
  }, {
513
496
  "propName": "message",
514
497
  "methodName": "watchMessage"
515
- }, {
516
- "propName": "placement",
517
- "methodName": "watchPlacement"
518
498
  }, {
519
499
  "propName": "display",
520
500
  "methodName": "watchDisplay"
@@ -1 +1 @@
1
- {"version":3,"file":"mg-tooltip.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-tooltip/mg-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAChI,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAiC,MAAM,kBAAkB,CAAC;AACtI,OAAO,EAAkB,KAAK,EAA6B,qBAAqB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE3I;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,OAAgB,EAAkC,EAAE,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAE,OAAmB,CAAC,OAAO,CAAC,CAAC;AAErK;;GA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AAO,CACL,EAAC,IAAI;YACH,8DAAa;YACb,6DAAM,IAAI,EAAC,SAAS,GAAQ,CACvB,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["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, getTransformation, numberToPx } 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 */\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 mgTooltipContent: HTMLMgTooltipContentElement;\n private tooltipedElement: HTMLElement;\n private arrowElement: HTMLElement;\n private windows: Window[];\n private hasCustomTabIndex: boolean;\n private tooltipStrategy: Strategy;\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: TooltipPlacementType): 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 this.updateTooltip();\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 this.display = newValue;\n }\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 * Update tooltip position\n * @returns autoUpdate function\n */\n private updateTooltip = () =>\n autoUpdate(this.tooltipedElement, this.mgTooltipContent, async () => {\n // Placement\n const { x, y, placement, middlewareData } = await computePosition(this.tooltipedElement, this.mgTooltipContent, {\n placement: this.placement as Placement,\n strategy: this.tooltipStrategy,\n middleware: [\n offset(8),\n flip(),\n shift({\n limiter: limitShift(),\n }),\n arrow({ element: this.arrowElement }),\n ],\n });\n\n // Positioning\n Object.assign(this.mgTooltipContent.style, {\n position: this.tooltipStrategy,\n transform: getTransformation(x, y),\n });\n\n // Arrow positioning\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n\n const staticSide = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n }[placement.split('-')[0]];\n\n Object.assign(this.arrowElement.style, {\n left: numberToPx(arrowX),\n top: numberToPx(arrowY),\n [staticSide]: '-4px',\n });\n\n this.mgTooltipContent.setAttribute('data-placement', placement);\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 return;\n }\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.updateTooltip();\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 // define if the tooltip is inside a popover\n this.tooltipStrategy = this.element.closest('mg-popover') !== null ? 'absolute' : 'fixed';\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 // Set arrow element\n this.arrowElement = this.mgTooltipContent.querySelector('[data-floating-arrow]');\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 // 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.updateTooltip();\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 this.updateTooltip?.();\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"]}
1
+ {"version":3,"file":"mg-tooltip.js","sourceRoot":"","sources":["../../../../src/components/atoms/mg-tooltip/mg-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAChI,OAAO,EAA8B,YAAY,EAAkC,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAkB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,OA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,cAAc;QACd,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,oBAAoB;;QAClB,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChE,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAC,CAAC,WAAmB,EAAE,EAAE;YAC5C,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;QAC5E,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,OAAO,CACL,EAAC,IAAI;YACH,8DAAa;YACb,6DAAM,IAAI,EAAC,SAAS,GAAQ,CACvB,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["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 */\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"]}
@@ -1,7 +1,6 @@
1
1
  import { Host, h } from "@stencil/core";
2
2
  import { createID, getWindows, isValideID, toString } from "@mgdis/stencil-helpers";
3
- import { computePosition, autoUpdate, flip, shift, limitShift, offset, arrow } from "@floating-ui/dom";
4
- import { isFloatingUIPlacement, sides, alignments, getTransformation, numberToPx } from "./mg-popover.conf";
3
+ import { createPopper } from "@popperjs/core";
5
4
  /**
6
5
  * @slot - Element that will display the popover
7
6
  * @slot content - popover content
@@ -51,12 +50,13 @@ export class MgPopover {
51
50
  this.mgPopover.dataset.show = '';
52
51
  // Update aria-expanded
53
52
  this.interactiveElement.setAttribute('aria-expanded', 'true');
53
+ // Enable the event listeners
54
+ this.setPopperListeners(true);
54
55
  // hide when click outside
55
56
  // setTimeout is used to prevent event to trigger after creation
56
57
  setTimeout(() => {
57
58
  this.manageClickOutsideListeners('addEventListener');
58
59
  });
59
- this.updatePopover();
60
60
  };
61
61
  /**
62
62
  * Hide popover
@@ -66,9 +66,18 @@ export class MgPopover {
66
66
  this.mgPopover.removeAttribute('data-show');
67
67
  // Update aria-expanded
68
68
  this.interactiveElement.setAttribute('aria-expanded', 'false');
69
+ // Disable the event listeners
70
+ this.setPopperListeners(false);
69
71
  // Remove event listener
70
72
  this.manageClickOutsideListeners('removeEventListener');
71
73
  };
74
+ /**
75
+ * Set popper listeners
76
+ * @param newValue - if true enable popper listners
77
+ */
78
+ this.setPopperListeners = (newValue) => {
79
+ this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: newValue }] })));
80
+ };
72
81
  /**
73
82
  * Manage all clickOustside listeners
74
83
  * @param action - top process on elements listeners
@@ -106,7 +115,7 @@ export class MgPopover {
106
115
  this.mgPopoverContent.addEventListener('hide-content', this.handleHideContent);
107
116
  const arrow = document.createElement('div');
108
117
  arrow.setAttribute('slot', 'arrow');
109
- arrow.dataset.floatingArrow = '';
118
+ arrow.dataset.popperArrow = '';
110
119
  this.mgPopoverContent.appendChild(arrow);
111
120
  // insert elements in DOM
112
121
  ['[slot="title"]', '[slot="content"]:not(mg-popover-content)'].forEach(slotType => {
@@ -120,70 +129,6 @@ export class MgPopover {
120
129
  mgPopoverContent.setAttribute('id', this.identifier);
121
130
  }
122
131
  };
123
- /**
124
- * Get alternative placements ordered by proximity to initial placement
125
- * First check fallbackPlacement attribute, then generate alternatives:
126
- * 1. Same side with different alignments (start, center, end)
127
- * 2. Other sides in order
128
- * @param placement - initial placement
129
- * @returns array of alternative placements
130
- */
131
- this.getClosestPlacements = (placement) => {
132
- // First check if fallbackPlacement attribute is defined
133
- const fallbackPlacements = (this.element.dataset.fallbackPlacement || '')
134
- .split(',')
135
- .map(t => t.trim())
136
- .filter(isFloatingUIPlacement);
137
- if (fallbackPlacements.length > 0)
138
- return Array.from(new Set([...fallbackPlacements, ...sides]).values()).filter(isFloatingUIPlacement);
139
- // Extract side from placement (e.g. "top" from "top-start")
140
- const [side] = placement.split('-');
141
- // Generate placements for same side with different alignments
142
- const currentSidePlacements = alignments.map(alignment => (alignment !== null ? `${side}-${alignment}` : side));
143
- // Return unique placements: current side variants first, then other sides
144
- return Array.from(new Set([...currentSidePlacements, ...sides.filter(otherSide => otherSide !== side)])).filter(isFloatingUIPlacement);
145
- };
146
- /**
147
- * Update popover position
148
- * @returns autoUpdate function
149
- */
150
- this.updatePopover = () => autoUpdate(this.interactiveElement, this.mgPopover, async () => {
151
- const { x, y, placement, middlewareData } = await computePosition(this.interactiveElement, this.mgPopover, {
152
- placement: this.placement,
153
- strategy: 'fixed',
154
- middleware: [
155
- offset(0),
156
- flip({
157
- fallbackPlacements: this.getClosestPlacements(this.placement),
158
- }),
159
- shift({
160
- limiter: limitShift(),
161
- }),
162
- arrow({
163
- element: this.arrowElement,
164
- }),
165
- ],
166
- });
167
- Object.assign(this.mgPopover.style, {
168
- transform: getTransformation(x, y),
169
- });
170
- // Arrow positioning
171
- if (this.arrowElement !== null) {
172
- const { x: arrowX, y: arrowY } = middlewareData.arrow;
173
- const staticSide = {
174
- top: 'bottom',
175
- right: 'left',
176
- bottom: 'top',
177
- left: 'right',
178
- }[placement.split('-')[0]];
179
- Object.assign(this.arrowElement.style, {
180
- left: numberToPx(arrowX),
181
- top: numberToPx(arrowY),
182
- [staticSide]: '1px',
183
- });
184
- this.mgPopover.setAttribute('data-placement', placement);
185
- }
186
- });
187
132
  }
188
133
  validateIdentifier(newValue) {
189
134
  if (!isValideID(newValue)) {
@@ -192,10 +137,6 @@ export class MgPopover {
192
137
  // use renderPopoverContent to update popover-content id
193
138
  this.renderPopoverContent();
194
139
  }
195
- watchPlacement(newValue) {
196
- if (!isFloatingUIPlacement(newValue))
197
- this.placement = 'bottom';
198
- }
199
140
  validateArrowHide(newValue) {
200
141
  if (newValue)
201
142
  this.mgPopoverContent.dataset.arrowHide = '';
@@ -221,7 +162,7 @@ export class MgPopover {
221
162
  * update popper position after props change on component did update hook to benefit from render ended
222
163
  */
223
164
  componentDidUpdate() {
224
- this.updatePopover();
165
+ this.popper.update();
225
166
  }
226
167
  /**
227
168
  * Check if component props are well configured on init
@@ -234,7 +175,6 @@ export class MgPopover {
234
175
  this.validateCloseButton(this.closeButton);
235
176
  this.validateIdentifier(this.identifier);
236
177
  this.validateArrowHide(this.arrowHide);
237
- this.watchPlacement(this.placement);
238
178
  }
239
179
  /**
240
180
  * Check if component props are well configured on init
@@ -242,17 +182,38 @@ export class MgPopover {
242
182
  componentDidLoad() {
243
183
  // Get popover content
244
184
  this.mgPopover = this.element.querySelector(`#${this.identifier}`);
245
- // Get arrow element
246
- this.arrowElement = this.mgPopover.querySelector('[data-floating-arrow]');
247
- // Get interactive element (first element without slot attribute)
185
+ //Get interactive element (first element without slot attribute)
248
186
  this.interactiveElement = this.element.querySelector(':not([slot])');
249
187
  // Add aria attributes
250
188
  this.interactiveElement.setAttribute('aria-controls', this.identifier);
251
189
  this.interactiveElement.setAttribute('aria-expanded', `${this.display}`);
252
- // Add resize observer
253
- [this.interactiveElement, this.mgPopoverContent].forEach(element => {
190
+ const fallbackPlacements = [];
191
+ if (this.element.dataset.fallbackPlacement !== undefined) {
192
+ fallbackPlacements.push(this.element.dataset.fallbackPlacement);
193
+ }
194
+ // Create popperjs popover
195
+ this.popper = createPopper(this.interactiveElement, this.mgPopover, {
196
+ placement: this.placement,
197
+ strategy: 'fixed',
198
+ modifiers: [
199
+ {
200
+ name: 'offset',
201
+ options: {
202
+ offset: [0, 0],
203
+ },
204
+ },
205
+ {
206
+ name: 'flip',
207
+ options: {
208
+ fallbackPlacements: [...fallbackPlacements, 'auto'],
209
+ },
210
+ },
211
+ ],
212
+ });
213
+ // add resize observer
214
+ [this.interactiveElement, this.element.querySelector('mg-popover-content')].forEach(element => {
254
215
  new ResizeObserver(() => {
255
- this.updatePopover();
216
+ this.popper.update();
256
217
  }).observe(element);
257
218
  });
258
219
  // Add events to toggle display
@@ -276,20 +237,12 @@ export class MgPopover {
276
237
  });
277
238
  this.handleDisplay(this.display);
278
239
  }
279
- /**
280
- * Cleanup when component is disconnected
281
- */
282
- disconnectedCallback() {
283
- var _a;
284
- // Cleanup Floating UI instance
285
- (_a = this.updatePopover) === null || _a === void 0 ? void 0 : _a.call(this);
286
- }
287
240
  /**
288
241
  * Render
289
242
  * @returns HTML Element
290
243
  */
291
244
  render() {
292
- return (h(Host, { key: '26244db5e6a35b731b5220c06b77ad1f14378245' }, h("slot", { key: '92ca05ac9637cf9634d86b177393fd6d0e6c6796' }), h("slot", { key: 'bdc8f8a8b4f2c891e473cdac5a305c3f1ab615b0', name: "content" })));
245
+ return (h(Host, { key: '59f4be0c4d8f066a2f5c6197f237b4bb802fa4fa' }, h("slot", { key: 'bcaaa47052d360711722b9f617b93a4f0f148ca8' }), h("slot", { key: '598390c0e09b27edc2f2a77e29ee2a501a6ecdf8', name: "content" })));
293
246
  }
294
247
  static get is() { return "mg-popover"; }
295
248
  static get encapsulation() { return "shadow"; }
@@ -327,15 +280,15 @@ export class MgPopover {
327
280
  },
328
281
  "placement": {
329
282
  "type": "string",
330
- "mutable": true,
283
+ "mutable": false,
331
284
  "complexType": {
332
- "original": "PopoverPlacementType",
285
+ "original": "Placement",
333
286
  "resolved": "\"auto\" | \"auto-end\" | \"auto-start\" | \"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
334
287
  "references": {
335
- "PopoverPlacementType": {
288
+ "Placement": {
336
289
  "location": "import",
337
- "path": "./mg-popover.conf",
338
- "id": "src/components/molecules/mg-popover/mg-popover.conf.tsx::PopoverPlacementType"
290
+ "path": "@popperjs/core",
291
+ "id": "../../node_modules/.pnpm/@popperjs+core@2.11.8/node_modules/@popperjs/core/index.d.ts::Placement"
339
292
  }
340
293
  }
341
294
  },
@@ -476,9 +429,6 @@ export class MgPopover {
476
429
  return [{
477
430
  "propName": "identifier",
478
431
  "methodName": "validateIdentifier"
479
- }, {
480
- "propName": "placement",
481
- "methodName": "watchPlacement"
482
432
  }, {
483
433
  "propName": "arrowHide",
484
434
  "methodName": "validateArrowHide"