@mgdis/mg-components 3.3.0 → 4.1.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 (257) hide show
  1. package/dist/.storybook/utils.js +24 -0
  2. package/dist/cjs/{index-369388eb.js → index-179621c8.js} +108 -10
  3. package/dist/cjs/{index-bead7dbd.js → index-88560a66.js} +47 -48
  4. package/dist/cjs/loader.cjs.js +3 -17
  5. package/dist/cjs/mg-badge_24.cjs.entry.js +5687 -0
  6. package/dist/cjs/mg-components.cjs.js +3 -7
  7. package/dist/cjs/mg-modal.cjs.entry.js +12 -6
  8. package/dist/collection/collection-manifest.json +3 -1
  9. package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.js} +10 -6
  10. package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -2
  11. package/dist/collection/components/atoms/mg-badge/mg-badge.js +15 -3
  12. package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +16 -13
  13. package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
  14. package/dist/collection/components/atoms/mg-button/mg-button.css +6 -30
  15. package/dist/collection/components/atoms/mg-button/mg-button.js +53 -22
  16. package/dist/collection/components/atoms/mg-character-left/doc/mg-character-left.stories.js +20 -0
  17. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +10 -47
  18. package/dist/collection/components/atoms/mg-icon/{mg-icon.stories.js → doc/mg-icon.stories.js} +12 -4
  19. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +99 -10
  20. package/dist/collection/components/atoms/mg-icon/mg-icon.css +4 -0
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.js +22 -6
  22. package/dist/collection/components/atoms/mg-input-title/doc/mg-input-title.stories.js +21 -0
  23. package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +10 -8
  24. package/dist/collection/components/atoms/mg-tag/mg-tag.js +19 -4
  25. package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +58 -0
  26. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +26 -0
  27. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +71 -13
  28. package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
  29. package/dist/collection/components/molecules/inputs/MgInput.js +5 -15
  30. package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +3 -15
  31. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +22 -15
  32. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +8 -21
  33. package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +3 -12
  34. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +22 -20
  35. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +19 -18
  36. package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +9 -13
  37. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +23 -21
  38. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +43 -19
  39. package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +10 -12
  40. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +22 -20
  41. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +17 -22
  42. package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +3 -14
  43. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +22 -15
  44. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +8 -15
  45. package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +10 -16
  46. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +23 -20
  47. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +24 -31
  48. package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +18 -25
  49. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +54 -30
  50. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +42 -43
  51. package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +11 -14
  52. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +54 -24
  53. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +64 -37
  54. package/dist/collection/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.js +57 -0
  55. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +21 -11
  56. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +25 -10
  57. package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +25 -0
  58. package/dist/collection/components/molecules/mg-details/mg-details.css +14 -0
  59. package/dist/collection/components/molecules/mg-details/mg-details.js +141 -0
  60. package/dist/collection/components/molecules/mg-form/{mg-form.stories.js → doc/mg-form.stories.js} +9 -6
  61. package/dist/collection/components/molecules/mg-form/mg-form.css +5 -1
  62. package/dist/collection/components/molecules/mg-form/mg-form.js +53 -7
  63. package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +22 -0
  64. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.css +37 -0
  65. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +74 -0
  66. package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +10 -16
  67. package/dist/collection/components/molecules/mg-message/mg-message.js +15 -7
  68. package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +43 -0
  69. package/dist/collection/components/molecules/mg-modal/mg-modal.css +5 -7
  70. package/dist/collection/components/molecules/mg-modal/mg-modal.js +10 -4
  71. package/dist/collection/components/molecules/mg-pagination/doc/mg-pagination.stories.js +20 -0
  72. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +17 -18
  73. package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +29 -0
  74. package/dist/collection/components/molecules/mg-panel/mg-panel.css +4 -2
  75. package/dist/collection/components/molecules/mg-panel/mg-panel.js +12 -16
  76. package/dist/collection/components/molecules/mg-popover/{mg-popover.stories.js → doc/mg-popover.stories.js} +22 -16
  77. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +20 -0
  78. package/dist/collection/components/molecules/mg-popover/mg-popover.css +1 -1
  79. package/dist/collection/components/molecules/mg-popover/mg-popover.js +43 -13
  80. package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +20 -15
  81. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +7 -0
  82. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +3 -0
  83. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +75 -29
  84. package/dist/collection/locales/index.js +33 -4
  85. package/dist/collection/stories/helpers.stories.js +41 -0
  86. package/dist/collection/stories/icons.stories.js +10 -2
  87. package/dist/collection/stories/typography.stories.js +8 -1
  88. package/dist/collection/utils/components.utils.js +10 -0
  89. package/dist/collection/utils/locale.utils.js +7 -4
  90. package/dist/collection/variables.css +10 -5
  91. package/dist/collection/variables.scss +10 -5
  92. package/dist/components/MgInput.js +6 -23
  93. package/dist/components/components.utils.js +11 -1
  94. package/dist/components/index.d.ts +25 -5
  95. package/dist/components/index.js +25 -0
  96. package/dist/components/index2.js +97 -8
  97. package/dist/components/locale.utils.js +7 -5
  98. package/dist/components/mg-badge2.js +16 -4
  99. package/dist/components/mg-button2.js +14 -17
  100. package/dist/components/mg-character-left2.js +4 -27
  101. package/dist/components/mg-details.d.ts +11 -0
  102. package/dist/components/mg-details.js +87 -0
  103. package/dist/components/mg-form.js +40 -8
  104. package/dist/components/mg-icon2.js +122 -17
  105. package/dist/components/mg-illustrated-message.d.ts +11 -0
  106. package/dist/components/mg-illustrated-message.js +68 -0
  107. package/dist/components/mg-input-checkbox.js +11 -27
  108. package/dist/components/mg-input-date.js +21 -25
  109. package/dist/components/mg-input-numeric.js +28 -26
  110. package/dist/components/mg-input-password.js +18 -28
  111. package/dist/components/mg-input-radio.js +10 -22
  112. package/dist/components/mg-input-select2.js +24 -35
  113. package/dist/components/mg-input-text2.js +38 -26
  114. package/dist/components/mg-input-textarea.js +43 -20
  115. package/dist/components/mg-input-toggle.js +27 -18
  116. package/dist/components/mg-message.js +16 -8
  117. package/dist/components/mg-modal.js +11 -5
  118. package/dist/components/mg-pagination.js +16 -22
  119. package/dist/components/mg-panel.js +9 -12
  120. package/dist/components/mg-popover.js +22 -12
  121. package/dist/components/mg-tabs.js +77 -22
  122. package/dist/components/mg-tag.js +20 -5
  123. package/dist/components/mg-tooltip2.js +74 -12
  124. package/dist/components/popper.js +6 -2
  125. package/dist/esm/{index-c346f52d.js → index-7efedd97.js} +107 -8
  126. package/dist/esm/{index-9e877561.js → index-bca81100.js} +48 -46
  127. package/dist/esm/loader.js +3 -17
  128. package/dist/esm/mg-badge_24.entry.js +5660 -0
  129. package/dist/esm/mg-components.js +3 -7
  130. package/dist/esm/mg-modal.entry.js +12 -6
  131. package/dist/index.js +1 -1
  132. package/dist/mg-components/mg-components.css +1 -1
  133. package/dist/mg-components/mg-components.esm.js +1 -1
  134. package/dist/mg-components/p-5f89600c.js +1 -0
  135. package/dist/mg-components/p-a2883dc7.entry.js +1 -0
  136. package/dist/mg-components/p-b14a3443.js +2 -0
  137. package/dist/mg-components/p-cffe0519.entry.js +1 -0
  138. package/dist/mg-components/variables.css +10 -5
  139. package/dist/mg-components/variables.scss +10 -5
  140. package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +0 -0
  141. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -1
  142. package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +6 -0
  143. package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +8 -0
  144. package/dist/types/components/atoms/mg-button/mg-button.d.ts +12 -1
  145. package/dist/types/{stories/tags.stories.d.ts → components/atoms/mg-character-left/doc/mg-character-left.stories.d.ts} +2 -1
  146. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +5 -13
  147. package/dist/types/components/atoms/mg-icon/{mg-icon.stories.d.ts → doc/mg-icon.stories.d.ts} +0 -0
  148. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +3 -3
  149. package/dist/types/components/atoms/mg-input-title/{mg-input-title.stories.d.ts → doc/mg-input-title.stories.d.ts} +0 -0
  150. package/dist/types/components/atoms/mg-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +0 -0
  151. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +8 -1
  152. package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +24 -0
  153. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +13 -0
  154. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +27 -2
  155. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +0 -6
  156. package/dist/types/components/molecules/inputs/MgInput.d.ts +2 -4
  157. package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +0 -0
  158. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -2
  159. package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +0 -0
  160. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +7 -1
  161. package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +6 -0
  162. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +8 -2
  163. package/dist/types/components/molecules/inputs/mg-input-password/{mg-input-password.stories.d.ts → doc/mg-input-password.stories.d.ts} +8 -0
  164. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +7 -2
  165. package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.stories.d.ts} +0 -0
  166. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -1
  167. package/dist/types/components/molecules/inputs/mg-input-select/{mg-input-select.stories.d.ts → doc/mg-input-select.stories.d.ts} +11 -5
  168. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +7 -2
  169. package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +8 -0
  170. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +7 -7
  171. package/dist/types/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.d.ts → doc/mg-input-textarea.stories.d.ts} +8 -0
  172. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +14 -6
  173. package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.stories.d.ts} +0 -0
  174. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -0
  175. package/dist/types/components/molecules/mg-details/doc/mg-details.stories.d.ts +11 -0
  176. package/dist/types/components/molecules/mg-details/mg-details.d.ts +49 -0
  177. package/dist/types/components/molecules/mg-form/{mg-form.stories.d.ts → doc/mg-form.stories.d.ts} +0 -0
  178. package/dist/types/components/molecules/mg-form/mg-form.d.ts +14 -0
  179. package/dist/types/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.d.ts +6 -0
  180. package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +28 -0
  181. package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +0 -0
  182. package/dist/types/components/molecules/mg-message/mg-message.d.ts +2 -0
  183. package/dist/types/components/molecules/mg-modal/{mg-modal.stories.d.ts → doc/mg-modal.stories.d.ts} +0 -0
  184. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +2 -0
  185. package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +0 -0
  186. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +8 -0
  187. package/dist/types/components/molecules/mg-panel/{mg-panel.stories.d.ts → doc/mg-panel.stories.d.ts} +0 -0
  188. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +5 -0
  189. package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +28 -0
  190. package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +8 -0
  191. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +15 -2
  192. package/dist/types/components/molecules/mg-tabs/{mg-tabs.stories.d.ts → doc/mg-tabs.stories.d.ts} +0 -0
  193. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +7 -1
  194. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +44 -0
  195. package/dist/types/components.d.ts +240 -147
  196. package/dist/types/home/runner/work/mg-components/mg-components/.stencil/.storybook/utils.d.ts +1 -0
  197. package/dist/types/locales/index.d.ts +109 -46
  198. package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
  199. package/dist/types/utils/components.utils.d.ts +8 -0
  200. package/dist/types/utils/locale.utils.d.ts +7 -3
  201. package/loader/index.js +1 -1
  202. package/package.json +16 -16
  203. package/readme.md +6 -35
  204. package/dist/cjs/css-shim-629916b0.js +0 -6
  205. package/dist/cjs/mg-badge_21.cjs.entry.js +0 -3358
  206. package/dist/cjs/mg-popover.cjs.entry.js +0 -161
  207. package/dist/cjs/popper-0c3964e7.js +0 -1786
  208. package/dist/cjs/shadow-css-546083ef.js +0 -390
  209. package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +0 -23
  210. package/dist/collection/components/atoms/mg-input-title/mg-input-title.stories.js +0 -21
  211. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.stories.js +0 -26
  212. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +0 -78
  213. package/dist/collection/components/molecules/mg-modal/mg-modal.stories.js +0 -51
  214. package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +0 -24
  215. package/dist/collection/components/molecules/mg-panel/mg-panel.stories.js +0 -39
  216. package/dist/collection/stories/buttons.stories.js +0 -43
  217. package/dist/collection/stories/messages.stories.js +0 -44
  218. package/dist/collection/stories/tags.stories.js +0 -13
  219. package/dist/esm/css-shim-0993aa3b.js +0 -4
  220. package/dist/esm/mg-badge_21.entry.js +0 -3334
  221. package/dist/esm/mg-popover.entry.js +0 -157
  222. package/dist/esm/popper-8874fd6c.js +0 -1784
  223. package/dist/esm/shadow-css-dfa0587f.js +0 -388
  224. package/dist/esm-es5/css-shim-0993aa3b.js +0 -1
  225. package/dist/esm-es5/index-9e877561.js +0 -1
  226. package/dist/esm-es5/index-c346f52d.js +0 -1
  227. package/dist/esm-es5/index.js +0 -0
  228. package/dist/esm-es5/loader.js +0 -1
  229. package/dist/esm-es5/mg-badge_21.entry.js +0 -2
  230. package/dist/esm-es5/mg-components.js +0 -1
  231. package/dist/esm-es5/mg-modal.entry.js +0 -1
  232. package/dist/esm-es5/mg-popover.entry.js +0 -1
  233. package/dist/esm-es5/popper-8874fd6c.js +0 -1
  234. package/dist/esm-es5/shadow-css-dfa0587f.js +0 -12
  235. package/dist/mg-components/mg-components.js +0 -132
  236. package/dist/mg-components/p-136c8d6f.system.entry.js +0 -2
  237. package/dist/mg-components/p-3c14153d.js +0 -1
  238. package/dist/mg-components/p-50ea2036.system.js +0 -1
  239. package/dist/mg-components/p-55a22b35.system.js +0 -1
  240. package/dist/mg-components/p-5e796581.js +0 -12
  241. package/dist/mg-components/p-656b5efb.system.js +0 -1
  242. package/dist/mg-components/p-68d6f104.js +0 -1
  243. package/dist/mg-components/p-6d49ed95.js +0 -1
  244. package/dist/mg-components/p-6f173f62.system.entry.js +0 -1
  245. package/dist/mg-components/p-70177194.entry.js +0 -1
  246. package/dist/mg-components/p-8b2d8a2a.system.js +0 -13
  247. package/dist/mg-components/p-8cb61c3f.system.js +0 -1
  248. package/dist/mg-components/p-ace173b1.js +0 -1
  249. package/dist/mg-components/p-b7488a4c.entry.js +0 -1
  250. package/dist/mg-components/p-c1ffb2e1.entry.js +0 -1
  251. package/dist/mg-components/p-c90cc4bf.system.js +0 -1
  252. package/dist/mg-components/p-de1164fa.system.entry.js +0 -1
  253. package/dist/mg-components/p-e4a502b5.system.js +0 -1
  254. package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +0 -16
  255. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
  256. package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +0 -12
  257. package/dist/types/stories/messages.stories.d.ts +0 -13
@@ -1,3334 +0,0 @@
1
- import { r as registerInstance, h, g as getElement, c as createEvent, H as Host } from './index-9e877561.js';
2
- import { C as ClassList, c as createID, m as messages, l as locale, a as currency, b as allItemsAreString } from './index-c346f52d.js';
3
- import { c as createPopper } from './popper-8874fd6c.js';
4
-
5
- /**
6
- * List of all possibles variants
7
- */
8
- const variants$4 = ['info', 'primary', 'secondary', 'success', 'warning', 'danger'];
9
-
10
- const mgBadgeCss = ".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}.mg-badge{padding:0 0.4rem;height:var(--mg-badge-size);min-width:var(--mg-badge-size);-webkit-box-sizing:border-box;box-sizing:border-box;border:0.1rem solid;border-radius:50%;border-radius:calc(var(--mg-badge-size) / 2);font-size:var(--mg-badge-font-size);font-weight:600;text-align:center;line-height:var(--mg-badge-size)}.mg-badge.mg-badge--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-badge.mg-badge--primary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-badge.mg-badge--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-badge.mg-badge--success.mg-badge--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-badge.mg-badge--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-badge.mg-badge--warning.mg-badge--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-badge.mg-badge--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-badge.mg-badge--danger.mg-badge--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-badge.mg-badge--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-badge.mg-badge--info.mg-badge--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-badge,mg-badge{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}";
11
-
12
- const MgBadge = class {
13
- constructor(hostRef) {
14
- registerInstance(this, hostRef);
15
- /**
16
- * Define button variant
17
- */
18
- this.variant = variants$4[0]; // info
19
- /**
20
- * Component classes
21
- */
22
- this.classList = new ClassList(['mg-badge']);
23
- }
24
- validateValue(newValue) {
25
- if (`${newValue}`.match(/^(\d+|[?*!a-z])$/i) === null) {
26
- throw new Error('<mg-badge> prop "value" must be interger or ponctuation character.');
27
- }
28
- }
29
- validateVariant(newValue) {
30
- if (!variants$4.includes(newValue)) {
31
- throw new Error(`<mg-badge> prop "variant" must be one of : ${variants$4.join(', ')}.`);
32
- }
33
- this.classList.add(`mg-badge--${this.variant}`);
34
- }
35
- validateOutline(newValue) {
36
- if (newValue)
37
- this.classList.add(`mg-badge--outline`);
38
- }
39
- /**
40
- * Check if props are well configured on init
41
- *
42
- * @returns {void}
43
- */
44
- componentWillLoad() {
45
- this.validateValue(this.value);
46
- this.validateVariant(this.variant);
47
- this.validateOutline(this.outline);
48
- }
49
- /**
50
- * Render
51
- *
52
- * @returns {HTMLElement} HTML Element
53
- */
54
- render() {
55
- return (h("span", { class: this.classList.join() }, this.value, h("span", { class: "sr-only" }, this.label)));
56
- }
57
- static get watchers() { return {
58
- "value": ["validateValue"],
59
- "variant": ["validateVariant"],
60
- "outline": ["validateOutline"]
61
- }; }
62
- };
63
- MgBadge.style = mgBadgeCss;
64
-
65
- /**
66
- * List of all possibles variants
67
- */
68
- const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success'];
69
-
70
- const mgButtonCss = ".mg-button.sc-mg-button{position:relative;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-webkit-column-gap:0.6rem;-moz-column-gap:0.6rem;column-gap:0.6rem;padding:calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;min-height:var(--default-size);-webkit-box-sizing:border-box;box-sizing:border-box;border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-border-radius));cursor:pointer;background-image:none;border-top-width:var(--mg-button-border-top-width, 0.1rem);border-right-width:var(--mg-button-border-right-width, 0.1rem);border-bottom-width:var(--mg-button-border-bottom-width, 0.1rem);border-left-width:var(--mg-button-border-left-width, 0.1rem);border-style:solid;font-family:inherit;text-decoration:none;font-weight:normal;text-align:left;-ms-touch-action:manipulation;touch-action:manipulation}.mg-button[disabled].sc-mg-button,.mg-button[aria-disabled=true].sc-mg-button,.mg-button.disabled.sc-mg-button{opacity:var(--mg-button-disabled-opacity);cursor:default}.mg-button.mg-button--icon.sc-mg-button{padding:0;-ms-flex-pack:center;justify-content:center;width:var(--default-size);height:var(--default-size);border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-icon-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-icon-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-icon-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-icon-border-radius));font-size:var(--font-size);line-height:var(--font-size)}.mg-button.mg-button--primary.sc-mg-button{border-color:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l));border-color:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - 10%));color:hsl(var(--mg-button-primary-font-color));background:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l));background:-webkit-gradient(linear, left top, left bottom, from(hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l))), to(hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%))));background:linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%)))}.mg-button.mg-button--primary.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--primary.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--primary.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l))}.mg-button.mg-button--secondary.sc-mg-button{border-color:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l));border-color:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - 10%));color:hsl(var(--mg-button-secondary-font-color));background:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l));background:-webkit-gradient(linear, left top, left bottom, from(hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l))), to(hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%))));background:linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%)))}.mg-button.mg-button--secondary.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--secondary.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--secondary.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l))}.mg-button.mg-button--danger.sc-mg-button{border-color:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));border-color:hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - 10%));color:hsl(var(--color-neutral));background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));background:-webkit-gradient(linear, left top, left bottom, from(hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))), to(hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%))));background:linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%)))}.mg-button.mg-button--danger.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-button.mg-button--danger-alt.sc-mg-button{border-color:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l));border-color:hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - 10%));color:hsl(var(--color-danger));background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l));background:-webkit-gradient(linear, left top, left bottom, from(hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))), to(hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%))));background:linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%)))}.mg-button.mg-button--danger-alt.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger-alt.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger-alt.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))}.mg-button.mg-button--info.sc-mg-button{border-color:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));border-color:hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - 10%));color:hsl(var(--color-neutral));background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));background:-webkit-gradient(linear, left top, left bottom, from(hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))), to(hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%))));background:linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%)))}.mg-button.mg-button--info.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--info.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--info.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-button.mg-button--success.sc-mg-button{border-color:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l));border-color:hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - 10%));color:hsl(var(--color-dark));background:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l));background:-webkit-gradient(linear, left top, left bottom, from(hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))), to(hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-gradient) * 10%))));background:linear-gradient(to bottom, hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l)), hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-gradient) * 10%)))}.mg-button.mg-button--success.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--success.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--success.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))}.mg-button.mg-button--flat.sc-mg-button{background:none;border:none}.mg-button.mg-button--flat.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--flat.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--flat.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsla(var(--color-dark), 0.1)}.mg-button.sc-mg-button mg-icon.sc-mg-button:only-child,.mg-button .sc-mg-button-s>mg-icon{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-negative:0;flex-shrink:0;line-height:1;margin:auto 0}.mg-button.mg-button--loading.sc-mg-button>mg-icon.sc-mg-button{position:absolute;left:50%;top:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.mg-button.mg-button--loading.sc-mg-button .mg-button__content.sc-mg-button{opacity:0}.mg-button__content.sc-mg-button{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-webkit-column-gap:0.6rem;-moz-column-gap:0.6rem;column-gap:0.6rem}mg-button.sc-mg-button{display:inline-block}.mg-button.sc-mg-button,mg-button.sc-mg-button{vertical-align:middle;max-width:100%}";
71
-
72
- const MgButton = class {
73
- constructor(hostRef) {
74
- registerInstance(this, hostRef);
75
- /************
76
- * Internal *
77
- ************/
78
- this.onClickElementFn = null;
79
- /**
80
- * Define button variant
81
- */
82
- this.variant = variants$3[0]; // Primary
83
- /**
84
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
85
- * If not set, it will be created.
86
- */
87
- this.identifier = createID('mg-button');
88
- /**
89
- * Disable button
90
- */
91
- this.disabled = false;
92
- /**
93
- * Define if button is round.
94
- * Used for icon button.
95
- */
96
- this.isIcon = false;
97
- /**
98
- * Option to set input disable on click, in order to prevent multi-click.
99
- * Parent component have to remove the attribute 'disabled' when the process ends.
100
- */
101
- this.disableOnClick = false;
102
- /**
103
- * Prop to set aria-expanded on button element
104
- */
105
- this.expanded = false;
106
- /**
107
- * Option to set aria-haspopup
108
- * The aria-haspopup state informs assistive technology users that there is a popup and the type of popup it is, but provides no interactivity.
109
- */
110
- this.haspopup = false;
111
- /**
112
- * Define if button is loading, default to false.
113
- * Trigger when button is clicked or key-up ['enter', 'space], then value change to true.
114
- * It's required to reset to false when action/promise in parent is done to stop the loading state
115
- */
116
- this.loading = false;
117
- /**
118
- * Component classes
119
- */
120
- this.classList = new ClassList(['mg-button']);
121
- /**
122
- * Trigger actions onClick event
123
- *
124
- * @param {MouseEvent} event click event
125
- * @returns {void}
126
- */
127
- this.handleClick = (event) => {
128
- if (this.disabled)
129
- event.stopPropagation();
130
- // Used to prevent multi-click.
131
- if (this.disableOnClick && !this.disabled) {
132
- this.loading = true;
133
- this.disabled = true;
134
- }
135
- };
136
- }
137
- validateVariant(newValue) {
138
- if (!variants$3.includes(newValue)) {
139
- throw new Error(`<mg-button> prop "variant" must be one of : ${variants$3.join(', ')}`);
140
- }
141
- this.classList.add(`mg-button--${this.variant}`);
142
- }
143
- disabledHandler(isDisabled) {
144
- // Remove loading when enable
145
- // Will be set back onclick
146
- if (!isDisabled && this.disableOnClick) {
147
- this.loading = false;
148
- }
149
- // Manage if onclick
150
- this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
151
- }
152
- loadingHandler(newValue) {
153
- // we add loading style if it newvalue is true else we remove it
154
- if (newValue) {
155
- this.classList.add('mg-button--loading');
156
- }
157
- else {
158
- this.classList.delete('mg-button--loading');
159
- }
160
- }
161
- /**
162
- * Check if props are well configured on init
163
- *
164
- * @returns {void}
165
- */
166
- componentWillLoad() {
167
- this.validateVariant(this.variant);
168
- if (this.isIcon) {
169
- this.classList.add(`mg-button--icon`);
170
- if (typeof this.label !== 'string' || this.label === '') {
171
- throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
172
- }
173
- }
174
- // Store the onclick fn
175
- this.onClickElementFn = this.element.onclick;
176
- this.disabledHandler(this.disabled);
177
- }
178
- /**
179
- * Render component
180
- *
181
- * @returns {HTMLElement} html element
182
- */
183
- render() {
184
- return (h("button", { id: this.identifier, class: this.classList.join(), "aria-label": this.label, "aria-disabled": this.disabled.toString(), "aria-expanded": this.expanded, "aria-controls": this.controls, "aria-haspopup": this.haspopup, onClick: this.handleClick }, this.loading && h("mg-icon", { icon: "loader", spin: true }), h("div", { class: "mg-button__content" }, h("slot", null))));
185
- }
186
- get element() { return getElement(this); }
187
- static get watchers() { return {
188
- "variant": ["validateVariant"],
189
- "disabled": ["disabledHandler"],
190
- "loading": ["loadingHandler"]
191
- }; }
192
- };
193
- MgButton.style = mgButtonCss;
194
-
195
- const mgCharacterLeftCss = "mg-character-left.sc-mg-character-left{display:block}";
196
-
197
- const MgCharacterLeft = class {
198
- constructor(hostRef) {
199
- registerInstance(this, hostRef);
200
- /************
201
- * Internal *
202
- ************/
203
- this.mustacheCounter = '{counter}';
204
- /**
205
- * Template to display remaining characters.
206
- * Must have {counter} inside
207
- */
208
- this.template = messages.nbCharLeft;
209
- /**
210
- * Sets the characters to count
211
- */
212
- this.characters = '';
213
- /**
214
- * Calculate number character left
215
- *
216
- * @returns {string} message
217
- */
218
- this.getMessage = () => {
219
- return this.template.replace(this.mustacheCounter, `<strong>${this.maxlength - this.characters.length}</strong>`);
220
- };
221
- }
222
- validateTemplate(newValue) {
223
- if (typeof newValue !== 'string' || newValue === '' || newValue.indexOf(this.mustacheCounter) === -1) {
224
- throw new Error(`<mg-character-left> prop "template" must contain "${this.mustacheCounter}".`);
225
- }
226
- }
227
- validateMaxlength(newValue) {
228
- if (typeof newValue !== 'number') {
229
- throw new Error('<mg-character-left> prop "maxlength" is required.');
230
- }
231
- }
232
- /*************
233
- * Lifecycle *
234
- *************/
235
- /**
236
- * Check if props are well configured on init
237
- *
238
- * @returns {void}
239
- */
240
- componentWillLoad() {
241
- this.validateTemplate(this.template);
242
- this.validateMaxlength(this.maxlength);
243
- }
244
- /**
245
- * Render component
246
- *
247
- * @returns {HTMLElement} HTML Element
248
- */
249
- render() {
250
- return h("span", { id: this.identifier, innerHTML: this.getMessage(), "aria-live": "polite" });
251
- }
252
- static get watchers() { return {
253
- "template": ["validateTemplate"],
254
- "maxlength": ["validateMaxlength"]
255
- }; }
256
- };
257
- MgCharacterLeft.style = mgCharacterLeftCss;
258
-
259
- const mgFormCss = ".is-asterisk{color:hsl(var(--color-danger))}.mg-form,.mg-form-group{--mg-inputs-margin-bottom:1.5rem;--mg-inputs-title-horizontal-space:3rem;--mg-inputs-title-width:15rem;--mg-inputs-shrink:0}.mg-form.mg-form--all-required,.mg-form-group.mg-form--all-required{--mg-input-title-display:none}";
260
-
261
- const MgForm = class {
262
- constructor(hostRef) {
263
- registerInstance(this, hostRef);
264
- this.formValid = createEvent(this, "form-valid", 7);
265
- /**
266
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
267
- * If not set, it will be created.
268
- */
269
- this.identifier = createID('mg-form');
270
- /**
271
- * Input name
272
- * If not set the value equals the identifier
273
- */
274
- this.name = this.identifier;
275
- /**
276
- * Define if form is readonly
277
- */
278
- this.readonly = false;
279
- /**
280
- * Define if form is disabled
281
- */
282
- this.disabled = false;
283
- /**
284
- * Component classes
285
- */
286
- this.classList = new ClassList(['mg-form']);
287
- /**
288
- * Define required message based on mg-inputs required elements
289
- * Also
290
- *
291
- * @returns {void}
292
- */
293
- this.setRequiredMessage = () => {
294
- // Get required fields
295
- const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !this.disabled);
296
- // All fields are required
297
- // mg-input-toggle can not be required
298
- if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
299
- this.requiredMessage = messages.form.allRequired;
300
- this.classList.add('mg-form--all-required');
301
- }
302
- // Some fields are required
303
- else if (requiredInputs.length > 0) {
304
- this.requiredMessage = messages.form.required;
305
- }
306
- };
307
- /**
308
- * Check if form is valid
309
- *
310
- * @returns {void}
311
- */
312
- this.checkValidity = () => {
313
- const validity = !this.mgInputs.some(input => input.invalid);
314
- this.valid = validity;
315
- this.invalid = !validity;
316
- this.formValid.emit(validity);
317
- };
318
- }
319
- /**
320
- * Public method to display errors
321
- *
322
- * @returns {Promise<void>}
323
- */
324
- async displayError() {
325
- if (!this.readonly) {
326
- this.mgInputs.forEach(input => {
327
- input.displayError && input.displayError();
328
- });
329
- this.checkValidity();
330
- }
331
- }
332
- /*************
333
- * Lifecycle *
334
- *************/
335
- /**
336
- * Check if component props are well configured on init
337
- *
338
- * @returns {void}
339
- */
340
- componentWillLoad() {
341
- // Get slotted mgIputs
342
- this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
343
- // Define required message
344
- this.setRequiredMessage();
345
- // Check validity when slotted mgImputs are ready
346
- Promise.all(this.mgInputs.map(async (input) => {
347
- // Set inputs readonly or disabled based on form configuration
348
- // Othewise listen to events
349
- if (this.readonly)
350
- input.readonly = true;
351
- else if (this.disabled)
352
- input.disabled = true;
353
- else
354
- input.addEventListener('input-valid', this.checkValidity);
355
- await input.componentOnReady();
356
- })).then(() => {
357
- this.checkValidity();
358
- });
359
- }
360
- /**
361
- * Render
362
- *
363
- * @returns {HTMLElement} HTML Element
364
- */
365
- render() {
366
- return (h("form", { class: this.classList.join(), id: this.identifier, name: this.name }, this.requiredMessage && h("p", { innerHTML: this.requiredMessage }), h("slot", null), !this.readonly && !this.disabled && h("slot", { name: "actions" })));
367
- }
368
- get element() { return getElement(this); }
369
- };
370
- MgForm.style = mgFormCss;
371
-
372
- /**
373
- * Icon SVG paths
374
- */
375
- const icons = {
376
- 'arrow-down': () => (h("path", { fill: "currentColor", d: "M13,10.1H10.23a.31.31,0,0,1-.32-.28h0V.94A.3.3,0,0,0,9.59.65H6.37A.32.32,0,0,0,6,.94H6V9.81a.29.29,0,0,1-.31.29H3a.3.3,0,0,0-.31.29.27.27,0,0,0,.08.22l5.06,4.58a.36.36,0,0,0,.46,0l5-4.58a.29.29,0,0,0,0-.42C13.22,10.1,13.12,10.1,13,10.1Z" })),
377
- 'arrow-left': () => (h("path", { fill: "currentColor", d: "M5.88,12.93V10.18a.3.3,0,0,1,.28-.32H15a.31.31,0,0,0,.29-.33h0V6.32A.31.31,0,0,0,15,6H6.17a.32.32,0,0,1-.29-.31h0V2.93a.3.3,0,0,0-.28-.32.32.32,0,0,0-.23.09L.79,7.76a.36.36,0,0,0,0,.46l4.58,5a.31.31,0,0,0,.43,0A.4.4,0,0,0,5.88,12.93Z" })),
378
- 'arrow-right': () => (h("path", { fill: "currentColor", d: "M10.16,3V5.75a.3.3,0,0,1-.28.32H1a.31.31,0,0,0-.29.33h0V9.61A.31.31,0,0,0,1,9.94H9.87a.29.29,0,0,1,.29.31h0V13a.3.3,0,0,0,.28.32.32.32,0,0,0,.23-.09l4.58-5.06a.36.36,0,0,0,0-.46l-4.58-5a.3.3,0,0,0-.42,0C10.16,2.76,10.16,2.87,10.16,3Z" })),
379
- 'arrow-up': () => (h("path", { fill: "currentColor", d: "M3.06,5.82H5.81a.31.31,0,0,1,.32.28h0V15a.31.31,0,0,0,.33.29H9.67A.3.3,0,0,0,10,15h0V6.11a.3.3,0,0,1,.31-.29h2.75a.3.3,0,0,0,.23-.51L8.23.73a.36.36,0,0,0-.46,0l-5,4.58a.3.3,0,0,0,0,.43C2.82,5.83,2.92,5.82,3.06,5.82Z" })),
380
- 'arrow-up-right-square': () => (h("path", { fill: "currentColor", d: "M14.33 3v10A1.34 1.34 0 0 1 13 14.33H3A1.34 1.34 0 0 1 1.67 13V3A1.34 1.34 0 0 1 3 1.67h10A1.34 1.34 0 0 1 14.33 3Zm-2.48.46H8.68a.67.67 0 0 0-.68.7.63.63 0 0 0 .2.47l.91.91-5.53 5.53a.33.33 0 0 0 0 .48l.87.87a.33.33 0 0 0 .48 0l5.53-5.52.91.9a.69.69 0 0 0 1 0 .71.71 0 0 0 .19-.48V4.15a.67.67 0 0 0-.67-.67Z" })),
381
- 'arrows-rotate': () => (h("path", { fill: "currentColor", d: "M2.3,7h3.4c0.3,0,0.6-0.3,0.6-0.6c0-0.1-0.1-0.3-0.2-0.4L5.1,4.9c1.7-1.6,4.4-1.5,6,0.2c0,0,0,0,0,0 c0.5,0.5,0.8,1.2,1,1.9h2.1C13.7,3.5,10.4,1.2,7,1.8C5.7,2,4.6,2.6,3.6,3.4L2.7,2.5c-0.2-0.2-0.6-0.2-0.8,0c0,0,0,0,0,0l0,0 C1.8,2.6,1.7,2.8,1.7,2.9v3.4C1.7,6.7,1.9,7,2.3,7z M13.7,9h-3.4C9.9,9,9.7,9.3,9.7,9.6c0,0.2,0.1,0.3,0.2,0.4l1.1,1.1 c-1.7,1.6-4.4,1.5-6-0.2C4.4,10.4,4,9.7,3.8,9H1.7c0.6,3.5,3.9,5.8,7.3,5.2c1.3-0.2,2.4-0.8,3.3-1.7l0.9,0.9c0.2,0.2,0.6,0.2,0.8,0 c0,0,0,0,0,0l0,0c0.1-0.1,0.2-0.3,0.2-0.4V9.6C14.3,9.3,14.1,9,13.7,9z" })),
382
- 'ban': () => (h("path", { fill: "currentColor", d: "M8 .67A7.33 7.33 0 1 0 15.33 8 7.33 7.33 0 0 0 8 .67Zm3.85 3.48a5.46 5.46 0 0 1 .61 7L4.88 3.54a5.46 5.46 0 0 1 6.97.61Zm-7.7 7.7a5.45 5.45 0 0 1-.61-7l7.58 7.58a5.46 5.46 0 0 1-7-.61Z" })),
383
- 'calculator': () => (h("path", { fill: "currentColor", d: "M12.83.67H3.17a.5.5 0 0 0-.5.5v13.66a.5.5 0 0 0 .5.5h9.66a.5.5 0 0 0 .5-.5V1.17a.5.5 0 0 0-.5-.5ZM5.58 13.39a.29.29 0 0 1-.28.3H4.1a.29.29 0 0 1-.3-.28v-1.2a.29.29 0 0 1 .28-.3h1.2a.29.29 0 0 1 .3.28v1.2Zm0-3.28a.29.29 0 0 1-.3.3H4.1a.29.29 0 0 1-.3-.3V8.93a.29.29 0 0 1 .28-.3h1.2a.29.29 0 0 1 .3.28v1.2Zm3.29 3.28a.29.29 0 0 1-.3.3H7.38a.29.29 0 0 1-.3-.3v-1.18a.29.29 0 0 1 .3-.3h1.19a.29.29 0 0 1 .3.3Zm0-3.28a.32.32 0 0 1-.3.3H7.38a.32.32 0 0 1-.3-.3V8.93a.29.29 0 0 1 .3-.3h1.19a.29.29 0 0 1 .3.3Zm3.33 3.28a.29.29 0 0 1-.28.3h-1.25a.29.29 0 0 1-.3-.28V8.93a.29.29 0 0 1 .28-.3h1.25a.29.29 0 0 1 .3.28v4.48Zm0-7.15a.29.29 0 0 1-.3.3H4.1a.29.29 0 0 1-.3-.3V2.61a.29.29 0 0 1 .28-.3h7.82a.29.29 0 0 1 .3.28v3.65Z" })),
384
- 'check': () => (h("path", { fill: "currentColor", d: "M15.3,4.2L14.2,3c-0.1-0.1-0.3-0.1-0.4,0L6,10.4l-3.8-4C2.2,6.3,2.1,6.3,2,6.4L0.7,7.6c-0.1,0.1-0.1,0.2,0,0.3l5.1,5.4c0.1,0.1,0.2,0.1,0.3,0c0,0,0,0,0,0L7.4,12l0,0l7.9-7.4C15.4,4.5,15.4,4.3,15.3,4.2C15.3,4.2,15.3,4.2,15.3,4.2z" })),
385
- 'check-circle': () => (h("path", { fill: "currentColor", d: "M15.33 8A7.33 7.33 0 1 1 8 .67 7.33 7.33 0 0 1 15.33 8Zm-8.18 3.88 5.44-5.44a.46.46 0 0 0 0-.65l-.67-.67a.48.48 0 0 0-.67 0L6.82 9.54 4.75 7.47a.46.46 0 0 0-.65 0l-.67.67a.46.46 0 0 0 0 .65l3.07 3.07a.46.46 0 0 0 .65 0Z" })),
386
- 'chevron-down': () => (h("path", { fill: "currentColor", d: "M7.43,12.21.9,5.69a.81.81,0,0,1,0-1.14h0l.76-.77a.81.81,0,0,1,1.14,0L8,9l5.2-5.18a.81.81,0,0,1,1.14,0l.76.77a.8.8,0,0,1,0,1.13h0L8.57,12.21a.79.79,0,0,1-1.13,0Z" })),
387
- 'chevron-left': () => (h("path", { fill: "currentColor", d: "M3.79,7.43,10.31.9a.81.81,0,0,1,1.14,0h0l.77.76a.81.81,0,0,1,0,1.14L7,8l5.18,5.2a.81.81,0,0,1,0,1.14l-.77.76a.8.8,0,0,1-1.13,0h0L3.79,8.57a.79.79,0,0,1,0-1.13Z" })),
388
- 'chevron-right': () => (h("path", { fill: "currentColor", d: "M12.21,8.57,5.69,15.1a.81.81,0,0,1-1.14,0h0l-.77-.76a.81.81,0,0,1,0-1.14L9,8,3.78,2.8a.81.81,0,0,1,0-1.14L4.55.9A.8.8,0,0,1,5.68.9h0l6.53,6.53a.79.79,0,0,1,0,1.13Z" })),
389
- 'chevron-up': () => (h("path", { fill: "currentColor", d: "M8.57,3.79l6.53,6.52a.81.81,0,0,1,0,1.14h0l-.76.77a.81.81,0,0,1-1.14,0L8,7,2.8,12.22a.81.81,0,0,1-1.14,0L.9,11.45a.8.8,0,0,1,0-1.13h0L7.43,3.79a.79.79,0,0,1,1.13,0Z" })),
390
- 'clock': () => (h("path", { fill: "currentColor", d: "M8,.67C3.95,.67,.67,3.95,.67,8s3.28,7.33,7.33,7.33,7.33-3.28,7.33-7.33h0C15.33,3.95,12.05,.67,8,.67h0Zm1.69,10.33l-2.61-1.88c-.09-.07-.14-.17-.14-.28V3.84c0-.19,.16-.35,.35-.36h1.42c.2,0,.35,.16,.36,.36V7.93l1.87,1.37c.16,.1,.2,.32,.09,.47v.02h-.01l-.83,1.15c-.12,.15-.34,.18-.5,.06Z" })),
391
- 'conversation': () => (h("path", { fill: "currentColor", d: "M11.22,6.48c0-2.11-2.36-3.81-5.28-3.81S.67,4.37.67,6.48a3.15,3.15,0,0,0,1,2.19A5.17,5.17,0,0,1,.72,10a.2.2,0,0,0,0,.21.23.23,0,0,0,.19.12,4.79,4.79,0,0,0,2.25-.6,6.84,6.84,0,0,0,2.82.6C8.86,10.29,11.22,8.58,11.22,6.48Zm3.1,5.23a3.08,3.08,0,0,0,1-2.19C15.28,7.93,14,6.57,12,6a3.84,3.84,0,0,1,0,.48C12,9,9.3,11.05,6,11.05a7.16,7.16,0,0,1-.8-.05A5.6,5.6,0,0,0,10,13.33a6.7,6.7,0,0,0,2.82-.59,4.66,4.66,0,0,0,2.25.59.21.21,0,0,0,.19-.11.2.2,0,0,0,0-.21,5.15,5.15,0,0,1-.91-1.3Z" })),
392
- 'cross': () => (h("path", { fill: "currentColor", d: "M14.26 12.74 9.52 8l4.7-4.7a.29.29 0 0 0 0-.41l-1.1-1.1a.29.29 0 0 0-.41 0L8 6.48 3.26 1.74a.24.24 0 0 0-.34 0L1.74 2.91a.24.24 0 0 0 0 .34L6.48 8l-4.7 4.7a.29.29 0 0 0 0 .41l1.1 1.1a.29.29 0 0 0 .41 0L8 9.52l4.74 4.74a.24.24 0 0 0 .34 0l1.17-1.17a.24.24 0 0 0 0-.34Z" })),
393
- 'cross-circle': () => (h("path", { fill: "currentColor", d: "M8.06.67H8A7.33 7.33 0 0 0 .68 8v.1a7.42 7.42 0 0 0 7.23 7.23A7.33 7.33 0 1 0 8.06.67Zm3.6 9.57a.28.28 0 0 1 0 .4l-.19.2-.61.61-.2.19a.27.27 0 0 1-.39 0L8 9.41l-2.23 2.24a.27.27 0 0 1-.39 0l-.2-.2-.6-.6-.19-.2a.28.28 0 0 1 0-.4L6.6 8 4.36 5.76a.28.28 0 0 1 0-.4l1-1a.28.28 0 0 1 .4 0L8 6.59l2.24-2.24a.28.28 0 0 1 .4 0l.2.2.6.6.2.2a.28.28 0 0 1 0 .4L9.42 8Z" })),
394
- 'download': () => (h("path", { fill: "currentColor", d: "M6.44,2V6.09a.31.31,0,0,1-.31.31H4a.31.31,0,0,0-.31.29.33.33,0,0,0,.1.23l4,4a.29.29,0,0,0,.41,0h0l4-4a.3.3,0,0,0,0-.42A.29.29,0,0,0,12,6.4H9.91a.31.31,0,0,1-.31-.31h0V2a.29.29,0,0,0-.28-.3H6.74a.29.29,0,0,0-.3.28ZM1.69,13v1a.29.29,0,0,0,.29.29H14a.29.29,0,0,0,.29-.29V13a.29.29,0,0,0-.28-.3H2a.29.29,0,0,0-.33.25Z" })),
395
- 'exclamation-circle': () => (h("path", { fill: "currentColor", d: "M8 15.33A7.33 7.33 0 1 0 .67 8 7.33 7.33 0 0 0 8 15.33ZM7 4a.29.29 0 0 1 .3-.3h1.35A.29.29 0 0 1 9 4v4.68a.29.29 0 0 1-.28.3H7.35a.29.29 0 0 1-.3-.28Zm0 6.78a.29.29 0 0 1 .3-.3h1.35a.29.29 0 0 1 .3.3H9V12a.29.29 0 0 1-.28.3H7.35a.29.29 0 0 1-.3-.28Z" })),
396
- 'exclamation-triangle': () => (h("path", { fill: "currentColor", d: "m14.28 13.87-6-12a.32.32 0 0 0-.41-.15.36.36 0 0 0-.15.15l-6 12a.31.31 0 0 0 .14.42.33.33 0 0 0 .14 0h12a.3.3 0 0 0 .33-.28.31.31 0 0 0-.05-.14ZM7 6a.29.29 0 0 1 .28-.28h1.44A.28.28 0 0 1 9 6v4a.28.28 0 0 1-.28.29H7.28A.29.29 0 0 1 7 10Zm2 7a.31.31 0 0 1-.3.32H7.32A.32.32 0 0 1 7 13v-1.38a.31.31 0 0 1 .31-.31h1.4a.31.31 0 0 1 .31.31H9Z" })),
397
- 'file-cog': () => (h("path", { fill: "currentColor", d: "M9,10.1C9,10.6,8.5,11,8,11l0,0c-0.6,0-1-0.4-1-1c0-0.6,0.4-1,1-1C8.6,9,9,9.4,9,10.1C9,10,9,10,9,10.1z M13.2,3.7l-2.8-2.8c-0.1-0.1-0.3-0.2-0.5-0.2H9.8v3.7h3.5V4.2C13.3,4,13.2,3.8,13.2,3.7L13.2,3.7z M9.6,5.3h3.8v9.4 c0,0.4-0.3,0.6-0.7,0.7H3.3c-0.4,0-0.7-0.3-0.7-0.7c0,0,0,0,0,0V1.3C2.7,1,3,0.7,3.3,0.7h5.5v3.9l0,0C8.9,4.9,9.2,5.2,9.6,5.3 C9.5,5.2,9.5,5.2,9.6,5.3z M10,8L9.5,8.3C9.3,8.1,9,8,8.8,7.9V7.3c0-0.1,0-0.1-0.1-0.1c-0.4-0.1-0.9-0.1-1.3,0 c-0.1,0-0.1,0.1-0.1,0.1v0.6C7,8,6.7,8.1,6.5,8.3L6,8C5.9,8,5.9,8,5.8,8C5.5,8.3,5.3,8.7,5.2,9.1c0,0.1,0,0.1,0.1,0.2l0.5,0.3 c-0.1,0.3-0.1,0.6,0,0.8l-0.5,0.3c-0.1,0-0.1,0.1-0.1,0.2c0.1,0.4,0.4,0.8,0.7,1.1c0.1,0,0.1,0,0.2,0l0.5-0.3 C6.7,11.9,7,12,7.2,12.1v0.6c0,0.1,0,0.1,0.1,0.1c0.4,0.1,0.9,0.1,1.3,0c0.1,0,0.1-0.1,0.1-0.1v-0.5C9,12.1,9.3,12,9.5,11.8l0.5,0.3 c0.1,0,0.1,0,0.2,0c0.3-0.3,0.5-0.7,0.6-1.1c0-0.1,0-0.1-0.1-0.2l0,0l-0.5-0.3c0-0.3,0-0.6,0-0.8l0.5-0.3c0.1,0,0.1-0.1,0.1-0.2 c-0.1-0.4-0.4-0.8-0.6-1.1C10.1,8,10.1,8,10,8z" })),
398
- 'file-text': () => (h("path", { fill: "currentColor", d: "M8.9 4.6V.7H3.3c-.3 0-.6.3-.6.6v13.3c0 .4.3.7.7.7h9.3c.4 0 .7-.3.7-.7V5.3H9.6c-.4-.1-.7-.4-.7-.7zm1.8 6.7c0 .2-.2.3-.3.4H5.7c-.2 0-.3-.2-.3-.4v-.2c0-.2.2-.3.3-.3h4.6c.2 0 .3.2.3.3v.2zm0-1.8c0 .2-.2.3-.3.3H5.7c-.2 0-.3-.2-.3-.3v-.2c0-.2.2-.3.3-.3h4.6c.2 0 .3.2.3.3v.2zm0-2.1v.2c0 .2-.2.3-.3.3H5.7c-.2.1-.4-.1-.4-.2v-.3c0-.2.2-.3.3-.3h4.6c.3 0 .5.1.5.3zm2.6-3.2v.2H9.8V.7h.2c.2 0 .3.1.5.2l2.7 2.8c0 .1.1.3.1.5z" })),
399
- 'file-upload': () => [
400
- h("path", { fill: "currentColor", d: "M13.1 3.7 10.4.9c-.1-.1-.3-.2-.5-.2h-.1v3.7h3.5v-.2c0-.2-.1-.4-.2-.5z" }),
401
- h("path", { fill: "currentColor", d: "M13.3 14.6V5.3H9.6c-.4 0-.7-.3-.7-.7V.7H3.3c-.3 0-.6.3-.6.6v13.3c0 .4.3.7.7.7h9.3c.3 0 .6-.3.6-.7zm-3-4.6H8.9c-.1 0-.2.1-.2.2v2.6c0 .1-.1.2-.2.2H6.9c-.1 0-.2-.1-.2-.2v-2.6c0-.1-.1-.2-.2-.2H5.1C5 9.9 5 9.8 5 9.7l2.5-2.6c.1-.1.2-.1.3 0l2.5 2.5.1.1c.1.2 0 .3-.1.3z" }),
402
- ],
403
- 'floppy-disk': () => (h("path", { fill: "currentColor", d: "m13.94 4.44-2.38-2.38a1.39 1.39 0 0 0-1-.39H3A1.35 1.35 0 0 0 1.67 3v10A1.35 1.35 0 0 0 3 14.33h10A1.35 1.35 0 0 0 14.33 13V5.4a1.39 1.39 0 0 0-.39-1ZM8 12.52a1.81 1.81 0 1 1 1.81-1.81A1.81 1.81 0 0 1 8 12.52Zm2.71-8.6v2.84a.34.34 0 0 1-.34.34H3.82a.34.34 0 0 1-.34-.34V3.82a.34.34 0 0 1 .34-.34h6.46a.35.35 0 0 1 .24.1l.1.1a.35.35 0 0 1 .1.24Z" })),
404
- 'history': () => [
405
- h("path", { fill: "currentColor", d: "M8,1.67A6.37,6.37,0,0,0,3.6,3.42l-.91-.91a.6.6,0,0,0-.85,0h0a.58.58,0,0,0-.18.43V6.37A.61.61,0,0,0,2.24,7H5.68a.62.62,0,0,0,.62-.62A.69.69,0,0,0,6.12,6L5.05,4.87a4.29,4.29,0,1,1,.1,6.36.3.3,0,0,0-.41,0l-1,1a.3.3,0,0,0,0,.42h0A6.33,6.33,0,1,0,8,1.67Z" }),
406
- h("path", { fill: "currentColor", d: "M9.85,9.3l-.36.36a.3.3,0,0,1-.43,0L7.45,8V5.15a.3.3,0,0,1,.3-.3h.5a.3.3,0,0,1,.3.3V7.58l1.3,1.3A.31.31,0,0,1,9.85,9.3Z" }),
407
- ],
408
- 'info-circle': () => (h("path", { fill: "currentColor", d: "M8 .67A7.33 7.33 0 1 0 15.33 8 7.33 7.33 0 0 0 8 .67ZM9 12a.29.29 0 0 1-.3.3H7.35a.29.29 0 0 1-.3-.3V7.32A.29.29 0 0 1 7.33 7h1.32a.29.29 0 0 1 .35.3Zm0-6.74a.29.29 0 0 1-.3.3H7.35a.29.29 0 0 1-.3-.3V4a.29.29 0 0 1 .28-.3h1.32a.29.29 0 0 1 .3.28V4Z" })),
409
- 'lines-rectangle': () => (h("path", { fill: "currentColor", d: "M12.32.67H3.68c-.56 0-1.01.45-1.01 1.01v12.64c0 .56.45 1.01 1.01 1.01h8.64c.56 0 1.01-.45 1.01-1.01V1.68c0-.56-.45-1.01-1.01-1.01ZM9 11.25H4.67v-2H9v2Zm2.33-4.49H4.67v-2h6.67v2Z" })),
410
- 'list': () => (h("path", { fill: "currentColor", d: "M1.9 2.68c-.67 0-1.22.56-1.21 1.23 0 .67.56 1.22 1.23 1.21.67 0 1.22-.56 1.21-1.23 0-.32-.13-.63-.36-.86-.23-.23-.54-.36-.87-.35Zm0 4.09a1.23 1.23 0 1 0 0 2.46 1.23 1.23 0 1 0 0-2.46Zm0 4.09a1.23 1.23 0 1 0 0 2.46 1.23 1.23 0 1 0 0-2.46Zm13 .41H5.18c-.23 0-.41.18-.41.41v.82c0 .23.18.41.41.41h9.75c.23 0 .41-.18.41-.41v-.82c0-.23-.18-.41-.41-.41h-.03Zm0-8.18H5.18c-.23 0-.41.18-.41.41v.81c0 .23.18.41.41.41h9.75c.23 0 .41-.18.41-.41V3.5c0-.23-.18-.41-.41-.41h-.03Zm0 4.09H5.18c-.23 0-.41.18-.41.41v.82c0 .23.18.41.41.41h9.75c.23 0 .41-.18.41-.41v-.82c0-.23-.18-.41-.41-.41h-.03Z" })),
411
- 'loader': () => [
412
- h("path", { fill: "currentColor", class: "loader__full-circle", d: "M8 2.67A5.33 5.33 0 1 1 2.67 8 5.33 5.33 0 0 1 8 2.67m0-2A7.33 7.33 0 1 0 15.33 8 7.33 7.33 0 0 0 8 .67Z" }),
413
- h("path", { fill: "currentColor", d: "M8 2.67v-2A7.33 7.33 0 0 0 .67 8h2A5.33 5.33 0 0 1 8 2.67Z" }),
414
- ],
415
- 'lock': () => (h("path", { fill: "currentColor", d: "M12 5.56h-.67v-1.4C11.37 2.28 9.88.71 8 .67 6.12.71 4.63 2.28 4.67 4.16v1.4H4c-.75.02-1.35.64-1.33 1.39V14c.02.73.6 1.31 1.33 1.33h8c.75-.02 1.35-.64 1.33-1.39V7a1.37 1.37 0 0 0-1.28-1.44H12Zm-4 6.28c-.77.04-1.43-.56-1.47-1.33-.04-.77.56-1.43 1.33-1.47.77-.04 1.43.56 1.47 1.33v.07c.02.75-.57 1.38-1.32 1.4H8Zm2.07-6.28H5.93v-1.4A2.12 2.12 0 0 1 8 2c1.17.03 2.1 1 2.07 2.17v1.39Z" })),
416
- 'log-in': () => (h("path", { fill: "currentColor", d: "M10.97,7.78h0L6.97,3.78c-.12-.12-.31-.12-.42,0h0c-.07,.06-.12,.15-.13,.24v2.07c0,.17-.13,.3-.3,.32H1.97c-.16,0-.29,.12-.3,.28h0v2.58c0,.16,.12,.29,.28,.3H6.11c.17,0,.3,.14,.3,.31v2.14c0,.16,.12,.29,.28,.3h0c.11,.01,.21-.03,.28-.11l4-4c.11-.12,.11-.3,0-.42Zm3.37,5.26h0v1c0,.16-.13,.28-.28,.28h-4.77c-.16,0-.28-.13-.28-.28v-1c0-.16,.13-.28,.28-.28h3.43V3.3h-3.42c-.16,0-.29-.13-.29-.29V1.97c0-.16,.13-.29,.29-.29h4.76c.16,0,.29,.13,.29,.29v.68h0V13.04Z" })),
417
- 'log-out': () => [
418
- h("path", { fill: "currentColor", d: "M14.25,7.77h0l-4-4a.31.31,0,0,0-.43,0A.34.34,0,0,0,9.7,4V6.07a.32.32,0,0,1-.3.32H5.23a.3.3,0,0,0-.3.3V9.25a.3.3,0,0,0,.3.3H9.4a.31.31,0,0,1,.3.31V12a.3.3,0,0,0,.3.3.33.33,0,0,0,.23-.09l4-4A.29.29,0,0,0,14.25,7.77Z" }),
419
- h("path", { fill: "currentColor", d: "M6.71,12.72H3.27V3.26H6.69A.31.31,0,0,0,7,3V2a.3.3,0,0,0-.31-.3H2A.29.29,0,0,0,1.67,2h0V3h0V14a.27.27,0,0,0,.1.24h0a.32.32,0,0,0,.14.08H6.71A.3.3,0,0,0,7,14V13A.3.3,0,0,0,6.71,12.72Z" }),
420
- ],
421
- 'magnifying-glass': () => (h("path", { fill: "currentColor", d: "M11.24,9.52A5.17,5.17,0,0,0,9.51,2.41l-.17-.09A5.18,5.18,0,0,0,4,11.18a5.16,5.16,0,0,0,5.54.11L12.3,14a1,1,0,0,0,1.41,0l.33-.33a1,1,0,0,0,0-1.41Zm-4.4.5A3.19,3.19,0,1,1,10,6.8v.06A3.19,3.19,0,0,1,6.84,10Z" })),
422
- 'paper-plane': () => (h("path", { fill: "currentColor", d: "M14 1.69 1.84 7a.28.28 0 0 0-.15.36.29.29 0 0 0 .16.15l3.27 1.82a.57.57 0 0 0 .61-.06l6.45-5.57c.05 0 .15-.1.19-.06s0 .14-.06.18l-5.59 6.29a.52.52 0 0 0 0 .63l2.09 3.44a.28.28 0 0 0 .37.12.3.3 0 0 0 .13-.12l5-12.11a.3.3 0 0 0-.14-.37.28.28 0 0 0-.17-.01Z" })),
423
- 'paper-plane-slash': () => (h("path", { fill: "currentColor", d: "M2.67,1.69,14.26,13.28l-1,1-2.79-2.8-1.1,2.67a.3.3,0,0,1-.13.12.28.28,0,0,1-.37-.12L6.75,10.74a.52.52,0,0,1,0-.63L7.82,8.9l-.76-.76L5.76,9.27a.57.57,0,0,1-.61.06L1.88,7.51a.29.29,0,0,1-.16-.15A.28.28,0,0,1,1.87,7L4.68,5.76l-3-3Zm11.53,0a.28.28,0,0,0-.22,0L7.53,4.51,9.26,6.24l3-2.54s.15-.1.19-.06,0,.14-.06.18L9.75,6.73l1.88,1.88,2.71-6.54A.3.3,0,0,0,14.2,1.7Z" })),
424
- 'pen': () => (h("path", { fill: "currentColor", d: "M1.67,11.69v2.64h2.64l7.78-7.78-2.64-2.64L1.67,11.69ZM14.13,4.51c.27-.28,.27-.72,0-1h0l-1.65-1.64c-.28-.27-.72-.27-1,0h0l-1.28,1.29,2.64,2.64,1.29-1.29Z" })),
425
- 'pen-fancy': () => (h("path", { fill: "currentColor", d: "M3.63,8.65c-.24,.07-.43,.26-.5,.5l-1.46,4.37,.11,.12,2.3-2.3c0-.06,0-.13,0-.19,0-.44,.35-.8,.79-.81,.44,0,.8,.35,.81,.79,0,.44-.35,.8-.79,.81,0,0-.01,0-.02,0h-.19l-2.3,2.3,.12,.11,4.37-1.46c.24-.07,.43-.26,.5-.5l.82-2.08-2.49-2.48-2.07,.82ZM10.8,2.35L6.27,7.28l2.42,2.42,4.94-4.52c2.1-1.86-.99-4.92-2.83-2.83Z" })),
426
- 'plus-circle': () => (h("path", { fill: "currentColor", d: "M8,0.7C4,0.7,0.7,4,0.7,8S4,15.3,8,15.3S15.3,12,15.3,8l0,0C15.3,4,12,0.7,8,0.7 C8,0.7,8,0.7,8,0.7z M12.3,8.8c0,0.2-0.2,0.4-0.4,0.4H9.2v2.7c0,0.2-0.2,0.4-0.4,0.4H7.2c-0.2,0-0.4-0.2-0.3-0.4V9.2H4.1 C3.9,9.2,3.7,9,3.7,8.8V7.2c0-0.2,0.2-0.4,0.4-0.3h2.7V4.1c0-0.2,0.2-0.4,0.3-0.4h1.7c0.2,0,0.4,0.2,0.4,0.4v2.7h2.7 c0.2,0,0.4,0.2,0.4,0.3L12.3,8.8z" })),
427
- 'share': () => (h("path", { fill: "currentColor", d: "M13.43,10.67a2,2,0,0,0-2.42.18L5.64,8.28a2.11,2.11,0,0,0,0-.56L11,5.15a2,2,0,0,0,2.42.18,2,2,0,1,0-3.08-1.57L4.83,6.4l-.11-.09a2,2,0,1,0,.12,3.3l5.51,2.63a2,2,0,1,0,3.08-1.57Z" })),
428
- 'trash': () => [
429
- h("path", { fill: "currentColor", d: "M11.5,14.8h-7 c-0.6,0-1.1-0.5-1.1-1.1V4.4h9.3v9.2C12.6,14.2,12.1,14.8,11.5,14.8 M6.9,6.8c0-0.3-0.3-0.6-0.6-0.6S5.8,6.5,5.8,6.8v5.2 c0,0.3,0.3,0.6,0.6,0.6s0.6-0.3,0.6-0.6V6.8z M10.3,6.8c0-0.3-0.3-0.6-0.6-0.6S9.2,6.5,9.2,6.8v5.2c0,0.3,0.3,0.6,0.6,0.6 s0.6-0.3,0.6-0.6V6.8z" }),
430
- h("path", { fill: "currentColor", d: "M13,2h-2.9L9.9,1.6 C9.8,1.4,9.6,1.2,9.4,1.2H6.6c-0.2,0-0.4,0.1-0.5,0.3L5.8,2H2.9C2.7,2,2.5,2.2,2.5,2.4c0,0,0,0,0,0v0.8c0,0.2,0.2,0.4,0.4,0.4H13 c0.2,0,0.4-0.2,0.4-0.4V2.4C13.4,2.2,13.2,2,13,2z" }),
431
- ],
432
- 'unlock': () => (h("path", { fill: "currentColor", d: "M13.33 13.94V7a1.37 1.37 0 0 0-1.28-1.44h-.72v-1.4A3.422 3.422 0 0 0 8 .67 3.4 3.4 0 0 0 4.68 4h1.26C6 2.9 6.9 2.03 8 2c1.17.03 2.1 1 2.07 2.17v1.39H4c-.75.02-1.35.64-1.33 1.39V14c.02.73.6 1.31 1.33 1.33h8c.75-.02 1.35-.64 1.33-1.39ZM8 11.84c-.77.04-1.43-.56-1.47-1.33-.04-.77.56-1.43 1.33-1.47.77-.04 1.43.56 1.47 1.33v.07c.02.75-.57 1.38-1.32 1.4H8Z" })),
433
- 'user-plus': () => (h("path", { fill: "currentColor", d: "M14,3.33H12.65V2a.36.36,0,0,0-.35-.33h-.65A.36.36,0,0,0,11.3,2V3.33H10a.34.34,0,0,0-.33.34v.66a.34.34,0,0,0,.33.34H11.3V6a.37.37,0,0,0,.35.33h.65A.37.37,0,0,0,12.65,6V4.67H14a.34.34,0,0,0,.32-.34V3.67A.34.34,0,0,0,14,3.33ZM9.28,9.77h-.2a5.19,5.19,0,0,1-3.91,0H5A3,3,0,0,0,1.7,12.46h0v.72A1.27,1.27,0,0,0,3,14.33h8.25a1.26,1.26,0,0,0,1.36-1.14v-.68A3,3,0,0,0,9.37,9.76H9.28ZM7.13,3.7A2.64,2.64,0,1,1,4.5,6.34h0A2.64,2.64,0,0,1,7.13,3.7Z" })),
434
- 'users': () => (h("path", { fill: "currentColor", d: "M12,8.76h-.2a5.24,5.24,0,0,1-3.93,0H7.61a3.05,3.05,0,0,0-3.3,2.75v.69a1.28,1.28,0,0,0,1.38,1.14H14a1.27,1.27,0,0,0,1.37-1.14v-.69A3.07,3.07,0,0,0,12,8.75Zm-6.4-.32A2,2,0,0,0,4.31,8H2.48A1.69,1.69,0,0,0,.65,9.53v.76a.85.85,0,0,0,.91.76H3.45A3.58,3.58,0,0,1,5.61,8.44ZM9.81,2.66A2.65,2.65,0,1,1,7.16,5.31h0A2.65,2.65,0,0,1,9.81,2.66ZM3.31,4.18A1.51,1.51,0,1,1,1.8,5.69,1.51,1.51,0,0,1,3.31,4.18Z" })),
435
- };
436
- /**
437
- * List of all possibles sizes
438
- */
439
- const sizes$1 = ['regular', 'large', 'extra-large'];
440
- /**
441
- * List of all possibles variants
442
- */
443
- const variants$2 = ['success', 'warning', 'danger', 'info'];
444
-
445
- const mgIconCss = ":host{display:-ms-inline-flexbox;display:inline-flex;vertical-align:middle}.mg-icon[size=regular],.mg-icon.mg-icon--size-regular{width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size)}.mg-icon[size=large],.mg-icon.mg-icon--size-large{width:var(--mg-icon-large-size);height:var(--mg-icon-large-size)}.mg-icon[size=extra-large],.mg-icon.mg-icon--size-extra-large{width:var(--mg-icon-extra-large-size);height:var(--mg-icon-extra-large-size)}.mg-icon[class*=mg-icon--variant-]{border-radius:var(--mg-message-border-radius);padding:0.3rem}.mg-icon.mg-icon--variant-success{background-color:hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) + 20%))}.mg-icon.mg-icon--variant-warning{background-color:hsl(var(--color-warning-h), var(--color-warning-s), calc(var(--color-warning-l) + 20%))}.mg-icon.mg-icon--variant-danger{background-color:hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) + 20%))}.mg-icon.mg-icon--variant-info{background-color:hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) + 20%))}.loader__full-circle{opacity:0.2}.mg-icon--spin{-webkit-animation-name:rotate;animation-name:rotate;-webkit-animation-duration:0.75s;animation-duration:0.75s;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite}@-webkit-keyframes rotate{to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotate{to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}";
446
-
447
- const MgIcon = class {
448
- constructor(hostRef) {
449
- registerInstance(this, hostRef);
450
- /**
451
- * Define icon size
452
- */
453
- this.size = 'regular';
454
- /**
455
- * Make the icon spin
456
- */
457
- this.spin = false;
458
- /**
459
- * Component classes
460
- */
461
- this.classList = new ClassList(['mg-icon']);
462
- /**
463
- * getIcon
464
- *
465
- * @returns {HTMLElement} icon html
466
- */
467
- this.getIcon = () => icons[this.icon]();
468
- }
469
- validateIcon(newValue) {
470
- if (!Object.keys(icons).includes(newValue)) {
471
- throw new Error(`<mg-icon> prop "icon" must be one of : ${Object.keys(icons).join(', ')}`);
472
- }
473
- this.classList.add(`mg-icon--${this.icon}`);
474
- }
475
- validateSize(newValue) {
476
- if (!sizes$1.includes(newValue)) {
477
- throw new Error(`<mg-icon> prop "size" must be one of : ${sizes$1.join(', ')}`);
478
- }
479
- this.classList.add(`mg-icon--size-${this.size}`);
480
- }
481
- validateVariant(newValue) {
482
- if (newValue !== undefined && !variants$2.includes(newValue)) {
483
- throw new Error(`<mg-icon> prop "variant" must be one of : ${variants$2.join(', ')}`);
484
- }
485
- else if (newValue !== undefined) {
486
- this.classList.add(`mg-icon--variant-${this.variant}`);
487
- }
488
- }
489
- handleSpin(newValue) {
490
- if (newValue) {
491
- this.classList.add('mg-icon--spin');
492
- }
493
- }
494
- /**
495
- * Check if props are well configured on init
496
- *
497
- * @returns {void}
498
- */
499
- componentWillLoad() {
500
- this.validateIcon(this.icon);
501
- this.validateSize(this.size);
502
- this.validateVariant(this.variant);
503
- this.handleSpin(this.spin);
504
- }
505
- /**
506
- * Render component
507
- *
508
- * @returns {HTMLElement} HTML Element
509
- */
510
- render() {
511
- return (h("svg", { class: this.classList.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
512
- }
513
- static get watchers() { return {
514
- "icon": ["validateIcon"],
515
- "size": ["validateSize"],
516
- "variant": ["validateVariant"],
517
- "spin": ["handleSpin"]
518
- }; }
519
- };
520
- MgIcon.style = mgIconCss;
521
-
522
- /**
523
- * Possible input classes
524
- */
525
- var InputClass;
526
- (function (InputClass) {
527
- InputClass["ERROR"] = "is-not-valid";
528
- })(InputClass || (InputClass = {}));
529
-
530
- /**
531
- * Apply in all input child node the aria-describedby attribute
532
- *
533
- * @param {VNode[]} children Represent scoped elements
534
- * @param {Set<string>} ariaDescribedbyIDs List of IDs
535
- * @param {FunctionalUtilities} utils Stencil.js utils
536
- * @returns {VNode[]} Children with aria-describedby attribute
537
- */
538
- const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
539
- if (['input', 'select', 'textarea'].includes(child.vtag)) {
540
- return Object.assign(Object.assign({}, child), { vattrs: Object.assign(Object.assign({}, child.vattrs), { 'aria-describedby': [...ariaDescribedbyIDs].join(' ') }) });
541
- }
542
- // we recursively apply ariadescribedBy attributes to child input nodes if exists
543
- if (child.vchildren === null)
544
- return Object.assign({}, child);
545
- return Object.assign(Object.assign({}, child), { vchildren: applyAriadescribedBy(child.vchildren, ariaDescribedbyIDs, utils) });
546
- });
547
- /**
548
- * Add classes based on props
549
- *
550
- * @param {MgInputProps} props MgInput Interface Props
551
- */
552
- const manageClasses = (props) => {
553
- props.classList.add('mg-input');
554
- if (props.labelOnTop)
555
- props.classList.add('mg-input--label-on-top');
556
- if (props.readonly)
557
- props.classList.add('mg-input--readonly');
558
- if (props.width !== undefined)
559
- props.classList.add(`mg-input--width-${props.width}`);
560
- if (props.readonly || props.disabled) {
561
- props.classList.delete(InputClass.ERROR);
562
- }
563
- };
564
- /**
565
- * Get tagname
566
- *
567
- * @param {boolean} isFieldset is fieldset
568
- * @returns {string} tag name
569
- */
570
- const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
571
- /**
572
- * Get input template
573
- *
574
- * @param {MgInputProps} props MgInput Interface Props
575
- * @param {VNode[]} children Represent scoped elements
576
- * @param {FunctionalUtilities} utils Stencil.js utils
577
- * @returns {VNode[]} input template
578
- */
579
- const MgInput = (props, children, utils) => {
580
- /**
581
- * Check required properties
582
- */
583
- if (typeof props.label !== 'string' || props.label === '') {
584
- throw new Error('<mg-input> prop "label" is required');
585
- }
586
- if (props.labelOnTop && props.labelHide) {
587
- throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide"');
588
- }
589
- /**
590
- * Component classes
591
- */
592
- manageClasses(props);
593
- /**
594
- * a11y IDs
595
- */
596
- const ariaDescribedbyIDs = new Set();
597
- // Character Left
598
- const characterLeftId = `${props.identifier}-character-left`;
599
- if (props.classList.has('is-focused') && props.displayCharacterLeft) {
600
- ariaDescribedbyIDs.add(characterLeftId);
601
- }
602
- // Help text
603
- const helpTextId = `${props.identifier}-help-text`;
604
- if (typeof props.helpText === 'string' && props.helpText !== '') {
605
- ariaDescribedbyIDs.add(helpTextId);
606
- }
607
- // Error Message
608
- const helpTextErrorId = `${props.identifier}-error`;
609
- if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {
610
- ariaDescribedbyIDs.add(helpTextErrorId);
611
- }
612
- /**
613
- * Update input(s) in children
614
- */
615
- if (props.readonly) {
616
- children = children.filter(child => child.$name$ === 'append-input');
617
- }
618
- else {
619
- children = applyAriadescribedBy(children, ariaDescribedbyIDs, utils);
620
- }
621
- /**
622
- * Return template
623
- *
624
- * +--------+--------------+---------+
625
- * | label | input | tooltip |
626
- * | +--------------+---------+
627
- * | | nb Char Left |
628
- * | +------------------------+
629
- * | | Help Text |
630
- * | +------------------------+
631
- * | | Error |
632
- * +--------+------------------------+
633
- *
634
- * Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change
635
- */
636
- const TagName = getTagName(props.isFieldset);
637
- /**
638
- * Get tooltip node
639
- *
640
- * @returns {VNode[]} mg-tooltip
641
- */
642
- const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
643
- h("mg-icon", { icon: "info-circle" })));
644
- /**
645
- * Get input title (label) node
646
- *
647
- * @returns {VNode[]} mg-input-title
648
- */
649
- const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled, "is-legend": props.isFieldset }, props.label));
650
- return (h(TagName, { class: props.classList.join() },
651
- props.labelOnTop ? (h("div", { class: "mg-input__title" },
652
- getInputTitle(),
653
- !props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
654
- props.readonly ? (h("div", { class: "mg-input__input-container" },
655
- h("strong", null, props.readonlyValue || props.value),
656
- children)) : (h("div", { class: "mg-input__input-container" },
657
- h("div", { class: "mg-input__input" },
658
- children,
659
- !props.labelOnTop && props.tooltip && getTooltip()),
660
- props.displayCharacterLeft && props.maxlength && props.classList.has('is-focused') && (h("mg-character-left", { identifier: characterLeftId, characters: props.value, maxlength: props.maxlength, template: props.characterLeftTemplate })),
661
- props.helpText && h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }),
662
- props.errorMessage && h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" })))));
663
- };
664
-
665
- const mgInputCheckboxCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);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{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;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:-ms-inline-flexbox;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:-ms-inline-flexbox;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-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}fieldset.mg-input{border:0;margin-left:0;margin-right:0;padding:0}fieldset.mg-input input[type=radio],fieldset.mg-input input[type=checkbox]{-ms-flex-negative:0;flex-shrink:0;width:var(--mg-input-check-size);height:var(--mg-input-check-size);margin-top:calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);margin-right:0.6rem;margin-bottom:0;margin-left:0}fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container{margin-top:0.7rem}fieldset.mg-input.is-not-valid .mg-input__input-group{color:initial}.mg-input__input-container mg-tooltip{margin-left:2rem}.mg-input__input-group-container{margin:0;padding:0;list-style:none;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-column-gap:2.3rem;-moz-column-gap:2.3rem;column-gap:2.3rem;row-gap:1rem;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2)}.mg-input__input-group-container--vertical{-ms-flex-direction:column;flex-direction:column}.mg-input__input-group{display:-ms-flexbox;display:flex;-ms-flex-align:top;align-items:top}.mg-input__input-group.mg-input__input-group--disabled label{opacity:0.3}.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}";
666
-
667
- /**
668
- * type CheckboxItem validation function
669
- *
670
- * @param {CheckboxItem} item Checkbox item
671
- * @returns {boolean} match item expectations
672
- */
673
- const isCheckboxItem = (item) => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined;
674
- const MgInputCheckbox = class {
675
- constructor(hostRef) {
676
- registerInstance(this, hostRef);
677
- this.valueChange = createEvent(this, "value-change", 7);
678
- this.inputValid = createEvent(this, "input-valid", 7);
679
- /************
680
- * Internal *
681
- ************/
682
- // classes
683
- this.classError = InputClass.ERROR;
684
- // HTML selector
685
- this.inputs = [];
686
- /**
687
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
688
- * If not set, it will be created.
689
- */
690
- this.identifier = createID('mg-input-checkbox');
691
- /**
692
- * Input name
693
- * If not set the value equals the identifier
694
- */
695
- this.name = this.identifier;
696
- /**
697
- * Define if label is visible
698
- */
699
- this.labelHide = false;
700
- /**
701
- * Define if inputs are display verticaly
702
- */
703
- this.inputVerticalList = false;
704
- /**
705
- * Define if input is required
706
- */
707
- this.required = false;
708
- /**
709
- * Define if input is readonly
710
- */
711
- this.readonly = false;
712
- /**
713
- * Define if input is disabled
714
- */
715
- this.disabled = false;
716
- /**
717
- * Component classes
718
- */
719
- this.classList = new ClassList(['mg-input--checkbox']);
720
- /**
721
- * Formated value for display
722
- */
723
- this.checkboxItems = [];
724
- /**
725
- * Handle input event
726
- *
727
- * @param {InputEvent} event input event
728
- */
729
- this.handleInput = (event) => {
730
- this.checkboxItems = this.checkboxItems.map(item => {
731
- if (item.id === event.target.id) {
732
- item.value = Boolean(event.target.checked);
733
- }
734
- return item;
735
- });
736
- this.value = this.checkboxItems.map(o => ({ value: o.value, title: o.title, disabled: o.disabled }));
737
- this.checkValidity();
738
- };
739
- /**
740
- * Handle blur event
741
- */
742
- this.handleBlur = () => {
743
- // Check validity
744
- this.checkValidity();
745
- this.checkError();
746
- };
747
- /**
748
- * Check if input is valid
749
- */
750
- this.checkValidity = () => {
751
- if (!this.readonly) {
752
- const validity = this.getInvalidElement() === undefined;
753
- // Set validity
754
- this.valid = validity;
755
- this.invalid = !validity;
756
- //Send event
757
- this.inputValid.emit(validity);
758
- }
759
- };
760
- /**
761
- * Check input errors
762
- */
763
- this.checkError = () => {
764
- const invalidElement = this.getInvalidElement();
765
- // Set error message
766
- this.errorMessage = undefined;
767
- if (!this.valid && invalidElement.validity.valueMissing) {
768
- this.errorMessage = messages.errors.required;
769
- }
770
- // Update class
771
- if (this.valid) {
772
- this.classList.delete(this.classError);
773
- }
774
- else {
775
- this.classList.add(this.classError);
776
- }
777
- };
778
- /**
779
- * get invalid element
780
- *
781
- * @returns {HTMLInputElement} element
782
- */
783
- this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
784
- }
785
- validateValue(newValue) {
786
- if (newValue && newValue.every(item => isCheckboxItem(item))) {
787
- this.checkboxItems = newValue.map((item, index) => ({
788
- id: `${this.identifier}_${index.toString()}`,
789
- title: item.title,
790
- value: item.value,
791
- disabled: item.disabled,
792
- }));
793
- this.valueChange.emit(newValue);
794
- }
795
- else {
796
- throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
797
- }
798
- }
799
- handleReadOnly() {
800
- this.classList.delete(this.classError);
801
- }
802
- /**
803
- * Public method to display errors
804
- *
805
- * @returns {Promise<void>}
806
- */
807
- async displayError() {
808
- this.checkValidity();
809
- this.checkError();
810
- }
811
- /*************
812
- * Lifecycle *
813
- *************/
814
- /**
815
- * Check if component props are well configured on init
816
- *
817
- * @returns {ReturnType<typeof setTimeout>} timeout
818
- */
819
- componentWillLoad() {
820
- // Check values format
821
- this.validateValue(this.value);
822
- // Check validity when component is ready
823
- // return a promise to process action only in the FIRST render().
824
- // https://stenciljs.com/docs/component-lifecycle#componentwillload
825
- return setTimeout(() => {
826
- this.checkValidity();
827
- }, 0);
828
- }
829
- /**
830
- * Render
831
- *
832
- * @returns {HTMLElement} HTML Element
833
- */
834
- render() {
835
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: undefined, width: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
836
- .filter(item => {
837
- return !this.readonly || item.value;
838
- })
839
- .map(input => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => this.inputs.push(el) }), h("label", { htmlFor: input.id }, input.title)))))));
840
- }
841
- static get watchers() { return {
842
- "value": ["validateValue"],
843
- "readonly": ["handleReadOnly"]
844
- }; }
845
- };
846
- MgInputCheckbox.style = mgInputCheckboxCss;
847
-
848
- var InputError$1;
849
- (function (InputError) {
850
- InputError["MIN"] = "min";
851
- InputError["MAX"] = "max";
852
- InputError["MINMAX"] = "minMax";
853
- InputError["REQUIRED"] = "required";
854
- })(InputError$1 || (InputError$1 = {}));
855
-
856
- /**
857
- * Format number to the locale currency
858
- *
859
- * @param {number} number number to format
860
- * @returns {string} formatted currency
861
- */
862
- function localeCurrency(number) {
863
- return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
864
- }
865
- /**
866
- * Format number to locale
867
- *
868
- * @param {number} number number to format
869
- * @returns {string} formatted number
870
- */
871
- function localeNumber(number) {
872
- return new Intl.NumberFormat(locale).format(number);
873
- }
874
- /**
875
- * Date RegExp
876
- */
877
- const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
878
- /**
879
- * Locale date format
880
- *
881
- * @param {string} date date to format
882
- * @returns {string} formatted date
883
- */
884
- function localeDate(date) {
885
- if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
886
- return '';
887
- }
888
- return new Intl.DateTimeFormat(locale).format(new Date(date));
889
- }
890
-
891
- const mgInputDateCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);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{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;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:-ms-inline-flexbox;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:-ms-inline-flexbox;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-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;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)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left: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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.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)}.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}";
892
-
893
- const MgInputDate = class {
894
- constructor(hostRef) {
895
- registerInstance(this, hostRef);
896
- this.valueChange = createEvent(this, "value-change", 7);
897
- this.inputValid = createEvent(this, "input-valid", 7);
898
- /************
899
- * Internal *
900
- ************/
901
- // classes
902
- this.classError = InputClass.ERROR;
903
- /**
904
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
905
- * If not set, it will be created.
906
- */
907
- this.identifier = createID('mg-input-date');
908
- /**
909
- * Input name
910
- * If not set the value equals the identifier
911
- */
912
- this.name = this.identifier;
913
- /**
914
- * Define if label is visible
915
- */
916
- this.labelHide = false;
917
- /**
918
- * Define if input is required
919
- */
920
- this.required = false;
921
- /**
922
- * Define if input is readonly
923
- */
924
- this.readonly = false;
925
- /**
926
- * Define if input is disabled
927
- */
928
- this.disabled = false;
929
- /**
930
- * Component classes
931
- */
932
- this.classList = new ClassList(['mg-input--date']);
933
- /**
934
- * Handle input event
935
- */
936
- this.handleInput = () => {
937
- this.checkValidity();
938
- this.value = this.input.value;
939
- };
940
- /**
941
- * Handle blur event
942
- */
943
- this.handleBlur = () => {
944
- this.checkValidity();
945
- this.checkError();
946
- };
947
- /**
948
- * Check if input is valid
949
- */
950
- this.checkValidity = () => {
951
- if (!this.readonly && this.input !== undefined) {
952
- const validity = this.input.checkValidity();
953
- // Set validity
954
- this.valid = validity;
955
- this.invalid = !validity;
956
- //Send event
957
- this.inputValid.emit(validity);
958
- }
959
- };
960
- /**
961
- * get input error code
962
- *
963
- * @returns {null | InputError} error code
964
- */
965
- this.getInputError = () => {
966
- var _a, _b;
967
- let inputError = null;
968
- // required
969
- if (this.input.validity.valueMissing) {
970
- inputError = InputError$1.REQUIRED;
971
- }
972
- // min & max
973
- else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && ((_b = this.max) === null || _b === void 0 ? void 0 : _b.length) > 0) {
974
- inputError = InputError$1.MINMAX;
975
- }
976
- // min
977
- else if (this.input.validity.rangeUnderflow) {
978
- inputError = InputError$1.MIN;
979
- }
980
- //max
981
- else if (this.input.validity.rangeOverflow) {
982
- inputError = InputError$1.MAX;
983
- }
984
- return inputError;
985
- };
986
- /**
987
- * Set error message
988
- *
989
- * @returns {void}
990
- */
991
- this.setErrorMessage = () => {
992
- var _a;
993
- const inputError = this.getInputError();
994
- // required
995
- if (inputError === InputError$1.REQUIRED) {
996
- this.errorMessage = messages.errors[inputError];
997
- }
998
- // min, max & minMax
999
- else if ([InputError$1.MIN, InputError$1.MAX, InputError$1.MINMAX].includes(inputError)) {
1000
- this.errorMessage = messages.errors.date[inputError].replace('{min}', localeDate(this.min)).replace('{max}', localeDate(this.max));
1001
- }
1002
- // wrong date format
1003
- // element.validity.badInput is default error message
1004
- else {
1005
- this.errorMessage = messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min) : localeDate('1900-01-01'));
1006
- }
1007
- };
1008
- /**
1009
- * Check input errors
1010
- *
1011
- * @returns {void}
1012
- */
1013
- this.checkError = () => {
1014
- // Set error message
1015
- this.errorMessage = undefined;
1016
- if (!this.valid) {
1017
- this.setErrorMessage();
1018
- this.classList.add(this.classError);
1019
- }
1020
- else {
1021
- this.classList.delete(this.classError);
1022
- }
1023
- };
1024
- }
1025
- validateValue(newValue) {
1026
- if (newValue !== undefined && newValue !== '' && !(typeof newValue === 'string' && dateRegExp.test(newValue))) {
1027
- throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
1028
- }
1029
- else {
1030
- this.valueChange.emit(this.value);
1031
- }
1032
- }
1033
- validateMin(newValue) {
1034
- this.validateDateFormat(newValue);
1035
- }
1036
- validateMax(newValue) {
1037
- this.validateDateFormat(newValue);
1038
- }
1039
- /**
1040
- * Public method to display errors
1041
- *
1042
- * @returns {Promise<void>}
1043
- */
1044
- async displayError() {
1045
- this.checkValidity();
1046
- this.checkError();
1047
- }
1048
- /**
1049
- * Date format validation
1050
- *
1051
- * @param {string} date date to validate
1052
- * @returns {void}
1053
- */
1054
- validateDateFormat(date) {
1055
- if ((date === null || date === void 0 ? void 0 : date.length) > 0 && !(typeof date === 'string' && dateRegExp.test(date))) {
1056
- throw new Error("<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd");
1057
- }
1058
- }
1059
- /*************
1060
- * Lifecycle *
1061
- *************/
1062
- /**
1063
- * Check if component props are well configured on init
1064
- *
1065
- * @returns {ReturnType<typeof setTimeout>} timeout
1066
- */
1067
- componentWillLoad() {
1068
- this.validateValue(this.value);
1069
- this.validateMin(this.min);
1070
- this.validateMax(this.max);
1071
- // Check validity when component is ready
1072
- // return a promise to process action only in the FIRST render().
1073
- // https://stenciljs.com/docs/component-lifecycle#componentwillload
1074
- return setTimeout(() => {
1075
- this.checkValidity();
1076
- }, 0);
1077
- }
1078
- /**
1079
- * Render
1080
- *
1081
- * @returns {HTMLElement} HTML Element
1082
- */
1083
- render() {
1084
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value), tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el => (this.input = el) })));
1085
- }
1086
- static get watchers() { return {
1087
- "value": ["validateValue"],
1088
- "min": ["validateMin"],
1089
- "max": ["validateMax"]
1090
- }; }
1091
- };
1092
- MgInputDate.style = mgInputDateCss;
1093
-
1094
- /**
1095
- * List of all possibles types
1096
- */
1097
- const types = ['decimal', 'integer', 'currency'];
1098
- var InputError;
1099
- (function (InputError) {
1100
- InputError["MIN"] = "min";
1101
- InputError["MAX"] = "max";
1102
- InputError["MINMAX"] = "minMax";
1103
- InputError["REQUIRED"] = "required";
1104
- })(InputError || (InputError = {}));
1105
-
1106
- const mgInputNumericCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);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{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;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:-ms-inline-flexbox;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:-ms-inline-flexbox;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-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;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)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left: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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.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){-ms-flex-pack:justify;justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{-ms-flex:auto;flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{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}.mg-input .mg-input__box{text-align:right}";
1107
-
1108
- const MgInputNumeric = class {
1109
- constructor(hostRef) {
1110
- registerInstance(this, hostRef);
1111
- this.valueChange = createEvent(this, "value-change", 7);
1112
- this.inputValid = createEvent(this, "input-valid", 7);
1113
- // Classes
1114
- this.classError = InputClass.ERROR;
1115
- /**
1116
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1117
- * If not set, it will be created.
1118
- */
1119
- this.identifier = createID('mg-input-numeric');
1120
- /**
1121
- * Input name
1122
- * If not set the value equals the identifier
1123
- */
1124
- this.name = this.identifier;
1125
- /**
1126
- * Define if label is visible
1127
- */
1128
- this.labelHide = false;
1129
- /**
1130
- * Define if input is required
1131
- */
1132
- this.required = false;
1133
- /**
1134
- * Define if input is readonly
1135
- */
1136
- this.readonly = false;
1137
- /**
1138
- * Define if input is disabled
1139
- */
1140
- this.disabled = false;
1141
- /**
1142
- * Define numeric type
1143
- */
1144
- this.type = types[0];
1145
- /**
1146
- * Override integer length
1147
- * integer is the number before the decimal point
1148
- */
1149
- this.integerLength = 13;
1150
- /**
1151
- * Override decimal length
1152
- * decimal is the number after the decimal point
1153
- */
1154
- this.decimalLength = 2;
1155
- /**
1156
- * Component classes
1157
- */
1158
- this.classList = new ClassList(['mg-input--numeric']);
1159
- /**
1160
- * Define if input has focus
1161
- */
1162
- this.hasFocus = false;
1163
- /**
1164
- * Handle input event
1165
- *
1166
- * @returns {void}
1167
- */
1168
- this.handleInput = () => {
1169
- // Check validity
1170
- this.checkValidity();
1171
- this.value = this.input.value;
1172
- };
1173
- /**
1174
- * Handle focus event
1175
- *
1176
- * @returns {void}
1177
- */
1178
- this.handleFocus = () => {
1179
- this.hasFocus = true;
1180
- };
1181
- /**
1182
- * Handle blur event
1183
- *
1184
- * @returns {void}
1185
- */
1186
- this.handleBlur = () => {
1187
- // Check validity
1188
- this.checkValidity();
1189
- this.checkError();
1190
- this.hasFocus = false;
1191
- };
1192
- /**
1193
- * Check if input is valid
1194
- *
1195
- * @returns {void}
1196
- */
1197
- this.checkValidity = () => {
1198
- if (!this.readonly) {
1199
- const validity = this.getInputError() === null;
1200
- // Set validity
1201
- this.valid = validity;
1202
- this.invalid = !validity;
1203
- //Send event
1204
- this.inputValid.emit(validity);
1205
- }
1206
- };
1207
- /**
1208
- * Set error message
1209
- *
1210
- * @returns {void}
1211
- */
1212
- this.setErrorMessage = () => {
1213
- const inputError = this.getInputError();
1214
- if (inputError === InputError.REQUIRED) {
1215
- this.errorMessage = messages.errors[inputError];
1216
- }
1217
- else {
1218
- this.errorMessage = messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
1219
- }
1220
- };
1221
- /**
1222
- * Check input errors
1223
- *
1224
- * @returns {void}
1225
- */
1226
- this.checkError = () => {
1227
- // Set error message
1228
- this.errorMessage = undefined;
1229
- // Update class
1230
- if (!this.valid) {
1231
- this.setErrorMessage();
1232
- this.classList.add(this.classError);
1233
- }
1234
- else {
1235
- this.classList.delete(this.classError);
1236
- }
1237
- };
1238
- /**
1239
- * Get input error code
1240
- *
1241
- * @returns {null | InputError} error code
1242
- */
1243
- this.getInputError = () => {
1244
- let inputError = null;
1245
- if (this.input === undefined)
1246
- return inputError;
1247
- // required
1248
- if (!this.input.checkValidity() && this.input.validity.valueMissing) {
1249
- inputError = InputError.REQUIRED;
1250
- }
1251
- // Min & Max
1252
- else if (this.min !== undefined && this.numericValue < this.min && this.max === undefined) {
1253
- // Only a min value is set
1254
- inputError = InputError.MIN;
1255
- }
1256
- else if (this.max !== undefined && this.numericValue > this.max && this.min === undefined) {
1257
- // Only a max value is set
1258
- inputError = InputError.MAX;
1259
- }
1260
- else if ((this.min !== undefined && this.numericValue < this.min) || (this.max !== undefined && this.numericValue > this.max)) {
1261
- // both min and max values are set
1262
- inputError = InputError.MINMAX;
1263
- }
1264
- return inputError;
1265
- };
1266
- /**
1267
- * Format value based on type
1268
- *
1269
- * @param {number} value value to format
1270
- * @returns {string} formated local value
1271
- */
1272
- this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value) : localeNumber(value));
1273
- /**
1274
- * Validate append slot
1275
- *
1276
- * @returns {void}
1277
- */
1278
- this.validateAppendSlot = () => {
1279
- const slotAppendInput = this.element.querySelector('[slot="append-input"]');
1280
- if (slotAppendInput !== null) {
1281
- this.classList.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
1282
- }
1283
- };
1284
- }
1285
- validateValue(newValue) {
1286
- if (newValue !== undefined && newValue !== null) {
1287
- // Split number and decimal
1288
- const [integer, decimal = ''] = newValue.replace('-', '').split(/[\.,]/);
1289
- // Regex
1290
- const regex = this.type === 'integer' ? /^[\-]?\d+$/ : /^[\-]?\d+[.,]?\d*$/;
1291
- // Filter input
1292
- if (newValue === '' || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
1293
- this.storedValue = newValue;
1294
- }
1295
- else if (this.storedValue !== undefined) {
1296
- newValue = this.storedValue;
1297
- }
1298
- else {
1299
- newValue = null;
1300
- }
1301
- // Set value and input value
1302
- this.value = newValue;
1303
- if (this.input !== undefined)
1304
- this.input.value = this.value;
1305
- // emit numeric value
1306
- this.numericValue = this.value !== '' && this.value !== null ? parseFloat(this.value.replace(',', '.')) : null;
1307
- this.valueChange.emit(this.numericValue);
1308
- // Set readOnlyValue
1309
- this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
1310
- }
1311
- }
1312
- validateType(newValue) {
1313
- if (!types.includes(newValue)) {
1314
- throw new Error(`<mg-input-numeric> prop "type" must be one of : ${types.join(', ')}`);
1315
- }
1316
- this.classList.add(`mg-input--numeric--${this.type}`);
1317
- }
1318
- validateIntegerLength(newValue) {
1319
- if (newValue < 1) {
1320
- throw new Error(`<mg-input-numeric> prop "integer-length" must be a positive number.`);
1321
- }
1322
- }
1323
- validateDecimalLength(newValue) {
1324
- if (newValue < 1) {
1325
- throw new Error(`<mg-input-numeric> prop "decimal-length" must be a positive number, consider using prop "type" to "integer" instead.`);
1326
- }
1327
- }
1328
- /**
1329
- * Public method to display errors
1330
- *
1331
- * @returns {Promise<void>}
1332
- */
1333
- async displayError() {
1334
- this.checkValidity();
1335
- this.checkError();
1336
- }
1337
- /**
1338
- * Displayed value in input
1339
- * Change on focus/blur
1340
- *
1341
- * @returns {string} display value
1342
- */
1343
- displayValue() {
1344
- return this.hasFocus ? this.value : this.readonlyValue;
1345
- }
1346
- /*************
1347
- * Lifecycle *
1348
- *************/
1349
- /**
1350
- * Check if component props are well configured on init
1351
- *
1352
- * @returns {ReturnType<typeof setTimeout>} timeout
1353
- */
1354
- componentWillLoad() {
1355
- this.validateValue(this.value);
1356
- this.validateType(this.type);
1357
- this.validateIntegerLength(this.integerLength);
1358
- this.validateDecimalLength(this.decimalLength);
1359
- this.validateAppendSlot();
1360
- // Check validity when component is ready
1361
- // return a promise to process action only in the FIRST render().
1362
- // https://stenciljs.com/docs/component-lifecycle#componentwillload
1363
- return setTimeout(() => {
1364
- this.checkValidity();
1365
- }, 0);
1366
- }
1367
- /**
1368
- * Render
1369
- *
1370
- * @returns {HTMLElement} HTML Element
1371
- */
1372
- render() {
1373
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), h("slot", { name: "append-input" })));
1374
- }
1375
- get element() { return getElement(this); }
1376
- static get watchers() { return {
1377
- "value": ["validateValue"],
1378
- "type": ["validateType"],
1379
- "integerLength": ["validateIntegerLength"],
1380
- "decimalLength": ["validateDecimalLength"]
1381
- }; }
1382
- };
1383
- MgInputNumeric.style = mgInputNumericCss;
1384
-
1385
- const mgInputPasswordCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);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{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;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:-ms-inline-flexbox;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:-ms-inline-flexbox;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-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;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)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left: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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.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){-ms-flex-pack:justify;justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{-ms-flex:auto;flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{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}";
1386
-
1387
- const MgInputPassword = class {
1388
- constructor(hostRef) {
1389
- registerInstance(this, hostRef);
1390
- this.valueChange = createEvent(this, "value-change", 7);
1391
- this.inputValid = createEvent(this, "input-valid", 7);
1392
- /************
1393
- * Internal *
1394
- ************/
1395
- // classes
1396
- this.classError = InputClass.ERROR;
1397
- /**
1398
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1399
- * If not set, it will be created.
1400
- */
1401
- this.identifier = createID('mg-input-password');
1402
- /**
1403
- * Input name
1404
- * If not set the value equals the identifier
1405
- */
1406
- this.name = this.identifier;
1407
- /**
1408
- * Define if label is visible
1409
- */
1410
- this.labelHide = false;
1411
- /**
1412
- * Define if input is required
1413
- */
1414
- this.required = false;
1415
- /**
1416
- * Define if input is readonly
1417
- */
1418
- this.readonly = false;
1419
- /**
1420
- * Define if input is disabled
1421
- */
1422
- this.disabled = false;
1423
- /**
1424
- * Define input width
1425
- */
1426
- this.width = 'full';
1427
- /**
1428
- * Component classes
1429
- */
1430
- this.classList = new ClassList(['mg-input--password']);
1431
- /**
1432
- * Handle input event
1433
- */
1434
- this.handleInput = () => {
1435
- this.checkValidity();
1436
- this.value = this.input.value;
1437
- };
1438
- /**
1439
- * Handle blur event
1440
- */
1441
- this.handleBlur = () => {
1442
- this.checkValidity();
1443
- this.checkError();
1444
- };
1445
- /**
1446
- * Check if input is valid
1447
- */
1448
- this.checkValidity = () => {
1449
- if (!this.readonly && this.input !== undefined) {
1450
- const validity = this.input.checkValidity();
1451
- // Set validity
1452
- this.valid = validity;
1453
- this.invalid = !validity;
1454
- //Send event
1455
- this.inputValid.emit(validity);
1456
- }
1457
- };
1458
- /**
1459
- * Check input errors
1460
- */
1461
- this.checkError = () => {
1462
- // Set error message
1463
- this.errorMessage = undefined;
1464
- // required
1465
- if (!this.valid && this.input.validity.valueMissing) {
1466
- this.errorMessage = messages.errors.required;
1467
- }
1468
- // Update class
1469
- if (this.valid) {
1470
- this.classList.delete(this.classError);
1471
- }
1472
- else {
1473
- this.classList.add(this.classError);
1474
- }
1475
- };
1476
- }
1477
- handleValue(newValue) {
1478
- this.valueChange.emit(newValue);
1479
- }
1480
- /**
1481
- * Public method to display errors
1482
- *
1483
- * @returns {Promise<void>}
1484
- */
1485
- async displayError() {
1486
- this.checkValidity();
1487
- this.checkError();
1488
- }
1489
- /*************
1490
- * Lifecycle *
1491
- *************/
1492
- /**
1493
- * Check if component props are well configured on init
1494
- *
1495
- * @returns {ReturnType<typeof setTimeout>} timeout
1496
- */
1497
- componentWillLoad() {
1498
- // Check validity when component is ready
1499
- // return a promise to process action only in the FIRST render().
1500
- // https://stenciljs.com/docs/component-lifecycle#componentwillload
1501
- return setTimeout(() => {
1502
- this.checkValidity();
1503
- }, 0);
1504
- }
1505
- /**
1506
- * Render
1507
- *
1508
- * @returns {HTMLElement} HTML Element
1509
- */
1510
- render() {
1511
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, displayCharacterLeft: false, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) })));
1512
- }
1513
- static get watchers() { return {
1514
- "value": ["handleValue"]
1515
- }; }
1516
- };
1517
- MgInputPassword.style = mgInputPasswordCss;
1518
-
1519
- const mgInputRadioCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);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{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;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:-ms-inline-flexbox;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:-ms-inline-flexbox;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-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}fieldset.mg-input{border:0;margin-left:0;margin-right:0;padding:0}fieldset.mg-input input[type=radio],fieldset.mg-input input[type=checkbox]{-ms-flex-negative:0;flex-shrink:0;width:var(--mg-input-check-size);height:var(--mg-input-check-size);margin-top:calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);margin-right:0.6rem;margin-bottom:0;margin-left:0}fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container{margin-top:0.7rem}fieldset.mg-input.is-not-valid .mg-input__input-group{color:initial}.mg-input__input-container mg-tooltip{margin-left:2rem}.mg-input__input-group-container{margin:0;padding:0;list-style:none;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-column-gap:2.3rem;-moz-column-gap:2.3rem;column-gap:2.3rem;row-gap:1rem;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2)}.mg-input__input-group-container--vertical{-ms-flex-direction:column;flex-direction:column}.mg-input__input-group{display:-ms-flexbox;display:flex;-ms-flex-align:top;align-items:top}.mg-input__input-group.mg-input__input-group--disabled label{opacity:0.3}.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}";
1520
-
1521
- /**
1522
- * type Option validation function
1523
- *
1524
- * @param {RadioOption} option radio option
1525
- * @returns {boolean} radio option type is valid
1526
- */
1527
- const isOption$2 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
1528
- const MgInputRadio = class {
1529
- constructor(hostRef) {
1530
- registerInstance(this, hostRef);
1531
- this.valueChange = createEvent(this, "value-change", 7);
1532
- this.inputValid = createEvent(this, "input-valid", 7);
1533
- /************
1534
- * Internal *
1535
- ************/
1536
- // classes
1537
- this.classError = InputClass.ERROR;
1538
- // HTML selector
1539
- this.inputs = [];
1540
- /**
1541
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1542
- * If not set, it will be created.
1543
- */
1544
- this.identifier = createID('mg-input-radio');
1545
- /**
1546
- * Input name
1547
- * If not set the value equals the identifier
1548
- */
1549
- this.name = this.identifier;
1550
- /**
1551
- * Define if label is displayed on top
1552
- */
1553
- this.labelOnTop = false;
1554
- /**
1555
- * Define if label is visible
1556
- */
1557
- this.labelHide = false;
1558
- /**
1559
- * Define if inputs are display verticaly
1560
- */
1561
- this.inputVerticalList = false;
1562
- /**
1563
- * Define if input is required
1564
- */
1565
- this.required = false;
1566
- /**
1567
- * Define if input is readonly
1568
- */
1569
- this.readonly = false;
1570
- /**
1571
- * Define if input is disabled
1572
- */
1573
- this.disabled = false;
1574
- /**
1575
- * Component classes
1576
- */
1577
- this.classList = new ClassList(['mg-input--radio']);
1578
- /**
1579
- * Handle input event
1580
- *
1581
- * @param {event} event input event
1582
- * @returns {void}
1583
- */
1584
- this.handleInput = (event) => {
1585
- this.checkValidity();
1586
- this.value = this.options[event.target.value].value;
1587
- };
1588
- /**
1589
- * Handle blur event
1590
- *
1591
- * @returns {void}
1592
- */
1593
- this.handleBlur = () => {
1594
- this.checkValidity();
1595
- this.checkError();
1596
- };
1597
- /**
1598
- * Check if input is valid
1599
- *
1600
- * @returns {void}
1601
- */
1602
- this.checkValidity = () => {
1603
- if (!this.readonly) {
1604
- const validity = this.getInvalidElement() === undefined;
1605
- // Set validity
1606
- this.valid = validity;
1607
- this.invalid = !validity;
1608
- //Send event
1609
- this.inputValid.emit(validity);
1610
- }
1611
- };
1612
- /**
1613
- * Check input errors
1614
- *
1615
- * @returns {void}
1616
- */
1617
- this.checkError = () => {
1618
- const invalidElement = this.getInvalidElement();
1619
- // Set error message
1620
- this.errorMessage = undefined;
1621
- if (!this.valid && invalidElement.validity.valueMissing) {
1622
- this.errorMessage = messages.errors.required;
1623
- }
1624
- // Update class
1625
- if (this.valid) {
1626
- this.classList.delete(this.classError);
1627
- }
1628
- else {
1629
- this.classList.add(this.classError);
1630
- }
1631
- };
1632
- /**
1633
- * get invalid element
1634
- *
1635
- * @returns {HTMLInputElement} element
1636
- */
1637
- this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
1638
- }
1639
- handleValue(newValue) {
1640
- this.valueChange.emit(newValue);
1641
- }
1642
- validateItems(newValue) {
1643
- // Validate if items have required min length
1644
- if (typeof newValue === 'object' && newValue.length < 2) {
1645
- throw new Error('<mg-input-radio> prop "items" require at least 2 items.');
1646
- }
1647
- // String array
1648
- else if (allItemsAreString(newValue)) {
1649
- this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
1650
- }
1651
- // Object array
1652
- else if (newValue && newValue.every(item => isOption$2(item))) {
1653
- this.options = newValue;
1654
- }
1655
- else {
1656
- throw new Error('<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption.');
1657
- }
1658
- }
1659
- /**
1660
- * Public method to display errors
1661
- *
1662
- * @returns {Promise<void>}
1663
- */
1664
- async displayError() {
1665
- this.checkValidity();
1666
- this.checkError();
1667
- }
1668
- /*************
1669
- * Lifecycle *
1670
- *************/
1671
- /**
1672
- * Check if component props are well configured on init
1673
- *
1674
- * @returns {ReturnType<typeof setTimeout>} timeout
1675
- */
1676
- componentWillLoad() {
1677
- // Check items format
1678
- this.validateItems(this.items);
1679
- // Check validity when component is ready
1680
- // return a promise to process action only in the FIRST render().
1681
- // https://stenciljs.com/docs/component-lifecycle#componentwillload
1682
- return setTimeout(() => {
1683
- this.checkValidity();
1684
- }, 0);
1685
- }
1686
- /**
1687
- * Render
1688
- *
1689
- * @returns {HTMLElement} HTML Element
1690
- */
1691
- render() {
1692
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, width: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.options.map((input, index) => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => this.inputs.push(el) }), h("label", { htmlFor: this.identifier + '_' + index }, input.title)))))));
1693
- }
1694
- static get watchers() { return {
1695
- "value": ["handleValue"],
1696
- "items": ["validateItems"]
1697
- }; }
1698
- };
1699
- MgInputRadio.style = mgInputRadioCss;
1700
-
1701
- const mgInputSelectCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);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{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;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:-ms-inline-flexbox;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:-ms-inline-flexbox;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-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;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)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left: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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.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){-ms-flex-pack:justify;justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{-ms-flex:auto;flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{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}.mg-input__box{padding-top:0;padding-bottom:0;padding-right:1rem}";
1702
-
1703
- /**
1704
- * Check if item is a well configured option
1705
- *
1706
- * @param {SelectOption} option select option
1707
- * @returns {boolean} select option type is valid
1708
- */
1709
- const isOption$1 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
1710
- /**
1711
- * Group options
1712
- *
1713
- * @param {(SelectOption | OptGroup)[]} acc reduce accumulator
1714
- * @param {SelectOption} item item to add
1715
- * @param {string} item.group item group
1716
- * @param {string} item.title item title
1717
- * @param {unknown} item.value item value
1718
- * @param {boolean} item.disabled is item disabled
1719
- * @returns {(SelectOption | OptGroup)[]} grouped options
1720
- */
1721
- const groupOptions = (acc, { group, title, value, disabled }) => {
1722
- if (group !== undefined) {
1723
- // Check if group is already created
1724
- const optGroup = acc.find(grp => grp.group === group);
1725
- // Add to group
1726
- if (optGroup !== undefined) {
1727
- optGroup.options.push({ title, value, disabled });
1728
- }
1729
- // Create group
1730
- else {
1731
- acc.push({ group, options: [{ title, value, disabled }] });
1732
- }
1733
- }
1734
- else {
1735
- acc.push({ title, value, disabled });
1736
- }
1737
- return acc;
1738
- };
1739
- const MgInputSelect = class {
1740
- constructor(hostRef) {
1741
- registerInstance(this, hostRef);
1742
- this.valueChange = createEvent(this, "value-change", 7);
1743
- this.inputValid = createEvent(this, "input-valid", 7);
1744
- /************
1745
- * Internal *
1746
- ************/
1747
- // classes
1748
- this.classError = InputClass.ERROR;
1749
- /**
1750
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1751
- * If not set, it will be created.
1752
- */
1753
- this.identifier = createID('mg-input-select');
1754
- /**
1755
- * Input name
1756
- * If not set the value equals the identifier
1757
- */
1758
- this.name = this.identifier;
1759
- /**
1760
- * Define if label is visible
1761
- */
1762
- this.labelHide = false;
1763
- /**
1764
- * Input placeholder.
1765
- * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.
1766
- */
1767
- this.placeholder = messages.input.select.placeholder;
1768
- /**
1769
- * Option to remove placeholder
1770
- */
1771
- this.placeholderHide = false;
1772
- /**
1773
- * Option to disable placeholder
1774
- */
1775
- this.placeholderDisabled = false;
1776
- /**
1777
- * Define if input is required
1778
- */
1779
- this.required = false;
1780
- /**
1781
- * Define if input is readonly
1782
- */
1783
- this.readonly = false;
1784
- /**
1785
- * Define if input is disabled
1786
- */
1787
- this.disabled = false;
1788
- /**
1789
- * Component classes
1790
- */
1791
- this.classList = new ClassList(['mg-input--select']);
1792
- /**
1793
- * Handle input event
1794
- */
1795
- this.handleInput = () => {
1796
- this.checkValidity();
1797
- if (this.input.value !== '') {
1798
- this.value = allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.title === this.input.value).value;
1799
- }
1800
- else {
1801
- this.value = null;
1802
- }
1803
- };
1804
- /**
1805
- * Handle blur event
1806
- */
1807
- this.handleBlur = () => {
1808
- this.checkValidity();
1809
- this.checkError();
1810
- };
1811
- /**
1812
- * Check if input is valid
1813
- */
1814
- this.checkValidity = () => {
1815
- if (!this.readonly && this.input !== undefined) {
1816
- const validity = this.input.checkValidity && this.input.checkValidity();
1817
- // Set validity
1818
- this.valid = validity;
1819
- this.invalid = !validity;
1820
- //Send event
1821
- this.inputValid.emit(validity);
1822
- }
1823
- };
1824
- /**
1825
- * Check input errors
1826
- */
1827
- this.checkError = () => {
1828
- // Set error message
1829
- this.errorMessage = undefined;
1830
- if (!this.valid && this.input.validity.valueMissing) {
1831
- this.errorMessage = messages.errors.required;
1832
- }
1833
- // Update class
1834
- if (this.valid) {
1835
- this.classList.delete(this.classError);
1836
- }
1837
- else {
1838
- this.classList.add(this.classError);
1839
- }
1840
- };
1841
- }
1842
- handleValue(newValue) {
1843
- if (newValue !== null) {
1844
- this.readonlyValue = allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.value === newValue).title;
1845
- }
1846
- else {
1847
- this.readonlyValue = null;
1848
- }
1849
- this.valueChange.emit(newValue);
1850
- }
1851
- validateItems(newValue) {
1852
- // String array
1853
- if (allItemsAreString(newValue)) {
1854
- this.valueExist = newValue.includes(this.value);
1855
- this.options = newValue.map((item) => ({ title: item, value: item }));
1856
- }
1857
- // Object array
1858
- else if (newValue && newValue.every(item => isOption$1(item))) {
1859
- this.valueExist = newValue.map(item => item.value).includes(this.value);
1860
- // Grouped object options
1861
- if (newValue.some(item => item.group !== undefined)) {
1862
- this.options = newValue.reduce(groupOptions, []);
1863
- }
1864
- // Standart object options
1865
- else {
1866
- this.options = newValue;
1867
- }
1868
- }
1869
- else {
1870
- throw new Error('<mg-input-select> prop "items" is required and all items must be the same type, string or Option.');
1871
- }
1872
- }
1873
- /**
1874
- * Public method to display errors
1875
- *
1876
- * @returns {Promise<void>}
1877
- */
1878
- async displayError() {
1879
- this.checkValidity();
1880
- this.checkError();
1881
- }
1882
- /*************
1883
- * Lifecycle *
1884
- *************/
1885
- /**
1886
- * Check if component props are well configured on init
1887
- *
1888
- * @returns {ReturnType<typeof setTimeout>} timeout
1889
- */
1890
- componentWillLoad() {
1891
- // Check items format
1892
- this.validateItems(this.items);
1893
- // Check validity when component is ready
1894
- // return a promise to process action only in the FIRST render().
1895
- // https://stenciljs.com/docs/component-lifecycle#componentwillload
1896
- return setTimeout(() => {
1897
- this.checkValidity();
1898
- }, 0);
1899
- }
1900
- /**
1901
- * Render
1902
- *
1903
- * @returns {HTMLElement} HTML Element
1904
- */
1905
- render() {
1906
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
1907
- h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map(option => option.group !== undefined ? (h("optgroup", { label: option.group }, option.options.map(optgroup => (h("option", { value: optgroup.title, selected: JSON.stringify(this.value) === JSON.stringify(optgroup.value), disabled: optgroup.disabled }, optgroup.title))))) : (h("option", { value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title))))));
1908
- }
1909
- static get watchers() { return {
1910
- "value": ["handleValue"],
1911
- "items": ["validateItems"]
1912
- }; }
1913
- };
1914
- MgInputSelect.style = mgInputSelectCss;
1915
-
1916
- const mgInputTextCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);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{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;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:-ms-inline-flexbox;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:-ms-inline-flexbox;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-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;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)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left: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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.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){-ms-flex-pack:justify;justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{-ms-flex:auto;flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{display:none}.mg-input.is-focused mg-character-left{display:block}.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}.mg-input.mg-input--has-icon .mg-input__input{position:relative}.mg-input.mg-input--has-icon .mg-input__input>mg-icon{position:absolute;top:calc(var(--default-size) - var(--mg-icon-regular-size));left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);-webkit-transform:translateY(-50%);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__input .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}";
1917
-
1918
- const MgInputText = class {
1919
- constructor(hostRef) {
1920
- registerInstance(this, hostRef);
1921
- this.valueChange = createEvent(this, "value-change", 7);
1922
- this.inputValid = createEvent(this, "input-valid", 7);
1923
- /************
1924
- * Internal *
1925
- ************/
1926
- // classes
1927
- this.classFocus = 'is-focused';
1928
- this.isInputGroupAppend = 'mg-input--is-input-group-append';
1929
- this.classError = InputClass.ERROR;
1930
- /**
1931
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1932
- * If not set, it will be created.
1933
- */
1934
- this.identifier = createID('mg-input-text');
1935
- /**
1936
- * Input name
1937
- * If not set the value equals the identifier
1938
- */
1939
- this.name = this.identifier;
1940
- /**
1941
- * Input type
1942
- */
1943
- this.type = 'text';
1944
- /**
1945
- * Define if label is visible
1946
- */
1947
- this.labelHide = false;
1948
- /**
1949
- * Input max length
1950
- */
1951
- this.maxlength = 400;
1952
- /**
1953
- * Define if input is required
1954
- */
1955
- this.required = false;
1956
- /**
1957
- * Define if input is readonly
1958
- */
1959
- this.readonly = false;
1960
- /**
1961
- * Define if input is disabled
1962
- */
1963
- this.disabled = false;
1964
- /**
1965
- * Define input width
1966
- */
1967
- this.width = 'full';
1968
- /**
1969
- * Define if component should display character left
1970
- */
1971
- this.displayCharacterLeft = true;
1972
- /**
1973
- * Component classes
1974
- */
1975
- this.classList = new ClassList(['mg-input--text']);
1976
- /**
1977
- * Handle input event
1978
- *
1979
- * @returns {void}
1980
- */
1981
- this.handleInput = () => {
1982
- this.checkValidity();
1983
- this.value = this.input.value;
1984
- };
1985
- /**
1986
- * Handle focus event
1987
- *
1988
- * @returns {void}
1989
- */
1990
- this.handleFocus = () => {
1991
- this.classList.add(this.classFocus);
1992
- this.classList = new ClassList(this.classList.classes);
1993
- };
1994
- /**
1995
- * Handle blur event
1996
- *
1997
- * @returns {void}
1998
- */
1999
- this.handleBlur = () => {
2000
- // Manage focus
2001
- this.classList.delete(this.classFocus);
2002
- this.classList = new ClassList(this.classList.classes);
2003
- // Check validity
2004
- this.checkValidity();
2005
- this.checkError();
2006
- };
2007
- /**
2008
- * Check if input is valid
2009
- *
2010
- * @returns {void}
2011
- */
2012
- this.checkValidity = () => {
2013
- if (!this.readonly && this.input !== undefined) {
2014
- const validity = this.input.checkValidity();
2015
- // Set validity
2016
- this.valid = validity;
2017
- this.invalid = !validity;
2018
- //Send event
2019
- this.inputValid.emit(validity);
2020
- }
2021
- };
2022
- /**
2023
- * Check input errors
2024
- *
2025
- * @returns {void}
2026
- */
2027
- this.checkError = () => {
2028
- // Set error message
2029
- this.errorMessage = undefined;
2030
- // Does not match pattern
2031
- if (!this.valid && this.input.validity.patternMismatch) {
2032
- this.errorMessage = this.patternErrorMessage;
2033
- }
2034
- // required
2035
- else if (!this.valid && this.input.validity.valueMissing) {
2036
- this.errorMessage = messages.errors.required;
2037
- }
2038
- // Update class
2039
- if (this.valid) {
2040
- this.classList.delete(this.classError);
2041
- }
2042
- else {
2043
- this.classList.add(this.classError);
2044
- }
2045
- };
2046
- /**
2047
- * Validate patern configuration
2048
- *
2049
- * @returns {void}
2050
- */
2051
- this.validatePattern = () => {
2052
- if (this.pattern &&
2053
- typeof this.pattern === 'string' &&
2054
- this.pattern !== '' &&
2055
- (this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
2056
- throw new Error('<mg-input-text> prop "pattern" must be paired with the prop "patternErrorMessage"');
2057
- }
2058
- };
2059
- /**
2060
- * Validate append slot
2061
- *
2062
- * @returns {void}
2063
- */
2064
- this.validateAppendSlot = () => {
2065
- const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
2066
- if (slotAppendInput.length === 1) {
2067
- this.classList.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.isInputGroupAppend : 'mg-input--is-append-input-slot-content');
2068
- }
2069
- else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
2070
- this.classList.add(this.isInputGroupAppend);
2071
- this.classList.add('mg-input--has-buttons-group-append');
2072
- }
2073
- };
2074
- }
2075
- handleValue(newValue) {
2076
- this.valueChange.emit(newValue);
2077
- }
2078
- /**
2079
- * Public method to play input focus
2080
- *
2081
- * @returns {Promise<void>}
2082
- */
2083
- async setFocus() {
2084
- this.input.focus();
2085
- }
2086
- /**
2087
- * Public method to display errors
2088
- *
2089
- * @returns {Promise<void>}
2090
- */
2091
- async displayError() {
2092
- this.checkValidity();
2093
- this.checkError();
2094
- }
2095
- /*************
2096
- * Lifecycle *
2097
- *************/
2098
- /**
2099
- * Check if component props are well configured on init
2100
- *
2101
- * @returns {ReturnType<typeof setTimeout>} timeout
2102
- */
2103
- componentWillLoad() {
2104
- if (this.icon !== undefined) {
2105
- this.classList.add('mg-input--has-icon');
2106
- }
2107
- this.validatePattern();
2108
- this.validateAppendSlot();
2109
- // Check validity when component is ready
2110
- // return a promise to process action only in the FIRST render().
2111
- // https://stenciljs.com/docs/component-lifecycle#componentwillload
2112
- return setTimeout(() => {
2113
- this.checkValidity();
2114
- }, 0);
2115
- }
2116
- /**
2117
- * Render
2118
- *
2119
- * @returns {HTMLElement} HTML Element
2120
- */
2121
- render() {
2122
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, displayCharacterLeft: this.displayCharacterLeft, characterLeftTemplate: this.characterLeftTemplate, maxlength: this.maxlength, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type, class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), h("slot", { name: "append-input" })));
2123
- }
2124
- get element() { return getElement(this); }
2125
- static get watchers() { return {
2126
- "value": ["handleValue"]
2127
- }; }
2128
- };
2129
- MgInputText.style = mgInputTextCss;
2130
-
2131
- const mgInputTextareaCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);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{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;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:-ms-inline-flexbox;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:-ms-inline-flexbox;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-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;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)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left: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-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.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){-ms-flex-pack:justify;justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{-ms-flex:auto;flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{display:none}.mg-input.is-focused mg-character-left{display:block}.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}.mg-input .mg-input__box{height:auto}@-moz-document url-prefix(){.mg-input__box{overflow-x:hidden}}";
2132
-
2133
- const MgInputTextarea = class {
2134
- constructor(hostRef) {
2135
- registerInstance(this, hostRef);
2136
- this.valueChange = createEvent(this, "value-change", 7);
2137
- this.inputValid = createEvent(this, "input-valid", 7);
2138
- /************
2139
- * Internal *
2140
- ************/
2141
- // classes
2142
- this.classFocus = 'is-focused';
2143
- this.classError = InputClass.ERROR;
2144
- /**
2145
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2146
- * If not set, it will be created.
2147
- */
2148
- this.identifier = createID('mg-input-textarea');
2149
- /**
2150
- * Input name
2151
- * If not set the value equals the identifier
2152
- */
2153
- this.name = this.identifier;
2154
- /**
2155
- * Define if label is visible
2156
- */
2157
- this.labelHide = false;
2158
- /**
2159
- * Input max length
2160
- */
2161
- this.maxlength = 4000;
2162
- /**
2163
- * Define if input is required
2164
- */
2165
- this.required = false;
2166
- /**
2167
- * Define if input is readonly
2168
- */
2169
- this.readonly = false;
2170
- /**
2171
- * Define if input is disabled
2172
- */
2173
- this.disabled = false;
2174
- /**
2175
- * Define input width
2176
- */
2177
- this.width = 'full';
2178
- /**
2179
- * Define the number of visible text lines for the control
2180
- */
2181
- this.rows = 3;
2182
- /**
2183
- * Define if component should display character left
2184
- */
2185
- this.displayCharacterLeft = true;
2186
- /**
2187
- * Component classes
2188
- */
2189
- this.classList = new ClassList(['mg-input--textarea']);
2190
- /**
2191
- * Handle input event
2192
- */
2193
- this.handleInput = () => {
2194
- this.value = this.input.value;
2195
- };
2196
- /**
2197
- * Handle focus event
2198
- */
2199
- this.handleFocus = () => {
2200
- this.classList.add(this.classFocus);
2201
- this.classList = new ClassList(this.classList.classes);
2202
- };
2203
- /**
2204
- * Handle blur event
2205
- */
2206
- this.handleBlur = () => {
2207
- // Manage focus
2208
- this.classList.delete(this.classFocus);
2209
- this.classList = new ClassList(this.classList.classes);
2210
- // Check validity
2211
- this.checkValidity();
2212
- this.checkError();
2213
- };
2214
- /**
2215
- * Get pattern validity
2216
- * Pattern is not defined on textarea field : https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
2217
- *
2218
- * @returns {boolean} is pattern valid
2219
- */
2220
- this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
2221
- /**
2222
- * Check if input is valid
2223
- */
2224
- this.checkValidity = () => {
2225
- if (!this.readonly && this.input !== undefined) {
2226
- const validity = this.input.checkValidity && this.input.checkValidity() && this.getPatternValidity();
2227
- // Set validity
2228
- this.valid = validity;
2229
- this.invalid = !validity;
2230
- //Send event
2231
- this.inputValid.emit(validity);
2232
- }
2233
- };
2234
- /**
2235
- * Check input errors
2236
- */
2237
- this.checkError = () => {
2238
- // Set error message
2239
- this.errorMessage = undefined;
2240
- // Does not match pattern
2241
- if (!this.valid && !this.getPatternValidity()) {
2242
- this.errorMessage = this.patternErrorMessage;
2243
- }
2244
- // required
2245
- else if (!this.valid && this.input.validity.valueMissing) {
2246
- this.errorMessage = messages.errors.required;
2247
- }
2248
- // Update class
2249
- if (this.valid) {
2250
- this.classList.delete(this.classError);
2251
- }
2252
- else {
2253
- this.classList.add(this.classError);
2254
- }
2255
- };
2256
- /**
2257
- * Validate pattern configuration
2258
- */
2259
- this.validatePattern = () => {
2260
- if (this.pattern &&
2261
- typeof this.pattern === 'string' &&
2262
- this.pattern !== '' &&
2263
- (this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
2264
- throw new Error('<mg-input-textarea> prop "pattern" must be paired with the prop "patternErrorMessage"');
2265
- }
2266
- };
2267
- }
2268
- handleValue(newValue) {
2269
- this.checkValidity();
2270
- this.valueChange.emit(newValue);
2271
- }
2272
- /**
2273
- * Public method to display errors
2274
- *
2275
- * @returns {Promise<void>}
2276
- */
2277
- async displayError() {
2278
- this.checkValidity();
2279
- this.checkError();
2280
- }
2281
- /*************
2282
- * Lifecycle *
2283
- *************/
2284
- /**
2285
- * Check if component props are well configured on init
2286
- *
2287
- * @returns {ReturnType<typeof setTimeout>} timeout
2288
- */
2289
- componentWillLoad() {
2290
- this.validatePattern();
2291
- // Check validity when component is ready
2292
- // return a promise to process action only in the FIRST render().
2293
- // https://stenciljs.com/docs/component-lifecycle#componentwillload
2294
- return setTimeout(() => {
2295
- this.checkValidity();
2296
- }, 0);
2297
- }
2298
- /**
2299
- * Render
2300
- *
2301
- * @returns {HTMLElement} HTML Element
2302
- */
2303
- render() {
2304
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, displayCharacterLeft: this.displayCharacterLeft, characterLeftTemplate: this.characterLeftTemplate, maxlength: this.maxlength, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("textarea", { class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) })));
2305
- }
2306
- static get watchers() { return {
2307
- "value": ["handleValue"]
2308
- }; }
2309
- };
2310
- MgInputTextarea.style = mgInputTextareaCss;
2311
-
2312
- const mgInputTitleCss = ".is-asterisk.sc-mg-input-title{color:hsl(var(--color-danger))}legend.mg-input-title.sc-mg-input-title{padding-left:0;padding-right:0}.mg-input-title__required.sc-mg-input-title{display:var(--mg-input-title-display, unset)}";
2313
-
2314
- const MgInputTitle = class {
2315
- constructor(hostRef) {
2316
- registerInstance(this, hostRef);
2317
- /**
2318
- * Switch from label to fieldset sementic
2319
- */
2320
- this.isLegend = false;
2321
- /**
2322
- * Component parent tagname
2323
- */
2324
- this.tagName = 'label';
2325
- this.getTagName = () => {
2326
- this.tagName = this.isLegend ? 'legend' : 'label';
2327
- };
2328
- }
2329
- /*************
2330
- * Lifecycle *
2331
- *************/
2332
- /**
2333
- * Init tag name
2334
- *
2335
- * @returns {void}
2336
- */
2337
- componentWillLoad() {
2338
- this.getTagName();
2339
- }
2340
- /**
2341
- * Render
2342
- *
2343
- * @returns {HTMLElement} HTML Element
2344
- */
2345
- render() {
2346
- const TagName = this.tagName;
2347
- // \u00A0 represent a &nbsp;
2348
- return (h(TagName, { class: "mg-input-title", htmlFor: this.isLegend ? undefined : this.identifier }, h("slot", null), this.required && (h("span", { class: "mg-input-title__required" }, "\u00A0", h("span", { class: "is-asterisk" }, "*")))));
2349
- }
2350
- };
2351
- MgInputTitle.style = mgInputTitleCss;
2352
-
2353
- const mgInputToggleCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);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{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;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:-ms-inline-flexbox;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:-ms-inline-flexbox;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-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.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}.mg-input.mg-input.mg-input--toggle .mg-input__input-container{-ms-flex:auto;flex:auto;min-width:0}.mg-input__button-toggle{display:-ms-flexbox;display:flex;padding:0.2rem;min-width:0;background-color:hsl(var(--color-light));border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:calc((var(--font-size) * var(--line-height) + 2 * (0.7rem + var(--mg-inputs-border-width))) / var(--mg-input-toggle-border-radius-ratio));font-size:inherit;line-height:inherit;cursor:pointer}.mg-input__button-toggle:disabled{cursor:default}.mg-input__toggle-item-container{padding:0.5rem 0.9rem;border:0;-webkit-box-sizing:border-box;box-sizing:border-box;border-radius:calc((var(--font-size) * var(--line-height) + 1rem) / var(--mg-input-toggle-border-radius-ratio));background-color:unset;font-weight:unset;color:hsl(var(--color-dark));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;width:calc(var(--font-size) * var(--line-height) + 1rem);height:calc(var(--font-size) * var(--line-height) + 1rem);padding:0;visibility:hidden}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container:first-of-type{visibility:visible}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container ::slotted(mg-icon){display:-ms-flexbox;display:flex}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{visibility:hidden}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{visibility:visible}.mg-input.mg-input--toggle-on-off .mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-dark));background-color:hsl(var(--color-dark-h), calc(var(--color-dark-s) - 30%), calc(var(--color-dark-l) + 75%))}.mg-input.mg-input--toggle-on-off.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-readonly .mg-input__button-toggle{border-color:transparent;background-color:transparent;cursor:initial}.mg-input.mg-input--toggle-readonly .mg-input__toggle-item-container:last-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{display:-ms-flexbox;display:flex}.mg-input.mg-input--toggle-disabled .mg-input__button-toggle{opacity:0.3}";
2354
-
2355
- /**
2356
- * type Option validation function
2357
- *
2358
- * @param {ToggleValue} option radio option
2359
- * @returns {boolean} toggle option type is valid
2360
- */
2361
- const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
2362
- const MgInputToggle = class {
2363
- constructor(hostRef) {
2364
- registerInstance(this, hostRef);
2365
- this.valueChange = createEvent(this, "value-change", 7);
2366
- this.inputValid = createEvent(this, "input-valid", 7);
2367
- /************
2368
- * Internal *
2369
- ************/
2370
- // classes
2371
- this.classReadonly = 'mg-input--toggle-readonly';
2372
- this.classDisabled = 'mg-input--toggle-disabled';
2373
- this.classIsActive = 'mg-input--toggle-is-active';
2374
- /**
2375
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2376
- * If not set, it will be created.
2377
- */
2378
- this.identifier = createID('mg-input-toggle');
2379
- /**
2380
- * Input name
2381
- * If not set the value equals the identifier
2382
- */
2383
- this.name = this.identifier;
2384
- /**
2385
- * Define if label is visible
2386
- */
2387
- this.labelHide = false;
2388
- /**
2389
- * Define if toggle have on/off style
2390
- */
2391
- this.isOnOff = false;
2392
- /**
2393
- * Define if toggle display icon
2394
- */
2395
- this.isIcon = false;
2396
- /**
2397
- * Define if input is readonly
2398
- */
2399
- this.readonly = false;
2400
- /**
2401
- * Define if input is disabled
2402
- */
2403
- this.disabled = false;
2404
- /**
2405
- * Component classes
2406
- */
2407
- this.classList = new ClassList(['mg-input--toggle']);
2408
- /**
2409
- * Checked internal value
2410
- */
2411
- this.checked = false;
2412
- /**
2413
- * Change checked value
2414
- *
2415
- * @returns {void}
2416
- */
2417
- this.toggleChecked = () => {
2418
- this.checked = !this.checked;
2419
- };
2420
- /**
2421
- * Slots validation
2422
- *
2423
- * @returns {void}
2424
- */
2425
- this.validateSlots = () => {
2426
- const slots = Array.from(this.element.children);
2427
- if (slots.length !== 2) {
2428
- throw new Error('<mg-input-toggle> 2 slots are required.');
2429
- }
2430
- else if (!this.isIcon) {
2431
- // Due to text-overflow set to ellipsis
2432
- // we need to ensure that slot element have title to display value on mouse over
2433
- slots.forEach(slot => slot.setAttribute('title', slot.textContent));
2434
- }
2435
- };
2436
- }
2437
- handleValue(newValue) {
2438
- // Swich to the right option
2439
- this.setChecked();
2440
- // Emit value-change event
2441
- this.valueChange.emit(newValue);
2442
- }
2443
- validateItems(newValue) {
2444
- if (typeof newValue === 'object' && this.items.length !== 2) {
2445
- throw new Error('<mg-input-toggle> prop "items" require 2 items.');
2446
- }
2447
- // String array
2448
- else if (allItemsAreString(newValue)) {
2449
- this.options = newValue.map(item => ({ title: item, value: item }));
2450
- }
2451
- // Object array
2452
- else if (newValue && newValue.every(item => isOption(item))) {
2453
- this.options = newValue;
2454
- }
2455
- else {
2456
- throw new Error('<mg-input-toggle> prop "items" is required and all items must be the same type: ToggleValue.');
2457
- }
2458
- }
2459
- handleIsOnOff(newValue) {
2460
- if (newValue)
2461
- this.classList.add(`mg-input--toggle-on-off`);
2462
- }
2463
- handleIsIcon(newValue) {
2464
- if (newValue)
2465
- this.classList.add(`mg-input--toggle-icon`);
2466
- }
2467
- handleReadonly(newValue) {
2468
- if (newValue)
2469
- this.classList.add(this.classReadonly);
2470
- else
2471
- this.classList.delete(this.classReadonly);
2472
- }
2473
- handleDisabled(newValue) {
2474
- if (newValue)
2475
- this.classList.add(this.classDisabled);
2476
- else
2477
- this.classList.delete(this.classDisabled);
2478
- }
2479
- handleChecked(newValue) {
2480
- // style
2481
- if (newValue)
2482
- this.classList.add(this.classIsActive);
2483
- else
2484
- this.classList.delete(this.classIsActive);
2485
- // update value
2486
- this.value = this.options[newValue ? 1 : 0].value;
2487
- }
2488
- /**
2489
- * set checked state
2490
- *
2491
- * @returns {void}
2492
- */
2493
- setChecked() {
2494
- // has "value" props type is not a boolean, it is bind/render as an attributes/props
2495
- // true props will be represent by "true" string so we convert it has boolean
2496
- // true attribute will be represent by "" string so we convert it has boolean
2497
- // https://stenciljs.com/docs/properties
2498
- if (['', 'true'].includes(this.value) && this.options.find(option => option.value) !== undefined) {
2499
- this.value = true;
2500
- }
2501
- this.checked = this.value === this.options[1].value;
2502
- }
2503
- /*************
2504
- * Lifecycle *
2505
- *************/
2506
- /**
2507
- * Check if component props are well configured on init
2508
- */
2509
- componentWillLoad() {
2510
- // Check items format
2511
- this.validateItems(this.items);
2512
- // Check slots
2513
- this.validateSlots();
2514
- // init checked value
2515
- this.setChecked();
2516
- // apply handler
2517
- this.handleIsOnOff(this.isOnOff);
2518
- this.handleIsIcon(this.isIcon);
2519
- this.handleReadonly(this.readonly);
2520
- this.handleDisabled(this.disabled);
2521
- }
2522
- /**
2523
- * Render
2524
- *
2525
- * @returns {HTMLElement} HTML Element
2526
- */
2527
- render() {
2528
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, width: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-2" })))));
2529
- }
2530
- get element() { return getElement(this); }
2531
- static get watchers() { return {
2532
- "value": ["handleValue"],
2533
- "items": ["validateItems"],
2534
- "isOnOff": ["handleIsOnOff"],
2535
- "isIcon": ["handleIsIcon"],
2536
- "readonly": ["handleReadonly"],
2537
- "disabled": ["handleDisabled"],
2538
- "checked": ["handleChecked"]
2539
- }; }
2540
- };
2541
- MgInputToggle.style = mgInputToggleCss;
2542
-
2543
- /**
2544
- * List of all possibles message variants
2545
- */
2546
- const variants$1 = ['info', 'warning', 'success', 'danger'];
2547
-
2548
- const mgMessageCss = ".mg-message{display:inline-block;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;min-height:var(--default-size);overflow:hidden;background-color:white;border-radius:var(--mg-message-border-radius);-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow)}.mg-message::before{content:\"\";position:absolute;top:0;left:0;width:0.3rem;height:100%}.mg-message.mg-message--info::before{background-color:hsl(var(--color-info))}.mg-message.mg-message--info .mg-message__icon{color:hsl(var(--color-info))}.mg-message.mg-message--warning::before{background-color:hsl(var(--color-warning))}.mg-message.mg-message--warning .mg-message__icon{color:hsl(var(--color-warning))}.mg-message.mg-message--success::before{background-color:hsl(var(--color-success))}.mg-message.mg-message--success .mg-message__icon{color:hsl(var(--color-success))}.mg-message.mg-message--danger::before{background-color:hsl(var(--color-danger))}.mg-message.mg-message--danger .mg-message__icon{color:hsl(var(--color-danger))}.mg-message.mg-message--close-button{padding-right:3.4rem}.mg-message.mg-message--hide{display:none}.mg-message ::slotted(*){margin:0;padding:0}.mg-message__icon{position:absolute;top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);left:1.3rem;line-height:1}.mg-message__content{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:end;justify-content:flex-end;-ms-flex-line-pack:stretch;align-content:stretch;padding:0 1rem 0 3.8rem}.mg-message__content-slot{-ms-flex-positive:1;flex-grow:1;margin:0.84rem 0}.mg-message__content-separator{display:inline-block;width:4.5rem;height:0}.mg-message__content-actions-slot{padding:1rem 0;text-align:right}.mg-message__close-button{position:absolute;top:0;right:0}.mg-message,mg-message{max-width:100%}";
2549
-
2550
- const MgMessage = class {
2551
- constructor(hostRef) {
2552
- registerInstance(this, hostRef);
2553
- this.componentShow = createEvent(this, "component-show", 7);
2554
- this.componentHide = createEvent(this, "component-hide", 7);
2555
- /************
2556
- * Internal *
2557
- ************/
2558
- this.closeButtonId = '';
2559
- // Stored timer setted when hide action is run from setTimeOut
2560
- this.storedTimer = null;
2561
- /**
2562
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2563
- * If not set, it will be created.
2564
- */
2565
- this.identifier = createID('mg-message');
2566
- /**
2567
- * Message variant
2568
- */
2569
- this.variant = variants$1[0]; // info
2570
- /**
2571
- * Define if message has a cross button
2572
- * RG 01: https://jira.mgdis.fr/browse/PDA9-140
2573
- */
2574
- this.closeButton = false;
2575
- /**
2576
- * Define if message is hidden
2577
- */
2578
- this.hide = false;
2579
- /**
2580
- * Component classes
2581
- */
2582
- this.classList = new ClassList(['mg-message']);
2583
- /**
2584
- * Define if component is using actions slot
2585
- */
2586
- this.hasActions = false;
2587
- /**
2588
- * Handle close button
2589
- */
2590
- this.handleClose = () => {
2591
- this.hide = true;
2592
- };
2593
- /**
2594
- * Hide component whith delay
2595
- */
2596
- this.hideWithDelay = () => {
2597
- if (this.delay > 0 && this.hide !== true) {
2598
- this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
2599
- }
2600
- else if (this.storedTimer !== null) {
2601
- clearTimeout(this.storedTimer);
2602
- }
2603
- };
2604
- /**
2605
- * Get icon corresponding to variant
2606
- *
2607
- * @returns {string} icon
2608
- */
2609
- this.getIcon = () => {
2610
- switch (this.variant) {
2611
- case 'info':
2612
- return 'info-circle';
2613
- case 'warning':
2614
- return 'exclamation-triangle';
2615
- case 'success':
2616
- return 'check-circle';
2617
- case 'danger':
2618
- return 'exclamation-circle';
2619
- }
2620
- };
2621
- }
2622
- validateDelay(newValue) {
2623
- if (newValue && newValue < 2) {
2624
- throw new Error(`<mg-message> prop "delay" must be greater than 2 seconds.`);
2625
- }
2626
- }
2627
- validateVariant(newValue, oldValue) {
2628
- if (!variants$1.includes(newValue)) {
2629
- throw new Error(`<mg-message> prop "variant" must be one of : ${variants$1.join(', ')}`);
2630
- }
2631
- if (oldValue !== undefined) {
2632
- this.classList.delete(`mg-message--${oldValue}`);
2633
- }
2634
- this.classList.add(`mg-message--${this.variant}`);
2635
- }
2636
- validateCloseButton(newValue) {
2637
- if (newValue && this.hasActions) {
2638
- this.closeButton = false;
2639
- throw new Error('<mg-message> prop "close-button" can\'t be used with the actions slot.');
2640
- }
2641
- }
2642
- validateHide(newValue) {
2643
- if (newValue) {
2644
- this.componentHide.emit();
2645
- this.classList.add('mg-message--hide');
2646
- }
2647
- else {
2648
- this.componentShow.emit();
2649
- this.classList.delete('mg-message--hide');
2650
- }
2651
- this.hideWithDelay();
2652
- }
2653
- /*************
2654
- * Lifecycle *
2655
- *************/
2656
- /**
2657
- * Check if component props are well configured on init
2658
- */
2659
- componentWillLoad() {
2660
- this.validateVariant(this.variant);
2661
- // Check if close button is an can be activated
2662
- this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
2663
- this.validateCloseButton(this.closeButton);
2664
- if (this.closeButton) {
2665
- this.classList.add('mg-message--close-button');
2666
- this.closeButtonId = `${this.identifier}-close-button`;
2667
- }
2668
- this.validateDelay(this.delay);
2669
- this.validateHide(this.hide);
2670
- }
2671
- /**
2672
- * Render
2673
- *
2674
- * @returns {HTMLElement} HTML Element
2675
- */
2676
- render() {
2677
- return (h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("span", { class: "mg-message__icon" }, h("mg-icon", { icon: this.getIcon() })), h("div", { class: "mg-message__content" }, h("span", { class: "mg-message__content-slot" }, h("slot", null)), this.hasActions && h("span", { class: "mg-message__content-separator" }), this.hasActions && (h("span", { class: "mg-message__content-actions-slot" }, h("slot", { name: "actions" })))), this.closeButton && (h("span", { class: "mg-message__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: messages.message.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" }))))));
2678
- }
2679
- get element() { return getElement(this); }
2680
- static get watchers() { return {
2681
- "delay": ["validateDelay"],
2682
- "variant": ["validateVariant"],
2683
- "closeButton": ["validateCloseButton"],
2684
- "hide": ["validateHide"]
2685
- }; }
2686
- };
2687
- MgMessage.style = mgMessageCss;
2688
-
2689
- var NavigationAction;
2690
- (function (NavigationAction) {
2691
- NavigationAction["NEXT"] = "next";
2692
- NavigationAction["PREVIOUS"] = "previous";
2693
- })(NavigationAction || (NavigationAction = {}));
2694
-
2695
- const mgPaginationCss = ".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}.mg-pagination__nav{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}.mg-pagination__nav mg-input-select{margin-right:0.5rem}.mg-pagination__button{display:-ms-flexbox;display:flex}.mg-pagination__button:first-of-type{margin-right:1rem}.mg-pagination__button:last-of-type{margin-left:1rem}";
2696
-
2697
- /**
2698
- * Range generator
2699
- *
2700
- * start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
2701
- * then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
2702
- * then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
2703
- * then with Array.from(Array(...)) we get the complete array with "index" values instead of "empty" values
2704
- * ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
2705
- * finaly we map values from "start" range and apply the "step" coefficiant,
2706
- * ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
2707
- *
2708
- * range(1, 1) = [1]
2709
- * range(1, 5) = [1, 2, 3, 4, 5]
2710
- * range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
2711
- *
2712
- * @param {number} start start range
2713
- * @param {number} end start end
2714
- * @param {number} step step size
2715
- * @returns {number[]} range numbers
2716
- */
2717
- const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
2718
- const MgPagination = class {
2719
- constructor(hostRef) {
2720
- registerInstance(this, hostRef);
2721
- this.currentPageChange = createEvent(this, "current-page-change", 7);
2722
- /**************
2723
- * Decorators *
2724
- **************/
2725
- /**
2726
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2727
- * If not set, it will be created.
2728
- */
2729
- this.identifier = createID('mg-pagination');
2730
- /**
2731
- * Panignation label. Is a short description.
2732
- * Customize default value can be usefull to improve accessibility
2733
- */
2734
- this.label = 'pagination';
2735
- /**
2736
- * Component total pages
2737
- */
2738
- this.totalPages = 1;
2739
- /**
2740
- * Component current page
2741
- */
2742
- this.currentPage = 1;
2743
- /**
2744
- * Change current page from target
2745
- *
2746
- * @param {number} target target page
2747
- * @returns {void}
2748
- */
2749
- this.goToPage = (target) => {
2750
- this.currentPage = target;
2751
- };
2752
- /************
2753
- * Handlers *
2754
- ************/
2755
- /**
2756
- * select handler
2757
- *
2758
- * @param {InputEvent} event value change event
2759
- * @returns {void}
2760
- */
2761
- this.handleSelect = (event) => {
2762
- const to = Number(event.target.value);
2763
- this.goToPage(to > 0 ? to : 1);
2764
- };
2765
- /**
2766
- * Go to 'previous/next' page button handler
2767
- *
2768
- * @param {string} action navigation action
2769
- * @returns {void}
2770
- */
2771
- this.handleGoToPage = (action) => {
2772
- this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
2773
- };
2774
- }
2775
- validateTotalPages(newValue) {
2776
- if (newValue < 1) {
2777
- throw new Error('<mg-pagination> prop "totalPages" must be greater than 0');
2778
- }
2779
- }
2780
- validateCurrentPage(newValue) {
2781
- if (newValue < 1) {
2782
- throw new Error('<mg-pagination> prop "currentPage" must be greater than 0');
2783
- }
2784
- else if (newValue > this.totalPages) {
2785
- throw new Error('<mg-pagination> prop "currentPage" can not be greater than total page');
2786
- }
2787
- this.currentPageChange.emit(newValue);
2788
- }
2789
- /*************
2790
- * Lifecycle *
2791
- *************/
2792
- /**
2793
- * Check if props are well configured on init
2794
- *
2795
- * @returns {void}
2796
- */
2797
- componentWillLoad() {
2798
- this.validateTotalPages(this.totalPages);
2799
- this.validateCurrentPage(this.currentPage);
2800
- }
2801
- /**
2802
- * Render
2803
- *
2804
- * @returns {HTMLElement} HTML Element
2805
- */
2806
- render() {
2807
- const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: messages.pagination[`${action}Page`],
2808
- // eslint-disable-next-line react/jsx-no-bind
2809
- onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" }, action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }), messages.general[action], action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
2810
- return (h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination__nav" }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), h("span", { class: "sr-only" }, messages.pagination.page, " ", this.currentPage), h("span", null, "/ ", this.totalPages, " ", this.totalPages > 1 ? messages.pagination.pages : messages.pagination.page), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
2811
- }
2812
- static get watchers() { return {
2813
- "totalPages": ["validateTotalPages"],
2814
- "currentPage": ["validateCurrentPage"]
2815
- }; }
2816
- };
2817
- MgPagination.style = mgPaginationCss;
2818
-
2819
- const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow)}.mg-panel__header{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:justify;justify-content:space-between;padding:0 1rem 0 0.3rem;-ms-flex-align:start;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:-ms-flexbox;display:flex;margin:0.3rem 0}.mg-panel__header-left--full{-ms-flex:1 1 auto;flex:1 1 auto}.mg-panel__header-right{-ms-flex:1 auto;flex:1 auto}.mg-panel__header-left mg-input-text{-ms-flex-positive:1;flex-grow:1}.mg-panel__collapse-button{font-family:var(--font-family-heading);font-size:1.4rem;font-weight:500;margin:0 0.3rem 0 0}.mg-panel__content{padding:1.5rem}.mg-panel ::slotted([slot=header-right]){display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:1rem;margin-left:auto}";
2820
-
2821
- const MgPanel = class {
2822
- constructor(hostRef) {
2823
- registerInstance(this, hostRef);
2824
- this.titleChange = createEvent(this, "title-change", 7);
2825
- this.expandedChange = createEvent(this, "expanded-change", 7);
2826
- /**************
2827
- * Decorators *
2828
- **************/
2829
- /**
2830
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2831
- * If not set, it will be created.
2832
- */
2833
- this.identifier = createID('mg-panel');
2834
- /**
2835
- * Panel is opened
2836
- */
2837
- this.expanded = false;
2838
- /**
2839
- * Disable possibility to toggle expand
2840
- */
2841
- this.expandToggleDisabled = false;
2842
- /**
2843
- * Panel title is editabled
2844
- */
2845
- this.titleEditable = false;
2846
- /**
2847
- * Component classes
2848
- */
2849
- this.classList = new ClassList(['mg-panel']);
2850
- /**
2851
- * Title is in edition mode
2852
- */
2853
- this.isEditing = false;
2854
- /************
2855
- * Methods *
2856
- ************/
2857
- /**
2858
- * Toggle is editing state
2859
- *
2860
- * @returns {void}
2861
- */
2862
- this.toggleIsEditing = () => {
2863
- this.isEditing = !this.isEditing;
2864
- };
2865
- /************
2866
- * Handlers *
2867
- ************/
2868
- /**
2869
- * Collapse button click handler
2870
- *
2871
- * @returns {void}
2872
- */
2873
- this.handleCollapseButton = () => {
2874
- if (!this.expandToggleDisabled) {
2875
- this.expanded = !this.expanded;
2876
- }
2877
- };
2878
- /**
2879
- * Edit button click handler
2880
- *
2881
- * @returns {void}
2882
- */
2883
- this.handleEditButton = () => {
2884
- this.toggleIsEditing();
2885
- };
2886
- /**
2887
- * Update title handler
2888
- *
2889
- * @param {CustomEvent<string>} event input value change event
2890
- * @returns {void}
2891
- */
2892
- this.handleUpdateTitle = (event) => {
2893
- this.updatedPanelTitle = event.detail;
2894
- };
2895
- /**
2896
- * Cancel edition button handler
2897
- *
2898
- * @returns {void}
2899
- */
2900
- this.handleCancelEditButton = () => {
2901
- this.updatedPanelTitle = undefined;
2902
- this.toggleIsEditing();
2903
- };
2904
- /**
2905
- * Validate edition button handler
2906
- *
2907
- * @returns {void}
2908
- */
2909
- this.handleValidateEditButton = () => {
2910
- if (this.editInputElement.valid) {
2911
- if (this.updatedPanelTitle !== undefined)
2912
- this.panelTitle = this.updatedPanelTitle;
2913
- this.toggleIsEditing();
2914
- }
2915
- };
2916
- /**
2917
- * Header left conditional render
2918
- *
2919
- * @typedef {HTMLElement} HTMLMgButtonElement
2920
- * @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
2921
- */
2922
- this.headerLeft = () => {
2923
- const collapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", class: "mg-panel__collapse-button", identifier: `${this.identifier}-collapse-button`, expanded: this.expanded, controls: `${this.identifier}-content`, disabled: this.expandToggleDisabled }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle));
2924
- if (this.titleEditable && !this.isEditing) {
2925
- return [
2926
- collapseButton(),
2927
- h("mg-button", { "is-icon": true, variant: "flat", label: messages.panel.editLabel, onClick: this.handleEditButton, identifier: `${this.identifier}-edit-button` }, h("mg-icon", { icon: "pen" })),
2928
- ];
2929
- }
2930
- if (this.titleEditable && this.isEditing) {
2931
- return [
2932
- collapseButton(),
2933
- h("mg-input-text", { label: messages.panel.editLabel, "label-hide": true, value: this.panelTitle, "onValue-change": this.handleUpdateTitle, displayCharacterLeft: false, pattern: this.titlePattern, "pattern-error-message": this.titlePatternErrorMessage, identifier: `${this.identifier}-edition-input`, ref: el => (this.editInputElement = el) }, h("mg-button", { slot: "append-input", label: messages.general.cancel, "is-icon": true, variant: "secondary", onClick: this.handleCancelEditButton, identifier: `${this.identifier}-edition-button-cancel` }, h("mg-icon", { icon: "cross" })), h("mg-button", { slot: "append-input", label: messages.general.validate, "is-icon": true, variant: "secondary", onClick: this.handleValidateEditButton, identifier: `${this.identifier}-edition-button-validate` }, h("mg-icon", { icon: "check" }))),
2934
- ];
2935
- }
2936
- return collapseButton();
2937
- };
2938
- }
2939
- handelTileChange(newValue) {
2940
- this.titleChange.emit(newValue);
2941
- }
2942
- validatetitlePattern(newValue) {
2943
- if (newValue && !this.titleEditable) {
2944
- throw new Error('<mg-panel> prop "titleEditable" must be set to `true`.');
2945
- }
2946
- if (newValue && this.titlePatternErrorMessage === undefined) {
2947
- throw new Error('<mg-panel> prop "titlePattern" must be paired with the prop "titlePatternErrorMessage".');
2948
- }
2949
- }
2950
- handleExpanded(newValue) {
2951
- this.expandedChange.emit(newValue);
2952
- }
2953
- /*************
2954
- * Lifecycle *
2955
- *************/
2956
- /**
2957
- * Check if props are well configured on init
2958
- *
2959
- * @returns {void}
2960
- */
2961
- componentWillLoad() {
2962
- this.validatetitlePattern(this.titlePattern);
2963
- }
2964
- /**
2965
- * Edit DOM after render
2966
- *
2967
- * @returns {void}
2968
- */
2969
- componentDidRender() {
2970
- // when we are editing we get focus on edition input
2971
- if (this.isEditing) {
2972
- this.editInputElement.setFocus();
2973
- }
2974
- }
2975
- /**
2976
- * Render component
2977
- *
2978
- * @returns {HTMLElement} html element
2979
- */
2980
- render() {
2981
- return (h("section", { class: this.classList.join(), id: this.identifier }, h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), h("div", { class: "mg-panel__header-right" }, h("slot", { name: "header-right" }))), h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, h("slot", null))));
2982
- }
2983
- static get watchers() { return {
2984
- "panelTitle": ["handelTileChange"],
2985
- "titlePattern": ["validatetitlePattern"],
2986
- "expanded": ["handleExpanded"]
2987
- }; }
2988
- };
2989
- MgPanel.style = mgPanelCss;
2990
-
2991
- /**
2992
- * List of all possibles sizes
2993
- */
2994
- const sizes = ['regular', 'large'];
2995
-
2996
- const mgTabsCss = ".mg-tabs.mg-tabs--size-regular.sc-mg-tabs .mg-tabs__navigation-button.sc-mg-tabs{padding:calc(1rem + 0.3rem) calc(1rem * 1.3) 1rem}.mg-tabs.mg-tabs--size-large.sc-mg-tabs .mg-tabs__navigation-button.sc-mg-tabs{padding:calc(1.8rem + 0.3rem) calc(1.8rem * 1.3) 1.8rem}.mg-tabs__header.sc-mg-tabs{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap}.mg-tabs__navigation-button.sc-mg-tabs{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-webkit-column-gap:0.5rem;-moz-column-gap:0.5rem;column-gap:0.5rem;background:none;border:none;border-bottom:0.3rem solid transparent;color:hsl(var(--color-dark));line-height:var(--line-height);cursor:pointer}.mg-tabs__navigation-button.sc-mg-tabs:disabled,.mg-tabs__navigation-button--disabled.sc-mg-tabs{cursor:default;opacity:30%}.mg-tabs__navigation-button.sc-mg-tabs:hover:not(:disabled),.mg-tabs__navigation-button.sc-mg-tabs:focus:not(:disabled){background-color:hsla(var(--color-info-h), var(--color-info-s), var(--color-info-l), 10%)}.mg-tabs__navigation-button.mg-tabs__navigation-button--active.sc-mg-tabs{color:hsl(var(--color-info));border-bottom-color:hsl(var(--color-info));font-weight:700}.mg-tabs__content-container.sc-mg-tabs:focus-visible{outline:none}";
2997
-
2998
- /**
2999
- * type TabItem validation function
3000
- *
3001
- * @param {TabItem} tab tab item
3002
- * @returns {boolean} tab item type is valid
3003
- */
3004
- const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
3005
- const MgTabs = class {
3006
- constructor(hostRef) {
3007
- registerInstance(this, hostRef);
3008
- this.activeTabChange = createEvent(this, "active-tab-change", 7);
3009
- /**
3010
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
3011
- * If not set, it will be created.
3012
- */
3013
- this.identifier = createID('mg-tabs');
3014
- /**
3015
- * Define tabs size
3016
- */
3017
- this.size = 'regular';
3018
- /**
3019
- * Active tab number
3020
- * default: first is 1
3021
- */
3022
- this.activeTab = 1;
3023
- /**
3024
- * Component tabs
3025
- */
3026
- this.tabs = [];
3027
- /**
3028
- * Component classes
3029
- */
3030
- this.classList = new ClassList(['mg-tabs']);
3031
- /**
3032
- * Handle click events on tabs
3033
- *
3034
- * @param {MouseEvent} event mouse event
3035
- */
3036
- this.handleClick = (event) => {
3037
- const tabId = event.currentTarget.getAttribute('data-index');
3038
- this.activeTab = Number(tabId);
3039
- };
3040
- /**
3041
- * Handle keyboard event on tabs
3042
- *
3043
- * @param {MouseEvent} event mouse event
3044
- * @returns {void}
3045
- */
3046
- this.handleKeydown = (event) => {
3047
- let tabId = Number(event.target.getAttribute('data-index'));
3048
- const parent = event.target.parentElement;
3049
- // change selected id from key code
3050
- // /* IE FIX */ delete 'Right'
3051
- if (['ArrowRight', 'Right'].includes(event.key)) {
3052
- tabId++;
3053
- // /* IE FIX */ delete 'Left'
3054
- }
3055
- else if (['ArrowLeft', 'Left'].includes(event.key)) {
3056
- tabId--;
3057
- }
3058
- // get selected tab
3059
- const selectedTab = parent.querySelector(`[data-index="${tabId}"]`);
3060
- // apply selected tab if exist
3061
- if (selectedTab !== null) {
3062
- selectedTab.focus();
3063
- this.activeTab = tabId;
3064
- }
3065
- };
3066
- /**
3067
- * Validate slots setting
3068
- */
3069
- this.validateSlots = () => {
3070
- const slots = Array.from(this.element.children).filter(slot => { var _a; return (_a = slot.getAttribute('slot')) === null || _a === void 0 ? void 0 : _a.includes('tab_content-'); });
3071
- if (slots.length !== this.tabs.length) {
3072
- throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
3073
- }
3074
- };
3075
- }
3076
- validateSize(newValue) {
3077
- if (!sizes.includes(newValue)) {
3078
- throw new Error(`<mg-tabs> prop "size" must be one of : ${sizes.join(', ')}`);
3079
- }
3080
- this.classList.add(`mg-tabs--size-${this.size}`);
3081
- }
3082
- validateItems(newValue) {
3083
- // String array
3084
- if (allItemsAreString(newValue)) {
3085
- this.tabs = newValue.map(item => ({ label: item, disabled: false }));
3086
- }
3087
- // Object array
3088
- else if (newValue && newValue.every(item => isTabItem(item))) {
3089
- this.tabs = newValue;
3090
- }
3091
- else {
3092
- throw new Error('<mg-tabs> prop "items" is required and all items must be the same type: TabItem.');
3093
- }
3094
- }
3095
- validateActiveTab(newValue) {
3096
- if (newValue < 1 || newValue > this.tabs.length) {
3097
- throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
3098
- }
3099
- else {
3100
- this.activeTabChange.emit(newValue);
3101
- }
3102
- }
3103
- /*************
3104
- * Lifecycle *
3105
- *************/
3106
- /**
3107
- * Check if component props are well configured on init
3108
- *
3109
- * @returns {void}
3110
- */
3111
- componentWillLoad() {
3112
- // Check tabs format
3113
- this.validateItems(this.items);
3114
- this.validateActiveTab(this.activeTab);
3115
- this.validateSize(this.size);
3116
- this.validateSlots();
3117
- }
3118
- /**
3119
- * Render
3120
- *
3121
- * @returns {HTMLElement} HTML Element
3122
- */
3123
- render() {
3124
- return (h(Host, null, h("div", { class: this.classList.join() }, h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => {
3125
- const tabIndex = index + 1;
3126
- return (h("button", { role: "tab", id: `${this.identifier}-${tabIndex}`, class: {
3127
- 'mg-tabs__navigation-button': true,
3128
- 'mg-tabs__navigation-button--active': tabIndex === this.activeTab,
3129
- 'mg-tabs__navigation-button--disabled': tab.disabled,
3130
- }, tabindex: tabIndex === this.activeTab ? 0 : -1, "aria-selected": (tabIndex === this.activeTab).toString(), "aria-controls": `pannel-${tabIndex}`, onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": tabIndex, disabled: tab.disabled }, tab.icon !== undefined && h("mg-icon", { icon: tab.icon }), tab.label, tab.badge !== undefined && h("mg-badge", { variant: "info", value: tab.badge.value, label: tab.badge.label })));
3131
- })), this.tabs.map((_tab, index) => {
3132
- const tabIndex = index + 1;
3133
- return (h("article", { role: "tabpanel", id: `pannel-${tabIndex}`, hidden: tabIndex !== this.activeTab, "aria-labelledby": `${this.identifier}-${this.activeTab}`, tabindex: tabIndex === this.activeTab ? 0 : -1, class: "mg-tabs__content-container" }, h("slot", { name: `tab_content-${tabIndex}` })));
3134
- }))));
3135
- }
3136
- get element() { return getElement(this); }
3137
- static get watchers() { return {
3138
- "size": ["validateSize"],
3139
- "items": ["validateItems"],
3140
- "activeTab": ["validateActiveTab"]
3141
- }; }
3142
- };
3143
- MgTabs.style = mgTabsCss;
3144
-
3145
- /**
3146
- * List of all possibles variants
3147
- */
3148
- const variants = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'];
3149
-
3150
- const mgTagCss = ".mg-tag{padding:calc((var(--mg-tag-height) - 0.2rem - var(--mg-tag-font-size) * var(--line-height)) / 2) 0.6rem;min-height:var(--mg-tag-height);-webkit-box-sizing:border-box;box-sizing:border-box;border-radius:var(--mg-tag-border-radius);border:0.1rem solid;font-size:var(--mg-tag-font-size);font-weight:600;text-align:center}.mg-tag.mg-tag--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-tag.mg-tag--primary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-tag.mg-tag--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-tag.mg-tag--success.mg-tag--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-tag.mg-tag--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-tag.mg-tag--warning.mg-tag--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-tag.mg-tag--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-tag.mg-tag--danger.mg-tag--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-tag.mg-tag--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-tag.mg-tag--info.mg-tag--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-tag,mg-tag{display:inline-block;vertical-align:middle}";
3151
-
3152
- const MgTag = class {
3153
- constructor(hostRef) {
3154
- registerInstance(this, hostRef);
3155
- /**
3156
- * Define button variant
3157
- */
3158
- this.variant = variants[0]; // info
3159
- /**
3160
- * Component classes
3161
- */
3162
- this.classList = new ClassList(['mg-tag']);
3163
- }
3164
- validateVariant(newValue) {
3165
- if (!variants.includes(newValue)) {
3166
- throw new Error(`<mg-tag> prop "variant" must be one of : ${variants.join(', ')}.`);
3167
- }
3168
- this.classList.add(`mg-tag--${this.variant}`);
3169
- }
3170
- validateOutline(newValue) {
3171
- if (newValue)
3172
- this.classList.add(`mg-tag--outline`);
3173
- }
3174
- /*************
3175
- * Lifecycle *
3176
- *************/
3177
- /**
3178
- * Check if props are well configured on init
3179
- *
3180
- * @returns {void}
3181
- */
3182
- componentWillLoad() {
3183
- this.validateVariant(this.variant);
3184
- this.validateOutline(this.outline);
3185
- }
3186
- /**
3187
- * Render
3188
- *
3189
- * @returns {HTMLElement} HTML Element
3190
- */
3191
- render() {
3192
- return (h("span", { class: this.classList.join() }, h("slot", null)));
3193
- }
3194
- static get watchers() { return {
3195
- "variant": ["validateVariant"],
3196
- "outline": ["validateOutline"]
3197
- }; }
3198
- };
3199
- MgTag.style = mgTagCss;
3200
-
3201
- const mgTooltipCss = ".sc-mg-tooltip-h{display:inline-block}.mg-tooltip.sc-mg-tooltip{display:none;padding:0.5rem 0.8rem;z-index:9999;border-radius:var(--mg-tooltip-border-radius);background-color:hsl(var(--mg-tooltip-background-color));color:hsl(var(--mg-tooltip-font-color));text-align:start}.mg-tooltip[data-show].sc-mg-tooltip{display:block}.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip,.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip::before{position:absolute;width:0.8rem;height:0.8rem;z-index:9999;background:inherit}.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip{visibility:hidden}.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip::before{visibility:visible;content:\"\";-webkit-transform:rotate(45deg);transform:rotate(45deg)}.mg-tooltip[data-popper-placement^=top].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{bottom:-4px}.mg-tooltip[data-popper-placement^=bottom].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{top:-4px}.mg-tooltip[data-popper-placement^=left].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{right:-4px}.mg-tooltip[data-popper-placement^=right].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{left:-4px}";
3202
-
3203
- const MgTooltip = class {
3204
- constructor(hostRef) {
3205
- registerInstance(this, hostRef);
3206
- /**
3207
- * Sets an `id` attribute.
3208
- * Needed by the input for accessibility `aria-decribedby`.
3209
- */
3210
- this.identifier = createID('mg-tooltip');
3211
- /**
3212
- * Tooltip placement
3213
- */
3214
- this.placement = 'bottom';
3215
- /**
3216
- * Display tooltip
3217
- */
3218
- this.display = false;
3219
- /**
3220
- * Disable tooltip
3221
- */
3222
- this.disabled = false;
3223
- /**
3224
- * Show tooltip
3225
- *
3226
- * @returns {void}
3227
- */
3228
- this.show = () => {
3229
- // Make the tooltip visible
3230
- this.tooltip.setAttribute('data-show', '');
3231
- // Enable the event listeners
3232
- this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
3233
- // Update its position
3234
- this.popper.update();
3235
- };
3236
- /**
3237
- * Hide tooltip
3238
- *
3239
- * @returns {void}
3240
- */
3241
- this.hide = () => {
3242
- // Hide the tooltip
3243
- this.tooltip.removeAttribute('data-show');
3244
- // Disable the event listeners
3245
- this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
3246
- };
3247
- }
3248
- handleDisplay(newVal) {
3249
- if (newVal) {
3250
- this.show();
3251
- }
3252
- else {
3253
- this.hide();
3254
- }
3255
- }
3256
- /*************
3257
- * Lifecycle *
3258
- *************/
3259
- /**
3260
- * Get slotted element
3261
- * Check if it already contain an interactive element, if not we need to add a tabIndex attribute
3262
- * We need to attach the focused element to the tooltip (aria-describedby)
3263
- *
3264
- * @returns {void}
3265
- */
3266
- componentDidLoad() {
3267
- var _a;
3268
- // Get tooltip element
3269
- this.tooltip = this.element.querySelector(`#${this.identifier}`);
3270
- // get slotted element
3271
- const slotElement = this.element.firstElementChild;
3272
- // Get interactive element
3273
- const interactiveElements = ['a', 'button', 'input', 'textarea', 'select']; //! Might needs updates
3274
- const interactiveElement = this.element.querySelector(interactiveElements.join(',')) || ((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
3275
- // define selected element to become tooltip selector
3276
- const tooltipedElement = interactiveElement || slotElement;
3277
- // Add tabindex to slotted element if we can't find any interactive element
3278
- if (interactiveElement === null || interactiveElement === undefined)
3279
- slotElement.tabIndex = 0;
3280
- // Set aria-describedby
3281
- const ariaDescribedby = slotElement.getAttribute('aria-describedby');
3282
- if (ariaDescribedby === null) {
3283
- tooltipedElement.setAttribute('aria-describedby', this.identifier);
3284
- }
3285
- else {
3286
- slotElement.setAttribute('aria-describedby', `${ariaDescribedby} ${this.identifier}`);
3287
- }
3288
- // Create popperjs tooltip
3289
- this.popper = createPopper(tooltipedElement, this.tooltip, {
3290
- placement: this.placement,
3291
- modifiers: [
3292
- {
3293
- name: 'offset',
3294
- options: {
3295
- offset: [0, 8],
3296
- },
3297
- },
3298
- ],
3299
- });
3300
- // Add events
3301
- ['mouseenter', 'focus'].forEach(event => {
3302
- tooltipedElement.addEventListener(event, () => {
3303
- if (!this.disabled)
3304
- this.display = true;
3305
- });
3306
- });
3307
- ['mouseleave', 'blur', 'keydown'].forEach(event => {
3308
- tooltipedElement.addEventListener(event, (e) => {
3309
- // we continue to process ONLY for KeyboardEvents 'Escape'
3310
- if (e.type === 'keydown' && e.code !== 'Escape') {
3311
- return;
3312
- }
3313
- if (!this.disabled)
3314
- this.display = false;
3315
- });
3316
- });
3317
- this.handleDisplay(this.display);
3318
- }
3319
- /**
3320
- * Render
3321
- *
3322
- * @returns {HTMLElement} HTML Element
3323
- */
3324
- render() {
3325
- return (h(Host, null, h("slot", null), h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip", innerHTML: this.message }, h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
3326
- }
3327
- get element() { return getElement(this); }
3328
- static get watchers() { return {
3329
- "display": ["handleDisplay"]
3330
- }; }
3331
- };
3332
- MgTooltip.style = mgTooltipCss;
3333
-
3334
- export { MgBadge as mg_badge, MgButton as mg_button, MgCharacterLeft as mg_character_left, MgForm as mg_form, MgIcon as mg_icon, MgInputCheckbox as mg_input_checkbox, MgInputDate as mg_input_date, MgInputNumeric as mg_input_numeric, MgInputPassword as mg_input_password, MgInputRadio as mg_input_radio, MgInputSelect as mg_input_select, MgInputText as mg_input_text, MgInputTextarea as mg_input_textarea, MgInputTitle as mg_input_title, MgInputToggle as mg_input_toggle, MgMessage as mg_message, MgPagination as mg_pagination, MgPanel as mg_panel, MgTabs as mg_tabs, MgTag as mg_tag, MgTooltip as mg_tooltip };