@mgdis/mg-components 5.9.1 → 5.10.1
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.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_31.cjs.entry.js +345 -648
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +19 -43
- package/dist/cjs/{mg-menu.conf-9afe6571.js → mg-menu.conf-196151fe.js} +16 -21
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +9 -12
- package/dist/collection/components/atoms/mg-button/mg-button.js +18 -27
- package/dist/collection/components/atoms/mg-card/mg-card.js +22 -15
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +1 -4
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -2
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +26 -23
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -4
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +11 -16
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +12 -34
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +26 -24
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +10 -20
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +7 -17
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +14 -34
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +6 -13
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -27
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +21 -45
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +17 -43
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +14 -22
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +17 -28
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +11 -29
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +20 -47
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +11 -23
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -6
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -27
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -4
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +4 -12
- package/dist/collection/components/molecules/mg-message/mg-message.js +12 -20
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +8 -17
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +11 -19
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +11 -30
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +8 -21
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +3 -8
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +20 -36
- package/dist/collection/locales/index.js +2 -3
- package/dist/collection/utils/behaviors.utils.js +16 -32
- package/dist/collection/utils/components.utils.js +22 -33
- package/dist/collection/utils/locale.utils.js +14 -18
- package/dist/collection/utils/unit.test.utils.js +7 -15
- package/dist/components/MgInput.js +30 -24
- package/dist/components/components.utils.js +22 -33
- package/dist/components/index2.js +16 -21
- package/dist/components/mg-action-more.js +9 -21
- package/dist/components/mg-badge2.js +9 -12
- package/dist/components/mg-button2.js +18 -27
- package/dist/components/mg-card2.js +20 -13
- package/dist/components/mg-character-left2.js +1 -4
- package/dist/components/mg-details.js +1 -6
- package/dist/components/mg-divider.js +1 -2
- package/dist/components/mg-form.js +7 -23
- package/dist/components/mg-icon2.js +26 -23
- package/dist/components/mg-illustrated-message.js +1 -4
- package/dist/components/mg-input-checkbox.js +9 -16
- package/dist/components/mg-input-date.js +6 -13
- package/dist/components/mg-input-numeric.js +13 -30
- package/dist/components/mg-input-password.js +5 -9
- package/dist/components/mg-input-radio.js +9 -23
- package/dist/components/mg-input-select2.js +20 -41
- package/dist/components/mg-input-text2.js +15 -35
- package/dist/components/mg-input-textarea.js +13 -18
- package/dist/components/mg-input-title2.js +1 -4
- package/dist/components/mg-input-toggle.js +16 -24
- package/dist/components/mg-item-more.js +18 -42
- package/dist/components/mg-menu-item2.js +17 -44
- package/dist/components/mg-menu2.js +9 -27
- package/dist/components/mg-message.js +12 -20
- package/dist/components/mg-modal.js +8 -17
- package/dist/components/mg-pagination.js +11 -19
- package/dist/components/mg-panel.js +11 -30
- package/dist/components/mg-popover2.js +8 -21
- package/dist/components/mg-skip-links.js +3 -8
- package/dist/components/mg-tabs.js +20 -36
- package/dist/components/mg-tag.js +11 -16
- package/dist/components/mg-tooltip2.js +12 -34
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_31.entry.js +345 -648
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +19 -43
- package/dist/esm/{mg-menu.conf-881fbd82.js → mg-menu.conf-9ca023ee.js} +16 -21
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-67ce7cb8.entry.js → p-97aaca3e.entry.js} +1 -1
- package/dist/mg-components/p-d891e707.entry.js +1 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +2 -5
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +5 -14
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +11 -8
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -4
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +1 -2
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +8 -7
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -4
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +3 -8
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -33
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -1
- package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -6
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -11
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -11
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +7 -26
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +3 -7
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -18
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +9 -22
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +3 -23
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -9
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -11
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +10 -29
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +21 -49
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +3 -15
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +1 -6
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -19
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +1 -4
- package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +2 -12
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +4 -12
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -12
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +5 -14
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +4 -23
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +3 -16
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +2 -7
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +15 -30
- package/dist/types/components.d.ts +22 -34
- package/dist/types/locales/index.d.ts +2 -3
- package/dist/types/utils/behaviors.utils.d.ts +14 -29
- package/dist/types/utils/components.utils.d.ts +19 -29
- package/dist/types/utils/locale.utils.d.ts +14 -18
- package/dist/types/utils/unit.test.utils.d.ts +11 -24
- package/package.json +11 -12
- package/dist/mg-components/p-9a93b7af.entry.js +0 -1
- /package/dist/mg-components/{p-367f92d2.js → p-0d3146d9.js} +0 -0
|
@@ -10,8 +10,6 @@ export class MgInputNumeric {
|
|
|
10
10
|
this.hasDisplayedError = false;
|
|
11
11
|
/**
|
|
12
12
|
* Handle input event
|
|
13
|
-
*
|
|
14
|
-
* @returns {void}
|
|
15
13
|
*/
|
|
16
14
|
this.handleInput = () => {
|
|
17
15
|
// Check validity
|
|
@@ -23,26 +21,22 @@ export class MgInputNumeric {
|
|
|
23
21
|
};
|
|
24
22
|
/**
|
|
25
23
|
* Handle focus event
|
|
26
|
-
*
|
|
27
|
-
* @returns {void}
|
|
28
24
|
*/
|
|
29
25
|
this.handleFocus = () => {
|
|
30
26
|
this.hasFocus = true;
|
|
31
27
|
};
|
|
32
28
|
/**
|
|
33
29
|
* Handle blur event
|
|
34
|
-
*
|
|
35
|
-
* @returns {void}
|
|
36
30
|
*/
|
|
37
31
|
this.handleBlur = () => {
|
|
32
|
+
if (this.value === '-')
|
|
33
|
+
this.value = '';
|
|
38
34
|
// Display Error
|
|
39
35
|
this.displayError();
|
|
40
36
|
this.hasFocus = false;
|
|
41
37
|
};
|
|
42
38
|
/**
|
|
43
39
|
* Check if input is valid
|
|
44
|
-
*
|
|
45
|
-
* @returns {void}
|
|
46
40
|
*/
|
|
47
41
|
this.checkValidity = () => {
|
|
48
42
|
this.valid = this.readonly || this.disabled || this.getInputError() === null;
|
|
@@ -52,8 +46,6 @@ export class MgInputNumeric {
|
|
|
52
46
|
};
|
|
53
47
|
/**
|
|
54
48
|
* Set input error message
|
|
55
|
-
*
|
|
56
|
-
* @returns {void}
|
|
57
49
|
*/
|
|
58
50
|
this.setErrorMessage = () => {
|
|
59
51
|
// Set error message
|
|
@@ -70,8 +62,7 @@ export class MgInputNumeric {
|
|
|
70
62
|
};
|
|
71
63
|
/**
|
|
72
64
|
* Get input error code
|
|
73
|
-
*
|
|
74
|
-
* @returns {null | InputError} error code
|
|
65
|
+
* @returns error code
|
|
75
66
|
*/
|
|
76
67
|
this.getInputError = () => {
|
|
77
68
|
let inputError = null;
|
|
@@ -99,20 +90,17 @@ export class MgInputNumeric {
|
|
|
99
90
|
};
|
|
100
91
|
/**
|
|
101
92
|
* Format value based on type
|
|
102
|
-
*
|
|
103
|
-
* @
|
|
104
|
-
* @returns {string} formated local value
|
|
93
|
+
* @param value - value to format
|
|
94
|
+
* @returns formated local value
|
|
105
95
|
*/
|
|
106
96
|
this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));
|
|
107
97
|
/**
|
|
108
98
|
* Validate append slot
|
|
109
|
-
*
|
|
110
|
-
* @returns {void}
|
|
111
99
|
*/
|
|
112
100
|
this.validateAppendSlot = () => {
|
|
113
101
|
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
114
102
|
if (slotAppendInput !== null) {
|
|
115
|
-
this.
|
|
103
|
+
this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
116
104
|
}
|
|
117
105
|
};
|
|
118
106
|
this.value = undefined;
|
|
@@ -136,7 +124,7 @@ export class MgInputNumeric {
|
|
|
136
124
|
this.decimalLength = 2;
|
|
137
125
|
this.valid = undefined;
|
|
138
126
|
this.invalid = undefined;
|
|
139
|
-
this.
|
|
127
|
+
this.classCollection = new ClassList(['mg-input--numeric']);
|
|
140
128
|
this.errorMessage = undefined;
|
|
141
129
|
this.hasFocus = false;
|
|
142
130
|
}
|
|
@@ -148,7 +136,7 @@ export class MgInputNumeric {
|
|
|
148
136
|
// Regex
|
|
149
137
|
const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+[.,]?\d*$/;
|
|
150
138
|
// Filter input
|
|
151
|
-
if (
|
|
139
|
+
if (['', '-'].includes(newValue) || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
152
140
|
this.storedValue = newValue;
|
|
153
141
|
}
|
|
154
142
|
else if (this.storedValue !== undefined) {
|
|
@@ -195,8 +183,6 @@ export class MgInputNumeric {
|
|
|
195
183
|
}
|
|
196
184
|
/**
|
|
197
185
|
* Public method to display errors
|
|
198
|
-
*
|
|
199
|
-
* @returns {Promise<void>}
|
|
200
186
|
*/
|
|
201
187
|
async displayError() {
|
|
202
188
|
this.checkValidity();
|
|
@@ -206,8 +192,7 @@ export class MgInputNumeric {
|
|
|
206
192
|
/**
|
|
207
193
|
* Displayed value in input
|
|
208
194
|
* Change on focus/blur
|
|
209
|
-
*
|
|
210
|
-
* @returns {MgInputNumeric['value'] | MgInputNumeric['readonlyValue']} display value
|
|
195
|
+
* @returns display value
|
|
211
196
|
*/
|
|
212
197
|
displayValue() {
|
|
213
198
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -217,8 +202,7 @@ export class MgInputNumeric {
|
|
|
217
202
|
*************/
|
|
218
203
|
/**
|
|
219
204
|
* Check if component props are well configured on init
|
|
220
|
-
*
|
|
221
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
205
|
+
* @returns timeout
|
|
222
206
|
*/
|
|
223
207
|
componentWillLoad() {
|
|
224
208
|
// Get locales
|
|
@@ -241,11 +225,10 @@ export class MgInputNumeric {
|
|
|
241
225
|
}
|
|
242
226
|
/**
|
|
243
227
|
* Render
|
|
244
|
-
*
|
|
245
|
-
* @returns {HTMLElement} HTML Element
|
|
228
|
+
* @returns HTML Element
|
|
246
229
|
*/
|
|
247
230
|
render() {
|
|
248
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
231
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, 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 => {
|
|
249
232
|
if (el !== null)
|
|
250
233
|
this.input = el;
|
|
251
234
|
} }), h("slot", { name: "append-input" })));
|
|
@@ -639,7 +622,7 @@ export class MgInputNumeric {
|
|
|
639
622
|
}
|
|
640
623
|
static get states() {
|
|
641
624
|
return {
|
|
642
|
-
"
|
|
625
|
+
"classCollection": {},
|
|
643
626
|
"errorMessage": {},
|
|
644
627
|
"hasFocus": {}
|
|
645
628
|
};
|
|
@@ -692,10 +675,7 @@ export class MgInputNumeric {
|
|
|
692
675
|
},
|
|
693
676
|
"docs": {
|
|
694
677
|
"text": "Public method to display errors",
|
|
695
|
-
"tags": [
|
|
696
|
-
"name": "returns",
|
|
697
|
-
"text": undefined
|
|
698
|
-
}]
|
|
678
|
+
"tags": []
|
|
699
679
|
}
|
|
700
680
|
}
|
|
701
681
|
};
|
|
@@ -58,7 +58,7 @@ export class MgInputPassword {
|
|
|
58
58
|
this.helpText = undefined;
|
|
59
59
|
this.valid = undefined;
|
|
60
60
|
this.invalid = undefined;
|
|
61
|
-
this.
|
|
61
|
+
this.classCollection = new ClassList(['mg-input--password']);
|
|
62
62
|
this.errorMessage = undefined;
|
|
63
63
|
}
|
|
64
64
|
handleValue(newValue) {
|
|
@@ -76,8 +76,6 @@ export class MgInputPassword {
|
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Public method to display errors
|
|
79
|
-
*
|
|
80
|
-
* @returns {Promise<void>}
|
|
81
79
|
*/
|
|
82
80
|
async displayError() {
|
|
83
81
|
this.checkValidity();
|
|
@@ -89,8 +87,7 @@ export class MgInputPassword {
|
|
|
89
87
|
*************/
|
|
90
88
|
/**
|
|
91
89
|
* Check if component props are well configured on init
|
|
92
|
-
*
|
|
93
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
90
|
+
* @returns timeout
|
|
94
91
|
*/
|
|
95
92
|
componentWillLoad() {
|
|
96
93
|
// Get locales
|
|
@@ -104,11 +101,10 @@ export class MgInputPassword {
|
|
|
104
101
|
}
|
|
105
102
|
/**
|
|
106
103
|
* Render
|
|
107
|
-
*
|
|
108
|
-
* @returns {HTMLElement} HTML Element
|
|
104
|
+
* @returns HTML Element
|
|
109
105
|
*/
|
|
110
106
|
render() {
|
|
111
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
107
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, 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 }, 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 => {
|
|
112
108
|
if (el !== null)
|
|
113
109
|
this.input = el;
|
|
114
110
|
} })));
|
|
@@ -397,7 +393,7 @@ export class MgInputPassword {
|
|
|
397
393
|
}
|
|
398
394
|
static get states() {
|
|
399
395
|
return {
|
|
400
|
-
"
|
|
396
|
+
"classCollection": {},
|
|
401
397
|
"errorMessage": {}
|
|
402
398
|
};
|
|
403
399
|
}
|
|
@@ -449,10 +445,7 @@ export class MgInputPassword {
|
|
|
449
445
|
},
|
|
450
446
|
"docs": {
|
|
451
447
|
"text": "Public method to display errors",
|
|
452
|
-
"tags": [
|
|
453
|
-
"name": "returns",
|
|
454
|
-
"text": undefined
|
|
455
|
-
}]
|
|
448
|
+
"tags": []
|
|
456
449
|
}
|
|
457
450
|
}
|
|
458
451
|
};
|
|
@@ -7,9 +7,8 @@ import { ClassList, allItemsAreString } from '../../../../utils/components.utils
|
|
|
7
7
|
import { initLocales } from '../../../../locales';
|
|
8
8
|
/**
|
|
9
9
|
* type Option validation function
|
|
10
|
-
*
|
|
11
|
-
* @
|
|
12
|
-
* @returns {boolean} radio option type is valid
|
|
10
|
+
* @param option - radio option
|
|
11
|
+
* @returns radio option type is valid
|
|
13
12
|
*/
|
|
14
13
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
15
14
|
export class MgInputRadio {
|
|
@@ -23,9 +22,7 @@ export class MgInputRadio {
|
|
|
23
22
|
this.hasDisplayedError = false;
|
|
24
23
|
/**
|
|
25
24
|
* Handle input event
|
|
26
|
-
*
|
|
27
|
-
* @param {event} event input event
|
|
28
|
-
* @returns {void}
|
|
25
|
+
* @param event - input event
|
|
29
26
|
*/
|
|
30
27
|
this.handleInput = (event) => {
|
|
31
28
|
this.checkValidity();
|
|
@@ -33,8 +30,6 @@ export class MgInputRadio {
|
|
|
33
30
|
};
|
|
34
31
|
/**
|
|
35
32
|
* Handle blur event
|
|
36
|
-
*
|
|
37
|
-
* @returns {void}
|
|
38
33
|
*/
|
|
39
34
|
this.handleBlur = () => {
|
|
40
35
|
this.checkValidity();
|
|
@@ -42,8 +37,6 @@ export class MgInputRadio {
|
|
|
42
37
|
};
|
|
43
38
|
/**
|
|
44
39
|
* Check if input is valid
|
|
45
|
-
*
|
|
46
|
-
* @returns {void}
|
|
47
40
|
*/
|
|
48
41
|
this.checkValidity = () => {
|
|
49
42
|
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
@@ -53,8 +46,6 @@ export class MgInputRadio {
|
|
|
53
46
|
};
|
|
54
47
|
/**
|
|
55
48
|
* Set input error message
|
|
56
|
-
*
|
|
57
|
-
* @returns {void}
|
|
58
49
|
*/
|
|
59
50
|
this.setErrorMessage = () => {
|
|
60
51
|
const invalidElement = this.getInvalidElement();
|
|
@@ -66,8 +57,7 @@ export class MgInputRadio {
|
|
|
66
57
|
};
|
|
67
58
|
/**
|
|
68
59
|
* get invalid element
|
|
69
|
-
*
|
|
70
|
-
* @returns {HTMLInputElement} element
|
|
60
|
+
* @returns element
|
|
71
61
|
*/
|
|
72
62
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
73
63
|
this.value = undefined;
|
|
@@ -85,7 +75,7 @@ export class MgInputRadio {
|
|
|
85
75
|
this.helpText = undefined;
|
|
86
76
|
this.valid = undefined;
|
|
87
77
|
this.invalid = undefined;
|
|
88
|
-
this.
|
|
78
|
+
this.classCollection = new ClassList(['mg-input--radio']);
|
|
89
79
|
this.errorMessage = undefined;
|
|
90
80
|
this.options = undefined;
|
|
91
81
|
}
|
|
@@ -121,8 +111,6 @@ export class MgInputRadio {
|
|
|
121
111
|
}
|
|
122
112
|
/**
|
|
123
113
|
* Public method to display errors
|
|
124
|
-
*
|
|
125
|
-
* @returns {Promise<void>}
|
|
126
114
|
*/
|
|
127
115
|
async displayError() {
|
|
128
116
|
this.checkValidity();
|
|
@@ -134,8 +122,7 @@ export class MgInputRadio {
|
|
|
134
122
|
*************/
|
|
135
123
|
/**
|
|
136
124
|
* Check if component props are well configured on init
|
|
137
|
-
*
|
|
138
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
125
|
+
* @returns timeout
|
|
139
126
|
*/
|
|
140
127
|
componentWillLoad() {
|
|
141
128
|
// Get locales
|
|
@@ -151,11 +138,10 @@ export class MgInputRadio {
|
|
|
151
138
|
}
|
|
152
139
|
/**
|
|
153
140
|
* Render
|
|
154
|
-
*
|
|
155
|
-
* @returns {HTMLElement} HTML Element
|
|
141
|
+
* @returns HTML Element
|
|
156
142
|
*/
|
|
157
143
|
render() {
|
|
158
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
144
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, 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 }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => {
|
|
159
145
|
if (el !== null)
|
|
160
146
|
this.inputs[index] = el;
|
|
161
147
|
} }), h("label", { htmlFor: this.identifier + '_' + index }, input.title)))))));
|
|
@@ -443,7 +429,7 @@ export class MgInputRadio {
|
|
|
443
429
|
}
|
|
444
430
|
static get states() {
|
|
445
431
|
return {
|
|
446
|
-
"
|
|
432
|
+
"classCollection": {},
|
|
447
433
|
"errorMessage": {},
|
|
448
434
|
"options": {}
|
|
449
435
|
};
|
|
@@ -496,10 +482,7 @@ export class MgInputRadio {
|
|
|
496
482
|
},
|
|
497
483
|
"docs": {
|
|
498
484
|
"text": "Public method to display errors",
|
|
499
|
-
"tags": [
|
|
500
|
-
"name": "returns",
|
|
501
|
-
"text": undefined
|
|
502
|
-
}]
|
|
485
|
+
"tags": []
|
|
503
486
|
}
|
|
504
487
|
}
|
|
505
488
|
};
|
|
@@ -6,35 +6,27 @@ import { ClassList, allItemsAreString } from '../../../../utils/components.utils
|
|
|
6
6
|
import { initLocales } from '../../../../locales';
|
|
7
7
|
/**
|
|
8
8
|
* Check if item is a well configured option
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
11
|
-
* @returns {boolean} select option type is valid
|
|
9
|
+
* @param option - select option
|
|
10
|
+
* @returns select option type is valid
|
|
12
11
|
*/
|
|
13
12
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
14
13
|
/**
|
|
15
14
|
* Check if items[] is SelectOption
|
|
16
|
-
*
|
|
17
|
-
* @
|
|
18
|
-
* @returns {boolean} select option array type is valid
|
|
15
|
+
* @param items - select option
|
|
16
|
+
* @returns select option array type is valid
|
|
19
17
|
*/
|
|
20
18
|
const allItemsAreOptions = (items) => Array.isArray(items) && items.every(item => isOption(item));
|
|
21
19
|
/**
|
|
22
20
|
* Check if item is a well configured optgroup
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
25
|
-
* @returns {boolean} select optgroup type is valid
|
|
21
|
+
* @param optgroup - select option
|
|
22
|
+
* @returns select optgroup type is valid
|
|
26
23
|
*/
|
|
27
24
|
const isOptGroup = (optgroup) => typeof optgroup === 'object' && typeof optgroup.group === 'string' && allItemsAreOptions(optgroup.options);
|
|
28
25
|
/**
|
|
29
26
|
* Group options
|
|
30
|
-
*
|
|
31
|
-
* @param
|
|
32
|
-
* @
|
|
33
|
-
* @param {string} item.group item group
|
|
34
|
-
* @param {string} item.title item title
|
|
35
|
-
* @param {unknown} item.value item value
|
|
36
|
-
* @param {boolean} item.disabled is item disabled
|
|
37
|
-
* @returns {(SelectOption | OptGroup)[]} grouped options
|
|
27
|
+
* @param acc - reduce accumulator
|
|
28
|
+
* @param item - item to add
|
|
29
|
+
* @returns grouped options
|
|
38
30
|
*/
|
|
39
31
|
const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
40
32
|
if (group !== undefined) {
|
|
@@ -60,8 +52,6 @@ export class MgInputSelect {
|
|
|
60
52
|
this.hasDisplayedError = false;
|
|
61
53
|
/**
|
|
62
54
|
* Handle input event
|
|
63
|
-
*
|
|
64
|
-
* @returns {void}
|
|
65
55
|
*/
|
|
66
56
|
this.handleInput = () => {
|
|
67
57
|
this.updateValue();
|
|
@@ -70,16 +60,13 @@ export class MgInputSelect {
|
|
|
70
60
|
};
|
|
71
61
|
/**
|
|
72
62
|
* Method to compare item.title with input.value
|
|
73
|
-
*
|
|
74
|
-
* @
|
|
75
|
-
* @returns {boolean} truthy if input.value is an item
|
|
63
|
+
* @param item - item to compare with
|
|
64
|
+
* @returns truthy if input.value is an item
|
|
76
65
|
*/
|
|
77
66
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
78
67
|
/**
|
|
79
68
|
* value props setter
|
|
80
|
-
*
|
|
81
|
-
* @param {MgInputSelect['value']} newValue value to update with
|
|
82
|
-
* @returns {void}
|
|
69
|
+
* @param newValue - value to update with
|
|
83
70
|
*/
|
|
84
71
|
this.setValue = (newValue) => {
|
|
85
72
|
this.checkValidity();
|
|
@@ -87,8 +74,6 @@ export class MgInputSelect {
|
|
|
87
74
|
};
|
|
88
75
|
/**
|
|
89
76
|
* Update value from input.value
|
|
90
|
-
*
|
|
91
|
-
* @returns {void}
|
|
92
77
|
*/
|
|
93
78
|
this.updateValue = () => {
|
|
94
79
|
if (this.input.value === '') {
|
|
@@ -114,8 +99,7 @@ export class MgInputSelect {
|
|
|
114
99
|
};
|
|
115
100
|
/**
|
|
116
101
|
* Input value is disabled
|
|
117
|
-
*
|
|
118
|
-
* @returns {boolean} truthy if input value is disabled
|
|
102
|
+
* @returns truthy if input value is disabled
|
|
119
103
|
*/
|
|
120
104
|
this.isDisabledValue = () => { var _a; return allItemsAreOptions(this.options) && ((_a = this.options.find(this.isInputValue)) === null || _a === void 0 ? void 0 : _a.disabled) === true; };
|
|
121
105
|
/**
|
|
@@ -140,9 +124,8 @@ export class MgInputSelect {
|
|
|
140
124
|
};
|
|
141
125
|
/**
|
|
142
126
|
* Render option
|
|
143
|
-
*
|
|
144
|
-
* @
|
|
145
|
-
* @returns {HTMLElement} render option
|
|
127
|
+
* @param option - to render
|
|
128
|
+
* @returns render option
|
|
146
129
|
*/
|
|
147
130
|
this.renderOption = (option) => (h("option", { key: option.title, value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title));
|
|
148
131
|
this.value = undefined;
|
|
@@ -163,7 +146,7 @@ export class MgInputSelect {
|
|
|
163
146
|
this.helpText = undefined;
|
|
164
147
|
this.valid = undefined;
|
|
165
148
|
this.invalid = undefined;
|
|
166
|
-
this.
|
|
149
|
+
this.classCollection = new ClassList(['mg-input--select']);
|
|
167
150
|
this.errorMessage = undefined;
|
|
168
151
|
this.options = undefined;
|
|
169
152
|
this.valueExist = undefined;
|
|
@@ -221,8 +204,6 @@ export class MgInputSelect {
|
|
|
221
204
|
}
|
|
222
205
|
/**
|
|
223
206
|
* Public method to display errors
|
|
224
|
-
*
|
|
225
|
-
* @returns {Promise<void>}
|
|
226
207
|
*/
|
|
227
208
|
async displayError() {
|
|
228
209
|
this.checkValidity();
|
|
@@ -234,8 +215,7 @@ export class MgInputSelect {
|
|
|
234
215
|
*************/
|
|
235
216
|
/**
|
|
236
217
|
* Check if component props are well configured on init
|
|
237
|
-
*
|
|
238
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
218
|
+
* @returns timeout
|
|
239
219
|
*/
|
|
240
220
|
componentWillLoad() {
|
|
241
221
|
// Get locales
|
|
@@ -256,11 +236,10 @@ export class MgInputSelect {
|
|
|
256
236
|
}
|
|
257
237
|
/**
|
|
258
238
|
* Render
|
|
259
|
-
*
|
|
260
|
-
* @returns {HTMLElement} HTML Element
|
|
239
|
+
* @returns HTML Element
|
|
261
240
|
*/
|
|
262
241
|
render() {
|
|
263
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
242
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: undefined, 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 => {
|
|
264
243
|
if (el !== null)
|
|
265
244
|
this.input = el;
|
|
266
245
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -605,7 +584,7 @@ export class MgInputSelect {
|
|
|
605
584
|
}
|
|
606
585
|
static get states() {
|
|
607
586
|
return {
|
|
608
|
-
"
|
|
587
|
+
"classCollection": {},
|
|
609
588
|
"errorMessage": {},
|
|
610
589
|
"options": {},
|
|
611
590
|
"valueExist": {},
|
|
@@ -664,10 +643,7 @@ export class MgInputSelect {
|
|
|
664
643
|
},
|
|
665
644
|
"docs": {
|
|
666
645
|
"text": "Public method to display errors",
|
|
667
|
-
"tags": [
|
|
668
|
-
"name": "returns",
|
|
669
|
-
"text": undefined
|
|
670
|
-
}]
|
|
646
|
+
"tags": []
|
|
671
647
|
}
|
|
672
648
|
}
|
|
673
649
|
};
|