@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
@@ -6,6 +6,7 @@ export class MgInputPassword {
6
6
  constructor() {
7
7
  // hasDisplayedError (triggered by blur event)
8
8
  this.hasDisplayedError = false;
9
+ this.customErrorMessage = { lock: false };
9
10
  /**
10
11
  * Input name
11
12
  * If not set the value equals the identifier
@@ -81,14 +82,15 @@ export class MgInputPassword {
81
82
  };
82
83
  /**
83
84
  * Set input error message
84
- * @param errorMessage - errorMessage override
85
+ * @param fromSetErrorContext - context come from `setError` method
85
86
  */
86
- this.setErrorMessage = (errorMessage) => {
87
+ this.setErrorMessage = (fromSetErrorContext = false) => {
87
88
  // Set error message
88
89
  this.errorMessage = undefined;
89
90
  if (!this.valid) {
90
- if (errorMessage !== undefined) {
91
- this.errorMessage = errorMessage;
91
+ // Does have a new custom error message OR does have a custom error message locked
92
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
93
+ this.errorMessage = this.customErrorMessage.message;
92
94
  }
93
95
  // required
94
96
  else if (this.input.validity.valueMissing) {
@@ -164,17 +166,22 @@ export class MgInputPassword {
164
166
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
165
167
  * @param valid - value indicating the validity
166
168
  * @param errorMessage - the error message to display
169
+ * @param errorMessageLock - lock the error message and validity state
167
170
  */
168
- async setError(valid, errorMessage) {
171
+ async setError(valid, errorMessage, errorMessageLock = false) {
169
172
  if (typeof valid !== 'boolean') {
170
173
  throw new Error('<mg-input-password> method "setError()" param "valid" must be a boolean.');
171
174
  }
172
- else if (!isValidString(errorMessage)) {
175
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
173
176
  throw new Error('<mg-input-password> method "setError()" param "errorMessage" must be a string.');
174
177
  }
175
178
  else {
179
+ this.customErrorMessage = {
180
+ lock: valid ? false : errorMessageLock,
181
+ message: valid ? undefined : errorMessage,
182
+ };
176
183
  this.setValidity(valid);
177
- this.setErrorMessage(valid ? undefined : errorMessage);
184
+ this.setErrorMessage(true);
178
185
  this.hasDisplayedError = this.invalid;
179
186
  }
180
187
  }
@@ -192,6 +199,8 @@ export class MgInputPassword {
192
199
  // - Keep everything in sync both inside and outside the component
193
200
  return new Promise(resolve => {
194
201
  requestAnimationFrame(() => {
202
+ // unlock validity check by reseting customErrorMessage
203
+ this.customErrorMessage = { lock: false };
195
204
  this.checkValidity();
196
205
  this.errorMessage = undefined;
197
206
  this.hasDisplayedError = false;
@@ -205,11 +214,13 @@ export class MgInputPassword {
205
214
  * @param newValue - valid new value
206
215
  */
207
216
  setValidity(newValue) {
208
- const oldValidValue = this.valid;
209
- this.valid = newValue;
217
+ const oldValue = this.valid;
218
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
219
+ this.valid = newValue;
220
+ }
210
221
  this.invalid = !this.valid;
211
222
  // We need to send valid event even if it is the same value
212
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
223
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
213
224
  this.inputValid.emit(this.valid);
214
225
  }
215
226
  /*************
@@ -237,7 +248,7 @@ export class MgInputPassword {
237
248
  * @returns HTML Element
238
249
  */
239
250
  render() {
240
- return (h("mg-input", { key: '4bdaa6d26811f66fa43b580ac6e85c61b308ee92', 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 === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.value !== undefined && h("b", { class: "mg-c-input__readonly-value" }, '•'.repeat(this.value.length))) : (h("span", { class: "mg-c-input__input-group" }, h("input", { type: this.displayPassword ? 'text' : 'password', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, maxlength: this.maxlength, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
251
+ return (h("mg-input", { key: '845c075a44c50043776b7577642254d772629eef', 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 === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.value !== undefined && h("b", { class: "mg-c-input__readonly-value" }, '•'.repeat(this.value.length))) : (h("span", { class: "mg-c-input__input-group" }, h("input", { type: this.displayPassword ? 'text' : 'password', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, maxlength: this.maxlength, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
241
252
  if (el !== null)
242
253
  this.input = el;
243
254
  } }), h("mg-button", { label: this.messages.input.password[this.displayPassword ? 'hide' : 'display'], disabled: this.disabled, variant: "flat", class: "mg-c-input__append-button", "is-icon": true, onClick: this.toggleDisplayPassword, "aria-controls": this.identifier }, h("mg-icon", { class: "mg-c-input__input-icon", icon: this.displayPassword ? 'eye-slash' : 'eye' }))))));
@@ -689,7 +700,7 @@ export class MgInputPassword {
689
700
  },
690
701
  "setError": {
691
702
  "complexType": {
692
- "signature": "(valid: MgInputPassword[\"valid\"], errorMessage: string) => Promise<void>",
703
+ "signature": "(valid: MgInputPassword[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
693
704
  "parameters": [{
694
705
  "name": "valid",
695
706
  "type": "boolean",
@@ -698,6 +709,10 @@ export class MgInputPassword {
698
709
  "name": "errorMessage",
699
710
  "type": "string",
700
711
  "docs": "- the error message to display"
712
+ }, {
713
+ "name": "errorMessageLock",
714
+ "type": "boolean",
715
+ "docs": "- lock the error message and validity state"
701
716
  }],
702
717
  "references": {
703
718
  "Promise": {
@@ -719,6 +734,9 @@ export class MgInputPassword {
719
734
  }, {
720
735
  "name": "param",
721
736
  "text": "errorMessage - the error message to display"
737
+ }, {
738
+ "name": "param",
739
+ "text": "errorMessageLock - lock the error message and validity state"
722
740
  }]
723
741
  }
724
742
  },
@@ -19,6 +19,7 @@ export class MgInputRadio {
19
19
  this.classVerticalList = 'mg-c-input--vertical-list';
20
20
  // hasDisplayedError (triggered by blur event)
21
21
  this.hasDisplayedError = false;
22
+ this.customErrorMessage = { lock: false };
22
23
  /**
23
24
  * Input name
24
25
  * If not set the value equals the identifier
@@ -82,16 +83,18 @@ export class MgInputRadio {
82
83
  };
83
84
  /**
84
85
  * Set input error message
85
- * @param errorMessage - errorMessage override
86
+ * @param fromSetErrorContext - context come from `setError` method
86
87
  */
87
- this.setErrorMessage = (errorMessage) => {
88
+ this.setErrorMessage = (fromSetErrorContext = false) => {
88
89
  const invalidElement = this.getInvalidElement();
89
90
  // Set error message
90
91
  this.errorMessage = undefined;
91
92
  if (!this.valid) {
92
- if (errorMessage !== undefined) {
93
- this.errorMessage = errorMessage;
93
+ // Does have a new custom error message OR does have a custom error message locked
94
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
95
+ this.errorMessage = this.customErrorMessage.message;
94
96
  }
97
+ // required
95
98
  else if (invalidElement.validity.valueMissing) {
96
99
  this.errorMessage = this.messages.errors.required;
97
100
  }
@@ -196,17 +199,22 @@ export class MgInputRadio {
196
199
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
197
200
  * @param valid - value indicating the validity
198
201
  * @param errorMessage - the error message to display
202
+ * @param errorMessageLock - lock the error message and validity state
199
203
  */
200
- async setError(valid, errorMessage) {
204
+ async setError(valid, errorMessage, errorMessageLock = false) {
201
205
  if (typeof valid !== 'boolean') {
202
206
  throw new Error('<mg-input-radio> method "setError()" param "valid" must be a boolean.');
203
207
  }
204
- else if (!isValidString(errorMessage)) {
208
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
205
209
  throw new Error('<mg-input-radio> method "setError()" param "errorMessage" must be a string.');
206
210
  }
207
211
  else {
212
+ this.customErrorMessage = {
213
+ lock: valid ? false : errorMessageLock,
214
+ message: valid ? undefined : errorMessage,
215
+ };
208
216
  this.setValidity(valid);
209
- this.setErrorMessage(valid ? undefined : errorMessage);
217
+ this.setErrorMessage(true);
210
218
  this.hasDisplayedError = this.invalid;
211
219
  }
212
220
  }
@@ -224,6 +232,8 @@ export class MgInputRadio {
224
232
  // - Keep everything in sync both inside and outside the component
225
233
  return new Promise(resolve => {
226
234
  requestAnimationFrame(() => {
235
+ // unlock validity check by reseting customErrorMessage
236
+ this.customErrorMessage = { lock: false };
227
237
  this.checkValidity();
228
238
  this.errorMessage = undefined;
229
239
  this.hasDisplayedError = false;
@@ -237,11 +247,13 @@ export class MgInputRadio {
237
247
  * @param newValue - valid new value
238
248
  */
239
249
  setValidity(newValue) {
240
- const oldValidValue = this.valid;
241
- this.valid = newValue;
250
+ const oldValue = this.valid;
251
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
252
+ this.valid = newValue;
253
+ }
242
254
  this.invalid = !this.valid;
243
255
  // We need to send valid event even if it is the same value
244
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
256
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
245
257
  this.inputValid.emit(this.valid);
246
258
  }
247
259
  /*************
@@ -272,7 +284,7 @@ export class MgInputRadio {
272
284
  * @returns HTML Element
273
285
  */
274
286
  render() {
275
- 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) => {
287
+ 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) => {
276
288
  if (el !== null)
277
289
  this.inputs[index] = el;
278
290
  } }), h("label", { htmlFor: this.identifier + '_' + index }, input.title))))))));
@@ -704,7 +716,7 @@ export class MgInputRadio {
704
716
  },
705
717
  "setError": {
706
718
  "complexType": {
707
- "signature": "(valid: MgInputRadio[\"valid\"], errorMessage: string) => Promise<void>",
719
+ "signature": "(valid: MgInputRadio[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
708
720
  "parameters": [{
709
721
  "name": "valid",
710
722
  "type": "boolean",
@@ -713,6 +725,10 @@ export class MgInputRadio {
713
725
  "name": "errorMessage",
714
726
  "type": "string",
715
727
  "docs": "- the error message to display"
728
+ }, {
729
+ "name": "errorMessageLock",
730
+ "type": "boolean",
731
+ "docs": "- lock the error message and validity state"
716
732
  }],
717
733
  "references": {
718
734
  "Promise": {
@@ -734,6 +750,9 @@ export class MgInputRadio {
734
750
  }, {
735
751
  "name": "param",
736
752
  "text": "errorMessage - the error message to display"
753
+ }, {
754
+ "name": "param",
755
+ "text": "errorMessageLock - lock the error message and validity state"
737
756
  }]
738
757
  }
739
758
  },
@@ -7,6 +7,7 @@ export class MgInputRichTextEditor {
7
7
  constructor() {
8
8
  // hasDisplayedError (triggered by blur event)
9
9
  this.hasDisplayedError = false;
10
+ this.customErrorMessage = { lock: false };
10
11
  // Classes
11
12
  this.classFocus = 'mg-u-is-focused';
12
13
  /**
@@ -72,20 +73,23 @@ export class MgInputRichTextEditor {
72
73
  };
73
74
  /**
74
75
  * Set input error message
75
- * @param errorMessage - errorMessage override
76
+ * @param fromSetErrorContext - context come from `setError` method
76
77
  */
77
- this.setErrorMessage = (errorMessage) => {
78
+ this.setErrorMessage = (fromSetErrorContext = false) => {
79
+ // Set error message
78
80
  this.errorMessage = undefined;
79
- if (this.valid)
80
- return;
81
- else if (isValidString(errorMessage)) {
82
- this.errorMessage = errorMessage;
83
- }
84
- else if (this.required && this.isEmpty()) {
85
- this.errorMessage = this.messages.errors.required;
86
- }
87
- else if (!this.getPatternValidity()) {
88
- this.errorMessage = this.patternErrorMessage;
81
+ // Does have a new custom error message
82
+ if (!this.valid) {
83
+ // Does have a new custom error message OR does have a custom error message locked
84
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
85
+ this.errorMessage = this.customErrorMessage.message;
86
+ }
87
+ else if (this.required && this.isEmpty()) {
88
+ this.errorMessage = this.messages.errors.required;
89
+ }
90
+ else if (!this.getPatternValidity()) {
91
+ this.errorMessage = this.patternErrorMessage;
92
+ }
89
93
  }
90
94
  };
91
95
  /**
@@ -213,17 +217,22 @@ export class MgInputRichTextEditor {
213
217
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
214
218
  * @param valid - value indicating the validity
215
219
  * @param errorMessage - the error message to display
220
+ * @param errorMessageLock - lock the error message and validity state
216
221
  */
217
- async setError(valid, errorMessage) {
222
+ async setError(valid, errorMessage, errorMessageLock = false) {
218
223
  if (typeof valid !== 'boolean') {
219
224
  throw new Error('<mg-input-rich-text-editor> method "setError()" param "valid" must be a boolean.');
220
225
  }
221
- else if (!isValidString(errorMessage)) {
226
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
222
227
  throw new Error('<mg-input-rich-text-editor> method "setError()" param "errorMessage" must be a string.');
223
228
  }
224
229
  else {
230
+ this.customErrorMessage = {
231
+ lock: valid ? false : errorMessageLock,
232
+ message: valid ? undefined : errorMessage,
233
+ };
225
234
  this.setValidity(valid);
226
- this.setErrorMessage(valid ? undefined : errorMessage);
235
+ this.setErrorMessage(true);
227
236
  this.hasDisplayedError = this.invalid;
228
237
  }
229
238
  }
@@ -242,6 +251,8 @@ export class MgInputRichTextEditor {
242
251
  // - Keep everything in sync both inside and outside the component
243
252
  return new Promise(resolve => {
244
253
  requestAnimationFrame(() => {
254
+ // unlock validity check by reseting customErrorMessage
255
+ this.customErrorMessage = { lock: false };
245
256
  this.checkValidity();
246
257
  this.errorMessage = undefined;
247
258
  this.hasDisplayedError = false;
@@ -255,10 +266,12 @@ export class MgInputRichTextEditor {
255
266
  * @param newValue - valid new value
256
267
  */
257
268
  setValidity(newValue) {
258
- const oldValidValue = this.valid;
259
- this.valid = newValue;
269
+ const oldValue = this.valid;
270
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
271
+ this.valid = newValue;
272
+ }
260
273
  this.invalid = !this.valid;
261
- if (this.valid !== oldValidValue) {
274
+ if (this.valid !== oldValue) {
262
275
  this.inputValid.emit(this.valid);
263
276
  }
264
277
  }
@@ -308,7 +321,7 @@ export class MgInputRichTextEditor {
308
321
  * @returns HTML mg-input Element
309
322
  */
310
323
  render() {
311
- 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 => {
324
+ 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 => {
312
325
  this.wrapperElement = el;
313
326
  }, id: this.identifier, class: "mg-c-input__wrapper" }, h("div", null)))));
314
327
  }
@@ -805,7 +818,7 @@ export class MgInputRichTextEditor {
805
818
  },
806
819
  "setError": {
807
820
  "complexType": {
808
- "signature": "(valid: MgInputRichTextEditor[\"valid\"], errorMessage: string) => Promise<void>",
821
+ "signature": "(valid: MgInputRichTextEditor[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
809
822
  "parameters": [{
810
823
  "name": "valid",
811
824
  "type": "boolean",
@@ -814,6 +827,10 @@ export class MgInputRichTextEditor {
814
827
  "name": "errorMessage",
815
828
  "type": "string",
816
829
  "docs": "- the error message to display"
830
+ }, {
831
+ "name": "errorMessageLock",
832
+ "type": "boolean",
833
+ "docs": "- lock the error message and validity state"
817
834
  }],
818
835
  "references": {
819
836
  "Promise": {
@@ -835,6 +852,9 @@ export class MgInputRichTextEditor {
835
852
  }, {
836
853
  "name": "param",
837
854
  "text": "errorMessage - the error message to display"
855
+ }, {
856
+ "name": "param",
857
+ "text": "errorMessageLock - lock the error message and validity state"
838
858
  }]
839
859
  }
840
860
  },
@@ -48,6 +48,7 @@ export class MgInputSelect {
48
48
  constructor() {
49
49
  // hasDisplayedError (triggered by blur event)
50
50
  this.hasDisplayedError = false;
51
+ this.customErrorMessage = { lock: false };
51
52
  /**
52
53
  * Input name
53
54
  * If not set the value equals the identifier
@@ -156,15 +157,17 @@ export class MgInputSelect {
156
157
  };
157
158
  /**
158
159
  * Set input error message
159
- * @param errorMessage - errorMessage override
160
+ * @param fromSetErrorContext - context come from `setError` method
160
161
  */
161
- this.setErrorMessage = (errorMessage) => {
162
+ this.setErrorMessage = (fromSetErrorContext = false) => {
162
163
  // Set error message
163
164
  this.errorMessage = undefined;
164
165
  if (!this.valid) {
165
- if (errorMessage !== undefined) {
166
- this.errorMessage = errorMessage;
166
+ // Does have a new custom error message OR does have a custom error message locked
167
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
168
+ this.errorMessage = this.customErrorMessage.message;
167
169
  }
170
+ // required
168
171
  else if (this.input.validity.valueMissing) {
169
172
  this.errorMessage = this.messages.errors.required;
170
173
  }
@@ -278,17 +281,22 @@ export class MgInputSelect {
278
281
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
279
282
  * @param valid - value indicating the validity
280
283
  * @param errorMessage - the error message to display
284
+ * @param errorMessageLock - lock the error message and validity state
281
285
  */
282
- async setError(valid, errorMessage) {
286
+ async setError(valid, errorMessage, errorMessageLock = false) {
283
287
  if (typeof valid !== 'boolean') {
284
288
  throw new Error('<mg-input-select> method "setError()" param "valid" must be a boolean.');
285
289
  }
286
- else if (!isValidString(errorMessage)) {
290
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
287
291
  throw new Error('<mg-input-select> method "setError()" param "errorMessage" must be a string.');
288
292
  }
289
293
  else {
294
+ this.customErrorMessage = {
295
+ lock: valid ? false : errorMessageLock,
296
+ message: valid ? undefined : errorMessage,
297
+ };
290
298
  this.setValidity(valid);
291
- this.setErrorMessage(valid ? undefined : errorMessage);
299
+ this.setErrorMessage(true);
292
300
  this.hasDisplayedError = this.invalid;
293
301
  }
294
302
  }
@@ -306,6 +314,8 @@ export class MgInputSelect {
306
314
  // - Keep everything in sync both inside and outside the component
307
315
  return new Promise(resolve => {
308
316
  requestAnimationFrame(() => {
317
+ // unlock validity check by reseting customErrorMessage
318
+ this.customErrorMessage = { lock: false };
309
319
  this.checkValidity();
310
320
  this.errorMessage = undefined;
311
321
  this.hasDisplayedError = false;
@@ -319,11 +329,13 @@ export class MgInputSelect {
319
329
  * @param newValue - valid new value
320
330
  */
321
331
  setValidity(newValue) {
322
- const oldValidValue = this.valid;
323
- this.valid = newValue;
332
+ const oldValue = this.valid;
333
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
334
+ this.valid = newValue;
335
+ }
324
336
  this.invalid = !this.valid;
325
337
  // We need to send valid event even if it is the same value
326
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue)) {
338
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue)) {
327
339
  this.inputValid.emit(this.valid);
328
340
  }
329
341
  }
@@ -360,7 +372,7 @@ export class MgInputSelect {
360
372
  */
361
373
  render() {
362
374
  const readonlyValue = this.getReadonlyValue();
363
- 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) => {
375
+ 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) => {
364
376
  if (el !== null)
365
377
  this.input = el;
366
378
  } }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
@@ -857,7 +869,7 @@ export class MgInputSelect {
857
869
  },
858
870
  "setError": {
859
871
  "complexType": {
860
- "signature": "(valid: MgInputSelect[\"valid\"], errorMessage: string) => Promise<void>",
872
+ "signature": "(valid: MgInputSelect[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
861
873
  "parameters": [{
862
874
  "name": "valid",
863
875
  "type": "boolean",
@@ -866,6 +878,10 @@ export class MgInputSelect {
866
878
  "name": "errorMessage",
867
879
  "type": "string",
868
880
  "docs": "- the error message to display"
881
+ }, {
882
+ "name": "errorMessageLock",
883
+ "type": "boolean",
884
+ "docs": "- lock the error message and validity state"
869
885
  }],
870
886
  "references": {
871
887
  "Promise": {
@@ -887,6 +903,9 @@ export class MgInputSelect {
887
903
  }, {
888
904
  "name": "param",
889
905
  "text": "errorMessage - the error message to display"
906
+ }, {
907
+ "name": "param",
908
+ "text": "errorMessageLock - lock the error message and validity state"
890
909
  }]
891
910
  }
892
911
  },
@@ -31,6 +31,7 @@ export class MgInputText {
31
31
  this.classIsAppendInputSlotContent = 'mg-c-input--is-append-input-slot-content';
32
32
  // hasDisplayedError (triggered by blur event)
33
33
  this.hasDisplayedError = false;
34
+ this.customErrorMessage = { lock: false };
34
35
  /**
35
36
  * Input name
36
37
  * If not set the value equals the identifier
@@ -129,27 +130,29 @@ export class MgInputText {
129
130
  };
130
131
  /**
131
132
  * Set input error message
132
- * @param errorMessage - errorMessage override
133
+ * @param fromSetErrorContext - context come from `setError` method
133
134
  */
134
- this.setErrorMessage = (errorMessage) => {
135
+ this.setErrorMessage = (fromSetErrorContext = false) => {
135
136
  var _a;
136
137
  // Set error message
137
138
  this.errorMessage = undefined;
138
- // Does have a custom error message
139
- if (!this.valid && errorMessage !== undefined) {
140
- this.errorMessage = errorMessage;
141
- }
142
- // Does not match type (email, emails, tel, url, etc.)
143
- else if (!this.valid && this.input.validity.typeMismatch) {
144
- this.errorMessage = this.messages.input.text.errors.typeMismatch[this.type];
145
- }
146
- // Does not match pattern
147
- else if (!this.valid && this.input.validity.patternMismatch) {
148
- this.errorMessage = (_a = this.patternErrorMessage) !== null && _a !== void 0 ? _a : this.messages.input.text.errors.typeMismatch[this.type];
149
- }
150
- // required
151
- else if (!this.valid && this.input.validity.valueMissing) {
152
- this.errorMessage = this.messages.errors.required;
139
+ if (!this.valid) {
140
+ // Does have a new custom error message OR does have a custom error message locked
141
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
142
+ this.errorMessage = this.customErrorMessage.message;
143
+ }
144
+ // Does not match type (email, emails, tel, url, etc.)
145
+ else if (this.input.validity.typeMismatch) {
146
+ this.errorMessage = this.messages.input.text.errors.typeMismatch[this.type];
147
+ }
148
+ // Does not match pattern
149
+ else if (this.input.validity.patternMismatch) {
150
+ this.errorMessage = (_a = this.patternErrorMessage) !== null && _a !== void 0 ? _a : this.messages.input.text.errors.typeMismatch[this.type];
151
+ }
152
+ // required
153
+ else if (this.input.validity.valueMissing) {
154
+ this.errorMessage = this.messages.errors.required;
155
+ }
153
156
  }
154
157
  };
155
158
  /**
@@ -283,17 +286,22 @@ export class MgInputText {
283
286
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
284
287
  * @param valid - value indicating the validity
285
288
  * @param errorMessage - the error message to display
289
+ * @param errorMessageLock - lock the error message and validity state
286
290
  */
287
- async setError(valid, errorMessage) {
291
+ async setError(valid, errorMessage, errorMessageLock = false) {
288
292
  if (typeof valid !== 'boolean') {
289
293
  throw new Error('<mg-input-text> method "setError()" param "valid" must be a boolean.');
290
294
  }
291
- else if (!isValidString(errorMessage)) {
295
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
292
296
  throw new Error('<mg-input-text> method "setError()" param "errorMessage" must be a string.');
293
297
  }
294
298
  else {
299
+ this.customErrorMessage = {
300
+ lock: valid ? false : errorMessageLock,
301
+ message: valid ? undefined : errorMessage,
302
+ };
295
303
  this.setValidity(valid);
296
- this.setErrorMessage(valid ? undefined : errorMessage);
304
+ this.setErrorMessage(true);
297
305
  this.hasDisplayedError = this.invalid;
298
306
  }
299
307
  }
@@ -311,6 +319,8 @@ export class MgInputText {
311
319
  // - Keep everything in sync both inside and outside the component
312
320
  return new Promise(resolve => {
313
321
  requestAnimationFrame(() => {
322
+ // unlock validity check by reseting customErrorMessage
323
+ this.customErrorMessage = { lock: false };
314
324
  this.checkValidity();
315
325
  this.errorMessage = undefined;
316
326
  this.hasDisplayedError = false;
@@ -324,11 +334,13 @@ export class MgInputText {
324
334
  * @param newValue - valid new value
325
335
  */
326
336
  setValidity(newValue) {
327
- const oldValidValue = this.valid;
328
- this.valid = newValue;
337
+ const oldValue = this.valid;
338
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
339
+ this.valid = newValue;
340
+ }
329
341
  this.invalid = !this.valid;
330
342
  // We need to send valid event even if it is the same value
331
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
343
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
332
344
  this.inputValid.emit(this.valid);
333
345
  }
334
346
  /*************
@@ -365,7 +377,7 @@ export class MgInputText {
365
377
  * @returns HTML Element
366
378
  */
367
379
  render() {
368
- 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
380
+ 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
369
381
  ? this.value && this.renderReadonly()
370
382
  : [
371
383
  h("div", { key: "input", class: "mg-c-input__with-character-left", style: {
@@ -956,7 +968,7 @@ export class MgInputText {
956
968
  },
957
969
  "setError": {
958
970
  "complexType": {
959
- "signature": "(valid: MgInputText[\"valid\"], errorMessage: string) => Promise<void>",
971
+ "signature": "(valid: MgInputText[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
960
972
  "parameters": [{
961
973
  "name": "valid",
962
974
  "type": "boolean",
@@ -965,6 +977,10 @@ export class MgInputText {
965
977
  "name": "errorMessage",
966
978
  "type": "string",
967
979
  "docs": "- the error message to display"
980
+ }, {
981
+ "name": "errorMessageLock",
982
+ "type": "boolean",
983
+ "docs": "- lock the error message and validity state"
968
984
  }],
969
985
  "references": {
970
986
  "Promise": {
@@ -986,6 +1002,9 @@ export class MgInputText {
986
1002
  }, {
987
1003
  "name": "param",
988
1004
  "text": "errorMessage - the error message to display"
1005
+ }, {
1006
+ "name": "param",
1007
+ "text": "errorMessageLock - lock the error message and validity state"
989
1008
  }]
990
1009
  }
991
1010
  },