@mgdis/mg-components 6.3.0 → 6.4.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 (231) hide show
  1. package/dist/cjs/{index-a5b2cd1b.js → index-911898e4.js} +410 -266
  2. package/dist/cjs/index-911898e4.js.map +1 -0
  3. package/dist/cjs/{index-cc11af95.js → index-a3269bfc.js} +3 -3
  4. package/dist/cjs/{index-cc11af95.js.map → index-a3269bfc.js.map} +1 -1
  5. package/dist/cjs/{index.es-ac7c22e3.js → index.es-325100d7.js} +47 -47
  6. package/dist/cjs/index.es-325100d7.js.map +1 -0
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/cjs/mg-action-more_36.cjs.entry.js +1341 -951
  9. package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
  10. package/dist/cjs/mg-alert.cjs.entry.js +15 -12
  11. package/dist/cjs/mg-alert.cjs.entry.js.map +1 -1
  12. package/dist/cjs/mg-components.cjs.js +3 -3
  13. package/dist/cjs/mg-components.cjs.js.map +1 -1
  14. package/dist/cjs/mg-loader.cjs.entry.js +6 -8
  15. package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
  16. package/dist/cjs/mg-progress.cjs.entry.js +27 -12
  17. package/dist/cjs/mg-progress.cjs.entry.js.map +1 -1
  18. package/dist/collection/collection-manifest.json +2 -2
  19. package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js +10 -3
  20. package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js.map +1 -1
  21. package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js +15 -4
  22. package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js.map +1 -1
  23. package/dist/collection/components/atoms/mg-badge/mg-badge.js +15 -4
  24. package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
  25. package/dist/collection/components/atoms/mg-button/mg-button.js +50 -11
  26. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  27. package/dist/collection/components/atoms/mg-card/mg-card.js +1 -1
  28. package/dist/collection/components/atoms/mg-divider/mg-divider.js +9 -1
  29. package/dist/collection/components/atoms/mg-divider/mg-divider.js.map +1 -1
  30. package/dist/collection/components/atoms/mg-icon/mg-icon.js +22 -6
  31. package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
  32. package/dist/collection/components/atoms/mg-tag/mg-tag.js +14 -4
  33. package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
  34. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +3 -4
  35. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js.map +1 -1
  36. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +28 -6
  37. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
  38. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +50 -13
  39. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js.map +1 -1
  40. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +29 -11
  41. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +106 -33
  43. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
  44. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +99 -36
  45. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
  46. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +130 -35
  47. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
  48. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +87 -25
  49. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
  50. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +86 -26
  51. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
  52. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +92 -30
  53. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
  54. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +108 -31
  55. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
  56. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +109 -29
  57. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
  58. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +67 -21
  59. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
  60. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +16 -70
  61. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js.map +1 -1
  62. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +101 -89
  63. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
  64. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +194 -157
  65. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
  66. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +19 -8
  67. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
  68. package/dist/collection/components/molecules/mg-alert/mg-alert.js +15 -6
  69. package/dist/collection/components/molecules/mg-alert/mg-alert.js.map +1 -1
  70. package/dist/collection/components/molecules/mg-details/mg-details.js +17 -5
  71. package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
  72. package/dist/collection/components/molecules/mg-form/mg-form.js +48 -16
  73. package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
  74. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +13 -3
  75. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -1
  76. package/dist/collection/components/molecules/mg-loader/mg-loader.js +5 -5
  77. package/dist/collection/components/molecules/mg-loader/mg-loader.js.map +1 -1
  78. package/dist/collection/components/molecules/mg-message/mg-message.js +22 -6
  79. package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
  80. package/dist/collection/components/molecules/mg-modal/mg-modal.js +37 -9
  81. package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
  82. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +28 -9
  83. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
  84. package/dist/collection/components/molecules/mg-panel/mg-panel.js +48 -13
  85. package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
  86. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +10 -2
  87. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -1
  88. package/dist/collection/components/molecules/mg-popover/mg-popover.js +44 -7
  89. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  90. package/dist/collection/components/molecules/mg-progress/mg-progress.js +26 -1
  91. package/dist/collection/components/molecules/mg-progress/mg-progress.js.map +1 -1
  92. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +3 -2
  93. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -1
  94. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +28 -8
  95. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
  96. package/dist/collection/utils/behaviors.utils.js +44 -107
  97. package/dist/collection/utils/behaviors.utils.js.map +1 -1
  98. package/dist/components/index.es.js +42 -42
  99. package/dist/components/index.es.js.map +1 -1
  100. package/dist/components/index2.js +2 -2
  101. package/dist/components/mg-action-more.js +15 -12
  102. package/dist/components/mg-action-more.js.map +1 -1
  103. package/dist/components/mg-alert.js +13 -10
  104. package/dist/components/mg-alert.js.map +1 -1
  105. package/dist/components/mg-badge2.js +13 -10
  106. package/dist/components/mg-badge2.js.map +1 -1
  107. package/dist/components/mg-button2.js +37 -16
  108. package/dist/components/mg-button2.js.map +1 -1
  109. package/dist/components/mg-card2.js +1 -1
  110. package/dist/components/mg-character-left2.js +8 -7
  111. package/dist/components/mg-character-left2.js.map +1 -1
  112. package/dist/components/mg-details.js +11 -7
  113. package/dist/components/mg-details.js.map +1 -1
  114. package/dist/components/mg-divider2.js +7 -1
  115. package/dist/components/mg-divider2.js.map +1 -1
  116. package/dist/components/mg-form.js +35 -21
  117. package/dist/components/mg-form.js.map +1 -1
  118. package/dist/components/mg-icon2.js +17 -11
  119. package/dist/components/mg-icon2.js.map +1 -1
  120. package/dist/components/mg-illustrated-message.js +10 -4
  121. package/dist/components/mg-illustrated-message.js.map +1 -1
  122. package/dist/components/mg-input-checkbox-paginated2.js +14 -10
  123. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
  124. package/dist/components/mg-input-checkbox.js +73 -40
  125. package/dist/components/mg-input-checkbox.js.map +1 -1
  126. package/dist/components/mg-input-date.js +77 -46
  127. package/dist/components/mg-input-date.js.map +1 -1
  128. package/dist/components/mg-input-numeric.js +89 -44
  129. package/dist/components/mg-input-numeric.js.map +1 -1
  130. package/dist/components/mg-input-password.js +55 -27
  131. package/dist/components/mg-input-password.js.map +1 -1
  132. package/dist/components/mg-input-radio.js +59 -31
  133. package/dist/components/mg-input-radio.js.map +1 -1
  134. package/dist/components/mg-input-select2.js +59 -35
  135. package/dist/components/mg-input-select2.js.map +1 -1
  136. package/dist/components/mg-input-text2.js +69 -38
  137. package/dist/components/mg-input-text2.js.map +1 -1
  138. package/dist/components/mg-input-textarea.js +71 -35
  139. package/dist/components/mg-input-textarea.js.map +1 -1
  140. package/dist/components/mg-input-title2.js +11 -8
  141. package/dist/components/mg-input-title2.js.map +1 -1
  142. package/dist/components/mg-input-toggle.js +43 -25
  143. package/dist/components/mg-input-toggle.js.map +1 -1
  144. package/dist/components/mg-input2.js +37 -20
  145. package/dist/components/mg-input2.js.map +1 -1
  146. package/dist/components/mg-item-more2.js +146 -270
  147. package/dist/components/mg-item-more2.js.map +1 -1
  148. package/dist/components/mg-loader.js +4 -6
  149. package/dist/components/mg-loader.js.map +1 -1
  150. package/dist/components/mg-menu-item2.js +193 -149
  151. package/dist/components/mg-menu-item2.js.map +1 -1
  152. package/dist/components/mg-message2.js +21 -9
  153. package/dist/components/mg-message2.js.map +1 -1
  154. package/dist/components/mg-modal.js +33 -15
  155. package/dist/components/mg-modal.js.map +1 -1
  156. package/dist/components/mg-pagination2.js +21 -14
  157. package/dist/components/mg-pagination2.js.map +1 -1
  158. package/dist/components/mg-panel.js +37 -20
  159. package/dist/components/mg-panel.js.map +1 -1
  160. package/dist/components/mg-popover-content2.js +9 -3
  161. package/dist/components/mg-popover-content2.js.map +1 -1
  162. package/dist/components/mg-popover2.js +35 -10
  163. package/dist/components/mg-popover2.js.map +1 -1
  164. package/dist/components/mg-progress.js +26 -11
  165. package/dist/components/mg-progress.js.map +1 -1
  166. package/dist/components/mg-skip-links.js +2 -3
  167. package/dist/components/mg-skip-links.js.map +1 -1
  168. package/dist/components/mg-tabs.js +27 -17
  169. package/dist/components/mg-tabs.js.map +1 -1
  170. package/dist/components/mg-tag.js +12 -8
  171. package/dist/components/mg-tag.js.map +1 -1
  172. package/dist/components/mg-tooltip-content2.js +1 -2
  173. package/dist/components/mg-tooltip-content2.js.map +1 -1
  174. package/dist/components/mg-tooltip2.js +24 -12
  175. package/dist/components/mg-tooltip2.js.map +1 -1
  176. package/dist/esm/{index-eb0e1053.js → index-1f32332a.js} +410 -266
  177. package/dist/esm/index-1f32332a.js.map +1 -0
  178. package/dist/esm/{index-f3d3fb70.js → index-9bd10f5d.js} +3 -3
  179. package/dist/esm/{index-f3d3fb70.js.map → index-9bd10f5d.js.map} +1 -1
  180. package/dist/esm/{index.es-940821a9.js → index.es-a2587b72.js} +43 -43
  181. package/dist/esm/index.es-a2587b72.js.map +1 -0
  182. package/dist/esm/loader.js +3 -3
  183. package/dist/esm/mg-action-more_36.entry.js +1341 -951
  184. package/dist/esm/mg-action-more_36.entry.js.map +1 -1
  185. package/dist/esm/mg-alert.entry.js +15 -12
  186. package/dist/esm/mg-alert.entry.js.map +1 -1
  187. package/dist/esm/mg-components.js +4 -4
  188. package/dist/esm/mg-components.js.map +1 -1
  189. package/dist/esm/mg-loader.entry.js +6 -8
  190. package/dist/esm/mg-loader.entry.js.map +1 -1
  191. package/dist/esm/mg-progress.entry.js +27 -12
  192. package/dist/esm/mg-progress.entry.js.map +1 -1
  193. package/dist/mg-components/mg-components.esm.js +1 -1
  194. package/dist/mg-components/mg-components.esm.js.map +1 -1
  195. package/dist/mg-components/p-0ead5317.entry.js +2 -0
  196. package/dist/mg-components/{p-d0086664.entry.js.map → p-0ead5317.entry.js.map} +1 -1
  197. package/dist/mg-components/p-35898742.js +3 -0
  198. package/dist/mg-components/p-35898742.js.map +1 -0
  199. package/dist/mg-components/p-3b052ac0.entry.js +2 -0
  200. package/dist/mg-components/p-3b052ac0.entry.js.map +1 -0
  201. package/dist/mg-components/p-6810a565.entry.js +2 -0
  202. package/dist/mg-components/p-6810a565.entry.js.map +1 -0
  203. package/dist/mg-components/{p-ee51ec5e.js → p-b986c107.js} +2 -2
  204. package/dist/mg-components/p-b986c107.js.map +1 -0
  205. package/dist/mg-components/{p-a49e2b74.js → p-dc436f3c.js} +2 -2
  206. package/dist/mg-components/p-f48d964f.entry.js +2 -0
  207. package/dist/mg-components/p-f48d964f.entry.js.map +1 -0
  208. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +6 -0
  209. package/dist/types/components/molecules/internals/mg-item-more/mg-item-more.d.ts +1 -15
  210. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +14 -30
  211. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +46 -37
  212. package/dist/types/components.d.ts +0 -5
  213. package/dist/types/utils/behaviors.utils.d.ts +15 -44
  214. package/ide/intellij/web-types.json +3 -7
  215. package/ide/vscode/html-custom-data.json +2 -2
  216. package/package.json +22 -22
  217. package/dist/cjs/index-a5b2cd1b.js.map +0 -1
  218. package/dist/cjs/index.es-ac7c22e3.js.map +0 -1
  219. package/dist/esm/index-eb0e1053.js.map +0 -1
  220. package/dist/esm/index.es-940821a9.js.map +0 -1
  221. package/dist/mg-components/p-15b6849a.js +0 -3
  222. package/dist/mg-components/p-15b6849a.js.map +0 -1
  223. package/dist/mg-components/p-3aecf564.entry.js +0 -2
  224. package/dist/mg-components/p-3aecf564.entry.js.map +0 -1
  225. package/dist/mg-components/p-6f3d70b2.entry.js +0 -2
  226. package/dist/mg-components/p-6f3d70b2.entry.js.map +0 -1
  227. package/dist/mg-components/p-a17ea0af.entry.js +0 -2
  228. package/dist/mg-components/p-a17ea0af.entry.js.map +0 -1
  229. package/dist/mg-components/p-d0086664.entry.js +0 -2
  230. package/dist/mg-components/p-ee51ec5e.js.map +0 -1
  231. /package/dist/mg-components/{p-a49e2b74.js.map → p-dc436f3c.js.map} +0 -0
@@ -8,6 +8,12 @@ const MgDivider = /*@__PURE__*/ proxyCustomElement(class MgDivider extends HTMLE
8
8
  super();
9
9
  this.__registerHost();
10
10
  this.__attachShadow();
11
+ /**************
12
+ * Decorators *
13
+ **************/
14
+ /**
15
+ * Define component size
16
+ */
11
17
  this.fullWidth = false;
12
18
  }
13
19
  /**
@@ -15,7 +21,7 @@ const MgDivider = /*@__PURE__*/ proxyCustomElement(class MgDivider extends HTMLE
15
21
  * @returns HTML Element
16
22
  */
17
23
  render() {
18
- return (h("div", { key: 'b7d74c11f15700cbffa553bf4d688ad291473087', class: {
24
+ return (h("div", { key: '60b987cb329c6db14c2cc4a665e7f32b2696a3ee', class: {
19
25
  'mg-c-divider': true,
20
26
  'mg-c-divider--full-width': this.fullWidth,
21
27
  } }));
@@ -1 +1 @@
1
- {"file":"mg-divider2.js","mappings":";;AAAA,MAAM,YAAY,GAAG,ipBAAipB,CAAC;AACvqB,wBAAe,YAAY;;MCMd,SAAS;;;;;yBAQA,KAAK;;;;;;IAMzB,MAAM;QACJ,QACE,4DACE,KAAK,EAAE;gBACL,cAAc,EAAE,IAAI;gBACpB,0BAA0B,EAAE,IAAI,CAAC,SAAS;aAC3C,GACI,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["../styles/dist/components/mg-divider.css?tag=mg-divider&encapsulation=shadow","src/components/atoms/mg-divider/mg-divider.tsx"],"sourcesContent":["/*!\n * @prop --mg-c-divider-color-background: Defines the background color of the divider. The default value is `color-mix(in srgb, var(--mg-b-color-dark), transparent 85%)`.\n * @prop --mg-c-divider-thickness: Defines the thickness of the divider. The default value is `--mg-b-size-border`.\n * @prop --mg-c-divider-spacing-vertical: Defines the vertical spacing of the divider. The default value is `--mg-b-size-40`.\n */.mg-c-divider{width:var(--mg-b-size-120);height:var(--mg-c-divider-thickness);margin:var(--mg-c-divider-spacing-vertical) auto;background-color:var(--mg-c-divider-color-background)}.mg-c-divider.mg-c-divider--full-width{width:100%}/*# sourceMappingURL=mg-divider.css.map */\n","import { Component, h, Prop } from '@stencil/core';\n\n@Component({\n tag: 'mg-divider',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-divider.css',\n shadow: true,\n})\nexport class MgDivider {\n /**************\n * Decorators *\n **************/\n\n /**\n * Define component size\n */\n @Prop() fullWidth = false;\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <div\n class={{\n 'mg-c-divider': true,\n 'mg-c-divider--full-width': this.fullWidth,\n }}\n ></div>\n );\n }\n}\n"],"version":3}
1
+ {"file":"mg-divider2.js","mappings":";;AAAA,MAAM,YAAY,GAAG,ipBAAipB,CAAC;AACvqB,wBAAe,YAAY;;MCMd,SAAS;IALtB;;;;;;;;;;QAaU,cAAS,GAAG,KAAK,CAAC;KAgB3B;;;;;IAVC,MAAM;QACJ,QACE,4DACE,KAAK,EAAE;gBACL,cAAc,EAAE,IAAI;gBACpB,0BAA0B,EAAE,IAAI,CAAC,SAAS;aAC3C,GACI,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["../styles/dist/components/mg-divider.css?tag=mg-divider&encapsulation=shadow","src/components/atoms/mg-divider/mg-divider.tsx"],"sourcesContent":["/*!\n * @prop --mg-c-divider-color-background: Defines the background color of the divider. The default value is `color-mix(in srgb, var(--mg-b-color-dark), transparent 85%)`.\n * @prop --mg-c-divider-thickness: Defines the thickness of the divider. The default value is `--mg-b-size-border`.\n * @prop --mg-c-divider-spacing-vertical: Defines the vertical spacing of the divider. The default value is `--mg-b-size-40`.\n */.mg-c-divider{width:var(--mg-b-size-120);height:var(--mg-c-divider-thickness);margin:var(--mg-c-divider-spacing-vertical) auto;background-color:var(--mg-c-divider-color-background)}.mg-c-divider.mg-c-divider--full-width{width:100%}/*# sourceMappingURL=mg-divider.css.map */\n","import { Component, h, Prop } from '@stencil/core';\n\n@Component({\n tag: 'mg-divider',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-divider.css',\n shadow: true,\n})\nexport class MgDivider {\n /**************\n * Decorators *\n **************/\n\n /**\n * Define component size\n */\n @Prop() fullWidth = false;\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <div\n class={{\n 'mg-c-divider': true,\n 'mg-c-divider--full-width': this.fullWidth,\n }}\n ></div>\n );\n }\n}\n"],"version":3}
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { q as qe, X as Xe, G as Ge, Y as Ye } from './index.es.js';
2
+ import { z as ze, G as Ge, I as Ie, J as Je } from './index.es.js';
3
3
  import { i as initLocales } from './index2.js';
4
4
 
5
5
  /**
@@ -24,6 +24,28 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class MgForm extends HTMLEleme
24
24
  // Classes
25
25
  this.classAllRequired = 'mg-c-form--all-required';
26
26
  this.classLabelOnTop = 'mg-c-form--label-on-top';
27
+ /**
28
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
29
+ * If not set, it will be created.
30
+ */
31
+ this.identifier = ze('mg-form');
32
+ /**
33
+ * Input name
34
+ * If not set the value equals the identifier
35
+ */
36
+ this.name = this.identifier;
37
+ /**
38
+ * Define if form is readonly
39
+ */
40
+ this.readonly = false;
41
+ /**
42
+ * Define if form is disabled
43
+ */
44
+ this.disabled = false;
45
+ /**
46
+ * Component classes
47
+ */
48
+ this.classCollection = new Ge(['mg-c-form']);
27
49
  /**
28
50
  * Define required message based on mg-inputs required elements
29
51
  */
@@ -109,31 +131,20 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class MgForm extends HTMLEleme
109
131
  }
110
132
  });
111
133
  };
112
- this.identifier = qe('mg-form');
113
- this.name = this.identifier;
114
- this.readonly = false;
115
- this.requiredMessage = undefined;
116
- this.ariaRole = undefined;
117
- this.labelOnTop = undefined;
118
- this.disabled = false;
119
- this.valid = undefined;
120
- this.invalid = undefined;
121
- this.classCollection = new Xe(['mg-c-form']);
122
- this.requiredMessageText = undefined;
123
134
  }
124
135
  watchIdentifier(newValue) {
125
- if (!Ge(newValue)) {
126
- console.error(`<mg-form> prop "identifier" value is invalid. Passed value: ${Ye(newValue)}.`);
136
+ if (!Ie(newValue)) {
137
+ console.error(`<mg-form> prop "identifier" value is invalid. Passed value: ${Je(newValue)}.`);
127
138
  }
128
139
  }
129
140
  validateRequiredMessage(newValue) {
130
141
  if (newValue && !requiredMessageStatus.includes(newValue)) {
131
- throw new Error(`<mg-form> prop "requiredMessage" must be one of: ${requiredMessageStatus.join(', ')}. Passed value: ${Ye(newValue)}.`);
142
+ throw new Error(`<mg-form> prop "requiredMessage" must be one of: ${requiredMessageStatus.join(', ')}. Passed value: ${Je(newValue)}.`);
132
143
  }
133
144
  }
134
145
  validateAriaRole(newValue) {
135
146
  if (newValue && !roles.includes(newValue)) {
136
- throw new Error(`<mg-form> prop "ariaRole" must be one of: ${roles.join(', ')}. Passed value: ${Ye(newValue)}.`);
147
+ throw new Error(`<mg-form> prop "ariaRole" must be one of: ${roles.join(', ')}. Passed value: ${Je(newValue)}.`);
137
148
  }
138
149
  }
139
150
  handlelabelOnTop(newValue) {
@@ -209,17 +220,20 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class MgForm extends HTMLEleme
209
220
  */
210
221
  componentDidLoad() {
211
222
  // Update mgInputs when mgForm content change
212
- new MutationObserver(() => {
213
- this.setMgInputs();
214
- this.checkValidity();
215
- }).observe(this.element, { childList: true });
223
+ const observerOptions = { childList: true, subtree: true };
224
+ new MutationObserver((mutations) => {
225
+ if (mutations.some(mutation => Object.keys(observerOptions).includes(mutation.type))) {
226
+ this.setMgInputs();
227
+ this.checkValidity();
228
+ }
229
+ }).observe(this.element, observerOptions);
216
230
  }
217
231
  /**
218
232
  * Render
219
233
  * @returns HTML Element
220
234
  */
221
235
  render() {
222
- return (h("form", { key: 'ecfaff2bb897ce2c48ed352167bb418703a56c98', class: this.classCollection.join(), id: this.identifier, name: this.name, onSubmit: this.handleFormSubmit, role: this.ariaRole }, this.requiredMessageText && h("p", { key: '4d4fa2ff3cf4f25ebe0b009ae1995734bfcafd3b', innerHTML: this.requiredMessageText }), h("slot", { key: 'dc0c7acadf6b744335852f847a8336b018e28cb5' }), !this.readonly && !this.disabled && h("slot", { key: 'ede3ace32f6a88067845013fa65e5414cae5fcea', name: "actions" })));
236
+ return (h("form", { key: 'e61304b43787fba050014fd223f82e36aa76a133', class: this.classCollection.join(), id: this.identifier, name: this.name, onSubmit: this.handleFormSubmit, role: this.ariaRole }, this.requiredMessageText && h("p", { key: '4ff8cc35336c0943584b717c6c5717fb517b4301', innerHTML: this.requiredMessageText }), h("slot", { key: '214cbf3473b2bb00534b315e4faae164e07a14a4' }), !this.readonly && !this.disabled && h("slot", { key: 'db314dd5d606da7dc5fce4c8663f4064586b34be', name: "actions" })));
223
237
  }
224
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IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,IACjI,IAAI,CAAC,mBAAmB,IAAI,0DAAG,SAAS,EAAE,IAAI,CAAC,mBAAmB,GAAM,EACzE,8DAAa,EACZ,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,6DAAM,IAAI,EAAC,SAAS,GAAQ,CAC5D,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgForm","createID","ClassList","isValideID","toString"],"sources":["src/components/molecules/mg-form/mg-form.conf.ts","../styles/dist/components/mg-form.css?tag=mg-form&encapsulation=shadow","src/components/molecules/mg-form/mg-form.tsx"],"sourcesContent":["import { AriaRole } from '../../../types';\n\n/**\n * List of all possibles roles\n */\nexport const roles = ['form', 'search', 'none', 'presentation'] as const;\n\n/**\n * Aria Role type from roles\n */\nexport type AriaRoleType = AriaRole & (typeof roles)[number];\n\n/**\n * List of all possibles required message status\n */\nexport const requiredMessageStatus = ['default', 'hide'] as const;\n\n/**\n * RequiredMessageStatus type from requiredMessageStatus\n */\nexport type RequiredMessageStatusType = (typeof requiredMessageStatus)[number];\n",".mg-u-form-legacy{--mg-c-form-inputs-title-width: calc(100% / 3 - 20px)}.mg-u-is-asterisk{color:var(--mg-b-color-danger)}/*!\n * @prop --mg-c-form-inputs-title-width: Defines the width of the input title. Fallback on `calc(28 * var(--mg-b-size-8))`.\n */.mg-c-form{--mg-c-input-title-width: var(--mg-c-form-inputs-title-width, calc(28 * var(--mg-b-size-8)));--mg-c-input-margin-bottom: var(--mg-b-size-16);--mg-c-input-title-horizontal-space: var(--mg-b-size-32)}.mg-c-form.mg-c-form--all-required{--mg-c-input-title-display: none}.mg-c-form.mg-c-form--label-on-top{--mg-c-input-margin-bottom: var(--mg-b-size-24)}.mg-c-form>p{font-size:var(--mg-b-font-size-small)}/*# sourceMappingURL=mg-form.css.map */\n","import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { createID, ClassList, toString, isValideID } from '@mgdis/stencil-helpers';\nimport { initLocales } from '../../../locales';\nimport { HTMLMgInputsElement } from '../inputs/mg-input/mg-input.conf';\nimport { AriaRoleType, requiredMessageStatus, RequiredMessageStatusType, roles } from './mg-form.conf';\n\n/**\n * @slot - Form content\n * @slot actions - Actions content\n */\n@Component({\n tag: 'mg-form',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-form.css',\n shadow: true,\n})\nexport class MgForm {\n /************\n * Internal *\n ************/\n\n private mgInputs: (HTMLMgInputsElement & { disabled: boolean })[];\n private mgButtons: HTMLMgButtonElement[];\n\n // Classes\n private readonly classAllRequired = 'mg-c-form--all-required';\n private readonly classLabelOnTop = 'mg-c-form--label-on-top';\n\n // Locales\n private messages;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgFormElement;\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n * If not set, it will be created.\n */\n @Prop() identifier: string = createID('mg-form');\n @Watch('identifier')\n watchIdentifier(newValue: MgForm['identifier']): void {\n if (!isValideID(newValue)) {\n console.error(`<mg-form> prop \"identifier\" value is invalid. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Define if form is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define when required message is display.\n * When it is unset, component use it internal logic to manage \"required message\" help text display.\n * When you set the prop to `default`, you override the component internal logique to torce it display \"required message\" help text.\n * When you set the prop to `hide`, it will prevent the rendering of the message in the component's DOM.\n * As **this element is an accessibility requirement in the view**,\n * you **MUST*** re-implement this message on your own and display it when your form contains required inputs.\n */\n @Prop() requiredMessage?: RequiredMessageStatusType;\n @Watch('requiredMessage')\n validateRequiredMessage(newValue): void {\n if (newValue && !requiredMessageStatus.includes(newValue)) {\n throw new Error(`<mg-form> prop \"requiredMessage\" must be one of: ${requiredMessageStatus.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define `<form/>` element aria role\n * see more about aria roles use case: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles\n */\n @Prop() ariaRole?: AriaRoleType;\n @Watch('ariaRole')\n validateAriaRole(newValue: MgForm['ariaRole']) {\n if (newValue && !roles.includes(newValue)) {\n throw new Error(`<mg-form> prop \"ariaRole\" must be one of: ${roles.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define if slotted mg-component's label are displayed on top\n */\n @Prop() labelOnTop?: boolean;\n @Watch('labelOnTop')\n handlelabelOnTop(newValue: MgForm['labelOnTop']) {\n if (newValue) {\n this.classCollection.add(this.classLabelOnTop);\n } else {\n this.classCollection.delete(this.classLabelOnTop);\n }\n }\n /**\n * Define if form is disabled\n */\n @Prop() disabled = false;\n @Watch('readonly')\n @Watch('disabled')\n @Watch('requiredMessage')\n handleAttributeChange(): void {\n this.setMgInputs();\n this.setRequiredMessage();\n }\n\n /**\n * Define form valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define form invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-form']);\n\n /**\n * Required message\n */\n @State() requiredMessageText: string;\n\n /**\n * Emitted event on form validity check\n * Tells if form is valid or not\n */\n @Event({ eventName: 'form-valid' }) formValid: EventEmitter<HTMLMgFormElement['valid']>;\n\n /**\n * Emitted event on form submit\n */\n @Event({ eventName: 'form-submit' }) formSubmit: EventEmitter<boolean>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n if (!this.readonly) {\n this.mgInputs.forEach(input => {\n input.displayError?.();\n });\n this.checkValidity();\n }\n }\n\n /**\n * Reset form inputs values, validity and error state\n */\n @Method()\n async reset(): Promise<void> {\n if (!this.readonly) {\n await Promise.all(\n this.mgInputs.map(async input => {\n if (input.reset !== undefined) {\n await input.reset();\n }\n }),\n );\n }\n }\n\n /**\n * Define required message based on mg-inputs required elements\n */\n private setRequiredMessage = (): void => {\n // init required message\n this.requiredMessageText = null;\n this.classCollection.delete(this.classAllRequired);\n\n if (this.requiredMessage === 'hide') return;\n else if (this.requiredMessage === 'default') {\n this.requiredMessageText = this.messages.form.required;\n return;\n }\n\n // If the form is disabled or readonly none of them are required\n // Check if all fields are not editable (readonly or disabled)\n const isEditable = input => !(input.disabled || input.readonly);\n const isMgInputToggle = input => input.nodeName === 'MG-INPUT-TOGGLE';\n if (!this.disabled && !this.readonly && this.mgInputs.some(input => isEditable(input) && !isMgInputToggle(input))) {\n // Get editable inputs\n const editableInputs: HTMLMgInputsElement[] = this.mgInputs.filter(isEditable);\n // Get required inputs\n // mg-input-toggle can not be required\n const requiredInputs: HTMLMgInputsElement[] = editableInputs.filter(input => !isMgInputToggle(input) && input.required);\n // All inputs are required\n if (\n [requiredInputs.length, editableInputs.length].every(length => length === 1) ||\n (requiredInputs.length > 1 && requiredInputs.length === editableInputs.filter(input => !isMgInputToggle(input)).length)\n ) {\n this.requiredMessageText = this.getRequiredMessageBasedOnCount(requiredInputs, 'allRequiredSingle', 'allRequired');\n this.classCollection.add(this.classAllRequired);\n }\n // Some fields are required\n else if (requiredInputs.length > 0) {\n this.requiredMessageText = this.getRequiredMessageBasedOnCount(requiredInputs, 'requiredSingle', 'required');\n }\n }\n };\n\n /**\n * Returns a required message based on the count of required inputs.\n * @param requiredInputs - An array of required input elements.\n * @param keySingle - The key for the singular message format.\n * @param keyPlural - The key for the plural message format.\n * @returns The appropriate required message based on the count of required inputs.\n */\n private getRequiredMessageBasedOnCount = (requiredInputs: HTMLMgInputsElement[], keySingle: string, keyPlural: string) =>\n this.messages.form[requiredInputs.length === 1 ? keySingle : keyPlural];\n\n /**\n * Check if form is valid\n */\n private checkValidity = (): void => {\n // Update required on input event\n this.setRequiredMessage();\n\n this.valid = !this.mgInputs.some(input => input.invalid);\n this.invalid = !this.valid;\n // We need to send valid event if it is the same value\n this.formValid.emit(this.valid);\n };\n\n /**\n * Handle Form Submit\n * @param event - submit event\n */\n private handleFormSubmit = (event: SubmitEvent): void => {\n event.preventDefault();\n this.formSubmit.emit();\n };\n\n /**\n * Set mgInputs\n */\n private setMgInputs = (): void => {\n // Get slotted mgInputs\n this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node: Node) => node.nodeName.startsWith('MG-INPUT')) as (HTMLMgInputsElement & { disabled: boolean })[];\n // Set inputs readonly or disabled based on form configuration\n // Othewise listen to events\n this.mgInputs.forEach(input => {\n if (this.labelOnTop) {\n input.labelOnTop = true;\n }\n if (this.readonly) {\n input.readonly = true;\n } else if (this.disabled) {\n input.disabled = true;\n } else {\n input.addEventListener('input-valid', this.checkValidity);\n }\n });\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Get locales\n this.messages = initLocales(this.element).messages;\n\n this.watchIdentifier(this.identifier);\n this.validateAriaRole(this.ariaRole);\n this.validateRequiredMessage(this.requiredMessage);\n this.handlelabelOnTop(this.labelOnTop);\n\n // Get slotted mgButtons\n this.mgButtons = Array.from(this.element.querySelectorAll('mg-button'));\n\n // Set button form identifier\n this.mgButtons.forEach(mgButton => {\n mgButton.setAttribute('form', this.identifier);\n });\n\n // Set mgInputs\n this.setMgInputs();\n\n // Check validity when slotted mgInputs are ready\n Promise.all(\n this.mgInputs.map(async input => {\n try {\n await input.componentOnReady();\n } catch {} // prevent error with VueJS first render\n }),\n ).then(() => {\n // Define required message and check validity\n this.checkValidity();\n });\n }\n\n /**\n * Add slot listeners\n */\n componentDidLoad(): void {\n // Update mgInputs when mgForm content change\n new MutationObserver(() => {\n this.setMgInputs();\n this.checkValidity();\n }).observe(this.element, { childList: true });\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <form class={this.classCollection.join()} id={this.identifier} name={this.name} onSubmit={this.handleFormSubmit} role={this.ariaRole}>\n {this.requiredMessageText && <p innerHTML={this.requiredMessageText}></p>}\n <slot></slot>\n {!this.readonly && !this.disabled && <slot name=\"actions\"></slot>}\n </form>\n );\n }\n}\n"],"version":3}
1
+ {"file":"mg-form.js","mappings":";;;;AAEA;;;AAGO,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAU,CAAC;AAOzE;;;AAGO,MAAM,qBAAqB,GAAG,CAAC,SAAS,EAAE,MAAM,CAAU;;ACfjE,MAAM,SAAS,GAAG,qpBAAqpB,CAAC;AACxqB,qBAAe,SAAS;;MCcXA,QAAM;IALnB;;;;;;;QAcmB,qBAAgB,GAAG,yBAAyB,CAAC;QAC7C,oBAAe,GAAG,yBAAyB,CAAC;;;;;QAkBrD,eAAU,GAAWC,EAAQ,CAAC,SAAS,CAAC,CAAC;;;;;QAYzC,SAAI,GAAW,IAAI,CAAC,UAAU,CAAC;;;;QAK/B,aAAQ,GAAG,KAAK,CAAC;;;;QA6CjB,aAAQ,GAAG,KAAK,CAAC;;;;QAsBhB,oBAAe,GAAc,IAAIC,EAAS,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;;;;QAkD3D,uBAAkB,GAAG;;YAE3B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;YAChC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAEnD,IAAI,IAAI,CAAC,eAAe,KAAK,MAAM;gBAAE,OAAO;iBACvC,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE;gBAC3C,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;gBACvD,OAAO;aACR;;;YAID,MAAM,UAA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CAAC;SACtB,CAAC,CAAC;KACJ;;;;IAKD,gBAAgB;;QAEd,MAAM,eAAe,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;QAC1D,IAAI,gBAAgB,CAAC,CAAC,SAAS;YAC7B,IAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE;gBACnF,IAAI,CAAC,WAAW,EAAE,CAAC;gBACnB,IAAI,CAAC,aAAa,EAAE,CAAC;aACtB;SACF,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;KAC3C;;;;;IAMD,MAAM;QACJ,QACE,6DAAM,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,IACjI,IAAI,CAAC,mBAAmB,IAAI,0DAAG,SAAS,EAAE,IAAI,CAAC,mBAAmB,GAAM,EACzE,8DAAa,EACZ,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,6DAAM,IAAI,EAAC,SAAS,GAAQ,CAC5D,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgForm","createID","ClassList","isValideID","toString"],"sources":["src/components/molecules/mg-form/mg-form.conf.ts","../styles/dist/components/mg-form.css?tag=mg-form&encapsulation=shadow","src/components/molecules/mg-form/mg-form.tsx"],"sourcesContent":["import { AriaRole } from '../../../types';\n\n/**\n * List of all possibles roles\n */\nexport const roles = ['form', 'search', 'none', 'presentation'] as const;\n\n/**\n * Aria Role type from roles\n */\nexport type AriaRoleType = AriaRole & (typeof roles)[number];\n\n/**\n * List of all possibles required message status\n */\nexport const requiredMessageStatus = ['default', 'hide'] as const;\n\n/**\n * RequiredMessageStatus type from requiredMessageStatus\n */\nexport type RequiredMessageStatusType = (typeof requiredMessageStatus)[number];\n",".mg-u-form-legacy{--mg-c-form-inputs-title-width: calc(100% / 3 - 20px)}.mg-u-is-asterisk{color:var(--mg-b-color-danger)}/*!\n * @prop --mg-c-form-inputs-title-width: Defines the width of the input title. Fallback on `calc(28 * var(--mg-b-size-8))`.\n */.mg-c-form{--mg-c-input-title-width: var(--mg-c-form-inputs-title-width, calc(28 * var(--mg-b-size-8)));--mg-c-input-margin-bottom: var(--mg-b-size-16);--mg-c-input-title-horizontal-space: var(--mg-b-size-32)}.mg-c-form.mg-c-form--all-required{--mg-c-input-title-display: none}.mg-c-form.mg-c-form--label-on-top{--mg-c-input-margin-bottom: var(--mg-b-size-24)}.mg-c-form>p{font-size:var(--mg-b-font-size-small)}/*# sourceMappingURL=mg-form.css.map */\n","import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { createID, ClassList, toString, isValideID } from '@mgdis/stencil-helpers';\nimport { initLocales } from '../../../locales';\nimport { HTMLMgInputsElement } from '../inputs/mg-input/mg-input.conf';\nimport { AriaRoleType, requiredMessageStatus, RequiredMessageStatusType, roles } from './mg-form.conf';\n\n/**\n * @slot - Form content\n * @slot actions - Actions content\n */\n@Component({\n tag: 'mg-form',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-form.css',\n shadow: true,\n})\nexport class MgForm {\n /************\n * Internal *\n ************/\n\n private mgInputs: (HTMLMgInputsElement & { disabled: boolean })[];\n private mgButtons: HTMLMgButtonElement[];\n\n // Classes\n private readonly classAllRequired = 'mg-c-form--all-required';\n private readonly classLabelOnTop = 'mg-c-form--label-on-top';\n\n // Locales\n private messages;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgFormElement;\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n * If not set, it will be created.\n */\n @Prop() identifier: string = createID('mg-form');\n @Watch('identifier')\n watchIdentifier(newValue: MgForm['identifier']): void {\n if (!isValideID(newValue)) {\n console.error(`<mg-form> prop \"identifier\" value is invalid. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Define if form is readonly\n */\n @Prop() readonly = false;\n\n /**\n * Define when required message is display.\n * When it is unset, component use it internal logic to manage \"required message\" help text display.\n * When you set the prop to `default`, you override the component internal logique to torce it display \"required message\" help text.\n * When you set the prop to `hide`, it will prevent the rendering of the message in the component's DOM.\n * As **this element is an accessibility requirement in the view**,\n * you **MUST*** re-implement this message on your own and display it when your form contains required inputs.\n */\n @Prop() requiredMessage?: RequiredMessageStatusType;\n @Watch('requiredMessage')\n validateRequiredMessage(newValue): void {\n if (newValue && !requiredMessageStatus.includes(newValue)) {\n throw new Error(`<mg-form> prop \"requiredMessage\" must be one of: ${requiredMessageStatus.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define `<form/>` element aria role\n * see more about aria roles use case: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles\n */\n @Prop() ariaRole?: AriaRoleType;\n @Watch('ariaRole')\n validateAriaRole(newValue: MgForm['ariaRole']) {\n if (newValue && !roles.includes(newValue)) {\n throw new Error(`<mg-form> prop \"ariaRole\" must be one of: ${roles.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define if slotted mg-component's label are displayed on top\n */\n @Prop() labelOnTop?: boolean;\n @Watch('labelOnTop')\n handlelabelOnTop(newValue: MgForm['labelOnTop']) {\n if (newValue) {\n this.classCollection.add(this.classLabelOnTop);\n } else {\n this.classCollection.delete(this.classLabelOnTop);\n }\n }\n /**\n * Define if form is disabled\n */\n @Prop() disabled = false;\n @Watch('readonly')\n @Watch('disabled')\n @Watch('requiredMessage')\n handleAttributeChange(): void {\n this.setMgInputs();\n this.setRequiredMessage();\n }\n\n /**\n * Define form valid state\n */\n @Prop({ mutable: true }) valid: boolean;\n\n /**\n * Define form invalid state\n */\n @Prop({ mutable: true }) invalid: boolean;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-form']);\n\n /**\n * Required message\n */\n @State() requiredMessageText: string;\n\n /**\n * Emitted event on form validity check\n * Tells if form is valid or not\n */\n @Event({ eventName: 'form-valid' }) formValid: EventEmitter<HTMLMgFormElement['valid']>;\n\n /**\n * Emitted event on form submit\n */\n @Event({ eventName: 'form-submit' }) formSubmit: EventEmitter<boolean>;\n\n /**\n * Display input error if it exists.\n */\n @Method()\n async displayError(): Promise<void> {\n if (!this.readonly) {\n this.mgInputs.forEach(input => {\n input.displayError?.();\n });\n this.checkValidity();\n }\n }\n\n /**\n * Reset form inputs values, validity and error state\n */\n @Method()\n async reset(): Promise<void> {\n if (!this.readonly) {\n await Promise.all(\n this.mgInputs.map(async input => {\n if (input.reset !== undefined) {\n await input.reset();\n }\n }),\n );\n }\n }\n\n /**\n * Define required message based on mg-inputs required elements\n */\n private setRequiredMessage = (): void => {\n // init required message\n this.requiredMessageText = null;\n this.classCollection.delete(this.classAllRequired);\n\n if (this.requiredMessage === 'hide') return;\n else if (this.requiredMessage === 'default') {\n this.requiredMessageText = this.messages.form.required;\n return;\n }\n\n // If the form is disabled or readonly none of them are required\n // Check if all fields are not editable (readonly or disabled)\n const isEditable = input => !(input.disabled || input.readonly);\n const isMgInputToggle = input => input.nodeName === 'MG-INPUT-TOGGLE';\n if (!this.disabled && !this.readonly && this.mgInputs.some(input => isEditable(input) && !isMgInputToggle(input))) {\n // Get editable inputs\n const editableInputs: HTMLMgInputsElement[] = this.mgInputs.filter(isEditable);\n // Get required inputs\n // mg-input-toggle can not be required\n const requiredInputs: HTMLMgInputsElement[] = editableInputs.filter(input => !isMgInputToggle(input) && input.required);\n // All inputs are required\n if (\n [requiredInputs.length, editableInputs.length].every(length => length === 1) ||\n (requiredInputs.length > 1 && requiredInputs.length === editableInputs.filter(input => !isMgInputToggle(input)).length)\n ) {\n this.requiredMessageText = this.getRequiredMessageBasedOnCount(requiredInputs, 'allRequiredSingle', 'allRequired');\n this.classCollection.add(this.classAllRequired);\n }\n // Some fields are required\n else if (requiredInputs.length > 0) {\n this.requiredMessageText = this.getRequiredMessageBasedOnCount(requiredInputs, 'requiredSingle', 'required');\n }\n }\n };\n\n /**\n * Returns a required message based on the count of required inputs.\n * @param requiredInputs - An array of required input elements.\n * @param keySingle - The key for the singular message format.\n * @param keyPlural - The key for the plural message format.\n * @returns The appropriate required message based on the count of required inputs.\n */\n private getRequiredMessageBasedOnCount = (requiredInputs: HTMLMgInputsElement[], keySingle: string, keyPlural: string) =>\n this.messages.form[requiredInputs.length === 1 ? keySingle : keyPlural];\n\n /**\n * Check if form is valid\n */\n private checkValidity = (): void => {\n // Update required on input event\n this.setRequiredMessage();\n\n this.valid = !this.mgInputs.some(input => input.invalid);\n this.invalid = !this.valid;\n // We need to send valid event if it is the same value\n this.formValid.emit(this.valid);\n };\n\n /**\n * Handle Form Submit\n * @param event - submit event\n */\n private handleFormSubmit = (event: SubmitEvent): void => {\n event.preventDefault();\n this.formSubmit.emit();\n };\n\n /**\n * Set mgInputs\n */\n private setMgInputs = (): void => {\n // Get slotted mgInputs\n this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node: Node) => node.nodeName.startsWith('MG-INPUT')) as (HTMLMgInputsElement & { disabled: boolean })[];\n // Set inputs readonly or disabled based on form configuration\n // Othewise listen to events\n this.mgInputs.forEach(input => {\n if (this.labelOnTop) {\n input.labelOnTop = true;\n }\n if (this.readonly) {\n input.readonly = true;\n } else if (this.disabled) {\n input.disabled = true;\n } else {\n input.addEventListener('input-valid', this.checkValidity);\n }\n });\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Get locales\n this.messages = initLocales(this.element).messages;\n\n this.watchIdentifier(this.identifier);\n this.validateAriaRole(this.ariaRole);\n this.validateRequiredMessage(this.requiredMessage);\n this.handlelabelOnTop(this.labelOnTop);\n\n // Get slotted mgButtons\n this.mgButtons = Array.from(this.element.querySelectorAll('mg-button'));\n\n // Set button form identifier\n this.mgButtons.forEach(mgButton => {\n mgButton.setAttribute('form', this.identifier);\n });\n\n // Set mgInputs\n this.setMgInputs();\n\n // Check validity when slotted mgInputs are ready\n Promise.all(\n this.mgInputs.map(async input => {\n try {\n await input.componentOnReady();\n } catch {} // prevent error with VueJS first render\n }),\n ).then(() => {\n // Define required message and check validity\n this.checkValidity();\n });\n }\n\n /**\n * Add slot listeners\n */\n componentDidLoad(): void {\n // Update mgInputs when mgForm content change\n const observerOptions = { childList: true, subtree: true }\n new MutationObserver((mutations) => {\n if(mutations.some(mutation => Object.keys(observerOptions).includes(mutation.type))) {\n this.setMgInputs();\n this.checkValidity();\n }\n }).observe(this.element, observerOptions);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <form class={this.classCollection.join()} id={this.identifier} name={this.name} onSubmit={this.handleFormSubmit} role={this.ariaRole}>\n {this.requiredMessageText && <p innerHTML={this.requiredMessageText}></p>}\n <slot></slot>\n {!this.readonly && !this.disabled && <slot name=\"actions\"></slot>}\n </form>\n );\n }\n}\n"],"version":3}
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement } from '@stencil/core/internal/client';
2
- import { X as Xe, Y as Ye } from './index.es.js';
2
+ import { G as Ge, J as Je } from './index.es.js';
3
3
 
4
4
  /**
5
5
  * List of all possibles sizes
@@ -24,6 +24,18 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class MgIcon extends HTMLElement
24
24
  super();
25
25
  this.__registerHost();
26
26
  this.__attachShadow();
27
+ /**
28
+ * Define icon size
29
+ */
30
+ this.size = 'medium';
31
+ /**
32
+ * Make the icon spin
33
+ */
34
+ this.spin = false;
35
+ /**
36
+ * Component classes
37
+ */
38
+ this.classCollection = new Ge(['mg-c-icon']);
27
39
  /**
28
40
  * Method to set default varianStyle props
29
41
  * needeed has stencil doesn't know that props is mutated when updated in prop watcher
@@ -44,16 +56,10 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class MgIcon extends HTMLElement
44
56
  this.svg.setAttribute('focusable', 'false');
45
57
  this.svg.setAttribute('class', this.classCollection.join());
46
58
  };
47
- this.icon = undefined;
48
- this.size = 'medium';
49
- this.variant = undefined;
50
- this.variantStyle = undefined;
51
- this.spin = false;
52
- this.classCollection = new Xe(['mg-c-icon']);
53
59
  }
54
60
  validateIcon(newValue, oldValue) {
55
61
  if (!Object.keys(icons).includes(newValue))
56
- throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}. Passed value: ${Ye(newValue)}.`);
62
+ throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}. Passed value: ${Je(newValue)}.`);
57
63
  else {
58
64
  if (oldValue !== undefined)
59
65
  this.classCollection.delete(`mg-c-icon--${oldValue}`);
@@ -63,7 +69,7 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class MgIcon extends HTMLElement
63
69
  }
64
70
  validateSize(newValue, oldValue) {
65
71
  if (!sizes.includes(newValue))
66
- throw new Error(`<mg-icon> prop "size" must be one of: ${sizes.join(', ')}. Passed value: ${Ye(newValue)}.`);
72
+ throw new Error(`<mg-icon> prop "size" must be one of: ${sizes.join(', ')}. Passed value: ${Je(newValue)}.`);
67
73
  else {
68
74
  if (oldValue !== undefined)
69
75
  this.classCollection.delete(`mg-c-icon--size-${oldValue}`);
@@ -73,7 +79,7 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class MgIcon extends HTMLElement
73
79
  validateVariant(newValue, oldValue) {
74
80
  if (newValue !== undefined) {
75
81
  if (!variants.includes(newValue))
76
- throw new Error(`<mg-icon> prop "variant" must be one of: ${variants.join(', ')}. Passed value: ${Ye(newValue)}.`);
82
+ throw new Error(`<mg-icon> prop "variant" must be one of: ${variants.join(', ')}. Passed value: ${Je(newValue)}.`);
77
83
  else {
78
84
  this.setDefaultVariantStyle();
79
85
  if (oldValue !== undefined)
@@ -85,7 +91,7 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class MgIcon extends HTMLElement
85
91
  validateVariantStyle(newValue, oldValue) {
86
92
  if (newValue !== undefined) {
87
93
  if (!variantStyles.includes(newValue))
88
- throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}. Passed value: ${Ye(newValue)}.`);
94
+ throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}. Passed value: ${Je(newValue)}.`);
89
95
  else {
90
96
  if (oldValue !== undefined)
91
97
  this.classCollection.delete(`mg-c-icon--variant-style-${oldValue}`);