@mgdis/mg-components 3.3.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/dist/cjs/{index-bead7dbd.js → index-88560a66.js} +47 -48
  2. package/dist/cjs/{index-369388eb.js → index-a39c5567.js} +97 -10
  3. package/dist/cjs/loader.cjs.js +3 -17
  4. package/dist/cjs/mg-badge_21.cjs.entry.js +461 -281
  5. package/dist/cjs/mg-components.cjs.js +3 -7
  6. package/dist/cjs/mg-modal.cjs.entry.js +12 -6
  7. package/dist/cjs/mg-popover.cjs.entry.js +15 -6
  8. package/dist/cjs/{popper-0c3964e7.js → popper-71bf3058.js} +6 -2
  9. package/dist/collection/collection-manifest.json +1 -1
  10. package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.js} +1 -1
  11. package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -2
  12. package/dist/collection/components/atoms/mg-badge/mg-badge.js +15 -3
  13. package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +2 -2
  14. package/dist/collection/components/atoms/mg-button/mg-button.css +6 -30
  15. package/dist/collection/components/atoms/mg-button/mg-button.js +7 -2
  16. package/dist/collection/components/atoms/mg-character-left/{mg-character-left.stories.js → doc/mg-character-left.stories.js} +1 -1
  17. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +10 -47
  18. package/dist/collection/components/atoms/mg-icon/{mg-icon.stories.js → doc/mg-icon.stories.js} +1 -1
  19. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +86 -10
  20. package/dist/collection/components/atoms/mg-icon/mg-icon.css +4 -0
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.js +22 -6
  22. package/dist/collection/components/atoms/mg-input-title/{mg-input-title.stories.js → doc/mg-input-title.stories.js} +0 -0
  23. package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +1 -1
  24. package/dist/collection/components/atoms/mg-tag/mg-tag.js +19 -4
  25. package/dist/collection/components/atoms/mg-tooltip/{mg-tooltip.stories.js → doc/mg-tooltip.stories.js} +14 -1
  26. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +20 -0
  27. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +7 -2
  28. package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
  29. package/dist/collection/components/molecules/inputs/MgInput.js +5 -15
  30. package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +0 -0
  31. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +19 -13
  32. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +8 -21
  33. package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +0 -0
  34. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +19 -18
  35. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +19 -18
  36. package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +9 -2
  37. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +20 -19
  38. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +43 -19
  39. package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +10 -1
  40. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +19 -18
  41. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +17 -22
  42. package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +0 -0
  43. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +19 -13
  44. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +8 -15
  45. package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +10 -3
  46. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +20 -18
  47. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +24 -31
  48. package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +11 -7
  49. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +51 -28
  50. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +42 -43
  51. package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +10 -4
  52. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +51 -22
  53. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +64 -37
  54. package/dist/collection/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.js → doc/mg-input-toggle.stories.js} +0 -0
  55. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +18 -9
  56. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +9 -3
  57. package/dist/collection/components/molecules/mg-form/{mg-form.stories.js → doc/mg-form.stories.js} +0 -0
  58. package/dist/collection/components/molecules/mg-form/mg-form.css +4 -0
  59. package/dist/collection/components/molecules/mg-form/mg-form.js +5 -3
  60. package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +1 -1
  61. package/dist/collection/components/molecules/mg-message/mg-message.js +15 -7
  62. package/dist/collection/components/molecules/mg-modal/{mg-modal.stories.js → doc/mg-modal.stories.js} +0 -0
  63. package/dist/collection/components/molecules/mg-modal/mg-modal.css +5 -7
  64. package/dist/collection/components/molecules/mg-modal/mg-modal.js +10 -4
  65. package/dist/collection/components/molecules/mg-pagination/{mg-pagination.stories.js → doc/mg-pagination.stories.js} +0 -0
  66. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +17 -18
  67. package/dist/collection/components/molecules/mg-panel/{mg-panel.stories.js → doc/mg-panel.stories.js} +0 -0
  68. package/dist/collection/components/molecules/mg-panel/mg-panel.css +5 -1
  69. package/dist/collection/components/molecules/mg-panel/mg-panel.js +10 -9
  70. package/dist/collection/components/molecules/mg-popover/{mg-popover.stories.js → doc/mg-popover.stories.js} +10 -0
  71. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +20 -0
  72. package/dist/collection/components/molecules/mg-popover/mg-popover.js +19 -5
  73. package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +11 -5
  74. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +7 -0
  75. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +3 -0
  76. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +72 -26
  77. package/dist/collection/locales/index.js +33 -4
  78. package/dist/collection/stories/helpers.stories.js +33 -0
  79. package/dist/collection/utils/locale.utils.js +7 -4
  80. package/dist/collection/variables.css +10 -5
  81. package/dist/collection/variables.scss +10 -5
  82. package/dist/components/MgInput.js +6 -23
  83. package/dist/components/index.d.ts +23 -5
  84. package/dist/components/index.js +23 -0
  85. package/dist/components/index2.js +97 -8
  86. package/dist/components/locale.utils.js +7 -5
  87. package/dist/components/mg-badge2.js +16 -4
  88. package/dist/components/mg-button2.js +8 -3
  89. package/dist/components/mg-character-left2.js +4 -27
  90. package/dist/components/mg-form.js +6 -4
  91. package/dist/components/mg-icon2.js +109 -17
  92. package/dist/components/mg-input-checkbox.js +11 -27
  93. package/dist/components/mg-input-date.js +21 -25
  94. package/dist/components/mg-input-numeric.js +28 -26
  95. package/dist/components/mg-input-password.js +18 -28
  96. package/dist/components/mg-input-radio.js +10 -22
  97. package/dist/components/mg-input-select2.js +24 -35
  98. package/dist/components/mg-input-text2.js +38 -26
  99. package/dist/components/mg-input-textarea.js +43 -20
  100. package/dist/components/mg-input-toggle.js +11 -11
  101. package/dist/components/mg-message.js +16 -8
  102. package/dist/components/mg-modal.js +11 -5
  103. package/dist/components/mg-pagination.js +16 -22
  104. package/dist/components/mg-panel.js +8 -7
  105. package/dist/components/mg-popover.js +13 -4
  106. package/dist/components/mg-tabs.js +75 -21
  107. package/dist/components/mg-tag.js +20 -5
  108. package/dist/components/mg-tooltip2.js +1 -1
  109. package/dist/components/popper.js +6 -2
  110. package/dist/esm/{index-9e877561.js → index-bca81100.js} +48 -46
  111. package/dist/esm/{index-c346f52d.js → index-e51ae032.js} +97 -8
  112. package/dist/esm/loader.js +3 -17
  113. package/dist/esm/mg-badge_21.entry.js +458 -278
  114. package/dist/esm/mg-components.js +3 -7
  115. package/dist/esm/mg-modal.entry.js +12 -6
  116. package/dist/esm/mg-popover.entry.js +15 -6
  117. package/dist/esm/{popper-8874fd6c.js → popper-93ecb064.js} +6 -2
  118. package/dist/index.js +1 -1
  119. package/dist/mg-components/mg-components.css +1 -1
  120. package/dist/mg-components/mg-components.esm.js +1 -1
  121. package/dist/mg-components/p-003a1344.entry.js +1 -0
  122. package/dist/mg-components/p-462d648a.entry.js +1 -0
  123. package/dist/mg-components/p-4c66f794.js +1 -0
  124. package/dist/mg-components/p-5126ab10.entry.js +1 -0
  125. package/dist/mg-components/p-780bd52d.js +1 -0
  126. package/dist/mg-components/p-b14a3443.js +2 -0
  127. package/dist/mg-components/variables.css +10 -5
  128. package/dist/mg-components/variables.scss +10 -5
  129. package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +0 -0
  130. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -1
  131. package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +0 -0
  132. package/dist/types/components/atoms/mg-button/mg-button.d.ts +1 -1
  133. package/dist/types/components/atoms/mg-character-left/{mg-character-left.stories.d.ts → doc/mg-character-left.stories.d.ts} +0 -0
  134. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +5 -13
  135. package/dist/types/components/atoms/mg-icon/{mg-icon.stories.d.ts → doc/mg-icon.stories.d.ts} +0 -0
  136. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +3 -3
  137. package/dist/types/components/atoms/mg-input-title/{mg-input-title.stories.d.ts → doc/mg-input-title.stories.d.ts} +0 -0
  138. package/dist/types/components/atoms/mg-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +0 -0
  139. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +8 -1
  140. package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +29 -0
  141. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +8 -0
  142. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +2 -1
  143. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +0 -6
  144. package/dist/types/components/molecules/inputs/MgInput.d.ts +2 -4
  145. package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +0 -0
  146. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -2
  147. package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +0 -0
  148. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +7 -1
  149. package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +6 -0
  150. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +8 -2
  151. package/dist/types/components/molecules/inputs/mg-input-password/{mg-input-password.stories.d.ts → doc/mg-input-password.stories.d.ts} +8 -0
  152. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +7 -2
  153. package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.stories.d.ts} +0 -0
  154. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -1
  155. package/dist/types/components/molecules/inputs/mg-input-select/{mg-input-select.stories.d.ts → doc/mg-input-select.stories.d.ts} +11 -5
  156. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +7 -2
  157. package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +8 -0
  158. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +7 -7
  159. package/dist/types/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.d.ts → doc/mg-input-textarea.stories.d.ts} +8 -0
  160. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +14 -6
  161. package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.stories.d.ts} +0 -0
  162. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -0
  163. package/dist/types/components/molecules/mg-form/{mg-form.stories.d.ts → doc/mg-form.stories.d.ts} +0 -0
  164. package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -0
  165. package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +0 -0
  166. package/dist/types/components/molecules/mg-message/mg-message.d.ts +2 -0
  167. package/dist/types/components/molecules/mg-modal/{mg-modal.stories.d.ts → doc/mg-modal.stories.d.ts} +0 -0
  168. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +2 -0
  169. package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +0 -0
  170. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +8 -0
  171. package/dist/types/components/molecules/mg-panel/{mg-panel.stories.d.ts → doc/mg-panel.stories.d.ts} +0 -0
  172. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +5 -0
  173. package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +25 -0
  174. package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +8 -0
  175. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +9 -1
  176. package/dist/types/components/molecules/mg-tabs/{mg-tabs.stories.d.ts → doc/mg-tabs.stories.d.ts} +0 -0
  177. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +7 -1
  178. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +44 -0
  179. package/dist/types/components.d.ts +149 -151
  180. package/dist/types/locales/index.d.ts +109 -46
  181. package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
  182. package/dist/types/utils/locale.utils.d.ts +7 -3
  183. package/loader/index.js +1 -1
  184. package/package.json +41 -14
  185. package/readme.md +6 -35
  186. package/dist/cjs/css-shim-629916b0.js +0 -6
  187. package/dist/cjs/shadow-css-546083ef.js +0 -390
  188. package/dist/collection/stories/buttons.stories.js +0 -43
  189. package/dist/collection/stories/messages.stories.js +0 -44
  190. package/dist/collection/stories/tags.stories.js +0 -13
  191. package/dist/esm/css-shim-0993aa3b.js +0 -4
  192. package/dist/esm/shadow-css-dfa0587f.js +0 -388
  193. package/dist/esm-es5/css-shim-0993aa3b.js +0 -1
  194. package/dist/esm-es5/index-9e877561.js +0 -1
  195. package/dist/esm-es5/index-c346f52d.js +0 -1
  196. package/dist/esm-es5/index.js +0 -0
  197. package/dist/esm-es5/loader.js +0 -1
  198. package/dist/esm-es5/mg-badge_21.entry.js +0 -2
  199. package/dist/esm-es5/mg-components.js +0 -1
  200. package/dist/esm-es5/mg-modal.entry.js +0 -1
  201. package/dist/esm-es5/mg-popover.entry.js +0 -1
  202. package/dist/esm-es5/popper-8874fd6c.js +0 -1
  203. package/dist/esm-es5/shadow-css-dfa0587f.js +0 -12
  204. package/dist/mg-components/mg-components.js +0 -132
  205. package/dist/mg-components/p-136c8d6f.system.entry.js +0 -2
  206. package/dist/mg-components/p-3c14153d.js +0 -1
  207. package/dist/mg-components/p-50ea2036.system.js +0 -1
  208. package/dist/mg-components/p-55a22b35.system.js +0 -1
  209. package/dist/mg-components/p-5e796581.js +0 -12
  210. package/dist/mg-components/p-656b5efb.system.js +0 -1
  211. package/dist/mg-components/p-68d6f104.js +0 -1
  212. package/dist/mg-components/p-6d49ed95.js +0 -1
  213. package/dist/mg-components/p-6f173f62.system.entry.js +0 -1
  214. package/dist/mg-components/p-70177194.entry.js +0 -1
  215. package/dist/mg-components/p-8b2d8a2a.system.js +0 -13
  216. package/dist/mg-components/p-8cb61c3f.system.js +0 -1
  217. package/dist/mg-components/p-ace173b1.js +0 -1
  218. package/dist/mg-components/p-b7488a4c.entry.js +0 -1
  219. package/dist/mg-components/p-c1ffb2e1.entry.js +0 -1
  220. package/dist/mg-components/p-c90cc4bf.system.js +0 -1
  221. package/dist/mg-components/p-de1164fa.system.entry.js +0 -1
  222. package/dist/mg-components/p-e4a502b5.system.js +0 -1
  223. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
  224. package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +0 -12
  225. package/dist/types/stories/messages.stories.d.ts +0 -13
  226. package/dist/types/stories/tags.stories.d.ts +0 -5
@@ -1,11 +1,8 @@
1
- import { Component, h, Prop, State, Watch, Event } from '@stencil/core';
1
+ import { Component, Element, h, Prop, State, Watch, Event } from '@stencil/core';
2
2
  import { createID, ClassList } from '../../../utils/components.utils';
3
- import { messages } from '../../../locales';
3
+ import { initLocales } from '../../../locales';
4
4
  export class MgPanel {
5
5
  constructor() {
6
- /**************
7
- * Decorators *
8
- **************/
9
6
  /**
10
7
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
11
8
  * If not set, it will be created.
@@ -106,17 +103,17 @@ export class MgPanel {
106
103
  if (this.titleEditable && !this.isEditing) {
107
104
  return [
108
105
  collapseButton(),
109
- h("mg-button", { "is-icon": true, variant: "flat", label: messages.panel.editLabel, onClick: this.handleEditButton, identifier: `${this.identifier}-edit-button` },
106
+ h("mg-button", { "is-icon": true, variant: "flat", class: "mg-panel__edit-button", label: this.messages.panel.editLabel, onClick: this.handleEditButton, identifier: `${this.identifier}-edit-button` },
110
107
  h("mg-icon", { icon: "pen" })),
111
108
  ];
112
109
  }
113
110
  if (this.titleEditable && this.isEditing) {
114
111
  return [
115
112
  collapseButton(),
116
- h("mg-input-text", { label: messages.panel.editLabel, "label-hide": true, value: this.panelTitle, "onValue-change": this.handleUpdateTitle, displayCharacterLeft: false, pattern: this.titlePattern, "pattern-error-message": this.titlePatternErrorMessage, identifier: `${this.identifier}-edition-input`, ref: el => (this.editInputElement = el) },
117
- h("mg-button", { slot: "append-input", label: messages.general.cancel, "is-icon": true, variant: "secondary", onClick: this.handleCancelEditButton, identifier: `${this.identifier}-edition-button-cancel` },
113
+ h("mg-input-text", { label: this.messages.panel.editLabel, "label-hide": true, value: this.panelTitle, "onValue-change": this.handleUpdateTitle, displayCharacterLeft: false, pattern: this.titlePattern, "pattern-error-message": this.titlePatternErrorMessage, identifier: `${this.identifier}-edition-input`, ref: el => (this.editInputElement = el) },
114
+ h("mg-button", { slot: "append-input", label: this.messages.general.cancel, "is-icon": true, variant: "secondary", onClick: this.handleCancelEditButton, identifier: `${this.identifier}-edition-button-cancel` },
118
115
  h("mg-icon", { icon: "cross" })),
119
- h("mg-button", { slot: "append-input", label: messages.general.validate, "is-icon": true, variant: "secondary", onClick: this.handleValidateEditButton, identifier: `${this.identifier}-edition-button-validate` },
116
+ h("mg-button", { slot: "append-input", label: this.messages.general.confirm, "is-icon": true, variant: "secondary", onClick: this.handleValidateEditButton, identifier: `${this.identifier}-edition-button-validate` },
120
117
  h("mg-icon", { icon: "check" }))),
121
118
  ];
122
119
  }
@@ -146,6 +143,9 @@ export class MgPanel {
146
143
  * @returns {void}
147
144
  */
148
145
  componentWillLoad() {
146
+ // Get locales
147
+ this.messages = initLocales(this.element).messages;
148
+ // Validate
149
149
  this.validatetitlePattern(this.titlePattern);
150
150
  }
151
151
  /**
@@ -342,6 +342,7 @@ export class MgPanel {
342
342
  "references": {}
343
343
  }
344
344
  }]; }
345
+ static get elementRef() { return "element"; }
345
346
  static get watchers() { return [{
346
347
  "propName": "panelTitle",
347
348
  "methodName": "handelTileChange"
@@ -1,4 +1,5 @@
1
1
  import { h } from '@stencil/core';
2
+ import { placements } from '../mg-popover.conf';
2
3
  export default {
3
4
  component: 'mg-popover',
4
5
  title: 'Molecules/mg-popover',
@@ -6,6 +7,15 @@ export default {
6
7
  layout: 'centered',
7
8
  docs: { iframeHeight: 600 },
8
9
  },
10
+ argTypes: {
11
+ placement: {
12
+ options: placements,
13
+ control: { type: 'select' },
14
+ table: {
15
+ defaultValue: { summary: placements[0] },
16
+ },
17
+ },
18
+ },
9
19
  };
10
20
  /**
11
21
  * 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * List of all possibles placements
3
+ */
4
+ export const placements = [
5
+ 'auto',
6
+ 'auto-start',
7
+ 'auto-end',
8
+ 'top',
9
+ 'top-start',
10
+ 'top-end',
11
+ 'bottom',
12
+ 'bottom-start',
13
+ 'bottom-end',
14
+ 'right',
15
+ 'right-start',
16
+ 'right-end',
17
+ 'left',
18
+ 'left-start',
19
+ 'left-end',
20
+ ];
@@ -1,7 +1,7 @@
1
1
  import { Component, Element, Host, h, Prop, Watch } from '@stencil/core';
2
2
  import { createID } from '../../../utils/components.utils';
3
3
  import { createPopper } from '@popperjs/core';
4
- import { messages } from '../../../locales';
4
+ import { initLocales } from '../../../locales';
5
5
  export class MgPopover {
6
6
  constructor() {
7
7
  this.closeButtonId = '';
@@ -66,7 +66,7 @@ export class MgPopover {
66
66
  this.popover.removeAttribute('data-show');
67
67
  // Disable the event listeners
68
68
  this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
69
- // Remove even listener
69
+ // Remove event listener
70
70
  document.removeEventListener('click', this.clickOutside, false);
71
71
  };
72
72
  /**
@@ -89,6 +89,15 @@ export class MgPopover {
89
89
  /*************
90
90
  * Lifecycle *
91
91
  *************/
92
+ /**
93
+ * Check if component props are well configured on init
94
+ *
95
+ * @returns {void} timeout
96
+ */
97
+ componentWillLoad() {
98
+ // Get locales
99
+ this.messages = initLocales(this.element).messages;
100
+ }
92
101
  /**
93
102
  * Check if component props are well configured on init
94
103
  *
@@ -145,7 +154,7 @@ export class MgPopover {
145
154
  return (h(Host, null,
146
155
  h("slot", null),
147
156
  h("div", { id: this.identifier, class: "mg-popover" },
148
- !this.disabled && this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: messages.general.close, onClick: this.handleCloseButton },
157
+ !this.disabled && this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton },
149
158
  h("mg-icon", { icon: "cross" }))),
150
159
  h("div", { class: "mg-popover__title" },
151
160
  h("slot", { name: "title" })),
@@ -183,9 +192,14 @@ export class MgPopover {
183
192
  "type": "string",
184
193
  "mutable": false,
185
194
  "complexType": {
186
- "original": "| 'auto'\n | 'auto-start'\n | 'auto-end'\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'left'\n | 'left-start'\n | 'left-end'",
195
+ "original": "Placement",
187
196
  "resolved": "\"auto\" | \"auto-end\" | \"auto-start\" | \"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
188
- "references": {}
197
+ "references": {
198
+ "Placement": {
199
+ "location": "import",
200
+ "path": "./mg-popover.conf"
201
+ }
202
+ }
189
203
  },
190
204
  "required": false,
191
205
  "optional": false,
@@ -1,5 +1,5 @@
1
1
  import { h } from '@stencil/core';
2
- import { sizes } from './mg-tabs.conf';
2
+ import { sizes, Status } from '../mg-tabs.conf';
3
3
  export default {
4
4
  component: 'mg-tabs',
5
5
  title: 'Molecules/mg-tabs',
@@ -22,17 +22,18 @@ const Template = args => {
22
22
  return (h("mg-tabs", Object.assign({}, args, { "active-tab": activeTab }),
23
23
  h("div", { slot: "tab_content-1" }, "Content 1"),
24
24
  h("div", { slot: "tab_content-2" }, "Content 2"),
25
- h("div", { slot: "tab_content-3" }, "Content 3")));
25
+ h("div", { slot: "tab_content-3" }, "Content 3"),
26
+ h("div", { slot: "tab_content-4" }, "Content 4")));
26
27
  };
27
28
  export const MgTabs = Template.bind({});
28
29
  MgTabs.args = {
29
- items: ['Tab 1', 'Tab 2', 'Tab 3'],
30
+ items: ['Tab 1', 'Tab 2', 'Tab 3', 'Tab 4'],
30
31
  label: 'Short tabs description. Needed for accessibility',
31
32
  activeTab: undefined,
32
33
  size: sizes[0], // regular
33
34
  };
34
35
  export const MgTabsItems = Template.bind({});
35
- MgTabsItems.args = Object.assign(Object.assign({}, MgTabs.args), { items: [
36
+ MgTabsItems.args = Object.assign(Object.assign({}, MgTabs.args), { activeTab: 3, items: [
36
37
  {
37
38
  label: 'Tab 1',
38
39
  icon: 'check',
@@ -41,10 +42,15 @@ MgTabsItems.args = Object.assign(Object.assign({}, MgTabs.args), { items: [
41
42
  {
42
43
  label: 'Tab 2',
43
44
  badge: { value: 5, label: 'messages' },
44
- disabled: true,
45
+ status: Status.DISABLED,
45
46
  },
46
47
  {
47
48
  label: 'Tab 3',
48
49
  icon: 'cross',
49
50
  },
51
+ {
52
+ label: 'Tab 4',
53
+ icon: 'trash',
54
+ status: Status.HIDDEN,
55
+ },
50
56
  ] });
@@ -1,3 +1,10 @@
1
+ export var Status;
2
+ (function (Status) {
3
+ Status["VISIBLE"] = "visible";
4
+ Status["HIDDEN"] = "hidden";
5
+ Status["DISABLED"] = "disabled";
6
+ Status["ACTIVE"] = "active";
7
+ })(Status || (Status = {}));
1
8
  /**
2
9
  * List of all possibles sizes
3
10
  */
@@ -35,6 +35,9 @@
35
35
  border-bottom-color: hsl(var(--color-info));
36
36
  font-weight: 700;
37
37
  }
38
+ .mg-tabs__navigation-button.mg-tabs__navigation-button--hidden {
39
+ display: none;
40
+ }
38
41
 
39
42
  .mg-tabs__content-container:focus-visible {
40
43
  outline: none;
@@ -1,6 +1,6 @@
1
1
  import { Component, Event, h, Host, Prop, State, Element, Watch } from '@stencil/core';
2
2
  import { createID, ClassList, allItemsAreString } from '../../../utils/components.utils';
3
- import { sizes } from './mg-tabs.conf';
3
+ import { sizes, Status } from './mg-tabs.conf';
4
4
  /**
5
5
  * type TabItem validation function
6
6
  *
@@ -10,6 +10,12 @@ import { sizes } from './mg-tabs.conf';
10
10
  const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
11
11
  export class MgTabs {
12
12
  constructor() {
13
+ /************
14
+ * Internal *
15
+ ************/
16
+ this.tabPanel = 'panel';
17
+ this.startIndex = 1;
18
+ this.buttonTabBaseClass = 'mg-tabs__navigation-button';
13
19
  /**
14
20
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
15
21
  * If not set, it will be created.
@@ -32,6 +38,46 @@ export class MgTabs {
32
38
  * Component classes
33
39
  */
34
40
  this.classList = new ClassList(['mg-tabs']);
41
+ /**
42
+ * Method to set active tab
43
+ *
44
+ * @param {number} tabKey item tab key to set to ACTIVE status
45
+ * @returns {void}
46
+ */
47
+ this.setActiveTab = (tabKey) => {
48
+ // reset active tabs
49
+ this.tabs.forEach(tab => {
50
+ if (this.tabHasGivenStatus(tab, Status.ACTIVE))
51
+ tab.status = Status.VISIBLE;
52
+ });
53
+ // set active tab from given tab key
54
+ this.tabs[tabKey - this.startIndex].status = Status.ACTIVE;
55
+ // emit change active tab key event
56
+ this.activeTabChange.emit(tabKey);
57
+ };
58
+ /**
59
+ * Method to know if given tab has the given status
60
+ *
61
+ * @param {TabItem} tab item tab key to set to ACTIVE status
62
+ * @param {Status} status status to valide
63
+ * @returns {boolean} status comparaison
64
+ */
65
+ this.tabHasGivenStatus = (tab, status) => tab.status === status;
66
+ /**
67
+ * Method to get element id from index
68
+ *
69
+ * @param {string} element to get id
70
+ * @param {number} index to generate id
71
+ * @returns {string} generated element id
72
+ */
73
+ this.getElementId = (element, index) => `${element}-${this.getTabIndex(index)}`;
74
+ /**
75
+ * Method to get tab index
76
+ *
77
+ * @param {number} index to get
78
+ * @returns {number} index
79
+ */
80
+ this.getTabIndex = (index) => index + this.startIndex;
35
81
  /**
36
82
  * Handle click events on tabs
37
83
  *
@@ -41,6 +87,14 @@ export class MgTabs {
41
87
  const tabId = event.currentTarget.getAttribute('data-index');
42
88
  this.activeTab = Number(tabId);
43
89
  };
90
+ /**
91
+ * get navigation button class from given status
92
+ *
93
+ * @param {Status} status button tab status
94
+ * @param {boolean} isSelector set if we need a CSS selector with the dot '.' at the begin. default value = false.
95
+ * @returns {string} button class/selector variant
96
+ */
97
+ this.getNavigationButtonClass = (status, isSelector = false) => `${isSelector ? '.' : ''}${this.buttonTabBaseClass}--${status}`;
44
98
  /**
45
99
  * Handle keyboard event on tabs
46
100
  *
@@ -51,16 +105,14 @@ export class MgTabs {
51
105
  let tabId = Number(event.target.getAttribute('data-index'));
52
106
  const parent = event.target.parentElement;
53
107
  // change selected id from key code
54
- // /* IE FIX */ delete 'Right'
55
- if (['ArrowRight', 'Right'].includes(event.key)) {
108
+ if (event.key === 'ArrowRight') {
56
109
  tabId++;
57
- // /* IE FIX */ delete 'Left'
58
110
  }
59
- else if (['ArrowLeft', 'Left'].includes(event.key)) {
111
+ else if (event.key === 'ArrowLeft') {
60
112
  tabId--;
61
113
  }
62
- // get selected tab
63
- const selectedTab = parent.querySelector(`[data-index="${tabId}"]`);
114
+ // get selected tab if NOT hidden, disabled
115
+ const selectedTab = parent.querySelector(`[data-index="${tabId}"]:not(${[this.getNavigationButtonClass(Status.HIDDEN, true), this.getNavigationButtonClass(Status.DISABLED, true)].join()})`);
64
116
  // apply selected tab if exist
65
117
  if (selectedTab !== null) {
66
118
  selectedTab.focus();
@@ -86,7 +138,7 @@ export class MgTabs {
86
138
  validateItems(newValue) {
87
139
  // String array
88
140
  if (allItemsAreString(newValue)) {
89
- this.tabs = newValue.map(item => ({ label: item, disabled: false }));
141
+ this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
90
142
  }
91
143
  // Object array
92
144
  else if (newValue && newValue.every(item => isTabItem(item))) {
@@ -101,7 +153,7 @@ export class MgTabs {
101
153
  throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
102
154
  }
103
155
  else {
104
- this.activeTabChange.emit(newValue);
156
+ this.setActiveTab(newValue);
105
157
  }
106
158
  }
107
159
  /*************
@@ -127,25 +179,19 @@ export class MgTabs {
127
179
  render() {
128
180
  return (h(Host, null,
129
181
  h("div", { class: this.classList.join() },
130
- h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => {
131
- const tabIndex = index + 1;
132
- return (h("button", { role: "tab", id: `${this.identifier}-${tabIndex}`, class: {
133
- 'mg-tabs__navigation-button': true,
134
- 'mg-tabs__navigation-button--active': tabIndex === this.activeTab,
135
- 'mg-tabs__navigation-button--disabled': tab.disabled,
136
- }, tabindex: tabIndex === this.activeTab ? 0 : -1, "aria-selected": (tabIndex === this.activeTab).toString(), "aria-controls": `pannel-${tabIndex}`, onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": tabIndex, disabled: tab.disabled },
137
- tab.icon !== undefined && h("mg-icon", { icon: tab.icon }),
138
- tab.label,
139
- tab.badge !== undefined && h("mg-badge", { variant: "info", value: tab.badge.value, label: tab.badge.label })));
140
- })),
141
- this.tabs.map((_tab, index) => {
142
- const tabIndex = index + 1;
143
- return (h("article", { role: "tabpanel", id: `pannel-${tabIndex}`, hidden: tabIndex !== this.activeTab, "aria-labelledby": `${this.identifier}-${this.activeTab}`, tabindex: tabIndex === this.activeTab ? 0 : -1, class: "mg-tabs__content-container" },
144
- h("slot", { name: `tab_content-${tabIndex}` })));
145
- }))));
182
+ h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => (h("button", { role: "tab", id: this.getElementId(this.identifier, index), class: {
183
+ [`${this.buttonTabBaseClass}`]: true,
184
+ [`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasGivenStatus(tab, Status.ACTIVE),
185
+ [`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasGivenStatus(tab, Status.DISABLED),
186
+ [`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasGivenStatus(tab, Status.HIDDEN),
187
+ }, tabindex: this.tabHasGivenStatus(tab, Status.ACTIVE) ? 0 : -1, "aria-selected": this.tabHasGivenStatus(tab, Status.ACTIVE).toString(), "aria-controls": this.getElementId(this.tabPanel, index), onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": this.getTabIndex(index), disabled: this.tabHasGivenStatus(tab, Status.DISABLED) },
188
+ tab.icon !== undefined && h("mg-icon", { icon: tab.icon }),
189
+ tab.label,
190
+ tab.badge !== undefined && h("mg-badge", { variant: "info", value: tab.badge.value, label: tab.badge.label }))))),
191
+ this.tabs.map((tab, index) => (h("article", { role: "tabpanel", id: this.getElementId(this.tabPanel, index), hidden: !this.tabHasGivenStatus(tab, Status.ACTIVE), "aria-labelledby": this.getElementId(this.identifier, index), tabindex: this.tabHasGivenStatus(tab, Status.ACTIVE) ? 0 : -1, class: "mg-tabs__content-container" },
192
+ h("slot", { name: this.getElementId('tab_content', index) })))))));
146
193
  }
147
194
  static get is() { return "mg-tabs"; }
148
- static get encapsulation() { return "scoped"; }
149
195
  static get originalStyleUrls() { return {
150
196
  "$": ["mg-tabs.scss"]
151
197
  }; }
@@ -1,4 +1,33 @@
1
- export const locale = 'fr-FR';
2
- import fr from './fr-FR/messages.json';
3
- export const messages = fr;
4
- export const currency = 'EUR';
1
+ import en from './en/messages.json';
2
+ import fr from './fr/messages.json';
3
+ const defaultLocale = 'en';
4
+ const messages = { en, fr };
5
+ /**
6
+ * Get locale
7
+ *
8
+ * @param {HTMLElement} element element that needs to know the locale to use
9
+ * @returns {string} locale
10
+ */
11
+ const getLocale = (element) => {
12
+ var _a;
13
+ return ((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang) || navigator.language || defaultLocale;
14
+ };
15
+ /**
16
+ * Get Intl object
17
+ * We load the defined locale but for now we only support the first subtag for messages
18
+ *
19
+ * @param {HTMLElement} element element we need to get the language
20
+ * @returns {{ locale: string; messages: unknown }} messages object
21
+ */
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ export const initLocales = (element) => {
24
+ // Get local
25
+ const locale = getLocale(element);
26
+ // Only keep first subtag
27
+ const localeSubtag = locale.split('-').shift();
28
+ // Return
29
+ return {
30
+ locale,
31
+ messages: messages[localeSubtag] || messages[defaultLocale],
32
+ };
33
+ };
@@ -0,0 +1,33 @@
1
+ import { h } from '@stencil/core';
2
+ export default {
3
+ title: 'Style/Helpers',
4
+ argTypes: {
5
+ align: {
6
+ options: ['left', 'right'],
7
+ control: { type: 'select' },
8
+ },
9
+ },
10
+ };
11
+ const Template = args => (h("div", null,
12
+ h("h1", null, "Helpers"),
13
+ h("h2", null, ".mg-group-elements"),
14
+ h("p", null,
15
+ "Buttons can be grouped in an HTMLelement using the ",
16
+ h("code", null, ".mg-group-elements"),
17
+ " class, it will ensure a 10px margin space between them, even verticaly. Above exemples are using it."),
18
+ h("p", null,
19
+ "By adding the ",
20
+ h("code", null, ".mg-group-elements--align-right"),
21
+ " class you 'll set a right alignment of the button, even when line breaks."),
22
+ h("h3", null, "Demo"),
23
+ h("div", { class: `mg-group-elements${args.align === 'right' ? ' mg-group-elements--align-right' : ''}` },
24
+ h("mg-button", null, "First Button"),
25
+ h("mg-button", { label: "" },
26
+ h("mg-icon", { icon: "info-circle" }),
27
+ "Second Button"),
28
+ h("mg-button", { "is-icon": true, label: "Third button" },
29
+ h("mg-icon", { icon: "info-circle" })))));
30
+ export const Helpers = Template.bind({});
31
+ Helpers.args = {
32
+ align: 'left',
33
+ };
@@ -1,20 +1,22 @@
1
- import { locale, currency } from '../locales';
2
1
  /**
3
2
  * Format number to the locale currency
4
3
  *
5
4
  * @param {number} number number to format
5
+ * @param {string} locale locale to apply
6
+ * @param {string} currency currency to apply
6
7
  * @returns {string} formatted currency
7
8
  */
8
- export function localeCurrency(number) {
9
+ export function localeCurrency(number, locale, currency) {
9
10
  return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
10
11
  }
11
12
  /**
12
13
  * Format number to locale
13
14
  *
14
15
  * @param {number} number number to format
16
+ * @param {string} locale locale to apply
15
17
  * @returns {string} formatted number
16
18
  */
17
- export function localeNumber(number) {
19
+ export function localeNumber(number, locale) {
18
20
  return new Intl.NumberFormat(locale).format(number);
19
21
  }
20
22
  /**
@@ -25,9 +27,10 @@ export const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
25
27
  * Locale date format
26
28
  *
27
29
  * @param {string} date date to format
30
+ * @param {string} locale locale to apply
28
31
  * @returns {string} formatted date
29
32
  */
30
- export function localeDate(date) {
33
+ export function localeDate(date, locale) {
31
34
  if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
32
35
  return '';
33
36
  }
@@ -53,11 +53,11 @@
53
53
  --color-info: var(--color-info-h), var(--color-info-s), var(--color-info-l);
54
54
 
55
55
  /* Danger */
56
- /* #df242c; */
57
- /* rgb(223, 36, 44); */
56
+ /* #db1f29; */
57
+ /* rgb(219, 31, 41); */
58
58
  --color-danger-h: 357;
59
- --color-danger-s: 74.5%;
60
- --color-danger-l: 50.8%;
59
+ --color-danger-s: 75%;
60
+ --color-danger-l: 49%;
61
61
  --color-danger: var(--color-danger-h), var(--color-danger-s), var(--color-danger-l);
62
62
 
63
63
  /* Dark */
@@ -99,6 +99,7 @@
99
99
  /*
100
100
  <mg-icon>
101
101
  */
102
+ --mg-icon-small-size: 1.2rem;
102
103
  --mg-icon-regular-size: 1.6rem;
103
104
  --mg-icon-large-size: 2.4rem;
104
105
  --mg-icon-extra-large-size: 3.6rem;
@@ -111,6 +112,7 @@
111
112
  --mg-button-icon-border-radius: var(--default-size);
112
113
  --mg-button-disabled-opacity: 0.6;
113
114
  --mg-button-gradient: 1; /* Can only be 1 or 0 to enable disable gradient */
115
+ --mg-button-border-variation: 1; /* Can only be 1 or 0 to enable disable border variation */
114
116
 
115
117
  /* Primary */
116
118
  --mg-button-primary-color-h: var(--color-dark-h);
@@ -161,7 +163,7 @@
161
163
  */
162
164
  --mg-modal-border-radius: 0.5rem;
163
165
  --mg-modal-title-font-size: 1.8rem;
164
- --mg-modal-content-font-size: 1.3rem;
166
+ --mg-modal-content-font-size: 1.2rem;
165
167
 
166
168
  /*
167
169
  <mg-panel>
@@ -187,6 +189,9 @@
187
189
  --mg-inputs-color: #b5c2c9;
188
190
  --mg-inputs-spacer: 1rem;
189
191
 
192
+ /* Error message background */
193
+ --mg-inputs-error-bg-color: var(--color-danger-h), calc(var(--color-danger-s) + 5%), calc(var(--color-danger-l) + 49%);
194
+
190
195
  /* Input focus shadow */
191
196
  /* #b5c2c9 */
192
197
  /* rgb(0, 221, 255); */
@@ -53,11 +53,11 @@
53
53
  --color-info: var(--color-info-h), var(--color-info-s), var(--color-info-l);
54
54
 
55
55
  /* Danger */
56
- /* #df242c; */
57
- /* rgb(223, 36, 44); */
56
+ /* #db1f29; */
57
+ /* rgb(219, 31, 41); */
58
58
  --color-danger-h: 357;
59
- --color-danger-s: 74.5%;
60
- --color-danger-l: 50.8%;
59
+ --color-danger-s: 75%;
60
+ --color-danger-l: 49%;
61
61
  --color-danger: var(--color-danger-h), var(--color-danger-s), var(--color-danger-l);
62
62
 
63
63
  /* Dark */
@@ -99,6 +99,7 @@
99
99
  /*
100
100
  <mg-icon>
101
101
  */
102
+ --mg-icon-small-size: 1.2rem;
102
103
  --mg-icon-regular-size: 1.6rem;
103
104
  --mg-icon-large-size: 2.4rem;
104
105
  --mg-icon-extra-large-size: 3.6rem;
@@ -111,6 +112,7 @@
111
112
  --mg-button-icon-border-radius: var(--default-size);
112
113
  --mg-button-disabled-opacity: 0.6;
113
114
  --mg-button-gradient: 1; /* Can only be 1 or 0 to enable disable gradient */
115
+ --mg-button-border-variation: 1; /* Can only be 1 or 0 to enable disable border variation */
114
116
 
115
117
  /* Primary */
116
118
  --mg-button-primary-color-h: var(--color-dark-h);
@@ -161,7 +163,7 @@
161
163
  */
162
164
  --mg-modal-border-radius: 0.5rem;
163
165
  --mg-modal-title-font-size: 1.8rem;
164
- --mg-modal-content-font-size: 1.3rem;
166
+ --mg-modal-content-font-size: 1.2rem;
165
167
 
166
168
  /*
167
169
  <mg-panel>
@@ -187,6 +189,9 @@
187
189
  --mg-inputs-color: #b5c2c9;
188
190
  --mg-inputs-spacer: 1rem;
189
191
 
192
+ /* Error message background */
193
+ --mg-inputs-error-bg-color: var(--color-danger-h), calc(var(--color-danger-s) + 5%), calc(var(--color-danger-l) + 49%);
194
+
190
195
  /* Input focus shadow */
191
196
  /* #b5c2c9 */
192
197
  /* rgb(0, 221, 255); */
@@ -1,13 +1,5 @@
1
1
  import { h } from '@stencil/core/internal/client';
2
2
 
3
- /**
4
- * Possible input classes
5
- */
6
- var InputClass;
7
- (function (InputClass) {
8
- InputClass["ERROR"] = "is-not-valid";
9
- })(InputClass || (InputClass = {}));
10
-
11
3
  /**
12
4
  * Apply in all input child node the aria-describedby attribute
13
5
  *
@@ -36,11 +28,8 @@ const manageClasses = (props) => {
36
28
  props.classList.add('mg-input--label-on-top');
37
29
  if (props.readonly)
38
30
  props.classList.add('mg-input--readonly');
39
- if (props.width !== undefined)
40
- props.classList.add(`mg-input--width-${props.width}`);
41
- if (props.readonly || props.disabled) {
42
- props.classList.delete(InputClass.ERROR);
43
- }
31
+ if (props.mgWidth !== undefined)
32
+ props.classList.add(`mg-input--width-${props.mgWidth}`);
44
33
  };
45
34
  /**
46
35
  * Get tagname
@@ -74,12 +63,7 @@ const MgInput = (props, children, utils) => {
74
63
  /**
75
64
  * a11y IDs
76
65
  */
77
- const ariaDescribedbyIDs = new Set();
78
- // Character Left
79
- const characterLeftId = `${props.identifier}-character-left`;
80
- if (props.classList.has('is-focused') && props.displayCharacterLeft) {
81
- ariaDescribedbyIDs.add(characterLeftId);
82
- }
66
+ const ariaDescribedbyIDs = new Set(props.ariaDescribedbyIDs);
83
67
  // Help text
84
68
  const helpTextId = `${props.identifier}-help-text`;
85
69
  if (typeof props.helpText === 'string' && props.helpText !== '') {
@@ -135,12 +119,11 @@ const MgInput = (props, children, utils) => {
135
119
  props.readonly ? (h("div", { class: "mg-input__input-container" },
136
120
  h("strong", null, props.readonlyValue || props.value),
137
121
  children)) : (h("div", { class: "mg-input__input-container" },
138
- h("div", { class: "mg-input__input" },
122
+ h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } },
139
123
  children,
140
124
  !props.labelOnTop && props.tooltip && getTooltip()),
141
- props.displayCharacterLeft && props.maxlength && props.classList.has('is-focused') && (h("mg-character-left", { identifier: characterLeftId, characters: props.value, maxlength: props.maxlength, template: props.characterLeftTemplate })),
142
125
  props.helpText && h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }),
143
- props.errorMessage && h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" })))));
126
+ props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
144
127
  };
145
128
 
146
- export { InputClass as I, MgInput as M };
129
+ export { MgInput as M };