@mgdis/mg-components 5.4.0 → 5.6.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-4dcc1812.js} +11 -1
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{mg-badge_29.cjs.entry.js → mg-badge_30.cjs.entry.js} +1112 -859
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +5 -4
- package/dist/collection/components/atoms/mg-badge/doc/mg-badge.stories.js +0 -7
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +13 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +7 -10
- 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 +15 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +12 -29
- package/dist/collection/components/atoms/mg-card/mg-card.css +17 -5
- 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 +13 -3
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +5 -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 +61 -16
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +2 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +9 -22
- 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 +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +21 -26
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +3 -3
- 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 +3 -3
- 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.js +18 -33
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +30 -36
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +3 -3
- 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 +3 -3
- 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.js +16 -33
- package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +43 -11
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +17 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +27 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +145 -25
- package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +7 -5
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +0 -4
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +51 -21
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +129 -92
- package/dist/collection/components/molecules/mg-details/mg-details.js +4 -8
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -22
- 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 +4 -9
- package/dist/collection/components/molecules/mg-message/mg-message.css +20 -19
- package/dist/collection/components/molecules/mg-message/mg-message.js +55 -33
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +20 -8
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +8 -26
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +4 -13
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +17 -5
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +11 -22
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +82 -20
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +54 -26
- 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 +108 -0
- package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +5 -3
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +11 -7
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +109 -75
- 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 -25
- package/dist/collection/styles/a11y.scss +32 -0
- package/dist/collection/styles/components.scss +3 -0
- package/dist/collection/styles/fonts.scss +21 -0
- package/dist/collection/styles/form.scss +3 -0
- package/dist/collection/styles/global.scss +87 -0
- package/dist/collection/styles/layout.scss +29 -0
- package/dist/collection/styles/main.scss +23 -0
- package/dist/collection/styles/navigation-button.scss +76 -0
- package/dist/collection/styles/reset-mg-card-slotted-variables.scss +9 -0
- package/dist/collection/styles/typography.scss +75 -0
- package/dist/collection/styles/utilities.scss +21 -0
- package/dist/collection/utils/behaviors.utils.js +169 -0
- package/dist/collection/utils/components.utils.js +50 -0
- package/dist/collection/utils/locale.utils.js +22 -0
- package/dist/collection/utils/unit.test.utils.js +37 -32
- package/dist/collection/variables.css +9 -9
- package/dist/components/components.utils.js +51 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index2.js +73 -18
- package/dist/components/mg-badge2.js +8 -11
- package/dist/components/mg-button2.js +13 -30
- 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 +4 -8
- package/dist/components/mg-divider.js +0 -6
- package/dist/components/mg-form.js +8 -22
- package/dist/components/mg-icon2.js +18 -15
- package/dist/components/mg-illustrated-message.js +5 -10
- package/dist/components/mg-input-checkbox.js +17 -33
- package/dist/components/mg-input-date.js +23 -29
- package/dist/components/mg-input-numeric.js +26 -50
- package/dist/components/mg-input-password.js +18 -30
- package/dist/components/mg-input-radio.js +18 -33
- package/dist/components/mg-input-select2.js +32 -38
- 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 +16 -33
- package/dist/components/mg-menu-item.js +1 -264
- package/dist/components/mg-menu-item2.js +517 -0
- package/dist/components/mg-menu.js +142 -28
- package/dist/components/mg-message.js +64 -36
- package/dist/components/mg-modal.js +18 -30
- package/dist/components/mg-pagination.js +4 -13
- package/dist/components/mg-panel.js +20 -25
- package/dist/components/mg-popover.js +1 -200
- package/dist/components/mg-popover2.js +212 -0
- package/dist/components/mg-skip-links.d.ts +11 -0
- package/dist/components/mg-skip-links.js +80 -0
- package/dist/components/mg-tabs.js +108 -73
- package/dist/components/mg-tag.js +35 -13
- package/dist/components/mg-tooltip2.js +10 -23
- package/dist/esm/{index-aad0184c.js → index-dc9a2348.js} +11 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{mg-badge_29.entry.js → mg-badge_30.entry.js} +1112 -860
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- 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 +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-3899d5d2.js → p-182bd802.js} +2 -2
- package/dist/mg-components/p-f7da9dd2.entry.js +1 -0
- package/dist/mg-components/styles/a11y.scss +32 -0
- package/dist/mg-components/styles/components.scss +3 -0
- package/dist/mg-components/styles/fonts.scss +21 -0
- package/dist/mg-components/styles/form.scss +3 -0
- package/dist/mg-components/styles/global.scss +87 -0
- package/dist/mg-components/styles/layout.scss +29 -0
- package/dist/mg-components/styles/main.scss +23 -0
- package/dist/mg-components/styles/navigation-button.scss +76 -0
- package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +9 -0
- package/dist/mg-components/styles/typography.scss +75 -0
- package/dist/mg-components/styles/utilities.scss +21 -0
- package/dist/mg-components/variables.css +9 -9
- package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +0 -11
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +2 -2
- 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 +4 -4
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +6 -6
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +2 -2
- 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/molecules/inputs/MgInput.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
- 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-toggle/mg-input-toggle.conf.d.ts +1 -1
- package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +5 -0
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +37 -0
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +51 -3
- 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.conf.d.ts +0 -8
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +55 -15
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +22 -5
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +1 -1
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +12 -0
- 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 +49 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +5 -3
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +24 -14
- package/dist/types/components.d.ts +81 -18
- package/dist/types/locales/index.d.ts +16 -9
- package/dist/types/stencil-public-runtime.d.ts +44 -3
- package/dist/types/utils/behaviors.utils.d.ts +83 -0
- package/dist/types/utils/components.utils.d.ts +14 -0
- package/dist/types/utils/locale.utils.d.ts +13 -0
- package/dist/types/utils/unit.test.utils.d.ts +78 -0
- package/package.json +51 -46
- package/readme.md +25 -14
- package/dist/components/locale.utils.js +0 -40
- package/dist/components/mg-menu.conf.js +0 -10
- package/dist/mg-components/p-059a9a59.entry.js +0 -1
|
@@ -13,49 +13,50 @@ export class MgMessage {
|
|
|
13
13
|
this.closeButtonId = '';
|
|
14
14
|
// Stored timer setted when hide action is run from setTimeOut
|
|
15
15
|
this.storedTimer = null;
|
|
16
|
+
// Manage hover
|
|
17
|
+
this.isFocused = false;
|
|
18
|
+
this.isHovered = false;
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
this.identifier = createID('mg-message');
|
|
21
|
-
/**
|
|
22
|
-
* Message variant
|
|
23
|
-
*/
|
|
24
|
-
this.variant = variants[0]; // info
|
|
25
|
-
/**
|
|
26
|
-
* Define if message has a cross button
|
|
27
|
-
* RG 01: https://jira.mgdis.fr/browse/PDA9-140
|
|
28
|
-
*/
|
|
29
|
-
this.closeButton = false;
|
|
30
|
-
/**
|
|
31
|
-
* Define if message is hidden
|
|
20
|
+
* Set timer
|
|
21
|
+
*
|
|
22
|
+
* @returns {void}
|
|
32
23
|
*/
|
|
33
|
-
this.
|
|
24
|
+
this.setTimer = () => {
|
|
25
|
+
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
26
|
+
};
|
|
34
27
|
/**
|
|
35
|
-
*
|
|
28
|
+
* Clear timer
|
|
29
|
+
*
|
|
30
|
+
* @returns {void}
|
|
36
31
|
*/
|
|
37
|
-
this.
|
|
32
|
+
this.clearTimer = () => {
|
|
33
|
+
clearTimeout(this.storedTimer);
|
|
34
|
+
};
|
|
38
35
|
/**
|
|
39
|
-
*
|
|
36
|
+
* Event to add on element
|
|
37
|
+
*
|
|
38
|
+
* @param {MouseEvent | FocusEvent} event event
|
|
39
|
+
* @returns {void}
|
|
40
40
|
*/
|
|
41
|
-
this.
|
|
41
|
+
this.timerEvents = (event) => {
|
|
42
|
+
this.clearTimer();
|
|
43
|
+
const isMouseEvent = event.type === 'mouseenter';
|
|
44
|
+
// Needed to ensure we don't start the timer
|
|
45
|
+
this[isMouseEvent ? 'isHovered' : 'isFocused'] = true;
|
|
46
|
+
// Restart timer when loose focus AND mouse leave
|
|
47
|
+
this.element.addEventListener(isMouseEvent ? 'mouseleave' : 'focusout', eventOut => {
|
|
48
|
+
this[eventOut.type === 'mouseleave' ? 'isHovered' : 'isFocused'] = false;
|
|
49
|
+
// Start timer if needed
|
|
50
|
+
if (!this.isFocused && !this.isHovered)
|
|
51
|
+
this.setTimer();
|
|
52
|
+
}, { once: true });
|
|
53
|
+
};
|
|
42
54
|
/**
|
|
43
55
|
* Handle close button
|
|
44
56
|
*/
|
|
45
57
|
this.handleClose = () => {
|
|
46
58
|
this.hide = true;
|
|
47
59
|
};
|
|
48
|
-
/**
|
|
49
|
-
* Hide component whith delay
|
|
50
|
-
*/
|
|
51
|
-
this.hideWithDelay = () => {
|
|
52
|
-
if (this.delay > 0 && this.hide !== true) {
|
|
53
|
-
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
54
|
-
}
|
|
55
|
-
else if (this.storedTimer !== null) {
|
|
56
|
-
clearTimeout(this.storedTimer);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
60
|
/**
|
|
60
61
|
* Get icon corresponding to variant
|
|
61
62
|
*
|
|
@@ -75,6 +76,13 @@ export class MgMessage {
|
|
|
75
76
|
break;
|
|
76
77
|
}
|
|
77
78
|
};
|
|
79
|
+
this.identifier = createID('mg-message');
|
|
80
|
+
this.delay = undefined;
|
|
81
|
+
this.variant = variants[0];
|
|
82
|
+
this.closeButton = false;
|
|
83
|
+
this.hide = false;
|
|
84
|
+
this.classList = new ClassList(['mg-message']);
|
|
85
|
+
this.hasActions = false;
|
|
78
86
|
}
|
|
79
87
|
validateDelay(newValue) {
|
|
80
88
|
if (newValue && newValue < 2) {
|
|
@@ -102,12 +110,26 @@ export class MgMessage {
|
|
|
102
110
|
if (newValue) {
|
|
103
111
|
this.componentHide.emit();
|
|
104
112
|
this.classList.add(this.classHide);
|
|
113
|
+
// Remove event Listener
|
|
114
|
+
['focusin', 'mouseenter'].forEach(event => {
|
|
115
|
+
this.element.removeEventListener(event, this.timerEvents);
|
|
116
|
+
});
|
|
117
|
+
// Clear Timer
|
|
118
|
+
this.clearTimer();
|
|
105
119
|
}
|
|
106
120
|
else {
|
|
107
121
|
this.componentShow.emit();
|
|
108
122
|
this.classList.delete(this.classHide);
|
|
123
|
+
// If delay is set
|
|
124
|
+
if (this.delay > 1) {
|
|
125
|
+
// Start timer
|
|
126
|
+
this.setTimer();
|
|
127
|
+
// Stop timer when get focus or mouse enter
|
|
128
|
+
['focusin', 'mouseenter'].forEach(event => {
|
|
129
|
+
this.element.addEventListener(event, this.timerEvents);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
109
132
|
}
|
|
110
|
-
this.hideWithDelay();
|
|
111
133
|
}
|
|
112
134
|
/*************
|
|
113
135
|
* Lifecycle *
|
|
@@ -136,7 +158,7 @@ export class MgMessage {
|
|
|
136
158
|
* @returns {HTMLElement} HTML Element
|
|
137
159
|
*/
|
|
138
160
|
render() {
|
|
139
|
-
return (h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("span", { class: "mg-message__icon" }, h("mg-icon", { icon: this.getIcon() })), h("div", { class: "mg-message__content" }, h("span", { class: "mg-message__content-slot" }, h("slot", null)), this.hasActions && h("span", { class: "mg-message__content-separator" }), this.hasActions && (h("span", { class: "mg-message__content-actions-slot" }, h("slot", { name: "actions" })))), this.closeButton && (h("span", { class: "mg-message__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" }))))));
|
|
161
|
+
return (h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("mg-card", null, h("span", { class: "mg-message__bar" }), h("span", { class: "mg-message__icon" }, h("mg-icon", { icon: this.getIcon() })), h("div", { class: "mg-message__content" }, h("span", { class: "mg-message__content-slot" }, h("slot", null)), this.hasActions && h("span", { class: "mg-message__content-separator" }), this.hasActions && (h("span", { class: "mg-message__content-actions-slot" }, h("slot", { name: "actions" })))), this.closeButton && (h("span", { class: "mg-message__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))))));
|
|
140
162
|
}
|
|
141
163
|
static get is() { return "mg-message"; }
|
|
142
164
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--mg-card-border-radius: var(--mg-modal-border-radius);
|
|
3
|
+
--mg-card-padding: 1.5rem 2.5rem;
|
|
4
|
+
--mg-card-border: none;
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
.mg-modal {
|
|
2
8
|
display: flex;
|
|
3
9
|
justify-content: center;
|
|
@@ -9,7 +15,13 @@
|
|
|
9
15
|
left: 0;
|
|
10
16
|
z-index: 2000;
|
|
11
17
|
padding: 2rem 0;
|
|
12
|
-
background-color:
|
|
18
|
+
background-color: hsl(var(--color-light), 0.85);
|
|
19
|
+
}
|
|
20
|
+
.mg-modal mg-card {
|
|
21
|
+
display: flex;
|
|
22
|
+
width: 60rem;
|
|
23
|
+
max-width: 100%;
|
|
24
|
+
max-height: 100%;
|
|
13
25
|
}
|
|
14
26
|
.mg-modal__dialog {
|
|
15
27
|
display: flex;
|
|
@@ -17,15 +29,8 @@
|
|
|
17
29
|
flex-direction: column;
|
|
18
30
|
align-self: center;
|
|
19
31
|
row-gap: 3rem;
|
|
20
|
-
padding: 1.5rem 2.5rem;
|
|
21
|
-
width: 60rem;
|
|
22
32
|
height: fit-content;
|
|
23
|
-
max-width: 100%;
|
|
24
33
|
max-height: 100%;
|
|
25
|
-
box-sizing: border-box;
|
|
26
|
-
background-color: hsl(var(--color-light));
|
|
27
|
-
box-shadow: var(--box-shadow);
|
|
28
|
-
border-radius: var(--mg-modal-border-radius);
|
|
29
34
|
}
|
|
30
35
|
.mg-modal__header {
|
|
31
36
|
margin-bottom: 0.5rem;
|
|
@@ -50,4 +55,11 @@
|
|
|
50
55
|
}
|
|
51
56
|
.mg-modal.mg-modal--hide {
|
|
52
57
|
display: none;
|
|
58
|
+
}
|
|
59
|
+
.mg-modal ::slotted(*) {
|
|
60
|
+
--mg-card-border: var(--mg-card-border-default);
|
|
61
|
+
--mg-card-padding: var(--mg-card-padding-default);
|
|
62
|
+
--mg-card-border-radius: var(--mg-card-border-radius-default);
|
|
63
|
+
--mg-card-background: var(--mg-card-background-default);
|
|
64
|
+
--mg-card-box-shadow: var(--mg-card-box-shadow-default);
|
|
53
65
|
}
|
|
@@ -8,31 +8,6 @@ export class MgModal {
|
|
|
8
8
|
// IDs
|
|
9
9
|
this.closeButtonId = '';
|
|
10
10
|
this.titleId = '';
|
|
11
|
-
/**
|
|
12
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
13
|
-
* If not set, it will be created.
|
|
14
|
-
*/
|
|
15
|
-
this.identifier = createID('mg-modal');
|
|
16
|
-
/**
|
|
17
|
-
* Define if modal has a cross button
|
|
18
|
-
*/
|
|
19
|
-
this.closeButton = false;
|
|
20
|
-
/**
|
|
21
|
-
* Define if modal is hidden
|
|
22
|
-
*/
|
|
23
|
-
this.hide = false;
|
|
24
|
-
/**
|
|
25
|
-
* Define if component is using actions slot
|
|
26
|
-
*/
|
|
27
|
-
this.hasActions = false;
|
|
28
|
-
/**
|
|
29
|
-
* Define if component is using content slot
|
|
30
|
-
*/
|
|
31
|
-
this.hasContent = false;
|
|
32
|
-
/**
|
|
33
|
-
* Component classes
|
|
34
|
-
*/
|
|
35
|
-
this.classList = new ClassList(['mg-modal']);
|
|
36
11
|
this.setFocus = () => {
|
|
37
12
|
// Get all focusable elements
|
|
38
13
|
this.modalFocusableElements = Array.from(this.element.querySelectorAll(focusableElements)).reduce((acc, focusableElement) => {
|
|
@@ -75,6 +50,13 @@ export class MgModal {
|
|
|
75
50
|
this.handleClose = () => {
|
|
76
51
|
this.hide = true;
|
|
77
52
|
};
|
|
53
|
+
this.identifier = createID('mg-modal');
|
|
54
|
+
this.modalTitle = undefined;
|
|
55
|
+
this.closeButton = false;
|
|
56
|
+
this.hide = false;
|
|
57
|
+
this.hasActions = false;
|
|
58
|
+
this.hasContent = false;
|
|
59
|
+
this.classList = new ClassList(['mg-modal']);
|
|
78
60
|
}
|
|
79
61
|
validateModalTitle(newValue) {
|
|
80
62
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -150,7 +132,7 @@ export class MgModal {
|
|
|
150
132
|
* @returns {HTMLElement} HTML Element
|
|
151
133
|
*/
|
|
152
134
|
render() {
|
|
153
|
-
return (h("
|
|
135
|
+
return (h("div", { role: "alertdialog", id: this.identifier, class: this.classList.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, h("mg-card", null, h("div", { class: "mg-modal__dialog" }, h("header", { class: "mg-modal__header" }, this.closeButton && (h("span", { class: "mg-modal__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))), h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (h("article", { class: "mg-modal__content" }, h("slot", { name: "content" }))), this.hasActions && (h("footer", { class: "mg-modal__footer" }, h("slot", { name: "actions" })))))));
|
|
154
136
|
}
|
|
155
137
|
static get is() { return "mg-modal"; }
|
|
156
138
|
static get encapsulation() { return "shadow"; }
|
|
@@ -25,19 +25,6 @@ import { initLocales } from './../../../locales';
|
|
|
25
25
|
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
26
26
|
export class MgPagination {
|
|
27
27
|
constructor() {
|
|
28
|
-
/**
|
|
29
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
30
|
-
* If not set, it will be created.
|
|
31
|
-
*/
|
|
32
|
-
this.identifier = createID('mg-pagination');
|
|
33
|
-
/**
|
|
34
|
-
* Component total pages
|
|
35
|
-
*/
|
|
36
|
-
this.totalPages = 1;
|
|
37
|
-
/**
|
|
38
|
-
* Component current page
|
|
39
|
-
*/
|
|
40
|
-
this.currentPage = 1;
|
|
41
28
|
/**
|
|
42
29
|
* Change current page from target
|
|
43
30
|
*
|
|
@@ -70,6 +57,10 @@ export class MgPagination {
|
|
|
70
57
|
this.handleGoToPage = (action, disabled) => {
|
|
71
58
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
72
59
|
};
|
|
60
|
+
this.identifier = createID('mg-pagination');
|
|
61
|
+
this.label = undefined;
|
|
62
|
+
this.totalPages = 1;
|
|
63
|
+
this.currentPage = 1;
|
|
73
64
|
}
|
|
74
65
|
validateTotalPages(newValue) {
|
|
75
66
|
if (newValue < 1) {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
:host {
|
|
2
|
+
--mg-card-border: none;
|
|
3
|
+
--mg-card-padding: 0;
|
|
4
|
+
--mg-card-border-radius: var(--mg-panel-border-radius);
|
|
5
|
+
--mg-card-background: hsl(var(--mg-panel-background));
|
|
6
|
+
--mg-card-box-shadow: var(--mg-panel-box-shadow);
|
|
7
|
+
}
|
|
8
|
+
|
|
6
9
|
.mg-panel__header {
|
|
7
10
|
display: flex;
|
|
8
11
|
flex-wrap: wrap;
|
|
@@ -17,6 +20,8 @@
|
|
|
17
20
|
.mg-panel__header-right {
|
|
18
21
|
padding-left: 0.3rem;
|
|
19
22
|
flex: 1 auto;
|
|
23
|
+
min-height: var(--default-size);
|
|
24
|
+
align-items: center;
|
|
20
25
|
}
|
|
21
26
|
.mg-panel__header-left mg-input-text {
|
|
22
27
|
flex-grow: 1;
|
|
@@ -40,4 +45,11 @@
|
|
|
40
45
|
flex-wrap: wrap;
|
|
41
46
|
gap: 1rem;
|
|
42
47
|
margin-left: auto;
|
|
48
|
+
}
|
|
49
|
+
.mg-panel ::slotted(*) {
|
|
50
|
+
--mg-card-border: var(--mg-card-border-default);
|
|
51
|
+
--mg-card-padding: var(--mg-card-padding-default);
|
|
52
|
+
--mg-card-border-radius: var(--mg-card-border-radius-default);
|
|
53
|
+
--mg-card-background: var(--mg-card-background-default);
|
|
54
|
+
--mg-card-box-shadow: var(--mg-card-box-shadow-default);
|
|
43
55
|
}
|
|
@@ -3,27 +3,6 @@ import { createID, ClassList } from '../../../utils/components.utils';
|
|
|
3
3
|
import { initLocales } from '../../../locales';
|
|
4
4
|
export class MgPanel {
|
|
5
5
|
constructor() {
|
|
6
|
-
/**
|
|
7
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
8
|
-
* If not set, it will be created.
|
|
9
|
-
*/
|
|
10
|
-
this.identifier = createID('mg-panel');
|
|
11
|
-
/**
|
|
12
|
-
* Panel is opened
|
|
13
|
-
*/
|
|
14
|
-
this.expanded = false;
|
|
15
|
-
/**
|
|
16
|
-
* Panel title is editabled
|
|
17
|
-
*/
|
|
18
|
-
this.titleEditable = false;
|
|
19
|
-
/**
|
|
20
|
-
* Component classes
|
|
21
|
-
*/
|
|
22
|
-
this.classList = new ClassList(['mg-panel']);
|
|
23
|
-
/**
|
|
24
|
-
* Title is in edition mode
|
|
25
|
-
*/
|
|
26
|
-
this.isEditing = false;
|
|
27
6
|
/************
|
|
28
7
|
* Methods *
|
|
29
8
|
************/
|
|
@@ -108,6 +87,16 @@ export class MgPanel {
|
|
|
108
87
|
}
|
|
109
88
|
return collapseButton();
|
|
110
89
|
};
|
|
90
|
+
this.identifier = createID('mg-panel');
|
|
91
|
+
this.panelTitle = undefined;
|
|
92
|
+
this.titlePattern = undefined;
|
|
93
|
+
this.titlePatternErrorMessage = undefined;
|
|
94
|
+
this.expanded = false;
|
|
95
|
+
this.expandToggleDisabled = undefined;
|
|
96
|
+
this.titleEditable = false;
|
|
97
|
+
this.classList = new ClassList(['mg-panel']);
|
|
98
|
+
this.isEditing = false;
|
|
99
|
+
this.updatedPanelTitle = undefined;
|
|
111
100
|
}
|
|
112
101
|
validatePanelTitle(newValue) {
|
|
113
102
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -158,7 +147,7 @@ export class MgPanel {
|
|
|
158
147
|
* @returns {HTMLElement} html element
|
|
159
148
|
*/
|
|
160
149
|
render() {
|
|
161
|
-
return (h("section", { class: this.classList.join(), id: this.identifier }, h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), h("div", { class: "mg-panel__header-right" }, h("slot", { name: "header-right" }))), h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, h("slot", null))));
|
|
150
|
+
return (h("section", { class: this.classList.join(), id: this.identifier }, h("mg-card", null, h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), h("div", { class: "mg-panel__header-right" }, h("slot", { name: "header-right" }))), h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, h("slot", null)))));
|
|
162
151
|
}
|
|
163
152
|
static get is() { return "mg-panel"; }
|
|
164
153
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
:host {
|
|
2
|
+
--mg-card-padding: var(--mg-popover-padding-vertical, 1.5rem) var(--mg-popover-padding-horizontal, var(--mg-popover-padding-vertical, 1.5rem));
|
|
3
|
+
--mg-card-border: none;
|
|
4
|
+
--mg-card-border-radius: 0.5rem;
|
|
5
|
+
--mg-card-background: hsl(var(--mg-popover-background-color));
|
|
6
|
+
position: relative;
|
|
2
7
|
display: contents;
|
|
3
8
|
}
|
|
4
|
-
|
|
9
|
+
:host::slotted(*) {
|
|
5
10
|
display: inline-block;
|
|
6
11
|
}
|
|
7
12
|
|
|
8
13
|
.mg-popover {
|
|
9
14
|
display: none;
|
|
10
|
-
padding:
|
|
11
|
-
z-index:
|
|
12
|
-
border-radius: 0.5rem;
|
|
13
|
-
background-color: hsl(var(--mg-popover-background-color));
|
|
14
|
-
box-shadow: var(--box-shadow);
|
|
15
|
+
padding: 1rem;
|
|
16
|
+
z-index: 2000;
|
|
15
17
|
color: hsl(var(--mg-popover-font-color));
|
|
16
18
|
}
|
|
19
|
+
.mg-popover mg-card {
|
|
20
|
+
position: relative;
|
|
21
|
+
z-index: -1;
|
|
22
|
+
}
|
|
17
23
|
.mg-popover[data-show] {
|
|
18
24
|
display: block;
|
|
19
25
|
}
|
|
@@ -23,35 +29,91 @@ mg-popover::slotted(*) {
|
|
|
23
29
|
margin-top: calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);
|
|
24
30
|
margin-left: 3rem;
|
|
25
31
|
}
|
|
26
|
-
.mg-popover__arrow, .mg-popover__arrow::before {
|
|
27
|
-
position: absolute;
|
|
28
|
-
width: 2rem;
|
|
29
|
-
height: 2rem;
|
|
30
|
-
z-index: -1;
|
|
31
|
-
background: inherit;
|
|
32
|
-
}
|
|
33
32
|
.mg-popover__arrow {
|
|
33
|
+
position: absolute;
|
|
34
34
|
visibility: hidden;
|
|
35
|
+
width: calc(3rem + 2 * var(--mg-card-border-radius) + 2rem);
|
|
36
|
+
height: calc(3rem + 2 * var(--mg-card-border-radius) + 2rem);
|
|
35
37
|
}
|
|
36
|
-
.mg-popover__arrow
|
|
38
|
+
.mg-popover__arrow:before {
|
|
37
39
|
visibility: visible;
|
|
38
40
|
content: "";
|
|
39
|
-
|
|
41
|
+
position: absolute;
|
|
42
|
+
}
|
|
43
|
+
.mg-popover[data-popper-placement^=top] > .mg-popover__arrow, .mg-popover[data-popper-placement^=bottom] > .mg-popover__arrow {
|
|
44
|
+
height: 1rem;
|
|
45
|
+
}
|
|
46
|
+
.mg-popover[data-popper-placement^=top] > .mg-popover__arrow:before, .mg-popover[data-popper-placement^=bottom] > .mg-popover__arrow:before {
|
|
47
|
+
left: calc(var(--mg-card-border-radius) + 1rem);
|
|
48
|
+
border-right: calc(3rem / 2) solid transparent;
|
|
49
|
+
border-left: calc(3rem / 2) solid transparent;
|
|
40
50
|
}
|
|
41
51
|
.mg-popover[data-popper-placement^=top] > .mg-popover__arrow {
|
|
42
|
-
bottom:
|
|
52
|
+
bottom: 0.1rem;
|
|
53
|
+
filter: drop-shadow(0 0.5rem 0.25rem hsl(var(--color-dark), 0.15));
|
|
54
|
+
}
|
|
55
|
+
.mg-popover[data-popper-placement^=top] > .mg-popover__arrow:before {
|
|
56
|
+
border-top: 1rem solid hsl(var(--mg-popover-background-color));
|
|
43
57
|
}
|
|
44
58
|
.mg-popover[data-popper-placement^=bottom] > .mg-popover__arrow {
|
|
45
|
-
top:
|
|
59
|
+
top: 0.1rem;
|
|
60
|
+
filter: drop-shadow(0 -0.5rem 0.25rem hsl(var(--color-dark), 0.15));
|
|
61
|
+
}
|
|
62
|
+
.mg-popover[data-popper-placement^=bottom] > .mg-popover__arrow:before {
|
|
63
|
+
border-bottom: 1rem solid hsl(var(--mg-popover-background-color));
|
|
64
|
+
}
|
|
65
|
+
.mg-popover[data-popper-placement^=left] > .mg-popover__arrow, .mg-popover[data-popper-placement^=right] > .mg-popover__arrow {
|
|
66
|
+
width: 1rem;
|
|
67
|
+
}
|
|
68
|
+
.mg-popover[data-popper-placement^=left] > .mg-popover__arrow:before, .mg-popover[data-popper-placement^=right] > .mg-popover__arrow:before {
|
|
69
|
+
top: calc(var(--mg-card-border-radius) + 1rem);
|
|
70
|
+
border-top: calc(3rem / 2) solid transparent;
|
|
71
|
+
border-bottom: calc(3rem / 2) solid transparent;
|
|
46
72
|
}
|
|
47
73
|
.mg-popover[data-popper-placement^=left] > .mg-popover__arrow {
|
|
48
|
-
right:
|
|
74
|
+
right: 0.1rem;
|
|
75
|
+
filter: drop-shadow(0.5rem 0 0.25rem hsl(var(--color-dark), 0.15));
|
|
76
|
+
}
|
|
77
|
+
.mg-popover[data-popper-placement^=left] > .mg-popover__arrow:before {
|
|
78
|
+
border-left: 1rem solid hsl(var(--mg-popover-background-color));
|
|
49
79
|
}
|
|
50
80
|
.mg-popover[data-popper-placement^=right] > .mg-popover__arrow {
|
|
51
|
-
left:
|
|
81
|
+
left: 0.1rem;
|
|
82
|
+
filter: drop-shadow(-0.5rem 0 0.25rem hsl(var(--color-dark), 0.15));
|
|
83
|
+
}
|
|
84
|
+
.mg-popover[data-popper-placement^=right] > .mg-popover__arrow:before {
|
|
85
|
+
border-right: 1rem solid hsl(var(--mg-popover-background-color));
|
|
86
|
+
}
|
|
87
|
+
.mg-popover[data-popper-placement^=left-start], .mg-popover[data-popper-placement^=left-end], .mg-popover[data-popper-placement^=right-start], .mg-popover[data-popper-placement^=right-end] {
|
|
88
|
+
padding: 0 1rem;
|
|
89
|
+
}
|
|
90
|
+
.mg-popover[data-popper-placement^=left-start] > .mg-popover__arrow, .mg-popover[data-popper-placement^=left-end] > .mg-popover__arrow, .mg-popover[data-popper-placement^=right-start] > .mg-popover__arrow, .mg-popover[data-popper-placement^=right-end] > .mg-popover__arrow {
|
|
91
|
+
height: calc(3rem + 2 * var(--mg-card-border-radius));
|
|
92
|
+
}
|
|
93
|
+
.mg-popover[data-popper-placement^=left-start] > .mg-popover__arrow:before, .mg-popover[data-popper-placement^=left-end] > .mg-popover__arrow:before, .mg-popover[data-popper-placement^=right-start] > .mg-popover__arrow:before, .mg-popover[data-popper-placement^=right-end] > .mg-popover__arrow:before {
|
|
94
|
+
top: var(--mg-card-border-radius);
|
|
52
95
|
}
|
|
53
96
|
.mg-popover__title ::slotted([slot=title]) {
|
|
54
97
|
margin: 0 0 1rem !important;
|
|
55
98
|
font-size: var(--mg-popover-title-font-size) !important;
|
|
56
99
|
font-weight: 600;
|
|
100
|
+
}
|
|
101
|
+
.mg-popover--arrow-hide.mg-popover[data-popper-placement^=top] {
|
|
102
|
+
padding-bottom: 0;
|
|
103
|
+
}
|
|
104
|
+
.mg-popover--arrow-hide.mg-popover[data-popper-placement^=bottom] {
|
|
105
|
+
padding-top: 0;
|
|
106
|
+
}
|
|
107
|
+
.mg-popover--arrow-hide.mg-popover[data-popper-placement$=end], .mg-popover--arrow-hide.mg-popover[data-popper-placement^=left] {
|
|
108
|
+
padding-right: 0;
|
|
109
|
+
}
|
|
110
|
+
.mg-popover--arrow-hide.mg-popover[data-popper-placement$=start], .mg-popover--arrow-hide.mg-popover[data-popper-placement^=right] {
|
|
111
|
+
padding-left: 0;
|
|
112
|
+
}
|
|
113
|
+
.mg-popover ::slotted(*) {
|
|
114
|
+
--mg-card-border: var(--mg-card-border-default);
|
|
115
|
+
--mg-card-padding: var(--mg-card-padding-default);
|
|
116
|
+
--mg-card-border-radius: var(--mg-card-border-radius-default);
|
|
117
|
+
--mg-card-background: var(--mg-card-background-default);
|
|
118
|
+
--mg-card-box-shadow: var(--mg-card-box-shadow-default);
|
|
57
119
|
}
|
|
@@ -1,31 +1,13 @@
|
|
|
1
1
|
import { Host, h } from '@stencil/core';
|
|
2
2
|
import { createID, isTagName } from '../../../utils/components.utils';
|
|
3
3
|
import { createPopper } from '@popperjs/core';
|
|
4
|
+
import { getWindows, ClassList } from '../../../utils/components.utils';
|
|
4
5
|
import { initLocales } from '../../../locales';
|
|
5
6
|
export class MgPopover {
|
|
6
7
|
constructor() {
|
|
7
8
|
this.closeButtonId = '';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Needed by the input for accessibility `aria-decribedby`.
|
|
11
|
-
*/
|
|
12
|
-
this.identifier = createID('mg-popover');
|
|
13
|
-
/**
|
|
14
|
-
* Popover placement
|
|
15
|
-
*/
|
|
16
|
-
this.placement = 'bottom';
|
|
17
|
-
/**
|
|
18
|
-
* Define if popover has a cross button
|
|
19
|
-
*/
|
|
20
|
-
this.closeButton = false;
|
|
21
|
-
/**
|
|
22
|
-
* Display popover
|
|
23
|
-
*/
|
|
24
|
-
this.display = false;
|
|
25
|
-
/**
|
|
26
|
-
* Disable popover
|
|
27
|
-
*/
|
|
28
|
-
this.disabled = false;
|
|
9
|
+
// Classes
|
|
10
|
+
this.classArrowHide = `mg-popover--arrow-hide`;
|
|
29
11
|
/**
|
|
30
12
|
* Check if clicked outside of component
|
|
31
13
|
*
|
|
@@ -52,7 +34,9 @@ export class MgPopover {
|
|
|
52
34
|
// hide when click outside
|
|
53
35
|
// setTimeout is used to prevent event to trigger after creation
|
|
54
36
|
setTimeout(() => {
|
|
55
|
-
|
|
37
|
+
this.windows.forEach((localWindow) => {
|
|
38
|
+
localWindow.addEventListener('click', this.clickOutside, false);
|
|
39
|
+
});
|
|
56
40
|
}, 0);
|
|
57
41
|
};
|
|
58
42
|
/**
|
|
@@ -66,7 +50,9 @@ export class MgPopover {
|
|
|
66
50
|
// Disable the event listeners
|
|
67
51
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
|
|
68
52
|
// Remove event listener
|
|
69
|
-
|
|
53
|
+
this.windows.forEach((localWindow) => {
|
|
54
|
+
localWindow.removeEventListener('click', this.clickOutside, false);
|
|
55
|
+
});
|
|
70
56
|
};
|
|
71
57
|
/**
|
|
72
58
|
* Handle action for close button
|
|
@@ -76,6 +62,19 @@ export class MgPopover {
|
|
|
76
62
|
this.handleCloseButton = () => {
|
|
77
63
|
this.display = false;
|
|
78
64
|
};
|
|
65
|
+
this.identifier = createID('mg-popover');
|
|
66
|
+
this.placement = 'bottom';
|
|
67
|
+
this.arrowHide = false;
|
|
68
|
+
this.closeButton = false;
|
|
69
|
+
this.display = false;
|
|
70
|
+
this.disabled = false;
|
|
71
|
+
this.classList = new ClassList(['mg-popover']);
|
|
72
|
+
}
|
|
73
|
+
validateArrowHide(newValue) {
|
|
74
|
+
if (newValue)
|
|
75
|
+
this.classList.add(this.classArrowHide);
|
|
76
|
+
else
|
|
77
|
+
this.classList.delete(this.classArrowHide);
|
|
79
78
|
}
|
|
80
79
|
handleDisplay(newValue) {
|
|
81
80
|
if (newValue) {
|
|
@@ -95,8 +94,11 @@ export class MgPopover {
|
|
|
95
94
|
* @returns {void} timeout
|
|
96
95
|
*/
|
|
97
96
|
componentWillLoad() {
|
|
97
|
+
// Get windows to attach events
|
|
98
|
+
this.windows = getWindows(window);
|
|
98
99
|
// Get locales
|
|
99
100
|
this.messages = initLocales(this.element).messages;
|
|
101
|
+
this.validateArrowHide(this.arrowHide);
|
|
100
102
|
}
|
|
101
103
|
/**
|
|
102
104
|
* Check if component props are well configured on init
|
|
@@ -114,7 +116,7 @@ export class MgPopover {
|
|
|
114
116
|
this.closeButtonId = `${this.identifier}-close-button`;
|
|
115
117
|
}
|
|
116
118
|
// Get popover content
|
|
117
|
-
this.popover = this.element.shadowRoot.
|
|
119
|
+
this.popover = this.element.shadowRoot.getElementById(this.identifier);
|
|
118
120
|
//Get interactive element (first element without slot attribute)
|
|
119
121
|
const interactiveElement = this.element.querySelector(':not([slot])');
|
|
120
122
|
// Add aria attributes
|
|
@@ -128,7 +130,7 @@ export class MgPopover {
|
|
|
128
130
|
{
|
|
129
131
|
name: 'offset',
|
|
130
132
|
options: {
|
|
131
|
-
offset: [0,
|
|
133
|
+
offset: [0, 0],
|
|
132
134
|
},
|
|
133
135
|
},
|
|
134
136
|
],
|
|
@@ -151,7 +153,7 @@ export class MgPopover {
|
|
|
151
153
|
* @returns {HTMLElement} HTML Element
|
|
152
154
|
*/
|
|
153
155
|
render() {
|
|
154
|
-
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: "mg-
|
|
156
|
+
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: this.classList.join() }, h("mg-card", null, this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, h("mg-icon", { icon: "cross" }))), h("div", { class: "mg-popover__title" }, h("slot", { name: "title" })), h("slot", { name: "content" })), !this.arrowHide && h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
155
157
|
}
|
|
156
158
|
static get is() { return "mg-popover"; }
|
|
157
159
|
static get encapsulation() { return "shadow"; }
|
|
@@ -208,6 +210,24 @@ export class MgPopover {
|
|
|
208
210
|
"reflect": false,
|
|
209
211
|
"defaultValue": "'bottom'"
|
|
210
212
|
},
|
|
213
|
+
"arrowHide": {
|
|
214
|
+
"type": "boolean",
|
|
215
|
+
"mutable": false,
|
|
216
|
+
"complexType": {
|
|
217
|
+
"original": "boolean",
|
|
218
|
+
"resolved": "boolean",
|
|
219
|
+
"references": {}
|
|
220
|
+
},
|
|
221
|
+
"required": false,
|
|
222
|
+
"optional": false,
|
|
223
|
+
"docs": {
|
|
224
|
+
"tags": [],
|
|
225
|
+
"text": "Hide popover arrow"
|
|
226
|
+
},
|
|
227
|
+
"attribute": "arrow-hide",
|
|
228
|
+
"reflect": false,
|
|
229
|
+
"defaultValue": "false"
|
|
230
|
+
},
|
|
211
231
|
"closeButton": {
|
|
212
232
|
"type": "boolean",
|
|
213
233
|
"mutable": false,
|
|
@@ -264,6 +284,11 @@ export class MgPopover {
|
|
|
264
284
|
}
|
|
265
285
|
};
|
|
266
286
|
}
|
|
287
|
+
static get states() {
|
|
288
|
+
return {
|
|
289
|
+
"classList": {}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
267
292
|
static get events() {
|
|
268
293
|
return [{
|
|
269
294
|
"method": "displayChange",
|
|
@@ -285,6 +310,9 @@ export class MgPopover {
|
|
|
285
310
|
static get elementRef() { return "element"; }
|
|
286
311
|
static get watchers() {
|
|
287
312
|
return [{
|
|
313
|
+
"propName": "arrowHide",
|
|
314
|
+
"methodName": "validateArrowHide"
|
|
315
|
+
}, {
|
|
288
316
|
"propName": "display",
|
|
289
317
|
"methodName": "handleDisplay"
|
|
290
318
|
}];
|