@mgdis/mg-components 6.17.0 → 6.19.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 (127) hide show
  1. package/dist/cjs/{index-DCZEYvlH.js → index-Bp6wZzau.js} +5 -1
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/mg-action-more_37.cjs.entry.js +438 -212
  4. package/dist/cjs/mg-alert.cjs.entry.js +2 -2
  5. package/dist/cjs/mg-components.cjs.js +2 -2
  6. package/dist/cjs/mg-fieldset.cjs.entry.js +141 -0
  7. package/dist/cjs/mg-input-combobox.cjs.entry.js +93 -80
  8. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +35 -26
  9. package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-D7jmj_lh.js} +7 -0
  10. package/dist/cjs/mg-loader.cjs.entry.js +2 -2
  11. package/dist/cjs/mg-progress.cjs.entry.js +2 -2
  12. package/dist/collection/assets/icons/index.js +1 -1
  13. package/dist/collection/collection-manifest.json +1 -0
  14. package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
  15. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +5 -0
  16. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +178 -18
  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-checkbox/mg-input-checkbox.js +36 -16
  19. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +98 -78
  20. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +41 -22
  21. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +32 -12
  22. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +30 -12
  23. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +31 -12
  24. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +41 -25
  25. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +31 -12
  26. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +60 -40
  27. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +35 -33
  28. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +36 -11
  29. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +1 -1
  30. package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +5 -1
  31. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +2 -2
  32. package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
  33. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  34. package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +404 -0
  35. package/dist/collection/components/molecules/mg-form/mg-form.js +13 -4
  36. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
  37. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  38. package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
  39. package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
  40. package/dist/collection/components/molecules/mg-panel/mg-panel.js +40 -9
  41. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  42. package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
  43. package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
  44. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  45. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
  46. package/dist/components/mg-action-more.js +1 -1
  47. package/dist/components/mg-alert.js +1 -1
  48. package/dist/components/mg-details.js +1 -1
  49. package/dist/components/mg-fieldset.d.ts +11 -0
  50. package/dist/components/mg-fieldset.js +209 -0
  51. package/dist/components/mg-form.js +4 -3
  52. package/dist/components/mg-icon2.js +1 -1
  53. package/dist/components/mg-illustrated-message.js +2 -2
  54. package/dist/components/mg-input-checkbox-paginated2.js +1 -1
  55. package/dist/components/mg-input-checkbox.js +29 -16
  56. package/dist/components/mg-input-combobox.js +92 -79
  57. package/dist/components/mg-input-date.js +34 -22
  58. package/dist/components/mg-input-numeric.js +25 -12
  59. package/dist/components/mg-input-password.js +23 -12
  60. package/dist/components/mg-input-radio.js +23 -11
  61. package/dist/components/mg-input-rich-text-editor.js +33 -24
  62. package/dist/components/mg-input-select2.js +24 -12
  63. package/dist/components/mg-input-text2.js +51 -39
  64. package/dist/components/mg-input-textarea.js +28 -33
  65. package/dist/components/mg-input-toggle.js +35 -10
  66. package/dist/components/mg-input2.js +119 -19
  67. package/dist/components/mg-item-more2.js +5 -1
  68. package/dist/components/mg-loader2.js +1 -1
  69. package/dist/components/mg-message2.js +2 -2
  70. package/dist/components/mg-modal.js +3 -3
  71. package/dist/components/mg-panel.js +37 -8
  72. package/dist/components/mg-popover-content2.js +2 -2
  73. package/dist/components/mg-popover2.js +2 -2
  74. package/dist/components/mg-progress.js +1 -1
  75. package/dist/components/mg-skip-links.js +1 -1
  76. package/dist/components/mg-tabs2.js +1 -1
  77. package/dist/esm/{index-T6kOJXP1.js → index-BluNKQ3L.js} +5 -1
  78. package/dist/esm/{index-WtiuOkLj.js → index-C7xjtdiw.js} +1 -1
  79. package/dist/esm/loader.js +3 -3
  80. package/dist/esm/mg-action-more_37.entry.js +439 -213
  81. package/dist/esm/mg-alert.entry.js +3 -3
  82. package/dist/esm/mg-components.js +3 -3
  83. package/dist/esm/mg-fieldset.entry.js +139 -0
  84. package/dist/esm/mg-input-combobox.entry.js +94 -81
  85. package/dist/esm/mg-input-rich-text-editor.entry.js +36 -27
  86. package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-DDnrE1hD.js} +6 -1
  87. package/dist/esm/mg-loader.entry.js +3 -3
  88. package/dist/esm/mg-progress.entry.js +3 -3
  89. package/dist/mg-components/mg-components.css +1 -1
  90. package/dist/mg-components/mg-components.esm.js +1 -1
  91. package/dist/mg-components/p-016bd291.entry.js +1 -0
  92. package/dist/mg-components/{p-397bf67b.entry.js → p-186a6139.entry.js} +1 -1
  93. package/dist/mg-components/p-66a1cb83.entry.js +1 -0
  94. package/dist/mg-components/p-6efd819f.entry.js +1 -0
  95. package/dist/mg-components/{p-c5da335e.entry.js → p-916dfb6d.entry.js} +1 -1
  96. package/dist/mg-components/p-BluNKQ3L.js +2 -0
  97. package/dist/mg-components/{p-WtiuOkLj.js → p-C7xjtdiw.js} +1 -1
  98. package/dist/mg-components/p-DDnrE1hD.js +1 -0
  99. package/dist/mg-components/{p-0e6b40d6.entry.js → p-d2c72f09.entry.js} +1 -1
  100. package/dist/mg-components/{p-5dc3a1fb.entry.js → p-d5a276eb.entry.js} +1 -1
  101. package/dist/types/assets/icons/index.d.ts +9 -0
  102. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +6 -0
  103. package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +32 -1
  104. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -3
  105. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.d.ts +1 -0
  106. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +8 -7
  107. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -2
  108. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +4 -2
  109. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -2
  110. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
  111. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -3
  112. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -2
  113. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -7
  114. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -8
  115. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -2
  116. package/dist/types/components/molecules/mg-fieldset/mg-fieldset.d.ts +105 -0
  117. package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
  118. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +8 -1
  119. package/dist/types/components.d.ts +168 -18
  120. package/ide/intellij/web-types.json +289 -22
  121. package/ide/vscode/css-custom-data.json +7 -3
  122. package/ide/vscode/html-custom-data.json +300 -8
  123. package/package.json +18 -18
  124. package/dist/mg-components/p-8a69175b.entry.js +0 -1
  125. package/dist/mg-components/p-CNgv8hc5.js +0 -1
  126. package/dist/mg-components/p-T6kOJXP1.js +0 -2
  127. package/dist/mg-components/p-d84d87ea.entry.js +0 -1
@@ -7,7 +7,7 @@ import { d as defineCustomElement$3 } from './mg-input-title2.js';
7
7
  import { d as defineCustomElement$2 } from './mg-tooltip2.js';
8
8
  import { d as defineCustomElement$1 } from './mg-tooltip-content2.js';
9
9
 
10
- const mgInputSelectCss = ".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-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__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.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}.mg-c-input__box{padding-top:0;padding-right:var(--mg-b-size-8);padding-bottom:0}@media screen and (max-width: 767px){.mg-c-input__box{width:100%}}";
10
+ const mgInputSelectCss = ".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__input-group-container{position:relative}.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__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.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__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-full .mg-c-input__input-group-container{width:100%;flex-grow:1}.mg-c-input.mg-c-input--width-2.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-4.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-16.mg-c-input--display-character-left .mg-c-input__input-group-container{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.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}.mg-c-input__box{max-width:100%;padding-top:0;padding-right:var(--mg-b-size-8);padding-bottom:0}@media screen and (max-width: 767px){.mg-c-input__box{width:100%}}";
11
11
 
12
12
  /**
13
13
  * Check if item is a well configured option
@@ -62,6 +62,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class MgInputSelect exten
62
62
  this.inputValid = createEvent(this, "input-valid", 7);
63
63
  // hasDisplayedError (triggered by blur event)
64
64
  this.hasDisplayedError = false;
65
+ this.customErrorMessage = { lock: false };
65
66
  /**
66
67
  * Input name
67
68
  * If not set the value equals the identifier
@@ -170,15 +171,17 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class MgInputSelect exten
170
171
  };
171
172
  /**
172
173
  * Set input error message
173
- * @param errorMessage - errorMessage override
174
+ * @param fromSetErrorContext - context come from `setError` method
174
175
  */
175
- this.setErrorMessage = (errorMessage) => {
176
+ this.setErrorMessage = (fromSetErrorContext = false) => {
176
177
  // Set error message
177
178
  this.errorMessage = undefined;
178
179
  if (!this.valid) {
179
- if (errorMessage !== undefined) {
180
- this.errorMessage = errorMessage;
180
+ // Does have a new custom error message OR does have a custom error message locked
181
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
182
+ this.errorMessage = this.customErrorMessage.message;
181
183
  }
184
+ // required
182
185
  else if (this.input.validity.valueMissing) {
183
186
  this.errorMessage = this.messages.errors.required;
184
187
  }
@@ -292,17 +295,22 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class MgInputSelect exten
292
295
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
293
296
  * @param valid - value indicating the validity
294
297
  * @param errorMessage - the error message to display
298
+ * @param errorMessageLock - lock the error message and validity state
295
299
  */
296
- async setError(valid, errorMessage) {
300
+ async setError(valid, errorMessage, errorMessageLock = false) {
297
301
  if (typeof valid !== 'boolean') {
298
302
  throw new Error('<mg-input-select> method "setError()" param "valid" must be a boolean.');
299
303
  }
300
- else if (!isValidString(errorMessage)) {
304
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
301
305
  throw new Error('<mg-input-select> method "setError()" param "errorMessage" must be a string.');
302
306
  }
303
307
  else {
308
+ this.customErrorMessage = {
309
+ lock: valid ? false : errorMessageLock,
310
+ message: valid ? undefined : errorMessage,
311
+ };
304
312
  this.setValidity(valid);
305
- this.setErrorMessage(valid ? undefined : errorMessage);
313
+ this.setErrorMessage(true);
306
314
  this.hasDisplayedError = this.invalid;
307
315
  }
308
316
  }
@@ -320,6 +328,8 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class MgInputSelect exten
320
328
  // - Keep everything in sync both inside and outside the component
321
329
  return new Promise(resolve => {
322
330
  requestAnimationFrame(() => {
331
+ // unlock validity check by reseting customErrorMessage
332
+ this.customErrorMessage = { lock: false };
323
333
  this.checkValidity();
324
334
  this.errorMessage = undefined;
325
335
  this.hasDisplayedError = false;
@@ -333,11 +343,13 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class MgInputSelect exten
333
343
  * @param newValue - valid new value
334
344
  */
335
345
  setValidity(newValue) {
336
- const oldValidValue = this.valid;
337
- this.valid = newValue;
346
+ const oldValue = this.valid;
347
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
348
+ this.valid = newValue;
349
+ }
338
350
  this.invalid = !this.valid;
339
351
  // We need to send valid event even if it is the same value
340
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue)) {
352
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue)) {
341
353
  this.inputValid.emit(this.valid);
342
354
  }
343
355
  }
@@ -374,7 +386,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class MgInputSelect exten
374
386
  */
375
387
  render() {
376
388
  const readonlyValue = this.getReadonlyValue();
377
- return (h("mg-input", { key: '1394827503d3f2dd71efc6efa389ac707573d2ec', 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 && readonlyValue === null ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("select", { class: "mg-c-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
389
+ return (h("mg-input", { key: '928c7d4ebccfe38ae86630d2cb8c06f07ca09a8a', 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 && readonlyValue === null ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("select", { class: "mg-c-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
378
390
  if (el !== null)
379
391
  this.input = el;
380
392
  } }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
@@ -1,6 +1,6 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { C as ClassList, i as isValidString, d as allItemsAreString, t as toString } from './index2.js';
3
- import { d as defineCustomElement$4, c as classReadonly, a as classDisabled, w as widths } from './mg-input2.js';
3
+ import { d as defineCustomElement$4, c as classReadonly, a as classDisabled, w as widths, e as classDisplayCharacterLeft } from './mg-input2.js';
4
4
  import { i as initLocales } from './index3.js';
5
5
  import { d as defineCustomElement$6 } from './mg-character-left2.js';
6
6
  import { d as defineCustomElement$5 } from './mg-icon2.js';
@@ -16,7 +16,7 @@ const helpTextTypes = ['email', 'emails', 'url'];
16
16
  // Define possible text types
17
17
  const textTypes = ['text', 'search', 'tel', ...helpTextTypes];
18
18
 
19
- const mgInputTextCss = ".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-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.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.mg-c-input--display-character-left mg-character-left{font-size:var(--mg-b-font-size-small);opacity:.6}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__help-text ::slotted(*),.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__error ::slotted(*){margin-top:0}.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}.mg-c-input__with-character-left{position:relative;width:100%}.mg-c-input.mg-u-is-focused .mg-c-input__with-character-left .mg-c-input__box{padding-right:max(var(--mg-c-character-left-message-length)*(.35ch + .3rem) + var(--mg-b-size-16)*clamp(0,var(--mg-c-character-left-message-length),1),var(--mg-b-size-8))}.mg-c-input__with-character-left mg-character-left{position:absolute;top:50%;right:var(--mg-b-size-8);display:none;font-size:var(--mg-b-font-size-small);opacity:.6;transform:translateY(-50%)}.mg-c-input.mg-u-is-focused .mg-c-input__with-character-left mg-character-left{display:block}";
19
+ const mgInputTextCss = ".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__input-group-container{position:relative}.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__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-full .mg-c-input__input-group-container{width:100%;flex-grow:1}.mg-c-input.mg-c-input--width-2.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-4.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-16.mg-c-input--display-character-left .mg-c-input__input-group-container{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.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.mg-c-input--display-character-left mg-character-left{position:absolute;display:none}.mg-c-input.mg-c-input--display-character-left mg-character-left>span{font-size:var(--mg-b-font-size-small);opacity:.6}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__help-text ::slotted(*),.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__error ::slotted(*){margin-top:0}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--display-character-left input:focus~mg-character-left,.mg-c-input.mg-c-input--display-character-left textarea:focus~mg-character-left{display:block}.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}.mg-c-input.mg-c-input--display-character-left mg-character-left{top:50%;right:var(--mg-b-size-8);font-size:var(--mg-b-font-size-small);transform:translateY(-50%)}.mg-c-input.mg-c-input--display-character-left .mg-c-input__box:focus{padding-right:max(var(--mg-c-character-left-message-length)*(.35ch + .3rem) + var(--mg-b-size-16)*clamp(0,var(--mg-c-character-left-message-length),1),var(--mg-b-size-8))}";
20
20
 
21
21
  /**
22
22
  * Check if object is an option
@@ -43,13 +43,13 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
43
43
  * Internal *
44
44
  ************/
45
45
  // Classes
46
- this.classFocus = 'mg-u-is-focused';
47
46
  this.classIsInputGroupAppend = 'mg-c-input--is-input-group-append';
48
47
  this.classHasIcon = 'mg-c-input--has-icon';
49
48
  this.classHasButtonsGroupAppend = 'mg-c-input--has-buttons-group-append';
50
49
  this.classIsAppendInputSlotContent = 'mg-c-input--is-append-input-slot-content';
51
50
  // hasDisplayedError (triggered by blur event)
52
51
  this.hasDisplayedError = false;
52
+ this.customErrorMessage = { lock: false };
53
53
  /**
54
54
  * Input name
55
55
  * If not set the value equals the identifier
@@ -119,20 +119,10 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
119
119
  }
120
120
  this.value = this.input.value;
121
121
  };
122
- /**
123
- * Handle focus event
124
- */
125
- this.handleFocus = () => {
126
- this.classCollection.add(this.classFocus);
127
- this.classCollection = new ClassList(this.classCollection.classes);
128
- };
129
122
  /**
130
123
  * Handle blur event
131
124
  */
132
125
  this.handleBlur = () => {
133
- // Manage focus
134
- this.classCollection.delete(this.classFocus);
135
- this.classCollection = new ClassList(this.classCollection.classes);
136
126
  // Display Error
137
127
  this.handlerInProgress = 'blur';
138
128
  this.displayError().finally(() => {
@@ -148,27 +138,29 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
148
138
  };
149
139
  /**
150
140
  * Set input error message
151
- * @param errorMessage - errorMessage override
141
+ * @param fromSetErrorContext - context come from `setError` method
152
142
  */
153
- this.setErrorMessage = (errorMessage) => {
143
+ this.setErrorMessage = (fromSetErrorContext = false) => {
154
144
  var _a;
155
145
  // Set error message
156
146
  this.errorMessage = undefined;
157
- // Does have a custom error message
158
- if (!this.valid && errorMessage !== undefined) {
159
- this.errorMessage = errorMessage;
160
- }
161
- // Does not match type (email, emails, tel, url, etc.)
162
- else if (!this.valid && this.input.validity.typeMismatch) {
163
- this.errorMessage = this.messages.input.text.errors.typeMismatch[this.type];
164
- }
165
- // Does not match pattern
166
- else if (!this.valid && this.input.validity.patternMismatch) {
167
- this.errorMessage = (_a = this.patternErrorMessage) !== null && _a !== void 0 ? _a : this.messages.input.text.errors.typeMismatch[this.type];
168
- }
169
- // required
170
- else if (!this.valid && this.input.validity.valueMissing) {
171
- this.errorMessage = this.messages.errors.required;
147
+ if (!this.valid) {
148
+ // Does have a new custom error message OR does have a custom error message locked
149
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
150
+ this.errorMessage = this.customErrorMessage.message;
151
+ }
152
+ // Does not match type (email, emails, tel, url, etc.)
153
+ else if (this.input.validity.typeMismatch) {
154
+ this.errorMessage = this.messages.input.text.errors.typeMismatch[this.type];
155
+ }
156
+ // Does not match pattern
157
+ else if (this.input.validity.patternMismatch) {
158
+ this.errorMessage = (_a = this.patternErrorMessage) !== null && _a !== void 0 ? _a : this.messages.input.text.errors.typeMismatch[this.type];
159
+ }
160
+ // required
161
+ else if (this.input.validity.valueMissing) {
162
+ this.errorMessage = this.messages.errors.required;
163
+ }
172
164
  }
173
165
  };
174
166
  /**
@@ -264,6 +256,14 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
264
256
  watchPattern() {
265
257
  this.validatePattern();
266
258
  }
259
+ validateCharacterLeftHide(newValue) {
260
+ if (newValue) {
261
+ this.classCollection.delete(classDisplayCharacterLeft);
262
+ }
263
+ else {
264
+ this.classCollection.add(classDisplayCharacterLeft);
265
+ }
266
+ }
267
267
  watchHelpText(newValue) {
268
268
  if (!isValidString(newValue) && helpTextTypes.includes(this.type)) {
269
269
  this.helpText = this.messages.input.text.helpText[this.type];
@@ -302,17 +302,22 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
302
302
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
303
303
  * @param valid - value indicating the validity
304
304
  * @param errorMessage - the error message to display
305
+ * @param errorMessageLock - lock the error message and validity state
305
306
  */
306
- async setError(valid, errorMessage) {
307
+ async setError(valid, errorMessage, errorMessageLock = false) {
307
308
  if (typeof valid !== 'boolean') {
308
309
  throw new Error('<mg-input-text> method "setError()" param "valid" must be a boolean.');
309
310
  }
310
- else if (!isValidString(errorMessage)) {
311
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
311
312
  throw new Error('<mg-input-text> method "setError()" param "errorMessage" must be a string.');
312
313
  }
313
314
  else {
315
+ this.customErrorMessage = {
316
+ lock: valid ? false : errorMessageLock,
317
+ message: valid ? undefined : errorMessage,
318
+ };
314
319
  this.setValidity(valid);
315
- this.setErrorMessage(valid ? undefined : errorMessage);
320
+ this.setErrorMessage(true);
316
321
  this.hasDisplayedError = this.invalid;
317
322
  }
318
323
  }
@@ -330,6 +335,8 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
330
335
  // - Keep everything in sync both inside and outside the component
331
336
  return new Promise(resolve => {
332
337
  requestAnimationFrame(() => {
338
+ // unlock validity check by reseting customErrorMessage
339
+ this.customErrorMessage = { lock: false };
333
340
  this.checkValidity();
334
341
  this.errorMessage = undefined;
335
342
  this.hasDisplayedError = false;
@@ -343,11 +350,13 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
343
350
  * @param newValue - valid new value
344
351
  */
345
352
  setValidity(newValue) {
346
- const oldValidValue = this.valid;
347
- this.valid = newValue;
353
+ const oldValue = this.valid;
354
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
355
+ this.valid = newValue;
356
+ }
348
357
  this.invalid = !this.valid;
349
358
  // We need to send valid event even if it is the same value
350
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
359
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
351
360
  this.inputValid.emit(this.valid);
352
361
  }
353
362
  /*************
@@ -370,6 +379,7 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
370
379
  this.watchMgWidth(this.mgWidth);
371
380
  this.watchReadonly(this.readonly);
372
381
  this.watchDisabled(this.disabled);
382
+ this.validateCharacterLeftHide(this.characterLeftHide);
373
383
  this.validateType(this.type);
374
384
  this.watchHelpText(this.helpText);
375
385
  // Check validity when component is ready
@@ -384,12 +394,12 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
384
394
  * @returns HTML Element
385
395
  */
386
396
  render() {
387
- return (h("mg-input", { key: '8b9ffd8f5546fe9ffe0e7054e794afa06de4189f', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: this.characterLeftId, 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
397
+ return (h("mg-input", { key: 'b6360c95530daf744ae5c3eb5cc41d6c81c3e35c', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: this.characterLeftId, 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
388
398
  ? this.value && this.renderReadonly()
389
399
  : [
390
- h("div", { key: "input", class: "mg-c-input__with-character-left", style: {
400
+ h("div", { key: "input", class: "mg-c-input__input-group-container", style: {
391
401
  '--mg-c-character-left-message-length': (!this.characterLeftHide ? this.maxlength.toString().length * 2 + 1 : 0).toString(),
392
- } }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type === 'emails' ? 'email' : this.type, multiple: this.type === 'emails', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, list: this.hasDatalist() ? this.datalistId : undefined, autocomplete: this.hasDatalist() ? 'off' : undefined, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
402
+ } }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type === 'emails' ? 'email' : this.type, multiple: this.type === 'emails', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, list: this.hasDatalist() ? this.datalistId : undefined, autocomplete: this.hasDatalist() ? 'off' : undefined, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), pattern: this.pattern, onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
393
403
  if (el !== null)
394
404
  this.input = el;
395
405
  } }), this.hasDatalist() && (h("datalist", { id: this.datalistId }, this.datalistoptions.map(option => (h("option", { value: isOption(option) ? option.title : option, key: option }))))), !this.characterLeftHide && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))),
@@ -408,6 +418,7 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
408
418
  "mgWidth": ["watchMgWidth"],
409
419
  "pattern": ["watchPattern"],
410
420
  "patternErrorMessage": ["watchPattern"],
421
+ "characterLeftHide": ["validateCharacterLeftHide"],
411
422
  "helpText": ["watchHelpText"]
412
423
  }; }
413
424
  static get style() { return mgInputTextCss; }
@@ -452,6 +463,7 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
452
463
  "mgWidth": ["watchMgWidth"],
453
464
  "pattern": ["watchPattern"],
454
465
  "patternErrorMessage": ["watchPattern"],
466
+ "characterLeftHide": ["validateCharacterLeftHide"],
455
467
  "helpText": ["watchHelpText"]
456
468
  }]);
457
469
  function defineCustomElement() {
@@ -1,6 +1,6 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { C as ClassList, i as isValidString, t as toString } from './index2.js';
3
- import { d as defineCustomElement$5, c as classReadonly, a as classDisabled, w as widths } from './mg-input2.js';
3
+ import { d as defineCustomElement$5, c as classReadonly, a as classDisabled, w as widths, e as classDisplayCharacterLeft } from './mg-input2.js';
4
4
  import { i as initLocales } from './index3.js';
5
5
  import { d as defineCustomElement$7 } from './mg-character-left2.js';
6
6
  import { d as defineCustomElement$6 } from './mg-icon2.js';
@@ -8,7 +8,7 @@ import { d as defineCustomElement$4 } from './mg-input-title2.js';
8
8
  import { d as defineCustomElement$3 } from './mg-tooltip2.js';
9
9
  import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
10
10
 
11
- const mgInputTextareaCss = ".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-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.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.mg-c-input--display-character-left mg-character-left{font-size:var(--mg-b-font-size-small);opacity:.6}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__help-text ::slotted(*),.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__error ::slotted(*){margin-top:0}.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}.mg-c-input__input{align-items:start}.mg-c-input__box{display:block;height:auto;resize:none}.mg-c-input__box.mg-c-input__box--resizable{resize:both}.mg-c-input__box.mg-c-input__box--resizable-horizontal{resize:horizontal}.mg-c-input__box.mg-c-input__box--resizable-vertical{resize:vertical}.mg-c-input__readonly-value{white-space:pre-line}.mg-c-input__with-character-left{flex-grow:1}.mg-c-input__with-character-left mg-character-left{display:block;text-align:end;visibility:hidden}.mg-c-input.mg-u-is-focused .mg-c-input__with-character-left mg-character-left{visibility:visible}@-moz-document url-prefix(){.mg-c-input__box{overflow-x:hidden}}";
11
+ const mgInputTextareaCss = ".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__input-group-container{position:relative}.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__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-full .mg-c-input__input-group-container{width:100%;flex-grow:1}.mg-c-input.mg-c-input--width-2.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-4.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-16.mg-c-input--display-character-left .mg-c-input__input-group-container{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.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.mg-c-input--display-character-left mg-character-left{position:absolute;display:none}.mg-c-input.mg-c-input--display-character-left mg-character-left>span{font-size:var(--mg-b-font-size-small);opacity:.6}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__help-text ::slotted(*),.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__error ::slotted(*){margin-top:0}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--display-character-left input:focus~mg-character-left,.mg-c-input.mg-c-input--display-character-left textarea:focus~mg-character-left{display:block}.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}.mg-c-input__input{align-items:start}.mg-c-input__box{display:block;height:auto;resize:none}.mg-c-input__box.mg-c-input__box--resizable{resize:both}.mg-c-input__box.mg-c-input__box--resizable-horizontal{resize:horizontal}.mg-c-input__box.mg-c-input__box--resizable-vertical{resize:vertical}.mg-c-input.mg-c-input--readonly .mg-c-input__readonly-value{white-space:pre-line}.mg-c-input.mg-c-input--display-character-left .mg-c-input__box{padding-bottom:var(--mg-b-size-24)}.mg-c-input.mg-c-input--display-character-left mg-character-left{right:calc(var(--mg-c-input-border-width) + .1rem);bottom:calc(var(--mg-c-input-border-width) + .1rem);padding:calc(var(--mg-b-size-4)/2 - var(--mg-c-input-border-width)) calc(var(--mg-b-size-4) - var(--mg-c-input-border-width));border:var(--mg-c-input-border-width) solid var(--mg-c-input-color-border);border-right-width:0;border-bottom-width:0;background:var(--mg-b-color-neutral-0);border-bottom-right-radius:var(--mg-c-input-border-radius);border-top-left-radius:var(--mg-c-input-border-radius)}@-moz-document url-prefix(){.mg-c-input__box{overflow-x:hidden}}";
12
12
 
13
13
  const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea extends HTMLElement {
14
14
  constructor(registerHost) {
@@ -19,14 +19,9 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
19
19
  this.__attachShadow();
20
20
  this.valueChange = createEvent(this, "value-change", 7);
21
21
  this.inputValid = createEvent(this, "input-valid", 7);
22
- /************
23
- * Internal *
24
- ************/
25
- // Classes
26
- this.classFocus = 'mg-u-is-focused';
27
- this.classDisplayCharacterLeft = 'mg-c-input--display-character-left';
28
22
  // hasDisplayedError (triggered by blur event)
29
23
  this.hasDisplayedError = false;
24
+ this.customErrorMessage = { lock: false };
30
25
  /**
31
26
  * Input name
32
27
  * If not set the value equals the identifier
@@ -90,20 +85,10 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
90
85
  }
91
86
  this.value = this.input.value;
92
87
  };
93
- /**
94
- * Handle focus event
95
- */
96
- this.handleFocus = () => {
97
- this.classCollection.add(this.classFocus);
98
- this.classCollection = new ClassList(this.classCollection.classes);
99
- };
100
88
  /**
101
89
  * Handle blur event
102
90
  */
103
91
  this.handleBlur = () => {
104
- // Manage focus
105
- this.classCollection.delete(this.classFocus);
106
- this.classCollection = new ClassList(this.classCollection.classes);
107
92
  // Display Error
108
93
  this.handlerInProgress = 'blur';
109
94
  this.displayError().finally(() => {
@@ -125,15 +110,16 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
125
110
  };
126
111
  /**
127
112
  * Set input error message
128
- * @param errorMessage - errorMessage override
113
+ * @param fromSetErrorContext - context come from `setError` method
129
114
  */
130
- this.setErrorMessage = (errorMessage) => {
115
+ this.setErrorMessage = (fromSetErrorContext = false) => {
131
116
  // Set error message
132
117
  this.errorMessage = undefined;
133
- // Does not match pattern
118
+ // Does have a new custom error message
134
119
  if (!this.valid) {
135
- if (errorMessage !== undefined) {
136
- this.errorMessage = errorMessage;
120
+ // Does have a new custom error message OR does have a custom error message locked
121
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
122
+ this.errorMessage = this.customErrorMessage.message;
137
123
  }
138
124
  else if (!this.getPatternValidity()) {
139
125
  this.errorMessage = this.patternErrorMessage;
@@ -187,10 +173,10 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
187
173
  }
188
174
  validatecharacterLeftHide(newValue) {
189
175
  if (newValue) {
190
- this.classCollection.delete(this.classDisplayCharacterLeft);
176
+ this.classCollection.delete(classDisplayCharacterLeft);
191
177
  }
192
178
  else {
193
- this.classCollection.add(this.classDisplayCharacterLeft);
179
+ this.classCollection.add(classDisplayCharacterLeft);
194
180
  }
195
181
  }
196
182
  /**
@@ -226,17 +212,22 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
226
212
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
227
213
  * @param valid - value indicating the validity
228
214
  * @param errorMessage - the error message to display
215
+ * @param errorMessageLock - lock the error message and validity state
229
216
  */
230
- async setError(valid, errorMessage) {
217
+ async setError(valid, errorMessage, errorMessageLock = false) {
231
218
  if (typeof valid !== 'boolean') {
232
219
  throw new Error('<mg-input-textarea> method "setError()" param "valid" must be a boolean.');
233
220
  }
234
- else if (!isValidString(errorMessage)) {
221
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
235
222
  throw new Error('<mg-input-textarea> method "setError()" param "errorMessage" must be a string.');
236
223
  }
237
224
  else {
225
+ this.customErrorMessage = {
226
+ lock: valid ? false : errorMessageLock,
227
+ message: valid ? undefined : errorMessage,
228
+ };
238
229
  this.setValidity(valid);
239
- this.setErrorMessage(valid ? undefined : errorMessage);
230
+ this.setErrorMessage(true);
240
231
  this.hasDisplayedError = this.invalid;
241
232
  }
242
233
  }
@@ -254,6 +245,8 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
254
245
  // - Keep everything in sync both inside and outside the component
255
246
  return new Promise(resolve => {
256
247
  requestAnimationFrame(() => {
248
+ // unlock validity check by reseting customErrorMessage
249
+ this.customErrorMessage = { lock: false };
257
250
  this.checkValidity();
258
251
  this.errorMessage = undefined;
259
252
  this.hasDisplayedError = false;
@@ -267,11 +260,13 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
267
260
  * @param newValue - valid new value
268
261
  */
269
262
  setValidity(newValue) {
270
- const oldValidValue = this.valid;
271
- this.valid = newValue;
263
+ const oldValue = this.valid;
264
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
265
+ this.valid = newValue;
266
+ }
272
267
  this.invalid = !this.valid;
273
268
  // We need to send valid event even if it is the same value
274
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
269
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
275
270
  this.inputValid.emit(this.valid);
276
271
  }
277
272
  /*************
@@ -304,13 +299,13 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
304
299
  * @returns HTML Element
305
300
  */
306
301
  render() {
307
- return (h("mg-input", { key: 'e87320fe4d3c2c857751ddcc30fab470956b4ed2', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: this.characterLeftId, 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 ? (this.value && h("b", { class: "mg-c-input__readonly-value" }, this.value)) : (h("div", { class: "mg-c-input__with-character-left" }, h("textarea", { class: {
302
+ return (h("mg-input", { key: 'a43b8b1572249e31fb6ea5bd9244639698629218', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: this.characterLeftId, 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 ? (this.value && h("b", { class: "mg-c-input__readonly-value" }, this.value)) : (h("div", { class: "mg-c-input__input-group-container" }, h("textarea", { class: {
308
303
  'mg-c-input__box': true,
309
304
  'mg-c-input__box--width': true,
310
305
  'mg-c-input__box--resizable': this.resizable === 'both',
311
306
  'mg-c-input__box--resizable-horizontal': this.resizable === 'horizontal',
312
307
  'mg-c-input__box--resizable-vertical': this.resizable === 'vertical',
313
- }, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
308
+ }, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
314
309
  if (el !== null)
315
310
  this.input = el;
316
311
  } }), !this.characterLeftHide && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))))));