@mgdis/mg-components 3.1.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 (271) hide show
  1. package/LICENSE +29 -0
  2. package/dist/cjs/css-shim-a22512c4.js +6 -0
  3. package/dist/cjs/index-85a4a0b6.js +1674 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +35 -0
  6. package/dist/cjs/mg-badge_20.cjs.entry.js +4661 -0
  7. package/dist/cjs/mg-components.cjs.js +23 -0
  8. package/dist/cjs/shadow-css-8940f82d.js +390 -0
  9. package/dist/collection/collection-manifest.json +31 -0
  10. package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +4 -0
  11. package/dist/collection/components/atoms/mg-badge/mg-badge.css +99 -0
  12. package/dist/collection/components/atoms/mg-badge/mg-badge.js +148 -0
  13. package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +27 -0
  14. package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
  15. package/dist/collection/components/atoms/mg-button/mg-button.css +134 -0
  16. package/dist/collection/components/atoms/mg-button/mg-button.js +236 -0
  17. package/dist/collection/components/atoms/mg-button/mg-button.stories.js +38 -0
  18. package/dist/collection/components/atoms/mg-character-left/mg-character-left.css +3 -0
  19. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +133 -0
  20. package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +15 -0
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +54 -0
  22. package/dist/collection/components/atoms/mg-icon/mg-icon.css +57 -0
  23. package/dist/collection/components/atoms/mg-icon/mg-icon.js +155 -0
  24. package/dist/collection/components/atoms/mg-icon/mg-icon.stories.js +34 -0
  25. package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +12 -0
  26. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +95 -0
  27. package/dist/collection/components/atoms/mg-input-title/mg-input-title.stories.js +21 -0
  28. package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js +4 -0
  29. package/dist/collection/components/atoms/mg-tag/mg-tag.css +73 -0
  30. package/dist/collection/components/atoms/mg-tag/mg-tag.js +94 -0
  31. package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +25 -0
  32. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +44 -0
  33. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +225 -0
  34. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.stories.js +26 -0
  35. package/dist/collection/components/molecules/inputs/MgInput.conf.js +7 -0
  36. package/dist/collection/components/molecules/inputs/MgInput.js +130 -0
  37. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +1 -0
  38. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +156 -0
  39. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +444 -0
  40. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +57 -0
  41. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +7 -0
  42. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +171 -0
  43. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +467 -0
  44. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +46 -0
  45. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +11 -0
  46. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +199 -0
  47. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +633 -0
  48. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +68 -0
  49. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +195 -0
  50. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +401 -0
  51. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +43 -0
  52. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js +1 -0
  53. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +156 -0
  54. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +443 -0
  55. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +65 -0
  56. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js +1 -0
  57. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +201 -0
  58. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +532 -0
  59. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +70 -0
  60. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +222 -0
  61. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +589 -0
  62. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +115 -0
  63. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +217 -0
  64. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +553 -0
  65. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +52 -0
  66. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +1 -0
  67. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +213 -0
  68. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +457 -0
  69. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +73 -0
  70. package/dist/collection/components/molecules/mg-message/mg-message.conf.js +4 -0
  71. package/dist/collection/components/molecules/mg-message/mg-message.css +94 -0
  72. package/dist/collection/components/molecules/mg-message/mg-message.js +285 -0
  73. package/dist/collection/components/molecules/mg-message/mg-message.stories.js +43 -0
  74. package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +5 -0
  75. package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +39 -0
  76. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +218 -0
  77. package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +23 -0
  78. package/dist/collection/components/molecules/mg-popover/mg-popover.css +59 -0
  79. package/dist/collection/components/molecules/mg-popover/mg-popover.js +249 -0
  80. package/dist/collection/components/molecules/mg-popover/mg-popover.stories.js +36 -0
  81. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +1 -0
  82. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +30 -0
  83. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +212 -0
  84. package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +40 -0
  85. package/dist/collection/fonts/OpenSans-Regular.ttf +0 -0
  86. package/dist/collection/fonts/OpenSans-SemiBold.ttf +0 -0
  87. package/dist/collection/fonts/Poppins-Bold.ttf +0 -0
  88. package/dist/collection/index.js +1 -0
  89. package/dist/collection/locales/index.js +4 -0
  90. package/dist/collection/stories/buttons.stories.js +43 -0
  91. package/dist/collection/stories/grids.stories.js +50 -0
  92. package/dist/collection/stories/icons.stories.js +20 -0
  93. package/dist/collection/stories/messages.stories.js +44 -0
  94. package/dist/collection/stories/tags.stories.js +13 -0
  95. package/dist/collection/stories/typography.stories.js +28 -0
  96. package/dist/collection/utils/components.utils.js +67 -0
  97. package/dist/collection/utils/locale.utils.js +32 -0
  98. package/dist/collection/utils/test.utils.js +26 -0
  99. package/dist/collection/variables.css +177 -0
  100. package/dist/collection/variables.scss +177 -0
  101. package/dist/components/MgInput.js +140 -0
  102. package/dist/components/components.utils.js +69 -0
  103. package/dist/components/index.d.ts +26 -0
  104. package/dist/components/index.js +1 -0
  105. package/dist/components/index2.js +54 -0
  106. package/dist/components/locale.utils.js +35 -0
  107. package/dist/components/mg-badge.d.ts +11 -0
  108. package/dist/components/mg-badge.js +6 -0
  109. package/dist/components/mg-badge2.js +82 -0
  110. package/dist/components/mg-button.d.ts +11 -0
  111. package/dist/components/mg-button.js +6 -0
  112. package/dist/components/mg-button2.js +148 -0
  113. package/dist/components/mg-character-left.d.ts +11 -0
  114. package/dist/components/mg-character-left.js +6 -0
  115. package/dist/components/mg-character-left2.js +77 -0
  116. package/dist/components/mg-icon.d.ts +11 -0
  117. package/dist/components/mg-icon.js +6 -0
  118. package/dist/components/mg-icon2.js +147 -0
  119. package/dist/components/mg-input-checkbox.d.ts +11 -0
  120. package/dist/components/mg-input-checkbox.js +222 -0
  121. package/dist/components/mg-input-date.d.ts +11 -0
  122. package/dist/components/mg-input-date.js +245 -0
  123. package/dist/components/mg-input-numeric.d.ts +11 -0
  124. package/dist/components/mg-input-numeric.js +324 -0
  125. package/dist/components/mg-input-password.d.ts +11 -0
  126. package/dist/components/mg-input-password.js +171 -0
  127. package/dist/components/mg-input-radio.d.ts +11 -0
  128. package/dist/components/mg-input-radio.js +211 -0
  129. package/dist/components/mg-input-select.d.ts +11 -0
  130. package/dist/components/mg-input-select.js +6 -0
  131. package/dist/components/mg-input-select2.js +243 -0
  132. package/dist/components/mg-input-text.d.ts +11 -0
  133. package/dist/components/mg-input-text.js +242 -0
  134. package/dist/components/mg-input-textarea.d.ts +11 -0
  135. package/dist/components/mg-input-textarea.js +224 -0
  136. package/dist/components/mg-input-title.d.ts +11 -0
  137. package/dist/components/mg-input-title.js +6 -0
  138. package/dist/components/mg-input-title2.js +55 -0
  139. package/dist/components/mg-input-toggle.d.ts +11 -0
  140. package/dist/components/mg-input-toggle.js +247 -0
  141. package/dist/components/mg-message.d.ts +11 -0
  142. package/dist/components/mg-message.js +183 -0
  143. package/dist/components/mg-pagination.d.ts +11 -0
  144. package/dist/components/mg-pagination.js +175 -0
  145. package/dist/components/mg-popover.d.ts +11 -0
  146. package/dist/components/mg-popover.js +183 -0
  147. package/dist/components/mg-tabs.d.ts +11 -0
  148. package/dist/components/mg-tabs.js +160 -0
  149. package/dist/components/mg-tag.d.ts +11 -0
  150. package/dist/components/mg-tag.js +76 -0
  151. package/dist/components/mg-tooltip.d.ts +11 -0
  152. package/dist/components/mg-tooltip.js +6 -0
  153. package/dist/components/mg-tooltip2.js +150 -0
  154. package/dist/components/popper.js +1784 -0
  155. package/dist/esm/css-shim-7c240feb.js +4 -0
  156. package/dist/esm/index-e3e84606.js +1643 -0
  157. package/dist/esm/index.js +1 -0
  158. package/dist/esm/loader.js +31 -0
  159. package/dist/esm/mg-badge_20.entry.js +4638 -0
  160. package/dist/esm/mg-components.js +21 -0
  161. package/dist/esm/polyfills/core-js.js +11 -0
  162. package/dist/esm/polyfills/css-shim.js +1 -0
  163. package/dist/esm/polyfills/dom.js +79 -0
  164. package/dist/esm/polyfills/es5-html-element.js +1 -0
  165. package/dist/esm/polyfills/index.js +34 -0
  166. package/dist/esm/polyfills/system.js +6 -0
  167. package/dist/esm/shadow-css-5d2d01ce.js +388 -0
  168. package/dist/esm-es5/css-shim-7c240feb.js +1 -0
  169. package/dist/esm-es5/index-e3e84606.js +1 -0
  170. package/dist/esm-es5/index.js +0 -0
  171. package/dist/esm-es5/loader.js +1 -0
  172. package/dist/esm-es5/mg-badge_20.entry.js +2 -0
  173. package/dist/esm-es5/mg-components.js +1 -0
  174. package/dist/esm-es5/shadow-css-5d2d01ce.js +12 -0
  175. package/dist/index.cjs.js +1 -0
  176. package/dist/index.js +1 -0
  177. package/dist/mg-components/fonts/OpenSans-Regular.ttf +0 -0
  178. package/dist/mg-components/fonts/OpenSans-SemiBold.ttf +0 -0
  179. package/dist/mg-components/fonts/Poppins-Bold.ttf +0 -0
  180. package/dist/mg-components/index.esm.js +0 -0
  181. package/dist/mg-components/mg-components.css +1 -0
  182. package/dist/mg-components/mg-components.esm.js +1 -0
  183. package/dist/mg-components/mg-components.js +132 -0
  184. package/dist/mg-components/p-1cd24462.system.js +1 -0
  185. package/dist/mg-components/p-2e2f6b27.system.entry.js +2 -0
  186. package/dist/mg-components/p-366a224e.js +1 -0
  187. package/dist/mg-components/p-422c429b.system.js +1 -0
  188. package/dist/mg-components/p-50ea2036.system.js +1 -0
  189. package/dist/mg-components/p-62fa3797.js +1 -0
  190. package/dist/mg-components/p-71d57b8b.system.js +13 -0
  191. package/dist/mg-components/p-9a215712.system.js +1 -0
  192. package/dist/mg-components/p-cbf0464b.entry.js +1 -0
  193. package/dist/mg-components/p-f6455ab3.js +12 -0
  194. package/dist/mg-components/variables.css +177 -0
  195. package/dist/mg-components/variables.scss +177 -0
  196. package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +8 -0
  197. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +36 -0
  198. package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +19 -0
  199. package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +4 -0
  200. package/dist/types/components/atoms/mg-button/mg-button.d.ts +67 -0
  201. package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +16 -0
  202. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +39 -0
  203. package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +7 -0
  204. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +12 -0
  205. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +36 -0
  206. package/dist/types/components/atoms/mg-icon/mg-icon.stories.d.ts +26 -0
  207. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +24 -0
  208. package/dist/types/components/atoms/mg-input-title/mg-input-title.stories.d.ts +6 -0
  209. package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +4 -0
  210. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +25 -0
  211. package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +14 -0
  212. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +56 -0
  213. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +11 -0
  214. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +10 -0
  215. package/dist/types/components/molecules/inputs/MgInput.d.ts +35 -0
  216. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +19 -0
  217. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +120 -0
  218. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +6 -0
  219. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +6 -0
  220. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +128 -0
  221. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +7 -0
  222. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +10 -0
  223. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +173 -0
  224. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +21 -0
  225. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +111 -0
  226. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +9 -0
  227. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +9 -0
  228. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +121 -0
  229. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +15 -0
  230. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +18 -0
  231. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +133 -0
  232. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +14 -0
  233. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +160 -0
  234. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +26 -0
  235. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +150 -0
  236. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +6 -0
  237. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +8 -0
  238. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +117 -0
  239. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +7 -0
  240. package/dist/types/components/molecules/mg-message/mg-message.conf.d.ts +4 -0
  241. package/dist/types/components/molecules/mg-message/mg-message.d.ts +76 -0
  242. package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +16 -0
  243. package/dist/types/components/molecules/mg-pagination/mg-pagination.conf.d.ts +4 -0
  244. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +53 -0
  245. package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +6 -0
  246. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +62 -0
  247. package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +12 -0
  248. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +10 -0
  249. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +63 -0
  250. package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +7 -0
  251. package/dist/types/components.d.ts +1987 -0
  252. package/dist/types/index.d.ts +1 -0
  253. package/dist/types/locales/index.d.ts +44 -0
  254. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  255. package/dist/types/stories/buttons.stories.d.ts +13 -0
  256. package/dist/types/stories/grids.stories.d.ts +5 -0
  257. package/dist/types/stories/icons.stories.d.ts +13 -0
  258. package/dist/types/stories/messages.stories.d.ts +13 -0
  259. package/dist/types/stories/tags.stories.d.ts +5 -0
  260. package/dist/types/stories/typography.stories.d.ts +5 -0
  261. package/dist/types/utils/components.utils.d.ts +43 -0
  262. package/dist/types/utils/locale.utils.d.ts +22 -0
  263. package/dist/types/utils/test.utils.d.ts +5 -0
  264. package/loader/cdn.js +3 -0
  265. package/loader/index.cjs.js +3 -0
  266. package/loader/index.d.ts +12 -0
  267. package/loader/index.es2017.js +3 -0
  268. package/loader/index.js +4 -0
  269. package/loader/package.json +10 -0
  270. package/package.json +86 -0
  271. package/readme.md +159 -0
@@ -0,0 +1,212 @@
1
+ import { Component, h, Host, Prop, State, Element, Watch } from '@stencil/core';
2
+ import { createID, ClassList, allItemsAreString } from '../../../utils/components.utils';
3
+ /**
4
+ * type TabItem validation function
5
+ * @param tab
6
+ * @returns {boolean}
7
+ */
8
+ const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
9
+ export class MgTabs {
10
+ constructor() {
11
+ /**
12
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
13
+ * If not set, it will be created.
14
+ */
15
+ this.identifier = createID('mg-tabs');
16
+ /**
17
+ * Active tab number
18
+ * default: first is 1
19
+ */
20
+ this.activeTab = 1;
21
+ /**
22
+ * Component tabs
23
+ */
24
+ this.tabs = [];
25
+ /**
26
+ * Component classes
27
+ */
28
+ this.classList = new ClassList(['mg-tabs']);
29
+ /**
30
+ * Handle click events on tabs
31
+ * @param event
32
+ */
33
+ this.handleClick = (event) => {
34
+ const tabId = event.currentTarget.getAttribute('data-index');
35
+ this.activeTab = Number(tabId);
36
+ };
37
+ /**
38
+ * Handle keyboard event on tabs
39
+ * @param event
40
+ */
41
+ this.handleKeydown = (event) => {
42
+ let selectedTab;
43
+ let tabId = Number(event.target.getAttribute('data-index'));
44
+ const parent = event.target.parentElement;
45
+ // change selected id from key code
46
+ // /* IE FIX */ delete 'Right'
47
+ if (['ArrowRight', 'Right'].includes(event.key)) {
48
+ tabId++;
49
+ // /* IE FIX */ delete 'Left'
50
+ }
51
+ else if (['ArrowLeft', 'Left'].includes(event.key)) {
52
+ tabId--;
53
+ }
54
+ // get selected tab
55
+ selectedTab = parent.querySelector(`[data-index="${tabId}"]`);
56
+ // apply selected tab if exist
57
+ if (selectedTab !== null) {
58
+ selectedTab.focus();
59
+ this.activeTab = tabId;
60
+ }
61
+ };
62
+ /**
63
+ * Validate slots setting
64
+ */
65
+ this.validateSlots = () => {
66
+ const slots = Array.from(this.element.children).filter(slot => { var _a; return (_a = slot.getAttribute('slot')) === null || _a === void 0 ? void 0 : _a.includes('tab_content-'); });
67
+ if (slots.length !== this.tabs.length) {
68
+ throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
69
+ }
70
+ };
71
+ }
72
+ validateItems(newValue) {
73
+ // String array
74
+ if (allItemsAreString(newValue)) {
75
+ this.tabs = newValue.map(item => ({ label: item }));
76
+ }
77
+ // Object array
78
+ else if (newValue && newValue.every(item => isTabItem(item))) {
79
+ this.tabs = newValue;
80
+ }
81
+ else {
82
+ throw new Error('<mg-tabs> prop "items" is required and all items must be the same type: TabItem.');
83
+ }
84
+ }
85
+ validateActiveTab(newValue) {
86
+ if (Number(newValue) < 1 || Number(newValue) > this.tabs.length) {
87
+ throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
88
+ }
89
+ }
90
+ /*************
91
+ * Lifecycle *
92
+ *************/
93
+ /**
94
+ * Check if component props are well configured on init
95
+ */
96
+ componentWillLoad() {
97
+ // Check tabs format
98
+ this.validateItems(this.items);
99
+ this.validateActiveTab(this.activeTab);
100
+ this.validateSlots();
101
+ }
102
+ render() {
103
+ return (h(Host, null,
104
+ h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => {
105
+ const tabIndex = index + 1;
106
+ return (h("button", { role: "tab", id: `${this.identifier}-${tabIndex}`, class: `mg-tabs__navigation-button ${tabIndex === this.activeTab ? 'mg-tabs__navigation-button--active' : ''}`, 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 },
107
+ tab.icon !== undefined && h("mg-icon", { icon: tab.icon }),
108
+ tab.label,
109
+ tab.badge !== undefined && h("mg-badge", { variant: "info", value: tab.badge.value, label: tab.badge.label })));
110
+ })),
111
+ this.tabs.map((_tab, index) => {
112
+ const tabIndex = index + 1;
113
+ 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" },
114
+ h("slot", { name: `tab_content-${tabIndex}` })));
115
+ })));
116
+ }
117
+ static get is() { return "mg-tabs"; }
118
+ static get encapsulation() { return "scoped"; }
119
+ static get originalStyleUrls() { return {
120
+ "$": ["mg-tabs.scss"]
121
+ }; }
122
+ static get styleUrls() { return {
123
+ "$": ["mg-tabs.css"]
124
+ }; }
125
+ static get properties() { return {
126
+ "identifier": {
127
+ "type": "string",
128
+ "mutable": false,
129
+ "complexType": {
130
+ "original": "string",
131
+ "resolved": "string",
132
+ "references": {}
133
+ },
134
+ "required": false,
135
+ "optional": true,
136
+ "docs": {
137
+ "tags": [],
138
+ "text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
139
+ },
140
+ "attribute": "identifier",
141
+ "reflect": false,
142
+ "defaultValue": "createID('mg-tabs')"
143
+ },
144
+ "label": {
145
+ "type": "string",
146
+ "mutable": false,
147
+ "complexType": {
148
+ "original": "string",
149
+ "resolved": "string",
150
+ "references": {}
151
+ },
152
+ "required": true,
153
+ "optional": false,
154
+ "docs": {
155
+ "tags": [],
156
+ "text": "Tabs label. Include short tabs description.\nRequired for accessibility"
157
+ },
158
+ "attribute": "label",
159
+ "reflect": false
160
+ },
161
+ "items": {
162
+ "type": "unknown",
163
+ "mutable": false,
164
+ "complexType": {
165
+ "original": "string[] | TabItem[]",
166
+ "resolved": "TabItem[] | string[]",
167
+ "references": {
168
+ "TabItem": {
169
+ "location": "import",
170
+ "path": "./mg-tabs.conf"
171
+ }
172
+ }
173
+ },
174
+ "required": true,
175
+ "optional": false,
176
+ "docs": {
177
+ "tags": [],
178
+ "text": "Tabs items\nRequired"
179
+ }
180
+ },
181
+ "activeTab": {
182
+ "type": "number",
183
+ "mutable": true,
184
+ "complexType": {
185
+ "original": "number",
186
+ "resolved": "number",
187
+ "references": {}
188
+ },
189
+ "required": false,
190
+ "optional": false,
191
+ "docs": {
192
+ "tags": [],
193
+ "text": "Active tab number\ndefault: first is 1"
194
+ },
195
+ "attribute": "active-tab",
196
+ "reflect": true,
197
+ "defaultValue": "1"
198
+ }
199
+ }; }
200
+ static get states() { return {
201
+ "tabs": {},
202
+ "classList": {}
203
+ }; }
204
+ static get elementRef() { return "element"; }
205
+ static get watchers() { return [{
206
+ "propName": "items",
207
+ "methodName": "validateItems"
208
+ }, {
209
+ "propName": "activeTab",
210
+ "methodName": "validateActiveTab"
211
+ }]; }
212
+ }
@@ -0,0 +1,40 @@
1
+ import { h } from '@stencil/core';
2
+ export default {
3
+ component: 'mg-tabs',
4
+ title: 'Molecules/mg-tabs',
5
+ };
6
+ /**
7
+ * 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
+ * 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
9
+ */
10
+ const Template = args => {
11
+ // return element
12
+ const activeTab = args.activeTab;
13
+ delete args.activeTab;
14
+ return (h("mg-tabs", Object.assign({}, args, { "active-tab": activeTab }),
15
+ h("div", { slot: "tab_content-1" }, "Content 1"),
16
+ h("div", { slot: "tab_content-2" }, "Content 2"),
17
+ h("div", { slot: "tab_content-3" }, "Content 3")));
18
+ };
19
+ export const MgTabs = Template.bind({});
20
+ MgTabs.args = {
21
+ items: ['Tab 1', 'Tab 2', 'Tab 3'],
22
+ label: 'Short tabs description. Needeed for accessibility',
23
+ activeTab: undefined,
24
+ };
25
+ export const MgTabsItems = Template.bind({});
26
+ MgTabsItems.args = Object.assign(Object.assign({}, MgTabs.args), { items: [
27
+ {
28
+ label: 'Tab 1',
29
+ icon: 'check',
30
+ badge: { value: 1, label: 'message' },
31
+ },
32
+ {
33
+ label: 'Tab 2',
34
+ badge: { value: 5, label: 'messages' },
35
+ },
36
+ {
37
+ label: 'Tab 3',
38
+ icon: 'cross',
39
+ },
40
+ ] });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export const locale = 'fr-FR';
2
+ import fr from './fr-FR/messages.json';
3
+ export const messages = fr;
4
+ export const currency = 'EUR';
@@ -0,0 +1,43 @@
1
+ import { h } from '@stencil/core';
2
+ import { variants } from '../components/atoms/mg-button/mg-button.conf';
3
+ export default {
4
+ title: 'Style/Buttons',
5
+ argTypes: {
6
+ align: {
7
+ options: ['left', 'right'],
8
+ control: { type: 'select' },
9
+ },
10
+ },
11
+ };
12
+ const Template = args => (h("div", null,
13
+ h("h1", null, "Buttons"),
14
+ variants.map(variant => (h("div", { style: { marginBottom: '1rem' }, class: `mg-group-elements${args.align === 'right' ? ' mg-group-elements--align-right' : ''}` },
15
+ h("button", Object.assign({ class: `mg-button mg-button--${variant}` }, args), variant),
16
+ h("button", Object.assign({ class: `mg-button mg-button--${variant}` }, args),
17
+ h("mg-icon", { icon: "info-circle" }),
18
+ variant),
19
+ h("button", Object.assign({ class: `mg-button mg-button--${variant} mg-button--icon` }, args),
20
+ h("mg-icon", { icon: "info-circle" }))))),
21
+ h("h2", null, "Link"),
22
+ variants.map(variant => (h("div", { style: { marginBottom: '1rem' }, class: `mg-group-elements${args.align === 'right' ? ' mg-group-elements--align-right' : ''}` },
23
+ h("a", Object.assign({ class: `mg-button mg-button--${variant}` }, args), variant),
24
+ h("a", Object.assign({ class: `mg-button mg-button--${variant}` }, args),
25
+ h("mg-icon", { icon: "info-circle" }),
26
+ variant),
27
+ h("a", Object.assign({ class: `mg-button mg-button--${variant} mg-button--icon` }, args),
28
+ h("mg-icon", { icon: "info-circle" }))))),
29
+ h("h2", null, "Helpers"),
30
+ h("h3", null, ".mg-group-elements"),
31
+ h("p", null,
32
+ "Buttons can be grouped in an HTMLelement using the ",
33
+ h("code", null, ".mg-group-elements"),
34
+ " class, it will ensure a 10px margin space between them, even verticaly. Above exemples are using it."),
35
+ h("p", null,
36
+ "By adding the ",
37
+ h("code", null, ".mg-group-elements--align-right"),
38
+ " class you 'll set a right alignment of the button, even when line breaks.")));
39
+ export const Buttons = Template.bind({});
40
+ Buttons.args = {
41
+ disabled: false,
42
+ align: 'left',
43
+ };
@@ -0,0 +1,50 @@
1
+ import { h } from '@stencil/core';
2
+ export default {
3
+ title: 'Style/Layout/Grid',
4
+ };
5
+ const Template = () => (h("main", { id: "demo" },
6
+ h("h1", null, "Grid"),
7
+ h("p", null,
8
+ "You can use grid classes by using the ",
9
+ h("code", null, ".mg-grid"),
10
+ " class in the container. This call will add flex properties to the container."),
11
+ h("h2", null, "Auto layout"),
12
+ h("p", null,
13
+ "Default column class is ",
14
+ h("code", null, "mg-grid__col"),
15
+ ". The width will be defined by the number of element using the class."),
16
+ h("div", { class: "mg-grid" },
17
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col"),
18
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col")),
19
+ h("div", { class: "mg-grid" },
20
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col"),
21
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col"),
22
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col")),
23
+ h("div", { class: "mg-grid" },
24
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col"),
25
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col"),
26
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col"),
27
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col"),
28
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col")),
29
+ h("h2", null, "Sized column"),
30
+ h("p", null, "Like Bootstrap, you can use sized colomn based on a 12 colomns grid."),
31
+ h("p", null,
32
+ "The library is using the BEM methodology, so to define a column width we need to set a modifier class, for exemple ",
33
+ h("code", null, "mg-grid__col-2"),
34
+ "."),
35
+ [...Array.from(Array(12).keys())].map((_e, i) => (h("div", { class: "mg-grid" },
36
+ h("div", { class: `mg-grid__col mg-grid__col-${i + 1}` },
37
+ ".mg-grid__col.mg-grid__col-",
38
+ i + 1)))),
39
+ h("h2", null, "Mix"),
40
+ h("p", null, "You can also mix unsized column with sized column."),
41
+ h("div", { class: "mg-grid" },
42
+ h("div", { class: "mg-grid__col mg-grid__col-3" }, ".mg-grid__col.mg-grid__col-3"),
43
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col"),
44
+ h("div", { class: "mg-grid__col mg-grid__col-3" }, ".mg-grid__col.mg-grid__col-3")),
45
+ h("div", { class: "mg-grid" },
46
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col"),
47
+ h("div", { class: "mg-grid__col mg-grid__col-5" }, ".mg-grid__col.mg-grid__col-5"),
48
+ h("div", { class: "mg-grid__col" }, ".mg-grid__col"))));
49
+ export const Grid = Template.bind({});
50
+ Grid.args = {};
@@ -0,0 +1,20 @@
1
+ import { h } from '@stencil/core';
2
+ import { icons, sizes } from '../components/atoms/mg-icon/mg-icon.conf';
3
+ export default {
4
+ title: 'Style/Icons',
5
+ argTypes: {
6
+ size: {
7
+ options: sizes,
8
+ control: { type: 'select' },
9
+ },
10
+ },
11
+ };
12
+ const Template = args => (h("ul", { style: { display: 'flex', flexWrap: 'wrap', margin: '0', padding: '0', listStyle: 'none', textAlign: 'center' } }, Object.keys(icons).map((icon) => (h("li", { style: { margin: '1rem', padding: '1rem', width: '100px' } },
13
+ h("div", { style: { color: args.color, margin: '1rem' } },
14
+ h("mg-icon", { icon: icon, size: args.size })),
15
+ h("div", null, icon))))));
16
+ export const Icons = Template.bind({});
17
+ Icons.args = {
18
+ color: '',
19
+ size: sizes[0], // regular
20
+ };
@@ -0,0 +1,44 @@
1
+ import { h } from '@stencil/core';
2
+ import { variants } from '../components/molecules/mg-message/mg-message.conf';
3
+ export default {
4
+ title: 'Style/Messages',
5
+ argTypes: {
6
+ variant: {
7
+ options: variants,
8
+ control: { type: 'select' },
9
+ },
10
+ },
11
+ };
12
+ const Template = args => (h("main", null,
13
+ h("h1", null, "Messages"),
14
+ h("h2", null, "Simple"),
15
+ h("div", { class: `mg-message mg-message--${args.variant}` },
16
+ h("span", { class: "mg-message__icon" },
17
+ h("mg-icon", { icon: "info-circle" })),
18
+ h("div", { class: "mg-message__content" },
19
+ h("span", { class: "mg-message__content-slot", innerHTML: args.content }))),
20
+ h("h2", null, "w/ close button"),
21
+ h("div", { class: `mg-message mg-message--${args.variant} mg-message--close-button` },
22
+ h("span", { class: "mg-message__icon" },
23
+ h("mg-icon", { icon: "info-circle" })),
24
+ h("div", { class: "mg-message__content" },
25
+ h("span", { class: "mg-message__content-slot", innerHTML: args.content })),
26
+ h("span", { class: "mg-message__close-button" },
27
+ h("button", { class: "mg-button mg-button--flat mg-button--icon" },
28
+ h("mg-icon", { icon: "cross", size: "small" })))),
29
+ h("h2", null, "w/ actions"),
30
+ h("div", { class: `mg-message mg-message--${args.variant}` },
31
+ h("span", { class: "mg-message__icon" },
32
+ h("mg-icon", { icon: "info-circle" })),
33
+ h("div", { class: "mg-message__content" },
34
+ h("span", { class: "mg-message__content-slot", innerHTML: args.content }),
35
+ h("span", { class: "mg-message__content-separator" }),
36
+ h("span", { class: "mg-message__content-actions-slot" },
37
+ h("span", { class: "mg-group-elements mg-group-elements--align-right" },
38
+ h("button", { class: "mg-button mg-button--primary" }, "Primary"),
39
+ h("button", { class: "mg-button mg-button--secondary" }, "Secondary")))))));
40
+ export const Messages = Template.bind({});
41
+ Messages.args = {
42
+ variant: variants[0],
43
+ content: '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>',
44
+ };
@@ -0,0 +1,13 @@
1
+ import { h } from '@stencil/core';
2
+ import { variants } from '../components/atoms/mg-tag/mg-tag.conf';
3
+ export default {
4
+ title: 'Style/Tags',
5
+ };
6
+ const Template = args => (h("div", null,
7
+ h("h1", null, "Tags"),
8
+ h("h2", null, "Plain"),
9
+ h("div", { class: "mg-group-elements" }, variants.map(variant => (h("span", Object.assign({ class: `mg-tag mg-tag--${variant}` }, args), variant)))),
10
+ h("h2", null, "Outline"),
11
+ h("div", { class: "mg-group-elements" }, variants.map(variant => (h("span", Object.assign({ class: `mg-tag mg-tag--${variant} mg-tag--outline` }, args), variant))))));
12
+ export const Tags = Template.bind({});
13
+ Tags.args = {};
@@ -0,0 +1,28 @@
1
+ import { h } from '@stencil/core';
2
+ export default {
3
+ title: 'Style/Typography',
4
+ };
5
+ const Template = args => (h("div", null,
6
+ h("h1", null, args.h1),
7
+ h("h2", null, args.h2),
8
+ h("h3", null, args.h3),
9
+ h("h4", null, args.h4),
10
+ h("h5", null, args.h5),
11
+ h("h6", null, args.h6),
12
+ h("p", null, args.p),
13
+ h("p", null,
14
+ h("strong", null, args.strong)),
15
+ h("p", null,
16
+ h("small", null, args.small))));
17
+ export const Typography = Template.bind({});
18
+ Typography.args = {
19
+ h1: 'The h1 heading element',
20
+ h2: 'The h2 heading element',
21
+ h3: 'The h3 heading element',
22
+ h4: 'The h4 heading element',
23
+ h5: 'The h5 heading element',
24
+ h6: 'The h6 heading element',
25
+ p: 'The Paragraph element',
26
+ strong: 'The Strong Importance element',
27
+ small: 'The side comment element',
28
+ };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Create random ID
3
+ * @param prefix {string} add prefix to created ID
4
+ * @returns {string} ID
5
+ */
6
+ export function createID(prefix = '', length = 10) {
7
+ let ID = '';
8
+ const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
9
+ const charsLength = chars.length;
10
+ for (var i = 0; i < length; i++) {
11
+ ID += chars.charAt(Math.floor(Math.random() * charsLength));
12
+ }
13
+ return (prefix !== '' ? `${prefix}-` : '') + ID;
14
+ }
15
+ /**
16
+ * Class to manage component classlist
17
+ * Set() are not working when imported in project
18
+ */
19
+ export class ClassList {
20
+ constructor(classlist = []) {
21
+ /**
22
+ * Add class
23
+ * @param className
24
+ * @returns {void}
25
+ */
26
+ this.add = (className) => {
27
+ if (!this.has(className)) {
28
+ this.classes.push(className);
29
+ }
30
+ };
31
+ /**
32
+ * Delete class
33
+ * @param className
34
+ * @returns {void}
35
+ */
36
+ this.delete = (className) => {
37
+ const index = this.classes.indexOf(className);
38
+ if (index > -1) {
39
+ this.classes.splice(index, 1);
40
+ }
41
+ };
42
+ /**
43
+ * Check if class exist in list
44
+ * @param className
45
+ * @returns {boolean}
46
+ */
47
+ this.has = (className) => {
48
+ return this.classes.includes(className);
49
+ };
50
+ /**
51
+ * Join classes seperated by spaces
52
+ * @returns {string}
53
+ */
54
+ this.join = () => {
55
+ return this.classes.join(' ');
56
+ };
57
+ this.classes = classlist;
58
+ }
59
+ }
60
+ /**
61
+ * Check if all items are string
62
+ * @param items
63
+ * @returns {boolean}
64
+ */
65
+ export function allItemsAreString(items) {
66
+ return items && items.every(item => typeof item === 'string');
67
+ }
@@ -0,0 +1,32 @@
1
+ import { locale, currency } from '../locales';
2
+ /**
3
+ * Format number to the locale currency
4
+ * @param number {number}
5
+ * @returns {string} formatted currency
6
+ */
7
+ export function localeCurrency(number) {
8
+ return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
9
+ }
10
+ /**
11
+ * Format number to locale
12
+ * @param number {number}
13
+ * @returns {string} formatted number
14
+ */
15
+ export function localeNumber(number) {
16
+ return new Intl.NumberFormat(locale).format(number);
17
+ }
18
+ /**
19
+ * Date RegExp
20
+ */
21
+ export const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
22
+ /**
23
+ * Locale date format
24
+ * @param date {string}
25
+ * @returns {string} formatted date
26
+ */
27
+ export function localeDate(date) {
28
+ if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
29
+ return '';
30
+ }
31
+ return new Intl.DateTimeFormat(locale).format(new Date(date));
32
+ }
@@ -0,0 +1,26 @@
1
+ import { newE2EPage } from '@stencil/core/testing';
2
+ export async function createPage(htmlString) {
3
+ const options = {
4
+ html: `<link rel="stylesheet" href="http://localhost:3333/build/variables.css" /><meta charset="UTF-8">${htmlString}`,
5
+ viewportWidth: 600,
6
+ };
7
+ const page = (await newE2EPage());
8
+ const viewport = Object.assign({ height: page.viewport().height }, { width: options.viewportWidth });
9
+ await page.setViewport(viewport);
10
+ await page.setContent(options.html, { waitUntil: 'networkidle0' });
11
+ await page.evaluateHandle('document.fonts.ready');
12
+ // monkey patch screenshot function to add some extra features
13
+ const screenshot = page.screenshot;
14
+ page.screenshot = async function () {
15
+ return screenshot.call(page, {
16
+ clip: {
17
+ x: 0,
18
+ y: 0,
19
+ width: page.viewport().width,
20
+ height: page.viewport().height,
21
+ },
22
+ });
23
+ };
24
+ return page;
25
+ }
26
+ export const cloneDeep = el => JSON.parse(JSON.stringify(el));