@mgdis/mg-components 5.1.0 → 5.2.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 (67) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/mg-badge_27.cjs.entry.js +354 -236
  3. package/dist/cjs/mg-components.cjs.js +1 -1
  4. package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -1
  5. package/dist/collection/components/atoms/mg-button/mg-button.js +3 -3
  6. package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
  7. package/dist/collection/components/molecules/inputs/MgInput.js +3 -11
  8. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +41 -20
  9. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +50 -39
  10. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +25 -6
  11. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +42 -33
  12. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +25 -6
  13. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +36 -17
  14. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +35 -14
  15. package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +2 -3
  16. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +28 -6
  17. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +36 -17
  18. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +25 -6
  19. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +38 -19
  20. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +25 -6
  21. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +37 -18
  22. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
  23. package/dist/collection/components/molecules/mg-form/mg-form.js +73 -27
  24. package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +6 -6
  25. package/dist/collection/components/molecules/mg-message/mg-message.js +1 -1
  26. package/dist/collection/components/molecules/mg-modal/mg-modal.js +0 -4
  27. package/dist/collection/utils/unit.test.utils.js +51 -0
  28. package/dist/collection/variables.css +6 -6
  29. package/dist/components/MgInput.js +4 -12
  30. package/dist/components/mg-badge2.js +1 -1
  31. package/dist/components/mg-button2.js +3 -3
  32. package/dist/components/mg-form.js +67 -26
  33. package/dist/components/mg-input-checkbox.js +36 -21
  34. package/dist/components/mg-input-date.js +44 -39
  35. package/dist/components/mg-input-numeric.js +37 -34
  36. package/dist/components/mg-input-password.js +32 -19
  37. package/dist/components/mg-input-radio.js +30 -15
  38. package/dist/components/mg-input-select2.js +32 -19
  39. package/dist/components/mg-input-text2.js +34 -21
  40. package/dist/components/mg-input-textarea.js +32 -19
  41. package/dist/components/mg-input-toggle.js +1 -1
  42. package/dist/components/mg-message.js +1 -1
  43. package/dist/components/mg-modal.js +0 -4
  44. package/dist/components/mg-tag.js +1 -1
  45. package/dist/esm/loader.js +1 -1
  46. package/dist/esm/mg-badge_27.entry.js +354 -236
  47. package/dist/esm/mg-components.js +1 -1
  48. package/dist/mg-components/mg-components.css +1 -1
  49. package/dist/mg-components/mg-components.esm.js +1 -1
  50. package/dist/mg-components/p-b2b07c3f.entry.js +1 -0
  51. package/dist/mg-components/variables.css +6 -6
  52. package/dist/types/components/atoms/mg-button/mg-button.d.ts +2 -2
  53. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +10 -8
  54. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +3 -8
  55. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +3 -8
  56. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -3
  57. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
  58. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -3
  59. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -4
  60. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -3
  61. package/dist/types/components/molecules/mg-form/mg-form.d.ts +21 -1
  62. package/dist/types/components/molecules/mg-message/mg-message.d.ts +3 -0
  63. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -0
  64. package/package.json +7 -8
  65. package/dist/collection/utils/test.utils.js +0 -38
  66. package/dist/mg-components/p-e131701a.entry.js +0 -1
  67. package/dist/types/utils/test.utils.d.ts +0 -17
@@ -106,7 +106,7 @@ const MgBadge = class {
106
106
  /************
107
107
  * Internal *
108
108
  ************/
109
- // classes
109
+ // Classes
110
110
  this.classOutline = `mg-badge--outline`;
111
111
  /**
112
112
  * Define button variant
@@ -233,7 +233,7 @@ const MgButton = class {
233
233
  }
234
234
  };
235
235
  /**
236
- * Handle onKeyDown event
236
+ * Handle onKeydown event
237
237
  *
238
238
  * @param {KeyboardEvent} event keyboard event
239
239
  * @returns {void}
@@ -248,7 +248,7 @@ const MgButton = class {
248
248
  }
249
249
  };
250
250
  /**
251
- * Handle onKeyUp event
251
+ * Handle onKeyup event
252
252
  *
253
253
  * @param {KeyboardEvent} event keyboard event
254
254
  * @returns {void}
@@ -331,7 +331,7 @@ const MgButton = class {
331
331
  * @returns {HTMLElement} html element
332
332
  */
333
333
  render() {
334
- return (index.h(index.Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyUp: this.handleKeyup, onKeyDown: this.handleKeydown }, index.h("div", { class: this.classList.join(), id: this.identifier }, this.loading && index.h("mg-icon", { icon: "loader", spin: true }), index.h("div", { class: "mg-button__content" }, index.h("slot", null)))));
334
+ return (index.h(index.Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, index.h("div", { class: this.classList.join(), id: this.identifier }, this.loading && index.h("mg-icon", { icon: "loader", spin: true }), index.h("div", { class: "mg-button__content" }, index.h("slot", null)))));
335
335
  }
336
336
  get element() { return index.getElement(this); }
337
337
  static get watchers() { return {
@@ -650,6 +650,8 @@ const MgForm = class {
650
650
  index.registerInstance(this, hostRef);
651
651
  this.formValid = index.createEvent(this, "form-valid", 7);
652
652
  this.formSubmit = index.createEvent(this, "form-submit", 7);
653
+ // Classes
654
+ this.classAllRequired = 'mg-form--all-required';
653
655
  /**
654
656
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
655
657
  * If not set, it will be created.
@@ -679,17 +681,24 @@ const MgForm = class {
679
681
  * @returns {void}
680
682
  */
681
683
  this.setRequiredMessage = () => {
682
- // Get required fields
683
- const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !this.disabled);
684
- // All fields are required
685
- // mg-input-toggle can not be required
686
- if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
687
- this.requiredMessage = this.messages.form.allRequired;
688
- this.classList.add('mg-form--all-required');
689
- }
690
- // Some fields are required
691
- else if (requiredInputs.length > 0) {
692
- this.requiredMessage = this.messages.form.required;
684
+ // init required message
685
+ this.requiredMessage = null;
686
+ this.classList.delete(this.classAllRequired);
687
+ // If the form is disabled or readonly none of them are required
688
+ // Check if all fields are not editable (readonly or disabled)
689
+ if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
690
+ // Get required fields
691
+ const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !input.readonly);
692
+ // All fields are required
693
+ // mg-input-toggle can not be required
694
+ if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
695
+ this.requiredMessage = this.messages.form.allRequired;
696
+ this.classList.add(this.classAllRequired);
697
+ }
698
+ // Some fields are required
699
+ else if (requiredInputs.length > 0) {
700
+ this.requiredMessage = this.messages.form.required;
701
+ }
693
702
  }
694
703
  };
695
704
  /**
@@ -698,15 +707,46 @@ const MgForm = class {
698
707
  * @returns {void}
699
708
  */
700
709
  this.checkValidity = () => {
701
- const validity = !this.mgInputs.some(input => input.invalid);
702
- this.valid = validity;
703
- this.invalid = !validity;
704
- this.formValid.emit(validity);
710
+ // Update required on input event
711
+ this.setRequiredMessage();
712
+ this.valid = !this.mgInputs.some(input => input.invalid);
713
+ this.invalid = !this.valid;
714
+ // We need to send valid event if it is the same value
715
+ this.formValid.emit(this.valid);
705
716
  };
717
+ /**
718
+ * Handle Form Submit
719
+ *
720
+ * @param {SubmitEvent} event submit event
721
+ * @returns {void}
722
+ */
706
723
  this.handleFormSubmit = (event) => {
707
724
  event.preventDefault();
708
725
  this.formSubmit.emit();
709
726
  };
727
+ /**
728
+ * Set mgInputs
729
+ *
730
+ * @returns {void}
731
+ */
732
+ this.setMgInputs = () => {
733
+ // Get slotted mgInputs
734
+ this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
735
+ // Set inputs readonly or disabled based on form configuration
736
+ // Othewise listen to events
737
+ this.mgInputs.map(input => {
738
+ if (this.readonly)
739
+ input.readonly = true;
740
+ else if (this.disabled)
741
+ input.disabled = true;
742
+ else
743
+ input.addEventListener('input-valid', this.checkValidity);
744
+ });
745
+ };
746
+ }
747
+ handleAttributeChange() {
748
+ this.setMgInputs();
749
+ this.setRequiredMessage();
710
750
  }
711
751
  /**
712
752
  * Public method to display errors
@@ -732,26 +772,18 @@ const MgForm = class {
732
772
  componentWillLoad() {
733
773
  // Get locales
734
774
  this.messages = initLocales(this.element).messages;
735
- // Get slotted mgInputs
736
- this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
737
775
  // Get slotted mgButtons
738
- this.mgButtons = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-BUTTON'));
776
+ this.mgButtons = Array.from(this.element.querySelectorAll('mg-button'));
739
777
  // Set button form identifier
740
778
  this.mgButtons.forEach(mgButton => {
741
779
  mgButton.setAttribute('form', this.identifier);
742
780
  });
781
+ // Set mgInputs
782
+ this.setMgInputs();
743
783
  // Define required message
744
784
  this.setRequiredMessage();
745
785
  // Check validity when slotted mgInputs are ready
746
786
  Promise.all(this.mgInputs.map(async (input) => {
747
- // Set inputs readonly or disabled based on form configuration
748
- // Othewise listen to events
749
- if (this.readonly)
750
- input.readonly = true;
751
- else if (this.disabled)
752
- input.disabled = true;
753
- else
754
- input.addEventListener('input-valid', this.checkValidity);
755
787
  try {
756
788
  await input.componentOnReady();
757
789
  }
@@ -774,6 +806,10 @@ const MgForm = class {
774
806
  });
775
807
  }
776
808
  });
809
+ // Update mgInputs when mgForm content change
810
+ new MutationObserver(() => {
811
+ this.setMgInputs();
812
+ }).observe(this.element, { childList: true });
777
813
  }
778
814
  /**
779
815
  * Render
@@ -784,6 +820,10 @@ const MgForm = class {
784
820
  return (index.h("form", { class: this.classList.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit }, this.requiredMessage && index.h("p", { innerHTML: this.requiredMessage }), index.h("slot", null), !this.readonly && !this.disabled && index.h("slot", { name: "actions" })));
785
821
  }
786
822
  get element() { return index.getElement(this); }
823
+ static get watchers() { return {
824
+ "readonly": ["handleAttributeChange"],
825
+ "disabled": ["handleAttributeChange"]
826
+ }; }
787
827
  };
788
828
  MgForm.style = mgFormCss;
789
829
 
@@ -1172,15 +1212,6 @@ const MgInput = (props, children, utils) => {
1172
1212
  if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {
1173
1213
  ariaDescribedbyIDs.add(helpTextErrorId);
1174
1214
  }
1175
- /**
1176
- * Update input(s) in children
1177
- */
1178
- if (props.readonly) {
1179
- children = children.filter(child => child.$name$ === 'append-input');
1180
- }
1181
- else {
1182
- children = applyAriadescribedBy(children, ariaDescribedbyIDs, utils);
1183
- }
1184
1215
  /**
1185
1216
  * Return template
1186
1217
  *
@@ -1206,19 +1237,20 @@ const MgInput = (props, children, utils) => {
1206
1237
  index.h("mg-icon", { icon: "info-circle" })));
1207
1238
  /**
1208
1239
  * Get input title (label) node
1240
+ * Display asterisk only if not disabled and not readonly
1209
1241
  *
1210
1242
  * @returns {VNode[]} mg-input-title
1211
1243
  */
1212
- const getInputTitle = () => (index.h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled, "is-legend": props.isFieldset }, props.label));
1244
+ const getInputTitle = () => (index.h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
1213
1245
  return (index.h(TagName, { class: props.classList.join() },
1214
1246
  props.labelOnTop ? (index.h("div", { class: "mg-input__title" },
1215
1247
  getInputTitle(),
1216
1248
  !props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
1217
1249
  props.readonly ? (index.h("div", { class: "mg-input__input-container" },
1218
1250
  index.h("strong", null, props.readonlyValue || props.value),
1219
- children)) : (index.h("div", { class: "mg-input__input-container" },
1251
+ children.filter(child => child.$name$ === 'append-input'))) : (index.h("div", { class: "mg-input__input-container" },
1220
1252
  index.h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } },
1221
- children,
1253
+ applyAriadescribedBy(children, ariaDescribedbyIDs, utils),
1222
1254
  !props.labelOnTop && props.tooltip && getTooltip()),
1223
1255
  props.helpText && index.h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }),
1224
1256
  props.errorMessage && !props.readonly && !props.disabled && (index.h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
@@ -1243,6 +1275,8 @@ const MgInputCheckbox = class {
1243
1275
  ************/
1244
1276
  // HTML selector
1245
1277
  this.inputs = [];
1278
+ // hasDisplayedError (triggered by blur event)
1279
+ this.hasDisplayedError = false;
1246
1280
  /**
1247
1281
  * Input name
1248
1282
  * If not set the value equals the identifier
@@ -1297,25 +1331,27 @@ const MgInputCheckbox = class {
1297
1331
  this.handleBlur = () => {
1298
1332
  // Check validity
1299
1333
  this.checkValidity();
1300
- this.checkError();
1334
+ this.setErrorMessage();
1301
1335
  };
1336
+ /**
1337
+ * get invalid element
1338
+ *
1339
+ * @returns {HTMLInputElement} element
1340
+ */
1341
+ this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
1302
1342
  /**
1303
1343
  * Check if input is valid
1304
1344
  */
1305
1345
  this.checkValidity = () => {
1306
- if (!this.readonly) {
1307
- const validity = this.getInvalidElement() === undefined;
1308
- // Set validity
1309
- this.valid = validity;
1310
- this.invalid = !validity;
1311
- //Send event
1312
- this.inputValid.emit(validity);
1313
- }
1346
+ this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
1347
+ this.invalid = !this.valid;
1348
+ // We need to send valid event even if it is the same value
1349
+ this.inputValid.emit(this.valid);
1314
1350
  };
1315
1351
  /**
1316
- * Check input errors
1352
+ * Set input error message
1317
1353
  */
1318
- this.checkError = () => {
1354
+ this.setErrorMessage = () => {
1319
1355
  const invalidElement = this.getInvalidElement();
1320
1356
  // Set error message
1321
1357
  this.errorMessage = undefined;
@@ -1323,12 +1359,6 @@ const MgInputCheckbox = class {
1323
1359
  this.errorMessage = this.messages.errors.required;
1324
1360
  }
1325
1361
  };
1326
- /**
1327
- * get invalid element
1328
- *
1329
- * @returns {HTMLInputElement} element
1330
- */
1331
- this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
1332
1362
  }
1333
1363
  validateValue(newValue) {
1334
1364
  if (newValue && newValue.every(item => isCheckboxItem(item))) {
@@ -1344,6 +1374,16 @@ const MgInputCheckbox = class {
1344
1374
  throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
1345
1375
  }
1346
1376
  }
1377
+ handleValidityChange(newValue, _oldValue, prop) {
1378
+ this.inputs.forEach(input => {
1379
+ input[prop] = newValue;
1380
+ });
1381
+ this.checkValidity();
1382
+ if (this.hasDisplayedError) {
1383
+ this.setErrorMessage();
1384
+ this.hasDisplayedError = false;
1385
+ }
1386
+ }
1347
1387
  /**
1348
1388
  * Public method to display errors
1349
1389
  *
@@ -1351,7 +1391,8 @@ const MgInputCheckbox = class {
1351
1391
  */
1352
1392
  async displayError() {
1353
1393
  this.checkValidity();
1354
- this.checkError();
1394
+ this.setErrorMessage();
1395
+ this.hasDisplayedError = this.invalid;
1355
1396
  }
1356
1397
  /*************
1357
1398
  * Lifecycle *
@@ -1379,15 +1420,21 @@ const MgInputCheckbox = class {
1379
1420
  * @returns {HTMLElement} HTML Element
1380
1421
  */
1381
1422
  render() {
1382
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
1423
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
1383
1424
  .filter(item => {
1384
1425
  return !this.readonly || item.value;
1385
1426
  })
1386
- .map(input => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => this.inputs.push(el) }), index.h("label", { htmlFor: input.id }, input.title)))))));
1427
+ .map((input, index$1) => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
1428
+ if (el !== null)
1429
+ this.inputs[index$1] = el;
1430
+ } }), index.h("label", { htmlFor: input.id }, input.title)))))));
1387
1431
  }
1388
1432
  get element() { return index.getElement(this); }
1389
1433
  static get watchers() { return {
1390
- "value": ["validateValue"]
1434
+ "value": ["validateValue"],
1435
+ "required": ["handleValidityChange"],
1436
+ "readonly": ["handleValidityChange"],
1437
+ "disabled": ["handleValidityChange"]
1391
1438
  }; }
1392
1439
  };
1393
1440
  MgInputCheckbox.style = mgInputCheckboxCss;
@@ -1446,8 +1493,8 @@ const MgInputDate = class {
1446
1493
  index.registerInstance(this, hostRef);
1447
1494
  this.valueChange = index.createEvent(this, "value-change", 7);
1448
1495
  this.inputValid = index.createEvent(this, "input-valid", 7);
1449
- // hasError (triggered by blur event)
1450
- this.hasError = false;
1496
+ // hasDisplayedError (triggered by blur event)
1497
+ this.hasDisplayedError = false;
1451
1498
  /**
1452
1499
  * Input name
1453
1500
  * If not set the value equals the identifier
@@ -1478,8 +1525,8 @@ const MgInputDate = class {
1478
1525
  */
1479
1526
  this.handleInput = () => {
1480
1527
  this.checkValidity();
1481
- if (this.hasError) {
1482
- this.checkError();
1528
+ if (this.hasDisplayedError) {
1529
+ this.setErrorMessage();
1483
1530
  }
1484
1531
  this.value = this.input.value;
1485
1532
  };
@@ -1493,14 +1540,11 @@ const MgInputDate = class {
1493
1540
  * Check if input is valid
1494
1541
  */
1495
1542
  this.checkValidity = () => {
1496
- if (!this.readonly && this.input !== undefined) {
1497
- const validity = this.input.checkValidity();
1498
- // Set validity
1499
- this.valid = validity;
1500
- this.invalid = !validity;
1501
- //Send event
1502
- this.inputValid.emit(validity);
1503
- }
1543
+ var _a;
1544
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
1545
+ this.invalid = !this.valid;
1546
+ // We need to send valid event even if it is the same value
1547
+ this.inputValid.emit(this.valid);
1504
1548
  };
1505
1549
  /**
1506
1550
  * get input error code
@@ -1529,48 +1573,50 @@ const MgInputDate = class {
1529
1573
  return inputError;
1530
1574
  };
1531
1575
  /**
1532
- * Set error message
1576
+ * Check input errors
1533
1577
  *
1534
1578
  * @returns {void}
1535
1579
  */
1536
1580
  this.setErrorMessage = () => {
1537
1581
  var _a;
1538
- const inputError = this.getInputError();
1539
- // required
1540
- if (inputError === InputError$1.REQUIRED) {
1541
- this.errorMessage = this.messages.errors[inputError];
1542
- }
1543
- // min, max & minMax
1544
- else if ([InputError$1.MIN, InputError$1.MAX, InputError$1.MINMAX].includes(inputError)) {
1545
- this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));
1546
- }
1547
- // wrong date format
1548
- // element.validity.badInput is default error message
1549
- else {
1550
- this.errorMessage = this.messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min, this.locale) : localeDate('1900-01-01', this.locale));
1551
- }
1552
- };
1553
- /**
1554
- * Check input errors
1555
- *
1556
- * @returns {void}
1557
- */
1558
- this.checkError = () => {
1559
1582
  // Set error message
1560
1583
  this.errorMessage = undefined;
1561
1584
  if (!this.valid) {
1562
- this.setErrorMessage();
1585
+ const inputError = this.getInputError();
1586
+ // required
1587
+ if (inputError === InputError$1.REQUIRED) {
1588
+ this.errorMessage = this.messages.errors[inputError];
1589
+ }
1590
+ // min, max & minMax
1591
+ else if ([InputError$1.MIN, InputError$1.MAX, InputError$1.MINMAX].includes(inputError)) {
1592
+ this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));
1593
+ }
1594
+ // wrong date format
1595
+ // element.validity.badInput is default error message
1596
+ else {
1597
+ this.errorMessage = this.messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min, this.locale) : localeDate('1900-01-01', this.locale));
1598
+ }
1563
1599
  }
1564
1600
  };
1565
1601
  }
1566
1602
  validateValue(newValue) {
1567
- if (newValue !== undefined && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
1603
+ if (newValue !== undefined && newValue !== null && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
1568
1604
  throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
1569
1605
  }
1570
1606
  else {
1571
1607
  this.valueChange.emit(this.value);
1572
1608
  }
1573
1609
  }
1610
+ handleValidityChange(newValue, _oldValue, prop) {
1611
+ if (this.input !== undefined) {
1612
+ this.input[prop] = newValue;
1613
+ this.checkValidity();
1614
+ if (this.hasDisplayedError) {
1615
+ this.setErrorMessage();
1616
+ this.hasDisplayedError = false;
1617
+ }
1618
+ }
1619
+ }
1574
1620
  validateMinMax(newValue) {
1575
1621
  if ((newValue === null || newValue === void 0 ? void 0 : newValue.length) === 0 || ((newValue === null || newValue === void 0 ? void 0 : newValue.length) > 0 && !(typeof newValue === 'string' && dateRegExp.test(newValue)))) {
1576
1622
  throw new Error("<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd");
@@ -1583,8 +1629,8 @@ const MgInputDate = class {
1583
1629
  */
1584
1630
  async displayError() {
1585
1631
  this.checkValidity();
1586
- this.checkError();
1587
- this.hasError = this.invalid;
1632
+ this.setErrorMessage();
1633
+ this.hasDisplayedError = this.invalid;
1588
1634
  }
1589
1635
  /*************
1590
1636
  * Lifecycle *
@@ -1616,11 +1662,17 @@ const MgInputDate = class {
1616
1662
  * @returns {HTMLElement} HTML Element
1617
1663
  */
1618
1664
  render() {
1619
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el => (this.input = el) })));
1665
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el => {
1666
+ if (el !== null)
1667
+ this.input = el;
1668
+ } })));
1620
1669
  }
1621
1670
  get element() { return index.getElement(this); }
1622
1671
  static get watchers() { return {
1623
1672
  "value": ["validateValue"],
1673
+ "required": ["handleValidityChange"],
1674
+ "readonly": ["handleValidityChange"],
1675
+ "disabled": ["handleValidityChange"],
1624
1676
  "min": ["validateMinMax"],
1625
1677
  "max": ["validateMinMax"]
1626
1678
  }; }
@@ -1639,15 +1691,15 @@ var InputError;
1639
1691
  InputError["REQUIRED"] = "required";
1640
1692
  })(InputError || (InputError = {}));
1641
1693
 
1642
- const mgInputNumericCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input .mg-input__box{text-align:var(--mg-inputs-text-align, right)}";
1694
+ const mgInputNumericCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input .mg-input__box{text-align:var(--mg-inputs-text-align, right)}";
1643
1695
 
1644
1696
  const MgInputNumeric = class {
1645
1697
  constructor(hostRef) {
1646
1698
  index.registerInstance(this, hostRef);
1647
1699
  this.valueChange = index.createEvent(this, "value-change", 7);
1648
1700
  this.inputValid = index.createEvent(this, "input-valid", 7);
1649
- // hasError (triggered by blur event)
1650
- this.hasError = false;
1701
+ // hasDisplayedError (triggered by blur event)
1702
+ this.hasDisplayedError = false;
1651
1703
  /**
1652
1704
  * Input name
1653
1705
  * If not set the value equals the identifier
@@ -1703,8 +1755,8 @@ const MgInputNumeric = class {
1703
1755
  this.handleInput = () => {
1704
1756
  // Check validity
1705
1757
  this.checkValidity();
1706
- if (this.hasError) {
1707
- this.checkError();
1758
+ if (this.hasDisplayedError) {
1759
+ this.setErrorMessage();
1708
1760
  }
1709
1761
  this.value = this.input.value;
1710
1762
  };
@@ -1732,40 +1784,27 @@ const MgInputNumeric = class {
1732
1784
  * @returns {void}
1733
1785
  */
1734
1786
  this.checkValidity = () => {
1735
- if (!this.readonly) {
1736
- const validity = this.getInputError() === null;
1737
- // Set validity
1738
- this.valid = validity;
1739
- this.invalid = !validity;
1740
- //Send event
1741
- this.inputValid.emit(validity);
1742
- }
1787
+ this.valid = this.readonly || this.disabled || this.getInputError() === null;
1788
+ this.invalid = !this.valid;
1789
+ // We need to send valid event even if it is the same value
1790
+ this.inputValid.emit(this.valid);
1743
1791
  };
1744
1792
  /**
1745
- * Set error message
1793
+ * Set input error message
1746
1794
  *
1747
1795
  * @returns {void}
1748
1796
  */
1749
1797
  this.setErrorMessage = () => {
1750
- const inputError = this.getInputError();
1751
- if (inputError === InputError.REQUIRED) {
1752
- this.errorMessage = this.messages.errors[inputError];
1753
- }
1754
- else {
1755
- this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
1756
- }
1757
- };
1758
- /**
1759
- * Check input errors
1760
- *
1761
- * @returns {void}
1762
- */
1763
- this.checkError = () => {
1764
1798
  // Set error message
1765
1799
  this.errorMessage = undefined;
1766
- // Update class
1767
1800
  if (!this.valid) {
1768
- this.setErrorMessage();
1801
+ const inputError = this.getInputError();
1802
+ if (inputError === InputError.REQUIRED) {
1803
+ this.errorMessage = this.messages.errors[inputError];
1804
+ }
1805
+ else {
1806
+ this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
1807
+ }
1769
1808
  }
1770
1809
  };
1771
1810
  /**
@@ -1775,7 +1814,7 @@ const MgInputNumeric = class {
1775
1814
  */
1776
1815
  this.getInputError = () => {
1777
1816
  let inputError = null;
1778
- if (this.input === undefined)
1817
+ if (this.input === undefined || this.input === null)
1779
1818
  return inputError;
1780
1819
  // required
1781
1820
  if (!this.input.checkValidity() && this.input.validity.valueMissing) {
@@ -1842,6 +1881,16 @@ const MgInputNumeric = class {
1842
1881
  this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
1843
1882
  }
1844
1883
  }
1884
+ handleValidityChange(newValue, _oldValue, prop) {
1885
+ if (this.input !== undefined) {
1886
+ this.input[prop] = newValue;
1887
+ this.checkValidity();
1888
+ if (this.hasDisplayedError) {
1889
+ this.setErrorMessage();
1890
+ this.hasDisplayedError = false;
1891
+ }
1892
+ }
1893
+ }
1845
1894
  validateType(newValue) {
1846
1895
  if (!types.includes(newValue)) {
1847
1896
  throw new Error(`<mg-input-numeric> prop "type" must be one of : ${types.join(', ')}`);
@@ -1864,8 +1913,8 @@ const MgInputNumeric = class {
1864
1913
  */
1865
1914
  async displayError() {
1866
1915
  this.checkValidity();
1867
- this.checkError();
1868
- this.hasError = this.invalid;
1916
+ this.setErrorMessage();
1917
+ this.hasDisplayedError = this.invalid;
1869
1918
  }
1870
1919
  /**
1871
1920
  * Displayed value in input
@@ -1908,11 +1957,17 @@ const MgInputNumeric = class {
1908
1957
  * @returns {HTMLElement} HTML Element
1909
1958
  */
1910
1959
  render() {
1911
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), index.h("slot", { name: "append-input" })));
1960
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
1961
+ if (el !== null)
1962
+ this.input = el;
1963
+ } }), index.h("slot", { name: "append-input" })));
1912
1964
  }
1913
1965
  get element() { return index.getElement(this); }
1914
1966
  static get watchers() { return {
1915
1967
  "value": ["validateValue"],
1968
+ "required": ["handleValidityChange"],
1969
+ "readonly": ["handleValidityChange"],
1970
+ "disabled": ["handleValidityChange"],
1916
1971
  "type": ["validateType"],
1917
1972
  "integerLength": ["validateIntegerLength"],
1918
1973
  "decimalLength": ["validateDecimalLength"]
@@ -1920,15 +1975,15 @@ const MgInputNumeric = class {
1920
1975
  };
1921
1976
  MgInputNumeric.style = mgInputNumericCss;
1922
1977
 
1923
- const mgInputPasswordCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}";
1978
+ const mgInputPasswordCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}";
1924
1979
 
1925
1980
  const MgInputPassword = class {
1926
1981
  constructor(hostRef) {
1927
1982
  index.registerInstance(this, hostRef);
1928
1983
  this.valueChange = index.createEvent(this, "value-change", 7);
1929
1984
  this.inputValid = index.createEvent(this, "input-valid", 7);
1930
- // hasError (triggered by blur event)
1931
- this.hasError = false;
1985
+ // hasDisplayedError (triggered by blur event)
1986
+ this.hasDisplayedError = false;
1932
1987
  /**
1933
1988
  * Input name
1934
1989
  * If not set the value equals the identifier
@@ -1963,8 +2018,8 @@ const MgInputPassword = class {
1963
2018
  */
1964
2019
  this.handleInput = () => {
1965
2020
  this.checkValidity();
1966
- if (this.hasError) {
1967
- this.checkError();
2021
+ if (this.hasDisplayedError) {
2022
+ this.setErrorMessage();
1968
2023
  }
1969
2024
  this.value = this.input.value;
1970
2025
  };
@@ -1978,19 +2033,16 @@ const MgInputPassword = class {
1978
2033
  * Check if input is valid
1979
2034
  */
1980
2035
  this.checkValidity = () => {
1981
- if (!this.readonly && this.input !== undefined) {
1982
- const validity = this.input.checkValidity();
1983
- // Set validity
1984
- this.valid = validity;
1985
- this.invalid = !validity;
1986
- //Send event
1987
- this.inputValid.emit(validity);
1988
- }
2036
+ var _a;
2037
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
2038
+ this.invalid = !this.valid;
2039
+ // We need to send valid event even if it is the same value
2040
+ this.inputValid.emit(this.valid);
1989
2041
  };
1990
2042
  /**
1991
- * Check input errors
2043
+ * Set input error message
1992
2044
  */
1993
- this.checkError = () => {
2045
+ this.setErrorMessage = () => {
1994
2046
  // Set error message
1995
2047
  this.errorMessage = undefined;
1996
2048
  // required
@@ -2002,6 +2054,16 @@ const MgInputPassword = class {
2002
2054
  handleValue(newValue) {
2003
2055
  this.valueChange.emit(newValue);
2004
2056
  }
2057
+ handleValidityChange(newValue, _oldValue, prop) {
2058
+ if (this.input !== undefined) {
2059
+ this.input[prop] = newValue;
2060
+ this.checkValidity();
2061
+ if (this.hasDisplayedError) {
2062
+ this.setErrorMessage();
2063
+ this.hasDisplayedError = false;
2064
+ }
2065
+ }
2066
+ }
2005
2067
  /**
2006
2068
  * Public method to display errors
2007
2069
  *
@@ -2009,8 +2071,8 @@ const MgInputPassword = class {
2009
2071
  */
2010
2072
  async displayError() {
2011
2073
  this.checkValidity();
2012
- this.checkError();
2013
- this.hasError = this.invalid;
2074
+ this.setErrorMessage();
2075
+ this.hasDisplayedError = this.invalid;
2014
2076
  }
2015
2077
  /*************
2016
2078
  * Lifecycle *
@@ -2036,11 +2098,17 @@ const MgInputPassword = class {
2036
2098
  * @returns {HTMLElement} HTML Element
2037
2099
  */
2038
2100
  render() {
2039
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) })));
2101
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
2102
+ if (el !== null)
2103
+ this.input = el;
2104
+ } })));
2040
2105
  }
2041
2106
  get element() { return index.getElement(this); }
2042
2107
  static get watchers() { return {
2043
- "value": ["handleValue"]
2108
+ "value": ["handleValue"],
2109
+ "required": ["handleValidityChange"],
2110
+ "readonly": ["handleValidityChange"],
2111
+ "disabled": ["handleValidityChange"]
2044
2112
  }; }
2045
2113
  };
2046
2114
  MgInputPassword.style = mgInputPasswordCss;
@@ -2064,6 +2132,8 @@ const MgInputRadio = class {
2064
2132
  ************/
2065
2133
  // HTML selector
2066
2134
  this.inputs = [];
2135
+ // hasDisplayedError (triggered by blur event)
2136
+ this.hasDisplayedError = false;
2067
2137
  /**
2068
2138
  * Input name
2069
2139
  * If not set the value equals the identifier
@@ -2114,7 +2184,7 @@ const MgInputRadio = class {
2114
2184
  */
2115
2185
  this.handleBlur = () => {
2116
2186
  this.checkValidity();
2117
- this.checkError();
2187
+ this.setErrorMessage();
2118
2188
  };
2119
2189
  /**
2120
2190
  * Check if input is valid
@@ -2122,21 +2192,17 @@ const MgInputRadio = class {
2122
2192
  * @returns {void}
2123
2193
  */
2124
2194
  this.checkValidity = () => {
2125
- if (!this.readonly) {
2126
- const validity = this.getInvalidElement() === undefined;
2127
- // Set validity
2128
- this.valid = validity;
2129
- this.invalid = !validity;
2130
- //Send event
2131
- this.inputValid.emit(validity);
2132
- }
2195
+ this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
2196
+ this.invalid = !this.valid;
2197
+ // We need to send valid event even if it is the same value
2198
+ this.inputValid.emit(this.valid);
2133
2199
  };
2134
2200
  /**
2135
- * Check input errors
2201
+ * Set input error message
2136
2202
  *
2137
2203
  * @returns {void}
2138
2204
  */
2139
- this.checkError = () => {
2205
+ this.setErrorMessage = () => {
2140
2206
  const invalidElement = this.getInvalidElement();
2141
2207
  // Set error message
2142
2208
  this.errorMessage = undefined;
@@ -2149,7 +2215,7 @@ const MgInputRadio = class {
2149
2215
  *
2150
2216
  * @returns {HTMLInputElement} element
2151
2217
  */
2152
- this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
2218
+ this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
2153
2219
  }
2154
2220
  handleValue(newValue) {
2155
2221
  this.valueChange.emit(newValue);
@@ -2171,6 +2237,16 @@ const MgInputRadio = class {
2171
2237
  throw new Error('<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption.');
2172
2238
  }
2173
2239
  }
2240
+ handleValidityChange(newValue, _oldValue, prop) {
2241
+ this.inputs.forEach(input => {
2242
+ input[prop] = newValue;
2243
+ });
2244
+ this.checkValidity();
2245
+ if (this.hasDisplayedError) {
2246
+ this.setErrorMessage();
2247
+ this.hasDisplayedError = false;
2248
+ }
2249
+ }
2174
2250
  /**
2175
2251
  * Public method to display errors
2176
2252
  *
@@ -2178,7 +2254,8 @@ const MgInputRadio = class {
2178
2254
  */
2179
2255
  async displayError() {
2180
2256
  this.checkValidity();
2181
- this.checkError();
2257
+ this.setErrorMessage();
2258
+ this.hasDisplayedError = this.invalid;
2182
2259
  }
2183
2260
  /*************
2184
2261
  * Lifecycle *
@@ -2206,17 +2283,23 @@ const MgInputRadio = class {
2206
2283
  * @returns {HTMLElement} HTML Element
2207
2284
  */
2208
2285
  render() {
2209
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.options.map((input, index$1) => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "radio", id: this.identifier + '_' + index$1, name: this.identifier, value: index$1, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index$1].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => this.inputs.push(el) }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title)))))));
2286
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.options.map((input, index$1) => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "radio", id: this.identifier + '_' + index$1, name: this.identifier, value: index$1, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index$1].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => {
2287
+ if (el !== null)
2288
+ this.inputs[index$1] = el;
2289
+ } }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title)))))));
2210
2290
  }
2211
2291
  get element() { return index.getElement(this); }
2212
2292
  static get watchers() { return {
2213
2293
  "value": ["handleValue"],
2214
- "items": ["validateItems"]
2294
+ "items": ["validateItems"],
2295
+ "required": ["handleValidityChange"],
2296
+ "readonly": ["handleValidityChange"],
2297
+ "disabled": ["handleValidityChange"]
2215
2298
  }; }
2216
2299
  };
2217
2300
  MgInputRadio.style = mgInputRadioCss;
2218
2301
 
2219
- const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input__box{width:100%;padding-top:0;padding-bottom:0;padding-right:1rem}";
2302
+ const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input__box{width:100%;padding-top:0;padding-bottom:0;padding-right:1rem}.mg-input.mg-input--select:not(.mg-input--label-on-top) .mg-input__box{max-width:unset}";
2220
2303
 
2221
2304
  /**
2222
2305
  * Check if item is a well configured option
@@ -2259,8 +2342,8 @@ const MgInputSelect = class {
2259
2342
  index.registerInstance(this, hostRef);
2260
2343
  this.valueChange = index.createEvent(this, "value-change", 7);
2261
2344
  this.inputValid = index.createEvent(this, "input-valid", 7);
2262
- // hasError (triggered by blur event)
2263
- this.hasError = false;
2345
+ // hasDisplayedError (triggered by blur event)
2346
+ this.hasDisplayedError = false;
2264
2347
  /**
2265
2348
  * Input name
2266
2349
  * If not set the value equals the identifier
@@ -2299,8 +2382,8 @@ const MgInputSelect = class {
2299
2382
  */
2300
2383
  this.handleInput = () => {
2301
2384
  this.checkValidity();
2302
- if (this.hasError) {
2303
- this.checkError();
2385
+ if (this.hasDisplayedError) {
2386
+ this.setErrorMessage();
2304
2387
  }
2305
2388
  if (this.input.value !== '') {
2306
2389
  this.value = allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.title === this.input.value).value;
@@ -2319,19 +2402,16 @@ const MgInputSelect = class {
2319
2402
  * Check if input is valid
2320
2403
  */
2321
2404
  this.checkValidity = () => {
2322
- if (!this.readonly && this.input !== undefined) {
2323
- const validity = this.input.checkValidity && this.input.checkValidity();
2324
- // Set validity
2325
- this.valid = validity;
2326
- this.invalid = !validity;
2327
- //Send event
2328
- this.inputValid.emit(validity);
2329
- }
2405
+ var _a;
2406
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
2407
+ this.invalid = !this.valid;
2408
+ // We need to send valid event even if it is the same value
2409
+ this.inputValid.emit(this.valid);
2330
2410
  };
2331
2411
  /**
2332
- * Check input errors
2412
+ * Set input error message
2333
2413
  */
2334
- this.checkError = () => {
2414
+ this.setErrorMessage = () => {
2335
2415
  // Set error message
2336
2416
  this.errorMessage = undefined;
2337
2417
  if (!this.valid && this.input.validity.valueMissing) {
@@ -2370,6 +2450,16 @@ const MgInputSelect = class {
2370
2450
  throw new Error('<mg-input-select> prop "items" is required and all items must be the same type, string or Option.');
2371
2451
  }
2372
2452
  }
2453
+ handleValidityChange(newValue, _oldValue, prop) {
2454
+ if (this.input !== undefined) {
2455
+ this.input[prop] = newValue;
2456
+ this.checkValidity();
2457
+ if (this.hasDisplayedError) {
2458
+ this.setErrorMessage();
2459
+ this.hasDisplayedError = false;
2460
+ }
2461
+ }
2462
+ }
2373
2463
  /**
2374
2464
  * Public method to display errors
2375
2465
  *
@@ -2377,8 +2467,8 @@ const MgInputSelect = class {
2377
2467
  */
2378
2468
  async displayError() {
2379
2469
  this.checkValidity();
2380
- this.checkError();
2381
- this.hasError = this.invalid;
2470
+ this.setErrorMessage();
2471
+ this.hasDisplayedError = this.invalid;
2382
2472
  }
2383
2473
  /*************
2384
2474
  * Lifecycle *
@@ -2410,18 +2500,24 @@ const MgInputSelect = class {
2410
2500
  * @returns {HTMLElement} HTML Element
2411
2501
  */
2412
2502
  render() {
2413
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
2503
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
2504
+ if (el !== null)
2505
+ this.input = el;
2506
+ } }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
2414
2507
  index.h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map(option => option.group !== undefined ? (index.h("optgroup", { label: option.group }, option.options.map(optgroup => (index.h("option", { value: optgroup.title, selected: JSON.stringify(this.value) === JSON.stringify(optgroup.value), disabled: optgroup.disabled }, optgroup.title))))) : (index.h("option", { value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title))))));
2415
2508
  }
2416
2509
  get element() { return index.getElement(this); }
2417
2510
  static get watchers() { return {
2418
2511
  "value": ["handleValue"],
2419
- "items": ["validateItems"]
2512
+ "items": ["validateItems"],
2513
+ "required": ["handleValidityChange"],
2514
+ "readonly": ["handleValidityChange"],
2515
+ "disabled": ["handleValidityChange"]
2420
2516
  }; }
2421
2517
  };
2422
2518
  MgInputSelect.style = mgInputSelectCss;
2423
2519
 
2424
- const mgInputTextCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input.mg-input--has-icon .mg-input__with-character-left>mg-icon{position:absolute;top:50%;left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__with-character-left .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}.mg-input__with-character-left{position:relative;display:inline-flex}.mg-input--width-full .mg-input__with-character-left{width:100%}.mg-input.is-focused .mg-input__with-character-left .mg-input__box{padding-right:calc(var(--mg-character-left-message-length) * 1ch + 0.8rem)}.mg-input__with-character-left mg-character-left{position:absolute;display:none;top:50%;right:1rem;opacity:0.6;transform:translateY(-50%);font-size:1.1rem}.mg-input.is-focused .mg-input__with-character-left mg-character-left{display:block}";
2520
+ const mgInputTextCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input.mg-input--has-icon .mg-input__with-character-left>mg-icon{position:absolute;top:50%;left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__with-character-left .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}.mg-input__with-character-left{position:relative;display:inline-flex}.mg-input--width-full .mg-input__with-character-left{width:100%}.mg-input.is-focused .mg-input__with-character-left .mg-input__box{padding-right:calc(var(--mg-character-left-message-length) * 1ch + 0.8rem)}.mg-input__with-character-left mg-character-left{position:absolute;display:none;top:50%;right:1rem;opacity:0.6;transform:translateY(-50%);font-size:1.1rem}.mg-input.is-focused .mg-input__with-character-left mg-character-left{display:block}";
2425
2521
 
2426
2522
  const MgInputText = class {
2427
2523
  constructor(hostRef) {
@@ -2431,12 +2527,12 @@ const MgInputText = class {
2431
2527
  /************
2432
2528
  * Internal *
2433
2529
  ************/
2434
- // classes
2530
+ // Classes
2435
2531
  this.classFocus = 'is-focused';
2436
2532
  this.classIsInputGroupAppend = 'mg-input--is-input-group-append';
2437
2533
  this.classHasIcon = 'mg-input--has-icon';
2438
- // hasError (triggered by blur event)
2439
- this.hasError = false;
2534
+ // hasDisplayedError (triggered by blur event)
2535
+ this.hasDisplayedError = false;
2440
2536
  /**
2441
2537
  * Input name
2442
2538
  * If not set the value equals the identifier
@@ -2485,8 +2581,8 @@ const MgInputText = class {
2485
2581
  */
2486
2582
  this.handleInput = () => {
2487
2583
  this.checkValidity();
2488
- if (this.hasError) {
2489
- this.checkError();
2584
+ if (this.hasDisplayedError) {
2585
+ this.setErrorMessage();
2490
2586
  }
2491
2587
  this.value = this.input.value;
2492
2588
  };
@@ -2517,21 +2613,18 @@ const MgInputText = class {
2517
2613
  * @returns {void}
2518
2614
  */
2519
2615
  this.checkValidity = () => {
2520
- if (!this.readonly && this.input !== undefined) {
2521
- const validity = this.input.checkValidity();
2522
- // Set validity
2523
- this.valid = validity;
2524
- this.invalid = !validity;
2525
- //Send event
2526
- this.inputValid.emit(validity);
2527
- }
2616
+ var _a;
2617
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
2618
+ this.invalid = !this.valid;
2619
+ // We need to send valid event even if it is the same value
2620
+ this.inputValid.emit(this.valid);
2528
2621
  };
2529
2622
  /**
2530
- * Check input errors
2623
+ * Set input error message
2531
2624
  *
2532
2625
  * @returns {void}
2533
2626
  */
2534
- this.checkError = () => {
2627
+ this.setErrorMessage = () => {
2535
2628
  // Set error message
2536
2629
  this.errorMessage = undefined;
2537
2630
  // Does not match pattern
@@ -2544,7 +2637,7 @@ const MgInputText = class {
2544
2637
  }
2545
2638
  };
2546
2639
  /**
2547
- * Validate patern configuration
2640
+ * Validate pattern configuration
2548
2641
  *
2549
2642
  * @returns {void}
2550
2643
  */
@@ -2583,6 +2676,16 @@ const MgInputText = class {
2583
2676
  this.classList.delete(this.classHasIcon);
2584
2677
  }
2585
2678
  }
2679
+ handleValidityChange(newValue, _oldValue, prop) {
2680
+ if (this.input !== undefined) {
2681
+ this.input[prop] = newValue;
2682
+ this.checkValidity();
2683
+ if (this.hasDisplayedError) {
2684
+ this.setErrorMessage();
2685
+ this.hasDisplayedError = false;
2686
+ }
2687
+ }
2688
+ }
2586
2689
  /**
2587
2690
  * Public method to play input focus
2588
2691
  *
@@ -2598,8 +2701,8 @@ const MgInputText = class {
2598
2701
  */
2599
2702
  async displayError() {
2600
2703
  this.checkValidity();
2601
- this.checkError();
2602
- this.hasError = this.invalid;
2704
+ this.setErrorMessage();
2705
+ this.hasDisplayedError = this.invalid;
2603
2706
  }
2604
2707
  /*************
2605
2708
  * Lifecycle *
@@ -2634,17 +2737,23 @@ const MgInputText = class {
2634
2737
  '--mg-character-left-message-length': (this.displayCharacterLeft
2635
2738
  ? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
2636
2739
  : 0).toString(),
2637
- } }, this.icon !== undefined && index.h("mg-icon", { icon: this.icon }), index.h("input", { type: this.type, class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), this.displayCharacterLeft && this.maxlength > 0 && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))), index.h("slot", { name: "append-input" })));
2740
+ } }, this.icon !== undefined && index.h("mg-icon", { icon: this.icon }), index.h("input", { type: this.type, class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
2741
+ if (el !== null)
2742
+ this.input = el;
2743
+ } }), this.displayCharacterLeft && this.maxlength > 0 && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))), index.h("slot", { name: "append-input" })));
2638
2744
  }
2639
2745
  get element() { return index.getElement(this); }
2640
2746
  static get watchers() { return {
2641
2747
  "value": ["handleValue"],
2642
- "icon": ["validateIcon"]
2748
+ "icon": ["validateIcon"],
2749
+ "required": ["handleValidityChange"],
2750
+ "readonly": ["handleValidityChange"],
2751
+ "disabled": ["handleValidityChange"]
2643
2752
  }; }
2644
2753
  };
2645
2754
  MgInputText.style = mgInputTextCss;
2646
2755
 
2647
- const mgInputTextareaCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input .mg-input__box{display:block;height:auto;resize:none}.mg-input .mg-input__box.mg-input__box--resizable{resize:both}.mg-input .mg-input__box.mg-input__box--resizable-horizontal{resize:horizontal}.mg-input .mg-input__box.mg-input__box--resizable-vertical{resize:vertical}.mg-input__with-character-left{width:100%}.mg-input__with-character-left mg-character-left{display:block;visibility:hidden;margin-top:0.2rem;text-align:end}.mg-input.is-focused .mg-input__with-character-left mg-character-left{visibility:visible}@-moz-document url-prefix(){.mg-input__box{overflow-x:hidden}}";
2756
+ const mgInputTextareaCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input .mg-input__box{display:block;height:auto;resize:none}.mg-input .mg-input__box.mg-input__box--resizable{resize:both}.mg-input .mg-input__box.mg-input__box--resizable-horizontal{resize:horizontal}.mg-input .mg-input__box.mg-input__box--resizable-vertical{resize:vertical}.mg-input__with-character-left{width:100%}.mg-input__with-character-left mg-character-left{display:block;visibility:hidden;margin-top:0.2rem;text-align:end}.mg-input.is-focused .mg-input__with-character-left mg-character-left{visibility:visible}@-moz-document url-prefix(){.mg-input__box{overflow-x:hidden}}";
2648
2757
 
2649
2758
  const MgInputTextarea = class {
2650
2759
  constructor(hostRef) {
@@ -2654,11 +2763,11 @@ const MgInputTextarea = class {
2654
2763
  /************
2655
2764
  * Internal *
2656
2765
  ************/
2657
- // classes
2766
+ // Classes
2658
2767
  this.classFocus = 'is-focused';
2659
2768
  this.classHasDisplayCharacterLeft = 'mg-input--has-display-character-left';
2660
- // hasError (triggered by blur event)
2661
- this.hasError = false;
2769
+ // hasDisplayedError (triggered by blur event)
2770
+ this.hasDisplayedError = false;
2662
2771
  /**
2663
2772
  * Input name
2664
2773
  * If not set the value equals the identifier
@@ -2708,9 +2817,9 @@ const MgInputTextarea = class {
2708
2817
  * Handle input event
2709
2818
  */
2710
2819
  this.handleInput = () => {
2711
- if (this.hasError) {
2820
+ if (this.hasDisplayedError) {
2712
2821
  this.checkValidity();
2713
- this.checkError();
2822
+ this.setErrorMessage();
2714
2823
  }
2715
2824
  this.value = this.input.value;
2716
2825
  };
@@ -2742,19 +2851,16 @@ const MgInputTextarea = class {
2742
2851
  * Check if input is valid
2743
2852
  */
2744
2853
  this.checkValidity = () => {
2745
- if (!this.readonly && this.input !== undefined) {
2746
- const validity = this.input.checkValidity && this.input.checkValidity() && this.getPatternValidity();
2747
- // Set validity
2748
- this.valid = validity;
2749
- this.invalid = !validity;
2750
- //Send event
2751
- this.inputValid.emit(validity);
2752
- }
2854
+ var _a;
2855
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined && this.input.checkValidity() && this.getPatternValidity());
2856
+ this.invalid = !this.valid;
2857
+ // We need to send valid event even if it is the same value
2858
+ this.inputValid.emit(this.valid);
2753
2859
  };
2754
2860
  /**
2755
- * Check input errors
2861
+ * Set input error message
2756
2862
  */
2757
- this.checkError = () => {
2863
+ this.setErrorMessage = () => {
2758
2864
  // Set error message
2759
2865
  this.errorMessage = undefined;
2760
2866
  // Does not match pattern
@@ -2782,6 +2888,16 @@ const MgInputTextarea = class {
2782
2888
  this.checkValidity();
2783
2889
  this.valueChange.emit(newValue);
2784
2890
  }
2891
+ handleValidityChange(newValue, _oldValue, prop) {
2892
+ if (this.input !== undefined) {
2893
+ this.input[prop] = newValue;
2894
+ this.checkValidity();
2895
+ if (this.hasDisplayedError) {
2896
+ this.setErrorMessage();
2897
+ this.hasDisplayedError = false;
2898
+ }
2899
+ }
2900
+ }
2785
2901
  validateDisplayCharacterLeft(newValue) {
2786
2902
  if (newValue) {
2787
2903
  this.classList.add(this.classHasDisplayCharacterLeft);
@@ -2797,8 +2913,8 @@ const MgInputTextarea = class {
2797
2913
  */
2798
2914
  async displayError() {
2799
2915
  this.checkValidity();
2800
- this.checkError();
2801
- this.hasError = this.invalid;
2916
+ this.setErrorMessage();
2917
+ this.hasDisplayedError = this.invalid;
2802
2918
  }
2803
2919
  /*************
2804
2920
  * Lifecycle *
@@ -2833,11 +2949,17 @@ const MgInputTextarea = class {
2833
2949
  'mg-input__box--resizable': this.resizable === 'both',
2834
2950
  'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
2835
2951
  'mg-input__box--resizable-vertical': this.resizable === 'vertical',
2836
- }, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), this.displayCharacterLeft && this.maxlength > 0 && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
2952
+ }, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
2953
+ if (el !== null)
2954
+ this.input = el;
2955
+ } }), this.displayCharacterLeft && this.maxlength > 0 && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
2837
2956
  }
2838
2957
  get element() { return index.getElement(this); }
2839
2958
  static get watchers() { return {
2840
2959
  "value": ["handleValue"],
2960
+ "required": ["handleValidityChange"],
2961
+ "readonly": ["handleValidityChange"],
2962
+ "disabled": ["handleValidityChange"],
2841
2963
  "displayCharacterLeft": ["validateDisplayCharacterLeft"]
2842
2964
  }; }
2843
2965
  };
@@ -2910,7 +3032,7 @@ const MgInputToggle = class {
2910
3032
  /************
2911
3033
  * Internal *
2912
3034
  ************/
2913
- // classes
3035
+ // Classes
2914
3036
  this.classReadonly = 'mg-input--toggle-readonly';
2915
3037
  this.classDisabled = 'mg-input--toggle-disabled';
2916
3038
  this.classIsActive = 'mg-input--toggle-is-active';
@@ -3108,7 +3230,7 @@ const MgMessage = class {
3108
3230
  /************
3109
3231
  * Internal *
3110
3232
  ************/
3111
- // classes
3233
+ // Classes
3112
3234
  this.classHide = 'mg-message--hide';
3113
3235
  // IDs
3114
3236
  this.closeButtonId = '';
@@ -3386,10 +3508,6 @@ const MgModal = class {
3386
3508
  */
3387
3509
  componentDidLoad() {
3388
3510
  new MutationObserver(mutationList => {
3389
- /*
3390
- TODO find a way to cover this callback
3391
- */
3392
- /* istanbul ignore next */
3393
3511
  if (mutationList.some(mutation => mutation.attributeName === 'aria-hidden' && mutation.target.ariaHidden === null)) {
3394
3512
  this.setFocus();
3395
3513
  }
@@ -5907,7 +6025,7 @@ const MgTag = class {
5907
6025
  /************
5908
6026
  * Internal *
5909
6027
  ************/
5910
- // classes
6028
+ // Classes
5911
6029
  this.classOutline = `mg-tag--outline`;
5912
6030
  /**************
5913
6031
  * Decorators *