@mgdis/mg-components 3.1.0 → 4.0.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 (241) hide show
  1. package/dist/cjs/{index-85a4a0b6.js → index-88560a66.js} +123 -48
  2. package/dist/cjs/index-a39c5567.js +233 -0
  3. package/dist/cjs/loader.cjs.js +3 -17
  4. package/dist/cjs/mg-badge_21.cjs.entry.js +3538 -0
  5. package/dist/cjs/mg-components.cjs.js +3 -7
  6. package/dist/cjs/mg-modal.cjs.entry.js +117 -0
  7. package/dist/cjs/mg-popover.cjs.entry.js +170 -0
  8. package/dist/cjs/popper-71bf3058.js +1790 -0
  9. package/dist/collection/collection-manifest.json +4 -1
  10. package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.js} +4 -1
  11. package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
  12. package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -2
  13. package/dist/collection/components/atoms/mg-badge/mg-badge.js +26 -10
  14. package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +7 -2
  15. package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
  16. package/dist/collection/components/atoms/mg-button/mg-button.css +46 -49
  17. package/dist/collection/components/atoms/mg-button/mg-button.js +78 -4
  18. package/dist/collection/components/atoms/mg-character-left/{mg-character-left.stories.js → doc/mg-character-left.stories.js} +8 -0
  19. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +20 -46
  20. package/dist/collection/components/atoms/mg-icon/{mg-icon.stories.js → doc/mg-icon.stories.js} +1 -1
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +104 -9
  22. package/dist/collection/components/atoms/mg-icon/mg-icon.css +9 -7
  23. package/dist/collection/components/atoms/mg-icon/mg-icon.js +33 -7
  24. package/dist/collection/components/atoms/mg-input-title/{mg-input-title.stories.js → doc/mg-input-title.stories.js} +0 -0
  25. package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +4 -4
  26. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +14 -3
  27. package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +4 -1
  28. package/dist/collection/components/atoms/mg-tag/mg-tag.js +28 -6
  29. package/dist/collection/components/atoms/mg-tooltip/{mg-tooltip.stories.js → doc/mg-tooltip.stories.js} +14 -1
  30. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +20 -0
  31. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +16 -2
  32. package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
  33. package/dist/collection/components/molecules/inputs/MgInput.js +25 -29
  34. package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +6 -1
  35. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +25 -11
  36. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +102 -52
  37. package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +6 -1
  38. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +37 -9
  39. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +136 -66
  40. package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +15 -3
  41. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +38 -10
  42. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +180 -80
  43. package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +16 -2
  44. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +37 -9
  45. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +108 -47
  46. package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +6 -1
  47. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +25 -11
  48. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +113 -42
  49. package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +22 -2
  50. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +39 -10
  51. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +145 -71
  52. package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +17 -8
  53. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +69 -19
  54. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +184 -83
  55. package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +16 -5
  56. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +69 -13
  57. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +163 -70
  58. package/dist/collection/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.js → doc/mg-input-toggle.stories.js} +6 -1
  59. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +22 -10
  60. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +68 -33
  61. package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +58 -0
  62. package/dist/collection/components/molecules/mg-form/mg-form.css +19 -0
  63. package/dist/collection/components/molecules/mg-form/mg-form.js +271 -0
  64. package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +6 -2
  65. package/dist/collection/components/molecules/mg-message/mg-message.css +1 -1
  66. package/dist/collection/components/molecules/mg-message/mg-message.js +26 -11
  67. package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +51 -0
  68. package/dist/collection/components/molecules/mg-modal/mg-modal.css +52 -0
  69. package/dist/collection/components/molecules/mg-modal/mg-modal.js +240 -0
  70. package/dist/collection/components/molecules/mg-pagination/{mg-pagination.stories.js → doc/mg-pagination.stories.js} +1 -0
  71. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +47 -28
  72. package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +39 -0
  73. package/dist/collection/components/molecules/mg-panel/mg-panel.css +53 -0
  74. package/dist/collection/components/molecules/mg-panel/mg-panel.js +356 -0
  75. package/dist/collection/components/molecules/mg-popover/{mg-popover.stories.js → doc/mg-popover.stories.js} +10 -0
  76. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +20 -0
  77. package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -2
  78. package/dist/collection/components/molecules/mg-popover/mg-popover.js +37 -12
  79. package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +20 -4
  80. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +11 -1
  81. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +17 -3
  82. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +139 -26
  83. package/dist/collection/locales/index.js +33 -4
  84. package/dist/collection/stories/helpers.stories.js +33 -0
  85. package/dist/collection/utils/components.utils.js +16 -9
  86. package/dist/collection/utils/locale.utils.js +13 -7
  87. package/dist/collection/utils/test.utils.js +27 -15
  88. package/dist/collection/variables.css +39 -5
  89. package/dist/collection/variables.scss +39 -5
  90. package/dist/components/MgInput.js +26 -37
  91. package/dist/components/components.utils.js +16 -9
  92. package/dist/components/index.d.ts +24 -6
  93. package/dist/components/index.js +23 -0
  94. package/dist/components/index2.js +116 -17
  95. package/dist/components/locale.utils.js +13 -8
  96. package/dist/components/mg-badge2.js +25 -9
  97. package/dist/components/mg-button2.js +29 -5
  98. package/dist/components/mg-character-left2.js +14 -26
  99. package/dist/components/mg-form.d.ts +11 -0
  100. package/dist/components/mg-form.js +148 -0
  101. package/dist/components/mg-icon2.js +138 -17
  102. package/dist/components/mg-input-checkbox.js +66 -53
  103. package/dist/components/mg-input-date.js +100 -69
  104. package/dist/components/mg-input-numeric.js +125 -81
  105. package/dist/components/mg-input-password.js +69 -48
  106. package/dist/components/mg-input-radio.js +74 -46
  107. package/dist/components/mg-input-select2.js +103 -71
  108. package/dist/components/mg-input-text.js +1 -237
  109. package/dist/components/mg-input-text2.js +300 -0
  110. package/dist/components/mg-input-textarea.js +100 -46
  111. package/dist/components/mg-input-title2.js +13 -4
  112. package/dist/components/mg-input-toggle.js +39 -31
  113. package/dist/components/mg-message.js +25 -10
  114. package/dist/components/mg-modal.d.ts +11 -0
  115. package/dist/components/mg-modal.js +153 -0
  116. package/dist/components/mg-pagination.js +45 -31
  117. package/dist/components/mg-panel.d.ts +11 -0
  118. package/dist/components/mg-panel.js +244 -0
  119. package/dist/components/mg-popover.js +31 -11
  120. package/dist/components/mg-tabs.js +113 -23
  121. package/dist/components/mg-tag.js +27 -5
  122. package/dist/components/mg-tooltip2.js +10 -1
  123. package/dist/components/popper.js +6 -2
  124. package/dist/esm/{index-e3e84606.js → index-bca81100.js} +124 -46
  125. package/dist/esm/index-e51ae032.js +228 -0
  126. package/dist/esm/loader.js +3 -17
  127. package/dist/esm/mg-badge_21.entry.js +3514 -0
  128. package/dist/esm/mg-components.js +3 -7
  129. package/dist/esm/mg-modal.entry.js +113 -0
  130. package/dist/esm/mg-popover.entry.js +166 -0
  131. package/dist/esm/polyfills/css-shim.js +1 -1
  132. package/dist/esm/popper-93ecb064.js +1788 -0
  133. package/dist/index.js +1 -1
  134. package/dist/mg-components/mg-components.css +1 -1
  135. package/dist/mg-components/mg-components.esm.js +1 -1
  136. package/dist/mg-components/p-003a1344.entry.js +1 -0
  137. package/dist/mg-components/p-462d648a.entry.js +1 -0
  138. package/dist/mg-components/p-4c66f794.js +1 -0
  139. package/dist/mg-components/p-5126ab10.entry.js +1 -0
  140. package/dist/mg-components/p-780bd52d.js +1 -0
  141. package/dist/mg-components/p-b14a3443.js +2 -0
  142. package/dist/mg-components/variables.css +39 -5
  143. package/dist/mg-components/variables.scss +39 -5
  144. package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +5 -0
  145. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +16 -5
  146. package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +5 -0
  147. package/dist/types/components/atoms/mg-button/mg-button.d.ts +23 -3
  148. package/dist/types/components/atoms/mg-character-left/{mg-character-left.stories.d.ts → doc/mg-character-left.stories.d.ts} +9 -0
  149. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +16 -13
  150. package/dist/types/components/atoms/mg-icon/{mg-icon.stories.d.ts → doc/mg-icon.stories.d.ts} +0 -0
  151. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +1 -1
  152. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +14 -4
  153. package/dist/types/components/atoms/mg-input-title/{mg-input-title.stories.d.ts → doc/mg-input-title.stories.d.ts} +0 -0
  154. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +11 -1
  155. package/dist/types/components/atoms/mg-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +5 -0
  156. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +18 -4
  157. package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +29 -0
  158. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +8 -0
  159. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +13 -3
  160. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +6 -4
  161. package/dist/types/components/molecules/inputs/MgInput.d.ts +7 -8
  162. package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +5 -0
  163. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +36 -13
  164. package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +5 -0
  165. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +46 -15
  166. package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +11 -0
  167. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +61 -16
  168. package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +22 -0
  169. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +35 -11
  170. package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.stories.d.ts} +5 -0
  171. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
  172. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +42 -9
  173. package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +34 -0
  174. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +1 -1
  175. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +37 -9
  176. package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +13 -0
  177. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +52 -16
  178. package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +19 -0
  179. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +45 -17
  180. package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.stories.d.ts} +5 -0
  181. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
  182. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +29 -12
  183. package/dist/types/components/molecules/{mg-popover/mg-popover.stories.d.ts → mg-form/doc/mg-form.stories.d.ts} +3 -4
  184. package/dist/types/components/molecules/mg-form/mg-form.d.ts +83 -0
  185. package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +10 -0
  186. package/dist/types/components/molecules/mg-message/mg-message.d.ts +13 -4
  187. package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +13 -0
  188. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +85 -0
  189. package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +5 -0
  190. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +31 -7
  191. package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +11 -0
  192. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +139 -0
  193. package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +25 -0
  194. package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +8 -0
  195. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +27 -4
  196. package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +20 -0
  197. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +11 -0
  198. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +70 -6
  199. package/dist/types/components.d.ts +528 -211
  200. package/dist/types/locales/index.d.ts +108 -38
  201. package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
  202. package/dist/types/utils/components.utils.d.ts +16 -9
  203. package/dist/types/utils/locale.utils.d.ts +13 -6
  204. package/dist/types/utils/test.utils.d.ts +13 -1
  205. package/loader/index.js +1 -1
  206. package/package.json +45 -14
  207. package/readme.md +9 -35
  208. package/dist/cjs/css-shim-a22512c4.js +0 -6
  209. package/dist/cjs/mg-badge_20.cjs.entry.js +0 -4661
  210. package/dist/cjs/shadow-css-8940f82d.js +0 -390
  211. package/dist/collection/stories/buttons.stories.js +0 -43
  212. package/dist/collection/stories/messages.stories.js +0 -44
  213. package/dist/collection/stories/tags.stories.js +0 -13
  214. package/dist/esm/css-shim-7c240feb.js +0 -4
  215. package/dist/esm/mg-badge_20.entry.js +0 -4638
  216. package/dist/esm/shadow-css-5d2d01ce.js +0 -388
  217. package/dist/esm-es5/css-shim-7c240feb.js +0 -1
  218. package/dist/esm-es5/index-e3e84606.js +0 -1
  219. package/dist/esm-es5/index.js +0 -0
  220. package/dist/esm-es5/loader.js +0 -1
  221. package/dist/esm-es5/mg-badge_20.entry.js +0 -2
  222. package/dist/esm-es5/mg-components.js +0 -1
  223. package/dist/esm-es5/shadow-css-5d2d01ce.js +0 -12
  224. package/dist/mg-components/mg-components.js +0 -132
  225. package/dist/mg-components/p-1cd24462.system.js +0 -1
  226. package/dist/mg-components/p-2e2f6b27.system.entry.js +0 -2
  227. package/dist/mg-components/p-366a224e.js +0 -1
  228. package/dist/mg-components/p-422c429b.system.js +0 -1
  229. package/dist/mg-components/p-50ea2036.system.js +0 -1
  230. package/dist/mg-components/p-62fa3797.js +0 -1
  231. package/dist/mg-components/p-71d57b8b.system.js +0 -13
  232. package/dist/mg-components/p-9a215712.system.js +0 -1
  233. package/dist/mg-components/p-cbf0464b.entry.js +0 -1
  234. package/dist/mg-components/p-f6455ab3.js +0 -12
  235. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
  236. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +0 -9
  237. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +0 -14
  238. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +0 -6
  239. package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +0 -7
  240. package/dist/types/stories/messages.stories.d.ts +0 -13
  241. package/dist/types/stories/tags.stories.d.ts +0 -5
@@ -1,9 +1,8 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { I as InputClass, M as MgInput } from './MgInput.js';
2
+ import { M as MgInput } from './MgInput.js';
3
3
  import { c as createID, C as ClassList } from './components.utils.js';
4
- import { d as dateRegExp, l as localeDate } from './locale.utils.js';
5
- import { m as messages } from './index2.js';
6
- import { d as defineCustomElement$5 } from './mg-character-left2.js';
4
+ import { l as localeDate, d as dateRegExp } from './locale.utils.js';
5
+ import { i as initLocales } from './index2.js';
7
6
  import { d as defineCustomElement$4 } from './mg-icon2.js';
8
7
  import { d as defineCustomElement$3 } from './mg-input-title2.js';
9
8
  import { d as defineCustomElement$2 } from './mg-tooltip2.js';
@@ -16,7 +15,7 @@ var InputError;
16
15
  InputError["REQUIRED"] = "required";
17
16
  })(InputError || (InputError = {}));
18
17
 
19
- 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%;}.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);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--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}";
18
+ const mgInputDateCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem 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-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.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}";
20
19
 
21
20
  const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
22
21
  constructor() {
@@ -24,11 +23,9 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
24
23
  this.__registerHost();
25
24
  this.__attachShadow();
26
25
  this.valueChange = createEvent(this, "value-change", 7);
27
- /************
28
- * Internal *
29
- ************/
30
- // classes
31
- this.classError = InputClass.ERROR;
26
+ this.inputValid = createEvent(this, "input-valid", 7);
27
+ // hasError (triggered by blur event)
28
+ this.hasError = false;
32
29
  /**
33
30
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
34
31
  * If not set, it will be created.
@@ -64,19 +61,34 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
64
61
  */
65
62
  this.handleInput = () => {
66
63
  this.checkValidity();
64
+ if (this.hasError) {
65
+ this.checkError();
66
+ }
67
67
  this.value = this.input.value;
68
- this.valueChange.emit(this.value);
69
68
  };
70
69
  /**
71
70
  * Handle blur event
72
71
  */
73
72
  this.handleBlur = () => {
74
- this.checkValidity();
75
- this.checkError();
73
+ this.displayError();
74
+ };
75
+ /**
76
+ * Check if input is valid
77
+ */
78
+ this.checkValidity = () => {
79
+ if (!this.readonly && this.input !== undefined) {
80
+ const validity = this.input.checkValidity();
81
+ // Set validity
82
+ this.valid = validity;
83
+ this.invalid = !validity;
84
+ //Send event
85
+ this.inputValid.emit(validity);
86
+ }
76
87
  };
77
88
  /**
78
89
  * get input error code
79
- * @returns {null | InputError}
90
+ *
91
+ * @returns {null | InputError} error code
80
92
  */
81
93
  this.getInputError = () => {
82
94
  var _a, _b;
@@ -99,11 +111,48 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
99
111
  }
100
112
  return inputError;
101
113
  };
114
+ /**
115
+ * Set error message
116
+ *
117
+ * @returns {void}
118
+ */
119
+ this.setErrorMessage = () => {
120
+ var _a;
121
+ const inputError = this.getInputError();
122
+ // required
123
+ if (inputError === InputError.REQUIRED) {
124
+ this.errorMessage = this.messages.errors[inputError];
125
+ }
126
+ // min, max & minMax
127
+ else if ([InputError.MIN, InputError.MAX, InputError.MINMAX].includes(inputError)) {
128
+ this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));
129
+ }
130
+ // wrong date format
131
+ // element.validity.badInput is default error message
132
+ else {
133
+ this.errorMessage = this.messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min, this.locale) : localeDate('1900-01-01', this.locale));
134
+ }
135
+ };
136
+ /**
137
+ * Check input errors
138
+ *
139
+ * @returns {void}
140
+ */
141
+ this.checkError = () => {
142
+ // Set error message
143
+ this.errorMessage = undefined;
144
+ if (!this.valid) {
145
+ this.setErrorMessage();
146
+ }
147
+ };
102
148
  }
103
149
  validateValue(newValue) {
104
150
  if (newValue !== undefined && newValue !== '' && !(typeof newValue === 'string' && dateRegExp.test(newValue))) {
105
151
  throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
106
152
  }
153
+ else {
154
+ this.valueChange.emit(this.value);
155
+ }
107
156
  }
108
157
  validateMin(newValue) {
109
158
  this.validateDateFormat(newValue);
@@ -111,74 +160,60 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
111
160
  validateMax(newValue) {
112
161
  this.validateDateFormat(newValue);
113
162
  }
163
+ /**
164
+ * Public method to display errors
165
+ *
166
+ * @returns {Promise<void>}
167
+ */
168
+ async displayError() {
169
+ this.checkValidity();
170
+ this.checkError();
171
+ this.hasError = this.invalid;
172
+ }
114
173
  /**
115
174
  * Date format validation
116
- * @param date
175
+ *
176
+ * @param {string} date date to validate
177
+ * @returns {void}
117
178
  */
118
179
  validateDateFormat(date) {
119
180
  if ((date === null || date === void 0 ? void 0 : date.length) > 0 && !(typeof date === 'string' && dateRegExp.test(date))) {
120
181
  throw new Error("<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd");
121
182
  }
122
183
  }
123
- /**
124
- * Check if input is valid
125
- */
126
- checkValidity() {
127
- if (!this.readonly && this.input !== undefined) {
128
- const validity = this.input.checkValidity();
129
- // Set validity
130
- this.valid = validity;
131
- this.invalid = !validity;
132
- }
133
- }
134
- /**
135
- * Set error message
136
- */
137
- setErrorMessage() {
138
- var _a;
139
- const inputError = this.getInputError();
140
- // required
141
- if (inputError === InputError.REQUIRED) {
142
- this.errorMessage = messages.errors[inputError];
143
- }
144
- // min, max & minMax
145
- else if ([InputError.MIN, InputError.MAX, InputError.MINMAX].includes(inputError)) {
146
- this.errorMessage = messages.errors.date[inputError].replace('{min}', localeDate(this.min)).replace('{max}', localeDate(this.max));
147
- }
148
- // wrong date format
149
- // element.validity.badInput is default error message
150
- else {
151
- this.errorMessage = messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min) : localeDate('1900-01-01'));
152
- }
153
- }
154
- /**
155
- * Check input errors
156
- */
157
- checkError() {
158
- // Set error message
159
- this.errorMessage = undefined;
160
- if (!this.valid) {
161
- this.setErrorMessage();
162
- this.classList.add(this.classError);
163
- }
164
- else {
165
- this.classList.delete(this.classError);
166
- }
167
- }
168
184
  /*************
169
185
  * Lifecycle *
170
186
  *************/
187
+ /**
188
+ * Check if component props are well configured on init
189
+ *
190
+ * @returns {ReturnType<typeof setTimeout>} timeout
191
+ */
171
192
  componentWillLoad() {
193
+ // Get locales
194
+ const locales = initLocales(this.element);
195
+ this.locale = locales.locale;
196
+ this.messages = locales.messages;
197
+ // Validate
172
198
  this.validateValue(this.value);
173
199
  this.validateMin(this.min);
174
200
  this.validateMax(this.max);
201
+ // Check validity when component is ready
175
202
  // return a promise to process action only in the FIRST render().
176
203
  // https://stenciljs.com/docs/component-lifecycle#componentwillload
177
- return setTimeout(() => this.checkValidity(), 0);
204
+ return setTimeout(() => {
205
+ this.checkValidity();
206
+ }, 0);
178
207
  }
208
+ /**
209
+ * Render
210
+ *
211
+ * @returns {HTMLElement} HTML Element
212
+ */
179
213
  render() {
180
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value), tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el => (this.input = el) })));
214
+ return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el => (this.input = el) })));
181
215
  }
216
+ get element() { return this; }
182
217
  static get watchers() { return {
183
218
  "value": ["validateValue"],
184
219
  "min": ["validateMin"],
@@ -202,24 +237,20 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
202
237
  "min": [1],
203
238
  "max": [1],
204
239
  "classList": [32],
205
- "errorMessage": [32]
240
+ "errorMessage": [32],
241
+ "displayError": [64]
206
242
  }]);
207
243
  function defineCustomElement$1() {
208
244
  if (typeof customElements === "undefined") {
209
245
  return;
210
246
  }
211
- const components = ["mg-input-date", "mg-character-left", "mg-icon", "mg-input-title", "mg-tooltip"];
247
+ const components = ["mg-input-date", "mg-icon", "mg-input-title", "mg-tooltip"];
212
248
  components.forEach(tagName => { switch (tagName) {
213
249
  case "mg-input-date":
214
250
  if (!customElements.get(tagName)) {
215
251
  customElements.define(tagName, MgInputDate$1);
216
252
  }
217
253
  break;
218
- case "mg-character-left":
219
- if (!customElements.get(tagName)) {
220
- defineCustomElement$5();
221
- }
222
- break;
223
254
  case "mg-icon":
224
255
  if (!customElements.get(tagName)) {
225
256
  defineCustomElement$4();
@@ -1,9 +1,8 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { I as InputClass, M as MgInput } from './MgInput.js';
2
+ import { M as MgInput } from './MgInput.js';
3
3
  import { c as createID, C as ClassList } from './components.utils.js';
4
- import { m as messages } from './index2.js';
4
+ import { i as initLocales } from './index2.js';
5
5
  import { a as localeCurrency, b as localeNumber } from './locale.utils.js';
6
- import { d as defineCustomElement$5 } from './mg-character-left2.js';
7
6
  import { d as defineCustomElement$4 } from './mg-icon2.js';
8
7
  import { d as defineCustomElement$3 } from './mg-input-title2.js';
9
8
  import { d as defineCustomElement$2 } from './mg-tooltip2.js';
@@ -20,7 +19,7 @@ var InputError;
20
19
  InputError["REQUIRED"] = "required";
21
20
  })(InputError || (InputError = {}));
22
21
 
23
- 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%;}.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);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--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}";
22
+ const mgInputNumericCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem 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-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{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:var(--mg-inputs-text-align, right)}";
24
23
 
25
24
  const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
26
25
  constructor() {
@@ -28,8 +27,9 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
28
27
  this.__registerHost();
29
28
  this.__attachShadow();
30
29
  this.valueChange = createEvent(this, "value-change", 7);
31
- // Classes
32
- this.classError = InputClass.ERROR;
30
+ this.inputValid = createEvent(this, "input-valid", 7);
31
+ // hasError (triggered by blur event)
32
+ this.hasError = false;
33
33
  /**
34
34
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
35
35
  * If not set, it will be created.
@@ -60,6 +60,10 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
60
60
  * Define numeric type
61
61
  */
62
62
  this.type = types[0];
63
+ /**
64
+ * Define currency
65
+ */
66
+ this.currency = 'USD';
63
67
  /**
64
68
  * Override integer length
65
69
  * integer is the number before the decimal point
@@ -74,33 +78,87 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
74
78
  * Component classes
75
79
  */
76
80
  this.classList = new ClassList(['mg-input--numeric']);
81
+ /**
82
+ * Define if input has focus
83
+ */
84
+ this.hasFocus = false;
77
85
  /**
78
86
  * Handle input event
87
+ *
88
+ * @returns {void}
79
89
  */
80
90
  this.handleInput = () => {
81
91
  // Check validity
82
92
  this.checkValidity();
93
+ if (this.hasError) {
94
+ this.checkError();
95
+ }
83
96
  this.value = this.input.value;
84
97
  };
85
98
  /**
86
99
  * Handle focus event
100
+ *
101
+ * @returns {void}
87
102
  */
88
103
  this.handleFocus = () => {
89
- this.displayValue = this.value;
104
+ this.hasFocus = true;
90
105
  };
91
106
  /**
92
107
  * Handle blur event
108
+ *
109
+ * @returns {void}
93
110
  */
94
111
  this.handleBlur = () => {
95
- // Check validity
96
- this.checkValidity();
97
- this.checkError();
98
- // Display readonly value
99
- this.displayValue = this.readonlyValue;
112
+ // Display Error
113
+ this.displayError();
114
+ this.hasFocus = false;
100
115
  };
101
116
  /**
102
- * get input error code
103
- * @returns {null | InputError}
117
+ * Check if input is valid
118
+ *
119
+ * @returns {void}
120
+ */
121
+ this.checkValidity = () => {
122
+ if (!this.readonly) {
123
+ const validity = this.getInputError() === null;
124
+ // Set validity
125
+ this.valid = validity;
126
+ this.invalid = !validity;
127
+ //Send event
128
+ this.inputValid.emit(validity);
129
+ }
130
+ };
131
+ /**
132
+ * Set error message
133
+ *
134
+ * @returns {void}
135
+ */
136
+ this.setErrorMessage = () => {
137
+ const inputError = this.getInputError();
138
+ if (inputError === InputError.REQUIRED) {
139
+ this.errorMessage = this.messages.errors[inputError];
140
+ }
141
+ else {
142
+ this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
143
+ }
144
+ };
145
+ /**
146
+ * Check input errors
147
+ *
148
+ * @returns {void}
149
+ */
150
+ this.checkError = () => {
151
+ // Set error message
152
+ this.errorMessage = undefined;
153
+ // Update class
154
+ if (!this.valid) {
155
+ this.setErrorMessage();
156
+ }
157
+ };
158
+ /**
159
+ * Get input error code
160
+ *
161
+ * @returns {null | InputError} error code
104
162
  */
105
163
  this.getInputError = () => {
106
164
  let inputError = null;
@@ -111,7 +169,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
111
169
  inputError = InputError.REQUIRED;
112
170
  }
113
171
  // Min & Max
114
- if (this.min !== undefined && this.numericValue < this.min && this.max === undefined) {
172
+ else if (this.min !== undefined && this.numericValue < this.min && this.max === undefined) {
115
173
  // Only a min value is set
116
174
  inputError = InputError.MIN;
117
175
  }
@@ -127,10 +185,22 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
127
185
  };
128
186
  /**
129
187
  * Format value based on type
130
- * @param value {number}
188
+ *
189
+ * @param {number} value value to format
131
190
  * @returns {string} formated local value
132
191
  */
133
- this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value) : localeNumber(value));
192
+ this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));
193
+ /**
194
+ * Validate append slot
195
+ *
196
+ * @returns {void}
197
+ */
198
+ this.validateAppendSlot = () => {
199
+ const slotAppendInput = this.element.querySelector('[slot="append-input"]');
200
+ if (slotAppendInput !== null) {
201
+ this.classList.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
202
+ }
203
+ };
134
204
  }
135
205
  validateValue(newValue) {
136
206
  if (newValue !== undefined && newValue !== null) {
@@ -155,7 +225,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
155
225
  // emit numeric value
156
226
  this.numericValue = this.value !== '' && this.value !== null ? parseFloat(this.value.replace(',', '.')) : null;
157
227
  this.valueChange.emit(this.numericValue);
158
- // Set readOnlyValue
228
+ // Set readonlyValue
159
229
  this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
160
230
  }
161
231
  }
@@ -163,7 +233,6 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
163
233
  if (!types.includes(newValue)) {
164
234
  throw new Error(`<mg-input-numeric> prop "type" must be one of : ${types.join(', ')}`);
165
235
  }
166
- this.classList.add(`mg-input--numeric--${this.type}`);
167
236
  }
168
237
  validateIntegerLength(newValue) {
169
238
  if (newValue < 1) {
@@ -176,79 +245,57 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
176
245
  }
177
246
  }
178
247
  /**
179
- * Check if input is valid
248
+ * Public method to display errors
249
+ *
250
+ * @returns {Promise<void>}
180
251
  */
181
- checkValidity() {
182
- if (!this.readonly) {
183
- const validity = this.getInputError() === null;
184
- // Set validity
185
- this.valid = validity;
186
- this.invalid = !validity;
187
- }
188
- }
189
- /**
190
- * Set error message
191
- */
192
- setErrorMessage() {
193
- const inputError = this.getInputError();
194
- if (inputError === InputError.REQUIRED) {
195
- this.errorMessage = messages.errors[inputError];
196
- }
197
- else {
198
- this.errorMessage = messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
199
- }
252
+ async displayError() {
253
+ this.checkValidity();
254
+ this.checkError();
255
+ this.hasError = this.invalid;
200
256
  }
201
257
  /**
202
- * Check input errors
258
+ * Displayed value in input
259
+ * Change on focus/blur
260
+ *
261
+ * @returns {string} display value
203
262
  */
204
- checkError() {
205
- // Set error message
206
- this.errorMessage = undefined;
207
- // Update class
208
- if (!this.valid) {
209
- this.setErrorMessage();
210
- this.classList.add(this.classError);
211
- }
212
- else {
213
- this.classList.delete(this.classError);
214
- }
215
- }
216
- /**
217
- * Validate append slot
218
- */
219
- validateAppendSlot() {
220
- const slotAppendInput = this.element.querySelector('[slot="append-input"]');
221
- if (slotAppendInput !== null && slotAppendInput.querySelector('.mg-button') !== null) {
222
- this.classList.add('mg-input--is-input-group-append');
223
- this.classList = new ClassList(this.classList.classes);
224
- }
225
- else if (slotAppendInput !== null) {
226
- this.classList.add('mg-input--is-append-input-slot-content');
227
- this.classList = new ClassList(this.classList.classes);
228
- }
263
+ displayValue() {
264
+ return this.hasFocus ? this.value : this.readonlyValue;
229
265
  }
230
266
  /*************
231
267
  * Lifecycle *
232
268
  *************/
269
+ /**
270
+ * Check if component props are well configured on init
271
+ *
272
+ * @returns {ReturnType<typeof setTimeout>} timeout
273
+ */
233
274
  componentWillLoad() {
275
+ // Get locales
276
+ const locales = initLocales(this.element);
277
+ this.locale = locales.locale;
278
+ this.messages = locales.messages;
279
+ // Validate
234
280
  this.validateValue(this.value);
235
- // Set displayed value
236
- this.displayValue = this.readonlyValue;
237
281
  this.validateType(this.type);
238
282
  this.validateIntegerLength(this.integerLength);
239
283
  this.validateDecimalLength(this.decimalLength);
284
+ this.validateAppendSlot();
285
+ // Check validity when component is ready
240
286
  // return a promise to process action only in the FIRST render().
241
287
  // https://stenciljs.com/docs/component-lifecycle#componentwillload
242
- return setTimeout(() => this.checkValidity(), 0);
243
- }
244
- componentDidLoad() {
245
- this.validateAppendSlot();
288
+ return setTimeout(() => {
289
+ this.checkValidity();
290
+ }, 0);
246
291
  }
247
292
  /**
248
- * Check if component props are well configured on init
293
+ * Render
294
+ *
295
+ * @returns {HTMLElement} HTML Element
249
296
  */
250
297
  render() {
251
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-input__box", value: this.displayValue, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), h("slot", { name: "append-input" })));
298
+ return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), h("slot", { name: "append-input" })));
252
299
  }
253
300
  get element() { return this; }
254
301
  static get watchers() { return {
@@ -269,10 +316,11 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
269
316
  "required": [4],
270
317
  "readonly": [4],
271
318
  "disabled": [4],
272
- "width": [8],
319
+ "mgWidth": [8, "mg-width"],
273
320
  "tooltip": [1],
274
321
  "helpText": [1, "help-text"],
275
322
  "type": [1],
323
+ "currency": [1],
276
324
  "max": [2],
277
325
  "min": [2],
278
326
  "integerLength": [2, "integer-length"],
@@ -281,24 +329,20 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
281
329
  "invalid": [1028],
282
330
  "classList": [32],
283
331
  "errorMessage": [32],
284
- "displayValue": [32]
332
+ "hasFocus": [32],
333
+ "displayError": [64]
285
334
  }]);
286
335
  function defineCustomElement$1() {
287
336
  if (typeof customElements === "undefined") {
288
337
  return;
289
338
  }
290
- const components = ["mg-input-numeric", "mg-character-left", "mg-icon", "mg-input-title", "mg-tooltip"];
339
+ const components = ["mg-input-numeric", "mg-icon", "mg-input-title", "mg-tooltip"];
291
340
  components.forEach(tagName => { switch (tagName) {
292
341
  case "mg-input-numeric":
293
342
  if (!customElements.get(tagName)) {
294
343
  customElements.define(tagName, MgInputNumeric$1);
295
344
  }
296
345
  break;
297
- case "mg-character-left":
298
- if (!customElements.get(tagName)) {
299
- defineCustomElement$5();
300
- }
301
- break;
302
346
  case "mg-icon":
303
347
  if (!customElements.get(tagName)) {
304
348
  defineCustomElement$4();