@mgdis/mg-components 3.1.0 → 3.2.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 (225) hide show
  1. package/dist/cjs/css-shim-629916b0.js +6 -0
  2. package/dist/cjs/index-369388eb.js +146 -0
  3. package/dist/cjs/{index-85a4a0b6.js → index-bead7dbd.js} +78 -2
  4. package/dist/cjs/loader.cjs.js +4 -4
  5. package/dist/cjs/mg-badge_21.cjs.entry.js +3313 -0
  6. package/dist/cjs/mg-components.cjs.js +3 -3
  7. package/dist/cjs/mg-modal.cjs.entry.js +111 -0
  8. package/dist/cjs/mg-popover.cjs.entry.js +165 -0
  9. package/dist/cjs/popper-0c3964e7.js +1786 -0
  10. package/dist/cjs/{shadow-css-8940f82d.js → shadow-css-546083ef.js} +1 -1
  11. package/dist/collection/collection-manifest.json +4 -1
  12. package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
  13. package/dist/collection/components/atoms/mg-badge/mg-badge.js +11 -7
  14. package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +3 -0
  15. package/dist/collection/components/atoms/mg-button/mg-button.css +26 -17
  16. package/dist/collection/components/atoms/mg-button/mg-button.js +71 -2
  17. package/dist/collection/components/atoms/mg-button/mg-button.stories.js +5 -0
  18. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +12 -1
  19. package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +8 -0
  20. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +8 -0
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.css +5 -7
  22. package/dist/collection/components/atoms/mg-icon/mg-icon.js +11 -1
  23. package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +4 -4
  24. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +14 -3
  25. package/dist/collection/components/atoms/mg-tag/mg-tag.js +10 -3
  26. package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +3 -0
  27. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +9 -0
  28. package/dist/collection/components/molecules/inputs/MgInput.js +20 -14
  29. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +9 -1
  30. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +103 -40
  31. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +6 -1
  32. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +27 -0
  33. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +125 -56
  34. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +6 -1
  35. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +27 -0
  36. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +144 -68
  37. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +6 -1
  38. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +27 -0
  39. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +101 -35
  40. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +6 -1
  41. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +9 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +115 -37
  43. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +6 -1
  44. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +28 -1
  45. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +132 -51
  46. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +14 -1
  47. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +27 -0
  48. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +155 -53
  49. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +7 -2
  50. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +27 -0
  51. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +108 -42
  52. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +7 -2
  53. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +4 -1
  54. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +60 -31
  55. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +6 -1
  56. package/dist/collection/components/molecules/mg-form/mg-form.css +15 -0
  57. package/dist/collection/components/molecules/mg-form/mg-form.js +269 -0
  58. package/dist/collection/components/molecules/mg-form/mg-form.stories.js +58 -0
  59. package/dist/collection/components/molecules/mg-message/mg-message.css +1 -1
  60. package/dist/collection/components/molecules/mg-message/mg-message.js +11 -4
  61. package/dist/collection/components/molecules/mg-message/mg-message.stories.js +5 -1
  62. package/dist/collection/components/molecules/mg-modal/mg-modal.css +54 -0
  63. package/dist/collection/components/molecules/mg-modal/mg-modal.js +233 -0
  64. package/dist/collection/components/molecules/mg-modal/mg-modal.stories.js +51 -0
  65. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +32 -12
  66. package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +1 -0
  67. package/dist/collection/components/molecules/mg-panel/mg-panel.css +42 -0
  68. package/dist/collection/components/molecules/mg-panel/mg-panel.js +255 -0
  69. package/dist/collection/components/molecules/mg-panel/mg-panel.stories.js +31 -0
  70. package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -2
  71. package/dist/collection/components/molecules/mg-popover/mg-popover.js +19 -4
  72. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +4 -1
  73. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +14 -3
  74. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +68 -20
  75. package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +10 -1
  76. package/dist/collection/stories/messages.stories.js +1 -1
  77. package/dist/collection/utils/components.utils.js +16 -9
  78. package/dist/collection/utils/locale.utils.js +6 -3
  79. package/dist/collection/utils/test.utils.js +27 -15
  80. package/dist/collection/variables.css +30 -1
  81. package/dist/collection/variables.scss +30 -1
  82. package/dist/components/MgInput.js +20 -14
  83. package/dist/components/components.utils.js +16 -9
  84. package/dist/components/index.d.ts +1 -1
  85. package/dist/components/index2.js +22 -12
  86. package/dist/components/locale.utils.js +6 -3
  87. package/dist/components/mg-badge2.js +9 -5
  88. package/dist/components/mg-button2.js +21 -2
  89. package/dist/components/mg-character-left2.js +12 -1
  90. package/dist/components/mg-form.d.ts +11 -0
  91. package/dist/components/mg-form.js +146 -0
  92. package/dist/components/mg-icon2.js +20 -2
  93. package/dist/components/mg-input-checkbox.js +65 -36
  94. package/dist/components/mg-input-date.js +87 -52
  95. package/dist/components/mg-input-numeric.js +105 -63
  96. package/dist/components/mg-input-password.js +60 -29
  97. package/dist/components/mg-input-radio.js +74 -34
  98. package/dist/components/mg-input-select2.js +89 -46
  99. package/dist/components/mg-input-text.js +1 -237
  100. package/dist/components/mg-input-text2.js +288 -0
  101. package/dist/components/mg-input-textarea.js +67 -36
  102. package/dist/components/mg-input-title2.js +13 -4
  103. package/dist/components/mg-input-toggle.js +30 -22
  104. package/dist/components/mg-message.js +10 -3
  105. package/dist/components/mg-modal.d.ts +11 -0
  106. package/dist/components/mg-modal.js +147 -0
  107. package/dist/components/mg-pagination.js +31 -11
  108. package/dist/components/mg-panel.d.ts +11 -0
  109. package/dist/components/mg-panel.js +210 -0
  110. package/dist/components/mg-popover.js +20 -5
  111. package/dist/components/mg-tabs.js +43 -11
  112. package/dist/components/mg-tag.js +8 -1
  113. package/dist/components/mg-tooltip2.js +9 -0
  114. package/dist/esm/css-shim-0993aa3b.js +4 -0
  115. package/dist/esm/{index-e3e84606.js → index-9e877561.js} +78 -2
  116. package/dist/esm/index-c346f52d.js +139 -0
  117. package/dist/esm/loader.js +4 -4
  118. package/dist/esm/mg-badge_21.entry.js +3289 -0
  119. package/dist/esm/mg-components.js +3 -3
  120. package/dist/esm/mg-modal.entry.js +107 -0
  121. package/dist/esm/mg-popover.entry.js +161 -0
  122. package/dist/esm/polyfills/css-shim.js +1 -1
  123. package/dist/esm/popper-8874fd6c.js +1784 -0
  124. package/dist/esm/{shadow-css-5d2d01ce.js → shadow-css-dfa0587f.js} +1 -1
  125. package/dist/esm-es5/css-shim-0993aa3b.js +1 -0
  126. package/dist/esm-es5/index-9e877561.js +1 -0
  127. package/dist/esm-es5/index-c346f52d.js +1 -0
  128. package/dist/esm-es5/loader.js +1 -1
  129. package/dist/esm-es5/mg-badge_21.entry.js +2 -0
  130. package/dist/esm-es5/mg-components.js +1 -1
  131. package/dist/esm-es5/mg-modal.entry.js +1 -0
  132. package/dist/esm-es5/mg-popover.entry.js +1 -0
  133. package/dist/esm-es5/popper-8874fd6c.js +1 -0
  134. package/dist/esm-es5/{shadow-css-5d2d01ce.js → shadow-css-dfa0587f.js} +0 -0
  135. package/dist/mg-components/mg-components.css +1 -1
  136. package/dist/mg-components/mg-components.esm.js +1 -1
  137. package/dist/mg-components/mg-components.js +2 -2
  138. package/dist/mg-components/p-3633e9e1.system.entry.js +2 -0
  139. package/dist/mg-components/p-3c14153d.js +1 -0
  140. package/dist/mg-components/p-55a22b35.system.js +1 -0
  141. package/dist/mg-components/{p-f6455ab3.js → p-5e796581.js} +0 -0
  142. package/dist/mg-components/p-656b5efb.system.js +1 -0
  143. package/dist/mg-components/p-68d6f104.js +1 -0
  144. package/dist/mg-components/{p-366a224e.js → p-6d49ed95.js} +1 -1
  145. package/dist/mg-components/p-70177194.entry.js +1 -0
  146. package/dist/mg-components/{p-71d57b8b.system.js → p-8b2d8a2a.system.js} +0 -0
  147. package/dist/mg-components/p-8cb61c3f.system.js +1 -0
  148. package/dist/mg-components/p-ace173b1.js +1 -0
  149. package/dist/mg-components/p-c46fbd54.entry.js +1 -0
  150. package/dist/mg-components/p-c90cc4bf.system.js +1 -0
  151. package/dist/mg-components/p-cd2a4acc.system.entry.js +1 -0
  152. package/dist/mg-components/p-de1164fa.system.entry.js +1 -0
  153. package/dist/mg-components/p-dfe25da3.entry.js +1 -0
  154. package/dist/mg-components/p-e4a502b5.system.js +1 -0
  155. package/dist/mg-components/variables.css +30 -1
  156. package/dist/mg-components/variables.scss +30 -1
  157. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -4
  158. package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +5 -0
  159. package/dist/types/components/atoms/mg-button/mg-button.d.ts +22 -2
  160. package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +5 -0
  161. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +13 -2
  162. package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +9 -0
  163. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +1 -1
  164. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +11 -1
  165. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +11 -1
  166. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +10 -3
  167. package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +5 -0
  168. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -2
  169. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +8 -0
  170. package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -4
  171. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +31 -11
  172. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +5 -0
  173. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +39 -14
  174. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +5 -0
  175. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +53 -14
  176. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +5 -0
  177. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +28 -9
  178. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +5 -0
  179. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
  180. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +37 -8
  181. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +5 -0
  182. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +1 -1
  183. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +30 -7
  184. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +14 -0
  185. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +46 -10
  186. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +5 -0
  187. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +30 -10
  188. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +5 -0
  189. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
  190. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +27 -12
  191. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +5 -0
  192. package/dist/types/components/molecules/mg-form/mg-form.d.ts +82 -0
  193. package/dist/types/components/molecules/mg-form/mg-form.stories.d.ts +11 -0
  194. package/dist/types/components/molecules/mg-message/mg-message.d.ts +11 -4
  195. package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +10 -0
  196. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +83 -0
  197. package/dist/types/components/molecules/mg-modal/mg-modal.stories.d.ts +13 -0
  198. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +23 -7
  199. package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +5 -0
  200. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +110 -0
  201. package/dist/types/components/molecules/mg-panel/mg-panel.stories.d.ts +6 -0
  202. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +18 -3
  203. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +5 -0
  204. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +21 -6
  205. package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +8 -0
  206. package/dist/types/components.d.ts +365 -78
  207. package/dist/types/locales/index.d.ts +15 -8
  208. package/dist/types/utils/components.utils.d.ts +16 -9
  209. package/dist/types/utils/locale.utils.d.ts +6 -3
  210. package/dist/types/utils/test.utils.d.ts +13 -1
  211. package/package.json +13 -9
  212. package/readme.md +3 -0
  213. package/dist/cjs/css-shim-a22512c4.js +0 -6
  214. package/dist/cjs/mg-badge_20.cjs.entry.js +0 -4661
  215. package/dist/esm/css-shim-7c240feb.js +0 -4
  216. package/dist/esm/mg-badge_20.entry.js +0 -4638
  217. package/dist/esm-es5/css-shim-7c240feb.js +0 -1
  218. package/dist/esm-es5/index-e3e84606.js +0 -1
  219. package/dist/esm-es5/mg-badge_20.entry.js +0 -2
  220. package/dist/mg-components/p-1cd24462.system.js +0 -1
  221. package/dist/mg-components/p-2e2f6b27.system.entry.js +0 -2
  222. package/dist/mg-components/p-422c429b.system.js +0 -1
  223. package/dist/mg-components/p-62fa3797.js +0 -1
  224. package/dist/mg-components/p-9a215712.system.js +0 -1
  225. package/dist/mg-components/p-cbf0464b.entry.js +0 -1
@@ -9,12 +9,17 @@ export default {
9
9
  control: { type: 'select' },
10
10
  },
11
11
  },
12
+ parameters: { actions: { handles: ['value-change', 'input-valid'] } },
12
13
  };
13
14
  /**
14
15
  * 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
15
16
  * 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
17
+ *
18
+ * @param {any} args component arguments
19
+ * @returns {HTMLElement} HTMLElement
16
20
  */
17
- const Template = args => {
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ const Template = (args) => {
18
23
  const labelOnTop = args.labelOnTop;
19
24
  delete args.labelOnTop;
20
25
  const labelHide = args.labelHide;
@@ -10,6 +10,7 @@
10
10
  align-items: flex-start;
11
11
  min-height: var(--default-size);
12
12
  max-width: 100%;
13
+ margin-bottom: var(--mg-inputs-margin-bottom, 0);
13
14
  /* Style when input is not valid */
14
15
  /* Label */
15
16
  /* Label-on-top */
@@ -96,6 +97,7 @@
96
97
  */
97
98
  .mg-input__box {
98
99
  padding: calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);
100
+ width: 100%;
99
101
  height: var(--default-size);
100
102
  box-sizing: border-box;
101
103
  border-width: var(--mg-inputs-border-width);
@@ -145,6 +147,31 @@
145
147
  display: none;
146
148
  }
147
149
 
150
+ .mg-input.mg-input--label-on-top .mg-input__box {
151
+ width: auto;
152
+ max-width: 100%;
153
+ }
154
+
155
+ .mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]) {
156
+ --mg-button-border-radius-top-right: 0;
157
+ --mg-button-border-radius-bottom-right: 0;
158
+ --mg-button-border-radius-top-left: 0;
159
+ /* IE FIX */
160
+ --mg-button-border-radius-bottom-left: 0;
161
+ /* IE FIX */
162
+ }
163
+ .mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)) {
164
+ --mg-button-border-right-width: 0;
165
+ }
166
+ .mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type) {
167
+ --mg-button-border-radius-top-right: var(--mg-inputs-border-radius);
168
+ --mg-button-border-radius-bottom-right: var(--mg-inputs-border-radius);
169
+ --mg-button-border-radius-top-left: 0;
170
+ /* IE FIX */
171
+ --mg-button-border-radius-bottom-left: 0;
172
+ /* IE FIX */
173
+ }
174
+
148
175
  .mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]) {
149
176
  padding-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
150
177
  }
@@ -1,8 +1,8 @@
1
- import { Component, Event, h, Prop, State } from '@stencil/core';
1
+ import { Component, Event, h, Prop, State, Method, Watch } from '@stencil/core';
2
2
  import { MgInput } from '../MgInput';
3
+ import { InputClass } from '../MgInput.conf';
3
4
  import { createID, ClassList } from '../../../../utils/components.utils';
4
5
  import { messages } from '../../../../locales';
5
- import { InputClass } from '../MgInput.conf';
6
6
  export class MgInputPassword {
7
7
  constructor() {
8
8
  /************
@@ -50,7 +50,6 @@ export class MgInputPassword {
50
50
  this.handleInput = () => {
51
51
  this.checkValidity();
52
52
  this.value = this.input.value;
53
- this.valueChange.emit(this.value);
54
53
  };
55
54
  /**
56
55
  * Handle blur event
@@ -59,44 +58,71 @@ export class MgInputPassword {
59
58
  this.checkValidity();
60
59
  this.checkError();
61
60
  };
61
+ /**
62
+ * Check if input is valid
63
+ */
64
+ this.checkValidity = () => {
65
+ if (!this.readonly && this.input !== undefined) {
66
+ const validity = this.input.checkValidity();
67
+ // Set validity
68
+ this.valid = validity;
69
+ this.invalid = !validity;
70
+ //Send event
71
+ this.inputValid.emit(validity);
72
+ }
73
+ };
74
+ /**
75
+ * Check input errors
76
+ */
77
+ this.checkError = () => {
78
+ // Set error message
79
+ this.errorMessage = undefined;
80
+ // required
81
+ if (!this.valid && this.input.validity.valueMissing) {
82
+ this.errorMessage = messages.errors.required;
83
+ }
84
+ // Update class
85
+ if (this.valid) {
86
+ this.classList.delete(this.classError);
87
+ }
88
+ else {
89
+ this.classList.add(this.classError);
90
+ }
91
+ };
62
92
  }
63
- /**
64
- * Check if input is valid
65
- */
66
- checkValidity() {
67
- if (!this.readonly && this.input !== undefined) {
68
- const validity = this.input.checkValidity();
69
- // Set validity
70
- this.valid = validity;
71
- this.invalid = !validity;
72
- }
93
+ handleValue(newValue) {
94
+ this.valueChange.emit(newValue);
73
95
  }
74
96
  /**
75
- * Check input errors
97
+ * Public method to display errors
98
+ *
99
+ * @returns {Promise<void>}
76
100
  */
77
- checkError() {
78
- // Set error message
79
- this.errorMessage = undefined;
80
- // required
81
- if (!this.valid && this.input.validity.valueMissing) {
82
- this.errorMessage = messages.errors.required;
83
- }
84
- // Update class
85
- if (this.valid) {
86
- this.classList.delete(this.classError);
87
- }
88
- else {
89
- this.classList.add(this.classError);
90
- }
101
+ async displayError() {
102
+ this.checkValidity();
103
+ this.checkError();
91
104
  }
92
105
  /*************
93
106
  * Lifecycle *
94
107
  *************/
108
+ /**
109
+ * Check if component props are well configured on init
110
+ *
111
+ * @returns {ReturnType<typeof setTimeout>} timeout
112
+ */
95
113
  componentWillLoad() {
114
+ // Check validity when component is ready
96
115
  // return a promise to process action only in the FIRST render().
97
116
  // https://stenciljs.com/docs/component-lifecycle#componentwillload
98
- return setTimeout(() => this.checkValidity(), 0);
117
+ return setTimeout(() => {
118
+ this.checkValidity();
119
+ }, 0);
99
120
  }
121
+ /**
122
+ * Render
123
+ *
124
+ * @returns {HTMLElement} HTML Element
125
+ */
100
126
  render() {
101
127
  return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, displayCharacterLeft: false, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false },
102
128
  h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) })));
@@ -136,7 +162,7 @@ export class MgInputPassword {
136
162
  "references": {}
137
163
  },
138
164
  "required": false,
139
- "optional": true,
165
+ "optional": false,
140
166
  "docs": {
141
167
  "tags": [],
142
168
  "text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
@@ -154,7 +180,7 @@ export class MgInputPassword {
154
180
  "references": {}
155
181
  },
156
182
  "required": false,
157
- "optional": true,
183
+ "optional": false,
158
184
  "docs": {
159
185
  "tags": [],
160
186
  "text": "Input name\nIf not set the value equals the identifier"
@@ -175,7 +201,7 @@ export class MgInputPassword {
175
201
  "optional": false,
176
202
  "docs": {
177
203
  "tags": [],
178
- "text": "Input label\nRequired"
204
+ "text": "Input label"
179
205
  },
180
206
  "attribute": "label",
181
207
  "reflect": false
@@ -355,7 +381,7 @@ export class MgInputPassword {
355
381
  "optional": false,
356
382
  "docs": {
357
383
  "tags": [],
358
- "text": "Define input pattern to validate"
384
+ "text": "Define input valid state"
359
385
  },
360
386
  "attribute": "valid",
361
387
  "reflect": false
@@ -372,7 +398,7 @@ export class MgInputPassword {
372
398
  "optional": false,
373
399
  "docs": {
374
400
  "tags": [],
375
- "text": "Define input pattern error message"
401
+ "text": "Define input invalid state"
376
402
  },
377
403
  "attribute": "invalid",
378
404
  "reflect": false
@@ -390,12 +416,52 @@ export class MgInputPassword {
390
416
  "composed": true,
391
417
  "docs": {
392
418
  "tags": [],
393
- "text": "Emmited event when value change"
419
+ "text": "Emited event when value change"
394
420
  },
395
421
  "complexType": {
396
422
  "original": "string",
397
423
  "resolved": "string",
398
424
  "references": {}
399
425
  }
426
+ }, {
427
+ "method": "inputValid",
428
+ "name": "input-valid",
429
+ "bubbles": true,
430
+ "cancelable": true,
431
+ "composed": true,
432
+ "docs": {
433
+ "tags": [],
434
+ "text": "Emited event when checking validity"
435
+ },
436
+ "complexType": {
437
+ "original": "boolean",
438
+ "resolved": "boolean",
439
+ "references": {}
440
+ }
441
+ }]; }
442
+ static get methods() { return {
443
+ "displayError": {
444
+ "complexType": {
445
+ "signature": "() => Promise<void>",
446
+ "parameters": [],
447
+ "references": {
448
+ "Promise": {
449
+ "location": "global"
450
+ }
451
+ },
452
+ "return": "Promise<void>"
453
+ },
454
+ "docs": {
455
+ "text": "Public method to display errors",
456
+ "tags": [{
457
+ "name": "returns",
458
+ "text": undefined
459
+ }]
460
+ }
461
+ }
462
+ }; }
463
+ static get watchers() { return [{
464
+ "propName": "value",
465
+ "methodName": "handleValue"
400
466
  }]; }
401
467
  }
@@ -2,12 +2,17 @@ import { h } from '@stencil/core';
2
2
  export default {
3
3
  component: 'mg-input-password',
4
4
  title: 'Molecules/Inputs/mg-input-password',
5
+ parameters: { actions: { handles: ['value-change', 'input-valid'] } },
5
6
  };
6
7
  /**
7
8
  * 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
8
9
  * 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
10
+ *
11
+ * @param {any} args component arguments
12
+ * @returns {HTMLElement} HTMLElement
9
13
  */
10
- const Template = args => {
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ const Template = (args) => {
11
16
  const labelOnTop = args.labelOnTop;
12
17
  delete args.labelOnTop;
13
18
  const labelHide = args.labelHide;
@@ -10,6 +10,7 @@
10
10
  align-items: flex-start;
11
11
  min-height: var(--default-size);
12
12
  max-width: 100%;
13
+ margin-bottom: var(--mg-inputs-margin-bottom, 0);
13
14
  /* Style when input is not valid */
14
15
  /* Label */
15
16
  /* Label-on-top */
@@ -91,7 +92,8 @@
91
92
  */
92
93
  fieldset.mg-input {
93
94
  border: 0;
94
- margin: 0;
95
+ margin-left: 0;
96
+ margin-right: 0;
95
97
  padding: 0;
96
98
  }
97
99
  fieldset.mg-input input[type=radio],
@@ -108,6 +110,9 @@ fieldset.mg-input input[type=checkbox] {
108
110
  fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
109
111
  margin-top: 0.7rem;
110
112
  }
113
+ fieldset.mg-input.is-not-valid .mg-input__input-group {
114
+ color: initial;
115
+ }
111
116
 
112
117
  .mg-input__input-container mg-tooltip {
113
118
  margin-left: 2rem;
@@ -133,6 +138,9 @@ fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
133
138
  display: flex;
134
139
  align-items: top;
135
140
  }
141
+ .mg-input__input-group.mg-input__input-group--disabled label {
142
+ opacity: 0.3;
143
+ }
136
144
 
137
145
  /**
138
146
  * A11Y
@@ -1,12 +1,15 @@
1
- import { Component, Event, h, Prop, State, Watch } from '@stencil/core';
1
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { Component, Event, h, Prop, State, Watch, Method } from '@stencil/core';
2
4
  import { MgInput } from '../MgInput';
3
5
  import { createID, ClassList, allItemsAreString } from '../../../../utils/components.utils';
4
6
  import { messages } from '../../../../locales';
5
7
  import { InputClass } from '../MgInput.conf';
6
8
  /**
7
9
  * type Option validation function
8
- * @param option
9
- * @returns {boolean}
10
+ *
11
+ * @param {RadioOption} option radio option
12
+ * @returns {boolean} radio option type is valid
10
13
  */
11
14
  const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
12
15
  export class MgInputRadio {
@@ -58,25 +61,68 @@ export class MgInputRadio {
58
61
  this.classList = new ClassList(['mg-input--radio']);
59
62
  /**
60
63
  * Handle input event
64
+ *
65
+ * @param {event} event input event
66
+ * @returns {void}
61
67
  */
62
68
  this.handleInput = (event) => {
63
69
  this.checkValidity();
64
70
  this.value = this.options[event.target.value].value;
65
- this.valueChange.emit(this.value);
66
71
  };
67
72
  /**
68
73
  * Handle blur event
74
+ *
75
+ * @returns {void}
69
76
  */
70
77
  this.handleBlur = () => {
71
78
  this.checkValidity();
72
79
  this.checkError();
73
80
  };
81
+ /**
82
+ * Check if input is valid
83
+ *
84
+ * @returns {void}
85
+ */
86
+ this.checkValidity = () => {
87
+ if (!this.readonly) {
88
+ const validity = this.getInvalidElement() === undefined;
89
+ // Set validity
90
+ this.valid = validity;
91
+ this.invalid = !validity;
92
+ //Send event
93
+ this.inputValid.emit(validity);
94
+ }
95
+ };
96
+ /**
97
+ * Check input errors
98
+ *
99
+ * @returns {void}
100
+ */
101
+ this.checkError = () => {
102
+ const invalidElement = this.getInvalidElement();
103
+ // Set error message
104
+ this.errorMessage = undefined;
105
+ if (!this.valid && invalidElement.validity.valueMissing) {
106
+ this.errorMessage = messages.errors.required;
107
+ }
108
+ // Update class
109
+ if (this.valid) {
110
+ this.classList.delete(this.classError);
111
+ }
112
+ else {
113
+ this.classList.add(this.classError);
114
+ }
115
+ };
74
116
  /**
75
117
  * get invalid element
76
- * @returns element: HTMLInputElement
118
+ *
119
+ * @returns {HTMLInputElement} element
77
120
  */
78
121
  this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
79
122
  }
123
+ handleValue(newValue) {
124
+ this.valueChange.emit(newValue);
125
+ }
80
126
  validateItems(newValue) {
81
127
  // Validate if items have required min length
82
128
  if (typeof newValue === 'object' && newValue.length < 2) {
@@ -95,47 +141,40 @@ export class MgInputRadio {
95
141
  }
96
142
  }
97
143
  /**
98
- * Check if input is valid
144
+ * Public method to display errors
145
+ *
146
+ * @returns {Promise<void>}
99
147
  */
100
- checkValidity() {
101
- if (!this.readonly) {
102
- const validity = this.getInvalidElement() === undefined;
103
- // Set validity
104
- this.valid = validity;
105
- this.invalid = !validity;
106
- }
107
- }
108
- /**
109
- * Check input errors
110
- */
111
- checkError() {
112
- const invalidElement = this.getInvalidElement();
113
- // Set error message
114
- this.errorMessage = undefined;
115
- if (!this.valid && invalidElement.validity.valueMissing) {
116
- this.errorMessage = messages.errors.required;
117
- }
118
- // Update class
119
- if (this.valid) {
120
- this.classList.delete(this.classError);
121
- }
122
- else {
123
- this.classList.add(this.classError);
124
- }
148
+ async displayError() {
149
+ this.checkValidity();
150
+ this.checkError();
125
151
  }
126
152
  /*************
127
153
  * Lifecycle *
128
154
  *************/
155
+ /**
156
+ * Check if component props are well configured on init
157
+ *
158
+ * @returns {ReturnType<typeof setTimeout>} timeout
159
+ */
129
160
  componentWillLoad() {
130
161
  // Check items format
131
162
  this.validateItems(this.items);
163
+ // Check validity when component is ready
132
164
  // return a promise to process action only in the FIRST render().
133
165
  // https://stenciljs.com/docs/component-lifecycle#componentwillload
134
- return setTimeout(() => this.checkValidity(), 0);
166
+ return setTimeout(() => {
167
+ this.checkValidity();
168
+ }, 0);
135
169
  }
170
+ /**
171
+ * Render
172
+ *
173
+ * @returns {HTMLElement} HTML Element
174
+ */
136
175
  render() {
137
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, width: undefined, value: this.value && this.value.toString(), readonlyValue: this.value && this.value.toString(), tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true },
138
- h("ul", { class: `mg-input__input-group-container${this.inputVerticalList ? ' mg-input__input-group-container--vertical' : ''}` }, this.options.map((input, index) => (h("li", { class: "mg-input__input-group" },
176
+ return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, width: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true },
177
+ h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.options.map((input, index) => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } },
139
178
  h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => this.inputs.push(el) }),
140
179
  h("label", { htmlFor: this.identifier + '_' + index }, input.title)))))));
141
180
  }
@@ -233,7 +272,7 @@ export class MgInputRadio {
233
272
  "optional": false,
234
273
  "docs": {
235
274
  "tags": [],
236
- "text": "Input label\nRequired"
275
+ "text": "Input label"
237
276
  },
238
277
  "attribute": "label",
239
278
  "reflect": false
@@ -392,7 +431,7 @@ export class MgInputRadio {
392
431
  "optional": false,
393
432
  "docs": {
394
433
  "tags": [],
395
- "text": "Force valid component"
434
+ "text": "Define input valid state"
396
435
  },
397
436
  "attribute": "valid",
398
437
  "reflect": false
@@ -409,7 +448,7 @@ export class MgInputRadio {
409
448
  "optional": false,
410
449
  "docs": {
411
450
  "tags": [],
412
- "text": "Force invalid component"
451
+ "text": "Define input invalid state"
413
452
  },
414
453
  "attribute": "invalid",
415
454
  "reflect": false
@@ -435,8 +474,47 @@ export class MgInputRadio {
435
474
  "resolved": "any",
436
475
  "references": {}
437
476
  }
477
+ }, {
478
+ "method": "inputValid",
479
+ "name": "input-valid",
480
+ "bubbles": true,
481
+ "cancelable": true,
482
+ "composed": true,
483
+ "docs": {
484
+ "tags": [],
485
+ "text": "Emited event when checking validity"
486
+ },
487
+ "complexType": {
488
+ "original": "boolean",
489
+ "resolved": "boolean",
490
+ "references": {}
491
+ }
438
492
  }]; }
493
+ static get methods() { return {
494
+ "displayError": {
495
+ "complexType": {
496
+ "signature": "() => Promise<void>",
497
+ "parameters": [],
498
+ "references": {
499
+ "Promise": {
500
+ "location": "global"
501
+ }
502
+ },
503
+ "return": "Promise<void>"
504
+ },
505
+ "docs": {
506
+ "text": "Public method to display errors",
507
+ "tags": [{
508
+ "name": "returns",
509
+ "text": undefined
510
+ }]
511
+ }
512
+ }
513
+ }; }
439
514
  static get watchers() { return [{
515
+ "propName": "value",
516
+ "methodName": "handleValue"
517
+ }, {
440
518
  "propName": "items",
441
519
  "methodName": "validateItems"
442
520
  }]; }
@@ -8,12 +8,17 @@ export default {
8
8
  control: { type: 'radio' },
9
9
  },
10
10
  },
11
+ parameters: { actions: { handles: ['value-change', 'input-valid'] } },
11
12
  };
12
13
  /**
13
14
  * 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
14
15
  * 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
16
+ *
17
+ * @param {any} args component arguments
18
+ * @returns {HTMLElement} HTMLElement
15
19
  */
16
- const Template = args => {
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ const Template = (args) => {
17
22
  const labelOnTop = args.labelOnTop;
18
23
  delete args.labelOnTop;
19
24
  const helpText = args.helpText;
@@ -10,6 +10,7 @@
10
10
  align-items: flex-start;
11
11
  min-height: var(--default-size);
12
12
  max-width: 100%;
13
+ margin-bottom: var(--mg-inputs-margin-bottom, 0);
13
14
  /* Style when input is not valid */
14
15
  /* Label */
15
16
  /* Label-on-top */
@@ -96,6 +97,7 @@
96
97
  */
97
98
  .mg-input__box {
98
99
  padding: calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);
100
+ width: 100%;
99
101
  height: var(--default-size);
100
102
  box-sizing: border-box;
101
103
  border-width: var(--mg-inputs-border-width);
@@ -145,6 +147,31 @@
145
147
  display: none;
146
148
  }
147
149
 
150
+ .mg-input.mg-input--label-on-top .mg-input__box {
151
+ width: auto;
152
+ max-width: 100%;
153
+ }
154
+
155
+ .mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]) {
156
+ --mg-button-border-radius-top-right: 0;
157
+ --mg-button-border-radius-bottom-right: 0;
158
+ --mg-button-border-radius-top-left: 0;
159
+ /* IE FIX */
160
+ --mg-button-border-radius-bottom-left: 0;
161
+ /* IE FIX */
162
+ }
163
+ .mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)) {
164
+ --mg-button-border-right-width: 0;
165
+ }
166
+ .mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type) {
167
+ --mg-button-border-radius-top-right: var(--mg-inputs-border-radius);
168
+ --mg-button-border-radius-bottom-right: var(--mg-inputs-border-radius);
169
+ --mg-button-border-radius-top-left: 0;
170
+ /* IE FIX */
171
+ --mg-button-border-radius-bottom-left: 0;
172
+ /* IE FIX */
173
+ }
174
+
148
175
  .mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]) {
149
176
  padding-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
150
177
  }
@@ -197,5 +224,5 @@
197
224
  .mg-input__box {
198
225
  padding-top: 0;
199
226
  padding-bottom: 0;
200
- padding-right: 0;
227
+ padding-right: 1rem;
201
228
  }