@mgdis/mg-components 6.16.0 → 6.18.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 (160) hide show
  1. package/dist/cjs/{index-T3-qWqFE.js → index-DCZEYvlH.js} +51 -28
  2. package/dist/cjs/{index-YM1EJx9X.js → index-TUElr4Wv.js} +10 -10
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/mg-action-more_37.cjs.entry.js +443 -228
  5. package/dist/cjs/mg-alert.cjs.entry.js +3 -3
  6. package/dist/cjs/mg-components.cjs.js +3 -3
  7. package/dist/cjs/mg-fieldset.cjs.entry.js +141 -0
  8. package/dist/cjs/mg-input-combobox.cjs.entry.js +73 -57
  9. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +36 -23
  10. package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-HYIzRsy7.js} +5 -0
  11. package/dist/cjs/mg-loader.cjs.entry.js +3 -3
  12. package/dist/cjs/mg-progress.cjs.entry.js +2 -2
  13. package/dist/collection/collection-manifest.json +2 -1
  14. package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js +5 -5
  15. package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js +7 -7
  16. package/dist/collection/components/atoms/mg-badge/mg-badge.js +6 -6
  17. package/dist/collection/components/atoms/mg-button/mg-button.js +13 -13
  18. package/dist/collection/components/atoms/mg-card/mg-card.js +2 -2
  19. package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
  20. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +1 -1
  21. package/dist/collection/components/atoms/mg-icon/mg-icon.js +32 -26
  22. package/dist/collection/components/atoms/mg-tag/mg-tag.js +3 -3
  23. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +2 -2
  24. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +6 -6
  25. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +4 -0
  26. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +193 -33
  27. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +7 -9
  28. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +65 -46
  29. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +106 -86
  30. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +67 -65
  31. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +71 -66
  32. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +56 -38
  33. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +53 -35
  34. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +66 -47
  35. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +58 -40
  36. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +77 -59
  37. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +63 -45
  38. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +54 -30
  39. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +2 -4
  40. package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +9 -6
  41. package/dist/collection/components/molecules/menus/mg-menu-item/mg-menu-item.js +7 -7
  42. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +2 -5
  43. package/dist/collection/components/molecules/mg-alert/mg-alert.js +5 -5
  44. package/dist/collection/components/molecules/mg-details/mg-details.js +7 -7
  45. package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +404 -0
  46. package/dist/collection/components/molecules/mg-form/mg-form.js +26 -17
  47. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +3 -3
  48. package/dist/collection/components/molecules/mg-loader/mg-loader.js +4 -4
  49. package/dist/collection/components/molecules/mg-message/mg-message.js +4 -4
  50. package/dist/collection/components/molecules/mg-modal/mg-modal.js +8 -8
  51. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +7 -8
  52. package/dist/collection/components/molecules/mg-panel/mg-panel.js +53 -22
  53. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +2 -2
  54. package/dist/collection/components/molecules/mg-popover/mg-popover.js +7 -7
  55. package/dist/collection/components/molecules/mg-progress/mg-progress.js +7 -7
  56. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -2
  57. package/dist/collection/components/molecules/mg-table/mg-table.js +2 -3
  58. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +7 -8
  59. package/dist/collection/locales/en/messages.json +5 -5
  60. package/dist/collection/locales/fr/messages.json +5 -5
  61. package/dist/components/index3.js +10 -10
  62. package/dist/components/mg-action-more.js +5 -3
  63. package/dist/components/mg-alert.js +5 -3
  64. package/dist/components/mg-badge2.js +4 -2
  65. package/dist/components/mg-button2.js +4 -2
  66. package/dist/components/mg-card2.js +4 -2
  67. package/dist/components/mg-character-left2.js +4 -2
  68. package/dist/components/mg-details.js +5 -3
  69. package/dist/components/mg-divider2.js +4 -2
  70. package/dist/components/mg-fieldset.d.ts +11 -0
  71. package/dist/components/mg-fieldset.js +209 -0
  72. package/dist/components/mg-form.js +8 -5
  73. package/dist/components/mg-icon2.js +29 -21
  74. package/dist/components/mg-illustrated-message.js +5 -3
  75. package/dist/components/mg-input-checkbox-paginated2.js +6 -6
  76. package/dist/components/mg-input-checkbox.js +32 -17
  77. package/dist/components/mg-input-combobox.js +75 -57
  78. package/dist/components/mg-input-date.js +39 -42
  79. package/dist/components/mg-input-numeric.js +30 -30
  80. package/dist/components/mg-input-password.js +26 -13
  81. package/dist/components/mg-input-radio.js +27 -13
  82. package/dist/components/mg-input-rich-text-editor.js +37 -22
  83. package/dist/components/mg-input-select2.js +28 -14
  84. package/dist/components/mg-input-text2.js +40 -26
  85. package/dist/components/mg-input-textarea.js +27 -14
  86. package/dist/components/mg-input-title2.js +4 -2
  87. package/dist/components/mg-input-toggle.js +39 -12
  88. package/dist/components/mg-input2.js +121 -20
  89. package/dist/components/mg-item-more2.js +13 -5
  90. package/dist/components/mg-loader2.js +5 -3
  91. package/dist/components/mg-menu-item2.js +4 -2
  92. package/dist/components/mg-message2.js +6 -4
  93. package/dist/components/mg-modal.js +6 -4
  94. package/dist/components/mg-pagination.js +4 -2
  95. package/dist/components/mg-panel.js +40 -9
  96. package/dist/components/mg-popover-content2.js +5 -3
  97. package/dist/components/mg-popover2.js +5 -3
  98. package/dist/components/mg-progress.js +5 -3
  99. package/dist/components/mg-skip-links.js +5 -3
  100. package/dist/components/mg-table.js +4 -2
  101. package/dist/components/mg-tabs2.js +5 -3
  102. package/dist/components/mg-tag.js +4 -2
  103. package/dist/components/mg-tooltip-content2.js +4 -2
  104. package/dist/components/mg-tooltip2.js +4 -2
  105. package/dist/esm/{index-WtiuOkLj.js → index-C7xjtdiw.js} +1 -1
  106. package/dist/esm/{index-Bab8_u8S.js → index-CNX6lq0x.js} +10 -10
  107. package/dist/esm/{index-JHj_9FSs.js → index-T6kOJXP1.js} +51 -28
  108. package/dist/esm/loader.js +3 -3
  109. package/dist/esm/mg-action-more_37.entry.js +444 -229
  110. package/dist/esm/mg-alert.entry.js +4 -4
  111. package/dist/esm/mg-components.js +4 -4
  112. package/dist/esm/mg-fieldset.entry.js +139 -0
  113. package/dist/esm/mg-input-combobox.entry.js +74 -58
  114. package/dist/esm/mg-input-rich-text-editor.entry.js +37 -24
  115. package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-D9V2v4n2.js} +5 -1
  116. package/dist/esm/mg-loader.entry.js +4 -4
  117. package/dist/esm/mg-progress.entry.js +3 -3
  118. package/dist/mg-components/locales/en/messages.json +5 -5
  119. package/dist/mg-components/locales/fr/messages.json +5 -5
  120. package/dist/mg-components/mg-components.esm.js +1 -1
  121. package/dist/mg-components/p-2bab89c2.entry.js +1 -0
  122. package/dist/mg-components/{p-658f828c.entry.js → p-5abc77cd.entry.js} +1 -1
  123. package/dist/mg-components/p-7d2e43b2.entry.js +1 -0
  124. package/dist/mg-components/{p-c85b5d10.entry.js → p-92e5e5a6.entry.js} +1 -1
  125. package/dist/mg-components/{p-42a90251.entry.js → p-952288bd.entry.js} +1 -1
  126. package/dist/mg-components/{p-WtiuOkLj.js → p-C7xjtdiw.js} +1 -1
  127. package/dist/mg-components/p-CNX6lq0x.js +1 -0
  128. package/dist/mg-components/p-D9V2v4n2.js +1 -0
  129. package/dist/mg-components/p-T6kOJXP1.js +2 -0
  130. package/dist/mg-components/p-f2cddd52.entry.js +1 -0
  131. package/dist/mg-components/{p-82455ac7.entry.js → p-f6afaeb8.entry.js} +1 -1
  132. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +1 -1
  133. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +0 -5
  134. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +5 -0
  135. package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +32 -1
  136. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -3
  137. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +4 -2
  138. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -2
  139. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +4 -2
  140. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -2
  141. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
  142. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -2
  143. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -2
  144. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +4 -2
  145. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -2
  146. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -2
  147. package/dist/types/components/molecules/mg-fieldset/mg-fieldset.d.ts +105 -0
  148. package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
  149. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +8 -1
  150. package/dist/types/components.d.ts +168 -18
  151. package/dist/types/stencil-public-runtime.d.ts +39 -2
  152. package/dist/types/types/index.d.ts +1 -1
  153. package/ide/intellij/web-types.json +289 -181
  154. package/ide/vscode/html-custom-data.json +259 -18
  155. package/package.json +23 -23
  156. package/dist/mg-components/p-54156253.entry.js +0 -1
  157. package/dist/mg-components/p-Bab8_u8S.js +0 -1
  158. package/dist/mg-components/p-CNgv8hc5.js +0 -1
  159. package/dist/mg-components/p-JHj_9FSs.js +0 -2
  160. package/dist/mg-components/p-abbd151c.entry.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { P as Paginate, C as ClassList, f as formatID, e as Cursor, n as nextTick, h as Page, j as getObjectValueFromKey, t as toString, d as allItemsAreString, k as isObject, i as isValidString } from './index2.js';
2
+ import { P as Paginate, C as ClassList, f as formatID, e as Cursor, t as toString, n as nextTick, h as Page, j as getObjectValueFromKey, d as allItemsAreString, i as isValidString, k as isObject } from './index2.js';
3
3
  import { d as defineCustomElement$8, c as classReadonly, a as classDisabled, w as widths } from './mg-input2.js';
4
4
  import { i as initLocales } from './index3.js';
5
5
  import { K as Keys } from './events.utils.js';
@@ -52,9 +52,11 @@ const isFetchmappings = (value) => {
52
52
  }
53
53
  };
54
54
  const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox extends HTMLElement {
55
- constructor() {
55
+ constructor(registerHost) {
56
56
  super();
57
- this.__registerHost();
57
+ if (registerHost !== false) {
58
+ this.__registerHost();
59
+ }
58
60
  this.__attachShadow();
59
61
  this.valueChange = createEvent(this, "value-change", 7);
60
62
  this.filterChange = createEvent(this, "filter-change", 7);
@@ -68,6 +70,7 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
68
70
  this.classFocus = 'mg-u-is-focused';
69
71
  // hasDisplayedError (triggered by blur event)
70
72
  this.hasDisplayedError = false;
73
+ this.customErrorMessage = { lock: false };
71
74
  /**
72
75
  * Input name
73
76
  * If not set the value equals the identifier
@@ -202,7 +205,7 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
202
205
  // override keys actions
203
206
  switch (event.key) {
204
207
  case Keys.TAB:
205
- case Keys.ENTER:
208
+ case Keys.ENTER: {
206
209
  guard = event.key === Keys.ENTER;
207
210
  const option = (_a = this.option) !== null && _a !== void 0 ? _a : this.options.items.find(this.isCurrentOption);
208
211
  // Sets the value to the content of the focused option in the listbox.
@@ -212,12 +215,13 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
212
215
  // Closes the popover.
213
216
  this.popoverDisplay = false;
214
217
  break;
218
+ }
215
219
  case Keys.DOWN:
216
220
  case Keys.ARROWDOWN:
217
221
  case Keys.UP:
218
- case Keys.ARROWUP:
222
+ case Keys.ARROWUP: {
219
223
  guard = true;
220
- if (this.isLoading || !(this.page.total > 0)) {
224
+ if (this.isLoading || this.page.total === 0) {
221
225
  this.popoverDisplay = true;
222
226
  break;
223
227
  }
@@ -248,12 +252,13 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
248
252
  // open popover
249
253
  this.popoverDisplay = true;
250
254
  break;
255
+ }
251
256
  case Keys.LEFT:
252
257
  case Keys.ARROWLEFT:
253
258
  case Keys.HOME:
254
259
  case Keys.RIGHT:
255
260
  case Keys.ARROWRIGHT:
256
- case Keys.END:
261
+ case Keys.END: {
257
262
  // skip process if visual focus is not in popover
258
263
  if (!isItem(this.option))
259
264
  break;
@@ -273,8 +278,9 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
273
278
  this.input.setSelectionRange(index, index);
274
279
  }
275
280
  break;
281
+ }
276
282
  case Keys.ESC:
277
- case Keys.ESCAPE:
283
+ case Keys.ESCAPE: {
278
284
  guard = true;
279
285
  if (this.popoverDisplay) {
280
286
  // If the popover is displayed, closes it.
@@ -288,10 +294,12 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
288
294
  this.option = null;
289
295
  }
290
296
  break;
291
- default:
297
+ }
298
+ default: {
292
299
  // Remove visual focus from popover options
293
300
  this.option = null;
294
301
  break;
302
+ }
295
303
  }
296
304
  if (guard) {
297
305
  event.stopPropagation();
@@ -337,18 +345,20 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
337
345
  };
338
346
  /**
339
347
  * Set input error message
340
- * @param errorMessage - errorMessage override
348
+ * @param fromSetErrorContext - context come from `setError` method
341
349
  */
342
- this.setErrorMessage = (errorMessage) => {
350
+ this.setErrorMessage = (fromSetErrorContext = false) => {
343
351
  // Set error message
344
352
  this.errorMessage = undefined;
345
- // Does have a custom error message
346
- if (!this.valid && errorMessage !== undefined) {
347
- this.errorMessage = errorMessage;
348
- }
349
- // required
350
- else if (!this.valid && this.input.validity.valueMissing) {
351
- this.errorMessage = this.messages.errors.required;
353
+ if (!this.valid) {
354
+ // Does have a new custom error message OR does have a custom error message locked
355
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
356
+ this.errorMessage = this.customErrorMessage.message;
357
+ }
358
+ // required
359
+ else if (this.input.validity.valueMissing) {
360
+ this.errorMessage = this.messages.errors.required;
361
+ }
352
362
  }
353
363
  };
354
364
  /**
@@ -362,15 +372,14 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
362
372
  * @returns promisified action
363
373
  */
364
374
  this.loadingWrapper = (action) => {
375
+ var _a;
365
376
  let promise;
366
377
  let index;
367
378
  // cache initial loading action if not defined
368
- if (!Boolean(this.loadingAction)) {
369
- this.loadingAction = action.name;
370
- }
379
+ (_a = this.loadingAction) !== null && _a !== void 0 ? _a : (this.loadingAction = action.name);
371
380
  // update index
372
381
  if (Boolean(this.option) && this.loadingAction !== 'load-more') {
373
- index = this.page.items.findIndex(option => option.value.toString() === this.option.value.toString());
382
+ index = this.page.items.findIndex(option => toString(option.value) === toString(this.option.value));
374
383
  }
375
384
  else if (this.loadingAction === 'load-more') {
376
385
  index = this.page.items.length - this.page.baseIndex;
@@ -423,14 +432,14 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
423
432
  */
424
433
  this.goToNextPage = () => {
425
434
  this.showMore.emit();
426
- if (Boolean(this.fetchurl)) {
435
+ if (this.fetchurl !== undefined) {
427
436
  return this.getOptions(typeof this.page.next === 'string' ? this.page.next : undefined).then(nextPage => {
428
- if (!Boolean(nextPage))
429
- return;
430
- // merge items from current page and next page
431
- const items = [...this.page.items, ...nextPage.items];
432
- // create new options pagination withe merged items
433
- this.options = new Paginate(items, { total: nextPage.total, next: nextPage.next, top: items.length });
437
+ if (nextPage !== undefined) {
438
+ // merge items from current page and next page
439
+ const items = [...this.page.items, ...nextPage.items];
440
+ // create new options pagination withe merged items
441
+ this.options = new Paginate(items, { total: nextPage.total, next: nextPage.next, top: items.length });
442
+ }
434
443
  });
435
444
  }
436
445
  else {
@@ -447,12 +456,12 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
447
456
  * @returns promise
448
457
  */
449
458
  this.updatePage = async () => {
450
- if (Boolean(this.fetchurl)) {
459
+ if (this.fetchurl !== undefined) {
451
460
  return this.getOptions().then(page => {
452
- if (!Boolean(page))
453
- return;
454
- // reset current options pagination from API response
455
- this.options = new Paginate(page.items, { total: page.total, next: page.next, top: page.top });
461
+ if (page !== undefined) {
462
+ // reset current options pagination from API response
463
+ this.options = new Paginate(page.items, { total: page.total, next: page.next, top: page.top });
464
+ }
456
465
  });
457
466
  }
458
467
  else {
@@ -498,11 +507,11 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
498
507
  this.valueChange.emit(newValue);
499
508
  }
500
509
  watchItems(newValue) {
501
- if (Boolean(this.fetchurl) && !Boolean(newValue)) {
510
+ if (this.fetchurl !== undefined && newValue === undefined) {
502
511
  // skip newValue check
503
512
  return;
504
513
  }
505
- else if (Boolean(this.fetchurl) && Boolean(newValue)) {
514
+ else if (this.fetchurl !== undefined && newValue !== undefined) {
506
515
  throw new Error(`<mg-input-combobox> prop "items" values cannot be use with "fetchurl" prop defined. Passed value: ${toString(newValue)}.`);
507
516
  }
508
517
  // Empty options
@@ -522,7 +531,7 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
522
531
  }
523
532
  }
524
533
  watchIdentifier(newValue) {
525
- if (Boolean(newValue)) {
534
+ if (isValidString(newValue)) {
526
535
  this.popoverId = `${newValue}-popover`;
527
536
  this.element.dataset.mgPopoverGuard = this.popoverId;
528
537
  }
@@ -562,7 +571,7 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
562
571
  this.classCollection = new ClassList(this.classCollection.classes);
563
572
  }
564
573
  watchFetchUrl(newValue) {
565
- if (Boolean(newValue)) {
574
+ if (newValue !== undefined) {
566
575
  this.loadingWrapper({ name: 'load-data' });
567
576
  }
568
577
  }
@@ -570,20 +579,17 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
570
579
  if (this.fetchurl && newValue && !isObject(newValue)) {
571
580
  throw new Error(`<mg-input-combobox> prop "fetchoptions" value must be a valid RequestInit. Passed value: ${toString(newValue)}.`);
572
581
  }
573
- else {
574
- new Request(this.fetchurl, newValue);
575
- }
576
582
  }
577
583
  watchFetchMappings(newValue) {
578
- if (Boolean(this.fetchurl) && !Boolean(newValue)) {
584
+ if (this.fetchurl !== undefined && !isObject(newValue)) {
579
585
  throw new Error(`<mg-input-combobox> prop "fetchmappings" is required with "fetchurl" prop.`);
580
586
  }
581
- else if (Boolean(newValue) && !isFetchmappings(newValue)) {
587
+ else if (newValue !== undefined && !isFetchmappings(newValue)) {
582
588
  throw new Error(`<mg-input-combobox> prop "fetchmappings" value must be { request: RequestMappingType, response: ResponseMappingType }. Passed value: ${toString(newValue)}.`);
583
589
  }
584
590
  }
585
591
  watchOptions(newValue) {
586
- this.page = newValue.getPage(0, Boolean(this.filter) ? this.optionsFilter : undefined);
592
+ this.page = newValue.getPage(0, this.filter.length > 0 ? this.optionsFilter : undefined);
587
593
  }
588
594
  watchFilter(newValue) {
589
595
  this.loadingWrapper({ name: 'load-data' });
@@ -640,17 +646,22 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
640
646
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
641
647
  * @param valid - value indicating the validity
642
648
  * @param errorMessage - the error message to display
649
+ * @param errorMessageLock - lock the error message and validity state
643
650
  */
644
- async setError(valid, errorMessage) {
651
+ async setError(valid, errorMessage, errorMessageLock = false) {
645
652
  if (typeof valid !== 'boolean') {
646
653
  throw new Error('<mg-input-combobox> method "setError()" param "valid" must be a boolean.');
647
654
  }
648
- else if (!isValidString(errorMessage)) {
655
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
649
656
  throw new Error('<mg-input-combobox> method "setError()" param "errorMessage" must be a string.');
650
657
  }
651
658
  else {
659
+ this.customErrorMessage = {
660
+ lock: valid ? false : errorMessageLock,
661
+ message: valid ? undefined : errorMessage,
662
+ };
652
663
  this.setValidity(valid);
653
- this.setErrorMessage(valid ? undefined : errorMessage);
664
+ this.setErrorMessage(true);
654
665
  this.hasDisplayedError = this.invalid;
655
666
  }
656
667
  }
@@ -670,6 +681,8 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
670
681
  // - Keep everything in sync both inside and outside the component
671
682
  return new Promise(resolve => {
672
683
  requestAnimationFrame(() => {
684
+ // unlock validity check by reseting customErrorMessage
685
+ this.customErrorMessage = { lock: false };
673
686
  this.checkValidity();
674
687
  this.errorMessage = undefined;
675
688
  this.hasDisplayedError = false;
@@ -698,11 +711,13 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
698
711
  * @param newValue - valid new value
699
712
  */
700
713
  setValidity(newValue) {
701
- const oldValidValue = this.valid;
702
- this.valid = newValue;
714
+ const oldValue = this.valid;
715
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
716
+ this.valid = newValue;
717
+ }
703
718
  this.invalid = !this.valid;
704
719
  // We need to send valid event even if it is the same value
705
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
720
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
706
721
  this.inputValid.emit(this.valid);
707
722
  }
708
723
  /*************
@@ -718,7 +733,7 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
718
733
  // Validate
719
734
  this.watchIdentifier(this.identifier);
720
735
  this.watchItems(this.items);
721
- if (Boolean(this.fetchurl)) {
736
+ if (this.fetchurl !== undefined) {
722
737
  this.watchFetchOptions(this.fetchoptions);
723
738
  this.watchFetchMappings(this.fetchmappings);
724
739
  this.loadingWrapper({ name: 'load-data' });
@@ -745,14 +760,17 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
745
760
  const readonlyValue = this.getValueTitle();
746
761
  const withResetButton = this.value && !this.disabled;
747
762
  let popoverContent;
748
- if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0)
763
+ if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0) {
749
764
  popoverContent = 'list';
750
- else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && Boolean(this.filter))
765
+ }
766
+ else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && this.filter.length > 0) {
751
767
  popoverContent = 'notfound';
752
- else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0)
768
+ }
769
+ else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0) {
753
770
  popoverContent = 'notavailable';
771
+ }
754
772
  let activeDescendant;
755
- if (Boolean((_d = this.option) === null || _d === void 0 ? void 0 : _d.value)) {
773
+ if (((_d = this.option) === null || _d === void 0 ? void 0 : _d.value) !== undefined) {
756
774
  activeDescendant = this.option.value;
757
775
  }
758
776
  else if (typeof this.value === 'string') {
@@ -761,8 +779,8 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
761
779
  else {
762
780
  activeDescendant = (_e = this.value) === null || _e === void 0 ? void 0 : _e.value;
763
781
  }
764
- return (h("mg-input", { key: '79e5263cd3b1c0fa0b3f386a547f2bdd48a33b28', label: this.label, identifier: this.identifier, class: this.classCollection.classes.join(' '), ariaDescribedbyIDs: popoverContent && popoverContent !== 'list' ? popoverContent : undefined, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("mg-popover", { identifier: this.popoverId, placement: "bottom-start", display: this.popoverDisplay, "arrow-hide": true, style: {
765
- '--mg-c-input-list-width': Boolean((_f = this.input) === null || _f === void 0 ? void 0 : _f.offsetWidth) ? `${this.input.offsetWidth}px` : undefined,
782
+ return (h("mg-input", { key: 'bebf380dbdea1a9f9e0257a9425dcb6cd94a7a52', label: this.label, identifier: this.identifier, class: this.classCollection.classes.join(' '), ariaDescribedbyIDs: popoverContent && popoverContent !== 'list' ? popoverContent : undefined, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("mg-popover", { identifier: this.popoverId, placement: "bottom-start", display: this.popoverDisplay, "arrow-hide": true, style: {
783
+ '--mg-c-input-list-width': ((_f = this.input) === null || _f === void 0 ? void 0 : _f.offsetWidth) > 0 ? `${this.input.offsetWidth}px` : undefined,
766
784
  }, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, h("div", { class: "mg-c-input__input-group-container" }, h("mg-icon", { icon: "magnifying-glass" }), h("input", { type: "text", role: "combobox", class: "mg-c-input__box mg-c-input__box--width", value: this.filter, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-autocomplete": "list", "aria-expanded": this.popoverDisplay.toString(), "aria-controls": listId, "aria-invalid": (this.invalid === true).toString(), "aria-activedescendant": formatID(activeDescendant), onInput: this.handleFilterInput, onBlur: this.handleFilterBlur, onFocus: this.handleFilterFocus, onKeyDown: this.handleFilterKeydown, ref: (el) => {
767
785
  if (el !== null)
768
786
  this.input = el;
@@ -12,14 +12,17 @@ const DEFAULT_MAX_DATE = '9999-12-31';
12
12
  const mgInputDateCss = ".mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__with-character-left>mg-icon:first-of-type,.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__with-character-left .mg-c-input__box,.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}";
13
13
 
14
14
  const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends HTMLElement {
15
- constructor() {
15
+ constructor(registerHost) {
16
16
  super();
17
- this.__registerHost();
17
+ if (registerHost !== false) {
18
+ this.__registerHost();
19
+ }
18
20
  this.__attachShadow();
19
21
  this.valueChange = createEvent(this, "value-change", 7);
20
22
  this.inputValid = createEvent(this, "input-valid", 7);
21
23
  // hasDisplayedError (triggered by blur event)
22
24
  this.hasDisplayedError = false;
25
+ this.customErrorMessage = { lock: false };
23
26
  /**
24
27
  * Input name
25
28
  * If not set the value equals the identifier
@@ -70,7 +73,6 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
70
73
  * @returns formated pattern help text. Ex: Format attendu : jj/mm/aaaa (ex : 20/12/2020)
71
74
  */
72
75
  this.formatHelpText = (helpText) => {
73
- var _a, _b;
74
76
  // If the component is in readonly mode, return directly because the message will not be rendered
75
77
  if (this.readonly) {
76
78
  return undefined;
@@ -83,23 +85,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
83
85
  text = text.replace(defaultHelpTextVariable, this.formatHelpText(this.messages.input.date.helpText.expectedFormat));
84
86
  }
85
87
  // Replace pattern and date variables
86
- text = text.replace('{pattern}', this.renderPattern()).replace('{date}', localeDate(dateToString(new Date('2025-12-24')), this.systemLocale));
87
- // Add additional message for min/max if necessary
88
- let rangeMessage;
89
- if (((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== DEFAULT_MAX_DATE) {
90
- rangeMessage = this.messages.input.date.helpText.minMax.replace('{min}', localeDate(this.min, this.systemLocale)).replace('{max}', localeDate(this.max, this.systemLocale));
91
- }
92
- else if (((_b = this.min) === null || _b === void 0 ? void 0 : _b.length) > 0) {
93
- rangeMessage = this.messages.input.date.helpText.min.replace('{min}', localeDate(this.min, this.systemLocale));
94
- }
95
- else if (this.max !== DEFAULT_MAX_DATE) {
96
- rangeMessage = this.messages.input.date.helpText.max.replace('{max}', localeDate(this.max, this.systemLocale));
97
- }
98
- // Combine custom helpText with range message if both exist
99
- if (text !== undefined && rangeMessage !== undefined) {
100
- return `${text}<br>${rangeMessage}`;
101
- }
102
- return text;
88
+ return text.replace('{pattern}', this.renderPattern()).replace('{date}', localeDate(dateToString(new Date('2025-12-24')), this.systemLocale));
103
89
  };
104
90
  /**
105
91
  * Handle input event
@@ -149,39 +135,41 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
149
135
  */
150
136
  this.getInputError = () => {
151
137
  var _a;
138
+ let error;
152
139
  // bad input or pattern
153
140
  if (this.input.validity.badInput || (this.value && !this.isValidPattern(this.value))) {
154
- return 'badInput';
141
+ error = 'badInput';
155
142
  }
156
143
  // required
157
- if (this.input.validity.valueMissing) {
158
- return 'required';
144
+ else if (this.input.validity.valueMissing) {
145
+ error = 'required';
159
146
  }
160
147
  // min & max
161
- if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== DEFAULT_MAX_DATE) {
162
- return 'minMax';
148
+ else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== DEFAULT_MAX_DATE) {
149
+ error = 'minMax';
163
150
  }
164
151
  // min
165
- if (this.input.validity.rangeUnderflow) {
166
- return 'min';
152
+ else if (this.input.validity.rangeUnderflow) {
153
+ error = 'min';
167
154
  }
168
155
  // max
169
- if (this.input.validity.rangeOverflow) {
170
- return 'max';
156
+ else if (this.input.validity.rangeOverflow) {
157
+ error = 'max';
171
158
  }
172
- return null;
159
+ return error;
173
160
  };
174
161
  /**
175
162
  * Check input errors
176
- * @param errorMessage - errorMessage override
163
+ * @param fromSetErrorContext - context come from `setError` method
177
164
  */
178
- this.setErrorMessage = (errorMessage) => {
165
+ this.setErrorMessage = (fromSetErrorContext = false) => {
179
166
  // Set error message
180
167
  this.errorMessage = undefined;
181
168
  if (!this.valid) {
182
169
  const inputError = this.getInputError();
183
- if (errorMessage !== undefined) {
184
- this.errorMessage = errorMessage;
170
+ // Does have a new custom error message OR does have a custom error message locked
171
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
172
+ this.errorMessage = this.customErrorMessage.message;
185
173
  }
186
174
  // required
187
175
  else if (inputError === 'required') {
@@ -189,7 +177,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
189
177
  }
190
178
  // min, max & minMax
191
179
  else if (['min', 'max', 'minMax'].includes(inputError)) {
192
- this.errorMessage = this.messages.input.date.helpText[inputError]
180
+ this.errorMessage = this.messages.input.date.error[inputError]
193
181
  .replace('{min}', localeDate(this.min, this.systemLocale))
194
182
  .replace('{max}', localeDate(this.max, this.systemLocale));
195
183
  }
@@ -293,17 +281,22 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
293
281
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
294
282
  * @param valid - value indicating the validity
295
283
  * @param errorMessage - the error message to display
284
+ * @param errorMessageLock - lock the error message and validity state
296
285
  */
297
- async setError(valid, errorMessage) {
286
+ async setError(valid, errorMessage, errorMessageLock = false) {
298
287
  if (typeof valid !== 'boolean') {
299
288
  throw new Error('<mg-input-date> method "setError()" param "valid" must be a boolean.');
300
289
  }
301
- else if (!isValidString(errorMessage)) {
290
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
302
291
  throw new Error('<mg-input-date> method "setError()" param "errorMessage" must be a string.');
303
292
  }
304
293
  else {
294
+ this.customErrorMessage = {
295
+ lock: valid ? false : errorMessageLock,
296
+ message: valid ? undefined : errorMessage,
297
+ };
305
298
  this.setValidity(valid);
306
- this.setErrorMessage(valid ? undefined : errorMessage);
299
+ this.setErrorMessage(true);
307
300
  this.hasDisplayedError = this.invalid;
308
301
  }
309
302
  }
@@ -321,6 +314,8 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
321
314
  // - Keep everything in sync both inside and outside the component
322
315
  return new Promise(resolve => {
323
316
  requestAnimationFrame(() => {
317
+ // unlock validity check by reseting customErrorMessage
318
+ this.customErrorMessage = { lock: false };
324
319
  this.checkValidity();
325
320
  this.errorMessage = undefined;
326
321
  this.hasDisplayedError = false;
@@ -334,11 +329,13 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
334
329
  * @param newValue - valid new value
335
330
  */
336
331
  setValidity(newValue) {
337
- const oldValidValue = this.valid;
338
- this.valid = newValue;
332
+ const oldValue = this.valid;
333
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
334
+ this.valid = newValue;
335
+ }
339
336
  this.invalid = !this.valid;
340
337
  // We need to send valid event even if it is the same value
341
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
338
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
342
339
  this.inputValid.emit(this.valid);
343
340
  }
344
341
  /*************
@@ -374,7 +371,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class MgInputDate extends
374
371
  * @returns HTML Element
375
372
  */
376
373
  render() {
377
- return (h("mg-input", { key: '71daaa8818ab7120c61a45399ae016a4621c8f50', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === null ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly ? (this.value && h("b", { class: "mg-c-input__readonly-value" }, localeDate(this.value, this.locale))) : (h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, ref: (el) => {
374
+ return (h("mg-input", { key: '1428f0f9f11d829ec8d3ed507c8690d63839ff17', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === null ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly ? (this.value && h("b", { class: "mg-c-input__readonly-value" }, localeDate(this.value, this.locale))) : (h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, ref: (el) => {
378
375
  if (el !== null)
379
376
  this.input = el;
380
377
  } }))));