@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
@@ -0,0 +1,244 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { c as createID, C as ClassList } from './components.utils.js';
3
+ import { i as initLocales } from './index2.js';
4
+ import { d as defineCustomElement$7 } from './mg-button2.js';
5
+ import { d as defineCustomElement$6 } from './mg-character-left2.js';
6
+ import { d as defineCustomElement$5 } from './mg-icon2.js';
7
+ import { d as defineCustomElement$4 } from './mg-input-text2.js';
8
+ import { d as defineCustomElement$3 } from './mg-input-title2.js';
9
+ import { d as defineCustomElement$2 } from './mg-tooltip2.js';
10
+
11
+ const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);box-shadow:var(--box-shadow)}.mg-panel__header{display:flex;flex-wrap:wrap;justify-content:space-between;padding:0 1rem 0 0.3rem;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:flex;margin:0.3rem 0}.mg-panel__header-left--full{flex:1 1 auto}.mg-panel__header-right{flex:1 auto}.mg-panel__header-left mg-input-text{flex-grow:1}.mg-panel__collapse-button .mg-button{font-family:var(--font-family-heading);font-size:1.4rem;font-weight:500}.mg-panel__collapse-button,.mg-panel__edit-button{margin:0 0.3rem 0 0}.mg-panel__content{padding:1.5rem}.mg-panel ::slotted([slot=header-right]){display:flex;flex-wrap:wrap;gap:1rem;margin-left:auto}";
12
+
13
+ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14
+ constructor() {
15
+ super();
16
+ this.__registerHost();
17
+ this.__attachShadow();
18
+ this.titleChange = createEvent(this, "title-change", 7);
19
+ this.expandedChange = createEvent(this, "expanded-change", 7);
20
+ /**
21
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
22
+ * If not set, it will be created.
23
+ */
24
+ this.identifier = createID('mg-panel');
25
+ /**
26
+ * Panel is opened
27
+ */
28
+ this.expanded = false;
29
+ /**
30
+ * Disable possibility to toggle expand
31
+ */
32
+ this.expandToggleDisabled = false;
33
+ /**
34
+ * Panel title is editabled
35
+ */
36
+ this.titleEditable = false;
37
+ /**
38
+ * Component classes
39
+ */
40
+ this.classList = new ClassList(['mg-panel']);
41
+ /**
42
+ * Title is in edition mode
43
+ */
44
+ this.isEditing = false;
45
+ /************
46
+ * Methods *
47
+ ************/
48
+ /**
49
+ * Toggle is editing state
50
+ *
51
+ * @returns {void}
52
+ */
53
+ this.toggleIsEditing = () => {
54
+ this.isEditing = !this.isEditing;
55
+ };
56
+ /************
57
+ * Handlers *
58
+ ************/
59
+ /**
60
+ * Collapse button click handler
61
+ *
62
+ * @returns {void}
63
+ */
64
+ this.handleCollapseButton = () => {
65
+ if (!this.expandToggleDisabled) {
66
+ this.expanded = !this.expanded;
67
+ }
68
+ };
69
+ /**
70
+ * Edit button click handler
71
+ *
72
+ * @returns {void}
73
+ */
74
+ this.handleEditButton = () => {
75
+ this.toggleIsEditing();
76
+ };
77
+ /**
78
+ * Update title handler
79
+ *
80
+ * @param {CustomEvent<string>} event input value change event
81
+ * @returns {void}
82
+ */
83
+ this.handleUpdateTitle = (event) => {
84
+ this.updatedPanelTitle = event.detail;
85
+ };
86
+ /**
87
+ * Cancel edition button handler
88
+ *
89
+ * @returns {void}
90
+ */
91
+ this.handleCancelEditButton = () => {
92
+ this.updatedPanelTitle = undefined;
93
+ this.toggleIsEditing();
94
+ };
95
+ /**
96
+ * Validate edition button handler
97
+ *
98
+ * @returns {void}
99
+ */
100
+ this.handleValidateEditButton = () => {
101
+ if (this.editInputElement.valid) {
102
+ if (this.updatedPanelTitle !== undefined)
103
+ this.panelTitle = this.updatedPanelTitle;
104
+ this.toggleIsEditing();
105
+ }
106
+ };
107
+ /**
108
+ * Header left conditional render
109
+ *
110
+ * @typedef {HTMLElement} HTMLMgButtonElement
111
+ * @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
112
+ */
113
+ this.headerLeft = () => {
114
+ const collapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", class: "mg-panel__collapse-button", identifier: `${this.identifier}-collapse-button`, expanded: this.expanded, controls: `${this.identifier}-content`, disabled: this.expandToggleDisabled }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle));
115
+ if (this.titleEditable && !this.isEditing) {
116
+ return [
117
+ collapseButton(),
118
+ h("mg-button", { "is-icon": true, variant: "flat", class: "mg-panel__edit-button", label: this.messages.panel.editLabel, onClick: this.handleEditButton, identifier: `${this.identifier}-edit-button` }, h("mg-icon", { icon: "pen" })),
119
+ ];
120
+ }
121
+ if (this.titleEditable && this.isEditing) {
122
+ return [
123
+ collapseButton(),
124
+ h("mg-input-text", { label: this.messages.panel.editLabel, "label-hide": true, value: this.panelTitle, "onValue-change": this.handleUpdateTitle, displayCharacterLeft: false, pattern: this.titlePattern, "pattern-error-message": this.titlePatternErrorMessage, identifier: `${this.identifier}-edition-input`, ref: el => (this.editInputElement = el) }, h("mg-button", { slot: "append-input", label: this.messages.general.cancel, "is-icon": true, variant: "secondary", onClick: this.handleCancelEditButton, identifier: `${this.identifier}-edition-button-cancel` }, h("mg-icon", { icon: "cross" })), h("mg-button", { slot: "append-input", label: this.messages.general.confirm, "is-icon": true, variant: "secondary", onClick: this.handleValidateEditButton, identifier: `${this.identifier}-edition-button-validate` }, h("mg-icon", { icon: "check" }))),
125
+ ];
126
+ }
127
+ return collapseButton();
128
+ };
129
+ }
130
+ handelTileChange(newValue) {
131
+ this.titleChange.emit(newValue);
132
+ }
133
+ validatetitlePattern(newValue) {
134
+ if (newValue && !this.titleEditable) {
135
+ throw new Error('<mg-panel> prop "titleEditable" must be set to `true`.');
136
+ }
137
+ if (newValue && this.titlePatternErrorMessage === undefined) {
138
+ throw new Error('<mg-panel> prop "titlePattern" must be paired with the prop "titlePatternErrorMessage".');
139
+ }
140
+ }
141
+ handleExpanded(newValue) {
142
+ this.expandedChange.emit(newValue);
143
+ }
144
+ /*************
145
+ * Lifecycle *
146
+ *************/
147
+ /**
148
+ * Check if props are well configured on init
149
+ *
150
+ * @returns {void}
151
+ */
152
+ componentWillLoad() {
153
+ // Get locales
154
+ this.messages = initLocales(this.element).messages;
155
+ // Validate
156
+ this.validatetitlePattern(this.titlePattern);
157
+ }
158
+ /**
159
+ * Edit DOM after render
160
+ *
161
+ * @returns {void}
162
+ */
163
+ componentDidRender() {
164
+ // when we are editing we get focus on edition input
165
+ if (this.isEditing) {
166
+ this.editInputElement.setFocus();
167
+ }
168
+ }
169
+ /**
170
+ * Render component
171
+ *
172
+ * @returns {HTMLElement} html element
173
+ */
174
+ render() {
175
+ return (h("section", { class: this.classList.join(), id: this.identifier }, h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), h("div", { class: "mg-panel__header-right" }, h("slot", { name: "header-right" }))), h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, h("slot", null))));
176
+ }
177
+ get element() { return this; }
178
+ static get watchers() { return {
179
+ "panelTitle": ["handelTileChange"],
180
+ "titlePattern": ["validatetitlePattern"],
181
+ "expanded": ["handleExpanded"]
182
+ }; }
183
+ static get style() { return mgPanelCss; }
184
+ }, [1, "mg-panel", {
185
+ "identifier": [1],
186
+ "panelTitle": [1025, "panel-title"],
187
+ "titlePattern": [1025, "title-pattern"],
188
+ "titlePatternErrorMessage": [1025, "title-pattern-error-message"],
189
+ "expanded": [1028],
190
+ "expandToggleDisabled": [1028, "expand-toggle-disabled"],
191
+ "titleEditable": [4, "title-editable"],
192
+ "classList": [32],
193
+ "isEditing": [32],
194
+ "updatedPanelTitle": [32]
195
+ }]);
196
+ function defineCustomElement$1() {
197
+ if (typeof customElements === "undefined") {
198
+ return;
199
+ }
200
+ const components = ["mg-panel", "mg-button", "mg-character-left", "mg-icon", "mg-input-text", "mg-input-title", "mg-tooltip"];
201
+ components.forEach(tagName => { switch (tagName) {
202
+ case "mg-panel":
203
+ if (!customElements.get(tagName)) {
204
+ customElements.define(tagName, MgPanel$1);
205
+ }
206
+ break;
207
+ case "mg-button":
208
+ if (!customElements.get(tagName)) {
209
+ defineCustomElement$7();
210
+ }
211
+ break;
212
+ case "mg-character-left":
213
+ if (!customElements.get(tagName)) {
214
+ defineCustomElement$6();
215
+ }
216
+ break;
217
+ case "mg-icon":
218
+ if (!customElements.get(tagName)) {
219
+ defineCustomElement$5();
220
+ }
221
+ break;
222
+ case "mg-input-text":
223
+ if (!customElements.get(tagName)) {
224
+ defineCustomElement$4();
225
+ }
226
+ break;
227
+ case "mg-input-title":
228
+ if (!customElements.get(tagName)) {
229
+ defineCustomElement$3();
230
+ }
231
+ break;
232
+ case "mg-tooltip":
233
+ if (!customElements.get(tagName)) {
234
+ defineCustomElement$2();
235
+ }
236
+ break;
237
+ } });
238
+ }
239
+ defineCustomElement$1();
240
+
241
+ const MgPanel = MgPanel$1;
242
+ const defineCustomElement = defineCustomElement$1;
243
+
244
+ export { MgPanel, defineCustomElement };
@@ -1,11 +1,11 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
2
  import { c as createID } from './components.utils.js';
3
- import { m as messages } from './index2.js';
3
+ import { i as initLocales } from './index2.js';
4
4
  import { d as defineCustomElement$3 } from './mg-button2.js';
5
5
  import { d as defineCustomElement$2 } from './mg-icon2.js';
6
6
  import { c as createPopper } from './popper.js';
7
7
 
8
- const mgPopoverCss = "mg-popover.sc-mg-popover{display:contents}mg-popover.sc-mg-popover-s>*{display:inline-block}.mg-popover.sc-mg-popover{display:none;padding:1.5rem;z-index:9999;border-radius:0.5rem;background-color:hsl(var(--mg-popover-background-color));-webkit-box-shadow:0 0.3rem 0.8rem 0 rgba(0, 0, 0, 0.1);box-shadow:0 0.3rem 0.8rem 0 rgba(0, 0, 0, 0.1);color:hsl(var(--mg-popover-font-color))}.mg-popover[data-show].sc-mg-popover{display:block}.mg-popover.sc-mg-popover mg-button.sc-mg-popover{float:right;margin-right:calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);margin-top:calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);margin-left:3rem}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover,.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover::before{position:absolute;width:2rem;height:2rem;z-index:9999;background:inherit}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover{visibility:hidden}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover::before{visibility:visible;content:\"\";-webkit-transform:rotate(45deg);transform:rotate(45deg)}.mg-popover[data-popper-placement^=top].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{bottom:-6px}.mg-popover[data-popper-placement^=bottom].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{top:-6px}.mg-popover[data-popper-placement^=left].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{right:-6px}.mg-popover[data-popper-placement^=right].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{left:-6px}.mg-popover__title.sc-mg-popover-s>*,.mg-popover__title .sc-mg-popover-s>*{margin:0 0 1rem;font-size:var(--mg-popover-title-font-size);font-weight:600}";
8
+ const mgPopoverCss = "mg-popover.sc-mg-popover{display:contents}mg-popover.sc-mg-popover-s>*{display:inline-block}.mg-popover.sc-mg-popover{display:none;padding:1.5rem;z-index:9999;border-radius:0.5rem;background-color:hsl(var(--mg-popover-background-color));box-shadow:var(--box-shadow);color:hsl(var(--mg-popover-font-color))}.mg-popover[data-show].sc-mg-popover{display:block}.mg-popover.sc-mg-popover mg-button.sc-mg-popover{float:right;margin-right:calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);margin-top:calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);margin-left:3rem}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover,.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover::before{position:absolute;width:2rem;height:2rem;z-index:-1;background:inherit}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover{visibility:hidden}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-popover[data-popper-placement^=top].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{bottom:-6px}.mg-popover[data-popper-placement^=bottom].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{top:-6px}.mg-popover[data-popper-placement^=left].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{right:-6px}.mg-popover[data-popper-placement^=right].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{left:-6px}.mg-popover__title.sc-mg-popover-s>*,.mg-popover__title .sc-mg-popover-s>*{margin:0 0 1rem;font-size:var(--mg-popover-title-font-size);font-weight:600}";
9
9
 
10
10
  const MgPopover$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
11
11
  constructor() {
@@ -35,18 +35,19 @@ const MgPopover$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
35
35
  this.disabled = false;
36
36
  /**
37
37
  * Check if clicked outside of component
38
- * @param e {event}
38
+ *
39
+ * @param {MouseEvent} event mouse event
40
+ * @returns {void}
39
41
  */
40
- // Unable to trigger document events in unit tests: https://gitlab.mgdis.fr/core/core-ui/mg-components/-/issues/57
41
- /* istanbul ignore next */
42
- this.clickOutside = e => {
42
+ this.clickOutside = (event) => {
43
43
  var _a;
44
- if (!this.disabled && ((_a = e.target.closest(`#${this.identifier}`)) === null || _a === void 0 ? void 0 : _a.parentElement.nodeName) !== 'MG-POPOVER') {
44
+ if (!this.disabled && ((_a = event.target.closest(`#${this.identifier}`)) === null || _a === void 0 ? void 0 : _a.parentElement.nodeName) !== 'MG-POPOVER') {
45
45
  this.display = false;
46
46
  }
47
47
  };
48
48
  /**
49
49
  * Show popover
50
+ *
50
51
  * @returns {void}
51
52
  */
52
53
  this.show = () => {
@@ -59,13 +60,12 @@ const MgPopover$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
59
60
  // hide when click outside
60
61
  // setTimeout is used to prevent event to trigger after creation
61
62
  setTimeout(() => {
62
- // Unable to trigger document events in unit tests: https://gitlab.mgdis.fr/core/core-ui/mg-components/-/issues/57
63
- /* istanbul ignore next */
64
63
  document.addEventListener('click', this.clickOutside, false);
65
64
  }, 0);
66
65
  };
67
66
  /**
68
67
  * Hide popover
68
+ *
69
69
  * @returns {void}
70
70
  */
71
71
  this.hide = () => {
@@ -73,11 +73,12 @@ const MgPopover$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
73
73
  this.popover.removeAttribute('data-show');
74
74
  // Disable the event listeners
75
75
  this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
76
- // Remove even listener
76
+ // Remove event listener
77
77
  document.removeEventListener('click', this.clickOutside, false);
78
78
  };
79
79
  /**
80
80
  * Handle action for close button
81
+ *
81
82
  * @returns {void}
82
83
  */
83
84
  this.handleCloseButton = () => {
@@ -95,6 +96,20 @@ const MgPopover$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
95
96
  /*************
96
97
  * Lifecycle *
97
98
  *************/
99
+ /**
100
+ * Check if component props are well configured on init
101
+ *
102
+ * @returns {void} timeout
103
+ */
104
+ componentWillLoad() {
105
+ // Get locales
106
+ this.messages = initLocales(this.element).messages;
107
+ }
108
+ /**
109
+ * Check if component props are well configured on init
110
+ *
111
+ * @returns {void}
112
+ */
98
113
  componentDidLoad() {
99
114
  //Check if slotted title is a heading
100
115
  const headingElements = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
@@ -137,8 +152,13 @@ const MgPopover$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
137
152
  });
138
153
  this.handleDisplay(this.display);
139
154
  }
155
+ /**
156
+ * Render
157
+ *
158
+ * @returns {HTMLElement} HTML Element
159
+ */
140
160
  render() {
141
- return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: "mg-popover" }, !this.disabled && this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: messages.popover.closeButton, onClick: this.handleCloseButton }, h("mg-icon", { icon: "cross" }))), h("div", { class: "mg-popover__title" }, h("slot", { name: "title" })), h("slot", { name: "content" }), h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
161
+ return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: "mg-popover" }, !this.disabled && this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, h("mg-icon", { icon: "cross" }))), h("div", { class: "mg-popover__title" }, h("slot", { name: "title" })), h("slot", { name: "content" }), h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
142
162
  }
143
163
  get element() { return this; }
144
164
  static get watchers() { return {
@@ -1,25 +1,49 @@
1
- import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
2
  import { c as createID, C as ClassList, a as allItemsAreString } from './components.utils.js';
3
3
  import { d as defineCustomElement$3 } from './mg-badge2.js';
4
4
  import { d as defineCustomElement$2 } from './mg-icon2.js';
5
5
 
6
- const mgTabsCss = ".mg-tabs__header.sc-mg-tabs{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap}.mg-tabs__navigation-button.sc-mg-tabs{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-webkit-column-gap:0.5rem;-moz-column-gap:0.5rem;column-gap:0.5rem;padding:1.8rem 2.4rem 1.5rem;background:none;border:none;border-bottom:0.3rem solid transparent;color:hsl(var(--color-dark));line-height:var(--line-height);cursor:pointer}.mg-tabs__navigation-button.sc-mg-tabs:hover,.mg-tabs__navigation-button.sc-mg-tabs:focus{background-color:hsla(var(--color-info-h), var(--color-info-s), var(--color-info-l), 10%)}.mg-tabs__navigation-button.mg-tabs__navigation-button--active.sc-mg-tabs{color:hsl(var(--color-info));border-bottom-color:hsl(var(--color-info));font-weight:700}.mg-tabs__content-container.sc-mg-tabs:focus-visible{outline-color:transparent}";
6
+ var Status;
7
+ (function (Status) {
8
+ Status["VISIBLE"] = "visible";
9
+ Status["HIDDEN"] = "hidden";
10
+ Status["DISABLED"] = "disabled";
11
+ Status["ACTIVE"] = "active";
12
+ })(Status || (Status = {}));
13
+ /**
14
+ * List of all possibles sizes
15
+ */
16
+ const sizes = ['regular', 'large'];
17
+
18
+ const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button{padding:calc(1rem + 0.3rem) calc(1rem * 1.3) 1rem}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button{padding:calc(1.8rem + 0.3rem) calc(1.8rem * 1.3) 1.8rem}.mg-tabs__header{display:flex;flex-direction:row;flex-wrap:wrap}.mg-tabs__navigation-button{display:flex;align-items:center;column-gap:0.5rem;background:none;border:none;border-bottom:0.3rem solid transparent;color:hsl(var(--color-dark));line-height:var(--line-height);cursor:pointer}.mg-tabs__navigation-button:disabled,.mg-tabs__navigation-button--disabled{cursor:default;opacity:30%}.mg-tabs__navigation-button:hover:not(:disabled),.mg-tabs__navigation-button:focus:not(:disabled){background-color:hsla(var(--color-info-h), var(--color-info-s), var(--color-info-l), 10%)}.mg-tabs__navigation-button.mg-tabs__navigation-button--active{color:hsl(var(--color-info));border-bottom-color:hsl(var(--color-info));font-weight:700}.mg-tabs__navigation-button.mg-tabs__navigation-button--hidden{display:none}.mg-tabs__content-container:focus-visible{outline:none}";
7
19
 
8
20
  /**
9
21
  * type TabItem validation function
10
- * @param tab
11
- * @returns {boolean}
22
+ *
23
+ * @param {TabItem} tab tab item
24
+ * @returns {boolean} tab item type is valid
12
25
  */
13
26
  const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
14
27
  const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
15
28
  constructor() {
16
29
  super();
17
30
  this.__registerHost();
31
+ this.activeTabChange = createEvent(this, "active-tab-change", 7);
32
+ /************
33
+ * Internal *
34
+ ************/
35
+ this.tabPanel = 'panel';
36
+ this.startIndex = 1;
37
+ this.buttonTabBaseClass = 'mg-tabs__navigation-button';
18
38
  /**
19
39
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
20
40
  * If not set, it will be created.
21
41
  */
22
42
  this.identifier = createID('mg-tabs');
43
+ /**
44
+ * Define tabs size
45
+ */
46
+ this.size = 'regular';
23
47
  /**
24
48
  * Active tab number
25
49
  * default: first is 1
@@ -33,33 +57,81 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
33
57
  * Component classes
34
58
  */
35
59
  this.classList = new ClassList(['mg-tabs']);
60
+ /**
61
+ * Method to set active tab
62
+ *
63
+ * @param {number} tabKey item tab key to set to ACTIVE status
64
+ * @returns {void}
65
+ */
66
+ this.setActiveTab = (tabKey) => {
67
+ // reset active tabs
68
+ this.tabs.forEach(tab => {
69
+ if (this.tabHasGivenStatus(tab, Status.ACTIVE))
70
+ tab.status = Status.VISIBLE;
71
+ });
72
+ // set active tab from given tab key
73
+ this.tabs[tabKey - this.startIndex].status = Status.ACTIVE;
74
+ // emit change active tab key event
75
+ this.activeTabChange.emit(tabKey);
76
+ };
77
+ /**
78
+ * Method to know if given tab has the given status
79
+ *
80
+ * @param {TabItem} tab item tab key to set to ACTIVE status
81
+ * @param {Status} status status to valide
82
+ * @returns {boolean} status comparaison
83
+ */
84
+ this.tabHasGivenStatus = (tab, status) => tab.status === status;
85
+ /**
86
+ * Method to get element id from index
87
+ *
88
+ * @param {string} element to get id
89
+ * @param {number} index to generate id
90
+ * @returns {string} generated element id
91
+ */
92
+ this.getElementId = (element, index) => `${element}-${this.getTabIndex(index)}`;
93
+ /**
94
+ * Method to get tab index
95
+ *
96
+ * @param {number} index to get
97
+ * @returns {number} index
98
+ */
99
+ this.getTabIndex = (index) => index + this.startIndex;
36
100
  /**
37
101
  * Handle click events on tabs
38
- * @param event
102
+ *
103
+ * @param {MouseEvent} event mouse event
39
104
  */
40
105
  this.handleClick = (event) => {
41
106
  const tabId = event.currentTarget.getAttribute('data-index');
42
107
  this.activeTab = Number(tabId);
43
108
  };
109
+ /**
110
+ * get navigation button class from given status
111
+ *
112
+ * @param {Status} status button tab status
113
+ * @param {boolean} isSelector set if we need a CSS selector with the dot '.' at the begin. default value = false.
114
+ * @returns {string} button class/selector variant
115
+ */
116
+ this.getNavigationButtonClass = (status, isSelector = false) => `${isSelector ? '.' : ''}${this.buttonTabBaseClass}--${status}`;
44
117
  /**
45
118
  * Handle keyboard event on tabs
46
- * @param event
119
+ *
120
+ * @param {MouseEvent} event mouse event
121
+ * @returns {void}
47
122
  */
48
123
  this.handleKeydown = (event) => {
49
- let selectedTab;
50
124
  let tabId = Number(event.target.getAttribute('data-index'));
51
125
  const parent = event.target.parentElement;
52
126
  // change selected id from key code
53
- // /* IE FIX */ delete 'Right'
54
- if (['ArrowRight', 'Right'].includes(event.key)) {
127
+ if (event.key === 'ArrowRight') {
55
128
  tabId++;
56
- // /* IE FIX */ delete 'Left'
57
129
  }
58
- else if (['ArrowLeft', 'Left'].includes(event.key)) {
130
+ else if (event.key === 'ArrowLeft') {
59
131
  tabId--;
60
132
  }
61
- // get selected tab
62
- selectedTab = parent.querySelector(`[data-index="${tabId}"]`);
133
+ // get selected tab if NOT hidden, disabled
134
+ const selectedTab = parent.querySelector(`[data-index="${tabId}"]:not(${[this.getNavigationButtonClass(Status.HIDDEN, true), this.getNavigationButtonClass(Status.DISABLED, true)].join()})`);
63
135
  // apply selected tab if exist
64
136
  if (selectedTab !== null) {
65
137
  selectedTab.focus();
@@ -76,10 +148,16 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
76
148
  }
77
149
  };
78
150
  }
151
+ validateSize(newValue) {
152
+ if (!sizes.includes(newValue)) {
153
+ throw new Error(`<mg-tabs> prop "size" must be one of : ${sizes.join(', ')}`);
154
+ }
155
+ this.classList.add(`mg-tabs--size-${this.size}`);
156
+ }
79
157
  validateItems(newValue) {
80
158
  // String array
81
159
  if (allItemsAreString(newValue)) {
82
- this.tabs = newValue.map(item => ({ label: item }));
160
+ this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
83
161
  }
84
162
  // Object array
85
163
  else if (newValue && newValue.every(item => isTabItem(item))) {
@@ -90,40 +168,52 @@ const MgTabs$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
90
168
  }
91
169
  }
92
170
  validateActiveTab(newValue) {
93
- if (Number(newValue) < 1 || Number(newValue) > this.tabs.length) {
171
+ if (newValue < 1 || newValue > this.tabs.length) {
94
172
  throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
95
173
  }
174
+ else {
175
+ this.setActiveTab(newValue);
176
+ }
96
177
  }
97
178
  /*************
98
179
  * Lifecycle *
99
180
  *************/
100
181
  /**
101
182
  * Check if component props are well configured on init
183
+ *
184
+ * @returns {void}
102
185
  */
103
186
  componentWillLoad() {
104
187
  // Check tabs format
105
188
  this.validateItems(this.items);
106
189
  this.validateActiveTab(this.activeTab);
190
+ this.validateSize(this.size);
107
191
  this.validateSlots();
108
192
  }
193
+ /**
194
+ * Render
195
+ *
196
+ * @returns {HTMLElement} HTML Element
197
+ */
109
198
  render() {
110
- return (h(Host, null, h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => {
111
- const tabIndex = index + 1;
112
- 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 }, tab.icon !== undefined && h("mg-icon", { icon: tab.icon }), tab.label, tab.badge !== undefined && h("mg-badge", { variant: "info", value: tab.badge.value, label: tab.badge.label })));
113
- })), this.tabs.map((_tab, index) => {
114
- const tabIndex = index + 1;
115
- 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" }, h("slot", { name: `tab_content-${tabIndex}` })));
116
- })));
199
+ return (h(Host, null, h("div", { class: this.classList.join() }, h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => (h("button", { role: "tab", id: this.getElementId(this.identifier, index), class: {
200
+ [`${this.buttonTabBaseClass}`]: true,
201
+ [`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasGivenStatus(tab, Status.ACTIVE),
202
+ [`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasGivenStatus(tab, Status.DISABLED),
203
+ [`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasGivenStatus(tab, Status.HIDDEN),
204
+ }, tabindex: this.tabHasGivenStatus(tab, Status.ACTIVE) ? 0 : -1, "aria-selected": this.tabHasGivenStatus(tab, Status.ACTIVE).toString(), "aria-controls": this.getElementId(this.tabPanel, index), onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": this.getTabIndex(index), disabled: this.tabHasGivenStatus(tab, Status.DISABLED) }, tab.icon !== undefined && h("mg-icon", { icon: tab.icon }), tab.label, tab.badge !== undefined && h("mg-badge", { variant: "info", value: tab.badge.value, label: tab.badge.label }))))), this.tabs.map((tab, index) => (h("article", { role: "tabpanel", id: this.getElementId(this.tabPanel, index), hidden: !this.tabHasGivenStatus(tab, Status.ACTIVE), "aria-labelledby": this.getElementId(this.identifier, index), tabindex: this.tabHasGivenStatus(tab, Status.ACTIVE) ? 0 : -1, class: "mg-tabs__content-container" }, h("slot", { name: this.getElementId('tab_content', index) })))))));
117
205
  }
118
206
  get element() { return this; }
119
207
  static get watchers() { return {
208
+ "size": ["validateSize"],
120
209
  "items": ["validateItems"],
121
210
  "activeTab": ["validateActiveTab"]
122
211
  }; }
123
212
  static get style() { return mgTabsCss; }
124
- }, [6, "mg-tabs", {
213
+ }, [4, "mg-tabs", {
125
214
  "identifier": [1],
126
215
  "label": [1],
216
+ "size": [1],
127
217
  "items": [16],
128
218
  "activeTab": [1538, "active-tab"],
129
219
  "tabs": [32],
@@ -6,34 +6,54 @@ import { C as ClassList } from './components.utils.js';
6
6
  */
7
7
  const variants = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'];
8
8
 
9
- const mgTagCss = ".mg-tag{padding:calc((var(--mg-tag-height) - 0.2rem - var(--mg-tag-font-size) * var(--line-height)) / 2) 0.6rem;min-height:var(--mg-tag-height);-webkit-box-sizing:border-box;box-sizing:border-box;border-radius:var(--mg-tag-border-radius);border:0.1rem solid;font-size:var(--mg-tag-font-size);font-weight:600;text-align:center}.mg-tag.mg-tag--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-tag.mg-tag--primary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-tag.mg-tag--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-tag.mg-tag--success.mg-tag--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-tag.mg-tag--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-tag.mg-tag--warning.mg-tag--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-tag.mg-tag--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-tag.mg-tag--danger.mg-tag--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-tag.mg-tag--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-tag.mg-tag--info.mg-tag--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-tag,mg-tag{display:inline-block;vertical-align:middle}";
9
+ const mgTagCss = ".mg-tag{padding:calc((var(--mg-tag-height) - 0.2rem - var(--mg-tag-font-size) * var(--line-height)) / 2) 0.6rem;min-height:var(--mg-tag-height);box-sizing:border-box;border-radius:var(--mg-tag-border-radius);border:0.1rem solid;font-size:var(--mg-tag-font-size);font-weight:600;text-align:center}.mg-tag.mg-tag--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-tag.mg-tag--primary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-tag.mg-tag--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-tag.mg-tag--success.mg-tag--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-tag.mg-tag--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-tag.mg-tag--warning.mg-tag--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-tag.mg-tag--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-tag.mg-tag--danger.mg-tag--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-tag.mg-tag--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-tag.mg-tag--info.mg-tag--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-tag,mg-tag{display:inline-block;vertical-align:middle}";
10
10
 
11
11
  const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
12
12
  constructor() {
13
13
  super();
14
14
  this.__registerHost();
15
15
  this.__attachShadow();
16
+ /************
17
+ * Internal *
18
+ ************/
19
+ // classes
20
+ this.classOutline = `mg-tag--outline`;
21
+ /**************
22
+ * Decorators *
23
+ **************/
16
24
  /**
17
25
  * Define button variant
18
26
  */
19
- this.variant = variants[0];
27
+ this.variant = variants[0]; // primary
20
28
  /**
21
29
  * Component classes
22
30
  */
23
31
  this.classList = new ClassList(['mg-tag']);
24
32
  }
25
- validateVariant(newValue) {
33
+ validateVariant(newValue, oldValue) {
26
34
  if (!variants.includes(newValue)) {
27
35
  throw new Error(`<mg-tag> prop "variant" must be one of : ${variants.join(', ')}.`);
28
36
  }
29
- this.classList.add(`mg-tag--${this.variant}`);
37
+ else {
38
+ if (oldValue !== undefined) {
39
+ this.classList.delete(`mg-tag--${oldValue}`);
40
+ }
41
+ this.classList.add(`mg-tag--${newValue}`);
42
+ }
30
43
  }
31
44
  validateOutline(newValue) {
32
45
  if (newValue)
33
- this.classList.add(`mg-tag--outline`);
46
+ this.classList.add(this.classOutline);
47
+ else
48
+ this.classList.delete(this.classOutline);
34
49
  }
50
+ /*************
51
+ * Lifecycle *
52
+ *************/
35
53
  /**
36
54
  * Check if props are well configured on init
55
+ *
56
+ * @returns {void}
37
57
  */
38
58
  componentWillLoad() {
39
59
  this.validateVariant(this.variant);
@@ -41,6 +61,8 @@ const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
41
61
  }
42
62
  /**
43
63
  * Render
64
+ *
65
+ * @returns {HTMLElement} HTML Element
44
66
  */
45
67
  render() {
46
68
  return (h("span", { class: this.classList.join() }, h("slot", null)));