@mgdis/mg-components 5.26.0 → 5.27.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 (255) hide show
  1. package/dist/cjs/{index-c585c382.js → index-1d560837.js} +97 -81
  2. package/dist/cjs/index-1d560837.js.map +1 -0
  3. package/dist/cjs/{index-0a2783ee.js → index-7072369e.js} +17 -5
  4. package/dist/cjs/index-7072369e.js.map +1 -0
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/{mg-action-more_34.cjs.entry.js → mg-action-more_35.cjs.entry.js} +613 -694
  7. package/dist/cjs/mg-action-more_35.cjs.entry.js.map +1 -0
  8. package/dist/cjs/mg-components.cjs.js +3 -3
  9. package/dist/cjs/mg-components.cjs.js.map +1 -1
  10. package/dist/cjs/mg-item-more.cjs.entry.js +7 -6
  11. package/dist/cjs/mg-item-more.cjs.entry.js.map +1 -1
  12. package/dist/cjs/mg-loader.cjs.entry.js +3 -3
  13. package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
  14. package/dist/collection/assets/icons/index.js +1 -206
  15. package/dist/collection/assets/icons/index.js.map +1 -1
  16. package/dist/collection/collection-manifest.json +4 -3
  17. package/dist/collection/components/atoms/mg-badge/mg-badge.js +2 -2
  18. package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
  19. package/dist/collection/components/atoms/mg-button/mg-button.js +6 -6
  20. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  21. package/dist/collection/components/atoms/mg-card/mg-card.js +2 -2
  22. package/dist/collection/components/atoms/mg-card/mg-card.js.map +1 -1
  23. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +2 -2
  24. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js.map +1 -1
  25. package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
  26. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js.map +1 -1
  27. package/dist/collection/components/atoms/mg-icon/mg-icon.js +13 -8
  28. package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
  29. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +3 -3
  30. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js.map +1 -1
  31. package/dist/collection/components/atoms/mg-tag/mg-tag.js +3 -3
  32. package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
  33. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +21 -0
  34. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js.map +1 -0
  35. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +509 -0
  36. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js.map +1 -0
  37. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +1 -5
  38. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js.map +1 -1
  39. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +7 -7
  40. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
  41. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js.map +1 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +67 -45
  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 +31 -13
  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 +48 -18
  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 +54 -15
  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 +40 -8
  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 +44 -13
  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 +63 -24
  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 +47 -15
  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 +30 -21
  59. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
  60. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +3 -3
  61. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
  62. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +4 -0
  63. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js.map +1 -1
  64. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +43 -7
  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.conf.js.map +1 -1
  67. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +41 -41
  68. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
  69. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  70. package/dist/collection/components/molecules/mg-form/mg-form.js +4 -4
  71. package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
  72. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +3 -3
  73. package/dist/collection/components/molecules/mg-item-more/mg-item-more.conf.js.map +1 -1
  74. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +12 -11
  75. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +1 -1
  76. package/dist/collection/components/molecules/mg-loader/mg-loader.js +3 -3
  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 +3 -3
  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 +2 -2
  81. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +4 -4
  82. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
  83. package/dist/collection/components/molecules/mg-panel/mg-panel.js +4 -4
  84. package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
  85. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  86. package/dist/collection/components/molecules/mg-popover/mg-popover.js +2 -2
  87. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  88. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  89. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
  90. package/dist/collection/locales/en/messages.json +10 -3
  91. package/dist/collection/locales/fr/messages.json +10 -3
  92. package/dist/collection/locales/index.conf.js +2 -0
  93. package/dist/collection/locales/index.conf.js.map +1 -0
  94. package/dist/collection/utils/playwright.fixture.js +1 -1
  95. package/dist/collection/utils/playwright.fixture.js.map +1 -1
  96. package/dist/components/index.es.js +12 -12
  97. package/dist/components/index.es.js.map +1 -1
  98. package/dist/components/index2.js +24 -8
  99. package/dist/components/index2.js.map +1 -1
  100. package/dist/components/mg-action-more.js +15 -15
  101. package/dist/components/mg-action-more.js.map +1 -1
  102. package/dist/components/mg-badge2.js +1 -1
  103. package/dist/components/mg-badge2.js.map +1 -1
  104. package/dist/components/mg-button2.js +1 -1
  105. package/dist/components/mg-button2.js.map +1 -1
  106. package/dist/components/mg-card2.js +2 -2
  107. package/dist/components/mg-card2.js.map +1 -1
  108. package/dist/components/mg-character-left2.js +1 -1
  109. package/dist/components/mg-character-left2.js.map +1 -1
  110. package/dist/components/mg-details.js +1 -1
  111. package/dist/components/mg-divider.js +1 -1
  112. package/dist/components/mg-form.js +1 -1
  113. package/dist/components/mg-form.js.map +1 -1
  114. package/dist/components/mg-icon2.js +4 -416
  115. package/dist/components/mg-icon2.js.map +1 -1
  116. package/dist/components/mg-illustrated-message.js +3 -3
  117. package/dist/components/mg-input-checkbox-paginated2.js +13 -11
  118. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
  119. package/dist/components/mg-input-checkbox.js +71 -49
  120. package/dist/components/mg-input-checkbox.js.map +1 -1
  121. package/dist/components/mg-input-date.js +29 -11
  122. package/dist/components/mg-input-date.js.map +1 -1
  123. package/dist/components/mg-input-numeric.js +41 -12
  124. package/dist/components/mg-input-numeric.js.map +1 -1
  125. package/dist/components/mg-input-password.js +56 -12
  126. package/dist/components/mg-input-password.js.map +1 -1
  127. package/dist/components/mg-input-radio.js +41 -10
  128. package/dist/components/mg-input-radio.js.map +1 -1
  129. package/dist/components/mg-input-select2.js +42 -12
  130. package/dist/components/mg-input-select2.js.map +1 -1
  131. package/dist/components/mg-input-text2.js +50 -18
  132. package/dist/components/mg-input-text2.js.map +1 -1
  133. package/dist/components/mg-input-textarea.js +44 -13
  134. package/dist/components/mg-input-textarea.js.map +1 -1
  135. package/dist/components/mg-input-title2.js +1 -1
  136. package/dist/components/mg-input-title2.js.map +1 -1
  137. package/dist/components/mg-input-toggle.js +35 -22
  138. package/dist/components/mg-input-toggle.js.map +1 -1
  139. package/dist/components/mg-input.d.ts +11 -0
  140. package/dist/components/mg-input.js +8 -0
  141. package/dist/components/mg-input.js.map +1 -0
  142. package/dist/components/mg-input2.js +352 -0
  143. package/dist/components/mg-input2.js.map +1 -0
  144. package/dist/components/mg-item-more.js +7 -6
  145. package/dist/components/mg-item-more.js.map +1 -1
  146. package/dist/components/mg-loader.js +1 -1
  147. package/dist/components/mg-loader.js.map +1 -1
  148. package/dist/components/mg-menu-item2.js +21 -4
  149. package/dist/components/mg-menu-item2.js.map +1 -1
  150. package/dist/components/mg-menu2.js +1 -1
  151. package/dist/components/mg-menu2.js.map +1 -1
  152. package/dist/components/mg-message.js +1 -1
  153. package/dist/components/mg-message.js.map +1 -1
  154. package/dist/components/mg-modal.js +3 -3
  155. package/dist/components/mg-modal.js.map +1 -1
  156. package/dist/components/mg-pagination2.js +12 -6
  157. package/dist/components/mg-pagination2.js.map +1 -1
  158. package/dist/components/mg-panel.js +15 -9
  159. package/dist/components/mg-panel.js.map +1 -1
  160. package/dist/components/mg-popover-content2.js +1 -1
  161. package/dist/components/mg-popover2.js +2 -2
  162. package/dist/components/mg-popover2.js.map +1 -1
  163. package/dist/components/mg-skip-links.js +1 -1
  164. package/dist/components/mg-tabs.js +1 -1
  165. package/dist/components/mg-tag.js +1 -1
  166. package/dist/components/mg-tag.js.map +1 -1
  167. package/dist/esm/{index-bb17de92.js → index-445fc2a0.js} +97 -81
  168. package/dist/esm/index-445fc2a0.js.map +1 -0
  169. package/dist/esm/{index-ad78ece7.js → index-629a42c7.js} +17 -5
  170. package/dist/esm/index-629a42c7.js.map +1 -0
  171. package/dist/esm/loader.js +3 -3
  172. package/dist/esm/{mg-action-more_34.entry.js → mg-action-more_35.entry.js} +613 -695
  173. package/dist/esm/mg-action-more_35.entry.js.map +1 -0
  174. package/dist/esm/mg-components.js +4 -4
  175. package/dist/esm/mg-components.js.map +1 -1
  176. package/dist/esm/mg-item-more.entry.js +7 -6
  177. package/dist/esm/mg-item-more.entry.js.map +1 -1
  178. package/dist/esm/mg-loader.entry.js +3 -3
  179. package/dist/esm/mg-loader.entry.js.map +1 -1
  180. package/dist/mg-components/locales/en/messages.json +10 -3
  181. package/dist/mg-components/locales/fr/messages.json +10 -3
  182. package/dist/mg-components/mg-components.esm.js +1 -1
  183. package/dist/mg-components/mg-components.esm.js.map +1 -1
  184. package/dist/mg-components/p-3ebe6845.js +2 -0
  185. package/dist/mg-components/p-3ebe6845.js.map +1 -0
  186. package/dist/mg-components/{p-2db8355d.entry.js → p-6735e4b2.entry.js} +2 -2
  187. package/dist/mg-components/p-6735e4b2.entry.js.map +1 -0
  188. package/dist/mg-components/p-9dfaa41f.js +3 -0
  189. package/dist/mg-components/p-9dfaa41f.js.map +1 -0
  190. package/dist/mg-components/p-b3e0f7b3.entry.js +2 -0
  191. package/dist/mg-components/p-b3e0f7b3.entry.js.map +1 -0
  192. package/dist/mg-components/{p-d80b844d.entry.js → p-fe347f48.entry.js} +2 -2
  193. package/dist/mg-components/{p-d80b844d.entry.js.map → p-fe347f48.entry.js.map} +1 -1
  194. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +1 -1
  195. package/dist/types/components/atoms/mg-button/mg-button.d.ts +5 -5
  196. package/dist/types/components/atoms/mg-card/mg-card.d.ts +1 -1
  197. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -1
  198. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +5 -0
  199. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +3 -3
  200. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +2 -2
  201. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +2 -2
  202. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +35 -0
  203. package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +139 -0
  204. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.d.ts +5 -5
  205. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +3 -5
  206. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +13 -12
  207. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +8 -6
  208. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +12 -9
  209. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +16 -5
  210. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +7 -3
  211. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +7 -4
  212. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +18 -12
  213. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +12 -9
  214. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +12 -12
  215. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +1 -1
  216. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +8 -0
  217. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +10 -5
  218. package/dist/types/components/molecules/mg-action-more/mg-action-more.conf.d.ts +7 -16
  219. package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +9 -9
  220. package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -3
  221. package/dist/types/components/molecules/mg-item-more/mg-item-more.conf.d.ts +3 -12
  222. package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +4 -3
  223. package/dist/types/components/molecules/mg-loader/mg-loader.d.ts +2 -2
  224. package/dist/types/components/molecules/mg-message/mg-message.d.ts +2 -2
  225. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +2 -2
  226. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +3 -3
  227. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +1 -1
  228. package/dist/types/components.d.ts +203 -92
  229. package/dist/types/locales/index.conf.d.ts +4 -0
  230. package/ide/intellij/web-types.json +243 -18
  231. package/ide/vscode/html-custom-data.json +2766 -1332
  232. package/package.json +23 -27
  233. package/dist/cjs/index-0a2783ee.js.map +0 -1
  234. package/dist/cjs/index-c585c382.js.map +0 -1
  235. package/dist/cjs/mg-action-more_34.cjs.entry.js.map +0 -1
  236. package/dist/collection/components/molecules/inputs/MgInput.conf.js +0 -14
  237. package/dist/collection/components/molecules/inputs/MgInput.conf.js.map +0 -1
  238. package/dist/collection/components/molecules/inputs/MgInput.js +0 -125
  239. package/dist/collection/components/molecules/inputs/MgInput.js.map +0 -1
  240. package/dist/collection/utils/playwright.e2e.test.utils.js +0 -100
  241. package/dist/collection/utils/playwright.e2e.test.utils.js.map +0 -1
  242. package/dist/components/MgInput.js +0 -155
  243. package/dist/components/MgInput.js.map +0 -1
  244. package/dist/esm/index-ad78ece7.js.map +0 -1
  245. package/dist/esm/index-bb17de92.js.map +0 -1
  246. package/dist/esm/mg-action-more_34.entry.js.map +0 -1
  247. package/dist/mg-components/p-2db8355d.entry.js.map +0 -1
  248. package/dist/mg-components/p-95653110.entry.js +0 -2
  249. package/dist/mg-components/p-95653110.entry.js.map +0 -1
  250. package/dist/mg-components/p-bc62d75e.js +0 -3
  251. package/dist/mg-components/p-bc62d75e.js.map +0 -1
  252. package/dist/mg-components/p-d41aa78b.js +0 -2
  253. package/dist/mg-components/p-d41aa78b.js.map +0 -1
  254. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +0 -46
  255. package/dist/types/components/molecules/inputs/MgInput.d.ts +0 -13
@@ -1,14 +0,0 @@
1
- /**
2
- * Possible input width
3
- */
4
- export const widths = [2, 4, 16, 'full'];
5
- /**
6
- * Available handlers
7
- */
8
- export var Handler;
9
- (function (Handler) {
10
- Handler["BLUR"] = "blur";
11
- Handler["FOCUS"] = "focus";
12
- })(Handler || (Handler = {}));
13
- export const tooltipPositions = ['input', 'label'];
14
- //# sourceMappingURL=MgInput.conf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MgInput.conf.js","sourceRoot":"","sources":["../../../../src/components/molecules/inputs/MgInput.conf.ts"],"names":[],"mappings":"AAgCA;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,CAAU,CAAC;AAkBlD;;GAEG;AACH,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,wBAAa,CAAA;IACb,0BAAe,CAAA;AACjB,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAU,CAAC","sourcesContent":["import type { MgInputTitle } from '../../atoms/mg-input-title/mg-input-title';\nimport type { ClassList } from '@mgdis/stencil-helpers';\n\n/**\n * MgInput component props\n */\nexport interface MgInputProps {\n // Global\n identifier: string;\n classCollection: ClassList;\n // Label\n label: string;\n labelOnTop: boolean;\n labelHide: boolean;\n isFieldset: MgInputTitle['isLegend'];\n // Input\n value: string;\n readonlyValue: string | string[];\n required: boolean;\n readonly: boolean;\n mgWidth: Width;\n disabled: boolean;\n // Tooltip\n tooltip: string;\n tooltipPosition: TooltipPosition;\n // Help Text\n helpText: string;\n // Error Message\n errorMessage: string;\n // ariaDescribedbyIDs\n ariaDescribedbyIDs: string[];\n}\n/**\n * Possible input width\n */\nexport const widths = [2, 4, 16, 'full'] as const;\n\nexport type Width = (typeof widths)[number];\n\n/**\n * Possible Input types\n */\nexport type HTMLMgInputsElement =\n | HTMLMgInputCheckboxElement\n | HTMLMgInputDateElement\n | HTMLMgInputNumericElement\n | HTMLMgInputPasswordElement\n | HTMLMgInputRadioElement\n | HTMLMgInputSelectElement\n | HTMLMgInputTextElement\n | HTMLMgInputTextareaElement\n | (HTMLMgInputToggleElement & { required: true; invalid: false; displayError: () => void });\n\n/**\n * Available handlers\n */\nexport enum Handler {\n BLUR = 'blur',\n FOCUS = 'focus',\n}\n\nexport const tooltipPositions = ['input', 'label'] as const;\n\nexport type TooltipPosition = (typeof tooltipPositions)[number];\n"]}
@@ -1,125 +0,0 @@
1
- import { h } from "@stencil/core";
2
- import { widths, tooltipPositions } from "./MgInput.conf";
3
- import { isValidString } from "@mgdis/stencil-helpers";
4
- /**
5
- * Apply in all input child node the aria-describedby attribute
6
- * @param children - Represent scoped elements
7
- * @param ariaDescribedbyIDs - List of IDs
8
- * @param utils - Stencil.js utils
9
- * @returns Children with aria-describedby attribute
10
- */
11
- const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
12
- if (['input', 'select', 'textarea'].includes(child.vtag)) {
13
- return Object.assign(Object.assign({}, child), { vattrs: Object.assign(Object.assign({}, child.vattrs), { 'aria-describedby': [...ariaDescribedbyIDs].join(' ') }) });
14
- }
15
- // we recursively apply ariadescribedBy attributes to child input nodes if exists
16
- if (child.vchildren === null)
17
- return Object.assign({}, child);
18
- return Object.assign(Object.assign({}, child), { vchildren: applyAriadescribedBy(child.vchildren, ariaDescribedbyIDs, utils) });
19
- });
20
- /**
21
- * Add classes based on props
22
- * @param props - MgInput Interface Props
23
- */
24
- const manageClasses = (props) => {
25
- props.classCollection.add('mg-c-input');
26
- if (props.labelOnTop)
27
- props.classCollection.add('mg-c-input--label-on-top');
28
- else
29
- props.classCollection.delete('mg-c-input--label-on-top');
30
- if (props.readonly)
31
- props.classCollection.add('mg-c-input--readonly');
32
- else
33
- props.classCollection.delete('mg-c-input--readonly');
34
- widths.forEach(width => {
35
- props.classCollection.delete(`mg-c-input--width-${width}`);
36
- });
37
- if (props.mgWidth !== undefined)
38
- props.classCollection.add(`mg-c-input--width-${props.mgWidth}`);
39
- };
40
- /**
41
- * Check props configuration
42
- * @param props - MgInput Interface Props
43
- */
44
- const checkPropsConfig = (props) => {
45
- if (!isValidString(props.identifier)) {
46
- throw new Error('<mg-input> prop "identifier" is required.');
47
- }
48
- if (!isValidString(props.label)) {
49
- throw new Error('<mg-input> prop "label" is required.');
50
- }
51
- if (props.labelOnTop && props.labelHide) {
52
- throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide".');
53
- }
54
- if (!tooltipPositions.includes(props.tooltipPosition)) {
55
- throw new Error(`<mg-input> prop "tooltipPosition" must be one of: ${tooltipPositions.join(', ')}`);
56
- }
57
- };
58
- /**
59
- * Get tagname
60
- * @param isFieldset - is fieldset
61
- * @returns tag name
62
- */
63
- const getTagName = (isFieldset, readOnly) => (!isFieldset || readOnly ? 'div' : 'fieldset');
64
- /**
65
- * MgInput Interface
66
- */
67
- /**
68
- * Get input template
69
- * @param props - MgInput Interface Props
70
- * @param children - Represent scoped elements
71
- * @param utils - Stencil.js utils
72
- * @returns input template
73
- */
74
- export const MgInput = (props, children, utils) => {
75
- /**
76
- * Check props config
77
- */
78
- checkPropsConfig(props);
79
- /**
80
- * Set readonly value
81
- */
82
- if (props.readonlyValue === undefined)
83
- props.readonlyValue = props.value;
84
- /**
85
- * Component classes
86
- */
87
- manageClasses(props);
88
- /**
89
- * a11y IDs
90
- */
91
- const ariaDescribedbyIDs = new Set(props.ariaDescribedbyIDs);
92
- // Help text
93
- const helpTextId = `${props.identifier}-help-text`;
94
- if (typeof props.helpText === 'string' && props.helpText !== '') {
95
- ariaDescribedbyIDs.add(helpTextId);
96
- }
97
- // Error Message
98
- const helpTextErrorId = `${props.identifier}-error`;
99
- if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {
100
- ariaDescribedbyIDs.add(helpTextErrorId);
101
- }
102
- /**
103
- * Return template
104
- *
105
- * +--------+---------+--------------+---------+
106
- * | label | tooltip | input | tooltip |
107
- * |--------+---------+--------------+---------+
108
- * | | nb Char Left |
109
- * | +------------------------+
110
- * | | Help Text |
111
- * | +------------------------+
112
- * | | Error |
113
- * +------------------+------------------------+
114
- *
115
- * Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change
116
- */
117
- const TagName = getTagName(props.isFieldset, props.readonly);
118
- /**
119
- * Get tooltip node
120
- * @returns mg-tooltip
121
- */
122
- const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip }, h("mg-icon", { icon: "info-circle" })));
123
- return (h(TagName, { class: props.classCollection.join() }, h("div", { class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': props.labelHide } }, h("mg-input-title", { identifier: props.identifier, readonly: props.readonly, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label), props.tooltip && !props.readonly && (props.tooltipPosition === 'label' || props.labelOnTop) && !props.labelHide && getTooltip()), props.readonly ? (h("div", { class: "mg-c-input__input-container" }, Array.isArray(props.readonlyValue) ? (h("ul", null, props.readonlyValue.map(value => (h("li", { key: value }, h("strong", null, value)))))) : (h("strong", null, props.readonlyValue)), children.filter(child => Object.values(child).includes('append-input')))) : (h("div", { class: "mg-c-input__input-container" }, h("div", { class: { 'mg-c-input__input': true, 'mg-c-input__input--has-error': props.errorMessage !== undefined } }, applyAriadescribedBy(children, ariaDescribedbyIDs, utils), props.tooltip && !props.readonly && !props.labelOnTop && (props.tooltipPosition === 'input' || props.labelHide) && getTooltip()), props.helpText && h("div", { id: helpTextId, class: "mg-c-input__help-text", innerHTML: props.helpText }), props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-c-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
124
- };
125
- //# sourceMappingURL=MgInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MgInput.js","sourceRoot":"","sources":["../../../../src/components/molecules/inputs/MgInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,CAAC,EAA8B,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAqB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,CAAC,QAAiB,EAAE,kBAA+B,EAAE,KAA0B,EAAW,EAAE,CACvH,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE;IAC1B,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAc,CAAC,EAAE,CAAC;QACnE,uCACK,KAAK,KACR,MAAM,kCACD,KAAK,CAAC,MAAM,KAC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ACO,CACX,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { FunctionalComponent, h, VNode, FunctionalUtilities } from '@stencil/core';\nimport { widths, tooltipPositions, type MgInputProps } from './MgInput.conf';\nimport { isValidString } from '@mgdis/stencil-helpers';\n\n/**\n * Apply in all input child node the aria-describedby attribute\n * @param children - Represent scoped elements\n * @param ariaDescribedbyIDs - List of IDs\n * @param utils - Stencil.js utils\n * @returns Children with aria-describedby attribute\n */\nconst applyAriadescribedBy = (children: VNode[], ariaDescribedbyIDs: Set<string>, utils: FunctionalUtilities): VNode[] =>\n utils.map(children, child => {\n if (['input', 'select', 'textarea'].includes(child.vtag as string)) {\n return {\n ...child,\n vattrs: {\n ...child.vattrs,\n 'aria-describedby': [...ariaDescribedbyIDs].join(' '),\n },\n };\n }\n\n // we recursively apply ariadescribedBy attributes to child input nodes if exists\n if (child.vchildren === null) return { ...child };\n return {\n ...child,\n vchildren: applyAriadescribedBy(child.vchildren, ariaDescribedbyIDs, utils),\n };\n });\n\n/**\n * Add classes based on props\n * @param props - MgInput Interface Props\n */\nconst manageClasses = (props: MgInputProps): void => {\n props.classCollection.add('mg-c-input');\n\n if (props.labelOnTop) props.classCollection.add('mg-c-input--label-on-top');\n else props.classCollection.delete('mg-c-input--label-on-top');\n\n if (props.readonly) props.classCollection.add('mg-c-input--readonly');\n else props.classCollection.delete('mg-c-input--readonly');\n\n widths.forEach(width => {\n props.classCollection.delete(`mg-c-input--width-${width}`);\n });\n if (props.mgWidth !== undefined) props.classCollection.add(`mg-c-input--width-${props.mgWidth}`);\n};\n\n/**\n * Check props configuration\n * @param props - MgInput Interface Props\n */\nconst checkPropsConfig = (props: MgInputProps): void => {\n if (!isValidString(props.identifier)) {\n throw new Error('<mg-input> prop \"identifier\" is required.');\n }\n if (!isValidString(props.label)) {\n throw new Error('<mg-input> prop \"label\" is required.');\n }\n if (props.labelOnTop && props.labelHide) {\n throw new Error('<mg-input> prop \"labelOnTop\" must not be paired with the prop \"labelHide\".');\n }\n if (!tooltipPositions.includes(props.tooltipPosition)) {\n throw new Error(`<mg-input> prop \"tooltipPosition\" must be one of: ${tooltipPositions.join(', ')}`);\n }\n};\n\n/**\n * Get tagname\n * @param isFieldset - is fieldset\n * @returns tag name\n */\nconst getTagName = (isFieldset: MgInputProps['isFieldset'], readOnly: MgInputProps['readonly']): string => (!isFieldset || readOnly ? 'div' : 'fieldset');\n\n/**\n * MgInput Interface\n */\n\n/**\n * Get input template\n * @param props - MgInput Interface Props\n * @param children - Represent scoped elements\n * @param utils - Stencil.js utils\n * @returns input template\n */\nexport const MgInput: FunctionalComponent<MgInputProps> = (props: MgInputProps, children: VNode[], utils: FunctionalUtilities): VNode[] => {\n /**\n * Check props config\n */\n checkPropsConfig(props);\n\n /**\n * Set readonly value\n */\n if (props.readonlyValue === undefined) props.readonlyValue = props.value;\n\n /**\n * Component classes\n */\n manageClasses(props);\n\n /**\n * a11y IDs\n */\n const ariaDescribedbyIDs: Set<string> = new Set(props.ariaDescribedbyIDs);\n\n // Help text\n const helpTextId = `${props.identifier}-help-text`;\n if (typeof props.helpText === 'string' && props.helpText !== '') {\n ariaDescribedbyIDs.add(helpTextId);\n }\n\n // Error Message\n const helpTextErrorId = `${props.identifier}-error`;\n if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {\n ariaDescribedbyIDs.add(helpTextErrorId);\n }\n\n /**\n * Return template\n *\n * +--------+---------+--------------+---------+\n * | label | tooltip | input | tooltip |\n * |--------+---------+--------------+---------+\n * | | nb Char Left |\n * | +------------------------+\n * | | Help Text |\n * | +------------------------+\n * | | Error |\n * +------------------+------------------------+\n *\n * Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change\n */\n\n const TagName = getTagName(props.isFieldset, props.readonly);\n\n /**\n * Get tooltip node\n * @returns mg-tooltip\n */\n const getTooltip = (): VNode[] => (\n <mg-tooltip identifier={`${props.identifier}-tooltip`} message={props.tooltip}>\n <mg-icon icon=\"info-circle\"></mg-icon>\n </mg-tooltip>\n );\n\n return (\n <TagName class={props.classCollection.join()}>\n <div class={{ 'mg-c-input__title': true, 'mg-u-visually-hidden': props.labelHide }}>\n <mg-input-title identifier={props.identifier} readonly={props.readonly} required={props.required && !props.disabled && !props.readonly} is-legend={props.isFieldset}>\n {props.label}\n </mg-input-title>\n {props.tooltip && !props.readonly && (props.tooltipPosition === 'label' || props.labelOnTop) && !props.labelHide && getTooltip()}\n </div>\n {props.readonly ? (\n <div class=\"mg-c-input__input-container\">\n {Array.isArray(props.readonlyValue) ? (\n <ul>\n {props.readonlyValue.map(value => (\n <li key={value}>\n <strong>{value}</strong>\n </li>\n ))}\n </ul>\n ) : (\n <strong>{props.readonlyValue}</strong>\n )}\n {children.filter(child => Object.values(child).includes('append-input'))}\n </div>\n ) : (\n <div class=\"mg-c-input__input-container\">\n <div class={{ 'mg-c-input__input': true, 'mg-c-input__input--has-error': props.errorMessage !== undefined }}>\n {applyAriadescribedBy(children, ariaDescribedbyIDs, utils)}\n {props.tooltip && !props.readonly && !props.labelOnTop && (props.tooltipPosition === 'input' || props.labelHide) && getTooltip()}\n </div>\n {props.helpText && <div id={helpTextId} class=\"mg-c-input__help-text\" innerHTML={props.helpText}></div>}\n {props.errorMessage && !props.readonly && !props.disabled && (\n <div id={helpTextErrorId} class=\"mg-c-input__error\" innerHTML={props.errorMessage} aria-live=\"assertive\"></div>\n )}\n </div>\n )}\n </TagName>\n );\n};\n"]}
@@ -1,100 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { test as playwrightTest, expect as playwrightExpect, devices as playwrightDevices } from "@playwright/test";
3
- import { readFile } from "fs/promises";
4
- import { join } from "path";
5
- /**
6
- * Add mg-components to browser page
7
- *
8
- * @param page - browser page
9
- * @param html - html to load in page
10
- */
11
- export const setPageContent = async (page, html, viewportSize) => {
12
- // We need to add mg-components to the e2e page
13
- // Those solutions wasn't working to add the CSS
14
- // await page.addStyleTag({ url: 'http://localhost:3333/build/mg-components.css' });
15
- // CSS
16
- const css = await readFile(join(__dirname, '../../www/build/mg-components.css'), { encoding: 'utf8' });
17
- await page.addStyleTag({ content: css });
18
- // JS
19
- await page.addScriptTag({ url: 'http://localhost:3333/build/mg-components.esm.js', type: 'module' });
20
- // Set page size before style setting to prevent "resize" event to be triggered
21
- if (viewportSize !== undefined)
22
- await page.setViewportSize(viewportSize);
23
- // Set page content
24
- // Added the `e2e-screenshot` class to be able to do the screenshot on this specific one with
25
- // `await expect(page.locator('.e2e-screenshot')).toHaveScreenshot();`
26
- await page.setContent(`<style>${css} .e2e-screenshot { display: inline-block; }</style><span class="e2e-screenshot">${html}</span>`);
27
- // Make sure everything is loaded
28
- await page.waitForLoadState('networkidle');
29
- await page.waitForSelector('html.hydrated');
30
- };
31
- /**
32
- * playwright 'expect' function definition
33
- */
34
- export const expect = playwrightExpect;
35
- /**
36
- * playwright 'describe' function definition
37
- */
38
- export const describe = playwrightTest.describe;
39
- /**
40
- * playwright 'test' function definition
41
- */
42
- export const test = playwrightTest;
43
- /**
44
- * playwright 'devices' definition
45
- */
46
- export const devices = playwrightDevices;
47
- /**
48
- * Value to get in string
49
- * @param value - valut to stringify
50
- * @returns stringified value
51
- */
52
- const valueToString = (value) => (typeof value === 'object' ? JSON.stringify(value) : `${value}`);
53
- /**
54
- * repeat test over array
55
- * @param array - array of test
56
- * @param option - test runner option
57
- * @returns describe iteration
58
- */
59
- export const describeEach = (array, option) => (title, cb) => {
60
- array.forEach(value => {
61
- const displayTitle = title.replace('%s', valueToString(value));
62
- const fn = () => cb(value);
63
- if (Boolean(option))
64
- describe[option](displayTitle, fn);
65
- else
66
- describe(displayTitle, fn);
67
- });
68
- };
69
- /**
70
- * repeat test over array
71
- * @param array - array of test
72
- * @param option - test runner option
73
- * @returns test iteration
74
- */
75
- export const testEach = (array, option) => (title, cb) => {
76
- array.forEach(value => {
77
- const displayTitle = title.replace('%s', valueToString(value));
78
- const fn = async ({ page }) => cb(page, value);
79
- if (Boolean(option))
80
- test[option](displayTitle, fn);
81
- else
82
- test(displayTitle, fn);
83
- });
84
- };
85
- /**
86
- * Update .e2e-screenshot style for screenshot needs
87
- * @param page - playwright Page
88
- * @param params - css properties to apply
89
- * @returns class style definition
90
- */
91
- export const updateScreenshotClass = async (page, params) => page.evaluate(params => {
92
- const css = `.e2e-screenshot { ${Object.keys(params)
93
- .map(key => `${key}: ${typeof params[key] === 'string' ? params[key] : ''}`)
94
- .join(';')} }`;
95
- const body = document.getElementsByTagName('body')[0];
96
- const style = document.createElement('style');
97
- body.appendChild(style);
98
- style.appendChild(document.createTextNode(css));
99
- }, params);
100
- //# sourceMappingURL=playwright.e2e.test.utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"playwright.e2e.test.utils.js","sourceRoot":"","sources":["../../src/utils/playwright.e2e.test.utils.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAA2B,IAAI,IAAI,cAAc,EAAE,MAAM,IAAI,gBAAgB,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC7I,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,IAAU,EAAE,IAAY,EAAE,YAA2B,EAAiB,EAAE;IAC3G,+CAA+C;IAC/C,gDAAgD;IAChD,oFAAoF;IAEpF,MAAM;IACN,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,mCAAmC,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACvG,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAEzC,KAAK;IACL,MAAM,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,kDAAkD,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,C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AAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACxB,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC,EAAE,MAAM,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type Page, ViewportSize, test as playwrightTest, expect as playwrightExpect, devices as playwrightDevices } from '@playwright/test';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\n\n/**\n * Add mg-components to browser page\n *\n * @param page - browser page\n * @param html - html to load in page\n */\nexport const setPageContent = async (page: Page, html: string, viewportSize?: ViewportSize): Promise<void> => {\n // We need to add mg-components to the e2e page\n // Those solutions wasn't working to add the CSS\n // await page.addStyleTag({ url: 'http://localhost:3333/build/mg-components.css' });\n\n // CSS\n const css = await readFile(join(__dirname, '../../www/build/mg-components.css'), { encoding: 'utf8' });\n await page.addStyleTag({ content: css });\n\n // JS\n await page.addScriptTag({ url: 'http://localhost:3333/build/mg-components.esm.js', type: 'module' });\n\n // Set page size before style setting to prevent \"resize\" event to be triggered\n if (viewportSize !== undefined) await page.setViewportSize(viewportSize);\n\n // Set page content\n // Added the `e2e-screenshot` class to be able to do the screenshot on this specific one with\n // `await expect(page.locator('.e2e-screenshot')).toHaveScreenshot();`\n await page.setContent(`<style>${css} .e2e-screenshot { display: inline-block; }</style><span class=\"e2e-screenshot\">${html}</span>`);\n\n // Make sure everything is loaded\n await page.waitForLoadState('networkidle');\n await page.waitForSelector('html.hydrated');\n};\n\n/**\n * playwright 'expect' function definition\n */\nexport const expect = playwrightExpect;\n\n/**\n * playwright 'describe' function definition\n */\nexport const describe = playwrightTest.describe;\n\n/**\n * playwright 'test' function definition\n */\nexport const test = playwrightTest;\n\n/**\n * playwright 'devices' definition\n */\nexport const devices = playwrightDevices;\n\n/**\n * Value to get in string\n * @param value - valut to stringify\n * @returns stringified value\n */\nconst valueToString = (value: unknown): string => (typeof value === 'object' ? JSON.stringify(value) : `${value}`);\n\n/**\n * Declare page type\n */\nexport type PageType = Page;\n\n/**\n * repeat test over array\n * @param array - array of test\n * @param option - test runner option\n * @returns describe iteration\n */\nexport const describeEach = (array: unknown[] | any, option?: 'skip' | 'only') => (title: string, cb: (param: unknown) => void) => {\n array.forEach(value => {\n const displayTitle = title.replace('%s', valueToString(value));\n const fn = () => cb(value);\n if (Boolean(option)) describe[option](displayTitle, fn);\n else describe(displayTitle, fn);\n });\n};\n\n/**\n * repeat test over array\n * @param array - array of test\n * @param option - test runner option\n * @returns test iteration\n */\nexport const testEach = (array: unknown[] | any, option?: 'skip' | 'only') => (title: string, cb: (page: PageType, param: unknown) => Promise<void>) => {\n array.forEach(value => {\n const displayTitle = title.replace('%s', valueToString(value));\n const fn = async ({ page }) => cb(page, value);\n if (Boolean(option)) test[option](displayTitle, fn);\n else test(displayTitle, fn);\n });\n};\n\n/**\n * Update .e2e-screenshot style for screenshot needs\n * @param page - playwright Page\n * @param params - css properties to apply\n * @returns class style definition\n */\nexport const updateScreenshotClass = async (page: Page, params: unknown): Promise<void> =>\n page.evaluate(params => {\n const css = `.e2e-screenshot { ${Object.keys(params)\n .map(key => `${key}: ${typeof params[key] === 'string' ? params[key] : ''}`)\n .join(';')} }`;\n const body = document.getElementsByTagName('body')[0];\n const style = document.createElement('style');\n body.appendChild(style);\n style.appendChild(document.createTextNode(css));\n }, params);\n"]}
@@ -1,155 +0,0 @@
1
- import { h } from '@stencil/core/internal/client';
2
- import { B as Be } from './index.es.js';
3
-
4
- /**
5
- * Possible input width
6
- */
7
- const widths = [2, 4, 16, 'full'];
8
- /**
9
- * Available handlers
10
- */
11
- var Handler;
12
- (function (Handler) {
13
- Handler["BLUR"] = "blur";
14
- Handler["FOCUS"] = "focus";
15
- })(Handler || (Handler = {}));
16
- const tooltipPositions = ['input', 'label'];
17
-
18
- /**
19
- * Apply in all input child node the aria-describedby attribute
20
- * @param children - Represent scoped elements
21
- * @param ariaDescribedbyIDs - List of IDs
22
- * @param utils - Stencil.js utils
23
- * @returns Children with aria-describedby attribute
24
- */
25
- const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
26
- if (['input', 'select', 'textarea'].includes(child.vtag)) {
27
- return Object.assign(Object.assign({}, child), { vattrs: Object.assign(Object.assign({}, child.vattrs), { 'aria-describedby': [...ariaDescribedbyIDs].join(' ') }) });
28
- }
29
- // we recursively apply ariadescribedBy attributes to child input nodes if exists
30
- if (child.vchildren === null)
31
- return Object.assign({}, child);
32
- return Object.assign(Object.assign({}, child), { vchildren: applyAriadescribedBy(child.vchildren, ariaDescribedbyIDs, utils) });
33
- });
34
- /**
35
- * Add classes based on props
36
- * @param props - MgInput Interface Props
37
- */
38
- const manageClasses = (props) => {
39
- props.classCollection.add('mg-c-input');
40
- if (props.labelOnTop)
41
- props.classCollection.add('mg-c-input--label-on-top');
42
- else
43
- props.classCollection.delete('mg-c-input--label-on-top');
44
- if (props.readonly)
45
- props.classCollection.add('mg-c-input--readonly');
46
- else
47
- props.classCollection.delete('mg-c-input--readonly');
48
- widths.forEach(width => {
49
- props.classCollection.delete(`mg-c-input--width-${width}`);
50
- });
51
- if (props.mgWidth !== undefined)
52
- props.classCollection.add(`mg-c-input--width-${props.mgWidth}`);
53
- };
54
- /**
55
- * Check props configuration
56
- * @param props - MgInput Interface Props
57
- */
58
- const checkPropsConfig = (props) => {
59
- if (!Be(props.identifier)) {
60
- throw new Error('<mg-input> prop "identifier" is required.');
61
- }
62
- if (!Be(props.label)) {
63
- throw new Error('<mg-input> prop "label" is required.');
64
- }
65
- if (props.labelOnTop && props.labelHide) {
66
- throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide".');
67
- }
68
- if (!tooltipPositions.includes(props.tooltipPosition)) {
69
- throw new Error(`<mg-input> prop "tooltipPosition" must be one of: ${tooltipPositions.join(', ')}`);
70
- }
71
- };
72
- /**
73
- * Get tagname
74
- * @param isFieldset - is fieldset
75
- * @returns tag name
76
- */
77
- const getTagName = (isFieldset, readOnly) => (!isFieldset || readOnly ? 'div' : 'fieldset');
78
- /**
79
- * MgInput Interface
80
- */
81
- /**
82
- * Get input template
83
- * @param props - MgInput Interface Props
84
- * @param children - Represent scoped elements
85
- * @param utils - Stencil.js utils
86
- * @returns input template
87
- */
88
- const MgInput = (props, children, utils) => {
89
- /**
90
- * Check props config
91
- */
92
- checkPropsConfig(props);
93
- /**
94
- * Set readonly value
95
- */
96
- if (props.readonlyValue === undefined)
97
- props.readonlyValue = props.value;
98
- /**
99
- * Component classes
100
- */
101
- manageClasses(props);
102
- /**
103
- * a11y IDs
104
- */
105
- const ariaDescribedbyIDs = new Set(props.ariaDescribedbyIDs);
106
- // Help text
107
- const helpTextId = `${props.identifier}-help-text`;
108
- if (typeof props.helpText === 'string' && props.helpText !== '') {
109
- ariaDescribedbyIDs.add(helpTextId);
110
- }
111
- // Error Message
112
- const helpTextErrorId = `${props.identifier}-error`;
113
- if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {
114
- ariaDescribedbyIDs.add(helpTextErrorId);
115
- }
116
- /**
117
- * Return template
118
- *
119
- * +--------+---------+--------------+---------+
120
- * | label | tooltip | input | tooltip |
121
- * |--------+---------+--------------+---------+
122
- * | | nb Char Left |
123
- * | +------------------------+
124
- * | | Help Text |
125
- * | +------------------------+
126
- * | | Error |
127
- * +------------------+------------------------+
128
- *
129
- * Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change
130
- */
131
- const TagName = getTagName(props.isFieldset, props.readonly);
132
- /**
133
- * Get tooltip node
134
- * @returns mg-tooltip
135
- */
136
- const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
137
- h("mg-icon", { icon: "info-circle" })));
138
- return (h(TagName, { class: props.classCollection.join() },
139
- h("div", { class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': props.labelHide } },
140
- h("mg-input-title", { identifier: props.identifier, readonly: props.readonly, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label),
141
- props.tooltip && !props.readonly && (props.tooltipPosition === 'label' || props.labelOnTop) && !props.labelHide && getTooltip()),
142
- props.readonly ? (h("div", { class: "mg-c-input__input-container" },
143
- Array.isArray(props.readonlyValue) ? (h("ul", null, props.readonlyValue.map(value => (h("li", { key: value },
144
- h("strong", null, value)))))) : (h("strong", null, props.readonlyValue)),
145
- children.filter(child => Object.values(child).includes('append-input')))) : (h("div", { class: "mg-c-input__input-container" },
146
- h("div", { class: { 'mg-c-input__input': true, 'mg-c-input__input--has-error': props.errorMessage !== undefined } },
147
- applyAriadescribedBy(children, ariaDescribedbyIDs, utils),
148
- props.tooltip && !props.readonly && !props.labelOnTop && (props.tooltipPosition === 'input' || props.labelHide) && getTooltip()),
149
- props.helpText && h("div", { id: helpTextId, class: "mg-c-input__help-text", innerHTML: props.helpText }),
150
- props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-c-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
151
- };
152
-
153
- export { Handler as H, MgInput as M };
154
-
155
- //# sourceMappingURL=MgInput.js.map
@@ -1 +0,0 @@
1
- {"file":"MgInput.js","mappings":";;;AAgCA;;;AAGO,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,CAAU,CAAC;AAkBlD;;;IAGY;AAAZ,WAAY,OAAO;IACjB,wBAAa,CAAA;IACb,0BAAe,CAAA;AACjB,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB;AAEM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAU;;ACzD3D;;;;;;;AAOA,MAAM,oBAAoB,GAAG,CAAC,QAAiB,EAAE,kBAA+B,EAAE,KAA0B,KAC1G,KAAK,CAAC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AG,CAAC,KAAK,KAC5B,UAAI,GAAG,EAAE,KAAK;gBACZ,kBAAS,KAAK,CAAU,CACrB,CACN,CAAC,CACC,KAEL,kBAAS,KAAK,CAAC,aAAa,CAAU,CACvC;YACA,QAAQ,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CACpE,KAEN,WAAK,KAAK,EAAC,6BAA6B;YACtC,WAAK,KAAK,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,8BAA8B,EAAE,KAAK,CAAC,YAAY,KAAK,SAAS,EAAE;gBACxG,oBAAoB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,KAAK,CAAC;gBACzD,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,eAAe,KAAK,OAAO,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,UAAU,EAAE,CAC5H;YACL,KAAK,CAAC,QAAQ,IAAI,WAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAC,uBAAuB,EAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,GAAQ;YACtG,KAAK,CAAC,YAAY,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,KACvD,WAAK,EAAE,EAAE,eAAe,EAAE,KAAK,EAAC,mBAAmB,EAAC,SAAS,EAAE,KAAK,CAAC,YAAY,eAAY,WAAW,GAAO,CAChH,CACG,CACP,CACO,EACV;AACJ;;;;","names":["isValidString"],"sources":["src/components/molecules/inputs/MgInput.conf.ts","src/components/molecules/inputs/MgInput.tsx"],"sourcesContent":["import type { MgInputTitle } from '../../atoms/mg-input-title/mg-input-title';\nimport type { ClassList } from '@mgdis/stencil-helpers';\n\n/**\n * MgInput component props\n */\nexport interface MgInputProps {\n // Global\n identifier: string;\n classCollection: ClassList;\n // Label\n label: string;\n labelOnTop: boolean;\n labelHide: boolean;\n isFieldset: MgInputTitle['isLegend'];\n // Input\n value: string;\n readonlyValue: string | string[];\n required: boolean;\n readonly: boolean;\n mgWidth: Width;\n disabled: boolean;\n // Tooltip\n tooltip: string;\n tooltipPosition: TooltipPosition;\n // Help Text\n helpText: string;\n // Error Message\n errorMessage: string;\n // ariaDescribedbyIDs\n ariaDescribedbyIDs: string[];\n}\n/**\n * Possible input width\n */\nexport const widths = [2, 4, 16, 'full'] as const;\n\nexport type Width = (typeof widths)[number];\n\n/**\n * Possible Input types\n */\nexport type HTMLMgInputsElement =\n | HTMLMgInputCheckboxElement\n | HTMLMgInputDateElement\n | HTMLMgInputNumericElement\n | HTMLMgInputPasswordElement\n | HTMLMgInputRadioElement\n | HTMLMgInputSelectElement\n | HTMLMgInputTextElement\n | HTMLMgInputTextareaElement\n | (HTMLMgInputToggleElement & { required: true; invalid: false; displayError: () => void });\n\n/**\n * Available handlers\n */\nexport enum Handler {\n BLUR = 'blur',\n FOCUS = 'focus',\n}\n\nexport const tooltipPositions = ['input', 'label'] as const;\n\nexport type TooltipPosition = (typeof tooltipPositions)[number];\n","import { FunctionalComponent, h, VNode, FunctionalUtilities } from '@stencil/core';\nimport { widths, tooltipPositions, type MgInputProps } from './MgInput.conf';\nimport { isValidString } from '@mgdis/stencil-helpers';\n\n/**\n * Apply in all input child node the aria-describedby attribute\n * @param children - Represent scoped elements\n * @param ariaDescribedbyIDs - List of IDs\n * @param utils - Stencil.js utils\n * @returns Children with aria-describedby attribute\n */\nconst applyAriadescribedBy = (children: VNode[], ariaDescribedbyIDs: Set<string>, utils: FunctionalUtilities): VNode[] =>\n utils.map(children, child => {\n if (['input', 'select', 'textarea'].includes(child.vtag as string)) {\n return {\n ...child,\n vattrs: {\n ...child.vattrs,\n 'aria-describedby': [...ariaDescribedbyIDs].join(' '),\n },\n };\n }\n\n // we recursively apply ariadescribedBy attributes to child input nodes if exists\n if (child.vchildren === null) return { ...child };\n return {\n ...child,\n vchildren: applyAriadescribedBy(child.vchildren, ariaDescribedbyIDs, utils),\n };\n });\n\n/**\n * Add classes based on props\n * @param props - MgInput Interface Props\n */\nconst manageClasses = (props: MgInputProps): void => {\n props.classCollection.add('mg-c-input');\n\n if (props.labelOnTop) props.classCollection.add('mg-c-input--label-on-top');\n else props.classCollection.delete('mg-c-input--label-on-top');\n\n if (props.readonly) props.classCollection.add('mg-c-input--readonly');\n else props.classCollection.delete('mg-c-input--readonly');\n\n widths.forEach(width => {\n props.classCollection.delete(`mg-c-input--width-${width}`);\n });\n if (props.mgWidth !== undefined) props.classCollection.add(`mg-c-input--width-${props.mgWidth}`);\n};\n\n/**\n * Check props configuration\n * @param props - MgInput Interface Props\n */\nconst checkPropsConfig = (props: MgInputProps): void => {\n if (!isValidString(props.identifier)) {\n throw new Error('<mg-input> prop \"identifier\" is required.');\n }\n if (!isValidString(props.label)) {\n throw new Error('<mg-input> prop \"label\" is required.');\n }\n if (props.labelOnTop && props.labelHide) {\n throw new Error('<mg-input> prop \"labelOnTop\" must not be paired with the prop \"labelHide\".');\n }\n if (!tooltipPositions.includes(props.tooltipPosition)) {\n throw new Error(`<mg-input> prop \"tooltipPosition\" must be one of: ${tooltipPositions.join(', ')}`);\n }\n};\n\n/**\n * Get tagname\n * @param isFieldset - is fieldset\n * @returns tag name\n */\nconst getTagName = (isFieldset: MgInputProps['isFieldset'], readOnly: MgInputProps['readonly']): string => (!isFieldset || readOnly ? 'div' : 'fieldset');\n\n/**\n * MgInput Interface\n */\n\n/**\n * Get input template\n * @param props - MgInput Interface Props\n * @param children - Represent scoped elements\n * @param utils - Stencil.js utils\n * @returns input template\n */\nexport const MgInput: FunctionalComponent<MgInputProps> = (props: MgInputProps, children: VNode[], utils: FunctionalUtilities): VNode[] => {\n /**\n * Check props config\n */\n checkPropsConfig(props);\n\n /**\n * Set readonly value\n */\n if (props.readonlyValue === undefined) props.readonlyValue = props.value;\n\n /**\n * Component classes\n */\n manageClasses(props);\n\n /**\n * a11y IDs\n */\n const ariaDescribedbyIDs: Set<string> = new Set(props.ariaDescribedbyIDs);\n\n // Help text\n const helpTextId = `${props.identifier}-help-text`;\n if (typeof props.helpText === 'string' && props.helpText !== '') {\n ariaDescribedbyIDs.add(helpTextId);\n }\n\n // Error Message\n const helpTextErrorId = `${props.identifier}-error`;\n if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {\n ariaDescribedbyIDs.add(helpTextErrorId);\n }\n\n /**\n * Return template\n *\n * +--------+---------+--------------+---------+\n * | label | tooltip | input | tooltip |\n * |--------+---------+--------------+---------+\n * | | nb Char Left |\n * | +------------------------+\n * | | Help Text |\n * | +------------------------+\n * | | Error |\n * +------------------+------------------------+\n *\n * Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change\n */\n\n const TagName = getTagName(props.isFieldset, props.readonly);\n\n /**\n * Get tooltip node\n * @returns mg-tooltip\n */\n const getTooltip = (): VNode[] => (\n <mg-tooltip identifier={`${props.identifier}-tooltip`} message={props.tooltip}>\n <mg-icon icon=\"info-circle\"></mg-icon>\n </mg-tooltip>\n );\n\n return (\n <TagName class={props.classCollection.join()}>\n <div class={{ 'mg-c-input__title': true, 'mg-u-visually-hidden': props.labelHide }}>\n <mg-input-title identifier={props.identifier} readonly={props.readonly} required={props.required && !props.disabled && !props.readonly} is-legend={props.isFieldset}>\n {props.label}\n </mg-input-title>\n {props.tooltip && !props.readonly && (props.tooltipPosition === 'label' || props.labelOnTop) && !props.labelHide && getTooltip()}\n </div>\n {props.readonly ? (\n <div class=\"mg-c-input__input-container\">\n {Array.isArray(props.readonlyValue) ? (\n <ul>\n {props.readonlyValue.map(value => (\n <li key={value}>\n <strong>{value}</strong>\n </li>\n ))}\n </ul>\n ) : (\n <strong>{props.readonlyValue}</strong>\n )}\n {children.filter(child => Object.values(child).includes('append-input'))}\n </div>\n ) : (\n <div class=\"mg-c-input__input-container\">\n <div class={{ 'mg-c-input__input': true, 'mg-c-input__input--has-error': props.errorMessage !== undefined }}>\n {applyAriadescribedBy(children, ariaDescribedbyIDs, utils)}\n {props.tooltip && !props.readonly && !props.labelOnTop && (props.tooltipPosition === 'input' || props.labelHide) && getTooltip()}\n </div>\n {props.helpText && <div id={helpTextId} class=\"mg-c-input__help-text\" innerHTML={props.helpText}></div>}\n {props.errorMessage && !props.readonly && !props.disabled && (\n <div id={helpTextErrorId} class=\"mg-c-input__error\" innerHTML={props.errorMessage} aria-live=\"assertive\"></div>\n )}\n </div>\n )}\n </TagName>\n );\n};\n"],"version":3}