@mgdis/mg-components 5.1.0 → 5.3.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 (108) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/{mg-badge_27.cjs.entry.js → mg-badge_29.cjs.entry.js} +730 -242
  3. package/dist/cjs/mg-components.cjs.js +1 -1
  4. package/dist/collection/collection-manifest.json +3 -1
  5. package/dist/collection/components/atoms/mg-badge/mg-badge.js +14 -19
  6. package/dist/collection/components/atoms/mg-button/mg-button.js +3 -3
  7. package/dist/collection/components/atoms/mg-icon/mg-icon.js +17 -7
  8. package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
  9. package/dist/collection/components/molecules/inputs/MgInput.js +3 -11
  10. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +41 -20
  11. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +50 -39
  12. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +25 -6
  13. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +42 -33
  14. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +25 -6
  15. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +36 -17
  16. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +35 -14
  17. package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +2 -3
  18. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +28 -6
  19. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +36 -17
  20. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +25 -6
  21. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +38 -19
  22. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +25 -6
  23. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +37 -18
  24. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
  25. package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +87 -0
  26. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +8 -0
  27. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +10 -0
  28. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +185 -0
  29. package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +32 -0
  30. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +22 -0
  31. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +316 -0
  32. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +324 -0
  33. package/dist/collection/components/molecules/mg-form/mg-form.js +73 -27
  34. package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +6 -6
  35. package/dist/collection/components/molecules/mg-message/mg-message.js +1 -1
  36. package/dist/collection/components/molecules/mg-modal/mg-modal.js +0 -4
  37. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +3 -0
  38. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +67 -17
  39. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +10 -4
  40. package/dist/collection/locales/index.js +3 -1
  41. package/dist/collection/utils/unit.test.utils.js +51 -0
  42. package/dist/collection/variables.css +29 -7
  43. package/dist/components/MgInput.js +4 -12
  44. package/dist/components/index.d.ts +2 -0
  45. package/dist/components/index.js +2 -0
  46. package/dist/components/index2.js +3 -1
  47. package/dist/components/mg-badge2.js +1 -1
  48. package/dist/components/mg-button2.js +3 -3
  49. package/dist/components/mg-form.js +67 -26
  50. package/dist/components/mg-input-checkbox.js +36 -21
  51. package/dist/components/mg-input-date.js +44 -39
  52. package/dist/components/mg-input-numeric.js +37 -34
  53. package/dist/components/mg-input-password.js +32 -19
  54. package/dist/components/mg-input-radio.js +30 -15
  55. package/dist/components/mg-input-select2.js +32 -19
  56. package/dist/components/mg-input-text2.js +34 -21
  57. package/dist/components/mg-input-textarea.js +32 -19
  58. package/dist/components/mg-input-toggle.js +1 -1
  59. package/dist/components/mg-menu-item.d.ts +11 -0
  60. package/dist/components/mg-menu-item.js +273 -0
  61. package/dist/components/mg-menu.conf.js +10 -0
  62. package/dist/components/mg-menu.d.ts +11 -0
  63. package/dist/components/mg-menu.js +149 -0
  64. package/dist/components/mg-message.js +1 -1
  65. package/dist/components/mg-modal.js +0 -4
  66. package/dist/components/mg-tabs.js +6 -2
  67. package/dist/components/mg-tag.js +1 -1
  68. package/dist/esm/loader.js +1 -1
  69. package/dist/esm/{mg-badge_27.entry.js → mg-badge_29.entry.js} +729 -243
  70. package/dist/esm/mg-components.js +1 -1
  71. package/dist/mg-components/mg-components.css +1 -1
  72. package/dist/mg-components/mg-components.esm.js +1 -1
  73. package/dist/mg-components/p-204af46f.entry.js +1 -0
  74. package/dist/mg-components/variables.css +29 -7
  75. package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +2 -2
  76. package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +5 -5
  77. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -8
  78. package/dist/types/components/atoms/mg-button/mg-button.d.ts +2 -2
  79. package/dist/types/components/atoms/mg-icon/doc/mg-icon.stories.d.ts +2 -2
  80. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +10 -2
  81. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +7 -6
  82. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +10 -8
  83. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +3 -8
  84. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +3 -8
  85. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -3
  86. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
  87. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -3
  88. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -4
  89. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -3
  90. package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +17 -0
  91. package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +7 -0
  92. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +69 -0
  93. package/dist/types/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.d.ts +11 -0
  94. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +24 -0
  95. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +119 -0
  96. package/dist/types/components/molecules/mg-form/mg-form.d.ts +21 -1
  97. package/dist/types/components/molecules/mg-message/mg-message.d.ts +3 -0
  98. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -0
  99. package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +1 -1
  100. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +12 -4
  101. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +6 -6
  102. package/dist/types/components.d.ts +91 -14
  103. package/dist/types/locales/index.d.ts +7 -1
  104. package/dist/types/stories/icons.stories.d.ts +1 -1
  105. package/package.json +7 -8
  106. package/dist/collection/utils/test.utils.js +0 -38
  107. package/dist/mg-components/p-e131701a.entry.js +0 -1
  108. package/dist/types/utils/test.utils.d.ts +0 -17
@@ -11,6 +11,8 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
11
11
  this.__attachShadow();
12
12
  this.formValid = createEvent(this, "form-valid", 7);
13
13
  this.formSubmit = createEvent(this, "form-submit", 7);
14
+ // Classes
15
+ this.classAllRequired = 'mg-form--all-required';
14
16
  /**
15
17
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
16
18
  * If not set, it will be created.
@@ -40,17 +42,24 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
40
42
  * @returns {void}
41
43
  */
42
44
  this.setRequiredMessage = () => {
43
- // Get required fields
44
- const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !this.disabled);
45
- // All fields are required
46
- // mg-input-toggle can not be required
47
- if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
48
- this.requiredMessage = this.messages.form.allRequired;
49
- this.classList.add('mg-form--all-required');
50
- }
51
- // Some fields are required
52
- else if (requiredInputs.length > 0) {
53
- this.requiredMessage = this.messages.form.required;
45
+ // init required message
46
+ this.requiredMessage = null;
47
+ this.classList.delete(this.classAllRequired);
48
+ // If the form is disabled or readonly none of them are required
49
+ // Check if all fields are not editable (readonly or disabled)
50
+ if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
51
+ // Get required fields
52
+ const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !input.readonly);
53
+ // All fields are required
54
+ // mg-input-toggle can not be required
55
+ if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
56
+ this.requiredMessage = this.messages.form.allRequired;
57
+ this.classList.add(this.classAllRequired);
58
+ }
59
+ // Some fields are required
60
+ else if (requiredInputs.length > 0) {
61
+ this.requiredMessage = this.messages.form.required;
62
+ }
54
63
  }
55
64
  };
56
65
  /**
@@ -59,15 +68,46 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
59
68
  * @returns {void}
60
69
  */
61
70
  this.checkValidity = () => {
62
- const validity = !this.mgInputs.some(input => input.invalid);
63
- this.valid = validity;
64
- this.invalid = !validity;
65
- this.formValid.emit(validity);
71
+ // Update required on input event
72
+ this.setRequiredMessage();
73
+ this.valid = !this.mgInputs.some(input => input.invalid);
74
+ this.invalid = !this.valid;
75
+ // We need to send valid event if it is the same value
76
+ this.formValid.emit(this.valid);
66
77
  };
78
+ /**
79
+ * Handle Form Submit
80
+ *
81
+ * @param {SubmitEvent} event submit event
82
+ * @returns {void}
83
+ */
67
84
  this.handleFormSubmit = (event) => {
68
85
  event.preventDefault();
69
86
  this.formSubmit.emit();
70
87
  };
88
+ /**
89
+ * Set mgInputs
90
+ *
91
+ * @returns {void}
92
+ */
93
+ this.setMgInputs = () => {
94
+ // Get slotted mgInputs
95
+ this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
96
+ // Set inputs readonly or disabled based on form configuration
97
+ // Othewise listen to events
98
+ this.mgInputs.map(input => {
99
+ if (this.readonly)
100
+ input.readonly = true;
101
+ else if (this.disabled)
102
+ input.disabled = true;
103
+ else
104
+ input.addEventListener('input-valid', this.checkValidity);
105
+ });
106
+ };
107
+ }
108
+ handleAttributeChange() {
109
+ this.setMgInputs();
110
+ this.setRequiredMessage();
71
111
  }
72
112
  /**
73
113
  * Public method to display errors
@@ -93,26 +133,18 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
93
133
  componentWillLoad() {
94
134
  // Get locales
95
135
  this.messages = initLocales(this.element).messages;
96
- // Get slotted mgInputs
97
- this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
98
136
  // Get slotted mgButtons
99
- this.mgButtons = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-BUTTON'));
137
+ this.mgButtons = Array.from(this.element.querySelectorAll('mg-button'));
100
138
  // Set button form identifier
101
139
  this.mgButtons.forEach(mgButton => {
102
140
  mgButton.setAttribute('form', this.identifier);
103
141
  });
142
+ // Set mgInputs
143
+ this.setMgInputs();
104
144
  // Define required message
105
145
  this.setRequiredMessage();
106
146
  // Check validity when slotted mgInputs are ready
107
147
  Promise.all(this.mgInputs.map(async (input) => {
108
- // Set inputs readonly or disabled based on form configuration
109
- // Othewise listen to events
110
- if (this.readonly)
111
- input.readonly = true;
112
- else if (this.disabled)
113
- input.disabled = true;
114
- else
115
- input.addEventListener('input-valid', this.checkValidity);
116
148
  try {
117
149
  await input.componentOnReady();
118
150
  }
@@ -135,6 +167,10 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
135
167
  });
136
168
  }
137
169
  });
170
+ // Update mgInputs when mgForm content change
171
+ new MutationObserver(() => {
172
+ this.setMgInputs();
173
+ }).observe(this.element, { childList: true });
138
174
  }
139
175
  /**
140
176
  * Render
@@ -145,6 +181,10 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
145
181
  return (h("form", { class: this.classList.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit }, this.requiredMessage && h("p", { innerHTML: this.requiredMessage }), h("slot", null), !this.readonly && !this.disabled && h("slot", { name: "actions" })));
146
182
  }
147
183
  get element() { return this; }
184
+ static get watchers() { return {
185
+ "readonly": ["handleAttributeChange"],
186
+ "disabled": ["handleAttributeChange"]
187
+ }; }
148
188
  static get style() { return mgFormCss; }
149
189
  }, [1, "mg-form", {
150
190
  "identifier": [1],
@@ -154,6 +194,7 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
154
194
  "valid": [1028],
155
195
  "invalid": [1028],
156
196
  "classList": [32],
197
+ "requiredMessage": [32],
157
198
  "displayError": [64]
158
199
  }]);
159
200
  function defineCustomElement$1() {
@@ -27,6 +27,8 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
27
27
  ************/
28
28
  // HTML selector
29
29
  this.inputs = [];
30
+ // hasDisplayedError (triggered by blur event)
31
+ this.hasDisplayedError = false;
30
32
  /**
31
33
  * Input name
32
34
  * If not set the value equals the identifier
@@ -81,25 +83,27 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
81
83
  this.handleBlur = () => {
82
84
  // Check validity
83
85
  this.checkValidity();
84
- this.checkError();
86
+ this.setErrorMessage();
85
87
  };
88
+ /**
89
+ * get invalid element
90
+ *
91
+ * @returns {HTMLInputElement} element
92
+ */
93
+ this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
86
94
  /**
87
95
  * Check if input is valid
88
96
  */
89
97
  this.checkValidity = () => {
90
- if (!this.readonly) {
91
- const validity = this.getInvalidElement() === undefined;
92
- // Set validity
93
- this.valid = validity;
94
- this.invalid = !validity;
95
- //Send event
96
- this.inputValid.emit(validity);
97
- }
98
+ this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
99
+ this.invalid = !this.valid;
100
+ // We need to send valid event even if it is the same value
101
+ this.inputValid.emit(this.valid);
98
102
  };
99
103
  /**
100
- * Check input errors
104
+ * Set input error message
101
105
  */
102
- this.checkError = () => {
106
+ this.setErrorMessage = () => {
103
107
  const invalidElement = this.getInvalidElement();
104
108
  // Set error message
105
109
  this.errorMessage = undefined;
@@ -107,12 +111,6 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
107
111
  this.errorMessage = this.messages.errors.required;
108
112
  }
109
113
  };
110
- /**
111
- * get invalid element
112
- *
113
- * @returns {HTMLInputElement} element
114
- */
115
- this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
116
114
  }
117
115
  validateValue(newValue) {
118
116
  if (newValue && newValue.every(item => isCheckboxItem(item))) {
@@ -128,6 +126,16 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
128
126
  throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
129
127
  }
130
128
  }
129
+ handleValidityChange(newValue, _oldValue, prop) {
130
+ this.inputs.forEach(input => {
131
+ input[prop] = newValue;
132
+ });
133
+ this.checkValidity();
134
+ if (this.hasDisplayedError) {
135
+ this.setErrorMessage();
136
+ this.hasDisplayedError = false;
137
+ }
138
+ }
131
139
  /**
132
140
  * Public method to display errors
133
141
  *
@@ -135,7 +143,8 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
135
143
  */
136
144
  async displayError() {
137
145
  this.checkValidity();
138
- this.checkError();
146
+ this.setErrorMessage();
147
+ this.hasDisplayedError = this.invalid;
139
148
  }
140
149
  /*************
141
150
  * Lifecycle *
@@ -163,15 +172,21 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
163
172
  * @returns {HTMLElement} HTML Element
164
173
  */
165
174
  render() {
166
- return (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 }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
175
+ return (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 }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
167
176
  .filter(item => {
168
177
  return !this.readonly || item.value;
169
178
  })
170
- .map(input => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, 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) }), h("label", { htmlFor: input.id }, input.title)))))));
179
+ .map((input, index) => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, 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 => {
180
+ if (el !== null)
181
+ this.inputs[index] = el;
182
+ } }), h("label", { htmlFor: input.id }, input.title)))))));
171
183
  }
172
184
  get element() { return this; }
173
185
  static get watchers() { return {
174
- "value": ["validateValue"]
186
+ "value": ["validateValue"],
187
+ "required": ["handleValidityChange"],
188
+ "readonly": ["handleValidityChange"],
189
+ "disabled": ["handleValidityChange"]
175
190
  }; }
176
191
  static get style() { return mgInputCheckboxCss; }
177
192
  }, [1, "mg-input-checkbox", {
@@ -24,8 +24,8 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
24
24
  this.__attachShadow();
25
25
  this.valueChange = createEvent(this, "value-change", 7);
26
26
  this.inputValid = createEvent(this, "input-valid", 7);
27
- // hasError (triggered by blur event)
28
- this.hasError = false;
27
+ // hasDisplayedError (triggered by blur event)
28
+ this.hasDisplayedError = false;
29
29
  /**
30
30
  * Input name
31
31
  * If not set the value equals the identifier
@@ -56,8 +56,8 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
56
56
  */
57
57
  this.handleInput = () => {
58
58
  this.checkValidity();
59
- if (this.hasError) {
60
- this.checkError();
59
+ if (this.hasDisplayedError) {
60
+ this.setErrorMessage();
61
61
  }
62
62
  this.value = this.input.value;
63
63
  };
@@ -71,14 +71,11 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
71
71
  * Check if input is valid
72
72
  */
73
73
  this.checkValidity = () => {
74
- if (!this.readonly && this.input !== undefined) {
75
- const validity = this.input.checkValidity();
76
- // Set validity
77
- this.valid = validity;
78
- this.invalid = !validity;
79
- //Send event
80
- this.inputValid.emit(validity);
81
- }
74
+ var _a;
75
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
76
+ this.invalid = !this.valid;
77
+ // We need to send valid event even if it is the same value
78
+ this.inputValid.emit(this.valid);
82
79
  };
83
80
  /**
84
81
  * get input error code
@@ -107,48 +104,50 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
107
104
  return inputError;
108
105
  };
109
106
  /**
110
- * Set error message
107
+ * Check input errors
111
108
  *
112
109
  * @returns {void}
113
110
  */
114
111
  this.setErrorMessage = () => {
115
112
  var _a;
116
- const inputError = this.getInputError();
117
- // required
118
- if (inputError === InputError.REQUIRED) {
119
- this.errorMessage = this.messages.errors[inputError];
120
- }
121
- // min, max & minMax
122
- else if ([InputError.MIN, InputError.MAX, InputError.MINMAX].includes(inputError)) {
123
- this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));
124
- }
125
- // wrong date format
126
- // element.validity.badInput is default error message
127
- else {
128
- 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));
129
- }
130
- };
131
- /**
132
- * Check input errors
133
- *
134
- * @returns {void}
135
- */
136
- this.checkError = () => {
137
113
  // Set error message
138
114
  this.errorMessage = undefined;
139
115
  if (!this.valid) {
140
- this.setErrorMessage();
116
+ const inputError = this.getInputError();
117
+ // required
118
+ if (inputError === InputError.REQUIRED) {
119
+ this.errorMessage = this.messages.errors[inputError];
120
+ }
121
+ // min, max & minMax
122
+ else if ([InputError.MIN, InputError.MAX, InputError.MINMAX].includes(inputError)) {
123
+ this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));
124
+ }
125
+ // wrong date format
126
+ // element.validity.badInput is default error message
127
+ else {
128
+ 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));
129
+ }
141
130
  }
142
131
  };
143
132
  }
144
133
  validateValue(newValue) {
145
- if (newValue !== undefined && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
134
+ if (newValue !== undefined && newValue !== null && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
146
135
  throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
147
136
  }
148
137
  else {
149
138
  this.valueChange.emit(this.value);
150
139
  }
151
140
  }
141
+ handleValidityChange(newValue, _oldValue, prop) {
142
+ if (this.input !== undefined) {
143
+ this.input[prop] = newValue;
144
+ this.checkValidity();
145
+ if (this.hasDisplayedError) {
146
+ this.setErrorMessage();
147
+ this.hasDisplayedError = false;
148
+ }
149
+ }
150
+ }
152
151
  validateMinMax(newValue) {
153
152
  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)))) {
154
153
  throw new Error("<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd");
@@ -161,8 +160,8 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
161
160
  */
162
161
  async displayError() {
163
162
  this.checkValidity();
164
- this.checkError();
165
- this.hasError = this.invalid;
163
+ this.setErrorMessage();
164
+ this.hasDisplayedError = this.invalid;
166
165
  }
167
166
  /*************
168
167
  * Lifecycle *
@@ -194,11 +193,17 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
194
193
  * @returns {HTMLElement} HTML Element
195
194
  */
196
195
  render() {
197
- return (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 }, 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) })));
196
+ return (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 }, 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 => {
197
+ if (el !== null)
198
+ this.input = el;
199
+ } })));
198
200
  }
199
201
  get element() { return this; }
200
202
  static get watchers() { return {
201
203
  "value": ["validateValue"],
204
+ "required": ["handleValidityChange"],
205
+ "readonly": ["handleValidityChange"],
206
+ "disabled": ["handleValidityChange"],
202
207
  "min": ["validateMinMax"],
203
208
  "max": ["validateMinMax"]
204
209
  }; }
@@ -19,7 +19,7 @@ var InputError;
19
19
  InputError["REQUIRED"] = "required";
20
20
  })(InputError || (InputError = {}));
21
21
 
22
- 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)}";
22
+ 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)}";
23
23
 
24
24
  const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
25
25
  constructor() {
@@ -28,8 +28,8 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
28
28
  this.__attachShadow();
29
29
  this.valueChange = createEvent(this, "value-change", 7);
30
30
  this.inputValid = createEvent(this, "input-valid", 7);
31
- // hasError (triggered by blur event)
32
- this.hasError = false;
31
+ // hasDisplayedError (triggered by blur event)
32
+ this.hasDisplayedError = false;
33
33
  /**
34
34
  * Input name
35
35
  * If not set the value equals the identifier
@@ -85,8 +85,8 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
85
85
  this.handleInput = () => {
86
86
  // Check validity
87
87
  this.checkValidity();
88
- if (this.hasError) {
89
- this.checkError();
88
+ if (this.hasDisplayedError) {
89
+ this.setErrorMessage();
90
90
  }
91
91
  this.value = this.input.value;
92
92
  };
@@ -114,40 +114,27 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
114
114
  * @returns {void}
115
115
  */
116
116
  this.checkValidity = () => {
117
- if (!this.readonly) {
118
- const validity = this.getInputError() === null;
119
- // Set validity
120
- this.valid = validity;
121
- this.invalid = !validity;
122
- //Send event
123
- this.inputValid.emit(validity);
124
- }
117
+ this.valid = this.readonly || this.disabled || this.getInputError() === null;
118
+ this.invalid = !this.valid;
119
+ // We need to send valid event even if it is the same value
120
+ this.inputValid.emit(this.valid);
125
121
  };
126
122
  /**
127
- * Set error message
123
+ * Set input error message
128
124
  *
129
125
  * @returns {void}
130
126
  */
131
127
  this.setErrorMessage = () => {
132
- const inputError = this.getInputError();
133
- if (inputError === InputError.REQUIRED) {
134
- this.errorMessage = this.messages.errors[inputError];
135
- }
136
- else {
137
- this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
138
- }
139
- };
140
- /**
141
- * Check input errors
142
- *
143
- * @returns {void}
144
- */
145
- this.checkError = () => {
146
128
  // Set error message
147
129
  this.errorMessage = undefined;
148
- // Update class
149
130
  if (!this.valid) {
150
- this.setErrorMessage();
131
+ const inputError = this.getInputError();
132
+ if (inputError === InputError.REQUIRED) {
133
+ this.errorMessage = this.messages.errors[inputError];
134
+ }
135
+ else {
136
+ this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
137
+ }
151
138
  }
152
139
  };
153
140
  /**
@@ -157,7 +144,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
157
144
  */
158
145
  this.getInputError = () => {
159
146
  let inputError = null;
160
- if (this.input === undefined)
147
+ if (this.input === undefined || this.input === null)
161
148
  return inputError;
162
149
  // required
163
150
  if (!this.input.checkValidity() && this.input.validity.valueMissing) {
@@ -224,6 +211,16 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
224
211
  this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
225
212
  }
226
213
  }
214
+ handleValidityChange(newValue, _oldValue, prop) {
215
+ if (this.input !== undefined) {
216
+ this.input[prop] = newValue;
217
+ this.checkValidity();
218
+ if (this.hasDisplayedError) {
219
+ this.setErrorMessage();
220
+ this.hasDisplayedError = false;
221
+ }
222
+ }
223
+ }
227
224
  validateType(newValue) {
228
225
  if (!types.includes(newValue)) {
229
226
  throw new Error(`<mg-input-numeric> prop "type" must be one of : ${types.join(', ')}`);
@@ -246,8 +243,8 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
246
243
  */
247
244
  async displayError() {
248
245
  this.checkValidity();
249
- this.checkError();
250
- this.hasError = this.invalid;
246
+ this.setErrorMessage();
247
+ this.hasDisplayedError = this.invalid;
251
248
  }
252
249
  /**
253
250
  * Displayed value in input
@@ -290,11 +287,17 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
290
287
  * @returns {HTMLElement} HTML Element
291
288
  */
292
289
  render() {
293
- return (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 }, 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) }), h("slot", { name: "append-input" })));
290
+ return (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 }, 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 => {
291
+ if (el !== null)
292
+ this.input = el;
293
+ } }), h("slot", { name: "append-input" })));
294
294
  }
295
295
  get element() { return this; }
296
296
  static get watchers() { return {
297
297
  "value": ["validateValue"],
298
+ "required": ["handleValidityChange"],
299
+ "readonly": ["handleValidityChange"],
300
+ "disabled": ["handleValidityChange"],
298
301
  "type": ["validateType"],
299
302
  "integerLength": ["validateIntegerLength"],
300
303
  "decimalLength": ["validateDecimalLength"]