@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
|
@@ -15,8 +15,6 @@ export class MgInputText {
|
|
|
15
15
|
this.hasDisplayedError = false;
|
|
16
16
|
/**
|
|
17
17
|
* Handle input event
|
|
18
|
-
*
|
|
19
|
-
* @returns {void}
|
|
20
18
|
*/
|
|
21
19
|
this.handleInput = () => {
|
|
22
20
|
this.checkValidity();
|
|
@@ -27,29 +25,23 @@ export class MgInputText {
|
|
|
27
25
|
};
|
|
28
26
|
/**
|
|
29
27
|
* Handle focus event
|
|
30
|
-
*
|
|
31
|
-
* @returns {void}
|
|
32
28
|
*/
|
|
33
29
|
this.handleFocus = () => {
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
30
|
+
this.classCollection.add(this.classFocus);
|
|
31
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
36
32
|
};
|
|
37
33
|
/**
|
|
38
34
|
* Handle blur event
|
|
39
|
-
*
|
|
40
|
-
* @returns {void}
|
|
41
35
|
*/
|
|
42
36
|
this.handleBlur = () => {
|
|
43
37
|
// Manage focus
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
38
|
+
this.classCollection.delete(this.classFocus);
|
|
39
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
46
40
|
// Display Error
|
|
47
41
|
this.displayError();
|
|
48
42
|
};
|
|
49
43
|
/**
|
|
50
44
|
* Check if input is valid
|
|
51
|
-
*
|
|
52
|
-
* @returns {void}
|
|
53
45
|
*/
|
|
54
46
|
this.checkValidity = () => {
|
|
55
47
|
var _a;
|
|
@@ -60,8 +52,6 @@ export class MgInputText {
|
|
|
60
52
|
};
|
|
61
53
|
/**
|
|
62
54
|
* Set input error message
|
|
63
|
-
*
|
|
64
|
-
* @returns {void}
|
|
65
55
|
*/
|
|
66
56
|
this.setErrorMessage = () => {
|
|
67
57
|
// Set error message
|
|
@@ -77,11 +67,9 @@ export class MgInputText {
|
|
|
77
67
|
};
|
|
78
68
|
/**
|
|
79
69
|
* Validate pattern configuration
|
|
80
|
-
*
|
|
81
|
-
* @returns {void}
|
|
82
70
|
*/
|
|
83
71
|
this.validatePattern = () => {
|
|
84
|
-
if (this.pattern &&
|
|
72
|
+
if (this.pattern !== undefined &&
|
|
85
73
|
typeof this.pattern === 'string' &&
|
|
86
74
|
this.pattern !== '' &&
|
|
87
75
|
(this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
|
|
@@ -90,17 +78,15 @@ export class MgInputText {
|
|
|
90
78
|
};
|
|
91
79
|
/**
|
|
92
80
|
* Validate append slot
|
|
93
|
-
*
|
|
94
|
-
* @returns {void}
|
|
95
81
|
*/
|
|
96
82
|
this.validateAppendSlot = () => {
|
|
97
83
|
const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
|
|
98
84
|
if (slotAppendInput.length === 1) {
|
|
99
|
-
this.
|
|
85
|
+
this.classCollection.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.classIsInputGroupAppend : 'mg-input--is-append-input-slot-content');
|
|
100
86
|
}
|
|
101
87
|
else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
88
|
+
this.classCollection.add(this.classIsInputGroupAppend);
|
|
89
|
+
this.classCollection.add('mg-input--has-buttons-group-append');
|
|
104
90
|
}
|
|
105
91
|
};
|
|
106
92
|
this.value = undefined;
|
|
@@ -124,7 +110,7 @@ export class MgInputText {
|
|
|
124
110
|
this.helpText = undefined;
|
|
125
111
|
this.valid = undefined;
|
|
126
112
|
this.invalid = undefined;
|
|
127
|
-
this.
|
|
113
|
+
this.classCollection = new ClassList(['mg-input--text']);
|
|
128
114
|
this.errorMessage = undefined;
|
|
129
115
|
}
|
|
130
116
|
handleValue(newValue) {
|
|
@@ -132,10 +118,10 @@ export class MgInputText {
|
|
|
132
118
|
}
|
|
133
119
|
validateIcon(newValue) {
|
|
134
120
|
if (newValue !== undefined) {
|
|
135
|
-
this.
|
|
121
|
+
this.classCollection.add(this.classHasIcon);
|
|
136
122
|
}
|
|
137
123
|
else {
|
|
138
|
-
this.
|
|
124
|
+
this.classCollection.delete(this.classHasIcon);
|
|
139
125
|
}
|
|
140
126
|
}
|
|
141
127
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -150,16 +136,12 @@ export class MgInputText {
|
|
|
150
136
|
}
|
|
151
137
|
/**
|
|
152
138
|
* Public method to play input focus
|
|
153
|
-
*
|
|
154
|
-
* @returns {Promise<void>}
|
|
155
139
|
*/
|
|
156
140
|
async setFocus() {
|
|
157
141
|
this.input.focus();
|
|
158
142
|
}
|
|
159
143
|
/**
|
|
160
144
|
* Public method to display errors
|
|
161
|
-
*
|
|
162
|
-
* @returns {Promise<void>}
|
|
163
145
|
*/
|
|
164
146
|
async displayError() {
|
|
165
147
|
this.checkValidity();
|
|
@@ -171,8 +153,7 @@ export class MgInputText {
|
|
|
171
153
|
*************/
|
|
172
154
|
/**
|
|
173
155
|
* Check if component props are well configured on init
|
|
174
|
-
*
|
|
175
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
156
|
+
* @returns timeout
|
|
176
157
|
*/
|
|
177
158
|
componentWillLoad() {
|
|
178
159
|
// Get locales
|
|
@@ -191,11 +172,10 @@ export class MgInputText {
|
|
|
191
172
|
}
|
|
192
173
|
/**
|
|
193
174
|
* Render
|
|
194
|
-
*
|
|
195
|
-
* @returns {HTMLElement} HTML Element
|
|
175
|
+
* @returns HTML Element
|
|
196
176
|
*/
|
|
197
177
|
render() {
|
|
198
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
178
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], 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: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("div", { class: "mg-input__with-character-left", style: {
|
|
199
179
|
'--mg-character-left-message-length': (this.displayCharacterLeft
|
|
200
180
|
? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
|
|
201
181
|
: 0).toString(),
|
|
@@ -593,7 +573,7 @@ export class MgInputText {
|
|
|
593
573
|
}
|
|
594
574
|
static get states() {
|
|
595
575
|
return {
|
|
596
|
-
"
|
|
576
|
+
"classCollection": {},
|
|
597
577
|
"errorMessage": {}
|
|
598
578
|
};
|
|
599
579
|
}
|
|
@@ -645,10 +625,7 @@ export class MgInputText {
|
|
|
645
625
|
},
|
|
646
626
|
"docs": {
|
|
647
627
|
"text": "Public method to play input focus",
|
|
648
|
-
"tags": [
|
|
649
|
-
"name": "returns",
|
|
650
|
-
"text": undefined
|
|
651
|
-
}]
|
|
628
|
+
"tags": []
|
|
652
629
|
}
|
|
653
630
|
},
|
|
654
631
|
"displayError": {
|
|
@@ -664,10 +641,7 @@ export class MgInputText {
|
|
|
664
641
|
},
|
|
665
642
|
"docs": {
|
|
666
643
|
"text": "Public method to display errors",
|
|
667
|
-
"tags": [
|
|
668
|
-
"name": "returns",
|
|
669
|
-
"text": undefined
|
|
670
|
-
}]
|
|
644
|
+
"tags": []
|
|
671
645
|
}
|
|
672
646
|
}
|
|
673
647
|
};
|
|
@@ -26,24 +26,23 @@ export class MgInputTextarea {
|
|
|
26
26
|
* Handle focus event
|
|
27
27
|
*/
|
|
28
28
|
this.handleFocus = () => {
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
29
|
+
this.classCollection.add(this.classFocus);
|
|
30
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* Handle blur event
|
|
34
34
|
*/
|
|
35
35
|
this.handleBlur = () => {
|
|
36
36
|
// Manage focus
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
37
|
+
this.classCollection.delete(this.classFocus);
|
|
38
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
39
39
|
// Display Error
|
|
40
40
|
this.displayError();
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* Get pattern validity
|
|
44
44
|
* Pattern is not defined on textarea field: https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
|
|
45
|
-
*
|
|
46
|
-
* @returns {boolean} is pattern valid
|
|
45
|
+
* @returns is pattern valid
|
|
47
46
|
*/
|
|
48
47
|
this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
|
|
49
48
|
/**
|
|
@@ -75,7 +74,7 @@ export class MgInputTextarea {
|
|
|
75
74
|
* Validate pattern configuration
|
|
76
75
|
*/
|
|
77
76
|
this.validatePattern = () => {
|
|
78
|
-
if (this.pattern &&
|
|
77
|
+
if (this.pattern !== undefined &&
|
|
79
78
|
typeof this.pattern === 'string' &&
|
|
80
79
|
this.pattern !== '' &&
|
|
81
80
|
(this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
|
|
@@ -103,7 +102,7 @@ export class MgInputTextarea {
|
|
|
103
102
|
this.valid = undefined;
|
|
104
103
|
this.invalid = undefined;
|
|
105
104
|
this.resizable = 'none';
|
|
106
|
-
this.
|
|
105
|
+
this.classCollection = new ClassList(['mg-input--textarea']);
|
|
107
106
|
this.errorMessage = undefined;
|
|
108
107
|
}
|
|
109
108
|
handleValue(newValue) {
|
|
@@ -122,16 +121,14 @@ export class MgInputTextarea {
|
|
|
122
121
|
}
|
|
123
122
|
validateDisplayCharacterLeft(newValue) {
|
|
124
123
|
if (newValue) {
|
|
125
|
-
this.
|
|
124
|
+
this.classCollection.add(this.classHasDisplayCharacterLeft);
|
|
126
125
|
}
|
|
127
126
|
else {
|
|
128
|
-
this.
|
|
127
|
+
this.classCollection.delete(this.classHasDisplayCharacterLeft);
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
130
|
/**
|
|
132
131
|
* Public method to display errors
|
|
133
|
-
*
|
|
134
|
-
* @returns {Promise<void>}
|
|
135
132
|
*/
|
|
136
133
|
async displayError() {
|
|
137
134
|
this.checkValidity();
|
|
@@ -143,8 +140,7 @@ export class MgInputTextarea {
|
|
|
143
140
|
*************/
|
|
144
141
|
/**
|
|
145
142
|
* Check if component props are well configured on init
|
|
146
|
-
*
|
|
147
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
143
|
+
* @returns timeout
|
|
148
144
|
*/
|
|
149
145
|
componentWillLoad() {
|
|
150
146
|
// Get locales
|
|
@@ -162,11 +158,10 @@ export class MgInputTextarea {
|
|
|
162
158
|
}
|
|
163
159
|
/**
|
|
164
160
|
* Render
|
|
165
|
-
*
|
|
166
|
-
* @returns {HTMLElement} HTML Element
|
|
161
|
+
* @returns HTML Element
|
|
167
162
|
*/
|
|
168
163
|
render() {
|
|
169
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
164
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], 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: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("div", { class: "mg-input__with-character-left" }, h("textarea", { class: {
|
|
170
165
|
'mg-input__box': true,
|
|
171
166
|
'mg-input__box--resizable': this.resizable === 'both',
|
|
172
167
|
'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
@@ -566,7 +561,7 @@ export class MgInputTextarea {
|
|
|
566
561
|
}
|
|
567
562
|
static get states() {
|
|
568
563
|
return {
|
|
569
|
-
"
|
|
564
|
+
"classCollection": {},
|
|
570
565
|
"errorMessage": {}
|
|
571
566
|
};
|
|
572
567
|
}
|
|
@@ -618,10 +613,7 @@ export class MgInputTextarea {
|
|
|
618
613
|
},
|
|
619
614
|
"docs": {
|
|
620
615
|
"text": "Public method to display errors",
|
|
621
|
-
"tags": [
|
|
622
|
-
"name": "returns",
|
|
623
|
-
"text": undefined
|
|
624
|
-
}]
|
|
616
|
+
"tags": []
|
|
625
617
|
}
|
|
626
618
|
}
|
|
627
619
|
};
|
|
@@ -5,9 +5,8 @@ import { MgInput } from '../MgInput';
|
|
|
5
5
|
import { ClassList, allItemsAreString } from '../../../../utils/components.utils';
|
|
6
6
|
/**
|
|
7
7
|
* type Option validation function
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @returns {boolean} toggle option type is valid
|
|
8
|
+
* @param option - radio option
|
|
9
|
+
* @returns toggle option type is valid
|
|
11
10
|
*/
|
|
12
11
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
13
12
|
export class MgInputToggle {
|
|
@@ -23,16 +22,12 @@ export class MgInputToggle {
|
|
|
23
22
|
this.classIcon = 'mg-input--toggle-icon';
|
|
24
23
|
/**
|
|
25
24
|
* Change checked value
|
|
26
|
-
*
|
|
27
|
-
* @returns {void}
|
|
28
25
|
*/
|
|
29
26
|
this.toggleChecked = () => {
|
|
30
27
|
this.checked = !this.checked;
|
|
31
28
|
};
|
|
32
29
|
/**
|
|
33
30
|
* Slots validation
|
|
34
|
-
*
|
|
35
|
-
* @returns {void}
|
|
36
31
|
*/
|
|
37
32
|
this.validateSlots = () => {
|
|
38
33
|
const slots = Array.from(this.element.children);
|
|
@@ -58,7 +53,7 @@ export class MgInputToggle {
|
|
|
58
53
|
this.disabled = false;
|
|
59
54
|
this.tooltip = undefined;
|
|
60
55
|
this.helpText = undefined;
|
|
61
|
-
this.
|
|
56
|
+
this.classCollection = new ClassList(['mg-input--toggle']);
|
|
62
57
|
this.options = undefined;
|
|
63
58
|
this.checked = false;
|
|
64
59
|
}
|
|
@@ -86,41 +81,39 @@ export class MgInputToggle {
|
|
|
86
81
|
}
|
|
87
82
|
handleIsOnOff(newValue) {
|
|
88
83
|
if (newValue)
|
|
89
|
-
this.
|
|
84
|
+
this.classCollection.add(this.classOnOff);
|
|
90
85
|
else
|
|
91
|
-
this.
|
|
86
|
+
this.classCollection.delete(this.classOnOff);
|
|
92
87
|
}
|
|
93
88
|
handleIsIcon(newValue) {
|
|
94
89
|
if (newValue)
|
|
95
|
-
this.
|
|
90
|
+
this.classCollection.add(this.classIcon);
|
|
96
91
|
else
|
|
97
|
-
this.
|
|
92
|
+
this.classCollection.delete(this.classIcon);
|
|
98
93
|
}
|
|
99
94
|
handleReadonly(newValue) {
|
|
100
95
|
if (newValue)
|
|
101
|
-
this.
|
|
96
|
+
this.classCollection.add(this.classReadonly);
|
|
102
97
|
else
|
|
103
|
-
this.
|
|
98
|
+
this.classCollection.delete(this.classReadonly);
|
|
104
99
|
}
|
|
105
100
|
handleDisabled(newValue) {
|
|
106
101
|
if (newValue)
|
|
107
|
-
this.
|
|
102
|
+
this.classCollection.add(this.classDisabled);
|
|
108
103
|
else
|
|
109
|
-
this.
|
|
104
|
+
this.classCollection.delete(this.classDisabled);
|
|
110
105
|
}
|
|
111
106
|
handleChecked(newValue) {
|
|
112
107
|
// style
|
|
113
108
|
if (newValue)
|
|
114
|
-
this.
|
|
109
|
+
this.classCollection.add(this.classIsActive);
|
|
115
110
|
else
|
|
116
|
-
this.
|
|
111
|
+
this.classCollection.delete(this.classIsActive);
|
|
117
112
|
// update value
|
|
118
113
|
this.value = this.options[newValue ? 1 : 0].value;
|
|
119
114
|
}
|
|
120
115
|
/**
|
|
121
116
|
* set checked state
|
|
122
|
-
*
|
|
123
|
-
* @returns {void}
|
|
124
117
|
*/
|
|
125
118
|
setChecked() {
|
|
126
119
|
const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);
|
|
@@ -162,11 +155,10 @@ export class MgInputToggle {
|
|
|
162
155
|
}
|
|
163
156
|
/**
|
|
164
157
|
* Render
|
|
165
|
-
*
|
|
166
|
-
* @returns {HTMLElement} HTML Element
|
|
158
|
+
* @returns HTML Element
|
|
167
159
|
*/
|
|
168
160
|
render() {
|
|
169
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
161
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-2" })))));
|
|
170
162
|
}
|
|
171
163
|
static get is() { return "mg-input-toggle"; }
|
|
172
164
|
static get encapsulation() { return "shadow"; }
|
|
@@ -215,10 +207,7 @@ export class MgInputToggle {
|
|
|
215
207
|
"required": true,
|
|
216
208
|
"optional": false,
|
|
217
209
|
"docs": {
|
|
218
|
-
"tags": [
|
|
219
|
-
"name": "returns",
|
|
220
|
-
"text": undefined
|
|
221
|
-
}],
|
|
210
|
+
"tags": [],
|
|
222
211
|
"text": "Items are the possible options to select"
|
|
223
212
|
}
|
|
224
213
|
},
|
|
@@ -419,7 +408,7 @@ export class MgInputToggle {
|
|
|
419
408
|
}
|
|
420
409
|
static get states() {
|
|
421
410
|
return {
|
|
422
|
-
"
|
|
411
|
+
"classCollection": {},
|
|
423
412
|
"options": {},
|
|
424
413
|
"checked": {}
|
|
425
414
|
};
|
|
@@ -13,10 +13,8 @@ export class MgMenu {
|
|
|
13
13
|
*************/
|
|
14
14
|
/**
|
|
15
15
|
* Close matching menu-item
|
|
16
|
-
*
|
|
17
|
-
* @param
|
|
18
|
-
* @param {boolean} condition addionnal condition
|
|
19
|
-
* @returns {void}
|
|
16
|
+
* @param item - menu-item to close
|
|
17
|
+
* @param condition - addionnal condition
|
|
20
18
|
*/
|
|
21
19
|
this.closeMenuItem = (item, condition) => {
|
|
22
20
|
if (!this.isChildMenu && condition) {
|
|
@@ -25,22 +23,18 @@ export class MgMenu {
|
|
|
25
23
|
};
|
|
26
24
|
/**
|
|
27
25
|
* get mg-item-more element
|
|
28
|
-
*
|
|
29
|
-
* @returns {HTMLMgItemMoreElement} mg-item-more element
|
|
26
|
+
* @returns mg-item-more element
|
|
30
27
|
*/
|
|
31
28
|
this.getItemMore = () => this.element.querySelector('mg-item-more');
|
|
32
29
|
/**
|
|
33
|
-
* get mg-item-more
|
|
34
|
-
*
|
|
35
|
-
* @returns {HTMLMgMenuItemElement} mg-item-more >>> mg-menu-item element
|
|
30
|
+
* get mg-item-more child mg-menu-item element
|
|
31
|
+
* @returns mg-menu-item element
|
|
36
32
|
*/
|
|
37
33
|
this.getItemMoreMenuItem = () => { var _a, _b; return (_b = (_a = this.getItemMore()) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mg-menu-item'); };
|
|
38
34
|
/**
|
|
39
35
|
* Set item listend
|
|
40
|
-
*
|
|
41
|
-
* @param
|
|
42
|
-
* @param {MgMenu['focusedMenuItem']} index number
|
|
43
|
-
* @returns {void}
|
|
36
|
+
* @param item - mg-menu-item element
|
|
37
|
+
* @param index - number
|
|
44
38
|
*/
|
|
45
39
|
this.setItemListener = (item, index) => {
|
|
46
40
|
['click', 'focus'].forEach(trigger => {
|
|
@@ -55,8 +49,6 @@ export class MgMenu {
|
|
|
55
49
|
};
|
|
56
50
|
/**
|
|
57
51
|
* Store menu-items on component init and add listeners
|
|
58
|
-
*
|
|
59
|
-
* @returns {void}
|
|
60
52
|
*/
|
|
61
53
|
this.initMenuItemsListeners = () => {
|
|
62
54
|
// add listeners on menu item and edit index
|
|
@@ -66,16 +58,12 @@ export class MgMenu {
|
|
|
66
58
|
};
|
|
67
59
|
/**
|
|
68
60
|
* Handle item-loaded event on mg-item-more element
|
|
69
|
-
*
|
|
70
|
-
* @returns {void}
|
|
71
61
|
*/
|
|
72
62
|
this.handleItemLoaded = () => {
|
|
73
63
|
this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);
|
|
74
64
|
};
|
|
75
65
|
/**
|
|
76
66
|
* render mg-item-more
|
|
77
|
-
*
|
|
78
|
-
* @returns {void}
|
|
79
67
|
*/
|
|
80
68
|
this.renderMgItemMore = () => {
|
|
81
69
|
// /!\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement
|
|
@@ -117,8 +105,6 @@ export class MgMenu {
|
|
|
117
105
|
*************/
|
|
118
106
|
/**
|
|
119
107
|
* Validate props
|
|
120
|
-
*
|
|
121
|
-
* @returns {void}
|
|
122
108
|
*/
|
|
123
109
|
componentWillLoad() {
|
|
124
110
|
this.validateDirection(this.direction);
|
|
@@ -128,8 +114,7 @@ export class MgMenu {
|
|
|
128
114
|
}
|
|
129
115
|
/**
|
|
130
116
|
* Check if component slots configuration
|
|
131
|
-
*
|
|
132
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
117
|
+
* @returns timeout
|
|
133
118
|
*/
|
|
134
119
|
componentDidLoad() {
|
|
135
120
|
// update props and states after componentDidLoad hook
|
|
@@ -159,16 +144,13 @@ export class MgMenu {
|
|
|
159
144
|
}
|
|
160
145
|
/**
|
|
161
146
|
* Add listeners to items
|
|
162
|
-
*
|
|
163
|
-
* @returns {void}
|
|
164
147
|
*/
|
|
165
148
|
componentDidRender() {
|
|
166
149
|
this.initMenuItemsListeners();
|
|
167
150
|
}
|
|
168
151
|
/**
|
|
169
152
|
* Render
|
|
170
|
-
*
|
|
171
|
-
* @returns {HTMLElement} HTML Element
|
|
153
|
+
* @returns HTML Element
|
|
172
154
|
*/
|
|
173
155
|
render() {
|
|
174
156
|
return (h(Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, h("slot", null)));
|
|
@@ -221,7 +203,7 @@ export class MgMenu {
|
|
|
221
203
|
"optional": false,
|
|
222
204
|
"docs": {
|
|
223
205
|
"tags": [],
|
|
224
|
-
"text": "Component display direction.
|
|
206
|
+
"text": "Component display direction."
|
|
225
207
|
},
|
|
226
208
|
"attribute": "direction",
|
|
227
209
|
"reflect": true,
|
|
@@ -264,7 +246,7 @@ export class MgMenu {
|
|
|
264
246
|
"optional": false,
|
|
265
247
|
"docs": {
|
|
266
248
|
"tags": [],
|
|
267
|
-
"text": "Define mg-menu size
|
|
249
|
+
"text": "Define mg-menu size"
|
|
268
250
|
},
|
|
269
251
|
"attribute": "size",
|
|
270
252
|
"reflect": false,
|