@mgdis/mg-components 3.1.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/dist/cjs/{index-85a4a0b6.js → index-88560a66.js} +123 -48
  2. package/dist/cjs/index-a39c5567.js +233 -0
  3. package/dist/cjs/loader.cjs.js +3 -17
  4. package/dist/cjs/mg-badge_21.cjs.entry.js +3538 -0
  5. package/dist/cjs/mg-components.cjs.js +3 -7
  6. package/dist/cjs/mg-modal.cjs.entry.js +117 -0
  7. package/dist/cjs/mg-popover.cjs.entry.js +170 -0
  8. package/dist/cjs/popper-71bf3058.js +1790 -0
  9. package/dist/collection/collection-manifest.json +4 -1
  10. package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.js} +4 -1
  11. package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
  12. package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -2
  13. package/dist/collection/components/atoms/mg-badge/mg-badge.js +26 -10
  14. package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +7 -2
  15. package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
  16. package/dist/collection/components/atoms/mg-button/mg-button.css +46 -49
  17. package/dist/collection/components/atoms/mg-button/mg-button.js +78 -4
  18. package/dist/collection/components/atoms/mg-character-left/{mg-character-left.stories.js → doc/mg-character-left.stories.js} +8 -0
  19. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +20 -46
  20. package/dist/collection/components/atoms/mg-icon/{mg-icon.stories.js → doc/mg-icon.stories.js} +1 -1
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +104 -9
  22. package/dist/collection/components/atoms/mg-icon/mg-icon.css +9 -7
  23. package/dist/collection/components/atoms/mg-icon/mg-icon.js +33 -7
  24. package/dist/collection/components/atoms/mg-input-title/{mg-input-title.stories.js → doc/mg-input-title.stories.js} +0 -0
  25. package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +4 -4
  26. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +14 -3
  27. package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +4 -1
  28. package/dist/collection/components/atoms/mg-tag/mg-tag.js +28 -6
  29. package/dist/collection/components/atoms/mg-tooltip/{mg-tooltip.stories.js → doc/mg-tooltip.stories.js} +14 -1
  30. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +20 -0
  31. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +16 -2
  32. package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
  33. package/dist/collection/components/molecules/inputs/MgInput.js +25 -29
  34. package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +6 -1
  35. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +25 -11
  36. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +102 -52
  37. package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +6 -1
  38. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +37 -9
  39. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +136 -66
  40. package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +15 -3
  41. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +38 -10
  42. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +180 -80
  43. package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +16 -2
  44. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +37 -9
  45. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +108 -47
  46. package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +6 -1
  47. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +25 -11
  48. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +113 -42
  49. package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +22 -2
  50. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +39 -10
  51. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +145 -71
  52. package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +17 -8
  53. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +69 -19
  54. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +184 -83
  55. package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +16 -5
  56. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +69 -13
  57. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +163 -70
  58. package/dist/collection/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.js → doc/mg-input-toggle.stories.js} +6 -1
  59. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +22 -10
  60. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +68 -33
  61. package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +58 -0
  62. package/dist/collection/components/molecules/mg-form/mg-form.css +19 -0
  63. package/dist/collection/components/molecules/mg-form/mg-form.js +271 -0
  64. package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +6 -2
  65. package/dist/collection/components/molecules/mg-message/mg-message.css +1 -1
  66. package/dist/collection/components/molecules/mg-message/mg-message.js +26 -11
  67. package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +51 -0
  68. package/dist/collection/components/molecules/mg-modal/mg-modal.css +52 -0
  69. package/dist/collection/components/molecules/mg-modal/mg-modal.js +240 -0
  70. package/dist/collection/components/molecules/mg-pagination/{mg-pagination.stories.js → doc/mg-pagination.stories.js} +1 -0
  71. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +47 -28
  72. package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +39 -0
  73. package/dist/collection/components/molecules/mg-panel/mg-panel.css +53 -0
  74. package/dist/collection/components/molecules/mg-panel/mg-panel.js +356 -0
  75. package/dist/collection/components/molecules/mg-popover/{mg-popover.stories.js → doc/mg-popover.stories.js} +10 -0
  76. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +20 -0
  77. package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -2
  78. package/dist/collection/components/molecules/mg-popover/mg-popover.js +37 -12
  79. package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +20 -4
  80. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +11 -1
  81. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +17 -3
  82. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +139 -26
  83. package/dist/collection/locales/index.js +33 -4
  84. package/dist/collection/stories/helpers.stories.js +33 -0
  85. package/dist/collection/utils/components.utils.js +16 -9
  86. package/dist/collection/utils/locale.utils.js +13 -7
  87. package/dist/collection/utils/test.utils.js +27 -15
  88. package/dist/collection/variables.css +39 -5
  89. package/dist/collection/variables.scss +39 -5
  90. package/dist/components/MgInput.js +26 -37
  91. package/dist/components/components.utils.js +16 -9
  92. package/dist/components/index.d.ts +24 -6
  93. package/dist/components/index.js +23 -0
  94. package/dist/components/index2.js +116 -17
  95. package/dist/components/locale.utils.js +13 -8
  96. package/dist/components/mg-badge2.js +25 -9
  97. package/dist/components/mg-button2.js +29 -5
  98. package/dist/components/mg-character-left2.js +14 -26
  99. package/dist/components/mg-form.d.ts +11 -0
  100. package/dist/components/mg-form.js +148 -0
  101. package/dist/components/mg-icon2.js +138 -17
  102. package/dist/components/mg-input-checkbox.js +66 -53
  103. package/dist/components/mg-input-date.js +100 -69
  104. package/dist/components/mg-input-numeric.js +125 -81
  105. package/dist/components/mg-input-password.js +69 -48
  106. package/dist/components/mg-input-radio.js +74 -46
  107. package/dist/components/mg-input-select2.js +103 -71
  108. package/dist/components/mg-input-text.js +1 -237
  109. package/dist/components/mg-input-text2.js +300 -0
  110. package/dist/components/mg-input-textarea.js +100 -46
  111. package/dist/components/mg-input-title2.js +13 -4
  112. package/dist/components/mg-input-toggle.js +39 -31
  113. package/dist/components/mg-message.js +25 -10
  114. package/dist/components/mg-modal.d.ts +11 -0
  115. package/dist/components/mg-modal.js +153 -0
  116. package/dist/components/mg-pagination.js +45 -31
  117. package/dist/components/mg-panel.d.ts +11 -0
  118. package/dist/components/mg-panel.js +244 -0
  119. package/dist/components/mg-popover.js +31 -11
  120. package/dist/components/mg-tabs.js +113 -23
  121. package/dist/components/mg-tag.js +27 -5
  122. package/dist/components/mg-tooltip2.js +10 -1
  123. package/dist/components/popper.js +6 -2
  124. package/dist/esm/{index-e3e84606.js → index-bca81100.js} +124 -46
  125. package/dist/esm/index-e51ae032.js +228 -0
  126. package/dist/esm/loader.js +3 -17
  127. package/dist/esm/mg-badge_21.entry.js +3514 -0
  128. package/dist/esm/mg-components.js +3 -7
  129. package/dist/esm/mg-modal.entry.js +113 -0
  130. package/dist/esm/mg-popover.entry.js +166 -0
  131. package/dist/esm/polyfills/css-shim.js +1 -1
  132. package/dist/esm/popper-93ecb064.js +1788 -0
  133. package/dist/index.js +1 -1
  134. package/dist/mg-components/mg-components.css +1 -1
  135. package/dist/mg-components/mg-components.esm.js +1 -1
  136. package/dist/mg-components/p-003a1344.entry.js +1 -0
  137. package/dist/mg-components/p-462d648a.entry.js +1 -0
  138. package/dist/mg-components/p-4c66f794.js +1 -0
  139. package/dist/mg-components/p-5126ab10.entry.js +1 -0
  140. package/dist/mg-components/p-780bd52d.js +1 -0
  141. package/dist/mg-components/p-b14a3443.js +2 -0
  142. package/dist/mg-components/variables.css +39 -5
  143. package/dist/mg-components/variables.scss +39 -5
  144. package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +5 -0
  145. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +16 -5
  146. package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +5 -0
  147. package/dist/types/components/atoms/mg-button/mg-button.d.ts +23 -3
  148. package/dist/types/components/atoms/mg-character-left/{mg-character-left.stories.d.ts → doc/mg-character-left.stories.d.ts} +9 -0
  149. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +16 -13
  150. package/dist/types/components/atoms/mg-icon/{mg-icon.stories.d.ts → doc/mg-icon.stories.d.ts} +0 -0
  151. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +1 -1
  152. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +14 -4
  153. package/dist/types/components/atoms/mg-input-title/{mg-input-title.stories.d.ts → doc/mg-input-title.stories.d.ts} +0 -0
  154. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +11 -1
  155. package/dist/types/components/atoms/mg-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +5 -0
  156. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +18 -4
  157. package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +29 -0
  158. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +8 -0
  159. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +13 -3
  160. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +6 -4
  161. package/dist/types/components/molecules/inputs/MgInput.d.ts +7 -8
  162. package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +5 -0
  163. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +36 -13
  164. package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +5 -0
  165. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +46 -15
  166. package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +11 -0
  167. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +61 -16
  168. package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +22 -0
  169. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +35 -11
  170. package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.stories.d.ts} +5 -0
  171. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
  172. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +42 -9
  173. package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +34 -0
  174. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +1 -1
  175. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +37 -9
  176. package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +13 -0
  177. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +52 -16
  178. package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +19 -0
  179. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +45 -17
  180. package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.stories.d.ts} +5 -0
  181. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
  182. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +29 -12
  183. package/dist/types/components/molecules/{mg-popover/mg-popover.stories.d.ts → mg-form/doc/mg-form.stories.d.ts} +3 -4
  184. package/dist/types/components/molecules/mg-form/mg-form.d.ts +83 -0
  185. package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +10 -0
  186. package/dist/types/components/molecules/mg-message/mg-message.d.ts +13 -4
  187. package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +13 -0
  188. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +85 -0
  189. package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +5 -0
  190. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +31 -7
  191. package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +11 -0
  192. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +139 -0
  193. package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +25 -0
  194. package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +8 -0
  195. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +27 -4
  196. package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +20 -0
  197. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +11 -0
  198. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +70 -6
  199. package/dist/types/components.d.ts +528 -211
  200. package/dist/types/locales/index.d.ts +108 -38
  201. package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
  202. package/dist/types/utils/components.utils.d.ts +16 -9
  203. package/dist/types/utils/locale.utils.d.ts +13 -6
  204. package/dist/types/utils/test.utils.d.ts +13 -1
  205. package/loader/index.js +1 -1
  206. package/package.json +45 -14
  207. package/readme.md +9 -35
  208. package/dist/cjs/css-shim-a22512c4.js +0 -6
  209. package/dist/cjs/mg-badge_20.cjs.entry.js +0 -4661
  210. package/dist/cjs/shadow-css-8940f82d.js +0 -390
  211. package/dist/collection/stories/buttons.stories.js +0 -43
  212. package/dist/collection/stories/messages.stories.js +0 -44
  213. package/dist/collection/stories/tags.stories.js +0 -13
  214. package/dist/esm/css-shim-7c240feb.js +0 -4
  215. package/dist/esm/mg-badge_20.entry.js +0 -4638
  216. package/dist/esm/shadow-css-5d2d01ce.js +0 -388
  217. package/dist/esm-es5/css-shim-7c240feb.js +0 -1
  218. package/dist/esm-es5/index-e3e84606.js +0 -1
  219. package/dist/esm-es5/index.js +0 -0
  220. package/dist/esm-es5/loader.js +0 -1
  221. package/dist/esm-es5/mg-badge_20.entry.js +0 -2
  222. package/dist/esm-es5/mg-components.js +0 -1
  223. package/dist/esm-es5/shadow-css-5d2d01ce.js +0 -12
  224. package/dist/mg-components/mg-components.js +0 -132
  225. package/dist/mg-components/p-1cd24462.system.js +0 -1
  226. package/dist/mg-components/p-2e2f6b27.system.entry.js +0 -2
  227. package/dist/mg-components/p-366a224e.js +0 -1
  228. package/dist/mg-components/p-422c429b.system.js +0 -1
  229. package/dist/mg-components/p-50ea2036.system.js +0 -1
  230. package/dist/mg-components/p-62fa3797.js +0 -1
  231. package/dist/mg-components/p-71d57b8b.system.js +0 -13
  232. package/dist/mg-components/p-9a215712.system.js +0 -1
  233. package/dist/mg-components/p-cbf0464b.entry.js +0 -1
  234. package/dist/mg-components/p-f6455ab3.js +0 -12
  235. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
  236. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +0 -9
  237. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +0 -14
  238. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +0 -6
  239. package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +0 -7
  240. package/dist/types/stories/messages.stories.d.ts +0 -13
  241. package/dist/types/stories/tags.stories.d.ts +0 -5
@@ -16,14 +16,17 @@
16
16
  "./components/molecules/inputs/mg-input-text/mg-input-text.js",
17
17
  "./components/molecules/inputs/mg-input-textarea/mg-input-textarea.js",
18
18
  "./components/molecules/inputs/mg-input-toggle/mg-input-toggle.js",
19
+ "./components/molecules/mg-form/mg-form.js",
19
20
  "./components/molecules/mg-message/mg-message.js",
21
+ "./components/molecules/mg-modal/mg-modal.js",
20
22
  "./components/molecules/mg-pagination/mg-pagination.js",
23
+ "./components/molecules/mg-panel/mg-panel.js",
21
24
  "./components/molecules/mg-popover/mg-popover.js",
22
25
  "./components/molecules/mg-tabs/mg-tabs.js"
23
26
  ],
24
27
  "compiler": {
25
28
  "name": "@stencil/core",
26
- "version": "2.14.1",
29
+ "version": "2.17.1",
27
30
  "typescriptVersion": "4.5.4"
28
31
  },
29
32
  "collections": [],
@@ -1,5 +1,5 @@
1
1
  import { h } from '@stencil/core';
2
- import { variants } from './mg-badge.conf';
2
+ import { variants } from '../mg-badge.conf';
3
3
  export default {
4
4
  component: 'mg-badge',
5
5
  title: 'Atoms/mg-badge',
@@ -7,6 +7,9 @@ export default {
7
7
  variant: {
8
8
  options: variants,
9
9
  control: { type: 'select' },
10
+ table: {
11
+ defaultValue: { summary: variants[0] },
12
+ },
10
13
  },
11
14
  value: {
12
15
  control: { type: 'text' },
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * List of all possibles variants
3
3
  */
4
- export const variants = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'];
4
+ export const variants = ['info', 'primary', 'secondary', 'success', 'warning', 'danger'];
@@ -28,8 +28,6 @@
28
28
  min-width: var(--mg-badge-size);
29
29
  box-sizing: border-box;
30
30
  border: 0.1rem solid;
31
- border-radius: 50%;
32
- /* IE FIX */
33
31
  border-radius: calc(var(--mg-badge-size) / 2);
34
32
  font-size: var(--mg-badge-font-size);
35
33
  font-weight: 600;
@@ -3,40 +3,56 @@ import { variants } from './mg-badge.conf';
3
3
  import { ClassList } from '../../../utils/components.utils';
4
4
  export class MgBadge {
5
5
  constructor() {
6
+ /************
7
+ * Internal *
8
+ ************/
9
+ // classes
10
+ this.classOutline = `mg-badge--outline`;
6
11
  /**
7
12
  * Define button variant
8
13
  */
9
- this.variant = variants[variants.length - 1];
14
+ this.variant = variants[0]; // info
10
15
  /**
11
16
  * Component classes
12
17
  */
13
18
  this.classList = new ClassList(['mg-badge']);
14
19
  }
15
- valideValue(newValue) {
20
+ validateValue(newValue) {
16
21
  if (`${newValue}`.match(/^(\d+|[?*!a-z])$/i) === null) {
17
22
  throw new Error('<mg-badge> prop "value" must be interger or ponctuation character.');
18
23
  }
19
24
  }
20
- validateVariant(newValue) {
25
+ validateVariant(newValue, oldValue) {
21
26
  if (!variants.includes(newValue)) {
22
27
  throw new Error(`<mg-badge> prop "variant" must be one of : ${variants.join(', ')}.`);
23
28
  }
24
- this.classList.add(`mg-badge--${this.variant}`);
29
+ else {
30
+ if (oldValue !== undefined) {
31
+ this.classList.delete(`mg-badge--${oldValue}`);
32
+ }
33
+ this.classList.add(`mg-badge--${newValue}`);
34
+ }
25
35
  }
26
36
  validateOutline(newValue) {
27
37
  if (newValue)
28
- this.classList.add(`mg-badge--outline`);
38
+ this.classList.add(this.classOutline);
39
+ else
40
+ this.classList.delete(this.classOutline);
29
41
  }
30
42
  /**
31
43
  * Check if props are well configured on init
44
+ *
45
+ * @returns {void}
32
46
  */
33
47
  componentWillLoad() {
34
- this.valideValue(this.value);
48
+ this.validateValue(this.value);
35
49
  this.validateVariant(this.variant);
36
50
  this.validateOutline(this.outline);
37
51
  }
38
52
  /**
39
53
  * Render
54
+ *
55
+ * @returns {HTMLElement} HTML Element
40
56
  */
41
57
  render() {
42
58
  return (h("span", { class: this.classList.join() },
@@ -105,14 +121,14 @@ export class MgBadge {
105
121
  "references": {}
106
122
  },
107
123
  "required": false,
108
- "optional": true,
124
+ "optional": false,
109
125
  "docs": {
110
126
  "tags": [],
111
127
  "text": "Define button variant"
112
128
  },
113
129
  "attribute": "variant",
114
130
  "reflect": false,
115
- "defaultValue": "variants[variants.length - 1]"
131
+ "defaultValue": "variants[0]"
116
132
  },
117
133
  "outline": {
118
134
  "type": "boolean",
@@ -123,7 +139,7 @@ export class MgBadge {
123
139
  "references": {}
124
140
  },
125
141
  "required": false,
126
- "optional": true,
142
+ "optional": false,
127
143
  "docs": {
128
144
  "tags": [],
129
145
  "text": "Define if button is using outline style"
@@ -137,7 +153,7 @@ export class MgBadge {
137
153
  }; }
138
154
  static get watchers() { return [{
139
155
  "propName": "value",
140
- "methodName": "valideValue"
156
+ "methodName": "validateValue"
141
157
  }, {
142
158
  "propName": "variant",
143
159
  "methodName": "validateVariant"
@@ -1,6 +1,6 @@
1
1
  import { h } from '@stencil/core';
2
- import { variants } from './mg-button.conf';
3
- import { icons } from '../mg-icon/mg-icon.conf';
2
+ import { variants } from '../mg-button.conf';
3
+ import { icons } from '../../mg-icon/mg-icon.conf';
4
4
  export default {
5
5
  component: 'mg-button',
6
6
  title: 'Atoms/mg-button',
@@ -8,6 +8,9 @@ export default {
8
8
  variant: {
9
9
  options: variants,
10
10
  control: { type: 'select' },
11
+ table: {
12
+ defaultValue: { summary: variants[0] },
13
+ },
11
14
  },
12
15
  },
13
16
  };
@@ -31,6 +34,8 @@ MgButton.args = {
31
34
  disabled: false,
32
35
  disableOnClick: false,
33
36
  isIcon: false,
37
+ expanded: false,
38
+ controls: undefined,
34
39
  };
35
40
  export const IsIcon = Template.bind({});
36
41
  IsIcon.args = Object.assign(Object.assign({}, MgButton.args), { isIcon: true, slot: h("mg-icon", { icon: Object.keys(icons)[0] }) });
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * List of all possibles variants
3
3
  */
4
- export const variants = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat'];
4
+ export const variants = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success'];
@@ -5,6 +5,7 @@
5
5
  position: relative;
6
6
  display: inline-flex;
7
7
  align-items: center;
8
+ column-gap: 0.6rem;
8
9
  padding: calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;
9
10
  min-height: var(--default-size);
10
11
  box-sizing: border-box;
@@ -14,113 +15,109 @@
14
15
  border-bottom-left-radius: var(--mg-button-border-radius-bottom-left, var(--mg-button-border-radius));
15
16
  cursor: pointer;
16
17
  background-image: none;
17
- border: 0.1rem solid;
18
+ border-top-width: var(--mg-button-border-top-width, 0.1rem);
19
+ border-right-width: var(--mg-button-border-right-width, 0.1rem);
20
+ border-bottom-width: var(--mg-button-border-bottom-width, 0.1rem);
21
+ border-left-width: var(--mg-button-border-left-width, 0.1rem);
22
+ border-style: solid;
18
23
  font-family: inherit;
19
24
  text-decoration: none;
20
25
  font-weight: normal;
21
26
  text-align: left;
22
27
  touch-action: manipulation;
23
28
  }
24
- .mg-button[disabled], .mg-button[aria-disabled], .mg-button.disabled {
29
+ .mg-button[disabled], .mg-button[aria-disabled=true], .mg-button.disabled {
25
30
  opacity: var(--mg-button-disabled-opacity);
26
- cursor: not-allowed;
31
+ cursor: default;
27
32
  }
28
33
  .mg-button.mg-button--icon {
29
34
  padding: 0;
30
35
  justify-content: center;
31
36
  width: var(--default-size);
32
37
  height: var(--default-size);
33
- border-radius: var(--mg-button-icon-border-radius);
38
+ border-top-right-radius: var(--mg-button-border-radius-top-right, var(--mg-button-icon-border-radius));
39
+ border-top-left-radius: var(--mg-button-border-radius-top-left, var(--mg-button-icon-border-radius));
40
+ border-bottom-right-radius: var(--mg-button-border-radius-bottom-right, var(--mg-button-icon-border-radius));
41
+ border-bottom-left-radius: var(--mg-button-border-radius-bottom-left, var(--mg-button-icon-border-radius));
42
+ font-size: var(--font-size);
43
+ line-height: var(--font-size);
34
44
  }
35
45
  .mg-button.mg-button--primary {
36
- border-color: hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l));
37
- /* IE FIX */
38
- border-color: hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - 10%));
46
+ border-color: hsl(var(--mg-button-primary-border-color, var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-border-variation) * 10%)));
39
47
  color: hsl(var(--mg-button-primary-font-color));
40
- background: hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l));
41
- /* IE FIX */
42
- background: linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - 10%)));
48
+ background: linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%)));
43
49
  }
44
- .mg-button.mg-button--primary:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--primary:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--primary:active:not([disabled], [aria-disabled], .disabled) {
50
+ .mg-button.mg-button--primary:hover:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--primary:focus:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--primary:active:not([disabled], [aria-disabled=true], .disabled) {
45
51
  background: hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l));
46
52
  }
47
53
  .mg-button.mg-button--secondary {
48
- border-color: hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l));
49
- /* IE FIX */
50
- border-color: hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - 10%));
54
+ border-color: hsl(var(--mg-button-secondary-border-color, var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-border-variation) * 10%)));
51
55
  color: hsl(var(--mg-button-secondary-font-color));
52
- background: hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l));
53
- /* IE FIX */
54
- background: linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - 10%)));
56
+ background: linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%)));
55
57
  }
56
- .mg-button.mg-button--secondary:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--secondary:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--secondary:active:not([disabled], [aria-disabled], .disabled) {
58
+ .mg-button.mg-button--secondary:hover:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--secondary:focus:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--secondary:active:not([disabled], [aria-disabled=true], .disabled) {
57
59
  background: hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l));
58
60
  }
59
61
  .mg-button.mg-button--danger {
60
- border-color: hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));
61
- /* IE FIX */
62
- border-color: hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - 10%));
62
+ border-color: hsl(var(--mg-button-danger-border-color, var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-border-variation) * 10%)));
63
63
  color: hsl(var(--color-neutral));
64
- background: hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));
65
- /* IE FIX */
66
- background: linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - 10%)));
64
+ background: linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%)));
67
65
  }
68
- .mg-button.mg-button--danger:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--danger:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--danger:active:not([disabled], [aria-disabled], .disabled) {
66
+ .mg-button.mg-button--danger:hover:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--danger:focus:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--danger:active:not([disabled], [aria-disabled=true], .disabled) {
69
67
  background: hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));
70
68
  }
71
69
  .mg-button.mg-button--danger-alt {
72
- border-color: hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l));
73
- /* IE FIX */
74
- border-color: hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - 10%));
70
+ border-color: hsl(var(--mg-button-danger-alt-border-color, var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-border-variation) * 10%)));
75
71
  color: hsl(var(--color-danger));
76
- background: hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l));
77
- /* IE FIX */
78
- background: linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - 10%)));
72
+ background: linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%)));
79
73
  }
80
- .mg-button.mg-button--danger-alt:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--danger-alt:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--danger-alt:active:not([disabled], [aria-disabled], .disabled) {
74
+ .mg-button.mg-button--danger-alt:hover:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--danger-alt:focus:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--danger-alt:active:not([disabled], [aria-disabled=true], .disabled) {
81
75
  background: hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l));
82
76
  }
83
77
  .mg-button.mg-button--info {
84
- border-color: hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));
85
- /* IE FIX */
86
- border-color: hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - 10%));
78
+ border-color: hsl(var(--mg-button-info-border-color, var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-border-variation) * 10%)));
87
79
  color: hsl(var(--color-neutral));
88
- background: hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));
89
- /* IE FIX */
90
- background: linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - 10%)));
80
+ background: linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%)));
91
81
  }
92
- .mg-button.mg-button--info:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--info:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--info:active:not([disabled], [aria-disabled], .disabled) {
82
+ .mg-button.mg-button--info:hover:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--info:focus:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--info:active:not([disabled], [aria-disabled=true], .disabled) {
93
83
  background: hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));
94
84
  }
85
+ .mg-button.mg-button--success {
86
+ border-color: hsl(var(--mg-button-success-border-color, var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-border-variation) * 10%)));
87
+ color: hsl(var(--color-dark));
88
+ background: linear-gradient(to bottom, hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l)), hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-gradient) * 10%)));
89
+ }
90
+ .mg-button.mg-button--success:hover:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--success:focus:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--success:active:not([disabled], [aria-disabled=true], .disabled) {
91
+ background: hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l));
92
+ }
95
93
  .mg-button.mg-button--flat {
96
94
  background: none;
97
95
  border: none;
98
96
  }
99
- .mg-button.mg-button--flat:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--flat:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--flat:active:not([disabled], [aria-disabled], .disabled) {
97
+ .mg-button.mg-button--flat:hover:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--flat:focus:not([disabled], [aria-disabled=true], .disabled), .mg-button.mg-button--flat:active:not([disabled], [aria-disabled=true], .disabled) {
100
98
  background: hsla(var(--color-dark), 0.1);
101
99
  }
100
+ .mg-button mg-icon:only-child,
102
101
  .mg-button ::slotted(mg-icon) {
103
102
  display: inline-flex;
104
103
  flex-shrink: 0;
105
104
  line-height: 1;
106
105
  margin: auto 0;
107
106
  }
108
- .mg-button__content {
109
- display: flex;
110
- align-items: baseline;
111
- column-gap: 0.6rem;
112
- }
113
- .mg-button--loading > mg-icon {
107
+ .mg-button.mg-button--loading > mg-icon {
114
108
  position: absolute;
115
109
  left: 50%;
116
110
  top: 50%;
117
111
  transform: translate(-50%, -50%);
118
112
  }
119
- .mg-button--loading .mg-button__content {
113
+ .mg-button.mg-button--loading .mg-button__content {
120
114
  opacity: 0;
121
115
  }
122
- .mg-button ::slotted(mg-badge) {
123
- margin-left: 0.3rem;
116
+
117
+ .mg-button__content {
118
+ display: flex;
119
+ align-items: center;
120
+ column-gap: 0.6rem;
124
121
  }
125
122
 
126
123
  mg-button {
@@ -30,6 +30,15 @@ export class MgButton {
30
30
  * Parent component have to remove the attribute 'disabled' when the process ends.
31
31
  */
32
32
  this.disableOnClick = false;
33
+ /**
34
+ * Prop to set aria-expanded on button element
35
+ */
36
+ this.expanded = false;
37
+ /**
38
+ * Option to set aria-haspopup
39
+ * The aria-haspopup state informs assistive technology users that there is a popup and the type of popup it is, but provides no interactivity.
40
+ */
41
+ this.haspopup = false;
33
42
  /**
34
43
  * Define if button is loading, default to false.
35
44
  * Trigger when button is clicked or key-up ['enter', 'space], then value change to true.
@@ -42,6 +51,9 @@ export class MgButton {
42
51
  this.classList = new ClassList(['mg-button']);
43
52
  /**
44
53
  * Trigger actions onClick event
54
+ *
55
+ * @param {MouseEvent} event click event
56
+ * @returns {void}
45
57
  */
46
58
  this.handleClick = (event) => {
47
59
  if (this.disabled)
@@ -53,11 +65,16 @@ export class MgButton {
53
65
  }
54
66
  };
55
67
  }
56
- validateVariant(newValue) {
68
+ validateVariant(newValue, oldValue) {
57
69
  if (!variants.includes(newValue)) {
58
70
  throw new Error(`<mg-button> prop "variant" must be one of : ${variants.join(', ')}`);
59
71
  }
60
- this.classList.add(`mg-button--${this.variant}`);
72
+ else {
73
+ if (oldValue !== undefined) {
74
+ this.classList.delete(`mg-button--${oldValue}`);
75
+ }
76
+ this.classList.add(`mg-button--${newValue}`);
77
+ }
61
78
  }
62
79
  disabledHandler(isDisabled) {
63
80
  // Remove loading when enable
@@ -79,6 +96,8 @@ export class MgButton {
79
96
  }
80
97
  /**
81
98
  * Check if props are well configured on init
99
+ *
100
+ * @returns {void}
82
101
  */
83
102
  componentWillLoad() {
84
103
  this.validateVariant(this.variant);
@@ -94,9 +113,11 @@ export class MgButton {
94
113
  }
95
114
  /**
96
115
  * Render component
116
+ *
117
+ * @returns {HTMLElement} html element
97
118
  */
98
119
  render() {
99
- return (h("button", { id: this.identifier, class: this.classList.join(), "aria-label": this.label, "aria-disabled": this.disabled, onClick: this.handleClick },
120
+ return (h("button", { id: this.identifier, class: this.classList.join(), "aria-label": this.label, "aria-disabled": this.disabled.toString(), "aria-expanded": this.expanded, "aria-controls": this.controls, "aria-haspopup": this.haspopup, onClick: this.handleClick },
100
121
  this.loading && h("mg-icon", { icon: "loader", spin: true }),
101
122
  h("div", { class: "mg-button__content" },
102
123
  h("slot", null))));
@@ -137,7 +158,7 @@ export class MgButton {
137
158
  "references": {}
138
159
  },
139
160
  "required": false,
140
- "optional": true,
161
+ "optional": false,
141
162
  "docs": {
142
163
  "tags": [],
143
164
  "text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
@@ -216,6 +237,59 @@ export class MgButton {
216
237
  "attribute": "disable-on-click",
217
238
  "reflect": false,
218
239
  "defaultValue": "false"
240
+ },
241
+ "expanded": {
242
+ "type": "boolean",
243
+ "mutable": false,
244
+ "complexType": {
245
+ "original": "boolean",
246
+ "resolved": "boolean",
247
+ "references": {}
248
+ },
249
+ "required": false,
250
+ "optional": false,
251
+ "docs": {
252
+ "tags": [],
253
+ "text": "Prop to set aria-expanded on button element"
254
+ },
255
+ "attribute": "expanded",
256
+ "reflect": false,
257
+ "defaultValue": "false"
258
+ },
259
+ "controls": {
260
+ "type": "string",
261
+ "mutable": false,
262
+ "complexType": {
263
+ "original": "string",
264
+ "resolved": "string",
265
+ "references": {}
266
+ },
267
+ "required": false,
268
+ "optional": false,
269
+ "docs": {
270
+ "tags": [],
271
+ "text": "Prop to set aria-controls on button element"
272
+ },
273
+ "attribute": "controls",
274
+ "reflect": false
275
+ },
276
+ "haspopup": {
277
+ "type": "any",
278
+ "mutable": false,
279
+ "complexType": {
280
+ "original": "boolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog'",
281
+ "resolved": "\"dialog\" | \"grid\" | \"listbox\" | \"menu\" | \"tree\" | boolean",
282
+ "references": {}
283
+ },
284
+ "required": false,
285
+ "optional": false,
286
+ "docs": {
287
+ "tags": [],
288
+ "text": "Option to set aria-haspopup\nThe aria-haspopup state informs assistive technology users that there is a popup and the type of popup it is, but provides no interactivity."
289
+ },
290
+ "attribute": "haspopup",
291
+ "reflect": false,
292
+ "defaultValue": "false"
219
293
  }
220
294
  }; }
221
295
  static get states() { return {
@@ -1,7 +1,15 @@
1
1
  import { h } from '@stencil/core';
2
+ import messages from '../../../../locales/en/messages.json';
2
3
  export default {
3
4
  component: 'mg-character-left',
4
5
  title: 'Atoms/mg-character-left',
6
+ argTypes: {
7
+ template: {
8
+ table: {
9
+ defaultValue: { summary: messages.nbCharLeft },
10
+ },
11
+ },
12
+ },
5
13
  };
6
14
  const Template = args => h("mg-character-left", Object.assign({}, args));
7
15
  export const MgCharacterLeft = Template.bind({});
@@ -1,32 +1,11 @@
1
- import { Component, h, Prop, Watch } from '@stencil/core';
2
- import { messages } from '../../../locales';
1
+ import { Component, Element, h, Prop, Watch } from '@stencil/core';
2
+ import { initLocales } from '../../../locales';
3
3
  export class MgCharacterLeft {
4
4
  constructor() {
5
- /************
6
- * Internal *
7
- ************/
8
- this.mustacheCounter = '{counter}';
9
- /**
10
- * Template to display remaining characters.
11
- * Must have {counter} inside
12
- */
13
- this.template = messages.nbCharLeft;
14
5
  /**
15
6
  * Sets the characters to count
16
7
  */
17
8
  this.characters = '';
18
- /**
19
- * Calculate number character left
20
- * @returns {string}
21
- */
22
- this.getMessage = () => {
23
- return this.template.replace(this.mustacheCounter, `<strong>${this.maxlength - this.characters.length}</strong>`);
24
- };
25
- }
26
- validateTemplate(newValue) {
27
- if (typeof newValue !== 'string' || newValue === '' || newValue.indexOf(this.mustacheCounter) === -1) {
28
- throw new Error(`<mg-character-left> prop "template" must contain "${this.mustacheCounter}".`);
29
- }
30
9
  }
31
10
  validateMaxlength(newValue) {
32
11
  if (typeof newValue !== 'number') {
@@ -36,12 +15,27 @@ export class MgCharacterLeft {
36
15
  /*************
37
16
  * Lifecycle *
38
17
  *************/
18
+ /**
19
+ * Check if props are well configured on init
20
+ *
21
+ * @returns {void}
22
+ */
39
23
  componentWillLoad() {
40
- this.validateTemplate(this.template);
41
24
  this.validateMaxlength(this.maxlength);
25
+ this.messages = initLocales(this.element).messages;
42
26
  }
27
+ /**
28
+ * Render component
29
+ *
30
+ * @returns {HTMLElement} HTML Element
31
+ */
43
32
  render() {
44
- return h("span", { id: this.identifier, innerHTML: this.getMessage(), "aria-live": "polite" });
33
+ return (h("span", { id: this.identifier, "aria-live": "polite" },
34
+ h("span", { "aria-hidden": "true" },
35
+ this.maxlength - this.characters.length,
36
+ "/",
37
+ this.maxlength),
38
+ h("span", { class: "sr-only" }, this.messages.nbCharLeft.replace('{counter}', this.maxlength - this.characters.length))));
45
39
  }
46
40
  static get is() { return "mg-character-left"; }
47
41
  static get encapsulation() { return "scoped"; }
@@ -69,24 +63,6 @@ export class MgCharacterLeft {
69
63
  "attribute": "identifier",
70
64
  "reflect": false
71
65
  },
72
- "template": {
73
- "type": "string",
74
- "mutable": false,
75
- "complexType": {
76
- "original": "string",
77
- "resolved": "string",
78
- "references": {}
79
- },
80
- "required": false,
81
- "optional": false,
82
- "docs": {
83
- "tags": [],
84
- "text": "Template to display remaining characters.\nMust have {counter} inside"
85
- },
86
- "attribute": "template",
87
- "reflect": false,
88
- "defaultValue": "messages.nbCharLeft"
89
- },
90
66
  "characters": {
91
67
  "type": "string",
92
68
  "mutable": false,
@@ -123,10 +99,8 @@ export class MgCharacterLeft {
123
99
  "reflect": false
124
100
  }
125
101
  }; }
102
+ static get elementRef() { return "element"; }
126
103
  static get watchers() { return [{
127
- "propName": "template",
128
- "methodName": "validateTemplate"
129
- }, {
130
104
  "propName": "maxlength",
131
105
  "methodName": "validateMaxlength"
132
106
  }]; }
@@ -1,5 +1,5 @@
1
1
  import { h } from '@stencil/core';
2
- import { icons, sizes, variants } from './mg-icon.conf';
2
+ import { icons, sizes, variants } from '../mg-icon.conf';
3
3
  export default {
4
4
  component: 'mg-icon',
5
5
  title: 'Atoms/mg-icon',