@mgdis/mg-components 5.16.0 → 5.18.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 (475) hide show
  1. package/dist/cjs/{index-fede8ee2.js → index-c042e24b.js} +321 -68
  2. package/dist/cjs/index-c042e24b.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +2 -0
  4. package/dist/cjs/index.cjs.js.map +1 -0
  5. package/dist/cjs/loader.cjs.js +5 -12
  6. package/dist/cjs/loader.cjs.js.map +1 -0
  7. package/dist/cjs/mg-action-more_34.cjs.entry.js +485 -163
  8. package/dist/cjs/mg-action-more_34.cjs.entry.js.map +1 -0
  9. package/dist/cjs/mg-components.cjs.js +5 -3
  10. package/dist/cjs/mg-components.cjs.js.map +1 -0
  11. package/dist/cjs/mg-item-more.cjs.entry.js +4 -2
  12. package/dist/cjs/mg-item-more.cjs.entry.js.map +1 -0
  13. package/dist/cjs/{mg-menu.conf-f9d0ddec.js → mg-menu.conf-43aacf30.js} +2 -0
  14. package/dist/cjs/mg-menu.conf-43aacf30.js.map +1 -0
  15. package/dist/collection/assets/icons/index.js +7 -2
  16. package/dist/collection/collection-manifest.json +37 -37
  17. package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -0
  18. package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js.map +1 -0
  19. package/dist/collection/components/atoms/mg-badge/mg-badge.js +6 -4
  20. package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -0
  21. package/dist/collection/components/atoms/mg-badge/test/mg-badge.e2e.playwright.js +33 -0
  22. package/dist/collection/components/atoms/mg-badge/test/mg-badge.e2e.playwright.js.map +1 -0
  23. package/dist/collection/components/atoms/mg-badge/test/mg-badge.spec.js +70 -0
  24. package/dist/collection/components/atoms/mg-badge/test/mg-badge.spec.js.map +1 -0
  25. package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -0
  26. package/dist/collection/components/atoms/mg-button/mg-button.conf.js.map +1 -0
  27. package/dist/collection/components/atoms/mg-button/mg-button.js +10 -6
  28. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -0
  29. package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js +91 -0
  30. package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js.map +1 -0
  31. package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js +142 -0
  32. package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js.map +1 -0
  33. package/dist/collection/components/atoms/mg-card/mg-card.conf.js +1 -0
  34. package/dist/collection/components/atoms/mg-card/mg-card.conf.js.map +1 -0
  35. package/dist/collection/components/atoms/mg-card/mg-card.js +8 -5
  36. package/dist/collection/components/atoms/mg-card/mg-card.js.map +1 -0
  37. package/dist/collection/components/atoms/mg-card/test/mg-card.e2e.js +36 -0
  38. package/dist/collection/components/atoms/mg-card/test/mg-card.e2e.js.map +1 -0
  39. package/dist/collection/components/atoms/mg-card/test/mg-card.spec.js +43 -0
  40. package/dist/collection/components/atoms/mg-card/test/mg-card.spec.js.map +1 -0
  41. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +3 -2
  42. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js.map +1 -0
  43. package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.e2e.js +15 -0
  44. package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.e2e.js.map +1 -0
  45. package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.spec.js +42 -0
  46. package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.spec.js.map +1 -0
  47. package/dist/collection/components/atoms/mg-divider/mg-divider.js +2 -1
  48. package/dist/collection/components/atoms/mg-divider/mg-divider.js.map +1 -0
  49. package/dist/collection/components/atoms/mg-divider/test/mg-divider.e2e.js +11 -0
  50. package/dist/collection/components/atoms/mg-divider/test/mg-divider.e2e.js.map +1 -0
  51. package/dist/collection/components/atoms/mg-divider/test/mg-divider.spec.js +14 -0
  52. package/dist/collection/components/atoms/mg-divider/test/mg-divider.spec.js.map +1 -0
  53. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +1 -0
  54. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js.map +1 -0
  55. package/dist/collection/components/atoms/mg-icon/mg-icon.js +11 -7
  56. package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -0
  57. package/dist/collection/components/atoms/mg-icon/test/mg-icon.e2e.js +55 -0
  58. package/dist/collection/components/atoms/mg-icon/test/mg-icon.e2e.js.map +1 -0
  59. package/dist/collection/components/atoms/mg-icon/test/mg-icon.spec.js +84 -0
  60. package/dist/collection/components/atoms/mg-icon/test/mg-icon.spec.js.map +1 -0
  61. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +2 -1
  62. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js.map +1 -0
  63. package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.js +18 -0
  64. package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.js.map +1 -0
  65. package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.spec.js +27 -0
  66. package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.spec.js.map +1 -0
  67. package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js +1 -0
  68. package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js.map +1 -0
  69. package/dist/collection/components/atoms/mg-tag/mg-tag.js +6 -4
  70. package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -0
  71. package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.js +37 -0
  72. package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.js.map +1 -0
  73. package/dist/collection/components/atoms/mg-tag/test/mg-tag.spec.js +71 -0
  74. package/dist/collection/components/atoms/mg-tag/test/mg-tag.spec.js.map +1 -0
  75. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +2 -1
  76. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js.map +1 -0
  77. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +1 -0
  78. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -0
  79. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +38 -16
  80. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -0
  81. package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.e2e.js +138 -0
  82. package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.e2e.js.map +1 -0
  83. package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js +272 -0
  84. package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js.map +1 -0
  85. package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -0
  86. package/dist/collection/components/molecules/inputs/MgInput.conf.js.map +1 -0
  87. package/dist/collection/components/molecules/inputs/MgInput.js +3 -2
  88. package/dist/collection/components/molecules/inputs/MgInput.js.map +1 -0
  89. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +2 -1
  90. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js.map +1 -0
  91. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +12 -7
  92. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -0
  93. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +1 -0
  94. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js.map +1 -0
  95. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +109 -27
  96. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -0
  97. package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.js +243 -0
  98. package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.js.map +1 -0
  99. package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js +638 -0
  100. package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js.map +1 -0
  101. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +1 -0
  102. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js.map +1 -0
  103. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +88 -15
  104. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -0
  105. package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.e2e.js +123 -0
  106. package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.e2e.js.map +1 -0
  107. package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js +379 -0
  108. package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js.map +1 -0
  109. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +1 -0
  110. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js.map +1 -0
  111. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +120 -46
  112. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -0
  113. package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.e2e.js +212 -0
  114. package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.e2e.js.map +1 -0
  115. package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js +456 -0
  116. package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js.map +1 -0
  117. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +92 -16
  118. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -0
  119. package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.e2e.js +115 -0
  120. package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.e2e.js.map +1 -0
  121. package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js +289 -0
  122. package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js.map +1 -0
  123. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js +1 -0
  124. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js.map +1 -0
  125. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +91 -15
  126. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -0
  127. package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.e2e.js +154 -0
  128. package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.e2e.js.map +1 -0
  129. package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.spec.js +355 -0
  130. package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.spec.js.map +1 -0
  131. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js +1 -0
  132. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js.map +1 -0
  133. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +95 -17
  134. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -0
  135. package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.e2e.js +194 -0
  136. package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.e2e.js.map +1 -0
  137. package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js +399 -0
  138. package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js.map +1 -0
  139. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +104 -27
  140. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -0
  141. package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.js +171 -0
  142. package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.js.map +1 -0
  143. package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js +343 -0
  144. package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js.map +1 -0
  145. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +108 -31
  146. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -0
  147. package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.e2e.js +129 -0
  148. package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.e2e.js.map +1 -0
  149. package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js +318 -0
  150. package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js.map +1 -0
  151. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +1 -0
  152. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js.map +1 -0
  153. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +6 -4
  154. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -0
  155. package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.js +125 -0
  156. package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.js.map +1 -0
  157. package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js +203 -0
  158. package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js.map +1 -0
  159. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +1 -0
  160. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js.map +1 -0
  161. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +9 -5
  162. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -0
  163. package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.e2e.js +268 -0
  164. package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.e2e.js.map +1 -0
  165. package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.spec.js +175 -0
  166. package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.spec.js.map +1 -0
  167. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +1 -0
  168. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js.map +1 -0
  169. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +10 -7
  170. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -0
  171. package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.js +119 -0
  172. package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.js.map +1 -0
  173. package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.spec.js +295 -0
  174. package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.spec.js.map +1 -0
  175. package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js +1 -0
  176. package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js.map +1 -0
  177. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +19 -13
  178. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -0
  179. package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.js +128 -0
  180. package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.js.map +1 -0
  181. package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.spec.js +187 -0
  182. package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.spec.js.map +1 -0
  183. package/dist/collection/components/molecules/mg-details/mg-details.js +2 -1
  184. package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -0
  185. package/dist/collection/components/molecules/mg-details/test/mg-details.e2e.playwright.js +30 -0
  186. package/dist/collection/components/molecules/mg-details/test/mg-details.e2e.playwright.js.map +1 -0
  187. package/dist/collection/components/molecules/mg-details/test/mg-details.spec.js +42 -0
  188. package/dist/collection/components/molecules/mg-details/test/mg-details.spec.js.map +1 -0
  189. package/dist/collection/components/molecules/mg-form/mg-form.js +8 -6
  190. package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -0
  191. package/dist/collection/components/molecules/mg-form/test/mg-form.e2e.js +169 -0
  192. package/dist/collection/components/molecules/mg-form/test/mg-form.e2e.js.map +1 -0
  193. package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js +277 -0
  194. package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js.map +1 -0
  195. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +3 -2
  196. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -0
  197. package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.e2e.js +39 -0
  198. package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.e2e.js.map +1 -0
  199. package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.spec.js +36 -0
  200. package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.spec.js.map +1 -0
  201. package/dist/collection/components/molecules/mg-item-more/mg-item-more.conf.js +1 -0
  202. package/dist/collection/components/molecules/mg-item-more/mg-item-more.conf.js.map +1 -0
  203. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +11 -7
  204. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +1 -0
  205. package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.js +85 -0
  206. package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.js.map +1 -0
  207. package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.spec.js +106 -0
  208. package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.spec.js.map +1 -0
  209. package/dist/collection/components/molecules/mg-message/mg-message.conf.js +1 -0
  210. package/dist/collection/components/molecules/mg-message/mg-message.conf.js.map +1 -0
  211. package/dist/collection/components/molecules/mg-message/mg-message.js +7 -5
  212. package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -0
  213. package/dist/collection/components/molecules/mg-message/test/mg-message.e2e.js +64 -0
  214. package/dist/collection/components/molecules/mg-message/test/mg-message.e2e.js.map +1 -0
  215. package/dist/collection/components/molecules/mg-message/test/mg-message.spec.js +109 -0
  216. package/dist/collection/components/molecules/mg-message/test/mg-message.spec.js.map +1 -0
  217. package/dist/collection/components/molecules/mg-modal/mg-modal.conf.js +1 -0
  218. package/dist/collection/components/molecules/mg-modal/mg-modal.conf.js.map +1 -0
  219. package/dist/collection/components/molecules/mg-modal/mg-modal.js +7 -5
  220. package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -0
  221. package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js +62 -0
  222. package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js.map +1 -0
  223. package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.template.js +40 -0
  224. package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.template.js.map +1 -0
  225. package/dist/collection/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.js +26 -0
  226. package/dist/collection/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.js.map +1 -0
  227. package/dist/collection/components/molecules/mg-modal/test/mg-modal.spec.js +122 -0
  228. package/dist/collection/components/molecules/mg-modal/test/mg-modal.spec.js.map +1 -0
  229. package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +1 -0
  230. package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js.map +1 -0
  231. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +5 -4
  232. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -0
  233. package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.js +57 -0
  234. package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.js.map +1 -0
  235. package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.spec.js +121 -0
  236. package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.spec.js.map +1 -0
  237. package/dist/collection/components/molecules/mg-panel/mg-panel.conf.js +1 -0
  238. package/dist/collection/components/molecules/mg-panel/mg-panel.conf.js.map +1 -0
  239. package/dist/collection/components/molecules/mg-panel/mg-panel.js +17 -12
  240. package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -0
  241. package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js +106 -0
  242. package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js.map +1 -0
  243. package/dist/collection/components/molecules/mg-panel/test/mg-panel.spec.js +213 -0
  244. package/dist/collection/components/molecules/mg-panel/test/mg-panel.spec.js.map +1 -0
  245. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +4 -3
  246. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -0
  247. package/dist/collection/components/molecules/mg-popover/mg-popover.js +40 -18
  248. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -0
  249. package/dist/collection/components/molecules/mg-popover/test/mg-popover.e2e.js +159 -0
  250. package/dist/collection/components/molecules/mg-popover/test/mg-popover.e2e.js.map +1 -0
  251. package/dist/collection/components/molecules/mg-popover/test/mg-popover.spec.js +142 -0
  252. package/dist/collection/components/molecules/mg-popover/test/mg-popover.spec.js.map +1 -0
  253. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.conf.js +1 -0
  254. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.conf.js.map +1 -0
  255. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +5 -3
  256. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -0
  257. package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.e2e.js +55 -0
  258. package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.e2e.js.map +1 -0
  259. package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.spec.js +55 -0
  260. package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.spec.js.map +1 -0
  261. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +1 -0
  262. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js.map +1 -0
  263. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +8 -5
  264. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -0
  265. package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.js +76 -0
  266. package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.js.map +1 -0
  267. package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.spec.js +332 -0
  268. package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.spec.js.map +1 -0
  269. package/dist/collection/index.js +1 -0
  270. package/dist/collection/index.js.map +1 -0
  271. package/dist/collection/locales/index.js +4 -3
  272. package/dist/collection/locales/index.js.map +1 -0
  273. package/dist/collection/locales/index.spec.js +27 -0
  274. package/dist/collection/locales/index.spec.js.map +1 -0
  275. package/dist/collection/stories/icon-gallery.js +4 -3
  276. package/dist/collection/stories/icon-gallery.js.map +1 -0
  277. package/dist/collection/test/typography.e2e.playwright.js +12 -0
  278. package/dist/collection/test/typography.e2e.playwright.js.map +1 -0
  279. package/dist/collection/utils/behaviors.utils.js +1 -0
  280. package/dist/collection/utils/behaviors.utils.js.map +1 -0
  281. package/dist/collection/utils/behaviors.utils.spec.js +57 -0
  282. package/dist/collection/utils/behaviors.utils.spec.js.map +1 -0
  283. package/dist/collection/utils/components.utils.js +7 -0
  284. package/dist/collection/utils/components.utils.js.map +1 -0
  285. package/dist/collection/utils/components.utils.spec.js +128 -0
  286. package/dist/collection/utils/components.utils.spec.js.map +1 -0
  287. package/dist/collection/utils/e2e.test.utils.js +46 -0
  288. package/dist/collection/utils/e2e.test.utils.js.map +1 -0
  289. package/dist/collection/utils/locale.utils.js +1 -0
  290. package/dist/collection/utils/locale.utils.js.map +1 -0
  291. package/dist/collection/utils/locale.utils.spec.js +52 -0
  292. package/dist/collection/utils/locale.utils.spec.js.map +1 -0
  293. package/dist/collection/utils/playwright.e2e.test.utils.js +100 -0
  294. package/dist/collection/utils/playwright.e2e.test.utils.js.map +1 -0
  295. package/dist/collection/utils/stencil.e2e.test.utils.js +33 -0
  296. package/dist/collection/utils/stencil.e2e.test.utils.js.map +1 -0
  297. package/dist/collection/utils/unit.test.utils.js +2 -1
  298. package/dist/collection/utils/unit.test.utils.js.map +1 -0
  299. package/dist/components/MgInput.js +2 -0
  300. package/dist/components/MgInput.js.map +1 -0
  301. package/dist/components/components.utils.js +9 -1
  302. package/dist/components/components.utils.js.map +1 -0
  303. package/dist/components/index.d.ts +5 -37
  304. package/dist/components/index.js +3 -36
  305. package/dist/components/index.js.map +1 -0
  306. package/dist/components/index2.js +2 -0
  307. package/dist/components/index2.js.map +1 -0
  308. package/dist/components/mg-action-more.js +14 -4
  309. package/dist/components/mg-action-more.js.map +1 -0
  310. package/dist/components/mg-badge.js +2 -0
  311. package/dist/components/mg-badge.js.map +1 -0
  312. package/dist/components/mg-badge2.js +8 -1
  313. package/dist/components/mg-badge2.js.map +1 -0
  314. package/dist/components/mg-button.js +2 -0
  315. package/dist/components/mg-button.js.map +1 -0
  316. package/dist/components/mg-button2.js +8 -1
  317. package/dist/components/mg-button2.js.map +1 -0
  318. package/dist/components/mg-card.js +2 -0
  319. package/dist/components/mg-card.js.map +1 -0
  320. package/dist/components/mg-card2.js +6 -1
  321. package/dist/components/mg-card2.js.map +1 -0
  322. package/dist/components/mg-character-left.js +2 -0
  323. package/dist/components/mg-character-left.js.map +1 -0
  324. package/dist/components/mg-character-left2.js +5 -1
  325. package/dist/components/mg-character-left2.js.map +1 -0
  326. package/dist/components/mg-details.js +7 -1
  327. package/dist/components/mg-details.js.map +1 -0
  328. package/dist/components/mg-divider.js +3 -1
  329. package/dist/components/mg-divider.js.map +1 -0
  330. package/dist/components/mg-form.js +7 -2
  331. package/dist/components/mg-form.js.map +1 -0
  332. package/dist/components/mg-icon.js +2 -0
  333. package/dist/components/mg-icon.js.map +1 -0
  334. package/dist/components/mg-icon2.js +21 -3
  335. package/dist/components/mg-icon2.js.map +1 -0
  336. package/dist/components/mg-illustrated-message.js +3 -1
  337. package/dist/components/mg-illustrated-message.js.map +1 -0
  338. package/dist/components/mg-input-checkbox-paginated.js +2 -0
  339. package/dist/components/mg-input-checkbox-paginated.js.map +1 -0
  340. package/dist/components/mg-input-checkbox-paginated2.js +6 -1
  341. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -0
  342. package/dist/components/mg-input-checkbox.js +64 -14
  343. package/dist/components/mg-input-checkbox.js.map +1 -0
  344. package/dist/components/mg-input-date.js +51 -9
  345. package/dist/components/mg-input-date.js.map +1 -0
  346. package/dist/components/mg-input-numeric.js +82 -39
  347. package/dist/components/mg-input-numeric.js.map +1 -0
  348. package/dist/components/mg-input-password.js +53 -11
  349. package/dist/components/mg-input-password.js.map +1 -0
  350. package/dist/components/mg-input-radio.js +53 -10
  351. package/dist/components/mg-input-radio.js.map +1 -0
  352. package/dist/components/mg-input-select.js +2 -0
  353. package/dist/components/mg-input-select.js.map +1 -0
  354. package/dist/components/mg-input-select2.js +53 -10
  355. package/dist/components/mg-input-select2.js.map +1 -0
  356. package/dist/components/mg-input-text.js +2 -0
  357. package/dist/components/mg-input-text.js.map +1 -0
  358. package/dist/components/mg-input-text2.js +64 -23
  359. package/dist/components/mg-input-text2.js.map +1 -0
  360. package/dist/components/mg-input-textarea.js +69 -27
  361. package/dist/components/mg-input-textarea.js.map +1 -0
  362. package/dist/components/mg-input-title.js +2 -0
  363. package/dist/components/mg-input-title.js.map +1 -0
  364. package/dist/components/mg-input-title2.js +6 -1
  365. package/dist/components/mg-input-title2.js.map +1 -0
  366. package/dist/components/mg-input-toggle.js +11 -1
  367. package/dist/components/mg-input-toggle.js.map +1 -0
  368. package/dist/components/mg-item-more.js +7 -1
  369. package/dist/components/mg-item-more.js.map +1 -0
  370. package/dist/components/mg-menu-item.js +2 -0
  371. package/dist/components/mg-menu-item.js.map +1 -0
  372. package/dist/components/mg-menu-item2.js +9 -1
  373. package/dist/components/mg-menu-item2.js.map +1 -0
  374. package/dist/components/mg-menu.conf.js +2 -0
  375. package/dist/components/mg-menu.conf.js.map +1 -0
  376. package/dist/components/mg-menu.js +2 -0
  377. package/dist/components/mg-menu.js.map +1 -0
  378. package/dist/components/mg-menu2.js +8 -1
  379. package/dist/components/mg-menu2.js.map +1 -0
  380. package/dist/components/mg-message.js +8 -1
  381. package/dist/components/mg-message.js.map +1 -0
  382. package/dist/components/mg-modal.js +8 -2
  383. package/dist/components/mg-modal.js.map +1 -0
  384. package/dist/components/mg-pagination.js +2 -0
  385. package/dist/components/mg-pagination.js.map +1 -0
  386. package/dist/components/mg-pagination2.js +6 -1
  387. package/dist/components/mg-pagination2.js.map +1 -0
  388. package/dist/components/mg-panel.js +16 -7
  389. package/dist/components/mg-panel.js.map +1 -0
  390. package/dist/components/mg-popover-content.js +2 -0
  391. package/dist/components/mg-popover-content.js.map +1 -0
  392. package/dist/components/mg-popover-content2.js +3 -1
  393. package/dist/components/mg-popover-content2.js.map +1 -0
  394. package/dist/components/mg-popover.js +2 -0
  395. package/dist/components/mg-popover.js.map +1 -0
  396. package/dist/components/mg-popover2.js +40 -15
  397. package/dist/components/mg-popover2.js.map +1 -0
  398. package/dist/components/mg-skip-links.js +5 -1
  399. package/dist/components/mg-skip-links.js.map +1 -0
  400. package/dist/components/mg-tabs.js +8 -1
  401. package/dist/components/mg-tabs.js.map +1 -0
  402. package/dist/components/mg-tag.js +7 -1
  403. package/dist/components/mg-tag.js.map +1 -0
  404. package/dist/components/mg-tooltip-content.js +2 -0
  405. package/dist/components/mg-tooltip-content.js.map +1 -0
  406. package/dist/components/mg-tooltip-content2.js +3 -1
  407. package/dist/components/mg-tooltip-content2.js.map +1 -0
  408. package/dist/components/mg-tooltip.js +2 -0
  409. package/dist/components/mg-tooltip.js.map +1 -0
  410. package/dist/components/mg-tooltip2.js +37 -12
  411. package/dist/components/mg-tooltip2.js.map +1 -0
  412. package/dist/components/popper.js +2 -0
  413. package/dist/components/popper.js.map +1 -0
  414. package/dist/esm/{index-1d40b052.js → index-ce01e63b.js} +321 -68
  415. package/dist/esm/index-ce01e63b.js.map +1 -0
  416. package/dist/esm/index.js +2 -0
  417. package/dist/esm/index.js.map +1 -0
  418. package/dist/esm/loader.js +6 -13
  419. package/dist/esm/loader.js.map +1 -0
  420. package/dist/esm/mg-action-more_34.entry.js +485 -163
  421. package/dist/esm/mg-action-more_34.entry.js.map +1 -0
  422. package/dist/esm/mg-components.js +6 -4
  423. package/dist/esm/mg-components.js.map +1 -0
  424. package/dist/esm/mg-item-more.entry.js +4 -2
  425. package/dist/esm/mg-item-more.entry.js.map +1 -0
  426. package/dist/esm/{mg-menu.conf-2cc079ae.js → mg-menu.conf-012fc9b4.js} +2 -0
  427. package/dist/esm/mg-menu.conf-012fc9b4.js.map +1 -0
  428. package/dist/mg-components/index.esm.js +2 -0
  429. package/dist/mg-components/index.esm.js.map +1 -0
  430. package/dist/mg-components/mg-components.esm.js +2 -1
  431. package/dist/mg-components/mg-components.esm.js.map +1 -0
  432. package/dist/mg-components/p-1aa89acf.js +3 -0
  433. package/dist/mg-components/p-1aa89acf.js.map +1 -0
  434. package/dist/mg-components/p-1d7d6fa0.js +2 -0
  435. package/dist/mg-components/p-1d7d6fa0.js.map +1 -0
  436. package/dist/mg-components/p-9257e8f1.entry.js +2 -0
  437. package/dist/mg-components/p-9257e8f1.entry.js.map +1 -0
  438. package/dist/mg-components/p-ff3ca349.entry.js +2 -0
  439. package/dist/mg-components/p-ff3ca349.entry.js.map +1 -0
  440. package/dist/types/components/atoms/mg-badge/test/mg-badge.e2e.playwright.d.ts +1 -0
  441. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +2 -1
  442. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +22 -1
  443. package/dist/types/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.d.ts +1 -0
  444. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +17 -2
  445. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +35 -20
  446. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +16 -1
  447. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +16 -1
  448. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +16 -1
  449. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +17 -5
  450. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +17 -5
  451. package/dist/types/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.d.ts +2 -0
  452. package/dist/types/components/molecules/mg-details/test/mg-details.e2e.playwright.d.ts +1 -0
  453. package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
  454. package/dist/types/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.d.ts +1 -0
  455. package/dist/types/components/molecules/mg-modal/test/mg-modal.e2e.playwright.d.ts +1 -0
  456. package/dist/types/components/molecules/mg-modal/test/mg-modal.e2e.template.d.ts +12 -0
  457. package/dist/types/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.d.ts +1 -0
  458. package/dist/types/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.d.ts +1 -0
  459. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +1 -1
  460. package/dist/types/components/molecules/mg-panel/test/mg-panel.e2e.playwright.d.ts +1 -0
  461. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +1 -0
  462. package/dist/types/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.d.ts +1 -0
  463. package/dist/types/components.d.ts +79 -11
  464. package/dist/types/stencil-public-runtime.d.ts +43 -17
  465. package/dist/types/test/typography.e2e.playwright.d.ts +1 -0
  466. package/dist/types/utils/components.utils.d.ts +6 -0
  467. package/dist/types/utils/e2e.test.utils.d.ts +22 -0
  468. package/dist/types/utils/stencil.e2e.test.utils.d.ts +14 -0
  469. package/loader/index.d.ts +2 -2
  470. package/package.json +5 -5
  471. package/dist/esm/polyfills/css-shim.js +0 -1
  472. package/dist/mg-components/p-067080e4.js +0 -1
  473. package/dist/mg-components/p-3286bc46.entry.js +0 -1
  474. package/dist/mg-components/p-3bf1e2f0.js +0 -2
  475. package/dist/mg-components/p-91f4a30d.entry.js +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.utils.js","sourceRoot":"","sources":["../../src/utils/components.utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAU,EAAE;EAC3D,MAAM,KAAK,GAAG,sCAAsC,CAAC;EACrD,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;EAEjC,IAAI,EAAE,GAAG,EAAE,CAAC;EACZ,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;EACrB,OAAO,MAAM,GAAG,CAAC,EAAE;IACjB,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,qCAAqC;IAC7D,MAAM,KAAK,GAAG,GAAG,GAAG,WAAW,CAAC;IAChC,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAM,EAAE,CAAC;GACV;EACD,OAAO,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;AAClD,CAAC,CAA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eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;KACvC;GACF;EACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAW,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC","sourcesContent":["/**\n * Create random ID\n * @param prefix - add prefix to created ID\n * @param length - ID length\n * @returns ID\n */\nexport const createID = (prefix = '', length = 10): string => {\n const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';\n const charsLength = chars.length;\n\n let ID = '';\n let now = Date.now();\n while (length > 0) {\n now += Math.pow(10, 6); // Add 1 millisecond to the timestamp\n const index = now % charsLength;\n ID += chars.charAt(index);\n length--;\n }\n return (prefix !== '' ? `${prefix}-` : '') + ID;\n};\n\n/**\n * Class to manage component classlist\n * Set() are not working when imported in project\n */\nexport class ClassList {\n /**\n * Available classes\n */\n classes: string[];\n\n constructor(classlist: string[] = []) {\n this.classes = classlist;\n }\n\n /**\n * Add class\n * @param className - class name to add\n */\n add = (className: string): void => {\n if (!this.has(className)) {\n this.classes.push(className);\n }\n };\n\n /**\n * Delete class\n * @param className - class name to delete\n */\n delete = (className: string): void => {\n const index = this.classes.indexOf(className);\n if (index > -1) {\n this.classes.splice(index, 1);\n }\n };\n\n /**\n * Check if class exist in list\n * @param className - class name to check\n * @returns class name is in the list\n */\n has = (className: string): boolean => {\n return this.classes.includes(className);\n };\n\n /**\n * Join classes seperated by spaces\n * @returns joined values\n */\n join = (): string => {\n return this.classes.join(' ');\n };\n}\n\n/**\n * Check if all items are string\n * @param items - items to check\n * @returns all items are string\n */\nexport const allItemsAreString = (items: unknown): items is string[] => Array.isArray(items) && items.every(item => typeof item === 'string');\n\n/**\n * Check if element is a heading\n * @param element - slotted element\n * @param tagNames - allowed tag names list\n * @returns element is a heading\n */\nexport const isTagName = (element: Element, tagNames: string[]): boolean => {\n return tagNames.includes(element?.tagName.toLowerCase());\n};\n\n/**\n * Focusable elements query selector\n */\nexport const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"]), [identifier]';\n\n/**\n * Get windows\n * @param localWindow - the window we are lookink for other windows\n * @returns The list of windows found\n */\nexport const getWindows = (localWindow: Window): Window[] => {\n const parentWindows = getParentWindows(localWindow);\n const childWindows = getChildWindows(localWindow);\n return [localWindow, ...parentWindows, ...childWindows];\n};\n\n/**\n * Get parent windows\n * @param localWindow - the window we are lookink for parents\n * @param windows - The list of allready found windows\n * @returns The list of windows found\n */\nexport const getParentWindows = (localWindow: Window, windows: Window[] = []): Window[] => {\n // Check if is in iframe\n if (localWindow.self !== localWindow.top) {\n // Check if we have permission to access parent\n try {\n const parentWindow: Window = localWindow.parent;\n windows.push(parentWindow);\n return getParentWindows(parentWindow, windows);\n } catch (err) {\n console.error('Different hosts between iframes:', err);\n return windows;\n }\n }\n return windows;\n};\n\n/**\n * Get child windows\n * @param localWindow - the window we are lookink for children\n * @param windows - The list of allready found windows\n * @returns The list of windows found\n */\nconst getChildWindows = (localWindow: Window, windows: Window[] = []): Window[] => {\n if (localWindow.frames.length > 0) {\n for (const childWindow of Array.from(localWindow.frames)) {\n windows.push(childWindow);\n getChildWindows(childWindow, windows);\n }\n }\n return windows;\n};\n\n/**\n * Validate string\n * @param value - value to check\n * @returns if string is valid\n */\nexport const isValidString = (value: unknown): boolean => typeof value === 'string' && value.trim() !== '';\n"]}
@@ -0,0 +1,128 @@
1
+ import { createID, ClassList, allItemsAreString, isTagName, getWindows, isValidString } from "./components.utils";
2
+ import { mockConsoleError } from "./unit.test.utils";
3
+ mockConsoleError();
4
+ describe('components.utils', () => {
5
+ describe('createID', () => {
6
+ test.each([undefined, '', 'blu'])('Should generate a prefixed ID if defined : %s', prefix => {
7
+ const id = createID(prefix);
8
+ let regexp = /^[a-z0-9]{10}$/;
9
+ if (prefix !== undefined && prefix !== '') {
10
+ regexp = new RegExp(`^${prefix}-[a-z0-9]{10}$`);
11
+ }
12
+ expect(id).toMatch(regexp);
13
+ });
14
+ });
15
+ describe('ClassList', () => {
16
+ test('Should add classes to list', () => {
17
+ const classCollection = new ClassList();
18
+ expect(classCollection.classes).toEqual([]);
19
+ classCollection.add('blu');
20
+ expect(classCollection.classes).toEqual(['blu']);
21
+ classCollection.add('bli');
22
+ expect(classCollection.classes).toEqual(['blu', 'bli']);
23
+ // Should not add classes if already in list
24
+ classCollection.add('blu');
25
+ expect(classCollection.classes).toEqual(['blu', 'bli']);
26
+ });
27
+ test('Should delete classes from list', () => {
28
+ const classCollection = new ClassList(['blu', 'bli']);
29
+ classCollection.delete('blu');
30
+ expect(classCollection.classes).toEqual(['bli']);
31
+ // List doesn't change if class name doesn't existe in list
32
+ classCollection.delete('bla');
33
+ expect(classCollection.classes).toEqual(['bli']);
34
+ });
35
+ test('Should check if class already in list', () => {
36
+ const classCollection = new ClassList(['blu']);
37
+ expect(classCollection.has('blu')).toEqual(true);
38
+ expect(classCollection.has('bli')).toEqual(false);
39
+ });
40
+ test('Should return seperated space classes list', () => {
41
+ const classCollection = new ClassList(['blu', 'bli']);
42
+ expect(classCollection.join()).toEqual('blu bli');
43
+ });
44
+ });
45
+ describe('allItemsAreString', () => {
46
+ test.each([
47
+ { items: ['blu', 'bli', 'blo', 'bla'], expected: true },
48
+ { items: ['blu', 'bli', 'blo', { value: 'bla' }], expected: false },
49
+ ])('Should test if all otems are string: %s', ({ items, expected }) => {
50
+ expect(allItemsAreString(items)).toEqual(expected);
51
+ });
52
+ });
53
+ describe('isTagName', () => {
54
+ test.each([
55
+ { querySelector: 'h1', expected: true },
56
+ { querySelector: 'span', expected: false },
57
+ { querySelector: 'blu', expected: false },
58
+ ])('Should test if all otems are string: %s', ({ querySelector, expected }) => {
59
+ const div = document.createElement('div');
60
+ div.innerHTML = '<h1></h1><span></span>';
61
+ const elm = div.querySelector(querySelector);
62
+ expect(isTagName(elm, ['h1'])).toEqual(expected);
63
+ });
64
+ });
65
+ describe('getWindows', () => {
66
+ const mockWindowFramesLength = jest.fn();
67
+ const mockWindowIndexZero = jest.fn();
68
+ Object.defineProperty(window, 'frames', {
69
+ value: {
70
+ get length() {
71
+ return mockWindowFramesLength();
72
+ },
73
+ get 0() {
74
+ return mockWindowIndexZero();
75
+ },
76
+ },
77
+ });
78
+ afterEach(() => {
79
+ jest.clearAllMocks();
80
+ });
81
+ test('Should return the window in an array', () => {
82
+ mockWindowFramesLength.mockReturnValue(0);
83
+ const localWindow = window;
84
+ const windows = getWindows(localWindow);
85
+ expect(windows).toHaveLength(1);
86
+ expect(windows[0]).toEqual(localWindow);
87
+ });
88
+ test('Should return the window with a parent', () => {
89
+ mockWindowFramesLength.mockReturnValue(0);
90
+ const spyWindowSelf = jest.spyOn(window, 'self', 'get').mockImplementationOnce(jest.fn());
91
+ const spyWindowParent = jest.spyOn(window, 'parent', 'get').mockImplementationOnce(() => window);
92
+ const windows = getWindows(window);
93
+ expect(windows).toHaveLength(2);
94
+ expect(spyWindowSelf).toBeCalledTimes(2);
95
+ expect(spyWindowParent).toBeCalledTimes(1);
96
+ });
97
+ test('Should return the window with a child', () => {
98
+ mockWindowFramesLength.mockReturnValueOnce(1).mockReturnValueOnce(1).mockReturnValue(0);
99
+ mockWindowIndexZero.mockReturnValueOnce(window);
100
+ const windows = getWindows(window);
101
+ expect(windows).toHaveLength(2);
102
+ });
103
+ test('Should throw an error when cannot access top parent window', () => {
104
+ mockWindowFramesLength.mockReturnValue(0);
105
+ const spyConsole = jest.spyOn(console, 'error');
106
+ const spyWindowSelf = jest.spyOn(window, 'self', 'get').mockImplementationOnce(jest.fn());
107
+ const spyWindowParent = jest.spyOn(window, 'parent', 'get').mockImplementationOnce(() => {
108
+ throw new Error('non');
109
+ });
110
+ const localWindow = window;
111
+ const windows = getWindows(localWindow);
112
+ expect(windows).toHaveLength(1);
113
+ expect(windows[0]).toEqual(localWindow);
114
+ expect(spyConsole).toBeCalledTimes(1);
115
+ expect(spyWindowSelf).toBeCalledTimes(1);
116
+ expect(spyWindowParent).toBeCalledTimes(1);
117
+ });
118
+ });
119
+ describe('isValidString', () => {
120
+ test.each(['', ' ', null, undefined, 1, {}, []])('Should return "false" for invalid values', value => {
121
+ expect(isValidString(value)).toEqual(false);
122
+ });
123
+ test.each(['batman', 'batman '])('Should return "true" for valid value', value => {
124
+ expect(isValidString(value)).toEqual(true);
125
+ });
126
+ });
127
+ });
128
+ //# sourceMappingURL=components.utils.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.utils.spec.js","sourceRoot":"","sources":["../../src/utils/components.utils.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAClH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,gBAAgB,EAAE,CAAC;AAEnB,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;EAChC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,+CAA+C,EAAE,MAAM,CAAC,EAAE;MAC1F,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;MAC5B,IAAI,MAAM,GAAG,gBAAgB,CAAC;MAC9B,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,EAAE,EAAE;QACzC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,MAAM,gBAAgB,CAAC,CAAC;OACjD;MACD,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;EAEH,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,CAAC,4BAA4B,EAAE,GAAG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,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { createID, ClassList, allItemsAreString, isTagName, getWindows, isValidString } from './components.utils';\nimport { mockConsoleError } from './unit.test.utils';\n\nmockConsoleError();\n\ndescribe('components.utils', () => {\n describe('createID', () => {\n test.each([undefined, '', 'blu'])('Should generate a prefixed ID if defined : %s', prefix => {\n const id = createID(prefix);\n let regexp = /^[a-z0-9]{10}$/;\n if (prefix !== undefined && prefix !== '') {\n regexp = new RegExp(`^${prefix}-[a-z0-9]{10}$`);\n }\n expect(id).toMatch(regexp);\n });\n });\n\n describe('ClassList', () => {\n test('Should add classes to list', () => {\n const classCollection = new ClassList();\n expect(classCollection.classes).toEqual([]);\n classCollection.add('blu');\n expect(classCollection.classes).toEqual(['blu']);\n classCollection.add('bli');\n expect(classCollection.classes).toEqual(['blu', 'bli']);\n // Should not add classes if already in list\n classCollection.add('blu');\n expect(classCollection.classes).toEqual(['blu', 'bli']);\n });\n\n test('Should delete classes from list', () => {\n const classCollection = new ClassList(['blu', 'bli']);\n classCollection.delete('blu');\n expect(classCollection.classes).toEqual(['bli']);\n // List doesn't change if class name doesn't existe in list\n classCollection.delete('bla');\n expect(classCollection.classes).toEqual(['bli']);\n });\n\n test('Should check if class already in list', () => {\n const classCollection = new ClassList(['blu']);\n expect(classCollection.has('blu')).toEqual(true);\n expect(classCollection.has('bli')).toEqual(false);\n });\n\n test('Should return seperated space classes list', () => {\n const classCollection = new ClassList(['blu', 'bli']);\n expect(classCollection.join()).toEqual('blu bli');\n });\n });\n\n describe('allItemsAreString', () => {\n test.each([\n { items: ['blu', 'bli', 'blo', 'bla'], expected: true },\n { items: ['blu', 'bli', 'blo', { value: 'bla' }], expected: false },\n ])('Should test if all otems are string: %s', ({ items, expected }) => {\n expect(allItemsAreString(items as string[])).toEqual(expected);\n });\n });\n\n describe('isTagName', () => {\n test.each([\n { querySelector: 'h1', expected: true },\n { querySelector: 'span', expected: false },\n { querySelector: 'blu', expected: false },\n ])('Should test if all otems are string: %s', ({ querySelector, expected }) => {\n const div = document.createElement('div');\n div.innerHTML = '<h1></h1><span></span>';\n const elm = div.querySelector(querySelector);\n expect(isTagName(elm as HTMLElement, ['h1'])).toEqual(expected);\n });\n });\n\n describe('getWindows', () => {\n const mockWindowFramesLength = jest.fn();\n const mockWindowIndexZero = jest.fn();\n Object.defineProperty(window, 'frames', {\n value: {\n get length() {\n return mockWindowFramesLength();\n },\n get 0() {\n return mockWindowIndexZero();\n },\n },\n });\n\n afterEach(() => {\n jest.clearAllMocks();\n });\n\n test('Should return the window in an array', () => {\n mockWindowFramesLength.mockReturnValue(0);\n const localWindow: Window = window;\n const windows: Window[] = getWindows(localWindow);\n expect(windows).toHaveLength(1);\n expect(windows[0]).toEqual(localWindow);\n });\n\n test('Should return the window with a parent', () => {\n mockWindowFramesLength.mockReturnValue(0);\n const spyWindowSelf = jest.spyOn(window, 'self', 'get').mockImplementationOnce(jest.fn());\n const spyWindowParent = jest.spyOn(window, 'parent', 'get').mockImplementationOnce(() => window);\n\n const windows = getWindows(window);\n expect(windows).toHaveLength(2);\n expect(spyWindowSelf).toBeCalledTimes(2);\n expect(spyWindowParent).toBeCalledTimes(1);\n });\n\n test('Should return the window with a child', () => {\n mockWindowFramesLength.mockReturnValueOnce(1).mockReturnValueOnce(1).mockReturnValue(0);\n mockWindowIndexZero.mockReturnValueOnce(window);\n const windows = getWindows(window);\n expect(windows).toHaveLength(2);\n });\n\n test('Should throw an error when cannot access top parent window', () => {\n mockWindowFramesLength.mockReturnValue(0);\n const spyConsole = jest.spyOn(console, 'error');\n const spyWindowSelf = jest.spyOn(window, 'self', 'get').mockImplementationOnce(jest.fn());\n const spyWindowParent = jest.spyOn(window, 'parent', 'get').mockImplementationOnce(() => {\n throw new Error('non');\n });\n const localWindow: Window = window;\n const windows: Window[] = getWindows(localWindow);\n expect(windows).toHaveLength(1);\n expect(windows[0]).toEqual(localWindow);\n expect(spyConsole).toBeCalledTimes(1);\n expect(spyWindowSelf).toBeCalledTimes(1);\n expect(spyWindowParent).toBeCalledTimes(1);\n });\n });\n\n describe('isValidString', () => {\n test.each(['', ' ', null, undefined, 1, {}, []])('Should return \"false\" for invalid values', value => {\n expect(isValidString(value)).toEqual(false);\n });\n\n test.each(['batman', 'batman '])('Should return \"true\" for valid value', value => {\n expect(isValidString(value)).toEqual(true);\n });\n });\n});\n"]}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Add a darker background
3
+ * usefull for light rendered element
4
+ * @param condition - condition to add darker background
5
+ * @param html - html to update
6
+ * @returns html to render
7
+ */
8
+ export const darkBackground = (condition, html) => `${condition ? '<span style="background:#999;display:inline-block;">' : ''}${html}${condition ? '</span>' : ''}`;
9
+ /**
10
+ * Render attributes from props objects
11
+ * @param args - argument to render as string. ex: `{status: 'visible'}`
12
+ * @returns formated inline attributed. ex: 'status="visible"'
13
+ */
14
+ export const renderAttributes = (args) => (typeof args === 'object' &&
15
+ Object.keys(args)
16
+ .filter(key => ![null, undefined, false].includes(args[key]) && typeof args[key] !== 'object')
17
+ .map(key => `${key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()}="${args[key]}"`)
18
+ .join(' ')) ||
19
+ '';
20
+ /**
21
+ * Render properties from props objects.
22
+ * Insert return value in <script></script> element
23
+ * @param args - argument to render as script. ex: `{status: 'visible'}`
24
+ * @param selector - querySelector get targetted element and bind properties on it
25
+ * @returns stringified properties script
26
+ */
27
+ export const renderProperties = (args, selector) => {
28
+ // has generated id selector starting with "#" create charcters (ex: '#0j3xzw4w7m') make test crashed sometime with "querySelector"
29
+ // we use "getElementById" document query
30
+ const query = selector.startsWith('#') ? 'getElementById' : 'querySelector';
31
+ if (query === 'getElementById')
32
+ selector = selector.replace('#', '');
33
+ return typeof args === 'object'
34
+ ? `
35
+ ${Object.keys(args)
36
+ .filter(key => typeof args[key] === 'object')
37
+ .map(key => `document.${query}('${selector}').${key}=${JSON.stringify(args[key], (_key, val) => (typeof val === 'function' ? `<fn>${val}</fn>` : val))}`) // stringify json AND keep function values
38
+ .join(';\n') // create string
39
+ .split('"<fn>') // remove fn start decorator
40
+ .join('')
41
+ .split('</fn>"')
42
+ .join('') // remove fn end decorator
43
+ }`
44
+ : '';
45
+ };
46
+ //# sourceMappingURL=e2e.test.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"e2e.test.utils.js","sourceRoot":"","sources":["../../src/utils/e2e.test.utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAkB,EAAE,IAAY,EAAU,EAAE,CACzE,GAAG,SAAS,CAAC,CAAC,CAAC,sDAAsD,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAEnH;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAa,EAAU,EAAE,CACxD,CAAC,OAAO,IAAI,KAAK,QAAQ;EACvB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;KACd,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC;KAC7F,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;KACrF,IAAI,CAAC,GAAG,CAAC,CAAC;EACf,EAAE,CAAC;AAEL;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAa,EAAE,QAAgB,EAAU,EAAE;EAC1E,mIAAmI;EACnI,yCAAyC;EACzC,MAAM,KAAK,GAAuC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,eAAe,CAAC;EAChH,IAAI,KAAK,KAAK,gBAAgB;IAAE,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;EAErE,OAAO,OAAO,IAAI,KAAK,QAAQ;IAC7B,CAAC,CAAC;IAEF,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;OACd,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC;OAC5C,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,KAAK,KAAK,QAAQ,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,0CAA0C;OACnM,IAAI,CAAC,KAAK,CAAC,CAAC,gBAAgB;OAC5B,KAAK,CAAC,OAAO,CAAC,CAAC,4BAA4B;OAC3C,IAAI,CAAC,EAAE,CAAC;OACR,KAAK,CAAC,QAAQ,CAAC;OACf,IAAI,CAAC,EAAE,CAAC,CAAC,0BAA0B;IACxC,EAAE;IACA,CAAC,CAAC,EAAE,CAAC;AACT,CAAC,CAAC","sourcesContent":["/**\n * Add a darker background\n * usefull for light rendered element\n * @param condition - condition to add darker background\n * @param html - html to update\n * @returns html to render\n */\nexport const darkBackground = (condition: boolean, html: string): string =>\n `${condition ? '<span style=\"background:#999;display:inline-block;\">' : ''}${html}${condition ? '</span>' : ''}`;\n\n/**\n * Render attributes from props objects\n * @param args - argument to render as string. ex: `{status: 'visible'}`\n * @returns formated inline attributed. ex: 'status=\"visible\"'\n */\nexport const renderAttributes = (args: unknown): string =>\n (typeof args === 'object' &&\n Object.keys(args)\n .filter(key => ![null, undefined, false].includes(args[key]) && typeof args[key] !== 'object')\n .map(key => `${key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()}=\"${args[key]}\"`)\n .join(' ')) ||\n '';\n\n/**\n * Render properties from props objects.\n * Insert return value in <script></script> element\n * @param args - argument to render as script. ex: `{status: 'visible'}`\n * @param selector - querySelector get targetted element and bind properties on it\n * @returns stringified properties script\n */\nexport const renderProperties = (args: unknown, selector: string): string => {\n // has generated id selector starting with \"#\" create charcters (ex: '#0j3xzw4w7m') make test crashed sometime with \"querySelector\"\n // we use \"getElementById\" document query\n const query: 'querySelector' | 'getElementById' = selector.startsWith('#') ? 'getElementById' : 'querySelector';\n if (query === 'getElementById') selector = selector.replace('#', '');\n\n return typeof args === 'object'\n ? `\n ${\n Object.keys(args)\n .filter(key => typeof args[key] === 'object')\n .map(key => `document.${query}('${selector}').${key}=${JSON.stringify(args[key], (_key, val) => (typeof val === 'function' ? `<fn>${val}</fn>` : val))}`) // stringify json AND keep function values\n .join(';\\n') // create string\n .split('\"<fn>') // remove fn start decorator\n .join('')\n .split('</fn>\"')\n .join('') // remove fn end decorator\n }`\n : '';\n};\n"]}
@@ -54,3 +54,4 @@ export const getLocaleMessages = (element, messages, defaultLocale) => {
54
54
  messages: messages[localeSubtag] || messages[defaultLocale],
55
55
  };
56
56
  };
57
+ //# sourceMappingURL=locale.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.utils.js","sourceRoot":"","sources":["../../src/utils/locale.utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,QAAgB,EAAU,EAAE;EACzF,OAAO,IAAI,IAAI,CAAC,YAAY,CA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zB,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;EAC/C,SAAS;EACT,OAAO;IACL,MAAM;IACN,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,IAAI,QAAQ,CAAC,aAAa,CAAC;GAC5D,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Format number to the locale currency\n * @param number - number to format\n * @param locale - locale to apply\n * @param currency - currency to apply\n * @returns formatted currency\n */\nexport const localeCurrency = (number: number, locale: string, currency: string): string => {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);\n};\n\n/**\n * Format number to locale\n * @param number - number to format\n * @param locale - locale to apply\n * @returns formatted number\n */\nexport const localeNumber = (number: number, locale: string): string => {\n return new Intl.NumberFormat(locale).format(number);\n};\n\n/**\n * Date RegExp\n */\nexport const dateRegExp = /^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$/;\n\n/**\n * Locale date format\n * @param date - date to format\n * @param locale - locale to apply\n * @returns formatted date\n */\nexport const localeDate = (date: string, locale: string): string => {\n if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {\n return '';\n }\n return new Intl.DateTimeFormat(locale).format(new Date(date));\n};\n\n/**\n * Get locale and messages\n * We load the defined locale but for now we only support the first subtag for messages\n * @param element - element we need to get the language\n * @param messages - messages to use\n * @param defaultLocale - default messages locale\n * @returns messages object\n */\nexport const getLocaleMessages = (element: HTMLElement, messages: unknown, defaultLocale: string): { locale: string; messages: Record<string, unknown> } => {\n // Get local\n const closestLangAttribute: HTMLElement = element.closest('[lang]');\n const closestLang: string[] = Intl.NumberFormat.supportedLocalesOf(closestLangAttribute?.lang);\n const locale = closestLang.length > 0 ? closestLang[0] : navigator.language || defaultLocale;\n // Only keep first subtag\n const localeSubtag = locale.split('-').shift();\n // Return\n return {\n locale,\n messages: messages[localeSubtag] || messages[defaultLocale],\n };\n};\n"]}
@@ -0,0 +1,52 @@
1
+ import { localeCurrency, localeNumber, localeDate, getLocaleMessages } from "./locale.utils";
2
+ import messagesEn from "../locales/en/messages.json";
3
+ import messagesFr from "../locales/fr/messages.json";
4
+ describe('locale.utils', () => {
5
+ describe.each(['en', 'fr'])('locale.utils: %s', locale => {
6
+ describe('localeCurrency', () => {
7
+ test('Should Format number to the locale currency', () => {
8
+ const formatedCurrency = localeCurrency(1234567890.12, locale, 'EUR');
9
+ expect(formatedCurrency).toEqual(locale === 'en' ? '€1,234,567,890.12' : '1 234 567 890,12\xa0€');
10
+ });
11
+ });
12
+ describe('localeNumber', () => {
13
+ test('Should Format number to the locale', () => {
14
+ const formatedCurrency = localeNumber(1234567890.12, locale);
15
+ expect(formatedCurrency).toEqual(locale === 'en' ? '1,234,567,890.12' : '1 234 567 890,12');
16
+ });
17
+ });
18
+ describe('localeDate', () => {
19
+ test.each([undefined, '', 'blu'])('Should return empty string: %s', date => {
20
+ const formatedDate = localeDate(date, locale);
21
+ expect(formatedDate).toEqual('');
22
+ });
23
+ test('Should return formated date', () => {
24
+ const formatedDate = localeDate('2022-06-02', locale);
25
+ expect(formatedDate).toEqual(locale === 'en' ? '6/2/2022' : '02/06/2022');
26
+ });
27
+ });
28
+ describe('getLocaleMessages', () => {
29
+ const messages = { en: messagesEn, fr: messagesFr };
30
+ test('Should return default locale', () => {
31
+ const locales = getLocaleMessages(document.createElement('div'), messages, 'en');
32
+ expect(locales.locale).toEqual('en');
33
+ expect(locales.messages).toMatchObject(messagesEn);
34
+ });
35
+ test('Should return matching locale', () => {
36
+ const div = document.createElement('div');
37
+ div.lang = 'fr-FR';
38
+ const locales = getLocaleMessages(div, messages, 'en');
39
+ expect(locales.locale).toEqual(div.lang);
40
+ expect(locales.messages).toMatchObject(messagesFr);
41
+ });
42
+ test('Should return default locale messages when requested does not exist', () => {
43
+ const div = document.createElement('div');
44
+ div.lang = 'ca';
45
+ const locales = getLocaleMessages(div, messages, 'en');
46
+ expect(locales.locale).toEqual(div.lang);
47
+ expect(locales.messages).toMatchObject(messagesEn);
48
+ });
49
+ });
50
+ });
51
+ });
52
+ //# sourceMappingURL=locale.utils.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.utils.spec.js","sourceRoot":"","sources":["../../src/utils/locale.utils.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,UAAU,MAAM,6BAA6B,CAAC;AACrD,OAAO,UAAU,MAAM,6BAA6B,CAAC;AAErD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;EAC5B,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,kBAAkB,EAAE,MAAM,CAAC,EAAE;IACvD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;MAC9B,IAAI,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACvD,MAAM,gBAAgB,GAAG,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACtE,MAAM,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC;MACpG,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;MAC5B,IAAI,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC9C,MAAM,gBAAgB,GAAG,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAC7D,MAAM,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;MAC9F,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG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GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QACvD,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;MACrD,CAAC,CAAC,CAAC;MAEH,IAAI,CAAC,qEAAqE,EAAE,GAAG,EAAE;QAC/E,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1C,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;QAChB,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QACvD,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;MACrD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { localeCurrency, localeNumber, localeDate, getLocaleMessages } from './locale.utils';\nimport messagesEn from '../locales/en/messages.json';\nimport messagesFr from '../locales/fr/messages.json';\n\ndescribe('locale.utils', () => {\n describe.each(['en', 'fr'])('locale.utils: %s', locale => {\n describe('localeCurrency', () => {\n test('Should Format number to the locale currency', () => {\n const formatedCurrency = localeCurrency(1234567890.12, locale, 'EUR');\n expect(formatedCurrency).toEqual(locale === 'en' ? '€1,234,567,890.12' : '1 234 567 890,12\\xa0€');\n });\n });\n\n describe('localeNumber', () => {\n test('Should Format number to the locale', () => {\n const formatedCurrency = localeNumber(1234567890.12, locale);\n expect(formatedCurrency).toEqual(locale === 'en' ? '1,234,567,890.12' : '1 234 567 890,12');\n });\n });\n\n describe('localeDate', () => {\n test.each([undefined, '', 'blu'])('Should return empty string: %s', date => {\n const formatedDate = localeDate(date, locale);\n expect(formatedDate).toEqual('');\n });\n\n test('Should return formated date', () => {\n const formatedDate = localeDate('2022-06-02', locale);\n expect(formatedDate).toEqual(locale === 'en' ? '6/2/2022' : '02/06/2022');\n });\n });\n\n describe('getLocaleMessages', () => {\n const messages = { en: messagesEn, fr: messagesFr };\n test('Should return default locale', () => {\n const locales = getLocaleMessages(document.createElement('div'), messages, 'en');\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 = getLocaleMessages(div, messages, 'en');\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 = getLocaleMessages(div, messages, 'en');\n expect(locales.locale).toEqual(div.lang);\n expect(locales.messages).toMatchObject(messagesEn);\n });\n });\n });\n});\n"]}
@@ -0,0 +1,100 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { test as playwrightTest, expect as playwrightExpect, devices as playwrightDevices } from "@playwright/test";
3
+ import { readFile } from "fs/promises";
4
+ import { join } from "path";
5
+ /**
6
+ * Add mg-components to browser page
7
+ *
8
+ * @param page - browser page
9
+ * @param html - html to load in page
10
+ */
11
+ export const setPageContent = async (page, html, viewportSize) => {
12
+ // We need to add mg-components to the e2e page
13
+ // Those solutions wasn't working to add the CSS
14
+ // await page.addStyleTag({ url: 'http://localhost:3333/build/mg-components.css' });
15
+ // CSS
16
+ const css = await readFile(join(__dirname, '../../www/build/mg-components.css'), { encoding: 'utf8' });
17
+ await page.addStyleTag({ content: css });
18
+ // JS
19
+ await page.addScriptTag({ url: 'http://localhost:3333/build/mg-components.esm.js', type: 'module' });
20
+ // Set page content
21
+ // Added the `e2e-screenshot` class to be able to do the screenshot on this specific one with
22
+ // `await expect(page.locator('.e2e-screenshot')).toHaveScreenshot();`
23
+ await page.setContent(`<style>${css} .e2e-screenshot { display: inline-block; }</style><span class="e2e-screenshot">${html}</span>`);
24
+ // Set page size
25
+ if (viewportSize !== undefined)
26
+ await page.setViewportSize(viewportSize);
27
+ // Make sure everything is loaded
28
+ await page.waitForLoadState('networkidle');
29
+ await page.waitForSelector('html.hydrated');
30
+ };
31
+ /**
32
+ * playwright 'expect' function definition
33
+ */
34
+ export const expect = playwrightExpect;
35
+ /**
36
+ * playwright 'describe' function definition
37
+ */
38
+ export const describe = playwrightTest.describe;
39
+ /**
40
+ * playwright 'test' function definition
41
+ */
42
+ export const test = playwrightTest;
43
+ /**
44
+ * playwright 'devices' definition
45
+ */
46
+ export const devices = playwrightDevices;
47
+ /**
48
+ * Value to get in string
49
+ * @param value - valut to stringify
50
+ * @returns stringified value
51
+ */
52
+ const valueToString = (value) => (typeof value === 'object' ? JSON.stringify(value) : `${value}`);
53
+ /**
54
+ * repeat test over array
55
+ * @param array - array of test
56
+ * @param option - test runner option
57
+ * @returns describe iteration
58
+ */
59
+ export const describeEach = (array, option) => (title, cb) => {
60
+ array.forEach(value => {
61
+ const displayTitle = title.replace('%s', valueToString(value));
62
+ const fn = () => cb(value);
63
+ if (Boolean(option))
64
+ describe[option](displayTitle, fn);
65
+ else
66
+ describe(displayTitle, fn);
67
+ });
68
+ };
69
+ /**
70
+ * repeat test over array
71
+ * @param array - array of test
72
+ * @param option - test runner option
73
+ * @returns test iteration
74
+ */
75
+ export const testEach = (array, option) => (title, cb) => {
76
+ array.forEach(value => {
77
+ const displayTitle = title.replace('%s', valueToString(value));
78
+ const fn = async ({ page }) => cb(page, value);
79
+ if (Boolean(option))
80
+ test[option](displayTitle, fn);
81
+ else
82
+ test(displayTitle, fn);
83
+ });
84
+ };
85
+ /**
86
+ * Update .e2e-screenshot style for screenshot needs
87
+ * @param page - playwright Page
88
+ * @param params - css properties to apply
89
+ * @returns class style definition
90
+ */
91
+ export const updateScreenshotClass = async (page, params) => page.evaluate(params => {
92
+ const css = `.e2e-screenshot { ${Object.keys(params)
93
+ .map(key => `${key}: ${typeof params[key] === 'string' ? params[key] : ''}`)
94
+ .join(';')} }`;
95
+ const body = document.getElementsByTagName('body')[0];
96
+ const style = document.createElement('style');
97
+ body.appendChild(style);
98
+ style.appendChild(document.createTextNode(css));
99
+ }, params);
100
+ //# sourceMappingURL=playwright.e2e.test.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.e2e.test.utils.js","sourceRoot":"","sources":["../../src/utils/playwright.e2e.test.utils.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAA2B,IAAI,IAAI,cAAc,EAAE,MAAM,IAAI,gBAAgB,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC7I,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,IAAU,EAAE,IAAY,EAAE,YAA2B,EAAiB,EAAE;EAC3G,+CAA+C;EAC/C,gDAAgD;EAChD,oFAAoF;EAEpF,MAAM;EACN,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,mCAAmC,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;EACvG,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;EAEzC,KAAK;EACL,MAAM,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,kDAAkD,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;EAErG,mBAAmB;EACnB,6FAA6F;EAC7F,sEAAsE;EACtE,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,mFAAmF,IAAI,SAAS,CAAC,CAAC;EAErI,gBAAg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AC,KAAK,CAAC,CAAC;EACxB,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC,EAAE,MAAM,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type Page, ViewportSize, test as playwrightTest, expect as playwrightExpect, devices as playwrightDevices } from '@playwright/test';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\n\n/**\n * Add mg-components to browser page\n *\n * @param page - browser page\n * @param html - html to load in page\n */\nexport const setPageContent = async (page: Page, html: string, viewportSize?: ViewportSize): Promise<void> => {\n // We need to add mg-components to the e2e page\n // Those solutions wasn't working to add the CSS\n // await page.addStyleTag({ url: 'http://localhost:3333/build/mg-components.css' });\n\n // CSS\n const css = await readFile(join(__dirname, '../../www/build/mg-components.css'), { encoding: 'utf8' });\n await page.addStyleTag({ content: css });\n\n // JS\n await page.addScriptTag({ url: 'http://localhost:3333/build/mg-components.esm.js', type: 'module' });\n\n // Set page content\n // Added the `e2e-screenshot` class to be able to do the screenshot on this specific one with\n // `await expect(page.locator('.e2e-screenshot')).toHaveScreenshot();`\n await page.setContent(`<style>${css} .e2e-screenshot { display: inline-block; }</style><span class=\"e2e-screenshot\">${html}</span>`);\n\n // Set page size\n if (viewportSize !== undefined) await page.setViewportSize(viewportSize);\n\n // Make sure everything is loaded\n await page.waitForLoadState('networkidle');\n await page.waitForSelector('html.hydrated');\n};\n\n/**\n * playwright 'expect' function definition\n */\nexport const expect = playwrightExpect;\n\n/**\n * playwright 'describe' function definition\n */\nexport const describe = playwrightTest.describe;\n\n/**\n * playwright 'test' function definition\n */\nexport const test = playwrightTest;\n\n/**\n * playwright 'devices' definition\n */\nexport const devices = playwrightDevices;\n\n/**\n * Value to get in string\n * @param value - valut to stringify\n * @returns stringified value\n */\nconst valueToString = (value: unknown): string => (typeof value === 'object' ? JSON.stringify(value) : `${value}`);\n\n/**\n * Declare page type\n */\nexport type PageType = Page;\n\n/**\n * repeat test over array\n * @param array - array of test\n * @param option - test runner option\n * @returns describe iteration\n */\nexport const describeEach = (array: unknown[] | any, option?: 'skip' | 'only') => (title: string, cb: (param: unknown) => void) => {\n array.forEach(value => {\n const displayTitle = title.replace('%s', valueToString(value));\n const fn = () => cb(value);\n if (Boolean(option)) describe[option](displayTitle, fn);\n else describe(displayTitle, fn);\n });\n};\n\n/**\n * repeat test over array\n * @param array - array of test\n * @param option - test runner option\n * @returns test iteration\n */\nexport const testEach = (array: unknown[] | any, option?: 'skip' | 'only') => (title: string, cb: (page: PageType, param: unknown) => Promise<void>) => {\n array.forEach(value => {\n const displayTitle = title.replace('%s', valueToString(value));\n const fn = async ({ page }) => cb(page, value);\n if (Boolean(option)) test[option](displayTitle, fn);\n else test(displayTitle, fn);\n });\n};\n\n/**\n * Update .e2e-screenshot style for screenshot needs\n * @param page - playwright Page\n * @param params - css properties to apply\n * @returns class style definition\n */\nexport const updateScreenshotClass = async (page: Page, params: unknown): Promise<void> =>\n page.evaluate(params => {\n const css = `.e2e-screenshot { ${Object.keys(params)\n .map(key => `${key}: ${typeof params[key] === 'string' ? params[key] : ''}`)\n .join(';')} }`;\n const body = document.getElementsByTagName('body')[0];\n const style = document.createElement('style');\n body.appendChild(style);\n style.appendChild(document.createTextNode(css));\n }, params);\n"]}
@@ -0,0 +1,33 @@
1
+ import { newE2EPage } from "@stencil/core/testing";
2
+ /**
3
+ * Create E2E page
4
+ *
5
+ * @param htmlString - html to render
6
+ * @param viewPort - custom page viewPort - optional
7
+ * @returns page
8
+ */
9
+ export async function createPage(htmlString, viewPort) {
10
+ const defaultSize = 600;
11
+ const page = (await newE2EPage());
12
+ await page.setViewport({ width: (viewPort === null || viewPort === void 0 ? void 0 : viewPort.width) || defaultSize, height: (viewPort === null || viewPort === void 0 ? void 0 : viewPort.height) || defaultSize });
13
+ await page.setContent(`<link rel="stylesheet" href="http://localhost:3333/build/variables.css" /><meta charset="UTF-8">${htmlString}`, { waitUntil: 'networkidle0' });
14
+ await page.evaluateHandle('document.fonts.ready');
15
+ // monkey patch screenshot function to add some extra features
16
+ const screenshot = page.screenshot;
17
+ page.screenshot = async () => {
18
+ let width = page.viewport().width;
19
+ let height = page.viewport().height;
20
+ // if viewport has not been redefined
21
+ if (page.viewport().width === defaultSize && page.viewport().height === defaultSize) {
22
+ const htmlElement = await page.$('html');
23
+ const boundingBox = await htmlElement.boundingBox();
24
+ width = Math.round(boundingBox.width);
25
+ height = Math.round(boundingBox.height);
26
+ }
27
+ return screenshot.call(page, {
28
+ clip: { x: 0, y: 0, width, height },
29
+ });
30
+ };
31
+ return page;
32
+ }
33
+ //# sourceMappingURL=stencil.e2e.test.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stencil.e2e.test.utils.js","sourceRoot":"","sources":["../../src/utils/stencil.e2e.test.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,uBAAuB,CAAC;AAK5D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAAkB,EAAE,QAA8C;EACjG,MAAM,WAAW,GAAG,GAAG,CAAC;EACxB,MAAM,IAAI,GAAG,CAAC,MAAM,UAAU,EAAE,CAAwB,CAAC;EACzD,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,KAAI,WAAW,EAAE,MAAM,EAAE,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,KAAI,WAAW,EAAE,CAAC,CAAC;EAC3G,MAAM,IAAI,CAAC,UAAU,CAAC,mGAAmG,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;EACtK,MAAM,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC;EAElD,8DAA8D;EAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;EACnC,IAAI,CAAC,UAAU,GAAG,KAAK,IAAI,EAAE;IAC3B,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC;IAClC,IAAI,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC;IACpC,qCAAqC;IACrC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,KAAK,WAAW,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,KAAK,WAAW,EAAE;MACnF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;MACzC,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,WAAW,EAAE,CAAC;MACpD,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;MACtC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;KACzC;IAED,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE;MAC3B,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE;KACpC,CAAC,CAAC;EACL,CAAC,CAAC;EAEF,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { newE2EPage, E2EPage } from '@stencil/core/testing';\nimport { Page as PuppeteerPage } from 'puppeteer';\n\nexport type DesignSystemE2EPage = E2EPage & Pick<PuppeteerPage, 'screenshot' | 'viewport'>;\n\n/**\n * Create E2E page\n *\n * @param htmlString - html to render\n * @param viewPort - custom page viewPort - optional\n * @returns page\n */\nexport async function createPage(htmlString: string, viewPort?: { width?: number; height?: number }): Promise<DesignSystemE2EPage> {\n const defaultSize = 600;\n const page = (await newE2EPage()) as DesignSystemE2EPage;\n await page.setViewport({ width: viewPort?.width || defaultSize, height: viewPort?.height || defaultSize });\n await page.setContent(`<link rel=\"stylesheet\" href=\"http://localhost:3333/build/variables.css\" /><meta charset=\"UTF-8\">${htmlString}`, { waitUntil: 'networkidle0' });\n await page.evaluateHandle('document.fonts.ready');\n\n // monkey patch screenshot function to add some extra features\n const screenshot = page.screenshot;\n page.screenshot = async () => {\n let width = page.viewport().width;\n let height = page.viewport().height;\n // if viewport has not been redefined\n if (page.viewport().width === defaultSize && page.viewport().height === defaultSize) {\n const htmlElement = await page.$('html');\n const boundingBox = await htmlElement.boundingBox();\n width = Math.round(boundingBox.width);\n height = Math.round(boundingBox.height);\n }\n\n return screenshot.call(page, {\n clip: { x: 0, y: 0, width, height },\n });\n };\n\n return page;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable jsdoc/require-jsdoc */
2
- import { MockCustomEvent } from '@stencil/core/mock-doc';
2
+ import { MockCustomEvent } from "@stencil/core/mock-doc";
3
3
  /**
4
4
  * Clone Deep function
5
5
  * @param obj - object to clone
@@ -127,3 +127,4 @@ export const mockWindowFrames = () => {
127
127
  value: { length: 0 },
128
128
  });
129
129
  };
130
+ //# sourceMappingURL=unit.test.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit.test.utils.js","sourceRoot":"","sources":["../../src/utils/unit.test.utils.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAY,EAAW,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AAuBpF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAmC,EAA2B,EAAE;EAC1I,MAAM,oBAAoB;IAKxB,YAAY,EAAE;MAJd,eAAU,GAAe,UAAU,CAAC;MACpC,YAAO,GAA2D,OAAO,CAAC;MAC1E,gBAAW,GAA2B,WAAW,CAAC;MAGhD,IAAI,CAAC,EAAE,G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ockCustomEvent } from '@stencil/core/mock-doc';\n\n/**\n * Clone Deep function\n * @param obj - object to clone\n * @returns cloned json\n */\nexport const cloneDeep = (obj: unknown): unknown => JSON.parse(JSON.stringify(obj));\n\n/**\n * Utility function that mocks the `MutationObserver` API. Recommended to execute inside `beforeEach`.\n * @param mutationObserverMock - Parameter that is sent to the `Object.defineProperty`\n * overwrite method. `jest.fn()` mock functions can be passed here if the goal is to not only\n * mock the mutation observer, but its methods.\n * You can manually fire an intersection entry:\n * @param mutationObserverMock - configuration object\n * @returns Mocked MutationObserver\n * @example\n * ```\n * let fireMo;\n * setupMutationObserverMock({\n * observe: function () {\n * fireMo = this.cb;\n * },\n * });\n * ...\n * fireMo([{ type: 'childList', addedNodes: [AMockElemenet, AnotherMockElemenet], target: yourMockElemenet }]);;\n * ```\n */\ntype SetupMutationObserverMockParams = { disconnect: MutationObserver['disconnect']; observe: MutationObserver['observe']; takeRecords: MutationObserver['takeRecords'] };\nexport const setupMutationObserverMock = ({ disconnect, observe, takeRecords }: SetupMutationObserverMockParams): typeof MutationObserver => {\n class MockMutationObserver implements MutationObserver {\n disconnect: () => void = disconnect;\n observe: (target: Node, options?: MutationObserverInit) => void = observe;\n takeRecords: () => MutationRecord[] = takeRecords;\n cb: () => unknown;\n constructor(fn) {\n this.cb = fn;\n }\n }\n\n [window, global].forEach(element => {\n Object.defineProperty(element, 'MutationObserver', {\n writable: true,\n configurable: true,\n value: MockMutationObserver,\n });\n });\n\n return MockMutationObserver;\n};\n\ntype setupResizeObserverMockParams = { disconnect: ResizeObserver['disconnect']; observe: ResizeObserver['observe'] };\n\n/**\n * Utility function that mocks the `ResizeObserver` API. Recommended to execute inside `beforeEach`.\n * @param resizeObserverMock - Parameter that is sent to the `Object.defineProperty`\n * overwrite method. `jest.fn()` mock functions can be passed here if the goal is to not only\n * mock the resize observer, but its methods.\n * You can manually fire an intersection entry:\n * @param resizeObserverMock - configuration object\n * @returns Mocked ResizeObserver\n * @example\n * ```\n * let fireRo;\n * setupResizeObserverMock({\n * observe: function () {\n * fireRo = this.cb;\n * },\n * });\n * ...\n * fireRo([{\n * borderBoxSize: ResizeObserverSize[],\n * contentBoxSize: ResizeObserverSize[],\n * contentRect: DOMRectReadOnly,\n * devicePixelContentBoxSize: ResizeObserverSize[],\n * target: yourMockElemenet\n * }]);;\n * ```\n */\nexport const setupResizeObserverMock = ({ disconnect, observe }: setupResizeObserverMockParams): typeof ResizeObserver => {\n class MockResizeObserver implements ResizeObserver {\n disconnect: () => void = disconnect;\n observe: (target: Element, options?: ResizeObserverOptions) => void = observe;\n unobserve: () => void;\n cb: () => unknown;\n constructor(fn) {\n this.cb = fn;\n }\n }\n\n [window, global].forEach(element => {\n Object.defineProperty(element, 'ResizeObserver', {\n writable: true,\n configurable: true,\n value: MockResizeObserver,\n });\n });\n\n return MockResizeObserver;\n};\n\n/**\n * Utility function that mocks the `SubmitEvent` API. Recommended to execute inside `beforeEach`.\n * @example\n * ```\n * setupSubmitEventMock();\n * ```\n * @returns custom event mock\n */\nexport const setupSubmitEventMock = (): typeof MockCustomEvent => {\n class SubmitEvent extends MockCustomEvent {\n constructor(type: string, eventInitDict?: SubmitEventInit) {\n super(type, eventInitDict);\n }\n }\n\n [window, global].forEach(element => {\n Object.defineProperty(element, 'SubmitEvent', {\n writable: true,\n configurable: true,\n value: SubmitEvent,\n });\n });\n\n return SubmitEvent;\n};\n\n/**\n * force popover id when component use randomed identifier\n * @param component - element wich include mg-popover\n * @param id - new fixed id\n * @param interactiveElement - element where attribute 'aria-controls' is set\n */\nexport const forcePopoverId = (component: Element, id: string, interactiveElement = 'button'): void => {\n const popover = component.shadowRoot.querySelector('mg-popover');\n if (popover !== null) {\n popover.querySelector('mg-popover-content').setAttribute('id', id);\n component.shadowRoot.querySelector(interactiveElement).setAttribute('aria-controls', id);\n }\n};\n\n/**\n * fix popper console.error in test\n * it is generated in `@popperjs/core/dist/cjs/popper.js l.1859`\n * this is due to internal function isHTMLElement(), so we can not mock it directly.\n * this function check if test DOM element mockHTMLElement instance is 'instanceof HTMLElement'\n * so we only override the console.error side effect for this error\n */\nexport const mockConsoleError = (): void => {\n const errorFunction = console.error;\n const mock = jest.spyOn(console, 'error');\n mock.mockImplementation(error => {\n if (!error.includes('Popper')) errorFunction(error);\n });\n};\n\n/**\n * Add missing window.frames property to test context\n * usefull for component with iframe listeners, ex: mg-popover\n */\nexport const mockWindowFrames = (): void => {\n Object.defineProperty(window, 'frames', {\n value: { length: 0 },\n });\n};\n"]}
@@ -133,3 +133,5 @@ const MgInput = (props, children, utils) => {
133
133
  };
134
134
 
135
135
  export { MgInput as M };
136
+
137
+ //# sourceMappingURL=MgInput.js.map
@@ -0,0 +1 @@
1
+ {"file":"MgInput.js","mappings":";;AAAA;;;AAGO,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,CAAU;;ACCjD;;;;;;;AAOA,MAAM,oBAAoB,GAAG,CAAC,QAAiB,EAAE,kBAA+B,EAAE,KAA0B,KAC1G,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK;EACvB,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAc,CAAC,EAAE;IAClE,uCACK,KAAK,KACR,MAAM,kCACD,KAAK,CAAC,MAAM,KACf,kBAAkB,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAEvD;GACH;;EAGD,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI;IAAE,yBAAY,KAAK,EAAG;EAClD,uCACK,KAAK,KACR,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,kBAAkB,EAAE,KAAK,CAAC,IAC3E;AACJ,CAAC,CAAC,CAAC;AAEL;;;;AAIA,MAAM,aAAa,GAAG,CAAC,KAAmB;EACxC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;EAEt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AE,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE;IACzC,KAAK,CAAC,UAAU,IACf,WAAK,KAAK,EAAC,iBAAiB;MACzB,aAAa,EAAE;MACf,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,OAAO,IAAI,UAAU,EAAE,CAC7C,KAEN,aAAa,EAAE,CAChB;IACA,KAAK,CAAC,QAAQ,IACb,WAAK,KAAK,EAAC,2BAA2B;MACpC,kBAAS,KAAK,CAAC,aAAa,CAAU;MACrC,QAAQ,CAAC,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,cAAc,CAAC,CACtD,KAEN,WAAK,KAAK,EAAC,2BAA2B;MACpC,WAAK,KAAK,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,4BAA4B,EAAE,KAAK,CAAC,YAAY,KAAK,SAAS,EAAE;QACpG,oBAAoB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,KAAK,CAAC;QACzD,CAAC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,OAAO,IAAI,UAAU,EAAE,CAC/C;MACL,KAAK,CAAC,QAAQ,IAAI,WAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAC,qBAAqB,EAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,GAAQ;MACpG,KAAK,CAAC,YAAY,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,KACvD,WAAK,EAAE,EAAE,eAAe,EAAE,KAAK,EAAC,iBAAiB,EAAC,SAAS,EAAE,KAAK,CAAC,YAAY,eAAY,WAAW,GAAO,CAC9G,CACG,CACP,CACO,EACV;AACJ;;;;","names":[],"sources":["src/components/molecules/inputs/MgInput.conf.ts","src/components/molecules/inputs/MgInput.tsx"],"sourcesContent":["/**\n * Possible input width\n */\nexport const widths = [2, 4, 16, 'full'] as const;\n\nexport type Width = (typeof widths)[number];\n\n/**\n * Possible Input types\n */\n\nexport type HTMLMgInputsElement =\n | HTMLMgInputCheckboxElement\n | HTMLMgInputDateElement\n | HTMLMgInputNumericElement\n | HTMLMgInputPasswordElement\n | HTMLMgInputRadioElement\n | HTMLMgInputSelectElement\n | HTMLMgInputTextElement\n | HTMLMgInputTextareaElement\n | (HTMLMgInputToggleElement & { required: true; invalid: false; displayError: () => void });\n","import { FunctionalComponent, h, VNode, FunctionalUtilities } from '@stencil/core';\nimport { widths, Width } from './MgInput.conf';\nimport { ClassList } from '../../../utils/components.utils';\n\n/**\n * Apply in all input child node the aria-describedby attribute\n * @param children - Represent scoped elements\n * @param ariaDescribedbyIDs - List of IDs\n * @param utils - Stencil.js utils\n * @returns Children with aria-describedby attribute\n */\nconst applyAriadescribedBy = (children: VNode[], ariaDescribedbyIDs: Set<string>, utils: FunctionalUtilities): VNode[] =>\n utils.map(children, child => {\n if (['input', 'select', 'textarea'].includes(child.vtag as string)) {\n return {\n ...child,\n vattrs: {\n ...child.vattrs,\n 'aria-describedby': [...ariaDescribedbyIDs].join(' '),\n },\n };\n }\n\n // we recursively apply ariadescribedBy attributes to child input nodes if exists\n if (child.vchildren === null) return { ...child };\n return {\n ...child,\n vchildren: applyAriadescribedBy(child.vchildren, ariaDescribedbyIDs, utils),\n };\n });\n\n/**\n * Add classes based on props\n * @param props - MgInput Interface Props\n */\nconst manageClasses = (props: MgInputProps): void => {\n props.classCollection.add('mg-input');\n\n if (props.labelOnTop) props.classCollection.add('mg-input--label-on-top');\n else props.classCollection.delete('mg-input--label-on-top');\n\n if (props.readonly) props.classCollection.add('mg-input--readonly');\n else props.classCollection.delete('mg-input--readonly');\n\n widths.forEach(width => {\n props.classCollection.delete(`mg-input--width-${width}`);\n });\n if (props.mgWidth !== undefined) props.classCollection.add(`mg-input--width-${props.mgWidth}`);\n};\n\n/**\n * Get tagname\n * @param isFieldset - is fieldset\n * @returns tag name\n */\nconst getTagName = (isFieldset: boolean): string => (isFieldset ? 'fieldset' : 'div');\n\n/**\n * MgInput Interface\n */\ninterface MgInputProps {\n // Global\n identifier: string;\n classCollection: ClassList;\n // Label\n label: string;\n labelOnTop: boolean;\n labelHide: boolean;\n isFieldset: boolean;\n // Input\n value: string;\n readonlyValue: string;\n required: boolean;\n readonly: boolean;\n mgWidth: Width;\n disabled: boolean;\n // Tooltip\n tooltip: string;\n // Help Text\n helpText: string;\n // Error Message\n errorMessage: string;\n // ariaDescribedbyIDs\n ariaDescribedbyIDs: string[];\n}\n\n/**\n * Get input template\n * @param props - MgInput Interface Props\n * @param children - Represent scoped elements\n * @param utils - Stencil.js utils\n * @returns input template\n */\nexport const MgInput: FunctionalComponent<MgInputProps> = (props: MgInputProps, children: VNode[], utils: FunctionalUtilities): VNode[] => {\n /**\n * Check required properties\n */\n if (typeof props.identifier !== 'string' || props.identifier.trim() === '') {\n throw new Error('<mg-input> prop \"identifier\" is required.');\n }\n if (typeof props.label !== 'string' || props.label.trim() === '') {\n throw new Error('<mg-input> prop \"label\" is required.');\n }\n if (props.labelOnTop && props.labelHide) {\n throw new Error('<mg-input> prop \"labelOnTop\" must not be paired with the prop \"labelHide\".');\n }\n\n /**\n * Set readonly value\n */\n if (props.readonlyValue === undefined) props.readonlyValue = props.value;\n\n /**\n * Component classes\n */\n manageClasses(props);\n\n /**\n * a11y IDs\n */\n const ariaDescribedbyIDs: Set<string> = new Set(props.ariaDescribedbyIDs);\n\n // Help text\n const helpTextId = `${props.identifier}-help-text`;\n if (typeof props.helpText === 'string' && props.helpText !== '') {\n ariaDescribedbyIDs.add(helpTextId);\n }\n\n // Error Message\n const helpTextErrorId = `${props.identifier}-error`;\n if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {\n ariaDescribedbyIDs.add(helpTextErrorId);\n }\n\n /**\n * Return template\n *\n * +--------+--------------+---------+\n * | label | input | tooltip |\n * | +--------------+---------+\n * | | nb Char Left |\n * | +------------------------+\n * | | Help Text |\n * | +------------------------+\n * | | Error |\n * +--------+------------------------+\n *\n * Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change\n */\n\n const TagName: string = getTagName(props.isFieldset);\n\n /**\n * Get tooltip node\n * @returns mg-tooltip\n */\n const getTooltip = (): VNode[] => (\n <mg-tooltip identifier={`${props.identifier}-tooltip`} message={props.tooltip}>\n <mg-icon icon=\"info-circle\"></mg-icon>\n </mg-tooltip>\n );\n\n /**\n * Get input title (label) node\n * Display asterisk only if not disabled and not readonly\n * @returns mg-input-title\n */\n const getInputTitle = (): VNode[] => (\n <mg-input-title\n identifier={props.identifier}\n class={props.labelHide ? 'sr-only' : undefined}\n required={props.required && !props.disabled && !props.readonly}\n is-legend={props.isFieldset}\n >\n {props.label}\n </mg-input-title>\n );\n\n return (\n <TagName class={props.classCollection.join()}>\n {props.labelOnTop ? (\n <div class=\"mg-input__title\">\n {getInputTitle()}\n {!props.readonly && props.tooltip && getTooltip()}\n </div>\n ) : (\n getInputTitle()\n )}\n {props.readonly ? (\n <div class=\"mg-input__input-container\">\n <strong>{props.readonlyValue}</strong>\n {children.filter(child => child.$name$ === 'append-input')}\n </div>\n ) : (\n <div class=\"mg-input__input-container\">\n <div class={{ 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined }}>\n {applyAriadescribedBy(children, ariaDescribedbyIDs, utils)}\n {!props.labelOnTop && props.tooltip && getTooltip()}\n </div>\n {props.helpText && <div id={helpTextId} class=\"mg-input__help-text\" innerHTML={props.helpText}></div>}\n {props.errorMessage && !props.readonly && !props.disabled && (\n <div id={helpTextErrorId} class=\"mg-input__error\" innerHTML={props.errorMessage} aria-live=\"assertive\"></div>\n )}\n </div>\n )}\n </TagName>\n );\n};\n"],"version":3}
@@ -126,5 +126,13 @@ const getChildWindows = (localWindow, windows = []) => {
126
126
  }
127
127
  return windows;
128
128
  };
129
+ /**
130
+ * Validate string
131
+ * @param value - value to check
132
+ * @returns if string is valid
133
+ */
134
+ const isValidString = (value) => typeof value === 'string' && value.trim() !== '';
135
+
136
+ export { ClassList as C, allItemsAreString as a, isValidString as b, createID as c, focusableElements as f, getWindows as g, isTagName as i };
129
137
 
130
- export { ClassList as C, allItemsAreString as a, createID as c, focusableElements as f, getWindows as g, isTagName as i };
138
+ //# sourceMappingURL=components.utils.js.map
@@ -0,0 +1 @@
1
+ {"file":"components.utils.js","mappings":"AAAA;;;;;;MAMa,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE;EAC/C,MAAM,KAAK,GAAG,sCAAsC,CAAC;EACrD,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;EAEjC,IAAI,EAAE,GAAG,EAAE,CAAC;EACZ,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;EACrB,OAAO,MAAM,GAAG,CAAC,EAAE;IACjB,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACvB,MAAM,KAAK,GAAG,GAAG,GAAG,WAAW,CAAC;IAChC,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAM,EAAE,CAAC;GACV;EACD,OAAO,CAAC,MAAM,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC;AAClD,EAAE;AAEF;;;;MAIa,SAAS;EAMpB,YAAY,YAAsB,EAAE;;;;;IAQpC,QAAG,GAAG,CAAC,SAAiB;MACtB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;OAC9B;KACF,CAAC;;;;;IAMF,WAAM,GAAG,CAAC,SAAiB;MACzB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;MAC9C,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;QACd,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;OAC/B;KACF,CAAC;;;;;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,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;MACvD,OAAO,OAAO,CAAC;KAChB;GACF;EACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;AAMA,MAAM,eAAe,GAAG,CAAC,WAAmB,EAAE,UAAoB,EAAE;EAClE,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;IACjC,KAAK,MAAM,WAAW,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE;MACxD,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;MAC1B,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;KACvC;GACF;EACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;MAKa,aAAa,GAAG,CAAC,KAAc,KAAc,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK;;;;","names":[],"sources":["src/utils/components.utils.ts"],"sourcesContent":["/**\n * Create random ID\n * @param prefix - add prefix to created ID\n * @param length - ID length\n * @returns ID\n */\nexport const createID = (prefix = '', length = 10): string => {\n const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';\n const charsLength = chars.length;\n\n let ID = '';\n let now = Date.now();\n while (length > 0) {\n now += Math.pow(10, 6); // Add 1 millisecond to the timestamp\n const index = now % charsLength;\n ID += chars.charAt(index);\n length--;\n }\n return (prefix !== '' ? `${prefix}-` : '') + ID;\n};\n\n/**\n * Class to manage component classlist\n * Set() are not working when imported in project\n */\nexport class ClassList {\n /**\n * Available classes\n */\n classes: string[];\n\n constructor(classlist: string[] = []) {\n this.classes = classlist;\n }\n\n /**\n * Add class\n * @param className - class name to add\n */\n add = (className: string): void => {\n if (!this.has(className)) {\n this.classes.push(className);\n }\n };\n\n /**\n * Delete class\n * @param className - class name to delete\n */\n delete = (className: string): void => {\n const index = this.classes.indexOf(className);\n if (index > -1) {\n this.classes.splice(index, 1);\n }\n };\n\n /**\n * Check if class exist in list\n * @param className - class name to check\n * @returns class name is in the list\n */\n has = (className: string): boolean => {\n return this.classes.includes(className);\n };\n\n /**\n * Join classes seperated by spaces\n * @returns joined values\n */\n join = (): string => {\n return this.classes.join(' ');\n };\n}\n\n/**\n * Check if all items are string\n * @param items - items to check\n * @returns all items are string\n */\nexport const allItemsAreString = (items: unknown): items is string[] => Array.isArray(items) && items.every(item => typeof item === 'string');\n\n/**\n * Check if element is a heading\n * @param element - slotted element\n * @param tagNames - allowed tag names list\n * @returns element is a heading\n */\nexport const isTagName = (element: Element, tagNames: string[]): boolean => {\n return tagNames.includes(element?.tagName.toLowerCase());\n};\n\n/**\n * Focusable elements query selector\n */\nexport const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"]), [identifier]';\n\n/**\n * Get windows\n * @param localWindow - the window we are lookink for other windows\n * @returns The list of windows found\n */\nexport const getWindows = (localWindow: Window): Window[] => {\n const parentWindows = getParentWindows(localWindow);\n const childWindows = getChildWindows(localWindow);\n return [localWindow, ...parentWindows, ...childWindows];\n};\n\n/**\n * Get parent windows\n * @param localWindow - the window we are lookink for parents\n * @param windows - The list of allready found windows\n * @returns The list of windows found\n */\nexport const getParentWindows = (localWindow: Window, windows: Window[] = []): Window[] => {\n // Check if is in iframe\n if (localWindow.self !== localWindow.top) {\n // Check if we have permission to access parent\n try {\n const parentWindow: Window = localWindow.parent;\n windows.push(parentWindow);\n return getParentWindows(parentWindow, windows);\n } catch (err) {\n console.error('Different hosts between iframes:', err);\n return windows;\n }\n }\n return windows;\n};\n\n/**\n * Get child windows\n * @param localWindow - the window we are lookink for children\n * @param windows - The list of allready found windows\n * @returns The list of windows found\n */\nconst getChildWindows = (localWindow: Window, windows: Window[] = []): Window[] => {\n if (localWindow.frames.length > 0) {\n for (const childWindow of Array.from(localWindow.frames)) {\n windows.push(childWindow);\n getChildWindows(childWindow, windows);\n }\n }\n return windows;\n};\n\n/**\n * Validate string\n * @param value - value to check\n * @returns if string is valid\n */\nexport const isValidString = (value: unknown): boolean => typeof value === 'string' && value.trim() !== '';\n"],"version":3}