@mgdis/mg-components 6.17.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 (117) hide show
  1. package/dist/cjs/index-DCZEYvlH.js +4 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/mg-action-more_37.cjs.entry.js +411 -168
  4. package/dist/cjs/mg-alert.cjs.entry.js +1 -1
  5. package/dist/cjs/mg-components.cjs.js +1 -1
  6. package/dist/cjs/mg-fieldset.cjs.entry.js +141 -0
  7. package/dist/cjs/mg-input-combobox.cjs.entry.js +71 -55
  8. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +33 -20
  9. package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-HYIzRsy7.js} +5 -0
  10. package/dist/cjs/mg-loader.cjs.entry.js +1 -1
  11. package/dist/cjs/mg-progress.cjs.entry.js +1 -1
  12. package/dist/collection/collection-manifest.json +1 -0
  13. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +4 -0
  14. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +178 -18
  15. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +1 -1
  16. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +36 -16
  17. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +78 -55
  18. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +41 -22
  19. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +32 -12
  20. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +30 -12
  21. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +31 -12
  22. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +40 -20
  23. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +31 -12
  24. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +44 -25
  25. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +31 -13
  26. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +36 -11
  27. package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +5 -1
  28. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
  29. package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
  30. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  31. package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +404 -0
  32. package/dist/collection/components/molecules/mg-form/mg-form.js +13 -4
  33. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
  34. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  35. package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
  36. package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
  37. package/dist/collection/components/molecules/mg-panel/mg-panel.js +40 -9
  38. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  39. package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
  40. package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
  41. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  42. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
  43. package/dist/components/mg-action-more.js +1 -1
  44. package/dist/components/mg-alert.js +1 -1
  45. package/dist/components/mg-details.js +1 -1
  46. package/dist/components/mg-fieldset.d.ts +11 -0
  47. package/dist/components/mg-fieldset.js +209 -0
  48. package/dist/components/mg-form.js +4 -3
  49. package/dist/components/mg-illustrated-message.js +1 -1
  50. package/dist/components/mg-input-checkbox-paginated2.js +1 -1
  51. package/dist/components/mg-input-checkbox.js +28 -15
  52. package/dist/components/mg-input-combobox.js +71 -55
  53. package/dist/components/mg-input-date.js +33 -21
  54. package/dist/components/mg-input-numeric.js +24 -11
  55. package/dist/components/mg-input-password.js +22 -11
  56. package/dist/components/mg-input-radio.js +23 -11
  57. package/dist/components/mg-input-rich-text-editor.js +32 -19
  58. package/dist/components/mg-input-select2.js +24 -12
  59. package/dist/components/mg-input-text2.js +36 -24
  60. package/dist/components/mg-input-textarea.js +23 -12
  61. package/dist/components/mg-input-toggle.js +35 -10
  62. package/dist/components/mg-input2.js +117 -18
  63. package/dist/components/mg-item-more2.js +5 -1
  64. package/dist/components/mg-loader2.js +1 -1
  65. package/dist/components/mg-message2.js +2 -2
  66. package/dist/components/mg-modal.js +2 -2
  67. package/dist/components/mg-panel.js +36 -7
  68. package/dist/components/mg-popover-content2.js +1 -1
  69. package/dist/components/mg-popover2.js +1 -1
  70. package/dist/components/mg-progress.js +1 -1
  71. package/dist/components/mg-skip-links.js +1 -1
  72. package/dist/components/mg-tabs2.js +1 -1
  73. package/dist/esm/{index-WtiuOkLj.js → index-C7xjtdiw.js} +1 -1
  74. package/dist/esm/index-T6kOJXP1.js +4 -0
  75. package/dist/esm/loader.js +1 -1
  76. package/dist/esm/mg-action-more_37.entry.js +412 -169
  77. package/dist/esm/mg-alert.entry.js +2 -2
  78. package/dist/esm/mg-components.js +1 -1
  79. package/dist/esm/mg-fieldset.entry.js +139 -0
  80. package/dist/esm/mg-input-combobox.entry.js +72 -56
  81. package/dist/esm/mg-input-rich-text-editor.entry.js +34 -21
  82. package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-D9V2v4n2.js} +5 -1
  83. package/dist/esm/mg-loader.entry.js +2 -2
  84. package/dist/esm/mg-progress.entry.js +2 -2
  85. package/dist/mg-components/mg-components.esm.js +1 -1
  86. package/dist/mg-components/p-2bab89c2.entry.js +1 -0
  87. package/dist/mg-components/{p-0e6b40d6.entry.js → p-5abc77cd.entry.js} +1 -1
  88. package/dist/mg-components/p-7d2e43b2.entry.js +1 -0
  89. package/dist/mg-components/{p-5dc3a1fb.entry.js → p-92e5e5a6.entry.js} +1 -1
  90. package/dist/mg-components/{p-c5da335e.entry.js → p-952288bd.entry.js} +1 -1
  91. package/dist/mg-components/{p-WtiuOkLj.js → p-C7xjtdiw.js} +1 -1
  92. package/dist/mg-components/p-D9V2v4n2.js +1 -0
  93. package/dist/mg-components/p-f2cddd52.entry.js +1 -0
  94. package/dist/mg-components/{p-397bf67b.entry.js → p-f6afaeb8.entry.js} +1 -1
  95. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +5 -0
  96. package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +32 -1
  97. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -3
  98. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +4 -2
  99. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -2
  100. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +4 -2
  101. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -2
  102. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
  103. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -2
  104. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -2
  105. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +4 -2
  106. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -2
  107. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -2
  108. package/dist/types/components/molecules/mg-fieldset/mg-fieldset.d.ts +105 -0
  109. package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
  110. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +8 -1
  111. package/dist/types/components.d.ts +168 -18
  112. package/ide/intellij/web-types.json +272 -9
  113. package/ide/vscode/html-custom-data.json +243 -5
  114. package/package.json +15 -15
  115. package/dist/mg-components/p-8a69175b.entry.js +0 -1
  116. package/dist/mg-components/p-CNgv8hc5.js +0 -1
  117. package/dist/mg-components/p-d84d87ea.entry.js +0 -1
@@ -33,6 +33,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
33
33
  this.classVerticalList = 'mg-c-input--vertical-list';
34
34
  // hasDisplayedError (triggered by blur event)
35
35
  this.hasDisplayedError = false;
36
+ this.customErrorMessage = { lock: false };
36
37
  /**
37
38
  * Input name
38
39
  * If not set the value equals the identifier
@@ -96,16 +97,18 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
96
97
  };
97
98
  /**
98
99
  * Set input error message
99
- * @param errorMessage - errorMessage override
100
+ * @param fromSetErrorContext - context come from `setError` method
100
101
  */
101
- this.setErrorMessage = (errorMessage) => {
102
+ this.setErrorMessage = (fromSetErrorContext = false) => {
102
103
  const invalidElement = this.getInvalidElement();
103
104
  // Set error message
104
105
  this.errorMessage = undefined;
105
106
  if (!this.valid) {
106
- if (errorMessage !== undefined) {
107
- this.errorMessage = errorMessage;
107
+ // Does have a new custom error message OR does have a custom error message locked
108
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
109
+ this.errorMessage = this.customErrorMessage.message;
108
110
  }
111
+ // required
109
112
  else if (invalidElement.validity.valueMissing) {
110
113
  this.errorMessage = this.messages.errors.required;
111
114
  }
@@ -210,17 +213,22 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
210
213
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
211
214
  * @param valid - value indicating the validity
212
215
  * @param errorMessage - the error message to display
216
+ * @param errorMessageLock - lock the error message and validity state
213
217
  */
214
- async setError(valid, errorMessage) {
218
+ async setError(valid, errorMessage, errorMessageLock = false) {
215
219
  if (typeof valid !== 'boolean') {
216
220
  throw new Error('<mg-input-radio> method "setError()" param "valid" must be a boolean.');
217
221
  }
218
- else if (!isValidString(errorMessage)) {
222
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
219
223
  throw new Error('<mg-input-radio> method "setError()" param "errorMessage" must be a string.');
220
224
  }
221
225
  else {
226
+ this.customErrorMessage = {
227
+ lock: valid ? false : errorMessageLock,
228
+ message: valid ? undefined : errorMessage,
229
+ };
222
230
  this.setValidity(valid);
223
- this.setErrorMessage(valid ? undefined : errorMessage);
231
+ this.setErrorMessage(true);
224
232
  this.hasDisplayedError = this.invalid;
225
233
  }
226
234
  }
@@ -238,6 +246,8 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
238
246
  // - Keep everything in sync both inside and outside the component
239
247
  return new Promise(resolve => {
240
248
  requestAnimationFrame(() => {
249
+ // unlock validity check by reseting customErrorMessage
250
+ this.customErrorMessage = { lock: false };
241
251
  this.checkValidity();
242
252
  this.errorMessage = undefined;
243
253
  this.hasDisplayedError = false;
@@ -251,11 +261,13 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
251
261
  * @param newValue - valid new value
252
262
  */
253
263
  setValidity(newValue) {
254
- const oldValidValue = this.valid;
255
- this.valid = newValue;
264
+ const oldValue = this.valid;
265
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
266
+ this.valid = newValue;
267
+ }
256
268
  this.invalid = !this.valid;
257
269
  // We need to send valid event even if it is the same value
258
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
270
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
259
271
  this.inputValid.emit(this.valid);
260
272
  }
261
273
  /*************
@@ -286,7 +298,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRadio exten
286
298
  * @returns HTML Element
287
299
  */
288
300
  render() {
289
- return (h("mg-input", { key: '048aa732e7f8593701c9397e571b97584bc5e37b', 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 ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue)) : (h("ul", { class: "mg-c-input__input-group-container", role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: (el) => {
301
+ return (h("mg-input", { key: '9290ab8e5048dd6806985ab55d13bd8b0dd93bd1', 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 ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue)) : (h("ul", { class: "mg-c-input__input-group-container", role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: (el) => {
290
302
  if (el !== null)
291
303
  this.inputs[index] = el;
292
304
  } }), h("label", { htmlFor: this.identifier + '_' + index }, input.title))))))));
@@ -16395,6 +16395,7 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
16395
16395
  this.valueChange = createEvent(this, "value-change", 7);
16396
16396
  // hasDisplayedError (triggered by blur event)
16397
16397
  this.hasDisplayedError = false;
16398
+ this.customErrorMessage = { lock: false };
16398
16399
  // Classes
16399
16400
  this.classFocus = 'mg-u-is-focused';
16400
16401
  /**
@@ -16460,20 +16461,23 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
16460
16461
  };
16461
16462
  /**
16462
16463
  * Set input error message
16463
- * @param errorMessage - errorMessage override
16464
+ * @param fromSetErrorContext - context come from `setError` method
16464
16465
  */
16465
- this.setErrorMessage = (errorMessage) => {
16466
+ this.setErrorMessage = (fromSetErrorContext = false) => {
16467
+ // Set error message
16466
16468
  this.errorMessage = undefined;
16467
- if (this.valid)
16468
- return;
16469
- else if (isValidString(errorMessage)) {
16470
- this.errorMessage = errorMessage;
16471
- }
16472
- else if (this.required && this.isEmpty()) {
16473
- this.errorMessage = this.messages.errors.required;
16474
- }
16475
- else if (!this.getPatternValidity()) {
16476
- this.errorMessage = this.patternErrorMessage;
16469
+ // Does have a new custom error message
16470
+ if (!this.valid) {
16471
+ // Does have a new custom error message OR does have a custom error message locked
16472
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
16473
+ this.errorMessage = this.customErrorMessage.message;
16474
+ }
16475
+ else if (this.required && this.isEmpty()) {
16476
+ this.errorMessage = this.messages.errors.required;
16477
+ }
16478
+ else if (!this.getPatternValidity()) {
16479
+ this.errorMessage = this.patternErrorMessage;
16480
+ }
16477
16481
  }
16478
16482
  };
16479
16483
  /**
@@ -16601,17 +16605,22 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
16601
16605
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
16602
16606
  * @param valid - value indicating the validity
16603
16607
  * @param errorMessage - the error message to display
16608
+ * @param errorMessageLock - lock the error message and validity state
16604
16609
  */
16605
- async setError(valid, errorMessage) {
16610
+ async setError(valid, errorMessage, errorMessageLock = false) {
16606
16611
  if (typeof valid !== 'boolean') {
16607
16612
  throw new Error('<mg-input-rich-text-editor> method "setError()" param "valid" must be a boolean.');
16608
16613
  }
16609
- else if (!isValidString(errorMessage)) {
16614
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
16610
16615
  throw new Error('<mg-input-rich-text-editor> method "setError()" param "errorMessage" must be a string.');
16611
16616
  }
16612
16617
  else {
16618
+ this.customErrorMessage = {
16619
+ lock: valid ? false : errorMessageLock,
16620
+ message: valid ? undefined : errorMessage,
16621
+ };
16613
16622
  this.setValidity(valid);
16614
- this.setErrorMessage(valid ? undefined : errorMessage);
16623
+ this.setErrorMessage(true);
16615
16624
  this.hasDisplayedError = this.invalid;
16616
16625
  }
16617
16626
  }
@@ -16630,6 +16639,8 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
16630
16639
  // - Keep everything in sync both inside and outside the component
16631
16640
  return new Promise(resolve => {
16632
16641
  requestAnimationFrame(() => {
16642
+ // unlock validity check by reseting customErrorMessage
16643
+ this.customErrorMessage = { lock: false };
16633
16644
  this.checkValidity();
16634
16645
  this.errorMessage = undefined;
16635
16646
  this.hasDisplayedError = false;
@@ -16643,10 +16654,12 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
16643
16654
  * @param newValue - valid new value
16644
16655
  */
16645
16656
  setValidity(newValue) {
16646
- const oldValidValue = this.valid;
16647
- this.valid = newValue;
16657
+ const oldValue = this.valid;
16658
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
16659
+ this.valid = newValue;
16660
+ }
16648
16661
  this.invalid = !this.valid;
16649
- if (this.valid !== oldValidValue) {
16662
+ if (this.valid !== oldValue) {
16650
16663
  this.inputValid.emit(this.valid);
16651
16664
  }
16652
16665
  }
@@ -16695,7 +16708,7 @@ const MgInputRichTextEditor$1 = /*@__PURE__*/ proxyCustomElement(class MgInputRi
16695
16708
  * @returns HTML mg-input Element
16696
16709
  */
16697
16710
  render() {
16698
- return (h("mg-input", { key: 'b7f7fe282aa00b695418fe7f055955045bbd932d', identifier: this.identifier, class: this.classCollection.join(), label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, helpText: this.helpText, errorMessage: this.hasDisplayedError ? this.errorMessage : undefined }, this.readonly ? (h("div", { class: "mg-c-input__readonly-value", innerHTML: this.value })) : (h("div", { ref: el => {
16711
+ return (h("mg-input", { key: '2f8f244cb60996c9cbe891b04168b5aea420d3a0', identifier: this.identifier, class: this.classCollection.join(), label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, helpText: this.helpText, errorMessage: this.hasDisplayedError ? this.errorMessage : undefined }, this.readonly ? (h("div", { class: "mg-c-input__readonly-value", innerHTML: this.value })) : (h("div", { ref: el => {
16699
16712
  this.wrapperElement = el;
16700
16713
  }, id: this.identifier, class: "mg-c-input__wrapper" }, h("div", null)))));
16701
16714
  }
@@ -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__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{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
@@ -50,6 +50,7 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
50
50
  this.classIsAppendInputSlotContent = 'mg-c-input--is-append-input-slot-content';
51
51
  // hasDisplayedError (triggered by blur event)
52
52
  this.hasDisplayedError = false;
53
+ this.customErrorMessage = { lock: false };
53
54
  /**
54
55
  * Input name
55
56
  * If not set the value equals the identifier
@@ -148,27 +149,29 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
148
149
  };
149
150
  /**
150
151
  * Set input error message
151
- * @param errorMessage - errorMessage override
152
+ * @param fromSetErrorContext - context come from `setError` method
152
153
  */
153
- this.setErrorMessage = (errorMessage) => {
154
+ this.setErrorMessage = (fromSetErrorContext = false) => {
154
155
  var _a;
155
156
  // Set error message
156
157
  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;
158
+ if (!this.valid) {
159
+ // Does have a new custom error message OR does have a custom error message locked
160
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
161
+ this.errorMessage = this.customErrorMessage.message;
162
+ }
163
+ // Does not match type (email, emails, tel, url, etc.)
164
+ else if (this.input.validity.typeMismatch) {
165
+ this.errorMessage = this.messages.input.text.errors.typeMismatch[this.type];
166
+ }
167
+ // Does not match pattern
168
+ else if (this.input.validity.patternMismatch) {
169
+ this.errorMessage = (_a = this.patternErrorMessage) !== null && _a !== void 0 ? _a : this.messages.input.text.errors.typeMismatch[this.type];
170
+ }
171
+ // required
172
+ else if (this.input.validity.valueMissing) {
173
+ this.errorMessage = this.messages.errors.required;
174
+ }
172
175
  }
173
176
  };
174
177
  /**
@@ -302,17 +305,22 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
302
305
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
303
306
  * @param valid - value indicating the validity
304
307
  * @param errorMessage - the error message to display
308
+ * @param errorMessageLock - lock the error message and validity state
305
309
  */
306
- async setError(valid, errorMessage) {
310
+ async setError(valid, errorMessage, errorMessageLock = false) {
307
311
  if (typeof valid !== 'boolean') {
308
312
  throw new Error('<mg-input-text> method "setError()" param "valid" must be a boolean.');
309
313
  }
310
- else if (!isValidString(errorMessage)) {
314
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
311
315
  throw new Error('<mg-input-text> method "setError()" param "errorMessage" must be a string.');
312
316
  }
313
317
  else {
318
+ this.customErrorMessage = {
319
+ lock: valid ? false : errorMessageLock,
320
+ message: valid ? undefined : errorMessage,
321
+ };
314
322
  this.setValidity(valid);
315
- this.setErrorMessage(valid ? undefined : errorMessage);
323
+ this.setErrorMessage(true);
316
324
  this.hasDisplayedError = this.invalid;
317
325
  }
318
326
  }
@@ -330,6 +338,8 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
330
338
  // - Keep everything in sync both inside and outside the component
331
339
  return new Promise(resolve => {
332
340
  requestAnimationFrame(() => {
341
+ // unlock validity check by reseting customErrorMessage
342
+ this.customErrorMessage = { lock: false };
333
343
  this.checkValidity();
334
344
  this.errorMessage = undefined;
335
345
  this.hasDisplayedError = false;
@@ -343,11 +353,13 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
343
353
  * @param newValue - valid new value
344
354
  */
345
355
  setValidity(newValue) {
346
- const oldValidValue = this.valid;
347
- this.valid = newValue;
356
+ const oldValue = this.valid;
357
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
358
+ this.valid = newValue;
359
+ }
348
360
  this.invalid = !this.valid;
349
361
  // We need to send valid event even if it is the same value
350
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
362
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
351
363
  this.inputValid.emit(this.valid);
352
364
  }
353
365
  /*************
@@ -384,7 +396,7 @@ const MgInputText = /*@__PURE__*/ proxyCustomElement(class MgInputText extends H
384
396
  * @returns HTML Element
385
397
  */
386
398
  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
399
+ return (h("mg-input", { key: '69e40a90a6e4be8aa1eb3ac1b53acfe899c20453', 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
400
  ? this.value && this.renderReadonly()
389
401
  : [
390
402
  h("div", { key: "input", class: "mg-c-input__with-character-left", style: {
@@ -27,6 +27,7 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
27
27
  this.classDisplayCharacterLeft = 'mg-c-input--display-character-left';
28
28
  // hasDisplayedError (triggered by blur event)
29
29
  this.hasDisplayedError = false;
30
+ this.customErrorMessage = { lock: false };
30
31
  /**
31
32
  * Input name
32
33
  * If not set the value equals the identifier
@@ -125,15 +126,16 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
125
126
  };
126
127
  /**
127
128
  * Set input error message
128
- * @param errorMessage - errorMessage override
129
+ * @param fromSetErrorContext - context come from `setError` method
129
130
  */
130
- this.setErrorMessage = (errorMessage) => {
131
+ this.setErrorMessage = (fromSetErrorContext = false) => {
131
132
  // Set error message
132
133
  this.errorMessage = undefined;
133
- // Does not match pattern
134
+ // Does have a new custom error message
134
135
  if (!this.valid) {
135
- if (errorMessage !== undefined) {
136
- this.errorMessage = errorMessage;
136
+ // Does have a new custom error message OR does have a custom error message locked
137
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
138
+ this.errorMessage = this.customErrorMessage.message;
137
139
  }
138
140
  else if (!this.getPatternValidity()) {
139
141
  this.errorMessage = this.patternErrorMessage;
@@ -226,17 +228,22 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
226
228
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
227
229
  * @param valid - value indicating the validity
228
230
  * @param errorMessage - the error message to display
231
+ * @param errorMessageLock - lock the error message and validity state
229
232
  */
230
- async setError(valid, errorMessage) {
233
+ async setError(valid, errorMessage, errorMessageLock = false) {
231
234
  if (typeof valid !== 'boolean') {
232
235
  throw new Error('<mg-input-textarea> method "setError()" param "valid" must be a boolean.');
233
236
  }
234
- else if (!isValidString(errorMessage)) {
237
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
235
238
  throw new Error('<mg-input-textarea> method "setError()" param "errorMessage" must be a string.');
236
239
  }
237
240
  else {
241
+ this.customErrorMessage = {
242
+ lock: valid ? false : errorMessageLock,
243
+ message: valid ? undefined : errorMessage,
244
+ };
238
245
  this.setValidity(valid);
239
- this.setErrorMessage(valid ? undefined : errorMessage);
246
+ this.setErrorMessage(true);
240
247
  this.hasDisplayedError = this.invalid;
241
248
  }
242
249
  }
@@ -254,6 +261,8 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
254
261
  // - Keep everything in sync both inside and outside the component
255
262
  return new Promise(resolve => {
256
263
  requestAnimationFrame(() => {
264
+ // unlock validity check by reseting customErrorMessage
265
+ this.customErrorMessage = { lock: false };
257
266
  this.checkValidity();
258
267
  this.errorMessage = undefined;
259
268
  this.hasDisplayedError = false;
@@ -267,11 +276,13 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
267
276
  * @param newValue - valid new value
268
277
  */
269
278
  setValidity(newValue) {
270
- const oldValidValue = this.valid;
271
- this.valid = newValue;
279
+ const oldValue = this.valid;
280
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
281
+ this.valid = newValue;
282
+ }
272
283
  this.invalid = !this.valid;
273
284
  // We need to send valid event even if it is the same value
274
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
285
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
275
286
  this.inputValid.emit(this.valid);
276
287
  }
277
288
  /*************
@@ -304,7 +315,7 @@ const MgInputTextarea$1 = /*@__PURE__*/ proxyCustomElement(class MgInputTextarea
304
315
  * @returns HTML Element
305
316
  */
306
317
  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: {
318
+ return (h("mg-input", { key: '9b58ccb9f0b150f5de8cc9f895f4cdea2bbbeecd', 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: {
308
319
  'mg-c-input__box': true,
309
320
  'mg-c-input__box--width': true,
310
321
  'mg-c-input__box--resizable': this.resizable === 'both',