@mgdis/mg-components 5.10.0 → 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 +318 -427
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +19 -28
- package/dist/cjs/{mg-menu.conf-1942ac70.js → mg-menu.conf-196151fe.js} +16 -16
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +8 -9
- package/dist/collection/components/atoms/mg-button/mg-button.js +16 -20
- package/dist/collection/components/atoms/mg-card/mg-card.js +10 -12
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +1 -2
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +17 -19
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -2
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +11 -13
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +11 -21
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +26 -18
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +10 -14
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +7 -12
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +14 -22
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +6 -10
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -18
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +21 -32
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +16 -31
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +13 -17
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +17 -23
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +11 -18
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +20 -29
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +11 -15
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -3
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -19
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -2
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +4 -7
- package/dist/collection/components/molecules/mg-message/mg-message.js +11 -14
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +7 -11
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +11 -13
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +6 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +7 -13
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +2 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +20 -24
- package/dist/collection/locales/index.js +2 -2
- package/dist/collection/utils/behaviors.utils.js +16 -22
- package/dist/collection/utils/components.utils.js +21 -23
- package/dist/collection/utils/locale.utils.js +14 -14
- package/dist/collection/utils/unit.test.utils.js +7 -10
- package/dist/components/MgInput.js +30 -18
- package/dist/components/components.utils.js +21 -23
- package/dist/components/index2.js +16 -16
- package/dist/components/mg-action-more.js +9 -13
- package/dist/components/mg-badge2.js +8 -9
- package/dist/components/mg-button2.js +16 -20
- package/dist/components/mg-card2.js +8 -10
- package/dist/components/mg-character-left2.js +1 -2
- package/dist/components/mg-details.js +1 -3
- package/dist/components/mg-divider.js +1 -1
- package/dist/components/mg-form.js +7 -15
- package/dist/components/mg-icon2.js +17 -19
- package/dist/components/mg-illustrated-message.js +1 -2
- package/dist/components/mg-input-checkbox.js +9 -10
- package/dist/components/mg-input-date.js +6 -8
- package/dist/components/mg-input-numeric.js +13 -18
- package/dist/components/mg-input-password.js +5 -6
- package/dist/components/mg-input-radio.js +9 -14
- package/dist/components/mg-input-select2.js +20 -28
- package/dist/components/mg-input-text2.js +14 -23
- package/dist/components/mg-input-textarea.js +12 -13
- package/dist/components/mg-input-title2.js +1 -2
- package/dist/components/mg-input-toggle.js +16 -19
- package/dist/components/mg-item-more.js +18 -27
- package/dist/components/mg-menu-item2.js +17 -26
- package/dist/components/mg-menu2.js +9 -16
- package/dist/components/mg-message.js +11 -14
- package/dist/components/mg-modal.js +7 -11
- package/dist/components/mg-pagination.js +11 -13
- package/dist/components/mg-panel.js +6 -15
- package/dist/components/mg-popover2.js +7 -13
- package/dist/components/mg-skip-links.js +2 -4
- package/dist/components/mg-tabs.js +20 -24
- package/dist/components/mg-tag.js +11 -13
- package/dist/components/mg-tooltip2.js +11 -21
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_31.entry.js +318 -427
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +19 -28
- package/dist/esm/{mg-menu.conf-2cc1bb67.js → mg-menu.conf-9ca023ee.js} +16 -16
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-a56a3157.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 -3
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +5 -9
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +2 -6
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -2
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +3 -5
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -2
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +3 -5
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -21
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -1
- package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -5
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -6
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -6
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +7 -14
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +3 -4
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -10
- 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 -13
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +3 -12
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -5
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -6
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +10 -18
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +21 -31
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +3 -10
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +1 -3
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -11
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +1 -2
- package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +2 -7
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +4 -7
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -7
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +5 -9
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +4 -13
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +3 -9
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +2 -4
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +15 -19
- package/dist/types/components.d.ts +22 -34
- package/dist/types/locales/index.d.ts +2 -2
- package/dist/types/utils/behaviors.utils.d.ts +14 -20
- package/dist/types/utils/components.utils.d.ts +18 -20
- package/dist/types/utils/locale.utils.d.ts +14 -14
- package/dist/types/utils/unit.test.utils.d.ts +11 -17
- package/package.json +1 -1
- package/dist/mg-components/p-eb32bb18.entry.js +0 -1
- /package/dist/mg-components/{p-73156ac9.js → p-0d3146d9.js} +0 -0
|
@@ -5,13 +5,12 @@ export class MgIcon {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
/**
|
|
7
7
|
* getIcon
|
|
8
|
-
* @returns
|
|
8
|
+
* @returns icon html
|
|
9
9
|
*/
|
|
10
10
|
this.getIcon = () => icons[this.icon]();
|
|
11
11
|
/**
|
|
12
12
|
* Method to set default varianStyle props
|
|
13
13
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
14
|
-
* @returns {void}
|
|
15
14
|
*/
|
|
16
15
|
this.setDefaultVariantStyle = () => {
|
|
17
16
|
if (this.variantStyle === undefined)
|
|
@@ -22,15 +21,15 @@ export class MgIcon {
|
|
|
22
21
|
this.variant = undefined;
|
|
23
22
|
this.variantStyle = undefined;
|
|
24
23
|
this.spin = false;
|
|
25
|
-
this.
|
|
24
|
+
this.classCollection = new ClassList(['mg-icon']);
|
|
26
25
|
}
|
|
27
26
|
validateIcon(newValue, oldValue) {
|
|
28
27
|
if (!Object.keys(icons).includes(newValue))
|
|
29
28
|
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
|
|
30
29
|
else {
|
|
31
30
|
if (oldValue !== undefined)
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
31
|
+
this.classCollection.delete(`mg-icon--${oldValue}`);
|
|
32
|
+
this.classCollection.add(`mg-icon--${newValue}`);
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
validateSize(newValue, oldValue) {
|
|
@@ -38,8 +37,8 @@ export class MgIcon {
|
|
|
38
37
|
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
39
38
|
else {
|
|
40
39
|
if (oldValue !== undefined)
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
40
|
+
this.classCollection.delete(`mg-icon--size-${oldValue}`);
|
|
41
|
+
this.classCollection.add(`mg-icon--size-${newValue}`);
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
validateVariant(newValue, oldValue) {
|
|
@@ -49,8 +48,8 @@ export class MgIcon {
|
|
|
49
48
|
else {
|
|
50
49
|
this.setDefaultVariantStyle();
|
|
51
50
|
if (oldValue !== undefined)
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
51
|
+
this.classCollection.delete(`mg-icon--variant-${oldValue}`);
|
|
52
|
+
this.classCollection.add(`mg-icon--variant-${newValue}`);
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
}
|
|
@@ -60,24 +59,23 @@ export class MgIcon {
|
|
|
60
59
|
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
|
|
61
60
|
else {
|
|
62
61
|
if (oldValue !== undefined)
|
|
63
|
-
this.
|
|
64
|
-
this.
|
|
62
|
+
this.classCollection.delete(`mg-icon--variant-style-${oldValue}`);
|
|
63
|
+
this.classCollection.add(`mg-icon--variant-style-${newValue}`);
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
handleSpin(newValue) {
|
|
69
68
|
if (newValue) {
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
69
|
+
this.classCollection.add('mg-icon--spin');
|
|
70
|
+
this.classCollection.add('mg-a11y-animation');
|
|
72
71
|
}
|
|
73
72
|
else {
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
73
|
+
this.classCollection.delete('mg-icon--spin');
|
|
74
|
+
this.classCollection.delete('mg-a11y-animation');
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
/**
|
|
79
78
|
* Check if props are well configured on init
|
|
80
|
-
* @returns {void}
|
|
81
79
|
*/
|
|
82
80
|
componentWillLoad() {
|
|
83
81
|
this.validateIcon(this.icon);
|
|
@@ -88,10 +86,10 @@ export class MgIcon {
|
|
|
88
86
|
}
|
|
89
87
|
/**
|
|
90
88
|
* Render component
|
|
91
|
-
* @returns
|
|
89
|
+
* @returns HTML Element
|
|
92
90
|
*/
|
|
93
91
|
render() {
|
|
94
|
-
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()));
|
|
95
93
|
}
|
|
96
94
|
static get is() { return "mg-icon"; }
|
|
97
95
|
static get encapsulation() { return "shadow"; }
|
|
@@ -213,7 +211,7 @@ export class MgIcon {
|
|
|
213
211
|
}
|
|
214
212
|
static get states() {
|
|
215
213
|
return {
|
|
216
|
-
"
|
|
214
|
+
"classCollection": {}
|
|
217
215
|
};
|
|
218
216
|
}
|
|
219
217
|
static get watchers() {
|
|
@@ -19,7 +19,6 @@ export class MgInputTitle {
|
|
|
19
19
|
*************/
|
|
20
20
|
/**
|
|
21
21
|
* Init tag name
|
|
22
|
-
* @returns {void}
|
|
23
22
|
*/
|
|
24
23
|
componentWillLoad() {
|
|
25
24
|
this.validateIdentifier(this.identifier);
|
|
@@ -27,7 +26,7 @@ export class MgInputTitle {
|
|
|
27
26
|
}
|
|
28
27
|
/**
|
|
29
28
|
* Render
|
|
30
|
-
* @returns
|
|
29
|
+
* @returns HTML element
|
|
31
30
|
*/
|
|
32
31
|
render() {
|
|
33
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,17 +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
|
-
* @param
|
|
50
|
-
* @returns {void}
|
|
49
|
+
* @param textContent - html element textContent property
|
|
51
50
|
*/
|
|
52
51
|
validateTextContent(textContent) {
|
|
53
52
|
if (typeof textContent !== 'string' || textContent.trim() === '')
|
|
@@ -58,7 +57,6 @@ export class MgTag {
|
|
|
58
57
|
*************/
|
|
59
58
|
/**
|
|
60
59
|
* Check if props are well configured on init
|
|
61
|
-
* @returns {void}
|
|
62
60
|
*/
|
|
63
61
|
componentWillLoad() {
|
|
64
62
|
this.validateVariant(this.variant);
|
|
@@ -68,10 +66,10 @@ export class MgTag {
|
|
|
68
66
|
}
|
|
69
67
|
/**
|
|
70
68
|
* Render
|
|
71
|
-
* @returns
|
|
69
|
+
* @returns HTML Element
|
|
72
70
|
*/
|
|
73
71
|
render() {
|
|
74
|
-
return (h("span", { class: this.
|
|
72
|
+
return (h("span", { class: this.classCollection.join() }, h("slot", null)));
|
|
75
73
|
}
|
|
76
74
|
static get is() { return "mg-tag"; }
|
|
77
75
|
static get encapsulation() { return "shadow"; }
|
|
@@ -148,7 +146,7 @@ export class MgTag {
|
|
|
148
146
|
}
|
|
149
147
|
static get states() {
|
|
150
148
|
return {
|
|
151
|
-
"
|
|
149
|
+
"classCollection": {}
|
|
152
150
|
};
|
|
153
151
|
}
|
|
154
152
|
static get elementRef() { return "element"; }
|
|
@@ -6,7 +6,6 @@ export class MgTooltip {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
/**
|
|
8
8
|
* Show tooltip
|
|
9
|
-
* @returns {void}
|
|
10
9
|
*/
|
|
11
10
|
this.show = () => {
|
|
12
11
|
// Make the tooltip visible
|
|
@@ -26,7 +25,6 @@ export class MgTooltip {
|
|
|
26
25
|
};
|
|
27
26
|
/**
|
|
28
27
|
* Hide tooltip
|
|
29
|
-
* @returns {void}
|
|
30
28
|
*/
|
|
31
29
|
this.hide = () => {
|
|
32
30
|
// Hide the tooltip
|
|
@@ -41,8 +39,7 @@ export class MgTooltip {
|
|
|
41
39
|
};
|
|
42
40
|
/**
|
|
43
41
|
* Check if clicked outside of component and hidde tooltip
|
|
44
|
-
* @param
|
|
45
|
-
* @returns {void}
|
|
42
|
+
* @param event - mouse event
|
|
46
43
|
*/
|
|
47
44
|
this.clickOutside = (event) => {
|
|
48
45
|
if (event.target.closest('mg-tooltip') !== this.element)
|
|
@@ -50,8 +47,7 @@ export class MgTooltip {
|
|
|
50
47
|
};
|
|
51
48
|
/**
|
|
52
49
|
* Check if 'Escape' key is pressed of component and hidde tooltip
|
|
53
|
-
* @param
|
|
54
|
-
* @returns {void}
|
|
50
|
+
* @param event - keyboard event
|
|
55
51
|
*/
|
|
56
52
|
this.pressEscape = (event) => {
|
|
57
53
|
if (event.code === 'Escape')
|
|
@@ -59,9 +55,8 @@ export class MgTooltip {
|
|
|
59
55
|
};
|
|
60
56
|
/**
|
|
61
57
|
* Method to set display prop
|
|
62
|
-
* @param
|
|
63
|
-
* @param
|
|
64
|
-
* @returns {void}
|
|
58
|
+
* @param newValue - display prop new value
|
|
59
|
+
* @param condition - additionnal condition to apply display prop newValue
|
|
65
60
|
*/
|
|
66
61
|
this.setDisplay = (newValue, condition = true) => {
|
|
67
62
|
if (!this.disabled && condition)
|
|
@@ -69,10 +64,9 @@ export class MgTooltip {
|
|
|
69
64
|
};
|
|
70
65
|
/**
|
|
71
66
|
* Action for tooltip element and tooltiped element mouse listener
|
|
72
|
-
* @param
|
|
73
|
-
* @param
|
|
74
|
-
* @param
|
|
75
|
-
* @returns {void}
|
|
67
|
+
* @param elementGuard - tooltip element guard
|
|
68
|
+
* @param isMouseenter - mouseenter validation
|
|
69
|
+
* @param conditionalGuard - guard condition
|
|
76
70
|
*/
|
|
77
71
|
this.tooltipMouseListenerAction = (elementGuard, isMouseenter, conditionalGuard) => {
|
|
78
72
|
// we mutate elementGuard
|
|
@@ -91,15 +85,13 @@ export class MgTooltip {
|
|
|
91
85
|
};
|
|
92
86
|
/**
|
|
93
87
|
* Method to reset guard value
|
|
94
|
-
* @returns {void}
|
|
95
88
|
*/
|
|
96
89
|
this.resetGuard = () => {
|
|
97
90
|
this.guard = undefined;
|
|
98
91
|
};
|
|
99
92
|
/**
|
|
100
93
|
* Update slot content when it is a mg-button
|
|
101
|
-
* @param
|
|
102
|
-
* @returns {void}
|
|
94
|
+
* @param mgButton - slotted mg-button
|
|
103
95
|
*/
|
|
104
96
|
this.setMgButtonWrapper = (mgButton) => {
|
|
105
97
|
if (mgButton.disabled) {
|
|
@@ -116,8 +108,8 @@ export class MgTooltip {
|
|
|
116
108
|
};
|
|
117
109
|
/**
|
|
118
110
|
* Init tooltip
|
|
119
|
-
* @param
|
|
120
|
-
* @param
|
|
111
|
+
* @param slotElement - slotted element
|
|
112
|
+
* @param interactiveElement - interactive element
|
|
121
113
|
*/
|
|
122
114
|
this.initTooltip = (slotElement, interactiveElement) => {
|
|
123
115
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
@@ -193,7 +185,6 @@ export class MgTooltip {
|
|
|
193
185
|
*************/
|
|
194
186
|
/**
|
|
195
187
|
* set variables
|
|
196
|
-
* @returns {void}
|
|
197
188
|
*/
|
|
198
189
|
componentWillLoad() {
|
|
199
190
|
// Get windows to attach events
|
|
@@ -203,7 +194,6 @@ export class MgTooltip {
|
|
|
203
194
|
* Get slotted element
|
|
204
195
|
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
205
196
|
* We need to attach the focused element to the tooltip (aria-describedby)
|
|
206
|
-
* @returns {void}
|
|
207
197
|
*/
|
|
208
198
|
componentDidLoad() {
|
|
209
199
|
var _a;
|
|
@@ -236,7 +226,7 @@ export class MgTooltip {
|
|
|
236
226
|
}
|
|
237
227
|
/**
|
|
238
228
|
* Render
|
|
239
|
-
* @returns
|
|
229
|
+
* @returns HTML Element
|
|
240
230
|
*/
|
|
241
231
|
render() {
|
|
242
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 }))));
|
|
@@ -1,10 +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
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @returns
|
|
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
|
|
8
9
|
*/
|
|
9
10
|
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
10
11
|
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
@@ -17,29 +18,36 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
|
|
|
17
18
|
});
|
|
18
19
|
/**
|
|
19
20
|
* Add classes based on props
|
|
20
|
-
* @param
|
|
21
|
+
* @param props - MgInput Interface Props
|
|
21
22
|
*/
|
|
22
23
|
const manageClasses = (props) => {
|
|
23
|
-
props.
|
|
24
|
+
props.classCollection.add('mg-input');
|
|
24
25
|
if (props.labelOnTop)
|
|
25
|
-
props.
|
|
26
|
+
props.classCollection.add('mg-input--label-on-top');
|
|
27
|
+
else
|
|
28
|
+
props.classCollection.delete('mg-input--label-on-top');
|
|
26
29
|
if (props.readonly)
|
|
27
|
-
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
|
+
});
|
|
28
36
|
if (props.mgWidth !== undefined)
|
|
29
|
-
props.
|
|
37
|
+
props.classCollection.add(`mg-input--width-${props.mgWidth}`);
|
|
30
38
|
};
|
|
31
39
|
/**
|
|
32
40
|
* Get tagname
|
|
33
|
-
* @param
|
|
34
|
-
* @returns
|
|
41
|
+
* @param isFieldset - is fieldset
|
|
42
|
+
* @returns tag name
|
|
35
43
|
*/
|
|
36
44
|
const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
|
|
37
45
|
/**
|
|
38
46
|
* Get input template
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @returns
|
|
47
|
+
* @param props - MgInput Interface Props
|
|
48
|
+
* @param children - Represent scoped elements
|
|
49
|
+
* @param utils - Stencil.js utils
|
|
50
|
+
* @returns input template
|
|
43
51
|
*/
|
|
44
52
|
export const MgInput = (props, children, utils) => {
|
|
45
53
|
/**
|
|
@@ -95,14 +103,14 @@ export const MgInput = (props, children, utils) => {
|
|
|
95
103
|
const TagName = getTagName(props.isFieldset);
|
|
96
104
|
/**
|
|
97
105
|
* Get tooltip node
|
|
98
|
-
* @returns
|
|
106
|
+
* @returns mg-tooltip
|
|
99
107
|
*/
|
|
100
108
|
const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip }, h("mg-icon", { icon: "info-circle" })));
|
|
101
109
|
/**
|
|
102
110
|
* Get input title (label) node
|
|
103
111
|
* Display asterisk only if not disabled and not readonly
|
|
104
|
-
* @returns
|
|
112
|
+
* @returns mg-input-title
|
|
105
113
|
*/
|
|
106
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));
|
|
107
|
-
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" }))))));
|
|
108
116
|
};
|
|
@@ -5,8 +5,8 @@ import { ClassList } from '../../../../utils/components.utils';
|
|
|
5
5
|
import { initLocales } from '../../../../locales';
|
|
6
6
|
/**
|
|
7
7
|
* type CheckboxItem validation function
|
|
8
|
-
* @param
|
|
9
|
-
* @returns
|
|
8
|
+
* @param items - Checkbox item
|
|
9
|
+
* @returns match item type
|
|
10
10
|
*/
|
|
11
11
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
12
12
|
items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
|
|
@@ -21,7 +21,7 @@ export class MgInputCheckbox {
|
|
|
21
21
|
this.hasDisplayedError = false;
|
|
22
22
|
/**
|
|
23
23
|
* Handle input event
|
|
24
|
-
* @param
|
|
24
|
+
* @param event - input event
|
|
25
25
|
*/
|
|
26
26
|
this.handleInput = (event) => {
|
|
27
27
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -43,7 +43,7 @@ export class MgInputCheckbox {
|
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
45
|
* get invalid element
|
|
46
|
-
* @returns
|
|
46
|
+
* @returns element
|
|
47
47
|
*/
|
|
48
48
|
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
49
49
|
/**
|
|
@@ -80,7 +80,7 @@ export class MgInputCheckbox {
|
|
|
80
80
|
this.helpText = undefined;
|
|
81
81
|
this.valid = undefined;
|
|
82
82
|
this.invalid = undefined;
|
|
83
|
-
this.
|
|
83
|
+
this.classCollection = new ClassList(['mg-input--checkbox']);
|
|
84
84
|
this.errorMessage = undefined;
|
|
85
85
|
this.checkboxItems = [];
|
|
86
86
|
}
|
|
@@ -110,7 +110,6 @@ export class MgInputCheckbox {
|
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* Public method to display errors
|
|
113
|
-
* @returns {Promise<void>}
|
|
114
113
|
*/
|
|
115
114
|
async displayError() {
|
|
116
115
|
this.checkValidity();
|
|
@@ -122,7 +121,7 @@ export class MgInputCheckbox {
|
|
|
122
121
|
*************/
|
|
123
122
|
/**
|
|
124
123
|
* Check if component props are well configured on init
|
|
125
|
-
* @returns
|
|
124
|
+
* @returns timeout
|
|
126
125
|
*/
|
|
127
126
|
componentWillLoad() {
|
|
128
127
|
// Get locales
|
|
@@ -138,10 +137,10 @@ export class MgInputCheckbox {
|
|
|
138
137
|
}
|
|
139
138
|
/**
|
|
140
139
|
* Render
|
|
141
|
-
* @returns
|
|
140
|
+
* @returns HTML Element
|
|
142
141
|
*/
|
|
143
142
|
render() {
|
|
144
|
-
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
|
|
145
144
|
.filter(item => {
|
|
146
145
|
return !this.readonly || item.value;
|
|
147
146
|
})
|
|
@@ -415,7 +414,7 @@ export class MgInputCheckbox {
|
|
|
415
414
|
}
|
|
416
415
|
static get states() {
|
|
417
416
|
return {
|
|
418
|
-
"
|
|
417
|
+
"classCollection": {},
|
|
419
418
|
"errorMessage": {},
|
|
420
419
|
"checkboxItems": {}
|
|
421
420
|
};
|
|
@@ -476,10 +475,7 @@ export class MgInputCheckbox {
|
|
|
476
475
|
},
|
|
477
476
|
"docs": {
|
|
478
477
|
"text": "Public method to display errors",
|
|
479
|
-
"tags": [
|
|
480
|
-
"name": "returns",
|
|
481
|
-
"text": undefined
|
|
482
|
-
}]
|
|
478
|
+
"tags": []
|
|
483
479
|
}
|
|
484
480
|
}
|
|
485
481
|
};
|
|
@@ -36,7 +36,7 @@ export class MgInputDate {
|
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
* get input error code
|
|
39
|
-
* @returns
|
|
39
|
+
* @returns error code
|
|
40
40
|
*/
|
|
41
41
|
this.getInputError = () => {
|
|
42
42
|
var _a, _b;
|
|
@@ -61,7 +61,6 @@ export class MgInputDate {
|
|
|
61
61
|
};
|
|
62
62
|
/**
|
|
63
63
|
* Check input errors
|
|
64
|
-
* @returns {void}
|
|
65
64
|
*/
|
|
66
65
|
this.setErrorMessage = () => {
|
|
67
66
|
var _a;
|
|
@@ -99,7 +98,7 @@ export class MgInputDate {
|
|
|
99
98
|
this.invalid = undefined;
|
|
100
99
|
this.min = undefined;
|
|
101
100
|
this.max = undefined;
|
|
102
|
-
this.
|
|
101
|
+
this.classCollection = new ClassList(['mg-input--date']);
|
|
103
102
|
this.errorMessage = undefined;
|
|
104
103
|
}
|
|
105
104
|
validateValue(newValue) {
|
|
@@ -130,7 +129,6 @@ export class MgInputDate {
|
|
|
130
129
|
}
|
|
131
130
|
/**
|
|
132
131
|
* Public method to display errors
|
|
133
|
-
* @returns {Promise<void>}
|
|
134
132
|
*/
|
|
135
133
|
async displayError() {
|
|
136
134
|
this.checkValidity();
|
|
@@ -142,7 +140,7 @@ export class MgInputDate {
|
|
|
142
140
|
*************/
|
|
143
141
|
/**
|
|
144
142
|
* Check if component props are well configured on init
|
|
145
|
-
* @returns
|
|
143
|
+
* @returns timeout
|
|
146
144
|
*/
|
|
147
145
|
componentWillLoad() {
|
|
148
146
|
// Get locales
|
|
@@ -162,10 +160,10 @@ export class MgInputDate {
|
|
|
162
160
|
}
|
|
163
161
|
/**
|
|
164
162
|
* Render
|
|
165
|
-
* @returns
|
|
163
|
+
* @returns HTML Element
|
|
166
164
|
*/
|
|
167
165
|
render() {
|
|
168
|
-
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 => {
|
|
169
167
|
if (el !== null)
|
|
170
168
|
this.input = el;
|
|
171
169
|
} })));
|
|
@@ -448,7 +446,7 @@ export class MgInputDate {
|
|
|
448
446
|
}
|
|
449
447
|
static get states() {
|
|
450
448
|
return {
|
|
451
|
-
"
|
|
449
|
+
"classCollection": {},
|
|
452
450
|
"errorMessage": {}
|
|
453
451
|
};
|
|
454
452
|
}
|
|
@@ -500,10 +498,7 @@ export class MgInputDate {
|
|
|
500
498
|
},
|
|
501
499
|
"docs": {
|
|
502
500
|
"text": "Public method to display errors",
|
|
503
|
-
"tags": [
|
|
504
|
-
"name": "returns",
|
|
505
|
-
"text": undefined
|
|
506
|
-
}]
|
|
501
|
+
"tags": []
|
|
507
502
|
}
|
|
508
503
|
}
|
|
509
504
|
};
|