@mgdis/mg-components 5.10.0 → 5.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-9e1091ab.js → index-03d2557d.js} +3 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_31.cjs.entry.js +444 -455
- package/dist/cjs/mg-components.cjs.js +2 -2
- package/dist/cjs/mg-item-more.cjs.entry.js +20 -29
- package/dist/cjs/{mg-menu.conf-1942ac70.js → mg-menu.conf-05ec32a3.js} +30 -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.css +2 -0
- 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 +20 -25
- 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.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +18 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +126 -19
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +11 -14
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +1 -0
- 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.css +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +6 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +16 -16
- 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/en/messages.json +7 -0
- package/dist/collection/locales/fr/messages.json +7 -0
- package/dist/collection/locales/index.js +2 -2
- package/dist/collection/styles/reset-mg-card-slotted-variables.scss +1 -0
- 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 +30 -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 +9 -11
- 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 +126 -21
- package/dist/components/mg-input-date.js +7 -9
- package/dist/components/mg-input-numeric.js +14 -19
- package/dist/components/mg-input-password.js +6 -7
- package/dist/components/mg-input-radio.js +10 -15
- package/dist/components/mg-input-select2.js +21 -29
- package/dist/components/mg-input-text2.js +15 -24
- package/dist/components/mg-input-textarea.js +13 -14
- package/dist/components/mg-input-title2.js +1 -2
- package/dist/components/mg-input-toggle.js +17 -20
- 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 +12 -15
- package/dist/components/mg-modal.js +8 -12
- package/dist/components/mg-pagination.js +11 -13
- package/dist/components/mg-panel.js +7 -16
- package/dist/components/mg-popover2.js +17 -17
- 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 +20 -25
- package/dist/esm/{index-3249671d.js → index-407d5211.js} +3 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_31.entry.js +444 -455
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-item-more.entry.js +20 -29
- package/dist/esm/{mg-menu.conf-2cc1bb67.js → mg-menu.conf-c8aa56ce.js} +30 -16
- package/dist/mg-components/locales/en/messages.json +7 -0
- package/dist/mg-components/locales/fr/messages.json +7 -0
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-3bf533f7.js +2 -0
- package/dist/mg-components/p-51c2def3.entry.js +1 -0
- package/dist/mg-components/p-b14be68b.js +1 -0
- package/dist/mg-components/{p-a56a3157.entry.js → p-d3ed97d3.entry.js} +1 -1
- package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +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 +15 -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.conf.d.ts +8 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +40 -7
- 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 +7 -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 +31 -35
- package/dist/types/locales/index.d.ts +16 -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 +4 -4
- package/dist/mg-components/p-73156ac9.js +0 -1
- package/dist/mg-components/p-8fbc0d87.js +0 -2
- package/dist/mg-components/p-eb32bb18.entry.js +0 -1
|
@@ -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,15 +6,12 @@ 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
|
|
13
12
|
this.tooltip.dataset.show = '';
|
|
14
13
|
// Enable the event listeners
|
|
15
14
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
16
|
-
// Update its position
|
|
17
|
-
this.popper.update();
|
|
18
15
|
// hide when click outside
|
|
19
16
|
// setTimeout is used to prevent event to trigger after creation
|
|
20
17
|
setTimeout(() => {
|
|
@@ -26,7 +23,6 @@ export class MgTooltip {
|
|
|
26
23
|
};
|
|
27
24
|
/**
|
|
28
25
|
* Hide tooltip
|
|
29
|
-
* @returns {void}
|
|
30
26
|
*/
|
|
31
27
|
this.hide = () => {
|
|
32
28
|
// Hide the tooltip
|
|
@@ -41,8 +37,7 @@ export class MgTooltip {
|
|
|
41
37
|
};
|
|
42
38
|
/**
|
|
43
39
|
* Check if clicked outside of component and hidde tooltip
|
|
44
|
-
* @param
|
|
45
|
-
* @returns {void}
|
|
40
|
+
* @param event - mouse event
|
|
46
41
|
*/
|
|
47
42
|
this.clickOutside = (event) => {
|
|
48
43
|
if (event.target.closest('mg-tooltip') !== this.element)
|
|
@@ -50,18 +45,18 @@ export class MgTooltip {
|
|
|
50
45
|
};
|
|
51
46
|
/**
|
|
52
47
|
* Check if 'Escape' key is pressed of component and hidde tooltip
|
|
53
|
-
* @param
|
|
54
|
-
* @returns {void}
|
|
48
|
+
* @param event - keyboard event
|
|
55
49
|
*/
|
|
56
50
|
this.pressEscape = (event) => {
|
|
57
|
-
if (event.code === 'Escape')
|
|
51
|
+
if (event.code === 'Escape') {
|
|
58
52
|
this.setDisplay(false);
|
|
53
|
+
this.resetGuard();
|
|
54
|
+
}
|
|
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
|
|
@@ -178,7 +170,6 @@ export class MgTooltip {
|
|
|
178
170
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
179
171
|
throw new Error('<mg-tooltip> prop "message" is required.');
|
|
180
172
|
}
|
|
181
|
-
this.popper.update();
|
|
182
173
|
}
|
|
183
174
|
handleDisplay(newValue) {
|
|
184
175
|
if (newValue) {
|
|
@@ -193,7 +184,6 @@ export class MgTooltip {
|
|
|
193
184
|
*************/
|
|
194
185
|
/**
|
|
195
186
|
* set variables
|
|
196
|
-
* @returns {void}
|
|
197
187
|
*/
|
|
198
188
|
componentWillLoad() {
|
|
199
189
|
// Get windows to attach events
|
|
@@ -203,7 +193,6 @@ export class MgTooltip {
|
|
|
203
193
|
* Get slotted element
|
|
204
194
|
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
205
195
|
* We need to attach the focused element to the tooltip (aria-describedby)
|
|
206
|
-
* @returns {void}
|
|
207
196
|
*/
|
|
208
197
|
componentDidLoad() {
|
|
209
198
|
var _a;
|
|
@@ -234,9 +223,15 @@ export class MgTooltip {
|
|
|
234
223
|
this.handleDisplay(this.display);
|
|
235
224
|
this.validateMessage(this.message);
|
|
236
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* update popper position after props change on component did update hook to benefit from render ended
|
|
228
|
+
*/
|
|
229
|
+
componentDidUpdate() {
|
|
230
|
+
this.popper.update();
|
|
231
|
+
}
|
|
237
232
|
/**
|
|
238
233
|
* Render
|
|
239
|
-
* @returns
|
|
234
|
+
* @returns HTML Element
|
|
240
235
|
*/
|
|
241
236
|
render() {
|
|
242
237
|
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
|
};
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
85
85
|
margin-top: 0.5rem;
|
|
86
86
|
}
|
|
87
|
-
.mg-input__input .mg-input__box:disabled, .mg-input__input-group--disabled label, .mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle {
|
|
87
|
+
.mg-input__input .mg-input__box:disabled, .mg-input__input-group--disabled label, .mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle, .mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong {
|
|
88
88
|
opacity: var(--mg-disabled-opacity);
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -176,4 +176,21 @@ fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
|
|
|
176
176
|
animation: none !important;
|
|
177
177
|
transition: none !important;
|
|
178
178
|
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* checkbox multi
|
|
182
|
+
*/
|
|
183
|
+
.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi {
|
|
184
|
+
display: flex;
|
|
185
|
+
flex-wrap: wrap;
|
|
186
|
+
gap: calc(var(--mg-inputs-spacer) * 1.2);
|
|
187
|
+
}
|
|
188
|
+
.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-inputs {
|
|
189
|
+
margin: 0;
|
|
190
|
+
}
|
|
191
|
+
.mg-input.mg-input--checkbox-multi:not(.mg-input--label-on-top) mg-tooltip {
|
|
192
|
+
margin-left: var(--mg-inputs-spacer);
|
|
193
|
+
}
|
|
194
|
+
.mg-input.mg-input--checkbox-multi mg-popover {
|
|
195
|
+
--mg-popover-min-width: 7rem;
|
|
179
196
|
}
|