@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
+ {"file":"mg-input-numeric.js","mappings":";;;;;;;;;AAAA;;;AAGO,MAAM,KAAK,GAAa,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAElE,IAAY,UAKX;AALD,WAAY,UAAU;EACpB,yBAAW,CAAA;EACX,yBAAW,CAAA;EACX,+BAAiB,CAAA;EACjB,mCAAqB,CAAA;AACvB,CAAC,EALW,UAAU,KAAV,UAAU;;ACLtB,MAAM,iBAAiB,GAAG,gjLAAgjL;;MCa7jLA,gBAAc;;;;;;;;IAkBjB,sBAAiB,GAAG,KAAK,CAAC;;;;IA0R1B,gBAAW,GAAG;;MAEpB,IAAI,CAAC,aAAa,EAAE,CAAC;MACrB,IAAI,IAAI,CAAC,iBAAiB,EAAE;QAC1B,IAAI,CAAC,eAAe,EAAE,CAAC;OACxB;MACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;KAC/B,CAAC;;;;IAKM,gBAAW,GAAG;MACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;KACtB,CAAC;;;;IAKM,eAAU,GAAG;MACnB,IAAI,IAAI,CAAC,KAAK,KAAK,GAAG;QAAE,IAAI,CAAC,KAAK,GAAG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AE,IAAI,CAAC,KAAK,EACjB,aAAa,EAAE,IAAI,CAAC,aAAa,EACjC,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,UAAU,EAAE,KAAK,IAEjB,aACE,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,eAAe,EACrB,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,EAC1B,EAAE,EAAE,IAAI,CAAC,UAAU,EACnB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,KAAK,EAAE,IAAI,CAAC,WAAW,EACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,GAAG,EAAE,CAAC,EAAoB;QACxB,IAAI,EAAE,KAAK,IAAI;UAAE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;OAClC,GACD,EACF,YAAM,IAAI,EAAC,cAAc,GAAQ,CACzB,EACV;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgInputNumeric"],"sources":["src/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.ts","src/components/molecules/inputs/mg-input-numeric/mg-input-numeric.scss?tag=mg-input-numeric&encapsulation=shadow","src/components/molecules/inputs/mg-input-numeric/mg-input-numeric.tsx"],"sourcesContent":["/**\n * List of all possibles types\n */\nexport const types: string[] = ['decimal', 'integer', 'currency'];\n\nexport enum InputError {\n MIN = 'min',\n MAX = 'max',\n MINMAX = 'minMax',\n REQUIRED = 'required',\n}\n","@use '../styles/mg-input.scss';\n@use '../styles/mg-input-box.scss';\n@use '../styles/mg-input-width.scss';\n@use '../../../../styles/a11y.scss';\n\n.mg-input {\n .mg-input__box {\n text-align: var(--mg-inputs-text-align, right);\n }\n}\n","import { Component, Element, Event, h, Prop, EventEmitter, State, Watch, Method } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { Width } from '../MgInput.conf';\nimport { types, InputError } from './mg-input-numeric.conf';\nimport { ClassList } from '../../../../utils/components.utils';\nimport { initLocales } from '../../../../locales/';\nimport { localeCurrency, localeNumber } from '../../../../utils/locale.utils';\n\n@Component({\n tag: 'mg-input-numeric',\n styleUrl: 'mg-input-numeric.scss',\n shadow: true,\n})\nexport class MgInputNumeric {\n /************\n * Internal *\n ************/\n\n // Manage different values\n private storedValue: string;\n private numericValue: number;\n private readonlyValue: string;\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private locale: string;\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputNumericElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n validateValue(newValue: MgInputNumeric['value']): void {\n // has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type\n if (typeof newValue === 'string') {\n // Split number and decimal\n const [integer, decimal = ''] = newValue.replace('-', '').split(/[\\.,]/);\n // Regex\n const regex = this.type === 'integer' ? /^-?\\d+$/ : /^-?\\d+(?:[.,]\\d*)?$/;\n // Filter input\n if (this.isValidValue(newValue, regex, integer, decimal)) {\n this.storedValue = newValue;\n } else {\n newValue = this.handleInvalidValue();\n }\n // Set value and input value\n this.updateValues(newValue);\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Input placeholder.\n * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.\n */\n @Prop() placeholder: string;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n /**\n * Define input width\n */\n @Prop() mgWidth: Width;\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Define numeric type\n */\n @Prop() type: string = types[0];\n @Watch('type')\n validateType(newValue: MgInputNumeric['type']): void {\n if (!types.includes(newValue)) {\n throw new Error(`<mg-input-numeric> prop \"type\" must be one of: ${types.join(', ')}`);\n }\n }\n\n /**\n * Define currency\n */\n @Prop() currency = 'USD';\n\n /**\n * Maximum value\n */\n @Prop() max: number;\n\n /**\n * Minimum value\n */\n @Prop() min: number;\n\n /**\n * Override integer length\n * integer is the number before the decimal point\n */\n @Prop() integerLength = 13;\n @Watch('integerLength')\n validateIntegerLength(newValue: MgInputNumeric['integerLength']): void {\n if (newValue < 1) {\n throw new Error(`<mg-input-numeric> prop \"integer-length\" must be a positive number.`);\n }\n }\n\n /**\n * Override decimal length\n * decimal is the number after the decimal point\n */\n @Prop() decimalLength = 2;\n @Watch('decimalLength')\n validateDecimalLength(newValue: MgInputNumeric['decimalLength']): void {\n if (newValue < 1) {\n throw new Error(`<mg-input-numeric> prop \"decimal-length\" must be a positive number, consider using prop \"type\" to \"integer\" instead.`);\n }\n }\n\n /**\n * Define input pattern to validate\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input pattern error message\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-input--numeric']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Define if input has focus\n */\n @State() hasFocus = false;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<number>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<boolean>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputNumeric['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-numeric> method \"setError()\" param \"valid\" must be a boolean');\n } else if (typeof errorMessage !== 'string' || errorMessage.trim() === '') {\n throw new Error('<mg-input-numeric> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputNumeric['valid']) {\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n this.inputValid.emit(this.valid);\n }\n\n /**\n * Checks if the given value is valid according to the defined rules.\n * @param value - The input value to validate.\n * @param regex - The regular expression for validation.\n * @param integer - The integer part of the value.\n * @param decimal - The decimal part of the value.\n * @returns Returns true if the value is valid, otherwise false.\n */\n private isValidValue(value: string, regex: RegExp, integer: string, decimal: string): boolean {\n return ['', '-'].includes(value) || (value.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength));\n }\n\n /**\n * Handles invalid input values and returns a corrected value.\n * @returns The corrected value.\n */\n private handleInvalidValue(): string | null {\n return this.storedValue !== undefined ? this.storedValue : null;\n }\n\n /**\n * Updates the component values based on the validated input value.\n * @param newValue - The validated input value.\n */\n private updateValues(newValue: string | null): void {\n this.value = newValue;\n if (this.input !== undefined) this.input.value = this.value;\n\n this.numericValue = !['', null].includes(this.value) ? parseFloat(this.value.replace(',', '.')) : null;\n this.valueChange.emit(this.numericValue);\n\n this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';\n }\n\n /**\n * Displayed value in input\n * Change on focus/blur\n * @returns display value\n */\n private displayValue(): MgInputNumeric['value'] | MgInputNumeric['readonlyValue'] {\n return this.hasFocus ? this.value : this.readonlyValue;\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n // Check validity\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle focus event\n */\n private handleFocus = (): void => {\n this.hasFocus = true;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n if (this.value === '-') this.value = '';\n // Display Error\n this.displayError();\n this.hasFocus = false;\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || this.getInputError() === null);\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n const inputError = this.getInputError();\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n } else if (inputError === InputError.REQUIRED) {\n this.errorMessage = this.messages.errors[inputError];\n } else {\n this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);\n }\n }\n };\n\n /**\n * Get input error code\n * @returns error code\n */\n private getInputError = (): null | InputError => {\n let inputError = null;\n const hasNotEmptyValues = (toControl: unknown[]) => !toControl.some(value => [null, undefined].includes(value));\n\n if (!hasNotEmptyValues([this.input])) return inputError;\n\n // required\n if (!this.input.checkValidity() && this.input.validity.valueMissing) {\n inputError = InputError.REQUIRED;\n }\n // Min & Max\n else if (hasNotEmptyValues([this.min, this.numericValue]) && this.numericValue < this.min && this.max === undefined) {\n // Only a min value is set\n inputError = InputError.MIN;\n } else if (hasNotEmptyValues([this.max, this.numericValue]) && this.numericValue > this.max && this.min === undefined) {\n // Only a max value is set\n inputError = InputError.MAX;\n } else if (hasNotEmptyValues([this.min, this.max, this.numericValue]) && (this.numericValue < this.min || this.numericValue > this.max)) {\n // both min and max values are set\n inputError = InputError.MINMAX;\n }\n return inputError;\n };\n\n /**\n * Format value based on type\n * @param value - value to format\n * @returns formated local value\n */\n private formatValue = (value: number): string => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));\n\n /**\n * Validate append slot\n */\n private validateAppendSlot = (): void => {\n const slotAppendInput: HTMLSlotElement = this.element.querySelector('[slot=\"append-input\"]');\n if (slotAppendInput !== null) {\n this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n const locales = initLocales(this.element);\n this.locale = locales.locale;\n this.messages = locales.messages;\n // Validate component config\n this.validateType(this.type);\n this.validateIntegerLength(this.integerLength);\n this.validateDecimalLength(this.decimalLength);\n // validate value\n this.validateValue(this.value);\n this.validateAppendSlot();\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n readonly={this.readonly}\n mgWidth={this.mgWidth}\n disabled={this.disabled}\n value={this.value}\n readonlyValue={this.readonlyValue}\n tooltip={this.tooltip}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n isFieldset={false}\n >\n <input\n type=\"text\"\n class=\"mg-input__box\"\n value={this.displayValue()}\n id={this.identifier}\n name={this.name}\n placeholder={this.placeholder}\n title={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />\n <slot name=\"append-input\"></slot>\n </MgInput>\n );\n }\n}\n"],"version":3}
@@ -9,7 +9,7 @@ import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
9
9
 
10
10
  const mgInputPasswordCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle,.mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}";
11
11
 
12
- const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
12
+ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class MgInputPassword extends HTMLElement {
13
13
  constructor() {
14
14
  super();
15
15
  this.__registerHost();
@@ -39,20 +39,23 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
39
39
  */
40
40
  this.checkValidity = () => {
41
41
  var _a;
42
- this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
43
- this.invalid = !this.valid;
44
- // We need to send valid event even if it is the same value
45
- this.inputValid.emit(this.valid);
42
+ this.setValidity(this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true));
46
43
  };
47
44
  /**
48
45
  * Set input error message
46
+ * @param errorMessage - errorMessage override
49
47
  */
50
- this.setErrorMessage = () => {
48
+ this.setErrorMessage = (errorMessage) => {
51
49
  // Set error message
52
50
  this.errorMessage = undefined;
53
- // required
54
- if (!this.valid && this.input.validity.valueMissing) {
55
- this.errorMessage = this.messages.errors.required;
51
+ if (!this.valid) {
52
+ if (errorMessage !== undefined) {
53
+ this.errorMessage = errorMessage;
54
+ }
55
+ // required
56
+ else if (this.input.validity.valueMissing) {
57
+ this.errorMessage = this.messages.errors.required;
58
+ }
56
59
  }
57
60
  };
58
61
  this.value = undefined;
@@ -87,13 +90,44 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
87
90
  }
88
91
  }
89
92
  /**
90
- * Public method to display errors
93
+ * Display input error if it exists.
91
94
  */
92
95
  async displayError() {
93
96
  this.checkValidity();
94
97
  this.setErrorMessage();
95
98
  this.hasDisplayedError = this.invalid;
96
99
  }
100
+ /**
101
+ * Set an error and display a custom error message.
102
+ * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.
103
+ * It must be paired with an error message to display for the given context.
104
+ * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
105
+ * @param valid - value indicating the validity
106
+ * @param errorMessage - the error message to display
107
+ */
108
+ async setError(valid, errorMessage) {
109
+ if (typeof valid !== 'boolean') {
110
+ throw new Error('<mg-input-password> method "setError()" param "valid" must be a boolean');
111
+ }
112
+ else if (typeof errorMessage !== 'string' || errorMessage.trim() === '') {
113
+ throw new Error('<mg-input-password> method "setError()" param "errorMessage" must be a string');
114
+ }
115
+ else {
116
+ this.setValidity(valid);
117
+ this.setErrorMessage(valid ? undefined : errorMessage);
118
+ this.hasDisplayedError = this.invalid;
119
+ }
120
+ }
121
+ /**
122
+ * Method to set validity values
123
+ * @param newValue - valid new value
124
+ */
125
+ setValidity(newValue) {
126
+ this.valid = newValue;
127
+ this.invalid = !this.valid;
128
+ // We need to send valid event even if it is the same value
129
+ this.inputValid.emit(this.valid);
130
+ }
97
131
  /*************
98
132
  * Lifecycle *
99
133
  *************/
@@ -147,7 +181,13 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
147
181
  "invalid": [1028],
148
182
  "classCollection": [32],
149
183
  "errorMessage": [32],
150
- "displayError": [64]
184
+ "displayError": [64],
185
+ "setError": [64]
186
+ }, undefined, {
187
+ "value": ["handleValue"],
188
+ "required": ["handleValidityChange"],
189
+ "readonly": ["handleValidityChange"],
190
+ "disabled": ["handleValidityChange"]
151
191
  }]);
152
192
  function defineCustomElement$1() {
153
193
  if (typeof customElements === "undefined") {
@@ -188,3 +228,5 @@ const MgInputPassword = MgInputPassword$1;
188
228
  const defineCustomElement = defineCustomElement$1;
189
229
 
190
230
  export { MgInputPassword, defineCustomElement };
231
+
232
+ //# sourceMappingURL=mg-input-password.js.map
@@ -0,0 +1 @@
1
+ {"file":"mg-input-password.js","mappings":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ACvB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,GAAG,EAAE,CAAC,EAAoB;QACxB,IAAI,EAAE,KAAK,IAAI;UAAE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;OAClC,GACD,CACM,EACV;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgInputPassword"],"sources":["src/components/molecules/inputs/mg-input-password/mg-input-password.scss?tag=mg-input-password&encapsulation=shadow","src/components/molecules/inputs/mg-input-password/mg-input-password.tsx"],"sourcesContent":["@use '../styles/mg-input.scss';\n@use '../styles/mg-input-box.scss';\n@use '../styles/mg-input-width.scss';\n@use '../../../../styles/a11y.scss';\n","import { Component, Element, Event, h, Prop, EventEmitter, State, Method, Watch } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { Width } from '../MgInput.conf';\nimport { ClassList } from '../../../../utils/components.utils';\nimport { initLocales } from '../../../../locales';\n\n@Component({\n tag: 'mg-input-password',\n styleUrl: 'mg-input-password.scss',\n shadow: true,\n})\nexport class MgInputPassword {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private input: HTMLInputElement;\n\n // Locales\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputPasswordElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true, reflect: true }) value: string;\n @Watch('value')\n handleValue(newValue: string): void {\n this.valueChange.emit(newValue);\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Input placeholder.\n * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.\n */\n @Prop() placeholder: string;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n /**\n * Define input width\n */\n @Prop() mgWidth: Width = 'full';\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-input--password']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<string>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<boolean>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputPassword['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-password> method \"setError()\" param \"valid\" must be a boolean');\n } else if (typeof errorMessage !== 'string' || errorMessage.trim() === '') {\n throw new Error('<mg-input-password> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputPassword['valid']) {\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n }\n this.value = this.input.value;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n this.displayError();\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || (this.input?.checkValidity !== undefined ? this.input.checkValidity() : true));\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n }\n // required\n else if (this.input.validity.valueMissing) {\n this.errorMessage = this.messages.errors.required;\n }\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n this.messages = initLocales(this.element).messages;\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n readonly={this.readonly}\n mgWidth={this.mgWidth}\n disabled={this.disabled}\n value={this.value}\n readonlyValue={this.value !== undefined ? '•'.repeat(this.value.length) : undefined}\n tooltip={this.tooltip}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n isFieldset={false}\n >\n <input\n type=\"password\"\n class=\"mg-input__box\"\n value={this.value}\n id={this.identifier}\n name={this.name}\n placeholder={this.placeholder}\n title={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n onInput={this.handleInput}\n onBlur={this.handleBlur}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.input = el;\n }}\n />\n </MgInput>\n );\n }\n}\n"],"version":3}
@@ -15,7 +15,7 @@ const mgInputRadioCss = ":host{display:block}.mg-input{display:flex;align-items:
15
15
  * @returns radio option type is valid
16
16
  */
17
17
  const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
18
- const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
18
+ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio extends HTMLElement {
19
19
  constructor() {
20
20
  super();
21
21
  this.__registerHost();
@@ -48,20 +48,23 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
48
48
  * Check if input is valid
49
49
  */
50
50
  this.checkValidity = () => {
51
- this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
52
- this.invalid = !this.valid;
53
- // We need to send valid event even if it is the same value
54
- this.inputValid.emit(this.valid);
51
+ this.setValidity(this.readonly || this.disabled || this.getInvalidElement() === undefined);
55
52
  };
56
53
  /**
57
54
  * Set input error message
55
+ * @param errorMessage - errorMessage override
58
56
  */
59
- this.setErrorMessage = () => {
57
+ this.setErrorMessage = (errorMessage) => {
60
58
  const invalidElement = this.getInvalidElement();
61
59
  // Set error message
62
60
  this.errorMessage = undefined;
63
- if (!this.valid && invalidElement.validity.valueMissing) {
64
- this.errorMessage = this.messages.errors.required;
61
+ if (!this.valid) {
62
+ if (errorMessage !== undefined) {
63
+ this.errorMessage = errorMessage;
64
+ }
65
+ else if (invalidElement.validity.valueMissing) {
66
+ this.errorMessage = this.messages.errors.required;
67
+ }
65
68
  }
66
69
  };
67
70
  /**
@@ -119,13 +122,44 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
119
122
  }
120
123
  }
121
124
  /**
122
- * Public method to display errors
125
+ * Display input error if it exists.
123
126
  */
124
127
  async displayError() {
125
128
  this.checkValidity();
126
129
  this.setErrorMessage();
127
130
  this.hasDisplayedError = this.invalid;
128
131
  }
132
+ /**
133
+ * Set an error and display a custom error message.
134
+ * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.
135
+ * It must be paired with an error message to display for the given context.
136
+ * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
137
+ * @param valid - value indicating the validity
138
+ * @param errorMessage - the error message to display
139
+ */
140
+ async setError(valid, errorMessage) {
141
+ if (typeof valid !== 'boolean') {
142
+ throw new Error('<mg-input-radio> method "setError()" param "valid" must be a boolean');
143
+ }
144
+ else if (typeof errorMessage !== 'string' || errorMessage.trim() === '') {
145
+ throw new Error('<mg-input-radio> method "setError()" param "errorMessage" must be a string');
146
+ }
147
+ else {
148
+ this.setValidity(valid);
149
+ this.setErrorMessage(valid ? undefined : errorMessage);
150
+ this.hasDisplayedError = this.invalid;
151
+ }
152
+ }
153
+ /**
154
+ * Method to set validity values
155
+ * @param newValue - valid new value
156
+ */
157
+ setValidity(newValue) {
158
+ this.valid = newValue;
159
+ this.invalid = !this.valid;
160
+ // We need to send valid event even if it is the same value
161
+ this.inputValid.emit(this.valid);
162
+ }
129
163
  /*************
130
164
  * Lifecycle *
131
165
  *************/
@@ -183,7 +217,14 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
183
217
  "classCollection": [32],
184
218
  "errorMessage": [32],
185
219
  "options": [32],
186
- "displayError": [64]
220
+ "displayError": [64],
221
+ "setError": [64]
222
+ }, undefined, {
223
+ "value": ["handleValue"],
224
+ "items": ["validateItems"],
225
+ "required": ["handleValidityChange"],
226
+ "readonly": ["handleValidityChange"],
227
+ "disabled": ["handleValidityChange"]
187
228
  }]);
188
229
  function defineCustomElement$1() {
189
230
  if (typeof customElements === "undefined") {
@@ -224,3 +265,5 @@ const MgInputRadio = MgInputRadio$1;
224
265
  const defineCustomElement = defineCustomElement$1;
225
266
 
226
267
  export { MgInputRadio, defineCustomElement };
268
+
269
+ //# sourceMappingURL=mg-input-radio.js.map
@@ -0,0 +1 @@
1
+ {"file":"mg-input-radio.js","mappings":";;;;;;;;;AAAA,MAAM,eAAe,GAAG,w7GAAw7G;;ACSh9G;;;;;AAKA,MAAM,QAAQ,GAAG,CAAC,MAAmB,KAAc,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC;MAOnIA,cAAY;;;;;;;;;;;IAMf,WAAM,GAAuB,EAAE,CAAC;;IAMhC,sBAAiB,GAAG,KAAK,CAAC;;;;;IAgM1B,gBAAW,GAAG,CAAC,KAAgD;MACrE,IAAI,CAAC,aAAa,EAAE,CAAC;MACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;KACrD,CAAC;;;;IAKM,eAAU,GAAG;MACnB,IAAI,CAAC,aAAa,EAAE,CAAC;MACrB,IAAI,CAAC,eAAe,EAAE,CAAC;KACxB,CAAC;;;;IAKM,kBAAa,GAAG;MACtB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,iBAAiB,EAAE,KAAK,SAAS,CAAC,CAAC;KAC5F,CAAC;;;;;IAMM,oBAAe,GAAG,CAAC,YAAqB;MAC9C,MAAM,cAAc,GAAG,IAAI,CAAC,iBAA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AG,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,uBAAuB,EAAE,IAAI,EAAE,iCAAiC,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,EAAE,IAChI,aACE,IAAI,EAAC,OAAO,EACZ,EAAE,EAAE,IAAI,CAAC,UAAU,GAAG,GAAG,GAAG,KAAK,EACjC,IAAI,EAAE,IAAI,CAAC,UAAU,EACrB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,EACjF,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,EACzC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,GAAG,EAAE,CAAC,EAAoB;QACxB,IAAI,EAAE,KAAK,IAAI;UAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;OAC1C,GACD,EACF,aAAO,OAAO,EAAE,IAAI,CAAC,UAAU,GAAG,GAAG,GAAG,KAAK,IAAG,KAAK,CAAC,KAAK,CAAS,CACjE,CACN,CAAC,CACC,CACG,EACV;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgInputRadio"],"sources":["src/components/molecules/inputs/mg-input-radio/mg-input-radio.scss?tag=mg-input-radio&encapsulation=shadow","src/components/molecules/inputs/mg-input-radio/mg-input-radio.tsx"],"sourcesContent":["@use '../styles/mg-input.scss';\n@use '../styles/mg-input-fieldset.scss';\n@use '../../../../styles/a11y.scss';\n","/* eslint-disable jsx-a11y/no-redundant-roles */\n/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Component, Element, Event, h, Prop, EventEmitter, State, Watch, Method } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { ClassList, allItemsAreString } from '../../../../utils/components.utils';\nimport { initLocales } from '../../../../locales';\nimport { RadioOption } from './mg-input-radio.conf';\n\n/**\n * type Option validation function\n * @param option - radio option\n * @returns radio option type is valid\n */\nconst isOption = (option: RadioOption): boolean => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;\n\n@Component({\n tag: 'mg-input-radio',\n styleUrl: 'mg-input-radio.scss',\n shadow: true,\n})\nexport class MgInputRadio {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private inputs: HTMLInputElement[] = [];\n\n // Locales\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputRadioElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true }) value: any;\n @Watch('value')\n handleValue(newValue: any): void {\n this.valueChange.emit(newValue);\n }\n\n /**\n * Items are the possible options to select\n */\n @Prop() items!: string[] | RadioOption[];\n @Watch('items')\n validateItems(newValue: string[] | RadioOption[]): void {\n // Validate if items have required min length\n if (typeof newValue === 'object' && newValue.length < 2) {\n throw new Error('<mg-input-radio> prop \"items\" require at least 2 items.');\n }\n // String array\n else if (allItemsAreString(newValue as string[])) {\n this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));\n }\n // Object array\n else if (newValue && (newValue as RadioOption[]).every(item => isOption(item))) {\n this.options = newValue as RadioOption[];\n } else {\n throw new Error('<mg-input-radio> prop \"items\" is required and all items must be the same type, string or RadioOption.');\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop = false;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Define if inputs are display verticaly\n */\n @Prop() inputVerticalList = false;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n this.inputs.forEach(input => {\n input[prop] = newValue;\n });\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-input--radio']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Formated items for display\n */\n @State() options: RadioOption[];\n\n /**\n * Emitted event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<any>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<boolean>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputRadio['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-radio> method \"setError()\" param \"valid\" must be a boolean');\n } else if (typeof errorMessage !== 'string' || errorMessage.trim() === '') {\n throw new Error('<mg-input-radio> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputRadio['valid']) {\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n this.inputValid.emit(this.valid);\n }\n\n /**\n * Handle input event\n * @param event - input event\n */\n private handleInput = (event: InputEvent & { target: HTMLInputElement }) => {\n this.checkValidity();\n this.value = this.options[event.target.value].value;\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n this.checkValidity();\n this.setErrorMessage();\n };\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(this.readonly || this.disabled || this.getInvalidElement() === undefined);\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n const invalidElement = this.getInvalidElement();\n\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n } else if (invalidElement.validity.valueMissing) {\n this.errorMessage = this.messages.errors.required;\n }\n }\n };\n\n /**\n * get invalid element\n * @returns element\n */\n private getInvalidElement = (): HTMLInputElement => this.inputs.find((input: HTMLInputElement) => !input.disabled && !input.readOnly && !input.checkValidity());\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n this.messages = initLocales(this.element).messages;\n // Validate\n this.validateItems(this.items);\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n disabled={this.disabled}\n readonly={this.readonly}\n mgWidth={undefined}\n value={this.value as string}\n readonlyValue={this.value as string}\n tooltip={this.tooltip}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n isFieldset={true}\n >\n <ul class={{ 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }} role=\"list\">\n {this.options.map((input, index) => (\n <li key={input.title} class={{ 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled }}>\n <input\n type=\"radio\"\n id={this.identifier + '_' + index}\n name={this.identifier}\n value={index}\n checked={JSON.stringify(this.value) === JSON.stringify(this.options[index].value)}\n disabled={this.disabled || input.disabled}\n required={this.required}\n onBlur={this.handleBlur}\n onInput={this.handleInput}\n ref={(el: HTMLInputElement) => {\n if (el !== null) this.inputs[index] = el;\n }}\n />\n <label htmlFor={this.identifier + '_' + index}>{input.title}</label>\n </li>\n ))}\n </ul>\n </MgInput>\n );\n }\n}\n"],"version":3}
@@ -4,3 +4,5 @@ const MgInputSelect = MgInputSelect$1;
4
4
  const defineCustomElement = defineCustomElement$1;
5
5
 
6
6
  export { MgInputSelect, defineCustomElement };
7
+
8
+ //# sourceMappingURL=mg-input-select.js.map
@@ -0,0 +1 @@
1
+ {"file":"mg-input-select.js","mappings":";;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}
@@ -51,7 +51,7 @@ const groupOptions = (acc, { group, title, value, disabled }) => {
51
51
  }
52
52
  return acc;
53
53
  };
54
- const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
54
+ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class MgInputSelect extends HTMLElement {
55
55
  constructor() {
56
56
  super();
57
57
  this.__registerHost();
@@ -117,19 +117,22 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
117
117
  */
118
118
  this.checkValidity = () => {
119
119
  var _a;
120
- this.valid = !this.isDisabledValue() && (this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true));
121
- this.invalid = !this.valid;
122
- // We need to send valid event even if it is the same value
123
- this.inputValid.emit(this.valid);
120
+ this.setValidity(!this.isDisabledValue() && (this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true)));
124
121
  };
125
122
  /**
126
123
  * Set input error message
124
+ * @param errorMessage - errorMessage override
127
125
  */
128
- this.setErrorMessage = () => {
126
+ this.setErrorMessage = (errorMessage) => {
129
127
  // Set error message
130
128
  this.errorMessage = undefined;
131
- if (!this.valid && this.input.validity.valueMissing) {
132
- this.errorMessage = this.messages.errors.required;
129
+ if (!this.valid) {
130
+ if (errorMessage !== undefined) {
131
+ this.errorMessage = errorMessage;
132
+ }
133
+ else if (this.input.validity.valueMissing) {
134
+ this.errorMessage = this.messages.errors.required;
135
+ }
133
136
  }
134
137
  };
135
138
  /**
@@ -213,13 +216,44 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
213
216
  }
214
217
  }
215
218
  /**
216
- * Public method to display errors
219
+ * Display input error if it exists.
217
220
  */
218
221
  async displayError() {
219
222
  this.checkValidity();
220
223
  this.setErrorMessage();
221
224
  this.hasDisplayedError = this.invalid;
222
225
  }
226
+ /**
227
+ * Set an error and display a custom error message.
228
+ * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.
229
+ * It must be paired with an error message to display for the given context.
230
+ * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
231
+ * @param valid - value indicating the validity
232
+ * @param errorMessage - the error message to display
233
+ */
234
+ async setError(valid, errorMessage) {
235
+ if (typeof valid !== 'boolean') {
236
+ throw new Error('<mg-input-select> method "setError()" param "valid" must be a boolean');
237
+ }
238
+ else if (typeof errorMessage !== 'string' || errorMessage.trim() === '') {
239
+ throw new Error('<mg-input-select> method "setError()" param "errorMessage" must be a string');
240
+ }
241
+ else {
242
+ this.setValidity(valid);
243
+ this.setErrorMessage(valid ? undefined : errorMessage);
244
+ this.hasDisplayedError = this.invalid;
245
+ }
246
+ }
247
+ /**
248
+ * Method to set validity values
249
+ * @param newValue - valid new value
250
+ */
251
+ setValidity(newValue) {
252
+ this.valid = newValue;
253
+ this.invalid = !this.valid;
254
+ // We need to send valid event even if it is the same value
255
+ this.inputValid.emit(this.valid);
256
+ }
223
257
  /*************
224
258
  * Lifecycle *
225
259
  *************/
@@ -288,7 +322,14 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
288
322
  "options": [32],
289
323
  "valueExist": [32],
290
324
  "readonlyValue": [32],
291
- "displayError": [64]
325
+ "displayError": [64],
326
+ "setError": [64]
327
+ }, undefined, {
328
+ "value": ["validateValue"],
329
+ "items": ["validateItems"],
330
+ "required": ["handleValidityChange"],
331
+ "readonly": ["handleValidityChange"],
332
+ "disabled": ["handleValidityChange"]
292
333
  }]);
293
334
  function defineCustomElement() {
294
335
  if (typeof customElements === "undefined") {
@@ -326,3 +367,5 @@ function defineCustomElement() {
326
367
  defineCustomElement();
327
368
 
328
369
  export { MgInputSelect as M, defineCustomElement as d };
370
+
371
+ //# sourceMappingURL=mg-input-select2.js.map
@@ -0,0 +1 @@
1
+ {"file":"mg-input-select2.js","mappings":";;;;;;;;;AAAA,MAAM,gBAAgB,GAAG,2pLAA2pL;;ACSprL;;;;;AAKA,MAAM,QAAQ,GAAG,CAAC,MAAe,KAA6B,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAQ,MAAuB,CAAC,KAAK,KAAK,QAAQ,CAAC;AAE/I;;;;;AAKA,MAAM,kBAAkB,GAAG,CAAC,KAAgB,KAA8B,KAAK,CAAC,OAAO,CAAC,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;;;;;;;;","names":[],"sources":["src/components/molecules/inputs/mg-input-select/mg-input-select.scss?tag=mg-input-select&encapsulation=shadow","src/components/molecules/inputs/mg-input-select/mg-input-select.tsx"],"sourcesContent":["@use '../styles/mg-input.scss';\n@use '../styles/mg-input-box.scss';\n@use '../styles/mg-input-width.scss';\n@use '../../../../styles/a11y.scss';\n\n.mg-input__box {\n width: 100%;\n padding-top: 0;\n padding-bottom: 0;\n padding-right: 1rem;\n}\n\n:host(:not([mg-width])) .mg-input--select:not(.mg-input--label-on-top) .mg-input__box {\n max-width: unset;\n}\n","/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Component, Element, Event, h, Prop, State, EventEmitter, Watch, Method } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { Width } from '../MgInput.conf';\nimport { ClassList, allItemsAreString } from '../../../../utils/components.utils';\nimport { initLocales } from '../../../../locales';\nimport { SelectOption, OptGroup } from './mg-input-select.conf';\n\n/**\n * Check if item is a well configured option\n * @param option - select option\n * @returns select option type is valid\n */\nconst isOption = (option: unknown): option is SelectOption => typeof option === 'object' && typeof (option as SelectOption).title === 'string';\n\n/**\n * Check if items[] is SelectOption\n * @param items - select option\n * @returns select option array type is valid\n */\nconst allItemsAreOptions = (items: unknown[]): items is SelectOption[] => Array.isArray(items) && items.every(item => isOption(item));\n\n/**\n * Check if item is a well configured optgroup\n * @param optgroup - select option\n * @returns select optgroup type is valid\n */\nconst isOptGroup = (optgroup: unknown): optgroup is OptGroup =>\n typeof optgroup === 'object' && typeof (optgroup as OptGroup).group === 'string' && allItemsAreOptions((optgroup as OptGroup).options);\n\n/**\n * Group options\n * @param acc - reduce accumulator\n * @param item - item to add\n * @returns grouped options\n */\nconst groupOptions = (acc: (SelectOption | OptGroup)[], { group, title, value, disabled }: SelectOption): (SelectOption | OptGroup)[] => {\n if (group !== undefined) {\n // Check if group is already created\n const optGroup: OptGroup = (acc as OptGroup[]).find(grp => grp.group === group);\n // Add to group\n if (optGroup !== undefined) {\n optGroup.options.push({ title, value, disabled });\n }\n // Create group\n else {\n acc.push({ group, options: [{ title, value, disabled }] });\n }\n } else {\n acc.push({ title, value, disabled });\n }\n return acc;\n};\n\n@Component({\n tag: 'mg-input-select',\n styleUrl: 'mg-input-select.scss',\n shadow: true,\n})\nexport class MgInputSelect {\n /************\n * Internal *\n ************/\n\n // HTML selector\n private input: HTMLSelectElement;\n\n // Locales\n private messages;\n\n // hasDisplayedError (triggered by blur event)\n private hasDisplayedError = false;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputSelectElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true }) value: any;\n @Watch('value')\n validateValue(newValue: MgInputSelect['value']): void {\n if (allItemsAreString(this.items) && typeof newValue === 'string') {\n this.readonlyValue = Boolean(this.input?.value) ? this.input.value : newValue;\n } else if (allItemsAreOptions(this.items)) {\n this.readonlyValue = this.items.find(item => item.value === newValue)?.title;\n } else {\n this.readonlyValue = null;\n }\n this.valueChange.emit(newValue);\n }\n\n /**\n * Items are the possible options to select\n */\n @Prop() items!: (string | SelectOption)[];\n @Watch('items')\n validateItems(newValue: MgInputSelect['items']): void {\n // Empty options\n if (newValue.length === 0) {\n this.options = [];\n }\n // String array\n else if (allItemsAreString(newValue)) {\n if (typeof this.value === 'string') this.valueExist = newValue.includes(this.value);\n this.options = newValue.map(item => ({ title: item, value: item }));\n }\n // Object array\n else if (allItemsAreOptions(newValue)) {\n this.valueExist = newValue.map(item => item.value).includes(this.value);\n // Grouped object options\n if (newValue.some(item => Boolean(item.group))) {\n this.options = newValue.reduce(groupOptions, []);\n }\n // Standart object options\n else {\n this.options = newValue;\n }\n } else {\n throw new Error('<mg-input-select> prop \"items\" is required, can be an empty Array or all items must be the same type: string or Option.');\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Input placeholder.\n * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.\n */\n @Prop({ mutable: true }) placeholder: string;\n\n /**\n * Option to remove placeholder\n */\n @Prop() placeholderHide = false;\n\n /**\n * Option to disable placeholder\n */\n @Prop() placeholderDisabled = false;\n\n /**\n * Define if input is required\n */\n @Prop() required = false;\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('required')\n @Watch('readonly')\n @Watch('disabled')\n handleValidityChange(newValue: boolean, _oldValue: boolean, prop: string): void {\n if (this.input !== undefined) {\n this.input[prop] = newValue;\n this.checkValidity();\n if (this.hasDisplayedError) {\n this.setErrorMessage();\n this.hasDisplayedError = false;\n }\n }\n }\n\n /**\n * Define input width\n */\n @Prop({ reflect: true }) mgWidth: Width;\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Define input valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define input invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-input--select']);\n\n /**\n * Error message to display\n */\n @State() errorMessage: string;\n\n /**\n * Formated items for display\n */\n @State() options: (SelectOption | OptGroup)[];\n\n /**\n * Does value match any item option\n */\n @State() valueExist: boolean;\n\n /**\n * Does value match any item option\n */\n @State() readonlyValue: string;\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<MgInputSelect['value']>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<boolean>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n this.checkValidity();\n this.setErrorMessage();\n this.hasDisplayedError = this.invalid;\n }\n\n /**\n * Set an error and display a custom error message.\n * This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\n * It must be paired with an error message to display for the given context.\n * When used to set validity to `false`, you should use this method again to reset the validity to `true`.\n * @param valid - value indicating the validity\n * @param errorMessage - the error message to display\n */\n @Method()\n async setError(valid: MgInputSelect['valid'], errorMessage: string): Promise<void> {\n if (typeof valid !== 'boolean') {\n throw new Error('<mg-input-select> method \"setError()\" param \"valid\" must be a boolean');\n } else if (typeof errorMessage !== 'string' || errorMessage.trim() === '') {\n throw new Error('<mg-input-select> method \"setError()\" param \"errorMessage\" must be a string');\n } else {\n this.setValidity(valid);\n this.setErrorMessage(valid ? undefined : errorMessage);\n this.hasDisplayedError = this.invalid;\n }\n }\n\n /**\n * Method to set validity values\n * @param newValue - valid new value\n */\n private setValidity(newValue: MgInputSelect['valid']) {\n this.valid = newValue;\n this.invalid = !this.valid;\n // We need to send valid event even if it is the same value\n this.inputValid.emit(this.valid);\n }\n /**\n * Handle input event\n */\n private handleInput = (): void => {\n this.updateValue();\n if (this.hasDisplayedError) this.setErrorMessage();\n };\n\n /**\n * Method to compare item.title with input.value\n * @param item - item to compare with\n * @returns truthy if input.value is an item\n */\n private isInputValue = (item: SelectOption): boolean => item.title === this.input?.value;\n\n /**\n * value props setter\n * @param newValue - value to update with\n */\n private setValue = (newValue: MgInputSelect['value']): void => {\n this.checkValidity();\n this.value = newValue;\n };\n\n /**\n * Update value from input.value\n */\n private updateValue = (): void => {\n if (this.input.value === '') {\n this.setValue(null);\n } else if (allItemsAreString(this.items) && this.items.includes(this.input.value)) {\n this.setValue(this.input.value);\n } else if (allItemsAreOptions(this.items) && typeof this.input.value === 'string' && this.items.some(this.isInputValue)) {\n this.setValue(this.items.find(this.isInputValue).value);\n } else {\n // before set newValue with push to options[] the unknown input.value with a disable satus\n this.options.push({ title: this.input.value, value: this.input.value, disabled: true });\n this.setValue(this.input.value);\n }\n };\n\n /**\n * Handle blur event\n */\n private handleBlur = (): void => {\n this.displayError();\n };\n\n /**\n * Input value is disabled\n * @returns truthy if input value is disabled\n */\n private isDisabledValue = (): boolean => allItemsAreOptions(this.options) && this.options.find(this.isInputValue)?.disabled === true;\n\n /**\n * Check if input is valid\n */\n private checkValidity = (): void => {\n this.setValidity(!this.isDisabledValue() && (this.readonly || this.disabled || (this.input?.checkValidity !== undefined ? this.input.checkValidity() : true)));\n };\n\n /**\n * Set input error message\n * @param errorMessage - errorMessage override\n */\n private setErrorMessage = (errorMessage?: string): void => {\n // Set error message\n this.errorMessage = undefined;\n if (!this.valid) {\n if (errorMessage !== undefined) {\n this.errorMessage = errorMessage;\n } else if (this.input.validity.valueMissing) {\n this.errorMessage = this.messages.errors.required;\n }\n }\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n * @returns timeout\n */\n componentWillLoad(): ReturnType<typeof setTimeout> {\n // Get locales\n this.messages = initLocales(this.element).messages;\n // Validate\n this.validateItems(this.items);\n this.validateValue(this.value);\n // Set default placeholder\n if (this.placeholder === undefined || this.placeholder === '') {\n this.placeholder = this.messages.input.select.placeholder;\n }\n // Check validity when component is ready\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n this.checkValidity();\n }, 0);\n }\n\n /**\n * Render option\n * @param option - to render\n * @returns render option\n */\n private renderOption = (option: SelectOption): HTMLElement => (\n <option key={option.title} value={option.title} selected={JSON.stringify(this.value) === JSON.stringify(option.value)} disabled={option.disabled}>\n {option.title}\n </option>\n );\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={this.required}\n readonly={this.readonly}\n mgWidth={this.mgWidth}\n disabled={this.disabled}\n value={undefined}\n readonlyValue={this.readonlyValue}\n tooltip={this.tooltip}\n helpText={this.helpText}\n errorMessage={this.errorMessage}\n isFieldset={false}\n >\n <select\n class=\"mg-input__box\"\n id={this.identifier}\n name={this.name}\n title={this.placeholder}\n disabled={this.disabled}\n required={this.required}\n onInput={this.handleInput}\n onBlur={this.handleBlur}\n ref={(el: HTMLSelectElement) => {\n if (el !== null) this.input = el;\n }}\n >\n {(!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder\n <option value=\"\" disabled={this.placeholderDisabled && this.valueExist}>\n {this.placeholder}\n </option>\n )}\n {this.options.map(option =>\n isOptGroup(option) ? <optgroup label={option.group}>{option.options.map(this.renderOption)}</optgroup> : isOption(option) && this.renderOption(option),\n )}\n </select>\n </MgInput>\n );\n }\n}\n"],"version":3}
@@ -4,3 +4,5 @@ const MgInputText = MgInputText$1;
4
4
  const defineCustomElement = defineCustomElement$1;
5
5
 
6
6
  export { MgInputText, defineCustomElement };
7
+
8
+ //# sourceMappingURL=mg-input-text.js.map
@@ -0,0 +1 @@
1
+ {"file":"mg-input-text.js","mappings":";;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}