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