@mgdis/mg-components 5.5.0 → 5.7.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 (242) hide show
  1. package/dist/cjs/{index-c3450336.js → index-5e7ede97.js} +120 -4
  2. package/dist/cjs/loader.cjs.js +4 -3
  3. package/dist/cjs/{mg-badge_30.cjs.entry.js → mg-action-more_31.cjs.entry.js} +1223 -547
  4. package/dist/cjs/mg-components.cjs.js +7 -3
  5. package/dist/collection/collection-manifest.json +6 -5
  6. package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
  7. package/dist/collection/components/atoms/mg-badge/mg-badge.css +13 -0
  8. package/dist/collection/components/atoms/mg-badge/mg-badge.js +4 -4
  9. package/dist/collection/components/atoms/mg-button/mg-button.css +9 -22
  10. package/dist/collection/components/atoms/mg-button/mg-button.js +1 -1
  11. package/dist/collection/components/atoms/mg-card/mg-card.css +13 -6
  12. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +38 -28
  13. package/dist/collection/components/atoms/mg-icon/mg-icon.js +3 -3
  14. package/dist/collection/components/atoms/mg-tag/mg-tag.css +6 -6
  15. package/dist/collection/components/atoms/mg-tag/mg-tag.js +4 -4
  16. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +2 -0
  17. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +14 -17
  18. package/dist/collection/components/molecules/inputs/MgInput.js +6 -1
  19. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +4 -3
  20. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +3 -2
  21. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +7 -3
  22. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +5 -2
  23. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +7 -3
  24. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
  25. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +7 -3
  26. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +4 -3
  27. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +2 -1
  28. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +7 -3
  29. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +8 -4
  30. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +7 -3
  31. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +7 -3
  32. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
  33. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +4 -4
  34. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +17 -0
  35. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +27 -0
  36. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +141 -19
  37. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +0 -4
  38. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +48 -21
  39. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +139 -71
  40. package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js +1 -0
  41. package/dist/collection/components/molecules/mg-action-more/mg-action-more.css +38 -0
  42. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +252 -0
  43. package/dist/collection/components/molecules/mg-form/mg-form.js +2 -2
  44. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +4 -3
  45. package/dist/collection/components/molecules/mg-message/mg-message.css +7 -0
  46. package/dist/collection/components/molecules/mg-message/mg-message.js +54 -13
  47. package/dist/collection/components/molecules/mg-modal/mg-modal.css +8 -1
  48. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +19 -1
  49. package/dist/collection/components/molecules/mg-panel/mg-panel.css +7 -0
  50. package/dist/collection/components/molecules/mg-panel/mg-panel.js +2 -2
  51. package/dist/collection/components/molecules/mg-popover/mg-popover.css +72 -15
  52. package/dist/collection/components/molecules/mg-popover/mg-popover.js +64 -7
  53. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +33 -1
  54. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +12 -7
  55. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +105 -57
  56. package/dist/collection/locales/en/messages.json +10 -1
  57. package/dist/collection/locales/fr/messages.json +10 -1
  58. package/dist/collection/locales/index.js +3 -26
  59. package/dist/collection/styles/a11y.scss +32 -0
  60. package/dist/collection/styles/components.scss +3 -0
  61. package/dist/collection/styles/fonts.scss +21 -0
  62. package/dist/collection/styles/form.scss +3 -0
  63. package/dist/collection/styles/global.scss +87 -0
  64. package/dist/collection/styles/layout.scss +29 -0
  65. package/dist/collection/styles/main.scss +23 -0
  66. package/dist/collection/styles/mg-icon-animation.scss +6 -0
  67. package/dist/collection/styles/navigation-button.scss +77 -0
  68. package/dist/collection/styles/reset-mg-card-slotted-variables.scss +9 -0
  69. package/dist/collection/styles/typography.scss +75 -0
  70. package/dist/collection/styles/utilities.scss +21 -0
  71. package/dist/collection/utils/behaviors.utils.js +151 -0
  72. package/dist/collection/utils/components.utils.js +52 -0
  73. package/dist/collection/utils/locale.utils.js +28 -6
  74. package/dist/collection/utils/unit.test.utils.js +65 -32
  75. package/dist/collection/variables.css +11 -10
  76. package/dist/components/MgInput.js +6 -1
  77. package/dist/components/components.utils.js +53 -1
  78. package/dist/components/index.d.ts +10 -0
  79. package/dist/components/index.js +2 -1
  80. package/dist/components/index2.js +79 -20
  81. package/dist/components/mg-action-more.d.ts +11 -0
  82. package/dist/components/mg-action-more.js +215 -0
  83. package/dist/components/mg-badge2.js +5 -5
  84. package/dist/components/mg-button2.js +2 -2
  85. package/dist/components/mg-card2.js +1 -1
  86. package/dist/components/mg-form.js +2 -2
  87. package/dist/components/mg-icon2.js +41 -31
  88. package/dist/components/mg-illustrated-message.js +4 -3
  89. package/dist/components/mg-input-checkbox.js +3 -3
  90. package/dist/components/mg-input-date.js +7 -5
  91. package/dist/components/mg-input-numeric.js +3 -4
  92. package/dist/components/mg-input-password.js +1 -1
  93. package/dist/components/mg-input-radio.js +2 -2
  94. package/dist/components/mg-input-select2.js +9 -5
  95. package/dist/components/mg-input-text2.js +1 -1
  96. package/dist/components/mg-input-textarea.js +2 -2
  97. package/dist/components/mg-input-toggle.js +1 -1
  98. package/dist/components/mg-menu-item.js +1 -253
  99. package/dist/components/mg-menu-item2.js +520 -0
  100. package/dist/components/mg-menu.js +1 -129
  101. package/dist/components/mg-menu2.js +247 -0
  102. package/dist/components/mg-message.js +55 -14
  103. package/dist/components/mg-modal.js +1 -1
  104. package/dist/components/mg-pagination.js +3 -1
  105. package/dist/components/mg-panel.js +3 -3
  106. package/dist/components/mg-popover.js +1 -190
  107. package/dist/components/mg-popover2.js +226 -0
  108. package/dist/components/mg-skip-links.js +16 -2
  109. package/dist/components/mg-tabs.js +104 -55
  110. package/dist/components/mg-tag.js +5 -5
  111. package/dist/components/mg-tooltip2.js +15 -18
  112. package/dist/esm/{index-78edde1d.js → index-03cceb11.js} +120 -5
  113. package/dist/esm/loader.js +4 -3
  114. package/dist/esm/{mg-badge_30.entry.js → mg-action-more_31.entry.js} +1223 -548
  115. package/dist/esm/mg-components.js +4 -3
  116. package/dist/esm/polyfills/css-shim.js +1 -1
  117. package/dist/mg-components/locales/en/messages.json +10 -1
  118. package/dist/mg-components/locales/fr/messages.json +10 -1
  119. package/dist/mg-components/mg-components.css +1 -1
  120. package/dist/mg-components/mg-components.esm.js +1 -1
  121. package/dist/mg-components/p-4cfd5423.entry.js +1 -0
  122. package/dist/mg-components/p-e126dd84.js +2 -0
  123. package/dist/mg-components/styles/a11y.scss +32 -0
  124. package/dist/mg-components/styles/components.scss +3 -0
  125. package/dist/mg-components/styles/fonts.scss +21 -0
  126. package/dist/mg-components/styles/form.scss +3 -0
  127. package/dist/mg-components/styles/global.scss +87 -0
  128. package/dist/mg-components/styles/layout.scss +29 -0
  129. package/dist/mg-components/styles/main.scss +23 -0
  130. package/dist/mg-components/styles/mg-icon-animation.scss +6 -0
  131. package/dist/mg-components/styles/navigation-button.scss +77 -0
  132. package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +9 -0
  133. package/dist/mg-components/styles/typography.scss +75 -0
  134. package/dist/mg-components/styles/utilities.scss +21 -0
  135. package/dist/mg-components/variables.css +11 -10
  136. package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +2 -2
  137. package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +2 -2
  138. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +2 -2
  139. package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +1 -1
  140. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -2
  141. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +2 -2
  142. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
  143. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
  144. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +1 -1
  145. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
  146. package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +37 -0
  147. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +51 -3
  148. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +0 -8
  149. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +61 -15
  150. package/dist/types/components/molecules/mg-action-more/mg-action-more.conf.d.ts +42 -0
  151. package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +81 -0
  152. package/dist/types/components/molecules/mg-message/mg-message.d.ts +21 -4
  153. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +4 -0
  154. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +13 -0
  155. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.conf.d.ts +1 -1
  156. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +15 -0
  157. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +5 -3
  158. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +22 -12
  159. package/dist/types/components.d.ts +98 -12
  160. package/dist/types/locales/index.d.ts +21 -10
  161. package/dist/types/stencil-public-runtime.d.ts +48 -3
  162. package/dist/types/utils/behaviors.utils.d.ts +77 -0
  163. package/dist/types/utils/components.utils.d.ts +14 -0
  164. package/dist/types/utils/locale.utils.d.ts +16 -3
  165. package/dist/types/utils/unit.test.utils.d.ts +68 -14
  166. package/loader/index.d.ts +9 -0
  167. package/package.json +28 -27
  168. package/readme.md +22 -31
  169. package/dist/.storybook/utils.js +0 -24
  170. package/dist/collection/components/atoms/mg-badge/doc/mg-badge.stories.js +0 -27
  171. package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +0 -38
  172. package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +0 -18
  173. package/dist/collection/components/atoms/mg-character-left/doc/mg-character-left.stories.js +0 -20
  174. package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +0 -18
  175. package/dist/collection/components/atoms/mg-icon/doc/mg-icon.stories.js +0 -41
  176. package/dist/collection/components/atoms/mg-input-title/doc/mg-input-title.stories.js +0 -21
  177. package/dist/collection/components/atoms/mg-tag/doc/mg-tag.stories.js +0 -22
  178. package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -50
  179. package/dist/collection/components/molecules/inputs/mg-input-checkbox/doc/mg-input-checkbox.stories.js +0 -50
  180. package/dist/collection/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.js +0 -43
  181. package/dist/collection/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.js +0 -68
  182. package/dist/collection/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.js +0 -46
  183. package/dist/collection/components/molecules/inputs/mg-input-radio/doc/mg-input-radio.stories.js +0 -59
  184. package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +0 -77
  185. package/dist/collection/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.js +0 -110
  186. package/dist/collection/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.js +0 -54
  187. package/dist/collection/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.js +0 -51
  188. package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +0 -87
  189. package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +0 -39
  190. package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +0 -24
  191. package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +0 -47
  192. package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +0 -19
  193. package/dist/collection/components/molecules/mg-message/doc/mg-message.stories.js +0 -39
  194. package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +0 -39
  195. package/dist/collection/components/molecules/mg-pagination/doc/mg-pagination.stories.js +0 -20
  196. package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +0 -22
  197. package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -34
  198. package/dist/collection/components/molecules/mg-skip-links/doc/mg-skip-links.stories.js +0 -24
  199. package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +0 -51
  200. package/dist/collection/stories/grids.stories.js +0 -7
  201. package/dist/collection/stories/helpers.stories.js +0 -23
  202. package/dist/collection/stories/icons.stories.js +0 -25
  203. package/dist/collection/stories/typography.stories.js +0 -24
  204. package/dist/components/locale.utils.js +0 -40
  205. package/dist/components/mg-menu.conf.js +0 -10
  206. package/dist/mg-components/p-125c54ca.js +0 -2
  207. package/dist/mg-components/p-4961c96c.entry.js +0 -1
  208. package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +0 -13
  209. package/dist/types/components/atoms/mg-button/doc/mg-button.stories.d.ts +0 -16
  210. package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +0 -6
  211. package/dist/types/components/atoms/mg-character-left/doc/mg-character-left.stories.d.ts +0 -6
  212. package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +0 -6
  213. package/dist/types/components/atoms/mg-icon/doc/mg-icon.stories.d.ts +0 -26
  214. package/dist/types/components/atoms/mg-input-title/doc/mg-input-title.stories.d.ts +0 -6
  215. package/dist/types/components/atoms/mg-tag/doc/mg-tag.stories.d.ts +0 -6
  216. package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -18
  217. package/dist/types/components/molecules/inputs/mg-input-checkbox/doc/mg-input-checkbox.stories.d.ts +0 -11
  218. package/dist/types/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.d.ts +0 -12
  219. package/dist/types/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.d.ts +0 -32
  220. package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +0 -22
  221. package/dist/types/components/molecules/inputs/mg-input-radio/doc/mg-input-radio.stories.d.ts +0 -20
  222. package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +0 -34
  223. package/dist/types/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.d.ts +0 -39
  224. package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +0 -19
  225. package/dist/types/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.d.ts +0 -12
  226. package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +0 -17
  227. package/dist/types/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.d.ts +0 -12
  228. package/dist/types/components/molecules/mg-details/doc/mg-details.stories.d.ts +0 -11
  229. package/dist/types/components/molecules/mg-form/doc/mg-form.stories.d.ts +0 -11
  230. package/dist/types/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.d.ts +0 -6
  231. package/dist/types/components/molecules/mg-message/doc/mg-message.stories.d.ts +0 -26
  232. package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +0 -13
  233. package/dist/types/components/molecules/mg-pagination/doc/mg-pagination.stories.d.ts +0 -11
  234. package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +0 -11
  235. package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -22
  236. package/dist/types/components/molecules/mg-skip-links/doc/mg-skip-links.stories.d.ts +0 -11
  237. package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +0 -20
  238. package/dist/types/home/runner/work/mg-components/mg-components/.stencil/.storybook/utils.d.ts +0 -1
  239. package/dist/types/stories/grids.stories.d.ts +0 -5
  240. package/dist/types/stories/helpers.stories.d.ts +0 -13
  241. package/dist/types/stories/icons.stories.d.ts +0 -13
  242. package/dist/types/stories/typography.stories.d.ts +0 -5
@@ -0,0 +1,226 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { c as createID, C as ClassList, g as getWindows, i as isTagName } from './components.utils.js';
3
+ import { i as initLocales } from './index2.js';
4
+ import { d as defineCustomElement$3 } from './mg-button2.js';
5
+ import { d as defineCustomElement$2 } from './mg-card2.js';
6
+ import { d as defineCustomElement$1 } from './mg-icon2.js';
7
+ import { c as createPopper } from './popper.js';
8
+
9
+ const mgPopoverCss = ":host{--mg-card-padding:var(--mg-popover-padding-vertical, 1.5rem) var(--mg-popover-padding-horizontal, var(--mg-popover-padding-vertical, 1.5rem));--mg-card-border:none;--mg-card-border-radius:0.5rem;--mg-card-background:hsl(var(--mg-popover-background-color));position:relative;display:contents}:host::slotted(*){display:inline-block}.mg-popover{display:none;padding:1rem;z-index:2000;color:hsl(var(--mg-popover-font-color))}.mg-popover mg-card{position:relative}.mg-popover[data-show]{display:block}.mg-popover mg-button{float:right;margin-right:calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);margin-top:calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);margin-left:3rem}.mg-popover__arrow{position:absolute;visibility:hidden;width:calc(3rem + 2 * var(--mg-card-border-radius) + 2rem);height:calc(3rem + 2 * var(--mg-card-border-radius) + 2rem)}.mg-popover__arrow:before{visibility:visible;content:\"\";position:absolute}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow,.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{height:1rem}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow:before{left:calc(var(--mg-card-border-radius) + 1rem);border-right:calc(3rem / 2) solid transparent;border-left:calc(3rem / 2) solid transparent}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow{bottom:0.1rem;filter:drop-shadow(0 0.5rem 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow:before{border-top:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{top:0.1rem;filter:drop-shadow(0 -0.5rem 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow:before{border-bottom:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{width:1rem}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right]>.mg-popover__arrow:before{top:calc(var(--mg-card-border-radius) + 1rem);border-top:calc(3rem / 2) solid transparent;border-bottom:calc(3rem / 2) solid transparent}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow{right:0.1rem;filter:drop-shadow(0.5rem 0 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow:before{border-left:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{left:0.1rem;filter:drop-shadow(-0.5rem 0 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow:before{border-right:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=left-start],.mg-popover[data-popper-placement^=left-end],.mg-popover[data-popper-placement^=right-start],.mg-popover[data-popper-placement^=right-end]{padding:0 1rem}.mg-popover[data-popper-placement^=left-start]>.mg-popover__arrow,.mg-popover[data-popper-placement^=left-end]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right-start]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right-end]>.mg-popover__arrow{height:calc(3rem + 2 * var(--mg-card-border-radius))}.mg-popover[data-popper-placement^=left-start]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=left-end]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right-start]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right-end]>.mg-popover__arrow:before{top:var(--mg-card-border-radius)}.mg-popover__title ::slotted([slot=title]){margin:0 0 1rem !important;font-size:var(--mg-popover-title-font-size) !important;font-weight:600}.mg-popover--arrow-hide.mg-popover[data-popper-placement^=top]{padding-bottom:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement^=bottom]{padding-top:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement$=end],.mg-popover--arrow-hide.mg-popover[data-popper-placement^=left]{padding-right:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement$=start],.mg-popover--arrow-hide.mg-popover[data-popper-placement^=right]{padding-left:0}.mg-popover ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default)}";
10
+
11
+ const MgPopover = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
12
+ constructor() {
13
+ super();
14
+ this.__registerHost();
15
+ this.__attachShadow();
16
+ this.displayChange = createEvent(this, "display-change", 7);
17
+ this.closeButtonId = '';
18
+ // Classes
19
+ this.classArrowHide = `mg-popover--arrow-hide`;
20
+ /**
21
+ * Check if clicked outside of component
22
+ *
23
+ * @param {MouseEvent} event mouse event
24
+ * @returns {void}
25
+ */
26
+ this.clickOutside = (event) => {
27
+ var _a;
28
+ if (!this.disabled &&
29
+ event.target.closest('mg-popover') !== this.element &&
30
+ !(((_a = event.target.closest(`[data-mg-popover-guard]`)) === null || _a === void 0 ? void 0 : _a.dataset.mgPopoverGuard) === this.identifier)) {
31
+ this.display = false;
32
+ }
33
+ };
34
+ /**
35
+ * Show popover
36
+ *
37
+ * @returns {void}
38
+ */
39
+ this.show = () => {
40
+ // Make the popover visible
41
+ this.popover.dataset.show = '';
42
+ // Enable the event listeners
43
+ this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
44
+ // Update its position
45
+ this.popper.update();
46
+ // hide when click outside
47
+ // setTimeout is used to prevent event to trigger after creation
48
+ setTimeout(() => {
49
+ this.windows.forEach((localWindow) => {
50
+ localWindow.addEventListener('click', this.clickOutside, false);
51
+ });
52
+ }, 0);
53
+ };
54
+ /**
55
+ * Hide popover
56
+ *
57
+ * @returns {void}
58
+ */
59
+ this.hide = () => {
60
+ // Hide the popover
61
+ this.popover.removeAttribute('data-show');
62
+ // Disable the event listeners
63
+ this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
64
+ // Remove event listener
65
+ this.windows.forEach((localWindow) => {
66
+ localWindow.removeEventListener('click', this.clickOutside, false);
67
+ });
68
+ };
69
+ /**
70
+ * Handle action for close button
71
+ *
72
+ * @returns {void}
73
+ */
74
+ this.handleCloseButton = () => {
75
+ this.display = false;
76
+ };
77
+ this.identifier = createID('mg-popover');
78
+ this.placement = 'bottom';
79
+ this.arrowHide = false;
80
+ this.closeButton = false;
81
+ this.display = false;
82
+ this.disabled = false;
83
+ this.classList = new ClassList(['mg-popover']);
84
+ }
85
+ validateArrowHide(newValue) {
86
+ if (newValue)
87
+ this.classList.add(this.classArrowHide);
88
+ else
89
+ this.classList.delete(this.classArrowHide);
90
+ }
91
+ handleDisplay(newValue) {
92
+ if (newValue) {
93
+ this.show();
94
+ }
95
+ else {
96
+ this.hide();
97
+ }
98
+ this.displayChange.emit(newValue);
99
+ }
100
+ /*************
101
+ * Lifecycle *
102
+ *************/
103
+ /**
104
+ * Check if component props are well configured on init
105
+ *
106
+ * @returns {void} timeout
107
+ */
108
+ componentWillLoad() {
109
+ // Get windows to attach events
110
+ this.windows = getWindows(window);
111
+ // Get locales
112
+ this.messages = initLocales(this.element).messages;
113
+ this.validateArrowHide(this.arrowHide);
114
+ }
115
+ /**
116
+ * Check if component props are well configured on init
117
+ *
118
+ * @returns {void}
119
+ */
120
+ componentDidLoad() {
121
+ const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
122
+ const slottedTitleElement = this.element.querySelector('[slot="title"]');
123
+ if (slottedTitleElement && !isTagName(slottedTitleElement, headingTags)) {
124
+ throw new Error(`<mg-popover> Slotted title must be a heading: ${headingTags.join(', ')}`);
125
+ }
126
+ // Set close button id
127
+ if (this.closeButton) {
128
+ this.closeButtonId = `${this.identifier}-close-button`;
129
+ }
130
+ // Get popover content
131
+ this.popover = this.element.shadowRoot.getElementById(this.identifier);
132
+ //Get interactive element (first element without slot attribute)
133
+ const interactiveElement = this.element.querySelector(':not([slot])');
134
+ // Add aria attributes
135
+ interactiveElement.setAttribute('aria-controls', this.identifier);
136
+ interactiveElement.setAttribute('aria-expanded', `${this.display}`);
137
+ // Create popperjs popover
138
+ this.popper = createPopper(interactiveElement, this.popover, {
139
+ placement: this.placement,
140
+ strategy: 'fixed',
141
+ modifiers: [
142
+ {
143
+ name: 'offset',
144
+ options: {
145
+ offset: [0, 0],
146
+ },
147
+ },
148
+ ],
149
+ });
150
+ if (this.resizeObserver === undefined) {
151
+ // add resize observer
152
+ this.resizeObserver = new ResizeObserver(entries => {
153
+ if (entries.some(entrie => entrie.target.getAttribute('slot') !== null)) {
154
+ this.popper.update();
155
+ }
156
+ });
157
+ Array.from(this.element.querySelectorAll('[slot]')).forEach(element => {
158
+ this.resizeObserver.observe(element);
159
+ });
160
+ }
161
+ // Add events to toggle display
162
+ interactiveElement.addEventListener('click', () => {
163
+ if (!this.disabled)
164
+ this.display = !this.display;
165
+ });
166
+ // Add events to hide popover
167
+ this.element.addEventListener('keydown', e => {
168
+ if (!this.disabled && e.code === 'Escape')
169
+ this.display = false;
170
+ });
171
+ this.handleDisplay(this.display);
172
+ }
173
+ /**
174
+ * Render
175
+ *
176
+ * @returns {HTMLElement} HTML Element
177
+ */
178
+ render() {
179
+ return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: this.classList.join() }, h("mg-card", null, this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, h("mg-icon", { icon: "cross" }))), h("div", { class: "mg-popover__title" }, h("slot", { name: "title" })), h("slot", { name: "content" })), !this.arrowHide && h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
180
+ }
181
+ get element() { return this; }
182
+ static get watchers() { return {
183
+ "arrowHide": ["validateArrowHide"],
184
+ "display": ["handleDisplay"]
185
+ }; }
186
+ static get style() { return mgPopoverCss; }
187
+ }, [1, "mg-popover", {
188
+ "identifier": [1],
189
+ "placement": [1],
190
+ "arrowHide": [4, "arrow-hide"],
191
+ "closeButton": [4, "close-button"],
192
+ "display": [1028],
193
+ "disabled": [1028],
194
+ "classList": [32]
195
+ }]);
196
+ function defineCustomElement() {
197
+ if (typeof customElements === "undefined") {
198
+ return;
199
+ }
200
+ const components = ["mg-popover", "mg-button", "mg-card", "mg-icon"];
201
+ components.forEach(tagName => { switch (tagName) {
202
+ case "mg-popover":
203
+ if (!customElements.get(tagName)) {
204
+ customElements.define(tagName, MgPopover);
205
+ }
206
+ break;
207
+ case "mg-button":
208
+ if (!customElements.get(tagName)) {
209
+ defineCustomElement$3();
210
+ }
211
+ break;
212
+ case "mg-card":
213
+ if (!customElements.get(tagName)) {
214
+ defineCustomElement$2();
215
+ }
216
+ break;
217
+ case "mg-icon":
218
+ if (!customElements.get(tagName)) {
219
+ defineCustomElement$1();
220
+ }
221
+ break;
222
+ } });
223
+ }
224
+ defineCustomElement();
225
+
226
+ export { MgPopover as M, defineCustomElement as d };
@@ -1,4 +1,4 @@
1
- import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { i as initLocales } from './index2.js';
3
3
 
4
4
  const mgSkipLinksCss = ".mg-skip-links{position:absolute;transform:translateY(-100%);opacity:0;background:hsl(var(--color-light))}.mg-skip-links:focus-within{position:relative;transform:translateY(0);opacity:1}.mg-skip-links__list{display:flex;flex-wrap:wrap;align-items:center;gap:0.6rem;margin:0;padding:0.64rem 1.8rem;list-style:none}.mg-skip-links__link{display:inline-block;padding:1.2rem;color:hsl(var(--color-dark))}.mg-skip-links__link:hover{background:hsl(var(--color-dark), 0.1)}";
@@ -8,6 +8,20 @@ const MgSkipLinks$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
8
8
  super();
9
9
  this.__registerHost();
10
10
  this.__attachShadow();
11
+ this.goToAnchor = createEvent(this, "go-to-anchor", 7);
12
+ /***********
13
+ * Methods *
14
+ **********/
15
+ /**
16
+ * Handle link click and emit go-to-anchor event
17
+ *
18
+ * @param {MouseEvent} event mouse event
19
+ * @returns {void}
20
+ */
21
+ this.handleLinkCLick = (event) => {
22
+ event.currentTarget.blur();
23
+ this.goToAnchor.emit(event.currentTarget.getAttribute('href'));
24
+ };
11
25
  this.links = undefined;
12
26
  }
13
27
  validateLinks(links) {
@@ -35,7 +49,7 @@ const MgSkipLinks$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
35
49
  * @returns {HTMLElement} HTML Element
36
50
  */
37
51
  render() {
38
- return (h("nav", { class: "mg-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, h("ul", { class: "mg-skip-links__list" }, this.links.map(link => (h("li", null, h("a", { class: "mg-skip-links__link", href: link.href }, link.label)))))));
52
+ return (h("nav", { class: "mg-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, h("ul", { class: "mg-skip-links__list", role: "list" }, this.links.map(link => (h("li", { key: link.href }, h("a", { class: "mg-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
39
53
  }
40
54
  get element() { return this; }
41
55
  static get watchers() { return {
@@ -18,7 +18,7 @@ var Status;
18
18
  */
19
19
  const sizes = ['regular', 'large'];
20
20
 
21
- const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular{padding:1rem 2rem}.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button ::slotted([slot=label]),.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button ::slotted([slot=metadata]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular ::slotted([slot=label]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular ::slotted([slot=metadata]){font-size:1.3rem}.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button.mg-tabs__navigation-button--horizontal,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular.mg-tabs__navigation-button--horizontal{padding-bottom:calc(1rem - 0.3rem)}.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button.mg-tabs__navigation-button--vertical,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular.mg-tabs__navigation-button--vertical{padding-left:calc(2rem - 0.3rem)}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large{padding:1.5rem 3rem}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button,.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button ::slotted([slot=label]),.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button ::slotted([slot=metadata]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large ::slotted([slot=label]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large ::slotted([slot=metadata]){font-size:1.5rem}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button.mg-tabs__navigation-button--horizontal,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large.mg-tabs__navigation-button--horizontal{padding-bottom:calc(1.5rem - 0.3rem)}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button.mg-tabs__navigation-button--vertical,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large.mg-tabs__navigation-button--vertical{padding-left:calc(3rem - 0.3rem)}.mg-tabs__navigation-button{display:flex;align-items:center;column-gap:1rem;background-color:unset;border:none;font-family:var(--font-family);color:hsl(var(--mg-tabs-color-hsl, var(--color-dark)));line-height:var(--line-height);text-decoration:none;cursor:pointer}.mg-tabs__navigation-button:disabled,.mg-tabs__navigation-button--disabled{cursor:default;opacity:30%}.mg-tabs__navigation-button:focus-visible{z-index:10}.mg-tabs__navigation-button:hover:not(.mg-tabs__navigation-button--disabled),.mg-tabs__navigation-button:focus:not(.mg-tabs__navigation-button--disabled){background-color:hsla(var(--mg-tabs-focused-background-color-hsl), 10%)}.mg-tabs__navigation-button.mg-tabs__navigation-button--active{color:hsl(var(--mg-tabs-color-active-hsl));font-weight:700}.mg-tabs__navigation-button.mg-tabs__navigation-button--active.mg-tabs__navigation-button--horizontal{border-bottom-color:hsl(var(--mg-tabs-border-color-active-hsl))}.mg-tabs__navigation-button.mg-tabs__navigation-button--active.mg-tabs__navigation-button--vertical{border-left-color:hsl(var(--mg-tabs-border-color-active-hsl))}.mg-tabs__navigation-button.mg-tabs__navigation-button--hidden{display:none}.mg-tabs__navigation-button.mg-tabs__navigation-button--horizontal{border-bottom:0.3rem solid transparent}.mg-tabs__navigation-button.mg-tabs__navigation-button--vertical{border-left:0.3rem solid transparent}.mg-tabs__header{display:flex;flex-direction:row;flex-wrap:wrap}.mg-tabs__content-container:focus-visible{outline:none}.mg-tabs__navigation-button-text{flex:0 0 content}";
21
+ const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular{padding:1rem 2rem;height:calc()}.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button ::slotted([slot=label]),.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button ::slotted([slot=metadata]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular ::slotted([slot=label]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular ::slotted([slot=metadata]){font-size:var(--font-size)}.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button.mg-tabs__navigation-button--horizontal,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular.mg-tabs__navigation-button--horizontal{padding-bottom:calc(1rem - 0.3rem)}.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button.mg-tabs__navigation-button--vertical,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-regular.mg-tabs__navigation-button--vertical{padding-left:calc(2rem - 0.3rem)}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large{padding:1.5rem 3rem;height:calc()}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button,.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button ::slotted([slot=label]),.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button ::slotted([slot=metadata]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large ::slotted([slot=label]),.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large ::slotted([slot=metadata]){font-size:calc(var(--font-size) + 0.2rem)}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button.mg-tabs__navigation-button--horizontal,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large.mg-tabs__navigation-button--horizontal{padding-bottom:calc(1.5rem - 0.3rem)}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button.mg-tabs__navigation-button--vertical,.mg-tabs__navigation-button.mg-tabs__navigation-button--size-large.mg-tabs__navigation-button--vertical{padding-left:calc(3rem - 0.3rem)}.mg-tabs__navigation-button{display:flex;align-items:center;column-gap:var(--mg-tabs-navigation-button-column-gap, 1rem);background-color:unset;border:none;font-family:var(--font-family);font-weight:400;color:hsl(var(--mg-tabs-color-hsl, var(--color-dark)));line-height:var(--line-height);text-decoration:none;white-space:nowrap;box-sizing:border-box;cursor:pointer}.mg-tabs__navigation-button:disabled,.mg-tabs__navigation-button--disabled{cursor:default;opacity:var(--mg-disabled-opacity)}.mg-tabs__navigation-button:focus-visible{z-index:10}.mg-tabs__navigation-button:hover:not(.mg-tabs__navigation-button--disabled),.mg-tabs__navigation-button:focus-visible:not(.mg-tabs__navigation-button--disabled){background-color:hsl(var(--mg-tabs-focused-background-color-hsl), 0.1)}.mg-tabs__navigation-button.mg-tabs__navigation-button--active{color:hsl(var(--mg-tabs-color-active-hsl));font-weight:600}.mg-tabs__navigation-button.mg-tabs__navigation-button--active.mg-tabs__navigation-button--horizontal{border-bottom-color:hsl(var(--mg-tabs-border-color-active-hsl))}.mg-tabs__navigation-button.mg-tabs__navigation-button--active.mg-tabs__navigation-button--vertical{border-left-color:hsl(var(--mg-tabs-border-color-active-hsl))}.mg-tabs__navigation-button.mg-tabs__navigation-button--hidden{display:none}.mg-tabs__navigation-button.mg-tabs__navigation-button--horizontal{border-bottom:0.3rem solid transparent}.mg-tabs__navigation-button.mg-tabs__navigation-button--vertical{border-left:0.3rem solid transparent}.mg-tabs__header{display:flex;flex-direction:row;flex-wrap:wrap}.mg-tabs__content-container:focus-visible{outline:none}.mg-tabs__navigation-button-text{flex:0 0 content}";
22
22
 
23
23
  /**
24
24
  * type TabItem validation function
@@ -39,25 +39,7 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
39
39
  // classes
40
40
  this.tabPanel = 'panel';
41
41
  this.buttonTabBaseClass = 'mg-tabs__navigation-button';
42
- // variables
43
42
  this.startIndex = 1;
44
- /**
45
- * Method to set active tab
46
- *
47
- * @param {number} tabKey item tab key to set to ACTIVE status
48
- * @returns {void}
49
- */
50
- this.setActiveTab = (tabKey) => {
51
- // reset active tabs
52
- this.tabs.forEach(tab => {
53
- if (this.tabHasGivenStatus(tab, Status.ACTIVE))
54
- tab.status = Status.VISIBLE;
55
- });
56
- // set active tab from given tab key
57
- this.tabs[tabKey - this.startIndex].status = Status.ACTIVE;
58
- // emit change active tab key event
59
- this.activeTabChange.emit(tabKey);
60
- };
61
43
  /**
62
44
  * Method to know if given tab has the given status
63
45
  *
@@ -65,7 +47,7 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
65
47
  * @param {Status} status status to valide
66
48
  * @returns {boolean} status comparaison
67
49
  */
68
- this.tabHasGivenStatus = (tab, status) => tab.status === status;
50
+ this.tabHasStatus = (tab, status) => tab.status === status;
69
51
  /**
70
52
  * Method to get element id from index
71
53
  *
@@ -73,31 +55,43 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
73
55
  * @param {number} index to generate id
74
56
  * @returns {string} generated element id
75
57
  */
76
- this.getElementId = (element, index) => `${element}-${this.getTabIndex(index)}`;
58
+ this.getElementId = (element, index) => `${element}-${this.getTabItemIndex(index)}`;
77
59
  /**
78
- * Method to get tab index
60
+ * Method to get tab item index
79
61
  *
80
62
  * @param {number} index to get
81
63
  * @returns {number} index
82
64
  */
83
- this.getTabIndex = (index) => index + this.startIndex;
65
+ this.getTabItemIndex = (index) => index + this.startIndex;
66
+ /**
67
+ * Method to get the active-tab value
68
+ *
69
+ * @returns {number} of the active-tab
70
+ */
71
+ this.getActiveTab = () => this.activeTab || this.getTabItemIndex(this.tabs.map((tab, index) => (Object.assign(Object.assign({}, tab), { index }))).find(tab => this.tabHasStatus(tab, Status.ACTIVE)).index);
84
72
  /**
85
73
  * Handle click events on tabs
86
74
  *
87
75
  * @param {MouseEvent} event mouse event
88
76
  */
89
77
  this.handleClick = (event) => {
90
- const tabId = event.currentTarget.getAttribute('data-index');
91
- this.activeTab = Number(tabId);
78
+ const tabId = event.currentTarget.dataset.index;
79
+ const tab = this.tabs[Number(tabId) - this.startIndex];
80
+ if (this.tabHasStatus(tab, Status.HIDDEN) || this.tabHasStatus(tab, Status.DISABLED)) {
81
+ event.preventDefault();
82
+ }
83
+ else {
84
+ this.activeTab = Number(tabId);
85
+ this.tabFocus = undefined;
86
+ }
92
87
  };
93
88
  /**
94
89
  * get navigation button class from given status
95
90
  *
96
91
  * @param {Status} status button tab status
97
- * @param {boolean} isSelector set if we need a CSS selector with the dot '.' at the begin. default value = false.
98
92
  * @returns {string} button class/selector variant
99
93
  */
100
- this.getNavigationButtonClass = (status, isSelector = false) => `${isSelector ? '.' : ''}${this.buttonTabBaseClass}--${status}`;
94
+ this.getNavigationButtonClass = (status) => `${this.buttonTabBaseClass}--${status}`;
101
95
  /**
102
96
  * Handle keyboard event on tabs
103
97
  *
@@ -105,37 +99,66 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
105
99
  * @returns {void}
106
100
  */
107
101
  this.handleKeydown = (event) => {
108
- let tabId = Number(event.target.getAttribute('data-index'));
109
102
  const parent = event.target.parentElement;
110
- // change selected id from key code
111
- if (event.key === 'ArrowRight') {
112
- tabId++;
113
- }
114
- else if (event.key === 'ArrowLeft') {
115
- tabId--;
103
+ if (['ArrowRight', 'ArrowLeft'].includes(event.key)) {
104
+ this.tabFocus = Number(event.target.dataset.index);
105
+ parent.querySelector(`[data-index="${this.tabFocus}"]`).setAttribute('tabindex', '-1');
106
+ // Move right
107
+ if (event.key === 'ArrowRight') {
108
+ this.tabFocus++;
109
+ // If we're at the end, go to the start
110
+ if (this.tabFocus > this.tabs.length)
111
+ this.tabFocus = this.startIndex;
112
+ // Move left
113
+ }
114
+ else if (event.key === 'ArrowLeft') {
115
+ this.tabFocus--;
116
+ // If we're at the start, move to the end
117
+ if (this.tabFocus < this.startIndex)
118
+ this.tabFocus = this.tabs.length;
119
+ }
120
+ const parentButtonElement = parent.querySelector(`[data-index="${this.tabFocus}"]`);
121
+ // if focus item is ['hidden'] we recursively repeat action
122
+ if (this.tabHasStatus(this.tabs[this.tabFocus - 1], Status.HIDDEN)) {
123
+ parentButtonElement.dispatchEvent(new KeyboardEvent('keydown', { key: event.key, bubbles: true }));
124
+ // else run focus methods on tabFocus element
125
+ }
126
+ else {
127
+ parentButtonElement.setAttribute('tabindex', '0');
128
+ parentButtonElement.focus();
129
+ }
116
130
  }
117
- // get selected tab if NOT hidden, disabled
118
- const selectedTab = parent.querySelector(`[data-index="${tabId}"]:not(${[this.getNavigationButtonClass(Status.HIDDEN, true), this.getNavigationButtonClass(Status.DISABLED, true)].join()})`);
119
- // apply selected tab if exist
120
- if (selectedTab !== null) {
121
- selectedTab.focus();
122
- this.activeTab = tabId;
131
+ else if (event.key === 'Tab') {
132
+ this.resetFocus();
123
133
  }
124
134
  };
135
+ /**
136
+ * Method to reset focus behavior
137
+ *
138
+ * @returns {void}
139
+ */
140
+ this.resetFocus = () => {
141
+ // update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
142
+ setTimeout(() => {
143
+ this.tabFocus = undefined;
144
+ Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {
145
+ tab.setAttribute('tabindex', this.getActiveTab() - this.startIndex !== index ? '-1' : '0');
146
+ });
147
+ }, 0);
148
+ };
125
149
  /**
126
150
  * Validate slots setting
127
151
  */
128
152
  this.validateSlots = () => {
129
153
  const slots = Array.from(this.element.children).filter(slot => { var _a; return (_a = slot.getAttribute('slot')) === null || _a === void 0 ? void 0 : _a.includes('tab_content-'); });
130
- if (slots.length !== this.tabs.length) {
154
+ if (slots.length !== this.tabs.length)
131
155
  throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
132
- }
133
156
  };
134
157
  this.identifier = createID('mg-tabs');
135
158
  this.label = undefined;
136
159
  this.size = 'regular';
137
160
  this.items = undefined;
138
- this.activeTab = 1;
161
+ this.activeTab = undefined;
139
162
  this.tabs = [];
140
163
  this.classList = new ClassList(['mg-tabs']);
141
164
  }
@@ -146,29 +169,44 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
146
169
  }
147
170
  validateSize(newValue) {
148
171
  if (!sizes.includes(newValue)) {
149
- throw new Error(`<mg-tabs> prop "size" must be one of : ${sizes.join(', ')}`);
172
+ throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}`);
150
173
  }
151
174
  this.classList.add(`mg-tabs--size-${this.size}`);
152
175
  }
153
176
  validateItems(newValue) {
154
177
  // String array
155
178
  if (allItemsAreString(newValue)) {
156
- this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
179
+ this.tabs = newValue.map((item, index) => ({ label: item, status: index === 0 ? Status.ACTIVE : Status.VISIBLE }));
157
180
  }
158
181
  // Object array
159
- else if (newValue && newValue.every(item => isTabItem(item))) {
182
+ else if (newValue && newValue.length > 0 && newValue.every(item => isTabItem(item))) {
160
183
  this.tabs = newValue;
184
+ // init active tabs if not set. Default: index 0.
185
+ if (this.tabs.find(tab => this.tabHasStatus(tab, Status.ACTIVE)) === undefined)
186
+ this.tabs[0].status = Status.ACTIVE;
161
187
  }
162
188
  else {
163
189
  throw new Error('<mg-tabs> prop "items" is required and all items must be the same type: TabItem.');
164
190
  }
165
191
  }
166
192
  validateActiveTab(newValue) {
167
- if (newValue < 1 || newValue > this.tabs.length) {
168
- throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
193
+ if (typeof newValue === 'number' && newValue >= 1 && newValue <= this.tabs.length) {
194
+ this.tabs.forEach((tab, index) => {
195
+ const isNewActiveTab = index === newValue - this.startIndex;
196
+ // reset active tabs
197
+ if (this.tabHasStatus(tab, Status.ACTIVE) && !isNewActiveTab)
198
+ tab.status = Status.VISIBLE;
199
+ // set active tab from given tab key
200
+ else if ((tab.status === undefined || this.tabHasStatus(tab, Status.VISIBLE)) && isNewActiveTab)
201
+ tab.status = Status.ACTIVE;
202
+ });
203
+ // emit change active tab key event
204
+ if (this.tabs.find(tab => this.tabHasStatus(tab, Status.ACTIVE)) !== undefined) {
205
+ this.activeTabChange.emit(newValue);
206
+ }
169
207
  }
170
- else {
171
- this.setActiveTab(newValue);
208
+ else if (newValue !== undefined) {
209
+ throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
172
210
  }
173
211
  }
174
212
  /*************
@@ -187,19 +225,30 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
187
225
  this.validateSize(this.size);
188
226
  this.validateSlots();
189
227
  }
228
+ /**
229
+ * add listners
230
+ *
231
+ * @returns {void}
232
+ */
233
+ componentDidLoad() {
234
+ document.addEventListener('click', (event) => {
235
+ if (event.target.closest('mg-tabs') !== this.element)
236
+ this.resetFocus();
237
+ }, false);
238
+ }
190
239
  /**
191
240
  * Render
192
241
  *
193
242
  * @returns {HTMLElement} HTML Element
194
243
  */
195
244
  render() {
196
- return (h("div", { class: this.classList.join() }, h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => (h("button", { role: "tab", id: this.getElementId(this.identifier, index), class: {
245
+ return (h("div", { class: this.classList.join() }, h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => (h("button", { key: tab.label, role: "tab", id: this.getElementId(this.identifier, index), class: {
197
246
  [`${this.buttonTabBaseClass}`]: true,
198
247
  [`${this.buttonTabBaseClass}--horizontal`]: true,
199
- [`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasGivenStatus(tab, Status.ACTIVE),
200
- [`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasGivenStatus(tab, Status.DISABLED),
201
- [`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasGivenStatus(tab, Status.HIDDEN),
202
- }, tabindex: this.tabHasGivenStatus(tab, Status.ACTIVE) ? 0 : -1, "aria-selected": this.tabHasGivenStatus(tab, Status.ACTIVE).toString(), "aria-controls": this.getElementId(this.tabPanel, index), onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": this.getTabIndex(index), disabled: this.tabHasGivenStatus(tab, Status.DISABLED) }, tab.icon !== undefined && h("mg-icon", { icon: tab.icon }), tab.label, tab.badge !== undefined && h("mg-badge", { variant: tab.status !== Status.ACTIVE ? 'primary' : 'info', value: tab.badge.value, label: tab.badge.label }))))), this.tabs.map((tab, index) => (h("article", { role: "tabpanel", id: this.getElementId(this.tabPanel, index), hidden: !this.tabHasGivenStatus(tab, Status.ACTIVE), "aria-labelledby": this.getElementId(this.identifier, index), tabindex: this.tabHasGivenStatus(tab, Status.ACTIVE) ? 0 : -1, class: "mg-tabs__content-container" }, h("slot", { name: this.getElementId('tab_content', index) }))))));
248
+ [`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
249
+ [`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasStatus(tab, Status.DISABLED),
250
+ [`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasStatus(tab, Status.HIDDEN),
251
+ }, tabindex: this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1, "aria-selected": this.tabHasStatus(tab, Status.ACTIVE).toString(), "aria-controls": this.getElementId(this.tabPanel, index), "aria-disabled": this.tabHasStatus(tab, Status.DISABLED), onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": this.getTabItemIndex(index) }, tab.icon !== undefined && h("mg-icon", { icon: tab.icon }), tab.label, tab.badge !== undefined && h("mg-badge", { variant: "text-color", value: tab.badge.value, label: tab.badge.label, outline: tab.badge.role === 'information' }))))), this.tabs.map((tab, index) => (h("article", { key: tab.label, role: "tabpanel", id: this.getElementId(this.tabPanel, index), hidden: !this.tabHasStatus(tab, Status.ACTIVE), "aria-labelledby": this.getElementId(this.identifier, index), tabindex: this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1, class: "mg-tabs__content-container" }, h("slot", { name: this.getElementId('tab_content', index) }))))));
203
252
  }
204
253
  get element() { return this; }
205
254
  static get watchers() { return {
@@ -6,7 +6,7 @@ import { C as ClassList } from './components.utils.js';
6
6
  */
7
7
  const variants = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'];
8
8
 
9
- const mgTagCss = ".mg-tag{padding:calc((var(--mg-tag-height) - 0.2rem - var(--mg-tag-font-size) * var(--line-height)) / 2) 0.6rem;min-height:var(--mg-tag-height);box-sizing:border-box;border-radius:var(--mg-tag-border-radius);border:0.1rem solid;font-size:var(--mg-tag-font-size);font-weight:600;text-align:center}.mg-tag.mg-tag--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-tag.mg-tag--primary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-tag.mg-tag--primary.mg-tag--soft{font-weight:200;background-color:hsl(var(--color-dark-h), var(--color-dark-s), 90%);border-color:hsl(var(--color-dark-h), var(--color-dark-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--primary.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-tag.mg-tag--secondary.mg-tag--soft{font-weight:200;background-color:hsl(var(--color-light-h), var(--color-light-s), 90%);border-color:hsl(var(--color-light-h), var(--color-light-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-dark))}.mg-tag.mg-tag--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-tag.mg-tag--success.mg-tag--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-tag.mg-tag--success.mg-tag--soft{font-weight:200;background-color:hsl(var(--color-success-h), var(--color-success-s), 90%);border-color:hsl(var(--color-success-h), var(--color-success-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--success.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-success))}.mg-tag.mg-tag--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-tag.mg-tag--warning.mg-tag--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-tag.mg-tag--warning.mg-tag--soft{font-weight:200;background-color:hsl(var(--color-warning-h), var(--color-warning-s), 90%);border-color:hsl(var(--color-warning-h), var(--color-warning-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--warning.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-warning))}.mg-tag.mg-tag--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-tag.mg-tag--danger.mg-tag--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-tag.mg-tag--danger.mg-tag--soft{font-weight:200;background-color:hsl(var(--color-danger-h), var(--color-danger-s), 90%);border-color:hsl(var(--color-danger-h), var(--color-danger-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--danger.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-danger))}.mg-tag.mg-tag--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-tag.mg-tag--info.mg-tag--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-tag.mg-tag--info.mg-tag--soft{font-weight:200;background-color:hsl(var(--color-info-h), var(--color-info-s), 90%);border-color:hsl(var(--color-info-h), var(--color-info-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--info.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-info))}.mg-tag,mg-tag{display:inline-block;vertical-align:middle}::slotted(mg-icon){margin-right:0.4rem}";
9
+ const mgTagCss = ".mg-tag{padding:calc((var(--mg-tag-height) - 0.2rem - var(--mg-tag-font-size) * var(--line-height)) / 2) 0.6rem;min-height:var(--mg-tag-height);box-sizing:border-box;border-radius:var(--mg-tag-border-radius);border:0.1rem solid;font-size:var(--mg-tag-font-size);font-weight:600;text-align:center}.mg-tag.mg-tag--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-tag.mg-tag--primary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-tag.mg-tag--primary.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-dark-h), var(--color-dark-s), 90%);border-color:hsl(var(--color-dark-h), var(--color-dark-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--primary.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-tag.mg-tag--secondary.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-light-h), var(--color-light-s), 90%);border-color:hsl(var(--color-light-h), var(--color-light-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-dark))}.mg-tag.mg-tag--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-tag.mg-tag--success.mg-tag--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-tag.mg-tag--success.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-success-h), var(--color-success-s), 90%);border-color:hsl(var(--color-success-h), var(--color-success-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--success.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-success))}.mg-tag.mg-tag--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-tag.mg-tag--warning.mg-tag--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-tag.mg-tag--warning.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-warning-h), var(--color-warning-s), 90%);border-color:hsl(var(--color-warning-h), var(--color-warning-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--warning.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-warning))}.mg-tag.mg-tag--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-tag.mg-tag--danger.mg-tag--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-tag.mg-tag--danger.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-danger-h), var(--color-danger-s), 90%);border-color:hsl(var(--color-danger-h), var(--color-danger-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--danger.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-danger))}.mg-tag.mg-tag--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-tag.mg-tag--info.mg-tag--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-tag.mg-tag--info.mg-tag--soft{font-weight:400;background-color:hsl(var(--color-info-h), var(--color-info-s), 90%);border-color:hsl(var(--color-info-h), var(--color-info-s), 90%);color:hsl(var(--color-dark))}.mg-tag.mg-tag--info.mg-tag--soft ::slotted(mg-icon){color:hsl(var(--color-info))}.mg-tag,mg-tag{display:inline-block;vertical-align:middle}::slotted(mg-icon){margin-right:0.4rem}";
10
10
 
11
11
  const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
12
12
  constructor() {
@@ -17,8 +17,8 @@ const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
17
17
  * Internal *
18
18
  ************/
19
19
  // Classes
20
- this.classOutline = `mg-tag--outline`;
21
- this.classSoft = `mg-tag--soft`;
20
+ this.classOutline = 'mg-tag--outline';
21
+ this.classSoft = 'mg-tag--soft';
22
22
  this.variant = variants[0];
23
23
  this.outline = undefined;
24
24
  this.soft = undefined;
@@ -26,7 +26,7 @@ const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
26
26
  }
27
27
  validateVariant(newValue, oldValue) {
28
28
  if (!variants.includes(newValue)) {
29
- throw new Error(`<mg-tag> prop "variant" must be one of : ${variants.join(', ')}.`);
29
+ throw new Error(`<mg-tag> prop "variant" must be one of: ${variants.join(', ')}.`);
30
30
  }
31
31
  else {
32
32
  if (oldValue !== undefined) {
@@ -61,7 +61,7 @@ const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
61
61
  * @returns {void}
62
62
  */
63
63
  validateTextContent(textContent) {
64
- if (!textContent || textContent.trim() === '')
64
+ if (typeof textContent !== 'string' || textContent.trim() === '')
65
65
  throw new Error('<mg-tag> slot must contain a text content.');
66
66
  }
67
67
  /*************