@mgdis/mg-components 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/dist/cjs/css-shim-629916b0.js +6 -0
  2. package/dist/cjs/index-369388eb.js +146 -0
  3. package/dist/cjs/{index-85a4a0b6.js → index-bead7dbd.js} +78 -2
  4. package/dist/cjs/loader.cjs.js +4 -4
  5. package/dist/cjs/mg-badge_21.cjs.entry.js +3313 -0
  6. package/dist/cjs/mg-components.cjs.js +3 -3
  7. package/dist/cjs/mg-modal.cjs.entry.js +111 -0
  8. package/dist/cjs/mg-popover.cjs.entry.js +165 -0
  9. package/dist/cjs/popper-0c3964e7.js +1786 -0
  10. package/dist/cjs/{shadow-css-8940f82d.js → shadow-css-546083ef.js} +1 -1
  11. package/dist/collection/collection-manifest.json +4 -1
  12. package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
  13. package/dist/collection/components/atoms/mg-badge/mg-badge.js +11 -7
  14. package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +3 -0
  15. package/dist/collection/components/atoms/mg-button/mg-button.css +26 -17
  16. package/dist/collection/components/atoms/mg-button/mg-button.js +71 -2
  17. package/dist/collection/components/atoms/mg-button/mg-button.stories.js +5 -0
  18. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +12 -1
  19. package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +8 -0
  20. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +8 -0
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.css +5 -7
  22. package/dist/collection/components/atoms/mg-icon/mg-icon.js +11 -1
  23. package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +4 -4
  24. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +14 -3
  25. package/dist/collection/components/atoms/mg-tag/mg-tag.js +10 -3
  26. package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +3 -0
  27. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +9 -0
  28. package/dist/collection/components/molecules/inputs/MgInput.js +20 -14
  29. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +9 -1
  30. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +103 -40
  31. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +6 -1
  32. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +27 -0
  33. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +125 -56
  34. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +6 -1
  35. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +27 -0
  36. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +144 -68
  37. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +6 -1
  38. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +27 -0
  39. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +101 -35
  40. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +6 -1
  41. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +9 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +115 -37
  43. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +6 -1
  44. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +28 -1
  45. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +132 -51
  46. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +14 -1
  47. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +27 -0
  48. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +155 -53
  49. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +7 -2
  50. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +27 -0
  51. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +108 -42
  52. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +7 -2
  53. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +4 -1
  54. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +60 -31
  55. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +6 -1
  56. package/dist/collection/components/molecules/mg-form/mg-form.css +15 -0
  57. package/dist/collection/components/molecules/mg-form/mg-form.js +269 -0
  58. package/dist/collection/components/molecules/mg-form/mg-form.stories.js +58 -0
  59. package/dist/collection/components/molecules/mg-message/mg-message.css +1 -1
  60. package/dist/collection/components/molecules/mg-message/mg-message.js +11 -4
  61. package/dist/collection/components/molecules/mg-message/mg-message.stories.js +5 -1
  62. package/dist/collection/components/molecules/mg-modal/mg-modal.css +54 -0
  63. package/dist/collection/components/molecules/mg-modal/mg-modal.js +233 -0
  64. package/dist/collection/components/molecules/mg-modal/mg-modal.stories.js +51 -0
  65. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +32 -12
  66. package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +1 -0
  67. package/dist/collection/components/molecules/mg-panel/mg-panel.css +42 -0
  68. package/dist/collection/components/molecules/mg-panel/mg-panel.js +255 -0
  69. package/dist/collection/components/molecules/mg-panel/mg-panel.stories.js +31 -0
  70. package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -2
  71. package/dist/collection/components/molecules/mg-popover/mg-popover.js +19 -4
  72. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +4 -1
  73. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +14 -3
  74. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +68 -20
  75. package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +10 -1
  76. package/dist/collection/stories/messages.stories.js +1 -1
  77. package/dist/collection/utils/components.utils.js +16 -9
  78. package/dist/collection/utils/locale.utils.js +6 -3
  79. package/dist/collection/utils/test.utils.js +27 -15
  80. package/dist/collection/variables.css +30 -1
  81. package/dist/collection/variables.scss +30 -1
  82. package/dist/components/MgInput.js +20 -14
  83. package/dist/components/components.utils.js +16 -9
  84. package/dist/components/index.d.ts +1 -1
  85. package/dist/components/index2.js +22 -12
  86. package/dist/components/locale.utils.js +6 -3
  87. package/dist/components/mg-badge2.js +9 -5
  88. package/dist/components/mg-button2.js +21 -2
  89. package/dist/components/mg-character-left2.js +12 -1
  90. package/dist/components/mg-form.d.ts +11 -0
  91. package/dist/components/mg-form.js +146 -0
  92. package/dist/components/mg-icon2.js +20 -2
  93. package/dist/components/mg-input-checkbox.js +65 -36
  94. package/dist/components/mg-input-date.js +87 -52
  95. package/dist/components/mg-input-numeric.js +105 -63
  96. package/dist/components/mg-input-password.js +60 -29
  97. package/dist/components/mg-input-radio.js +74 -34
  98. package/dist/components/mg-input-select2.js +89 -46
  99. package/dist/components/mg-input-text.js +1 -237
  100. package/dist/components/mg-input-text2.js +288 -0
  101. package/dist/components/mg-input-textarea.js +67 -36
  102. package/dist/components/mg-input-title2.js +13 -4
  103. package/dist/components/mg-input-toggle.js +30 -22
  104. package/dist/components/mg-message.js +10 -3
  105. package/dist/components/mg-modal.d.ts +11 -0
  106. package/dist/components/mg-modal.js +147 -0
  107. package/dist/components/mg-pagination.js +31 -11
  108. package/dist/components/mg-panel.d.ts +11 -0
  109. package/dist/components/mg-panel.js +210 -0
  110. package/dist/components/mg-popover.js +20 -5
  111. package/dist/components/mg-tabs.js +43 -11
  112. package/dist/components/mg-tag.js +8 -1
  113. package/dist/components/mg-tooltip2.js +9 -0
  114. package/dist/esm/css-shim-0993aa3b.js +4 -0
  115. package/dist/esm/{index-e3e84606.js → index-9e877561.js} +78 -2
  116. package/dist/esm/index-c346f52d.js +139 -0
  117. package/dist/esm/loader.js +4 -4
  118. package/dist/esm/mg-badge_21.entry.js +3289 -0
  119. package/dist/esm/mg-components.js +3 -3
  120. package/dist/esm/mg-modal.entry.js +107 -0
  121. package/dist/esm/mg-popover.entry.js +161 -0
  122. package/dist/esm/polyfills/css-shim.js +1 -1
  123. package/dist/esm/popper-8874fd6c.js +1784 -0
  124. package/dist/esm/{shadow-css-5d2d01ce.js → shadow-css-dfa0587f.js} +1 -1
  125. package/dist/esm-es5/css-shim-0993aa3b.js +1 -0
  126. package/dist/esm-es5/index-9e877561.js +1 -0
  127. package/dist/esm-es5/index-c346f52d.js +1 -0
  128. package/dist/esm-es5/loader.js +1 -1
  129. package/dist/esm-es5/mg-badge_21.entry.js +2 -0
  130. package/dist/esm-es5/mg-components.js +1 -1
  131. package/dist/esm-es5/mg-modal.entry.js +1 -0
  132. package/dist/esm-es5/mg-popover.entry.js +1 -0
  133. package/dist/esm-es5/popper-8874fd6c.js +1 -0
  134. package/dist/esm-es5/{shadow-css-5d2d01ce.js → shadow-css-dfa0587f.js} +0 -0
  135. package/dist/mg-components/mg-components.css +1 -1
  136. package/dist/mg-components/mg-components.esm.js +1 -1
  137. package/dist/mg-components/mg-components.js +2 -2
  138. package/dist/mg-components/p-3633e9e1.system.entry.js +2 -0
  139. package/dist/mg-components/p-3c14153d.js +1 -0
  140. package/dist/mg-components/p-55a22b35.system.js +1 -0
  141. package/dist/mg-components/{p-f6455ab3.js → p-5e796581.js} +0 -0
  142. package/dist/mg-components/p-656b5efb.system.js +1 -0
  143. package/dist/mg-components/p-68d6f104.js +1 -0
  144. package/dist/mg-components/{p-366a224e.js → p-6d49ed95.js} +1 -1
  145. package/dist/mg-components/p-70177194.entry.js +1 -0
  146. package/dist/mg-components/{p-71d57b8b.system.js → p-8b2d8a2a.system.js} +0 -0
  147. package/dist/mg-components/p-8cb61c3f.system.js +1 -0
  148. package/dist/mg-components/p-ace173b1.js +1 -0
  149. package/dist/mg-components/p-c46fbd54.entry.js +1 -0
  150. package/dist/mg-components/p-c90cc4bf.system.js +1 -0
  151. package/dist/mg-components/p-cd2a4acc.system.entry.js +1 -0
  152. package/dist/mg-components/p-de1164fa.system.entry.js +1 -0
  153. package/dist/mg-components/p-dfe25da3.entry.js +1 -0
  154. package/dist/mg-components/p-e4a502b5.system.js +1 -0
  155. package/dist/mg-components/variables.css +30 -1
  156. package/dist/mg-components/variables.scss +30 -1
  157. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -4
  158. package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +5 -0
  159. package/dist/types/components/atoms/mg-button/mg-button.d.ts +22 -2
  160. package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +5 -0
  161. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +13 -2
  162. package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +9 -0
  163. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +1 -1
  164. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +11 -1
  165. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +11 -1
  166. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +10 -3
  167. package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +5 -0
  168. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -2
  169. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +8 -0
  170. package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -4
  171. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +31 -11
  172. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +5 -0
  173. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +39 -14
  174. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +5 -0
  175. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +53 -14
  176. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +5 -0
  177. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +28 -9
  178. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +5 -0
  179. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
  180. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +37 -8
  181. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +5 -0
  182. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +1 -1
  183. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +30 -7
  184. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +14 -0
  185. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +46 -10
  186. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +5 -0
  187. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +30 -10
  188. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +5 -0
  189. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
  190. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +27 -12
  191. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +5 -0
  192. package/dist/types/components/molecules/mg-form/mg-form.d.ts +82 -0
  193. package/dist/types/components/molecules/mg-form/mg-form.stories.d.ts +11 -0
  194. package/dist/types/components/molecules/mg-message/mg-message.d.ts +11 -4
  195. package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +10 -0
  196. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +83 -0
  197. package/dist/types/components/molecules/mg-modal/mg-modal.stories.d.ts +13 -0
  198. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +23 -7
  199. package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +5 -0
  200. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +110 -0
  201. package/dist/types/components/molecules/mg-panel/mg-panel.stories.d.ts +6 -0
  202. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +18 -3
  203. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +5 -0
  204. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +21 -6
  205. package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +8 -0
  206. package/dist/types/components.d.ts +365 -78
  207. package/dist/types/locales/index.d.ts +15 -8
  208. package/dist/types/utils/components.utils.d.ts +16 -9
  209. package/dist/types/utils/locale.utils.d.ts +6 -3
  210. package/dist/types/utils/test.utils.d.ts +13 -1
  211. package/package.json +13 -9
  212. package/readme.md +3 -0
  213. package/dist/cjs/css-shim-a22512c4.js +0 -6
  214. package/dist/cjs/mg-badge_20.cjs.entry.js +0 -4661
  215. package/dist/esm/css-shim-7c240feb.js +0 -4
  216. package/dist/esm/mg-badge_20.entry.js +0 -4638
  217. package/dist/esm-es5/css-shim-7c240feb.js +0 -1
  218. package/dist/esm-es5/index-e3e84606.js +0 -1
  219. package/dist/esm-es5/mg-badge_20.entry.js +0 -2
  220. package/dist/mg-components/p-1cd24462.system.js +0 -1
  221. package/dist/mg-components/p-2e2f6b27.system.entry.js +0 -2
  222. package/dist/mg-components/p-422c429b.system.js +0 -1
  223. package/dist/mg-components/p-62fa3797.js +0 -1
  224. package/dist/mg-components/p-9a215712.system.js +0 -1
  225. package/dist/mg-components/p-cbf0464b.entry.js +0 -1
@@ -0,0 +1,51 @@
1
+ /* eslint-disable react/jsx-no-bind */
2
+ import { h } from '@stencil/core';
3
+ export default {
4
+ component: 'mg-modal',
5
+ title: 'Molecules/mg-modal',
6
+ parameters: { actions: { handles: ['component-show', 'component-hide'] } },
7
+ };
8
+ /**
9
+ * 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
10
+ * 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
11
+ */
12
+ const Template = args => {
13
+ // Extract slot so it won't be render as an attribute
14
+ const slotContent = args.slotContent;
15
+ delete args.slotContent;
16
+ const slotActions = args.slotActions;
17
+ delete args.slotActions;
18
+ const closeButton = args.closeButton;
19
+ delete args.closeButton;
20
+ const modalTitle = args.modalTitle;
21
+ delete args.modalTitle;
22
+ // return element
23
+ return (h("div", null,
24
+ h("mg-button", { controls: "identifier", haspopup: "dialog", onClick: () => {
25
+ const mgModal = document.querySelector('mg-modal');
26
+ const isHide = mgModal.hide === true;
27
+ if (isHide) {
28
+ mgModal.removeAttribute('hide'); // storybook first render is an attribute then we use property
29
+ mgModal.hide = false;
30
+ }
31
+ else {
32
+ mgModal.hide = true;
33
+ }
34
+ } }, "Open modal"),
35
+ h("mg-modal", Object.assign({}, args, { "close-button": closeButton, "modal-title": modalTitle }),
36
+ slotContent && h("span", { slot: "content", innerHTML: slotContent }),
37
+ slotActions && h("span", { slot: "actions", innerHTML: slotActions }))));
38
+ };
39
+ export const MgModal = Template.bind({});
40
+ MgModal.args = {
41
+ slotContent: `<p slot="content">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>`,
42
+ slotActions: ``,
43
+ modalTitle: 'Modal title',
44
+ identifier: 'identifier',
45
+ closeButton: false,
46
+ hide: true,
47
+ };
48
+ export const WithCloseButton = Template.bind({});
49
+ WithCloseButton.args = Object.assign(Object.assign({}, MgModal.args), { closeButton: true });
50
+ export const WithActions = Template.bind({});
51
+ WithActions.args = Object.assign(Object.assign({}, MgModal.args), { closeButton: true, slotActions: `<div slot="actions" class="mg-group-elements mg-group-elements--align-right"><mg-button>Primary</mg-button><mg-button variant="secondary">Secondary</mg-button></div>` });
@@ -17,10 +17,10 @@ import { messages } from './../../../locales';
17
17
  * range(1, 5) = [1, 2, 3, 4, 5]
18
18
  * range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
19
19
  *
20
- * @param start
21
- * @param end
22
- * @param step
23
- * @returns {number[]}
20
+ * @param {number} start start range
21
+ * @param {number} end start end
22
+ * @param {number} step step size
23
+ * @returns {number[]} range numbers
24
24
  */
25
25
  const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
26
26
  export class MgPagination {
@@ -48,15 +48,21 @@ export class MgPagination {
48
48
  this.currentPage = 1;
49
49
  /**
50
50
  * Change current page from target
51
- * @param target
51
+ *
52
+ * @param {number} target target page
53
+ * @returns {void}
52
54
  */
53
- this.goToPage = (target) => (this.currentPage = target);
55
+ this.goToPage = (target) => {
56
+ this.currentPage = target;
57
+ };
54
58
  /************
55
59
  * Handlers *
56
60
  ************/
57
61
  /**
58
- * Default click handler
59
- * @param event
62
+ * select handler
63
+ *
64
+ * @param {InputEvent} event value change event
65
+ * @returns {void}
60
66
  */
61
67
  this.handleSelect = (event) => {
62
68
  const to = Number(event.target.value);
@@ -64,9 +70,13 @@ export class MgPagination {
64
70
  };
65
71
  /**
66
72
  * Go to 'previous/next' page button handler
73
+ *
74
+ * @param {string} action navigation action
67
75
  * @returns {void}
68
76
  */
69
- this.handleGoToPage = (action) => this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
77
+ this.handleGoToPage = (action) => {
78
+ this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
79
+ };
70
80
  }
71
81
  validateTotalPages(newValue) {
72
82
  if (newValue < 1) {
@@ -85,16 +95,26 @@ export class MgPagination {
85
95
  /*************
86
96
  * Lifecycle *
87
97
  *************/
98
+ /**
99
+ * Check if props are well configured on init
100
+ *
101
+ * @returns {void}
102
+ */
88
103
  componentWillLoad() {
89
104
  this.validateTotalPages(this.totalPages);
90
105
  this.validateCurrentPage(this.currentPage);
91
106
  }
107
+ /**
108
+ * Render
109
+ *
110
+ * @returns {HTMLElement} HTML Element
111
+ */
92
112
  render() {
93
113
  const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: messages.pagination[`${action}Page`],
94
114
  // eslint-disable-next-line react/jsx-no-bind
95
115
  onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" },
96
116
  action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }),
97
- messages.pagination[action],
117
+ messages.general[action],
98
118
  action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
99
119
  return (h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination__nav" },
100
120
  navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS),
@@ -107,7 +127,7 @@ export class MgPagination {
107
127
  "/ ",
108
128
  this.totalPages,
109
129
  " ",
110
- this.totalPages > 1 ? messages.pagination.pages : messages.pagination.pages),
130
+ this.totalPages > 1 ? messages.pagination.pages : messages.pagination.page),
111
131
  navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
112
132
  }
113
133
  static get is() { return "mg-pagination"; }
@@ -128,7 +148,7 @@ export class MgPagination {
128
148
  "references": {}
129
149
  },
130
150
  "required": false,
131
- "optional": true,
151
+ "optional": false,
132
152
  "docs": {
133
153
  "tags": [],
134
154
  "text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
@@ -2,6 +2,7 @@ import { h } from '@stencil/core';
2
2
  export default {
3
3
  component: 'mg-pagination',
4
4
  title: 'Molecules/mg-pagination',
5
+ parameters: { actions: { handles: ['current-page-change'] } },
5
6
  };
6
7
  /**
7
8
  * 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
@@ -0,0 +1,42 @@
1
+ .mg-panel {
2
+ background-color: hsl(var(--mg-panel-background));
3
+ border-radius: var(--mg-panel-border-radius);
4
+ box-shadow: var(--box-shadow);
5
+ }
6
+
7
+ .mg-panel__header {
8
+ display: flex;
9
+ flex-wrap: wrap;
10
+ justify-content: space-between;
11
+ padding: 0 1rem 0 0.3rem;
12
+ align-items: center;
13
+ }
14
+
15
+ .mg-panel__header-left,
16
+ .mg-panel__header-right {
17
+ display: flex;
18
+ flex-grow: 1;
19
+ margin: 0.3rem 0;
20
+ }
21
+
22
+ .mg-panel__header-left mg-input-text {
23
+ flex-grow: 1;
24
+ }
25
+
26
+ .mg-panel__collapse-button {
27
+ font-family: var(--font-family-heading);
28
+ font-size: 1.4rem;
29
+ font-weight: 500;
30
+ margin: 0 0.3rem 0 0;
31
+ }
32
+
33
+ .mg-panel__content {
34
+ padding: 1.5rem;
35
+ }
36
+
37
+ .mg-panel ::slotted([slot=header-right]) {
38
+ display: flex;
39
+ flex-wrap: wrap;
40
+ gap: 1rem;
41
+ margin-left: auto;
42
+ }
@@ -0,0 +1,255 @@
1
+ import { Component, h, Prop, State, Watch, Event } from '@stencil/core';
2
+ import { createID, ClassList } from '../../../utils/components.utils';
3
+ import { messages } from '../../../locales';
4
+ export class MgPanel {
5
+ constructor() {
6
+ /**************
7
+ * Decorators *
8
+ **************/
9
+ /**
10
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
11
+ * If not set, it will be created.
12
+ */
13
+ this.identifier = createID('mg-panel');
14
+ /**
15
+ * Panel is opened
16
+ */
17
+ this.expanded = false;
18
+ /**
19
+ * Panel title is editabled
20
+ */
21
+ this.titleEditable = false;
22
+ /**
23
+ * Component classes
24
+ */
25
+ this.classList = new ClassList(['mg-panel']);
26
+ /**
27
+ * Title is in edition mode
28
+ */
29
+ this.isEditing = false;
30
+ /************
31
+ * Methods *
32
+ ************/
33
+ /**
34
+ * Toggle is editing state
35
+ *
36
+ * @returns {void}
37
+ */
38
+ this.toggleIsEditing = () => {
39
+ this.isEditing = !this.isEditing;
40
+ };
41
+ /************
42
+ * Handlers *
43
+ ************/
44
+ /**
45
+ * Collapse button click handler
46
+ *
47
+ * @returns {void}
48
+ */
49
+ this.handleCollapseButton = () => {
50
+ this.expanded = !this.expanded;
51
+ };
52
+ /**
53
+ * Edit button click handler
54
+ *
55
+ * @returns {void}
56
+ */
57
+ this.handleEditButton = () => {
58
+ this.toggleIsEditing();
59
+ };
60
+ /**
61
+ * Update title handler
62
+ *
63
+ * @param {CustomEvent<string>} event input value change event
64
+ * @returns {void}
65
+ */
66
+ this.handleUpdateTitle = (event) => {
67
+ this.updatedPanelTitle = event.detail;
68
+ };
69
+ /**
70
+ * Cancel edition button handler
71
+ *
72
+ * @returns {void}
73
+ */
74
+ this.handleCancelEditButton = () => {
75
+ this.updatedPanelTitle = undefined;
76
+ this.toggleIsEditing();
77
+ };
78
+ /**
79
+ * Validate edition button handler
80
+ *
81
+ * @returns {void}
82
+ */
83
+ this.handleValidateEditButton = () => {
84
+ if (this.updatedPanelTitle !== undefined)
85
+ this.panelTitle = this.updatedPanelTitle;
86
+ this.toggleIsEditing();
87
+ };
88
+ /*************
89
+ * Lifecycle *
90
+ *************/
91
+ /**
92
+ * Header left conditional render
93
+ *
94
+ * @typedef {HTMLElement} HTMLMgButtonElement
95
+ * @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
96
+ */
97
+ this.headerLeft = () => {
98
+ 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` },
99
+ h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }),
100
+ !this.isEditing && this.panelTitle));
101
+ if (this.titleEditable && !this.isEditing) {
102
+ return [
103
+ collapseButton(),
104
+ h("mg-button", { "is-icon": true, variant: "secondary", label: messages.panel.editLabel, onClick: this.handleEditButton, identifier: `${this.identifier}-edit-button` },
105
+ h("mg-icon", { icon: "pen" })),
106
+ ];
107
+ }
108
+ if (this.titleEditable && this.isEditing) {
109
+ return [
110
+ collapseButton(),
111
+ h("mg-input-text", { label: messages.panel.editLabel, "label-hide": true, value: this.panelTitle, "onValue-change": this.handleUpdateTitle, displayCharacterLeft: false, identifier: `${this.identifier}-edition-input`, ref: el => (this.editInputElement = el) },
112
+ h("mg-button", { slot: "append-input", label: messages.general.cancel, "is-icon": true, variant: "secondary", onClick: this.handleCancelEditButton, identifier: `${this.identifier}-edition-button-cancel` },
113
+ h("mg-icon", { icon: "cross" })),
114
+ h("mg-button", { slot: "append-input", label: messages.general.validate, "is-icon": true, variant: "secondary", onClick: this.handleValidateEditButton, identifier: `${this.identifier}-edition-button-validate` },
115
+ h("mg-icon", { icon: "check" }))),
116
+ ];
117
+ }
118
+ return collapseButton();
119
+ };
120
+ }
121
+ handelTileChange(newValue) {
122
+ this.titleChange.emit(newValue);
123
+ }
124
+ /**
125
+ * Edit DOM after render
126
+ *
127
+ * @returns {void}
128
+ */
129
+ componentDidRender() {
130
+ // when we are editing we get focus on edition input
131
+ if (this.isEditing) {
132
+ this.editInputElement.setFocus();
133
+ }
134
+ }
135
+ /**
136
+ * Render component
137
+ *
138
+ * @returns {HTMLElement} html element
139
+ */
140
+ render() {
141
+ return (h("section", { class: this.classList.join(), id: this.identifier },
142
+ h("header", { class: "mg-panel__header", id: `${this.identifier}-header` },
143
+ h("div", { class: "mg-panel__header-left" }, this.headerLeft()),
144
+ h("div", { class: "mg-panel__header-right" },
145
+ h("slot", { name: "header-right" }))),
146
+ h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded },
147
+ h("slot", null))));
148
+ }
149
+ static get is() { return "mg-panel"; }
150
+ static get encapsulation() { return "shadow"; }
151
+ static get originalStyleUrls() { return {
152
+ "$": ["mg-panel.scss"]
153
+ }; }
154
+ static get styleUrls() { return {
155
+ "$": ["mg-panel.css"]
156
+ }; }
157
+ static get properties() { return {
158
+ "identifier": {
159
+ "type": "string",
160
+ "mutable": false,
161
+ "complexType": {
162
+ "original": "string",
163
+ "resolved": "string",
164
+ "references": {}
165
+ },
166
+ "required": false,
167
+ "optional": false,
168
+ "docs": {
169
+ "tags": [],
170
+ "text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
171
+ },
172
+ "attribute": "identifier",
173
+ "reflect": false,
174
+ "defaultValue": "createID('mg-panel')"
175
+ },
176
+ "panelTitle": {
177
+ "type": "string",
178
+ "mutable": true,
179
+ "complexType": {
180
+ "original": "string",
181
+ "resolved": "string",
182
+ "references": {}
183
+ },
184
+ "required": true,
185
+ "optional": false,
186
+ "docs": {
187
+ "tags": [],
188
+ "text": "Panel title"
189
+ },
190
+ "attribute": "panel-title",
191
+ "reflect": false
192
+ },
193
+ "expanded": {
194
+ "type": "boolean",
195
+ "mutable": true,
196
+ "complexType": {
197
+ "original": "boolean",
198
+ "resolved": "boolean",
199
+ "references": {}
200
+ },
201
+ "required": false,
202
+ "optional": false,
203
+ "docs": {
204
+ "tags": [],
205
+ "text": "Panel is opened"
206
+ },
207
+ "attribute": "expanded",
208
+ "reflect": false,
209
+ "defaultValue": "false"
210
+ },
211
+ "titleEditable": {
212
+ "type": "boolean",
213
+ "mutable": false,
214
+ "complexType": {
215
+ "original": "boolean",
216
+ "resolved": "boolean",
217
+ "references": {}
218
+ },
219
+ "required": false,
220
+ "optional": false,
221
+ "docs": {
222
+ "tags": [],
223
+ "text": "Panel title is editabled"
224
+ },
225
+ "attribute": "title-editable",
226
+ "reflect": false,
227
+ "defaultValue": "false"
228
+ }
229
+ }; }
230
+ static get states() { return {
231
+ "classList": {},
232
+ "isEditing": {},
233
+ "updatedPanelTitle": {}
234
+ }; }
235
+ static get events() { return [{
236
+ "method": "titleChange",
237
+ "name": "title-change",
238
+ "bubbles": true,
239
+ "cancelable": true,
240
+ "composed": true,
241
+ "docs": {
242
+ "tags": [],
243
+ "text": "Emmited event when title change"
244
+ },
245
+ "complexType": {
246
+ "original": "string",
247
+ "resolved": "string",
248
+ "references": {}
249
+ }
250
+ }]; }
251
+ static get watchers() { return [{
252
+ "propName": "panelTitle",
253
+ "methodName": "handelTileChange"
254
+ }]; }
255
+ }
@@ -0,0 +1,31 @@
1
+ import { h } from '@stencil/core';
2
+ export default {
3
+ component: 'mg-panel',
4
+ title: 'Molecules/mg-panel',
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
+ // Extract slot so it won't be render as an attribute
12
+ const panelTitle = args.panelTitle;
13
+ delete args.panelTitle;
14
+ const titleEditable = args.titleEditable;
15
+ delete args.titleEditable;
16
+ // return element
17
+ return (h("mg-panel", Object.assign({}, args, { "panel-title": panelTitle, "title-editable": titleEditable }),
18
+ h("div", null, "Content"),
19
+ h("div", { slot: "header-right" },
20
+ h("mg-button", { variant: "secondary" },
21
+ h("mg-icon", { icon: "file-upload" }),
22
+ " Upload"),
23
+ h("mg-button", { "is-icon": true, variant: "secondary", label: "delete" },
24
+ h("mg-icon", { icon: "trash" })))));
25
+ };
26
+ export const MgPanel = Template.bind({});
27
+ MgPanel.args = {
28
+ panelTitle: 'title',
29
+ expanded: false,
30
+ titleEditable: true,
31
+ };
@@ -11,7 +11,7 @@ mg-popover::slotted(*) {
11
11
  z-index: 9999;
12
12
  border-radius: 0.5rem;
13
13
  background-color: hsl(var(--mg-popover-background-color));
14
- box-shadow: 0 0.3rem 0.8rem 0 rgba(0, 0, 0, 0.1);
14
+ box-shadow: var(--box-shadow);
15
15
  color: hsl(var(--mg-popover-font-color));
16
16
  }
17
17
  .mg-popover[data-show] {
@@ -28,7 +28,7 @@ mg-popover::slotted(*) {
28
28
  position: absolute;
29
29
  width: 2rem;
30
30
  height: 2rem;
31
- z-index: 9999;
31
+ z-index: -1;
32
32
  background: inherit;
33
33
  }
34
34
  .mg-popover .mg-popover__arrow {
@@ -28,18 +28,21 @@ export class MgPopover {
28
28
  this.disabled = false;
29
29
  /**
30
30
  * Check if clicked outside of component
31
- * @param e {event}
31
+ *
32
+ * @param {MouseEvent} event mouse event
33
+ * @returns {void}
32
34
  */
33
35
  // Unable to trigger document events in unit tests: https://gitlab.mgdis.fr/core/core-ui/mg-components/-/issues/57
34
36
  /* istanbul ignore next */
35
- this.clickOutside = e => {
37
+ this.clickOutside = (event) => {
36
38
  var _a;
37
- if (!this.disabled && ((_a = e.target.closest(`#${this.identifier}`)) === null || _a === void 0 ? void 0 : _a.parentElement.nodeName) !== 'MG-POPOVER') {
39
+ if (!this.disabled && ((_a = event.target.closest(`#${this.identifier}`)) === null || _a === void 0 ? void 0 : _a.parentElement.nodeName) !== 'MG-POPOVER') {
38
40
  this.display = false;
39
41
  }
40
42
  };
41
43
  /**
42
44
  * Show popover
45
+ *
43
46
  * @returns {void}
44
47
  */
45
48
  this.show = () => {
@@ -59,6 +62,7 @@ export class MgPopover {
59
62
  };
60
63
  /**
61
64
  * Hide popover
65
+ *
62
66
  * @returns {void}
63
67
  */
64
68
  this.hide = () => {
@@ -71,6 +75,7 @@ export class MgPopover {
71
75
  };
72
76
  /**
73
77
  * Handle action for close button
78
+ *
74
79
  * @returns {void}
75
80
  */
76
81
  this.handleCloseButton = () => {
@@ -88,6 +93,11 @@ export class MgPopover {
88
93
  /*************
89
94
  * Lifecycle *
90
95
  *************/
96
+ /**
97
+ * Check if component props are well configured on init
98
+ *
99
+ * @returns {void}
100
+ */
91
101
  componentDidLoad() {
92
102
  //Check if slotted title is a heading
93
103
  const headingElements = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
@@ -130,11 +140,16 @@ export class MgPopover {
130
140
  });
131
141
  this.handleDisplay(this.display);
132
142
  }
143
+ /**
144
+ * Render
145
+ *
146
+ * @returns {HTMLElement} HTML Element
147
+ */
133
148
  render() {
134
149
  return (h(Host, null,
135
150
  h("slot", null),
136
151
  h("div", { id: this.identifier, class: "mg-popover" },
137
- !this.disabled && this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: messages.popover.closeButton, onClick: this.handleCloseButton },
152
+ !this.disabled && this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: messages.general.close, onClick: this.handleCloseButton },
138
153
  h("mg-icon", { icon: "cross" }))),
139
154
  h("div", { class: "mg-popover__title" },
140
155
  h("slot", { name: "title" })),
@@ -1 +1,4 @@
1
- export {};
1
+ /**
2
+ * List of all possibles sizes
3
+ */
4
+ export const sizes = ['regular', 'large'];
@@ -1,3 +1,11 @@
1
+ .mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button {
2
+ padding: calc(1rem + 0.3rem) calc(1rem * 1.3) 1rem;
3
+ }
4
+
5
+ .mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button {
6
+ padding: calc(1.8rem + 0.3rem) calc(1.8rem * 1.3) 1.8rem;
7
+ }
8
+
1
9
  .mg-tabs__header {
2
10
  display: flex;
3
11
  flex-direction: row;
@@ -8,7 +16,6 @@
8
16
  display: flex;
9
17
  align-items: center;
10
18
  column-gap: 0.5rem;
11
- padding: 1.8rem 2.4rem 1.5rem;
12
19
  background: none;
13
20
  border: none;
14
21
  border-bottom: 0.3rem solid transparent;
@@ -16,7 +23,11 @@
16
23
  line-height: var(--line-height);
17
24
  cursor: pointer;
18
25
  }
19
- .mg-tabs__navigation-button:hover, .mg-tabs__navigation-button:focus {
26
+ .mg-tabs__navigation-button:disabled, .mg-tabs__navigation-button--disabled {
27
+ cursor: default;
28
+ opacity: 30%;
29
+ }
30
+ .mg-tabs__navigation-button:hover:not(:disabled), .mg-tabs__navigation-button:focus:not(:disabled) {
20
31
  background-color: hsla(var(--color-info-h), var(--color-info-s), var(--color-info-l), 10%);
21
32
  }
22
33
  .mg-tabs__navigation-button.mg-tabs__navigation-button--active {
@@ -26,5 +37,5 @@
26
37
  }
27
38
 
28
39
  .mg-tabs__content-container:focus-visible {
29
- outline-color: transparent;
40
+ outline: none;
30
41
  }