@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,3313 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-bead7dbd.js');
6
+ const index$1 = require('./index-369388eb.js');
7
+ const popper = require('./popper-0c3964e7.js');
8
+
9
+ /**
10
+ * List of all possibles variants
11
+ */
12
+ const variants$4 = ['info', 'primary', 'secondary', 'success', 'warning', 'danger'];
13
+
14
+ const mgBadgeCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-badge{padding:0 0.4rem;height:var(--mg-badge-size);min-width:var(--mg-badge-size);-webkit-box-sizing:border-box;box-sizing:border-box;border:0.1rem solid;border-radius:50%;border-radius:calc(var(--mg-badge-size) / 2);font-size:var(--mg-badge-font-size);font-weight:600;text-align:center;line-height:var(--mg-badge-size)}.mg-badge.mg-badge--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-badge.mg-badge--primary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-badge.mg-badge--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-badge.mg-badge--success.mg-badge--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-badge.mg-badge--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-badge.mg-badge--warning.mg-badge--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-badge.mg-badge--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-badge.mg-badge--danger.mg-badge--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-badge.mg-badge--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-badge.mg-badge--info.mg-badge--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-badge,mg-badge{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}";
15
+
16
+ const MgBadge = class {
17
+ constructor(hostRef) {
18
+ index.registerInstance(this, hostRef);
19
+ /**
20
+ * Define button variant
21
+ */
22
+ this.variant = variants$4[0]; // info
23
+ /**
24
+ * Component classes
25
+ */
26
+ this.classList = new index$1.ClassList(['mg-badge']);
27
+ }
28
+ validateValue(newValue) {
29
+ if (`${newValue}`.match(/^(\d+|[?*!a-z])$/i) === null) {
30
+ throw new Error('<mg-badge> prop "value" must be interger or ponctuation character.');
31
+ }
32
+ }
33
+ validateVariant(newValue) {
34
+ if (!variants$4.includes(newValue)) {
35
+ throw new Error(`<mg-badge> prop "variant" must be one of : ${variants$4.join(', ')}.`);
36
+ }
37
+ this.classList.add(`mg-badge--${this.variant}`);
38
+ }
39
+ validateOutline(newValue) {
40
+ if (newValue)
41
+ this.classList.add(`mg-badge--outline`);
42
+ }
43
+ /**
44
+ * Check if props are well configured on init
45
+ *
46
+ * @returns {void}
47
+ */
48
+ componentWillLoad() {
49
+ this.validateValue(this.value);
50
+ this.validateVariant(this.variant);
51
+ this.validateOutline(this.outline);
52
+ }
53
+ /**
54
+ * Render
55
+ *
56
+ * @returns {HTMLElement} HTML Element
57
+ */
58
+ render() {
59
+ return (index.h("span", { class: this.classList.join() }, this.value, index.h("span", { class: "sr-only" }, this.label)));
60
+ }
61
+ static get watchers() { return {
62
+ "value": ["validateValue"],
63
+ "variant": ["validateVariant"],
64
+ "outline": ["validateOutline"]
65
+ }; }
66
+ };
67
+ MgBadge.style = mgBadgeCss;
68
+
69
+ /**
70
+ * List of all possibles variants
71
+ */
72
+ const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat'];
73
+
74
+ const mgButtonCss = ".mg-button.sc-mg-button{position:relative;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-webkit-column-gap:0.6rem;-moz-column-gap:0.6rem;column-gap:0.6rem;padding:calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;min-height:var(--default-size);-webkit-box-sizing:border-box;box-sizing:border-box;border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-border-radius));cursor:pointer;background-image:none;border-top-width:var(--mg-button-border-top-width, 0.1rem);border-right-width:var(--mg-button-border-right-width, 0.1rem);border-bottom-width:var(--mg-button-border-bottom-width, 0.1rem);border-left-width:var(--mg-button-border-left-width, 0.1rem);border-style:solid;font-family:inherit;text-decoration:none;font-weight:normal;text-align:left;-ms-touch-action:manipulation;touch-action:manipulation}.mg-button[disabled].sc-mg-button,.mg-button[aria-disabled].sc-mg-button,.mg-button.disabled.sc-mg-button{opacity:var(--mg-button-disabled-opacity);cursor:default}.mg-button.mg-button--icon.sc-mg-button{padding:0;-ms-flex-pack:center;justify-content:center;width:var(--default-size);height:var(--default-size);border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-icon-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-icon-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-icon-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-icon-border-radius));font-size:var(--font-size);line-height:var(--font-size)}.mg-button.mg-button--primary.sc-mg-button{border-color:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l));border-color:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - 10%));color:hsl(var(--mg-button-primary-font-color));background:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l));background:-webkit-gradient(linear, left top, left bottom, from(hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l))), to(hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%))));background:linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%)))}.mg-button.mg-button--primary.sc-mg-button:hover:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--primary.sc-mg-button:focus:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--primary.sc-mg-button:active:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l))}.mg-button.mg-button--secondary.sc-mg-button{border-color:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l));border-color:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - 10%));color:hsl(var(--mg-button-secondary-font-color));background:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l));background:-webkit-gradient(linear, left top, left bottom, from(hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l))), to(hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%))));background:linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%)))}.mg-button.mg-button--secondary.sc-mg-button:hover:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--secondary.sc-mg-button:focus:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--secondary.sc-mg-button:active:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l))}.mg-button.mg-button--danger.sc-mg-button{border-color:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));border-color:hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - 10%));color:hsl(var(--color-neutral));background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));background:-webkit-gradient(linear, left top, left bottom, from(hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))), to(hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%))));background:linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%)))}.mg-button.mg-button--danger.sc-mg-button:hover:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger.sc-mg-button:focus:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger.sc-mg-button:active:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-button.mg-button--danger-alt.sc-mg-button{border-color:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l));border-color:hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - 10%));color:hsl(var(--color-danger));background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l));background:-webkit-gradient(linear, left top, left bottom, from(hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))), to(hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%))));background:linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%)))}.mg-button.mg-button--danger-alt.sc-mg-button:hover:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger-alt.sc-mg-button:focus:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger-alt.sc-mg-button:active:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))}.mg-button.mg-button--info.sc-mg-button{border-color:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));border-color:hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - 10%));color:hsl(var(--color-neutral));background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));background:-webkit-gradient(linear, left top, left bottom, from(hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))), to(hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%))));background:linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%)))}.mg-button.mg-button--info.sc-mg-button:hover:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--info.sc-mg-button:focus:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--info.sc-mg-button:active:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-button.mg-button--flat.sc-mg-button{background:none;border:none}.mg-button.mg-button--flat.sc-mg-button:hover:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--flat.sc-mg-button:focus:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--flat.sc-mg-button:active:not([disabled],[aria-disabled].sc-mg-button,.disabled).sc-mg-button{background:hsla(var(--color-dark), 0.1)}.mg-button.sc-mg-button mg-icon.sc-mg-button:only-child,.mg-button .sc-mg-button-s>mg-icon{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-negative:0;flex-shrink:0;line-height:1;margin:auto 0}.mg-button.mg-button--loading.sc-mg-button>mg-icon.sc-mg-button{position:absolute;left:50%;top:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.mg-button.mg-button--loading.sc-mg-button .mg-button__content.sc-mg-button{opacity:0}.mg-button__content.sc-mg-button{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-webkit-column-gap:0.6rem;-moz-column-gap:0.6rem;column-gap:0.6rem}mg-button.sc-mg-button{display:inline-block}.mg-button.sc-mg-button,mg-button.sc-mg-button{vertical-align:middle;max-width:100%}";
75
+
76
+ const MgButton = class {
77
+ constructor(hostRef) {
78
+ index.registerInstance(this, hostRef);
79
+ /************
80
+ * Internal *
81
+ ************/
82
+ this.onClickElementFn = null;
83
+ /**
84
+ * Define button variant
85
+ */
86
+ this.variant = variants$3[0]; // Primary
87
+ /**
88
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
89
+ * If not set, it will be created.
90
+ */
91
+ this.identifier = index$1.createID('mg-button');
92
+ /**
93
+ * Disable button
94
+ */
95
+ this.disabled = false;
96
+ /**
97
+ * Define if button is round.
98
+ * Used for icon button.
99
+ */
100
+ this.isIcon = false;
101
+ /**
102
+ * Option to set input disable on click, in order to prevent multi-click.
103
+ * Parent component have to remove the attribute 'disabled' when the process ends.
104
+ */
105
+ this.disableOnClick = false;
106
+ /**
107
+ * Prop to set aria-expanded on button element
108
+ */
109
+ this.expanded = false;
110
+ /**
111
+ * Option to set aria-haspopup
112
+ * The aria-haspopup state informs assistive technology users that there is a popup and the type of popup it is, but provides no interactivity.
113
+ */
114
+ this.haspopup = false;
115
+ /**
116
+ * Define if button is loading, default to false.
117
+ * Trigger when button is clicked or key-up ['enter', 'space], then value change to true.
118
+ * It's required to reset to false when action/promise in parent is done to stop the loading state
119
+ */
120
+ this.loading = false;
121
+ /**
122
+ * Component classes
123
+ */
124
+ this.classList = new index$1.ClassList(['mg-button']);
125
+ /**
126
+ * Trigger actions onClick event
127
+ *
128
+ * @param {MouseEvent} event click event
129
+ * @returns {void}
130
+ */
131
+ this.handleClick = (event) => {
132
+ if (this.disabled)
133
+ event.stopPropagation();
134
+ // Used to prevent multi-click.
135
+ if (this.disableOnClick && !this.disabled) {
136
+ this.loading = true;
137
+ this.disabled = true;
138
+ }
139
+ };
140
+ }
141
+ validateVariant(newValue) {
142
+ if (!variants$3.includes(newValue)) {
143
+ throw new Error(`<mg-button> prop "variant" must be one of : ${variants$3.join(', ')}`);
144
+ }
145
+ this.classList.add(`mg-button--${this.variant}`);
146
+ }
147
+ disabledHandler(isDisabled) {
148
+ // Remove loading when enable
149
+ // Will be set back onclick
150
+ if (!isDisabled && this.disableOnClick) {
151
+ this.loading = false;
152
+ }
153
+ // Manage if onclick
154
+ this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
155
+ }
156
+ loadingHandler(newValue) {
157
+ // we add loading style if it newvalue is true else we remove it
158
+ if (newValue) {
159
+ this.classList.add('mg-button--loading');
160
+ }
161
+ else {
162
+ this.classList.delete('mg-button--loading');
163
+ }
164
+ }
165
+ /**
166
+ * Check if props are well configured on init
167
+ *
168
+ * @returns {void}
169
+ */
170
+ componentWillLoad() {
171
+ this.validateVariant(this.variant);
172
+ if (this.isIcon) {
173
+ this.classList.add(`mg-button--icon`);
174
+ if (typeof this.label !== 'string' || this.label === '') {
175
+ throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
176
+ }
177
+ }
178
+ // Store the onclick fn
179
+ this.onClickElementFn = this.element.onclick;
180
+ this.disabledHandler(this.disabled);
181
+ }
182
+ /**
183
+ * Render component
184
+ *
185
+ * @returns {HTMLElement} html element
186
+ */
187
+ render() {
188
+ return (index.h("button", { id: this.identifier, class: this.classList.join(), "aria-label": this.label, "aria-disabled": this.disabled, "aria-expanded": this.expanded, "aria-controls": this.controls, "aria-haspopup": this.haspopup, onClick: this.handleClick }, this.loading && index.h("mg-icon", { icon: "loader", spin: true }), index.h("div", { class: "mg-button__content" }, index.h("slot", null))));
189
+ }
190
+ get element() { return index.getElement(this); }
191
+ static get watchers() { return {
192
+ "variant": ["validateVariant"],
193
+ "disabled": ["disabledHandler"],
194
+ "loading": ["loadingHandler"]
195
+ }; }
196
+ };
197
+ MgButton.style = mgButtonCss;
198
+
199
+ const mgCharacterLeftCss = "mg-character-left.sc-mg-character-left{display:block}";
200
+
201
+ const MgCharacterLeft = class {
202
+ constructor(hostRef) {
203
+ index.registerInstance(this, hostRef);
204
+ /************
205
+ * Internal *
206
+ ************/
207
+ this.mustacheCounter = '{counter}';
208
+ /**
209
+ * Template to display remaining characters.
210
+ * Must have {counter} inside
211
+ */
212
+ this.template = index$1.messages.nbCharLeft;
213
+ /**
214
+ * Sets the characters to count
215
+ */
216
+ this.characters = '';
217
+ /**
218
+ * Calculate number character left
219
+ *
220
+ * @returns {string} message
221
+ */
222
+ this.getMessage = () => {
223
+ return this.template.replace(this.mustacheCounter, `<strong>${this.maxlength - this.characters.length}</strong>`);
224
+ };
225
+ }
226
+ validateTemplate(newValue) {
227
+ if (typeof newValue !== 'string' || newValue === '' || newValue.indexOf(this.mustacheCounter) === -1) {
228
+ throw new Error(`<mg-character-left> prop "template" must contain "${this.mustacheCounter}".`);
229
+ }
230
+ }
231
+ validateMaxlength(newValue) {
232
+ if (typeof newValue !== 'number') {
233
+ throw new Error('<mg-character-left> prop "maxlength" is required.');
234
+ }
235
+ }
236
+ /*************
237
+ * Lifecycle *
238
+ *************/
239
+ /**
240
+ * Check if props are well configured on init
241
+ *
242
+ * @returns {void}
243
+ */
244
+ componentWillLoad() {
245
+ this.validateTemplate(this.template);
246
+ this.validateMaxlength(this.maxlength);
247
+ }
248
+ /**
249
+ * Render component
250
+ *
251
+ * @returns {HTMLElement} HTML Element
252
+ */
253
+ render() {
254
+ return index.h("span", { id: this.identifier, innerHTML: this.getMessage(), "aria-live": "polite" });
255
+ }
256
+ static get watchers() { return {
257
+ "template": ["validateTemplate"],
258
+ "maxlength": ["validateMaxlength"]
259
+ }; }
260
+ };
261
+ MgCharacterLeft.style = mgCharacterLeftCss;
262
+
263
+ const mgFormCss = ".is-asterisk{color:hsl(var(--color-danger))}.mg-form,.mg-form-group{--mg-inputs-margin-bottom:1.5rem;--mg-inputs-title-horizontal-space:3rem;--mg-inputs-title-width:15rem;--mg-inputs-shrink:0}.mg-form.mg-form--all-required,.mg-form-group.mg-form--all-required{--mg-input-title-display:none}";
264
+
265
+ const MgForm = class {
266
+ constructor(hostRef) {
267
+ index.registerInstance(this, hostRef);
268
+ this.formValid = index.createEvent(this, "form-valid", 7);
269
+ /**
270
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
271
+ * If not set, it will be created.
272
+ */
273
+ this.identifier = index$1.createID('mg-form');
274
+ /**
275
+ * Input name
276
+ * If not set the value equals the identifier
277
+ */
278
+ this.name = this.identifier;
279
+ /**
280
+ * Define if form is readonly
281
+ */
282
+ this.readonly = false;
283
+ /**
284
+ * Define if form is disabled
285
+ */
286
+ this.disabled = false;
287
+ /**
288
+ * Component classes
289
+ */
290
+ this.classList = new index$1.ClassList(['mg-form']);
291
+ /**
292
+ * Define required message based on mg-inputs required elements
293
+ * Also
294
+ *
295
+ * @returns {void}
296
+ */
297
+ this.setRequiredMessage = () => {
298
+ // Get required fields
299
+ const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !this.disabled);
300
+ // All fields are required
301
+ // mg-input-toggle can not be required
302
+ if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
303
+ this.requiredMessage = index$1.messages.form.allRequired;
304
+ this.classList.add('mg-form--all-required');
305
+ }
306
+ // Some fields are required
307
+ else if (requiredInputs.length > 0) {
308
+ this.requiredMessage = index$1.messages.form.required;
309
+ }
310
+ };
311
+ /**
312
+ * Check if form is valid
313
+ *
314
+ * @returns {void}
315
+ */
316
+ this.checkValidity = () => {
317
+ const validity = !this.mgInputs.some(input => input.invalid);
318
+ this.valid = validity;
319
+ this.invalid = !validity;
320
+ this.formValid.emit(validity);
321
+ };
322
+ }
323
+ /**
324
+ * Public method to display errors
325
+ *
326
+ * @returns {Promise<void>}
327
+ */
328
+ async displayError() {
329
+ if (!this.readonly) {
330
+ this.mgInputs.forEach(input => {
331
+ input.displayError && input.displayError();
332
+ });
333
+ this.checkValidity();
334
+ }
335
+ }
336
+ /*************
337
+ * Lifecycle *
338
+ *************/
339
+ /**
340
+ * Check if component props are well configured on init
341
+ *
342
+ * @returns {void}
343
+ */
344
+ componentWillLoad() {
345
+ // Get slotted mgIputs
346
+ this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
347
+ // Define required message
348
+ this.setRequiredMessage();
349
+ // Check validity when slotted mgImputs are ready
350
+ Promise.all(this.mgInputs.map(async (input) => {
351
+ // Set inputs readonly or disabled based on form configuration
352
+ // Othewise listen to events
353
+ if (this.readonly)
354
+ input.readonly = true;
355
+ else if (this.disabled)
356
+ input.disabled = true;
357
+ else
358
+ input.addEventListener('input-valid', this.checkValidity);
359
+ await input.componentOnReady();
360
+ })).then(() => {
361
+ this.checkValidity();
362
+ });
363
+ }
364
+ /**
365
+ * Render
366
+ *
367
+ * @returns {HTMLElement} HTML Element
368
+ */
369
+ render() {
370
+ return (index.h("form", { class: this.classList.join(), id: this.identifier, name: this.name }, this.requiredMessage && index.h("p", { innerHTML: this.requiredMessage }), index.h("slot", null), !this.readonly && !this.disabled && index.h("slot", { name: "actions" })));
371
+ }
372
+ get element() { return index.getElement(this); }
373
+ };
374
+ MgForm.style = mgFormCss;
375
+
376
+ /**
377
+ * Icon SVG paths
378
+ */
379
+ const icons = {
380
+ 'arrow-down': () => (index.h("path", { fill: "currentColor", d: "M13,10.1H10.23a.31.31,0,0,1-.32-.28h0V.94A.3.3,0,0,0,9.59.65H6.37A.32.32,0,0,0,6,.94H6V9.81a.29.29,0,0,1-.31.29H3a.3.3,0,0,0-.31.29.27.27,0,0,0,.08.22l5.06,4.58a.36.36,0,0,0,.46,0l5-4.58a.29.29,0,0,0,0-.42C13.22,10.1,13.12,10.1,13,10.1Z" })),
381
+ 'arrow-left': () => (index.h("path", { fill: "currentColor", d: "M5.88,12.93V10.18a.3.3,0,0,1,.28-.32H15a.31.31,0,0,0,.29-.33h0V6.32A.31.31,0,0,0,15,6H6.17a.32.32,0,0,1-.29-.31h0V2.93a.3.3,0,0,0-.28-.32.32.32,0,0,0-.23.09L.79,7.76a.36.36,0,0,0,0,.46l4.58,5a.31.31,0,0,0,.43,0A.4.4,0,0,0,5.88,12.93Z" })),
382
+ 'arrow-right': () => (index.h("path", { fill: "currentColor", d: "M10.16,3V5.75a.3.3,0,0,1-.28.32H1a.31.31,0,0,0-.29.33h0V9.61A.31.31,0,0,0,1,9.94H9.87a.29.29,0,0,1,.29.31h0V13a.3.3,0,0,0,.28.32.32.32,0,0,0,.23-.09l4.58-5.06a.36.36,0,0,0,0-.46l-4.58-5a.3.3,0,0,0-.42,0C10.16,2.76,10.16,2.87,10.16,3Z" })),
383
+ 'arrow-up': () => (index.h("path", { fill: "currentColor", d: "M3.06,5.82H5.81a.31.31,0,0,1,.32.28h0V15a.31.31,0,0,0,.33.29H9.67A.3.3,0,0,0,10,15h0V6.11a.3.3,0,0,1,.31-.29h2.75a.3.3,0,0,0,.23-.51L8.23.73a.36.36,0,0,0-.46,0l-5,4.58a.3.3,0,0,0,0,.43C2.82,5.83,2.92,5.82,3.06,5.82Z" })),
384
+ 'arrow-up-right-square': () => (index.h("path", { fill: "currentColor", d: "M14.33 3v10A1.34 1.34 0 0 1 13 14.33H3A1.34 1.34 0 0 1 1.67 13V3A1.34 1.34 0 0 1 3 1.67h10A1.34 1.34 0 0 1 14.33 3Zm-2.48.46H8.68a.67.67 0 0 0-.68.7.63.63 0 0 0 .2.47l.91.91-5.53 5.53a.33.33 0 0 0 0 .48l.87.87a.33.33 0 0 0 .48 0l5.53-5.52.91.9a.69.69 0 0 0 1 0 .71.71 0 0 0 .19-.48V4.15a.67.67 0 0 0-.67-.67Z" })),
385
+ 'arrows-rotate': () => (index.h("path", { fill: "currentColor", d: "M2.3,7h3.4c0.3,0,0.6-0.3,0.6-0.6c0-0.1-0.1-0.3-0.2-0.4L5.1,4.9c1.7-1.6,4.4-1.5,6,0.2c0,0,0,0,0,0 c0.5,0.5,0.8,1.2,1,1.9h2.1C13.7,3.5,10.4,1.2,7,1.8C5.7,2,4.6,2.6,3.6,3.4L2.7,2.5c-0.2-0.2-0.6-0.2-0.8,0c0,0,0,0,0,0l0,0 C1.8,2.6,1.7,2.8,1.7,2.9v3.4C1.7,6.7,1.9,7,2.3,7z M13.7,9h-3.4C9.9,9,9.7,9.3,9.7,9.6c0,0.2,0.1,0.3,0.2,0.4l1.1,1.1 c-1.7,1.6-4.4,1.5-6-0.2C4.4,10.4,4,9.7,3.8,9H1.7c0.6,3.5,3.9,5.8,7.3,5.2c1.3-0.2,2.4-0.8,3.3-1.7l0.9,0.9c0.2,0.2,0.6,0.2,0.8,0 c0,0,0,0,0,0l0,0c0.1-0.1,0.2-0.3,0.2-0.4V9.6C14.3,9.3,14.1,9,13.7,9z" })),
386
+ 'ban': () => (index.h("path", { fill: "currentColor", d: "M8 .67A7.33 7.33 0 1 0 15.33 8 7.33 7.33 0 0 0 8 .67Zm3.85 3.48a5.46 5.46 0 0 1 .61 7L4.88 3.54a5.46 5.46 0 0 1 6.97.61Zm-7.7 7.7a5.45 5.45 0 0 1-.61-7l7.58 7.58a5.46 5.46 0 0 1-7-.61Z" })),
387
+ 'calculator': () => (index.h("path", { fill: "currentColor", d: "M12.83.67H3.17a.5.5 0 0 0-.5.5v13.66a.5.5 0 0 0 .5.5h9.66a.5.5 0 0 0 .5-.5V1.17a.5.5 0 0 0-.5-.5ZM5.58 13.39a.29.29 0 0 1-.28.3H4.1a.29.29 0 0 1-.3-.28v-1.2a.29.29 0 0 1 .28-.3h1.2a.29.29 0 0 1 .3.28v1.2Zm0-3.28a.29.29 0 0 1-.3.3H4.1a.29.29 0 0 1-.3-.3V8.93a.29.29 0 0 1 .28-.3h1.2a.29.29 0 0 1 .3.28v1.2Zm3.29 3.28a.29.29 0 0 1-.3.3H7.38a.29.29 0 0 1-.3-.3v-1.18a.29.29 0 0 1 .3-.3h1.19a.29.29 0 0 1 .3.3Zm0-3.28a.32.32 0 0 1-.3.3H7.38a.32.32 0 0 1-.3-.3V8.93a.29.29 0 0 1 .3-.3h1.19a.29.29 0 0 1 .3.3Zm3.33 3.28a.29.29 0 0 1-.28.3h-1.25a.29.29 0 0 1-.3-.28V8.93a.29.29 0 0 1 .28-.3h1.25a.29.29 0 0 1 .3.28v4.48Zm0-7.15a.29.29 0 0 1-.3.3H4.1a.29.29 0 0 1-.3-.3V2.61a.29.29 0 0 1 .28-.3h7.82a.29.29 0 0 1 .3.28v3.65Z" })),
388
+ 'check': () => (index.h("path", { fill: "currentColor", d: "M15.3,4.2L14.2,3c-0.1-0.1-0.3-0.1-0.4,0L6,10.4l-3.8-4C2.2,6.3,2.1,6.3,2,6.4L0.7,7.6c-0.1,0.1-0.1,0.2,0,0.3l5.1,5.4c0.1,0.1,0.2,0.1,0.3,0c0,0,0,0,0,0L7.4,12l0,0l7.9-7.4C15.4,4.5,15.4,4.3,15.3,4.2C15.3,4.2,15.3,4.2,15.3,4.2z" })),
389
+ 'check-circle': () => (index.h("path", { fill: "currentColor", d: "M15.33 8A7.33 7.33 0 1 1 8 .67 7.33 7.33 0 0 1 15.33 8Zm-8.18 3.88 5.44-5.44a.46.46 0 0 0 0-.65l-.67-.67a.48.48 0 0 0-.67 0L6.82 9.54 4.75 7.47a.46.46 0 0 0-.65 0l-.67.67a.46.46 0 0 0 0 .65l3.07 3.07a.46.46 0 0 0 .65 0Z" })),
390
+ 'chevron-down': () => (index.h("path", { fill: "currentColor", d: "M7.43,12.21.9,5.69a.81.81,0,0,1,0-1.14h0l.76-.77a.81.81,0,0,1,1.14,0L8,9l5.2-5.18a.81.81,0,0,1,1.14,0l.76.77a.8.8,0,0,1,0,1.13h0L8.57,12.21a.79.79,0,0,1-1.13,0Z" })),
391
+ 'chevron-left': () => (index.h("path", { fill: "currentColor", d: "M3.79,7.43,10.31.9a.81.81,0,0,1,1.14,0h0l.77.76a.81.81,0,0,1,0,1.14L7,8l5.18,5.2a.81.81,0,0,1,0,1.14l-.77.76a.8.8,0,0,1-1.13,0h0L3.79,8.57a.79.79,0,0,1,0-1.13Z" })),
392
+ 'chevron-right': () => (index.h("path", { fill: "currentColor", d: "M12.21,8.57,5.69,15.1a.81.81,0,0,1-1.14,0h0l-.77-.76a.81.81,0,0,1,0-1.14L9,8,3.78,2.8a.81.81,0,0,1,0-1.14L4.55.9A.8.8,0,0,1,5.68.9h0l6.53,6.53a.79.79,0,0,1,0,1.13Z" })),
393
+ 'chevron-up': () => (index.h("path", { fill: "currentColor", d: "M8.57,3.79l6.53,6.52a.81.81,0,0,1,0,1.14h0l-.76.77a.81.81,0,0,1-1.14,0L8,7,2.8,12.22a.81.81,0,0,1-1.14,0L.9,11.45a.8.8,0,0,1,0-1.13h0L7.43,3.79a.79.79,0,0,1,1.13,0Z" })),
394
+ 'cross': () => (index.h("path", { fill: "currentColor", d: "M14.26 12.74 9.52 8l4.7-4.7a.29.29 0 0 0 0-.41l-1.1-1.1a.29.29 0 0 0-.41 0L8 6.48 3.26 1.74a.24.24 0 0 0-.34 0L1.74 2.91a.24.24 0 0 0 0 .34L6.48 8l-4.7 4.7a.29.29 0 0 0 0 .41l1.1 1.1a.29.29 0 0 0 .41 0L8 9.52l4.74 4.74a.24.24 0 0 0 .34 0l1.17-1.17a.24.24 0 0 0 0-.34Z" })),
395
+ 'cross-circle': () => (index.h("path", { fill: "currentColor", d: "M8.06.67H8A7.33 7.33 0 0 0 .68 8v.1a7.42 7.42 0 0 0 7.23 7.23A7.33 7.33 0 1 0 8.06.67Zm3.6 9.57a.28.28 0 0 1 0 .4l-.19.2-.61.61-.2.19a.27.27 0 0 1-.39 0L8 9.41l-2.23 2.24a.27.27 0 0 1-.39 0l-.2-.2-.6-.6-.19-.2a.28.28 0 0 1 0-.4L6.6 8 4.36 5.76a.28.28 0 0 1 0-.4l1-1a.28.28 0 0 1 .4 0L8 6.59l2.24-2.24a.28.28 0 0 1 .4 0l.2.2.6.6.2.2a.28.28 0 0 1 0 .4L9.42 8Z" })),
396
+ 'download': () => (index.h("path", { fill: "currentColor", d: "M6.44,2V6.09a.31.31,0,0,1-.31.31H4a.31.31,0,0,0-.31.29.33.33,0,0,0,.1.23l4,4a.29.29,0,0,0,.41,0h0l4-4a.3.3,0,0,0,0-.42A.29.29,0,0,0,12,6.4H9.91a.31.31,0,0,1-.31-.31h0V2a.29.29,0,0,0-.28-.3H6.74a.29.29,0,0,0-.3.28ZM1.69,13v1a.29.29,0,0,0,.29.29H14a.29.29,0,0,0,.29-.29V13a.29.29,0,0,0-.28-.3H2a.29.29,0,0,0-.33.25Z" })),
397
+ 'exclamation-circle': () => (index.h("path", { fill: "currentColor", d: "M8 15.33A7.33 7.33 0 1 0 .67 8 7.33 7.33 0 0 0 8 15.33ZM7 4a.29.29 0 0 1 .3-.3h1.35A.29.29 0 0 1 9 4v4.68a.29.29 0 0 1-.28.3H7.35a.29.29 0 0 1-.3-.28Zm0 6.78a.29.29 0 0 1 .3-.3h1.35a.29.29 0 0 1 .3.3H9V12a.29.29 0 0 1-.28.3H7.35a.29.29 0 0 1-.3-.28Z" })),
398
+ 'exclamation-triangle': () => (index.h("path", { fill: "currentColor", d: "m14.28 13.87-6-12a.32.32 0 0 0-.41-.15.36.36 0 0 0-.15.15l-6 12a.31.31 0 0 0 .14.42.33.33 0 0 0 .14 0h12a.3.3 0 0 0 .33-.28.31.31 0 0 0-.05-.14ZM7 6a.29.29 0 0 1 .28-.28h1.44A.28.28 0 0 1 9 6v4a.28.28 0 0 1-.28.29H7.28A.29.29 0 0 1 7 10Zm2 7a.31.31 0 0 1-.3.32H7.32A.32.32 0 0 1 7 13v-1.38a.31.31 0 0 1 .31-.31h1.4a.31.31 0 0 1 .31.31H9Z" })),
399
+ 'file-cog': () => (index.h("path", { fill: "currentColor", d: "M9,10.1C9,10.6,8.5,11,8,11l0,0c-0.6,0-1-0.4-1-1c0-0.6,0.4-1,1-1C8.6,9,9,9.4,9,10.1C9,10,9,10,9,10.1z M13.2,3.7l-2.8-2.8c-0.1-0.1-0.3-0.2-0.5-0.2H9.8v3.7h3.5V4.2C13.3,4,13.2,3.8,13.2,3.7L13.2,3.7z M9.6,5.3h3.8v9.4 c0,0.4-0.3,0.6-0.7,0.7H3.3c-0.4,0-0.7-0.3-0.7-0.7c0,0,0,0,0,0V1.3C2.7,1,3,0.7,3.3,0.7h5.5v3.9l0,0C8.9,4.9,9.2,5.2,9.6,5.3 C9.5,5.2,9.5,5.2,9.6,5.3z M10,8L9.5,8.3C9.3,8.1,9,8,8.8,7.9V7.3c0-0.1,0-0.1-0.1-0.1c-0.4-0.1-0.9-0.1-1.3,0 c-0.1,0-0.1,0.1-0.1,0.1v0.6C7,8,6.7,8.1,6.5,8.3L6,8C5.9,8,5.9,8,5.8,8C5.5,8.3,5.3,8.7,5.2,9.1c0,0.1,0,0.1,0.1,0.2l0.5,0.3 c-0.1,0.3-0.1,0.6,0,0.8l-0.5,0.3c-0.1,0-0.1,0.1-0.1,0.2c0.1,0.4,0.4,0.8,0.7,1.1c0.1,0,0.1,0,0.2,0l0.5-0.3 C6.7,11.9,7,12,7.2,12.1v0.6c0,0.1,0,0.1,0.1,0.1c0.4,0.1,0.9,0.1,1.3,0c0.1,0,0.1-0.1,0.1-0.1v-0.5C9,12.1,9.3,12,9.5,11.8l0.5,0.3 c0.1,0,0.1,0,0.2,0c0.3-0.3,0.5-0.7,0.6-1.1c0-0.1,0-0.1-0.1-0.2l0,0l-0.5-0.3c0-0.3,0-0.6,0-0.8l0.5-0.3c0.1,0,0.1-0.1,0.1-0.2 c-0.1-0.4-0.4-0.8-0.6-1.1C10.1,8,10.1,8,10,8z" })),
400
+ 'file-text': () => (index.h("path", { fill: "currentColor", d: "M8.9 4.6V.7H3.3c-.3 0-.6.3-.6.6v13.3c0 .4.3.7.7.7h9.3c.4 0 .7-.3.7-.7V5.3H9.6c-.4-.1-.7-.4-.7-.7zm1.8 6.7c0 .2-.2.3-.3.4H5.7c-.2 0-.3-.2-.3-.4v-.2c0-.2.2-.3.3-.3h4.6c.2 0 .3.2.3.3v.2zm0-1.8c0 .2-.2.3-.3.3H5.7c-.2 0-.3-.2-.3-.3v-.2c0-.2.2-.3.3-.3h4.6c.2 0 .3.2.3.3v.2zm0-2.1v.2c0 .2-.2.3-.3.3H5.7c-.2.1-.4-.1-.4-.2v-.3c0-.2.2-.3.3-.3h4.6c.3 0 .5.1.5.3zm2.6-3.2v.2H9.8V.7h.2c.2 0 .3.1.5.2l2.7 2.8c0 .1.1.3.1.5z" })),
401
+ 'file-upload': () => [
402
+ index.h("path", { fill: "currentColor", d: "M13.1 3.7 10.4.9c-.1-.1-.3-.2-.5-.2h-.1v3.7h3.5v-.2c0-.2-.1-.4-.2-.5z" }),
403
+ index.h("path", { fill: "currentColor", d: "M13.3 14.6V5.3H9.6c-.4 0-.7-.3-.7-.7V.7H3.3c-.3 0-.6.3-.6.6v13.3c0 .4.3.7.7.7h9.3c.3 0 .6-.3.6-.7zm-3-4.6H8.9c-.1 0-.2.1-.2.2v2.6c0 .1-.1.2-.2.2H6.9c-.1 0-.2-.1-.2-.2v-2.6c0-.1-.1-.2-.2-.2H5.1C5 9.9 5 9.8 5 9.7l2.5-2.6c.1-.1.2-.1.3 0l2.5 2.5.1.1c.1.2 0 .3-.1.3z" }),
404
+ ],
405
+ 'floppy-disk': () => (index.h("path", { fill: "currentColor", d: "m13.94 4.44-2.38-2.38a1.39 1.39 0 0 0-1-.39H3A1.35 1.35 0 0 0 1.67 3v10A1.35 1.35 0 0 0 3 14.33h10A1.35 1.35 0 0 0 14.33 13V5.4a1.39 1.39 0 0 0-.39-1ZM8 12.52a1.81 1.81 0 1 1 1.81-1.81A1.81 1.81 0 0 1 8 12.52Zm2.71-8.6v2.84a.34.34 0 0 1-.34.34H3.82a.34.34 0 0 1-.34-.34V3.82a.34.34 0 0 1 .34-.34h6.46a.35.35 0 0 1 .24.1l.1.1a.35.35 0 0 1 .1.24Z" })),
406
+ 'info-circle': () => (index.h("path", { fill: "currentColor", d: "M8 .67A7.33 7.33 0 1 0 15.33 8 7.33 7.33 0 0 0 8 .67ZM9 12a.29.29 0 0 1-.3.3H7.35a.29.29 0 0 1-.3-.3V7.32A.29.29 0 0 1 7.33 7h1.32a.29.29 0 0 1 .35.3Zm0-6.74a.29.29 0 0 1-.3.3H7.35a.29.29 0 0 1-.3-.3V4a.29.29 0 0 1 .28-.3h1.32a.29.29 0 0 1 .3.28V4Z" })),
407
+ 'loader': () => [
408
+ index.h("path", { fill: "currentColor", class: "loader__full-circle", d: "M8 2.67A5.33 5.33 0 1 1 2.67 8 5.33 5.33 0 0 1 8 2.67m0-2A7.33 7.33 0 1 0 15.33 8 7.33 7.33 0 0 0 8 .67Z" }),
409
+ index.h("path", { fill: "currentColor", d: "M8 2.67v-2A7.33 7.33 0 0 0 .67 8h2A5.33 5.33 0 0 1 8 2.67Z" }),
410
+ ],
411
+ 'log-in': () => (index.h("path", { fill: "currentColor", d: "M10.97,7.78h0L6.97,3.78c-.12-.12-.31-.12-.42,0h0c-.07,.06-.12,.15-.13,.24v2.07c0,.17-.13,.3-.3,.32H1.97c-.16,0-.29,.12-.3,.28h0v2.58c0,.16,.12,.29,.28,.3H6.11c.17,0,.3,.14,.3,.31v2.14c0,.16,.12,.29,.28,.3h0c.11,.01,.21-.03,.28-.11l4-4c.11-.12,.11-.3,0-.42Zm3.37,5.26h0v1c0,.16-.13,.28-.28,.28h-4.77c-.16,0-.28-.13-.28-.28v-1c0-.16,.13-.28,.28-.28h3.43V3.3h-3.42c-.16,0-.29-.13-.29-.29V1.97c0-.16,.13-.29,.29-.29h4.76c.16,0,.29,.13,.29,.29v.68h0V13.04Z" })),
412
+ 'log-out': () => [
413
+ index.h("path", { fill: "currentColor", d: "M14.25,7.77h0l-4-4a.31.31,0,0,0-.43,0A.34.34,0,0,0,9.7,4V6.07a.32.32,0,0,1-.3.32H5.23a.3.3,0,0,0-.3.3V9.25a.3.3,0,0,0,.3.3H9.4a.31.31,0,0,1,.3.31V12a.3.3,0,0,0,.3.3.33.33,0,0,0,.23-.09l4-4A.29.29,0,0,0,14.25,7.77Z" }),
414
+ index.h("path", { fill: "currentColor", d: "M6.71,12.72H3.27V3.26H6.69A.31.31,0,0,0,7,3V2a.3.3,0,0,0-.31-.3H2A.29.29,0,0,0,1.67,2h0V3h0V14a.27.27,0,0,0,.1.24h0a.32.32,0,0,0,.14.08H6.71A.3.3,0,0,0,7,14V13A.3.3,0,0,0,6.71,12.72Z" }),
415
+ ],
416
+ 'magnifying-glass': () => (index.h("path", { fill: "currentColor", d: "M11.24,9.52A5.17,5.17,0,0,0,9.51,2.41l-.17-.09A5.18,5.18,0,0,0,4,11.18a5.16,5.16,0,0,0,5.54.11L12.3,14a1,1,0,0,0,1.41,0l.33-.33a1,1,0,0,0,0-1.41Zm-4.4.5A3.19,3.19,0,1,1,10,6.8v.06A3.19,3.19,0,0,1,6.84,10Z" })),
417
+ 'paper-plane': () => (index.h("path", { fill: "currentColor", d: "M14 1.69 1.84 7a.28.28 0 0 0-.15.36.29.29 0 0 0 .16.15l3.27 1.82a.57.57 0 0 0 .61-.06l6.45-5.57c.05 0 .15-.1.19-.06s0 .14-.06.18l-5.59 6.29a.52.52 0 0 0 0 .63l2.09 3.44a.28.28 0 0 0 .37.12.3.3 0 0 0 .13-.12l5-12.11a.3.3 0 0 0-.14-.37.28.28 0 0 0-.17-.01Z" })),
418
+ 'paper-plane-slash': () => (index.h("path", { fill: "currentColor", d: "M2.67,1.69,14.26,13.28l-1,1-2.79-2.8-1.1,2.67a.3.3,0,0,1-.13.12.28.28,0,0,1-.37-.12L6.75,10.74a.52.52,0,0,1,0-.63L7.82,8.9l-.76-.76L5.76,9.27a.57.57,0,0,1-.61.06L1.88,7.51a.29.29,0,0,1-.16-.15A.28.28,0,0,1,1.87,7L4.68,5.76l-3-3Zm11.53,0a.28.28,0,0,0-.22,0L7.53,4.51,9.26,6.24l3-2.54s.15-.1.19-.06,0,.14-.06.18L9.75,6.73l1.88,1.88,2.71-6.54A.3.3,0,0,0,14.2,1.7Z" })),
419
+ 'pen': () => (index.h("path", { fill: "currentColor", d: "M1.67,11.69v2.64h2.64l7.78-7.78-2.64-2.64L1.67,11.69ZM14.13,4.51c.27-.28,.27-.72,0-1h0l-1.65-1.64c-.28-.27-.72-.27-1,0h0l-1.28,1.29,2.64,2.64,1.29-1.29Z" })),
420
+ 'pen-fancy': () => (index.h("path", { fill: "currentColor", d: "M3.63,8.65c-.24,.07-.43,.26-.5,.5l-1.46,4.37,.11,.12,2.3-2.3c0-.06,0-.13,0-.19,0-.44,.35-.8,.79-.81,.44,0,.8,.35,.81,.79,0,.44-.35,.8-.79,.81,0,0-.01,0-.02,0h-.19l-2.3,2.3,.12,.11,4.37-1.46c.24-.07,.43-.26,.5-.5l.82-2.08-2.49-2.48-2.07,.82ZM10.8,2.35L6.27,7.28l2.42,2.42,4.94-4.52c2.1-1.86-.99-4.92-2.83-2.83Z" })),
421
+ 'plus-circle': () => (index.h("path", { fill: "currentColor", d: "M8,0.7C4,0.7,0.7,4,0.7,8S4,15.3,8,15.3S15.3,12,15.3,8l0,0C15.3,4,12,0.7,8,0.7 C8,0.7,8,0.7,8,0.7z M12.3,8.8c0,0.2-0.2,0.4-0.4,0.4H9.2v2.7c0,0.2-0.2,0.4-0.4,0.4H7.2c-0.2,0-0.4-0.2-0.3-0.4V9.2H4.1 C3.9,9.2,3.7,9,3.7,8.8V7.2c0-0.2,0.2-0.4,0.4-0.3h2.7V4.1c0-0.2,0.2-0.4,0.3-0.4h1.7c0.2,0,0.4,0.2,0.4,0.4v2.7h2.7 c0.2,0,0.4,0.2,0.4,0.3L12.3,8.8z" })),
422
+ 'trash': () => [
423
+ index.h("path", { fill: "currentColor", d: "M11.5,14.8h-7 c-0.6,0-1.1-0.5-1.1-1.1V4.4h9.3v9.2C12.6,14.2,12.1,14.8,11.5,14.8 M6.9,6.8c0-0.3-0.3-0.6-0.6-0.6S5.8,6.5,5.8,6.8v5.2 c0,0.3,0.3,0.6,0.6,0.6s0.6-0.3,0.6-0.6V6.8z M10.3,6.8c0-0.3-0.3-0.6-0.6-0.6S9.2,6.5,9.2,6.8v5.2c0,0.3,0.3,0.6,0.6,0.6 s0.6-0.3,0.6-0.6V6.8z" }),
424
+ index.h("path", { fill: "currentColor", d: "M13,2h-2.9L9.9,1.6 C9.8,1.4,9.6,1.2,9.4,1.2H6.6c-0.2,0-0.4,0.1-0.5,0.3L5.8,2H2.9C2.7,2,2.5,2.2,2.5,2.4c0,0,0,0,0,0v0.8c0,0.2,0.2,0.4,0.4,0.4H13 c0.2,0,0.4-0.2,0.4-0.4V2.4C13.4,2.2,13.2,2,13,2z" }),
425
+ ],
426
+ 'user-plus': () => (index.h("path", { fill: "currentColor", d: "M14,3.33H12.65V2a.36.36,0,0,0-.35-.33h-.65A.36.36,0,0,0,11.3,2V3.33H10a.34.34,0,0,0-.33.34v.66a.34.34,0,0,0,.33.34H11.3V6a.37.37,0,0,0,.35.33h.65A.37.37,0,0,0,12.65,6V4.67H14a.34.34,0,0,0,.32-.34V3.67A.34.34,0,0,0,14,3.33ZM9.28,9.77h-.2a5.19,5.19,0,0,1-3.91,0H5A3,3,0,0,0,1.7,12.46h0v.72A1.27,1.27,0,0,0,3,14.33h8.25a1.26,1.26,0,0,0,1.36-1.14v-.68A3,3,0,0,0,9.37,9.76H9.28ZM7.13,3.7A2.64,2.64,0,1,1,4.5,6.34h0A2.64,2.64,0,0,1,7.13,3.7Z" })),
427
+ 'users': () => (index.h("path", { fill: "currentColor", d: "M12,8.76h-.2a5.24,5.24,0,0,1-3.93,0H7.61a3.05,3.05,0,0,0-3.3,2.75v.69a1.28,1.28,0,0,0,1.38,1.14H14a1.27,1.27,0,0,0,1.37-1.14v-.69A3.07,3.07,0,0,0,12,8.75Zm-6.4-.32A2,2,0,0,0,4.31,8H2.48A1.69,1.69,0,0,0,.65,9.53v.76a.85.85,0,0,0,.91.76H3.45A3.58,3.58,0,0,1,5.61,8.44ZM9.81,2.66A2.65,2.65,0,1,1,7.16,5.31h0A2.65,2.65,0,0,1,9.81,2.66ZM3.31,4.18A1.51,1.51,0,1,1,1.8,5.69,1.51,1.51,0,0,1,3.31,4.18Z" })),
428
+ };
429
+ /**
430
+ * List of all possibles sizes
431
+ */
432
+ const sizes$1 = ['regular', 'large', 'extra-large'];
433
+ /**
434
+ * List of all possibles variants
435
+ */
436
+ const variants$2 = ['success', 'warning', 'danger', 'info'];
437
+
438
+ const mgIconCss = ":host{display:-ms-inline-flexbox;display:inline-flex;vertical-align:middle}.mg-icon[size=regular],.mg-icon.mg-icon--size-regular{width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size)}.mg-icon[size=large],.mg-icon.mg-icon--size-large{width:var(--mg-icon-large-size);height:var(--mg-icon-large-size)}.mg-icon[size=extra-large],.mg-icon.mg-icon--size-extra-large{width:var(--mg-icon-extra-large-size);height:var(--mg-icon-extra-large-size)}.mg-icon[class*=mg-icon--variant-]{border-radius:var(--mg-message-border-radius);padding:0.3rem}.mg-icon.mg-icon--variant-success{background-color:hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) + 20%))}.mg-icon.mg-icon--variant-warning{background-color:hsl(var(--color-warning-h), var(--color-warning-s), calc(var(--color-warning-l) + 20%))}.mg-icon.mg-icon--variant-danger{background-color:hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) + 20%))}.mg-icon.mg-icon--variant-info{background-color:hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) + 20%))}.loader__full-circle{opacity:0.2}.mg-icon--spin{-webkit-animation-name:rotate;animation-name:rotate;-webkit-animation-duration:0.75s;animation-duration:0.75s;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite}@-webkit-keyframes rotate{to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotate{to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}";
439
+
440
+ const MgIcon = class {
441
+ constructor(hostRef) {
442
+ index.registerInstance(this, hostRef);
443
+ /**
444
+ * Define icon size
445
+ */
446
+ this.size = 'regular';
447
+ /**
448
+ * Make the icon spin
449
+ */
450
+ this.spin = false;
451
+ /**
452
+ * Component classes
453
+ */
454
+ this.classList = new index$1.ClassList(['mg-icon']);
455
+ /**
456
+ * getIcon
457
+ *
458
+ * @returns {HTMLElement} icon html
459
+ */
460
+ this.getIcon = () => icons[this.icon]();
461
+ }
462
+ validateIcon(newValue) {
463
+ if (!Object.keys(icons).includes(newValue)) {
464
+ throw new Error(`<mg-icon> prop "icon" must be one of : ${Object.keys(icons).join(', ')}`);
465
+ }
466
+ this.classList.add(`mg-icon--${this.icon}`);
467
+ }
468
+ validateSize(newValue) {
469
+ if (!sizes$1.includes(newValue)) {
470
+ throw new Error(`<mg-icon> prop "size" must be one of : ${sizes$1.join(', ')}`);
471
+ }
472
+ this.classList.add(`mg-icon--size-${this.size}`);
473
+ }
474
+ validateVariant(newValue) {
475
+ if (newValue !== undefined && !variants$2.includes(newValue)) {
476
+ throw new Error(`<mg-icon> prop "variant" must be one of : ${variants$2.join(', ')}`);
477
+ }
478
+ else if (newValue !== undefined) {
479
+ this.classList.add(`mg-icon--variant-${this.variant}`);
480
+ }
481
+ }
482
+ handleSpin(newValue) {
483
+ if (newValue) {
484
+ this.classList.add('mg-icon--spin');
485
+ }
486
+ }
487
+ /**
488
+ * Check if props are well configured on init
489
+ *
490
+ * @returns {void}
491
+ */
492
+ componentWillLoad() {
493
+ this.validateIcon(this.icon);
494
+ this.validateSize(this.size);
495
+ this.validateVariant(this.variant);
496
+ this.handleSpin(this.spin);
497
+ }
498
+ /**
499
+ * Render component
500
+ *
501
+ * @returns {HTMLElement} HTML Element
502
+ */
503
+ render() {
504
+ return (index.h("svg", { class: this.classList.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
505
+ }
506
+ static get watchers() { return {
507
+ "icon": ["validateIcon"],
508
+ "size": ["validateSize"],
509
+ "variant": ["validateVariant"],
510
+ "spin": ["handleSpin"]
511
+ }; }
512
+ };
513
+ MgIcon.style = mgIconCss;
514
+
515
+ /**
516
+ * Possible input classes
517
+ */
518
+ var InputClass;
519
+ (function (InputClass) {
520
+ InputClass["ERROR"] = "is-not-valid";
521
+ })(InputClass || (InputClass = {}));
522
+
523
+ /**
524
+ * Apply in all input child node the aria-describedby attribute
525
+ *
526
+ * @param {VNode[]} children Represent scoped elements
527
+ * @param {Set<string>} ariaDescribedbyIDs List of IDs
528
+ * @param {FunctionalUtilities} utils Stencil.js utils
529
+ * @returns {VNode[]} Children with aria-describedby attribute
530
+ */
531
+ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
532
+ if (['input', 'select', 'textarea'].includes(child.vtag)) {
533
+ return Object.assign(Object.assign({}, child), { vattrs: Object.assign(Object.assign({}, child.vattrs), { 'aria-describedby': [...ariaDescribedbyIDs].join(' ') }) });
534
+ }
535
+ // we recursively apply ariadescribedBy attributes to child input nodes if exists
536
+ if (child.vchildren === null)
537
+ return Object.assign({}, child);
538
+ return Object.assign(Object.assign({}, child), { vchildren: applyAriadescribedBy(child.vchildren, ariaDescribedbyIDs, utils) });
539
+ });
540
+ /**
541
+ * Add classes based on props
542
+ *
543
+ * @param {MgInputProps} props MgInput Interface Props
544
+ */
545
+ const manageClasses = (props) => {
546
+ props.classList.add('mg-input');
547
+ if (props.labelOnTop)
548
+ props.classList.add('mg-input--label-on-top');
549
+ if (props.readonly)
550
+ props.classList.add('mg-input--readonly');
551
+ if (props.width !== undefined)
552
+ props.classList.add(`mg-input--width-${props.width}`);
553
+ if (props.readonly || props.disabled) {
554
+ props.classList.delete(InputClass.ERROR);
555
+ }
556
+ };
557
+ /**
558
+ * Get tagname
559
+ *
560
+ * @param {boolean} isFieldset is fieldset
561
+ * @returns {string} tag name
562
+ */
563
+ const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
564
+ /**
565
+ * Get input template
566
+ *
567
+ * @param {MgInputProps} props MgInput Interface Props
568
+ * @param {VNode[]} children Represent scoped elements
569
+ * @param {FunctionalUtilities} utils Stencil.js utils
570
+ * @returns {VNode[]} input template
571
+ */
572
+ const MgInput = (props, children, utils) => {
573
+ /**
574
+ * Check required properties
575
+ */
576
+ if (typeof props.label !== 'string' || props.label === '') {
577
+ throw new Error('<mg-input> prop "label" is required');
578
+ }
579
+ if (props.labelOnTop && props.labelHide) {
580
+ throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide"');
581
+ }
582
+ /**
583
+ * Component classes
584
+ */
585
+ manageClasses(props);
586
+ /**
587
+ * a11y IDs
588
+ */
589
+ const ariaDescribedbyIDs = new Set();
590
+ // Character Left
591
+ const characterLeftId = `${props.identifier}-character-left`;
592
+ if (props.classList.has('is-focused') && props.displayCharacterLeft) {
593
+ ariaDescribedbyIDs.add(characterLeftId);
594
+ }
595
+ // Help text
596
+ const helpTextId = `${props.identifier}-help-text`;
597
+ if (typeof props.helpText === 'string' && props.helpText !== '') {
598
+ ariaDescribedbyIDs.add(helpTextId);
599
+ }
600
+ // Error Message
601
+ const helpTextErrorId = `${props.identifier}-error`;
602
+ if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {
603
+ ariaDescribedbyIDs.add(helpTextErrorId);
604
+ }
605
+ /**
606
+ * Update input(s) in children
607
+ */
608
+ if (props.readonly) {
609
+ children = children.filter(child => child.$name$ === 'append-input');
610
+ }
611
+ else {
612
+ children = applyAriadescribedBy(children, ariaDescribedbyIDs, utils);
613
+ }
614
+ /**
615
+ * Return template
616
+ *
617
+ * +--------+--------------+---------+
618
+ * | label | input | tooltip |
619
+ * | +--------------+---------+
620
+ * | | nb Char Left |
621
+ * | +------------------------+
622
+ * | | Help Text |
623
+ * | +------------------------+
624
+ * | | Error |
625
+ * +--------+------------------------+
626
+ *
627
+ * Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change
628
+ */
629
+ const TagName = getTagName(props.isFieldset);
630
+ /**
631
+ * Get tooltip node
632
+ *
633
+ * @returns {VNode[]} mg-tooltip
634
+ */
635
+ const getTooltip = () => (index.h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
636
+ index.h("mg-icon", { icon: "info-circle" })));
637
+ /**
638
+ * Get input title (label) node
639
+ *
640
+ * @returns {VNode[]} mg-input-title
641
+ */
642
+ const getInputTitle = () => (index.h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled, "is-legend": props.isFieldset }, props.label));
643
+ return (index.h(TagName, { class: props.classList.join() },
644
+ props.labelOnTop ? (index.h("div", { class: "mg-input__title" },
645
+ getInputTitle(),
646
+ !props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
647
+ props.readonly ? (index.h("div", { class: "mg-input__input-container" },
648
+ index.h("strong", null, props.readonlyValue || props.value),
649
+ children)) : (index.h("div", { class: "mg-input__input-container" },
650
+ index.h("div", { class: "mg-input__input" },
651
+ children,
652
+ !props.labelOnTop && props.tooltip && getTooltip()),
653
+ props.displayCharacterLeft && props.maxlength && props.classList.has('is-focused') && (index.h("mg-character-left", { identifier: characterLeftId, characters: props.value, maxlength: props.maxlength, template: props.characterLeftTemplate })),
654
+ props.helpText && index.h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }),
655
+ props.errorMessage && index.h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" })))));
656
+ };
657
+
658
+ const mgInputCheckboxCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:-ms-inline-flexbox;display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:-ms-inline-flexbox;display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}fieldset.mg-input{border:0;margin-left:0;margin-right:0;padding:0}fieldset.mg-input input[type=radio],fieldset.mg-input input[type=checkbox]{-ms-flex-negative:0;flex-shrink:0;width:var(--mg-input-check-size);height:var(--mg-input-check-size);margin-top:calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);margin-right:0.6rem;margin-bottom:0;margin-left:0}fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container{margin-top:0.7rem}fieldset.mg-input.is-not-valid .mg-input__input-group{color:initial}.mg-input__input-container mg-tooltip{margin-left:2rem}.mg-input__input-group-container{margin:0;padding:0;list-style:none;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-column-gap:2.3rem;-moz-column-gap:2.3rem;column-gap:2.3rem;row-gap:1rem;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2)}.mg-input__input-group-container--vertical{-ms-flex-direction:column;flex-direction:column}.mg-input__input-group{display:-ms-flexbox;display:flex;-ms-flex-align:top;align-items:top}.mg-input__input-group.mg-input__input-group--disabled label{opacity:0.3}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}";
659
+
660
+ /**
661
+ * type CheckboxItem validation function
662
+ *
663
+ * @param {CheckboxItem} item Checkbox item
664
+ * @returns {boolean} match item expectations
665
+ */
666
+ const isCheckboxItem = (item) => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined;
667
+ const MgInputCheckbox = class {
668
+ constructor(hostRef) {
669
+ index.registerInstance(this, hostRef);
670
+ this.valueChange = index.createEvent(this, "value-change", 7);
671
+ this.inputValid = index.createEvent(this, "input-valid", 7);
672
+ /************
673
+ * Internal *
674
+ ************/
675
+ // classes
676
+ this.classError = InputClass.ERROR;
677
+ // HTML selector
678
+ this.inputs = [];
679
+ /**
680
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
681
+ * If not set, it will be created.
682
+ */
683
+ this.identifier = index$1.createID('mg-input-checkbox');
684
+ /**
685
+ * Input name
686
+ * If not set the value equals the identifier
687
+ */
688
+ this.name = this.identifier;
689
+ /**
690
+ * Define if label is visible
691
+ */
692
+ this.labelHide = false;
693
+ /**
694
+ * Define if inputs are display verticaly
695
+ */
696
+ this.inputVerticalList = false;
697
+ /**
698
+ * Define if input is required
699
+ */
700
+ this.required = false;
701
+ /**
702
+ * Define if input is readonly
703
+ */
704
+ this.readonly = false;
705
+ /**
706
+ * Define if input is disabled
707
+ */
708
+ this.disabled = false;
709
+ /**
710
+ * Component classes
711
+ */
712
+ this.classList = new index$1.ClassList(['mg-input--checkbox']);
713
+ /**
714
+ * Formated value for display
715
+ */
716
+ this.checkboxItems = [];
717
+ /**
718
+ * Handle input event
719
+ *
720
+ * @param {InputEvent} event input event
721
+ */
722
+ this.handleInput = (event) => {
723
+ this.checkboxItems = this.checkboxItems.map(item => {
724
+ if (item.id === event.target.id) {
725
+ item.value = Boolean(event.target.checked);
726
+ }
727
+ return item;
728
+ });
729
+ this.value = this.checkboxItems.map(o => ({ value: o.value, title: o.title, disabled: o.disabled }));
730
+ this.checkValidity();
731
+ };
732
+ /**
733
+ * Handle blur event
734
+ */
735
+ this.handleBlur = () => {
736
+ // Check validity
737
+ this.checkValidity();
738
+ this.checkError();
739
+ };
740
+ /**
741
+ * Check if input is valid
742
+ */
743
+ this.checkValidity = () => {
744
+ if (!this.readonly) {
745
+ const validity = this.getInvalidElement() === undefined;
746
+ // Set validity
747
+ this.valid = validity;
748
+ this.invalid = !validity;
749
+ //Send event
750
+ this.inputValid.emit(validity);
751
+ }
752
+ };
753
+ /**
754
+ * Check input errors
755
+ */
756
+ this.checkError = () => {
757
+ const invalidElement = this.getInvalidElement();
758
+ // Set error message
759
+ this.errorMessage = undefined;
760
+ if (!this.valid && invalidElement.validity.valueMissing) {
761
+ this.errorMessage = index$1.messages.errors.required;
762
+ }
763
+ // Update class
764
+ if (this.valid) {
765
+ this.classList.delete(this.classError);
766
+ }
767
+ else {
768
+ this.classList.add(this.classError);
769
+ }
770
+ };
771
+ /**
772
+ * get invalid element
773
+ *
774
+ * @returns {HTMLInputElement} element
775
+ */
776
+ this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
777
+ }
778
+ validateValue(newValue) {
779
+ if (newValue && newValue.every(item => isCheckboxItem(item))) {
780
+ this.checkboxItems = newValue.map((item, index) => ({
781
+ id: `${this.identifier}_${index.toString()}`,
782
+ title: item.title,
783
+ value: item.value,
784
+ disabled: item.disabled,
785
+ }));
786
+ this.valueChange.emit(newValue);
787
+ }
788
+ else {
789
+ throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
790
+ }
791
+ }
792
+ handleReadOnly() {
793
+ this.classList.delete(this.classError);
794
+ }
795
+ /**
796
+ * Public method to display errors
797
+ *
798
+ * @returns {Promise<void>}
799
+ */
800
+ async displayError() {
801
+ this.checkValidity();
802
+ this.checkError();
803
+ }
804
+ /*************
805
+ * Lifecycle *
806
+ *************/
807
+ /**
808
+ * Check if component props are well configured on init
809
+ *
810
+ * @returns {ReturnType<typeof setTimeout>} timeout
811
+ */
812
+ componentWillLoad() {
813
+ // Check values format
814
+ this.validateValue(this.value);
815
+ // Check validity when component is ready
816
+ // return a promise to process action only in the FIRST render().
817
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
818
+ return setTimeout(() => {
819
+ this.checkValidity();
820
+ }, 0);
821
+ }
822
+ /**
823
+ * Render
824
+ *
825
+ * @returns {HTMLElement} HTML Element
826
+ */
827
+ render() {
828
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: undefined, width: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
829
+ .filter(item => {
830
+ return !this.readonly || item.value;
831
+ })
832
+ .map(input => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => this.inputs.push(el) }), index.h("label", { htmlFor: input.id }, input.title)))))));
833
+ }
834
+ static get watchers() { return {
835
+ "value": ["validateValue"],
836
+ "readonly": ["handleReadOnly"]
837
+ }; }
838
+ };
839
+ MgInputCheckbox.style = mgInputCheckboxCss;
840
+
841
+ var InputError$1;
842
+ (function (InputError) {
843
+ InputError["MIN"] = "min";
844
+ InputError["MAX"] = "max";
845
+ InputError["MINMAX"] = "minMax";
846
+ InputError["REQUIRED"] = "required";
847
+ })(InputError$1 || (InputError$1 = {}));
848
+
849
+ /**
850
+ * Format number to the locale currency
851
+ *
852
+ * @param {number} number number to format
853
+ * @returns {string} formatted currency
854
+ */
855
+ function localeCurrency(number) {
856
+ return new Intl.NumberFormat(index$1.locale, { style: 'currency', currency: index$1.currency }).format(number);
857
+ }
858
+ /**
859
+ * Format number to locale
860
+ *
861
+ * @param {number} number number to format
862
+ * @returns {string} formatted number
863
+ */
864
+ function localeNumber(number) {
865
+ return new Intl.NumberFormat(index$1.locale).format(number);
866
+ }
867
+ /**
868
+ * Date RegExp
869
+ */
870
+ const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
871
+ /**
872
+ * Locale date format
873
+ *
874
+ * @param {string} date date to format
875
+ * @returns {string} formatted date
876
+ */
877
+ function localeDate(date) {
878
+ if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
879
+ return '';
880
+ }
881
+ return new Intl.DateTimeFormat(index$1.locale).format(new Date(date));
882
+ }
883
+
884
+ const mgInputDateCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:-ms-inline-flexbox;display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:-ms-inline-flexbox;display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0;--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius);--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}";
885
+
886
+ const MgInputDate = class {
887
+ constructor(hostRef) {
888
+ index.registerInstance(this, hostRef);
889
+ this.valueChange = index.createEvent(this, "value-change", 7);
890
+ this.inputValid = index.createEvent(this, "input-valid", 7);
891
+ /************
892
+ * Internal *
893
+ ************/
894
+ // classes
895
+ this.classError = InputClass.ERROR;
896
+ /**
897
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
898
+ * If not set, it will be created.
899
+ */
900
+ this.identifier = index$1.createID('mg-input-date');
901
+ /**
902
+ * Input name
903
+ * If not set the value equals the identifier
904
+ */
905
+ this.name = this.identifier;
906
+ /**
907
+ * Define if label is visible
908
+ */
909
+ this.labelHide = false;
910
+ /**
911
+ * Define if input is required
912
+ */
913
+ this.required = false;
914
+ /**
915
+ * Define if input is readonly
916
+ */
917
+ this.readonly = false;
918
+ /**
919
+ * Define if input is disabled
920
+ */
921
+ this.disabled = false;
922
+ /**
923
+ * Component classes
924
+ */
925
+ this.classList = new index$1.ClassList(['mg-input--date']);
926
+ /**
927
+ * Handle input event
928
+ */
929
+ this.handleInput = () => {
930
+ this.checkValidity();
931
+ this.value = this.input.value;
932
+ };
933
+ /**
934
+ * Handle blur event
935
+ */
936
+ this.handleBlur = () => {
937
+ this.checkValidity();
938
+ this.checkError();
939
+ };
940
+ /**
941
+ * Check if input is valid
942
+ */
943
+ this.checkValidity = () => {
944
+ if (!this.readonly && this.input !== undefined) {
945
+ const validity = this.input.checkValidity();
946
+ // Set validity
947
+ this.valid = validity;
948
+ this.invalid = !validity;
949
+ //Send event
950
+ this.inputValid.emit(validity);
951
+ }
952
+ };
953
+ /**
954
+ * get input error code
955
+ *
956
+ * @returns {null | InputError} error code
957
+ */
958
+ this.getInputError = () => {
959
+ var _a, _b;
960
+ let inputError = null;
961
+ // required
962
+ if (this.input.validity.valueMissing) {
963
+ inputError = InputError$1.REQUIRED;
964
+ }
965
+ // min & max
966
+ else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && ((_b = this.max) === null || _b === void 0 ? void 0 : _b.length) > 0) {
967
+ inputError = InputError$1.MINMAX;
968
+ }
969
+ // min
970
+ else if (this.input.validity.rangeUnderflow) {
971
+ inputError = InputError$1.MIN;
972
+ }
973
+ //max
974
+ else if (this.input.validity.rangeOverflow) {
975
+ inputError = InputError$1.MAX;
976
+ }
977
+ return inputError;
978
+ };
979
+ /**
980
+ * Set error message
981
+ *
982
+ * @returns {void}
983
+ */
984
+ this.setErrorMessage = () => {
985
+ var _a;
986
+ const inputError = this.getInputError();
987
+ // required
988
+ if (inputError === InputError$1.REQUIRED) {
989
+ this.errorMessage = index$1.messages.errors[inputError];
990
+ }
991
+ // min, max & minMax
992
+ else if ([InputError$1.MIN, InputError$1.MAX, InputError$1.MINMAX].includes(inputError)) {
993
+ this.errorMessage = index$1.messages.errors.date[inputError].replace('{min}', localeDate(this.min)).replace('{max}', localeDate(this.max));
994
+ }
995
+ // wrong date format
996
+ // element.validity.badInput is default error message
997
+ else {
998
+ this.errorMessage = index$1.messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min) : localeDate('1900-01-01'));
999
+ }
1000
+ };
1001
+ /**
1002
+ * Check input errors
1003
+ *
1004
+ * @returns {void}
1005
+ */
1006
+ this.checkError = () => {
1007
+ // Set error message
1008
+ this.errorMessage = undefined;
1009
+ if (!this.valid) {
1010
+ this.setErrorMessage();
1011
+ this.classList.add(this.classError);
1012
+ }
1013
+ else {
1014
+ this.classList.delete(this.classError);
1015
+ }
1016
+ };
1017
+ }
1018
+ validateValue(newValue) {
1019
+ if (newValue !== undefined && newValue !== '' && !(typeof newValue === 'string' && dateRegExp.test(newValue))) {
1020
+ throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
1021
+ }
1022
+ else {
1023
+ this.valueChange.emit(this.value);
1024
+ }
1025
+ }
1026
+ validateMin(newValue) {
1027
+ this.validateDateFormat(newValue);
1028
+ }
1029
+ validateMax(newValue) {
1030
+ this.validateDateFormat(newValue);
1031
+ }
1032
+ /**
1033
+ * Public method to display errors
1034
+ *
1035
+ * @returns {Promise<void>}
1036
+ */
1037
+ async displayError() {
1038
+ this.checkValidity();
1039
+ this.checkError();
1040
+ }
1041
+ /**
1042
+ * Date format validation
1043
+ *
1044
+ * @param {string} date date to validate
1045
+ * @returns {void}
1046
+ */
1047
+ validateDateFormat(date) {
1048
+ if ((date === null || date === void 0 ? void 0 : date.length) > 0 && !(typeof date === 'string' && dateRegExp.test(date))) {
1049
+ throw new Error("<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd");
1050
+ }
1051
+ }
1052
+ /*************
1053
+ * Lifecycle *
1054
+ *************/
1055
+ /**
1056
+ * Check if component props are well configured on init
1057
+ *
1058
+ * @returns {ReturnType<typeof setTimeout>} timeout
1059
+ */
1060
+ componentWillLoad() {
1061
+ this.validateValue(this.value);
1062
+ this.validateMin(this.min);
1063
+ this.validateMax(this.max);
1064
+ // Check validity when component is ready
1065
+ // return a promise to process action only in the FIRST render().
1066
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
1067
+ return setTimeout(() => {
1068
+ this.checkValidity();
1069
+ }, 0);
1070
+ }
1071
+ /**
1072
+ * Render
1073
+ *
1074
+ * @returns {HTMLElement} HTML Element
1075
+ */
1076
+ render() {
1077
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value), tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el => (this.input = el) })));
1078
+ }
1079
+ static get watchers() { return {
1080
+ "value": ["validateValue"],
1081
+ "min": ["validateMin"],
1082
+ "max": ["validateMax"]
1083
+ }; }
1084
+ };
1085
+ MgInputDate.style = mgInputDateCss;
1086
+
1087
+ /**
1088
+ * List of all possibles types
1089
+ */
1090
+ const types = ['decimal', 'integer', 'currency'];
1091
+ var InputError;
1092
+ (function (InputError) {
1093
+ InputError["MIN"] = "min";
1094
+ InputError["MAX"] = "max";
1095
+ InputError["MINMAX"] = "minMax";
1096
+ InputError["REQUIRED"] = "required";
1097
+ })(InputError || (InputError = {}));
1098
+
1099
+ const mgInputNumericCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:-ms-inline-flexbox;display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:-ms-inline-flexbox;display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0;--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius);--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){-ms-flex-pack:justify;justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{-ms-flex:auto;flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input .mg-input__box{text-align:right}";
1100
+
1101
+ const MgInputNumeric = class {
1102
+ constructor(hostRef) {
1103
+ index.registerInstance(this, hostRef);
1104
+ this.valueChange = index.createEvent(this, "value-change", 7);
1105
+ this.inputValid = index.createEvent(this, "input-valid", 7);
1106
+ // Classes
1107
+ this.classError = InputClass.ERROR;
1108
+ /**
1109
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1110
+ * If not set, it will be created.
1111
+ */
1112
+ this.identifier = index$1.createID('mg-input-numeric');
1113
+ /**
1114
+ * Input name
1115
+ * If not set the value equals the identifier
1116
+ */
1117
+ this.name = this.identifier;
1118
+ /**
1119
+ * Define if label is visible
1120
+ */
1121
+ this.labelHide = false;
1122
+ /**
1123
+ * Define if input is required
1124
+ */
1125
+ this.required = false;
1126
+ /**
1127
+ * Define if input is readonly
1128
+ */
1129
+ this.readonly = false;
1130
+ /**
1131
+ * Define if input is disabled
1132
+ */
1133
+ this.disabled = false;
1134
+ /**
1135
+ * Define numeric type
1136
+ */
1137
+ this.type = types[0];
1138
+ /**
1139
+ * Override integer length
1140
+ * integer is the number before the decimal point
1141
+ */
1142
+ this.integerLength = 13;
1143
+ /**
1144
+ * Override decimal length
1145
+ * decimal is the number after the decimal point
1146
+ */
1147
+ this.decimalLength = 2;
1148
+ /**
1149
+ * Component classes
1150
+ */
1151
+ this.classList = new index$1.ClassList(['mg-input--numeric']);
1152
+ /**
1153
+ * Define if input has focus
1154
+ */
1155
+ this.hasFocus = false;
1156
+ /**
1157
+ * Handle input event
1158
+ *
1159
+ * @returns {void}
1160
+ */
1161
+ this.handleInput = () => {
1162
+ // Check validity
1163
+ this.checkValidity();
1164
+ this.value = this.input.value;
1165
+ };
1166
+ /**
1167
+ * Handle focus event
1168
+ *
1169
+ * @returns {void}
1170
+ */
1171
+ this.handleFocus = () => {
1172
+ this.hasFocus = true;
1173
+ };
1174
+ /**
1175
+ * Handle blur event
1176
+ *
1177
+ * @returns {void}
1178
+ */
1179
+ this.handleBlur = () => {
1180
+ // Check validity
1181
+ this.checkValidity();
1182
+ this.checkError();
1183
+ this.hasFocus = false;
1184
+ };
1185
+ /**
1186
+ * Check if input is valid
1187
+ *
1188
+ * @returns {void}
1189
+ */
1190
+ this.checkValidity = () => {
1191
+ if (!this.readonly) {
1192
+ const validity = this.getInputError() === null;
1193
+ // Set validity
1194
+ this.valid = validity;
1195
+ this.invalid = !validity;
1196
+ //Send event
1197
+ this.inputValid.emit(validity);
1198
+ }
1199
+ };
1200
+ /**
1201
+ * Set error message
1202
+ *
1203
+ * @returns {void}
1204
+ */
1205
+ this.setErrorMessage = () => {
1206
+ const inputError = this.getInputError();
1207
+ if (inputError === InputError.REQUIRED) {
1208
+ this.errorMessage = index$1.messages.errors[inputError];
1209
+ }
1210
+ else {
1211
+ this.errorMessage = index$1.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
1212
+ }
1213
+ };
1214
+ /**
1215
+ * Check input errors
1216
+ *
1217
+ * @returns {void}
1218
+ */
1219
+ this.checkError = () => {
1220
+ // Set error message
1221
+ this.errorMessage = undefined;
1222
+ // Update class
1223
+ if (!this.valid) {
1224
+ this.setErrorMessage();
1225
+ this.classList.add(this.classError);
1226
+ }
1227
+ else {
1228
+ this.classList.delete(this.classError);
1229
+ }
1230
+ };
1231
+ /**
1232
+ * Get input error code
1233
+ *
1234
+ * @returns {null | InputError} error code
1235
+ */
1236
+ this.getInputError = () => {
1237
+ let inputError = null;
1238
+ if (this.input === undefined)
1239
+ return inputError;
1240
+ // required
1241
+ if (!this.input.checkValidity() && this.input.validity.valueMissing) {
1242
+ inputError = InputError.REQUIRED;
1243
+ }
1244
+ // Min & Max
1245
+ else if (this.min !== undefined && this.numericValue < this.min && this.max === undefined) {
1246
+ // Only a min value is set
1247
+ inputError = InputError.MIN;
1248
+ }
1249
+ else if (this.max !== undefined && this.numericValue > this.max && this.min === undefined) {
1250
+ // Only a max value is set
1251
+ inputError = InputError.MAX;
1252
+ }
1253
+ else if ((this.min !== undefined && this.numericValue < this.min) || (this.max !== undefined && this.numericValue > this.max)) {
1254
+ // both min and max values are set
1255
+ inputError = InputError.MINMAX;
1256
+ }
1257
+ return inputError;
1258
+ };
1259
+ /**
1260
+ * Format value based on type
1261
+ *
1262
+ * @param {number} value value to format
1263
+ * @returns {string} formated local value
1264
+ */
1265
+ this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value) : localeNumber(value));
1266
+ /**
1267
+ * Validate append slot
1268
+ *
1269
+ * @returns {void}
1270
+ */
1271
+ this.validateAppendSlot = () => {
1272
+ const slotAppendInput = this.element.querySelector('[slot="append-input"]');
1273
+ if (slotAppendInput !== null) {
1274
+ this.classList.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
1275
+ }
1276
+ };
1277
+ }
1278
+ validateValue(newValue) {
1279
+ if (newValue !== undefined && newValue !== null) {
1280
+ // Split number and decimal
1281
+ const [integer, decimal = ''] = newValue.replace('-', '').split(/[\.,]/);
1282
+ // Regex
1283
+ const regex = this.type === 'integer' ? /^[\-]?\d+$/ : /^[\-]?\d+[.,]?\d*$/;
1284
+ // Filter input
1285
+ if (newValue === '' || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
1286
+ this.storedValue = newValue;
1287
+ }
1288
+ else if (this.storedValue !== undefined) {
1289
+ newValue = this.storedValue;
1290
+ }
1291
+ else {
1292
+ newValue = null;
1293
+ }
1294
+ // Set value and input value
1295
+ this.value = newValue;
1296
+ if (this.input !== undefined)
1297
+ this.input.value = this.value;
1298
+ // emit numeric value
1299
+ this.numericValue = this.value !== '' && this.value !== null ? parseFloat(this.value.replace(',', '.')) : null;
1300
+ this.valueChange.emit(this.numericValue);
1301
+ // Set readOnlyValue
1302
+ this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
1303
+ }
1304
+ }
1305
+ validateType(newValue) {
1306
+ if (!types.includes(newValue)) {
1307
+ throw new Error(`<mg-input-numeric> prop "type" must be one of : ${types.join(', ')}`);
1308
+ }
1309
+ this.classList.add(`mg-input--numeric--${this.type}`);
1310
+ }
1311
+ validateIntegerLength(newValue) {
1312
+ if (newValue < 1) {
1313
+ throw new Error(`<mg-input-numeric> prop "integer-length" must be a positive number.`);
1314
+ }
1315
+ }
1316
+ validateDecimalLength(newValue) {
1317
+ if (newValue < 1) {
1318
+ throw new Error(`<mg-input-numeric> prop "decimal-length" must be a positive number, consider using prop "type" to "integer" instead.`);
1319
+ }
1320
+ }
1321
+ /**
1322
+ * Public method to display errors
1323
+ *
1324
+ * @returns {Promise<void>}
1325
+ */
1326
+ async displayError() {
1327
+ this.checkValidity();
1328
+ this.checkError();
1329
+ }
1330
+ /**
1331
+ * Displayed value in input
1332
+ * Change on focus/blur
1333
+ *
1334
+ * @returns {string} display value
1335
+ */
1336
+ displayValue() {
1337
+ return this.hasFocus ? this.value : this.readonlyValue;
1338
+ }
1339
+ /*************
1340
+ * Lifecycle *
1341
+ *************/
1342
+ /**
1343
+ * Check if component props are well configured on init
1344
+ *
1345
+ * @returns {ReturnType<typeof setTimeout>} timeout
1346
+ */
1347
+ componentWillLoad() {
1348
+ this.validateValue(this.value);
1349
+ this.validateType(this.type);
1350
+ this.validateIntegerLength(this.integerLength);
1351
+ this.validateDecimalLength(this.decimalLength);
1352
+ this.validateAppendSlot();
1353
+ // Check validity when component is ready
1354
+ // return a promise to process action only in the FIRST render().
1355
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
1356
+ return setTimeout(() => {
1357
+ this.checkValidity();
1358
+ }, 0);
1359
+ }
1360
+ /**
1361
+ * Render
1362
+ *
1363
+ * @returns {HTMLElement} HTML Element
1364
+ */
1365
+ render() {
1366
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), index.h("slot", { name: "append-input" })));
1367
+ }
1368
+ get element() { return index.getElement(this); }
1369
+ static get watchers() { return {
1370
+ "value": ["validateValue"],
1371
+ "type": ["validateType"],
1372
+ "integerLength": ["validateIntegerLength"],
1373
+ "decimalLength": ["validateDecimalLength"]
1374
+ }; }
1375
+ };
1376
+ MgInputNumeric.style = mgInputNumericCss;
1377
+
1378
+ const mgInputPasswordCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:-ms-inline-flexbox;display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:-ms-inline-flexbox;display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0;--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius);--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){-ms-flex-pack:justify;justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{-ms-flex:auto;flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}";
1379
+
1380
+ const MgInputPassword = class {
1381
+ constructor(hostRef) {
1382
+ index.registerInstance(this, hostRef);
1383
+ this.valueChange = index.createEvent(this, "value-change", 7);
1384
+ this.inputValid = index.createEvent(this, "input-valid", 7);
1385
+ /************
1386
+ * Internal *
1387
+ ************/
1388
+ // classes
1389
+ this.classError = InputClass.ERROR;
1390
+ /**
1391
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1392
+ * If not set, it will be created.
1393
+ */
1394
+ this.identifier = index$1.createID('mg-input-password');
1395
+ /**
1396
+ * Input name
1397
+ * If not set the value equals the identifier
1398
+ */
1399
+ this.name = this.identifier;
1400
+ /**
1401
+ * Define if label is visible
1402
+ */
1403
+ this.labelHide = false;
1404
+ /**
1405
+ * Define if input is required
1406
+ */
1407
+ this.required = false;
1408
+ /**
1409
+ * Define if input is readonly
1410
+ */
1411
+ this.readonly = false;
1412
+ /**
1413
+ * Define if input is disabled
1414
+ */
1415
+ this.disabled = false;
1416
+ /**
1417
+ * Define input width
1418
+ */
1419
+ this.width = 'full';
1420
+ /**
1421
+ * Component classes
1422
+ */
1423
+ this.classList = new index$1.ClassList(['mg-input--password']);
1424
+ /**
1425
+ * Handle input event
1426
+ */
1427
+ this.handleInput = () => {
1428
+ this.checkValidity();
1429
+ this.value = this.input.value;
1430
+ };
1431
+ /**
1432
+ * Handle blur event
1433
+ */
1434
+ this.handleBlur = () => {
1435
+ this.checkValidity();
1436
+ this.checkError();
1437
+ };
1438
+ /**
1439
+ * Check if input is valid
1440
+ */
1441
+ this.checkValidity = () => {
1442
+ if (!this.readonly && this.input !== undefined) {
1443
+ const validity = this.input.checkValidity();
1444
+ // Set validity
1445
+ this.valid = validity;
1446
+ this.invalid = !validity;
1447
+ //Send event
1448
+ this.inputValid.emit(validity);
1449
+ }
1450
+ };
1451
+ /**
1452
+ * Check input errors
1453
+ */
1454
+ this.checkError = () => {
1455
+ // Set error message
1456
+ this.errorMessage = undefined;
1457
+ // required
1458
+ if (!this.valid && this.input.validity.valueMissing) {
1459
+ this.errorMessage = index$1.messages.errors.required;
1460
+ }
1461
+ // Update class
1462
+ if (this.valid) {
1463
+ this.classList.delete(this.classError);
1464
+ }
1465
+ else {
1466
+ this.classList.add(this.classError);
1467
+ }
1468
+ };
1469
+ }
1470
+ handleValue(newValue) {
1471
+ this.valueChange.emit(newValue);
1472
+ }
1473
+ /**
1474
+ * Public method to display errors
1475
+ *
1476
+ * @returns {Promise<void>}
1477
+ */
1478
+ async displayError() {
1479
+ this.checkValidity();
1480
+ this.checkError();
1481
+ }
1482
+ /*************
1483
+ * Lifecycle *
1484
+ *************/
1485
+ /**
1486
+ * Check if component props are well configured on init
1487
+ *
1488
+ * @returns {ReturnType<typeof setTimeout>} timeout
1489
+ */
1490
+ componentWillLoad() {
1491
+ // Check validity when component is ready
1492
+ // return a promise to process action only in the FIRST render().
1493
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
1494
+ return setTimeout(() => {
1495
+ this.checkValidity();
1496
+ }, 0);
1497
+ }
1498
+ /**
1499
+ * Render
1500
+ *
1501
+ * @returns {HTMLElement} HTML Element
1502
+ */
1503
+ render() {
1504
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, displayCharacterLeft: false, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) })));
1505
+ }
1506
+ static get watchers() { return {
1507
+ "value": ["handleValue"]
1508
+ }; }
1509
+ };
1510
+ MgInputPassword.style = mgInputPasswordCss;
1511
+
1512
+ const mgInputRadioCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:-ms-inline-flexbox;display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:-ms-inline-flexbox;display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}fieldset.mg-input{border:0;margin-left:0;margin-right:0;padding:0}fieldset.mg-input input[type=radio],fieldset.mg-input input[type=checkbox]{-ms-flex-negative:0;flex-shrink:0;width:var(--mg-input-check-size);height:var(--mg-input-check-size);margin-top:calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);margin-right:0.6rem;margin-bottom:0;margin-left:0}fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container{margin-top:0.7rem}fieldset.mg-input.is-not-valid .mg-input__input-group{color:initial}.mg-input__input-container mg-tooltip{margin-left:2rem}.mg-input__input-group-container{margin:0;padding:0;list-style:none;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-column-gap:2.3rem;-moz-column-gap:2.3rem;column-gap:2.3rem;row-gap:1rem;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2)}.mg-input__input-group-container--vertical{-ms-flex-direction:column;flex-direction:column}.mg-input__input-group{display:-ms-flexbox;display:flex;-ms-flex-align:top;align-items:top}.mg-input__input-group.mg-input__input-group--disabled label{opacity:0.3}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}";
1513
+
1514
+ /**
1515
+ * type Option validation function
1516
+ *
1517
+ * @param {RadioOption} option radio option
1518
+ * @returns {boolean} radio option type is valid
1519
+ */
1520
+ const isOption$2 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
1521
+ const MgInputRadio = class {
1522
+ constructor(hostRef) {
1523
+ index.registerInstance(this, hostRef);
1524
+ this.valueChange = index.createEvent(this, "value-change", 7);
1525
+ this.inputValid = index.createEvent(this, "input-valid", 7);
1526
+ /************
1527
+ * Internal *
1528
+ ************/
1529
+ // classes
1530
+ this.classError = InputClass.ERROR;
1531
+ // HTML selector
1532
+ this.inputs = [];
1533
+ /**
1534
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1535
+ * If not set, it will be created.
1536
+ */
1537
+ this.identifier = index$1.createID('mg-input-radio');
1538
+ /**
1539
+ * Input name
1540
+ * If not set the value equals the identifier
1541
+ */
1542
+ this.name = this.identifier;
1543
+ /**
1544
+ * Define if label is displayed on top
1545
+ */
1546
+ this.labelOnTop = false;
1547
+ /**
1548
+ * Define if label is visible
1549
+ */
1550
+ this.labelHide = false;
1551
+ /**
1552
+ * Define if inputs are display verticaly
1553
+ */
1554
+ this.inputVerticalList = false;
1555
+ /**
1556
+ * Define if input is required
1557
+ */
1558
+ this.required = false;
1559
+ /**
1560
+ * Define if input is readonly
1561
+ */
1562
+ this.readonly = false;
1563
+ /**
1564
+ * Define if input is disabled
1565
+ */
1566
+ this.disabled = false;
1567
+ /**
1568
+ * Component classes
1569
+ */
1570
+ this.classList = new index$1.ClassList(['mg-input--radio']);
1571
+ /**
1572
+ * Handle input event
1573
+ *
1574
+ * @param {event} event input event
1575
+ * @returns {void}
1576
+ */
1577
+ this.handleInput = (event) => {
1578
+ this.checkValidity();
1579
+ this.value = this.options[event.target.value].value;
1580
+ };
1581
+ /**
1582
+ * Handle blur event
1583
+ *
1584
+ * @returns {void}
1585
+ */
1586
+ this.handleBlur = () => {
1587
+ this.checkValidity();
1588
+ this.checkError();
1589
+ };
1590
+ /**
1591
+ * Check if input is valid
1592
+ *
1593
+ * @returns {void}
1594
+ */
1595
+ this.checkValidity = () => {
1596
+ if (!this.readonly) {
1597
+ const validity = this.getInvalidElement() === undefined;
1598
+ // Set validity
1599
+ this.valid = validity;
1600
+ this.invalid = !validity;
1601
+ //Send event
1602
+ this.inputValid.emit(validity);
1603
+ }
1604
+ };
1605
+ /**
1606
+ * Check input errors
1607
+ *
1608
+ * @returns {void}
1609
+ */
1610
+ this.checkError = () => {
1611
+ const invalidElement = this.getInvalidElement();
1612
+ // Set error message
1613
+ this.errorMessage = undefined;
1614
+ if (!this.valid && invalidElement.validity.valueMissing) {
1615
+ this.errorMessage = index$1.messages.errors.required;
1616
+ }
1617
+ // Update class
1618
+ if (this.valid) {
1619
+ this.classList.delete(this.classError);
1620
+ }
1621
+ else {
1622
+ this.classList.add(this.classError);
1623
+ }
1624
+ };
1625
+ /**
1626
+ * get invalid element
1627
+ *
1628
+ * @returns {HTMLInputElement} element
1629
+ */
1630
+ this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
1631
+ }
1632
+ handleValue(newValue) {
1633
+ this.valueChange.emit(newValue);
1634
+ }
1635
+ validateItems(newValue) {
1636
+ // Validate if items have required min length
1637
+ if (typeof newValue === 'object' && newValue.length < 2) {
1638
+ throw new Error('<mg-input-radio> prop "items" require at least 2 items.');
1639
+ }
1640
+ // String array
1641
+ else if (index$1.allItemsAreString(newValue)) {
1642
+ this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
1643
+ }
1644
+ // Object array
1645
+ else if (newValue && newValue.every(item => isOption$2(item))) {
1646
+ this.options = newValue;
1647
+ }
1648
+ else {
1649
+ throw new Error('<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption.');
1650
+ }
1651
+ }
1652
+ /**
1653
+ * Public method to display errors
1654
+ *
1655
+ * @returns {Promise<void>}
1656
+ */
1657
+ async displayError() {
1658
+ this.checkValidity();
1659
+ this.checkError();
1660
+ }
1661
+ /*************
1662
+ * Lifecycle *
1663
+ *************/
1664
+ /**
1665
+ * Check if component props are well configured on init
1666
+ *
1667
+ * @returns {ReturnType<typeof setTimeout>} timeout
1668
+ */
1669
+ componentWillLoad() {
1670
+ // Check items format
1671
+ this.validateItems(this.items);
1672
+ // Check validity when component is ready
1673
+ // return a promise to process action only in the FIRST render().
1674
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
1675
+ return setTimeout(() => {
1676
+ this.checkValidity();
1677
+ }, 0);
1678
+ }
1679
+ /**
1680
+ * Render
1681
+ *
1682
+ * @returns {HTMLElement} HTML Element
1683
+ */
1684
+ render() {
1685
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, width: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.options.map((input, index$1) => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "radio", id: this.identifier + '_' + index$1, name: this.identifier, value: index$1, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index$1].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => this.inputs.push(el) }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title)))))));
1686
+ }
1687
+ static get watchers() { return {
1688
+ "value": ["handleValue"],
1689
+ "items": ["validateItems"]
1690
+ }; }
1691
+ };
1692
+ MgInputRadio.style = mgInputRadioCss;
1693
+
1694
+ const mgInputSelectCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:-ms-inline-flexbox;display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:-ms-inline-flexbox;display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0;--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius);--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){-ms-flex-pack:justify;justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{-ms-flex:auto;flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input__box{padding-top:0;padding-bottom:0;padding-right:1rem}";
1695
+
1696
+ /**
1697
+ * Check if item is a well configured option
1698
+ *
1699
+ * @param {SelectOption} option select option
1700
+ * @returns {boolean} select option type is valid
1701
+ */
1702
+ const isOption$1 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
1703
+ /**
1704
+ * Group options
1705
+ *
1706
+ * @param {(SelectOption | OptGroup)[]} acc reduce accumulator
1707
+ * @param {SelectOption} item item to add
1708
+ * @param {string} item.group item group
1709
+ * @param {string} item.title item title
1710
+ * @param {unknown} item.value item value
1711
+ * @param {boolean} item.disabled is item disabled
1712
+ * @returns {(SelectOption | OptGroup)[]} grouped options
1713
+ */
1714
+ const groupOptions = (acc, { group, title, value, disabled }) => {
1715
+ if (group !== undefined) {
1716
+ // Check if group is already created
1717
+ const optGroup = acc.find(grp => grp.group === group);
1718
+ // Add to group
1719
+ if (optGroup !== undefined) {
1720
+ optGroup.options.push({ title, value, disabled });
1721
+ }
1722
+ // Create group
1723
+ else {
1724
+ acc.push({ group, options: [{ title, value, disabled }] });
1725
+ }
1726
+ }
1727
+ else {
1728
+ acc.push({ title, value, disabled });
1729
+ }
1730
+ return acc;
1731
+ };
1732
+ const MgInputSelect = class {
1733
+ constructor(hostRef) {
1734
+ index.registerInstance(this, hostRef);
1735
+ this.valueChange = index.createEvent(this, "value-change", 7);
1736
+ this.inputValid = index.createEvent(this, "input-valid", 7);
1737
+ /************
1738
+ * Internal *
1739
+ ************/
1740
+ // classes
1741
+ this.classError = InputClass.ERROR;
1742
+ /**
1743
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1744
+ * If not set, it will be created.
1745
+ */
1746
+ this.identifier = index$1.createID('mg-input-select');
1747
+ /**
1748
+ * Input name
1749
+ * If not set the value equals the identifier
1750
+ */
1751
+ this.name = this.identifier;
1752
+ /**
1753
+ * Define if label is visible
1754
+ */
1755
+ this.labelHide = false;
1756
+ /**
1757
+ * Input placeholder.
1758
+ * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.
1759
+ */
1760
+ this.placeholder = index$1.messages.input.select.placeholder;
1761
+ /**
1762
+ * Option to remove placeholder
1763
+ */
1764
+ this.placeholderHide = false;
1765
+ /**
1766
+ * Option to disable placeholder
1767
+ */
1768
+ this.placeholderDisabled = false;
1769
+ /**
1770
+ * Define if input is required
1771
+ */
1772
+ this.required = false;
1773
+ /**
1774
+ * Define if input is readonly
1775
+ */
1776
+ this.readonly = false;
1777
+ /**
1778
+ * Define if input is disabled
1779
+ */
1780
+ this.disabled = false;
1781
+ /**
1782
+ * Component classes
1783
+ */
1784
+ this.classList = new index$1.ClassList(['mg-input--select']);
1785
+ /**
1786
+ * Handle input event
1787
+ */
1788
+ this.handleInput = () => {
1789
+ this.checkValidity();
1790
+ if (this.input.value !== '') {
1791
+ this.value = index$1.allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.title === this.input.value).value;
1792
+ }
1793
+ else {
1794
+ this.value = null;
1795
+ }
1796
+ };
1797
+ /**
1798
+ * Handle blur event
1799
+ */
1800
+ this.handleBlur = () => {
1801
+ this.checkValidity();
1802
+ this.checkError();
1803
+ };
1804
+ /**
1805
+ * Check if input is valid
1806
+ */
1807
+ this.checkValidity = () => {
1808
+ if (!this.readonly && this.input !== undefined) {
1809
+ const validity = this.input.checkValidity && this.input.checkValidity();
1810
+ // Set validity
1811
+ this.valid = validity;
1812
+ this.invalid = !validity;
1813
+ //Send event
1814
+ this.inputValid.emit(validity);
1815
+ }
1816
+ };
1817
+ /**
1818
+ * Check input errors
1819
+ */
1820
+ this.checkError = () => {
1821
+ // Set error message
1822
+ this.errorMessage = undefined;
1823
+ if (!this.valid && this.input.validity.valueMissing) {
1824
+ this.errorMessage = index$1.messages.errors.required;
1825
+ }
1826
+ // Update class
1827
+ if (this.valid) {
1828
+ this.classList.delete(this.classError);
1829
+ }
1830
+ else {
1831
+ this.classList.add(this.classError);
1832
+ }
1833
+ };
1834
+ }
1835
+ handleValue(newValue) {
1836
+ if (newValue !== null) {
1837
+ this.readonlyValue = index$1.allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.value === newValue).title;
1838
+ }
1839
+ else {
1840
+ this.readonlyValue = null;
1841
+ }
1842
+ this.valueChange.emit(newValue);
1843
+ }
1844
+ validateItems(newValue) {
1845
+ // String array
1846
+ if (index$1.allItemsAreString(newValue)) {
1847
+ this.valueExist = newValue.includes(this.value);
1848
+ this.options = newValue.map((item) => ({ title: item, value: item }));
1849
+ }
1850
+ // Object array
1851
+ else if (newValue && newValue.every(item => isOption$1(item))) {
1852
+ this.valueExist = newValue.map(item => item.value).includes(this.value);
1853
+ // Grouped object options
1854
+ if (newValue.some(item => item.group !== undefined)) {
1855
+ this.options = newValue.reduce(groupOptions, []);
1856
+ }
1857
+ // Standart object options
1858
+ else {
1859
+ this.options = newValue;
1860
+ }
1861
+ }
1862
+ else {
1863
+ throw new Error('<mg-input-select> prop "items" is required and all items must be the same type, string or Option.');
1864
+ }
1865
+ }
1866
+ /**
1867
+ * Public method to display errors
1868
+ *
1869
+ * @returns {Promise<void>}
1870
+ */
1871
+ async displayError() {
1872
+ this.checkValidity();
1873
+ this.checkError();
1874
+ }
1875
+ /*************
1876
+ * Lifecycle *
1877
+ *************/
1878
+ /**
1879
+ * Check if component props are well configured on init
1880
+ *
1881
+ * @returns {ReturnType<typeof setTimeout>} timeout
1882
+ */
1883
+ componentWillLoad() {
1884
+ // Check items format
1885
+ this.validateItems(this.items);
1886
+ // Check validity when component is ready
1887
+ // return a promise to process action only in the FIRST render().
1888
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
1889
+ return setTimeout(() => {
1890
+ this.checkValidity();
1891
+ }, 0);
1892
+ }
1893
+ /**
1894
+ * Render
1895
+ *
1896
+ * @returns {HTMLElement} HTML Element
1897
+ */
1898
+ render() {
1899
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
1900
+ index.h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map(option => option.group !== undefined ? (index.h("optgroup", { label: option.group }, option.options.map(optgroup => (index.h("option", { value: optgroup.title, selected: JSON.stringify(this.value) === JSON.stringify(optgroup.value), disabled: optgroup.disabled }, optgroup.title))))) : (index.h("option", { value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title))))));
1901
+ }
1902
+ static get watchers() { return {
1903
+ "value": ["handleValue"],
1904
+ "items": ["validateItems"]
1905
+ }; }
1906
+ };
1907
+ MgInputSelect.style = mgInputSelectCss;
1908
+
1909
+ const mgInputTextCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:-ms-inline-flexbox;display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:-ms-inline-flexbox;display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0;--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius);--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){-ms-flex-pack:justify;justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{-ms-flex:auto;flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{display:none}.mg-input.is-focused mg-character-left{display:block}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input.mg-input--has-icon .mg-input__input{position:relative}.mg-input.mg-input--has-icon .mg-input__input>mg-icon{position:absolute;top:calc(var(--default-size) - var(--mg-icon-regular-size));left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);-webkit-transform:translateY(-50%);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__input .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}";
1910
+
1911
+ const MgInputText = class {
1912
+ constructor(hostRef) {
1913
+ index.registerInstance(this, hostRef);
1914
+ this.valueChange = index.createEvent(this, "value-change", 7);
1915
+ this.inputValid = index.createEvent(this, "input-valid", 7);
1916
+ /************
1917
+ * Internal *
1918
+ ************/
1919
+ // classes
1920
+ this.classFocus = 'is-focused';
1921
+ this.isInputGroupAppend = 'mg-input--is-input-group-append';
1922
+ this.classError = InputClass.ERROR;
1923
+ /**
1924
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1925
+ * If not set, it will be created.
1926
+ */
1927
+ this.identifier = index$1.createID('mg-input-text');
1928
+ /**
1929
+ * Input name
1930
+ * If not set the value equals the identifier
1931
+ */
1932
+ this.name = this.identifier;
1933
+ /**
1934
+ * Input type
1935
+ */
1936
+ this.type = 'text';
1937
+ /**
1938
+ * Define if label is visible
1939
+ */
1940
+ this.labelHide = false;
1941
+ /**
1942
+ * Input max length
1943
+ */
1944
+ this.maxlength = 400;
1945
+ /**
1946
+ * Define if input is required
1947
+ */
1948
+ this.required = false;
1949
+ /**
1950
+ * Define if input is readonly
1951
+ */
1952
+ this.readonly = false;
1953
+ /**
1954
+ * Define if input is disabled
1955
+ */
1956
+ this.disabled = false;
1957
+ /**
1958
+ * Define input width
1959
+ */
1960
+ this.width = 'full';
1961
+ /**
1962
+ * Define if component should display character left
1963
+ */
1964
+ this.displayCharacterLeft = true;
1965
+ /**
1966
+ * Component classes
1967
+ */
1968
+ this.classList = new index$1.ClassList(['mg-input--text']);
1969
+ /**
1970
+ * Handle input event
1971
+ *
1972
+ * @returns {void}
1973
+ */
1974
+ this.handleInput = () => {
1975
+ this.checkValidity();
1976
+ this.value = this.input.value;
1977
+ };
1978
+ /**
1979
+ * Handle focus event
1980
+ *
1981
+ * @returns {void}
1982
+ */
1983
+ this.handleFocus = () => {
1984
+ this.classList.add(this.classFocus);
1985
+ this.classList = new index$1.ClassList(this.classList.classes);
1986
+ };
1987
+ /**
1988
+ * Handle blur event
1989
+ *
1990
+ * @returns {void}
1991
+ */
1992
+ this.handleBlur = () => {
1993
+ // Manage focus
1994
+ this.classList.delete(this.classFocus);
1995
+ this.classList = new index$1.ClassList(this.classList.classes);
1996
+ // Check validity
1997
+ this.checkValidity();
1998
+ this.checkError();
1999
+ };
2000
+ /**
2001
+ * Check if input is valid
2002
+ *
2003
+ * @returns {void}
2004
+ */
2005
+ this.checkValidity = () => {
2006
+ if (!this.readonly && this.input !== undefined) {
2007
+ const validity = this.input.checkValidity();
2008
+ // Set validity
2009
+ this.valid = validity;
2010
+ this.invalid = !validity;
2011
+ //Send event
2012
+ this.inputValid.emit(validity);
2013
+ }
2014
+ };
2015
+ /**
2016
+ * Check input errors
2017
+ *
2018
+ * @returns {void}
2019
+ */
2020
+ this.checkError = () => {
2021
+ // Set error message
2022
+ this.errorMessage = undefined;
2023
+ // Does not match pattern
2024
+ if (!this.valid && this.input.validity.patternMismatch) {
2025
+ this.errorMessage = this.patternErrorMessage;
2026
+ }
2027
+ // required
2028
+ else if (!this.valid && this.input.validity.valueMissing) {
2029
+ this.errorMessage = index$1.messages.errors.required;
2030
+ }
2031
+ // Update class
2032
+ if (this.valid) {
2033
+ this.classList.delete(this.classError);
2034
+ }
2035
+ else {
2036
+ this.classList.add(this.classError);
2037
+ }
2038
+ };
2039
+ /**
2040
+ * Validate patern configuration
2041
+ *
2042
+ * @returns {void}
2043
+ */
2044
+ this.validatePattern = () => {
2045
+ if (this.pattern &&
2046
+ typeof this.pattern === 'string' &&
2047
+ this.pattern !== '' &&
2048
+ (this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
2049
+ throw new Error('<mg-input-text> prop "pattern" must be paired with the prop "patternErrorMessage"');
2050
+ }
2051
+ };
2052
+ /**
2053
+ * Validate append slot
2054
+ *
2055
+ * @returns {void}
2056
+ */
2057
+ this.validateAppendSlot = () => {
2058
+ const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
2059
+ if (slotAppendInput.length === 1) {
2060
+ this.classList.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.isInputGroupAppend : 'mg-input--is-append-input-slot-content');
2061
+ }
2062
+ else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
2063
+ this.classList.add(this.isInputGroupAppend);
2064
+ this.classList.add('mg-input--has-buttons-group-append');
2065
+ }
2066
+ };
2067
+ }
2068
+ handleValue(newValue) {
2069
+ this.valueChange.emit(newValue);
2070
+ }
2071
+ /**
2072
+ * Public method to play input focus
2073
+ *
2074
+ * @returns {Promise<void>}
2075
+ */
2076
+ async setFocus() {
2077
+ this.input.focus();
2078
+ }
2079
+ /**
2080
+ * Public method to display errors
2081
+ *
2082
+ * @returns {Promise<void>}
2083
+ */
2084
+ async displayError() {
2085
+ this.checkValidity();
2086
+ this.checkError();
2087
+ }
2088
+ /*************
2089
+ * Lifecycle *
2090
+ *************/
2091
+ /**
2092
+ * Check if component props are well configured on init
2093
+ *
2094
+ * @returns {ReturnType<typeof setTimeout>} timeout
2095
+ */
2096
+ componentWillLoad() {
2097
+ if (this.icon !== undefined) {
2098
+ this.classList.add('mg-input--has-icon');
2099
+ }
2100
+ this.validatePattern();
2101
+ this.validateAppendSlot();
2102
+ // Check validity when component is ready
2103
+ // return a promise to process action only in the FIRST render().
2104
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
2105
+ return setTimeout(() => {
2106
+ this.checkValidity();
2107
+ }, 0);
2108
+ }
2109
+ /**
2110
+ * Render
2111
+ *
2112
+ * @returns {HTMLElement} HTML Element
2113
+ */
2114
+ render() {
2115
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, displayCharacterLeft: this.displayCharacterLeft, characterLeftTemplate: this.characterLeftTemplate, maxlength: this.maxlength, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, this.icon !== undefined && index.h("mg-icon", { icon: this.icon }), index.h("input", { type: this.type, class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), index.h("slot", { name: "append-input" })));
2116
+ }
2117
+ get element() { return index.getElement(this); }
2118
+ static get watchers() { return {
2119
+ "value": ["handleValue"]
2120
+ }; }
2121
+ };
2122
+ MgInputText.style = mgInputTextCss;
2123
+
2124
+ const mgInputTextareaCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:-ms-inline-flexbox;display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:-ms-inline-flexbox;display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);width:100%;height:var(--default-size);-webkit-box-sizing:border-box;box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size)}.mg-input__box::-webkit-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-moz-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::-ms-input-placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{-webkit-box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0;--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius);--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){-ms-flex-pack:justify;justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{-ms-flex:auto;flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{display:none}.mg-input.is-focused mg-character-left{display:block}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input .mg-input__box{height:auto}@-moz-document url-prefix(){.mg-input__box{overflow-x:hidden}}";
2125
+
2126
+ const MgInputTextarea = class {
2127
+ constructor(hostRef) {
2128
+ index.registerInstance(this, hostRef);
2129
+ this.valueChange = index.createEvent(this, "value-change", 7);
2130
+ this.inputValid = index.createEvent(this, "input-valid", 7);
2131
+ /************
2132
+ * Internal *
2133
+ ************/
2134
+ // classes
2135
+ this.classFocus = 'is-focused';
2136
+ this.classError = InputClass.ERROR;
2137
+ /**
2138
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2139
+ * If not set, it will be created.
2140
+ */
2141
+ this.identifier = index$1.createID('mg-input-textarea');
2142
+ /**
2143
+ * Input name
2144
+ * If not set the value equals the identifier
2145
+ */
2146
+ this.name = this.identifier;
2147
+ /**
2148
+ * Define if label is visible
2149
+ */
2150
+ this.labelHide = false;
2151
+ /**
2152
+ * Input max length
2153
+ */
2154
+ this.maxlength = 4000;
2155
+ /**
2156
+ * Define if input is required
2157
+ */
2158
+ this.required = false;
2159
+ /**
2160
+ * Define if input is readonly
2161
+ */
2162
+ this.readonly = false;
2163
+ /**
2164
+ * Define if input is disabled
2165
+ */
2166
+ this.disabled = false;
2167
+ /**
2168
+ * Define input width
2169
+ */
2170
+ this.width = 'full';
2171
+ /**
2172
+ * Define input pattern error message
2173
+ */
2174
+ this.rows = 3;
2175
+ /**
2176
+ * Define if component should display character left
2177
+ */
2178
+ this.displayCharacterLeft = true;
2179
+ /**
2180
+ * Component classes
2181
+ */
2182
+ this.classList = new index$1.ClassList(['mg-input--textarea']);
2183
+ /**
2184
+ * Handle input event
2185
+ */
2186
+ this.handleInput = () => {
2187
+ this.value = this.input.value;
2188
+ };
2189
+ /**
2190
+ * Handle focus event
2191
+ */
2192
+ this.handleFocus = () => {
2193
+ this.classList.add(this.classFocus);
2194
+ this.classList = new index$1.ClassList(this.classList.classes);
2195
+ };
2196
+ /**
2197
+ * Handle blur event
2198
+ */
2199
+ this.handleBlur = () => {
2200
+ // Manage focus
2201
+ this.classList.delete(this.classFocus);
2202
+ this.classList = new index$1.ClassList(this.classList.classes);
2203
+ // Check validity
2204
+ this.checkValidity();
2205
+ this.checkError();
2206
+ };
2207
+ /**
2208
+ * Get pattern validity
2209
+ * Pattern is not defined on textarea field : https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
2210
+ *
2211
+ * @returns {boolean} is pattern valid
2212
+ */
2213
+ this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
2214
+ /**
2215
+ * Check if input is valid
2216
+ */
2217
+ this.checkValidity = () => {
2218
+ if (!this.readonly && this.input !== undefined) {
2219
+ const validity = this.input.checkValidity && this.input.checkValidity() && this.getPatternValidity();
2220
+ // Set validity
2221
+ this.valid = validity;
2222
+ this.invalid = !validity;
2223
+ //Send event
2224
+ this.inputValid.emit(validity);
2225
+ }
2226
+ };
2227
+ /**
2228
+ * Check input errors
2229
+ */
2230
+ this.checkError = () => {
2231
+ // Set error message
2232
+ this.errorMessage = undefined;
2233
+ // Does not match pattern
2234
+ if (!this.valid && !this.getPatternValidity()) {
2235
+ this.errorMessage = this.patternErrorMessage;
2236
+ }
2237
+ // required
2238
+ else if (!this.valid && this.input.validity.valueMissing) {
2239
+ this.errorMessage = index$1.messages.errors.required;
2240
+ }
2241
+ // Update class
2242
+ if (this.valid) {
2243
+ this.classList.delete(this.classError);
2244
+ }
2245
+ else {
2246
+ this.classList.add(this.classError);
2247
+ }
2248
+ };
2249
+ /**
2250
+ * Validate pattern configuration
2251
+ */
2252
+ this.validatePattern = () => {
2253
+ if (this.pattern &&
2254
+ typeof this.pattern === 'string' &&
2255
+ this.pattern !== '' &&
2256
+ (this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
2257
+ throw new Error('<mg-input-textarea> prop "pattern" must be paired with the prop "patternErrorMessage"');
2258
+ }
2259
+ };
2260
+ }
2261
+ handleValue(newValue) {
2262
+ this.checkValidity();
2263
+ this.valueChange.emit(newValue);
2264
+ }
2265
+ /**
2266
+ * Public method to display errors
2267
+ *
2268
+ * @returns {Promise<void>}
2269
+ */
2270
+ async displayError() {
2271
+ this.checkValidity();
2272
+ this.checkError();
2273
+ }
2274
+ /*************
2275
+ * Lifecycle *
2276
+ *************/
2277
+ /**
2278
+ * Check if component props are well configured on init
2279
+ *
2280
+ * @returns {ReturnType<typeof setTimeout>} timeout
2281
+ */
2282
+ componentWillLoad() {
2283
+ this.validatePattern();
2284
+ // Check validity when component is ready
2285
+ // return a promise to process action only in the FIRST render().
2286
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
2287
+ return setTimeout(() => {
2288
+ this.checkValidity();
2289
+ }, 0);
2290
+ }
2291
+ /**
2292
+ * Render
2293
+ *
2294
+ * @returns {HTMLElement} HTML Element
2295
+ */
2296
+ render() {
2297
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, width: this.width, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, displayCharacterLeft: this.displayCharacterLeft, characterLeftTemplate: this.characterLeftTemplate, maxlength: this.maxlength, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("textarea", { class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) })));
2298
+ }
2299
+ static get watchers() { return {
2300
+ "value": ["handleValue"]
2301
+ }; }
2302
+ };
2303
+ MgInputTextarea.style = mgInputTextareaCss;
2304
+
2305
+ const mgInputTitleCss = ".is-asterisk.sc-mg-input-title{color:hsl(var(--color-danger))}legend.mg-input-title.sc-mg-input-title{padding-left:0;padding-right:0}.mg-input-title__required.sc-mg-input-title{display:var(--mg-input-title-display, unset)}";
2306
+
2307
+ const MgInputTitle = class {
2308
+ constructor(hostRef) {
2309
+ index.registerInstance(this, hostRef);
2310
+ /**
2311
+ * Switch from label to fieldset sementic
2312
+ */
2313
+ this.isLegend = false;
2314
+ /**
2315
+ * Component parent tagname
2316
+ */
2317
+ this.tagName = 'label';
2318
+ this.getTagName = () => {
2319
+ this.tagName = this.isLegend ? 'legend' : 'label';
2320
+ };
2321
+ }
2322
+ /*************
2323
+ * Lifecycle *
2324
+ *************/
2325
+ /**
2326
+ * Init tag name
2327
+ *
2328
+ * @returns {void}
2329
+ */
2330
+ componentWillLoad() {
2331
+ this.getTagName();
2332
+ }
2333
+ /**
2334
+ * Render
2335
+ *
2336
+ * @returns {HTMLElement} HTML Element
2337
+ */
2338
+ render() {
2339
+ const TagName = this.tagName;
2340
+ // \u00A0 represent a &nbsp;
2341
+ return (index.h(TagName, { class: "mg-input-title", htmlFor: this.isLegend ? undefined : this.identifier }, index.h("slot", null), this.required && (index.h("span", { class: "mg-input-title__required" }, "\u00A0", index.h("span", { class: "is-asterisk" }, "*")))));
2342
+ }
2343
+ };
2344
+ MgInputTitle.style = mgInputTitleCss;
2345
+
2346
+ const mgInputToggleCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:-ms-inline-flexbox;display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:-ms-inline-flexbox;display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input.mg-input.mg-input--toggle .mg-input__input-container{-ms-flex:auto;flex:auto;min-width:0}.mg-input__button-toggle{display:-ms-flexbox;display:flex;padding:0.2rem;min-width:0;background-color:hsl(var(--color-light));border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:calc((var(--font-size) * var(--line-height) + 2 * (0.7rem + var(--mg-inputs-border-width))) / var(--mg-input-toggle-border-radius-ratio));font-size:inherit;line-height:inherit;cursor:pointer}.mg-input__button-toggle:disabled{cursor:default}.mg-input__toggle-item-container{padding:0.5rem 0.9rem;border:0;-webkit-box-sizing:border-box;box-sizing:border-box;border-radius:calc((var(--font-size) * var(--line-height) + 1rem) / var(--mg-input-toggle-border-radius-ratio));background-color:unset;font-weight:unset;color:hsl(var(--color-dark));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;width:calc(var(--font-size) * var(--line-height) + 1rem);height:calc(var(--font-size) * var(--line-height) + 1rem);padding:0;visibility:hidden}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container:first-of-type{visibility:visible}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container ::slotted(mg-icon){display:-ms-flexbox;display:flex}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{visibility:hidden}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{visibility:visible}.mg-input.mg-input--toggle-on-off .mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-dark));background-color:hsl(var(--color-dark-h), calc(var(--color-dark-s) - 30%), calc(var(--color-dark-l) + 75%))}.mg-input.mg-input--toggle-on-off.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-readonly .mg-input__button-toggle{border-color:transparent;background-color:transparent;cursor:initial}.mg-input.mg-input--toggle-readonly .mg-input__toggle-item-container:last-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{display:-ms-flexbox;display:flex}.mg-input.mg-input--toggle-disabled .mg-input__button-toggle{opacity:0.3}";
2347
+
2348
+ /**
2349
+ * type Option validation function
2350
+ *
2351
+ * @param {ToggleValue} option radio option
2352
+ * @returns {boolean} toggle option type is valid
2353
+ */
2354
+ const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
2355
+ const MgInputToggle = class {
2356
+ constructor(hostRef) {
2357
+ index.registerInstance(this, hostRef);
2358
+ this.valueChange = index.createEvent(this, "value-change", 7);
2359
+ this.inputValid = index.createEvent(this, "input-valid", 7);
2360
+ /************
2361
+ * Internal *
2362
+ ************/
2363
+ // classes
2364
+ this.classReadonly = 'mg-input--toggle-readonly';
2365
+ this.classDisabled = 'mg-input--toggle-disabled';
2366
+ this.classIsActive = 'mg-input--toggle-is-active';
2367
+ /**
2368
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2369
+ * If not set, it will be created.
2370
+ */
2371
+ this.identifier = index$1.createID('mg-input-toggle');
2372
+ /**
2373
+ * Input name
2374
+ * If not set the value equals the identifier
2375
+ */
2376
+ this.name = this.identifier;
2377
+ /**
2378
+ * Define if label is visible
2379
+ */
2380
+ this.labelHide = false;
2381
+ /**
2382
+ * Define if toggle have on/off style
2383
+ */
2384
+ this.isOnOff = false;
2385
+ /**
2386
+ * Define if toggle display icon
2387
+ */
2388
+ this.isIcon = false;
2389
+ /**
2390
+ * Define if input is readonly
2391
+ */
2392
+ this.readonly = false;
2393
+ /**
2394
+ * Define if input is disabled
2395
+ */
2396
+ this.disabled = false;
2397
+ /**
2398
+ * Component classes
2399
+ */
2400
+ this.classList = new index$1.ClassList(['mg-input--toggle']);
2401
+ /**
2402
+ * Checked internal value
2403
+ */
2404
+ this.checked = false;
2405
+ /**
2406
+ * Change checked value
2407
+ *
2408
+ * @returns {void}
2409
+ */
2410
+ this.toggleChecked = () => {
2411
+ this.checked = !this.checked;
2412
+ };
2413
+ /**
2414
+ * Slots validation
2415
+ *
2416
+ * @returns {void}
2417
+ */
2418
+ this.validateSlots = () => {
2419
+ const slots = Array.from(this.element.children);
2420
+ if (slots.length !== 2) {
2421
+ throw new Error('<mg-input-toggle> 2 slots are required.');
2422
+ }
2423
+ else if (!this.isIcon) {
2424
+ // Due to text-overflow set to ellipsis
2425
+ // we need to ensure that slot element have title to display value on mouse over
2426
+ slots.forEach(slot => slot.setAttribute('title', slot.textContent));
2427
+ }
2428
+ };
2429
+ }
2430
+ handleValue(newValue) {
2431
+ // Swich to the right option
2432
+ this.setChecked();
2433
+ // Emit value-change event
2434
+ this.valueChange.emit(newValue);
2435
+ }
2436
+ validateItems(newValue) {
2437
+ if (typeof newValue === 'object' && this.items.length !== 2) {
2438
+ throw new Error('<mg-input-toggle> prop "items" require 2 items.');
2439
+ }
2440
+ // String array
2441
+ else if (index$1.allItemsAreString(newValue)) {
2442
+ this.options = newValue.map(item => ({ title: item, value: item }));
2443
+ }
2444
+ // Object array
2445
+ else if (newValue && newValue.every(item => isOption(item))) {
2446
+ this.options = newValue;
2447
+ }
2448
+ else {
2449
+ throw new Error('<mg-input-toggle> prop "items" is required and all items must be the same type: ToggleValue.');
2450
+ }
2451
+ }
2452
+ handleIsOnOff(newValue) {
2453
+ if (newValue)
2454
+ this.classList.add(`mg-input--toggle-on-off`);
2455
+ }
2456
+ handleIsIcon(newValue) {
2457
+ if (newValue)
2458
+ this.classList.add(`mg-input--toggle-icon`);
2459
+ }
2460
+ handleReadonly(newValue) {
2461
+ if (newValue)
2462
+ this.classList.add(this.classReadonly);
2463
+ else
2464
+ this.classList.delete(this.classReadonly);
2465
+ }
2466
+ handleDisabled(newValue) {
2467
+ if (newValue)
2468
+ this.classList.add(this.classDisabled);
2469
+ else
2470
+ this.classList.delete(this.classDisabled);
2471
+ }
2472
+ handleChecked(newValue) {
2473
+ // style
2474
+ if (newValue)
2475
+ this.classList.add(this.classIsActive);
2476
+ else
2477
+ this.classList.delete(this.classIsActive);
2478
+ // update value
2479
+ this.value = this.options[newValue ? 1 : 0].value;
2480
+ }
2481
+ /**
2482
+ * set checked state
2483
+ *
2484
+ * @returns {void}
2485
+ */
2486
+ setChecked() {
2487
+ // has "value" props type is not a boolean, it is bind/render as an attributes/props
2488
+ // true props will be represent by "true" string so we convert it has boolean
2489
+ // true attribute will be represent by "" string so we convert it has boolean
2490
+ // https://stenciljs.com/docs/properties
2491
+ if (['', 'true'].includes(this.value) && this.options.find(option => option.value) !== undefined) {
2492
+ this.value = true;
2493
+ }
2494
+ this.checked = this.value === this.options[1].value;
2495
+ }
2496
+ /*************
2497
+ * Lifecycle *
2498
+ *************/
2499
+ /**
2500
+ * Check if component props are well configured on init
2501
+ */
2502
+ componentWillLoad() {
2503
+ // Check items format
2504
+ this.validateItems(this.items);
2505
+ // Check slots
2506
+ this.validateSlots();
2507
+ // init checked value
2508
+ this.setChecked();
2509
+ // apply handler
2510
+ this.handleIsOnOff(this.isOnOff);
2511
+ this.handleIsIcon(this.isIcon);
2512
+ this.handleReadonly(this.readonly);
2513
+ this.handleDisabled(this.disabled);
2514
+ }
2515
+ /**
2516
+ * Render
2517
+ *
2518
+ * @returns {HTMLElement} HTML Element
2519
+ */
2520
+ render() {
2521
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, width: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, index.h("button", { type: "button", role: "switch", "aria-checked": this.checked, "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, index.h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, index.h("slot", { name: "item-1" })), index.h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, index.h("slot", { name: "item-2" })))));
2522
+ }
2523
+ get element() { return index.getElement(this); }
2524
+ static get watchers() { return {
2525
+ "value": ["handleValue"],
2526
+ "items": ["validateItems"],
2527
+ "isOnOff": ["handleIsOnOff"],
2528
+ "isIcon": ["handleIsIcon"],
2529
+ "readonly": ["handleReadonly"],
2530
+ "disabled": ["handleDisabled"],
2531
+ "checked": ["handleChecked"]
2532
+ }; }
2533
+ };
2534
+ MgInputToggle.style = mgInputToggleCss;
2535
+
2536
+ /**
2537
+ * List of all possibles message variants
2538
+ */
2539
+ const variants$1 = ['info', 'warning', 'success', 'danger'];
2540
+
2541
+ const mgMessageCss = ".mg-message{display:inline-block;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;min-height:var(--default-size);overflow:hidden;background-color:white;border-radius:var(--mg-message-border-radius);-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow)}.mg-message::before{content:\"\";position:absolute;top:0;left:0;width:0.3rem;height:100%}.mg-message.mg-message--info::before{background-color:hsl(var(--color-info))}.mg-message.mg-message--info .mg-message__icon{color:hsl(var(--color-info))}.mg-message.mg-message--warning::before{background-color:hsl(var(--color-warning))}.mg-message.mg-message--warning .mg-message__icon{color:hsl(var(--color-warning))}.mg-message.mg-message--success::before{background-color:hsl(var(--color-success))}.mg-message.mg-message--success .mg-message__icon{color:hsl(var(--color-success))}.mg-message.mg-message--danger::before{background-color:hsl(var(--color-danger))}.mg-message.mg-message--danger .mg-message__icon{color:hsl(var(--color-danger))}.mg-message.mg-message--close-button{padding-right:3.4rem}.mg-message.mg-message--hide{display:none}.mg-message ::slotted(*){margin:0;padding:0}.mg-message__icon{position:absolute;top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);left:1.3rem;line-height:1}.mg-message__content{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:end;justify-content:flex-end;-ms-flex-line-pack:stretch;align-content:stretch;padding:0 1rem 0 3.8rem}.mg-message__content-slot{-ms-flex-positive:1;flex-grow:1;margin:0.84rem 0}.mg-message__content-separator{display:inline-block;width:4.5rem;height:0}.mg-message__content-actions-slot{padding:1rem 0;text-align:right}.mg-message__close-button{position:absolute;top:0;right:0}.mg-message,mg-message{max-width:100%}";
2542
+
2543
+ const MgMessage = class {
2544
+ constructor(hostRef) {
2545
+ index.registerInstance(this, hostRef);
2546
+ this.componentShow = index.createEvent(this, "component-show", 7);
2547
+ this.componentHide = index.createEvent(this, "component-hide", 7);
2548
+ /************
2549
+ * Internal *
2550
+ ************/
2551
+ this.closeButtonId = '';
2552
+ // Stored timer setted when hide action is run from setTimeOut
2553
+ this.storedTimer = null;
2554
+ /**
2555
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2556
+ * If not set, it will be created.
2557
+ */
2558
+ this.identifier = index$1.createID('mg-message');
2559
+ /**
2560
+ * Message variant
2561
+ */
2562
+ this.variant = variants$1[0]; // info
2563
+ /**
2564
+ * Define if message has a cross button
2565
+ * RG 01: https://jira.mgdis.fr/browse/PDA9-140
2566
+ */
2567
+ this.closeButton = false;
2568
+ /**
2569
+ * Define if message is hidden
2570
+ */
2571
+ this.hide = false;
2572
+ /**
2573
+ * Component classes
2574
+ */
2575
+ this.classList = new index$1.ClassList(['mg-message']);
2576
+ /**
2577
+ * Define if component is using actions slot
2578
+ */
2579
+ this.hasActions = false;
2580
+ /**
2581
+ * Handle close button
2582
+ */
2583
+ this.handleClose = () => {
2584
+ this.hide = true;
2585
+ };
2586
+ /**
2587
+ * Hide component whith delay
2588
+ */
2589
+ this.hideWithDelay = () => {
2590
+ if (this.delay > 0 && this.hide !== true) {
2591
+ this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
2592
+ }
2593
+ else if (this.storedTimer !== null) {
2594
+ clearTimeout(this.storedTimer);
2595
+ }
2596
+ };
2597
+ /**
2598
+ * Get icon corresponding to variant
2599
+ *
2600
+ * @returns {string} icon
2601
+ */
2602
+ this.getIcon = () => {
2603
+ switch (this.variant) {
2604
+ case 'info':
2605
+ return 'info-circle';
2606
+ case 'warning':
2607
+ return 'exclamation-triangle';
2608
+ case 'success':
2609
+ return 'check-circle';
2610
+ case 'danger':
2611
+ return 'exclamation-circle';
2612
+ }
2613
+ };
2614
+ }
2615
+ validateDelay(newValue) {
2616
+ if (newValue && newValue < 2) {
2617
+ throw new Error(`<mg-message> prop "delay" must be greater than 2 seconds.`);
2618
+ }
2619
+ }
2620
+ validateVariant(newValue, oldValue) {
2621
+ if (!variants$1.includes(newValue)) {
2622
+ throw new Error(`<mg-message> prop "variant" must be one of : ${variants$1.join(', ')}`);
2623
+ }
2624
+ if (oldValue !== undefined) {
2625
+ this.classList.delete(`mg-message--${oldValue}`);
2626
+ }
2627
+ this.classList.add(`mg-message--${this.variant}`);
2628
+ }
2629
+ validateCloseButton(newValue) {
2630
+ if (newValue && this.hasActions) {
2631
+ this.closeButton = false;
2632
+ throw new Error('<mg-message> prop "close-button" can\'t be used with the actions slot.');
2633
+ }
2634
+ }
2635
+ validateHide(newValue) {
2636
+ if (newValue) {
2637
+ this.componentHide.emit();
2638
+ this.classList.add('mg-message--hide');
2639
+ }
2640
+ else {
2641
+ this.componentShow.emit();
2642
+ this.classList.delete('mg-message--hide');
2643
+ }
2644
+ this.hideWithDelay();
2645
+ }
2646
+ /*************
2647
+ * Lifecycle *
2648
+ *************/
2649
+ /**
2650
+ * Check if component props are well configured on init
2651
+ */
2652
+ componentWillLoad() {
2653
+ this.validateVariant(this.variant);
2654
+ // Check if close button is an can be activated
2655
+ this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
2656
+ this.validateCloseButton(this.closeButton);
2657
+ if (this.closeButton) {
2658
+ this.classList.add('mg-message--close-button');
2659
+ this.closeButtonId = `${this.identifier}-close-button`;
2660
+ }
2661
+ this.validateDelay(this.delay);
2662
+ this.validateHide(this.hide);
2663
+ }
2664
+ /**
2665
+ * Render
2666
+ *
2667
+ * @returns {HTMLElement} HTML Element
2668
+ */
2669
+ render() {
2670
+ return (index.h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, index.h("span", { class: "mg-message__icon" }, index.h("mg-icon", { icon: this.getIcon() })), index.h("div", { class: "mg-message__content" }, index.h("span", { class: "mg-message__content-slot" }, index.h("slot", null)), this.hasActions && index.h("span", { class: "mg-message__content-separator" }), this.hasActions && (index.h("span", { class: "mg-message__content-actions-slot" }, index.h("slot", { name: "actions" })))), this.closeButton && (index.h("span", { class: "mg-message__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: index$1.messages.message.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" }))))));
2671
+ }
2672
+ get element() { return index.getElement(this); }
2673
+ static get watchers() { return {
2674
+ "delay": ["validateDelay"],
2675
+ "variant": ["validateVariant"],
2676
+ "closeButton": ["validateCloseButton"],
2677
+ "hide": ["validateHide"]
2678
+ }; }
2679
+ };
2680
+ MgMessage.style = mgMessageCss;
2681
+
2682
+ var NavigationAction;
2683
+ (function (NavigationAction) {
2684
+ NavigationAction["NEXT"] = "next";
2685
+ NavigationAction["PREVIOUS"] = "previous";
2686
+ })(NavigationAction || (NavigationAction = {}));
2687
+
2688
+ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-pagination__nav{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}.mg-pagination__nav mg-input-select{margin-right:0.5rem}.mg-pagination__button{display:-ms-flexbox;display:flex}.mg-pagination__button:first-of-type{margin-right:1rem}.mg-pagination__button:last-of-type{margin-left:1rem}";
2689
+
2690
+ /**
2691
+ * Range generator
2692
+ *
2693
+ * start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
2694
+ * then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
2695
+ * then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
2696
+ * then with Array.from(Array(...)) we get the complete array with "index" values instead of "empty" values
2697
+ * ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
2698
+ * finaly we map values from "start" range and apply the "step" coefficiant,
2699
+ * ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
2700
+ *
2701
+ * range(1, 1) = [1]
2702
+ * range(1, 5) = [1, 2, 3, 4, 5]
2703
+ * range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
2704
+ *
2705
+ * @param {number} start start range
2706
+ * @param {number} end start end
2707
+ * @param {number} step step size
2708
+ * @returns {number[]} range numbers
2709
+ */
2710
+ const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
2711
+ const MgPagination = class {
2712
+ constructor(hostRef) {
2713
+ index.registerInstance(this, hostRef);
2714
+ this.currentPageChange = index.createEvent(this, "current-page-change", 7);
2715
+ /**************
2716
+ * Decorators *
2717
+ **************/
2718
+ /**
2719
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2720
+ * If not set, it will be created.
2721
+ */
2722
+ this.identifier = index$1.createID('mg-pagination');
2723
+ /**
2724
+ * Panignation label. Is a short description.
2725
+ * Customize default value can be usefull to improve accessibility
2726
+ */
2727
+ this.label = 'pagination';
2728
+ /**
2729
+ * Component total pages
2730
+ */
2731
+ this.totalPages = 1;
2732
+ /**
2733
+ * Component current page
2734
+ */
2735
+ this.currentPage = 1;
2736
+ /**
2737
+ * Change current page from target
2738
+ *
2739
+ * @param {number} target target page
2740
+ * @returns {void}
2741
+ */
2742
+ this.goToPage = (target) => {
2743
+ this.currentPage = target;
2744
+ };
2745
+ /************
2746
+ * Handlers *
2747
+ ************/
2748
+ /**
2749
+ * select handler
2750
+ *
2751
+ * @param {InputEvent} event value change event
2752
+ * @returns {void}
2753
+ */
2754
+ this.handleSelect = (event) => {
2755
+ const to = Number(event.target.value);
2756
+ this.goToPage(to > 0 ? to : 1);
2757
+ };
2758
+ /**
2759
+ * Go to 'previous/next' page button handler
2760
+ *
2761
+ * @param {string} action navigation action
2762
+ * @returns {void}
2763
+ */
2764
+ this.handleGoToPage = (action) => {
2765
+ this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
2766
+ };
2767
+ }
2768
+ validateTotalPages(newValue) {
2769
+ if (newValue < 1) {
2770
+ throw new Error('<mg-pagination> prop "totalPages" must be greater than 0');
2771
+ }
2772
+ }
2773
+ validateCurrentPage(newValue) {
2774
+ if (newValue < 1) {
2775
+ throw new Error('<mg-pagination> prop "currentPage" must be greater than 0');
2776
+ }
2777
+ else if (newValue > this.totalPages) {
2778
+ throw new Error('<mg-pagination> prop "currentPage" can not be greater than total page');
2779
+ }
2780
+ this.currentPageChange.emit(newValue);
2781
+ }
2782
+ /*************
2783
+ * Lifecycle *
2784
+ *************/
2785
+ /**
2786
+ * Check if props are well configured on init
2787
+ *
2788
+ * @returns {void}
2789
+ */
2790
+ componentWillLoad() {
2791
+ this.validateTotalPages(this.totalPages);
2792
+ this.validateCurrentPage(this.currentPage);
2793
+ }
2794
+ /**
2795
+ * Render
2796
+ *
2797
+ * @returns {HTMLElement} HTML Element
2798
+ */
2799
+ render() {
2800
+ const navigationActionButton = (disabled, action) => (index.h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: index$1.messages.pagination[`${action}Page`],
2801
+ // eslint-disable-next-line react/jsx-no-bind
2802
+ onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" }, action === NavigationAction.PREVIOUS && index.h("mg-icon", { icon: "chevron-left" }), index$1.messages.general[action], action === NavigationAction.NEXT && index.h("mg-icon", { icon: "chevron-right" })));
2803
+ return (index.h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination__nav" }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), index.h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: index$1.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), index.h("span", { class: "sr-only" }, index$1.messages.pagination.page, " ", this.currentPage), index.h("span", null, "/ ", this.totalPages, " ", this.totalPages > 1 ? index$1.messages.pagination.pages : index$1.messages.pagination.page), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
2804
+ }
2805
+ static get watchers() { return {
2806
+ "totalPages": ["validateTotalPages"],
2807
+ "currentPage": ["validateCurrentPage"]
2808
+ }; }
2809
+ };
2810
+ MgPagination.style = mgPaginationCss;
2811
+
2812
+ const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow)}.mg-panel__header{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:justify;justify-content:space-between;padding:0 1rem 0 0.3rem;-ms-flex-align:center;align-items:center}.mg-panel__header-left,.mg-panel__header-right{display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;margin:0.3rem 0}.mg-panel__header-left mg-input-text{-ms-flex-positive:1;flex-grow:1}.mg-panel__collapse-button{font-family:var(--font-family-heading);font-size:1.4rem;font-weight:500;margin:0 0.3rem 0 0}.mg-panel__content{padding:1.5rem}.mg-panel ::slotted([slot=header-right]){display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:1rem;margin-left:auto}";
2813
+
2814
+ const MgPanel = class {
2815
+ constructor(hostRef) {
2816
+ index.registerInstance(this, hostRef);
2817
+ this.titleChange = index.createEvent(this, "title-change", 7);
2818
+ /**************
2819
+ * Decorators *
2820
+ **************/
2821
+ /**
2822
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2823
+ * If not set, it will be created.
2824
+ */
2825
+ this.identifier = index$1.createID('mg-panel');
2826
+ /**
2827
+ * Panel is opened
2828
+ */
2829
+ this.expanded = false;
2830
+ /**
2831
+ * Panel title is editabled
2832
+ */
2833
+ this.titleEditable = false;
2834
+ /**
2835
+ * Component classes
2836
+ */
2837
+ this.classList = new index$1.ClassList(['mg-panel']);
2838
+ /**
2839
+ * Title is in edition mode
2840
+ */
2841
+ this.isEditing = false;
2842
+ /************
2843
+ * Methods *
2844
+ ************/
2845
+ /**
2846
+ * Toggle is editing state
2847
+ *
2848
+ * @returns {void}
2849
+ */
2850
+ this.toggleIsEditing = () => {
2851
+ this.isEditing = !this.isEditing;
2852
+ };
2853
+ /************
2854
+ * Handlers *
2855
+ ************/
2856
+ /**
2857
+ * Collapse button click handler
2858
+ *
2859
+ * @returns {void}
2860
+ */
2861
+ this.handleCollapseButton = () => {
2862
+ this.expanded = !this.expanded;
2863
+ };
2864
+ /**
2865
+ * Edit button click handler
2866
+ *
2867
+ * @returns {void}
2868
+ */
2869
+ this.handleEditButton = () => {
2870
+ this.toggleIsEditing();
2871
+ };
2872
+ /**
2873
+ * Update title handler
2874
+ *
2875
+ * @param {CustomEvent<string>} event input value change event
2876
+ * @returns {void}
2877
+ */
2878
+ this.handleUpdateTitle = (event) => {
2879
+ this.updatedPanelTitle = event.detail;
2880
+ };
2881
+ /**
2882
+ * Cancel edition button handler
2883
+ *
2884
+ * @returns {void}
2885
+ */
2886
+ this.handleCancelEditButton = () => {
2887
+ this.updatedPanelTitle = undefined;
2888
+ this.toggleIsEditing();
2889
+ };
2890
+ /**
2891
+ * Validate edition button handler
2892
+ *
2893
+ * @returns {void}
2894
+ */
2895
+ this.handleValidateEditButton = () => {
2896
+ if (this.updatedPanelTitle !== undefined)
2897
+ this.panelTitle = this.updatedPanelTitle;
2898
+ this.toggleIsEditing();
2899
+ };
2900
+ /*************
2901
+ * Lifecycle *
2902
+ *************/
2903
+ /**
2904
+ * Header left conditional render
2905
+ *
2906
+ * @typedef {HTMLElement} HTMLMgButtonElement
2907
+ * @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
2908
+ */
2909
+ this.headerLeft = () => {
2910
+ const collapseButton = () => (index.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` }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle));
2911
+ if (this.titleEditable && !this.isEditing) {
2912
+ return [
2913
+ collapseButton(),
2914
+ index.h("mg-button", { "is-icon": true, variant: "secondary", label: index$1.messages.panel.editLabel, onClick: this.handleEditButton, identifier: `${this.identifier}-edit-button` }, index.h("mg-icon", { icon: "pen" })),
2915
+ ];
2916
+ }
2917
+ if (this.titleEditable && this.isEditing) {
2918
+ return [
2919
+ collapseButton(),
2920
+ index.h("mg-input-text", { label: index$1.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) }, index.h("mg-button", { slot: "append-input", label: index$1.messages.general.cancel, "is-icon": true, variant: "secondary", onClick: this.handleCancelEditButton, identifier: `${this.identifier}-edition-button-cancel` }, index.h("mg-icon", { icon: "cross" })), index.h("mg-button", { slot: "append-input", label: index$1.messages.general.validate, "is-icon": true, variant: "secondary", onClick: this.handleValidateEditButton, identifier: `${this.identifier}-edition-button-validate` }, index.h("mg-icon", { icon: "check" }))),
2921
+ ];
2922
+ }
2923
+ return collapseButton();
2924
+ };
2925
+ }
2926
+ handelTileChange(newValue) {
2927
+ this.titleChange.emit(newValue);
2928
+ }
2929
+ /**
2930
+ * Edit DOM after render
2931
+ *
2932
+ * @returns {void}
2933
+ */
2934
+ componentDidRender() {
2935
+ // when we are editing we get focus on edition input
2936
+ if (this.isEditing) {
2937
+ this.editInputElement.setFocus();
2938
+ }
2939
+ }
2940
+ /**
2941
+ * Render component
2942
+ *
2943
+ * @returns {HTMLElement} html element
2944
+ */
2945
+ render() {
2946
+ return (index.h("section", { class: this.classList.join(), id: this.identifier }, index.h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, index.h("div", { class: "mg-panel__header-left" }, this.headerLeft()), index.h("div", { class: "mg-panel__header-right" }, index.h("slot", { name: "header-right" }))), index.h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, index.h("slot", null))));
2947
+ }
2948
+ static get watchers() { return {
2949
+ "panelTitle": ["handelTileChange"]
2950
+ }; }
2951
+ };
2952
+ MgPanel.style = mgPanelCss;
2953
+
2954
+ /**
2955
+ * List of all possibles sizes
2956
+ */
2957
+ const sizes = ['regular', 'large'];
2958
+
2959
+ const mgTabsCss = ".mg-tabs.mg-tabs--size-regular.sc-mg-tabs .mg-tabs__navigation-button.sc-mg-tabs{padding:calc(1rem + 0.3rem) calc(1rem * 1.3) 1rem}.mg-tabs.mg-tabs--size-large.sc-mg-tabs .mg-tabs__navigation-button.sc-mg-tabs{padding:calc(1.8rem + 0.3rem) calc(1.8rem * 1.3) 1.8rem}.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;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:disabled,.mg-tabs__navigation-button--disabled.sc-mg-tabs{cursor:default;opacity:30%}.mg-tabs__navigation-button.sc-mg-tabs:hover:not(:disabled),.mg-tabs__navigation-button.sc-mg-tabs: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.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:none}";
2960
+
2961
+ /**
2962
+ * type TabItem validation function
2963
+ *
2964
+ * @param {TabItem} tab tab item
2965
+ * @returns {boolean} tab item type is valid
2966
+ */
2967
+ const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
2968
+ const MgTabs = class {
2969
+ constructor(hostRef) {
2970
+ index.registerInstance(this, hostRef);
2971
+ /**
2972
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2973
+ * If not set, it will be created.
2974
+ */
2975
+ this.identifier = index$1.createID('mg-tabs');
2976
+ /**
2977
+ * Define tabs size
2978
+ */
2979
+ this.size = 'regular';
2980
+ /**
2981
+ * Active tab number
2982
+ * default: first is 1
2983
+ */
2984
+ this.activeTab = 1;
2985
+ /**
2986
+ * Component tabs
2987
+ */
2988
+ this.tabs = [];
2989
+ /**
2990
+ * Component classes
2991
+ */
2992
+ this.classList = new index$1.ClassList(['mg-tabs']);
2993
+ /**
2994
+ * Handle click events on tabs
2995
+ *
2996
+ * @param {MouseEvent} event mouse event
2997
+ */
2998
+ this.handleClick = (event) => {
2999
+ const tabId = event.currentTarget.getAttribute('data-index');
3000
+ this.activeTab = Number(tabId);
3001
+ };
3002
+ /**
3003
+ * Handle keyboard event on tabs
3004
+ *
3005
+ * @param {MouseEvent} event mouse event
3006
+ * @returns {void}
3007
+ */
3008
+ this.handleKeydown = (event) => {
3009
+ let tabId = Number(event.target.getAttribute('data-index'));
3010
+ const parent = event.target.parentElement;
3011
+ // change selected id from key code
3012
+ // /* IE FIX */ delete 'Right'
3013
+ if (['ArrowRight', 'Right'].includes(event.key)) {
3014
+ tabId++;
3015
+ // /* IE FIX */ delete 'Left'
3016
+ }
3017
+ else if (['ArrowLeft', 'Left'].includes(event.key)) {
3018
+ tabId--;
3019
+ }
3020
+ // get selected tab
3021
+ const selectedTab = parent.querySelector(`[data-index="${tabId}"]`);
3022
+ // apply selected tab if exist
3023
+ if (selectedTab !== null) {
3024
+ selectedTab.focus();
3025
+ this.activeTab = tabId;
3026
+ }
3027
+ };
3028
+ /**
3029
+ * Validate slots setting
3030
+ */
3031
+ this.validateSlots = () => {
3032
+ const slots = Array.from(this.element.children).filter(slot => { var _a; return (_a = slot.getAttribute('slot')) === null || _a === void 0 ? void 0 : _a.includes('tab_content-'); });
3033
+ if (slots.length !== this.tabs.length) {
3034
+ throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
3035
+ }
3036
+ };
3037
+ }
3038
+ validateSize(newValue) {
3039
+ if (!sizes.includes(newValue)) {
3040
+ throw new Error(`<mg-tabs> prop "size" must be one of : ${sizes.join(', ')}`);
3041
+ }
3042
+ this.classList.add(`mg-tabs--size-${this.size}`);
3043
+ }
3044
+ validateItems(newValue) {
3045
+ // String array
3046
+ if (index$1.allItemsAreString(newValue)) {
3047
+ this.tabs = newValue.map(item => ({ label: item, disabled: false }));
3048
+ }
3049
+ // Object array
3050
+ else if (newValue && newValue.every(item => isTabItem(item))) {
3051
+ this.tabs = newValue;
3052
+ }
3053
+ else {
3054
+ throw new Error('<mg-tabs> prop "items" is required and all items must be the same type: TabItem.');
3055
+ }
3056
+ }
3057
+ validateActiveTab(newValue) {
3058
+ if (Number(newValue) < 1 || Number(newValue) > this.tabs.length) {
3059
+ throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
3060
+ }
3061
+ }
3062
+ /*************
3063
+ * Lifecycle *
3064
+ *************/
3065
+ /**
3066
+ * Check if component props are well configured on init
3067
+ *
3068
+ * @returns {void}
3069
+ */
3070
+ componentWillLoad() {
3071
+ // Check tabs format
3072
+ this.validateItems(this.items);
3073
+ this.validateActiveTab(this.activeTab);
3074
+ this.validateSize(this.size);
3075
+ this.validateSlots();
3076
+ }
3077
+ /**
3078
+ * Render
3079
+ *
3080
+ * @returns {HTMLElement} HTML Element
3081
+ */
3082
+ render() {
3083
+ return (index.h(index.Host, null, index.h("div", { class: this.classList.join() }, index.h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index$1) => {
3084
+ const tabIndex = index$1 + 1;
3085
+ return (index.h("button", { role: "tab", id: `${this.identifier}-${tabIndex}`, class: {
3086
+ 'mg-tabs__navigation-button': true,
3087
+ 'mg-tabs__navigation-button--active': tabIndex === this.activeTab,
3088
+ 'mg-tabs__navigation-button--disabled': tab.disabled,
3089
+ }, 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, disabled: tab.disabled }, tab.icon !== undefined && index.h("mg-icon", { icon: tab.icon }), tab.label, tab.badge !== undefined && index.h("mg-badge", { variant: "info", value: tab.badge.value, label: tab.badge.label })));
3090
+ })), this.tabs.map((_tab, index$1) => {
3091
+ const tabIndex = index$1 + 1;
3092
+ return (index.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" }, index.h("slot", { name: `tab_content-${tabIndex}` })));
3093
+ }))));
3094
+ }
3095
+ get element() { return index.getElement(this); }
3096
+ static get watchers() { return {
3097
+ "size": ["validateSize"],
3098
+ "items": ["validateItems"],
3099
+ "activeTab": ["validateActiveTab"]
3100
+ }; }
3101
+ };
3102
+ MgTabs.style = mgTabsCss;
3103
+
3104
+ /**
3105
+ * List of all possibles variants
3106
+ */
3107
+ const variants = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'];
3108
+
3109
+ 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}";
3110
+
3111
+ const MgTag = class {
3112
+ constructor(hostRef) {
3113
+ index.registerInstance(this, hostRef);
3114
+ /**
3115
+ * Define button variant
3116
+ */
3117
+ this.variant = variants[0]; // info
3118
+ /**
3119
+ * Component classes
3120
+ */
3121
+ this.classList = new index$1.ClassList(['mg-tag']);
3122
+ }
3123
+ validateVariant(newValue) {
3124
+ if (!variants.includes(newValue)) {
3125
+ throw new Error(`<mg-tag> prop "variant" must be one of : ${variants.join(', ')}.`);
3126
+ }
3127
+ this.classList.add(`mg-tag--${this.variant}`);
3128
+ }
3129
+ validateOutline(newValue) {
3130
+ if (newValue)
3131
+ this.classList.add(`mg-tag--outline`);
3132
+ }
3133
+ /*************
3134
+ * Lifecycle *
3135
+ *************/
3136
+ /**
3137
+ * Check if props are well configured on init
3138
+ *
3139
+ * @returns {void}
3140
+ */
3141
+ componentWillLoad() {
3142
+ this.validateVariant(this.variant);
3143
+ this.validateOutline(this.outline);
3144
+ }
3145
+ /**
3146
+ * Render
3147
+ *
3148
+ * @returns {HTMLElement} HTML Element
3149
+ */
3150
+ render() {
3151
+ return (index.h("span", { class: this.classList.join() }, index.h("slot", null)));
3152
+ }
3153
+ static get watchers() { return {
3154
+ "variant": ["validateVariant"],
3155
+ "outline": ["validateOutline"]
3156
+ }; }
3157
+ };
3158
+ MgTag.style = mgTagCss;
3159
+
3160
+ const mgTooltipCss = ".sc-mg-tooltip-h{display:inline-block}.mg-tooltip.sc-mg-tooltip{display:none;padding:0.5rem 0.8rem;z-index:9999;border-radius:var(--mg-tooltip-border-radius);background-color:hsl(var(--mg-tooltip-background-color));color:hsl(var(--mg-tooltip-font-color));text-align:start}.mg-tooltip[data-show].sc-mg-tooltip{display:block}.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip,.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip::before{position:absolute;width:0.8rem;height:0.8rem;z-index:9999;background:inherit}.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip{visibility:hidden}.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip::before{visibility:visible;content:\"\";-webkit-transform:rotate(45deg);transform:rotate(45deg)}.mg-tooltip[data-popper-placement^=top].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{bottom:-4px}.mg-tooltip[data-popper-placement^=bottom].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{top:-4px}.mg-tooltip[data-popper-placement^=left].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{right:-4px}.mg-tooltip[data-popper-placement^=right].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{left:-4px}";
3161
+
3162
+ const MgTooltip = class {
3163
+ constructor(hostRef) {
3164
+ index.registerInstance(this, hostRef);
3165
+ /**
3166
+ * Sets an `id` attribute.
3167
+ * Needed by the input for accessibility `aria-decribedby`.
3168
+ */
3169
+ this.identifier = index$1.createID('mg-tooltip');
3170
+ /**
3171
+ * Tooltip placement
3172
+ */
3173
+ this.placement = 'bottom';
3174
+ /**
3175
+ * Display tooltip
3176
+ */
3177
+ this.display = false;
3178
+ /**
3179
+ * Disable tooltip
3180
+ */
3181
+ this.disabled = false;
3182
+ /**
3183
+ * Show tooltip
3184
+ *
3185
+ * @returns {void}
3186
+ */
3187
+ this.show = () => {
3188
+ // Make the tooltip visible
3189
+ this.tooltip.setAttribute('data-show', '');
3190
+ // Enable the event listeners
3191
+ this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
3192
+ // Update its position
3193
+ this.popper.update();
3194
+ };
3195
+ /**
3196
+ * Hide tooltip
3197
+ *
3198
+ * @returns {void}
3199
+ */
3200
+ this.hide = () => {
3201
+ // Hide the tooltip
3202
+ this.tooltip.removeAttribute('data-show');
3203
+ // Disable the event listeners
3204
+ this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
3205
+ };
3206
+ }
3207
+ handleDisplay(newVal) {
3208
+ if (newVal) {
3209
+ this.show();
3210
+ }
3211
+ else {
3212
+ this.hide();
3213
+ }
3214
+ }
3215
+ /*************
3216
+ * Lifecycle *
3217
+ *************/
3218
+ /**
3219
+ * Get slotted element
3220
+ * Check if it already contain an interactive element, if not we need to add a tabIndex attribute
3221
+ * We need to attach the focused element to the tooltip (aria-describedby)
3222
+ *
3223
+ * @returns {void}
3224
+ */
3225
+ componentDidLoad() {
3226
+ var _a;
3227
+ // Get tooltip element
3228
+ this.tooltip = this.element.querySelector(`#${this.identifier}`);
3229
+ // get slotted element
3230
+ const slotElement = this.element.firstElementChild;
3231
+ // Get interactive element
3232
+ const interactiveElements = ['a', 'button', 'input', 'textarea', 'select']; //! Might needs updates
3233
+ const interactiveElement = this.element.querySelector(interactiveElements.join(',')) || ((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
3234
+ // define selected element to become tooltip selector
3235
+ const tooltipedElement = interactiveElement || slotElement;
3236
+ // Add tabindex to slotted element if we can't find any interactive element
3237
+ if (interactiveElement === null || interactiveElement === undefined)
3238
+ slotElement.tabIndex = 0;
3239
+ // Set aria-describedby
3240
+ const ariaDescribedby = slotElement.getAttribute('aria-describedby');
3241
+ if (ariaDescribedby === null) {
3242
+ tooltipedElement.setAttribute('aria-describedby', this.identifier);
3243
+ }
3244
+ else {
3245
+ slotElement.setAttribute('aria-describedby', `${ariaDescribedby} ${this.identifier}`);
3246
+ }
3247
+ // Create popperjs tooltip
3248
+ this.popper = popper.createPopper(tooltipedElement, this.tooltip, {
3249
+ placement: this.placement,
3250
+ modifiers: [
3251
+ {
3252
+ name: 'offset',
3253
+ options: {
3254
+ offset: [0, 8],
3255
+ },
3256
+ },
3257
+ ],
3258
+ });
3259
+ // Add events
3260
+ ['mouseenter', 'focus'].forEach(event => {
3261
+ tooltipedElement.addEventListener(event, () => {
3262
+ if (!this.disabled)
3263
+ this.display = true;
3264
+ });
3265
+ });
3266
+ ['mouseleave', 'blur', 'keydown'].forEach(event => {
3267
+ tooltipedElement.addEventListener(event, (e) => {
3268
+ // we continue to process ONLY for KeyboardEvents 'Escape'
3269
+ if (e.type === 'keydown' && e.code !== 'Escape') {
3270
+ return;
3271
+ }
3272
+ if (!this.disabled)
3273
+ this.display = false;
3274
+ });
3275
+ });
3276
+ this.handleDisplay(this.display);
3277
+ }
3278
+ /**
3279
+ * Render
3280
+ *
3281
+ * @returns {HTMLElement} HTML Element
3282
+ */
3283
+ render() {
3284
+ return (index.h(index.Host, null, index.h("slot", null), index.h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip", innerHTML: this.message }, index.h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
3285
+ }
3286
+ get element() { return index.getElement(this); }
3287
+ static get watchers() { return {
3288
+ "display": ["handleDisplay"]
3289
+ }; }
3290
+ };
3291
+ MgTooltip.style = mgTooltipCss;
3292
+
3293
+ exports.mg_badge = MgBadge;
3294
+ exports.mg_button = MgButton;
3295
+ exports.mg_character_left = MgCharacterLeft;
3296
+ exports.mg_form = MgForm;
3297
+ exports.mg_icon = MgIcon;
3298
+ exports.mg_input_checkbox = MgInputCheckbox;
3299
+ exports.mg_input_date = MgInputDate;
3300
+ exports.mg_input_numeric = MgInputNumeric;
3301
+ exports.mg_input_password = MgInputPassword;
3302
+ exports.mg_input_radio = MgInputRadio;
3303
+ exports.mg_input_select = MgInputSelect;
3304
+ exports.mg_input_text = MgInputText;
3305
+ exports.mg_input_textarea = MgInputTextarea;
3306
+ exports.mg_input_title = MgInputTitle;
3307
+ exports.mg_input_toggle = MgInputToggle;
3308
+ exports.mg_message = MgMessage;
3309
+ exports.mg_pagination = MgPagination;
3310
+ exports.mg_panel = MgPanel;
3311
+ exports.mg_tabs = MgTabs;
3312
+ exports.mg_tag = MgTag;
3313
+ exports.mg_tooltip = MgTooltip;