@mgdis/mg-components 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/LICENSE +29 -0
  2. package/dist/cjs/css-shim-a22512c4.js +6 -0
  3. package/dist/cjs/index-85a4a0b6.js +1674 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +35 -0
  6. package/dist/cjs/mg-badge_20.cjs.entry.js +4661 -0
  7. package/dist/cjs/mg-components.cjs.js +23 -0
  8. package/dist/cjs/shadow-css-8940f82d.js +390 -0
  9. package/dist/collection/collection-manifest.json +31 -0
  10. package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +4 -0
  11. package/dist/collection/components/atoms/mg-badge/mg-badge.css +99 -0
  12. package/dist/collection/components/atoms/mg-badge/mg-badge.js +148 -0
  13. package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +27 -0
  14. package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
  15. package/dist/collection/components/atoms/mg-button/mg-button.css +134 -0
  16. package/dist/collection/components/atoms/mg-button/mg-button.js +236 -0
  17. package/dist/collection/components/atoms/mg-button/mg-button.stories.js +38 -0
  18. package/dist/collection/components/atoms/mg-character-left/mg-character-left.css +3 -0
  19. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +133 -0
  20. package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +15 -0
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +54 -0
  22. package/dist/collection/components/atoms/mg-icon/mg-icon.css +57 -0
  23. package/dist/collection/components/atoms/mg-icon/mg-icon.js +155 -0
  24. package/dist/collection/components/atoms/mg-icon/mg-icon.stories.js +34 -0
  25. package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +12 -0
  26. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +95 -0
  27. package/dist/collection/components/atoms/mg-input-title/mg-input-title.stories.js +21 -0
  28. package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js +4 -0
  29. package/dist/collection/components/atoms/mg-tag/mg-tag.css +73 -0
  30. package/dist/collection/components/atoms/mg-tag/mg-tag.js +94 -0
  31. package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +25 -0
  32. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +44 -0
  33. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +225 -0
  34. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.stories.js +26 -0
  35. package/dist/collection/components/molecules/inputs/MgInput.conf.js +7 -0
  36. package/dist/collection/components/molecules/inputs/MgInput.js +130 -0
  37. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +1 -0
  38. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +156 -0
  39. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +444 -0
  40. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +57 -0
  41. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +7 -0
  42. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +171 -0
  43. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +467 -0
  44. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +46 -0
  45. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +11 -0
  46. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +199 -0
  47. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +633 -0
  48. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +68 -0
  49. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +195 -0
  50. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +401 -0
  51. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +43 -0
  52. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js +1 -0
  53. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +156 -0
  54. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +443 -0
  55. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +65 -0
  56. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js +1 -0
  57. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +201 -0
  58. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +532 -0
  59. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +70 -0
  60. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +222 -0
  61. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +589 -0
  62. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +115 -0
  63. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +217 -0
  64. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +553 -0
  65. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +52 -0
  66. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +1 -0
  67. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +213 -0
  68. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +457 -0
  69. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +73 -0
  70. package/dist/collection/components/molecules/mg-message/mg-message.conf.js +4 -0
  71. package/dist/collection/components/molecules/mg-message/mg-message.css +94 -0
  72. package/dist/collection/components/molecules/mg-message/mg-message.js +285 -0
  73. package/dist/collection/components/molecules/mg-message/mg-message.stories.js +43 -0
  74. package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +5 -0
  75. package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +39 -0
  76. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +218 -0
  77. package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +23 -0
  78. package/dist/collection/components/molecules/mg-popover/mg-popover.css +59 -0
  79. package/dist/collection/components/molecules/mg-popover/mg-popover.js +249 -0
  80. package/dist/collection/components/molecules/mg-popover/mg-popover.stories.js +36 -0
  81. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +1 -0
  82. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +30 -0
  83. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +212 -0
  84. package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +40 -0
  85. package/dist/collection/fonts/OpenSans-Regular.ttf +0 -0
  86. package/dist/collection/fonts/OpenSans-SemiBold.ttf +0 -0
  87. package/dist/collection/fonts/Poppins-Bold.ttf +0 -0
  88. package/dist/collection/index.js +1 -0
  89. package/dist/collection/locales/index.js +4 -0
  90. package/dist/collection/stories/buttons.stories.js +43 -0
  91. package/dist/collection/stories/grids.stories.js +50 -0
  92. package/dist/collection/stories/icons.stories.js +20 -0
  93. package/dist/collection/stories/messages.stories.js +44 -0
  94. package/dist/collection/stories/tags.stories.js +13 -0
  95. package/dist/collection/stories/typography.stories.js +28 -0
  96. package/dist/collection/utils/components.utils.js +67 -0
  97. package/dist/collection/utils/locale.utils.js +32 -0
  98. package/dist/collection/utils/test.utils.js +26 -0
  99. package/dist/collection/variables.css +177 -0
  100. package/dist/collection/variables.scss +177 -0
  101. package/dist/components/MgInput.js +140 -0
  102. package/dist/components/components.utils.js +69 -0
  103. package/dist/components/index.d.ts +26 -0
  104. package/dist/components/index.js +1 -0
  105. package/dist/components/index2.js +54 -0
  106. package/dist/components/locale.utils.js +35 -0
  107. package/dist/components/mg-badge.d.ts +11 -0
  108. package/dist/components/mg-badge.js +6 -0
  109. package/dist/components/mg-badge2.js +82 -0
  110. package/dist/components/mg-button.d.ts +11 -0
  111. package/dist/components/mg-button.js +6 -0
  112. package/dist/components/mg-button2.js +148 -0
  113. package/dist/components/mg-character-left.d.ts +11 -0
  114. package/dist/components/mg-character-left.js +6 -0
  115. package/dist/components/mg-character-left2.js +77 -0
  116. package/dist/components/mg-icon.d.ts +11 -0
  117. package/dist/components/mg-icon.js +6 -0
  118. package/dist/components/mg-icon2.js +147 -0
  119. package/dist/components/mg-input-checkbox.d.ts +11 -0
  120. package/dist/components/mg-input-checkbox.js +222 -0
  121. package/dist/components/mg-input-date.d.ts +11 -0
  122. package/dist/components/mg-input-date.js +245 -0
  123. package/dist/components/mg-input-numeric.d.ts +11 -0
  124. package/dist/components/mg-input-numeric.js +324 -0
  125. package/dist/components/mg-input-password.d.ts +11 -0
  126. package/dist/components/mg-input-password.js +171 -0
  127. package/dist/components/mg-input-radio.d.ts +11 -0
  128. package/dist/components/mg-input-radio.js +211 -0
  129. package/dist/components/mg-input-select.d.ts +11 -0
  130. package/dist/components/mg-input-select.js +6 -0
  131. package/dist/components/mg-input-select2.js +243 -0
  132. package/dist/components/mg-input-text.d.ts +11 -0
  133. package/dist/components/mg-input-text.js +242 -0
  134. package/dist/components/mg-input-textarea.d.ts +11 -0
  135. package/dist/components/mg-input-textarea.js +224 -0
  136. package/dist/components/mg-input-title.d.ts +11 -0
  137. package/dist/components/mg-input-title.js +6 -0
  138. package/dist/components/mg-input-title2.js +55 -0
  139. package/dist/components/mg-input-toggle.d.ts +11 -0
  140. package/dist/components/mg-input-toggle.js +247 -0
  141. package/dist/components/mg-message.d.ts +11 -0
  142. package/dist/components/mg-message.js +183 -0
  143. package/dist/components/mg-pagination.d.ts +11 -0
  144. package/dist/components/mg-pagination.js +175 -0
  145. package/dist/components/mg-popover.d.ts +11 -0
  146. package/dist/components/mg-popover.js +183 -0
  147. package/dist/components/mg-tabs.d.ts +11 -0
  148. package/dist/components/mg-tabs.js +160 -0
  149. package/dist/components/mg-tag.d.ts +11 -0
  150. package/dist/components/mg-tag.js +76 -0
  151. package/dist/components/mg-tooltip.d.ts +11 -0
  152. package/dist/components/mg-tooltip.js +6 -0
  153. package/dist/components/mg-tooltip2.js +150 -0
  154. package/dist/components/popper.js +1784 -0
  155. package/dist/esm/css-shim-7c240feb.js +4 -0
  156. package/dist/esm/index-e3e84606.js +1643 -0
  157. package/dist/esm/index.js +1 -0
  158. package/dist/esm/loader.js +31 -0
  159. package/dist/esm/mg-badge_20.entry.js +4638 -0
  160. package/dist/esm/mg-components.js +21 -0
  161. package/dist/esm/polyfills/core-js.js +11 -0
  162. package/dist/esm/polyfills/css-shim.js +1 -0
  163. package/dist/esm/polyfills/dom.js +79 -0
  164. package/dist/esm/polyfills/es5-html-element.js +1 -0
  165. package/dist/esm/polyfills/index.js +34 -0
  166. package/dist/esm/polyfills/system.js +6 -0
  167. package/dist/esm/shadow-css-5d2d01ce.js +388 -0
  168. package/dist/esm-es5/css-shim-7c240feb.js +1 -0
  169. package/dist/esm-es5/index-e3e84606.js +1 -0
  170. package/dist/esm-es5/index.js +0 -0
  171. package/dist/esm-es5/loader.js +1 -0
  172. package/dist/esm-es5/mg-badge_20.entry.js +2 -0
  173. package/dist/esm-es5/mg-components.js +1 -0
  174. package/dist/esm-es5/shadow-css-5d2d01ce.js +12 -0
  175. package/dist/index.cjs.js +1 -0
  176. package/dist/index.js +1 -0
  177. package/dist/mg-components/fonts/OpenSans-Regular.ttf +0 -0
  178. package/dist/mg-components/fonts/OpenSans-SemiBold.ttf +0 -0
  179. package/dist/mg-components/fonts/Poppins-Bold.ttf +0 -0
  180. package/dist/mg-components/index.esm.js +0 -0
  181. package/dist/mg-components/mg-components.css +1 -0
  182. package/dist/mg-components/mg-components.esm.js +1 -0
  183. package/dist/mg-components/mg-components.js +132 -0
  184. package/dist/mg-components/p-1cd24462.system.js +1 -0
  185. package/dist/mg-components/p-2e2f6b27.system.entry.js +2 -0
  186. package/dist/mg-components/p-366a224e.js +1 -0
  187. package/dist/mg-components/p-422c429b.system.js +1 -0
  188. package/dist/mg-components/p-50ea2036.system.js +1 -0
  189. package/dist/mg-components/p-62fa3797.js +1 -0
  190. package/dist/mg-components/p-71d57b8b.system.js +13 -0
  191. package/dist/mg-components/p-9a215712.system.js +1 -0
  192. package/dist/mg-components/p-cbf0464b.entry.js +1 -0
  193. package/dist/mg-components/p-f6455ab3.js +12 -0
  194. package/dist/mg-components/variables.css +177 -0
  195. package/dist/mg-components/variables.scss +177 -0
  196. package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +8 -0
  197. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +36 -0
  198. package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +19 -0
  199. package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +4 -0
  200. package/dist/types/components/atoms/mg-button/mg-button.d.ts +67 -0
  201. package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +16 -0
  202. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +39 -0
  203. package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +7 -0
  204. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +12 -0
  205. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +36 -0
  206. package/dist/types/components/atoms/mg-icon/mg-icon.stories.d.ts +26 -0
  207. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +24 -0
  208. package/dist/types/components/atoms/mg-input-title/mg-input-title.stories.d.ts +6 -0
  209. package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +4 -0
  210. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +25 -0
  211. package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +14 -0
  212. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +56 -0
  213. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +11 -0
  214. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +10 -0
  215. package/dist/types/components/molecules/inputs/MgInput.d.ts +35 -0
  216. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +19 -0
  217. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +120 -0
  218. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +6 -0
  219. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +6 -0
  220. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +128 -0
  221. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +7 -0
  222. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +10 -0
  223. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +173 -0
  224. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +21 -0
  225. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +111 -0
  226. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +9 -0
  227. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +9 -0
  228. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +121 -0
  229. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +15 -0
  230. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +18 -0
  231. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +133 -0
  232. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +14 -0
  233. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +160 -0
  234. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +26 -0
  235. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +150 -0
  236. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +6 -0
  237. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +8 -0
  238. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +117 -0
  239. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +7 -0
  240. package/dist/types/components/molecules/mg-message/mg-message.conf.d.ts +4 -0
  241. package/dist/types/components/molecules/mg-message/mg-message.d.ts +76 -0
  242. package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +16 -0
  243. package/dist/types/components/molecules/mg-pagination/mg-pagination.conf.d.ts +4 -0
  244. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +53 -0
  245. package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +6 -0
  246. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +62 -0
  247. package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +12 -0
  248. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +10 -0
  249. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +63 -0
  250. package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +7 -0
  251. package/dist/types/components.d.ts +1987 -0
  252. package/dist/types/index.d.ts +1 -0
  253. package/dist/types/locales/index.d.ts +44 -0
  254. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  255. package/dist/types/stories/buttons.stories.d.ts +13 -0
  256. package/dist/types/stories/grids.stories.d.ts +5 -0
  257. package/dist/types/stories/icons.stories.d.ts +13 -0
  258. package/dist/types/stories/messages.stories.d.ts +13 -0
  259. package/dist/types/stories/tags.stories.d.ts +5 -0
  260. package/dist/types/stories/typography.stories.d.ts +5 -0
  261. package/dist/types/utils/components.utils.d.ts +43 -0
  262. package/dist/types/utils/locale.utils.d.ts +22 -0
  263. package/dist/types/utils/test.utils.d.ts +5 -0
  264. package/loader/cdn.js +3 -0
  265. package/loader/index.cjs.js +3 -0
  266. package/loader/index.d.ts +12 -0
  267. package/loader/index.es2017.js +3 -0
  268. package/loader/index.js +4 -0
  269. package/loader/package.json +10 -0
  270. package/package.json +86 -0
  271. package/readme.md +159 -0
@@ -0,0 +1,4661 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-85a4a0b6.js');
6
+
7
+ /**
8
+ * List of all possibles variants
9
+ */
10
+ const variants$4 = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'];
11
+
12
+ /**
13
+ * Create random ID
14
+ * @param prefix {string} add prefix to created ID
15
+ * @returns {string} ID
16
+ */
17
+ function createID(prefix = '', length = 10) {
18
+ let ID = '';
19
+ const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
20
+ const charsLength = chars.length;
21
+ for (var i = 0; i < length; i++) {
22
+ ID += chars.charAt(Math.floor(Math.random() * charsLength));
23
+ }
24
+ return (prefix !== '' ? `${prefix}-` : '') + ID;
25
+ }
26
+ /**
27
+ * Class to manage component classlist
28
+ * Set() are not working when imported in project
29
+ */
30
+ class ClassList {
31
+ constructor(classlist = []) {
32
+ /**
33
+ * Add class
34
+ * @param className
35
+ * @returns {void}
36
+ */
37
+ this.add = (className) => {
38
+ if (!this.has(className)) {
39
+ this.classes.push(className);
40
+ }
41
+ };
42
+ /**
43
+ * Delete class
44
+ * @param className
45
+ * @returns {void}
46
+ */
47
+ this.delete = (className) => {
48
+ const index = this.classes.indexOf(className);
49
+ if (index > -1) {
50
+ this.classes.splice(index, 1);
51
+ }
52
+ };
53
+ /**
54
+ * Check if class exist in list
55
+ * @param className
56
+ * @returns {boolean}
57
+ */
58
+ this.has = (className) => {
59
+ return this.classes.includes(className);
60
+ };
61
+ /**
62
+ * Join classes seperated by spaces
63
+ * @returns {string}
64
+ */
65
+ this.join = () => {
66
+ return this.classes.join(' ');
67
+ };
68
+ this.classes = classlist;
69
+ }
70
+ }
71
+ /**
72
+ * Check if all items are string
73
+ * @param items
74
+ * @returns {boolean}
75
+ */
76
+ function allItemsAreString(items) {
77
+ return items && items.every(item => typeof item === 'string');
78
+ }
79
+
80
+ 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}";
81
+
82
+ const MgBadge = class {
83
+ constructor(hostRef) {
84
+ index.registerInstance(this, hostRef);
85
+ /**
86
+ * Define button variant
87
+ */
88
+ this.variant = variants$4[variants$4.length - 1];
89
+ /**
90
+ * Component classes
91
+ */
92
+ this.classList = new ClassList(['mg-badge']);
93
+ }
94
+ valideValue(newValue) {
95
+ if (`${newValue}`.match(/^(\d+|[?*!a-z])$/i) === null) {
96
+ throw new Error('<mg-badge> prop "value" must be interger or ponctuation character.');
97
+ }
98
+ }
99
+ validateVariant(newValue) {
100
+ if (!variants$4.includes(newValue)) {
101
+ throw new Error(`<mg-badge> prop "variant" must be one of : ${variants$4.join(', ')}.`);
102
+ }
103
+ this.classList.add(`mg-badge--${this.variant}`);
104
+ }
105
+ validateOutline(newValue) {
106
+ if (newValue)
107
+ this.classList.add(`mg-badge--outline`);
108
+ }
109
+ /**
110
+ * Check if props are well configured on init
111
+ */
112
+ componentWillLoad() {
113
+ this.valideValue(this.value);
114
+ this.validateVariant(this.variant);
115
+ this.validateOutline(this.outline);
116
+ }
117
+ /**
118
+ * Render
119
+ */
120
+ render() {
121
+ return (index.h("span", { class: this.classList.join() }, this.value, index.h("span", { class: "sr-only" }, this.label)));
122
+ }
123
+ static get watchers() { return {
124
+ "value": ["valideValue"],
125
+ "variant": ["validateVariant"],
126
+ "outline": ["validateOutline"]
127
+ }; }
128
+ };
129
+ MgBadge.style = mgBadgeCss;
130
+
131
+ /**
132
+ * List of all possibles variants
133
+ */
134
+ const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat'];
135
+
136
+ const mgButtonCss = ".mg-button.sc-mg-button{position:relative;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;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:0.1rem 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:not-allowed}.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-radius:var(--mg-button-icon-border-radius)}.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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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) - 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-s>mg-icon,.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__content.sc-mg-button{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;-webkit-column-gap:0.6rem;-moz-column-gap:0.6rem;column-gap:0.6rem}.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--loading.sc-mg-button .mg-button__content.sc-mg-button{opacity:0}.mg-button.sc-mg-button-s>mg-badge,.mg-button .sc-mg-button-s>mg-badge{margin-left:0.3rem}mg-button.sc-mg-button{display:inline-block}.mg-button.sc-mg-button,mg-button.sc-mg-button{vertical-align:middle;max-width:100%}";
137
+
138
+ const MgButton = class {
139
+ constructor(hostRef) {
140
+ index.registerInstance(this, hostRef);
141
+ /************
142
+ * Internal *
143
+ ************/
144
+ this.onClickElementFn = null;
145
+ /**
146
+ * Define button variant
147
+ */
148
+ this.variant = variants$3[0]; // Primary
149
+ /**
150
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
151
+ * If not set, it will be created.
152
+ */
153
+ this.identifier = createID('mg-button');
154
+ /**
155
+ * Disable button
156
+ */
157
+ this.disabled = false;
158
+ /**
159
+ * Define if button is round.
160
+ * Used for icon button.
161
+ */
162
+ this.isIcon = false;
163
+ /**
164
+ * Option to set input disable on click, in order to prevent multi-click.
165
+ * Parent component have to remove the attribute 'disabled' when the process ends.
166
+ */
167
+ this.disableOnClick = false;
168
+ /**
169
+ * Define if button is loading, default to false.
170
+ * Trigger when button is clicked or key-up ['enter', 'space], then value change to true.
171
+ * It's required to reset to false when action/promise in parent is done to stop the loading state
172
+ */
173
+ this.loading = false;
174
+ /**
175
+ * Component classes
176
+ */
177
+ this.classList = new ClassList(['mg-button']);
178
+ /**
179
+ * Trigger actions onClick event
180
+ */
181
+ this.handleClick = (event) => {
182
+ if (this.disabled)
183
+ event.stopPropagation();
184
+ // Used to prevent multi-click.
185
+ if (this.disableOnClick && !this.disabled) {
186
+ this.loading = true;
187
+ this.disabled = true;
188
+ }
189
+ };
190
+ }
191
+ validateVariant(newValue) {
192
+ if (!variants$3.includes(newValue)) {
193
+ throw new Error(`<mg-button> prop "variant" must be one of : ${variants$3.join(', ')}`);
194
+ }
195
+ this.classList.add(`mg-button--${this.variant}`);
196
+ }
197
+ disabledHandler(isDisabled) {
198
+ // Remove loading when enable
199
+ // Will be set back onclick
200
+ if (!isDisabled && this.disableOnClick) {
201
+ this.loading = false;
202
+ }
203
+ // Manage if onclick
204
+ this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
205
+ }
206
+ loadingHandler(newValue) {
207
+ // we add loading style if it newvalue is true else we remove it
208
+ if (newValue) {
209
+ this.classList.add('mg-button--loading');
210
+ }
211
+ else {
212
+ this.classList.delete('mg-button--loading');
213
+ }
214
+ }
215
+ /**
216
+ * Check if props are well configured on init
217
+ */
218
+ componentWillLoad() {
219
+ this.validateVariant(this.variant);
220
+ if (this.isIcon) {
221
+ this.classList.add(`mg-button--icon`);
222
+ if (typeof this.label !== 'string' || this.label === '') {
223
+ throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
224
+ }
225
+ }
226
+ // Store the onclick fn
227
+ this.onClickElementFn = this.element.onclick;
228
+ this.disabledHandler(this.disabled);
229
+ }
230
+ /**
231
+ * Render component
232
+ */
233
+ render() {
234
+ return (index.h("button", { id: this.identifier, class: this.classList.join(), "aria-label": this.label, "aria-disabled": this.disabled, onClick: this.handleClick }, this.loading && index.h("mg-icon", { icon: "loader", spin: true }), index.h("div", { class: "mg-button__content" }, index.h("slot", null))));
235
+ }
236
+ get element() { return index.getElement(this); }
237
+ static get watchers() { return {
238
+ "variant": ["validateVariant"],
239
+ "disabled": ["disabledHandler"],
240
+ "loading": ["loadingHandler"]
241
+ }; }
242
+ };
243
+ MgButton.style = mgButtonCss;
244
+
245
+ const errors = {
246
+ required: "Ce champ est obligatoire.",
247
+ date: {
248
+ badInput: "Le format de la date doit être du type <span aria-hidden=\"true\">jj/mm/aaaa</span><span class=\"sr-only\">j j / m m / a a a a</span> et la date supérieure au {min}",
249
+ min: "La date ne peut pas être antérieure au {min}",
250
+ max: "La date ne peut pas être postérieure au {max}",
251
+ minMax: "La date doit être comprise entre {min} et {max}"
252
+ },
253
+ numeric: {
254
+ min: "La valeur ne peut pas être inférieure à {min}",
255
+ max: "La valeur ne peut pas être supérieure à {max}",
256
+ minMax: "La valeur doit être comprise entre {min} et {max}"
257
+ }
258
+ };
259
+ const nbCharLeft = "{counter} caractères disponibles.";
260
+ const input = {
261
+ select: {
262
+ placeholder: "Veuillez sélectionner une valeur"
263
+ },
264
+ checkbox: {
265
+ "true": "Oui",
266
+ "false": "Non",
267
+ indeterminate: "Indéterminé"
268
+ }
269
+ };
270
+ const message = {
271
+ closeButton: "Fermer le message"
272
+ };
273
+ const popover = {
274
+ closeButton: "Fermer"
275
+ };
276
+ const pagination = {
277
+ page: "page",
278
+ pages: "pages",
279
+ next: "suivant",
280
+ previous: "précédent",
281
+ nextPage: "Page suivante",
282
+ previousPage: "Page précédente",
283
+ selectPage: "Sélectionner la page à afficher."
284
+ };
285
+ const fr = {
286
+ errors: errors,
287
+ nbCharLeft: nbCharLeft,
288
+ input: input,
289
+ message: message,
290
+ popover: popover,
291
+ pagination: pagination
292
+ };
293
+
294
+ const locale = 'fr-FR';
295
+ const messages = fr;
296
+ const currency = 'EUR';
297
+
298
+ const mgCharacterLeftCss = "mg-character-left.sc-mg-character-left{display:block}";
299
+
300
+ const MgCharacterLeft = class {
301
+ constructor(hostRef) {
302
+ index.registerInstance(this, hostRef);
303
+ /************
304
+ * Internal *
305
+ ************/
306
+ this.mustacheCounter = '{counter}';
307
+ /**
308
+ * Template to display remaining characters.
309
+ * Must have {counter} inside
310
+ */
311
+ this.template = messages.nbCharLeft;
312
+ /**
313
+ * Sets the characters to count
314
+ */
315
+ this.characters = '';
316
+ /**
317
+ * Calculate number character left
318
+ * @returns {string}
319
+ */
320
+ this.getMessage = () => {
321
+ return this.template.replace(this.mustacheCounter, `<strong>${this.maxlength - this.characters.length}</strong>`);
322
+ };
323
+ }
324
+ validateTemplate(newValue) {
325
+ if (typeof newValue !== 'string' || newValue === '' || newValue.indexOf(this.mustacheCounter) === -1) {
326
+ throw new Error(`<mg-character-left> prop "template" must contain "${this.mustacheCounter}".`);
327
+ }
328
+ }
329
+ validateMaxlength(newValue) {
330
+ if (typeof newValue !== 'number') {
331
+ throw new Error('<mg-character-left> prop "maxlength" is required.');
332
+ }
333
+ }
334
+ /*************
335
+ * Lifecycle *
336
+ *************/
337
+ componentWillLoad() {
338
+ this.validateTemplate(this.template);
339
+ this.validateMaxlength(this.maxlength);
340
+ }
341
+ render() {
342
+ return index.h("span", { id: this.identifier, innerHTML: this.getMessage(), "aria-live": "polite" });
343
+ }
344
+ static get watchers() { return {
345
+ "template": ["validateTemplate"],
346
+ "maxlength": ["validateMaxlength"]
347
+ }; }
348
+ };
349
+ MgCharacterLeft.style = mgCharacterLeftCss;
350
+
351
+ /**
352
+ * Icon SVG paths
353
+ */
354
+ const icons = {
355
+ '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" })),
356
+ '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" })),
357
+ '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" })),
358
+ '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" })),
359
+ '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" })),
360
+ '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" })),
361
+ '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" })),
362
+ '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" })),
363
+ '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" })),
364
+ '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" })),
365
+ '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" })),
366
+ '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" })),
367
+ '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" })),
368
+ '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" })),
369
+ '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" })),
370
+ '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" })),
371
+ '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" })),
372
+ '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" })),
373
+ '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" })),
374
+ '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" })),
375
+ 'file-upload': () => [
376
+ 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" }),
377
+ 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" }),
378
+ ],
379
+ '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" })),
380
+ '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" })),
381
+ 'loader': () => [
382
+ 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" }),
383
+ 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" }),
384
+ ],
385
+ 'log-out': () => [
386
+ 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" }),
387
+ 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" }),
388
+ ],
389
+ '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" })),
390
+ '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" })),
391
+ '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" })),
392
+ '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" })),
393
+ '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" })),
394
+ '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" })),
395
+ };
396
+ /**
397
+ * List of all possibles sizes
398
+ */
399
+ const sizes = ['regular', 'large', 'extra-large'];
400
+ /**
401
+ * List of all possibles variants
402
+ */
403
+ const variants$2 = ['success', 'warning', 'danger', 'info'];
404
+
405
+ const mgIconCss = ".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%))}mg-icon,.mg-icon{display:inline-block;vertical-align:middle;line-height:1}.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)}}";
406
+
407
+ const MgIcon = class {
408
+ constructor(hostRef) {
409
+ index.registerInstance(this, hostRef);
410
+ /**
411
+ * Define icon size
412
+ */
413
+ this.size = 'regular';
414
+ /**
415
+ * Make the icon spin
416
+ */
417
+ this.spin = false;
418
+ /**
419
+ * Component classes
420
+ */
421
+ this.classList = new ClassList(['mg-icon']);
422
+ }
423
+ validateIcon(newValue) {
424
+ if (!Object.keys(icons).includes(newValue)) {
425
+ throw new Error(`<mg-icon> prop "icon" must be one of : ${Object.keys(icons).join(', ')}`);
426
+ }
427
+ this.classList.add(`mg-icon--${this.icon}`);
428
+ }
429
+ validateSize(newValue) {
430
+ if (!sizes.includes(newValue)) {
431
+ throw new Error(`<mg-icon> prop "size" must be one of : ${sizes.join(', ')}`);
432
+ }
433
+ this.classList.add(`mg-icon--size-${this.size}`);
434
+ }
435
+ validateVariant(newValue) {
436
+ if (newValue !== undefined && !variants$2.includes(newValue)) {
437
+ throw new Error(`<mg-icon> prop "variant" must be one of : ${variants$2.join(', ')}`);
438
+ }
439
+ else if (newValue !== undefined) {
440
+ this.classList.add(`mg-icon--variant-${this.variant}`);
441
+ }
442
+ }
443
+ handleSpin(newValue) {
444
+ if (newValue) {
445
+ this.classList.add('mg-icon--spin');
446
+ }
447
+ }
448
+ /**
449
+ * Check if props are well configured on init
450
+ */
451
+ componentWillLoad() {
452
+ this.validateIcon(this.icon);
453
+ this.validateSize(this.size);
454
+ this.validateVariant(this.variant);
455
+ this.handleSpin(this.spin);
456
+ }
457
+ /**
458
+ * Render component
459
+ */
460
+ render() {
461
+ return (index.h("svg", { class: this.classList.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, icons[this.icon]()));
462
+ }
463
+ static get watchers() { return {
464
+ "icon": ["validateIcon"],
465
+ "size": ["validateSize"],
466
+ "variant": ["validateVariant"],
467
+ "spin": ["handleSpin"]
468
+ }; }
469
+ };
470
+ MgIcon.style = mgIconCss;
471
+
472
+ /**
473
+ * Possible input classes
474
+ */
475
+ var InputClass;
476
+ (function (InputClass) {
477
+ InputClass["ERROR"] = "is-not-valid";
478
+ })(InputClass || (InputClass = {}));
479
+
480
+ /**
481
+ * Apply in all input child node the aria-describedby attribute
482
+ * @param children
483
+ * @param ariaDescribedbyIDs
484
+ * @param utils
485
+ * @returns {VNode[]}
486
+ */
487
+ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
488
+ if (['input', 'select', 'textarea'].includes(child.vtag)) {
489
+ return Object.assign(Object.assign({}, child), { vattrs: Object.assign(Object.assign({}, child.vattrs), { 'aria-describedby': [...ariaDescribedbyIDs].join(' ') }) });
490
+ }
491
+ // we recursively apply ariadescribedBy attributes to child input nodes if exists
492
+ if (child.vchildren === null)
493
+ return Object.assign({}, child);
494
+ return Object.assign(Object.assign({}, child), { vchildren: applyAriadescribedBy(child.vchildren, ariaDescribedbyIDs, utils) });
495
+ });
496
+ /**
497
+ * Add classes based on props
498
+ * @param props
499
+ */
500
+ const manageClasses = (props) => {
501
+ props.classList.add('mg-input');
502
+ if (props.labelOnTop)
503
+ props.classList.add('mg-input--label-on-top');
504
+ if (props.readonly)
505
+ props.classList.add('mg-input--readonly');
506
+ if (props.width !== undefined)
507
+ props.classList.add(`mg-input--width-${props.width}`);
508
+ if (props.readonly || props.disabled) {
509
+ props.classList.delete(InputClass.ERROR);
510
+ }
511
+ };
512
+ /**
513
+ * Define tagname based on props
514
+ * @param isFieldset
515
+ * @returns {string} tag name
516
+ */
517
+ const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
518
+ /**
519
+ * Get input template
520
+ * @param props MgInput Interface Props
521
+ * @param children Represent scoped elements
522
+ * @param utils Stencil.js utils
523
+ * @returns JSX template
524
+ */
525
+ const MgInput = (props, children, utils) => {
526
+ /**
527
+ * Check required properties
528
+ */
529
+ if (typeof props.label !== 'string' || props.label === '') {
530
+ throw new Error('<mg-input> prop "label" is required');
531
+ }
532
+ if (props.labelOnTop && props.labelHide) {
533
+ throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide"');
534
+ }
535
+ /**
536
+ * Component classes
537
+ */
538
+ manageClasses(props);
539
+ /**
540
+ * a11y IDs
541
+ */
542
+ const ariaDescribedbyIDs = new Set();
543
+ // Character Left
544
+ const characterLeftId = `${props.identifier}-character-left`;
545
+ if (props.classList.has('is-focused') && props.displayCharacterLeft) {
546
+ ariaDescribedbyIDs.add(characterLeftId);
547
+ }
548
+ // Help text
549
+ const helpTextId = `${props.identifier}-help-text`;
550
+ if (typeof props.helpText === 'string' && props.helpText !== '') {
551
+ ariaDescribedbyIDs.add(helpTextId);
552
+ }
553
+ // Error Message
554
+ const helpTextErrorId = `${props.identifier}-error`;
555
+ if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {
556
+ ariaDescribedbyIDs.add(helpTextErrorId);
557
+ }
558
+ /**
559
+ * Update input(s) in children
560
+ */
561
+ if (props.readonly) {
562
+ children = children.filter(child => child.$name$ === 'append-input');
563
+ }
564
+ else {
565
+ children = applyAriadescribedBy(children, ariaDescribedbyIDs, utils);
566
+ }
567
+ /**
568
+ * Return template
569
+ *
570
+ * +--------+--------------+---------+
571
+ * | label | input | tooltip |
572
+ * | +--------------+---------+
573
+ * | | nb Char Left |
574
+ * | +------------------------+
575
+ * | | Help Text |
576
+ * | +------------------------+
577
+ * | | Error |
578
+ * +--------+------------------------+
579
+ *
580
+ * Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change
581
+ */
582
+ const TagName = getTagName(props.isFieldset);
583
+ /**
584
+ * Get tooltip node
585
+ * @returns mg-tooltip
586
+ */
587
+ const getTooltip = () => (index.h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
588
+ index.h("mg-icon", { icon: "info-circle" })));
589
+ /**
590
+ * Get input title (label) node
591
+ * @returns mg-input-title
592
+ */
593
+ const getInputTitle = () => (index.h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required, "is-legend": props.isFieldset }, props.label));
594
+ return (index.h(TagName, { class: props.classList.join() },
595
+ props.labelOnTop ? (index.h("div", { class: "mg-input__title" },
596
+ getInputTitle(),
597
+ !props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
598
+ props.readonly ? (index.h("div", { class: "mg-input__input-container" },
599
+ index.h("strong", null, props.readonlyValue || props.value),
600
+ children)) : (index.h("div", { class: "mg-input__input-container" },
601
+ index.h("div", { class: "mg-input__input" },
602
+ children,
603
+ !props.labelOnTop && props.tooltip && getTooltip()),
604
+ 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 })),
605
+ props.helpText && index.h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }),
606
+ props.errorMessage && index.h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" })))));
607
+ };
608
+
609
+ 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%;}.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: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}.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}.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}";
610
+
611
+ /**
612
+ * type CheckboxItem validation function
613
+ * @param CheckboxItem
614
+ * @returns {boolean}
615
+ */
616
+ const isCheckboxItem = (item) => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined;
617
+ const MgInputCheckbox = class {
618
+ constructor(hostRef) {
619
+ index.registerInstance(this, hostRef);
620
+ this.valueChange = index.createEvent(this, "value-change", 7);
621
+ /************
622
+ * Internal *
623
+ ************/
624
+ // classes
625
+ this.classError = InputClass.ERROR;
626
+ // HTML selector
627
+ this.inputs = [];
628
+ /**
629
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
630
+ * If not set, it will be created.
631
+ */
632
+ this.identifier = createID('mg-input-checkbox');
633
+ /**
634
+ * Input name
635
+ * If not set the value equals the identifier
636
+ */
637
+ this.name = this.identifier;
638
+ /**
639
+ * Define if label is visible
640
+ */
641
+ this.labelHide = false;
642
+ /**
643
+ * Define if inputs are display verticaly
644
+ */
645
+ this.inputVerticalList = false;
646
+ /**
647
+ * Define if input is required
648
+ */
649
+ this.required = false;
650
+ /**
651
+ * Define if input is readonly
652
+ */
653
+ this.readonly = false;
654
+ /**
655
+ * Define if input is disabled
656
+ */
657
+ this.disabled = false;
658
+ /**
659
+ * Component classes
660
+ */
661
+ this.classList = new ClassList(['mg-input--checkbox']);
662
+ /**
663
+ * Formated value for display
664
+ */
665
+ this.checkboxItems = [];
666
+ /**
667
+ * Handle input event
668
+ * @param event
669
+ */
670
+ this.handleInput = (event) => {
671
+ this.checkboxItems = this.checkboxItems.map(item => {
672
+ if (item.id === event.target.id) {
673
+ item.value = Boolean(event.target.checked);
674
+ }
675
+ return item;
676
+ });
677
+ this.value = this.checkboxItems.map(o => ({ value: o.value, title: o.title, disabled: o.disabled }));
678
+ this.checkValidity();
679
+ this.valueChange.emit(this.value);
680
+ };
681
+ /**
682
+ * Handle blur event
683
+ */
684
+ this.handleBlur = () => {
685
+ // Check validity
686
+ this.checkValidity();
687
+ this.checkError();
688
+ };
689
+ /**
690
+ * get invalid element
691
+ * @returns element: HTMLInputElement
692
+ */
693
+ this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
694
+ }
695
+ validateValue(newValue) {
696
+ if (newValue && newValue.every(item => isCheckboxItem(item))) {
697
+ this.checkboxItems = newValue.map((item, index) => ({
698
+ id: `${this.identifier}_${index.toString()}`,
699
+ title: item.title,
700
+ value: item.value,
701
+ disabled: item.disabled,
702
+ }));
703
+ }
704
+ else {
705
+ throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
706
+ }
707
+ }
708
+ handleReadOnly() {
709
+ this.classList.delete(this.classError);
710
+ }
711
+ /**
712
+ * Check if input is valid
713
+ */
714
+ checkValidity() {
715
+ if (!this.readonly) {
716
+ const validity = this.getInvalidElement() === undefined;
717
+ // Set validity
718
+ this.valid = validity;
719
+ this.invalid = !validity;
720
+ }
721
+ }
722
+ /**
723
+ * Check input errors
724
+ */
725
+ checkError() {
726
+ const invalidElement = this.getInvalidElement();
727
+ // Set error message
728
+ this.errorMessage = undefined;
729
+ if (!this.valid && invalidElement.validity.valueMissing) {
730
+ this.errorMessage = messages.errors.required;
731
+ }
732
+ // Update class
733
+ if (this.valid) {
734
+ this.classList.delete(this.classError);
735
+ }
736
+ else {
737
+ this.classList.add(this.classError);
738
+ }
739
+ }
740
+ /*************
741
+ * Lifecycle *
742
+ *************/
743
+ componentWillLoad() {
744
+ // Check values format
745
+ this.validateValue(this.value);
746
+ // return a promise to process action only in the FIRST render().
747
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
748
+ return setTimeout(() => this.checkValidity(), 0);
749
+ }
750
+ render() {
751
+ 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${this.inputVerticalList ? ' mg-input__input-group-container--vertical' : ''}` }, this.checkboxItems
752
+ .filter(item => {
753
+ return !this.readonly || item.value;
754
+ })
755
+ .map(input => (index.h("li", { class: "mg-input__input-group" }, 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)))))));
756
+ }
757
+ static get watchers() { return {
758
+ "value": ["validateValue"],
759
+ "readonly": ["handleReadOnly"]
760
+ }; }
761
+ };
762
+ MgInputCheckbox.style = mgInputCheckboxCss;
763
+
764
+ var InputError$1;
765
+ (function (InputError) {
766
+ InputError["MIN"] = "min";
767
+ InputError["MAX"] = "max";
768
+ InputError["MINMAX"] = "minMax";
769
+ InputError["REQUIRED"] = "required";
770
+ })(InputError$1 || (InputError$1 = {}));
771
+
772
+ /**
773
+ * Format number to the locale currency
774
+ * @param number {number}
775
+ * @returns {string} formatted currency
776
+ */
777
+ function localeCurrency(number) {
778
+ return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
779
+ }
780
+ /**
781
+ * Format number to locale
782
+ * @param number {number}
783
+ * @returns {string} formatted number
784
+ */
785
+ function localeNumber(number) {
786
+ return new Intl.NumberFormat(locale).format(number);
787
+ }
788
+ /**
789
+ * Date RegExp
790
+ */
791
+ const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
792
+ /**
793
+ * Locale date format
794
+ * @param date {string}
795
+ * @returns {string} formatted date
796
+ */
797
+ function localeDate(date) {
798
+ if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
799
+ return '';
800
+ }
801
+ return new Intl.DateTimeFormat(locale).format(new Date(date));
802
+ }
803
+
804
+ 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%;}.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);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--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}";
805
+
806
+ const MgInputDate = class {
807
+ constructor(hostRef) {
808
+ index.registerInstance(this, hostRef);
809
+ this.valueChange = index.createEvent(this, "value-change", 7);
810
+ /************
811
+ * Internal *
812
+ ************/
813
+ // classes
814
+ this.classError = InputClass.ERROR;
815
+ /**
816
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
817
+ * If not set, it will be created.
818
+ */
819
+ this.identifier = createID('mg-input-date');
820
+ /**
821
+ * Input name
822
+ * If not set the value equals the identifier
823
+ */
824
+ this.name = this.identifier;
825
+ /**
826
+ * Define if label is visible
827
+ */
828
+ this.labelHide = false;
829
+ /**
830
+ * Define if input is required
831
+ */
832
+ this.required = false;
833
+ /**
834
+ * Define if input is readonly
835
+ */
836
+ this.readonly = false;
837
+ /**
838
+ * Define if input is disabled
839
+ */
840
+ this.disabled = false;
841
+ /**
842
+ * Component classes
843
+ */
844
+ this.classList = new ClassList(['mg-input--date']);
845
+ /**
846
+ * Handle input event
847
+ */
848
+ this.handleInput = () => {
849
+ this.checkValidity();
850
+ this.value = this.input.value;
851
+ this.valueChange.emit(this.value);
852
+ };
853
+ /**
854
+ * Handle blur event
855
+ */
856
+ this.handleBlur = () => {
857
+ this.checkValidity();
858
+ this.checkError();
859
+ };
860
+ /**
861
+ * get input error code
862
+ * @returns {null | InputError}
863
+ */
864
+ this.getInputError = () => {
865
+ var _a, _b;
866
+ let inputError = null;
867
+ // required
868
+ if (this.input.validity.valueMissing) {
869
+ inputError = InputError$1.REQUIRED;
870
+ }
871
+ // min & max
872
+ 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) {
873
+ inputError = InputError$1.MINMAX;
874
+ }
875
+ // min
876
+ else if (this.input.validity.rangeUnderflow) {
877
+ inputError = InputError$1.MIN;
878
+ }
879
+ //max
880
+ else if (this.input.validity.rangeOverflow) {
881
+ inputError = InputError$1.MAX;
882
+ }
883
+ return inputError;
884
+ };
885
+ }
886
+ validateValue(newValue) {
887
+ if (newValue !== undefined && newValue !== '' && !(typeof newValue === 'string' && dateRegExp.test(newValue))) {
888
+ throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
889
+ }
890
+ }
891
+ validateMin(newValue) {
892
+ this.validateDateFormat(newValue);
893
+ }
894
+ validateMax(newValue) {
895
+ this.validateDateFormat(newValue);
896
+ }
897
+ /**
898
+ * Date format validation
899
+ * @param date
900
+ */
901
+ validateDateFormat(date) {
902
+ if ((date === null || date === void 0 ? void 0 : date.length) > 0 && !(typeof date === 'string' && dateRegExp.test(date))) {
903
+ throw new Error("<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd");
904
+ }
905
+ }
906
+ /**
907
+ * Check if input is valid
908
+ */
909
+ checkValidity() {
910
+ if (!this.readonly && this.input !== undefined) {
911
+ const validity = this.input.checkValidity();
912
+ // Set validity
913
+ this.valid = validity;
914
+ this.invalid = !validity;
915
+ }
916
+ }
917
+ /**
918
+ * Set error message
919
+ */
920
+ setErrorMessage() {
921
+ var _a;
922
+ const inputError = this.getInputError();
923
+ // required
924
+ if (inputError === InputError$1.REQUIRED) {
925
+ this.errorMessage = messages.errors[inputError];
926
+ }
927
+ // min, max & minMax
928
+ else if ([InputError$1.MIN, InputError$1.MAX, InputError$1.MINMAX].includes(inputError)) {
929
+ this.errorMessage = messages.errors.date[inputError].replace('{min}', localeDate(this.min)).replace('{max}', localeDate(this.max));
930
+ }
931
+ // wrong date format
932
+ // element.validity.badInput is default error message
933
+ else {
934
+ this.errorMessage = 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'));
935
+ }
936
+ }
937
+ /**
938
+ * Check input errors
939
+ */
940
+ checkError() {
941
+ // Set error message
942
+ this.errorMessage = undefined;
943
+ if (!this.valid) {
944
+ this.setErrorMessage();
945
+ this.classList.add(this.classError);
946
+ }
947
+ else {
948
+ this.classList.delete(this.classError);
949
+ }
950
+ }
951
+ /*************
952
+ * Lifecycle *
953
+ *************/
954
+ componentWillLoad() {
955
+ this.validateValue(this.value);
956
+ this.validateMin(this.min);
957
+ this.validateMax(this.max);
958
+ // return a promise to process action only in the FIRST render().
959
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
960
+ return setTimeout(() => this.checkValidity(), 0);
961
+ }
962
+ render() {
963
+ 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) })));
964
+ }
965
+ static get watchers() { return {
966
+ "value": ["validateValue"],
967
+ "min": ["validateMin"],
968
+ "max": ["validateMax"]
969
+ }; }
970
+ };
971
+ MgInputDate.style = mgInputDateCss;
972
+
973
+ /**
974
+ * List of all possibles types
975
+ */
976
+ const types = ['decimal', 'integer', 'currency'];
977
+ var InputError;
978
+ (function (InputError) {
979
+ InputError["MIN"] = "min";
980
+ InputError["MAX"] = "max";
981
+ InputError["MINMAX"] = "minMax";
982
+ InputError["REQUIRED"] = "required";
983
+ })(InputError || (InputError = {}));
984
+
985
+ 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%;}.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);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--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}";
986
+
987
+ const MgInputNumeric = class {
988
+ constructor(hostRef) {
989
+ index.registerInstance(this, hostRef);
990
+ this.valueChange = index.createEvent(this, "value-change", 7);
991
+ // Classes
992
+ this.classError = InputClass.ERROR;
993
+ /**
994
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
995
+ * If not set, it will be created.
996
+ */
997
+ this.identifier = createID('mg-input-numeric');
998
+ /**
999
+ * Input name
1000
+ * If not set the value equals the identifier
1001
+ */
1002
+ this.name = this.identifier;
1003
+ /**
1004
+ * Define if label is visible
1005
+ */
1006
+ this.labelHide = false;
1007
+ /**
1008
+ * Define if input is required
1009
+ */
1010
+ this.required = false;
1011
+ /**
1012
+ * Define if input is readonly
1013
+ */
1014
+ this.readonly = false;
1015
+ /**
1016
+ * Define if input is disabled
1017
+ */
1018
+ this.disabled = false;
1019
+ /**
1020
+ * Define numeric type
1021
+ */
1022
+ this.type = types[0];
1023
+ /**
1024
+ * Override integer length
1025
+ * integer is the number before the decimal point
1026
+ */
1027
+ this.integerLength = 13;
1028
+ /**
1029
+ * Override decimal length
1030
+ * decimal is the number after the decimal point
1031
+ */
1032
+ this.decimalLength = 2;
1033
+ /**
1034
+ * Component classes
1035
+ */
1036
+ this.classList = new ClassList(['mg-input--numeric']);
1037
+ /**
1038
+ * Handle input event
1039
+ */
1040
+ this.handleInput = () => {
1041
+ // Check validity
1042
+ this.checkValidity();
1043
+ this.value = this.input.value;
1044
+ };
1045
+ /**
1046
+ * Handle focus event
1047
+ */
1048
+ this.handleFocus = () => {
1049
+ this.displayValue = this.value;
1050
+ };
1051
+ /**
1052
+ * Handle blur event
1053
+ */
1054
+ this.handleBlur = () => {
1055
+ // Check validity
1056
+ this.checkValidity();
1057
+ this.checkError();
1058
+ // Display readonly value
1059
+ this.displayValue = this.readonlyValue;
1060
+ };
1061
+ /**
1062
+ * get input error code
1063
+ * @returns {null | InputError}
1064
+ */
1065
+ this.getInputError = () => {
1066
+ let inputError = null;
1067
+ if (this.input === undefined)
1068
+ return inputError;
1069
+ // required
1070
+ if (!this.input.checkValidity() && this.input.validity.valueMissing) {
1071
+ inputError = InputError.REQUIRED;
1072
+ }
1073
+ // Min & Max
1074
+ if (this.min !== undefined && this.numericValue < this.min && this.max === undefined) {
1075
+ // Only a min value is set
1076
+ inputError = InputError.MIN;
1077
+ }
1078
+ else if (this.max !== undefined && this.numericValue > this.max && this.min === undefined) {
1079
+ // Only a max value is set
1080
+ inputError = InputError.MAX;
1081
+ }
1082
+ else if ((this.min !== undefined && this.numericValue < this.min) || (this.max !== undefined && this.numericValue > this.max)) {
1083
+ // both min and max values are set
1084
+ inputError = InputError.MINMAX;
1085
+ }
1086
+ return inputError;
1087
+ };
1088
+ /**
1089
+ * Format value based on type
1090
+ * @param value {number}
1091
+ * @returns {string} formated local value
1092
+ */
1093
+ this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value) : localeNumber(value));
1094
+ }
1095
+ validateValue(newValue) {
1096
+ if (newValue !== undefined && newValue !== null) {
1097
+ // Split number and decimal
1098
+ const [integer, decimal = ''] = newValue.replace('-', '').split(/[\.,]/);
1099
+ // Regex
1100
+ const regex = this.type === 'integer' ? /^[\-]?\d+$/ : /^[\-]?\d+[.,]?\d*$/;
1101
+ // Filter input
1102
+ if (newValue === '' || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
1103
+ this.storedValue = newValue;
1104
+ }
1105
+ else if (this.storedValue !== undefined) {
1106
+ newValue = this.storedValue;
1107
+ }
1108
+ else {
1109
+ newValue = null;
1110
+ }
1111
+ // Set value and input value
1112
+ this.value = newValue;
1113
+ if (this.input !== undefined)
1114
+ this.input.value = this.value;
1115
+ // emit numeric value
1116
+ this.numericValue = this.value !== '' && this.value !== null ? parseFloat(this.value.replace(',', '.')) : null;
1117
+ this.valueChange.emit(this.numericValue);
1118
+ // Set readOnlyValue
1119
+ this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
1120
+ }
1121
+ }
1122
+ validateType(newValue) {
1123
+ if (!types.includes(newValue)) {
1124
+ throw new Error(`<mg-input-numeric> prop "type" must be one of : ${types.join(', ')}`);
1125
+ }
1126
+ this.classList.add(`mg-input--numeric--${this.type}`);
1127
+ }
1128
+ validateIntegerLength(newValue) {
1129
+ if (newValue < 1) {
1130
+ throw new Error(`<mg-input-numeric> prop "integer-length" must be a positive number.`);
1131
+ }
1132
+ }
1133
+ validateDecimalLength(newValue) {
1134
+ if (newValue < 1) {
1135
+ throw new Error(`<mg-input-numeric> prop "decimal-length" must be a positive number, consider using prop "type" to "integer" instead.`);
1136
+ }
1137
+ }
1138
+ /**
1139
+ * Check if input is valid
1140
+ */
1141
+ checkValidity() {
1142
+ if (!this.readonly) {
1143
+ const validity = this.getInputError() === null;
1144
+ // Set validity
1145
+ this.valid = validity;
1146
+ this.invalid = !validity;
1147
+ }
1148
+ }
1149
+ /**
1150
+ * Set error message
1151
+ */
1152
+ setErrorMessage() {
1153
+ const inputError = this.getInputError();
1154
+ if (inputError === InputError.REQUIRED) {
1155
+ this.errorMessage = messages.errors[inputError];
1156
+ }
1157
+ else {
1158
+ this.errorMessage = messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
1159
+ }
1160
+ }
1161
+ /**
1162
+ * Check input errors
1163
+ */
1164
+ checkError() {
1165
+ // Set error message
1166
+ this.errorMessage = undefined;
1167
+ // Update class
1168
+ if (!this.valid) {
1169
+ this.setErrorMessage();
1170
+ this.classList.add(this.classError);
1171
+ }
1172
+ else {
1173
+ this.classList.delete(this.classError);
1174
+ }
1175
+ }
1176
+ /**
1177
+ * Validate append slot
1178
+ */
1179
+ validateAppendSlot() {
1180
+ const slotAppendInput = this.element.querySelector('[slot="append-input"]');
1181
+ if (slotAppendInput !== null && slotAppendInput.querySelector('.mg-button') !== null) {
1182
+ this.classList.add('mg-input--is-input-group-append');
1183
+ this.classList = new ClassList(this.classList.classes);
1184
+ }
1185
+ else if (slotAppendInput !== null) {
1186
+ this.classList.add('mg-input--is-append-input-slot-content');
1187
+ this.classList = new ClassList(this.classList.classes);
1188
+ }
1189
+ }
1190
+ /*************
1191
+ * Lifecycle *
1192
+ *************/
1193
+ componentWillLoad() {
1194
+ this.validateValue(this.value);
1195
+ // Set displayed value
1196
+ this.displayValue = this.readonlyValue;
1197
+ this.validateType(this.type);
1198
+ this.validateIntegerLength(this.integerLength);
1199
+ this.validateDecimalLength(this.decimalLength);
1200
+ // return a promise to process action only in the FIRST render().
1201
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
1202
+ return setTimeout(() => this.checkValidity(), 0);
1203
+ }
1204
+ componentDidLoad() {
1205
+ this.validateAppendSlot();
1206
+ }
1207
+ /**
1208
+ * Check if component props are well configured on init
1209
+ */
1210
+ render() {
1211
+ 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" })));
1212
+ }
1213
+ get element() { return index.getElement(this); }
1214
+ static get watchers() { return {
1215
+ "value": ["validateValue"],
1216
+ "type": ["validateType"],
1217
+ "integerLength": ["validateIntegerLength"],
1218
+ "decimalLength": ["validateDecimalLength"]
1219
+ }; }
1220
+ };
1221
+ MgInputNumeric.style = mgInputNumericCss;
1222
+
1223
+ 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%;}.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);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--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}";
1224
+
1225
+ const MgInputPassword = class {
1226
+ constructor(hostRef) {
1227
+ index.registerInstance(this, hostRef);
1228
+ this.valueChange = index.createEvent(this, "value-change", 7);
1229
+ /************
1230
+ * Internal *
1231
+ ************/
1232
+ // classes
1233
+ this.classError = InputClass.ERROR;
1234
+ /**
1235
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1236
+ * If not set, it will be created.
1237
+ */
1238
+ this.identifier = createID('mg-input-password');
1239
+ /**
1240
+ * Input name
1241
+ * If not set the value equals the identifier
1242
+ */
1243
+ this.name = this.identifier;
1244
+ /**
1245
+ * Define if label is visible
1246
+ */
1247
+ this.labelHide = false;
1248
+ /**
1249
+ * Define if input is required
1250
+ */
1251
+ this.required = false;
1252
+ /**
1253
+ * Define if input is readonly
1254
+ */
1255
+ this.readonly = false;
1256
+ /**
1257
+ * Define if input is disabled
1258
+ */
1259
+ this.disabled = false;
1260
+ /**
1261
+ * Define input width
1262
+ */
1263
+ this.width = 'full';
1264
+ /**
1265
+ * Component classes
1266
+ */
1267
+ this.classList = new ClassList(['mg-input--password']);
1268
+ /**
1269
+ * Handle input event
1270
+ */
1271
+ this.handleInput = () => {
1272
+ this.checkValidity();
1273
+ this.value = this.input.value;
1274
+ this.valueChange.emit(this.value);
1275
+ };
1276
+ /**
1277
+ * Handle blur event
1278
+ */
1279
+ this.handleBlur = () => {
1280
+ this.checkValidity();
1281
+ this.checkError();
1282
+ };
1283
+ }
1284
+ /**
1285
+ * Check if input is valid
1286
+ */
1287
+ checkValidity() {
1288
+ if (!this.readonly && this.input !== undefined) {
1289
+ const validity = this.input.checkValidity();
1290
+ // Set validity
1291
+ this.valid = validity;
1292
+ this.invalid = !validity;
1293
+ }
1294
+ }
1295
+ /**
1296
+ * Check input errors
1297
+ */
1298
+ checkError() {
1299
+ // Set error message
1300
+ this.errorMessage = undefined;
1301
+ // required
1302
+ if (!this.valid && this.input.validity.valueMissing) {
1303
+ this.errorMessage = messages.errors.required;
1304
+ }
1305
+ // Update class
1306
+ if (this.valid) {
1307
+ this.classList.delete(this.classError);
1308
+ }
1309
+ else {
1310
+ this.classList.add(this.classError);
1311
+ }
1312
+ }
1313
+ /*************
1314
+ * Lifecycle *
1315
+ *************/
1316
+ componentWillLoad() {
1317
+ // return a promise to process action only in the FIRST render().
1318
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
1319
+ return setTimeout(() => this.checkValidity(), 0);
1320
+ }
1321
+ render() {
1322
+ 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) })));
1323
+ }
1324
+ };
1325
+ MgInputPassword.style = mgInputPasswordCss;
1326
+
1327
+ 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%;}.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: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}.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}.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}";
1328
+
1329
+ /**
1330
+ * type Option validation function
1331
+ * @param option
1332
+ * @returns {boolean}
1333
+ */
1334
+ const isOption$2 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
1335
+ const MgInputRadio = class {
1336
+ constructor(hostRef) {
1337
+ index.registerInstance(this, hostRef);
1338
+ this.valueChange = index.createEvent(this, "value-change", 7);
1339
+ /************
1340
+ * Internal *
1341
+ ************/
1342
+ // classes
1343
+ this.classError = InputClass.ERROR;
1344
+ // HTML selector
1345
+ this.inputs = [];
1346
+ /**
1347
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1348
+ * If not set, it will be created.
1349
+ */
1350
+ this.identifier = createID('mg-input-radio');
1351
+ /**
1352
+ * Input name
1353
+ * If not set the value equals the identifier
1354
+ */
1355
+ this.name = this.identifier;
1356
+ /**
1357
+ * Define if label is displayed on top
1358
+ */
1359
+ this.labelOnTop = false;
1360
+ /**
1361
+ * Define if label is visible
1362
+ */
1363
+ this.labelHide = false;
1364
+ /**
1365
+ * Define if inputs are display verticaly
1366
+ */
1367
+ this.inputVerticalList = false;
1368
+ /**
1369
+ * Define if input is required
1370
+ */
1371
+ this.required = false;
1372
+ /**
1373
+ * Define if input is readonly
1374
+ */
1375
+ this.readonly = false;
1376
+ /**
1377
+ * Define if input is disabled
1378
+ */
1379
+ this.disabled = false;
1380
+ /**
1381
+ * Component classes
1382
+ */
1383
+ this.classList = new ClassList(['mg-input--radio']);
1384
+ /**
1385
+ * Handle input event
1386
+ */
1387
+ this.handleInput = (event) => {
1388
+ this.checkValidity();
1389
+ this.value = this.options[event.target.value].value;
1390
+ this.valueChange.emit(this.value);
1391
+ };
1392
+ /**
1393
+ * Handle blur event
1394
+ */
1395
+ this.handleBlur = () => {
1396
+ this.checkValidity();
1397
+ this.checkError();
1398
+ };
1399
+ /**
1400
+ * get invalid element
1401
+ * @returns element: HTMLInputElement
1402
+ */
1403
+ this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
1404
+ }
1405
+ validateItems(newValue) {
1406
+ // Validate if items have required min length
1407
+ if (typeof newValue === 'object' && newValue.length < 2) {
1408
+ throw new Error('<mg-input-radio> prop "items" require at least 2 items.');
1409
+ }
1410
+ // String array
1411
+ else if (allItemsAreString(newValue)) {
1412
+ this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
1413
+ }
1414
+ // Object array
1415
+ else if (newValue && newValue.every(item => isOption$2(item))) {
1416
+ this.options = newValue;
1417
+ }
1418
+ else {
1419
+ throw new Error('<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption.');
1420
+ }
1421
+ }
1422
+ /**
1423
+ * Check if input is valid
1424
+ */
1425
+ checkValidity() {
1426
+ if (!this.readonly) {
1427
+ const validity = this.getInvalidElement() === undefined;
1428
+ // Set validity
1429
+ this.valid = validity;
1430
+ this.invalid = !validity;
1431
+ }
1432
+ }
1433
+ /**
1434
+ * Check input errors
1435
+ */
1436
+ checkError() {
1437
+ const invalidElement = this.getInvalidElement();
1438
+ // Set error message
1439
+ this.errorMessage = undefined;
1440
+ if (!this.valid && invalidElement.validity.valueMissing) {
1441
+ this.errorMessage = messages.errors.required;
1442
+ }
1443
+ // Update class
1444
+ if (this.valid) {
1445
+ this.classList.delete(this.classError);
1446
+ }
1447
+ else {
1448
+ this.classList.add(this.classError);
1449
+ }
1450
+ }
1451
+ /*************
1452
+ * Lifecycle *
1453
+ *************/
1454
+ componentWillLoad() {
1455
+ // Check items format
1456
+ this.validateItems(this.items);
1457
+ // return a promise to process action only in the FIRST render().
1458
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
1459
+ return setTimeout(() => this.checkValidity(), 0);
1460
+ }
1461
+ render() {
1462
+ 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 && this.value.toString(), readonlyValue: this.value && this.value.toString(), 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${this.inputVerticalList ? ' mg-input__input-group-container--vertical' : ''}` }, this.options.map((input, index$1) => (index.h("li", { class: "mg-input__input-group" }, 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)))))));
1463
+ }
1464
+ static get watchers() { return {
1465
+ "items": ["validateItems"]
1466
+ }; }
1467
+ };
1468
+ MgInputRadio.style = mgInputRadioCss;
1469
+
1470
+ 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%;}.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);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--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:0}";
1471
+
1472
+ /**
1473
+ * Check if item is a well configured option
1474
+ * @param option
1475
+ * @returns {boolean}
1476
+ */
1477
+ const isOption$1 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
1478
+ /**
1479
+ * Group options
1480
+ * @param acc
1481
+ * @param {SelectOption} item
1482
+ * @param {string} item.group
1483
+ * @param {string} item.title
1484
+ * @param {any} item.value
1485
+ * @param {boolean} item.disabled
1486
+ * @returns {OptGroup} grouped options
1487
+ */
1488
+ const groupOptions = (acc, { group, title, value, disabled }) => {
1489
+ if (group !== undefined) {
1490
+ // Check if group is already created
1491
+ const optgroup = acc.find((grp) => grp.group === group);
1492
+ // Add to group
1493
+ if (optgroup) {
1494
+ optgroup.options.push({ title, value, disabled });
1495
+ }
1496
+ // Create group
1497
+ else {
1498
+ acc.push({ group, options: [{ title, value, disabled }] });
1499
+ }
1500
+ }
1501
+ else {
1502
+ acc.push({ title, value, disabled });
1503
+ }
1504
+ return acc;
1505
+ };
1506
+ const MgInputSelect = class {
1507
+ constructor(hostRef) {
1508
+ index.registerInstance(this, hostRef);
1509
+ this.valueChange = index.createEvent(this, "value-change", 7);
1510
+ /************
1511
+ * Internal *
1512
+ ************/
1513
+ // classes
1514
+ this.classError = InputClass.ERROR;
1515
+ /**
1516
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1517
+ * If not set, it will be created.
1518
+ */
1519
+ this.identifier = createID('mg-input-select');
1520
+ /**
1521
+ * Input name
1522
+ * If not set the value equals the identifier
1523
+ */
1524
+ this.name = this.identifier;
1525
+ /**
1526
+ * Define if label is visible
1527
+ */
1528
+ this.labelHide = false;
1529
+ /**
1530
+ * Input placeholder.
1531
+ * It should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help text.
1532
+ */
1533
+ this.placeholder = messages.input.select.placeholder;
1534
+ /**
1535
+ * Option to remove placeholder
1536
+ */
1537
+ this.placeholderHide = false;
1538
+ /**
1539
+ * Option to disable placeholder
1540
+ */
1541
+ this.placeholderDisabled = false;
1542
+ /**
1543
+ * Define if input is required
1544
+ */
1545
+ this.required = false;
1546
+ /**
1547
+ * Define if input is readonly
1548
+ */
1549
+ this.readonly = false;
1550
+ /**
1551
+ * Define if input is disabled
1552
+ */
1553
+ this.disabled = false;
1554
+ /**
1555
+ * Component classes
1556
+ */
1557
+ this.classList = new ClassList(['mg-input--select']);
1558
+ /**
1559
+ * Handle input event
1560
+ */
1561
+ this.handleInput = () => {
1562
+ this.checkValidity();
1563
+ this.value = this.input.value !== '' ? this.options[this.input.value].value : null;
1564
+ this.valueChange.emit(this.value);
1565
+ };
1566
+ /**
1567
+ * Handle blur event
1568
+ */
1569
+ this.handleBlur = () => {
1570
+ this.checkValidity();
1571
+ this.checkError();
1572
+ };
1573
+ }
1574
+ validateItems(newValue) {
1575
+ // String array
1576
+ if (allItemsAreString(newValue)) {
1577
+ this.valueExist = newValue.includes(this.value);
1578
+ this.options = newValue.map(item => ({ title: item, value: item }));
1579
+ }
1580
+ // Object array
1581
+ else if (newValue && newValue.every(item => isOption$1(item))) {
1582
+ this.valueExist = newValue.map(item => item.value).includes(this.value);
1583
+ // Grouped object options
1584
+ if (newValue.some((item) => item.group !== undefined)) {
1585
+ this.options = newValue.reduce(groupOptions, []);
1586
+ }
1587
+ // Standart object options
1588
+ else {
1589
+ this.options = newValue;
1590
+ }
1591
+ }
1592
+ else {
1593
+ throw new Error('<mg-input-select> prop "items" is required and all items must be the same type, string or Option.');
1594
+ }
1595
+ }
1596
+ /**
1597
+ * Check if input is valid
1598
+ */
1599
+ checkValidity() {
1600
+ if (!this.readonly && this.input !== undefined) {
1601
+ const validity = this.input.checkValidity && this.input.checkValidity();
1602
+ // Set validity
1603
+ this.valid = validity;
1604
+ this.invalid = !validity;
1605
+ }
1606
+ }
1607
+ /**
1608
+ * Check input errors
1609
+ */
1610
+ checkError() {
1611
+ // Set error message
1612
+ this.errorMessage = undefined;
1613
+ if (!this.valid && this.input.validity.valueMissing) {
1614
+ this.errorMessage = messages.errors.required;
1615
+ }
1616
+ // Update class
1617
+ if (this.valid) {
1618
+ this.classList.delete(this.classError);
1619
+ }
1620
+ else {
1621
+ this.classList.add(this.classError);
1622
+ }
1623
+ }
1624
+ /*************
1625
+ * Lifecycle *
1626
+ *************/
1627
+ componentWillLoad() {
1628
+ // Check items format
1629
+ this.validateItems(this.items);
1630
+ // return a promise to process action only in the FIRST render().
1631
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
1632
+ return setTimeout(() => this.checkValidity(), 0);
1633
+ }
1634
+ render() {
1635
+ 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: 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
1636
+ index.h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map((option, optionIndex) => option.group !== undefined ? (index.h("optgroup", { label: option.group }, option.options.map((optgroup, optgroupIndex) => (index.h("option", { value: optgroupIndex, selected: JSON.stringify(this.value) === JSON.stringify(optgroup.value), disabled: optgroup.disabled }, optgroup.title))))) : (index.h("option", { value: optionIndex, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title))))));
1637
+ }
1638
+ static get watchers() { return {
1639
+ "items": ["validateItems"]
1640
+ }; }
1641
+ };
1642
+ MgInputSelect.style = mgInputSelectCss;
1643
+
1644
+ 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%;}.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);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--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)}";
1645
+
1646
+ const MgInputText = class {
1647
+ constructor(hostRef) {
1648
+ index.registerInstance(this, hostRef);
1649
+ this.valueChange = index.createEvent(this, "value-change", 7);
1650
+ /************
1651
+ * Internal *
1652
+ ************/
1653
+ // classes
1654
+ this.classFocus = 'is-focused';
1655
+ this.classError = InputClass.ERROR;
1656
+ /**
1657
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1658
+ * If not set, it will be created.
1659
+ */
1660
+ this.identifier = createID('mg-input-text');
1661
+ /**
1662
+ * Input name
1663
+ * If not set the value equals the identifier
1664
+ */
1665
+ this.name = this.identifier;
1666
+ /**
1667
+ * Input type
1668
+ */
1669
+ this.type = 'text';
1670
+ /**
1671
+ * Define if label is visible
1672
+ */
1673
+ this.labelHide = false;
1674
+ /**
1675
+ * Input max length
1676
+ */
1677
+ this.maxlength = 400;
1678
+ /**
1679
+ * Define if input is required
1680
+ */
1681
+ this.required = false;
1682
+ /**
1683
+ * Define if input is readonly
1684
+ */
1685
+ this.readonly = false;
1686
+ /**
1687
+ * Define if input is disabled
1688
+ */
1689
+ this.disabled = false;
1690
+ /**
1691
+ * Define input width
1692
+ */
1693
+ this.width = 'full';
1694
+ /**
1695
+ * Define if component should display character left
1696
+ */
1697
+ this.displayCharacterLeft = true;
1698
+ /**
1699
+ * Component classes
1700
+ */
1701
+ this.classList = new ClassList(['mg-input--text']);
1702
+ /**
1703
+ * Handle input event
1704
+ */
1705
+ this.handleInput = () => {
1706
+ this.checkValidity();
1707
+ this.value = this.input.value;
1708
+ this.valueChange.emit(this.value);
1709
+ };
1710
+ /**
1711
+ * Handle focus event
1712
+ */
1713
+ this.handleFocus = () => {
1714
+ this.classList.add(this.classFocus);
1715
+ this.classList = new ClassList(this.classList.classes);
1716
+ };
1717
+ /**
1718
+ * Handle blur event
1719
+ */
1720
+ this.handleBlur = () => {
1721
+ // Manage focus
1722
+ this.classList.delete(this.classFocus);
1723
+ this.classList = new ClassList(this.classList.classes);
1724
+ // Check validity
1725
+ this.checkValidity();
1726
+ this.checkError();
1727
+ };
1728
+ /**
1729
+ * Validate patern configuration
1730
+ */
1731
+ this.validatePattern = () => {
1732
+ if (this.pattern &&
1733
+ typeof this.pattern === 'string' &&
1734
+ this.pattern !== '' &&
1735
+ (this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
1736
+ throw new Error('<mg-input-text> prop "pattern" must be paired with the prop "patternErrorMessage"');
1737
+ }
1738
+ };
1739
+ }
1740
+ /**
1741
+ * Check if input is valid
1742
+ */
1743
+ checkValidity() {
1744
+ if (!this.readonly && this.input !== undefined) {
1745
+ const validity = this.input.checkValidity();
1746
+ // Set validity
1747
+ this.valid = validity;
1748
+ this.invalid = !validity;
1749
+ }
1750
+ }
1751
+ /**
1752
+ * Check input errors
1753
+ */
1754
+ checkError() {
1755
+ // Set error message
1756
+ this.errorMessage = undefined;
1757
+ // Does not match pattern
1758
+ if (!this.valid && this.input.validity.patternMismatch) {
1759
+ this.errorMessage = this.patternErrorMessage;
1760
+ }
1761
+ // required
1762
+ else if (!this.valid && this.input.validity.valueMissing) {
1763
+ this.errorMessage = messages.errors.required;
1764
+ }
1765
+ // Update class
1766
+ if (this.valid) {
1767
+ this.classList.delete(this.classError);
1768
+ }
1769
+ else {
1770
+ this.classList.add(this.classError);
1771
+ }
1772
+ }
1773
+ /**
1774
+ * Validate append slot
1775
+ */
1776
+ validateAppendSlot() {
1777
+ const slotAppendInput = this.element.querySelector('[slot="append-input"]');
1778
+ if (slotAppendInput !== null && slotAppendInput.querySelector('.mg-button') !== null) {
1779
+ this.classList.add('mg-input--is-input-group-append');
1780
+ this.classList = new ClassList(this.classList.classes);
1781
+ }
1782
+ else if (slotAppendInput !== null) {
1783
+ this.classList.add('mg-input--is-append-input-slot-content');
1784
+ this.classList = new ClassList(this.classList.classes);
1785
+ }
1786
+ }
1787
+ /*************
1788
+ * Lifecycle *
1789
+ *************/
1790
+ /**
1791
+ * Check if component props are well configured on init
1792
+ */
1793
+ componentWillLoad() {
1794
+ if (this.icon !== undefined) {
1795
+ this.classList.add('mg-input--has-icon');
1796
+ }
1797
+ this.validatePattern();
1798
+ // return a promise to process action only in the FIRST render().
1799
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
1800
+ return setTimeout(() => this.checkValidity(), 0);
1801
+ }
1802
+ componentDidLoad() {
1803
+ this.validateAppendSlot();
1804
+ }
1805
+ render() {
1806
+ 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" })));
1807
+ }
1808
+ get element() { return index.getElement(this); }
1809
+ };
1810
+ MgInputText.style = mgInputTextCss;
1811
+
1812
+ 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%;}.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);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--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}}";
1813
+
1814
+ const MgInputTextarea = class {
1815
+ constructor(hostRef) {
1816
+ index.registerInstance(this, hostRef);
1817
+ this.valueChange = index.createEvent(this, "value-change", 7);
1818
+ /************
1819
+ * Internal *
1820
+ ************/
1821
+ // classes
1822
+ this.classFocus = 'is-focused';
1823
+ this.classError = InputClass.ERROR;
1824
+ /**
1825
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1826
+ * If not set, it will be created.
1827
+ */
1828
+ this.identifier = createID('mg-input-textarea');
1829
+ /**
1830
+ * Input name
1831
+ * If not set the value equals the identifier
1832
+ */
1833
+ this.name = this.identifier;
1834
+ /**
1835
+ * Define if label is visible
1836
+ */
1837
+ this.labelHide = false;
1838
+ /**
1839
+ * Input max length
1840
+ */
1841
+ this.maxlength = 4000;
1842
+ /**
1843
+ * Define if input is required
1844
+ */
1845
+ this.required = false;
1846
+ /**
1847
+ * Define if input is readonly
1848
+ */
1849
+ this.readonly = false;
1850
+ /**
1851
+ * Define if input is disabled
1852
+ */
1853
+ this.disabled = false;
1854
+ /**
1855
+ * Define input width
1856
+ */
1857
+ this.width = 'full';
1858
+ /**
1859
+ * Define input pattern error message
1860
+ */
1861
+ this.rows = 3;
1862
+ /**
1863
+ * Define if component should display character left
1864
+ */
1865
+ this.displayCharacterLeft = true;
1866
+ /**
1867
+ * Component classes
1868
+ */
1869
+ this.classList = new ClassList(['mg-input--textarea']);
1870
+ /**
1871
+ * Handle input event
1872
+ */
1873
+ this.handleInput = () => {
1874
+ this.checkValidity();
1875
+ this.value = this.input.value;
1876
+ this.valueChange.emit(this.value);
1877
+ };
1878
+ /**
1879
+ * Handle focus event
1880
+ */
1881
+ this.handleFocus = () => {
1882
+ this.classList.add(this.classFocus);
1883
+ this.classList = new ClassList(this.classList.classes);
1884
+ };
1885
+ /**
1886
+ * Handle blur event
1887
+ */
1888
+ this.handleBlur = () => {
1889
+ // Manage focus
1890
+ this.classList.delete(this.classFocus);
1891
+ this.classList = new ClassList(this.classList.classes);
1892
+ // Check validity
1893
+ this.checkValidity();
1894
+ this.checkError();
1895
+ };
1896
+ /**
1897
+ * Get pattern validity
1898
+ * Pattern is not defined on textarea field : https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
1899
+ * @returns {boolean}
1900
+ */
1901
+ this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
1902
+ /**
1903
+ * Validate pattern configuration
1904
+ */
1905
+ this.validatePattern = () => {
1906
+ if (this.pattern &&
1907
+ typeof this.pattern === 'string' &&
1908
+ this.pattern !== '' &&
1909
+ (this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
1910
+ throw new Error('<mg-input-textarea> prop "pattern" must be paired with the prop "patternErrorMessage"');
1911
+ }
1912
+ };
1913
+ }
1914
+ /**
1915
+ * Check if input is valid
1916
+ */
1917
+ checkValidity() {
1918
+ if (!this.readonly && this.input !== undefined) {
1919
+ const patternValidity = this.getPatternValidity();
1920
+ const validity = this.input.checkValidity && this.input.checkValidity() && patternValidity;
1921
+ // Set validity
1922
+ this.valid = validity;
1923
+ this.invalid = !validity;
1924
+ }
1925
+ }
1926
+ /**
1927
+ * Check input errors
1928
+ */
1929
+ checkError() {
1930
+ const patternValidity = this.getPatternValidity();
1931
+ // Set error message
1932
+ this.errorMessage = undefined;
1933
+ if (!this.valid && !patternValidity) {
1934
+ this.errorMessage = this.patternErrorMessage;
1935
+ }
1936
+ // required
1937
+ else if (!this.valid && this.input.validity.valueMissing) {
1938
+ this.errorMessage = messages.errors.required;
1939
+ }
1940
+ // Update class
1941
+ if (this.valid) {
1942
+ this.classList.delete(this.classError);
1943
+ }
1944
+ else {
1945
+ this.classList.add(this.classError);
1946
+ }
1947
+ }
1948
+ /*************
1949
+ * Lifecycle *
1950
+ *************/
1951
+ componentWillLoad() {
1952
+ this.validatePattern();
1953
+ // return a promise to process action only in the FIRST render().
1954
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
1955
+ return setTimeout(() => this.checkValidity(), 0);
1956
+ }
1957
+ render() {
1958
+ 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) })));
1959
+ }
1960
+ };
1961
+ MgInputTextarea.style = mgInputTextareaCss;
1962
+
1963
+ 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}";
1964
+
1965
+ const MgInputTitle = class {
1966
+ constructor(hostRef) {
1967
+ index.registerInstance(this, hostRef);
1968
+ /**
1969
+ * Switch from label to fieldset sementic
1970
+ */
1971
+ this.isLegend = false;
1972
+ /**
1973
+ * Component parent tagname
1974
+ */
1975
+ this.tagName = 'label';
1976
+ this.getTagName = () => {
1977
+ this.tagName = this.isLegend ? 'legend' : 'label';
1978
+ };
1979
+ }
1980
+ /*************
1981
+ * Lifecycle *
1982
+ *************/
1983
+ componentWillLoad() {
1984
+ // Init tag name
1985
+ this.getTagName();
1986
+ }
1987
+ // \u00A0 represent a &nbsp;
1988
+ render() {
1989
+ const TagName = this.tagName;
1990
+ return (index.h(TagName, { class: "mg-input-title", htmlFor: this.isLegend ? undefined : this.identifier }, index.h("slot", null), this.required && [`\u00A0`, index.h("span", { class: "is-asterisk" }, "*")]));
1991
+ }
1992
+ };
1993
+ MgInputTitle.style = mgInputTitleCss;
1994
+
1995
+ 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%;}.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__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;cursor:not-allowed}";
1996
+
1997
+ /**
1998
+ * type Option validation function
1999
+ * @param option
2000
+ * @returns {boolean}
2001
+ */
2002
+ const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
2003
+ const MgInputToggle = class {
2004
+ constructor(hostRef) {
2005
+ index.registerInstance(this, hostRef);
2006
+ this.valueChange = index.createEvent(this, "value-change", 7);
2007
+ /************
2008
+ * Internal *
2009
+ ************/
2010
+ // classes
2011
+ this.classReadonly = 'mg-input--toggle-readonly';
2012
+ this.classDisabled = 'mg-input--toggle-disabled';
2013
+ this.classIsActive = 'mg-input--toggle-is-active';
2014
+ /**
2015
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2016
+ * If not set, it will be created.
2017
+ */
2018
+ this.identifier = createID('mg-input-toggle');
2019
+ /**
2020
+ * Input name
2021
+ * If not set the value equals the identifier
2022
+ */
2023
+ this.name = this.identifier;
2024
+ /**
2025
+ * Define if label is visible
2026
+ */
2027
+ this.labelHide = false;
2028
+ /**
2029
+ * Define if toggle have on/off style
2030
+ */
2031
+ this.isOnOff = false;
2032
+ /**
2033
+ * Define if toggle display icon
2034
+ */
2035
+ this.isIcon = false;
2036
+ /**
2037
+ * Define if input is readonly
2038
+ */
2039
+ this.readonly = false;
2040
+ /**
2041
+ * Define if input is disabled
2042
+ */
2043
+ this.disabled = false;
2044
+ /**
2045
+ * Component classes
2046
+ */
2047
+ this.classList = new ClassList(['mg-input--toggle']);
2048
+ /**
2049
+ * Checked internal value
2050
+ */
2051
+ this.checked = false;
2052
+ /**
2053
+ * Change checked value
2054
+ */
2055
+ this.toggleChecked = () => {
2056
+ this.setChecked(!this.checked);
2057
+ };
2058
+ /**
2059
+ * Slots validation
2060
+ */
2061
+ this.validateSlots = () => {
2062
+ const slots = Array.from(this.element.children);
2063
+ if (slots.length !== 2) {
2064
+ throw new Error('<mg-input-toggle> 2 slots are required.');
2065
+ }
2066
+ else if (!this.isIcon) {
2067
+ // Due to text-overflow set to ellipsis
2068
+ // we need to ensure that slot element have title to display value on mouse over
2069
+ slots.forEach(slot => slot.setAttribute('title', slot.textContent));
2070
+ }
2071
+ };
2072
+ }
2073
+ validateItems(newValue) {
2074
+ if (typeof newValue === 'object' && this.items.length !== 2) {
2075
+ throw new Error('<mg-input-toggle> prop "items" require 2 items.');
2076
+ }
2077
+ // String array
2078
+ else if (allItemsAreString(newValue)) {
2079
+ this.options = newValue.map(item => ({ title: item, value: item }));
2080
+ }
2081
+ // Object array
2082
+ else if (newValue && newValue.every(item => isOption(item))) {
2083
+ this.options = newValue;
2084
+ }
2085
+ else {
2086
+ throw new Error('<mg-input-toggle> prop "items" is required and all items must be the same type: ToggleValue.');
2087
+ }
2088
+ }
2089
+ handleIsOnOff(newValue) {
2090
+ if (newValue)
2091
+ this.classList.add(`mg-input--toggle-on-off`);
2092
+ }
2093
+ handleIsIcon(newValue) {
2094
+ if (newValue)
2095
+ this.classList.add(`mg-input--toggle-icon`);
2096
+ }
2097
+ handleReadonly(newValue) {
2098
+ if (newValue)
2099
+ this.classList.add(this.classReadonly);
2100
+ else
2101
+ this.classList.delete(this.classReadonly);
2102
+ }
2103
+ handleDisabled(newValue) {
2104
+ if (newValue)
2105
+ this.classList.add(this.classDisabled);
2106
+ else
2107
+ this.classList.delete(this.classDisabled);
2108
+ }
2109
+ handleChecked(newValue) {
2110
+ // style
2111
+ if (newValue)
2112
+ this.classList.add(this.classIsActive);
2113
+ else
2114
+ this.classList.delete(this.classIsActive);
2115
+ // update value
2116
+ this.value = this.options[this.checked ? 1 : 0].value;
2117
+ this.valueChange.emit(this.value);
2118
+ }
2119
+ /**
2120
+ * set checked state
2121
+ * @param newValue?
2122
+ */
2123
+ setChecked(newValue) {
2124
+ // has "value" props type is not a boolean, it is bind/render as an attributes/props
2125
+ // true props will be represent by "true" string so we convert it has boolean
2126
+ // true attribute will be represent by "" string so we convert it has boolean
2127
+ // https://stenciljs.com/docs/properties
2128
+ if (['', 'true'].includes(this.value) && this.options.find(option => option.value) !== undefined) {
2129
+ this.value = true;
2130
+ }
2131
+ if (newValue !== undefined) {
2132
+ this.checked = newValue;
2133
+ }
2134
+ else if (this.value === this.options[1].value) {
2135
+ this.checked = true;
2136
+ }
2137
+ else {
2138
+ this.checked = false;
2139
+ }
2140
+ }
2141
+ /*************
2142
+ * Lifecycle *
2143
+ *************/
2144
+ /**
2145
+ * Check if component props are well configured on init
2146
+ */
2147
+ componentWillLoad() {
2148
+ // Check items format
2149
+ this.validateItems(this.items);
2150
+ // init checked value
2151
+ this.setChecked();
2152
+ // apply handler
2153
+ this.handleIsOnOff(this.isOnOff);
2154
+ this.handleIsIcon(this.isIcon);
2155
+ this.handleReadonly(this.readonly);
2156
+ this.handleDisabled(this.disabled);
2157
+ this.validateSlots();
2158
+ }
2159
+ render() {
2160
+ var _a;
2161
+ 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: (_a = this.value) === null || _a === void 0 ? void 0 : _a.toString(), 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,
2162
+ // eslint-disable-next-line react/jsx-no-bind
2163
+ 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" })))));
2164
+ }
2165
+ get element() { return index.getElement(this); }
2166
+ static get watchers() { return {
2167
+ "items": ["validateItems"],
2168
+ "isOnOff": ["handleIsOnOff"],
2169
+ "isIcon": ["handleIsIcon"],
2170
+ "readonly": ["handleReadonly"],
2171
+ "disabled": ["handleDisabled"],
2172
+ "checked": ["handleChecked"]
2173
+ }; }
2174
+ };
2175
+ MgInputToggle.style = mgInputToggleCss;
2176
+
2177
+ /**
2178
+ * List of all possibles message variants
2179
+ */
2180
+ const variants$1 = ['info', 'warning', 'success', 'danger'];
2181
+
2182
+ 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:0 0.3rem 0.8rem 0 hsla(var(--color-dark), 0.1);box-shadow:0 0.3rem 0.8rem 0 hsla(var(--color-dark), 0.1)}.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%}";
2183
+
2184
+ const MgMessage = class {
2185
+ constructor(hostRef) {
2186
+ index.registerInstance(this, hostRef);
2187
+ this.componentShow = index.createEvent(this, "component-show", 7);
2188
+ this.componentHide = index.createEvent(this, "component-hide", 7);
2189
+ /************
2190
+ * Internal *
2191
+ ************/
2192
+ this.closeButtonId = '';
2193
+ // Stored timer setted when hide action is run from setTimeOut
2194
+ this.storedTimer = null;
2195
+ /**
2196
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2197
+ * If not set, it will be created.
2198
+ */
2199
+ this.identifier = createID('mg-message');
2200
+ /**
2201
+ * Message variant
2202
+ */
2203
+ this.variant = variants$1[0];
2204
+ /**
2205
+ * Define if message has a cross button
2206
+ * RG 01: https://jira.mgdis.fr/browse/PDA9-140
2207
+ */
2208
+ this.closeButton = false;
2209
+ /**
2210
+ * Define if message is hidden
2211
+ */
2212
+ this.hide = false;
2213
+ /**
2214
+ * Component classes
2215
+ */
2216
+ this.classList = new ClassList(['mg-message']);
2217
+ /**
2218
+ * Define if component is using actions slot
2219
+ */
2220
+ this.hasActions = false;
2221
+ /**
2222
+ * Handle close button
2223
+ */
2224
+ this.handleClose = () => {
2225
+ this.hide = true;
2226
+ };
2227
+ /**
2228
+ * Hide component whith delay
2229
+ */
2230
+ this.hideWithDelay = () => {
2231
+ if (this.delay > 0 && this.hide !== true) {
2232
+ this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
2233
+ }
2234
+ else if (this.storedTimer !== null) {
2235
+ clearTimeout(this.storedTimer);
2236
+ }
2237
+ };
2238
+ /**
2239
+ * Get icon corresponding to variant
2240
+ */
2241
+ this.getIcon = () => {
2242
+ switch (this.variant) {
2243
+ case 'info':
2244
+ return 'info-circle';
2245
+ case 'warning':
2246
+ return 'exclamation-triangle';
2247
+ case 'success':
2248
+ return 'check-circle';
2249
+ case 'danger':
2250
+ return 'exclamation-circle';
2251
+ }
2252
+ };
2253
+ }
2254
+ validateDelay(newValue) {
2255
+ if (newValue && newValue < 2) {
2256
+ throw new Error(`<mg-message> prop "delay" must be greater than 2 seconds.`);
2257
+ }
2258
+ }
2259
+ validateVariant(newValue, oldValue) {
2260
+ if (!variants$1.includes(newValue)) {
2261
+ throw new Error(`<mg-message> prop "variant" must be one of : ${variants$1.join(', ')}`);
2262
+ }
2263
+ if (oldValue !== undefined) {
2264
+ this.classList.delete(`mg-message--${oldValue}`);
2265
+ }
2266
+ this.classList.add(`mg-message--${this.variant}`);
2267
+ }
2268
+ validateCloseButton(newValue) {
2269
+ if (newValue && this.hasActions) {
2270
+ this.closeButton = false;
2271
+ throw new Error('<mg-message> prop "close-button" can\'t be used with the actions slot.');
2272
+ }
2273
+ }
2274
+ validateHide(newValue) {
2275
+ if (newValue) {
2276
+ this.componentHide.emit();
2277
+ this.classList.add('mg-message--hide');
2278
+ }
2279
+ else {
2280
+ this.componentShow.emit();
2281
+ this.classList.delete('mg-message--hide');
2282
+ }
2283
+ this.hideWithDelay();
2284
+ }
2285
+ /*************
2286
+ * Lifecycle *
2287
+ *************/
2288
+ /**
2289
+ * Check if component props are well configured on init
2290
+ */
2291
+ componentWillLoad() {
2292
+ this.validateVariant(this.variant);
2293
+ // Check if close button is an can be activated
2294
+ this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
2295
+ this.validateCloseButton(this.closeButton);
2296
+ if (this.closeButton) {
2297
+ this.classList.add('mg-message--close-button');
2298
+ this.closeButtonId = `${this.identifier}-close-button`;
2299
+ }
2300
+ this.validateDelay(this.delay);
2301
+ this.validateHide(this.hide);
2302
+ }
2303
+ render() {
2304
+ 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: messages.message.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" }))))));
2305
+ }
2306
+ get element() { return index.getElement(this); }
2307
+ static get watchers() { return {
2308
+ "delay": ["validateDelay"],
2309
+ "variant": ["validateVariant"],
2310
+ "closeButton": ["validateCloseButton"],
2311
+ "hide": ["validateHide"]
2312
+ }; }
2313
+ };
2314
+ MgMessage.style = mgMessageCss;
2315
+
2316
+ var NavigationAction;
2317
+ (function (NavigationAction) {
2318
+ NavigationAction["NEXT"] = "next";
2319
+ NavigationAction["PREVIOUS"] = "previous";
2320
+ })(NavigationAction || (NavigationAction = {}));
2321
+
2322
+ 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}";
2323
+
2324
+ /**
2325
+ * Range generator
2326
+ *
2327
+ * start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
2328
+ * then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
2329
+ * then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
2330
+ * then with Array.from(Array(...)) we get the complete array with "index" values instead of "empty" values
2331
+ * ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
2332
+ * finaly we map values from "start" range and apply the "step" coefficiant,
2333
+ * ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
2334
+ *
2335
+ * range(1, 1) = [1]
2336
+ * range(1, 5) = [1, 2, 3, 4, 5]
2337
+ * range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
2338
+ *
2339
+ * @param start
2340
+ * @param end
2341
+ * @param step
2342
+ * @returns {number[]}
2343
+ */
2344
+ const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
2345
+ const MgPagination = class {
2346
+ constructor(hostRef) {
2347
+ index.registerInstance(this, hostRef);
2348
+ this.currentPageChange = index.createEvent(this, "current-page-change", 7);
2349
+ /**************
2350
+ * Decorators *
2351
+ **************/
2352
+ /**
2353
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2354
+ * If not set, it will be created.
2355
+ */
2356
+ this.identifier = createID('mg-pagination');
2357
+ /**
2358
+ * Panignation label. Is a short description.
2359
+ * Customize default value can be usefull to improve accessibility
2360
+ */
2361
+ this.label = 'pagination';
2362
+ /**
2363
+ * Component total pages
2364
+ */
2365
+ this.totalPages = 1;
2366
+ /**
2367
+ * Component current page
2368
+ */
2369
+ this.currentPage = 1;
2370
+ /**
2371
+ * Change current page from target
2372
+ * @param target
2373
+ */
2374
+ this.goToPage = (target) => (this.currentPage = target);
2375
+ /************
2376
+ * Handlers *
2377
+ ************/
2378
+ /**
2379
+ * Default click handler
2380
+ * @param event
2381
+ */
2382
+ this.handleSelect = (event) => {
2383
+ const to = Number(event.target.value);
2384
+ this.goToPage(to > 0 ? to : 1);
2385
+ };
2386
+ /**
2387
+ * Go to 'previous/next' page button handler
2388
+ * @returns {void}
2389
+ */
2390
+ this.handleGoToPage = (action) => this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
2391
+ }
2392
+ validateTotalPages(newValue) {
2393
+ if (newValue < 1) {
2394
+ throw new Error('<mg-pagination> prop "totalPages" must be greater than 0');
2395
+ }
2396
+ }
2397
+ validateCurrentPage(newValue) {
2398
+ if (newValue < 1) {
2399
+ throw new Error('<mg-pagination> prop "currentPage" must be greater than 0');
2400
+ }
2401
+ else if (newValue > this.totalPages) {
2402
+ throw new Error('<mg-pagination> prop "currentPage" can not be greater than total page');
2403
+ }
2404
+ this.currentPageChange.emit(newValue);
2405
+ }
2406
+ /*************
2407
+ * Lifecycle *
2408
+ *************/
2409
+ componentWillLoad() {
2410
+ this.validateTotalPages(this.totalPages);
2411
+ this.validateCurrentPage(this.currentPage);
2412
+ }
2413
+ render() {
2414
+ const navigationActionButton = (disabled, action) => (index.h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: messages.pagination[`${action}Page`],
2415
+ // eslint-disable-next-line react/jsx-no-bind
2416
+ onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" }, action === NavigationAction.PREVIOUS && index.h("mg-icon", { icon: "chevron-left" }), messages.pagination[action], action === NavigationAction.NEXT && index.h("mg-icon", { icon: "chevron-right" })));
2417
+ 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: messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), index.h("span", { class: "sr-only" }, messages.pagination.page, " ", this.currentPage), index.h("span", null, "/ ", this.totalPages, " ", this.totalPages > 1 ? messages.pagination.pages : messages.pagination.pages), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
2418
+ }
2419
+ static get watchers() { return {
2420
+ "totalPages": ["validateTotalPages"],
2421
+ "currentPage": ["validateCurrentPage"]
2422
+ }; }
2423
+ };
2424
+ MgPagination.style = mgPaginationCss;
2425
+
2426
+ var top = 'top';
2427
+ var bottom = 'bottom';
2428
+ var right = 'right';
2429
+ var left = 'left';
2430
+ var auto = 'auto';
2431
+ var basePlacements = [top, bottom, right, left];
2432
+ var start = 'start';
2433
+ var end = 'end';
2434
+ var clippingParents = 'clippingParents';
2435
+ var viewport = 'viewport';
2436
+ var popper = 'popper';
2437
+ var reference = 'reference';
2438
+ var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
2439
+ return acc.concat([placement + "-" + start, placement + "-" + end]);
2440
+ }, []);
2441
+ var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
2442
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
2443
+ }, []); // modifiers that need to read the DOM
2444
+
2445
+ var beforeRead = 'beforeRead';
2446
+ var read = 'read';
2447
+ var afterRead = 'afterRead'; // pure-logic modifiers
2448
+
2449
+ var beforeMain = 'beforeMain';
2450
+ var main = 'main';
2451
+ var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
2452
+
2453
+ var beforeWrite = 'beforeWrite';
2454
+ var write = 'write';
2455
+ var afterWrite = 'afterWrite';
2456
+ var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
2457
+
2458
+ function getNodeName(element) {
2459
+ return element ? (element.nodeName || '').toLowerCase() : null;
2460
+ }
2461
+
2462
+ function getWindow(node) {
2463
+ if (node == null) {
2464
+ return window;
2465
+ }
2466
+
2467
+ if (node.toString() !== '[object Window]') {
2468
+ var ownerDocument = node.ownerDocument;
2469
+ return ownerDocument ? ownerDocument.defaultView || window : window;
2470
+ }
2471
+
2472
+ return node;
2473
+ }
2474
+
2475
+ function isElement(node) {
2476
+ var OwnElement = getWindow(node).Element;
2477
+ return node instanceof OwnElement || node instanceof Element;
2478
+ }
2479
+
2480
+ function isHTMLElement(node) {
2481
+ var OwnElement = getWindow(node).HTMLElement;
2482
+ return node instanceof OwnElement || node instanceof HTMLElement;
2483
+ }
2484
+
2485
+ function isShadowRoot(node) {
2486
+ // IE 11 has no ShadowRoot
2487
+ if (typeof ShadowRoot === 'undefined') {
2488
+ return false;
2489
+ }
2490
+
2491
+ var OwnElement = getWindow(node).ShadowRoot;
2492
+ return node instanceof OwnElement || node instanceof ShadowRoot;
2493
+ }
2494
+
2495
+ // and applies them to the HTMLElements such as popper and arrow
2496
+
2497
+ function applyStyles(_ref) {
2498
+ var state = _ref.state;
2499
+ Object.keys(state.elements).forEach(function (name) {
2500
+ var style = state.styles[name] || {};
2501
+ var attributes = state.attributes[name] || {};
2502
+ var element = state.elements[name]; // arrow is optional + virtual elements
2503
+
2504
+ if (!isHTMLElement(element) || !getNodeName(element)) {
2505
+ return;
2506
+ } // Flow doesn't support to extend this property, but it's the most
2507
+ // effective way to apply styles to an HTMLElement
2508
+ // $FlowFixMe[cannot-write]
2509
+
2510
+
2511
+ Object.assign(element.style, style);
2512
+ Object.keys(attributes).forEach(function (name) {
2513
+ var value = attributes[name];
2514
+
2515
+ if (value === false) {
2516
+ element.removeAttribute(name);
2517
+ } else {
2518
+ element.setAttribute(name, value === true ? '' : value);
2519
+ }
2520
+ });
2521
+ });
2522
+ }
2523
+
2524
+ function effect$2(_ref2) {
2525
+ var state = _ref2.state;
2526
+ var initialStyles = {
2527
+ popper: {
2528
+ position: state.options.strategy,
2529
+ left: '0',
2530
+ top: '0',
2531
+ margin: '0'
2532
+ },
2533
+ arrow: {
2534
+ position: 'absolute'
2535
+ },
2536
+ reference: {}
2537
+ };
2538
+ Object.assign(state.elements.popper.style, initialStyles.popper);
2539
+ state.styles = initialStyles;
2540
+
2541
+ if (state.elements.arrow) {
2542
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
2543
+ }
2544
+
2545
+ return function () {
2546
+ Object.keys(state.elements).forEach(function (name) {
2547
+ var element = state.elements[name];
2548
+ var attributes = state.attributes[name] || {};
2549
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
2550
+
2551
+ var style = styleProperties.reduce(function (style, property) {
2552
+ style[property] = '';
2553
+ return style;
2554
+ }, {}); // arrow is optional + virtual elements
2555
+
2556
+ if (!isHTMLElement(element) || !getNodeName(element)) {
2557
+ return;
2558
+ }
2559
+
2560
+ Object.assign(element.style, style);
2561
+ Object.keys(attributes).forEach(function (attribute) {
2562
+ element.removeAttribute(attribute);
2563
+ });
2564
+ });
2565
+ };
2566
+ } // eslint-disable-next-line import/no-unused-modules
2567
+
2568
+
2569
+ const applyStyles$1 = {
2570
+ name: 'applyStyles',
2571
+ enabled: true,
2572
+ phase: 'write',
2573
+ fn: applyStyles,
2574
+ effect: effect$2,
2575
+ requires: ['computeStyles']
2576
+ };
2577
+
2578
+ function getBasePlacement(placement) {
2579
+ return placement.split('-')[0];
2580
+ }
2581
+
2582
+ var max = Math.max;
2583
+ var min = Math.min;
2584
+ var round = Math.round;
2585
+
2586
+ function getBoundingClientRect(element, includeScale) {
2587
+ if (includeScale === void 0) {
2588
+ includeScale = false;
2589
+ }
2590
+
2591
+ var rect = element.getBoundingClientRect();
2592
+ var scaleX = 1;
2593
+ var scaleY = 1;
2594
+
2595
+ if (isHTMLElement(element) && includeScale) {
2596
+ var offsetHeight = element.offsetHeight;
2597
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
2598
+ // Fallback to 1 in case both values are `0`
2599
+
2600
+ if (offsetWidth > 0) {
2601
+ scaleX = round(rect.width) / offsetWidth || 1;
2602
+ }
2603
+
2604
+ if (offsetHeight > 0) {
2605
+ scaleY = round(rect.height) / offsetHeight || 1;
2606
+ }
2607
+ }
2608
+
2609
+ return {
2610
+ width: rect.width / scaleX,
2611
+ height: rect.height / scaleY,
2612
+ top: rect.top / scaleY,
2613
+ right: rect.right / scaleX,
2614
+ bottom: rect.bottom / scaleY,
2615
+ left: rect.left / scaleX,
2616
+ x: rect.left / scaleX,
2617
+ y: rect.top / scaleY
2618
+ };
2619
+ }
2620
+
2621
+ // means it doesn't take into account transforms.
2622
+
2623
+ function getLayoutRect(element) {
2624
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
2625
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
2626
+
2627
+ var width = element.offsetWidth;
2628
+ var height = element.offsetHeight;
2629
+
2630
+ if (Math.abs(clientRect.width - width) <= 1) {
2631
+ width = clientRect.width;
2632
+ }
2633
+
2634
+ if (Math.abs(clientRect.height - height) <= 1) {
2635
+ height = clientRect.height;
2636
+ }
2637
+
2638
+ return {
2639
+ x: element.offsetLeft,
2640
+ y: element.offsetTop,
2641
+ width: width,
2642
+ height: height
2643
+ };
2644
+ }
2645
+
2646
+ function contains(parent, child) {
2647
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
2648
+
2649
+ if (parent.contains(child)) {
2650
+ return true;
2651
+ } // then fallback to custom implementation with Shadow DOM support
2652
+ else if (rootNode && isShadowRoot(rootNode)) {
2653
+ var next = child;
2654
+
2655
+ do {
2656
+ if (next && parent.isSameNode(next)) {
2657
+ return true;
2658
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
2659
+
2660
+
2661
+ next = next.parentNode || next.host;
2662
+ } while (next);
2663
+ } // Give up, the result is false
2664
+
2665
+
2666
+ return false;
2667
+ }
2668
+
2669
+ function getComputedStyle(element) {
2670
+ return getWindow(element).getComputedStyle(element);
2671
+ }
2672
+
2673
+ function isTableElement(element) {
2674
+ return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
2675
+ }
2676
+
2677
+ function getDocumentElement(element) {
2678
+ // $FlowFixMe[incompatible-return]: assume body is always available
2679
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
2680
+ element.document) || window.document).documentElement;
2681
+ }
2682
+
2683
+ function getParentNode(element) {
2684
+ if (getNodeName(element) === 'html') {
2685
+ return element;
2686
+ }
2687
+
2688
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
2689
+ // $FlowFixMe[incompatible-return]
2690
+ // $FlowFixMe[prop-missing]
2691
+ element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
2692
+ element.parentNode || ( // DOM Element detected
2693
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
2694
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
2695
+ getDocumentElement(element) // fallback
2696
+
2697
+ );
2698
+ }
2699
+
2700
+ function getTrueOffsetParent(element) {
2701
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
2702
+ getComputedStyle(element).position === 'fixed') {
2703
+ return null;
2704
+ }
2705
+
2706
+ return element.offsetParent;
2707
+ } // `.offsetParent` reports `null` for fixed elements, while absolute elements
2708
+ // return the containing block
2709
+
2710
+
2711
+ function getContainingBlock(element) {
2712
+ var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
2713
+ var isIE = navigator.userAgent.indexOf('Trident') !== -1;
2714
+
2715
+ if (isIE && isHTMLElement(element)) {
2716
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
2717
+ var elementCss = getComputedStyle(element);
2718
+
2719
+ if (elementCss.position === 'fixed') {
2720
+ return null;
2721
+ }
2722
+ }
2723
+
2724
+ var currentNode = getParentNode(element);
2725
+
2726
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
2727
+ var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
2728
+ // create a containing block.
2729
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2730
+
2731
+ if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
2732
+ return currentNode;
2733
+ } else {
2734
+ currentNode = currentNode.parentNode;
2735
+ }
2736
+ }
2737
+
2738
+ return null;
2739
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
2740
+ // such as table ancestors and cross browser bugs.
2741
+
2742
+
2743
+ function getOffsetParent(element) {
2744
+ var window = getWindow(element);
2745
+ var offsetParent = getTrueOffsetParent(element);
2746
+
2747
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
2748
+ offsetParent = getTrueOffsetParent(offsetParent);
2749
+ }
2750
+
2751
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
2752
+ return window;
2753
+ }
2754
+
2755
+ return offsetParent || getContainingBlock(element) || window;
2756
+ }
2757
+
2758
+ function getMainAxisFromPlacement(placement) {
2759
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
2760
+ }
2761
+
2762
+ function within(min$1, value, max$1) {
2763
+ return max(min$1, min(value, max$1));
2764
+ }
2765
+ function withinMaxClamp(min, value, max) {
2766
+ var v = within(min, value, max);
2767
+ return v > max ? max : v;
2768
+ }
2769
+
2770
+ function getFreshSideObject() {
2771
+ return {
2772
+ top: 0,
2773
+ right: 0,
2774
+ bottom: 0,
2775
+ left: 0
2776
+ };
2777
+ }
2778
+
2779
+ function mergePaddingObject(paddingObject) {
2780
+ return Object.assign({}, getFreshSideObject(), paddingObject);
2781
+ }
2782
+
2783
+ function expandToHashMap(value, keys) {
2784
+ return keys.reduce(function (hashMap, key) {
2785
+ hashMap[key] = value;
2786
+ return hashMap;
2787
+ }, {});
2788
+ }
2789
+
2790
+ var toPaddingObject = function toPaddingObject(padding, state) {
2791
+ padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
2792
+ placement: state.placement
2793
+ })) : padding;
2794
+ return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
2795
+ };
2796
+
2797
+ function arrow(_ref) {
2798
+ var _state$modifiersData$;
2799
+
2800
+ var state = _ref.state,
2801
+ name = _ref.name,
2802
+ options = _ref.options;
2803
+ var arrowElement = state.elements.arrow;
2804
+ var popperOffsets = state.modifiersData.popperOffsets;
2805
+ var basePlacement = getBasePlacement(state.placement);
2806
+ var axis = getMainAxisFromPlacement(basePlacement);
2807
+ var isVertical = [left, right].indexOf(basePlacement) >= 0;
2808
+ var len = isVertical ? 'height' : 'width';
2809
+
2810
+ if (!arrowElement || !popperOffsets) {
2811
+ return;
2812
+ }
2813
+
2814
+ var paddingObject = toPaddingObject(options.padding, state);
2815
+ var arrowRect = getLayoutRect(arrowElement);
2816
+ var minProp = axis === 'y' ? top : left;
2817
+ var maxProp = axis === 'y' ? bottom : right;
2818
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
2819
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
2820
+ var arrowOffsetParent = getOffsetParent(arrowElement);
2821
+ var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
2822
+ var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
2823
+ // outside of the popper bounds
2824
+
2825
+ var min = paddingObject[minProp];
2826
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
2827
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
2828
+ var offset = within(min, center, max); // Prevents breaking syntax highlighting...
2829
+
2830
+ var axisProp = axis;
2831
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
2832
+ }
2833
+
2834
+ function effect$1(_ref2) {
2835
+ var state = _ref2.state,
2836
+ options = _ref2.options;
2837
+ var _options$element = options.element,
2838
+ arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
2839
+
2840
+ if (arrowElement == null) {
2841
+ return;
2842
+ } // CSS selector
2843
+
2844
+
2845
+ if (typeof arrowElement === 'string') {
2846
+ arrowElement = state.elements.popper.querySelector(arrowElement);
2847
+
2848
+ if (!arrowElement) {
2849
+ return;
2850
+ }
2851
+ }
2852
+
2853
+ if (!contains(state.elements.popper, arrowElement)) {
2854
+
2855
+ return;
2856
+ }
2857
+
2858
+ state.elements.arrow = arrowElement;
2859
+ } // eslint-disable-next-line import/no-unused-modules
2860
+
2861
+
2862
+ const arrow$1 = {
2863
+ name: 'arrow',
2864
+ enabled: true,
2865
+ phase: 'main',
2866
+ fn: arrow,
2867
+ effect: effect$1,
2868
+ requires: ['popperOffsets'],
2869
+ requiresIfExists: ['preventOverflow']
2870
+ };
2871
+
2872
+ function getVariation(placement) {
2873
+ return placement.split('-')[1];
2874
+ }
2875
+
2876
+ var unsetSides = {
2877
+ top: 'auto',
2878
+ right: 'auto',
2879
+ bottom: 'auto',
2880
+ left: 'auto'
2881
+ }; // Round the offsets to the nearest suitable subpixel based on the DPR.
2882
+ // Zooming can change the DPR, but it seems to report a value that will
2883
+ // cleanly divide the values into the appropriate subpixels.
2884
+
2885
+ function roundOffsetsByDPR(_ref) {
2886
+ var x = _ref.x,
2887
+ y = _ref.y;
2888
+ var win = window;
2889
+ var dpr = win.devicePixelRatio || 1;
2890
+ return {
2891
+ x: round(x * dpr) / dpr || 0,
2892
+ y: round(y * dpr) / dpr || 0
2893
+ };
2894
+ }
2895
+
2896
+ function mapToStyles(_ref2) {
2897
+ var _Object$assign2;
2898
+
2899
+ var popper = _ref2.popper,
2900
+ popperRect = _ref2.popperRect,
2901
+ placement = _ref2.placement,
2902
+ variation = _ref2.variation,
2903
+ offsets = _ref2.offsets,
2904
+ position = _ref2.position,
2905
+ gpuAcceleration = _ref2.gpuAcceleration,
2906
+ adaptive = _ref2.adaptive,
2907
+ roundOffsets = _ref2.roundOffsets,
2908
+ isFixed = _ref2.isFixed;
2909
+ var _offsets$x = offsets.x,
2910
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
2911
+ _offsets$y = offsets.y,
2912
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
2913
+
2914
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
2915
+ x: x,
2916
+ y: y
2917
+ }) : {
2918
+ x: x,
2919
+ y: y
2920
+ };
2921
+
2922
+ x = _ref3.x;
2923
+ y = _ref3.y;
2924
+ var hasX = offsets.hasOwnProperty('x');
2925
+ var hasY = offsets.hasOwnProperty('y');
2926
+ var sideX = left;
2927
+ var sideY = top;
2928
+ var win = window;
2929
+
2930
+ if (adaptive) {
2931
+ var offsetParent = getOffsetParent(popper);
2932
+ var heightProp = 'clientHeight';
2933
+ var widthProp = 'clientWidth';
2934
+
2935
+ if (offsetParent === getWindow(popper)) {
2936
+ offsetParent = getDocumentElement(popper);
2937
+
2938
+ if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
2939
+ heightProp = 'scrollHeight';
2940
+ widthProp = 'scrollWidth';
2941
+ }
2942
+ } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
2943
+
2944
+
2945
+ offsetParent = offsetParent;
2946
+
2947
+ if (placement === top || (placement === left || placement === right) && variation === end) {
2948
+ sideY = bottom;
2949
+ var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
2950
+ offsetParent[heightProp];
2951
+ y -= offsetY - popperRect.height;
2952
+ y *= gpuAcceleration ? 1 : -1;
2953
+ }
2954
+
2955
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
2956
+ sideX = right;
2957
+ var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
2958
+ offsetParent[widthProp];
2959
+ x -= offsetX - popperRect.width;
2960
+ x *= gpuAcceleration ? 1 : -1;
2961
+ }
2962
+ }
2963
+
2964
+ var commonStyles = Object.assign({
2965
+ position: position
2966
+ }, adaptive && unsetSides);
2967
+
2968
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
2969
+ x: x,
2970
+ y: y
2971
+ }) : {
2972
+ x: x,
2973
+ y: y
2974
+ };
2975
+
2976
+ x = _ref4.x;
2977
+ y = _ref4.y;
2978
+
2979
+ if (gpuAcceleration) {
2980
+ var _Object$assign;
2981
+
2982
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
2983
+ }
2984
+
2985
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
2986
+ }
2987
+
2988
+ function computeStyles(_ref5) {
2989
+ var state = _ref5.state,
2990
+ options = _ref5.options;
2991
+ var _options$gpuAccelerat = options.gpuAcceleration,
2992
+ gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
2993
+ _options$adaptive = options.adaptive,
2994
+ adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
2995
+ _options$roundOffsets = options.roundOffsets,
2996
+ roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
2997
+
2998
+ var commonStyles = {
2999
+ placement: getBasePlacement(state.placement),
3000
+ variation: getVariation(state.placement),
3001
+ popper: state.elements.popper,
3002
+ popperRect: state.rects.popper,
3003
+ gpuAcceleration: gpuAcceleration,
3004
+ isFixed: state.options.strategy === 'fixed'
3005
+ };
3006
+
3007
+ if (state.modifiersData.popperOffsets != null) {
3008
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
3009
+ offsets: state.modifiersData.popperOffsets,
3010
+ position: state.options.strategy,
3011
+ adaptive: adaptive,
3012
+ roundOffsets: roundOffsets
3013
+ })));
3014
+ }
3015
+
3016
+ if (state.modifiersData.arrow != null) {
3017
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
3018
+ offsets: state.modifiersData.arrow,
3019
+ position: 'absolute',
3020
+ adaptive: false,
3021
+ roundOffsets: roundOffsets
3022
+ })));
3023
+ }
3024
+
3025
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
3026
+ 'data-popper-placement': state.placement
3027
+ });
3028
+ } // eslint-disable-next-line import/no-unused-modules
3029
+
3030
+
3031
+ const computeStyles$1 = {
3032
+ name: 'computeStyles',
3033
+ enabled: true,
3034
+ phase: 'beforeWrite',
3035
+ fn: computeStyles,
3036
+ data: {}
3037
+ };
3038
+
3039
+ var passive = {
3040
+ passive: true
3041
+ };
3042
+
3043
+ function effect(_ref) {
3044
+ var state = _ref.state,
3045
+ instance = _ref.instance,
3046
+ options = _ref.options;
3047
+ var _options$scroll = options.scroll,
3048
+ scroll = _options$scroll === void 0 ? true : _options$scroll,
3049
+ _options$resize = options.resize,
3050
+ resize = _options$resize === void 0 ? true : _options$resize;
3051
+ var window = getWindow(state.elements.popper);
3052
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
3053
+
3054
+ if (scroll) {
3055
+ scrollParents.forEach(function (scrollParent) {
3056
+ scrollParent.addEventListener('scroll', instance.update, passive);
3057
+ });
3058
+ }
3059
+
3060
+ if (resize) {
3061
+ window.addEventListener('resize', instance.update, passive);
3062
+ }
3063
+
3064
+ return function () {
3065
+ if (scroll) {
3066
+ scrollParents.forEach(function (scrollParent) {
3067
+ scrollParent.removeEventListener('scroll', instance.update, passive);
3068
+ });
3069
+ }
3070
+
3071
+ if (resize) {
3072
+ window.removeEventListener('resize', instance.update, passive);
3073
+ }
3074
+ };
3075
+ } // eslint-disable-next-line import/no-unused-modules
3076
+
3077
+
3078
+ const eventListeners = {
3079
+ name: 'eventListeners',
3080
+ enabled: true,
3081
+ phase: 'write',
3082
+ fn: function fn() {},
3083
+ effect: effect,
3084
+ data: {}
3085
+ };
3086
+
3087
+ var hash$1 = {
3088
+ left: 'right',
3089
+ right: 'left',
3090
+ bottom: 'top',
3091
+ top: 'bottom'
3092
+ };
3093
+ function getOppositePlacement(placement) {
3094
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
3095
+ return hash$1[matched];
3096
+ });
3097
+ }
3098
+
3099
+ var hash = {
3100
+ start: 'end',
3101
+ end: 'start'
3102
+ };
3103
+ function getOppositeVariationPlacement(placement) {
3104
+ return placement.replace(/start|end/g, function (matched) {
3105
+ return hash[matched];
3106
+ });
3107
+ }
3108
+
3109
+ function getWindowScroll(node) {
3110
+ var win = getWindow(node);
3111
+ var scrollLeft = win.pageXOffset;
3112
+ var scrollTop = win.pageYOffset;
3113
+ return {
3114
+ scrollLeft: scrollLeft,
3115
+ scrollTop: scrollTop
3116
+ };
3117
+ }
3118
+
3119
+ function getWindowScrollBarX(element) {
3120
+ // If <html> has a CSS width greater than the viewport, then this will be
3121
+ // incorrect for RTL.
3122
+ // Popper 1 is broken in this case and never had a bug report so let's assume
3123
+ // it's not an issue. I don't think anyone ever specifies width on <html>
3124
+ // anyway.
3125
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
3126
+ // this (e.g. Edge 2019, IE11, Safari)
3127
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
3128
+ }
3129
+
3130
+ function getViewportRect(element) {
3131
+ var win = getWindow(element);
3132
+ var html = getDocumentElement(element);
3133
+ var visualViewport = win.visualViewport;
3134
+ var width = html.clientWidth;
3135
+ var height = html.clientHeight;
3136
+ var x = 0;
3137
+ var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
3138
+ // can be obscured underneath it.
3139
+ // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
3140
+ // if it isn't open, so if this isn't available, the popper will be detected
3141
+ // to overflow the bottom of the screen too early.
3142
+
3143
+ if (visualViewport) {
3144
+ width = visualViewport.width;
3145
+ height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
3146
+ // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
3147
+ // errors due to floating point numbers, so we need to check precision.
3148
+ // Safari returns a number <= 0, usually < -1 when pinch-zoomed
3149
+ // Feature detection fails in mobile emulation mode in Chrome.
3150
+ // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
3151
+ // 0.001
3152
+ // Fallback here: "Not Safari" userAgent
3153
+
3154
+ if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
3155
+ x = visualViewport.offsetLeft;
3156
+ y = visualViewport.offsetTop;
3157
+ }
3158
+ }
3159
+
3160
+ return {
3161
+ width: width,
3162
+ height: height,
3163
+ x: x + getWindowScrollBarX(element),
3164
+ y: y
3165
+ };
3166
+ }
3167
+
3168
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
3169
+
3170
+ function getDocumentRect(element) {
3171
+ var _element$ownerDocumen;
3172
+
3173
+ var html = getDocumentElement(element);
3174
+ var winScroll = getWindowScroll(element);
3175
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
3176
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
3177
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
3178
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
3179
+ var y = -winScroll.scrollTop;
3180
+
3181
+ if (getComputedStyle(body || html).direction === 'rtl') {
3182
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
3183
+ }
3184
+
3185
+ return {
3186
+ width: width,
3187
+ height: height,
3188
+ x: x,
3189
+ y: y
3190
+ };
3191
+ }
3192
+
3193
+ function isScrollParent(element) {
3194
+ // Firefox wants us to check `-x` and `-y` variations as well
3195
+ var _getComputedStyle = getComputedStyle(element),
3196
+ overflow = _getComputedStyle.overflow,
3197
+ overflowX = _getComputedStyle.overflowX,
3198
+ overflowY = _getComputedStyle.overflowY;
3199
+
3200
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
3201
+ }
3202
+
3203
+ function getScrollParent(node) {
3204
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
3205
+ // $FlowFixMe[incompatible-return]: assume body is always available
3206
+ return node.ownerDocument.body;
3207
+ }
3208
+
3209
+ if (isHTMLElement(node) && isScrollParent(node)) {
3210
+ return node;
3211
+ }
3212
+
3213
+ return getScrollParent(getParentNode(node));
3214
+ }
3215
+
3216
+ /*
3217
+ given a DOM element, return the list of all scroll parents, up the list of ancesors
3218
+ until we get to the top window object. This list is what we attach scroll listeners
3219
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
3220
+ reference element's position.
3221
+ */
3222
+
3223
+ function listScrollParents(element, list) {
3224
+ var _element$ownerDocumen;
3225
+
3226
+ if (list === void 0) {
3227
+ list = [];
3228
+ }
3229
+
3230
+ var scrollParent = getScrollParent(element);
3231
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
3232
+ var win = getWindow(scrollParent);
3233
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
3234
+ var updatedList = list.concat(target);
3235
+ return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
3236
+ updatedList.concat(listScrollParents(getParentNode(target)));
3237
+ }
3238
+
3239
+ function rectToClientRect(rect) {
3240
+ return Object.assign({}, rect, {
3241
+ left: rect.x,
3242
+ top: rect.y,
3243
+ right: rect.x + rect.width,
3244
+ bottom: rect.y + rect.height
3245
+ });
3246
+ }
3247
+
3248
+ function getInnerBoundingClientRect(element) {
3249
+ var rect = getBoundingClientRect(element);
3250
+ rect.top = rect.top + element.clientTop;
3251
+ rect.left = rect.left + element.clientLeft;
3252
+ rect.bottom = rect.top + element.clientHeight;
3253
+ rect.right = rect.left + element.clientWidth;
3254
+ rect.width = element.clientWidth;
3255
+ rect.height = element.clientHeight;
3256
+ rect.x = rect.left;
3257
+ rect.y = rect.top;
3258
+ return rect;
3259
+ }
3260
+
3261
+ function getClientRectFromMixedType(element, clippingParent) {
3262
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
3263
+ } // A "clipping parent" is an overflowable container with the characteristic of
3264
+ // clipping (or hiding) overflowing elements with a position different from
3265
+ // `initial`
3266
+
3267
+
3268
+ function getClippingParents(element) {
3269
+ var clippingParents = listScrollParents(getParentNode(element));
3270
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
3271
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
3272
+
3273
+ if (!isElement(clipperElement)) {
3274
+ return [];
3275
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
3276
+
3277
+
3278
+ return clippingParents.filter(function (clippingParent) {
3279
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
3280
+ });
3281
+ } // Gets the maximum area that the element is visible in due to any number of
3282
+ // clipping parents
3283
+
3284
+
3285
+ function getClippingRect(element, boundary, rootBoundary) {
3286
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
3287
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
3288
+ var firstClippingParent = clippingParents[0];
3289
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
3290
+ var rect = getClientRectFromMixedType(element, clippingParent);
3291
+ accRect.top = max(rect.top, accRect.top);
3292
+ accRect.right = min(rect.right, accRect.right);
3293
+ accRect.bottom = min(rect.bottom, accRect.bottom);
3294
+ accRect.left = max(rect.left, accRect.left);
3295
+ return accRect;
3296
+ }, getClientRectFromMixedType(element, firstClippingParent));
3297
+ clippingRect.width = clippingRect.right - clippingRect.left;
3298
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
3299
+ clippingRect.x = clippingRect.left;
3300
+ clippingRect.y = clippingRect.top;
3301
+ return clippingRect;
3302
+ }
3303
+
3304
+ function computeOffsets(_ref) {
3305
+ var reference = _ref.reference,
3306
+ element = _ref.element,
3307
+ placement = _ref.placement;
3308
+ var basePlacement = placement ? getBasePlacement(placement) : null;
3309
+ var variation = placement ? getVariation(placement) : null;
3310
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
3311
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
3312
+ var offsets;
3313
+
3314
+ switch (basePlacement) {
3315
+ case top:
3316
+ offsets = {
3317
+ x: commonX,
3318
+ y: reference.y - element.height
3319
+ };
3320
+ break;
3321
+
3322
+ case bottom:
3323
+ offsets = {
3324
+ x: commonX,
3325
+ y: reference.y + reference.height
3326
+ };
3327
+ break;
3328
+
3329
+ case right:
3330
+ offsets = {
3331
+ x: reference.x + reference.width,
3332
+ y: commonY
3333
+ };
3334
+ break;
3335
+
3336
+ case left:
3337
+ offsets = {
3338
+ x: reference.x - element.width,
3339
+ y: commonY
3340
+ };
3341
+ break;
3342
+
3343
+ default:
3344
+ offsets = {
3345
+ x: reference.x,
3346
+ y: reference.y
3347
+ };
3348
+ }
3349
+
3350
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
3351
+
3352
+ if (mainAxis != null) {
3353
+ var len = mainAxis === 'y' ? 'height' : 'width';
3354
+
3355
+ switch (variation) {
3356
+ case start:
3357
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
3358
+ break;
3359
+
3360
+ case end:
3361
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
3362
+ break;
3363
+ }
3364
+ }
3365
+
3366
+ return offsets;
3367
+ }
3368
+
3369
+ function detectOverflow(state, options) {
3370
+ if (options === void 0) {
3371
+ options = {};
3372
+ }
3373
+
3374
+ var _options = options,
3375
+ _options$placement = _options.placement,
3376
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
3377
+ _options$boundary = _options.boundary,
3378
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
3379
+ _options$rootBoundary = _options.rootBoundary,
3380
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
3381
+ _options$elementConte = _options.elementContext,
3382
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
3383
+ _options$altBoundary = _options.altBoundary,
3384
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
3385
+ _options$padding = _options.padding,
3386
+ padding = _options$padding === void 0 ? 0 : _options$padding;
3387
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
3388
+ var altContext = elementContext === popper ? reference : popper;
3389
+ var popperRect = state.rects.popper;
3390
+ var element = state.elements[altBoundary ? altContext : elementContext];
3391
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
3392
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
3393
+ var popperOffsets = computeOffsets({
3394
+ reference: referenceClientRect,
3395
+ element: popperRect,
3396
+ strategy: 'absolute',
3397
+ placement: placement
3398
+ });
3399
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
3400
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
3401
+ // 0 or negative = within the clipping rect
3402
+
3403
+ var overflowOffsets = {
3404
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
3405
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
3406
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
3407
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
3408
+ };
3409
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
3410
+
3411
+ if (elementContext === popper && offsetData) {
3412
+ var offset = offsetData[placement];
3413
+ Object.keys(overflowOffsets).forEach(function (key) {
3414
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
3415
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
3416
+ overflowOffsets[key] += offset[axis] * multiply;
3417
+ });
3418
+ }
3419
+
3420
+ return overflowOffsets;
3421
+ }
3422
+
3423
+ function computeAutoPlacement(state, options) {
3424
+ if (options === void 0) {
3425
+ options = {};
3426
+ }
3427
+
3428
+ var _options = options,
3429
+ placement = _options.placement,
3430
+ boundary = _options.boundary,
3431
+ rootBoundary = _options.rootBoundary,
3432
+ padding = _options.padding,
3433
+ flipVariations = _options.flipVariations,
3434
+ _options$allowedAutoP = _options.allowedAutoPlacements,
3435
+ allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
3436
+ var variation = getVariation(placement);
3437
+ var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
3438
+ return getVariation(placement) === variation;
3439
+ }) : basePlacements;
3440
+ var allowedPlacements = placements$1.filter(function (placement) {
3441
+ return allowedAutoPlacements.indexOf(placement) >= 0;
3442
+ });
3443
+
3444
+ if (allowedPlacements.length === 0) {
3445
+ allowedPlacements = placements$1;
3446
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
3447
+
3448
+
3449
+ var overflows = allowedPlacements.reduce(function (acc, placement) {
3450
+ acc[placement] = detectOverflow(state, {
3451
+ placement: placement,
3452
+ boundary: boundary,
3453
+ rootBoundary: rootBoundary,
3454
+ padding: padding
3455
+ })[getBasePlacement(placement)];
3456
+ return acc;
3457
+ }, {});
3458
+ return Object.keys(overflows).sort(function (a, b) {
3459
+ return overflows[a] - overflows[b];
3460
+ });
3461
+ }
3462
+
3463
+ function getExpandedFallbackPlacements(placement) {
3464
+ if (getBasePlacement(placement) === auto) {
3465
+ return [];
3466
+ }
3467
+
3468
+ var oppositePlacement = getOppositePlacement(placement);
3469
+ return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
3470
+ }
3471
+
3472
+ function flip(_ref) {
3473
+ var state = _ref.state,
3474
+ options = _ref.options,
3475
+ name = _ref.name;
3476
+
3477
+ if (state.modifiersData[name]._skip) {
3478
+ return;
3479
+ }
3480
+
3481
+ var _options$mainAxis = options.mainAxis,
3482
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
3483
+ _options$altAxis = options.altAxis,
3484
+ checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
3485
+ specifiedFallbackPlacements = options.fallbackPlacements,
3486
+ padding = options.padding,
3487
+ boundary = options.boundary,
3488
+ rootBoundary = options.rootBoundary,
3489
+ altBoundary = options.altBoundary,
3490
+ _options$flipVariatio = options.flipVariations,
3491
+ flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
3492
+ allowedAutoPlacements = options.allowedAutoPlacements;
3493
+ var preferredPlacement = state.options.placement;
3494
+ var basePlacement = getBasePlacement(preferredPlacement);
3495
+ var isBasePlacement = basePlacement === preferredPlacement;
3496
+ var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
3497
+ var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
3498
+ return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
3499
+ placement: placement,
3500
+ boundary: boundary,
3501
+ rootBoundary: rootBoundary,
3502
+ padding: padding,
3503
+ flipVariations: flipVariations,
3504
+ allowedAutoPlacements: allowedAutoPlacements
3505
+ }) : placement);
3506
+ }, []);
3507
+ var referenceRect = state.rects.reference;
3508
+ var popperRect = state.rects.popper;
3509
+ var checksMap = new Map();
3510
+ var makeFallbackChecks = true;
3511
+ var firstFittingPlacement = placements[0];
3512
+
3513
+ for (var i = 0; i < placements.length; i++) {
3514
+ var placement = placements[i];
3515
+
3516
+ var _basePlacement = getBasePlacement(placement);
3517
+
3518
+ var isStartVariation = getVariation(placement) === start;
3519
+ var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
3520
+ var len = isVertical ? 'width' : 'height';
3521
+ var overflow = detectOverflow(state, {
3522
+ placement: placement,
3523
+ boundary: boundary,
3524
+ rootBoundary: rootBoundary,
3525
+ altBoundary: altBoundary,
3526
+ padding: padding
3527
+ });
3528
+ var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
3529
+
3530
+ if (referenceRect[len] > popperRect[len]) {
3531
+ mainVariationSide = getOppositePlacement(mainVariationSide);
3532
+ }
3533
+
3534
+ var altVariationSide = getOppositePlacement(mainVariationSide);
3535
+ var checks = [];
3536
+
3537
+ if (checkMainAxis) {
3538
+ checks.push(overflow[_basePlacement] <= 0);
3539
+ }
3540
+
3541
+ if (checkAltAxis) {
3542
+ checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
3543
+ }
3544
+
3545
+ if (checks.every(function (check) {
3546
+ return check;
3547
+ })) {
3548
+ firstFittingPlacement = placement;
3549
+ makeFallbackChecks = false;
3550
+ break;
3551
+ }
3552
+
3553
+ checksMap.set(placement, checks);
3554
+ }
3555
+
3556
+ if (makeFallbackChecks) {
3557
+ // `2` may be desired in some cases – research later
3558
+ var numberOfChecks = flipVariations ? 3 : 1;
3559
+
3560
+ var _loop = function _loop(_i) {
3561
+ var fittingPlacement = placements.find(function (placement) {
3562
+ var checks = checksMap.get(placement);
3563
+
3564
+ if (checks) {
3565
+ return checks.slice(0, _i).every(function (check) {
3566
+ return check;
3567
+ });
3568
+ }
3569
+ });
3570
+
3571
+ if (fittingPlacement) {
3572
+ firstFittingPlacement = fittingPlacement;
3573
+ return "break";
3574
+ }
3575
+ };
3576
+
3577
+ for (var _i = numberOfChecks; _i > 0; _i--) {
3578
+ var _ret = _loop(_i);
3579
+
3580
+ if (_ret === "break") break;
3581
+ }
3582
+ }
3583
+
3584
+ if (state.placement !== firstFittingPlacement) {
3585
+ state.modifiersData[name]._skip = true;
3586
+ state.placement = firstFittingPlacement;
3587
+ state.reset = true;
3588
+ }
3589
+ } // eslint-disable-next-line import/no-unused-modules
3590
+
3591
+
3592
+ const flip$1 = {
3593
+ name: 'flip',
3594
+ enabled: true,
3595
+ phase: 'main',
3596
+ fn: flip,
3597
+ requiresIfExists: ['offset'],
3598
+ data: {
3599
+ _skip: false
3600
+ }
3601
+ };
3602
+
3603
+ function getSideOffsets(overflow, rect, preventedOffsets) {
3604
+ if (preventedOffsets === void 0) {
3605
+ preventedOffsets = {
3606
+ x: 0,
3607
+ y: 0
3608
+ };
3609
+ }
3610
+
3611
+ return {
3612
+ top: overflow.top - rect.height - preventedOffsets.y,
3613
+ right: overflow.right - rect.width + preventedOffsets.x,
3614
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
3615
+ left: overflow.left - rect.width - preventedOffsets.x
3616
+ };
3617
+ }
3618
+
3619
+ function isAnySideFullyClipped(overflow) {
3620
+ return [top, right, bottom, left].some(function (side) {
3621
+ return overflow[side] >= 0;
3622
+ });
3623
+ }
3624
+
3625
+ function hide(_ref) {
3626
+ var state = _ref.state,
3627
+ name = _ref.name;
3628
+ var referenceRect = state.rects.reference;
3629
+ var popperRect = state.rects.popper;
3630
+ var preventedOffsets = state.modifiersData.preventOverflow;
3631
+ var referenceOverflow = detectOverflow(state, {
3632
+ elementContext: 'reference'
3633
+ });
3634
+ var popperAltOverflow = detectOverflow(state, {
3635
+ altBoundary: true
3636
+ });
3637
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
3638
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
3639
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
3640
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
3641
+ state.modifiersData[name] = {
3642
+ referenceClippingOffsets: referenceClippingOffsets,
3643
+ popperEscapeOffsets: popperEscapeOffsets,
3644
+ isReferenceHidden: isReferenceHidden,
3645
+ hasPopperEscaped: hasPopperEscaped
3646
+ };
3647
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
3648
+ 'data-popper-reference-hidden': isReferenceHidden,
3649
+ 'data-popper-escaped': hasPopperEscaped
3650
+ });
3651
+ } // eslint-disable-next-line import/no-unused-modules
3652
+
3653
+
3654
+ const hide$1 = {
3655
+ name: 'hide',
3656
+ enabled: true,
3657
+ phase: 'main',
3658
+ requiresIfExists: ['preventOverflow'],
3659
+ fn: hide
3660
+ };
3661
+
3662
+ function distanceAndSkiddingToXY(placement, rects, offset) {
3663
+ var basePlacement = getBasePlacement(placement);
3664
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
3665
+
3666
+ var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
3667
+ placement: placement
3668
+ })) : offset,
3669
+ skidding = _ref[0],
3670
+ distance = _ref[1];
3671
+
3672
+ skidding = skidding || 0;
3673
+ distance = (distance || 0) * invertDistance;
3674
+ return [left, right].indexOf(basePlacement) >= 0 ? {
3675
+ x: distance,
3676
+ y: skidding
3677
+ } : {
3678
+ x: skidding,
3679
+ y: distance
3680
+ };
3681
+ }
3682
+
3683
+ function offset(_ref2) {
3684
+ var state = _ref2.state,
3685
+ options = _ref2.options,
3686
+ name = _ref2.name;
3687
+ var _options$offset = options.offset,
3688
+ offset = _options$offset === void 0 ? [0, 0] : _options$offset;
3689
+ var data = placements.reduce(function (acc, placement) {
3690
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
3691
+ return acc;
3692
+ }, {});
3693
+ var _data$state$placement = data[state.placement],
3694
+ x = _data$state$placement.x,
3695
+ y = _data$state$placement.y;
3696
+
3697
+ if (state.modifiersData.popperOffsets != null) {
3698
+ state.modifiersData.popperOffsets.x += x;
3699
+ state.modifiersData.popperOffsets.y += y;
3700
+ }
3701
+
3702
+ state.modifiersData[name] = data;
3703
+ } // eslint-disable-next-line import/no-unused-modules
3704
+
3705
+
3706
+ const offset$1 = {
3707
+ name: 'offset',
3708
+ enabled: true,
3709
+ phase: 'main',
3710
+ requires: ['popperOffsets'],
3711
+ fn: offset
3712
+ };
3713
+
3714
+ function popperOffsets(_ref) {
3715
+ var state = _ref.state,
3716
+ name = _ref.name;
3717
+ // Offsets are the actual position the popper needs to have to be
3718
+ // properly positioned near its reference element
3719
+ // This is the most basic placement, and will be adjusted by
3720
+ // the modifiers in the next step
3721
+ state.modifiersData[name] = computeOffsets({
3722
+ reference: state.rects.reference,
3723
+ element: state.rects.popper,
3724
+ strategy: 'absolute',
3725
+ placement: state.placement
3726
+ });
3727
+ } // eslint-disable-next-line import/no-unused-modules
3728
+
3729
+
3730
+ const popperOffsets$1 = {
3731
+ name: 'popperOffsets',
3732
+ enabled: true,
3733
+ phase: 'read',
3734
+ fn: popperOffsets,
3735
+ data: {}
3736
+ };
3737
+
3738
+ function getAltAxis(axis) {
3739
+ return axis === 'x' ? 'y' : 'x';
3740
+ }
3741
+
3742
+ function preventOverflow(_ref) {
3743
+ var state = _ref.state,
3744
+ options = _ref.options,
3745
+ name = _ref.name;
3746
+ var _options$mainAxis = options.mainAxis,
3747
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
3748
+ _options$altAxis = options.altAxis,
3749
+ checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
3750
+ boundary = options.boundary,
3751
+ rootBoundary = options.rootBoundary,
3752
+ altBoundary = options.altBoundary,
3753
+ padding = options.padding,
3754
+ _options$tether = options.tether,
3755
+ tether = _options$tether === void 0 ? true : _options$tether,
3756
+ _options$tetherOffset = options.tetherOffset,
3757
+ tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
3758
+ var overflow = detectOverflow(state, {
3759
+ boundary: boundary,
3760
+ rootBoundary: rootBoundary,
3761
+ padding: padding,
3762
+ altBoundary: altBoundary
3763
+ });
3764
+ var basePlacement = getBasePlacement(state.placement);
3765
+ var variation = getVariation(state.placement);
3766
+ var isBasePlacement = !variation;
3767
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
3768
+ var altAxis = getAltAxis(mainAxis);
3769
+ var popperOffsets = state.modifiersData.popperOffsets;
3770
+ var referenceRect = state.rects.reference;
3771
+ var popperRect = state.rects.popper;
3772
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
3773
+ placement: state.placement
3774
+ })) : tetherOffset;
3775
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
3776
+ mainAxis: tetherOffsetValue,
3777
+ altAxis: tetherOffsetValue
3778
+ } : Object.assign({
3779
+ mainAxis: 0,
3780
+ altAxis: 0
3781
+ }, tetherOffsetValue);
3782
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
3783
+ var data = {
3784
+ x: 0,
3785
+ y: 0
3786
+ };
3787
+
3788
+ if (!popperOffsets) {
3789
+ return;
3790
+ }
3791
+
3792
+ if (checkMainAxis) {
3793
+ var _offsetModifierState$;
3794
+
3795
+ var mainSide = mainAxis === 'y' ? top : left;
3796
+ var altSide = mainAxis === 'y' ? bottom : right;
3797
+ var len = mainAxis === 'y' ? 'height' : 'width';
3798
+ var offset = popperOffsets[mainAxis];
3799
+ var min$1 = offset + overflow[mainSide];
3800
+ var max$1 = offset - overflow[altSide];
3801
+ var additive = tether ? -popperRect[len] / 2 : 0;
3802
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
3803
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
3804
+ // outside the reference bounds
3805
+
3806
+ var arrowElement = state.elements.arrow;
3807
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
3808
+ width: 0,
3809
+ height: 0
3810
+ };
3811
+ var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
3812
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
3813
+ var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
3814
+ // to include its full size in the calculation. If the reference is small
3815
+ // and near the edge of a boundary, the popper can overflow even if the
3816
+ // reference is not overflowing as well (e.g. virtual elements with no
3817
+ // width or height)
3818
+
3819
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
3820
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
3821
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
3822
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
3823
+ var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
3824
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
3825
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
3826
+ var tetherMax = offset + maxOffset - offsetModifierValue;
3827
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
3828
+ popperOffsets[mainAxis] = preventedOffset;
3829
+ data[mainAxis] = preventedOffset - offset;
3830
+ }
3831
+
3832
+ if (checkAltAxis) {
3833
+ var _offsetModifierState$2;
3834
+
3835
+ var _mainSide = mainAxis === 'x' ? top : left;
3836
+
3837
+ var _altSide = mainAxis === 'x' ? bottom : right;
3838
+
3839
+ var _offset = popperOffsets[altAxis];
3840
+
3841
+ var _len = altAxis === 'y' ? 'height' : 'width';
3842
+
3843
+ var _min = _offset + overflow[_mainSide];
3844
+
3845
+ var _max = _offset - overflow[_altSide];
3846
+
3847
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
3848
+
3849
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
3850
+
3851
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
3852
+
3853
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
3854
+
3855
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
3856
+
3857
+ popperOffsets[altAxis] = _preventedOffset;
3858
+ data[altAxis] = _preventedOffset - _offset;
3859
+ }
3860
+
3861
+ state.modifiersData[name] = data;
3862
+ } // eslint-disable-next-line import/no-unused-modules
3863
+
3864
+
3865
+ const preventOverflow$1 = {
3866
+ name: 'preventOverflow',
3867
+ enabled: true,
3868
+ phase: 'main',
3869
+ fn: preventOverflow,
3870
+ requiresIfExists: ['offset']
3871
+ };
3872
+
3873
+ function getHTMLElementScroll(element) {
3874
+ return {
3875
+ scrollLeft: element.scrollLeft,
3876
+ scrollTop: element.scrollTop
3877
+ };
3878
+ }
3879
+
3880
+ function getNodeScroll(node) {
3881
+ if (node === getWindow(node) || !isHTMLElement(node)) {
3882
+ return getWindowScroll(node);
3883
+ } else {
3884
+ return getHTMLElementScroll(node);
3885
+ }
3886
+ }
3887
+
3888
+ function isElementScaled(element) {
3889
+ var rect = element.getBoundingClientRect();
3890
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
3891
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
3892
+ return scaleX !== 1 || scaleY !== 1;
3893
+ } // Returns the composite rect of an element relative to its offsetParent.
3894
+ // Composite means it takes into account transforms as well as layout.
3895
+
3896
+
3897
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
3898
+ if (isFixed === void 0) {
3899
+ isFixed = false;
3900
+ }
3901
+
3902
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
3903
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
3904
+ var documentElement = getDocumentElement(offsetParent);
3905
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
3906
+ var scroll = {
3907
+ scrollLeft: 0,
3908
+ scrollTop: 0
3909
+ };
3910
+ var offsets = {
3911
+ x: 0,
3912
+ y: 0
3913
+ };
3914
+
3915
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
3916
+ if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
3917
+ isScrollParent(documentElement)) {
3918
+ scroll = getNodeScroll(offsetParent);
3919
+ }
3920
+
3921
+ if (isHTMLElement(offsetParent)) {
3922
+ offsets = getBoundingClientRect(offsetParent, true);
3923
+ offsets.x += offsetParent.clientLeft;
3924
+ offsets.y += offsetParent.clientTop;
3925
+ } else if (documentElement) {
3926
+ offsets.x = getWindowScrollBarX(documentElement);
3927
+ }
3928
+ }
3929
+
3930
+ return {
3931
+ x: rect.left + scroll.scrollLeft - offsets.x,
3932
+ y: rect.top + scroll.scrollTop - offsets.y,
3933
+ width: rect.width,
3934
+ height: rect.height
3935
+ };
3936
+ }
3937
+
3938
+ function order(modifiers) {
3939
+ var map = new Map();
3940
+ var visited = new Set();
3941
+ var result = [];
3942
+ modifiers.forEach(function (modifier) {
3943
+ map.set(modifier.name, modifier);
3944
+ }); // On visiting object, check for its dependencies and visit them recursively
3945
+
3946
+ function sort(modifier) {
3947
+ visited.add(modifier.name);
3948
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
3949
+ requires.forEach(function (dep) {
3950
+ if (!visited.has(dep)) {
3951
+ var depModifier = map.get(dep);
3952
+
3953
+ if (depModifier) {
3954
+ sort(depModifier);
3955
+ }
3956
+ }
3957
+ });
3958
+ result.push(modifier);
3959
+ }
3960
+
3961
+ modifiers.forEach(function (modifier) {
3962
+ if (!visited.has(modifier.name)) {
3963
+ // check for visited object
3964
+ sort(modifier);
3965
+ }
3966
+ });
3967
+ return result;
3968
+ }
3969
+
3970
+ function orderModifiers(modifiers) {
3971
+ // order based on dependencies
3972
+ var orderedModifiers = order(modifiers); // order based on phase
3973
+
3974
+ return modifierPhases.reduce(function (acc, phase) {
3975
+ return acc.concat(orderedModifiers.filter(function (modifier) {
3976
+ return modifier.phase === phase;
3977
+ }));
3978
+ }, []);
3979
+ }
3980
+
3981
+ function debounce(fn) {
3982
+ var pending;
3983
+ return function () {
3984
+ if (!pending) {
3985
+ pending = new Promise(function (resolve) {
3986
+ Promise.resolve().then(function () {
3987
+ pending = undefined;
3988
+ resolve(fn());
3989
+ });
3990
+ });
3991
+ }
3992
+
3993
+ return pending;
3994
+ };
3995
+ }
3996
+
3997
+ function mergeByName(modifiers) {
3998
+ var merged = modifiers.reduce(function (merged, current) {
3999
+ var existing = merged[current.name];
4000
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
4001
+ options: Object.assign({}, existing.options, current.options),
4002
+ data: Object.assign({}, existing.data, current.data)
4003
+ }) : current;
4004
+ return merged;
4005
+ }, {}); // IE11 does not support Object.values
4006
+
4007
+ return Object.keys(merged).map(function (key) {
4008
+ return merged[key];
4009
+ });
4010
+ }
4011
+
4012
+ var DEFAULT_OPTIONS = {
4013
+ placement: 'bottom',
4014
+ modifiers: [],
4015
+ strategy: 'absolute'
4016
+ };
4017
+
4018
+ function areValidElements() {
4019
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4020
+ args[_key] = arguments[_key];
4021
+ }
4022
+
4023
+ return !args.some(function (element) {
4024
+ return !(element && typeof element.getBoundingClientRect === 'function');
4025
+ });
4026
+ }
4027
+
4028
+ function popperGenerator(generatorOptions) {
4029
+ if (generatorOptions === void 0) {
4030
+ generatorOptions = {};
4031
+ }
4032
+
4033
+ var _generatorOptions = generatorOptions,
4034
+ _generatorOptions$def = _generatorOptions.defaultModifiers,
4035
+ defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
4036
+ _generatorOptions$def2 = _generatorOptions.defaultOptions,
4037
+ defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
4038
+ return function createPopper(reference, popper, options) {
4039
+ if (options === void 0) {
4040
+ options = defaultOptions;
4041
+ }
4042
+
4043
+ var state = {
4044
+ placement: 'bottom',
4045
+ orderedModifiers: [],
4046
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
4047
+ modifiersData: {},
4048
+ elements: {
4049
+ reference: reference,
4050
+ popper: popper
4051
+ },
4052
+ attributes: {},
4053
+ styles: {}
4054
+ };
4055
+ var effectCleanupFns = [];
4056
+ var isDestroyed = false;
4057
+ var instance = {
4058
+ state: state,
4059
+ setOptions: function setOptions(setOptionsAction) {
4060
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
4061
+ cleanupModifierEffects();
4062
+ state.options = Object.assign({}, defaultOptions, state.options, options);
4063
+ state.scrollParents = {
4064
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
4065
+ popper: listScrollParents(popper)
4066
+ }; // Orders the modifiers based on their dependencies and `phase`
4067
+ // properties
4068
+
4069
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
4070
+
4071
+ state.orderedModifiers = orderedModifiers.filter(function (m) {
4072
+ return m.enabled;
4073
+ }); // Validate the provided modifiers so that the consumer will get warned
4074
+
4075
+ runModifierEffects();
4076
+ return instance.update();
4077
+ },
4078
+ // Sync update – it will always be executed, even if not necessary. This
4079
+ // is useful for low frequency updates where sync behavior simplifies the
4080
+ // logic.
4081
+ // For high frequency updates (e.g. `resize` and `scroll` events), always
4082
+ // prefer the async Popper#update method
4083
+ forceUpdate: function forceUpdate() {
4084
+ if (isDestroyed) {
4085
+ return;
4086
+ }
4087
+
4088
+ var _state$elements = state.elements,
4089
+ reference = _state$elements.reference,
4090
+ popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
4091
+ // anymore
4092
+
4093
+ if (!areValidElements(reference, popper)) {
4094
+
4095
+ return;
4096
+ } // Store the reference and popper rects to be read by modifiers
4097
+
4098
+
4099
+ state.rects = {
4100
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
4101
+ popper: getLayoutRect(popper)
4102
+ }; // Modifiers have the ability to reset the current update cycle. The
4103
+ // most common use case for this is the `flip` modifier changing the
4104
+ // placement, which then needs to re-run all the modifiers, because the
4105
+ // logic was previously ran for the previous placement and is therefore
4106
+ // stale/incorrect
4107
+
4108
+ state.reset = false;
4109
+ state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
4110
+ // is filled with the initial data specified by the modifier. This means
4111
+ // it doesn't persist and is fresh on each update.
4112
+ // To ensure persistent data, use `${name}#persistent`
4113
+
4114
+ state.orderedModifiers.forEach(function (modifier) {
4115
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
4116
+ });
4117
+
4118
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
4119
+
4120
+ if (state.reset === true) {
4121
+ state.reset = false;
4122
+ index = -1;
4123
+ continue;
4124
+ }
4125
+
4126
+ var _state$orderedModifie = state.orderedModifiers[index],
4127
+ fn = _state$orderedModifie.fn,
4128
+ _state$orderedModifie2 = _state$orderedModifie.options,
4129
+ _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
4130
+ name = _state$orderedModifie.name;
4131
+
4132
+ if (typeof fn === 'function') {
4133
+ state = fn({
4134
+ state: state,
4135
+ options: _options,
4136
+ name: name,
4137
+ instance: instance
4138
+ }) || state;
4139
+ }
4140
+ }
4141
+ },
4142
+ // Async and optimistically optimized update – it will not be executed if
4143
+ // not necessary (debounced to run at most once-per-tick)
4144
+ update: debounce(function () {
4145
+ return new Promise(function (resolve) {
4146
+ instance.forceUpdate();
4147
+ resolve(state);
4148
+ });
4149
+ }),
4150
+ destroy: function destroy() {
4151
+ cleanupModifierEffects();
4152
+ isDestroyed = true;
4153
+ }
4154
+ };
4155
+
4156
+ if (!areValidElements(reference, popper)) {
4157
+
4158
+ return instance;
4159
+ }
4160
+
4161
+ instance.setOptions(options).then(function (state) {
4162
+ if (!isDestroyed && options.onFirstUpdate) {
4163
+ options.onFirstUpdate(state);
4164
+ }
4165
+ }); // Modifiers have the ability to execute arbitrary code before the first
4166
+ // update cycle runs. They will be executed in the same order as the update
4167
+ // cycle. This is useful when a modifier adds some persistent data that
4168
+ // other modifiers need to use, but the modifier is run after the dependent
4169
+ // one.
4170
+
4171
+ function runModifierEffects() {
4172
+ state.orderedModifiers.forEach(function (_ref3) {
4173
+ var name = _ref3.name,
4174
+ _ref3$options = _ref3.options,
4175
+ options = _ref3$options === void 0 ? {} : _ref3$options,
4176
+ effect = _ref3.effect;
4177
+
4178
+ if (typeof effect === 'function') {
4179
+ var cleanupFn = effect({
4180
+ state: state,
4181
+ name: name,
4182
+ instance: instance,
4183
+ options: options
4184
+ });
4185
+
4186
+ var noopFn = function noopFn() {};
4187
+
4188
+ effectCleanupFns.push(cleanupFn || noopFn);
4189
+ }
4190
+ });
4191
+ }
4192
+
4193
+ function cleanupModifierEffects() {
4194
+ effectCleanupFns.forEach(function (fn) {
4195
+ return fn();
4196
+ });
4197
+ effectCleanupFns = [];
4198
+ }
4199
+
4200
+ return instance;
4201
+ };
4202
+ }
4203
+
4204
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
4205
+ var createPopper = /*#__PURE__*/popperGenerator({
4206
+ defaultModifiers: defaultModifiers
4207
+ }); // eslint-disable-next-line import/no-unused-modules
4208
+
4209
+ const mgPopoverCss = "mg-popover.sc-mg-popover{display:contents}mg-popover.sc-mg-popover-s>*{display:inline-block}.mg-popover.sc-mg-popover{display:none;padding:1.5rem;z-index:9999;border-radius:0.5rem;background-color:hsl(var(--mg-popover-background-color));-webkit-box-shadow:0 0.3rem 0.8rem 0 rgba(0, 0, 0, 0.1);box-shadow:0 0.3rem 0.8rem 0 rgba(0, 0, 0, 0.1);color:hsl(var(--mg-popover-font-color))}.mg-popover[data-show].sc-mg-popover{display:block}.mg-popover.sc-mg-popover mg-button.sc-mg-popover{float:right;margin-right:calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);margin-top:calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);margin-left:3rem}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover,.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover::before{position:absolute;width:2rem;height:2rem;z-index:9999;background:inherit}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover{visibility:hidden}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover::before{visibility:visible;content:\"\";-webkit-transform:rotate(45deg);transform:rotate(45deg)}.mg-popover[data-popper-placement^=top].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{bottom:-6px}.mg-popover[data-popper-placement^=bottom].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{top:-6px}.mg-popover[data-popper-placement^=left].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{right:-6px}.mg-popover[data-popper-placement^=right].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{left:-6px}.mg-popover__title.sc-mg-popover-s>*,.mg-popover__title .sc-mg-popover-s>*{margin:0 0 1rem;font-size:var(--mg-popover-title-font-size);font-weight:600}";
4210
+
4211
+ const MgPopover = class {
4212
+ constructor(hostRef) {
4213
+ index.registerInstance(this, hostRef);
4214
+ this.closeButtonId = '';
4215
+ /**
4216
+ * Sets an `id` attribute.
4217
+ * Needed by the input for accessibility `aria-decribedby`.
4218
+ */
4219
+ this.identifier = createID('mg-popover');
4220
+ /**
4221
+ * Popover placement
4222
+ */
4223
+ this.placement = 'bottom';
4224
+ /**
4225
+ * Define if popover has a cross button
4226
+ */
4227
+ this.closeButton = false;
4228
+ /**
4229
+ * Display popover
4230
+ */
4231
+ this.display = false;
4232
+ /**
4233
+ * Disable popover
4234
+ */
4235
+ this.disabled = false;
4236
+ /**
4237
+ * Check if clicked outside of component
4238
+ * @param e {event}
4239
+ */
4240
+ // Unable to trigger document events in unit tests: https://gitlab.mgdis.fr/core/core-ui/mg-components/-/issues/57
4241
+ /* istanbul ignore next */
4242
+ this.clickOutside = e => {
4243
+ var _a;
4244
+ if (!this.disabled && ((_a = e.target.closest(`#${this.identifier}`)) === null || _a === void 0 ? void 0 : _a.parentElement.nodeName) !== 'MG-POPOVER') {
4245
+ this.display = false;
4246
+ }
4247
+ };
4248
+ /**
4249
+ * Show popover
4250
+ * @returns {void}
4251
+ */
4252
+ this.show = () => {
4253
+ // Make the popover visible
4254
+ this.popover.setAttribute('data-show', '');
4255
+ // Enable the event listeners
4256
+ this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
4257
+ // Update its position
4258
+ this.popper.update();
4259
+ // hide when click outside
4260
+ // setTimeout is used to prevent event to trigger after creation
4261
+ setTimeout(() => {
4262
+ // Unable to trigger document events in unit tests: https://gitlab.mgdis.fr/core/core-ui/mg-components/-/issues/57
4263
+ /* istanbul ignore next */
4264
+ document.addEventListener('click', this.clickOutside, false);
4265
+ }, 0);
4266
+ };
4267
+ /**
4268
+ * Hide popover
4269
+ * @returns {void}
4270
+ */
4271
+ this.hide = () => {
4272
+ // Hide the popover
4273
+ this.popover.removeAttribute('data-show');
4274
+ // Disable the event listeners
4275
+ this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
4276
+ // Remove even listener
4277
+ document.removeEventListener('click', this.clickOutside, false);
4278
+ };
4279
+ /**
4280
+ * Handle action for close button
4281
+ * @returns {void}
4282
+ */
4283
+ this.handleCloseButton = () => {
4284
+ this.display = false;
4285
+ };
4286
+ }
4287
+ handleDisplay(newVal) {
4288
+ if (newVal) {
4289
+ this.show();
4290
+ }
4291
+ else {
4292
+ this.hide();
4293
+ }
4294
+ }
4295
+ /*************
4296
+ * Lifecycle *
4297
+ *************/
4298
+ componentDidLoad() {
4299
+ //Check if slotted title is a heading
4300
+ const headingElements = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
4301
+ const slotedTitleElement = this.element.querySelector('[slot="title"]');
4302
+ if (slotedTitleElement !== null && !headingElements.includes(slotedTitleElement.tagName.toLowerCase())) {
4303
+ throw new Error(`<mg-popover> Slotted title must be a heading: ${headingElements.join(', ')}.`);
4304
+ }
4305
+ // Set close button id
4306
+ if (this.closeButton) {
4307
+ this.closeButtonId = `${this.identifier}-close-button`;
4308
+ }
4309
+ // Get popover content
4310
+ this.popover = this.element.querySelector(`#${this.identifier}`);
4311
+ //Get interactive element
4312
+ const interactiveElement = this.element.firstElementChild;
4313
+ // Add aria attributes
4314
+ interactiveElement.setAttribute('aria-controls', this.identifier);
4315
+ interactiveElement.setAttribute('aria-expanded', `${this.display}`);
4316
+ // Create popperjs popover
4317
+ this.popper = createPopper(interactiveElement, this.popover, {
4318
+ placement: this.placement,
4319
+ modifiers: [
4320
+ {
4321
+ name: 'offset',
4322
+ options: {
4323
+ offset: [0, 10],
4324
+ },
4325
+ },
4326
+ ],
4327
+ });
4328
+ // Add events to toggle display
4329
+ interactiveElement.addEventListener('click', () => {
4330
+ if (!this.disabled)
4331
+ this.display = !this.display;
4332
+ });
4333
+ // Add events to hide popover
4334
+ this.element.addEventListener('keydown', e => {
4335
+ if (!this.disabled && e.code === 'Escape')
4336
+ this.display = false;
4337
+ });
4338
+ this.handleDisplay(this.display);
4339
+ }
4340
+ render() {
4341
+ return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: "mg-popover" }, !this.disabled && this.closeButton && (index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: messages.popover.closeButton, onClick: this.handleCloseButton }, index.h("mg-icon", { icon: "cross" }))), index.h("div", { class: "mg-popover__title" }, index.h("slot", { name: "title" })), index.h("slot", { name: "content" }), index.h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
4342
+ }
4343
+ get element() { return index.getElement(this); }
4344
+ static get watchers() { return {
4345
+ "display": ["handleDisplay"]
4346
+ }; }
4347
+ };
4348
+ MgPopover.style = mgPopoverCss;
4349
+
4350
+ const mgTabsCss = ".mg-tabs__header.sc-mg-tabs{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap}.mg-tabs__navigation-button.sc-mg-tabs{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-webkit-column-gap:0.5rem;-moz-column-gap:0.5rem;column-gap:0.5rem;padding:1.8rem 2.4rem 1.5rem;background:none;border:none;border-bottom:0.3rem solid transparent;color:hsl(var(--color-dark));line-height:var(--line-height);cursor:pointer}.mg-tabs__navigation-button.sc-mg-tabs:hover,.mg-tabs__navigation-button.sc-mg-tabs:focus{background-color:hsla(var(--color-info-h), var(--color-info-s), var(--color-info-l), 10%)}.mg-tabs__navigation-button.mg-tabs__navigation-button--active.sc-mg-tabs{color:hsl(var(--color-info));border-bottom-color:hsl(var(--color-info));font-weight:700}.mg-tabs__content-container.sc-mg-tabs:focus-visible{outline-color:transparent}";
4351
+
4352
+ /**
4353
+ * type TabItem validation function
4354
+ * @param tab
4355
+ * @returns {boolean}
4356
+ */
4357
+ const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
4358
+ const MgTabs = class {
4359
+ constructor(hostRef) {
4360
+ index.registerInstance(this, hostRef);
4361
+ /**
4362
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
4363
+ * If not set, it will be created.
4364
+ */
4365
+ this.identifier = createID('mg-tabs');
4366
+ /**
4367
+ * Active tab number
4368
+ * default: first is 1
4369
+ */
4370
+ this.activeTab = 1;
4371
+ /**
4372
+ * Component tabs
4373
+ */
4374
+ this.tabs = [];
4375
+ /**
4376
+ * Component classes
4377
+ */
4378
+ this.classList = new ClassList(['mg-tabs']);
4379
+ /**
4380
+ * Handle click events on tabs
4381
+ * @param event
4382
+ */
4383
+ this.handleClick = (event) => {
4384
+ const tabId = event.currentTarget.getAttribute('data-index');
4385
+ this.activeTab = Number(tabId);
4386
+ };
4387
+ /**
4388
+ * Handle keyboard event on tabs
4389
+ * @param event
4390
+ */
4391
+ this.handleKeydown = (event) => {
4392
+ let selectedTab;
4393
+ let tabId = Number(event.target.getAttribute('data-index'));
4394
+ const parent = event.target.parentElement;
4395
+ // change selected id from key code
4396
+ // /* IE FIX */ delete 'Right'
4397
+ if (['ArrowRight', 'Right'].includes(event.key)) {
4398
+ tabId++;
4399
+ // /* IE FIX */ delete 'Left'
4400
+ }
4401
+ else if (['ArrowLeft', 'Left'].includes(event.key)) {
4402
+ tabId--;
4403
+ }
4404
+ // get selected tab
4405
+ selectedTab = parent.querySelector(`[data-index="${tabId}"]`);
4406
+ // apply selected tab if exist
4407
+ if (selectedTab !== null) {
4408
+ selectedTab.focus();
4409
+ this.activeTab = tabId;
4410
+ }
4411
+ };
4412
+ /**
4413
+ * Validate slots setting
4414
+ */
4415
+ this.validateSlots = () => {
4416
+ 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-'); });
4417
+ if (slots.length !== this.tabs.length) {
4418
+ throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
4419
+ }
4420
+ };
4421
+ }
4422
+ validateItems(newValue) {
4423
+ // String array
4424
+ if (allItemsAreString(newValue)) {
4425
+ this.tabs = newValue.map(item => ({ label: item }));
4426
+ }
4427
+ // Object array
4428
+ else if (newValue && newValue.every(item => isTabItem(item))) {
4429
+ this.tabs = newValue;
4430
+ }
4431
+ else {
4432
+ throw new Error('<mg-tabs> prop "items" is required and all items must be the same type: TabItem.');
4433
+ }
4434
+ }
4435
+ validateActiveTab(newValue) {
4436
+ if (Number(newValue) < 1 || Number(newValue) > this.tabs.length) {
4437
+ throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
4438
+ }
4439
+ }
4440
+ /*************
4441
+ * Lifecycle *
4442
+ *************/
4443
+ /**
4444
+ * Check if component props are well configured on init
4445
+ */
4446
+ componentWillLoad() {
4447
+ // Check tabs format
4448
+ this.validateItems(this.items);
4449
+ this.validateActiveTab(this.activeTab);
4450
+ this.validateSlots();
4451
+ }
4452
+ render() {
4453
+ return (index.h(index.Host, null, index.h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index$1) => {
4454
+ const tabIndex = index$1 + 1;
4455
+ return (index.h("button", { role: "tab", id: `${this.identifier}-${tabIndex}`, class: `mg-tabs__navigation-button ${tabIndex === this.activeTab ? 'mg-tabs__navigation-button--active' : ''}`, tabindex: tabIndex === this.activeTab ? 0 : -1, "aria-selected": (tabIndex === this.activeTab).toString(), "aria-controls": `pannel-${tabIndex}`, onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": tabIndex }, tab.icon !== undefined && 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 })));
4456
+ })), this.tabs.map((_tab, index$1) => {
4457
+ const tabIndex = index$1 + 1;
4458
+ 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}` })));
4459
+ })));
4460
+ }
4461
+ get element() { return index.getElement(this); }
4462
+ static get watchers() { return {
4463
+ "items": ["validateItems"],
4464
+ "activeTab": ["validateActiveTab"]
4465
+ }; }
4466
+ };
4467
+ MgTabs.style = mgTabsCss;
4468
+
4469
+ /**
4470
+ * List of all possibles variants
4471
+ */
4472
+ const variants = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'];
4473
+
4474
+ 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}";
4475
+
4476
+ const MgTag = class {
4477
+ constructor(hostRef) {
4478
+ index.registerInstance(this, hostRef);
4479
+ /**
4480
+ * Define button variant
4481
+ */
4482
+ this.variant = variants[0];
4483
+ /**
4484
+ * Component classes
4485
+ */
4486
+ this.classList = new ClassList(['mg-tag']);
4487
+ }
4488
+ validateVariant(newValue) {
4489
+ if (!variants.includes(newValue)) {
4490
+ throw new Error(`<mg-tag> prop "variant" must be one of : ${variants.join(', ')}.`);
4491
+ }
4492
+ this.classList.add(`mg-tag--${this.variant}`);
4493
+ }
4494
+ validateOutline(newValue) {
4495
+ if (newValue)
4496
+ this.classList.add(`mg-tag--outline`);
4497
+ }
4498
+ /**
4499
+ * Check if props are well configured on init
4500
+ */
4501
+ componentWillLoad() {
4502
+ this.validateVariant(this.variant);
4503
+ this.validateOutline(this.outline);
4504
+ }
4505
+ /**
4506
+ * Render
4507
+ */
4508
+ render() {
4509
+ return (index.h("span", { class: this.classList.join() }, index.h("slot", null)));
4510
+ }
4511
+ static get watchers() { return {
4512
+ "variant": ["validateVariant"],
4513
+ "outline": ["validateOutline"]
4514
+ }; }
4515
+ };
4516
+ MgTag.style = mgTagCss;
4517
+
4518
+ 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}";
4519
+
4520
+ const MgTooltip = class {
4521
+ constructor(hostRef) {
4522
+ index.registerInstance(this, hostRef);
4523
+ /**
4524
+ * Sets an `id` attribute.
4525
+ * Needed by the input for accessibility `aria-decribedby`.
4526
+ */
4527
+ this.identifier = createID('mg-tooltip');
4528
+ /**
4529
+ * Tooltip placement
4530
+ */
4531
+ this.placement = 'bottom';
4532
+ /**
4533
+ * Display tooltip
4534
+ */
4535
+ this.display = false;
4536
+ /**
4537
+ * Disable tooltip
4538
+ */
4539
+ this.disabled = false;
4540
+ /**
4541
+ * Show tooltip
4542
+ * @returns {void}
4543
+ */
4544
+ this.show = () => {
4545
+ // Make the tooltip visible
4546
+ this.tooltip.setAttribute('data-show', '');
4547
+ // Enable the event listeners
4548
+ this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
4549
+ // Update its position
4550
+ this.popper.update();
4551
+ };
4552
+ /**
4553
+ * Hide tooltip
4554
+ * @returns {void}
4555
+ */
4556
+ this.hide = () => {
4557
+ // Hide the tooltip
4558
+ this.tooltip.removeAttribute('data-show');
4559
+ // Disable the event listeners
4560
+ this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
4561
+ };
4562
+ }
4563
+ handleDisplay(newVal) {
4564
+ if (newVal) {
4565
+ this.show();
4566
+ }
4567
+ else {
4568
+ this.hide();
4569
+ }
4570
+ }
4571
+ /*************
4572
+ * Lifecycle *
4573
+ *************/
4574
+ /**
4575
+ * Get slotted element
4576
+ * Check if it already contain an interactive element, if not we need to add a tabIndex attribute
4577
+ * We need to attach the focused element to the tooltip (aria-describedby)
4578
+ */
4579
+ componentDidLoad() {
4580
+ var _a;
4581
+ // Get tooltip element
4582
+ this.tooltip = this.element.querySelector(`#${this.identifier}`);
4583
+ // get slotted element
4584
+ const slotElement = this.element.firstElementChild;
4585
+ // Get interactive element
4586
+ const interactiveElements = ['a', 'button', 'input', 'textarea', 'select']; //! Might needs updates
4587
+ const interactiveElement = this.element.querySelector(interactiveElements.join(',')) || ((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
4588
+ // define selected element to become tooltip selector
4589
+ const tooltipedElement = interactiveElement || slotElement;
4590
+ // Add tabindex to slotted element if we can't find any interactive element
4591
+ if (interactiveElement === null || interactiveElement === undefined)
4592
+ slotElement.tabIndex = 0;
4593
+ // Set aria-describedby
4594
+ const ariaDescribedby = slotElement.getAttribute('aria-describedby');
4595
+ if (ariaDescribedby === null) {
4596
+ tooltipedElement.setAttribute('aria-describedby', this.identifier);
4597
+ }
4598
+ else {
4599
+ slotElement.setAttribute('aria-describedby', `${ariaDescribedby} ${this.identifier}`);
4600
+ }
4601
+ // Create popperjs tooltip
4602
+ this.popper = createPopper(tooltipedElement, this.tooltip, {
4603
+ placement: this.placement,
4604
+ modifiers: [
4605
+ {
4606
+ name: 'offset',
4607
+ options: {
4608
+ offset: [0, 8],
4609
+ },
4610
+ },
4611
+ ],
4612
+ });
4613
+ // Add events
4614
+ ['mouseenter', 'focus'].forEach(event => {
4615
+ tooltipedElement.addEventListener(event, () => {
4616
+ if (!this.disabled)
4617
+ this.display = true;
4618
+ });
4619
+ });
4620
+ ['mouseleave', 'blur', 'keydown'].forEach(event => {
4621
+ tooltipedElement.addEventListener(event, (e) => {
4622
+ // we continue to process ONLY for KeyboardEvents 'Escape'
4623
+ if (e.type === 'keydown' && e.code !== 'Escape') {
4624
+ return;
4625
+ }
4626
+ if (!this.disabled)
4627
+ this.display = false;
4628
+ });
4629
+ });
4630
+ this.handleDisplay(this.display);
4631
+ }
4632
+ render() {
4633
+ 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 }))));
4634
+ }
4635
+ get element() { return index.getElement(this); }
4636
+ static get watchers() { return {
4637
+ "display": ["handleDisplay"]
4638
+ }; }
4639
+ };
4640
+ MgTooltip.style = mgTooltipCss;
4641
+
4642
+ exports.mg_badge = MgBadge;
4643
+ exports.mg_button = MgButton;
4644
+ exports.mg_character_left = MgCharacterLeft;
4645
+ exports.mg_icon = MgIcon;
4646
+ exports.mg_input_checkbox = MgInputCheckbox;
4647
+ exports.mg_input_date = MgInputDate;
4648
+ exports.mg_input_numeric = MgInputNumeric;
4649
+ exports.mg_input_password = MgInputPassword;
4650
+ exports.mg_input_radio = MgInputRadio;
4651
+ exports.mg_input_select = MgInputSelect;
4652
+ exports.mg_input_text = MgInputText;
4653
+ exports.mg_input_textarea = MgInputTextarea;
4654
+ exports.mg_input_title = MgInputTitle;
4655
+ exports.mg_input_toggle = MgInputToggle;
4656
+ exports.mg_message = MgMessage;
4657
+ exports.mg_pagination = MgPagination;
4658
+ exports.mg_popover = MgPopover;
4659
+ exports.mg_tabs = MgTabs;
4660
+ exports.mg_tag = MgTag;
4661
+ exports.mg_tooltip = MgTooltip;