@mgdis/mg-components 5.19.2 → 5.20.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 (496) hide show
  1. package/dist/cjs/{components.utils-dc9c8a53.js → components.utils-cd908d4e.js} +102 -99
  2. package/dist/cjs/components.utils-cd908d4e.js.map +1 -0
  3. package/dist/cjs/{index-c042e24b.js → index-8532b5e9.js} +320 -137
  4. package/dist/cjs/index-8532b5e9.js.map +1 -0
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/mg-action-more_34.cjs.entry.js +5130 -5057
  7. package/dist/cjs/mg-action-more_34.cjs.entry.js.map +1 -1
  8. package/dist/cjs/mg-components.cjs.js +3 -3
  9. package/dist/cjs/mg-components.cjs.js.map +1 -1
  10. package/dist/cjs/mg-item-more.cjs.entry.js +224 -224
  11. package/dist/cjs/mg-item-more.cjs.entry.js.map +1 -1
  12. package/dist/collection/assets/icons/index.js +193 -183
  13. package/dist/collection/assets/icons/index.js.map +1 -0
  14. package/dist/collection/collection-manifest.json +6 -6
  15. package/dist/collection/components/atoms/mg-badge/mg-badge.js +161 -161
  16. package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
  17. package/dist/collection/components/atoms/mg-button/mg-button.js +362 -347
  18. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  19. package/dist/collection/components/atoms/mg-card/mg-card.js +126 -126
  20. package/dist/collection/components/atoms/mg-card/mg-card.js.map +1 -1
  21. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +101 -101
  22. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js.map +1 -1
  23. package/dist/collection/components/atoms/mg-divider/mg-divider.js +47 -47
  24. package/dist/collection/components/atoms/mg-divider/mg-divider.js.map +1 -1
  25. package/dist/collection/components/atoms/mg-icon/mg-icon.js +231 -231
  26. package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
  27. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +132 -132
  28. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js.map +1 -1
  29. package/dist/collection/components/atoms/mg-tag/mg-tag.js +158 -158
  30. package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
  31. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +46 -46
  32. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js.map +1 -1
  33. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +3 -3
  34. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -1
  35. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +398 -398
  36. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
  37. package/dist/collection/components/molecules/inputs/MgInput.conf.js +8 -0
  38. package/dist/collection/components/molecules/inputs/MgInput.conf.js.map +1 -1
  39. package/dist/collection/components/molecules/inputs/MgInput.js +84 -84
  40. package/dist/collection/components/molecules/inputs/MgInput.js.map +1 -1
  41. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +8 -8
  42. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js.map +1 -1
  43. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +266 -266
  44. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
  45. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +4 -4
  46. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js.map +1 -1
  47. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +789 -791
  48. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
  49. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +4 -4
  50. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js.map +1 -1
  51. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +589 -572
  52. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
  53. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +4 -4
  54. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js.map +1 -1
  55. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +779 -767
  56. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
  57. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +537 -520
  58. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
  59. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +566 -550
  60. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
  61. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +701 -689
  62. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
  63. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js +0 -4
  64. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js.map +1 -1
  65. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +771 -754
  66. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
  67. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +706 -689
  68. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
  69. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +527 -522
  70. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
  71. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +2 -2
  72. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js.map +1 -1
  73. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +263 -263
  74. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
  75. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +6 -6
  76. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js.map +1 -1
  77. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +423 -423
  78. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
  79. package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js.map +1 -1
  80. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +214 -214
  81. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
  82. package/dist/collection/components/molecules/mg-details/mg-details.js +155 -150
  83. package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
  84. package/dist/collection/components/molecules/mg-form/mg-form.js +332 -335
  85. package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
  86. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +85 -85
  87. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -1
  88. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +189 -189
  89. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +1 -1
  90. package/dist/collection/components/molecules/mg-message/mg-message.js +325 -304
  91. package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
  92. package/dist/collection/components/molecules/mg-modal/mg-modal.js +317 -317
  93. package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
  94. package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +2 -2
  95. package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js.map +1 -1
  96. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +216 -216
  97. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
  98. package/dist/collection/components/molecules/mg-panel/mg-panel.js +409 -399
  99. package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
  100. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +91 -91
  101. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -1
  102. package/dist/collection/components/molecules/mg-popover/mg-popover.js +336 -329
  103. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  104. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +94 -94
  105. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -1
  106. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +4 -4
  107. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js.map +1 -1
  108. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +348 -343
  109. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
  110. package/dist/collection/locales/fr/messages.json +4 -4
  111. package/dist/collection/locales/index.spec.js +20 -20
  112. package/dist/collection/locales/index.spec.js.map +1 -1
  113. package/dist/collection/utils/behaviors.utils.js +127 -127
  114. package/dist/collection/utils/behaviors.utils.js.map +1 -1
  115. package/dist/collection/utils/behaviors.utils.spec.js +42 -42
  116. package/dist/collection/utils/behaviors.utils.spec.js.map +1 -1
  117. package/dist/collection/utils/components.utils.js +77 -75
  118. package/dist/collection/utils/components.utils.js.map +1 -1
  119. package/dist/collection/utils/components.utils.spec.js +150 -135
  120. package/dist/collection/utils/components.utils.spec.js.map +1 -1
  121. package/dist/collection/utils/e2e.test.utils.js +21 -21
  122. package/dist/collection/utils/e2e.test.utils.js.map +1 -1
  123. package/dist/collection/utils/locale.utils.js +17 -17
  124. package/dist/collection/utils/locale.utils.js.map +1 -1
  125. package/dist/collection/utils/locale.utils.spec.js +45 -45
  126. package/dist/collection/utils/locale.utils.spec.js.map +1 -1
  127. package/dist/collection/utils/playwright.e2e.test.utils.js +41 -41
  128. package/dist/collection/utils/playwright.e2e.test.utils.js.map +1 -1
  129. package/dist/collection/utils/playwright.fixture.js +24 -0
  130. package/dist/collection/utils/playwright.fixture.js.map +1 -0
  131. package/dist/collection/utils/unit.test.utils.js +50 -50
  132. package/dist/collection/utils/unit.test.utils.js.map +1 -1
  133. package/dist/components/MgInput.js +105 -97
  134. package/dist/components/MgInput.js.map +1 -1
  135. package/dist/components/components.utils.js +78 -76
  136. package/dist/components/components.utils.js.map +1 -1
  137. package/dist/components/index2.js +21 -21
  138. package/dist/components/index2.js.map +1 -1
  139. package/dist/components/mg-action-more.d.ts +2 -2
  140. package/dist/components/mg-action-more.js +173 -173
  141. package/dist/components/mg-action-more.js.map +1 -1
  142. package/dist/components/mg-badge.d.ts +2 -2
  143. package/dist/components/mg-badge2.js +83 -83
  144. package/dist/components/mg-badge2.js.map +1 -1
  145. package/dist/components/mg-button.d.ts +2 -2
  146. package/dist/components/mg-button2.js +182 -167
  147. package/dist/components/mg-button2.js.map +1 -1
  148. package/dist/components/mg-card.d.ts +2 -2
  149. package/dist/components/mg-card2.js +77 -77
  150. package/dist/components/mg-card2.js.map +1 -1
  151. package/dist/components/mg-character-left.d.ts +2 -2
  152. package/dist/components/mg-character-left2.js +50 -50
  153. package/dist/components/mg-character-left2.js.map +1 -1
  154. package/dist/components/mg-details.d.ts +2 -2
  155. package/dist/components/mg-details.js +69 -69
  156. package/dist/components/mg-details.js.map +1 -1
  157. package/dist/components/mg-divider.d.ts +2 -2
  158. package/dist/components/mg-divider.js +30 -30
  159. package/dist/components/mg-divider.js.map +1 -1
  160. package/dist/components/mg-form.d.ts +2 -2
  161. package/dist/components/mg-form.js +171 -179
  162. package/dist/components/mg-form.js.map +1 -1
  163. package/dist/components/mg-icon.d.ts +2 -2
  164. package/dist/components/mg-icon2.js +327 -309
  165. package/dist/components/mg-icon2.js.map +1 -1
  166. package/dist/components/mg-illustrated-message.d.ts +2 -2
  167. package/dist/components/mg-illustrated-message.js +51 -51
  168. package/dist/components/mg-illustrated-message.js.map +1 -1
  169. package/dist/components/mg-input-checkbox-paginated.d.ts +2 -2
  170. package/dist/components/mg-input-checkbox-paginated2.js +170 -170
  171. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
  172. package/dist/components/mg-input-checkbox.d.ts +2 -2
  173. package/dist/components/mg-input-checkbox.js +478 -480
  174. package/dist/components/mg-input-checkbox.js.map +1 -1
  175. package/dist/components/mg-input-date.d.ts +2 -2
  176. package/dist/components/mg-input-date.js +266 -260
  177. package/dist/components/mg-input-date.js.map +1 -1
  178. package/dist/components/mg-input-numeric.d.ts +2 -2
  179. package/dist/components/mg-input-numeric.js +354 -348
  180. package/dist/components/mg-input-numeric.js.map +1 -1
  181. package/dist/components/mg-input-password.d.ts +2 -2
  182. package/dist/components/mg-input-password.js +205 -199
  183. package/dist/components/mg-input-password.js.map +1 -1
  184. package/dist/components/mg-input-radio.d.ts +2 -2
  185. package/dist/components/mg-input-radio.js +236 -231
  186. package/dist/components/mg-input-radio.js.map +1 -1
  187. package/dist/components/mg-input-select.d.ts +2 -2
  188. package/dist/components/mg-input-select2.js +316 -310
  189. package/dist/components/mg-input-select2.js.map +1 -1
  190. package/dist/components/mg-input-text.d.ts +2 -2
  191. package/dist/components/mg-input-text2.js +306 -300
  192. package/dist/components/mg-input-text2.js.map +1 -1
  193. package/dist/components/mg-input-textarea.d.ts +2 -2
  194. package/dist/components/mg-input-textarea.js +277 -271
  195. package/dist/components/mg-input-textarea.js.map +1 -1
  196. package/dist/components/mg-input-title.d.ts +2 -2
  197. package/dist/components/mg-input-title2.js +60 -60
  198. package/dist/components/mg-input-title2.js.map +1 -1
  199. package/dist/components/mg-input-toggle.d.ts +2 -2
  200. package/dist/components/mg-input-toggle.js +251 -251
  201. package/dist/components/mg-input-toggle.js.map +1 -1
  202. package/dist/components/mg-item-more.d.ts +2 -2
  203. package/dist/components/mg-item-more.js +285 -285
  204. package/dist/components/mg-item-more.js.map +1 -1
  205. package/dist/components/mg-menu-item.d.ts +2 -2
  206. package/dist/components/mg-menu-item2.js +345 -345
  207. package/dist/components/mg-menu-item2.js.map +1 -1
  208. package/dist/components/mg-menu.conf.js +2 -2
  209. package/dist/components/mg-menu.conf.js.map +1 -1
  210. package/dist/components/mg-menu.d.ts +2 -2
  211. package/dist/components/mg-menu2.js +176 -176
  212. package/dist/components/mg-menu2.js.map +1 -1
  213. package/dist/components/mg-message.d.ts +2 -2
  214. package/dist/components/mg-message.js +198 -193
  215. package/dist/components/mg-message.js.map +1 -1
  216. package/dist/components/mg-modal.d.ts +2 -2
  217. package/dist/components/mg-modal.js +198 -198
  218. package/dist/components/mg-modal.js.map +1 -1
  219. package/dist/components/mg-pagination.d.ts +2 -2
  220. package/dist/components/mg-pagination2.js +133 -133
  221. package/dist/components/mg-pagination2.js.map +1 -1
  222. package/dist/components/mg-panel.d.ts +2 -2
  223. package/dist/components/mg-panel.js +238 -238
  224. package/dist/components/mg-panel.js.map +1 -1
  225. package/dist/components/mg-popover-content.d.ts +2 -2
  226. package/dist/components/mg-popover-content2.js +70 -70
  227. package/dist/components/mg-popover-content2.js.map +1 -1
  228. package/dist/components/mg-popover.d.ts +2 -2
  229. package/dist/components/mg-popover2.js +224 -222
  230. package/dist/components/mg-popover2.js.map +1 -1
  231. package/dist/components/mg-skip-links.d.ts +2 -2
  232. package/dist/components/mg-skip-links.js +57 -57
  233. package/dist/components/mg-skip-links.js.map +1 -1
  234. package/dist/components/mg-tabs.d.ts +2 -2
  235. package/dist/components/mg-tabs.js +243 -243
  236. package/dist/components/mg-tabs.js.map +1 -1
  237. package/dist/components/mg-tag.d.ts +2 -2
  238. package/dist/components/mg-tag.js +97 -97
  239. package/dist/components/mg-tag.js.map +1 -1
  240. package/dist/components/mg-tooltip-content.d.ts +2 -2
  241. package/dist/components/mg-tooltip-content2.js +30 -30
  242. package/dist/components/mg-tooltip-content2.js.map +1 -1
  243. package/dist/components/mg-tooltip.d.ts +2 -2
  244. package/dist/components/mg-tooltip2.js +316 -316
  245. package/dist/components/mg-tooltip2.js.map +1 -1
  246. package/dist/components/popper.js +6 -12
  247. package/dist/components/popper.js.map +1 -1
  248. package/dist/esm/{components.utils-0f76010d.js → components.utils-0d67c31c.js} +102 -100
  249. package/dist/esm/components.utils-0d67c31c.js.map +1 -0
  250. package/dist/esm/{index-ce01e63b.js → index-f34a3a2c.js} +320 -137
  251. package/dist/esm/index-f34a3a2c.js.map +1 -0
  252. package/dist/esm/loader.js +3 -3
  253. package/dist/esm/mg-action-more_34.entry.js +5130 -5057
  254. package/dist/esm/mg-action-more_34.entry.js.map +1 -1
  255. package/dist/esm/mg-components.js +4 -4
  256. package/dist/esm/mg-components.js.map +1 -1
  257. package/dist/esm/mg-item-more.entry.js +224 -224
  258. package/dist/esm/mg-item-more.entry.js.map +1 -1
  259. package/dist/mg-components/locales/fr/messages.json +4 -4
  260. package/dist/mg-components/mg-components.css +1 -1
  261. package/dist/mg-components/mg-components.esm.js +1 -1
  262. package/dist/mg-components/mg-components.esm.js.map +1 -1
  263. package/dist/mg-components/p-629454f7.entry.js +2 -0
  264. package/dist/mg-components/p-629454f7.entry.js.map +1 -0
  265. package/dist/mg-components/p-7444ff40.js +3 -0
  266. package/dist/mg-components/p-7444ff40.js.map +1 -0
  267. package/dist/mg-components/p-af42d17b.js +2 -0
  268. package/dist/mg-components/p-af42d17b.js.map +1 -0
  269. package/dist/mg-components/{p-01ebc95a.entry.js → p-e0fb0f3c.entry.js} +2 -2
  270. package/dist/mg-components/p-e0fb0f3c.entry.js.map +1 -0
  271. package/dist/types/assets/icons/index.d.ts +193 -0
  272. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +41 -41
  273. package/dist/types/components/atoms/mg-button/mg-button.d.ts +100 -96
  274. package/dist/types/components/atoms/mg-card/mg-card.d.ts +39 -39
  275. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +37 -37
  276. package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +12 -12
  277. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +56 -56
  278. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +34 -34
  279. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +51 -51
  280. package/dist/types/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.d.ts +12 -12
  281. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +3 -3
  282. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +113 -113
  283. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +10 -3
  284. package/dist/types/components/molecules/inputs/MgInput.d.ts +17 -16
  285. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.d.ts +100 -100
  286. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +26 -26
  287. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +262 -260
  288. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +4 -4
  289. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +150 -149
  290. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +4 -4
  291. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +223 -222
  292. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +142 -141
  293. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +3 -3
  294. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +152 -151
  295. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +6 -6
  296. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +193 -192
  297. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.conf.d.ts +1 -6
  298. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +195 -194
  299. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +181 -180
  300. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +2 -2
  301. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +141 -141
  302. package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +2 -2
  303. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +97 -97
  304. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +6 -6
  305. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +179 -179
  306. package/dist/types/components/molecules/mg-action-more/mg-action-more.conf.d.ts +12 -11
  307. package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +72 -72
  308. package/dist/types/components/molecules/mg-details/mg-details.d.ts +45 -45
  309. package/dist/types/components/molecules/mg-form/mg-form.d.ts +103 -104
  310. package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +27 -27
  311. package/dist/types/components/molecules/mg-item-more/mg-item-more.conf.d.ts +5 -5
  312. package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +61 -61
  313. package/dist/types/components/molecules/mg-message/mg-message.d.ts +100 -93
  314. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +107 -107
  315. package/dist/types/components/molecules/mg-pagination/mg-pagination.conf.d.ts +2 -2
  316. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +74 -74
  317. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +149 -149
  318. package/dist/types/components/molecules/mg-popover/mg-popover-content/mg-popover-content.d.ts +43 -43
  319. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +88 -88
  320. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.conf.d.ts +2 -2
  321. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +40 -40
  322. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +10 -10
  323. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +118 -118
  324. package/dist/types/components.d.ts +296 -32
  325. package/dist/types/locales/index.d.ts +172 -172
  326. package/dist/types/stencil-public-runtime.d.ts +29 -0
  327. package/dist/types/utils/behaviors.utils.d.ts +65 -65
  328. package/dist/types/utils/components.utils.d.ts +32 -26
  329. package/dist/types/utils/locale.utils.d.ts +2 -2
  330. package/dist/types/utils/playwright.fixture.d.ts +3 -0
  331. package/dist/types/utils/unit.test.utils.d.ts +5 -5
  332. package/package.json +33 -47
  333. package/dist/cjs/components.utils-dc9c8a53.js.map +0 -1
  334. package/dist/cjs/index-c042e24b.js.map +0 -1
  335. package/dist/collection/components/atoms/mg-badge/test/mg-badge.e2e.playwright.js +0 -33
  336. package/dist/collection/components/atoms/mg-badge/test/mg-badge.e2e.playwright.js.map +0 -1
  337. package/dist/collection/components/atoms/mg-badge/test/mg-badge.spec.js +0 -70
  338. package/dist/collection/components/atoms/mg-badge/test/mg-badge.spec.js.map +0 -1
  339. package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js +0 -91
  340. package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js.map +0 -1
  341. package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js +0 -142
  342. package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js.map +0 -1
  343. package/dist/collection/components/atoms/mg-card/test/mg-card.e2e.js +0 -36
  344. package/dist/collection/components/atoms/mg-card/test/mg-card.e2e.js.map +0 -1
  345. package/dist/collection/components/atoms/mg-card/test/mg-card.spec.js +0 -43
  346. package/dist/collection/components/atoms/mg-card/test/mg-card.spec.js.map +0 -1
  347. package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.e2e.js +0 -15
  348. package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.e2e.js.map +0 -1
  349. package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.spec.js +0 -42
  350. package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.spec.js.map +0 -1
  351. package/dist/collection/components/atoms/mg-divider/test/mg-divider.e2e.js +0 -11
  352. package/dist/collection/components/atoms/mg-divider/test/mg-divider.e2e.js.map +0 -1
  353. package/dist/collection/components/atoms/mg-divider/test/mg-divider.spec.js +0 -14
  354. package/dist/collection/components/atoms/mg-divider/test/mg-divider.spec.js.map +0 -1
  355. package/dist/collection/components/atoms/mg-icon/test/mg-icon.e2e.js +0 -55
  356. package/dist/collection/components/atoms/mg-icon/test/mg-icon.e2e.js.map +0 -1
  357. package/dist/collection/components/atoms/mg-icon/test/mg-icon.spec.js +0 -84
  358. package/dist/collection/components/atoms/mg-icon/test/mg-icon.spec.js.map +0 -1
  359. package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.playwright.js +0 -12
  360. package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.playwright.js.map +0 -1
  361. package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.spec.js +0 -23
  362. package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.spec.js.map +0 -1
  363. package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.playwright.js +0 -23
  364. package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.playwright.js.map +0 -1
  365. package/dist/collection/components/atoms/mg-tag/test/mg-tag.spec.js +0 -71
  366. package/dist/collection/components/atoms/mg-tag/test/mg-tag.spec.js.map +0 -1
  367. package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.e2e.js +0 -138
  368. package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.e2e.js.map +0 -1
  369. package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js +0 -272
  370. package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js.map +0 -1
  371. package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.js +0 -237
  372. package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.js.map +0 -1
  373. package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js +0 -640
  374. package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js.map +0 -1
  375. package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.e2e.js +0 -123
  376. package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.e2e.js.map +0 -1
  377. package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js +0 -379
  378. package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js.map +0 -1
  379. package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.e2e.js +0 -212
  380. package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.e2e.js.map +0 -1
  381. package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js +0 -456
  382. package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js.map +0 -1
  383. package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.e2e.js +0 -115
  384. package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.e2e.js.map +0 -1
  385. package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js +0 -289
  386. package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js.map +0 -1
  387. package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.e2e.js +0 -154
  388. package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.e2e.js.map +0 -1
  389. package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.spec.js +0 -355
  390. package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.spec.js.map +0 -1
  391. package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.e2e.js +0 -194
  392. package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.e2e.js.map +0 -1
  393. package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js +0 -399
  394. package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js.map +0 -1
  395. package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.playwright.js +0 -147
  396. package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.playwright.js.map +0 -1
  397. package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js +0 -353
  398. package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js.map +0 -1
  399. package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.e2e.js +0 -129
  400. package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.e2e.js.map +0 -1
  401. package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js +0 -318
  402. package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js.map +0 -1
  403. package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.playwright.js +0 -108
  404. package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.playwright.js.map +0 -1
  405. package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js +0 -247
  406. package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js.map +0 -1
  407. package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.e2e.playwright.js +0 -239
  408. package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.e2e.playwright.js.map +0 -1
  409. package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.spec.js +0 -175
  410. package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.spec.js.map +0 -1
  411. package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.playwright.js +0 -100
  412. package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.playwright.js.map +0 -1
  413. package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.spec.js +0 -295
  414. package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.spec.js.map +0 -1
  415. package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.js +0 -128
  416. package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.js.map +0 -1
  417. package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.spec.js +0 -187
  418. package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.spec.js.map +0 -1
  419. package/dist/collection/components/molecules/mg-details/test/mg-details.e2e.playwright.js +0 -30
  420. package/dist/collection/components/molecules/mg-details/test/mg-details.e2e.playwright.js.map +0 -1
  421. package/dist/collection/components/molecules/mg-details/test/mg-details.spec.js +0 -42
  422. package/dist/collection/components/molecules/mg-details/test/mg-details.spec.js.map +0 -1
  423. package/dist/collection/components/molecules/mg-form/test/mg-form.e2e.js +0 -169
  424. package/dist/collection/components/molecules/mg-form/test/mg-form.e2e.js.map +0 -1
  425. package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js +0 -277
  426. package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js.map +0 -1
  427. package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.e2e.js +0 -39
  428. package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.e2e.js.map +0 -1
  429. package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.spec.js +0 -36
  430. package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.spec.js.map +0 -1
  431. package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.js +0 -85
  432. package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.js.map +0 -1
  433. package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.spec.js +0 -106
  434. package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.spec.js.map +0 -1
  435. package/dist/collection/components/molecules/mg-message/test/mg-message.e2e.js +0 -64
  436. package/dist/collection/components/molecules/mg-message/test/mg-message.e2e.js.map +0 -1
  437. package/dist/collection/components/molecules/mg-message/test/mg-message.spec.js +0 -109
  438. package/dist/collection/components/molecules/mg-message/test/mg-message.spec.js.map +0 -1
  439. package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js +0 -62
  440. package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js.map +0 -1
  441. package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.template.js +0 -40
  442. package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.template.js.map +0 -1
  443. package/dist/collection/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.js +0 -26
  444. package/dist/collection/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.js.map +0 -1
  445. package/dist/collection/components/molecules/mg-modal/test/mg-modal.spec.js +0 -122
  446. package/dist/collection/components/molecules/mg-modal/test/mg-modal.spec.js.map +0 -1
  447. package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.js +0 -57
  448. package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.js.map +0 -1
  449. package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.spec.js +0 -121
  450. package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.spec.js.map +0 -1
  451. package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js +0 -106
  452. package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js.map +0 -1
  453. package/dist/collection/components/molecules/mg-panel/test/mg-panel.spec.js +0 -213
  454. package/dist/collection/components/molecules/mg-panel/test/mg-panel.spec.js.map +0 -1
  455. package/dist/collection/components/molecules/mg-popover/test/mg-popover.e2e.playwright.js +0 -140
  456. package/dist/collection/components/molecules/mg-popover/test/mg-popover.e2e.playwright.js.map +0 -1
  457. package/dist/collection/components/molecules/mg-popover/test/mg-popover.spec.js +0 -142
  458. package/dist/collection/components/molecules/mg-popover/test/mg-popover.spec.js.map +0 -1
  459. package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.e2e.js +0 -55
  460. package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.e2e.js.map +0 -1
  461. package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.spec.js +0 -55
  462. package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.spec.js.map +0 -1
  463. package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.js +0 -76
  464. package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.js.map +0 -1
  465. package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.spec.js +0 -332
  466. package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.spec.js.map +0 -1
  467. package/dist/collection/utils/stencil.e2e.test.utils.js +0 -33
  468. package/dist/collection/utils/stencil.e2e.test.utils.js.map +0 -1
  469. package/dist/esm/components.utils-0f76010d.js.map +0 -1
  470. package/dist/esm/index-ce01e63b.js.map +0 -1
  471. package/dist/mg-components/p-01ebc95a.entry.js.map +0 -1
  472. package/dist/mg-components/p-1aa89acf.js +0 -3
  473. package/dist/mg-components/p-1aa89acf.js.map +0 -1
  474. package/dist/mg-components/p-71a5a848.entry.js +0 -2
  475. package/dist/mg-components/p-71a5a848.entry.js.map +0 -1
  476. package/dist/mg-components/p-c9e2c669.js +0 -2
  477. package/dist/mg-components/p-c9e2c669.js.map +0 -1
  478. package/dist/types/components/atoms/mg-badge/test/mg-badge.e2e.playwright.d.ts +0 -1
  479. package/dist/types/components/atoms/mg-input-title/test/mg-input-title.e2e.playwright.d.ts +0 -1
  480. package/dist/types/components/atoms/mg-tag/test/mg-tag.e2e.playwright.d.ts +0 -1
  481. package/dist/types/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.d.ts +0 -1
  482. package/dist/types/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.playwright.d.ts +0 -1
  483. package/dist/types/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.playwright.d.ts +0 -1
  484. package/dist/types/components/molecules/menu/mg-menu/test/mg-menu.e2e.playwright.d.ts +0 -1
  485. package/dist/types/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.playwright.d.ts +0 -1
  486. package/dist/types/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.d.ts +0 -2
  487. package/dist/types/components/molecules/mg-details/test/mg-details.e2e.playwright.d.ts +0 -1
  488. package/dist/types/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.d.ts +0 -1
  489. package/dist/types/components/molecules/mg-modal/test/mg-modal.e2e.playwright.d.ts +0 -1
  490. package/dist/types/components/molecules/mg-modal/test/mg-modal.e2e.template.d.ts +0 -12
  491. package/dist/types/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.d.ts +0 -1
  492. package/dist/types/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.d.ts +0 -1
  493. package/dist/types/components/molecules/mg-panel/test/mg-panel.e2e.playwright.d.ts +0 -1
  494. package/dist/types/components/molecules/mg-popover/test/mg-popover.e2e.playwright.d.ts +0 -1
  495. package/dist/types/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.d.ts +0 -1
  496. package/dist/types/utils/stencil.e2e.test.utils.d.ts +0 -14
@@ -1 +1 @@
1
- {"version":3,"file":"mg-tabs.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-tabs/mg-tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACxG,OAAO,EAAW,KAAK,EAAE,MAAM,EAAY,MAAM,gBAAgB,CAAC;AAElE;;;;GAIG;AACH,MAAM,SAAS,GAAG,CAAC,GAAY,EAAkB,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAQ,GAAe,CAAC,KAAK,KAAK,QAAQ,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CACK;MACR,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAC7B,eACE,GAAG,EAAE,GAAG,CAAC,KAAK,EACd,IAAI,EAAC,UAAU,EACf,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,EAC3C,MAAM,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,qBAC7B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,EAC1D,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACxD,KAAK,EAAC,8BAA8B;QAEpC,YAAM,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,KAAK,CAAC,GAAS,CACpD,CACX,CAAC,CACE,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, h, Prop, State, Element, Watch } from '@stencil/core';\nimport { createID, ClassList, allItemsAreString, isValidString } from '../../../utils/components.utils';\nimport { TabItem, sizes, Status, SizeType } from './mg-tabs.conf';\n\n/**\n * type TabItem validation function\n * @param tab - tab item\n * @returns tab item type is valid\n */\nconst isTabItem = (tab: unknown): tab is TabItem => typeof tab === 'object' && typeof (tab as TabItem).label === 'string';\n\n@Component({\n tag: 'mg-tabs',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-tabs.css',\n shadow: true,\n})\nexport class MgTabs {\n /************\n * Internal *\n ************/\n\n // classes\n private readonly tabPanel = 'panel';\n private readonly buttonTabBaseClass = 'mg-c-tabs__navigation-button';\n\n // variables\n private tabFocus: number;\n private startIndex = 1;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTabsElement;\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n * If not set, it will be created.\n */\n @Prop() identifier: string = createID('mg-tabs');\n\n /**\n * Tabs label. Include short tabs description.\n * Required for accessibility\n */\n @Prop() label!: string;\n @Watch('label')\n validateLabel(newValue: MgTabs['label']): void {\n if (!isValidString(newValue)) {\n throw new Error('<mg-tabs> prop \"label\" is required.');\n }\n }\n\n /**\n * Define tabs size\n */\n @Prop() size: SizeType = 'regular';\n @Watch('size')\n validateSize(newValue: MgTabs['size']): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<mg-tabs> prop \"size\" must be one of: ${sizes.join(', ')}`);\n }\n this.classCollection.add(`mg-c-tabs--size-${this.size}`);\n }\n\n /**\n * Tabs items\n */\n @Prop() items!: string[] | TabItem[];\n @Watch('items')\n validateItems(newValue: MgTabs['items']): void {\n // String array\n if (allItemsAreString(newValue)) this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));\n // Object array\n else if (Array.isArray(newValue) && newValue.length > 0 && newValue.every(isTabItem)) this.tabs = newValue;\n else throw new Error('<mg-tabs> prop \"items\" is required and all items must be the same type: TabItem.');\n }\n\n /**\n * Active tab number\n */\n @Prop({ reflect: true, mutable: true }) activeTab: number;\n @Watch('activeTab')\n validateActiveTab(newValue: MgTabs['activeTab']): void {\n // when `active-tab` is undefined we set default value by searching an item with `Status.ACTIVE` or we use the `startIndex` has fallback value\n // after setting new value to `active-tab` the validate will be triggered again with the updated value and process the tab update\n if (newValue === undefined) {\n this.activeTab = this.tabs.some(tab => this.tabHasStatus(tab, Status.ACTIVE))\n ? this.getTabItemIndex(this.tabs.findIndex(tab => this.tabHasStatus(tab, Status.ACTIVE)))\n : this.startIndex;\n } else if (typeof newValue === 'number' && newValue >= this.startIndex && newValue <= this.tabs.length && this.isActivableTab(this.tabs[newValue - this.startIndex])) {\n // if new 'active-tab' is activable we update tab status to ACTIVE and toggle past ACTIVE to VISIBLE\n this.tabs.forEach((tab, index) => {\n const isNewActiveTab = index === newValue - this.startIndex;\n // reset active tabs\n if (this.tabHasStatus(tab, Status.ACTIVE) && !isNewActiveTab) tab.status = Status.VISIBLE;\n // set active tab from given tab key\n else if (this.isActivableTab(tab) && isNewActiveTab) tab.status = Status.ACTIVE;\n });\n // emit change active tab key event\n this.activeTabChange.emit(newValue);\n } else {\n throw new Error(`<mg-tabs> prop \"activeTab\" must be a number between ${this.startIndex} and ${this.tabs.length} and new value must be \"activable\".`);\n }\n }\n\n /**\n * Component tabs\n */\n @State() tabs: TabItem[] = [];\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-tabs']);\n\n /**\n * Emited event when active tab change\n */\n @Event({ eventName: 'active-tab-change' }) activeTabChange: EventEmitter<number>;\n\n /**\n * Validate that new tab status can be `Status.ACTIVE`\n * @param tab - tab item\n * @returns true when tab match condition to get a `Status.ACTIVE`\n */\n private isActivableTab = (tab: TabItem): boolean => [undefined, Status.ACTIVE, Status.VISIBLE].includes(tab.status);\n\n /**\n * Method to know if given tab has the given status\n * @param tab - item tab key to set to ACTIVE status\n * @param status - status to valide\n * @returns status comparaison\n */\n private tabHasStatus = (tab: TabItem, status: Status): boolean => tab.status === status;\n\n /**\n * Method to get element id from index\n * @param element - to get id\n * @param index - to generate id\n * @returns generated element id\n */\n private getElementId = (element: string, index: number): string => `${element}-${this.getTabItemIndex(index)}`;\n\n /**\n * Method to get tab item index\n * @param index - to get\n * @returns index\n */\n private getTabItemIndex = (index: number): number => index + this.startIndex;\n\n /**\n * Handle click events on tabs\n * @param event - mouse event\n */\n private handleClick = (event: MouseEvent & { currentTarget: HTMLElement }): void => {\n const tabId = event.currentTarget.dataset.index;\n if (!this.isActivableTab(this.tabs[Number(tabId) - this.startIndex])) {\n event.preventDefault();\n } else {\n this.activeTab = Number(tabId);\n this.tabFocus = undefined;\n }\n };\n\n /**\n * get navigation button class from given status\n * @param status - button tab status\n * @returns button class/selector variant\n */\n private getNavigationButtonClass = (status: Status): string => `${this.buttonTabBaseClass}--${status}`;\n\n /**\n * Handle keyboard event on tabs\n * @param event - mouse event\n */\n private handleKeydown = (event: KeyboardEvent & { target: HTMLElement }): void => {\n const parent = event.target.parentElement;\n if (['ArrowRight', 'ArrowLeft'].includes(event.key)) {\n this.tabFocus = Number(event.target.dataset.index);\n parent.querySelector(`[data-index=\"${this.tabFocus}\"]`).setAttribute('tabindex', '-1');\n\n // Move right\n if (event.key === 'ArrowRight') {\n this.tabFocus++;\n // If we're at the end, go to the start\n if (this.tabFocus > this.tabs.length) this.tabFocus = this.startIndex;\n // Move left\n } else if (event.key === 'ArrowLeft') {\n this.tabFocus--;\n // If we're at the start, move to the end\n if (this.tabFocus < this.startIndex) this.tabFocus = this.tabs.length;\n }\n\n const parentButtonElement: HTMLButtonElement = parent.querySelector(`[data-index=\"${this.tabFocus}\"]`);\n // if focus item is ['hidden'] we recursively repeat action\n if (this.tabHasStatus(this.tabs[this.tabFocus - 1], Status.HIDDEN)) {\n parentButtonElement.dispatchEvent(new KeyboardEvent('keydown', { key: event.key, bubbles: true }));\n // else run focus methods on tabFocus element\n } else {\n parentButtonElement.setAttribute('tabindex', '0');\n parentButtonElement.focus();\n }\n } else if (event.key === 'Tab') {\n this.resetFocus();\n }\n };\n\n /**\n * Method to reset focus behavior\n */\n private resetFocus = (): void => {\n // update asynchronously tabindex to prevent get focus on new tabindex at then end of event process\n setTimeout(() => {\n this.tabFocus = undefined;\n Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {\n tab.setAttribute('tabindex', this.activeTab - this.startIndex !== index ? '-1' : '0');\n });\n }, 0);\n };\n\n /**\n * Validate slots setting\n */\n private validateSlots = (): void => {\n const slots = Array.from(this.element.children).filter(slot => slot.getAttribute('slot')?.includes('tab_content-'));\n if (slots.length !== this.tabs.length) throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Check tabs format\n this.validateLabel(this.label);\n this.validateItems(this.items);\n this.validateActiveTab(this.activeTab);\n this.validateSize(this.size);\n this.validateSlots();\n }\n\n /**\n * add listners\n */\n componentDidLoad(): void {\n document.addEventListener(\n 'click',\n (event: MouseEvent & { target: HTMLElement }) => {\n if (event.target.closest('mg-tabs') !== this.element) this.resetFocus();\n },\n false,\n );\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <div class={this.classCollection.join()}>\n <header role=\"tablist\" aria-label={this.label} class=\"mg-c-tabs__header\">\n {this.tabs.map((tab, index) => (\n <button\n key={tab.label}\n role=\"tab\"\n id={this.getElementId(this.identifier, index)}\n class={{\n [`${this.buttonTabBaseClass}`]: true,\n [`${this.buttonTabBaseClass}--horizontal`]: true,\n [`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),\n [`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasStatus(tab, Status.DISABLED),\n [`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasStatus(tab, Status.HIDDEN),\n }}\n tabindex={this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1}\n aria-selected={this.tabHasStatus(tab, Status.ACTIVE).toString()}\n aria-controls={this.getElementId(this.tabPanel, index)}\n aria-disabled={this.tabHasStatus(tab, Status.DISABLED)}\n onClick={this.handleClick}\n onKeyDown={this.handleKeydown}\n data-index={this.getTabItemIndex(index)}\n >\n {tab.icon !== undefined && <mg-icon icon={tab.icon}></mg-icon>}\n {tab.label}\n {tab.badge !== undefined && <mg-badge variant=\"text-color\" value={tab.badge.value} label={tab.badge.label} outline={tab.badge.role === 'information'}></mg-badge>}\n </button>\n ))}\n </header>\n {this.tabs.map((tab, index) => (\n <article\n key={tab.label}\n role=\"tabpanel\"\n id={this.getElementId(this.tabPanel, index)}\n hidden={!this.tabHasStatus(tab, Status.ACTIVE)}\n aria-labelledby={this.getElementId(this.identifier, index)}\n tabindex={this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1}\n class=\"mg-c-tabs__content-container\"\n >\n <slot name={this.getElementId('tab_content', index)}></slot>\n </article>\n ))}\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"mg-tabs.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-tabs/mg-tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAClH,OAAO,EAAW,KAAK,EAAE,MAAM,EAAY,MAAM,gBAAgB,CAAC;AAElE;;;;GAIG;AACH,MAAM,SAAS,GAAG,CAAC,GAAY,EAAkB,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAQ,GAAe,CAAC,KAAK,KAAK,QAAQ,CAAC;AAO1H,MAAM,OAAO,MAAM;;QACjB;;sBAEc;QAEd,UAAU;QACO,aAAQ,GAAG,OAAO,CAAC;QACnB,uBAAkB,GAAG,8BAA8B,CAAC;QAI7D,eAAU,GAAG,CAAC,CAAC;QAiGvB;;;;WAIG;QACK,mBAAc,GAAG,CAAC,GAAY,EAAW,EAAE,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEpH;;;;;WAKG;QACK,iBAAY,GAAG,CAAC,GAAY,EAAE,MAAc,EAAW,EAAE,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AI,CAAC,UAAU,EAAE,KAAK,CAAC,EAC1D,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACxD,KAAK,EAAC,8BAA8B;gBAEpC,YAAM,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,KAAK,CAAC,GAAS,CACpD,CACX,CAAC,CACE,CACP,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, h, Prop, State, Element, Watch } from '@stencil/core';\nimport { createID, ClassList, allItemsAreString, isValidString, nextTick } from '../../../utils/components.utils';\nimport { TabItem, sizes, Status, SizeType } from './mg-tabs.conf';\n\n/**\n * type TabItem validation function\n * @param tab - tab item\n * @returns tab item type is valid\n */\nconst isTabItem = (tab: unknown): tab is TabItem => typeof tab === 'object' && typeof (tab as TabItem).label === 'string';\n\n@Component({\n tag: 'mg-tabs',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-tabs.css',\n shadow: true,\n})\nexport class MgTabs {\n /************\n * Internal *\n ************/\n\n // classes\n private readonly tabPanel = 'panel';\n private readonly buttonTabBaseClass = 'mg-c-tabs__navigation-button';\n\n // variables\n private tabFocus: number;\n private startIndex = 1;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTabsElement;\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n * If not set, it will be created.\n */\n @Prop() identifier: string = createID('mg-tabs');\n\n /**\n * Tabs label. Include short tabs description.\n * Required for accessibility\n */\n @Prop() label!: string;\n @Watch('label')\n validateLabel(newValue: MgTabs['label']): void {\n if (!isValidString(newValue)) {\n throw new Error('<mg-tabs> prop \"label\" is required.');\n }\n }\n\n /**\n * Define tabs size\n */\n @Prop() size: SizeType = 'regular';\n @Watch('size')\n validateSize(newValue: MgTabs['size']): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<mg-tabs> prop \"size\" must be one of: ${sizes.join(', ')}`);\n }\n this.classCollection.add(`mg-c-tabs--size-${this.size}`);\n }\n\n /**\n * Tabs items\n */\n @Prop() items!: string[] | TabItem[];\n @Watch('items')\n validateItems(newValue: MgTabs['items']): void {\n // String array\n if (allItemsAreString(newValue)) this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));\n // Object array\n else if (Array.isArray(newValue) && newValue.length > 0 && newValue.every(isTabItem)) this.tabs = newValue;\n else throw new Error('<mg-tabs> prop \"items\" is required and all items must be the same type: TabItem.');\n }\n\n /**\n * Active tab number\n */\n @Prop({ reflect: true, mutable: true }) activeTab: number;\n @Watch('activeTab')\n validateActiveTab(newValue: MgTabs['activeTab']): void {\n // when `active-tab` is undefined we set default value by searching an item with `Status.ACTIVE` or we use the `startIndex` has fallback value\n // after setting new value to `active-tab` the validate will be triggered again with the updated value and process the tab update\n if (newValue === undefined) {\n this.activeTab = this.tabs.some(tab => this.tabHasStatus(tab, Status.ACTIVE))\n ? this.getTabItemIndex(this.tabs.findIndex(tab => this.tabHasStatus(tab, Status.ACTIVE)))\n : this.startIndex;\n } else if (typeof newValue === 'number' && newValue >= this.startIndex && newValue <= this.tabs.length && this.isActivableTab(this.tabs[newValue - this.startIndex])) {\n // if new 'active-tab' is activable we update tab status to ACTIVE and toggle past ACTIVE to VISIBLE\n this.tabs.forEach((tab, index) => {\n const isNewActiveTab = index === newValue - this.startIndex;\n // reset active tabs\n if (this.tabHasStatus(tab, Status.ACTIVE) && !isNewActiveTab) tab.status = Status.VISIBLE;\n // set active tab from given tab key\n else if (this.isActivableTab(tab) && isNewActiveTab) tab.status = Status.ACTIVE;\n });\n // emit change active tab key event\n this.activeTabChange.emit(newValue);\n } else {\n throw new Error(`<mg-tabs> prop \"activeTab\" must be a number between ${this.startIndex} and ${this.tabs.length} and new value must be \"activable\".`);\n }\n }\n\n /**\n * Component tabs\n */\n @State() tabs: TabItem[] = [];\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-tabs']);\n\n /**\n * Emited event when active tab change\n */\n @Event({ eventName: 'active-tab-change' }) activeTabChange: EventEmitter<HTMLMgTabsElement['activeTab']>;\n\n /**\n * Validate that new tab status can be `Status.ACTIVE`\n * @param tab - tab item\n * @returns true when tab match condition to get a `Status.ACTIVE`\n */\n private isActivableTab = (tab: TabItem): boolean => [undefined, Status.ACTIVE, Status.VISIBLE].includes(tab.status);\n\n /**\n * Method to know if given tab has the given status\n * @param tab - item tab key to set to ACTIVE status\n * @param status - status to valide\n * @returns status comparaison\n */\n private tabHasStatus = (tab: TabItem, status: Status): boolean => tab.status === status;\n\n /**\n * Method to get element id from index\n * @param element - to get id\n * @param index - to generate id\n * @returns generated element id\n */\n private getElementId = (element: string, index: number): string => `${element}-${this.getTabItemIndex(index)}`;\n\n /**\n * Method to get tab item index\n * @param index - to get\n * @returns index\n */\n private getTabItemIndex = (index: number): number => index + this.startIndex;\n\n /**\n * Handle click events on tabs\n * @param event - mouse event\n */\n private handleClick = (event: MouseEvent & { currentTarget: HTMLElement }): void => {\n const tabId = event.currentTarget.dataset.index;\n if (!this.isActivableTab(this.tabs[Number(tabId) - this.startIndex])) {\n event.preventDefault();\n } else {\n this.activeTab = Number(tabId);\n this.tabFocus = undefined;\n }\n };\n\n /**\n * get navigation button class from given status\n * @param status - button tab status\n * @returns button class/selector variant\n */\n private getNavigationButtonClass = (status: Status): string => `${this.buttonTabBaseClass}--${status}`;\n\n /**\n * Handle keyboard event on tabs\n * @param event - mouse event\n */\n private handleKeydown = (event: KeyboardEvent & { target: HTMLElement }): void => {\n const parent = event.target.parentElement;\n if (['ArrowRight', 'ArrowLeft'].includes(event.key)) {\n this.tabFocus = Number(event.target.dataset.index);\n parent.querySelector(`[data-index=\"${this.tabFocus}\"]`).setAttribute('tabindex', '-1');\n\n // Move right\n if (event.key === 'ArrowRight') {\n this.tabFocus++;\n // If we're at the end, go to the start\n if (this.tabFocus > this.tabs.length) this.tabFocus = this.startIndex;\n // Move left\n } else if (event.key === 'ArrowLeft') {\n this.tabFocus--;\n // If we're at the start, move to the end\n if (this.tabFocus < this.startIndex) this.tabFocus = this.tabs.length;\n }\n\n const parentButtonElement: HTMLButtonElement = parent.querySelector(`[data-index=\"${this.tabFocus}\"]`);\n // if focus item is ['hidden'] we recursively repeat action\n if (this.tabHasStatus(this.tabs[this.tabFocus - 1], Status.HIDDEN)) {\n parentButtonElement.dispatchEvent(new KeyboardEvent('keydown', { key: event.key, bubbles: true }));\n // else run focus methods on tabFocus element\n } else {\n parentButtonElement.setAttribute('tabindex', '0');\n parentButtonElement.focus();\n }\n } else if (event.key === 'Tab') {\n this.resetFocus();\n }\n };\n\n /**\n * Method to reset focus behavior\n */\n private resetFocus = (): void => {\n // update asynchronously tabindex to prevent get focus on new tabindex at then end of event process\n nextTick(() => {\n this.tabFocus = undefined;\n Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {\n tab.setAttribute('tabindex', this.activeTab - this.startIndex !== index ? '-1' : '0');\n });\n });\n };\n\n /**\n * Validate slots setting\n */\n private validateSlots = (): void => {\n const slots = Array.from(this.element.children).filter(slot => slot.getAttribute('slot')?.includes('tab_content-'));\n if (slots.length !== this.tabs.length) throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Check tabs format\n this.validateLabel(this.label);\n this.validateItems(this.items);\n this.validateActiveTab(this.activeTab);\n this.validateSize(this.size);\n this.validateSlots();\n }\n\n /**\n * add listners\n */\n componentDidLoad(): void {\n document.addEventListener(\n 'click',\n (event: MouseEvent & { target: HTMLElement }) => {\n if (event.target.closest('mg-tabs') !== this.element) this.resetFocus();\n },\n false,\n );\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <div class={this.classCollection.join()}>\n <header role=\"tablist\" aria-label={this.label} class=\"mg-c-tabs__header\">\n {this.tabs.map((tab, index) => (\n <button\n key={tab.label}\n role=\"tab\"\n id={this.getElementId(this.identifier, index)}\n class={{\n [`${this.buttonTabBaseClass}`]: true,\n [`${this.buttonTabBaseClass}--horizontal`]: true,\n [`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),\n [`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasStatus(tab, Status.DISABLED),\n [`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasStatus(tab, Status.HIDDEN),\n }}\n tabindex={this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1}\n aria-selected={this.tabHasStatus(tab, Status.ACTIVE).toString()}\n aria-controls={this.getElementId(this.tabPanel, index)}\n aria-disabled={this.tabHasStatus(tab, Status.DISABLED)}\n onClick={this.handleClick}\n onKeyDown={this.handleKeydown}\n data-index={this.getTabItemIndex(index)}\n >\n {tab.icon !== undefined && <mg-icon icon={tab.icon}></mg-icon>}\n {tab.label}\n {tab.badge !== undefined && <mg-badge variant=\"text-color\" value={tab.badge.value} label={tab.badge.label} outline={tab.badge.role === 'information'}></mg-badge>}\n </button>\n ))}\n </header>\n {this.tabs.map((tab, index) => (\n <article\n key={tab.label}\n role=\"tabpanel\"\n id={this.getElementId(this.tabPanel, index)}\n hidden={!this.tabHasStatus(tab, Status.ACTIVE)}\n aria-labelledby={this.getElementId(this.identifier, index)}\n tabindex={this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1}\n class=\"mg-c-tabs__content-container\"\n >\n <slot name={this.getElementId('tab_content', index)}></slot>\n </article>\n ))}\n </div>\n );\n }\n}\n"]}
@@ -25,10 +25,10 @@
25
25
  "selectButton": "Sélectionner des valeurs",
26
26
  "showButton": "Voir",
27
27
  "label": "Saisissez une valeur",
28
- "result": "resultat",
29
- "results": "resultats",
30
- "searchResults": "List de resultat(s) de la recherche.",
31
- "noResult": "Aucun resultat.",
28
+ "result": "résultat",
29
+ "results": "résultats",
30
+ "searchResults": "List de résultat(s) de la recherche.",
31
+ "noResult": "Aucun résultat.",
32
32
  "sections": {
33
33
  "selected": {
34
34
  "title": "Sélectionné",
@@ -2,26 +2,26 @@ import { initLocales } from ".";
2
2
  import messagesEn from "./en/messages.json";
3
3
  import messagesFr from "./fr/messages.json";
4
4
  describe('locales', () => {
5
- describe('initLocales', () => {
6
- test('Should return default locale', () => {
7
- const locales = initLocales(document.createElement('div'));
8
- expect(locales.locale).toEqual('en');
9
- expect(locales.messages).toMatchObject(messagesEn);
5
+ describe('initLocales', () => {
6
+ test('Should return default locale', () => {
7
+ const locales = initLocales(document.createElement('div'));
8
+ expect(locales.locale).toEqual('en');
9
+ expect(locales.messages).toMatchObject(messagesEn);
10
+ });
11
+ test('Should return matching locale', () => {
12
+ const div = document.createElement('div');
13
+ div.lang = 'fr-FR';
14
+ const locales = initLocales(div);
15
+ expect(locales.locale).toEqual(div.lang);
16
+ expect(locales.messages).toMatchObject(messagesFr);
17
+ });
18
+ test('Should return default locale messages when requested does not exist', () => {
19
+ const div = document.createElement('div');
20
+ div.lang = 'ca';
21
+ const locales = initLocales(div);
22
+ expect(locales.locale).toEqual(div.lang);
23
+ expect(locales.messages).toMatchObject(messagesEn);
24
+ });
10
25
  });
11
- test('Should return matching locale', () => {
12
- const div = document.createElement('div');
13
- div.lang = 'fr-FR';
14
- const locales = initLocales(div);
15
- expect(locales.locale).toEqual(div.lang);
16
- expect(locales.messages).toMatchObject(messagesFr);
17
- });
18
- test('Should return default locale messages when requested does not exist', () => {
19
- const div = document.createElement('div');
20
- div.lang = 'ca';
21
- const locales = initLocales(div);
22
- expect(locales.locale).toEqual(div.lang);
23
- expect(locales.messages).toMatchObject(messagesEn);
24
- });
25
- });
26
26
  });
27
27
  //# sourceMappingURL=index.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../src/locales/index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;AAChC,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAE5C,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;EACvB,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,CAAC,8BAA8B,EAAE,GAAG,EAAE;MACxC,MAAM,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;MAC3D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;MACrC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE;MACzC,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;MAC1C,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC;MACnB,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;MACjC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;MACzC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,qEAAqE,EAAE,GAAG,EAAE;MAC/E,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;MAC1C,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;MAChB,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;MACjC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;MACzC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initLocales } from '.';\nimport messagesEn from './en/messages.json';\nimport messagesFr from './fr/messages.json';\n\ndescribe('locales', () => {\n describe('initLocales', () => {\n test('Should return default locale', () => {\n const locales = initLocales(document.createElement('div'));\n expect(locales.locale).toEqual('en');\n expect(locales.messages).toMatchObject(messagesEn);\n });\n\n test('Should return matching locale', () => {\n const div = document.createElement('div');\n div.lang = 'fr-FR';\n const locales = initLocales(div);\n expect(locales.locale).toEqual(div.lang);\n expect(locales.messages).toMatchObject(messagesFr);\n });\n\n test('Should return default locale messages when requested does not exist', () => {\n const div = document.createElement('div');\n div.lang = 'ca';\n const locales = initLocales(div);\n expect(locales.locale).toEqual(div.lang);\n expect(locales.messages).toMatchObject(messagesEn);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../src/locales/index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;AAChC,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAE5C,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;QAC3B,IAAI,CAAC,8BAA8B,EAAE,GAAG,EAAE;YACxC,MAAM,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACrC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACzC,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC1C,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC;YACnB,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YACjC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACzC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,qEAAqE,EAAE,GAAG,EAAE;YAC/E,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC1C,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;YAChB,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YACjC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACzC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initLocales } from '.';\nimport messagesEn from './en/messages.json';\nimport messagesFr from './fr/messages.json';\n\ndescribe('locales', () => {\n describe('initLocales', () => {\n test('Should return default locale', () => {\n const locales = initLocales(document.createElement('div'));\n expect(locales.locale).toEqual('en');\n expect(locales.messages).toMatchObject(messagesEn);\n });\n\n test('Should return matching locale', () => {\n const div = document.createElement('div');\n div.lang = 'fr-FR';\n const locales = initLocales(div);\n expect(locales.locale).toEqual(div.lang);\n expect(locales.messages).toMatchObject(messagesFr);\n });\n\n test('Should return default locale messages when requested does not exist', () => {\n const div = document.createElement('div');\n div.lang = 'ca';\n const locales = initLocales(div);\n expect(locales.locale).toEqual(div.lang);\n expect(locales.messages).toMatchObject(messagesEn);\n });\n });\n});\n"]}
@@ -6,136 +6,136 @@
6
6
  const isMgItemMore = (element) => element.nodeName === 'MG-ITEM-MORE';
7
7
  export var OverflowBehaviorElements;
8
8
  (function (OverflowBehaviorElements) {
9
- OverflowBehaviorElements["BASE_INDEX"] = "data-overflow-base-index";
10
- OverflowBehaviorElements["PROXY_INDEX"] = "data-overflow-proxy-index";
9
+ OverflowBehaviorElements["BASE_INDEX"] = "data-overflow-base-index";
10
+ OverflowBehaviorElements["PROXY_INDEX"] = "data-overflow-proxy-index";
11
11
  })(OverflowBehaviorElements || (OverflowBehaviorElements = {}));
12
12
  export class OverflowBehavior {
13
- constructor(element, render) {
14
- this.element = element;
15
- this.render = render;
16
- /**********
17
- * Public *
18
- **********/
19
- /**
20
- * Disconnect ResizeObserver
21
- */
22
- this.disconnect = () => {
23
- this._resizeObserver.disconnect();
24
- };
25
- /************
26
- * Internal *
27
- ************/
28
- /**
29
- * run overflow behavior
30
- * @param width - width of the container. Optional.
31
- */
32
- this.run = (width) => {
33
- if (this._moreElement === undefined) {
34
- // set moreElement
35
- this._moreElement = this.render();
36
- // set children
37
- this._baseChildren = this.getInteractiveItems(this.element);
38
- if (isMgItemMore(this._moreElement)) {
39
- this._proxyChildren = this.getInteractiveItems(this._moreElement.shadowRoot.querySelector('mg-menu'));
13
+ constructor(element, render) {
14
+ this.element = element;
15
+ this.render = render;
16
+ /**********
17
+ * Public *
18
+ **********/
19
+ /**
20
+ * Disconnect ResizeObserver
21
+ */
22
+ this.disconnect = () => {
23
+ this._resizeObserver.disconnect();
24
+ };
25
+ /************
26
+ * Internal *
27
+ ************/
28
+ /**
29
+ * run overflow behavior
30
+ * @param width - width of the container. Optional.
31
+ */
32
+ this.run = (width) => {
33
+ if (this._moreElement === undefined) {
34
+ // set moreElement
35
+ this._moreElement = this.render();
36
+ // set children
37
+ this._baseChildren = this.getInteractiveItems(this.element);
38
+ if (isMgItemMore(this._moreElement)) {
39
+ this._proxyChildren = this.getInteractiveItems(this._moreElement.shadowRoot.querySelector('mg-menu'));
40
+ }
41
+ // update children
42
+ this._baseChildren.forEach((child, index) => {
43
+ child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);
44
+ // set moreElement children
45
+ this._proxyChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);
46
+ });
47
+ }
48
+ if (width !== undefined)
49
+ this.updateDisplayedItems(width);
50
+ };
51
+ /**
52
+ * Get interactive children filtred by authorized nodeName ['MG-MENU-ITEM', 'MG-BUTTON']
53
+ * @param element - element to parse
54
+ * @returns children
55
+ */
56
+ this.getInteractiveItems = (element) => { var _a; return (((_a = element.children) === null || _a === void 0 ? void 0 : _a.length) > 0 ? Array.from(element.children) : []).filter(element => ['MG-MENU-ITEM', 'MG-BUTTON'].includes(element.nodeName)); };
57
+ /**
58
+ * Update displayed items in container from a given available space
59
+ * @param availableWidth - available width in container to display child items
60
+ */
61
+ this.updateDisplayedItems = (availableWidth) => {
62
+ this.restoreItems();
63
+ const acc = { accWidth: 0, previousItem: null };
64
+ [...this._baseChildren, this._moreElement].forEach((child) => {
65
+ acc.accWidth += child.offsetWidth;
66
+ const hasPreviuosItem = acc.previousItem !== null;
67
+ const isPreviousItemHidden = hasPreviuosItem && acc.previousItem.getAttribute('hidden') !== null;
68
+ // if previous item is hidden AND is NOT more element we hidde current
69
+ // OR if item has an overflow we hidde current
70
+ // OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item
71
+ // ELSE current is a display item
72
+ this.toggleItem(child, (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden));
73
+ // update previous item with current item
74
+ acc.previousItem = child;
75
+ });
76
+ };
77
+ /**
78
+ * Utility method to know if item overflow partialy or totaly in the container
79
+ * @param cumulateWidth - previous sibling elements cumulate width + item width
80
+ * @param item - item HTML element
81
+ * @param availableWidth - container available width
82
+ * @returns truthy if element is overflow
83
+ */
84
+ this.isOverflowElement = (cumulateWidth, item, availableWidth) => {
85
+ if (item.previousElementSibling === null || this.isMoreElement(item))
86
+ return false;
87
+ else if (!this.isMoreElement(item.nextElementSibling))
88
+ return cumulateWidth + this._moreElement.offsetWidth > availableWidth;
89
+ else
90
+ return cumulateWidth > availableWidth;
91
+ };
92
+ /**
93
+ * Utility method to know if a given element is the 'MORE' element
94
+ * @param element - element to match with 'MORE' element
95
+ * @returns truthy if element is the 'MORE' element
96
+ */
97
+ this.isMoreElement = (element) => element.nodeName === 'MG-ITEM-MORE';
98
+ /**
99
+ * Toggle display item element
100
+ * @param item - item to control
101
+ * @param isHidden - is item hidden
102
+ */
103
+ this.toggleItem = (item, isHidden) => {
104
+ const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));
105
+ if (this.isMoreElement(item))
106
+ this.toggleElement(this._moreElement, isHidden);
107
+ else if (mgActionMenuindex >= 0) {
108
+ this.toggleElement(item, isHidden);
109
+ this.toggleElement(this._proxyChildren[mgActionMenuindex], !isHidden);
110
+ }
111
+ };
112
+ /**
113
+ * Toggle element's hidde attribute
114
+ * @param element - element to toggle
115
+ * @param isHidden - element is hidden
116
+ */
117
+ this.toggleElement = (element, isHidden) => {
118
+ if (isHidden)
119
+ element.setAttribute('hidden', '');
120
+ else
121
+ element.removeAttribute('hidden');
122
+ };
123
+ /**
124
+ * Remove hidden attributes on all items
125
+ */
126
+ this.restoreItems = () => {
127
+ [...this._baseChildren, this._moreElement].forEach(item => item.removeAttribute('hidden'));
128
+ };
129
+ if (this._resizeObserver === undefined) {
130
+ // add resize observer
131
+ this._resizeObserver = new ResizeObserver(entries => {
132
+ entries.forEach(entry => {
133
+ this.run(entry.contentRect.width);
134
+ });
135
+ });
136
+ this._resizeObserver.observe(this.element);
40
137
  }
41
- // update children
42
- this._baseChildren.forEach((child, index) => {
43
- child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);
44
- // set moreElement children
45
- this._proxyChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);
46
- });
47
- }
48
- if (width !== undefined)
49
- this.updateDisplayedItems(width);
50
- };
51
- /**
52
- * Get interactive children filtred by authorized nodeName ['MG-MENU-ITEM', 'MG-BUTTON']
53
- * @param element - element to parse
54
- * @returns children
55
- */
56
- this.getInteractiveItems = (element) => { var _a; return (((_a = element.children) === null || _a === void 0 ? void 0 : _a.length) > 0 ? Array.from(element.children) : []).filter(element => ['MG-MENU-ITEM', 'MG-BUTTON'].includes(element.nodeName)); };
57
- /**
58
- * Update displayed items in container from a given available space
59
- * @param availableWidth - available width in container to display child items
60
- */
61
- this.updateDisplayedItems = (availableWidth) => {
62
- this.restoreItems();
63
- const acc = { accWidth: 0, previousItem: null };
64
- [...this._baseChildren, this._moreElement].forEach((child) => {
65
- acc.accWidth += child.offsetWidth;
66
- const hasPreviuosItem = acc.previousItem !== null;
67
- const isPreviousItemHidden = hasPreviuosItem && acc.previousItem.getAttribute('hidden') !== null;
68
- // if previous item is hidden AND is NOT more element we hidde current
69
- // OR if item has an overflow we hidde current
70
- // OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item
71
- // ELSE current is a display item
72
- this.toggleItem(child, (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden));
73
- // update previous item with current item
74
- acc.previousItem = child;
75
- });
76
- };
77
- /**
78
- * Utility method to know if item overflow partialy or totaly in the container
79
- * @param cumulateWidth - previous sibling elements cumulate width + item width
80
- * @param item - item HTML element
81
- * @param availableWidth - container available width
82
- * @returns truthy if element is overflow
83
- */
84
- this.isOverflowElement = (cumulateWidth, item, availableWidth) => {
85
- if (item.previousElementSibling === null || this.isMoreElement(item))
86
- return false;
87
- else if (!this.isMoreElement(item.nextElementSibling))
88
- return cumulateWidth + this._moreElement.offsetWidth > availableWidth;
89
- else
90
- return cumulateWidth > availableWidth;
91
- };
92
- /**
93
- * Utility method to know if a given element is the 'MORE' element
94
- * @param element - element to match with 'MORE' element
95
- * @returns truthy if element is the 'MORE' element
96
- */
97
- this.isMoreElement = (element) => element.nodeName === 'MG-ITEM-MORE';
98
- /**
99
- * Toggle display item element
100
- * @param item - item to control
101
- * @param isHidden - is item hidden
102
- */
103
- this.toggleItem = (item, isHidden) => {
104
- const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));
105
- if (this.isMoreElement(item))
106
- this.toggleElement(this._moreElement, isHidden);
107
- else if (mgActionMenuindex >= 0) {
108
- this.toggleElement(item, isHidden);
109
- this.toggleElement(this._proxyChildren[mgActionMenuindex], !isHidden);
110
- }
111
- };
112
- /**
113
- * Toggle element's hidde attribute
114
- * @param element - element to toggle
115
- * @param isHidden - element is hidden
116
- */
117
- this.toggleElement = (element, isHidden) => {
118
- if (isHidden)
119
- element.setAttribute('hidden', '');
120
- else
121
- element.removeAttribute('hidden');
122
- };
123
- /**
124
- * Remove hidden attributes on all items
125
- */
126
- this.restoreItems = () => {
127
- [...this._baseChildren, this._moreElement].forEach(item => item.removeAttribute('hidden'));
128
- };
129
- if (this._resizeObserver === undefined) {
130
- // add resize observer
131
- this._resizeObserver = new ResizeObserver(entries => {
132
- entries.forEach(entry => {
133
- this.run(entry.contentRect.width);
134
- });
135
- });
136
- this._resizeObserver.observe(this.element);
138
+ this.run();
137
139
  }
138
- this.run();
139
- }
140
140
  }
141
141
  //# sourceMappingURL=behaviors.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"behaviors.utils.js","sourceRoot":"","sources":["../../src/utils/behaviors.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,YAA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QAAQ,CAAC,CAAC;OACvE;IACH,CAAC,CAAC;IAEF;;;;OAIG;IACK,kBAAa,GAAG,CAAC,OAAgB,EAAE,QAAiB,EAAQ,EAAE;MACpE,IAAI,QAAQ;QAAE,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;;QAC5C,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC,CAAC;IAEF;;OAEG;IACK,iBAAY,GAAG,GAAS,EAAE;MAChC,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7F,CAAC,CAAC;IAvIA,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE;MACtC,sBAAsB;MACtB,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;QAClD,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;UACtB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;MACL,CAAC,CAAC,CAAC;MACH,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAC5C;IACD,IAAI,CAAC,GAAG,EAAE,CAAC;EACb,CAAC;CA8HF","sourcesContent":["/**\n * MgItemMore type guard\n * @param element - element to control type\n * @returns truthy if element is mg-item-more\n */\nconst isMgItemMore = (element: HTMLElement): element is HTMLMgItemMoreElement => element.nodeName === 'MG-ITEM-MORE';\n\nexport enum OverflowBehaviorElements {\n BASE_INDEX = 'data-overflow-base-index',\n PROXY_INDEX = 'data-overflow-proxy-index',\n}\n\nexport class OverflowBehavior {\n // variables\n private _resizeObserver: ResizeObserver;\n private _moreElement: HTMLElement;\n private _baseChildren: Element[];\n private _proxyChildren: Element[];\n\n constructor(private element: Element, private render: () => HTMLElement) {\n if (this._resizeObserver === undefined) {\n // add resize observer\n this._resizeObserver = new ResizeObserver(entries => {\n entries.forEach(entry => {\n this.run(entry.contentRect.width);\n });\n });\n this._resizeObserver.observe(this.element);\n }\n this.run();\n }\n\n /**********\n * Public *\n **********/\n\n /**\n * Disconnect ResizeObserver\n */\n public disconnect = (): void => {\n this._resizeObserver.disconnect();\n };\n\n /************\n * Internal *\n ************/\n\n /**\n * run overflow behavior\n * @param width - width of the container. Optional.\n */\n private run = (width?: number): void => {\n if (this._moreElement === undefined) {\n // set moreElement\n this._moreElement = this.render();\n\n // set children\n this._baseChildren = this.getInteractiveItems(this.element);\n if (isMgItemMore(this._moreElement)) {\n this._proxyChildren = this.getInteractiveItems(this._moreElement.shadowRoot.querySelector('mg-menu'));\n }\n\n // update children\n this._baseChildren.forEach((child, index) => {\n child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);\n // set moreElement children\n this._proxyChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);\n });\n }\n\n if (width !== undefined) this.updateDisplayedItems(width);\n };\n\n /**\n * Get interactive children filtred by authorized nodeName ['MG-MENU-ITEM', 'MG-BUTTON']\n * @param element - element to parse\n * @returns children\n */\n private getInteractiveItems = (element: Element) =>\n (element.children?.length > 0 ? Array.from(element.children) : []).filter(element => ['MG-MENU-ITEM', 'MG-BUTTON'].includes(element.nodeName));\n\n /**\n * Update displayed items in container from a given available space\n * @param availableWidth - available width in container to display child items\n */\n private updateDisplayedItems = (availableWidth: number): void => {\n this.restoreItems();\n const acc = { accWidth: 0, previousItem: null };\n [...this._baseChildren, this._moreElement].forEach((child: HTMLMgMenuItemElement | HTMLMgItemMoreElement) => {\n acc.accWidth += child.offsetWidth;\n const hasPreviuosItem = acc.previousItem !== null;\n const isPreviousItemHidden = hasPreviuosItem && acc.previousItem.getAttribute('hidden') !== null;\n // if previous item is hidden AND is NOT more element we hidde current\n // OR if item has an overflow we hidde current\n // OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item\n // ELSE current is a display item\n this.toggleItem(\n child,\n (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden),\n );\n\n // update previous item with current item\n acc.previousItem = child;\n });\n };\n\n /**\n * Utility method to know if item overflow partialy or totaly in the container\n * @param cumulateWidth - previous sibling elements cumulate width + item width\n * @param item - item HTML element\n * @param availableWidth - container available width\n * @returns truthy if element is overflow\n */\n private isOverflowElement = (cumulateWidth: number, item: HTMLElement, availableWidth: number): boolean => {\n if (item.previousElementSibling === null || this.isMoreElement(item)) return false;\n else if (!this.isMoreElement(item.nextElementSibling)) return cumulateWidth + this._moreElement.offsetWidth > availableWidth;\n else return cumulateWidth > availableWidth;\n };\n\n /**\n * Utility method to know if a given element is the 'MORE' element\n * @param element - element to match with 'MORE' element\n * @returns truthy if element is the 'MORE' element\n */\n private isMoreElement = (element: Element): boolean => element.nodeName === 'MG-ITEM-MORE';\n\n /**\n * Toggle display item element\n * @param item - item to control\n * @param isHidden - is item hidden\n */\n private toggleItem = (item: HTMLElement, isHidden: boolean): void => {\n const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));\n if (this.isMoreElement(item)) this.toggleElement(this._moreElement, isHidden);\n else if (mgActionMenuindex >= 0) {\n this.toggleElement(item, isHidden);\n this.toggleElement(this._proxyChildren[mgActionMenuindex], !isHidden);\n }\n };\n\n /**\n * Toggle element's hidde attribute\n * @param element - element to toggle\n * @param isHidden - element is hidden\n */\n private toggleElement = (element: Element, isHidden: boolean): void => {\n if (isHidden) element.setAttribute('hidden', '');\n else element.removeAttribute('hidden');\n };\n\n /**\n * Remove hidden attributes on all items\n */\n private restoreItems = (): void => {\n [...this._baseChildren, this._moreElement].forEach(item => item.removeAttribute('hidden'));\n };\n}\n"]}
1
+ {"version":3,"file":"behaviors.utils.js","sourceRoot":"","sources":["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,QAAQ,CAAC,CAAC;gBACnC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;aACvE;QACH,CAAC,CAAC;QAEF;;;;WAIG;QACK,kBAAa,GAAG,CAAC,OAAgB,EAAE,QAAiB,EAAQ,EAAE;YACpE,IAAI,QAAQ;gBAAE,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;;gBAC5C,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC,CAAC;QAEF;;WAEG;QACK,iBAAY,GAAG,GAAS,EAAE;YAChC,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC7F,CAAC,CAAC;QAvIA,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE;YACtC,sBAAsB;YACtB,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;gBAClD,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;oBACtB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;gBACpC,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAC5C;QACD,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC;CA8HF","sourcesContent":["/**\n * MgItemMore type guard\n * @param element - element to control type\n * @returns truthy if element is mg-item-more\n */\nconst isMgItemMore = (element: HTMLElement): element is HTMLMgItemMoreElement => element.nodeName === 'MG-ITEM-MORE';\n\nexport enum OverflowBehaviorElements {\n BASE_INDEX = 'data-overflow-base-index',\n PROXY_INDEX = 'data-overflow-proxy-index',\n}\n\nexport class OverflowBehavior {\n // variables\n private _resizeObserver: ResizeObserver;\n private _moreElement: HTMLElement;\n private _baseChildren: Element[];\n private _proxyChildren: Element[];\n\n constructor(\n private element: Element,\n private render: () => HTMLElement,\n ) {\n if (this._resizeObserver === undefined) {\n // add resize observer\n this._resizeObserver = new ResizeObserver(entries => {\n entries.forEach(entry => {\n this.run(entry.contentRect.width);\n });\n });\n this._resizeObserver.observe(this.element);\n }\n this.run();\n }\n\n /**********\n * Public *\n **********/\n\n /**\n * Disconnect ResizeObserver\n */\n public disconnect = (): void => {\n this._resizeObserver.disconnect();\n };\n\n /************\n * Internal *\n ************/\n\n /**\n * run overflow behavior\n * @param width - width of the container. Optional.\n */\n private run = (width?: number): void => {\n if (this._moreElement === undefined) {\n // set moreElement\n this._moreElement = this.render();\n\n // set children\n this._baseChildren = this.getInteractiveItems(this.element);\n if (isMgItemMore(this._moreElement)) {\n this._proxyChildren = this.getInteractiveItems(this._moreElement.shadowRoot.querySelector('mg-menu'));\n }\n\n // update children\n this._baseChildren.forEach((child, index) => {\n child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);\n // set moreElement children\n this._proxyChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);\n });\n }\n\n if (width !== undefined) this.updateDisplayedItems(width);\n };\n\n /**\n * Get interactive children filtred by authorized nodeName ['MG-MENU-ITEM', 'MG-BUTTON']\n * @param element - element to parse\n * @returns children\n */\n private getInteractiveItems = (element: Element) =>\n (element.children?.length > 0 ? Array.from(element.children) : []).filter(element => ['MG-MENU-ITEM', 'MG-BUTTON'].includes(element.nodeName));\n\n /**\n * Update displayed items in container from a given available space\n * @param availableWidth - available width in container to display child items\n */\n private updateDisplayedItems = (availableWidth: number): void => {\n this.restoreItems();\n const acc = { accWidth: 0, previousItem: null };\n [...this._baseChildren, this._moreElement].forEach((child: HTMLMgMenuItemElement | HTMLMgItemMoreElement) => {\n acc.accWidth += child.offsetWidth;\n const hasPreviuosItem = acc.previousItem !== null;\n const isPreviousItemHidden = hasPreviuosItem && acc.previousItem.getAttribute('hidden') !== null;\n // if previous item is hidden AND is NOT more element we hidde current\n // OR if item has an overflow we hidde current\n // OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item\n // ELSE current is a display item\n this.toggleItem(\n child,\n (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden),\n );\n\n // update previous item with current item\n acc.previousItem = child;\n });\n };\n\n /**\n * Utility method to know if item overflow partialy or totaly in the container\n * @param cumulateWidth - previous sibling elements cumulate width + item width\n * @param item - item HTML element\n * @param availableWidth - container available width\n * @returns truthy if element is overflow\n */\n private isOverflowElement = (cumulateWidth: number, item: HTMLElement, availableWidth: number): boolean => {\n if (item.previousElementSibling === null || this.isMoreElement(item)) return false;\n else if (!this.isMoreElement(item.nextElementSibling)) return cumulateWidth + this._moreElement.offsetWidth > availableWidth;\n else return cumulateWidth > availableWidth;\n };\n\n /**\n * Utility method to know if a given element is the 'MORE' element\n * @param element - element to match with 'MORE' element\n * @returns truthy if element is the 'MORE' element\n */\n private isMoreElement = (element: Element): boolean => element.nodeName === 'MG-ITEM-MORE';\n\n /**\n * Toggle display item element\n * @param item - item to control\n * @param isHidden - is item hidden\n */\n private toggleItem = (item: HTMLElement, isHidden: boolean): void => {\n const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));\n if (this.isMoreElement(item)) this.toggleElement(this._moreElement, isHidden);\n else if (mgActionMenuindex >= 0) {\n this.toggleElement(item, isHidden);\n this.toggleElement(this._proxyChildren[mgActionMenuindex], !isHidden);\n }\n };\n\n /**\n * Toggle element's hidde attribute\n * @param element - element to toggle\n * @param isHidden - element is hidden\n */\n private toggleElement = (element: Element, isHidden: boolean): void => {\n if (isHidden) element.setAttribute('hidden', '');\n else element.removeAttribute('hidden');\n };\n\n /**\n * Remove hidden attributes on all items\n */\n private restoreItems = (): void => {\n [...this._baseChildren, this._moreElement].forEach(item => item.removeAttribute('hidden'));\n };\n}\n"]}
@@ -6,52 +6,52 @@ import { MgMenu } from "../components/molecules/menu/mg-menu/mg-menu";
6
6
  import { OverflowBehavior } from "./behaviors.utils";
7
7
  import { setupMutationObserverMock, setupResizeObserverMock } from "./unit.test.utils";
8
8
  const getPage = render => newSpecPage({
9
- components: [MgMenu, MgMenuItem, MgItemMore],
10
- template: () => render,
9
+ components: [MgMenu, MgMenuItem, MgItemMore],
10
+ template: () => render,
11
11
  });
12
12
  describe('behavior.utils', () => {
13
- describe('OverflowBehavior', () => {
14
- let fireRo;
15
- beforeEach(() => {
16
- jest.useFakeTimers();
17
- setupResizeObserverMock({
18
- observe: function () {
19
- fireRo = this.cb;
20
- },
21
- disconnect: () => null,
22
- });
23
- setupMutationObserverMock({
24
- disconnect: () => null,
25
- observe: () => null,
26
- takeRecords: () => null,
27
- });
28
- });
29
- afterEach(() => jest.runOnlyPendingTimers());
30
- describe('render menu', () => {
31
- test.each([50, 80, 100, 250])('should manage resize with observer, case %s', async (width) => {
32
- const args = { label: 'batman' };
33
- const page = await getPage(h("mg-menu", Object.assign({}, args), h("mg-menu-item", null, h("span", { slot: "label" }, "Batman")), h("mg-menu-item", null, h("span", { slot: "label" }, "Joker")), h("mg-menu-item", null, h("span", { slot: "label" }, "Bane"))));
34
- jest.runAllTimers();
35
- await page.waitForChanges();
36
- const items = Array.from(page.doc.querySelectorAll('mg-menu-item'));
37
- items.forEach(item => {
38
- Object.defineProperty(item, 'offsetWidth', {
39
- get: jest.fn(() => 80),
40
- });
13
+ describe('OverflowBehavior', () => {
14
+ let fireRo;
15
+ beforeEach(() => {
16
+ jest.useFakeTimers({ legacyFakeTimers: true });
17
+ setupResizeObserverMock({
18
+ observe: function () {
19
+ fireRo = this.cb;
20
+ },
21
+ disconnect: () => null,
22
+ });
23
+ setupMutationObserverMock({
24
+ disconnect: () => null,
25
+ observe: () => null,
26
+ takeRecords: () => null,
27
+ });
41
28
  });
42
- Object.defineProperty(page.doc.querySelector('mg-item-more'), 'offsetWidth', {
43
- get: jest.fn(() => 50),
29
+ afterEach(() => jest.runOnlyPendingTimers());
30
+ describe('render menu', () => {
31
+ test.each([50, 80, 100, 250])('should manage resize with observer, case %s', async (width) => {
32
+ const args = { label: 'batman' };
33
+ const page = await getPage(h("mg-menu", Object.assign({}, args), h("mg-menu-item", null, h("span", { slot: "label" }, "Batman")), h("mg-menu-item", null, h("span", { slot: "label" }, "Joker")), h("mg-menu-item", null, h("span", { slot: "label" }, "Bane"))));
34
+ jest.runAllTimers();
35
+ await page.waitForChanges();
36
+ const items = Array.from(page.doc.querySelectorAll('mg-menu-item'));
37
+ items.forEach(item => {
38
+ Object.defineProperty(item, 'offsetWidth', {
39
+ get: jest.fn(() => 80),
40
+ });
41
+ });
42
+ Object.defineProperty(page.doc.querySelector('mg-item-more'), 'offsetWidth', {
43
+ get: jest.fn(() => 50),
44
+ });
45
+ fireRo([{ contentRect: { width } }]);
46
+ expect(page.root).toMatchSnapshot();
47
+ });
48
+ });
49
+ test('should fire disconnect callback', () => {
50
+ const behavior = new OverflowBehavior(h("div", null), () => h("span", null));
51
+ const spy = jest.spyOn(behavior._resizeObserver, 'disconnect');
52
+ behavior.disconnect();
53
+ expect(spy).toHaveBeenCalled();
44
54
  });
45
- fireRo([{ contentRect: { width } }]);
46
- expect(page.root).toMatchSnapshot();
47
- });
48
- });
49
- test('should fire disconnect callback', () => {
50
- const behavior = new OverflowBehavior(h("div", null), () => h("span", null));
51
- const spy = jest.spyOn(behavior._resizeObserver, 'disconnect');
52
- behavior.disconnect();
53
- expect(spy).toHaveBeenCalled();
54
55
  });
55
- });
56
56
  });
57
57
  //# sourceMappingURL=behaviors.utils.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"behaviors.utils.spec.js","sourceRoot":"","sources":["../../src/utils/behaviors.utils.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,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GAAG,EAAE,CAAC,eAAa,CAAC,CAAC;MACxE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAE,QAAmD,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;MAC3G,QAAQ,CAAC,UAAU,EAAE,CAAC;MAEtB,MAAM,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { h } from '@stencil/core/internal';\nimport { newSpecPage } from '@stencil/core/testing';\nimport { MgItemMore } from '../components/molecules/mg-item-more/mg-item-more';\nimport { MgMenuItem } from '../components/molecules/menu/mg-menu-item/mg-menu-item';\nimport { MgMenu } from '../components/molecules/menu/mg-menu/mg-menu';\nimport { OverflowBehavior } from './behaviors.utils';\nimport { setupMutationObserverMock, setupResizeObserverMock } from './unit.test.utils';\n\nconst getPage = render =>\n newSpecPage({\n components: [MgMenu, MgMenuItem, MgItemMore],\n template: () => render,\n });\n\ndescribe('behavior.utils', () => {\n describe('OverflowBehavior', () => {\n let fireRo;\n beforeEach(() => {\n jest.useFakeTimers();\n setupResizeObserverMock({\n observe: function () {\n fireRo = this.cb;\n },\n disconnect: () => null,\n });\n setupMutationObserverMock({\n disconnect: () => null,\n observe: () => null,\n takeRecords: () => null,\n });\n });\n afterEach(() => jest.runOnlyPendingTimers());\n\n describe('render menu', () => {\n test.each([50, 80, 100, 250])('should manage resize with observer, case %s', async width => {\n const args = { label: 'batman' };\n const page = await getPage(\n <mg-menu {...args}>\n <mg-menu-item>\n <span slot=\"label\">Batman</span>\n </mg-menu-item>\n <mg-menu-item>\n <span slot=\"label\">Joker</span>\n </mg-menu-item>\n <mg-menu-item>\n <span slot=\"label\">Bane</span>\n </mg-menu-item>\n </mg-menu>,\n );\n\n jest.runAllTimers();\n\n await page.waitForChanges();\n\n const items = Array.from(page.doc.querySelectorAll('mg-menu-item'));\n items.forEach(item => {\n Object.defineProperty(item, 'offsetWidth', {\n get: jest.fn(() => 80),\n });\n });\n\n Object.defineProperty(page.doc.querySelector('mg-item-more'), 'offsetWidth', {\n get: jest.fn(() => 50),\n });\n\n fireRo([{ contentRect: { width } }]);\n\n expect(page.root).toMatchSnapshot();\n });\n });\n\n test('should fire disconnect callback', () => {\n const behavior = new OverflowBehavior(<div></div>, () => <span></span>);\n const spy = jest.spyOn((behavior as unknown as { _resizeObserver: string })._resizeObserver, 'disconnect');\n behavior.disconnect();\n\n expect(spy).toHaveBeenCalled();\n });\n });\n});\n"]}
1
+ {"version":3,"file":"behaviors.utils.spec.js","sourceRoot":"","sources":["../../src/utils/behaviors.utils.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,mDAAmD,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,wDAAwD,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,8CAA8C,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEvF,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CACvB,WAAW,CAAC;IACV,UAAU,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC;IAC5C,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM;CACvB,CAAC,CAAC;AAEL,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,IAAI,MAAM,CAAC;QACX,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,aAAa,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;YAC/C,uBAAuB,CAAC;gBACtB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BACvB,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;gBAEH,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,aAAa,EAAE;oBAC3E,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;iBACvB,CAAC,CAAC;gBAEH,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;gBAErC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,iCAAiC,EAAE,GAAG,EAAE;YAC3C,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,cAAW,EAAE,GAAG,EAAE,CAAC,eAAa,CAAC,CAAC;YACxE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAE,QAAkD,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;YAC1G,QAAQ,CAAC,UAAU,EAAE,CAAC;YAEtB,MAAM,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { h } from '@stencil/core/internal';\nimport { newSpecPage } from '@stencil/core/testing';\nimport { MgItemMore } from '../components/molecules/mg-item-more/mg-item-more';\nimport { MgMenuItem } from '../components/molecules/menu/mg-menu-item/mg-menu-item';\nimport { MgMenu } from '../components/molecules/menu/mg-menu/mg-menu';\nimport { OverflowBehavior } from './behaviors.utils';\nimport { setupMutationObserverMock, setupResizeObserverMock } from './unit.test.utils';\n\nconst getPage = render =>\n newSpecPage({\n components: [MgMenu, MgMenuItem, MgItemMore],\n template: () => render,\n });\n\ndescribe('behavior.utils', () => {\n describe('OverflowBehavior', () => {\n let fireRo;\n beforeEach(() => {\n jest.useFakeTimers({ legacyFakeTimers: true });\n setupResizeObserverMock({\n observe: function () {\n fireRo = this.cb;\n },\n disconnect: () => null,\n });\n setupMutationObserverMock({\n disconnect: () => null,\n observe: () => null,\n takeRecords: () => null,\n });\n });\n afterEach(() => jest.runOnlyPendingTimers());\n\n describe('render menu', () => {\n test.each([50, 80, 100, 250])('should manage resize with observer, case %s', async width => {\n const args = { label: 'batman' };\n const page = await getPage(\n <mg-menu {...args}>\n <mg-menu-item>\n <span slot=\"label\">Batman</span>\n </mg-menu-item>\n <mg-menu-item>\n <span slot=\"label\">Joker</span>\n </mg-menu-item>\n <mg-menu-item>\n <span slot=\"label\">Bane</span>\n </mg-menu-item>\n </mg-menu>,\n );\n\n jest.runAllTimers();\n\n await page.waitForChanges();\n\n const items = Array.from(page.doc.querySelectorAll('mg-menu-item'));\n items.forEach(item => {\n Object.defineProperty(item, 'offsetWidth', {\n get: jest.fn(() => 80),\n });\n });\n\n Object.defineProperty(page.doc.querySelector('mg-item-more'), 'offsetWidth', {\n get: jest.fn(() => 50),\n });\n\n fireRo([{ contentRect: { width } }]);\n\n expect(page.root).toMatchSnapshot();\n });\n });\n\n test('should fire disconnect callback', () => {\n const behavior = new OverflowBehavior(<div></div>, () => <span></span>);\n const spy = jest.spyOn((behavior as unknown as { _resizeObserver: never })._resizeObserver, 'disconnect');\n behavior.disconnect();\n\n expect(spy).toHaveBeenCalled();\n });\n });\n});\n"]}