@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
|
@@ -5,24 +5,31 @@ export class MgIcon {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
/**
|
|
7
7
|
* getIcon
|
|
8
|
-
*
|
|
9
|
-
* @returns {HTMLElement} icon html
|
|
8
|
+
* @returns icon html
|
|
10
9
|
*/
|
|
11
10
|
this.getIcon = () => icons[this.icon]();
|
|
11
|
+
/**
|
|
12
|
+
* Method to set default varianStyle props
|
|
13
|
+
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
14
|
+
*/
|
|
15
|
+
this.setDefaultVariantStyle = () => {
|
|
16
|
+
if (this.variantStyle === undefined)
|
|
17
|
+
this.variantStyle = 'background';
|
|
18
|
+
};
|
|
12
19
|
this.icon = undefined;
|
|
13
20
|
this.size = 'regular';
|
|
14
21
|
this.variant = undefined;
|
|
15
22
|
this.variantStyle = undefined;
|
|
16
23
|
this.spin = false;
|
|
17
|
-
this.
|
|
24
|
+
this.classCollection = new ClassList(['mg-icon']);
|
|
18
25
|
}
|
|
19
26
|
validateIcon(newValue, oldValue) {
|
|
20
27
|
if (!Object.keys(icons).includes(newValue))
|
|
21
28
|
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
|
|
22
29
|
else {
|
|
23
30
|
if (oldValue !== undefined)
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
31
|
+
this.classCollection.delete(`mg-icon--${oldValue}`);
|
|
32
|
+
this.classCollection.add(`mg-icon--${newValue}`);
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
validateSize(newValue, oldValue) {
|
|
@@ -30,8 +37,8 @@ export class MgIcon {
|
|
|
30
37
|
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
31
38
|
else {
|
|
32
39
|
if (oldValue !== undefined)
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
40
|
+
this.classCollection.delete(`mg-icon--size-${oldValue}`);
|
|
41
|
+
this.classCollection.add(`mg-icon--size-${newValue}`);
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
44
|
validateVariant(newValue, oldValue) {
|
|
@@ -39,11 +46,10 @@ export class MgIcon {
|
|
|
39
46
|
if (!variants.includes(newValue))
|
|
40
47
|
throw new Error(`<mg-icon> prop "variant" must be one of: ${variants.join(', ')}`);
|
|
41
48
|
else {
|
|
42
|
-
|
|
43
|
-
this.variantStyle = 'background';
|
|
49
|
+
this.setDefaultVariantStyle();
|
|
44
50
|
if (oldValue !== undefined)
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
51
|
+
this.classCollection.delete(`mg-icon--variant-${oldValue}`);
|
|
52
|
+
this.classCollection.add(`mg-icon--variant-${newValue}`);
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
}
|
|
@@ -53,25 +59,23 @@ export class MgIcon {
|
|
|
53
59
|
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
|
|
54
60
|
else {
|
|
55
61
|
if (oldValue !== undefined)
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
62
|
+
this.classCollection.delete(`mg-icon--variant-style-${oldValue}`);
|
|
63
|
+
this.classCollection.add(`mg-icon--variant-style-${newValue}`);
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
handleSpin(newValue) {
|
|
62
68
|
if (newValue) {
|
|
63
|
-
this.
|
|
64
|
-
this.
|
|
69
|
+
this.classCollection.add('mg-icon--spin');
|
|
70
|
+
this.classCollection.add('mg-a11y-animation');
|
|
65
71
|
}
|
|
66
72
|
else {
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
73
|
+
this.classCollection.delete('mg-icon--spin');
|
|
74
|
+
this.classCollection.delete('mg-a11y-animation');
|
|
69
75
|
}
|
|
70
76
|
}
|
|
71
77
|
/**
|
|
72
78
|
* Check if props are well configured on init
|
|
73
|
-
*
|
|
74
|
-
* @returns {void}
|
|
75
79
|
*/
|
|
76
80
|
componentWillLoad() {
|
|
77
81
|
this.validateIcon(this.icon);
|
|
@@ -82,11 +86,10 @@ export class MgIcon {
|
|
|
82
86
|
}
|
|
83
87
|
/**
|
|
84
88
|
* Render component
|
|
85
|
-
*
|
|
86
|
-
* @returns {HTMLElement} HTML Element
|
|
89
|
+
* @returns HTML Element
|
|
87
90
|
*/
|
|
88
91
|
render() {
|
|
89
|
-
return (h("svg", { class: this.
|
|
92
|
+
return (h("svg", { class: this.classCollection.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
|
|
90
93
|
}
|
|
91
94
|
static get is() { return "mg-icon"; }
|
|
92
95
|
static get encapsulation() { return "shadow"; }
|
|
@@ -208,7 +211,7 @@ export class MgIcon {
|
|
|
208
211
|
}
|
|
209
212
|
static get states() {
|
|
210
213
|
return {
|
|
211
|
-
"
|
|
214
|
+
"classCollection": {}
|
|
212
215
|
};
|
|
213
216
|
}
|
|
214
217
|
static get watchers() {
|
|
@@ -19,8 +19,6 @@ export class MgInputTitle {
|
|
|
19
19
|
*************/
|
|
20
20
|
/**
|
|
21
21
|
* Init tag name
|
|
22
|
-
*
|
|
23
|
-
* @returns {void}
|
|
24
22
|
*/
|
|
25
23
|
componentWillLoad() {
|
|
26
24
|
this.validateIdentifier(this.identifier);
|
|
@@ -28,8 +26,7 @@ export class MgInputTitle {
|
|
|
28
26
|
}
|
|
29
27
|
/**
|
|
30
28
|
* Render
|
|
31
|
-
*
|
|
32
|
-
* @returns {HTMLElement} HTML Element
|
|
29
|
+
* @returns HTML element
|
|
33
30
|
*/
|
|
34
31
|
render() {
|
|
35
32
|
const TagName = this.tagName;
|
|
@@ -12,7 +12,7 @@ export class MgTag {
|
|
|
12
12
|
this.variant = variants[0];
|
|
13
13
|
this.outline = undefined;
|
|
14
14
|
this.soft = undefined;
|
|
15
|
-
this.
|
|
15
|
+
this.classCollection = new ClassList(['mg-tag']);
|
|
16
16
|
}
|
|
17
17
|
validateVariant(newValue, oldValue) {
|
|
18
18
|
if (!variants.includes(newValue)) {
|
|
@@ -20,16 +20,16 @@ export class MgTag {
|
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
22
|
if (oldValue !== undefined) {
|
|
23
|
-
this.
|
|
23
|
+
this.classCollection.delete(`mg-tag--${oldValue}`);
|
|
24
24
|
}
|
|
25
|
-
this.
|
|
25
|
+
this.classCollection.add(`mg-tag--${newValue}`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
validateOutline(newValue) {
|
|
29
29
|
if (newValue)
|
|
30
|
-
this.
|
|
30
|
+
this.classCollection.add(this.classOutline);
|
|
31
31
|
else
|
|
32
|
-
this.
|
|
32
|
+
this.classCollection.delete(this.classOutline);
|
|
33
33
|
}
|
|
34
34
|
validateSoft(newValue) {
|
|
35
35
|
// usage validation
|
|
@@ -37,18 +37,16 @@ export class MgTag {
|
|
|
37
37
|
throw new Error('<mg-tag> prop "soft" can NOT be used with prop "outline".');
|
|
38
38
|
// apply class
|
|
39
39
|
if (newValue)
|
|
40
|
-
this.
|
|
40
|
+
this.classCollection.add(this.classSoft);
|
|
41
41
|
else
|
|
42
|
-
this.
|
|
42
|
+
this.classCollection.delete(this.classSoft);
|
|
43
43
|
}
|
|
44
44
|
/*************
|
|
45
45
|
* Methods *
|
|
46
46
|
*************/
|
|
47
47
|
/**
|
|
48
48
|
* Validate the given textContent
|
|
49
|
-
*
|
|
50
|
-
* @param {string} textContent html element textContent property
|
|
51
|
-
* @returns {void}
|
|
49
|
+
* @param textContent - html element textContent property
|
|
52
50
|
*/
|
|
53
51
|
validateTextContent(textContent) {
|
|
54
52
|
if (typeof textContent !== 'string' || textContent.trim() === '')
|
|
@@ -59,8 +57,6 @@ export class MgTag {
|
|
|
59
57
|
*************/
|
|
60
58
|
/**
|
|
61
59
|
* Check if props are well configured on init
|
|
62
|
-
*
|
|
63
|
-
* @returns {void}
|
|
64
60
|
*/
|
|
65
61
|
componentWillLoad() {
|
|
66
62
|
this.validateVariant(this.variant);
|
|
@@ -70,11 +66,10 @@ export class MgTag {
|
|
|
70
66
|
}
|
|
71
67
|
/**
|
|
72
68
|
* Render
|
|
73
|
-
*
|
|
74
|
-
* @returns {HTMLElement} HTML Element
|
|
69
|
+
* @returns HTML Element
|
|
75
70
|
*/
|
|
76
71
|
render() {
|
|
77
|
-
return (h("span", { class: this.
|
|
72
|
+
return (h("span", { class: this.classCollection.join() }, h("slot", null)));
|
|
78
73
|
}
|
|
79
74
|
static get is() { return "mg-tag"; }
|
|
80
75
|
static get encapsulation() { return "shadow"; }
|
|
@@ -151,7 +146,7 @@ export class MgTag {
|
|
|
151
146
|
}
|
|
152
147
|
static get states() {
|
|
153
148
|
return {
|
|
154
|
-
"
|
|
149
|
+
"classCollection": {}
|
|
155
150
|
};
|
|
156
151
|
}
|
|
157
152
|
static get elementRef() { return "element"; }
|
|
@@ -6,8 +6,6 @@ export class MgTooltip {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
/**
|
|
8
8
|
* Show tooltip
|
|
9
|
-
*
|
|
10
|
-
* @returns {void}
|
|
11
9
|
*/
|
|
12
10
|
this.show = () => {
|
|
13
11
|
// Make the tooltip visible
|
|
@@ -27,8 +25,6 @@ export class MgTooltip {
|
|
|
27
25
|
};
|
|
28
26
|
/**
|
|
29
27
|
* Hide tooltip
|
|
30
|
-
*
|
|
31
|
-
* @returns {void}
|
|
32
28
|
*/
|
|
33
29
|
this.hide = () => {
|
|
34
30
|
// Hide the tooltip
|
|
@@ -43,9 +39,7 @@ export class MgTooltip {
|
|
|
43
39
|
};
|
|
44
40
|
/**
|
|
45
41
|
* Check if clicked outside of component and hidde tooltip
|
|
46
|
-
*
|
|
47
|
-
* @param {MouseEvent} event mouse event
|
|
48
|
-
* @returns {void}
|
|
42
|
+
* @param event - mouse event
|
|
49
43
|
*/
|
|
50
44
|
this.clickOutside = (event) => {
|
|
51
45
|
if (event.target.closest('mg-tooltip') !== this.element)
|
|
@@ -53,9 +47,7 @@ export class MgTooltip {
|
|
|
53
47
|
};
|
|
54
48
|
/**
|
|
55
49
|
* Check if 'Escape' key is pressed of component and hidde tooltip
|
|
56
|
-
*
|
|
57
|
-
* @param {KeyboardEvent} event keyboard event
|
|
58
|
-
* @returns {void}
|
|
50
|
+
* @param event - keyboard event
|
|
59
51
|
*/
|
|
60
52
|
this.pressEscape = (event) => {
|
|
61
53
|
if (event.code === 'Escape')
|
|
@@ -63,10 +55,8 @@ export class MgTooltip {
|
|
|
63
55
|
};
|
|
64
56
|
/**
|
|
65
57
|
* Method to set display prop
|
|
66
|
-
*
|
|
67
|
-
* @param
|
|
68
|
-
* @param {boolean} condition additionnal condition to apply display prop newValue
|
|
69
|
-
* @returns {void}
|
|
58
|
+
* @param newValue - display prop new value
|
|
59
|
+
* @param condition - additionnal condition to apply display prop newValue
|
|
70
60
|
*/
|
|
71
61
|
this.setDisplay = (newValue, condition = true) => {
|
|
72
62
|
if (!this.disabled && condition)
|
|
@@ -74,11 +64,9 @@ export class MgTooltip {
|
|
|
74
64
|
};
|
|
75
65
|
/**
|
|
76
66
|
* Action for tooltip element and tooltiped element mouse listener
|
|
77
|
-
*
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
80
|
-
* @param {Guard} conditionalGuard guard condition
|
|
81
|
-
* @returns {void}
|
|
67
|
+
* @param elementGuard - tooltip element guard
|
|
68
|
+
* @param isMouseenter - mouseenter validation
|
|
69
|
+
* @param conditionalGuard - guard condition
|
|
82
70
|
*/
|
|
83
71
|
this.tooltipMouseListenerAction = (elementGuard, isMouseenter, conditionalGuard) => {
|
|
84
72
|
// we mutate elementGuard
|
|
@@ -97,17 +85,13 @@ export class MgTooltip {
|
|
|
97
85
|
};
|
|
98
86
|
/**
|
|
99
87
|
* Method to reset guard value
|
|
100
|
-
*
|
|
101
|
-
* @returns {void}
|
|
102
88
|
*/
|
|
103
89
|
this.resetGuard = () => {
|
|
104
90
|
this.guard = undefined;
|
|
105
91
|
};
|
|
106
92
|
/**
|
|
107
93
|
* Update slot content when it is a mg-button
|
|
108
|
-
*
|
|
109
|
-
* @param {HTMLMgButtonElement} mgButton slotted mg-button
|
|
110
|
-
* @returns {void}
|
|
94
|
+
* @param mgButton - slotted mg-button
|
|
111
95
|
*/
|
|
112
96
|
this.setMgButtonWrapper = (mgButton) => {
|
|
113
97
|
if (mgButton.disabled) {
|
|
@@ -124,9 +108,8 @@ export class MgTooltip {
|
|
|
124
108
|
};
|
|
125
109
|
/**
|
|
126
110
|
* Init tooltip
|
|
127
|
-
*
|
|
128
|
-
* @param
|
|
129
|
-
* @param {HTMLElement} interactiveElement interactive element
|
|
111
|
+
* @param slotElement - slotted element
|
|
112
|
+
* @param interactiveElement - interactive element
|
|
130
113
|
*/
|
|
131
114
|
this.initTooltip = (slotElement, interactiveElement) => {
|
|
132
115
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
@@ -202,8 +185,6 @@ export class MgTooltip {
|
|
|
202
185
|
*************/
|
|
203
186
|
/**
|
|
204
187
|
* set variables
|
|
205
|
-
*
|
|
206
|
-
* @returns {void}
|
|
207
188
|
*/
|
|
208
189
|
componentWillLoad() {
|
|
209
190
|
// Get windows to attach events
|
|
@@ -213,8 +194,6 @@ export class MgTooltip {
|
|
|
213
194
|
* Get slotted element
|
|
214
195
|
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
215
196
|
* We need to attach the focused element to the tooltip (aria-describedby)
|
|
216
|
-
*
|
|
217
|
-
* @returns {void}
|
|
218
197
|
*/
|
|
219
198
|
componentDidLoad() {
|
|
220
199
|
var _a;
|
|
@@ -247,8 +226,7 @@ export class MgTooltip {
|
|
|
247
226
|
}
|
|
248
227
|
/**
|
|
249
228
|
* Render
|
|
250
|
-
*
|
|
251
|
-
* @returns {HTMLElement} HTML Element
|
|
229
|
+
* @returns HTML Element
|
|
252
230
|
*/
|
|
253
231
|
render() {
|
|
254
232
|
return (h(Host, null, h("slot", null), h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip" }, h("span", { innerHTML: this.message }), h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|
|
@@ -345,7 +323,7 @@ export class MgTooltip {
|
|
|
345
323
|
},
|
|
346
324
|
"disabled": {
|
|
347
325
|
"type": "boolean",
|
|
348
|
-
"mutable":
|
|
326
|
+
"mutable": false,
|
|
349
327
|
"complexType": {
|
|
350
328
|
"original": "boolean",
|
|
351
329
|
"resolved": "boolean",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
+
import { widths } from './MgInput.conf';
|
|
2
3
|
/**
|
|
3
4
|
* Apply in all input child node the aria-describedby attribute
|
|
4
|
-
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
8
|
-
* @returns {VNode[]} Children with aria-describedby attribute
|
|
5
|
+
* @param children - Represent scoped elements
|
|
6
|
+
* @param ariaDescribedbyIDs - List of IDs
|
|
7
|
+
* @param utils - Stencil.js utils
|
|
8
|
+
* @returns Children with aria-describedby attribute
|
|
9
9
|
*/
|
|
10
10
|
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
11
11
|
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
@@ -18,32 +18,36 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
|
|
|
18
18
|
});
|
|
19
19
|
/**
|
|
20
20
|
* Add classes based on props
|
|
21
|
-
*
|
|
22
|
-
* @param {MgInputProps} props MgInput Interface Props
|
|
21
|
+
* @param props - MgInput Interface Props
|
|
23
22
|
*/
|
|
24
23
|
const manageClasses = (props) => {
|
|
25
|
-
props.
|
|
24
|
+
props.classCollection.add('mg-input');
|
|
26
25
|
if (props.labelOnTop)
|
|
27
|
-
props.
|
|
26
|
+
props.classCollection.add('mg-input--label-on-top');
|
|
27
|
+
else
|
|
28
|
+
props.classCollection.delete('mg-input--label-on-top');
|
|
28
29
|
if (props.readonly)
|
|
29
|
-
props.
|
|
30
|
+
props.classCollection.add('mg-input--readonly');
|
|
31
|
+
else
|
|
32
|
+
props.classCollection.delete('mg-input--readonly');
|
|
33
|
+
widths.forEach(width => {
|
|
34
|
+
props.classCollection.delete(`mg-input--width-${width}`);
|
|
35
|
+
});
|
|
30
36
|
if (props.mgWidth !== undefined)
|
|
31
|
-
props.
|
|
37
|
+
props.classCollection.add(`mg-input--width-${props.mgWidth}`);
|
|
32
38
|
};
|
|
33
39
|
/**
|
|
34
40
|
* Get tagname
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
37
|
-
* @returns {string} tag name
|
|
41
|
+
* @param isFieldset - is fieldset
|
|
42
|
+
* @returns tag name
|
|
38
43
|
*/
|
|
39
44
|
const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
|
|
40
45
|
/**
|
|
41
46
|
* Get input template
|
|
42
|
-
*
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @
|
|
46
|
-
* @returns {VNode[]} input template
|
|
47
|
+
* @param props - MgInput Interface Props
|
|
48
|
+
* @param children - Represent scoped elements
|
|
49
|
+
* @param utils - Stencil.js utils
|
|
50
|
+
* @returns input template
|
|
47
51
|
*/
|
|
48
52
|
export const MgInput = (props, children, utils) => {
|
|
49
53
|
/**
|
|
@@ -99,16 +103,14 @@ export const MgInput = (props, children, utils) => {
|
|
|
99
103
|
const TagName = getTagName(props.isFieldset);
|
|
100
104
|
/**
|
|
101
105
|
* Get tooltip node
|
|
102
|
-
*
|
|
103
|
-
* @returns {VNode[]} mg-tooltip
|
|
106
|
+
* @returns mg-tooltip
|
|
104
107
|
*/
|
|
105
108
|
const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip }, h("mg-icon", { icon: "info-circle" })));
|
|
106
109
|
/**
|
|
107
110
|
* Get input title (label) node
|
|
108
111
|
* Display asterisk only if not disabled and not readonly
|
|
109
|
-
*
|
|
110
|
-
* @returns {VNode[]} mg-input-title
|
|
112
|
+
* @returns mg-input-title
|
|
111
113
|
*/
|
|
112
114
|
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
|
|
113
|
-
return (h(TagName, { class: props.
|
|
115
|
+
return (h(TagName, { class: props.classCollection.join() }, props.labelOnTop ? (h("div", { class: "mg-input__title" }, getInputTitle(), !props.readonly && props.tooltip && getTooltip())) : (getInputTitle()), props.readonly ? (h("div", { class: "mg-input__input-container" }, h("strong", null, props.readonlyValue), children.filter(child => child.$name$ === 'append-input'))) : (h("div", { class: "mg-input__input-container" }, h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } }, applyAriadescribedBy(children, ariaDescribedbyIDs, utils), !props.labelOnTop && props.tooltip && getTooltip()), props.helpText && h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }), props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
|
|
114
116
|
};
|
|
@@ -5,9 +5,8 @@ import { ClassList } from '../../../../utils/components.utils';
|
|
|
5
5
|
import { initLocales } from '../../../../locales';
|
|
6
6
|
/**
|
|
7
7
|
* type CheckboxItem validation function
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @returns {boolean} match item type
|
|
8
|
+
* @param items - Checkbox item
|
|
9
|
+
* @returns match item type
|
|
11
10
|
*/
|
|
12
11
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
13
12
|
items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
|
|
@@ -22,8 +21,7 @@ export class MgInputCheckbox {
|
|
|
22
21
|
this.hasDisplayedError = false;
|
|
23
22
|
/**
|
|
24
23
|
* Handle input event
|
|
25
|
-
*
|
|
26
|
-
* @param {InputEvent} event input event
|
|
24
|
+
* @param event - input event
|
|
27
25
|
*/
|
|
28
26
|
this.handleInput = (event) => {
|
|
29
27
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -45,8 +43,7 @@ export class MgInputCheckbox {
|
|
|
45
43
|
};
|
|
46
44
|
/**
|
|
47
45
|
* get invalid element
|
|
48
|
-
*
|
|
49
|
-
* @returns {HTMLInputElement} element
|
|
46
|
+
* @returns element
|
|
50
47
|
*/
|
|
51
48
|
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
52
49
|
/**
|
|
@@ -83,7 +80,7 @@ export class MgInputCheckbox {
|
|
|
83
80
|
this.helpText = undefined;
|
|
84
81
|
this.valid = undefined;
|
|
85
82
|
this.invalid = undefined;
|
|
86
|
-
this.
|
|
83
|
+
this.classCollection = new ClassList(['mg-input--checkbox']);
|
|
87
84
|
this.errorMessage = undefined;
|
|
88
85
|
this.checkboxItems = [];
|
|
89
86
|
}
|
|
@@ -113,8 +110,6 @@ export class MgInputCheckbox {
|
|
|
113
110
|
}
|
|
114
111
|
/**
|
|
115
112
|
* Public method to display errors
|
|
116
|
-
*
|
|
117
|
-
* @returns {Promise<void>}
|
|
118
113
|
*/
|
|
119
114
|
async displayError() {
|
|
120
115
|
this.checkValidity();
|
|
@@ -126,8 +121,7 @@ export class MgInputCheckbox {
|
|
|
126
121
|
*************/
|
|
127
122
|
/**
|
|
128
123
|
* Check if component props are well configured on init
|
|
129
|
-
*
|
|
130
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
124
|
+
* @returns timeout
|
|
131
125
|
*/
|
|
132
126
|
componentWillLoad() {
|
|
133
127
|
// Get locales
|
|
@@ -143,11 +137,10 @@ export class MgInputCheckbox {
|
|
|
143
137
|
}
|
|
144
138
|
/**
|
|
145
139
|
* Render
|
|
146
|
-
*
|
|
147
|
-
* @returns {HTMLElement} HTML Element
|
|
140
|
+
* @returns HTML Element
|
|
148
141
|
*/
|
|
149
142
|
render() {
|
|
150
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
143
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.checkboxItems
|
|
151
144
|
.filter(item => {
|
|
152
145
|
return !this.readonly || item.value;
|
|
153
146
|
})
|
|
@@ -421,7 +414,7 @@ export class MgInputCheckbox {
|
|
|
421
414
|
}
|
|
422
415
|
static get states() {
|
|
423
416
|
return {
|
|
424
|
-
"
|
|
417
|
+
"classCollection": {},
|
|
425
418
|
"errorMessage": {},
|
|
426
419
|
"checkboxItems": {}
|
|
427
420
|
};
|
|
@@ -482,10 +475,7 @@ export class MgInputCheckbox {
|
|
|
482
475
|
},
|
|
483
476
|
"docs": {
|
|
484
477
|
"text": "Public method to display errors",
|
|
485
|
-
"tags": [
|
|
486
|
-
"name": "returns",
|
|
487
|
-
"text": undefined
|
|
488
|
-
}]
|
|
478
|
+
"tags": []
|
|
489
479
|
}
|
|
490
480
|
}
|
|
491
481
|
};
|
|
@@ -36,8 +36,7 @@ export class MgInputDate {
|
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
* get input error code
|
|
39
|
-
*
|
|
40
|
-
* @returns {null | InputError} error code
|
|
39
|
+
* @returns error code
|
|
41
40
|
*/
|
|
42
41
|
this.getInputError = () => {
|
|
43
42
|
var _a, _b;
|
|
@@ -62,8 +61,6 @@ export class MgInputDate {
|
|
|
62
61
|
};
|
|
63
62
|
/**
|
|
64
63
|
* Check input errors
|
|
65
|
-
*
|
|
66
|
-
* @returns {void}
|
|
67
64
|
*/
|
|
68
65
|
this.setErrorMessage = () => {
|
|
69
66
|
var _a;
|
|
@@ -101,7 +98,7 @@ export class MgInputDate {
|
|
|
101
98
|
this.invalid = undefined;
|
|
102
99
|
this.min = undefined;
|
|
103
100
|
this.max = undefined;
|
|
104
|
-
this.
|
|
101
|
+
this.classCollection = new ClassList(['mg-input--date']);
|
|
105
102
|
this.errorMessage = undefined;
|
|
106
103
|
}
|
|
107
104
|
validateValue(newValue) {
|
|
@@ -132,8 +129,6 @@ export class MgInputDate {
|
|
|
132
129
|
}
|
|
133
130
|
/**
|
|
134
131
|
* Public method to display errors
|
|
135
|
-
*
|
|
136
|
-
* @returns {Promise<void>}
|
|
137
132
|
*/
|
|
138
133
|
async displayError() {
|
|
139
134
|
this.checkValidity();
|
|
@@ -145,8 +140,7 @@ export class MgInputDate {
|
|
|
145
140
|
*************/
|
|
146
141
|
/**
|
|
147
142
|
* Check if component props are well configured on init
|
|
148
|
-
*
|
|
149
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
143
|
+
* @returns timeout
|
|
150
144
|
*/
|
|
151
145
|
componentWillLoad() {
|
|
152
146
|
// Get locales
|
|
@@ -166,11 +160,10 @@ export class MgInputDate {
|
|
|
166
160
|
}
|
|
167
161
|
/**
|
|
168
162
|
* Render
|
|
169
|
-
*
|
|
170
|
-
* @returns {HTMLElement} HTML Element
|
|
163
|
+
* @returns HTML Element
|
|
171
164
|
*/
|
|
172
165
|
render() {
|
|
173
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
166
|
+
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: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
174
167
|
if (el !== null)
|
|
175
168
|
this.input = el;
|
|
176
169
|
} })));
|
|
@@ -453,7 +446,7 @@ export class MgInputDate {
|
|
|
453
446
|
}
|
|
454
447
|
static get states() {
|
|
455
448
|
return {
|
|
456
|
-
"
|
|
449
|
+
"classCollection": {},
|
|
457
450
|
"errorMessage": {}
|
|
458
451
|
};
|
|
459
452
|
}
|
|
@@ -505,10 +498,7 @@ export class MgInputDate {
|
|
|
505
498
|
},
|
|
506
499
|
"docs": {
|
|
507
500
|
"text": "Public method to display errors",
|
|
508
|
-
"tags": [
|
|
509
|
-
"name": "returns",
|
|
510
|
-
"text": undefined
|
|
511
|
-
}]
|
|
501
|
+
"tags": []
|
|
512
502
|
}
|
|
513
503
|
}
|
|
514
504
|
};
|