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