@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
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { h, Host } from '@stencil/core';
|
|
2
|
+
import { OverflowBehaviorElements } from '../../../../utils/behaviors.utils';
|
|
2
3
|
import { ClassList } from '../../../../utils/components.utils';
|
|
4
|
+
import { initLocales } from '../../../../locales';
|
|
3
5
|
import { Direction } from '../mg-menu/mg-menu.conf';
|
|
4
|
-
import {
|
|
6
|
+
import { Status } from './mg-menu-item.conf';
|
|
5
7
|
export class MgMenuItem {
|
|
6
8
|
constructor() {
|
|
7
9
|
/************
|
|
@@ -9,32 +11,9 @@ export class MgMenuItem {
|
|
|
9
11
|
************/
|
|
10
12
|
this.name = 'mg-menu-item';
|
|
11
13
|
this.navigationButton = `${this.name}__navigation-button`;
|
|
12
|
-
|
|
13
|
-
* Define menu-item status. Default: "visible"
|
|
14
|
-
*/
|
|
15
|
-
this.status = Status.VISIBLE;
|
|
16
|
-
/**
|
|
17
|
-
* Define menu-item size. Default: "large".
|
|
18
|
-
*/
|
|
19
|
-
this.size = 'large';
|
|
20
|
-
/**
|
|
21
|
-
* Define menu-item content expanded. Default: false.
|
|
22
|
-
*/
|
|
23
|
-
this.expanded = false;
|
|
24
|
-
/************
|
|
25
|
-
* States *
|
|
26
|
-
************/
|
|
27
|
-
/**
|
|
28
|
-
* Component button classes
|
|
29
|
-
*/
|
|
30
|
-
this.navigationButtonClassList = new ClassList([this.navigationButton]);
|
|
31
|
-
/**
|
|
32
|
-
* Does component have children. Default: false.
|
|
33
|
-
*/
|
|
34
|
-
this.hasChildren = false;
|
|
35
|
-
/************
|
|
14
|
+
/***********
|
|
36
15
|
* Methods *
|
|
37
|
-
|
|
16
|
+
**********/
|
|
38
17
|
/**
|
|
39
18
|
* Toggle expanded prop value
|
|
40
19
|
*
|
|
@@ -44,20 +23,20 @@ export class MgMenuItem {
|
|
|
44
23
|
this.expanded = !this.expanded;
|
|
45
24
|
};
|
|
46
25
|
/**
|
|
47
|
-
* Does an
|
|
26
|
+
* Does an Element have given Status
|
|
48
27
|
*
|
|
49
|
-
* @param {
|
|
28
|
+
* @param {Element} element to parse
|
|
50
29
|
* @param {MgMenuItem['status']} status to check
|
|
51
30
|
* @returns {boolean} true if element with status is found
|
|
52
31
|
*/
|
|
53
|
-
this.
|
|
32
|
+
this.hasStatus = (element, status) => element.querySelector(`${this.name}[status="${status}"]`) !== null;
|
|
54
33
|
/**
|
|
55
34
|
* Is component contextual direction match the given direction
|
|
56
35
|
*
|
|
57
36
|
* @param {MgMenuItem['direction']} direction in parent menu
|
|
58
37
|
* @returns {boolean} true is direction match the direction propertie
|
|
59
38
|
*/
|
|
60
|
-
this.
|
|
39
|
+
this.isDirection = (direction) => this.direction === direction;
|
|
61
40
|
/************
|
|
62
41
|
* Handlers *
|
|
63
42
|
************/
|
|
@@ -68,23 +47,57 @@ export class MgMenuItem {
|
|
|
68
47
|
* @returns {void}
|
|
69
48
|
*/
|
|
70
49
|
this.handleElementCLick = (event) => {
|
|
71
|
-
|
|
50
|
+
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status.DISABLED) {
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
event.stopPropagation();
|
|
53
|
+
}
|
|
54
|
+
// toggle expanded when mg-menu-item has child items
|
|
72
55
|
if (this.hasChildren)
|
|
73
56
|
this.toggleExpanded();
|
|
74
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Handle popover element display-change event
|
|
60
|
+
*
|
|
61
|
+
* @param {CustomEvent} event popover display event
|
|
62
|
+
* @returns {void}
|
|
63
|
+
*/
|
|
64
|
+
this.handlePopoverDisplay = (event) => {
|
|
65
|
+
this.expanded = event.detail;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Update displayNotificationBadge
|
|
69
|
+
* current component notification badge have priority over the slot badge when submenu contain badge
|
|
70
|
+
*
|
|
71
|
+
* @returns {void} update displayNotificationBadge value
|
|
72
|
+
*/
|
|
73
|
+
this.updateDisplayNotificationBadge = () => {
|
|
74
|
+
const childMenu = this.element.querySelector('mg-menu');
|
|
75
|
+
this.displayNotificationBadge =
|
|
76
|
+
childMenu !== null &&
|
|
77
|
+
Array.from(childMenu.children).some((subItem) => subItem.querySelector('mg-badge') !== null && subItem.getAttribute('hidden') === null);
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Render slot
|
|
81
|
+
*
|
|
82
|
+
* @returns {HTMLElement} HTML Element
|
|
83
|
+
*/
|
|
84
|
+
this.renderSlot = () => h("slot", null);
|
|
85
|
+
this.href = undefined;
|
|
86
|
+
this.status = Status.VISIBLE;
|
|
87
|
+
this.expanded = false;
|
|
88
|
+
this.size = 'regular';
|
|
89
|
+
this.navigationButtonClassList = new ClassList([this.navigationButton]);
|
|
90
|
+
this.direction = undefined;
|
|
91
|
+
this.isInMainMenu = undefined;
|
|
92
|
+
this.hasChildren = false;
|
|
93
|
+
this.displayNotificationBadge = undefined;
|
|
75
94
|
}
|
|
76
95
|
validateStatus(newValue, oldValue) {
|
|
77
96
|
if (oldValue !== undefined) {
|
|
78
97
|
this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
|
|
79
98
|
}
|
|
80
99
|
this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
|
|
81
|
-
|
|
82
|
-
validateSize(newValue, oldValue) {
|
|
83
|
-
if (!sizes.includes(newValue)) {
|
|
84
|
-
throw new Error(`<${this.name}> prop "size" must be one of : ${sizes.join(', ')}.`);
|
|
85
|
-
}
|
|
86
|
-
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
87
|
-
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
100
|
+
this.statusChange.emit(newValue);
|
|
88
101
|
}
|
|
89
102
|
validateExpanded(newValue) {
|
|
90
103
|
if (typeof newValue !== 'boolean')
|
|
@@ -98,16 +111,20 @@ export class MgMenuItem {
|
|
|
98
111
|
item.expanded = false;
|
|
99
112
|
});
|
|
100
113
|
}
|
|
101
|
-
else if (
|
|
114
|
+
else if (this.hasStatus(this.element, Status.ACTIVE)) {
|
|
102
115
|
// - when expanded and contain an active item parents are expended too
|
|
103
116
|
subItems.forEach(item => {
|
|
104
|
-
if (this.
|
|
117
|
+
if (this.hasStatus(item, Status.ACTIVE)) {
|
|
105
118
|
item.expanded = true;
|
|
106
119
|
}
|
|
107
120
|
});
|
|
108
121
|
}
|
|
109
122
|
}
|
|
110
123
|
}
|
|
124
|
+
validateSize(newValue, oldValue) {
|
|
125
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
126
|
+
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
127
|
+
}
|
|
111
128
|
validateHasChildren(newValue) {
|
|
112
129
|
if (newValue && this.element.href !== undefined) {
|
|
113
130
|
throw new Error(`<${this.name}> prop "href" is unauthorizied when element is a parent.`);
|
|
@@ -122,13 +139,14 @@ export class MgMenuItem {
|
|
|
122
139
|
* @returns {void}
|
|
123
140
|
*/
|
|
124
141
|
componentWillLoad() {
|
|
125
|
-
// has children items that is NOT [slot=
|
|
142
|
+
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
126
143
|
// we store only matching elements
|
|
127
|
-
this.hasChildren = Array.from(this.element.children).
|
|
144
|
+
this.hasChildren = Array.from(this.element.children).some(child => !['image', 'information', 'label', 'metadata'].includes(child.getAttribute('slot')));
|
|
128
145
|
// Validate props
|
|
129
146
|
this.validateSize(this.size);
|
|
130
147
|
this.validateStatus(this.status);
|
|
131
148
|
this.validateExpanded(this.expanded);
|
|
149
|
+
this.badgeLabel = initLocales(this.element).messages.plusMenu.badgeLabel;
|
|
132
150
|
}
|
|
133
151
|
/**
|
|
134
152
|
* Check if component slots configuration
|
|
@@ -152,49 +170,67 @@ export class MgMenuItem {
|
|
|
152
170
|
// return a promise to process action only in the FIRST render().
|
|
153
171
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
154
172
|
return setTimeout(() => {
|
|
155
|
-
var _a
|
|
173
|
+
var _a;
|
|
156
174
|
// define menu-item context states
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.isInMainMenu = this.element.parentElement.
|
|
161
|
-
const hasNextMenuItem = ((_a = this.element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.nodeName) === 'MG-MENU-ITEM';
|
|
162
|
-
const hasPreviousMenuItem = ((_b = this.element.previousElementSibling) === null || _b === void 0 ? void 0 : _b.nodeName) === 'MG-MENU-ITEM';
|
|
163
|
-
// manage last menu item
|
|
164
|
-
if (!hasNextMenuItem && hasPreviousMenuItem && this.isdirection(Direction.HORIZONTAL)) {
|
|
165
|
-
this.element.setAttribute('data-style-position-last', '');
|
|
166
|
-
}
|
|
175
|
+
const menu = this.element.closest('mg-menu');
|
|
176
|
+
this.direction = this.element.getAttribute(OverflowBehaviorElements.MORE) !== null || menu === null ? Direction.HORIZONTAL : menu.direction;
|
|
177
|
+
this.size = menu === null || menu === void 0 ? void 0 : menu.size;
|
|
178
|
+
this.isInMainMenu = this.element.parentElement.closest('mg-menu-item') === null;
|
|
167
179
|
// when main menu item contain an active item it will get the active style
|
|
168
180
|
// AND if item is in vertical menu it will be expanded
|
|
169
|
-
|
|
181
|
+
const hasActiveChild = Array.from(this.element.children).some(element => this.hasStatus(element, Status.ACTIVE) && element.getAttribute('hidden') === null);
|
|
182
|
+
if (this.isInMainMenu && hasActiveChild) {
|
|
170
183
|
this.status = Status.ACTIVE;
|
|
171
|
-
this.expanded = this.
|
|
184
|
+
this.expanded = this.isDirection(Direction.VERTICAL);
|
|
172
185
|
}
|
|
173
186
|
// manage menu items style depending to parent menu horientation
|
|
174
187
|
this.element.setAttribute(`data-style-direction-${this.direction}`, '');
|
|
175
188
|
this.navigationButtonClassList.add(`${this.navigationButton}--${this.direction}`);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
189
|
+
this.updateDisplayNotificationBadge();
|
|
190
|
+
// manage all sub levels child menu-items level with data-level attribut
|
|
191
|
+
if (this.isDirection(Direction.VERTICAL)) {
|
|
192
|
+
Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
|
|
180
193
|
const itemLevel = Number(item.getAttribute('data-level')) || 1;
|
|
181
194
|
item.setAttribute('data-level', `${itemLevel + 1}`);
|
|
182
|
-
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
// manage first sub-level menu-items
|
|
198
|
+
const childItems = Array.from(((_a = this.element.querySelector('mg-menu')) === null || _a === void 0 ? void 0 : _a.children) || []).filter(item => item.nodeName === 'MG-MENU-ITEM');
|
|
199
|
+
childItems.forEach(item => {
|
|
200
|
+
// manage child menu listener
|
|
201
|
+
new MutationObserver(() => {
|
|
202
|
+
this.updateDisplayNotificationBadge();
|
|
203
|
+
}).observe(item, { attributes: true });
|
|
183
204
|
});
|
|
184
205
|
}, 0);
|
|
185
206
|
}
|
|
186
207
|
/**
|
|
187
|
-
* Render
|
|
208
|
+
* Render ineractive element
|
|
188
209
|
*
|
|
189
210
|
* @returns {HTMLElement} HTML Element
|
|
190
211
|
*/
|
|
191
|
-
|
|
212
|
+
renderInteractiveElement() {
|
|
192
213
|
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
193
|
-
return (h(
|
|
214
|
+
return (h(TagName, { href: this.href, class: this.navigationButtonClassList.join(), tabindex: [Status.DISABLED, Status.HIDDEN].includes(this.status) ? -1 : 0, disabled: this.status === Status.DISABLED, hidden: this.status === Status.HIDDEN, "aria-expanded": this.hasChildren && this.expanded.toString(), "aria-current": this.status === Status.ACTIVE && 'page', onClick: this.handleElementCLick }, h("slot", { name: "image" }), h("div", { class: `${this.navigationButton}-center` }, h("div", { class: `${this.navigationButton}-text-content` }, h("slot", { name: "label" }), !this.displayNotificationBadge && h("slot", { name: "information" }), this.displayNotificationBadge && (h("span", { class: "mg-menu-item__navigation-button-text-content-notification" }, h("mg-badge", { label: this.badgeLabel, value: "!", variant: "info", slot: "information" })))), this.size !== 'regular' && h("slot", { name: "metadata" })), this.hasChildren && this.href === undefined && (h("span", { class: {
|
|
194
215
|
[`${this.navigationButton}-chevron`]: true,
|
|
195
216
|
[`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
|
|
196
217
|
'mg-a11y-animation': true,
|
|
197
|
-
} }, h("mg-icon", { icon: "chevron-down" }))))
|
|
218
|
+
} }, h("mg-icon", { icon: "chevron-down" })))));
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Render
|
|
222
|
+
*
|
|
223
|
+
* @returns {HTMLElement} HTML Element
|
|
224
|
+
*/
|
|
225
|
+
render() {
|
|
226
|
+
const getContainerClasses = () => ({
|
|
227
|
+
[`${this.name}__collapse-container`]: true,
|
|
228
|
+
[`${this.name}__collapse-container--first-level`]: this.isInMainMenu && this.isDirection(Direction.HORIZONTAL),
|
|
229
|
+
});
|
|
230
|
+
return (h(Host, { role: "menuitem", "aria-haspopup": this.hasChildren.toString() }, this.isDirection(Direction.HORIZONTAL) && this.hasChildren && this.href === undefined ? (h("mg-popover", { display: this.expanded, placement: "bottom-start", arrowHide: true, "onDisplay-change": this.handlePopoverDisplay }, this.renderInteractiveElement(), h("div", { class: getContainerClasses(), slot: "content" }, this.renderSlot()))) : ([
|
|
231
|
+
this.renderInteractiveElement(),
|
|
232
|
+
h("div", { class: getContainerClasses(), hidden: !this.expanded }, this.renderSlot()),
|
|
233
|
+
])));
|
|
198
234
|
}
|
|
199
235
|
static get is() { return "mg-menu-item"; }
|
|
200
236
|
static get encapsulation() { return "shadow"; }
|
|
@@ -222,7 +258,7 @@ export class MgMenuItem {
|
|
|
222
258
|
"optional": false,
|
|
223
259
|
"docs": {
|
|
224
260
|
"tags": [],
|
|
225
|
-
"text": "Define menu-item
|
|
261
|
+
"text": "Define menu-item href\nwhen defined menu-item contain an anchor instead of button"
|
|
226
262
|
},
|
|
227
263
|
"attribute": "href",
|
|
228
264
|
"reflect": false
|
|
@@ -250,29 +286,6 @@ export class MgMenuItem {
|
|
|
250
286
|
"reflect": true,
|
|
251
287
|
"defaultValue": "Status.VISIBLE"
|
|
252
288
|
},
|
|
253
|
-
"size": {
|
|
254
|
-
"type": "string",
|
|
255
|
-
"mutable": false,
|
|
256
|
-
"complexType": {
|
|
257
|
-
"original": "MenuItemSizeType",
|
|
258
|
-
"resolved": "\"large\" | \"medium\" | \"regular\"",
|
|
259
|
-
"references": {
|
|
260
|
-
"MenuItemSizeType": {
|
|
261
|
-
"location": "import",
|
|
262
|
-
"path": "./mg-menu-item.conf"
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
"required": false,
|
|
267
|
-
"optional": false,
|
|
268
|
-
"docs": {
|
|
269
|
-
"tags": [],
|
|
270
|
-
"text": "Define menu-item size. Default: \"large\"."
|
|
271
|
-
},
|
|
272
|
-
"attribute": "size",
|
|
273
|
-
"reflect": false,
|
|
274
|
-
"defaultValue": "'large'"
|
|
275
|
-
},
|
|
276
289
|
"expanded": {
|
|
277
290
|
"type": "boolean",
|
|
278
291
|
"mutable": true,
|
|
@@ -295,23 +308,47 @@ export class MgMenuItem {
|
|
|
295
308
|
}
|
|
296
309
|
static get states() {
|
|
297
310
|
return {
|
|
311
|
+
"size": {},
|
|
298
312
|
"navigationButtonClassList": {},
|
|
299
313
|
"direction": {},
|
|
300
314
|
"isInMainMenu": {},
|
|
301
|
-
"hasChildren": {}
|
|
315
|
+
"hasChildren": {},
|
|
316
|
+
"displayNotificationBadge": {}
|
|
302
317
|
};
|
|
303
318
|
}
|
|
319
|
+
static get events() {
|
|
320
|
+
return [{
|
|
321
|
+
"method": "statusChange",
|
|
322
|
+
"name": "status-change",
|
|
323
|
+
"bubbles": true,
|
|
324
|
+
"cancelable": true,
|
|
325
|
+
"composed": true,
|
|
326
|
+
"docs": {
|
|
327
|
+
"tags": [],
|
|
328
|
+
"text": "Emited event when status change"
|
|
329
|
+
},
|
|
330
|
+
"complexType": {
|
|
331
|
+
"original": "MgMenuItem['status']",
|
|
332
|
+
"resolved": "Status.ACTIVE | Status.DISABLED | Status.HIDDEN | Status.VISIBLE",
|
|
333
|
+
"references": {
|
|
334
|
+
"MgMenuItem": {
|
|
335
|
+
"location": "global"
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}];
|
|
340
|
+
}
|
|
304
341
|
static get elementRef() { return "element"; }
|
|
305
342
|
static get watchers() {
|
|
306
343
|
return [{
|
|
307
344
|
"propName": "status",
|
|
308
345
|
"methodName": "validateStatus"
|
|
309
|
-
}, {
|
|
310
|
-
"propName": "size",
|
|
311
|
-
"methodName": "validateSize"
|
|
312
346
|
}, {
|
|
313
347
|
"propName": "expanded",
|
|
314
348
|
"methodName": "validateExpanded"
|
|
349
|
+
}, {
|
|
350
|
+
"propName": "size",
|
|
351
|
+
"methodName": "validateSize"
|
|
315
352
|
}, {
|
|
316
353
|
"propName": "hasChildren",
|
|
317
354
|
"methodName": "validateHasChildren"
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
2
|
export class MgDetails {
|
|
3
3
|
constructor() {
|
|
4
|
-
/**
|
|
5
|
-
* Hide summary element
|
|
6
|
-
*/
|
|
7
|
-
this.hideSummary = false;
|
|
8
|
-
/**
|
|
9
|
-
* Define if details are diplayed
|
|
10
|
-
*/
|
|
11
|
-
this.expanded = false;
|
|
12
4
|
/**
|
|
13
5
|
* Handle details toggle
|
|
14
6
|
*
|
|
@@ -17,6 +9,10 @@ export class MgDetails {
|
|
|
17
9
|
this.handleToggle = () => {
|
|
18
10
|
this.expanded = this.details.open;
|
|
19
11
|
};
|
|
12
|
+
this.toggleClosed = undefined;
|
|
13
|
+
this.toggleOpened = undefined;
|
|
14
|
+
this.hideSummary = false;
|
|
15
|
+
this.expanded = false;
|
|
20
16
|
}
|
|
21
17
|
validateTitles(newValue) {
|
|
22
18
|
if (newValue === undefined || newValue.trim() === '') {
|
|
@@ -5,28 +5,6 @@ export class MgForm {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
// Classes
|
|
7
7
|
this.classAllRequired = 'mg-form--all-required';
|
|
8
|
-
/**
|
|
9
|
-
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
10
|
-
* If not set, it will be created.
|
|
11
|
-
*/
|
|
12
|
-
this.identifier = createID('mg-form');
|
|
13
|
-
/**
|
|
14
|
-
* Input name
|
|
15
|
-
* If not set the value equals the identifier
|
|
16
|
-
*/
|
|
17
|
-
this.name = this.identifier;
|
|
18
|
-
/**
|
|
19
|
-
* Define if form is readonly
|
|
20
|
-
*/
|
|
21
|
-
this.readonly = false;
|
|
22
|
-
/**
|
|
23
|
-
* Define if form is disabled
|
|
24
|
-
*/
|
|
25
|
-
this.disabled = false;
|
|
26
|
-
/**
|
|
27
|
-
* Component classes
|
|
28
|
-
*/
|
|
29
|
-
this.classList = new ClassList(['mg-form']);
|
|
30
8
|
/**
|
|
31
9
|
* Define required message based on mg-inputs required elements
|
|
32
10
|
* Also
|
|
@@ -96,6 +74,14 @@ export class MgForm {
|
|
|
96
74
|
input.addEventListener('input-valid', this.checkValidity);
|
|
97
75
|
});
|
|
98
76
|
};
|
|
77
|
+
this.identifier = createID('mg-form');
|
|
78
|
+
this.name = this.identifier;
|
|
79
|
+
this.readonly = false;
|
|
80
|
+
this.disabled = false;
|
|
81
|
+
this.valid = undefined;
|
|
82
|
+
this.invalid = undefined;
|
|
83
|
+
this.classList = new ClassList(['mg-form']);
|
|
84
|
+
this.requiredMessage = undefined;
|
|
99
85
|
}
|
|
100
86
|
handleAttributeChange() {
|
|
101
87
|
this.setMgInputs();
|
package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.css
CHANGED
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
max-width: 47.5rem;
|
|
21
21
|
}
|
|
22
22
|
.mg-illustrated-message__illustration {
|
|
23
|
-
max-height:
|
|
23
|
+
max-height: 18.4rem;
|
|
24
24
|
}
|
|
25
25
|
.mg-illustrated-message__illustration ::slotted([slot=illustration]) {
|
|
26
26
|
width: auto;
|
|
27
27
|
height: auto;
|
|
28
28
|
max-width: 100%;
|
|
29
|
-
max-height:
|
|
29
|
+
max-height: 18.4rem;
|
|
30
30
|
}
|
|
31
31
|
.mg-illustrated-message__illustration.mg-illustrated-message__illustration--small {
|
|
32
32
|
max-height: 6rem;
|
package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js
CHANGED
|
@@ -2,13 +2,7 @@ import { h } from '@stencil/core';
|
|
|
2
2
|
import { isTagName } from '../../../utils/components.utils';
|
|
3
3
|
export class MgIllustratedMessage {
|
|
4
4
|
constructor() {
|
|
5
|
-
/**
|
|
6
|
-
* Define illustration size
|
|
7
|
-
*/
|
|
8
5
|
this.size = 'regular';
|
|
9
|
-
/**
|
|
10
|
-
* Define component orientation
|
|
11
|
-
*/
|
|
12
6
|
this.direction = 'vertical';
|
|
13
7
|
}
|
|
14
8
|
/*************
|
|
@@ -21,13 +15,14 @@ export class MgIllustratedMessage {
|
|
|
21
15
|
*/
|
|
22
16
|
componentDidLoad() {
|
|
23
17
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
24
|
-
const
|
|
18
|
+
const slottedIllustrations = this.element.querySelectorAll('[slot="illustration"]');
|
|
25
19
|
if (!isTagName(this.element.querySelector('[slot="title"]'), headingTags)) {
|
|
26
20
|
throw new Error(`<mg-illustrated-message> Slotted title must be a heading: ${headingTags.join(', ')}`);
|
|
27
21
|
}
|
|
28
|
-
else if (
|
|
29
|
-
throw new Error(
|
|
22
|
+
else if (slottedIllustrations.length !== 1) {
|
|
23
|
+
throw new Error('<mg-illustrated-message> Slotted illustration must be present and unique.');
|
|
30
24
|
}
|
|
25
|
+
slottedIllustrations[0].setAttribute('aria-hidden', 'true');
|
|
31
26
|
}
|
|
32
27
|
/**
|
|
33
28
|
* Render
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--mg-card-padding: 0;
|
|
3
|
+
--mg-card-border-radius: var(--mg-message-border-radius);
|
|
4
|
+
--mg-card-border: none;
|
|
5
|
+
--mg-card-overflow: hidden;
|
|
6
|
+
}
|
|
7
|
+
|
|
1
8
|
.mg-message {
|
|
2
9
|
display: inline-block;
|
|
3
|
-
position: relative;
|
|
4
|
-
box-sizing: border-box;
|
|
5
10
|
min-height: var(--default-size);
|
|
6
|
-
overflow: hidden;
|
|
7
|
-
background-color: white;
|
|
8
|
-
border-radius: var(--mg-message-border-radius);
|
|
9
|
-
box-shadow: var(--box-shadow);
|
|
10
11
|
}
|
|
11
|
-
.mg-
|
|
12
|
-
content: "";
|
|
12
|
+
.mg-message__bar {
|
|
13
13
|
position: absolute;
|
|
14
14
|
top: 0;
|
|
15
15
|
left: 0;
|
|
16
16
|
width: 0.3rem;
|
|
17
17
|
height: 100%;
|
|
18
18
|
}
|
|
19
|
-
.mg-message.mg-message--info
|
|
19
|
+
.mg-message.mg-message--info .mg-message__bar {
|
|
20
20
|
background-color: hsl(var(--color-info));
|
|
21
21
|
}
|
|
22
22
|
.mg-message.mg-message--info .mg-message__icon {
|
|
23
23
|
color: hsl(var(--color-info));
|
|
24
24
|
}
|
|
25
|
-
.mg-message.mg-message--warning
|
|
25
|
+
.mg-message.mg-message--warning .mg-message__bar {
|
|
26
26
|
background-color: hsl(var(--color-warning));
|
|
27
27
|
}
|
|
28
28
|
.mg-message.mg-message--warning .mg-message__icon {
|
|
29
29
|
color: hsl(var(--color-warning));
|
|
30
30
|
}
|
|
31
|
-
.mg-message.mg-message--success
|
|
31
|
+
.mg-message.mg-message--success .mg-message__bar {
|
|
32
32
|
background-color: hsl(var(--color-success));
|
|
33
33
|
}
|
|
34
34
|
.mg-message.mg-message--success .mg-message__icon {
|
|
35
35
|
color: hsl(var(--color-success));
|
|
36
36
|
}
|
|
37
|
-
.mg-message.mg-message--danger
|
|
37
|
+
.mg-message.mg-message--danger .mg-message__bar {
|
|
38
38
|
background-color: hsl(var(--color-danger));
|
|
39
39
|
}
|
|
40
40
|
.mg-message.mg-message--danger .mg-message__icon {
|
|
41
41
|
color: hsl(var(--color-danger));
|
|
42
42
|
}
|
|
43
43
|
.mg-message.mg-message--close-button {
|
|
44
|
-
padding
|
|
44
|
+
--mg-card-padding: 0 3.4rem 0 0;
|
|
45
45
|
}
|
|
46
46
|
.mg-message.mg-message--hide {
|
|
47
47
|
display: none;
|
|
@@ -50,14 +50,12 @@
|
|
|
50
50
|
margin: 0;
|
|
51
51
|
padding: 0;
|
|
52
52
|
}
|
|
53
|
-
|
|
54
53
|
.mg-message__icon {
|
|
55
54
|
position: absolute;
|
|
56
55
|
top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
|
|
57
56
|
left: 1.3rem;
|
|
58
57
|
line-height: 1;
|
|
59
58
|
}
|
|
60
|
-
|
|
61
59
|
.mg-message__content {
|
|
62
60
|
display: flex;
|
|
63
61
|
flex-wrap: wrap;
|
|
@@ -65,28 +63,31 @@
|
|
|
65
63
|
align-content: stretch;
|
|
66
64
|
padding: 0 1rem 0 3.8rem;
|
|
67
65
|
}
|
|
68
|
-
|
|
69
66
|
.mg-message__content-slot {
|
|
70
67
|
flex-grow: 1;
|
|
71
68
|
margin: 0.84rem 0;
|
|
72
69
|
}
|
|
73
|
-
|
|
74
70
|
.mg-message__content-separator {
|
|
75
71
|
display: inline-block;
|
|
76
72
|
width: 4.5rem;
|
|
77
73
|
height: 0;
|
|
78
74
|
}
|
|
79
|
-
|
|
80
75
|
.mg-message__content-actions-slot {
|
|
81
76
|
padding: 1rem 0;
|
|
82
77
|
text-align: right;
|
|
83
78
|
}
|
|
84
|
-
|
|
85
79
|
.mg-message__close-button {
|
|
86
80
|
position: absolute;
|
|
87
81
|
top: 0;
|
|
88
82
|
right: 0;
|
|
89
83
|
}
|
|
84
|
+
.mg-message ::slotted(*) {
|
|
85
|
+
--mg-card-border: var(--mg-card-border-default);
|
|
86
|
+
--mg-card-padding: var(--mg-card-padding-default);
|
|
87
|
+
--mg-card-border-radius: var(--mg-card-border-radius-default);
|
|
88
|
+
--mg-card-background: var(--mg-card-background-default);
|
|
89
|
+
--mg-card-box-shadow: var(--mg-card-box-shadow-default);
|
|
90
|
+
}
|
|
90
91
|
|
|
91
92
|
.mg-message,
|
|
92
93
|
mg-message {
|