@mgdis/mg-components 5.0.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 (120) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/{mg-badge_24.cjs.entry.js → mg-badge_27.cjs.entry.js} +892 -295
  3. package/dist/cjs/mg-components.cjs.js +1 -1
  4. package/dist/collection/collection-manifest.json +2 -0
  5. package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -1
  6. package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +1 -0
  7. package/dist/collection/components/atoms/mg-button/mg-button.css +8 -0
  8. package/dist/collection/components/atoms/mg-button/mg-button.js +41 -3
  9. package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +18 -0
  10. package/dist/collection/components/atoms/mg-card/mg-card.css +7 -0
  11. package/dist/collection/components/atoms/mg-card/mg-card.js +26 -0
  12. package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +18 -0
  13. package/dist/collection/components/atoms/mg-divider/mg-divider.css +9 -0
  14. package/dist/collection/components/atoms/mg-divider/mg-divider.js +57 -0
  15. package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
  16. package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -5
  17. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +0 -20
  18. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +1 -1
  19. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +2 -1
  20. package/dist/collection/components/molecules/inputs/MgInput.js +3 -11
  21. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +41 -20
  22. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +50 -39
  23. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +25 -6
  24. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +42 -33
  25. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +25 -6
  26. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +36 -17
  27. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +35 -14
  28. package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +2 -3
  29. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +28 -6
  30. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +36 -17
  31. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +25 -6
  32. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +38 -19
  33. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +25 -6
  34. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +37 -18
  35. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
  36. package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +1 -0
  37. package/dist/collection/components/molecules/mg-details/mg-details.css +29 -0
  38. package/dist/collection/components/molecules/mg-details/mg-details.js +26 -4
  39. package/dist/collection/components/molecules/mg-form/mg-form.js +73 -27
  40. package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +6 -6
  41. package/dist/collection/components/molecules/mg-message/mg-message.js +1 -1
  42. package/dist/collection/components/molecules/mg-modal/mg-modal.css +2 -1
  43. package/dist/collection/components/molecules/mg-modal/mg-modal.js +48 -4
  44. package/dist/collection/components/molecules/mg-panel/mg-panel.css +5 -14
  45. package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -5
  46. package/dist/collection/components/molecules/mg-popover/mg-popover.css +1 -1
  47. package/dist/collection/components/molecules/mg-popover/mg-popover.js +3 -2
  48. package/dist/collection/utils/components.utils.js +10 -6
  49. package/dist/collection/utils/unit.test.utils.js +51 -0
  50. package/dist/collection/variables.css +23 -8
  51. package/dist/components/MgInput.js +4 -12
  52. package/dist/components/components.utils.js +11 -7
  53. package/dist/components/index.d.ts +2 -0
  54. package/dist/components/index.js +2 -0
  55. package/dist/components/mg-badge2.js +1 -1
  56. package/dist/components/mg-button2.js +23 -4
  57. package/dist/components/mg-card.d.ts +11 -0
  58. package/dist/components/mg-card.js +42 -0
  59. package/dist/components/mg-details.js +8 -3
  60. package/dist/components/mg-divider.d.ts +11 -0
  61. package/dist/components/mg-divider.js +51 -0
  62. package/dist/components/mg-form.js +67 -26
  63. package/dist/components/mg-input-checkbox.js +36 -21
  64. package/dist/components/mg-input-date.js +44 -39
  65. package/dist/components/mg-input-numeric.js +37 -34
  66. package/dist/components/mg-input-password.js +32 -19
  67. package/dist/components/mg-input-radio.js +30 -15
  68. package/dist/components/mg-input-select2.js +32 -19
  69. package/dist/components/mg-input-text2.js +34 -21
  70. package/dist/components/mg-input-textarea.js +32 -19
  71. package/dist/components/mg-input-toggle.js +1 -1
  72. package/dist/components/mg-message.js +1 -1
  73. package/dist/components/mg-modal.js +49 -5
  74. package/dist/components/mg-panel.js +1 -1
  75. package/dist/components/mg-popover.js +3 -2
  76. package/dist/components/mg-tag.js +1 -1
  77. package/dist/components/mg-tooltip2.js +2 -4
  78. package/dist/esm/loader.js +1 -1
  79. package/dist/esm/{mg-badge_24.entry.js → mg-badge_27.entry.js} +839 -245
  80. package/dist/esm/mg-components.js +1 -1
  81. package/dist/mg-components/mg-components.css +1 -1
  82. package/dist/mg-components/mg-components.esm.js +1 -1
  83. package/dist/mg-components/p-b2b07c3f.entry.js +1 -0
  84. package/dist/mg-components/variables.css +23 -8
  85. package/dist/types/components/atoms/mg-button/mg-button.d.ts +8 -2
  86. package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +6 -0
  87. package/dist/types/components/atoms/mg-card/mg-card.d.ts +11 -0
  88. package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +6 -0
  89. package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +15 -0
  90. package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -6
  91. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +0 -8
  92. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +1 -1
  93. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +10 -8
  94. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +3 -8
  95. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +3 -8
  96. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -3
  97. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
  98. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -3
  99. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -4
  100. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -3
  101. package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
  102. package/dist/types/components/molecules/mg-form/mg-form.d.ts +21 -1
  103. package/dist/types/components/molecules/mg-message/mg-message.d.ts +3 -0
  104. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +11 -0
  105. package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -6
  106. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +1 -1
  107. package/dist/types/components.d.ts +55 -6
  108. package/dist/types/utils/components.utils.d.ts +7 -3
  109. package/package.json +9 -9
  110. package/dist/cjs/index-179621c8.js +0 -244
  111. package/dist/cjs/mg-modal.cjs.entry.js +0 -128
  112. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +0 -20
  113. package/dist/collection/utils/test.utils.js +0 -38
  114. package/dist/esm/index-7efedd97.js +0 -238
  115. package/dist/esm/mg-modal.entry.js +0 -124
  116. package/dist/mg-components/p-5f89600c.js +0 -1
  117. package/dist/mg-components/p-b60a4c53.entry.js +0 -1
  118. package/dist/mg-components/p-df947fa5.entry.js +0 -1
  119. package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +0 -8
  120. package/dist/types/utils/test.utils.d.ts +0 -17
@@ -185,21 +185,40 @@
185
185
  .mg-input.mg-input--width-full:not(.mg-input--label-on-top) {
186
186
  justify-content: space-between;
187
187
  }
188
+ .mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box {
189
+ width: 100%;
190
+ }
188
191
  .mg-input.mg-input--width-full .mg-input__input-container {
189
192
  flex: auto;
190
193
  width: 100%;
191
194
  }
192
195
  .mg-input.mg-input--width-full .mg-input__input-container .mg-input__box {
196
+ max-width: 100%;
197
+ }
198
+ .mg-input:not(.mg-input--label-on-top) .mg-input__box {
193
199
  width: 100%;
200
+ max-width: calc(17.7rem + var(--mg-inputs-spacer) * 2);
201
+ min-width: 5rem;
194
202
  }
195
- .mg-input.mg-input--width-16 .mg-input__box {
196
- width: 21rem;
203
+ .mg-input.mg-input--width-16 .mg-input__input-container {
204
+ width: 100%;
197
205
  }
198
- .mg-input.mg-input--width-4 .mg-input__box {
199
- width: 7rem;
206
+ .mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input {
207
+ width: 100%;
208
+ max-width: 21rem;
200
209
  }
201
- .mg-input.mg-input--width-2 .mg-input__box {
202
- width: 5rem;
210
+ .mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left {
211
+ width: 100%;
212
+ }
213
+ .mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box {
214
+ max-width: 21rem;
215
+ min-width: 100%;
216
+ }
217
+ .mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box {
218
+ max-width: 7rem;
219
+ }
220
+ .mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box {
221
+ max-width: 5rem;
203
222
  }
204
223
 
205
224
  /**
@@ -228,4 +247,7 @@
228
247
  padding-top: 0;
229
248
  padding-bottom: 0;
230
249
  padding-right: 1rem;
250
+ }
251
+ .mg-input.mg-input--select:not(.mg-input--label-on-top) .mg-input__box {
252
+ max-width: unset;
231
253
  }
@@ -42,8 +42,8 @@ const groupOptions = (acc, { group, title, value, disabled }) => {
42
42
  };
43
43
  export class MgInputSelect {
44
44
  constructor() {
45
- // hasError (triggered by blur event)
46
- this.hasError = false;
45
+ // hasDisplayedError (triggered by blur event)
46
+ this.hasDisplayedError = false;
47
47
  /**
48
48
  * Input name
49
49
  * If not set the value equals the identifier
@@ -82,8 +82,8 @@ export class MgInputSelect {
82
82
  */
83
83
  this.handleInput = () => {
84
84
  this.checkValidity();
85
- if (this.hasError) {
86
- this.checkError();
85
+ if (this.hasDisplayedError) {
86
+ this.setErrorMessage();
87
87
  }
88
88
  if (this.input.value !== '') {
89
89
  this.value = allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.title === this.input.value).value;
@@ -102,19 +102,16 @@ export class MgInputSelect {
102
102
  * Check if input is valid
103
103
  */
104
104
  this.checkValidity = () => {
105
- if (!this.readonly && this.input !== undefined) {
106
- const validity = this.input.checkValidity && this.input.checkValidity();
107
- // Set validity
108
- this.valid = validity;
109
- this.invalid = !validity;
110
- //Send event
111
- this.inputValid.emit(validity);
112
- }
105
+ var _a;
106
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
107
+ this.invalid = !this.valid;
108
+ // We need to send valid event even if it is the same value
109
+ this.inputValid.emit(this.valid);
113
110
  };
114
111
  /**
115
- * Check input errors
112
+ * Set input error message
116
113
  */
117
- this.checkError = () => {
114
+ this.setErrorMessage = () => {
118
115
  // Set error message
119
116
  this.errorMessage = undefined;
120
117
  if (!this.valid && this.input.validity.valueMissing) {
@@ -153,6 +150,16 @@ export class MgInputSelect {
153
150
  throw new Error('<mg-input-select> prop "items" is required and all items must be the same type, string or Option.');
154
151
  }
155
152
  }
153
+ handleValidityChange(newValue, _oldValue, prop) {
154
+ if (this.input !== undefined) {
155
+ this.input[prop] = newValue;
156
+ this.checkValidity();
157
+ if (this.hasDisplayedError) {
158
+ this.setErrorMessage();
159
+ this.hasDisplayedError = false;
160
+ }
161
+ }
162
+ }
156
163
  /**
157
164
  * Public method to display errors
158
165
  *
@@ -160,8 +167,8 @@ export class MgInputSelect {
160
167
  */
161
168
  async displayError() {
162
169
  this.checkValidity();
163
- this.checkError();
164
- this.hasError = this.invalid;
170
+ this.setErrorMessage();
171
+ this.hasDisplayedError = this.invalid;
165
172
  }
166
173
  /*************
167
174
  * Lifecycle *
@@ -193,7 +200,10 @@ export class MgInputSelect {
193
200
  * @returns {HTMLElement} HTML Element
194
201
  */
195
202
  render() {
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: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, 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
203
+ 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("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 => {
204
+ if (el !== null)
205
+ this.input = el;
206
+ } }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
197
207
  h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map(option => option.group !== undefined ? (h("optgroup", { label: option.group }, option.options.map(optgroup => (h("option", { value: optgroup.title, selected: JSON.stringify(this.value) === JSON.stringify(optgroup.value), disabled: optgroup.disabled }, optgroup.title))))) : (h("option", { value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title))))));
198
208
  }
199
209
  static get is() { return "mg-input-select"; }
@@ -606,6 +616,15 @@ export class MgInputSelect {
606
616
  }, {
607
617
  "propName": "items",
608
618
  "methodName": "validateItems"
619
+ }, {
620
+ "propName": "required",
621
+ "methodName": "handleValidityChange"
622
+ }, {
623
+ "propName": "readonly",
624
+ "methodName": "handleValidityChange"
625
+ }, {
626
+ "propName": "disabled",
627
+ "methodName": "handleValidityChange"
609
628
  }];
610
629
  }
611
630
  }
@@ -185,21 +185,40 @@
185
185
  .mg-input.mg-input--width-full:not(.mg-input--label-on-top) {
186
186
  justify-content: space-between;
187
187
  }
188
+ .mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box {
189
+ width: 100%;
190
+ }
188
191
  .mg-input.mg-input--width-full .mg-input__input-container {
189
192
  flex: auto;
190
193
  width: 100%;
191
194
  }
192
195
  .mg-input.mg-input--width-full .mg-input__input-container .mg-input__box {
196
+ max-width: 100%;
197
+ }
198
+ .mg-input:not(.mg-input--label-on-top) .mg-input__box {
199
+ width: 100%;
200
+ max-width: calc(17.7rem + var(--mg-inputs-spacer) * 2);
201
+ min-width: 5rem;
202
+ }
203
+ .mg-input.mg-input--width-16 .mg-input__input-container {
204
+ width: 100%;
205
+ }
206
+ .mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input {
207
+ width: 100%;
208
+ max-width: 21rem;
209
+ }
210
+ .mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left {
193
211
  width: 100%;
194
212
  }
195
- .mg-input.mg-input--width-16 .mg-input__box {
196
- width: 21rem;
213
+ .mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box {
214
+ max-width: 21rem;
215
+ min-width: 100%;
197
216
  }
198
- .mg-input.mg-input--width-4 .mg-input__box {
199
- width: 7rem;
217
+ .mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box {
218
+ max-width: 7rem;
200
219
  }
201
- .mg-input.mg-input--width-2 .mg-input__box {
202
- width: 5rem;
220
+ .mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box {
221
+ max-width: 5rem;
203
222
  }
204
223
 
205
224
  /**
@@ -7,12 +7,12 @@ export class MgInputText {
7
7
  /************
8
8
  * Internal *
9
9
  ************/
10
- // classes
10
+ // Classes
11
11
  this.classFocus = 'is-focused';
12
12
  this.classIsInputGroupAppend = 'mg-input--is-input-group-append';
13
13
  this.classHasIcon = 'mg-input--has-icon';
14
- // hasError (triggered by blur event)
15
- this.hasError = false;
14
+ // hasDisplayedError (triggered by blur event)
15
+ this.hasDisplayedError = false;
16
16
  /**
17
17
  * Input name
18
18
  * If not set the value equals the identifier
@@ -61,8 +61,8 @@ export class MgInputText {
61
61
  */
62
62
  this.handleInput = () => {
63
63
  this.checkValidity();
64
- if (this.hasError) {
65
- this.checkError();
64
+ if (this.hasDisplayedError) {
65
+ this.setErrorMessage();
66
66
  }
67
67
  this.value = this.input.value;
68
68
  };
@@ -93,21 +93,18 @@ export class MgInputText {
93
93
  * @returns {void}
94
94
  */
95
95
  this.checkValidity = () => {
96
- if (!this.readonly && this.input !== undefined) {
97
- const validity = this.input.checkValidity();
98
- // Set validity
99
- this.valid = validity;
100
- this.invalid = !validity;
101
- //Send event
102
- this.inputValid.emit(validity);
103
- }
96
+ var _a;
97
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
98
+ this.invalid = !this.valid;
99
+ // We need to send valid event even if it is the same value
100
+ this.inputValid.emit(this.valid);
104
101
  };
105
102
  /**
106
- * Check input errors
103
+ * Set input error message
107
104
  *
108
105
  * @returns {void}
109
106
  */
110
- this.checkError = () => {
107
+ this.setErrorMessage = () => {
111
108
  // Set error message
112
109
  this.errorMessage = undefined;
113
110
  // Does not match pattern
@@ -120,7 +117,7 @@ export class MgInputText {
120
117
  }
121
118
  };
122
119
  /**
123
- * Validate patern configuration
120
+ * Validate pattern configuration
124
121
  *
125
122
  * @returns {void}
126
123
  */
@@ -159,6 +156,16 @@ export class MgInputText {
159
156
  this.classList.delete(this.classHasIcon);
160
157
  }
161
158
  }
159
+ handleValidityChange(newValue, _oldValue, prop) {
160
+ if (this.input !== undefined) {
161
+ this.input[prop] = newValue;
162
+ this.checkValidity();
163
+ if (this.hasDisplayedError) {
164
+ this.setErrorMessage();
165
+ this.hasDisplayedError = false;
166
+ }
167
+ }
168
+ }
162
169
  /**
163
170
  * Public method to play input focus
164
171
  *
@@ -174,8 +181,8 @@ export class MgInputText {
174
181
  */
175
182
  async displayError() {
176
183
  this.checkValidity();
177
- this.checkError();
178
- this.hasError = this.invalid;
184
+ this.setErrorMessage();
185
+ this.hasDisplayedError = this.invalid;
179
186
  }
180
187
  /*************
181
188
  * Lifecycle *
@@ -210,7 +217,10 @@ export class MgInputText {
210
217
  '--mg-character-left-message-length': (this.displayCharacterLeft
211
218
  ? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
212
219
  : 0).toString(),
213
- } }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), 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 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))), h("slot", { name: "append-input" })));
220
+ } }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), 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 => {
221
+ if (el !== null)
222
+ this.input = el;
223
+ } }), this.displayCharacterLeft && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))), h("slot", { name: "append-input" })));
214
224
  }
215
225
  static get is() { return "mg-input-text"; }
216
226
  static get encapsulation() { return "shadow"; }
@@ -688,6 +698,15 @@ export class MgInputText {
688
698
  }, {
689
699
  "propName": "icon",
690
700
  "methodName": "validateIcon"
701
+ }, {
702
+ "propName": "required",
703
+ "methodName": "handleValidityChange"
704
+ }, {
705
+ "propName": "readonly",
706
+ "methodName": "handleValidityChange"
707
+ }, {
708
+ "propName": "disabled",
709
+ "methodName": "handleValidityChange"
691
710
  }];
692
711
  }
693
712
  }
@@ -185,21 +185,40 @@
185
185
  .mg-input.mg-input--width-full:not(.mg-input--label-on-top) {
186
186
  justify-content: space-between;
187
187
  }
188
+ .mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box {
189
+ width: 100%;
190
+ }
188
191
  .mg-input.mg-input--width-full .mg-input__input-container {
189
192
  flex: auto;
190
193
  width: 100%;
191
194
  }
192
195
  .mg-input.mg-input--width-full .mg-input__input-container .mg-input__box {
196
+ max-width: 100%;
197
+ }
198
+ .mg-input:not(.mg-input--label-on-top) .mg-input__box {
199
+ width: 100%;
200
+ max-width: calc(17.7rem + var(--mg-inputs-spacer) * 2);
201
+ min-width: 5rem;
202
+ }
203
+ .mg-input.mg-input--width-16 .mg-input__input-container {
204
+ width: 100%;
205
+ }
206
+ .mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input {
207
+ width: 100%;
208
+ max-width: 21rem;
209
+ }
210
+ .mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left {
193
211
  width: 100%;
194
212
  }
195
- .mg-input.mg-input--width-16 .mg-input__box {
196
- width: 21rem;
213
+ .mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box {
214
+ max-width: 21rem;
215
+ min-width: 100%;
197
216
  }
198
- .mg-input.mg-input--width-4 .mg-input__box {
199
- width: 7rem;
217
+ .mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box {
218
+ max-width: 7rem;
200
219
  }
201
- .mg-input.mg-input--width-2 .mg-input__box {
202
- width: 5rem;
220
+ .mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box {
221
+ max-width: 5rem;
203
222
  }
204
223
 
205
224
  /**
@@ -7,11 +7,11 @@ export class MgInputTextarea {
7
7
  /************
8
8
  * Internal *
9
9
  ************/
10
- // classes
10
+ // Classes
11
11
  this.classFocus = 'is-focused';
12
12
  this.classHasDisplayCharacterLeft = 'mg-input--has-display-character-left';
13
- // hasError (triggered by blur event)
14
- this.hasError = false;
13
+ // hasDisplayedError (triggered by blur event)
14
+ this.hasDisplayedError = false;
15
15
  /**
16
16
  * Input name
17
17
  * If not set the value equals the identifier
@@ -61,9 +61,9 @@ export class MgInputTextarea {
61
61
  * Handle input event
62
62
  */
63
63
  this.handleInput = () => {
64
- if (this.hasError) {
64
+ if (this.hasDisplayedError) {
65
65
  this.checkValidity();
66
- this.checkError();
66
+ this.setErrorMessage();
67
67
  }
68
68
  this.value = this.input.value;
69
69
  };
@@ -95,19 +95,16 @@ export class MgInputTextarea {
95
95
  * Check if input is valid
96
96
  */
97
97
  this.checkValidity = () => {
98
- if (!this.readonly && this.input !== undefined) {
99
- const validity = this.input.checkValidity && this.input.checkValidity() && this.getPatternValidity();
100
- // Set validity
101
- this.valid = validity;
102
- this.invalid = !validity;
103
- //Send event
104
- this.inputValid.emit(validity);
105
- }
98
+ var _a;
99
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined && this.input.checkValidity() && this.getPatternValidity());
100
+ this.invalid = !this.valid;
101
+ // We need to send valid event even if it is the same value
102
+ this.inputValid.emit(this.valid);
106
103
  };
107
104
  /**
108
- * Check input errors
105
+ * Set input error message
109
106
  */
110
- this.checkError = () => {
107
+ this.setErrorMessage = () => {
111
108
  // Set error message
112
109
  this.errorMessage = undefined;
113
110
  // Does not match pattern
@@ -135,6 +132,16 @@ export class MgInputTextarea {
135
132
  this.checkValidity();
136
133
  this.valueChange.emit(newValue);
137
134
  }
135
+ handleValidityChange(newValue, _oldValue, prop) {
136
+ if (this.input !== undefined) {
137
+ this.input[prop] = newValue;
138
+ this.checkValidity();
139
+ if (this.hasDisplayedError) {
140
+ this.setErrorMessage();
141
+ this.hasDisplayedError = false;
142
+ }
143
+ }
144
+ }
138
145
  validateDisplayCharacterLeft(newValue) {
139
146
  if (newValue) {
140
147
  this.classList.add(this.classHasDisplayCharacterLeft);
@@ -150,8 +157,8 @@ export class MgInputTextarea {
150
157
  */
151
158
  async displayError() {
152
159
  this.checkValidity();
153
- this.checkError();
154
- this.hasError = this.invalid;
160
+ this.setErrorMessage();
161
+ this.hasDisplayedError = this.invalid;
155
162
  }
156
163
  /*************
157
164
  * Lifecycle *
@@ -186,7 +193,10 @@ export class MgInputTextarea {
186
193
  'mg-input__box--resizable': this.resizable === 'both',
187
194
  'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
188
195
  'mg-input__box--resizable-vertical': this.resizable === 'vertical',
189
- }, 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 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
196
+ }, 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 => {
197
+ if (el !== null)
198
+ this.input = el;
199
+ } }), this.displayCharacterLeft && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
190
200
  }
191
201
  static get is() { return "mg-input-textarea"; }
192
202
  static get encapsulation() { return "shadow"; }
@@ -643,6 +653,15 @@ export class MgInputTextarea {
643
653
  return [{
644
654
  "propName": "value",
645
655
  "methodName": "handleValue"
656
+ }, {
657
+ "propName": "required",
658
+ "methodName": "handleValidityChange"
659
+ }, {
660
+ "propName": "readonly",
661
+ "methodName": "handleValidityChange"
662
+ }, {
663
+ "propName": "disabled",
664
+ "methodName": "handleValidityChange"
646
665
  }, {
647
666
  "propName": "displayCharacterLeft",
648
667
  "methodName": "validateDisplayCharacterLeft"
@@ -15,7 +15,7 @@ export class MgInputToggle {
15
15
  /************
16
16
  * Internal *
17
17
  ************/
18
- // classes
18
+ // Classes
19
19
  this.classReadonly = 'mg-input--toggle-readonly';
20
20
  this.classDisabled = 'mg-input--toggle-disabled';
21
21
  this.classIsActive = 'mg-input--toggle-is-active';
@@ -20,4 +20,5 @@ MgDetails.args = {
20
20
  toggleClosed: 'Show details',
21
21
  toggleOpened: 'Hide details',
22
22
  expanded: false,
23
+ hideSummary: false,
23
24
  };
@@ -1,3 +1,24 @@
1
+ /**
2
+ * A11Y
3
+ */
4
+ .sr-only {
5
+ border: 0 !important;
6
+ clip: rect(1px, 1px, 1px, 1px) !important;
7
+ -webkit-clip-path: inset(50%) !important;
8
+ clip-path: inset(50%) !important;
9
+ height: 1px !important;
10
+ margin: -1px !important;
11
+ overflow: hidden !important;
12
+ padding: 0 !important;
13
+ position: absolute !important;
14
+ width: 1px !important;
15
+ white-space: nowrap !important;
16
+ }
17
+
18
+ *:focus:not(:focus-visible) {
19
+ outline: none;
20
+ }
21
+
1
22
  .mg-details summary {
2
23
  display: flex;
3
24
  align-items: baseline;
@@ -7,6 +28,14 @@
7
28
  .mg-details__toggle {
8
29
  margin-left: 1.5rem;
9
30
  flex-shrink: 0;
31
+ display: flex;
32
+ align-items: center;
33
+ align-self: flex-start;
34
+ gap: 0.6rem;
35
+ min-height: calc(var(--font-size) * var(--line-height));
36
+ }
37
+ .mg-details__toggle mg-icon {
38
+ align-self: self-end;
10
39
  }
11
40
 
12
41
  .mg-details__details {
@@ -1,6 +1,10 @@
1
1
  import { h } from '@stencil/core';
2
2
  export class MgDetails {
3
3
  constructor() {
4
+ /**
5
+ * Hide summary element
6
+ */
7
+ this.hideSummary = false;
4
8
  /**
5
9
  * Define if details are diplayed
6
10
  */
@@ -15,7 +19,7 @@ export class MgDetails {
15
19
  };
16
20
  }
17
21
  validateTitles(newValue) {
18
- if (newValue === undefined || newValue === '') {
22
+ if (newValue === undefined || newValue.trim() === '') {
19
23
  throw new Error('<mg-details> prop "toggleClosed" and "toggleOpened" must be defined.');
20
24
  }
21
25
  }
@@ -40,7 +44,7 @@ export class MgDetails {
40
44
  * @returns {HTMLElement} HTML Element
41
45
  */
42
46
  render() {
43
- return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), " ", this.expanded ? this.toggleOpened : this.toggleClosed)), h("div", { class: "mg-details__details" }, h("slot", { name: "details" }))));
47
+ return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), h("div", { class: "mg-details__details" }, h("slot", { name: "details" }))));
44
48
  }
45
49
  static get is() { return "mg-details"; }
46
50
  static get encapsulation() { return "shadow"; }
@@ -64,7 +68,7 @@ export class MgDetails {
64
68
  "resolved": "string",
65
69
  "references": {}
66
70
  },
67
- "required": false,
71
+ "required": true,
68
72
  "optional": false,
69
73
  "docs": {
70
74
  "tags": [],
@@ -81,7 +85,7 @@ export class MgDetails {
81
85
  "resolved": "string",
82
86
  "references": {}
83
87
  },
84
- "required": false,
88
+ "required": true,
85
89
  "optional": false,
86
90
  "docs": {
87
91
  "tags": [],
@@ -90,6 +94,24 @@ export class MgDetails {
90
94
  "attribute": "toggle-opened",
91
95
  "reflect": false
92
96
  },
97
+ "hideSummary": {
98
+ "type": "boolean",
99
+ "mutable": false,
100
+ "complexType": {
101
+ "original": "boolean",
102
+ "resolved": "boolean",
103
+ "references": {}
104
+ },
105
+ "required": false,
106
+ "optional": false,
107
+ "docs": {
108
+ "tags": [],
109
+ "text": "Hide summary element"
110
+ },
111
+ "attribute": "hide-summary",
112
+ "reflect": false,
113
+ "defaultValue": "false"
114
+ },
93
115
  "expanded": {
94
116
  "type": "boolean",
95
117
  "mutable": true,