@mgdis/mg-components 5.3.0 → 5.5.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-94497267.js → index-c3450336.js} +0 -0
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{mg-badge_29.cjs.entry.js → mg-badge_30.cjs.entry.js} +517 -715
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/atoms/mg-badge/doc/mg-badge.stories.js +0 -7
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +6 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +5 -8
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +0 -7
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.css +19 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +13 -30
- package/dist/collection/components/atoms/mg-card/mg-card.css +6 -1
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +2 -3
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +0 -6
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +20 -4
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +27 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +7 -12
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +4 -8
- package/dist/collection/components/atoms/mg-tag/doc/mg-tag.stories.js +1 -9
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +58 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +60 -15
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +97 -68
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +7 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +17 -33
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +7 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +17 -25
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +6 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +24 -47
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +7 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +17 -29
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +7 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +18 -33
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +6 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +23 -33
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +6 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +23 -41
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +6 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +23 -45
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +6 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +16 -33
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +8 -23
- package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +8 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +55 -24
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +18 -33
- package/dist/collection/components/molecules/mg-details/mg-details.css +6 -0
- package/dist/collection/components/molecules/mg-details/mg-details.js +4 -8
- package/dist/collection/components/molecules/mg-form/mg-form.js +9 -23
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.css +2 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +0 -6
- package/dist/collection/components/molecules/mg-message/mg-message.css +13 -19
- package/dist/collection/components/molecules/mg-message/mg-message.js +8 -27
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +12 -7
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +8 -26
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +6 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +4 -13
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +10 -5
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +11 -22
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +13 -9
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +7 -23
- package/dist/collection/components/molecules/mg-skip-links/doc/mg-skip-links.stories.js +24 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.conf.js +1 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.css +28 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +77 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +10 -23
- package/dist/collection/locales/en/messages.json +3 -0
- package/dist/collection/locales/fr/messages.json +3 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index2.js +8 -0
- package/dist/components/mg-badge2.js +6 -9
- package/dist/components/mg-button2.js +14 -31
- package/dist/components/mg-card.js +1 -37
- package/dist/components/mg-card2.js +39 -0
- package/dist/components/mg-character-left2.js +2 -3
- package/dist/components/mg-details.js +5 -9
- package/dist/components/mg-divider.js +0 -6
- package/dist/components/mg-form.js +9 -23
- package/dist/components/mg-icon2.js +28 -17
- package/dist/components/mg-illustrated-message.js +1 -7
- package/dist/components/mg-input-checkbox.js +18 -34
- package/dist/components/mg-input-date.js +18 -26
- package/dist/components/mg-input-numeric.js +25 -48
- package/dist/components/mg-input-password.js +18 -30
- package/dist/components/mg-input-radio.js +19 -34
- package/dist/components/mg-input-select2.js +25 -35
- package/dist/components/mg-input-text2.js +24 -42
- package/dist/components/mg-input-textarea.js +24 -46
- package/dist/components/mg-input-title2.js +4 -8
- package/dist/components/mg-input-toggle.js +17 -34
- package/dist/components/mg-menu-item.js +18 -33
- package/dist/components/mg-menu.js +9 -24
- package/dist/components/mg-message.js +17 -30
- package/dist/components/mg-modal.js +18 -30
- package/dist/components/mg-pagination.js +5 -14
- package/dist/components/mg-panel.js +20 -25
- package/dist/components/mg-popover.js +16 -26
- package/dist/components/mg-skip-links.d.ts +11 -0
- package/dist/components/mg-skip-links.js +66 -0
- package/dist/components/mg-tabs.js +10 -23
- package/dist/components/mg-tag.js +34 -12
- package/dist/components/mg-tooltip2.js +97 -68
- package/dist/esm/{index-aad0184c.js → index-78edde1d.js} +0 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{mg-badge_29.entry.js → mg-badge_30.entry.js} +517 -716
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/mg-components/locales/en/messages.json +3 -0
- package/dist/mg-components/locales/fr/messages.json +3 -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-3899d5d2.js → p-125c54ca.js} +0 -0
- package/dist/mg-components/p-4961c96c.entry.js +1 -0
- package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +0 -11
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +1 -1
- package/dist/types/components/atoms/mg-button/doc/mg-button.stories.d.ts +0 -11
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +6 -6
- package/dist/types/components/atoms/mg-tag/doc/mg-tag.stories.d.ts +0 -13
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +5 -1
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +27 -6
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +15 -0
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +0 -5
- package/dist/types/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.d.ts +1 -0
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +0 -4
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +1 -1
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +1 -1
- package/dist/types/components/molecules/mg-skip-links/doc/mg-skip-links.stories.d.ts +11 -0
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.conf.d.ts +7 -0
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +34 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +2 -2
- package/dist/types/components.d.ts +37 -6
- package/dist/types/locales/index.d.ts +6 -0
- package/dist/types/stencil-public-runtime.d.ts +5 -0
- package/dist/types/utils/unit.test.utils.d.ts +42 -0
- package/package.json +36 -31
- package/readme.md +3 -1
- package/dist/mg-components/p-204af46f.entry.js +0 -1
|
@@ -8,16 +8,10 @@ export class MgTag {
|
|
|
8
8
|
************/
|
|
9
9
|
// Classes
|
|
10
10
|
this.classOutline = `mg-tag--outline`;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* Define button variant
|
|
16
|
-
*/
|
|
17
|
-
this.variant = variants[0]; // primary
|
|
18
|
-
/**
|
|
19
|
-
* Component classes
|
|
20
|
-
*/
|
|
11
|
+
this.classSoft = `mg-tag--soft`;
|
|
12
|
+
this.variant = variants[0];
|
|
13
|
+
this.outline = undefined;
|
|
14
|
+
this.soft = undefined;
|
|
21
15
|
this.classList = new ClassList(['mg-tag']);
|
|
22
16
|
}
|
|
23
17
|
validateVariant(newValue, oldValue) {
|
|
@@ -37,6 +31,29 @@ export class MgTag {
|
|
|
37
31
|
else
|
|
38
32
|
this.classList.delete(this.classOutline);
|
|
39
33
|
}
|
|
34
|
+
validateSoft(newValue) {
|
|
35
|
+
// usage validation
|
|
36
|
+
if (newValue && this.outline)
|
|
37
|
+
throw new Error('<mg-tag> prop "soft" can NOT be used with prop "outline".');
|
|
38
|
+
// apply class
|
|
39
|
+
if (newValue)
|
|
40
|
+
this.classList.add(this.classSoft);
|
|
41
|
+
else
|
|
42
|
+
this.classList.delete(this.classSoft);
|
|
43
|
+
}
|
|
44
|
+
/*************
|
|
45
|
+
* Methods *
|
|
46
|
+
*************/
|
|
47
|
+
/**
|
|
48
|
+
* Validate the given textContent
|
|
49
|
+
*
|
|
50
|
+
* @param {string} textContent html element textContent property
|
|
51
|
+
* @returns {void}
|
|
52
|
+
*/
|
|
53
|
+
validateTextContent(textContent) {
|
|
54
|
+
if (!textContent || textContent.trim() === '')
|
|
55
|
+
throw new Error('<mg-tag> slot must contain a text content.');
|
|
56
|
+
}
|
|
40
57
|
/*************
|
|
41
58
|
* Lifecycle *
|
|
42
59
|
*************/
|
|
@@ -48,6 +65,8 @@ export class MgTag {
|
|
|
48
65
|
componentWillLoad() {
|
|
49
66
|
this.validateVariant(this.variant);
|
|
50
67
|
this.validateOutline(this.outline);
|
|
68
|
+
this.validateSoft(this.soft);
|
|
69
|
+
this.validateTextContent(this.element.textContent);
|
|
51
70
|
}
|
|
52
71
|
/**
|
|
53
72
|
* Render
|
|
@@ -75,15 +94,20 @@ export class MgTag {
|
|
|
75
94
|
"type": "string",
|
|
76
95
|
"mutable": false,
|
|
77
96
|
"complexType": {
|
|
78
|
-
"original": "
|
|
79
|
-
"resolved": "
|
|
80
|
-
"references": {
|
|
97
|
+
"original": "TagVariantType",
|
|
98
|
+
"resolved": "\"danger\" | \"info\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"",
|
|
99
|
+
"references": {
|
|
100
|
+
"TagVariantType": {
|
|
101
|
+
"location": "import",
|
|
102
|
+
"path": "./mg-tag.conf"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
81
105
|
},
|
|
82
106
|
"required": false,
|
|
83
107
|
"optional": false,
|
|
84
108
|
"docs": {
|
|
85
109
|
"tags": [],
|
|
86
|
-
"text": "Define
|
|
110
|
+
"text": "Define tag variant"
|
|
87
111
|
},
|
|
88
112
|
"attribute": "variant",
|
|
89
113
|
"reflect": false,
|
|
@@ -101,10 +125,27 @@ export class MgTag {
|
|
|
101
125
|
"optional": false,
|
|
102
126
|
"docs": {
|
|
103
127
|
"tags": [],
|
|
104
|
-
"text": "Define if
|
|
128
|
+
"text": "Define if tag is using outline style"
|
|
105
129
|
},
|
|
106
130
|
"attribute": "outline",
|
|
107
131
|
"reflect": false
|
|
132
|
+
},
|
|
133
|
+
"soft": {
|
|
134
|
+
"type": "boolean",
|
|
135
|
+
"mutable": false,
|
|
136
|
+
"complexType": {
|
|
137
|
+
"original": "boolean",
|
|
138
|
+
"resolved": "boolean",
|
|
139
|
+
"references": {}
|
|
140
|
+
},
|
|
141
|
+
"required": false,
|
|
142
|
+
"optional": false,
|
|
143
|
+
"docs": {
|
|
144
|
+
"tags": [],
|
|
145
|
+
"text": "Define if tag is using soft style"
|
|
146
|
+
},
|
|
147
|
+
"attribute": "soft",
|
|
148
|
+
"reflect": false
|
|
108
149
|
}
|
|
109
150
|
};
|
|
110
151
|
}
|
|
@@ -113,6 +154,7 @@ export class MgTag {
|
|
|
113
154
|
"classList": {}
|
|
114
155
|
};
|
|
115
156
|
}
|
|
157
|
+
static get elementRef() { return "element"; }
|
|
116
158
|
static get watchers() {
|
|
117
159
|
return [{
|
|
118
160
|
"propName": "variant",
|
|
@@ -120,6 +162,9 @@ export class MgTag {
|
|
|
120
162
|
}, {
|
|
121
163
|
"propName": "outline",
|
|
122
164
|
"methodName": "validateOutline"
|
|
165
|
+
}, {
|
|
166
|
+
"propName": "soft",
|
|
167
|
+
"methodName": "validateSoft"
|
|
123
168
|
}];
|
|
124
169
|
}
|
|
125
170
|
}
|
|
@@ -4,23 +4,6 @@ import { createPopper } from '@popperjs/core';
|
|
|
4
4
|
import { Guard } from './mg-tooltip.conf';
|
|
5
5
|
export class MgTooltip {
|
|
6
6
|
constructor() {
|
|
7
|
-
/**
|
|
8
|
-
* Sets an `id` attribute.
|
|
9
|
-
* Needed by the input for accessibility `aria-decribedby`.
|
|
10
|
-
*/
|
|
11
|
-
this.identifier = createID('mg-tooltip');
|
|
12
|
-
/**
|
|
13
|
-
* Tooltip placement
|
|
14
|
-
*/
|
|
15
|
-
this.placement = 'bottom';
|
|
16
|
-
/**
|
|
17
|
-
* Display tooltip
|
|
18
|
-
*/
|
|
19
|
-
this.display = false;
|
|
20
|
-
/**
|
|
21
|
-
* Disable tooltip
|
|
22
|
-
*/
|
|
23
|
-
this.disabled = false;
|
|
24
7
|
/**
|
|
25
8
|
* Show tooltip
|
|
26
9
|
*
|
|
@@ -87,6 +70,90 @@ export class MgTooltip {
|
|
|
87
70
|
this.resetGuard = () => {
|
|
88
71
|
this.guard = undefined;
|
|
89
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Update slot content when it is a mg-button
|
|
75
|
+
*
|
|
76
|
+
* @param {HTMLMgButtonElement} mgButton slotted mg-button
|
|
77
|
+
* @returns {void}
|
|
78
|
+
*/
|
|
79
|
+
this.setMgButtonWrapper = (mgButton) => {
|
|
80
|
+
if (mgButton.disabled) {
|
|
81
|
+
const div = document.createElement('div');
|
|
82
|
+
div.classList.add('mg-tooltip__mg-button-wrapper');
|
|
83
|
+
mgButton.parentNode.insertBefore(div, mgButton);
|
|
84
|
+
div.appendChild(mgButton);
|
|
85
|
+
this.tooltipedElement = div;
|
|
86
|
+
}
|
|
87
|
+
else if (mgButton.parentElement.classList.contains('mg-tooltip__mg-button-wrapper')) {
|
|
88
|
+
this.element.firstElementChild.replaceWith(mgButton);
|
|
89
|
+
this.tooltipedElement = mgButton;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Init tooltip
|
|
94
|
+
*
|
|
95
|
+
* @param {HTMLElement} slotElement slotted element
|
|
96
|
+
* @param {HTMLElement} interactiveElement interactive element
|
|
97
|
+
*/
|
|
98
|
+
this.initTooltip = (slotElement, interactiveElement) => {
|
|
99
|
+
// Add tabindex to slotted element if we can't find any interactive element
|
|
100
|
+
if (interactiveElement === null || interactiveElement === undefined)
|
|
101
|
+
slotElement.tabIndex = 0;
|
|
102
|
+
// Set aria-describedby
|
|
103
|
+
const ariaDescribedby = slotElement.getAttribute('aria-describedby');
|
|
104
|
+
if (ariaDescribedby === null) {
|
|
105
|
+
this.tooltipedElement.setAttribute('aria-describedby', this.identifier);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// We ensure to have uniq ids
|
|
109
|
+
slotElement.setAttribute('aria-describedby', `${[...new Set([...ariaDescribedby.split(' '), this.identifier])].join(' ')}`);
|
|
110
|
+
}
|
|
111
|
+
// Create popperjs tooltip
|
|
112
|
+
this.popper = createPopper(this.tooltipedElement, this.tooltip, {
|
|
113
|
+
placement: this.placement,
|
|
114
|
+
strategy: 'fixed',
|
|
115
|
+
modifiers: [
|
|
116
|
+
{
|
|
117
|
+
name: 'offset',
|
|
118
|
+
options: {
|
|
119
|
+
offset: [0, 8],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
// Manage tooltipedElement focus/blur events
|
|
125
|
+
this.tooltipedElement.addEventListener('focus', () => {
|
|
126
|
+
this.guard = Guard.FOCUS;
|
|
127
|
+
this.setDisplay(true);
|
|
128
|
+
});
|
|
129
|
+
['blur', 'keydown'].forEach(event => {
|
|
130
|
+
this.tooltipedElement.addEventListener(event, (e) => {
|
|
131
|
+
// we continue to process ONLY for KeyboardEvents 'Escape'
|
|
132
|
+
if (e.type === 'keydown' && e.code !== 'Escape') {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.resetGuard();
|
|
136
|
+
this.setDisplay(false);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
// manage tooltipElement & tooltipedElement mouseenter/mouseleave events
|
|
140
|
+
['mouseenter', 'mouseleave'].forEach(event => {
|
|
141
|
+
const isMouseenter = event === 'mouseenter';
|
|
142
|
+
[
|
|
143
|
+
{ element: this.tooltip, action: () => this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, isMouseenter, Guard.HOVER_TOOLTIPED_ELEMENT) },
|
|
144
|
+
{ element: this.tooltipedElement, action: () => this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, isMouseenter, Guard.HOVER_TOOLTIP_ELEMENT) },
|
|
145
|
+
].forEach(({ element, action }) => {
|
|
146
|
+
element.addEventListener(event, () => {
|
|
147
|
+
action();
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
this.identifier = createID('mg-tooltip');
|
|
153
|
+
this.message = undefined;
|
|
154
|
+
this.placement = 'bottom';
|
|
155
|
+
this.display = false;
|
|
156
|
+
this.disabled = false;
|
|
90
157
|
}
|
|
91
158
|
validateMessage(newValue) {
|
|
92
159
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -121,58 +188,20 @@ export class MgTooltip {
|
|
|
121
188
|
const interactiveElements = ['a', 'button', 'input', 'textarea', 'select']; //! Might needs updates
|
|
122
189
|
const interactiveElement = this.element.shadowRoot.querySelector(interactiveElements.join(',')) || ((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
|
|
123
190
|
// define selected element to become tooltip selector
|
|
124
|
-
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
slotElement.setAttribute('aria-describedby', `${ariaDescribedby} ${this.identifier}`);
|
|
135
|
-
}
|
|
136
|
-
// Create popperjs tooltip
|
|
137
|
-
this.popper = createPopper(tooltipedElement, this.tooltip, {
|
|
138
|
-
placement: this.placement,
|
|
139
|
-
strategy: 'fixed',
|
|
140
|
-
modifiers: [
|
|
141
|
-
{
|
|
142
|
-
name: 'offset',
|
|
143
|
-
options: {
|
|
144
|
-
offset: [0, 8],
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
});
|
|
149
|
-
// Manage tooltipedElement focus/blur events
|
|
150
|
-
tooltipedElement.addEventListener('focus', () => {
|
|
151
|
-
this.guard = Guard.FOCUS;
|
|
152
|
-
this.setDisplay(true);
|
|
153
|
-
});
|
|
154
|
-
['blur', 'keydown'].forEach(event => {
|
|
155
|
-
tooltipedElement.addEventListener(event, (e) => {
|
|
156
|
-
// we continue to process ONLY for KeyboardEvents 'Escape'
|
|
157
|
-
if (e.type === 'keydown' && e.code !== 'Escape') {
|
|
158
|
-
return;
|
|
191
|
+
this.tooltipedElement = interactiveElement || slotElement;
|
|
192
|
+
// Check if slotted element is a disabled mg-button
|
|
193
|
+
// In this case we wrap the mg-button into a div to enable the tooltip
|
|
194
|
+
if (slotElement.tagName === 'MG-BUTTON') {
|
|
195
|
+
new MutationObserver(mutationList => {
|
|
196
|
+
if (mutationList.some(mutation => mutation.attributeName === 'aria-disabled')) {
|
|
197
|
+
this.setMgButtonWrapper(slotElement);
|
|
198
|
+
this.initTooltip(slotElement, interactiveElement);
|
|
159
199
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
['mouseenter', 'mouseleave'].forEach(event => {
|
|
166
|
-
const isMouseenter = event === 'mouseenter';
|
|
167
|
-
[
|
|
168
|
-
{ element: this.tooltip, action: () => this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, isMouseenter, Guard.HOVER_TOOLTIPED_ELEMENT) },
|
|
169
|
-
{ element: tooltipedElement, action: () => this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, isMouseenter, Guard.HOVER_TOOLTIP_ELEMENT) },
|
|
170
|
-
].forEach(({ element, action }) => {
|
|
171
|
-
element.addEventListener(event, () => {
|
|
172
|
-
action();
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
});
|
|
200
|
+
}).observe(slotElement, { attributes: true });
|
|
201
|
+
this.setMgButtonWrapper(slotElement);
|
|
202
|
+
}
|
|
203
|
+
// Init Tooltip
|
|
204
|
+
this.initTooltip(slotElement, interactiveElement);
|
|
176
205
|
this.handleDisplay(this.display);
|
|
177
206
|
this.validateMessage(this.message);
|
|
178
207
|
}
|
|
@@ -168,4 +168,11 @@ fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
|
|
|
168
168
|
|
|
169
169
|
*:focus:not(:focus-visible) {
|
|
170
170
|
outline: none;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@media (prefers-reduced-motion) {
|
|
174
|
+
.mg-a11y-animation {
|
|
175
|
+
animation: none !important;
|
|
176
|
+
transition: none !important;
|
|
177
|
+
}
|
|
171
178
|
}
|
|
@@ -18,39 +18,6 @@ export class MgInputCheckbox {
|
|
|
18
18
|
this.inputs = [];
|
|
19
19
|
// hasDisplayedError (triggered by blur event)
|
|
20
20
|
this.hasDisplayedError = false;
|
|
21
|
-
/**
|
|
22
|
-
* Input name
|
|
23
|
-
* If not set the value equals the identifier
|
|
24
|
-
*/
|
|
25
|
-
this.name = this.identifier;
|
|
26
|
-
/**
|
|
27
|
-
* Define if label is visible
|
|
28
|
-
*/
|
|
29
|
-
this.labelHide = false;
|
|
30
|
-
/**
|
|
31
|
-
* Define if inputs are display verticaly
|
|
32
|
-
*/
|
|
33
|
-
this.inputVerticalList = false;
|
|
34
|
-
/**
|
|
35
|
-
* Define if input is required
|
|
36
|
-
*/
|
|
37
|
-
this.required = false;
|
|
38
|
-
/**
|
|
39
|
-
* Define if input is readonly
|
|
40
|
-
*/
|
|
41
|
-
this.readonly = false;
|
|
42
|
-
/**
|
|
43
|
-
* Define if input is disabled
|
|
44
|
-
*/
|
|
45
|
-
this.disabled = false;
|
|
46
|
-
/**
|
|
47
|
-
* Component classes
|
|
48
|
-
*/
|
|
49
|
-
this.classList = new ClassList(['mg-input--checkbox']);
|
|
50
|
-
/**
|
|
51
|
-
* Formated value for display
|
|
52
|
-
*/
|
|
53
|
-
this.checkboxItems = [];
|
|
54
21
|
/**
|
|
55
22
|
* Handle input event
|
|
56
23
|
*
|
|
@@ -100,6 +67,23 @@ export class MgInputCheckbox {
|
|
|
100
67
|
this.errorMessage = this.messages.errors.required;
|
|
101
68
|
}
|
|
102
69
|
};
|
|
70
|
+
this.value = undefined;
|
|
71
|
+
this.identifier = undefined;
|
|
72
|
+
this.name = this.identifier;
|
|
73
|
+
this.label = undefined;
|
|
74
|
+
this.labelOnTop = undefined;
|
|
75
|
+
this.labelHide = false;
|
|
76
|
+
this.inputVerticalList = false;
|
|
77
|
+
this.required = false;
|
|
78
|
+
this.readonly = false;
|
|
79
|
+
this.disabled = false;
|
|
80
|
+
this.tooltip = undefined;
|
|
81
|
+
this.helpText = undefined;
|
|
82
|
+
this.valid = undefined;
|
|
83
|
+
this.invalid = undefined;
|
|
84
|
+
this.classList = new ClassList(['mg-input--checkbox']);
|
|
85
|
+
this.errorMessage = undefined;
|
|
86
|
+
this.checkboxItems = [];
|
|
103
87
|
}
|
|
104
88
|
validateValue(newValue) {
|
|
105
89
|
if (newValue && newValue.every(item => isCheckboxItem(item))) {
|
|
@@ -8,31 +8,6 @@ export class MgInputDate {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
// hasDisplayedError (triggered by blur event)
|
|
10
10
|
this.hasDisplayedError = false;
|
|
11
|
-
/**
|
|
12
|
-
* Input name
|
|
13
|
-
* If not set the value equals the identifier
|
|
14
|
-
*/
|
|
15
|
-
this.name = this.identifier;
|
|
16
|
-
/**
|
|
17
|
-
* Define if label is visible
|
|
18
|
-
*/
|
|
19
|
-
this.labelHide = false;
|
|
20
|
-
/**
|
|
21
|
-
* Define if input is required
|
|
22
|
-
*/
|
|
23
|
-
this.required = false;
|
|
24
|
-
/**
|
|
25
|
-
* Define if input is readonly
|
|
26
|
-
*/
|
|
27
|
-
this.readonly = false;
|
|
28
|
-
/**
|
|
29
|
-
* Define if input is disabled
|
|
30
|
-
*/
|
|
31
|
-
this.disabled = false;
|
|
32
|
-
/**
|
|
33
|
-
* Component classes
|
|
34
|
-
*/
|
|
35
|
-
this.classList = new ClassList(['mg-input--date']);
|
|
36
11
|
/**
|
|
37
12
|
* Handle input event
|
|
38
13
|
*/
|
|
@@ -111,6 +86,23 @@ export class MgInputDate {
|
|
|
111
86
|
}
|
|
112
87
|
}
|
|
113
88
|
};
|
|
89
|
+
this.value = undefined;
|
|
90
|
+
this.identifier = undefined;
|
|
91
|
+
this.name = this.identifier;
|
|
92
|
+
this.label = undefined;
|
|
93
|
+
this.labelOnTop = undefined;
|
|
94
|
+
this.labelHide = false;
|
|
95
|
+
this.required = false;
|
|
96
|
+
this.readonly = false;
|
|
97
|
+
this.disabled = false;
|
|
98
|
+
this.tooltip = undefined;
|
|
99
|
+
this.helpText = undefined;
|
|
100
|
+
this.valid = undefined;
|
|
101
|
+
this.invalid = undefined;
|
|
102
|
+
this.min = undefined;
|
|
103
|
+
this.max = undefined;
|
|
104
|
+
this.classList = new ClassList(['mg-input--date']);
|
|
105
|
+
this.errorMessage = undefined;
|
|
114
106
|
}
|
|
115
107
|
validateValue(newValue) {
|
|
116
108
|
if (newValue !== undefined && newValue !== null && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
|
|
@@ -242,6 +242,12 @@
|
|
|
242
242
|
outline: none;
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
@media (prefers-reduced-motion) {
|
|
246
|
+
.mg-a11y-animation {
|
|
247
|
+
animation: none !important;
|
|
248
|
+
transition: none !important;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
245
251
|
.mg-input .mg-input__box {
|
|
246
252
|
text-align: var(--mg-inputs-text-align, right);
|
|
247
253
|
}
|
|
@@ -8,53 +8,6 @@ export class MgInputNumeric {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
// hasDisplayedError (triggered by blur event)
|
|
10
10
|
this.hasDisplayedError = false;
|
|
11
|
-
/**
|
|
12
|
-
* Input name
|
|
13
|
-
* If not set the value equals the identifier
|
|
14
|
-
*/
|
|
15
|
-
this.name = this.identifier;
|
|
16
|
-
/**
|
|
17
|
-
* Define if label is visible
|
|
18
|
-
*/
|
|
19
|
-
this.labelHide = false;
|
|
20
|
-
/**
|
|
21
|
-
* Define if input is required
|
|
22
|
-
*/
|
|
23
|
-
this.required = false;
|
|
24
|
-
/**
|
|
25
|
-
* Define if input is readonly
|
|
26
|
-
*/
|
|
27
|
-
this.readonly = false;
|
|
28
|
-
/**
|
|
29
|
-
* Define if input is disabled
|
|
30
|
-
*/
|
|
31
|
-
this.disabled = false;
|
|
32
|
-
/**
|
|
33
|
-
* Define numeric type
|
|
34
|
-
*/
|
|
35
|
-
this.type = types[0];
|
|
36
|
-
/**
|
|
37
|
-
* Define currency
|
|
38
|
-
*/
|
|
39
|
-
this.currency = 'USD';
|
|
40
|
-
/**
|
|
41
|
-
* Override integer length
|
|
42
|
-
* integer is the number before the decimal point
|
|
43
|
-
*/
|
|
44
|
-
this.integerLength = 13;
|
|
45
|
-
/**
|
|
46
|
-
* Override decimal length
|
|
47
|
-
* decimal is the number after the decimal point
|
|
48
|
-
*/
|
|
49
|
-
this.decimalLength = 2;
|
|
50
|
-
/**
|
|
51
|
-
* Component classes
|
|
52
|
-
*/
|
|
53
|
-
this.classList = new ClassList(['mg-input--numeric']);
|
|
54
|
-
/**
|
|
55
|
-
* Define if input has focus
|
|
56
|
-
*/
|
|
57
|
-
this.hasFocus = false;
|
|
58
11
|
/**
|
|
59
12
|
* Handle input event
|
|
60
13
|
*
|
|
@@ -161,6 +114,30 @@ export class MgInputNumeric {
|
|
|
161
114
|
this.classList.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
162
115
|
}
|
|
163
116
|
};
|
|
117
|
+
this.value = undefined;
|
|
118
|
+
this.identifier = undefined;
|
|
119
|
+
this.name = this.identifier;
|
|
120
|
+
this.label = undefined;
|
|
121
|
+
this.labelOnTop = undefined;
|
|
122
|
+
this.labelHide = false;
|
|
123
|
+
this.placeholder = undefined;
|
|
124
|
+
this.required = false;
|
|
125
|
+
this.readonly = false;
|
|
126
|
+
this.disabled = false;
|
|
127
|
+
this.mgWidth = undefined;
|
|
128
|
+
this.tooltip = undefined;
|
|
129
|
+
this.helpText = undefined;
|
|
130
|
+
this.type = types[0];
|
|
131
|
+
this.currency = 'USD';
|
|
132
|
+
this.max = undefined;
|
|
133
|
+
this.min = undefined;
|
|
134
|
+
this.integerLength = 13;
|
|
135
|
+
this.decimalLength = 2;
|
|
136
|
+
this.valid = undefined;
|
|
137
|
+
this.invalid = undefined;
|
|
138
|
+
this.classList = new ClassList(['mg-input--numeric']);
|
|
139
|
+
this.errorMessage = undefined;
|
|
140
|
+
this.hasFocus = false;
|
|
164
141
|
}
|
|
165
142
|
validateValue(newValue) {
|
|
166
143
|
if (newValue !== undefined && newValue !== null) {
|
|
@@ -6,35 +6,6 @@ export class MgInputPassword {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
// hasDisplayedError (triggered by blur event)
|
|
8
8
|
this.hasDisplayedError = false;
|
|
9
|
-
/**
|
|
10
|
-
* Input name
|
|
11
|
-
* If not set the value equals the identifier
|
|
12
|
-
*/
|
|
13
|
-
this.name = this.identifier;
|
|
14
|
-
/**
|
|
15
|
-
* Define if label is visible
|
|
16
|
-
*/
|
|
17
|
-
this.labelHide = false;
|
|
18
|
-
/**
|
|
19
|
-
* Define if input is required
|
|
20
|
-
*/
|
|
21
|
-
this.required = false;
|
|
22
|
-
/**
|
|
23
|
-
* Define if input is readonly
|
|
24
|
-
*/
|
|
25
|
-
this.readonly = false;
|
|
26
|
-
/**
|
|
27
|
-
* Define if input is disabled
|
|
28
|
-
*/
|
|
29
|
-
this.disabled = false;
|
|
30
|
-
/**
|
|
31
|
-
* Define input width
|
|
32
|
-
*/
|
|
33
|
-
this.mgWidth = 'full';
|
|
34
|
-
/**
|
|
35
|
-
* Component classes
|
|
36
|
-
*/
|
|
37
|
-
this.classList = new ClassList(['mg-input--password']);
|
|
38
9
|
/**
|
|
39
10
|
* Handle input event
|
|
40
11
|
*/
|
|
@@ -72,6 +43,23 @@ export class MgInputPassword {
|
|
|
72
43
|
this.errorMessage = this.messages.errors.required;
|
|
73
44
|
}
|
|
74
45
|
};
|
|
46
|
+
this.value = undefined;
|
|
47
|
+
this.identifier = undefined;
|
|
48
|
+
this.name = this.identifier;
|
|
49
|
+
this.label = undefined;
|
|
50
|
+
this.labelOnTop = undefined;
|
|
51
|
+
this.labelHide = false;
|
|
52
|
+
this.placeholder = undefined;
|
|
53
|
+
this.required = false;
|
|
54
|
+
this.readonly = false;
|
|
55
|
+
this.disabled = false;
|
|
56
|
+
this.mgWidth = 'full';
|
|
57
|
+
this.tooltip = undefined;
|
|
58
|
+
this.helpText = undefined;
|
|
59
|
+
this.valid = undefined;
|
|
60
|
+
this.invalid = undefined;
|
|
61
|
+
this.classList = new ClassList(['mg-input--password']);
|
|
62
|
+
this.errorMessage = undefined;
|
|
75
63
|
}
|
|
76
64
|
handleValue(newValue) {
|
|
77
65
|
this.valueChange.emit(newValue);
|
|
@@ -168,4 +168,11 @@ fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
|
|
|
168
168
|
|
|
169
169
|
*:focus:not(:focus-visible) {
|
|
170
170
|
outline: none;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@media (prefers-reduced-motion) {
|
|
174
|
+
.mg-a11y-animation {
|
|
175
|
+
animation: none !important;
|
|
176
|
+
transition: none !important;
|
|
177
|
+
}
|
|
171
178
|
}
|