@mgdis/mg-components 6.20.0 → 6.21.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 (159) hide show
  1. package/dist/cjs/{index-Bp6wZzau.js → index-C2viYwrR.js} +1757 -80
  2. package/dist/cjs/{index-TUElr4Wv.js → index-CCsGMNyq.js} +46 -0
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/mg-action-more_37.cjs.entry.js +684 -273
  5. package/dist/cjs/mg-alert.cjs.entry.js +17 -9
  6. package/dist/cjs/mg-components.cjs.js +3 -3
  7. package/dist/cjs/mg-fieldset.cjs.entry.js +24 -7
  8. package/dist/cjs/mg-input-combobox.cjs.entry.js +48 -18
  9. package/dist/cjs/mg-input-file.cjs.entry.js +384 -0
  10. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +30 -18
  11. package/dist/cjs/{mg-input.conf-D7jmj_lh.js → mg-input.conf-BNpeATnq.js} +7 -0
  12. package/dist/cjs/mg-loader.cjs.entry.js +8 -6
  13. package/dist/cjs/mg-progress.cjs.entry.js +19 -9
  14. package/dist/collection/collection-manifest.json +3 -2
  15. package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
  16. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +6 -0
  17. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +1 -1
  18. package/dist/collection/components/molecules/inputs/mg-input-file/mg-input-file.js +877 -0
  19. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
  20. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
  21. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
  22. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +12 -12
  23. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
  24. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +2 -2
  25. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
  26. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
  27. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
  28. package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
  29. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  30. package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +12 -3
  31. package/dist/collection/components/molecules/mg-form/mg-form.js +12 -2
  32. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
  33. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  34. package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
  35. package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
  36. package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
  37. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  38. package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
  39. package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
  40. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  41. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
  42. package/dist/collection/locales/en/messages.json +11 -0
  43. package/dist/collection/locales/fr/messages.json +11 -0
  44. package/dist/components/events.utils.js +1 -23
  45. package/dist/components/index.d.ts +2 -0
  46. package/dist/components/index.js +1 -1
  47. package/dist/components/index2.js +1 -408
  48. package/dist/components/index3.js +1 -476
  49. package/dist/components/mg-action-more.js +1 -254
  50. package/dist/components/mg-alert.js +1 -224
  51. package/dist/components/mg-badge.js +1 -6
  52. package/dist/components/mg-badge2.js +1 -113
  53. package/dist/components/mg-button.js +1 -6
  54. package/dist/components/mg-button2.js +1 -275
  55. package/dist/components/mg-card.js +1 -6
  56. package/dist/components/mg-card2.js +1 -92
  57. package/dist/components/mg-character-left.js +1 -6
  58. package/dist/components/mg-character-left2.js +1 -75
  59. package/dist/components/mg-details.js +1 -104
  60. package/dist/components/mg-divider.js +1 -6
  61. package/dist/components/mg-divider2.js +1 -49
  62. package/dist/components/mg-fieldset.js +1 -209
  63. package/dist/components/mg-form.js +1 -302
  64. package/dist/components/mg-icon.js +1 -6
  65. package/dist/components/mg-icon2.js +1 -188
  66. package/dist/components/mg-illustrated-message.js +1 -129
  67. package/dist/components/mg-input-checkbox-paginated.js +1 -6
  68. package/dist/components/mg-input-checkbox-paginated2.js +1 -135
  69. package/dist/components/mg-input-checkbox.js +1 -762
  70. package/dist/components/mg-input-combobox.js +1 -940
  71. package/dist/components/mg-input-date.js +1 -463
  72. package/dist/components/mg-input-file.d.ts +11 -0
  73. package/dist/components/mg-input-file.js +1 -0
  74. package/dist/components/mg-input-numeric.js +1 -592
  75. package/dist/components/mg-input-password.js +1 -360
  76. package/dist/components/mg-input-radio.js +1 -392
  77. package/dist/components/mg-input-rich-text-editor.js +1 -16797
  78. package/dist/components/mg-input-select.js +1 -6
  79. package/dist/components/mg-input-select2.js +1 -481
  80. package/dist/components/mg-input-text.js +1 -6
  81. package/dist/components/mg-input-text2.js +1 -514
  82. package/dist/components/mg-input-textarea.js +1 -412
  83. package/dist/components/mg-input-title.js +1 -6
  84. package/dist/components/mg-input-title2.js +1 -81
  85. package/dist/components/mg-input-toggle.js +1 -371
  86. package/dist/components/mg-input.conf.js +1 -0
  87. package/dist/components/mg-input.js +1 -6
  88. package/dist/components/mg-input2.js +1 -459
  89. package/dist/components/mg-item-more.js +1 -6
  90. package/dist/components/mg-item-more2.js +1 -505
  91. package/dist/components/mg-loader.js +1 -6
  92. package/dist/components/mg-loader2.js +1 -74
  93. package/dist/components/mg-menu-item.js +1 -6
  94. package/dist/components/mg-menu-item2.js +1 -485
  95. package/dist/components/mg-menu.js +1 -6
  96. package/dist/components/mg-message.js +1 -6
  97. package/dist/components/mg-message2.js +1 -146
  98. package/dist/components/mg-modal.js +1 -184
  99. package/dist/components/mg-pagination.js +1 -234
  100. package/dist/components/mg-panel.js +1 -350
  101. package/dist/components/mg-popover-content.js +1 -6
  102. package/dist/components/mg-popover-content2.js +1 -96
  103. package/dist/components/mg-popover.js +1 -6
  104. package/dist/components/mg-popover2.js +1 -312
  105. package/dist/components/mg-progress.js +1 -123
  106. package/dist/components/mg-skip-links.js +1 -78
  107. package/dist/components/mg-table.js +1 -319
  108. package/dist/components/mg-tabs.js +1 -6
  109. package/dist/components/mg-tabs2.js +1 -315
  110. package/dist/components/mg-tag.js +1 -133
  111. package/dist/components/mg-tooltip-content.js +1 -6
  112. package/dist/components/mg-tooltip-content2.js +1 -42
  113. package/dist/components/mg-tooltip.js +1 -6
  114. package/dist/components/mg-tooltip2.js +1 -421
  115. package/dist/components/popper.js +1 -1790
  116. package/dist/esm/{index-CNX6lq0x.js → index-D-uaxCxH.js} +46 -1
  117. package/dist/esm/{index-BluNKQ3L.js → index-DFwaH2hS.js} +1757 -80
  118. package/dist/esm/loader.js +3 -3
  119. package/dist/esm/mg-action-more_37.entry.js +684 -273
  120. package/dist/esm/mg-alert.entry.js +17 -9
  121. package/dist/esm/mg-components.js +4 -4
  122. package/dist/esm/mg-fieldset.entry.js +24 -7
  123. package/dist/esm/mg-input-combobox.entry.js +48 -18
  124. package/dist/esm/mg-input-file.entry.js +382 -0
  125. package/dist/esm/mg-input-rich-text-editor.entry.js +30 -18
  126. package/dist/esm/{mg-input.conf-DDnrE1hD.js → mg-input.conf-C9rmNQIL.js} +7 -1
  127. package/dist/esm/mg-loader.entry.js +8 -6
  128. package/dist/esm/mg-progress.entry.js +19 -9
  129. package/dist/mg-components/locales/en/messages.json +11 -0
  130. package/dist/mg-components/locales/fr/messages.json +11 -0
  131. package/dist/mg-components/mg-components.esm.js +1 -1
  132. package/dist/mg-components/{p-d5a276eb.entry.js → p-08fa327b.entry.js} +1 -1
  133. package/dist/mg-components/p-4175dcbe.entry.js +1 -0
  134. package/dist/mg-components/{p-7132bca1.entry.js → p-6b57f249.entry.js} +1 -1
  135. package/dist/mg-components/p-6b655830.entry.js +1 -0
  136. package/dist/mg-components/p-988c282e.entry.js +1 -0
  137. package/dist/mg-components/p-C9rmNQIL.js +1 -0
  138. package/dist/mg-components/p-D-uaxCxH.js +1 -0
  139. package/dist/mg-components/p-DFwaH2hS.js +2 -0
  140. package/dist/mg-components/p-a79b1f19.entry.js +1 -0
  141. package/dist/mg-components/{p-916dfb6d.entry.js → p-c3d116b9.entry.js} +1 -1
  142. package/dist/mg-components/p-dd1934f4.entry.js +1 -0
  143. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +7 -1
  144. package/dist/types/components/molecules/inputs/mg-input-file/mg-input-file.d.ts +210 -0
  145. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -4
  146. package/dist/types/components.d.ts +211 -10
  147. package/dist/types/stencil-public-runtime.d.ts +76 -12
  148. package/ide/intellij/web-types.json +356 -12
  149. package/ide/vscode/html-custom-data.json +338 -76
  150. package/package.json +19 -19
  151. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.scss +0 -1
  152. package/dist/mg-components/p-016bd291.entry.js +0 -1
  153. package/dist/mg-components/p-186a6139.entry.js +0 -1
  154. package/dist/mg-components/p-BluNKQ3L.js +0 -2
  155. package/dist/mg-components/p-CNX6lq0x.js +0 -1
  156. package/dist/mg-components/p-DDnrE1hD.js +0 -1
  157. package/dist/mg-components/p-cd061b38.entry.js +0 -1
  158. package/dist/mg-components/p-d2c72f09.entry.js +0 -1
  159. package/ide/vscode/custom.css-data.json +0 -425
@@ -1,476 +1 @@
1
- const errors$1 = {
2
- required: "This field is required."
3
- };
4
- const nbCharLeft$1 = "{counter} characters left.";
5
- const input$1 = {
6
- showMore: "Show more",
7
- select: {
8
- placeholder: "Select a value"
9
- },
10
- checkbox: {
11
- selectedValues: "{nb} selected values",
12
- selectedValue: "{nb} selected value",
13
- editButton: "Edit",
14
- selectButton: "Select values",
15
- showButton: "Show",
16
- sections: {
17
- label: "Values grouped by: \"Selected\" or \"Available\"",
18
- badge: {
19
- label: "value(s)"
20
- },
21
- search: {
22
- label: "Enter a value",
23
- values: "{count} value(s) found",
24
- noValue: "No values found"
25
- },
26
- selected: {
27
- title: "Selected",
28
- action: "Unselect all",
29
- tooltip: "Unselect all current values",
30
- values: "{count} value(s) selected",
31
- noValue: "No value selected"
32
- },
33
- notSelected: {
34
- title: "Available",
35
- action: "Select all",
36
- tooltip: "Select all current values",
37
- values: "{count} value(s) available",
38
- noValue: "All values are selected"
39
- }
40
- }
41
- },
42
- date: {
43
- pattern: {
44
- dd: "dd",
45
- mm: "mm",
46
- yyyy: "yyyy"
47
- },
48
- helpText: {
49
- expectedFormat: "Expected format: {pattern} (ex: {date})"
50
- },
51
- error: {
52
- badInput: "The date is inexistent or incorrect, the expected format is {pattern} (ex: {date})",
53
- min: "The date must be after or equal to {min}",
54
- max: "The date must be before or equal to {max}",
55
- minMax: "The date must be between {min} and {max}"
56
- }
57
- },
58
- numeric: {
59
- error: {
60
- min: "The value must be greater than or equal to {min}",
61
- max: "The value must be less than or equal to {max}",
62
- minMax: "The value must be between {min} and {max}"
63
- }
64
- },
65
- password: {
66
- display: "Display password value",
67
- hide: "Hide password value"
68
- },
69
- combobox: {
70
- notFound: "No value matches your input",
71
- notAvailable: "No value available",
72
- search: "Search…"
73
- },
74
- text: {
75
- helpText: {
76
- email: "Expected format: name@example.com",
77
- emails: "Expected format: first@example.com, second@example.com",
78
- url: "Expected format: https://example.com"
79
- },
80
- errors: {
81
- typeMismatch: {
82
- email: "The value is incorrect, the expected format is name@example.com",
83
- emails: "The value is incorrect, the expected format is first@example.com, second@example.com",
84
- url: "The value is incorrect, the expected format is https://example.com"
85
- }
86
- }
87
- }
88
- };
89
- const form$1 = {
90
- required: "Fields with a <strong class=\"mg-u-is-asterisk\">*</strong> are required",
91
- requiredSingle: "Field with a <strong class=\"mg-u-is-asterisk\">*</strong> is required",
92
- allRequired: "All fields are required",
93
- allRequiredSingle: "The field is required"
94
- };
95
- const alert$1 = {
96
- closeButton: "Close message"
97
- };
98
- const modal$1 = {
99
- closeButton: "Close modal"
100
- };
101
- const pagination$1 = {
102
- label: "Pagination",
103
- page: "page",
104
- pages: "pages",
105
- nextLabel: "Next page",
106
- previousLabel: "Previous page",
107
- selectPage: "Select the page to display."
108
- };
109
- const panel$1 = {
110
- editLabel: "Edit section title."
111
- };
112
- const skipLinks$1 = {
113
- navLabel: "Quick access"
114
- };
115
- const general$1 = {
116
- confirm: "Confirm",
117
- cancel: "Cancel",
118
- close: "Close",
119
- next: "Next",
120
- previous: "Previous",
121
- reset: "reset"
122
- };
123
- const menuItem$1 = {
124
- badgeLabel: "Include notification(s)",
125
- openNewTab: "Open link in a new tab"
126
- };
127
- const itemMore$1 = {
128
- menuLabel: "Additional menu"
129
- };
130
- const actionMore$1 = {
131
- label: "Actions"
132
- };
133
- const loader$1 = {
134
- inProgress: "Loading in progress…"
135
- };
136
- const table$1 = {
137
- sortableCaption: "(column headers with buttons are sortable)"
138
- };
139
- var en = {
140
- errors: errors$1,
141
- nbCharLeft: nbCharLeft$1,
142
- input: input$1,
143
- form: form$1,
144
- alert: alert$1,
145
- modal: modal$1,
146
- pagination: pagination$1,
147
- panel: panel$1,
148
- skipLinks: skipLinks$1,
149
- general: general$1,
150
- menuItem: menuItem$1,
151
- itemMore: itemMore$1,
152
- actionMore: actionMore$1,
153
- loader: loader$1,
154
- table: table$1
155
- };
156
-
157
- const errors = {
158
- required: "Ce champ est obligatoire."
159
- };
160
- const nbCharLeft = "{counter} caractères disponibles.";
161
- const input = {
162
- showMore: "Afficher plus",
163
- select: {
164
- placeholder: "Sélectionnez une valeur"
165
- },
166
- checkbox: {
167
- selectedValues: "{nb} valeurs sélectionnées",
168
- selectedValue: "{nb} valeur sélectionnée",
169
- editButton: "Modifier",
170
- selectButton: "Sélectionner des valeurs",
171
- showButton: "Voir",
172
- sections: {
173
- label: "Valeurs regroupées par: \"Sélectionnées\" ou \"Disponibles\"",
174
- badge: {
175
- label: "valeur(s)"
176
- },
177
- search: {
178
- label: "Saisissez une valeur",
179
- values: "{count} résultat(s)",
180
- noValue: "Aucune valeur n'a été trouvée."
181
- },
182
- selected: {
183
- title: "Sélectionnées",
184
- action: "Tout désélectionner",
185
- tooltip: "Désélectionne toutes les valeurs de la section",
186
- values: "{count} valeur(s) sélectionnée(s)",
187
- noValue: "Aucune valeur sélectionnée"
188
- },
189
- notSelected: {
190
- title: "Disponibles",
191
- action: "Tout sélectionner",
192
- tooltip: "Sélectionne toutes les valeurs de la section",
193
- values: "{count} valeur(s) disponible(s)",
194
- noValue: "Toutes les valeurs sont sélectionnées"
195
- }
196
- }
197
- },
198
- date: {
199
- pattern: {
200
- dd: "jj",
201
- mm: "mm",
202
- yyyy: "aaaa"
203
- },
204
- helpText: {
205
- expectedFormat: "Format attendu&nbsp;: {pattern} (ex&nbsp;: {date})"
206
- },
207
- error: {
208
- badInput: "La date est inexistante ou incorrecte, le format attendu est {pattern} (ex&nbsp;: {date})",
209
- min: "La date doit être postérieure ou égale au {min}",
210
- max: "La date doit être antérieure ou égale au {max}",
211
- minMax: "La date doit être comprise entre le {min} et le {max}"
212
- }
213
- },
214
- numeric: {
215
- error: {
216
- min: "La valeur doit être supérieure ou égale à {min}",
217
- max: "La valeur doit être inférieure ou égale à {max}",
218
- minMax: "La valeur doit être comprise entre {min} et {max}"
219
- }
220
- },
221
- password: {
222
- display: "Afficher le mot de passe",
223
- hide: "Masquer le mot de passe"
224
- },
225
- combobox: {
226
- notFound: "Aucune valeur ne correspondont à votre saisie",
227
- notAvailable: "Aucune valeur disponible",
228
- search: "Recherche…"
229
- },
230
- text: {
231
- helpText: {
232
- email: "Format attendu&nbsp;: nom@exemple.fr",
233
- emails: "Format attendu&nbsp;: premier@exemple.fr, second@exemple.fr",
234
- url: "Format attendu&nbsp;: https://exemple.fr"
235
- },
236
- errors: {
237
- typeMismatch: {
238
- email: "La valeur est incorrecte, le format attendu est nom@exemple.fr",
239
- emails: "La valeur est incorrecte, le format attendu est premier@exemple.fr, second@exemple.fr",
240
- url: "La valeur est incorrecte, le format attendu est https://exemple.fr"
241
- }
242
- }
243
- }
244
- };
245
- const form = {
246
- required: "Les champs marqués d'un <strong class=\"mg-u-is-asterisk\">*</strong> sont obligatoires",
247
- requiredSingle: "Le champ marqué d'un <strong class=\"mg-u-is-asterisk\">*</strong> est obligatoire",
248
- allRequired: "Tous les champs sont obligatoires",
249
- allRequiredSingle: "Le champ est obligatoire"
250
- };
251
- const alert = {
252
- closeButton: "Fermer le message"
253
- };
254
- const modal = {
255
- closeButton: "Fermer la modale"
256
- };
257
- const pagination = {
258
- label: "Pagination",
259
- page: "page",
260
- pages: "pages",
261
- nextLabel: "Page suivante",
262
- previousLabel: "Page précédente",
263
- selectPage: "Sélectionner la page à afficher."
264
- };
265
- const panel = {
266
- editLabel: "Modifier le titre de la section."
267
- };
268
- const skipLinks = {
269
- navLabel: "Accès rapide"
270
- };
271
- const general = {
272
- confirm: "Valider",
273
- cancel: "Annuler",
274
- close: "Fermer",
275
- next: "Suivant",
276
- previous: "Précédent",
277
- reset: "réinitialiser"
278
- };
279
- const menuItem = {
280
- badgeLabel: "Notification(s) incluse(s)",
281
- openNewTab: "Ouvrir le lien dans un nouvel onglet"
282
- };
283
- const itemMore = {
284
- menuLabel: "Menu complémentaire"
285
- };
286
- const actionMore = {
287
- label: "Actions"
288
- };
289
- const loader = {
290
- inProgress: "Chargement en cours…"
291
- };
292
- const table = {
293
- sortableCaption: "(les en-têtes de colonnes avec des boutons peuvent être triés)"
294
- };
295
- var fr = {
296
- errors: errors,
297
- nbCharLeft: nbCharLeft,
298
- input: input,
299
- form: form,
300
- alert: alert,
301
- modal: modal,
302
- pagination: pagination,
303
- panel: panel,
304
- skipLinks: skipLinks,
305
- general: general,
306
- menuItem: menuItem,
307
- itemMore: itemMore,
308
- actionMore: actionMore,
309
- loader: loader,
310
- table: table
311
- };
312
-
313
- /**
314
- * Date RegExp, usefull to test if string is a follow the date pattern
315
- * @example
316
- * ```ts
317
- * dateRegExp.test('mystring') // false
318
- * dateRegExp.test('2020-12-31') // true
319
- * ```
320
- */
321
- const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
322
-
323
- /**
324
- * Gets the date pattern based on the specified locale.
325
- * @param locale - the locale to refer to
326
- * @returns date pattern
327
- * @example
328
- * ```ts
329
- * localeDatePattern('fr') // 'dd/mm/yyyy'
330
- * ```
331
- */
332
- const localeDatePattern = (locale) => {
333
- const year = { value: '2023', pattern: 'yyyy' };
334
- const month = { value: '12', pattern: 'mm' };
335
- const day = { value: '24', pattern: 'dd' };
336
- return localeDate([year.value, month.value, day.value].join('-'), locale, { timeZone: 'UTC' })
337
- .replace(year.value, year.pattern)
338
- .replace(month.value, month.pattern)
339
- .replace(day.value, day.pattern);
340
- };
341
- /**
342
- * Get locale and messages
343
- * We load the defined locale but for now we only support the first subtag for messages
344
- * @param element - element we need to get the language
345
- * @param messages - messages to use
346
- * @param defaultLocale - default messages locale
347
- * @returns messages object
348
- */
349
- const localeMessages = (element, messages, defaultLocale) => {
350
- // Get local
351
- const closestLangAttribute = element.closest('[lang]');
352
- const closestLang = Intl.NumberFormat.supportedLocalesOf(closestLangAttribute?.lang);
353
- const locale = closestLang.length > 0 && typeof closestLang[0] === 'string' ? closestLang[0] : navigator.language || defaultLocale;
354
- // Only keep first subtag
355
- const localeSubtag = locale.split('-').shift();
356
- // If messages is empty, return a default object
357
- if (Object.keys(messages).length === 0) {
358
- return {
359
- locale,
360
- messages: { lang: defaultLocale },
361
- };
362
- }
363
- // Return
364
- return {
365
- locale,
366
- messages: (messages[localeSubtag] ?? messages[defaultLocale] ?? { lang: defaultLocale }),
367
- };
368
- };
369
- /**
370
- * Format number to the locale currency
371
- * @param number - number to format
372
- * @param locale - locale to apply
373
- * @param currency - currency to apply
374
- * @returns formatted currency
375
- * @example
376
- * ```ts
377
- * localeCurrency(1234567890.12, 'fr', 'EUR') // '1 234 567 890,12\xa0€'
378
- * ```
379
- */
380
- const localeCurrency = (number, locale, currency) => new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
381
- /**
382
- * Format number to locale
383
- * @param number - number to format
384
- * @param locale - locale to apply
385
- * @param decimalLength - decimal length to apply
386
- * @returns formatted number
387
- * @example
388
- * ```ts
389
- * localeNumber(1234567890.12, 'fr') // 1 234 567 890,12
390
- * ```
391
- */
392
- const localeNumber = (number, locale, decimalLength = 0) => new Intl.NumberFormat(locale, { minimumFractionDigits: decimalLength }).format(Number(number));
393
- /**
394
- * Format number as percentage based on locale
395
- * @param number - number to format
396
- * @param locale - locale to apply
397
- * @param decimalLength - decimal length to apply
398
- * @returns formatted percentage
399
- * @example
400
- * ```ts
401
- * localePercent(0.42, 'fr', 2) // '42,00 %'
402
- * localePercent(0.42, 'en', 2) // '42.00%'
403
- * ```
404
- */
405
- const localePercent = (number, locale, decimalLength = 0) => {
406
- return new Intl.NumberFormat(locale, {
407
- style: 'percent',
408
- minimumFractionDigits: decimalLength,
409
- maximumFractionDigits: decimalLength,
410
- }).format(number);
411
- };
412
- /**
413
- * Format number with standardized unit based on locale using Intl unit formatting
414
- * @param number - number to format
415
- * @param locale - locale to apply
416
- * @param unit - standardized unit (e.g., 'kilometer', 'kilogram', 'celsius')
417
- * @param unitDisplay - how to display the unit ('short', 'long', 'narrow')
418
- * @param decimalLength - decimal length to apply
419
- * @returns formatted number with localized unit
420
- * @example
421
- * ```ts
422
- * localeUnit(1234567890.12, 'fr', 'kilometer') // '1 234 567 890,12 km'
423
- * localeUnit(23, 'fr', 'celsius') // '23 °C'
424
- * localeUnit(10, 'fr', 'kilometer', 0, 'long') // '10 kilomètres'
425
- * ```
426
- */
427
- const localeUnit = (number, locale, unit, unitDisplay = 'short', decimalLength = 0) => {
428
- return new Intl.NumberFormat(locale, {
429
- style: 'unit',
430
- unit,
431
- unitDisplay,
432
- minimumFractionDigits: decimalLength,
433
- maximumFractionDigits: decimalLength,
434
- }).format(number);
435
- };
436
- /**
437
- * Locale date format
438
- * @param date - date to format
439
- * @param locale - locale to apply
440
- * @param config - DateTimeFormatOptions object to apply
441
- * @returns formatted date
442
- * @example
443
- * ```ts
444
- * localeDate('2022-06-02', 'fr') // '02/06/2022'
445
- * ```
446
- */
447
- const localeDate = (date, locale, config) => typeof date !== 'string' || date === '' || !dateRegExp.test(date) ? '' : new Intl.DateTimeFormat(locale, config).format(new Date(date));
448
- /**
449
- * Get Intl object
450
- * @param messages - locales to render in object format. `ex: { en: { porp: "test" }, fr: { porp: "test" }}`.
451
- * @param defaultLocale - fallback locale to render. `ex: 'en'`.
452
- * @returns from the element passed in return function you will get the matching messages object
453
- * @example
454
- * ```ts
455
- * import en from './en/messages.json';
456
- * import fr from './fr/messages.json';
457
- * import { defineLocales } from '@mgdis/core-ui-helpers/dist/utils';
458
- *
459
- * const defaultLocale = 'en';
460
- * const messages = { en, fr };
461
- *
462
- * export const initLocales = defineLocales(messages, defaultLocale);
463
- * ```
464
- */
465
- const defineLocales = (messages, defaultLocale) => (element) => localeMessages(element, messages, defaultLocale);
466
-
467
- const defaultLocale = 'en';
468
- const messages = { en, fr };
469
- /**
470
- * Get Intl object
471
- * @param element - element we need to get the language
472
- * @returns messages object
473
- */
474
- const initLocales = defineLocales(messages, defaultLocale);
475
-
476
- export { localeDatePattern as a, localeNumber as b, localeUnit as c, localePercent as d, localeCurrency as e, initLocales as i, localeDate as l };
1
+ const e=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,t=e=>{const t={value:"2023",pattern:"yyyy"},a={value:"12",pattern:"mm"},l={value:"24",pattern:"dd"};return n([t.value,a.value,l.value].join("-"),e,{timeZone:"UTC"}).replace(t.value,t.pattern).replace(a.value,a.pattern).replace(l.value,l.pattern)},a=(e,t,a)=>new Intl.NumberFormat(t,{style:"currency",currency:a}).format(e),l=(e,t,a=0)=>new Intl.NumberFormat(t,{minimumFractionDigits:a}).format(Number(e)),r=(e,t)=>{if("number"!=typeof e||Number.isNaN(e)||e<0)throw new Error("localeByte - size must be a positive number.");const a=["byte","kilobyte","megabyte","gigabyte","terabyte"],l=a.findIndex(((t,a)=>e<Math.pow(1024,a+1)));return Intl.NumberFormat(t,{minimumFractionDigits:0,maximumFractionDigits:2,unit:a[l],unitDisplay:"byte"===a[l]?"long":"short",style:"unit"}).format(e/Math.pow(1024,l))},s=(e,t,a=0)=>new Intl.NumberFormat(t,{style:"percent",minimumFractionDigits:a,maximumFractionDigits:a}).format(e),i=(e,t,a,l="short",r=0)=>new Intl.NumberFormat(t,{style:"unit",unit:a,unitDisplay:l,minimumFractionDigits:r,maximumFractionDigits:r}).format(e),n=(t,a,l)=>"string"==typeof t&&""!==t&&e.test(t)?new Intl.DateTimeFormat(a,l).format(new Date(t)):"",o=(u={en:{errors:{required:"This field is required."},nbCharLeft:"{counter} characters left.",input:{showMore:"Show more",select:{placeholder:"Select a value"},checkbox:{selectedValues:"{nb} selected values",selectedValue:"{nb} selected value",editButton:"Edit",selectButton:"Select values",showButton:"Show",sections:{label:'Values grouped by: "Selected" or "Available"',badge:{label:"value(s)"},search:{label:"Enter a value",values:"{count} value(s) found",noValue:"No values found"},selected:{title:"Selected",action:"Unselect all",tooltip:"Unselect all current values",values:"{count} value(s) selected",noValue:"No value selected"},notSelected:{title:"Available",action:"Select all",tooltip:"Select all current values",values:"{count} value(s) available",noValue:"All values are selected"}}},date:{pattern:{dd:"dd",mm:"mm",yyyy:"yyyy"},helpText:{expectedFormat:"Expected format: {pattern} (ex: {date})"},error:{badInput:"The date is inexistent or incorrect, the expected format is {pattern} (ex: {date})",min:"The date must be after or equal to {min}",max:"The date must be before or equal to {max}",minMax:"The date must be between {min} and {max}"}},numeric:{error:{min:"The value must be greater than or equal to {min}",max:"The value must be less than or equal to {max}",minMax:"The value must be between {min} and {max}"}},password:{display:"Display password value",hide:"Hide password value"},combobox:{notFound:"No value matches your input",notAvailable:"No value available",search:"Search…"},text:{helpText:{email:"Expected format: name@example.com",emails:"Expected format: first@example.com, second@example.com",url:"Expected format: https://example.com"},errors:{typeMismatch:{email:"The value is incorrect, the expected format is name@example.com",emails:"The value is incorrect, the expected format is first@example.com, second@example.com",url:"The value is incorrect, the expected format is https://example.com"}}},file:{helpText:{accept:"Accepted extensions: {{accept}}",maxSize:"Maximum size: {{maxSize}}"},errors:{maxSize:"The file size exceeds the maximum allowed size of {{maxSize}}"},browse:"Browse…",deleteButton:"Delete file"}},form:{required:'Fields with a <strong class="mg-u-is-asterisk">*</strong> are required',requiredSingle:'Field with a <strong class="mg-u-is-asterisk">*</strong> is required',allRequired:"All fields are required",allRequiredSingle:"The field is required"},alert:{closeButton:"Close message"},modal:{closeButton:"Close modal"},pagination:{label:"Pagination",page:"page",pages:"pages",nextLabel:"Next page",previousLabel:"Previous page",selectPage:"Select the page to display."},panel:{editLabel:"Edit section title."},skipLinks:{navLabel:"Quick access"},general:{confirm:"Confirm",cancel:"Cancel",close:"Close",next:"Next",previous:"Previous",reset:"reset"},menuItem:{badgeLabel:"Include notification(s)",openNewTab:"Open link in a new tab"},itemMore:{menuLabel:"Additional menu"},actionMore:{label:"Actions"},loader:{inProgress:"Loading in progress…"},table:{sortableCaption:"(column headers with buttons are sortable)"}},fr:{errors:{required:"Ce champ est obligatoire."},nbCharLeft:"{counter} caractères disponibles.",input:{showMore:"Afficher plus",select:{placeholder:"Sélectionnez une valeur"},checkbox:{selectedValues:"{nb} valeurs sélectionnées",selectedValue:"{nb} valeur sélectionnée",editButton:"Modifier",selectButton:"Sélectionner des valeurs",showButton:"Voir",sections:{label:'Valeurs regroupées par: "Sélectionnées" ou "Disponibles"',badge:{label:"valeur(s)"},search:{label:"Saisissez une valeur",values:"{count} résultat(s)",noValue:"Aucune valeur n'a été trouvée."},selected:{title:"Sélectionnées",action:"Tout désélectionner",tooltip:"Désélectionne toutes les valeurs de la section",values:"{count} valeur(s) sélectionnée(s)",noValue:"Aucune valeur sélectionnée"},notSelected:{title:"Disponibles",action:"Tout sélectionner",tooltip:"Sélectionne toutes les valeurs de la section",values:"{count} valeur(s) disponible(s)",noValue:"Toutes les valeurs sont sélectionnées"}}},date:{pattern:{dd:"jj",mm:"mm",yyyy:"aaaa"},helpText:{expectedFormat:"Format attendu&nbsp;: {pattern} (ex&nbsp;: {date})"},error:{badInput:"La date est inexistante ou incorrecte, le format attendu est {pattern} (ex&nbsp;: {date})",min:"La date doit être postérieure ou égale au {min}",max:"La date doit être antérieure ou égale au {max}",minMax:"La date doit être comprise entre le {min} et le {max}"}},numeric:{error:{min:"La valeur doit être supérieure ou égale à {min}",max:"La valeur doit être inférieure ou égale à {max}",minMax:"La valeur doit être comprise entre {min} et {max}"}},password:{display:"Afficher le mot de passe",hide:"Masquer le mot de passe"},combobox:{notFound:"Aucune valeur ne correspondont à votre saisie",notAvailable:"Aucune valeur disponible",search:"Recherche…"},text:{helpText:{email:"Format attendu&nbsp;: nom@exemple.fr",emails:"Format attendu&nbsp;: premier@exemple.fr, second@exemple.fr",url:"Format attendu&nbsp;: https://exemple.fr"},errors:{typeMismatch:{email:"La valeur est incorrecte, le format attendu est nom@exemple.fr",emails:"La valeur est incorrecte, le format attendu est premier@exemple.fr, second@exemple.fr",url:"La valeur est incorrecte, le format attendu est https://exemple.fr"}}},file:{helpText:{accept:"Extensions autorisée&nbsp;: {{acceptedFormat}}",maxSize:"Taille maximale&nbsp;: {{maxSize}}"},errors:{maxSize:"La taille du fichier dépasse la taille maximale autorisée de {{maxSize}}"},browse:"Parcourir…",deleteButton:"Supprimer le fichier"}},form:{required:'Les champs marqués d\'un <strong class="mg-u-is-asterisk">*</strong> sont obligatoires',requiredSingle:'Le champ marqué d\'un <strong class="mg-u-is-asterisk">*</strong> est obligatoire',allRequired:"Tous les champs sont obligatoires",allRequiredSingle:"Le champ est obligatoire"},alert:{closeButton:"Fermer le message"},modal:{closeButton:"Fermer la modale"},pagination:{label:"Pagination",page:"page",pages:"pages",nextLabel:"Page suivante",previousLabel:"Page précédente",selectPage:"Sélectionner la page à afficher."},panel:{editLabel:"Modifier le titre de la section."},skipLinks:{navLabel:"Accès rapide"},general:{confirm:"Valider",cancel:"Annuler",close:"Fermer",next:"Suivant",previous:"Précédent",reset:"réinitialiser"},menuItem:{badgeLabel:"Notification(s) incluse(s)",openNewTab:"Ouvrir le lien dans un nouvel onglet"},itemMore:{menuLabel:"Menu complémentaire"},actionMore:{label:"Actions"},loader:{inProgress:"Chargement en cours…"},table:{sortableCaption:"(les en-têtes de colonnes avec des boutons peuvent être triés)"}}},e=>((e,t,a)=>{const l=e.closest("[lang]"),r=Intl.NumberFormat.supportedLocalesOf(l?.lang),s=r.length>0&&"string"==typeof r[0]?r[0]:navigator.language||a,i=s.split("-").shift();return 0===Object.keys(t).length?{locale:s,messages:{lang:a}}:{locale:s,messages:t[i]??t[a]??{lang:a}}})(e,u,"en"));var u;export{n as a,t as b,l as c,i as d,s as e,a as f,o as i,r as l}