@mgdis/mg-components 5.21.1 → 5.23.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 (248) hide show
  1. package/dist/cjs/{index-b4c6ee30.js → index-0cf3e6d5.js} +22 -13
  2. package/dist/cjs/index-0cf3e6d5.js.map +1 -0
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/mg-action-more_34.cjs.entry.js +380 -285
  5. package/dist/cjs/mg-action-more_34.cjs.entry.js.map +1 -1
  6. package/dist/cjs/mg-components.cjs.js +3 -3
  7. package/dist/cjs/mg-components.cjs.js.map +1 -1
  8. package/dist/cjs/mg-item-more.cjs.entry.js +7 -6
  9. package/dist/cjs/mg-item-more.cjs.entry.js.map +1 -1
  10. package/dist/cjs/mg-menu.conf-0229bb75.js +333 -0
  11. package/dist/cjs/mg-menu.conf-0229bb75.js.map +1 -0
  12. package/dist/collection/assets/icons/index.js +91 -90
  13. package/dist/collection/assets/icons/index.js.map +1 -1
  14. package/dist/collection/collection-manifest.json +2 -2
  15. package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -1
  16. package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
  17. package/dist/collection/components/atoms/mg-button/mg-button.js +1 -1
  18. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  19. package/dist/collection/components/atoms/mg-card/mg-card.js +1 -1
  20. package/dist/collection/components/atoms/mg-card/mg-card.js.map +1 -1
  21. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js.map +1 -1
  22. package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
  23. package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
  24. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -1
  25. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js.map +1 -1
  26. package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
  27. package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
  28. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +4 -2
  29. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
  30. package/dist/collection/components/molecules/inputs/MgInput.js +1 -1
  31. package/dist/collection/components/molecules/inputs/MgInput.js.map +1 -1
  32. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +9 -5
  33. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
  34. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +9 -0
  35. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js.map +1 -1
  36. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +54 -39
  37. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
  38. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +35 -6
  39. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
  40. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -2
  41. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
  43. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
  44. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
  45. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
  46. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
  47. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
  48. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +1 -1
  49. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
  50. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
  51. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
  52. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
  53. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
  54. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
  55. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +1 -1
  56. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
  57. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
  58. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
  59. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  60. package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
  61. package/dist/collection/components/molecules/mg-form/mg-form.js +1 -1
  62. package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
  63. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
  64. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -1
  65. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +1 -1
  66. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +1 -1
  67. package/dist/collection/components/molecules/mg-message/mg-message.js +1 -1
  68. package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
  69. package/dist/collection/components/molecules/mg-modal/mg-modal.js +6 -5
  70. package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
  71. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +1 -1
  72. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
  73. package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
  74. package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
  75. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  76. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -1
  77. package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
  78. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  79. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  80. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -1
  81. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
  82. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
  83. package/dist/collection/locales/en/messages.json +13 -3
  84. package/dist/collection/locales/fr/messages.json +13 -3
  85. package/dist/collection/locales/index.js +2 -2
  86. package/dist/collection/locales/index.js.map +1 -1
  87. package/dist/collection/utils/behaviors.utils.js.map +1 -1
  88. package/dist/collection/utils/behaviors.utils.spec.js +1 -1
  89. package/dist/collection/utils/behaviors.utils.spec.js.map +1 -1
  90. package/dist/collection/utils/unit.test.utils.js +0 -104
  91. package/dist/collection/utils/unit.test.utils.js.map +1 -1
  92. package/dist/components/MgInput.js +3 -3
  93. package/dist/components/MgInput.js.map +1 -1
  94. package/dist/components/index.es.js +75 -0
  95. package/dist/components/index.es.js.map +1 -0
  96. package/dist/components/index2.js +30 -65
  97. package/dist/components/index2.js.map +1 -1
  98. package/dist/components/mg-action-more.js +5 -4
  99. package/dist/components/mg-action-more.js.map +1 -1
  100. package/dist/components/mg-badge2.js +5 -4
  101. package/dist/components/mg-badge2.js.map +1 -1
  102. package/dist/components/mg-button2.js +6 -5
  103. package/dist/components/mg-button2.js.map +1 -1
  104. package/dist/components/mg-card2.js +4 -3
  105. package/dist/components/mg-card2.js.map +1 -1
  106. package/dist/components/mg-character-left2.js +2 -1
  107. package/dist/components/mg-character-left2.js.map +1 -1
  108. package/dist/components/mg-details.js +4 -3
  109. package/dist/components/mg-details.js.map +1 -1
  110. package/dist/components/mg-divider.js +2 -1
  111. package/dist/components/mg-divider.js.map +1 -1
  112. package/dist/components/mg-form.js +5 -4
  113. package/dist/components/mg-form.js.map +1 -1
  114. package/dist/components/mg-icon2.js +96 -93
  115. package/dist/components/mg-icon2.js.map +1 -1
  116. package/dist/components/mg-illustrated-message.js +4 -3
  117. package/dist/components/mg-illustrated-message.js.map +1 -1
  118. package/dist/components/mg-input-checkbox-paginated.js +1 -1
  119. package/dist/components/mg-input-checkbox-paginated2.js +19 -6
  120. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
  121. package/dist/components/mg-input-checkbox.js +59 -43
  122. package/dist/components/mg-input-checkbox.js.map +1 -1
  123. package/dist/components/mg-input-date.js +41 -10
  124. package/dist/components/mg-input-date.js.map +1 -1
  125. package/dist/components/mg-input-numeric.js +7 -6
  126. package/dist/components/mg-input-numeric.js.map +1 -1
  127. package/dist/components/mg-input-password.js +5 -4
  128. package/dist/components/mg-input-password.js.map +1 -1
  129. package/dist/components/mg-input-radio.js +6 -5
  130. package/dist/components/mg-input-radio.js.map +1 -1
  131. package/dist/components/mg-input-select2.js +8 -7
  132. package/dist/components/mg-input-select2.js.map +1 -1
  133. package/dist/components/mg-input-text2.js +8 -7
  134. package/dist/components/mg-input-text2.js.map +1 -1
  135. package/dist/components/mg-input-textarea.js +8 -7
  136. package/dist/components/mg-input-textarea.js.map +1 -1
  137. package/dist/components/mg-input-title2.js +4 -3
  138. package/dist/components/mg-input-title2.js.map +1 -1
  139. package/dist/components/mg-input-toggle.js +6 -5
  140. package/dist/components/mg-input-toggle.js.map +1 -1
  141. package/dist/components/mg-item-more.js +4 -3
  142. package/dist/components/mg-item-more.js.map +1 -1
  143. package/dist/components/mg-menu-item2.js +6 -5
  144. package/dist/components/mg-menu-item2.js.map +1 -1
  145. package/dist/components/mg-menu2.js +2 -1
  146. package/dist/components/mg-menu2.js.map +1 -1
  147. package/dist/components/mg-message.js +5 -4
  148. package/dist/components/mg-message.js.map +1 -1
  149. package/dist/components/mg-modal.js +12 -10
  150. package/dist/components/mg-modal.js.map +1 -1
  151. package/dist/components/mg-pagination2.js +4 -3
  152. package/dist/components/mg-pagination2.js.map +1 -1
  153. package/dist/components/mg-panel.js +6 -5
  154. package/dist/components/mg-panel.js.map +1 -1
  155. package/dist/components/mg-popover-content2.js +5 -4
  156. package/dist/components/mg-popover-content2.js.map +1 -1
  157. package/dist/components/mg-popover2.js +5 -4
  158. package/dist/components/mg-popover2.js.map +1 -1
  159. package/dist/components/mg-skip-links.js +4 -3
  160. package/dist/components/mg-skip-links.js.map +1 -1
  161. package/dist/components/mg-tabs.js +8 -7
  162. package/dist/components/mg-tabs.js.map +1 -1
  163. package/dist/components/mg-tag.js +5 -4
  164. package/dist/components/mg-tag.js.map +1 -1
  165. package/dist/components/mg-tooltip-content2.js +2 -1
  166. package/dist/components/mg-tooltip-content2.js.map +1 -1
  167. package/dist/components/mg-tooltip2.js +11 -8
  168. package/dist/components/mg-tooltip2.js.map +1 -1
  169. package/dist/esm/{index-61c7cfb5.js → index-91977c3d.js} +22 -13
  170. package/dist/esm/index-91977c3d.js.map +1 -0
  171. package/dist/esm/loader.js +3 -3
  172. package/dist/esm/mg-action-more_34.entry.js +348 -253
  173. package/dist/esm/mg-action-more_34.entry.js.map +1 -1
  174. package/dist/esm/mg-components.js +4 -4
  175. package/dist/esm/mg-components.js.map +1 -1
  176. package/dist/esm/mg-item-more.entry.js +5 -4
  177. package/dist/esm/mg-item-more.entry.js.map +1 -1
  178. package/dist/esm/mg-menu.conf-4b2d2eab.js +315 -0
  179. package/dist/esm/mg-menu.conf-4b2d2eab.js.map +1 -0
  180. package/dist/mg-components/locales/en/messages.json +13 -3
  181. package/dist/mg-components/locales/fr/messages.json +13 -3
  182. package/dist/mg-components/mg-components.esm.js +1 -1
  183. package/dist/mg-components/mg-components.esm.js.map +1 -1
  184. package/dist/mg-components/p-1564df7a.js +2 -0
  185. package/dist/mg-components/p-1564df7a.js.map +1 -0
  186. package/dist/mg-components/p-49e1ffcb.js +3 -0
  187. package/dist/mg-components/p-49e1ffcb.js.map +1 -0
  188. package/dist/mg-components/p-6c68c7eb.entry.js +2 -0
  189. package/dist/mg-components/p-6c68c7eb.entry.js.map +1 -0
  190. package/dist/mg-components/p-d6d71404.entry.js +2 -0
  191. package/dist/mg-components/p-d6d71404.entry.js.map +1 -0
  192. package/dist/types/assets/icons/index.d.ts +1 -0
  193. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +1 -1
  194. package/dist/types/components/atoms/mg-button/mg-button.d.ts +1 -1
  195. package/dist/types/components/atoms/mg-card/mg-card.d.ts +1 -1
  196. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +1 -1
  197. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +1 -1
  198. package/dist/types/components/molecules/inputs/MgInput.d.ts +1 -1
  199. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +8 -0
  200. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +15 -13
  201. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +18 -1
  202. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +1 -1
  203. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +1 -1
  204. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +1 -1
  205. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +1 -1
  206. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +1 -1
  207. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +1 -1
  208. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +1 -1
  209. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +1 -1
  210. package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
  211. package/dist/types/components/molecules/mg-message/mg-message.d.ts +1 -1
  212. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +1 -1
  213. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +1 -1
  214. package/dist/types/components/molecules/mg-popover/mg-popover-content/mg-popover-content.d.ts +1 -1
  215. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +1 -1
  216. package/dist/types/components.d.ts +2 -2
  217. package/dist/types/locales/index.d.ts +1 -176
  218. package/dist/types/utils/unit.test.utils.d.ts +0 -82
  219. package/package.json +36 -35
  220. package/dist/cjs/components.utils-cd908d4e.js +0 -443
  221. package/dist/cjs/components.utils-cd908d4e.js.map +0 -1
  222. package/dist/cjs/index-b4c6ee30.js.map +0 -1
  223. package/dist/collection/utils/components.utils.js +0 -147
  224. package/dist/collection/utils/components.utils.js.map +0 -1
  225. package/dist/collection/utils/components.utils.spec.js +0 -156
  226. package/dist/collection/utils/components.utils.spec.js.map +0 -1
  227. package/dist/collection/utils/e2e.test.utils.js +0 -46
  228. package/dist/collection/utils/e2e.test.utils.js.map +0 -1
  229. package/dist/collection/utils/locale.utils.js +0 -57
  230. package/dist/collection/utils/locale.utils.js.map +0 -1
  231. package/dist/collection/utils/locale.utils.spec.js +0 -52
  232. package/dist/collection/utils/locale.utils.spec.js.map +0 -1
  233. package/dist/components/components.utils.js +0 -150
  234. package/dist/components/components.utils.js.map +0 -1
  235. package/dist/esm/components.utils-0d67c31c.js +0 -427
  236. package/dist/esm/components.utils-0d67c31c.js.map +0 -1
  237. package/dist/esm/index-61c7cfb5.js.map +0 -1
  238. package/dist/mg-components/p-1c17516a.entry.js +0 -2
  239. package/dist/mg-components/p-1c17516a.entry.js.map +0 -1
  240. package/dist/mg-components/p-5b4eb029.entry.js +0 -2
  241. package/dist/mg-components/p-5b4eb029.entry.js.map +0 -1
  242. package/dist/mg-components/p-6e7aebeb.js +0 -3
  243. package/dist/mg-components/p-6e7aebeb.js.map +0 -1
  244. package/dist/mg-components/p-af42d17b.js +0 -2
  245. package/dist/mg-components/p-af42d17b.js.map +0 -1
  246. package/dist/types/utils/components.utils.d.ts +0 -87
  247. package/dist/types/utils/e2e.test.utils.d.ts +0 -22
  248. package/dist/types/utils/locale.utils.d.ts +0 -38
@@ -1,150 +0,0 @@
1
- /**
2
- * Create random ID
3
- * @param prefix - add prefix to created ID
4
- * @param length - ID length
5
- * @returns ID
6
- */
7
- const createID = (prefix = '', length = 10) => {
8
- const randomBytes = new Uint8Array(length);
9
- crypto.getRandomValues(randomBytes);
10
- const hexString = Array.from(randomBytes)
11
- .map(byte => byte.toString(16).padStart(2, '0'))
12
- .join('')
13
- .slice(0, length);
14
- return prefix !== '' ? `${prefix}-${hexString}` : hexString;
15
- };
16
- /**
17
- * Class to manage component classlist
18
- * Set() are not working when imported in project
19
- */
20
- class ClassList {
21
- constructor(classlist = []) {
22
- /**
23
- * Add class
24
- * @param className - class name to add
25
- */
26
- this.add = (className) => {
27
- if (!this.has(className)) {
28
- this.classes.push(className);
29
- }
30
- };
31
- /**
32
- * Delete class
33
- * @param className - class name to delete
34
- */
35
- this.delete = (className) => {
36
- const index = this.classes.indexOf(className);
37
- if (index > -1) {
38
- this.classes.splice(index, 1);
39
- }
40
- };
41
- /**
42
- * Check if class exist in list
43
- * @param className - class name to check
44
- * @returns class name is in the list
45
- */
46
- this.has = (className) => {
47
- return this.classes.includes(className);
48
- };
49
- /**
50
- * Join classes seperated by spaces
51
- * @returns joined values
52
- */
53
- this.join = () => {
54
- return this.classes.join(' ');
55
- };
56
- this.classes = classlist;
57
- }
58
- }
59
- /**
60
- * Check if all items are string
61
- * @param items - items to check
62
- * @returns all items are string
63
- */
64
- const allItemsAreString = (items) => Array.isArray(items) && items.every(item => typeof item === 'string');
65
- /**
66
- * Check if element is a heading
67
- * @param element - slotted element
68
- * @param tagNames - allowed tag names list
69
- * @returns element is a heading
70
- */
71
- const isTagName = (element, tagNames) => {
72
- return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
73
- };
74
- /**
75
- * Focusable elements query selector
76
- */
77
- const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
78
- /**
79
- * Get windows
80
- * @param localWindow - the window we are lookink for other windows
81
- * @returns The list of windows found
82
- */
83
- const getWindows = (localWindow) => {
84
- const parentWindows = getParentWindows(localWindow);
85
- const childWindows = getChildWindows(localWindow);
86
- return [localWindow, ...parentWindows, ...childWindows];
87
- };
88
- /**
89
- * Get parent windows
90
- * @param localWindow - the window we are lookink for parents
91
- * @param windows - The list of allready found windows
92
- * @returns The list of windows found
93
- */
94
- const getParentWindows = (localWindow, windows = []) => {
95
- // Check if is in iframe
96
- if (localWindow.self !== localWindow.top) {
97
- // Check if we have permission to access parent
98
- try {
99
- const parentWindow = localWindow.parent;
100
- windows.push(parentWindow);
101
- return getParentWindows(parentWindow, windows);
102
- }
103
- catch (err) {
104
- console.error('Different hosts between iframes:', err);
105
- return windows;
106
- }
107
- }
108
- return windows;
109
- };
110
- /**
111
- * Get child windows
112
- * @param localWindow - the window we are lookink for children
113
- * @param windows - The list of allready found windows
114
- * @returns The list of windows found
115
- */
116
- const getChildWindows = (localWindow, windows = []) => {
117
- if (localWindow.frames.length > 0) {
118
- for (const childWindow of Array.from(localWindow.frames)) {
119
- windows.push(childWindow);
120
- getChildWindows(childWindow, windows);
121
- }
122
- }
123
- return windows;
124
- };
125
- /**
126
- * Validate string
127
- * @param value - value to check
128
- * @returns if string is valid
129
- */
130
- const isValidString = (value) => typeof value === 'string' && value.trim() !== '';
131
- /**
132
- * Clean string caraters
133
- * @param text - text to cliean
134
- * @returns cleanded string
135
- */
136
- const cleanString = (text) => typeof text === 'string' &&
137
- text
138
- .toLocaleLowerCase()
139
- .normalize('NFD')
140
- .replaceAll(/[\u0300-\u036f]/g, '');
141
- /**
142
- * Use to process code next tick in the event loop
143
- * @param callback - code to excute on next tick
144
- * @returns differed code excution
145
- */
146
- const nextTick = async (callback) => callback();
147
-
148
- export { ClassList as C, isTagName as a, cleanString as b, createID as c, allItemsAreString as d, focusableElements as f, getWindows as g, isValidString as i, nextTick as n };
149
-
150
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A,MAAM,eAAe,GAAG,CAAC,WAAmB,EAAE,UAAoB,EAAE;IAClE,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACjC,KAAK,MAAM,WAAW,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE;YACxD,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC1B,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;SACvC;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;MAKa,aAAa,GAAG,CAAC,KAAc,KAAc,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG;AAE3G;;;;;MAKa,WAAW,GAAG,CAAC,IAAY,KACtC,OAAO,IAAI,KAAK,QAAQ;IACxB,IAAI;SACD,iBAAiB,EAAE;SACnB,SAAS,CAAC,KAAK,CAAC;SAChB,UAAU,CAAC,kBAAkB,EAAE,EAAE,EAAE;AAExC;;;;;MAKa,QAAQ,GAAG,OAAO,QAAoB,KAAoB,QAAQ;;;;","names":[],"sources":["src/utils/components.utils.ts"],"sourcesContent":["/**\n * Create random ID\n * @param prefix - add prefix to created ID\n * @param length - ID length\n * @returns ID\n */\nexport const createID = (prefix = '', length = 10): string => {\n const randomBytes = new Uint8Array(length);\n\n crypto.getRandomValues(randomBytes);\n\n const hexString = Array.from(randomBytes)\n .map(byte => byte.toString(16).padStart(2, '0'))\n .join('')\n .slice(0, length);\n\n return prefix !== '' ? `${prefix}-${hexString}` : hexString;\n};\n\n/**\n * Class to manage component classlist\n * Set() are not working when imported in project\n */\nexport class ClassList {\n /**\n * Available classes\n */\n classes: string[];\n\n constructor(classlist: string[] = []) {\n this.classes = classlist;\n }\n\n /**\n * Add class\n * @param className - class name to add\n */\n add = (className: string): void => {\n if (!this.has(className)) {\n this.classes.push(className);\n }\n };\n\n /**\n * Delete class\n * @param className - class name to delete\n */\n delete = (className: string): void => {\n const index = this.classes.indexOf(className);\n if (index > -1) {\n this.classes.splice(index, 1);\n }\n };\n\n /**\n * Check if class exist in list\n * @param className - class name to check\n * @returns class name is in the list\n */\n has = (className: string): boolean => {\n return this.classes.includes(className);\n };\n\n /**\n * Join classes seperated by spaces\n * @returns joined values\n */\n join = (): string => {\n return this.classes.join(' ');\n };\n}\n\n/**\n * Check if all items are string\n * @param items - items to check\n * @returns all items are string\n */\nexport const allItemsAreString = (items: unknown): items is string[] => Array.isArray(items) && items.every(item => typeof item === 'string');\n\n/**\n * Check if element is a heading\n * @param element - slotted element\n * @param tagNames - allowed tag names list\n * @returns element is a heading\n */\nexport const isTagName = (element: Element, tagNames: string[]): boolean => {\n return tagNames.includes(element?.tagName.toLowerCase());\n};\n\n/**\n * Focusable elements query selector\n */\nexport const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"]), [identifier]';\n\n/**\n * Get windows\n * @param localWindow - the window we are lookink for other windows\n * @returns The list of windows found\n */\nexport const getWindows = (localWindow: Window): Window[] => {\n const parentWindows = getParentWindows(localWindow);\n const childWindows = getChildWindows(localWindow);\n return [localWindow, ...parentWindows, ...childWindows];\n};\n\n/**\n * Get parent windows\n * @param localWindow - the window we are lookink for parents\n * @param windows - The list of allready found windows\n * @returns The list of windows found\n */\nexport const getParentWindows = (localWindow: Window, windows: Window[] = []): Window[] => {\n // Check if is in iframe\n if (localWindow.self !== localWindow.top) {\n // Check if we have permission to access parent\n try {\n const parentWindow: Window = localWindow.parent;\n windows.push(parentWindow);\n return getParentWindows(parentWindow, windows);\n } catch (err) {\n console.error('Different hosts between iframes:', err);\n return windows;\n }\n }\n return windows;\n};\n\n/**\n * Get child windows\n * @param localWindow - the window we are lookink for children\n * @param windows - The list of allready found windows\n * @returns The list of windows found\n */\nconst getChildWindows = (localWindow: Window, windows: Window[] = []): Window[] => {\n if (localWindow.frames.length > 0) {\n for (const childWindow of Array.from(localWindow.frames)) {\n windows.push(childWindow);\n getChildWindows(childWindow, windows);\n }\n }\n return windows;\n};\n\n/**\n * Validate string\n * @param value - value to check\n * @returns if string is valid\n */\nexport const isValidString = (value: unknown): boolean => typeof value === 'string' && value.trim() !== '';\n\n/**\n * Clean string caraters\n * @param text - text to cliean\n * @returns cleanded string\n */\nexport const cleanString = (text: string): string =>\n typeof text === 'string' &&\n text\n .toLocaleLowerCase()\n .normalize('NFD')\n .replaceAll(/[\\u0300-\\u036f]/g, '');\n\n/**\n * Use to process code next tick in the event loop\n * @param callback - code to excute on next tick\n * @returns differed code excution\n */\nexport const nextTick = async (callback: () => void): Promise<void> => callback();\n"],"version":3}
@@ -1,427 +0,0 @@
1
- const errors$1 = {
2
- required: "This field is required.",
3
- date: {
4
- badInput: "The date format must be <span aria-hidden=\"true\">mm/dd/yyyy</span><span class=\"mg-u-visually-hidden\">m m / d d / y y y y</span> and the date must be greater than {min}",
5
- min: "The date cannot be earlier than {min}",
6
- max: "The date cannot be later than {max}",
7
- minMax: "The date must be between {min} and {max}"
8
- },
9
- numeric: {
10
- min: "The value cannot be less than {min}",
11
- max: "The value cannot be greater than {max}",
12
- minMax: "The value must be between {min} et {max}"
13
- }
14
- };
15
- const nbCharLeft$1 = "{counter} characters left.";
16
- const input$1 = {
17
- select: {
18
- placeholder: "Select a value"
19
- },
20
- checkbox: {
21
- selectedValues: "{nb} selected values",
22
- selectedValue: "{nb} selected value",
23
- editButton: "Edit",
24
- selectButton: "Select values",
25
- showButton: "Show",
26
- label: "Enter a value",
27
- result: "result",
28
- results: "results",
29
- searchResults: "Search result(s) list.",
30
- noResult: "No result.",
31
- sections: {
32
- selected: {
33
- title: "Selected",
34
- titlePlurial: "Selected",
35
- action: "Unselect all"
36
- },
37
- notSelected: {
38
- title: "Not selected",
39
- titlePlurial: "Not selected",
40
- action: "Select all"
41
- }
42
- }
43
- }
44
- };
45
- const form$1 = {
46
- required: "Fields with a <strong class=\"mg-u-is-asterisk\">*</strong> are required",
47
- requiredSingle: "Field with a <strong class=\"mg-u-is-asterisk\">*</strong> is required",
48
- allRequired: "All fields are required",
49
- allRequiredSingle: "The field is required"
50
- };
51
- const message$1 = {
52
- closeButton: "Close message"
53
- };
54
- const modal$1 = {
55
- closeButton: "Close modal"
56
- };
57
- const pagination$1 = {
58
- label: "Pagination",
59
- page: "page",
60
- pages: "pages",
61
- nextPage: "Next page",
62
- previousPage: "Previous page",
63
- selectPage: "Select the page to display."
64
- };
65
- const panel$1 = {
66
- editLabel: "Edit section title."
67
- };
68
- const skipLinks$1 = {
69
- navLabel: "Quick access"
70
- };
71
- const general$1 = {
72
- confirm: "Confirm",
73
- cancel: "Cancel",
74
- close: "Close",
75
- next: "next",
76
- previous: "previous"
77
- };
78
- const plusMenu$1 = {
79
- moreLabel: "Additional menu",
80
- badgeLabel: "Include notification(s)"
81
- };
82
- const actionMore$1 = {
83
- label: "Actions"
84
- };
85
- const en = {
86
- errors: errors$1,
87
- nbCharLeft: nbCharLeft$1,
88
- input: input$1,
89
- form: form$1,
90
- message: message$1,
91
- modal: modal$1,
92
- pagination: pagination$1,
93
- panel: panel$1,
94
- skipLinks: skipLinks$1,
95
- general: general$1,
96
- plusMenu: plusMenu$1,
97
- actionMore: actionMore$1
98
- };
99
-
100
- const errors = {
101
- required: "Ce champ est obligatoire.",
102
- date: {
103
- badInput: "Le format de la date doit être du type <span aria-hidden=\"true\">jj/mm/aaaa</span><span class=\"mg-u-visually-hidden\">j j / m m / a a a a</span> et la date supérieure au {min}",
104
- min: "La date ne peut pas être antérieure au {min}",
105
- max: "La date ne peut pas être postérieure au {max}",
106
- minMax: "La date doit être comprise entre le {min} et le {max}"
107
- },
108
- numeric: {
109
- min: "La valeur ne peut pas être inférieure à {min}",
110
- max: "La valeur ne peut pas être supérieure à {max}",
111
- minMax: "La valeur doit être comprise entre {min} et {max}"
112
- }
113
- };
114
- const nbCharLeft = "{counter} caractères disponibles.";
115
- const input = {
116
- select: {
117
- placeholder: "Sélectionnez une valeur"
118
- },
119
- checkbox: {
120
- selectedValues: "{nb} valeurs selectionnées",
121
- selectedValue: "{nb} valeur selectionnée",
122
- editButton: "Modifier",
123
- selectButton: "Sélectionner des valeurs",
124
- showButton: "Voir",
125
- label: "Saisissez une valeur",
126
- result: "résultat",
127
- results: "résultats",
128
- searchResults: "List de résultat(s) de la recherche.",
129
- noResult: "Aucun résultat.",
130
- sections: {
131
- selected: {
132
- title: "Sélectionné",
133
- titlePlurial: "Sélectionnés",
134
- action: "Tout désélectionner"
135
- },
136
- notSelected: {
137
- title: "Non sélectionné",
138
- titlePlurial: "Non sélectionnés",
139
- action: "Tout sélectionner"
140
- }
141
- }
142
- }
143
- };
144
- const form = {
145
- required: "Les champs marqués d'un <strong class=\"mg-u-is-asterisk\">*</strong> sont obligatoires",
146
- requiredSingle: "Le champ marqué d'un <strong class=\"mg-u-is-asterisk\">*</strong> est obligatoire",
147
- allRequired: "Tous les champs sont obligatoires",
148
- allRequiredSingle: "Le champ est obligatoire"
149
- };
150
- const message = {
151
- closeButton: "Fermer le message"
152
- };
153
- const modal = {
154
- closeButton: "Fermer la modale"
155
- };
156
- const pagination = {
157
- label: "Pagination",
158
- page: "page",
159
- pages: "pages",
160
- nextPage: "Page suivante",
161
- previousPage: "Page précédente",
162
- selectPage: "Sélectionner la page à afficher."
163
- };
164
- const panel = {
165
- editLabel: "Modifier le titre de la section."
166
- };
167
- const skipLinks = {
168
- navLabel: "Accès rapide"
169
- };
170
- const general = {
171
- confirm: "Valider",
172
- cancel: "Annuler",
173
- close: "Fermer",
174
- next: "suivant",
175
- previous: "précédent"
176
- };
177
- const plusMenu = {
178
- moreLabel: "Menu complémentaire",
179
- badgeLabel: "Notification(s) incluse(s)"
180
- };
181
- const actionMore = {
182
- label: "Actions"
183
- };
184
- const fr = {
185
- errors: errors,
186
- nbCharLeft: nbCharLeft,
187
- input: input,
188
- form: form,
189
- message: message,
190
- modal: modal,
191
- pagination: pagination,
192
- panel: panel,
193
- skipLinks: skipLinks,
194
- general: general,
195
- plusMenu: plusMenu,
196
- actionMore: actionMore
197
- };
198
-
199
- /**
200
- * Format number to the locale currency
201
- * @param number - number to format
202
- * @param locale - locale to apply
203
- * @param currency - currency to apply
204
- * @returns formatted currency
205
- */
206
- const localeCurrency = (number, locale, currency) => {
207
- return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
208
- };
209
- /**
210
- * Format number to locale
211
- * @param number - number to format
212
- * @param locale - locale to apply
213
- * @returns formatted number
214
- */
215
- const localeNumber = (number, locale) => {
216
- return new Intl.NumberFormat(locale).format(number);
217
- };
218
- /**
219
- * Date RegExp
220
- */
221
- const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
222
- /**
223
- * Locale date format
224
- * @param date - date to format
225
- * @param locale - locale to apply
226
- * @returns formatted date
227
- */
228
- const localeDate = (date, locale) => {
229
- if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
230
- return '';
231
- }
232
- return new Intl.DateTimeFormat(locale).format(new Date(date));
233
- };
234
- /**
235
- * Get locale and messages
236
- * We load the defined locale but for now we only support the first subtag for messages
237
- * @param element - element we need to get the language
238
- * @param messages - messages to use
239
- * @param defaultLocale - default messages locale
240
- * @returns messages object
241
- */
242
- const getLocaleMessages = (element, messages, defaultLocale) => {
243
- // Get local
244
- const closestLangAttribute = element.closest('[lang]');
245
- const closestLang = Intl.NumberFormat.supportedLocalesOf(closestLangAttribute === null || closestLangAttribute === void 0 ? void 0 : closestLangAttribute.lang);
246
- const locale = closestLang.length > 0 ? closestLang[0] : navigator.language || defaultLocale;
247
- // Only keep first subtag
248
- const localeSubtag = locale.split('-').shift();
249
- // Return
250
- return {
251
- locale,
252
- messages: messages[localeSubtag] || messages[defaultLocale],
253
- };
254
- };
255
-
256
- const defaultLocale = 'en';
257
- const messages = { en, fr };
258
- /**
259
- * Get Intl object
260
- * @param element - element we need to get the language
261
- * @returns messages object
262
- */
263
- const initLocales = (element) => getLocaleMessages(element, messages, defaultLocale);
264
-
265
- /**
266
- * Menu direction type
267
- */
268
- var Direction;
269
- (function (Direction) {
270
- Direction["VERTICAL"] = "vertical";
271
- Direction["HORIZONTAL"] = "horizontal";
272
- })(Direction || (Direction = {}));
273
- /**
274
- * List of all possibles sizes
275
- */
276
- const sizes = ['regular', 'medium', 'large'];
277
-
278
- /**
279
- * Create random ID
280
- * @param prefix - add prefix to created ID
281
- * @param length - ID length
282
- * @returns ID
283
- */
284
- const createID = (prefix = '', length = 10) => {
285
- const randomBytes = new Uint8Array(length);
286
- crypto.getRandomValues(randomBytes);
287
- const hexString = Array.from(randomBytes)
288
- .map(byte => byte.toString(16).padStart(2, '0'))
289
- .join('')
290
- .slice(0, length);
291
- return prefix !== '' ? `${prefix}-${hexString}` : hexString;
292
- };
293
- /**
294
- * Class to manage component classlist
295
- * Set() are not working when imported in project
296
- */
297
- class ClassList {
298
- constructor(classlist = []) {
299
- /**
300
- * Add class
301
- * @param className - class name to add
302
- */
303
- this.add = (className) => {
304
- if (!this.has(className)) {
305
- this.classes.push(className);
306
- }
307
- };
308
- /**
309
- * Delete class
310
- * @param className - class name to delete
311
- */
312
- this.delete = (className) => {
313
- const index = this.classes.indexOf(className);
314
- if (index > -1) {
315
- this.classes.splice(index, 1);
316
- }
317
- };
318
- /**
319
- * Check if class exist in list
320
- * @param className - class name to check
321
- * @returns class name is in the list
322
- */
323
- this.has = (className) => {
324
- return this.classes.includes(className);
325
- };
326
- /**
327
- * Join classes seperated by spaces
328
- * @returns joined values
329
- */
330
- this.join = () => {
331
- return this.classes.join(' ');
332
- };
333
- this.classes = classlist;
334
- }
335
- }
336
- /**
337
- * Check if all items are string
338
- * @param items - items to check
339
- * @returns all items are string
340
- */
341
- const allItemsAreString = (items) => Array.isArray(items) && items.every(item => typeof item === 'string');
342
- /**
343
- * Check if element is a heading
344
- * @param element - slotted element
345
- * @param tagNames - allowed tag names list
346
- * @returns element is a heading
347
- */
348
- const isTagName = (element, tagNames) => {
349
- return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
350
- };
351
- /**
352
- * Focusable elements query selector
353
- */
354
- const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
355
- /**
356
- * Get windows
357
- * @param localWindow - the window we are lookink for other windows
358
- * @returns The list of windows found
359
- */
360
- const getWindows = (localWindow) => {
361
- const parentWindows = getParentWindows(localWindow);
362
- const childWindows = getChildWindows(localWindow);
363
- return [localWindow, ...parentWindows, ...childWindows];
364
- };
365
- /**
366
- * Get parent windows
367
- * @param localWindow - the window we are lookink for parents
368
- * @param windows - The list of allready found windows
369
- * @returns The list of windows found
370
- */
371
- const getParentWindows = (localWindow, windows = []) => {
372
- // Check if is in iframe
373
- if (localWindow.self !== localWindow.top) {
374
- // Check if we have permission to access parent
375
- try {
376
- const parentWindow = localWindow.parent;
377
- windows.push(parentWindow);
378
- return getParentWindows(parentWindow, windows);
379
- }
380
- catch (err) {
381
- console.error('Different hosts between iframes:', err);
382
- return windows;
383
- }
384
- }
385
- return windows;
386
- };
387
- /**
388
- * Get child windows
389
- * @param localWindow - the window we are lookink for children
390
- * @param windows - The list of allready found windows
391
- * @returns The list of windows found
392
- */
393
- const getChildWindows = (localWindow, windows = []) => {
394
- if (localWindow.frames.length > 0) {
395
- for (const childWindow of Array.from(localWindow.frames)) {
396
- windows.push(childWindow);
397
- getChildWindows(childWindow, windows);
398
- }
399
- }
400
- return windows;
401
- };
402
- /**
403
- * Validate string
404
- * @param value - value to check
405
- * @returns if string is valid
406
- */
407
- const isValidString = (value) => typeof value === 'string' && value.trim() !== '';
408
- /**
409
- * Clean string caraters
410
- * @param text - text to cliean
411
- * @returns cleanded string
412
- */
413
- const cleanString = (text) => typeof text === 'string' &&
414
- text
415
- .toLocaleLowerCase()
416
- .normalize('NFD')
417
- .replaceAll(/[\u0300-\u036f]/g, '');
418
- /**
419
- * Use to process code next tick in the event loop
420
- * @param callback - code to excute on next tick
421
- * @returns differed code excution
422
- */
423
- const nextTick = async (callback) => callback();
424
-
425
- export { ClassList as C, Direction as D, isValidString as a, isTagName as b, createID as c, cleanString as d, dateRegExp as e, localeCurrency as f, localeNumber as g, allItemsAreString as h, initLocales as i, focusableElements as j, getWindows as k, localeDate as l, nextTick as n, sizes as s };
426
-
427
- //# sourceMappingURL=components.utils-0d67c31c.js.map
@@ -1 +0,0 @@
1
- {"file":"components.utils-0d67c31c.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;MAOa,cAAc,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,QAAgB;IAC7E,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACvF,EAAE;AAEF;;;;;;MAMa,YAAY,GAAG,CAAC,MAAc,EAAE,MAAc;IACzD,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACtD,EAAE;AAEF;;;MAGa,UAAU,GAAG,gDAAgD;AAE1E;;;;;;MAMa,UAAU,GAAG,CAAC,IAAY,EAAE,MAAc;IACrD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACrE,OAAO,EAAE,CAAC;KACX;IACD,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,EAAE;AAEF;;;;;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;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;MAKa,aAAa,GAAG,CAAC,KAAc,KAAc,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG;AAE3G;;;;;MAKa,WAAW,GAAG,CAAC,IAAY,KACtC,OAAO,IAAI,KAAK,QAAQ;IACxB,IAAI;SACD,iBAAiB,EAAE;SACnB,SAAS,CAAC,KAAK,CAAC;SAChB,UAAU,CAAC,kBAAkB,EAAE,EAAE,EAAE;AAExC;;;;;MAKa,QAAQ,GAAG,OAAO,QAAoB,KAAoB,QAAQ;;;;","names":[],"sources":["src/utils/locale.utils.ts","src/locales/index.ts","src/components/molecules/menu/mg-menu/mg-menu.conf.ts","src/utils/components.utils.ts"],"sourcesContent":["/**\n * Format number to the locale currency\n * @param number - number to format\n * @param locale - locale to apply\n * @param currency - currency to apply\n * @returns formatted currency\n */\nexport const localeCurrency = (number: number, locale: string, currency: string): string => {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);\n};\n\n/**\n * Format number to locale\n * @param number - number to format\n * @param locale - locale to apply\n * @returns formatted number\n */\nexport const localeNumber = (number: number, locale: string): string => {\n return new Intl.NumberFormat(locale).format(number);\n};\n\n/**\n * Date RegExp\n */\nexport const dateRegExp = /^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$/;\n\n/**\n * Locale date format\n * @param date - date to format\n * @param locale - locale to apply\n * @returns formatted date\n */\nexport const localeDate = (date: string, locale: string): string => {\n if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {\n return '';\n }\n return new Intl.DateTimeFormat(locale).format(new Date(date));\n};\n\n/**\n * Get locale and messages\n * We load the defined locale but for now we only support the first subtag for messages\n * @param element - element we need to get the language\n * @param messages - messages to use\n * @param defaultLocale - default messages locale\n * @returns messages object\n */\nexport const getLocaleMessages = (element: HTMLElement, messages: unknown, defaultLocale: string): { locale: string; messages: Record<string, unknown> } => {\n // Get local\n const closestLangAttribute: HTMLElement = element.closest('[lang]');\n const closestLang: string[] = Intl.NumberFormat.supportedLocalesOf(closestLangAttribute?.lang);\n const locale = closestLang.length > 0 ? closestLang[0] : navigator.language || defaultLocale;\n // Only keep first subtag\n const localeSubtag = locale.split('-').shift();\n // Return\n return {\n locale,\n messages: messages[localeSubtag] || messages[defaultLocale],\n };\n};\n","import en from './en/messages.json';\nimport fr from './fr/messages.json';\nimport { getLocaleMessages } from '../utils/locale.utils';\n\nconst defaultLocale = 'en';\nconst messages = { en, fr };\n\n/**\n * Get Intl object\n * @param element - element we need to get the language\n * @returns messages object\n */\nexport const initLocales = (element: HTMLElement): { locale: string; messages: Record<string, unknown> } => getLocaleMessages(element, messages, defaultLocale);\n","import { MgItemMore } from '../../mg-item-more/mg-item-more';\n\n/**\n * Menu direction type\n */\nexport enum Direction {\n VERTICAL = 'vertical',\n HORIZONTAL = 'horizontal',\n}\n\n/**\n * ItemMore prop type\n */\nexport type ItemMoreType = Pick<MgItemMore, 'icon' | 'slotlabel' | 'size'>;\n\n/**\n * List of all possibles sizes\n */\nexport const sizes = ['regular', 'medium', 'large'] as const;\n\n/**\n * item Size from sizes\n */\nexport type MenuSizeType = (typeof sizes)[number];\n","/**\n * Create random ID\n * @param prefix - add prefix to created ID\n * @param length - ID length\n * @returns ID\n */\nexport const createID = (prefix = '', length = 10): string => {\n const randomBytes = new Uint8Array(length);\n\n crypto.getRandomValues(randomBytes);\n\n const hexString = Array.from(randomBytes)\n .map(byte => byte.toString(16).padStart(2, '0'))\n .join('')\n .slice(0, length);\n\n return prefix !== '' ? `${prefix}-${hexString}` : hexString;\n};\n\n/**\n * Class to manage component classlist\n * Set() are not working when imported in project\n */\nexport class ClassList {\n /**\n * Available classes\n */\n classes: string[];\n\n constructor(classlist: string[] = []) {\n this.classes = classlist;\n }\n\n /**\n * Add class\n * @param className - class name to add\n */\n add = (className: string): void => {\n if (!this.has(className)) {\n this.classes.push(className);\n }\n };\n\n /**\n * Delete class\n * @param className - class name to delete\n */\n delete = (className: string): void => {\n const index = this.classes.indexOf(className);\n if (index > -1) {\n this.classes.splice(index, 1);\n }\n };\n\n /**\n * Check if class exist in list\n * @param className - class name to check\n * @returns class name is in the list\n */\n has = (className: string): boolean => {\n return this.classes.includes(className);\n };\n\n /**\n * Join classes seperated by spaces\n * @returns joined values\n */\n join = (): string => {\n return this.classes.join(' ');\n };\n}\n\n/**\n * Check if all items are string\n * @param items - items to check\n * @returns all items are string\n */\nexport const allItemsAreString = (items: unknown): items is string[] => Array.isArray(items) && items.every(item => typeof item === 'string');\n\n/**\n * Check if element is a heading\n * @param element - slotted element\n * @param tagNames - allowed tag names list\n * @returns element is a heading\n */\nexport const isTagName = (element: Element, tagNames: string[]): boolean => {\n return tagNames.includes(element?.tagName.toLowerCase());\n};\n\n/**\n * Focusable elements query selector\n */\nexport const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"]), [identifier]';\n\n/**\n * Get windows\n * @param localWindow - the window we are lookink for other windows\n * @returns The list of windows found\n */\nexport const getWindows = (localWindow: Window): Window[] => {\n const parentWindows = getParentWindows(localWindow);\n const childWindows = getChildWindows(localWindow);\n return [localWindow, ...parentWindows, ...childWindows];\n};\n\n/**\n * Get parent windows\n * @param localWindow - the window we are lookink for parents\n * @param windows - The list of allready found windows\n * @returns The list of windows found\n */\nexport const getParentWindows = (localWindow: Window, windows: Window[] = []): Window[] => {\n // Check if is in iframe\n if (localWindow.self !== localWindow.top) {\n // Check if we have permission to access parent\n try {\n const parentWindow: Window = localWindow.parent;\n windows.push(parentWindow);\n return getParentWindows(parentWindow, windows);\n } catch (err) {\n console.error('Different hosts between iframes:', err);\n return windows;\n }\n }\n return windows;\n};\n\n/**\n * Get child windows\n * @param localWindow - the window we are lookink for children\n * @param windows - The list of allready found windows\n * @returns The list of windows found\n */\nconst getChildWindows = (localWindow: Window, windows: Window[] = []): Window[] => {\n if (localWindow.frames.length > 0) {\n for (const childWindow of Array.from(localWindow.frames)) {\n windows.push(childWindow);\n getChildWindows(childWindow, windows);\n }\n }\n return windows;\n};\n\n/**\n * Validate string\n * @param value - value to check\n * @returns if string is valid\n */\nexport const isValidString = (value: unknown): boolean => typeof value === 'string' && value.trim() !== '';\n\n/**\n * Clean string caraters\n * @param text - text to cliean\n * @returns cleanded string\n */\nexport const cleanString = (text: string): string =>\n typeof text === 'string' &&\n text\n .toLocaleLowerCase()\n .normalize('NFD')\n .replaceAll(/[\\u0300-\\u036f]/g, '');\n\n/**\n * Use to process code next tick in the event loop\n * @param callback - code to excute on next tick\n * @returns differed code excution\n */\nexport const nextTick = async (callback: () => void): Promise<void> => callback();\n"],"version":3}