@mgdis/mg-components 6.17.0 → 6.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/cjs/{index-DCZEYvlH.js → index-Bp6wZzau.js} +5 -1
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/mg-action-more_37.cjs.entry.js +438 -212
  4. package/dist/cjs/mg-alert.cjs.entry.js +2 -2
  5. package/dist/cjs/mg-components.cjs.js +2 -2
  6. package/dist/cjs/mg-fieldset.cjs.entry.js +141 -0
  7. package/dist/cjs/mg-input-combobox.cjs.entry.js +93 -80
  8. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +35 -26
  9. package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-D7jmj_lh.js} +7 -0
  10. package/dist/cjs/mg-loader.cjs.entry.js +2 -2
  11. package/dist/cjs/mg-progress.cjs.entry.js +2 -2
  12. package/dist/collection/assets/icons/index.js +1 -1
  13. package/dist/collection/collection-manifest.json +1 -0
  14. package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
  15. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +5 -0
  16. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +178 -18
  17. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +1 -1
  18. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +36 -16
  19. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +98 -78
  20. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +41 -22
  21. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +32 -12
  22. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +30 -12
  23. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +31 -12
  24. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +41 -25
  25. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +31 -12
  26. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +60 -40
  27. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +35 -33
  28. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +36 -11
  29. package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +1 -1
  30. package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +5 -1
  31. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +2 -2
  32. package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
  33. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  34. package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +404 -0
  35. package/dist/collection/components/molecules/mg-form/mg-form.js +13 -4
  36. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
  37. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  38. package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
  39. package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
  40. package/dist/collection/components/molecules/mg-panel/mg-panel.js +40 -9
  41. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  42. package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
  43. package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
  44. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  45. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
  46. package/dist/components/mg-action-more.js +1 -1
  47. package/dist/components/mg-alert.js +1 -1
  48. package/dist/components/mg-details.js +1 -1
  49. package/dist/components/mg-fieldset.d.ts +11 -0
  50. package/dist/components/mg-fieldset.js +209 -0
  51. package/dist/components/mg-form.js +4 -3
  52. package/dist/components/mg-icon2.js +1 -1
  53. package/dist/components/mg-illustrated-message.js +2 -2
  54. package/dist/components/mg-input-checkbox-paginated2.js +1 -1
  55. package/dist/components/mg-input-checkbox.js +29 -16
  56. package/dist/components/mg-input-combobox.js +92 -79
  57. package/dist/components/mg-input-date.js +34 -22
  58. package/dist/components/mg-input-numeric.js +25 -12
  59. package/dist/components/mg-input-password.js +23 -12
  60. package/dist/components/mg-input-radio.js +23 -11
  61. package/dist/components/mg-input-rich-text-editor.js +33 -24
  62. package/dist/components/mg-input-select2.js +24 -12
  63. package/dist/components/mg-input-text2.js +51 -39
  64. package/dist/components/mg-input-textarea.js +28 -33
  65. package/dist/components/mg-input-toggle.js +35 -10
  66. package/dist/components/mg-input2.js +119 -19
  67. package/dist/components/mg-item-more2.js +5 -1
  68. package/dist/components/mg-loader2.js +1 -1
  69. package/dist/components/mg-message2.js +2 -2
  70. package/dist/components/mg-modal.js +3 -3
  71. package/dist/components/mg-panel.js +37 -8
  72. package/dist/components/mg-popover-content2.js +2 -2
  73. package/dist/components/mg-popover2.js +2 -2
  74. package/dist/components/mg-progress.js +1 -1
  75. package/dist/components/mg-skip-links.js +1 -1
  76. package/dist/components/mg-tabs2.js +1 -1
  77. package/dist/esm/{index-T6kOJXP1.js → index-BluNKQ3L.js} +5 -1
  78. package/dist/esm/{index-WtiuOkLj.js → index-C7xjtdiw.js} +1 -1
  79. package/dist/esm/loader.js +3 -3
  80. package/dist/esm/mg-action-more_37.entry.js +439 -213
  81. package/dist/esm/mg-alert.entry.js +3 -3
  82. package/dist/esm/mg-components.js +3 -3
  83. package/dist/esm/mg-fieldset.entry.js +139 -0
  84. package/dist/esm/mg-input-combobox.entry.js +94 -81
  85. package/dist/esm/mg-input-rich-text-editor.entry.js +36 -27
  86. package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-DDnrE1hD.js} +6 -1
  87. package/dist/esm/mg-loader.entry.js +3 -3
  88. package/dist/esm/mg-progress.entry.js +3 -3
  89. package/dist/mg-components/mg-components.css +1 -1
  90. package/dist/mg-components/mg-components.esm.js +1 -1
  91. package/dist/mg-components/p-016bd291.entry.js +1 -0
  92. package/dist/mg-components/{p-397bf67b.entry.js → p-186a6139.entry.js} +1 -1
  93. package/dist/mg-components/p-66a1cb83.entry.js +1 -0
  94. package/dist/mg-components/p-6efd819f.entry.js +1 -0
  95. package/dist/mg-components/{p-c5da335e.entry.js → p-916dfb6d.entry.js} +1 -1
  96. package/dist/mg-components/p-BluNKQ3L.js +2 -0
  97. package/dist/mg-components/{p-WtiuOkLj.js → p-C7xjtdiw.js} +1 -1
  98. package/dist/mg-components/p-DDnrE1hD.js +1 -0
  99. package/dist/mg-components/{p-0e6b40d6.entry.js → p-d2c72f09.entry.js} +1 -1
  100. package/dist/mg-components/{p-5dc3a1fb.entry.js → p-d5a276eb.entry.js} +1 -1
  101. package/dist/types/assets/icons/index.d.ts +9 -0
  102. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +6 -0
  103. package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +32 -1
  104. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -3
  105. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.d.ts +1 -0
  106. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +8 -7
  107. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -2
  108. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +4 -2
  109. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -2
  110. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
  111. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -3
  112. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -2
  113. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -7
  114. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -8
  115. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -2
  116. package/dist/types/components/molecules/mg-fieldset/mg-fieldset.d.ts +105 -0
  117. package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
  118. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +8 -1
  119. package/dist/types/components.d.ts +168 -18
  120. package/ide/intellij/web-types.json +289 -22
  121. package/ide/vscode/css-custom-data.json +7 -3
  122. package/ide/vscode/html-custom-data.json +300 -8
  123. package/package.json +18 -18
  124. package/dist/mg-components/p-8a69175b.entry.js +0 -1
  125. package/dist/mg-components/p-CNgv8hc5.js +0 -1
  126. package/dist/mg-components/p-T6kOJXP1.js +0 -2
  127. package/dist/mg-components/p-d84d87ea.entry.js +0 -1
@@ -11,6 +11,7 @@ export class MgInputNumeric {
11
11
  constructor() {
12
12
  // hasDisplayedError (triggered by blur event)
13
13
  this.hasDisplayedError = false;
14
+ this.customErrorMessage = { lock: false };
14
15
  /**
15
16
  * Input name
16
17
  * If not set the value equals the identifier
@@ -116,19 +117,22 @@ export class MgInputNumeric {
116
117
  this.formatErrorValue = (value) => localeNumber(value, this.locale, !Number.isInteger(value) && this.type === 'decimal' ? this.decimalLength : 0);
117
118
  /**
118
119
  * Set input error message
119
- * @param errorMessage - errorMessage override
120
+ * @param fromSetErrorContext - context come from `setError` method
120
121
  */
121
- this.setErrorMessage = (errorMessage) => {
122
+ this.setErrorMessage = (fromSetErrorContext = false) => {
122
123
  // Set error message
123
124
  this.errorMessage = undefined;
124
125
  if (!this.valid) {
125
126
  const inputError = this.getInputError();
126
- if (errorMessage !== undefined) {
127
- this.errorMessage = errorMessage;
127
+ // Does have a new custom error message OR does have a custom error message locked
128
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
129
+ this.errorMessage = this.customErrorMessage.message;
128
130
  }
131
+ // required
129
132
  else if (inputError === 'required') {
130
133
  this.errorMessage = this.messages.errors[inputError];
131
134
  }
135
+ // min/max
132
136
  else {
133
137
  const formattedMin = this.formatErrorValue(this.min);
134
138
  const formattedMax = this.formatErrorValue(this.max);
@@ -330,17 +334,22 @@ export class MgInputNumeric {
330
334
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
331
335
  * @param valid - value indicating the validity
332
336
  * @param errorMessage - the error message to display
337
+ * @param errorMessageLock - lock the error message and validity state
333
338
  */
334
- async setError(valid, errorMessage) {
339
+ async setError(valid, errorMessage, errorMessageLock = false) {
335
340
  if (typeof valid !== 'boolean') {
336
341
  throw new Error('<mg-input-numeric> method "setError()" param "valid" must be a boolean.');
337
342
  }
338
- else if (!isValidString(errorMessage)) {
343
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
339
344
  throw new Error('<mg-input-numeric> method "setError()" param "errorMessage" must be a string.');
340
345
  }
341
346
  else {
347
+ this.customErrorMessage = {
348
+ lock: valid ? false : errorMessageLock,
349
+ message: valid ? undefined : errorMessage,
350
+ };
342
351
  this.setValidity(valid);
343
- this.setErrorMessage(valid ? undefined : errorMessage);
352
+ this.setErrorMessage(true);
344
353
  this.hasDisplayedError = this.invalid;
345
354
  }
346
355
  }
@@ -358,6 +367,8 @@ export class MgInputNumeric {
358
367
  // - Keep everything in sync both inside and outside the component
359
368
  return new Promise(resolve => {
360
369
  requestAnimationFrame(() => {
370
+ // unlock validity check by reseting customErrorMessage
371
+ this.customErrorMessage = { lock: false };
361
372
  this.checkValidity();
362
373
  this.errorMessage = undefined;
363
374
  this.hasDisplayedError = false;
@@ -371,11 +382,13 @@ export class MgInputNumeric {
371
382
  * @param newValue - valid new value
372
383
  */
373
384
  setValidity(newValue) {
374
- const oldValidValue = this.valid;
375
- this.valid = newValue;
385
+ const oldValue = this.valid;
386
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
387
+ this.valid = newValue;
388
+ }
376
389
  this.invalid = !this.valid;
377
390
  // We need to send valid event even if it is the same value
378
- if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
391
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
379
392
  this.inputValid.emit(this.valid);
380
393
  }
381
394
  /**
@@ -447,7 +460,7 @@ export class MgInputNumeric {
447
460
  * @returns HTML Element
448
461
  */
449
462
  render() {
450
- return (h("mg-input", { key: '43e41f72e4cc4cf15a565167cee9e65035935e1f', 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.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly
463
+ return (h("mg-input", { key: 'c47f7c310587fc3bb4e7d5ffd07854a2297958df', 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.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly
451
464
  ? this.readonlyValue && this.renderReadonly()
452
465
  : [
453
466
  h("input", { key: "input", type: "text", class: "mg-c-input__box mg-c-input__box--width", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
@@ -1078,7 +1091,7 @@ export class MgInputNumeric {
1078
1091
  },
1079
1092
  "setError": {
1080
1093
  "complexType": {
1081
- "signature": "(valid: MgInputNumeric[\"valid\"], errorMessage: string) => Promise<void>",
1094
+ "signature": "(valid: MgInputNumeric[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
1082
1095
  "parameters": [{
1083
1096
  "name": "valid",
1084
1097
  "type": "boolean",
@@ -1087,6 +1100,10 @@ export class MgInputNumeric {
1087
1100
  "name": "errorMessage",
1088
1101
  "type": "string",
1089
1102
  "docs": "- the error message to display"
1103
+ }, {
1104
+ "name": "errorMessageLock",
1105
+ "type": "boolean",
1106
+ "docs": "- lock the error message and validity state"
1090
1107
  }],
1091
1108
  "references": {
1092
1109
  "Promise": {
@@ -1108,6 +1125,9 @@ export class MgInputNumeric {
1108
1125
  }, {
1109
1126
  "name": "param",
1110
1127
  "text": "errorMessage - the error message to display"
1128
+ }, {
1129
+ "name": "param",
1130
+ "text": "errorMessageLock - lock the error message and validity state"
1111
1131
  }]
1112
1132
  }
1113
1133
  },
@@ -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,8 +7,7 @@ export class MgInputRichTextEditor {
7
7
  constructor() {
8
8
  // hasDisplayedError (triggered by blur event)
9
9
  this.hasDisplayedError = false;
10
- // Classes
11
- this.classFocus = 'mg-u-is-focused';
10
+ this.customErrorMessage = { lock: false };
12
11
  /**
13
12
  * Define the value of the editor
14
13
  * Can be either HTML string or plain text
@@ -72,27 +71,29 @@ export class MgInputRichTextEditor {
72
71
  };
73
72
  /**
74
73
  * Set input error message
75
- * @param errorMessage - errorMessage override
74
+ * @param fromSetErrorContext - context come from `setError` method
76
75
  */
77
- this.setErrorMessage = (errorMessage) => {
76
+ this.setErrorMessage = (fromSetErrorContext = false) => {
77
+ // Set error message
78
78
  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;
79
+ // Does have a new custom error message
80
+ if (!this.valid) {
81
+ // Does have a new custom error message OR does have a custom error message locked
82
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
83
+ this.errorMessage = this.customErrorMessage.message;
84
+ }
85
+ else if (this.required && this.isEmpty()) {
86
+ this.errorMessage = this.messages.errors.required;
87
+ }
88
+ else if (!this.getPatternValidity()) {
89
+ this.errorMessage = this.patternErrorMessage;
90
+ }
89
91
  }
90
92
  };
91
93
  /**
92
94
  * Handle focus event
93
95
  */
94
96
  this.handleFocus = () => {
95
- this.classCollection.add(this.classFocus);
96
97
  this.classCollection = new ClassList(this.classCollection.classes);
97
98
  };
98
99
  /**
@@ -101,7 +102,6 @@ export class MgInputRichTextEditor {
101
102
  */
102
103
  this.handleBlur = () => {
103
104
  // Manage focus
104
- this.classCollection.delete(this.classFocus);
105
105
  this.classCollection = new ClassList(this.classCollection.classes);
106
106
  if (!this.readonly) {
107
107
  this.checkValidity();
@@ -169,7 +169,7 @@ export class MgInputRichTextEditor {
169
169
  * Get editor content as HTML
170
170
  * @returns HTML content of the editor
171
171
  */
172
- async getHTML() {
172
+ getHTML() {
173
173
  return new Promise(resolve => {
174
174
  requestAnimationFrame(() => {
175
175
  resolve(this.editor.getSemanticHTML());
@@ -213,17 +213,22 @@ export class MgInputRichTextEditor {
213
213
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
214
214
  * @param valid - value indicating the validity
215
215
  * @param errorMessage - the error message to display
216
+ * @param errorMessageLock - lock the error message and validity state
216
217
  */
217
- async setError(valid, errorMessage) {
218
+ async setError(valid, errorMessage, errorMessageLock = false) {
218
219
  if (typeof valid !== 'boolean') {
219
220
  throw new Error('<mg-input-rich-text-editor> method "setError()" param "valid" must be a boolean.');
220
221
  }
221
- else if (!isValidString(errorMessage)) {
222
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
222
223
  throw new Error('<mg-input-rich-text-editor> method "setError()" param "errorMessage" must be a string.');
223
224
  }
224
225
  else {
226
+ this.customErrorMessage = {
227
+ lock: valid ? false : errorMessageLock,
228
+ message: valid ? undefined : errorMessage,
229
+ };
225
230
  this.setValidity(valid);
226
- this.setErrorMessage(valid ? undefined : errorMessage);
231
+ this.setErrorMessage(true);
227
232
  this.hasDisplayedError = this.invalid;
228
233
  }
229
234
  }
@@ -242,6 +247,8 @@ export class MgInputRichTextEditor {
242
247
  // - Keep everything in sync both inside and outside the component
243
248
  return new Promise(resolve => {
244
249
  requestAnimationFrame(() => {
250
+ // unlock validity check by reseting customErrorMessage
251
+ this.customErrorMessage = { lock: false };
245
252
  this.checkValidity();
246
253
  this.errorMessage = undefined;
247
254
  this.hasDisplayedError = false;
@@ -255,10 +262,12 @@ export class MgInputRichTextEditor {
255
262
  * @param newValue - valid new value
256
263
  */
257
264
  setValidity(newValue) {
258
- const oldValidValue = this.valid;
259
- this.valid = newValue;
265
+ const oldValue = this.valid;
266
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
267
+ this.valid = newValue;
268
+ }
260
269
  this.invalid = !this.valid;
261
- if (this.valid !== oldValidValue) {
270
+ if (this.valid !== oldValue) {
262
271
  this.inputValid.emit(this.valid);
263
272
  }
264
273
  }
@@ -308,7 +317,7 @@ export class MgInputRichTextEditor {
308
317
  * @returns HTML mg-input Element
309
318
  */
310
319
  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 => {
320
+ return (h("mg-input", { key: '5e807e1059704a6624a1fda63ab56a6f9a51230f', 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
321
  this.wrapperElement = el;
313
322
  }, id: this.identifier, class: "mg-c-input__wrapper" }, h("div", null)))));
314
323
  }
@@ -805,7 +814,7 @@ export class MgInputRichTextEditor {
805
814
  },
806
815
  "setError": {
807
816
  "complexType": {
808
- "signature": "(valid: MgInputRichTextEditor[\"valid\"], errorMessage: string) => Promise<void>",
817
+ "signature": "(valid: MgInputRichTextEditor[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
809
818
  "parameters": [{
810
819
  "name": "valid",
811
820
  "type": "boolean",
@@ -814,6 +823,10 @@ export class MgInputRichTextEditor {
814
823
  "name": "errorMessage",
815
824
  "type": "string",
816
825
  "docs": "- the error message to display"
826
+ }, {
827
+ "name": "errorMessageLock",
828
+ "type": "boolean",
829
+ "docs": "- lock the error message and validity state"
817
830
  }],
818
831
  "references": {
819
832
  "Promise": {
@@ -835,6 +848,9 @@ export class MgInputRichTextEditor {
835
848
  }, {
836
849
  "name": "param",
837
850
  "text": "errorMessage - the error message to display"
851
+ }, {
852
+ "name": "param",
853
+ "text": "errorMessageLock - lock the error message and validity state"
838
854
  }]
839
855
  }
840
856
  },
@@ -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
  },