@mgdis/mg-components 6.10.0 → 6.11.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 (142) hide show
  1. package/dist/cjs/{index-CfIlskRh.js → index-B_WwxtkQ.js} +4 -4
  2. package/dist/cjs/{index-CfIlskRh.js.map → index-B_WwxtkQ.js.map} +1 -1
  3. package/dist/cjs/{index.es-BCLy9yYb.js → index.es-C-3Gv8Eu.js} +85 -81
  4. package/dist/cjs/index.es-C-3Gv8Eu.js.map +1 -0
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/mg-action-more_37.cjs.entry.js +1915 -1909
  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 +75 -72
  11. package/dist/cjs/mg-input-combobox.cjs.entry.js.map +1 -1
  12. package/dist/cjs/mg-input-combobox.entry.cjs.js.map +1 -1
  13. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +12 -12
  14. package/dist/cjs/mg-loader.cjs.entry.js +4 -4
  15. package/dist/cjs/mg-progress.cjs.entry.js +10 -10
  16. package/dist/collection/components/atoms/mg-button/mg-button.js +1 -1
  17. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  18. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +0 -1
  19. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -1
  20. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +43 -63
  21. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
  22. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.js.map +1 -1
  23. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +67 -45
  24. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js.map +1 -1
  25. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +25 -30
  26. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
  27. package/dist/collection/components/molecules/mg-details/mg-details.js +5 -1
  28. package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
  29. package/dist/collection/components/molecules/mg-popover/mg-popover.js +47 -97
  30. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  31. package/dist/components/index.es.js +71 -68
  32. package/dist/components/index.es.js.map +1 -1
  33. package/dist/components/index2.js +2 -2
  34. package/dist/components/mg-action-more.js +6 -6
  35. package/dist/components/mg-alert.js +5 -5
  36. package/dist/components/mg-badge2.js +6 -6
  37. package/dist/components/mg-button2.js +7 -7
  38. package/dist/components/mg-button2.js.map +1 -1
  39. package/dist/components/mg-character-left2.js +4 -4
  40. package/dist/components/mg-details.js +8 -4
  41. package/dist/components/mg-details.js.map +1 -1
  42. package/dist/components/mg-form.js +7 -7
  43. package/dist/components/mg-icon2.js +6 -6
  44. package/dist/components/mg-illustrated-message.js +5 -5
  45. package/dist/components/mg-input-checkbox.js +9 -9
  46. package/dist/components/mg-input-combobox.js +74 -71
  47. package/dist/components/mg-input-combobox.js.map +1 -1
  48. package/dist/components/mg-input-date.js +17 -17
  49. package/dist/components/mg-input-numeric.js +13 -13
  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-rich-text-editor.js +11 -11
  53. package/dist/components/mg-input-select2.js +32 -37
  54. package/dist/components/mg-input-select2.js.map +1 -1
  55. package/dist/components/mg-input-text2.js +9 -9
  56. package/dist/components/mg-input-textarea.js +7 -7
  57. package/dist/components/mg-input-title2.js +4 -4
  58. package/dist/components/mg-input-toggle.js +6 -6
  59. package/dist/components/mg-input2.js +8 -8
  60. package/dist/components/mg-item-more2.js +7 -7
  61. package/dist/components/mg-loader2.js +3 -3
  62. package/dist/components/mg-menu-item2.js +11 -11
  63. package/dist/components/mg-message2.js +4 -4
  64. package/dist/components/mg-modal.js +8 -8
  65. package/dist/components/mg-pagination2.js +6 -6
  66. package/dist/components/mg-panel.js +9 -9
  67. package/dist/components/mg-popover-content2.js +4 -4
  68. package/dist/components/mg-popover-content2.js.map +1 -1
  69. package/dist/components/mg-popover2.js +48 -96
  70. package/dist/components/mg-popover2.js.map +1 -1
  71. package/dist/components/mg-progress.js +10 -10
  72. package/dist/components/mg-skip-links.js +2 -2
  73. package/dist/components/mg-table.js +6 -6
  74. package/dist/components/mg-tabs.js +12 -12
  75. package/dist/components/mg-tag.js +4 -4
  76. package/dist/components/mg-tooltip-content2.js +1 -1
  77. package/dist/components/mg-tooltip-content2.js.map +1 -1
  78. package/dist/components/mg-tooltip2.js +47 -66
  79. package/dist/components/mg-tooltip2.js.map +1 -1
  80. package/dist/components/popper.js +1793 -0
  81. package/dist/components/popper.js.map +1 -0
  82. package/dist/esm/{index-DmsGewMC.js → index-DHpyFawS.js} +4 -4
  83. package/dist/esm/{index-DmsGewMC.js.map → index-DHpyFawS.js.map} +1 -1
  84. package/dist/esm/{index.es-rLV3KFPd.js → index.es-lyrZ9KRh.js} +73 -70
  85. package/dist/esm/index.es-lyrZ9KRh.js.map +1 -0
  86. package/dist/esm/loader.js +1 -1
  87. package/dist/esm/mg-action-more_37.entry.js +1915 -1909
  88. package/dist/esm/mg-action-more_37.entry.js.map +1 -1
  89. package/dist/esm/mg-alert.entry.js +6 -6
  90. package/dist/esm/mg-components.js +1 -1
  91. package/dist/esm/mg-input-combobox.entry.js +75 -72
  92. package/dist/esm/mg-input-combobox.entry.js.map +1 -1
  93. package/dist/esm/mg-input-rich-text-editor.entry.js +12 -12
  94. package/dist/esm/mg-loader.entry.js +4 -4
  95. package/dist/esm/mg-progress.entry.js +10 -10
  96. package/dist/mg-components/mg-components.esm.js +1 -1
  97. package/dist/mg-components/mg-input-combobox.entry.esm.js.map +1 -1
  98. package/dist/mg-components/{p-ad66e7b3.entry.js → p-596c0e08.entry.js} +2 -2
  99. package/dist/mg-components/p-8a3bd8ad.entry.js +2 -0
  100. package/dist/mg-components/p-8a3bd8ad.entry.js.map +1 -0
  101. package/dist/mg-components/p-98a74b62.entry.js +2 -0
  102. package/dist/mg-components/{p-cdbe689e.entry.js.map → p-98a74b62.entry.js.map} +1 -1
  103. package/dist/mg-components/{p-DK9teKTo.js → p-C-vIqOyI.js} +2 -2
  104. package/dist/mg-components/{p-DK9teKTo.js.map → p-C-vIqOyI.js.map} +1 -1
  105. package/dist/mg-components/{p-73099ed7.entry.js → p-d4ed3aad.entry.js} +2 -2
  106. package/dist/mg-components/p-e822bd96.entry.js +2 -0
  107. package/dist/mg-components/{p-88f77de2.entry.js.map → p-e822bd96.entry.js.map} +1 -1
  108. package/dist/mg-components/p-fc7b96e6.entry.js +2 -0
  109. package/dist/mg-components/p-fc7b96e6.entry.js.map +1 -0
  110. package/dist/mg-components/p-lyrZ9KRh.js +2 -0
  111. package/dist/mg-components/p-lyrZ9KRh.js.map +1 -0
  112. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +0 -6
  113. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +6 -8
  114. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.d.ts +1 -1
  115. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +5 -0
  116. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +0 -9
  117. package/dist/types/components/molecules/mg-details/mg-details.d.ts +1 -0
  118. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +8 -22
  119. package/dist/types/components.d.ts +11 -8
  120. package/ide/intellij/web-types.json +6 -2
  121. package/ide/vscode/html-custom-data.json +1 -1
  122. package/package.json +12 -12
  123. package/dist/cjs/index.es-BCLy9yYb.js.map +0 -1
  124. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +0 -2
  125. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js.map +0 -1
  126. package/dist/collection/utils/floating-ui.utils.js +0 -74
  127. package/dist/collection/utils/floating-ui.utils.js.map +0 -1
  128. package/dist/components/floating-ui.utils.js +0 -1721
  129. package/dist/components/floating-ui.utils.js.map +0 -1
  130. package/dist/esm/index.es-rLV3KFPd.js.map +0 -1
  131. package/dist/mg-components/p-0f761c6c.entry.js +0 -2
  132. package/dist/mg-components/p-0f761c6c.entry.js.map +0 -1
  133. package/dist/mg-components/p-88f77de2.entry.js +0 -2
  134. package/dist/mg-components/p-cdbe689e.entry.js +0 -2
  135. package/dist/mg-components/p-d3a868f0.entry.js +0 -2
  136. package/dist/mg-components/p-d3a868f0.entry.js.map +0 -1
  137. package/dist/mg-components/p-rLV3KFPd.js +0 -2
  138. package/dist/mg-components/p-rLV3KFPd.js.map +0 -1
  139. package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +0 -6
  140. package/dist/types/utils/floating-ui.utils.d.ts +0 -28
  141. /package/dist/mg-components/{p-ad66e7b3.entry.js.map → p-596c0e08.entry.js.map} +0 -0
  142. /package/dist/mg-components/{p-73099ed7.entry.js.map → p-d4ed3aad.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;;GAEG;AAMH,MAAM,OAAO,SAAS;IALtB;QA6BE;;;WAGG;QACK,eAAU,GAAW,QAAQ,CAAC,YAAY,CAAC,CAAC;QAsBp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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,OAAgB,EAAkC,EAAE,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAA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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 +1 @@
1
- {"version":3,"file":"mg-input-combobox.conf.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.ts"],"names":[],"mappings":"","sourcesContent":["import type { CursorType } from '@mgdis/stencil-helpers';\n\n/**\n * Define action type\n */\nexport type ActionType = { name: 'scroll' | 'load-data' | 'load-more'; cursor?: CursorType };\n\n/**\n * Define request mapping type\n */\nexport type RequestMappingType = { filter: string };\n\n/**\n * Define response mapping type\n */\nexport type ResponseMappingType = { total: string; items: string; next: string; itemTitle: string; itemValue: string };\n"]}
1
+ {"version":3,"file":"mg-input-combobox.conf.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.ts"],"names":[],"mappings":"","sourcesContent":["import type { CursorType } from '@mgdis/stencil-helpers';\n\n/**\n * Define action type\n */\nexport type ActionType = { name: 'scroll' | 'load-data' | 'load-more'; cursor?: CursorType };\n\n/**\n * Define request mapping type\n */\nexport type RequestMappingType = { filter: string };\n\n/**\n * Define response mapping type\n */\nexport type ResponseMappingType = { total: string; items: string; next: string; itemTitle: string; itemValue?: string };\n"]}
@@ -1,5 +1,5 @@
1
1
  import { h } from "@stencil/core";
2
- import { allItemsAreString, ClassList, getObjectValueFromKey, isValidString, nextTick, Page, Paginate, Cursor, toString, isObject } from "@mgdis/stencil-helpers";
2
+ import { allItemsAreString, ClassList, getObjectValueFromKey, isValidString, nextTick, Page, Paginate, Cursor, toString, isObject, formatID, } from "@mgdis/stencil-helpers";
3
3
  import { widths, classReadonly, classDisabled } from "../mg-input/mg-input.conf";
4
4
  import { initLocales } from "../../../../locales";
5
5
  import { Keys } from "../../../../utils/events.utils";
@@ -32,35 +32,13 @@ const isFetchmappings = (value) => {
32
32
  typeof response.items === 'string' &&
33
33
  typeof response.next === 'string' &&
34
34
  typeof response.itemTitle === 'string' &&
35
- typeof response.itemValue === 'string';
35
+ (typeof response.itemValue === 'string' || response.itemValue === undefined);
36
36
  return isValidRequest && isValidResponse;
37
37
  }
38
38
  else {
39
39
  return isValidRoot;
40
40
  }
41
41
  };
42
- /**
43
- * Map new URL from old url
44
- * @param newValue - new URL value
45
- * @param oldValue - previous URL value
46
- * @returns updated url
47
- */
48
- const mapUrl = (newValue, oldValue) => {
49
- if (!Boolean(newValue))
50
- return;
51
- else if (URL.canParse(newValue)) {
52
- return newValue;
53
- }
54
- // build new URL
55
- const params = newValue.includes('?') && newValue.split('?').pop();
56
- if (Boolean(params)) {
57
- const { origin, pathname } = new URL(oldValue);
58
- return `${origin}${pathname}?${params}`;
59
- }
60
- else {
61
- return newValue;
62
- }
63
- };
64
42
  export class MgInputCombobox {
65
43
  constructor() {
66
44
  /************
@@ -124,7 +102,7 @@ export class MgInputCombobox {
124
102
  * @param event - option element click event
125
103
  */
126
104
  this.handleOptionClick = (event) => {
127
- this.setValue(this.options.items.find(option => option.value === event.target.id));
105
+ this.setValue(this.options.items.find(option => formatID(option.value) === event.target.id));
128
106
  this.popoverDisplay = false;
129
107
  };
130
108
  /**
@@ -152,7 +130,14 @@ export class MgInputCombobox {
152
130
  this.setErrorMessage();
153
131
  if (!this.popoverDisplay)
154
132
  this.popoverDisplay = true;
155
- this.filter = this.input.value;
133
+ // update filter with debounce to prevent filter update overload
134
+ if (!this.debounce) {
135
+ this.debounce = true;
136
+ setTimeout(() => {
137
+ this.filter = this.input.value;
138
+ this.debounce = false;
139
+ }, 250);
140
+ }
156
141
  };
157
142
  /**
158
143
  * Handle `blur` event
@@ -456,18 +441,23 @@ export class MgInputCombobox {
456
441
  // add text filter
457
442
  const updateUrl = (typeof url === 'string' ? url : url.toString()).replaceAll(this.fetchmappings.request.filter, encodeURIComponent(this.filter));
458
443
  try {
459
- const response = await fetch(updateUrl, this.fetchoptions).then(response => response.json());
460
- if (!response)
461
- return null;
462
- const items = getObjectValueFromKey(response, this.fetchmappings.response.items).map((item) => ({
444
+ const response = await fetch(updateUrl, this.fetchoptions);
445
+ if (!response.ok) {
446
+ this.fetchError.emit(new Error(`${response.status} - ${response.statusText}`));
447
+ return;
448
+ }
449
+ const json = await response.json();
450
+ const items = getObjectValueFromKey(json, this.fetchmappings.response.items).map((item) => ({
463
451
  title: getObjectValueFromKey(item, this.fetchmappings.response.itemTitle),
464
- value: getObjectValueFromKey(item, this.fetchmappings.response.itemValue),
452
+ value: this.fetchmappings.response.itemValue ? getObjectValueFromKey(item, this.fetchmappings.response.itemValue) : item,
465
453
  }));
466
- const total = Number(getObjectValueFromKey(response, this.fetchmappings.response.total, 0));
467
- const next = mapUrl(getObjectValueFromKey(response, this.fetchmappings.response.next), this.fetchurl.toString());
454
+ const total = Number(getObjectValueFromKey(json, this.fetchmappings.response.total, 0));
455
+ const next = getObjectValueFromKey(json, this.fetchmappings.response.next);
468
456
  return { items, total, next, top: items.length };
469
457
  }
470
- catch (_a) { }
458
+ catch (error) {
459
+ this.fetchError.emit(error);
460
+ }
471
461
  };
472
462
  }
473
463
  watchValue(newValue) {
@@ -539,8 +529,8 @@ export class MgInputCombobox {
539
529
  this.classCollection = new ClassList(this.classCollection.classes);
540
530
  }
541
531
  watchFetchUrl(newValue) {
542
- if (newValue && !URL.canParse(newValue)) {
543
- throw new Error(`<mg-input-combobox> prop "fetchurl" value must be URL or string. Passed value: ${toString(newValue)}.`);
532
+ if (Boolean(newValue)) {
533
+ this.loadingWrapper({ name: 'load-data' });
544
534
  }
545
535
  }
546
536
  watchFetchOptions(newValue) {
@@ -652,8 +642,11 @@ export class MgInputCombobox {
652
642
  if (!isItem(newValue)) {
653
643
  this.value = '';
654
644
  }
645
+ else if (allItemsAreString(this.items || this.options.items)) {
646
+ this.value = newValue.title;
647
+ }
655
648
  else {
656
- this.value = allItemsAreString(this.items || this.options.items) ? newValue.title : Object.assign({}, newValue);
649
+ this.value = Object.assign({}, newValue);
657
650
  }
658
651
  }
659
652
  /**
@@ -682,7 +675,6 @@ export class MgInputCombobox {
682
675
  this.watchIdentifier(this.identifier);
683
676
  this.watchItems(this.items);
684
677
  if (Boolean(this.fetchurl)) {
685
- this.watchFetchUrl(this.fetchurl);
686
678
  this.watchFetchOptions(this.fetchoptions);
687
679
  this.watchFetchMappings(this.fetchmappings);
688
680
  this.loadingWrapper({ name: 'load-data' });
@@ -715,22 +707,32 @@ export class MgInputCombobox {
715
707
  popoverContent = 'notfound';
716
708
  else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0)
717
709
  popoverContent = 'notavailable';
718
- return (h("mg-input", { key: 'b8c4c6d18bb1d16ff0a8494ddb698cb4e0198e43', label: this.label, identifier: this.identifier, class: this.classCollection.classes.join(' '), ariaDescribedbyIDs: popoverContent && popoverContent !== 'list' ? [popoverContent] : [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("mg-popover", { identifier: this.popoverId, placement: "bottom-start", display: this.popoverDisplay, "arrow-hide": true, style: {
719
- '--mg-c-input-list-width': Boolean((_d = this.input) === null || _d === void 0 ? void 0 : _d.offsetWidth) ? `${this.input.offsetWidth}px` : undefined,
720
- '--mg-c-input-append-x': withResetButton ? '2' : '1',
721
- }, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, h("div", { class: "mg-c-input__input-group-container" }, h("mg-icon", { icon: "magnifying-glass" }), h("input", { type: "text", role: "combobox", class: "mg-c-input__box mg-c-input__box--width", value: this.filter, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-autocomplete": "list", "aria-expanded": this.popoverDisplay.toString(), "aria-controls": listId, "aria-invalid": (this.invalid === true).toString(), "aria-activedescendant": Boolean((_e = this.option) === null || _e === void 0 ? void 0 : _e.value) ? this.option.value : typeof this.value === 'string' ? this.value : (_f = this.value) === null || _f === void 0 ? void 0 : _f.value, onInput: this.handleFilterInput, onBlur: this.handleFilterBlur, onFocus: this.handleFilterFocus, onKeyDown: this.handleFilterKeydown, ref: (el) => {
710
+ let activeDescendant;
711
+ if (Boolean((_d = this.option) === null || _d === void 0 ? void 0 : _d.value)) {
712
+ activeDescendant = this.option.value;
713
+ }
714
+ else if (typeof this.value === 'string') {
715
+ activeDescendant = this.value;
716
+ }
717
+ else {
718
+ activeDescendant = (_e = this.value) === null || _e === void 0 ? void 0 : _e.value;
719
+ }
720
+ return (h("mg-input", { key: '9247630e9b86d6ca8e9e57089454551cf31f5531', label: this.label, identifier: this.identifier, class: this.classCollection.classes.join(' '), ariaDescribedbyIDs: popoverContent && popoverContent !== 'list' ? [popoverContent] : [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("mg-popover", { identifier: this.popoverId, placement: "bottom-start", display: this.popoverDisplay, "arrow-hide": true, style: {
721
+ '--mg-c-input-list-width': Boolean((_f = this.input) === null || _f === void 0 ? void 0 : _f.offsetWidth) ? `${this.input.offsetWidth}px` : undefined,
722
+ }, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, h("div", { class: "mg-c-input__input-group-container" }, h("mg-icon", { icon: "magnifying-glass" }), h("input", { type: "text", role: "combobox", class: "mg-c-input__box mg-c-input__box--width", value: this.filter, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-autocomplete": "list", "aria-expanded": this.popoverDisplay.toString(), "aria-controls": listId, "aria-invalid": (this.invalid === true).toString(), "aria-activedescendant": formatID(activeDescendant), onInput: this.handleFilterInput, onBlur: this.handleFilterBlur, onFocus: this.handleFilterFocus, onKeyDown: this.handleFilterKeydown, ref: (el) => {
722
723
  if (el !== null)
723
724
  this.input = el;
724
- } }), withResetButton && (h("mg-button", { class: "mg-c-input__box-append mg-c-input__reset", variant: "flat", "is-icon": true, label: this.messages.general.reset, "aria-controls": this.identifier, tabindex: "-1", onClick: this.handleResetButton }, h("mg-icon", { icon: "cross" }))), h("mg-button", { class: "mg-c-input__box-append", variant: "flat", "is-icon": true, label: this.itemsLabel, tabindex: "-1", disabled: this.disabled }, h("mg-icon", { icon: `chevron-${this.popoverDisplay ? 'up' : 'down'}` }))), h("div", { slot: "content", class: "mg-c-input__popover-container" }, popoverContent === 'list' && [
725
+ } }), withResetButton ? (h("mg-button", { class: "mg-c-input__box-append mg-c-input__reset", variant: "flat", "is-icon": true, label: this.messages.general.reset, "aria-controls": this.identifier, tabindex: "-1", onClick: this.handleResetButton }, h("mg-icon", { icon: "cross" }))) : (h("mg-button", { class: "mg-c-input__box-append", variant: "flat", "is-icon": true, label: this.itemsLabel, tabindex: "-1", disabled: this.disabled }, h("mg-icon", { icon: `chevron-${this.popoverDisplay ? 'up' : 'down'}` })))), h("div", { slot: "content", class: "mg-c-input__popover-container" }, popoverContent === 'list' && [
725
726
  // eslint-disable-next-line jsx-a11y/role-supports-aria-props
726
727
  h("ul", { key: "list", class: "mg-c-input__input-list", role: "listbox", id: listId, "aria-label": this.itemsLabel, "aria-setsize": this.page.total }, this.page.items.map(option => {
728
+ var _a;
727
729
  return (
728
730
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events
729
731
  h("li", { role: "option", class: {
730
732
  'mg-c-input__input-list-item': true,
731
- 'mg-c-input__input-list-item--focus-visible': this.option === option,
733
+ 'mg-c-input__input-list-item--focus-visible': JSON.stringify((_a = this.option) === null || _a === void 0 ? void 0 : _a.value) === JSON.stringify(option.value),
732
734
  'mg-c-input__input-list-item--selected': this.isCurrentOption(option),
733
- }, key: option.title, id: option.value.toString(), "aria-selected": this.isCurrentOption(option).toString(), onClick: this.handleOptionClick }, option.title, this.isCurrentOption(option) && h("mg-icon", { icon: "check" })));
735
+ }, key: option.title, id: formatID(option.value), "aria-selected": this.isCurrentOption(option).toString(), onClick: this.handleOptionClick }, option.title, this.isCurrentOption(option) && h("mg-icon", { icon: "check" })));
734
736
  })),
735
737
  this.isLoading && h("mg-loader", { key: "loader", message: this.messages.input.combobox.search, class: { 'mg-u-visually-hidden': Boolean(this.page.next) } }),
736
738
  this.page.next && (h("mg-button", { key: "load-more", variant: "flat", class: "mg-c-input__load-more", tabIndex: -1, disabled: this.isLoading, "full-width": true, "disable-on-click": true, onClick: this.handleLoadMoreButton, "aria-controls": listId, ref: (el) => {
@@ -1298,6 +1300,26 @@ export class MgInputCombobox {
1298
1300
  }
1299
1301
  }
1300
1302
  }
1303
+ }, {
1304
+ "method": "fetchError",
1305
+ "name": "fetch-error",
1306
+ "bubbles": true,
1307
+ "cancelable": true,
1308
+ "composed": true,
1309
+ "docs": {
1310
+ "tags": [],
1311
+ "text": "Emited event when fetch API throw an error"
1312
+ },
1313
+ "complexType": {
1314
+ "original": "Error",
1315
+ "resolved": "Error",
1316
+ "references": {
1317
+ "Error": {
1318
+ "location": "global",
1319
+ "id": "global::Error"
1320
+ }
1321
+ }
1322
+ }
1301
1323
  }];
1302
1324
  }
1303
1325
  static get methods() {