@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,11 +1,11 @@
1
1
  import { h } from '@stencil/core';
2
- import { InputClass } from './MgInput.conf';
3
2
  /**
4
3
  * Apply in all input child node the aria-describedby attribute
5
- * @param children
6
- * @param ariaDescribedbyIDs
7
- * @param utils
8
- * @returns {VNode[]}
4
+ *
5
+ * @param {VNode[]} children Represent scoped elements
6
+ * @param {Set<string>} ariaDescribedbyIDs List of IDs
7
+ * @param {FunctionalUtilities} utils Stencil.js utils
8
+ * @returns {VNode[]} Children with aria-describedby attribute
9
9
  */
10
10
  const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
11
11
  if (['input', 'select', 'textarea'].includes(child.vtag)) {
@@ -18,7 +18,8 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
18
18
  });
19
19
  /**
20
20
  * Add classes based on props
21
- * @param props
21
+ *
22
+ * @param {MgInputProps} props MgInput Interface Props
22
23
  */
23
24
  const manageClasses = (props) => {
24
25
  props.classList.add('mg-input');
@@ -26,24 +27,23 @@ const manageClasses = (props) => {
26
27
  props.classList.add('mg-input--label-on-top');
27
28
  if (props.readonly)
28
29
  props.classList.add('mg-input--readonly');
29
- if (props.width !== undefined)
30
- props.classList.add(`mg-input--width-${props.width}`);
31
- if (props.readonly || props.disabled) {
32
- props.classList.delete(InputClass.ERROR);
33
- }
30
+ if (props.mgWidth !== undefined)
31
+ props.classList.add(`mg-input--width-${props.mgWidth}`);
34
32
  };
35
33
  /**
36
- * Define tagname based on props
37
- * @param isFieldset
34
+ * Get tagname
35
+ *
36
+ * @param {boolean} isFieldset is fieldset
38
37
  * @returns {string} tag name
39
38
  */
40
39
  const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
41
40
  /**
42
41
  * Get input template
43
- * @param props MgInput Interface Props
44
- * @param children Represent scoped elements
45
- * @param utils Stencil.js utils
46
- * @returns JSX template
42
+ *
43
+ * @param {MgInputProps} props MgInput Interface Props
44
+ * @param {VNode[]} children Represent scoped elements
45
+ * @param {FunctionalUtilities} utils Stencil.js utils
46
+ * @returns {VNode[]} input template
47
47
  */
48
48
  export const MgInput = (props, children, utils) => {
49
49
  /**
@@ -62,12 +62,7 @@ export const MgInput = (props, children, utils) => {
62
62
  /**
63
63
  * a11y IDs
64
64
  */
65
- const ariaDescribedbyIDs = new Set();
66
- // Character Left
67
- const characterLeftId = `${props.identifier}-character-left`;
68
- if (props.classList.has('is-focused') && props.displayCharacterLeft) {
69
- ariaDescribedbyIDs.add(characterLeftId);
70
- }
65
+ const ariaDescribedbyIDs = new Set(props.ariaDescribedbyIDs);
71
66
  // Help text
72
67
  const helpTextId = `${props.identifier}-help-text`;
73
68
  if (typeof props.helpText === 'string' && props.helpText !== '') {
@@ -105,15 +100,17 @@ export const MgInput = (props, children, utils) => {
105
100
  const TagName = getTagName(props.isFieldset);
106
101
  /**
107
102
  * Get tooltip node
108
- * @returns mg-tooltip
103
+ *
104
+ * @returns {VNode[]} mg-tooltip
109
105
  */
110
106
  const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
111
107
  h("mg-icon", { icon: "info-circle" })));
112
108
  /**
113
109
  * Get input title (label) node
114
- * @returns mg-input-title
110
+ *
111
+ * @returns {VNode[]} mg-input-title
115
112
  */
116
- const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required, "is-legend": props.isFieldset }, props.label));
113
+ const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled, "is-legend": props.isFieldset }, props.label));
117
114
  return (h(TagName, { class: props.classList.join() },
118
115
  props.labelOnTop ? (h("div", { class: "mg-input__title" },
119
116
  getInputTitle(),
@@ -121,10 +118,9 @@ export const MgInput = (props, children, utils) => {
121
118
  props.readonly ? (h("div", { class: "mg-input__input-container" },
122
119
  h("strong", null, props.readonlyValue || props.value),
123
120
  children)) : (h("div", { class: "mg-input__input-container" },
124
- h("div", { class: "mg-input__input" },
121
+ h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } },
125
122
  children,
126
123
  !props.labelOnTop && props.tooltip && getTooltip()),
127
- props.displayCharacterLeft && props.maxlength && props.classList.has('is-focused') && (h("mg-character-left", { identifier: characterLeftId, characters: props.value, maxlength: props.maxlength, template: props.characterLeftTemplate })),
128
124
  props.helpText && h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }),
129
- props.errorMessage && h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" })))));
125
+ props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
130
126
  };
@@ -2,12 +2,17 @@ import { h } from '@stencil/core';
2
2
  export default {
3
3
  component: 'mg-input-checkbox',
4
4
  title: 'Molecules/Inputs/mg-input-checkbox',
5
+ parameters: { actions: { handles: ['value-change', 'input-valid'] } },
5
6
  };
6
7
  /**
7
8
  * 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
8
9
  * 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
10
+ *
11
+ * @param {any} args component arguments
12
+ * @returns {HTMLElement} HTMLElement
9
13
  */
10
- const Template = args => {
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ const Template = (args) => {
11
16
  // Extract slot so it won't be render as an attribute
12
17
  const labelOnTop = args.labelOnTop;
13
18
  delete args.labelOnTop;
@@ -10,16 +10,10 @@
10
10
  align-items: flex-start;
11
11
  min-height: var(--default-size);
12
12
  max-width: 100%;
13
- /* Style when input is not valid */
13
+ margin-bottom: var(--mg-inputs-margin-bottom, 0);
14
14
  /* Label */
15
15
  /* Label-on-top */
16
16
  }
17
- .mg-input.is-not-valid {
18
- color: hsl(var(--color-danger));
19
- }
20
- .mg-input.is-not-valid .mg-input__box {
21
- border-color: hsl(var(--color-danger));
22
- }
23
17
  .mg-input mg-input-title {
24
18
  flex-shrink: var(--mg-inputs-shrink, 1);
25
19
  width: var(--mg-inputs-title-width, auto);
@@ -73,6 +67,11 @@
73
67
  .mg-input__input-container mg-icon {
74
68
  display: flex;
75
69
  }
70
+ .mg-input__input-container .mg-input__help-text,
71
+ .mg-input__input-container .mg-input__error {
72
+ text-align: start;
73
+ font-size: 1.2rem;
74
+ }
76
75
 
77
76
  .mg-input__input {
78
77
  display: flex;
@@ -81,17 +80,29 @@
81
80
  .mg-input__input mg-tooltip {
82
81
  margin-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
83
82
  }
84
- .mg-input__input + * {
85
- text-align: start;
83
+ .mg-input__input.mg-input__input--has-error .mg-input__box {
84
+ border-color: hsl(var(--color-danger));
85
+ }
86
+ .mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
86
87
  margin-top: 0.5rem;
87
88
  }
88
89
 
90
+ .mg-input__error {
91
+ display: inline-block;
92
+ margin-top: 0.2rem;
93
+ padding: 0.3rem 0.8rem;
94
+ border-radius: 0.3rem;
95
+ background: hsl(var(--mg-inputs-error-bg-color));
96
+ color: hsl(var(--color-danger));
97
+ }
98
+
89
99
  /**
90
100
  * Manage style when input needs to be a fieldset, like checkbox and radio.
91
101
  */
92
102
  fieldset.mg-input {
93
103
  border: 0;
94
- margin: 0;
104
+ margin-left: 0;
105
+ margin-right: 0;
95
106
  padding: 0;
96
107
  }
97
108
  fieldset.mg-input input[type=radio],
@@ -110,7 +121,7 @@ fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
110
121
  }
111
122
 
112
123
  .mg-input__input-container mg-tooltip {
113
- margin-left: 2rem;
124
+ margin-left: 3rem;
114
125
  }
115
126
 
116
127
  /* input group container */
@@ -133,6 +144,9 @@ fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
133
144
  display: flex;
134
145
  align-items: top;
135
146
  }
147
+ .mg-input__input-group.mg-input__input-group--disabled label {
148
+ opacity: 0.3;
149
+ }
136
150
 
137
151
  /**
138
152
  * A11Y
@@ -1,12 +1,12 @@
1
- import { Component, Event, h, Prop, State, Watch } from '@stencil/core';
1
+ import { Component, Element, Event, h, Prop, State, Watch, Method } from '@stencil/core';
2
2
  import { MgInput } from '../MgInput';
3
3
  import { createID, ClassList } from '../../../../utils/components.utils';
4
- import { messages } from '../../../../locales';
5
- import { InputClass } from '../MgInput.conf';
4
+ import { initLocales } from '../../../../locales';
6
5
  /**
7
6
  * type CheckboxItem validation function
8
- * @param CheckboxItem
9
- * @returns {boolean}
7
+ *
8
+ * @param {CheckboxItem} item Checkbox item
9
+ * @returns {boolean} match item expectations
10
10
  */
11
11
  const isCheckboxItem = (item) => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined;
12
12
  export class MgInputCheckbox {
@@ -14,8 +14,6 @@ export class MgInputCheckbox {
14
14
  /************
15
15
  * Internal *
16
16
  ************/
17
- // classes
18
- this.classError = InputClass.ERROR;
19
17
  // HTML selector
20
18
  this.inputs = [];
21
19
  /**
@@ -58,7 +56,8 @@ export class MgInputCheckbox {
58
56
  this.checkboxItems = [];
59
57
  /**
60
58
  * Handle input event
61
- * @param event
59
+ *
60
+ * @param {InputEvent} event input event
62
61
  */
63
62
  this.handleInput = (event) => {
64
63
  this.checkboxItems = this.checkboxItems.map(item => {
@@ -69,7 +68,6 @@ export class MgInputCheckbox {
69
68
  });
70
69
  this.value = this.checkboxItems.map(o => ({ value: o.value, title: o.title, disabled: o.disabled }));
71
70
  this.checkValidity();
72
- this.valueChange.emit(this.value);
73
71
  };
74
72
  /**
75
73
  * Handle blur event
@@ -79,9 +77,34 @@ export class MgInputCheckbox {
79
77
  this.checkValidity();
80
78
  this.checkError();
81
79
  };
80
+ /**
81
+ * Check if input is valid
82
+ */
83
+ this.checkValidity = () => {
84
+ if (!this.readonly) {
85
+ const validity = this.getInvalidElement() === undefined;
86
+ // Set validity
87
+ this.valid = validity;
88
+ this.invalid = !validity;
89
+ //Send event
90
+ this.inputValid.emit(validity);
91
+ }
92
+ };
93
+ /**
94
+ * Check input errors
95
+ */
96
+ this.checkError = () => {
97
+ const invalidElement = this.getInvalidElement();
98
+ // Set error message
99
+ this.errorMessage = undefined;
100
+ if (!this.valid && invalidElement.validity.valueMissing) {
101
+ this.errorMessage = this.messages.errors.required;
102
+ }
103
+ };
82
104
  /**
83
105
  * get invalid element
84
- * @returns element: HTMLInputElement
106
+ *
107
+ * @returns {HTMLInputElement} element
85
108
  */
86
109
  this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
87
110
  }
@@ -93,60 +116,53 @@ export class MgInputCheckbox {
93
116
  value: item.value,
94
117
  disabled: item.disabled,
95
118
  }));
119
+ this.valueChange.emit(newValue);
96
120
  }
97
121
  else {
98
122
  throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
99
123
  }
100
124
  }
101
- handleReadOnly() {
102
- this.classList.delete(this.classError);
103
- }
104
125
  /**
105
- * Check if input is valid
126
+ * Public method to display errors
127
+ *
128
+ * @returns {Promise<void>}
106
129
  */
107
- checkValidity() {
108
- if (!this.readonly) {
109
- const validity = this.getInvalidElement() === undefined;
110
- // Set validity
111
- this.valid = validity;
112
- this.invalid = !validity;
113
- }
114
- }
115
- /**
116
- * Check input errors
117
- */
118
- checkError() {
119
- const invalidElement = this.getInvalidElement();
120
- // Set error message
121
- this.errorMessage = undefined;
122
- if (!this.valid && invalidElement.validity.valueMissing) {
123
- this.errorMessage = messages.errors.required;
124
- }
125
- // Update class
126
- if (this.valid) {
127
- this.classList.delete(this.classError);
128
- }
129
- else {
130
- this.classList.add(this.classError);
131
- }
130
+ async displayError() {
131
+ this.checkValidity();
132
+ this.checkError();
132
133
  }
133
134
  /*************
134
135
  * Lifecycle *
135
136
  *************/
137
+ /**
138
+ * Check if component props are well configured on init
139
+ *
140
+ * @returns {ReturnType<typeof setTimeout>} timeout
141
+ */
136
142
  componentWillLoad() {
137
- // Check values format
143
+ // Get locales
144
+ this.messages = initLocales(this.element).messages;
145
+ // Validate
138
146
  this.validateValue(this.value);
147
+ // Check validity when component is ready
139
148
  // return a promise to process action only in the FIRST render().
140
149
  // https://stenciljs.com/docs/component-lifecycle#componentwillload
141
- return setTimeout(() => this.checkValidity(), 0);
150
+ return setTimeout(() => {
151
+ this.checkValidity();
152
+ }, 0);
142
153
  }
154
+ /**
155
+ * Render
156
+ *
157
+ * @returns {HTMLElement} HTML Element
158
+ */
143
159
  render() {
144
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: undefined, width: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true },
145
- h("ul", { class: `mg-input__input-group-container${this.inputVerticalList ? ' mg-input__input-group-container--vertical' : ''}` }, this.checkboxItems
160
+ return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true },
161
+ h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
146
162
  .filter(item => {
147
163
  return !this.readonly || item.value;
148
164
  })
149
- .map(input => (h("li", { class: "mg-input__input-group" },
165
+ .map(input => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } },
150
166
  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) }),
151
167
  h("label", { htmlFor: input.id }, input.title)))))));
152
168
  }
@@ -188,7 +204,7 @@ export class MgInputCheckbox {
188
204
  "references": {}
189
205
  },
190
206
  "required": false,
191
- "optional": true,
207
+ "optional": false,
192
208
  "docs": {
193
209
  "tags": [],
194
210
  "text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
@@ -206,7 +222,7 @@ export class MgInputCheckbox {
206
222
  "references": {}
207
223
  },
208
224
  "required": false,
209
- "optional": true,
225
+ "optional": false,
210
226
  "docs": {
211
227
  "tags": [],
212
228
  "text": "Input name\nIf not set the value equals the identifier"
@@ -227,7 +243,7 @@ export class MgInputCheckbox {
227
243
  "optional": false,
228
244
  "docs": {
229
245
  "tags": [],
230
- "text": "Input label\nRequired"
246
+ "text": "Input label"
231
247
  },
232
248
  "attribute": "label",
233
249
  "reflect": false
@@ -385,7 +401,7 @@ export class MgInputCheckbox {
385
401
  "optional": false,
386
402
  "docs": {
387
403
  "tags": [],
388
- "text": "Force valid component"
404
+ "text": "Define input valid state"
389
405
  },
390
406
  "attribute": "valid",
391
407
  "reflect": false
@@ -402,7 +418,7 @@ export class MgInputCheckbox {
402
418
  "optional": false,
403
419
  "docs": {
404
420
  "tags": [],
405
- "text": "Force invalid component"
421
+ "text": "Define input invalid state"
406
422
  },
407
423
  "attribute": "invalid",
408
424
  "reflect": false
@@ -433,12 +449,46 @@ export class MgInputCheckbox {
433
449
  }
434
450
  }
435
451
  }
452
+ }, {
453
+ "method": "inputValid",
454
+ "name": "input-valid",
455
+ "bubbles": true,
456
+ "cancelable": true,
457
+ "composed": true,
458
+ "docs": {
459
+ "tags": [],
460
+ "text": "Emited event when checking validity"
461
+ },
462
+ "complexType": {
463
+ "original": "boolean",
464
+ "resolved": "boolean",
465
+ "references": {}
466
+ }
436
467
  }]; }
468
+ static get methods() { return {
469
+ "displayError": {
470
+ "complexType": {
471
+ "signature": "() => Promise<void>",
472
+ "parameters": [],
473
+ "references": {
474
+ "Promise": {
475
+ "location": "global"
476
+ }
477
+ },
478
+ "return": "Promise<void>"
479
+ },
480
+ "docs": {
481
+ "text": "Public method to display errors",
482
+ "tags": [{
483
+ "name": "returns",
484
+ "text": undefined
485
+ }]
486
+ }
487
+ }
488
+ }; }
489
+ static get elementRef() { return "element"; }
437
490
  static get watchers() { return [{
438
491
  "propName": "value",
439
492
  "methodName": "validateValue"
440
- }, {
441
- "propName": "readonly",
442
- "methodName": "handleReadOnly"
443
493
  }]; }
444
494
  }
@@ -2,12 +2,17 @@ import { h } from '@stencil/core';
2
2
  export default {
3
3
  component: 'mg-input-date',
4
4
  title: 'Molecules/Inputs/mg-input-date',
5
+ parameters: { actions: { handles: ['value-change', 'input-valid'] } },
5
6
  };
6
7
  /**
7
8
  * 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
8
9
  * 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
10
+ *
11
+ * @param {any} args component arguments
12
+ * @returns {HTMLElement} HTMLElement
9
13
  */
10
- const Template = args => {
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ const Template = (args) => {
11
16
  const labelOnTop = args.labelOnTop;
12
17
  delete args.labelOnTop;
13
18
  const labelHide = args.labelHide;
@@ -10,16 +10,10 @@
10
10
  align-items: flex-start;
11
11
  min-height: var(--default-size);
12
12
  max-width: 100%;
13
- /* Style when input is not valid */
13
+ margin-bottom: var(--mg-inputs-margin-bottom, 0);
14
14
  /* Label */
15
15
  /* Label-on-top */
16
16
  }
17
- .mg-input.is-not-valid {
18
- color: hsl(var(--color-danger));
19
- }
20
- .mg-input.is-not-valid .mg-input__box {
21
- border-color: hsl(var(--color-danger));
22
- }
23
17
  .mg-input mg-input-title {
24
18
  flex-shrink: var(--mg-inputs-shrink, 1);
25
19
  width: var(--mg-inputs-title-width, auto);
@@ -73,6 +67,11 @@
73
67
  .mg-input__input-container mg-icon {
74
68
  display: flex;
75
69
  }
70
+ .mg-input__input-container .mg-input__help-text,
71
+ .mg-input__input-container .mg-input__error {
72
+ text-align: start;
73
+ font-size: 1.2rem;
74
+ }
76
75
 
77
76
  .mg-input__input {
78
77
  display: flex;
@@ -81,11 +80,22 @@
81
80
  .mg-input__input mg-tooltip {
82
81
  margin-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
83
82
  }
84
- .mg-input__input + * {
85
- text-align: start;
83
+ .mg-input__input.mg-input__input--has-error .mg-input__box {
84
+ border-color: hsl(var(--color-danger));
85
+ }
86
+ .mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
86
87
  margin-top: 0.5rem;
87
88
  }
88
89
 
90
+ .mg-input__error {
91
+ display: inline-block;
92
+ margin-top: 0.2rem;
93
+ padding: 0.3rem 0.8rem;
94
+ border-radius: 0.3rem;
95
+ background: hsl(var(--mg-inputs-error-bg-color));
96
+ color: hsl(var(--color-danger));
97
+ }
98
+
89
99
  /**
90
100
  * Style for input "box":
91
101
  * - input[type="text"]
@@ -106,6 +116,7 @@
106
116
  font-family: inherit;
107
117
  color: hsl(var(--color-dark));
108
118
  font-size: var(--font-size);
119
+ text-align: var(--mg-inputs-text-align, left);
109
120
  }
110
121
  .mg-input__box::placeholder {
111
122
  color: var(--mg-inputs-color);
@@ -145,6 +156,23 @@
145
156
  display: none;
146
157
  }
147
158
 
159
+ .mg-input.mg-input--label-on-top .mg-input__box {
160
+ width: auto;
161
+ max-width: 100%;
162
+ }
163
+
164
+ .mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]) {
165
+ --mg-button-border-radius-top-right: 0;
166
+ --mg-button-border-radius-bottom-right: 0;
167
+ }
168
+ .mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)) {
169
+ --mg-button-border-right-width: 0;
170
+ }
171
+ .mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type) {
172
+ --mg-button-border-radius-top-right: var(--mg-inputs-border-radius);
173
+ --mg-button-border-radius-bottom-right: var(--mg-inputs-border-radius);
174
+ }
175
+
148
176
  .mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]) {
149
177
  padding-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
150
178
  }