@mgdis/mg-components 6.3.0 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/dist/cjs/{index-a5b2cd1b.js → index-1a5a1081.js} +331 -162
  2. package/dist/cjs/index-1a5a1081.js.map +1 -0
  3. package/dist/cjs/{index-cc11af95.js → index-ede3b3dc.js} +3 -3
  4. package/dist/cjs/{index-cc11af95.js.map → index-ede3b3dc.js.map} +1 -1
  5. package/dist/cjs/{index.es-ac7c22e3.js → index.es-a112f649.js} +40 -40
  6. package/dist/cjs/index.es-a112f649.js.map +1 -0
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/cjs/mg-action-more_36.cjs.entry.js +3411 -2633
  9. package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
  10. package/dist/cjs/mg-alert.cjs.entry.js +15 -12
  11. package/dist/cjs/mg-alert.cjs.entry.js.map +1 -1
  12. package/dist/cjs/mg-components.cjs.js +3 -3
  13. package/dist/cjs/mg-components.cjs.js.map +1 -1
  14. package/dist/cjs/mg-loader.cjs.entry.js +5 -7
  15. package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
  16. package/dist/cjs/mg-progress.cjs.entry.js +26 -11
  17. package/dist/cjs/mg-progress.cjs.entry.js.map +1 -1
  18. package/dist/collection/collection-manifest.json +2 -2
  19. package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js +10 -3
  20. package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js.map +1 -1
  21. package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js +15 -4
  22. package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js.map +1 -1
  23. package/dist/collection/components/atoms/mg-badge/mg-badge.js +15 -4
  24. package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
  25. package/dist/collection/components/atoms/mg-button/mg-button.js +50 -11
  26. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  27. package/dist/collection/components/atoms/mg-card/mg-card.js +1 -1
  28. package/dist/collection/components/atoms/mg-divider/mg-divider.js +9 -1
  29. package/dist/collection/components/atoms/mg-divider/mg-divider.js.map +1 -1
  30. package/dist/collection/components/atoms/mg-icon/mg-icon.js +22 -6
  31. package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
  32. package/dist/collection/components/atoms/mg-tag/mg-tag.js +14 -4
  33. package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
  34. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +3 -4
  35. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js.map +1 -1
  36. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +1 -0
  37. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -1
  38. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +95 -43
  39. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
  40. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +50 -13
  41. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js.map +1 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +29 -11
  43. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
  44. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +106 -33
  45. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
  46. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +99 -36
  47. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
  48. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +130 -35
  49. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
  50. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +87 -25
  51. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
  52. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +86 -26
  53. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
  54. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +92 -30
  55. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
  56. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +108 -31
  57. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
  58. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +109 -29
  59. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
  60. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +67 -21
  61. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
  62. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +16 -70
  63. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js.map +1 -1
  64. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +101 -89
  65. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
  66. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +202 -157
  67. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
  68. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +19 -8
  69. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
  70. package/dist/collection/components/molecules/mg-alert/mg-alert.js +15 -6
  71. package/dist/collection/components/molecules/mg-alert/mg-alert.js.map +1 -1
  72. package/dist/collection/components/molecules/mg-details/mg-details.js +22 -5
  73. package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
  74. package/dist/collection/components/molecules/mg-form/mg-form.js +48 -16
  75. package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
  76. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +13 -3
  77. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -1
  78. package/dist/collection/components/molecules/mg-loader/mg-loader.js +5 -5
  79. package/dist/collection/components/molecules/mg-loader/mg-loader.js.map +1 -1
  80. package/dist/collection/components/molecules/mg-message/mg-message.js +22 -6
  81. package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
  82. package/dist/collection/components/molecules/mg-modal/mg-modal.js +37 -9
  83. package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
  84. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +28 -9
  85. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
  86. package/dist/collection/components/molecules/mg-panel/mg-panel.js +48 -13
  87. package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
  88. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +10 -2
  89. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -1
  90. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +2 -0
  91. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js.map +1 -0
  92. package/dist/collection/components/molecules/mg-popover/mg-popover.js +133 -52
  93. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  94. package/dist/collection/components/molecules/mg-progress/mg-progress.js +26 -1
  95. package/dist/collection/components/molecules/mg-progress/mg-progress.js.map +1 -1
  96. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +3 -2
  97. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -1
  98. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +28 -8
  99. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
  100. package/dist/collection/utils/behaviors.utils.js +44 -107
  101. package/dist/collection/utils/behaviors.utils.js.map +1 -1
  102. package/dist/collection/utils/floating-ui.utils.js +33 -0
  103. package/dist/collection/utils/floating-ui.utils.js.map +1 -0
  104. package/dist/components/floating-ui.utils.js +2099 -0
  105. package/dist/components/floating-ui.utils.js.map +1 -0
  106. package/dist/components/index.es.js +37 -37
  107. package/dist/components/index.es.js.map +1 -1
  108. package/dist/components/index2.js +2 -2
  109. package/dist/components/mg-action-more.js +15 -12
  110. package/dist/components/mg-action-more.js.map +1 -1
  111. package/dist/components/mg-alert.js +13 -10
  112. package/dist/components/mg-alert.js.map +1 -1
  113. package/dist/components/mg-badge2.js +12 -9
  114. package/dist/components/mg-badge2.js.map +1 -1
  115. package/dist/components/mg-button2.js +36 -15
  116. package/dist/components/mg-button2.js.map +1 -1
  117. package/dist/components/mg-card2.js +2 -2
  118. package/dist/components/mg-card2.js.map +1 -1
  119. package/dist/components/mg-character-left2.js +8 -7
  120. package/dist/components/mg-character-left2.js.map +1 -1
  121. package/dist/components/mg-details.js +14 -5
  122. package/dist/components/mg-details.js.map +1 -1
  123. package/dist/components/mg-divider2.js +7 -1
  124. package/dist/components/mg-divider2.js.map +1 -1
  125. package/dist/components/mg-form.js +35 -21
  126. package/dist/components/mg-form.js.map +1 -1
  127. package/dist/components/mg-icon2.js +17 -11
  128. package/dist/components/mg-icon2.js.map +1 -1
  129. package/dist/components/mg-illustrated-message.js +12 -6
  130. package/dist/components/mg-illustrated-message.js.map +1 -1
  131. package/dist/components/mg-input-checkbox-paginated2.js +14 -10
  132. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
  133. package/dist/components/mg-input-checkbox.js +69 -36
  134. package/dist/components/mg-input-checkbox.js.map +1 -1
  135. package/dist/components/mg-input-date.js +75 -44
  136. package/dist/components/mg-input-date.js.map +1 -1
  137. package/dist/components/mg-input-numeric.js +88 -43
  138. package/dist/components/mg-input-numeric.js.map +1 -1
  139. package/dist/components/mg-input-password.js +54 -26
  140. package/dist/components/mg-input-password.js.map +1 -1
  141. package/dist/components/mg-input-radio.js +58 -30
  142. package/dist/components/mg-input-radio.js.map +1 -1
  143. package/dist/components/mg-input-select2.js +58 -34
  144. package/dist/components/mg-input-select2.js.map +1 -1
  145. package/dist/components/mg-input-text2.js +67 -36
  146. package/dist/components/mg-input-text2.js.map +1 -1
  147. package/dist/components/mg-input-textarea.js +69 -33
  148. package/dist/components/mg-input-textarea.js.map +1 -1
  149. package/dist/components/mg-input-title2.js +10 -7
  150. package/dist/components/mg-input-title2.js.map +1 -1
  151. package/dist/components/mg-input-toggle.js +42 -24
  152. package/dist/components/mg-input-toggle.js.map +1 -1
  153. package/dist/components/mg-input2.js +35 -18
  154. package/dist/components/mg-input2.js.map +1 -1
  155. package/dist/components/mg-item-more2.js +146 -270
  156. package/dist/components/mg-item-more2.js.map +1 -1
  157. package/dist/components/mg-loader.js +3 -5
  158. package/dist/components/mg-loader.js.map +1 -1
  159. package/dist/components/mg-menu-item2.js +200 -148
  160. package/dist/components/mg-menu-item2.js.map +1 -1
  161. package/dist/components/mg-message2.js +22 -10
  162. package/dist/components/mg-message2.js.map +1 -1
  163. package/dist/components/mg-modal.js +33 -15
  164. package/dist/components/mg-modal.js.map +1 -1
  165. package/dist/components/mg-pagination2.js +21 -14
  166. package/dist/components/mg-pagination2.js.map +1 -1
  167. package/dist/components/mg-panel.js +37 -20
  168. package/dist/components/mg-panel.js.map +1 -1
  169. package/dist/components/mg-popover-content2.js +11 -5
  170. package/dist/components/mg-popover-content2.js.map +1 -1
  171. package/dist/components/mg-popover2.js +119 -52
  172. package/dist/components/mg-popover2.js.map +1 -1
  173. package/dist/components/mg-progress.js +25 -10
  174. package/dist/components/mg-progress.js.map +1 -1
  175. package/dist/components/mg-skip-links.js +0 -1
  176. package/dist/components/mg-skip-links.js.map +1 -1
  177. package/dist/components/mg-tabs.js +26 -16
  178. package/dist/components/mg-tabs.js.map +1 -1
  179. package/dist/components/mg-tag.js +11 -7
  180. package/dist/components/mg-tag.js.map +1 -1
  181. package/dist/components/mg-tooltip-content2.js +2 -3
  182. package/dist/components/mg-tooltip-content2.js.map +1 -1
  183. package/dist/components/mg-tooltip2.js +86 -45
  184. package/dist/components/mg-tooltip2.js.map +1 -1
  185. package/dist/esm/{index-eb0e1053.js → index-5059254f.js} +331 -162
  186. package/dist/esm/index-5059254f.js.map +1 -0
  187. package/dist/esm/{index-f3d3fb70.js → index-a7c3b5c5.js} +3 -3
  188. package/dist/esm/{index-f3d3fb70.js.map → index-a7c3b5c5.js.map} +1 -1
  189. package/dist/esm/{index.es-940821a9.js → index.es-5e0101ac.js} +38 -38
  190. package/dist/esm/index.es-5e0101ac.js.map +1 -0
  191. package/dist/esm/loader.js +3 -3
  192. package/dist/esm/mg-action-more_36.entry.js +3411 -2633
  193. package/dist/esm/mg-action-more_36.entry.js.map +1 -1
  194. package/dist/esm/mg-alert.entry.js +15 -12
  195. package/dist/esm/mg-alert.entry.js.map +1 -1
  196. package/dist/esm/mg-components.js +4 -4
  197. package/dist/esm/mg-components.js.map +1 -1
  198. package/dist/esm/mg-loader.entry.js +5 -7
  199. package/dist/esm/mg-loader.entry.js.map +1 -1
  200. package/dist/esm/mg-progress.entry.js +26 -11
  201. package/dist/esm/mg-progress.entry.js.map +1 -1
  202. package/dist/mg-components/mg-components.esm.js +1 -1
  203. package/dist/mg-components/mg-components.esm.js.map +1 -1
  204. package/dist/mg-components/p-1a162791.entry.js +2 -0
  205. package/dist/mg-components/{p-d0086664.entry.js.map → p-1a162791.entry.js.map} +1 -1
  206. package/dist/mg-components/p-2403e01d.entry.js +2 -0
  207. package/dist/mg-components/p-2403e01d.entry.js.map +1 -0
  208. package/dist/mg-components/p-6c831a83.entry.js +2 -0
  209. package/dist/mg-components/p-6c831a83.entry.js.map +1 -0
  210. package/dist/mg-components/p-ad64ab4a.entry.js +2 -0
  211. package/dist/mg-components/p-ad64ab4a.entry.js.map +1 -0
  212. package/dist/mg-components/{p-ee51ec5e.js → p-b6c1a6ce.js} +2 -2
  213. package/dist/mg-components/p-b6c1a6ce.js.map +1 -0
  214. package/dist/mg-components/{p-a49e2b74.js → p-d9731ebc.js} +2 -2
  215. package/dist/mg-components/p-e39791fa.js +3 -0
  216. package/dist/mg-components/p-e39791fa.js.map +1 -0
  217. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +6 -0
  218. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +7 -6
  219. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +6 -0
  220. package/dist/types/components/molecules/internals/mg-item-more/mg-item-more.d.ts +1 -15
  221. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +14 -30
  222. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +54 -39
  223. package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
  224. package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +6 -0
  225. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +13 -8
  226. package/dist/types/components.d.ts +8 -11
  227. package/dist/types/utils/behaviors.utils.d.ts +15 -44
  228. package/dist/types/utils/floating-ui.utils.d.ts +19 -0
  229. package/ide/intellij/web-types.json +3 -7
  230. package/ide/vscode/html-custom-data.json +2 -2
  231. package/package.json +24 -24
  232. package/dist/cjs/index-a5b2cd1b.js.map +0 -1
  233. package/dist/cjs/index.es-ac7c22e3.js.map +0 -1
  234. package/dist/components/popper.js +0 -1794
  235. package/dist/components/popper.js.map +0 -1
  236. package/dist/esm/index-eb0e1053.js.map +0 -1
  237. package/dist/esm/index.es-940821a9.js.map +0 -1
  238. package/dist/mg-components/p-15b6849a.js +0 -3
  239. package/dist/mg-components/p-15b6849a.js.map +0 -1
  240. package/dist/mg-components/p-3aecf564.entry.js +0 -2
  241. package/dist/mg-components/p-3aecf564.entry.js.map +0 -1
  242. package/dist/mg-components/p-6f3d70b2.entry.js +0 -2
  243. package/dist/mg-components/p-6f3d70b2.entry.js.map +0 -1
  244. package/dist/mg-components/p-a17ea0af.entry.js +0 -2
  245. package/dist/mg-components/p-a17ea0af.entry.js.map +0 -1
  246. package/dist/mg-components/p-d0086664.entry.js +0 -2
  247. package/dist/mg-components/p-ee51ec5e.js.map +0 -1
  248. /package/dist/mg-components/{p-a49e2b74.js.map → p-d9731ebc.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
- import { m as me, q as qe, X as Xe, G as Ge, Y as Ye, t as tt } from './index.es.js';
2
+ import { G as Ge, K as Ke, m as me, X as Xe, V as Ve, s as st } from './index.es.js';
3
3
  import { i as initLocales } from './index2.js';
4
4
  import { d as defineCustomElement$6 } from './mg-badge2.js';
5
5
  import { d as defineCustomElement$5 } from './mg-button2.js';
@@ -42,7 +42,6 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
42
42
  super();
43
43
  this.__registerHost();
44
44
  this.__attachShadow();
45
- this.statusChange = createEvent(this, "status-change", 7);
46
45
  this.itemLoaded = createEvent(this, "item-loaded", 7);
47
46
  this.itemUpdated = createEvent(this, "item-updated", 7);
48
47
  /************
@@ -50,15 +49,44 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
50
49
  ************/
51
50
  this.name = 'mg-menu-item';
52
51
  this.navigationButton = 'mg-c-menu-item__navigation-button';
52
+ /************
53
+ * Props *
54
+ ************/
55
+ /**
56
+ * Identifier is used to control mg-popover
57
+ */
58
+ this.identifier = Ge('mg-menu-item');
59
+ /**
60
+ * Define menu-item status.
61
+ */
62
+ this.status = Status.VISIBLE;
63
+ /**
64
+ * Define menu-item content expanded.
65
+ */
66
+ this.expanded = false;
67
+ /**********
68
+ * States *
69
+ *********/
70
+ /**
71
+ * Define menu-item size.
72
+ */
73
+ this.size = 'medium';
74
+ /**
75
+ * Component button classes
76
+ */
77
+ this.navigationButtonClassList = new Ke([this.navigationButton]);
78
+ /**
79
+ * Does component have children.
80
+ */
81
+ this.hasChildren = false;
53
82
  /***********
54
83
  * Methods *
55
84
  **********/
56
85
  /**
57
- * Toggle expanded prop value
86
+ * Get parent menu
87
+ * @returns parent menu
58
88
  */
59
- this.toggleExpanded = () => {
60
- this.expanded = !this.expanded;
61
- };
89
+ this.getParentMenu = () => this.element.closest('mg-menu');
62
90
  /**
63
91
  * Does an Element have given Status
64
92
  * @param mgMenuItemElement - to parse
@@ -66,6 +94,24 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
66
94
  * @returns true if element with status is found
67
95
  */
68
96
  this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
97
+ /**
98
+ * Condition to know if component should display a mg-popover
99
+ * @returns truthy if component display popover
100
+ */
101
+ this.hasPopover = () => this.isDirection(Direction.HORIZONTAL) && (this.isInMainMenu() && Array.from(this.element.children).some(element => !element.querySelector('[slot]')) || this.isItemMore) && this.href === undefined;
102
+ /**
103
+ * Method to control if one of component children have active status
104
+ * @returns truthy if component has active child
105
+ */
106
+ this.hasActiveChild = () => {
107
+ var _a;
108
+ return Array.from(((_a = this.element.querySelector('mg-menu')) === null || _a === void 0 ? void 0 : _a.children) || []).some((element) => element.nodeName === 'MG-MENU-ITEM' && this.hasStatus(element, Status.ACTIVE) && !element.hasAttribute('hidden'));
109
+ };
110
+ /**
111
+ * Is component an interactive item
112
+ * @returns truthy if element is clickable
113
+ */
114
+ this.isInteractiveItem = () => this.hasChildren || !me(this.href);
69
115
  /**
70
116
  * Is component contextual direction match the given direction
71
117
  * @param direction - in parent menu
@@ -73,6 +119,11 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
73
119
  * @returns true is direction match the direction propertie
74
120
  */
75
121
  this.isDirection = (direction, compareWith = this.direction) => direction === compareWith;
122
+ /**
123
+ * Does component is in main menu
124
+ * @returns true if component is in main menu
125
+ */
126
+ this.isInMainMenu = () => this.getParentMenu() !== null && this.element.parentElement.closest('mg-menu-item') === null;
76
127
  /**
77
128
  * Update displayNotificationBadge
78
129
  * current component notification badge have priority over the slot badge when submenu contain badge
@@ -83,22 +134,34 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
83
134
  childMenu !== null && Array.from(childMenu.children).some((subItem) => subItem.querySelector('mg-badge') !== null && !subItem.hasAttribute('hidden'));
84
135
  };
85
136
  /**
86
- * Method to control if one of component children have active status
87
- * @returns truthy if component has active child
137
+ * Update expanded prop
138
+ * @param newValue - expanded new value
88
139
  */
89
- this.hasActiveChild = () => {
90
- var _a;
91
- return Array.from(((_a = this.element.querySelector('mg-menu')) === null || _a === void 0 ? void 0 : _a.children) || []).some((element) => element.nodeName === 'MG-MENU-ITEM' && this.hasStatus(element, Status.ACTIVE) && !element.hasAttribute('hidden'));
140
+ this.updateExpanded = (newValue) => {
141
+ if (this.isInteractiveItem()) {
142
+ // item is always expanded in vertical menu when has active child
143
+ this.expanded = this.isDirection(Direction.VERTICAL) && this.hasActiveChild() || newValue;
144
+ }
145
+ };
146
+ /**
147
+ * Update status
148
+ * @param guard - status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
149
+ */
150
+ this.updateStatus = (guard = []) => {
151
+ if (![Status.HIDDEN, Status.DISABLED, ...guard].includes(this.status)) {
152
+ this.status = this.hasActiveChild() ? Status.ACTIVE : Status.VISIBLE;
153
+ }
92
154
  };
93
155
  /**
94
- * Validate slots
156
+ * Update slots
95
157
  * @param guard - prevent action with guard. Default: false.
96
158
  */
97
- this.validateSlot = (guard = false) => {
159
+ this.updateSlot = (guard = false) => {
98
160
  // slot title AND metadata validation
99
161
  // add title on label AND metada slots due to text-overflow on these element
100
- if (Array.from(this.element.children).find(child => child.getAttribute('slot') === 'label') === undefined)
162
+ if (Array.from(this.element.children).find(child => child.getAttribute('slot') === 'label') === undefined) {
101
163
  throw new Error(`<${this.name}> slot "label" is required.`);
164
+ }
102
165
  ['label', 'metadata'].forEach(slot => {
103
166
  Array.from(this.element.querySelectorAll(`[slot="${slot}"]`)).forEach(element => {
104
167
  if (!me(element.textContent))
@@ -109,39 +172,22 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
109
172
  });
110
173
  };
111
174
  /**
112
- * Update status
113
- * @param guard - status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
175
+ * Update menu item
176
+ * @param guard - prevent action with guard
114
177
  */
115
- this.updateStatus = (guard = []) => {
116
- if (![Status.HIDDEN, Status.DISABLED, ...guard].includes(this.status)) {
117
- this.status = this.hasActiveChild() ? Status.ACTIVE : Status.VISIBLE;
118
- }
119
- };
120
- /**
121
- * Init event-listeners
122
- */
123
- this.initListeners = () => {
124
- var _a;
125
- // manage first sub-level menu-items
126
- Array.from(((_a = this.element.querySelector('mg-menu')) === null || _a === void 0 ? void 0 : _a.children) || []).forEach(item => {
127
- if (item.nodeName === 'MG-MENU-ITEM') {
128
- // manage child menu listener
129
- item.addEventListener('status-change', () => {
130
- this.updateStatus();
131
- });
132
- }
133
- });
178
+ this.updateItem = (guard) => {
179
+ const menu = this.getParentMenu();
180
+ // define element size
181
+ if ((menu === null || menu === void 0 ? void 0 : menu.size) !== undefined && !this.isItemMore)
182
+ this.size = menu.size;
183
+ else if (this.isItemMore)
184
+ this.size = this.element.dataset.size;
185
+ // when vertical main menu item contain an active item we force expanded
186
+ this.updateExpanded(this.expanded);
187
+ this.updateStatus(guard);
188
+ this.updatePopoverGuard();
189
+ this.updateDisplayNotificationBadge();
134
190
  };
135
- /**
136
- * Get mg-popover identifier
137
- * @returns generated mg-popover identifier
138
- */
139
- this.getPopoverIdentifier = () => `${this.identifier}-popover`;
140
- /**
141
- * Condition to know if component should display a mg-popover
142
- * @returns truthy if component display popover
143
- */
144
- this.displayPopover = () => this.isDirection(Direction.HORIZONTAL) && this.hasChildren && this.href === undefined;
145
191
  /************
146
192
  * Handlers *
147
193
  ************/
@@ -150,106 +196,123 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
150
196
  * @param event - click on element
151
197
  */
152
198
  this.handleElementCLick = (event) => {
153
- if ((this.hasChildren && !this.isInMainMenu) || this.status === Status.DISABLED) {
199
+ if (this.status === Status.DISABLED) {
154
200
  event.preventDefault();
155
201
  event.stopPropagation();
156
202
  }
157
- // toggle expanded when mg-menu-item has child items
158
- if (this.hasChildren)
159
- this.toggleExpanded();
203
+ // for non "poperized" menu-item we toggle expanded manualy
204
+ this.updateExpanded(!this.expanded);
205
+ // when item is the last clickable item we close the parent popover
206
+ if (!this.isInteractiveItem()) {
207
+ const closePopover = (element) => {
208
+ if (!element)
209
+ return;
210
+ else if (element !== this.element && element.expanded && element.shadowRoot.querySelector('mg-popover') !== null) {
211
+ element.expanded = false;
212
+ }
213
+ else {
214
+ closePopover(element.parentElement.closest('mg-menu-item'));
215
+ }
216
+ };
217
+ closePopover(this.element);
218
+ }
160
219
  };
161
220
  /**
162
221
  * Handle popover element display-change event
163
222
  * @param event - popover display event
164
223
  */
165
224
  this.handlePopoverDisplay = (event) => {
166
- this.expanded = event.detail;
225
+ this.updateExpanded(event.detail);
167
226
  };
168
227
  /**
169
228
  * Render slot
170
229
  * @returns HTML Element
171
230
  */
172
231
  this.renderSlot = () => h("slot", null);
173
- this.identifier = qe('mg-menu-item');
174
- this.href = undefined;
175
- this.target = undefined;
176
- this.status = Status.VISIBLE;
177
- this.expanded = false;
178
- this.size = 'medium';
179
- this.navigationButtonClassList = new Xe([this.navigationButton]);
180
- this.direction = undefined;
181
- this.isInMainMenu = undefined;
182
- this.isItemMore = undefined;
183
- this.hasChildren = false;
184
- this.displayNotificationBadge = undefined;
185
232
  }
186
233
  watchIdentifier(newValue) {
187
- if (!Ge(newValue)) {
188
- console.error(`<mg-menu-item> prop "identifier" value is invalid. Passed value: ${Ye(newValue)}.`);
234
+ if (!Xe(newValue)) {
235
+ console.error(`<mg-menu-item> prop "identifier" value is invalid. Passed value: ${Ve(newValue)}.`);
236
+ }
237
+ else {
238
+ this.popoverIdentifier = `${this.identifier}-popover`;
189
239
  }
190
240
  }
191
241
  watchTarget(newValue) {
192
242
  if (newValue && !targets.includes(newValue)) {
193
- throw new Error(`<mg-link> prop "target" must be one of: ${targets.join(', ')}. Passed value: ${Ye(newValue)}.`);
243
+ throw new Error(`<mg-link> prop "target" must be one of: ${targets.join(', ')}. Passed value: ${Ve(newValue)}.`);
194
244
  }
195
245
  }
196
- validateStatus(newValue, oldValue) {
197
- if (oldValue !== undefined) {
246
+ watchStatus(newValue, oldValue) {
247
+ if (oldValue !== undefined)
198
248
  this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
199
- }
200
249
  this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
201
- this.statusChange.emit(newValue);
202
250
  }
203
- validateExpanded(newValue) {
204
- if (typeof newValue !== 'boolean')
205
- throw new Error(`<${this.name}> prop "expanded" must be a boolean. Passed value: ${Ye(newValue)}.`);
206
- // if menu-item has sub-menu we have to apply some updates:
207
- if (this.hasChildren) {
208
- const subItems = Array.from(this.element.querySelectorAll(this.name));
209
- if (!newValue) {
210
- // - when main menu item is NOT expanded we need NOT expanded sub-items and NOT expanded sub-content
211
- subItems.forEach(item => {
212
- item.expanded = false;
213
- });
214
- }
215
- else if (this.element.querySelector(`${this.name}[status="${Status.ACTIVE}"]`) !== null) {
216
- // - when expanded and contain an active item parents are expended too
217
- subItems.forEach(item => {
218
- if (this.hasStatus(item, Status.ACTIVE)) {
219
- item.expanded = true;
220
- }
221
- });
222
- }
251
+ watchExpanded(newValue) {
252
+ if (typeof newValue !== 'boolean') {
253
+ throw new Error(`<${this.name}> prop "expanded" must be a boolean. Passed value: ${Ve(newValue)}.`);
254
+ }
255
+ else {
256
+ this.updateExpanded(newValue);
257
+ // when expanded all actives sub-items need to be expanded and non active closed
258
+ Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
259
+ if (item !== this.element)
260
+ item.expanded = newValue ? this.hasStatus(item, Status.ACTIVE) : false;
261
+ });
223
262
  }
224
263
  }
225
- validateSize(newValue, oldValue) {
226
- this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
264
+ watchSize(newValue, oldValue) {
265
+ if (oldValue !== undefined)
266
+ this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
227
267
  this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
228
268
  }
229
- validateDirection(newValue) {
230
- // manage menu items style depending to parent menu horientation
231
- this.element.setAttribute('data-style-direction', newValue);
269
+ validateDirection(newValue, oldValue) {
270
+ if (oldValue !== undefined)
271
+ this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
232
272
  this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
233
273
  // manage all sub levels child menu-items level with data-level attribut
234
- if (this.isDirection(Direction.VERTICAL, newValue)) {
235
- Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
274
+ Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
275
+ if (this.isDirection(Direction.VERTICAL, newValue)) {
236
276
  item.dataset.level = `${(Number(item.dataset.level) || 1) + 1}`;
237
- });
238
- }
277
+ }
278
+ else {
279
+ delete item.dataset.level;
280
+ }
281
+ });
239
282
  }
240
283
  validateHasChildren(newValue) {
241
284
  if (newValue && this.element.href !== undefined) {
242
285
  throw new Error(`<${this.name}> prop "href" is unauthorizied when element is a parent.`);
243
286
  }
244
287
  }
288
+ /**
289
+ * direction value in dataset
290
+ * @param newValue - new direction value
291
+ */
292
+ // eslint-disable-next-line @stencil-community/no-unused-watch
293
+ watchDataStyleDirection(newValue) {
294
+ this.direction = newValue;
295
+ }
296
+ /**
297
+ * has focus value in dataset
298
+ * @param newValue - new direction value
299
+ */
300
+ // eslint-disable-next-line @stencil-community/no-unused-watch
301
+ watchDataHasFocus(newValue) {
302
+ if (!newValue)
303
+ this.updateExpanded(Boolean(newValue));
304
+ }
245
305
  /**
246
306
  * Render popover clickoutside guard for content slot
247
307
  */
248
308
  updatePopoverGuard() {
249
- if (this.displayPopover())
250
- Array.from(this.element.children)
251
- .filter((child) => !child.hasAttribute('slot') && child.nodeName !== 'MG-MENU' && Boolean(child.dataset))
252
- .forEach((slot) => (slot.dataset.mgPopoverGuard = this.getPopoverIdentifier()));
309
+ const subItem = this.element.querySelector('*:not([slot])');
310
+ if (!subItem)
311
+ return;
312
+ if (this.hasPopover())
313
+ subItem.dataset.mgPopoverGuard = this.popoverIdentifier;
314
+ else
315
+ delete subItem.dataset.mgPopoverGuard;
253
316
  }
254
317
  /*************
255
318
  * Lifecycle *
@@ -263,13 +326,12 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
263
326
  this.hasChildren = Array.from(this.element.children).some(child => !['image', 'information', 'label', 'metadata'].includes(child.getAttribute('slot')));
264
327
  this.messages = initLocales(this.element).messages.menuItem;
265
328
  this.isItemMore = this.element.dataset.overflowMore !== undefined;
266
- // Validate props
267
- this.validateStatus(this.status);
268
- this.validateExpanded(this.expanded);
329
+ // watchers
330
+ this.watchStatus(this.status);
331
+ this.watchExpanded(this.expanded);
269
332
  this.watchTarget(this.target);
270
333
  this.watchIdentifier(this.identifier);
271
- // Validate states
272
- this.validateSize(this.size);
334
+ this.watchSize(this.size);
273
335
  }
274
336
  /**
275
337
  * Check if component slots configuration
@@ -277,40 +339,36 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
277
339
  */
278
340
  componentDidLoad() {
279
341
  // validation
280
- this.validateSlot(true);
342
+ this.updateSlot(true);
281
343
  // update props and states after componentDidLoad hook
282
344
  // return a promise to process action only in the FIRST render().
283
345
  // https://stenciljs.com/docs/component-lifecycle#componentwillload
284
346
  return setTimeout(() => {
285
- // define menu-item context states
286
- const menu = this.element.closest('mg-menu');
287
- this.direction = this.isItemMore || menu === null ? Direction.HORIZONTAL : menu.direction;
288
- this.isInMainMenu = menu !== null && this.element.parentElement.closest('mg-menu-item') === null;
289
- if ((menu === null || menu === void 0 ? void 0 : menu.size) !== undefined)
290
- this.size = menu.size;
291
- if (this.isItemMore)
292
- this.size = this.element.dataset.size;
293
- // when main menu item contain an active item it will get the active style
294
- // AND if item is in vertical menu it will be expanded
295
- if (this.hasActiveChild() && this.isInMainMenu)
296
- this.expanded = this.isDirection(Direction.VERTICAL);
297
- this.updateStatus([Status.ACTIVE]);
298
- this.updateDisplayNotificationBadge();
299
- this.updatePopoverGuard();
300
- // manage child dom changes with mutationObserver and listners
301
- this.initListeners();
347
+ this.watchDataStyleDirection(this.element.dataset.styleDirection);
348
+ this.watchDataHasFocus(this.element.dataset.hasFocus);
349
+ this.updateItem([Status.ACTIVE]);
302
350
  // emit loaded event when component is fully loaded
303
351
  this.itemLoaded.emit();
304
352
  new MutationObserver(mutationsList => {
305
- if (mutationsList.some(mutation => mutation.attributeName === 'hidden'))
353
+ if (mutationsList.some(mutation => ['hidden', 'status'].includes(mutation.attributeName)))
306
354
  this.updateStatus(this.hasChildren ? undefined : [Status.ACTIVE]);
307
355
  if (mutationsList.some(mutation => mutation.type === 'characterData'))
308
- this.validateSlot();
309
- this.updateDisplayNotificationBadge();
356
+ this.updateSlot();
357
+ if (mutationsList.some(mutation => mutation.type === 'childList'))
358
+ this.updateItem();
310
359
  this.itemUpdated.emit();
311
360
  }).observe(this.element, { attributes: true, childList: true, characterData: true, subtree: true });
312
361
  }, 0);
313
362
  }
363
+ /**
364
+ * Emit event when component is updated
365
+ * @returns promise process wich emit the 'item-updated' event
366
+ */
367
+ componentShouldUpdate() {
368
+ return st(() => {
369
+ this.itemUpdated.emit();
370
+ });
371
+ }
314
372
  /**
315
373
  * Render ineractive element
316
374
  * @returns HTML Element
@@ -325,15 +383,6 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
325
383
  [`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
326
384
  } }, h("mg-icon", { icon: "chevron-down" })))));
327
385
  }
328
- /**
329
- * Emit event when component is updated
330
- * @returns promise process wich emit the 'item-updated' event
331
- */
332
- componentShouldUpdate() {
333
- return tt(() => {
334
- this.itemUpdated.emit();
335
- });
336
- }
337
386
  /**
338
387
  * Render
339
388
  * @returns HTML Element
@@ -341,9 +390,9 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
341
390
  render() {
342
391
  const getContainerClasses = () => ({
343
392
  ['mg-c-menu-item__collapse-container']: true,
344
- ['mg-c-menu-item__collapse-container--first-level']: (this.isInMainMenu || this.isItemMore) && this.isDirection(Direction.HORIZONTAL),
393
+ ['mg-c-menu-item__collapse-container--first-level']: (this.isInMainMenu() || this.isItemMore) && this.isDirection(Direction.HORIZONTAL),
345
394
  });
346
- return (h(Host, { key: '0705617f39133b4da491c150f4984cc57cafe085', role: this.isItemMore ? 'presentation' : 'listitem' }, this.displayPopover() ? (h("mg-popover", { display: this.expanded, placement: "bottom-start", arrowHide: true, "onDisplay-change": this.handlePopoverDisplay, identifier: this.getPopoverIdentifier(), "data-fallback-placement": "bottom-end" // use for the last element of the menu if it is placed on the right side
395
+ return (h(Host, { key: '010958810569e4b777b08d6aebc39be61bb03291', role: this.isItemMore ? 'presentation' : 'listitem' }, this.hasPopover() ? (h("mg-popover", { display: this.expanded, placement: "bottom-start", arrowHide: true, "onDisplay-change": this.handlePopoverDisplay, identifier: this.popoverIdentifier, "data-fallback-placement": "bottom-end" // use for the last element of the menu if it is placed on the right side
347
396
  }, this.renderInteractiveElement(), h("div", { class: getContainerClasses(), slot: "content" }, this.renderSlot()))) : ([
348
397
  this.renderInteractiveElement(),
349
398
  h("div", { key: "vertical-container", class: getContainerClasses(), hidden: !this.expanded }, this.renderSlot()),
@@ -353,11 +402,13 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
353
402
  static get watchers() { return {
354
403
  "identifier": ["watchIdentifier"],
355
404
  "target": ["watchTarget"],
356
- "status": ["validateStatus"],
357
- "expanded": ["validateExpanded"],
358
- "size": ["validateSize"],
405
+ "status": ["watchStatus"],
406
+ "expanded": ["watchExpanded"],
407
+ "size": ["watchSize"],
359
408
  "direction": ["validateDirection"],
360
- "hasChildren": ["validateHasChildren"]
409
+ "hasChildren": ["validateHasChildren"],
410
+ "data-style-direction": ["watchDataStyleDirection"],
411
+ "data-has-focus": ["watchDataHasFocus"]
361
412
  }; }
362
413
  static get style() { return MgMenuItemStyle0; }
363
414
  }, [1, "mg-menu-item", {
@@ -369,18 +420,19 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
369
420
  "size": [32],
370
421
  "navigationButtonClassList": [32],
371
422
  "direction": [32],
372
- "isInMainMenu": [32],
373
423
  "isItemMore": [32],
374
424
  "hasChildren": [32],
375
425
  "displayNotificationBadge": [32]
376
426
  }, undefined, {
377
427
  "identifier": ["watchIdentifier"],
378
428
  "target": ["watchTarget"],
379
- "status": ["validateStatus"],
380
- "expanded": ["validateExpanded"],
381
- "size": ["validateSize"],
429
+ "status": ["watchStatus"],
430
+ "expanded": ["watchExpanded"],
431
+ "size": ["watchSize"],
382
432
  "direction": ["validateDirection"],
383
- "hasChildren": ["validateHasChildren"]
433
+ "hasChildren": ["validateHasChildren"],
434
+ "data-style-direction": ["watchDataStyleDirection"],
435
+ "data-has-focus": ["watchDataHasFocus"]
384
436
  }]);
385
437
  function defineCustomElement() {
386
438
  if (typeof customElements === "undefined") {