@mgdis/mg-components 5.5.0 → 5.7.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-c3450336.js → index-5e7ede97.js} +120 -4
- package/dist/cjs/loader.cjs.js +4 -3
- package/dist/cjs/{mg-badge_30.cjs.entry.js → mg-action-more_31.cjs.entry.js} +1223 -547
- package/dist/cjs/mg-components.cjs.js +7 -3
- package/dist/collection/collection-manifest.json +6 -5
- 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 +4 -4
- package/dist/collection/components/atoms/mg-button/mg-button.css +9 -22
- package/dist/collection/components/atoms/mg-button/mg-button.js +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.css +13 -6
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +38 -28
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +3 -3
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +6 -6
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +4 -4
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +2 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +14 -17
- package/dist/collection/components/molecules/inputs/MgInput.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +4 -3
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +3 -2
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +5 -2
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +4 -3
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +2 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +8 -4
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +4 -4
- 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 +141 -19
- 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 +48 -21
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +139 -71
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.css +38 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +252 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +2 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +4 -3
- package/dist/collection/components/molecules/mg-message/mg-message.css +7 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +54 -13
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +8 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +19 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +7 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +72 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +64 -7
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +33 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +12 -7
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +105 -57
- package/dist/collection/locales/en/messages.json +10 -1
- package/dist/collection/locales/fr/messages.json +10 -1
- package/dist/collection/locales/index.js +3 -26
- 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/mg-icon-animation.scss +6 -0
- package/dist/collection/styles/navigation-button.scss +77 -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 +151 -0
- package/dist/collection/utils/components.utils.js +52 -0
- package/dist/collection/utils/locale.utils.js +28 -6
- package/dist/collection/utils/unit.test.utils.js +65 -32
- package/dist/collection/variables.css +11 -10
- package/dist/components/MgInput.js +6 -1
- package/dist/components/components.utils.js +53 -1
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.js +2 -1
- package/dist/components/index2.js +79 -20
- package/dist/components/mg-action-more.d.ts +11 -0
- package/dist/components/mg-action-more.js +215 -0
- package/dist/components/mg-badge2.js +5 -5
- package/dist/components/mg-button2.js +2 -2
- package/dist/components/mg-card2.js +1 -1
- package/dist/components/mg-form.js +2 -2
- package/dist/components/mg-icon2.js +41 -31
- package/dist/components/mg-illustrated-message.js +4 -3
- package/dist/components/mg-input-checkbox.js +3 -3
- package/dist/components/mg-input-date.js +7 -5
- package/dist/components/mg-input-numeric.js +3 -4
- package/dist/components/mg-input-password.js +1 -1
- package/dist/components/mg-input-radio.js +2 -2
- package/dist/components/mg-input-select2.js +9 -5
- package/dist/components/mg-input-text2.js +1 -1
- package/dist/components/mg-input-textarea.js +2 -2
- package/dist/components/mg-input-toggle.js +1 -1
- package/dist/components/mg-menu-item.js +1 -253
- package/dist/components/mg-menu-item2.js +520 -0
- package/dist/components/mg-menu.js +1 -129
- package/dist/components/mg-menu2.js +247 -0
- package/dist/components/mg-message.js +55 -14
- package/dist/components/mg-modal.js +1 -1
- package/dist/components/mg-pagination.js +3 -1
- package/dist/components/mg-panel.js +3 -3
- package/dist/components/mg-popover.js +1 -190
- package/dist/components/mg-popover2.js +226 -0
- package/dist/components/mg-skip-links.js +16 -2
- package/dist/components/mg-tabs.js +104 -55
- package/dist/components/mg-tag.js +5 -5
- package/dist/components/mg-tooltip2.js +15 -18
- package/dist/esm/{index-78edde1d.js → index-03cceb11.js} +120 -5
- package/dist/esm/loader.js +4 -3
- package/dist/esm/{mg-badge_30.entry.js → mg-action-more_31.entry.js} +1223 -548
- package/dist/esm/mg-components.js +4 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/mg-components/locales/en/messages.json +10 -1
- package/dist/mg-components/locales/fr/messages.json +10 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-4cfd5423.entry.js +1 -0
- package/dist/mg-components/p-e126dd84.js +2 -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/mg-icon-animation.scss +6 -0
- package/dist/mg-components/styles/navigation-button.scss +77 -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 +11 -10
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +1 -1
- 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-textarea/mg-input-textarea.d.ts +1 -1
- 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/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/mg-menu-item.conf.d.ts +0 -8
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +61 -15
- package/dist/types/components/molecules/mg-action-more/mg-action-more.conf.d.ts +42 -0
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +81 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +21 -4
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +4 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +13 -0
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.conf.d.ts +1 -1
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +15 -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 +22 -12
- package/dist/types/components.d.ts +98 -12
- package/dist/types/locales/index.d.ts +21 -10
- package/dist/types/stencil-public-runtime.d.ts +48 -3
- package/dist/types/utils/behaviors.utils.d.ts +77 -0
- package/dist/types/utils/components.utils.d.ts +14 -0
- package/dist/types/utils/locale.utils.d.ts +16 -3
- package/dist/types/utils/unit.test.utils.d.ts +68 -14
- package/loader/index.d.ts +9 -0
- package/package.json +28 -27
- package/readme.md +22 -31
- package/dist/.storybook/utils.js +0 -24
- package/dist/collection/components/atoms/mg-badge/doc/mg-badge.stories.js +0 -27
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +0 -38
- package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +0 -18
- package/dist/collection/components/atoms/mg-character-left/doc/mg-character-left.stories.js +0 -20
- package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +0 -18
- package/dist/collection/components/atoms/mg-icon/doc/mg-icon.stories.js +0 -41
- package/dist/collection/components/atoms/mg-input-title/doc/mg-input-title.stories.js +0 -21
- package/dist/collection/components/atoms/mg-tag/doc/mg-tag.stories.js +0 -22
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -50
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/doc/mg-input-checkbox.stories.js +0 -50
- package/dist/collection/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.js +0 -43
- package/dist/collection/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.js +0 -68
- package/dist/collection/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.js +0 -46
- package/dist/collection/components/molecules/inputs/mg-input-radio/doc/mg-input-radio.stories.js +0 -59
- package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +0 -77
- package/dist/collection/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.js +0 -110
- package/dist/collection/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.js +0 -54
- package/dist/collection/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.js +0 -51
- package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +0 -87
- package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +0 -39
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +0 -24
- package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +0 -47
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +0 -19
- package/dist/collection/components/molecules/mg-message/doc/mg-message.stories.js +0 -39
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +0 -39
- package/dist/collection/components/molecules/mg-pagination/doc/mg-pagination.stories.js +0 -20
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +0 -22
- package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -34
- package/dist/collection/components/molecules/mg-skip-links/doc/mg-skip-links.stories.js +0 -24
- package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +0 -51
- package/dist/collection/stories/grids.stories.js +0 -7
- package/dist/collection/stories/helpers.stories.js +0 -23
- package/dist/collection/stories/icons.stories.js +0 -25
- package/dist/collection/stories/typography.stories.js +0 -24
- package/dist/components/locale.utils.js +0 -40
- package/dist/components/mg-menu.conf.js +0 -10
- package/dist/mg-components/p-125c54ca.js +0 -2
- package/dist/mg-components/p-4961c96c.entry.js +0 -1
- package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +0 -13
- package/dist/types/components/atoms/mg-button/doc/mg-button.stories.d.ts +0 -16
- package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-character-left/doc/mg-character-left.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-icon/doc/mg-icon.stories.d.ts +0 -26
- package/dist/types/components/atoms/mg-input-title/doc/mg-input-title.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tag/doc/mg-tag.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -18
- package/dist/types/components/molecules/inputs/mg-input-checkbox/doc/mg-input-checkbox.stories.d.ts +0 -11
- package/dist/types/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.d.ts +0 -12
- package/dist/types/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.d.ts +0 -32
- package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +0 -22
- package/dist/types/components/molecules/inputs/mg-input-radio/doc/mg-input-radio.stories.d.ts +0 -20
- package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +0 -34
- package/dist/types/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.d.ts +0 -39
- package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +0 -19
- package/dist/types/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.d.ts +0 -12
- package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +0 -17
- package/dist/types/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.d.ts +0 -12
- package/dist/types/components/molecules/mg-details/doc/mg-details.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-form/doc/mg-form.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-message/doc/mg-message.stories.d.ts +0 -26
- package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +0 -13
- package/dist/types/components/molecules/mg-pagination/doc/mg-pagination.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -22
- package/dist/types/components/molecules/mg-skip-links/doc/mg-skip-links.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +0 -20
- package/dist/types/home/runner/work/mg-components/mg-components/.stencil/.storybook/utils.d.ts +0 -1
- package/dist/types/stories/grids.stories.d.ts +0 -5
- package/dist/types/stories/helpers.stories.d.ts +0 -13
- package/dist/types/stories/icons.stories.d.ts +0 -13
- package/dist/types/stories/typography.stories.d.ts +0 -5
|
@@ -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,9 +11,9 @@ export class MgMenuItem {
|
|
|
9
11
|
************/
|
|
10
12
|
this.name = 'mg-menu-item';
|
|
11
13
|
this.navigationButton = `${this.name}__navigation-button`;
|
|
12
|
-
|
|
14
|
+
/***********
|
|
13
15
|
* Methods *
|
|
14
|
-
|
|
16
|
+
**********/
|
|
15
17
|
/**
|
|
16
18
|
* Toggle expanded prop value
|
|
17
19
|
*
|
|
@@ -21,20 +23,20 @@ export class MgMenuItem {
|
|
|
21
23
|
this.expanded = !this.expanded;
|
|
22
24
|
};
|
|
23
25
|
/**
|
|
24
|
-
* Does an
|
|
26
|
+
* Does an Element have given Status
|
|
25
27
|
*
|
|
26
|
-
* @param {
|
|
28
|
+
* @param {HTMLMgMenuItemElement} mgMenuItemElement to parse
|
|
27
29
|
* @param {MgMenuItem['status']} status to check
|
|
28
30
|
* @returns {boolean} true if element with status is found
|
|
29
31
|
*/
|
|
30
|
-
this.
|
|
32
|
+
this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
|
|
31
33
|
/**
|
|
32
34
|
* Is component contextual direction match the given direction
|
|
33
35
|
*
|
|
34
36
|
* @param {MgMenuItem['direction']} direction in parent menu
|
|
35
37
|
* @returns {boolean} true is direction match the direction propertie
|
|
36
38
|
*/
|
|
37
|
-
this.
|
|
39
|
+
this.isDirection = (direction) => this.direction === direction;
|
|
38
40
|
/************
|
|
39
41
|
* Handlers *
|
|
40
42
|
************/
|
|
@@ -45,7 +47,7 @@ export class MgMenuItem {
|
|
|
45
47
|
* @returns {void}
|
|
46
48
|
*/
|
|
47
49
|
this.handleElementCLick = (event) => {
|
|
48
|
-
if (this.hasChildren || this.status === Status.DISABLED) {
|
|
50
|
+
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status.DISABLED) {
|
|
49
51
|
event.preventDefault();
|
|
50
52
|
event.stopPropagation();
|
|
51
53
|
}
|
|
@@ -53,27 +55,60 @@ export class MgMenuItem {
|
|
|
53
55
|
if (this.hasChildren)
|
|
54
56
|
this.toggleExpanded();
|
|
55
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
|
+
* Method to control if one of component children have active status
|
|
81
|
+
*
|
|
82
|
+
* @returns {boolean} truthy if component has active child
|
|
83
|
+
*/
|
|
84
|
+
this.hasActiveChild = () => {
|
|
85
|
+
var _a;
|
|
86
|
+
return Array.from(((_a = this.element.querySelector('mg-menu')) === null || _a === void 0 ? void 0 : _a.children) || [])
|
|
87
|
+
.filter(element => element.nodeName === 'MG-MENU-ITEM')
|
|
88
|
+
.some((element) => this.hasStatus(element, Status.ACTIVE) && element.getAttribute('hidden') === null);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Render slot
|
|
92
|
+
*
|
|
93
|
+
* @returns {HTMLElement} HTML Element
|
|
94
|
+
*/
|
|
95
|
+
this.renderSlot = () => h("slot", null);
|
|
56
96
|
this.href = undefined;
|
|
57
97
|
this.status = Status.VISIBLE;
|
|
58
|
-
this.size = 'large';
|
|
59
98
|
this.expanded = false;
|
|
99
|
+
this.size = 'regular';
|
|
60
100
|
this.navigationButtonClassList = new ClassList([this.navigationButton]);
|
|
61
101
|
this.direction = undefined;
|
|
62
102
|
this.isInMainMenu = undefined;
|
|
63
103
|
this.hasChildren = false;
|
|
104
|
+
this.displayNotificationBadge = undefined;
|
|
64
105
|
}
|
|
65
106
|
validateStatus(newValue, oldValue) {
|
|
66
107
|
if (oldValue !== undefined) {
|
|
67
108
|
this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
|
|
68
109
|
}
|
|
69
110
|
this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
|
|
70
|
-
|
|
71
|
-
validateSize(newValue, oldValue) {
|
|
72
|
-
if (!sizes.includes(newValue)) {
|
|
73
|
-
throw new Error(`<${this.name}> prop "size" must be one of : ${sizes.join(', ')}.`);
|
|
74
|
-
}
|
|
75
|
-
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
76
|
-
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
111
|
+
this.statusChange.emit(newValue);
|
|
77
112
|
}
|
|
78
113
|
validateExpanded(newValue) {
|
|
79
114
|
if (typeof newValue !== 'boolean')
|
|
@@ -87,16 +122,20 @@ export class MgMenuItem {
|
|
|
87
122
|
item.expanded = false;
|
|
88
123
|
});
|
|
89
124
|
}
|
|
90
|
-
else if (
|
|
125
|
+
else if (this.element.querySelector(`${this.name}[status="${Status.ACTIVE}"]`) !== null) {
|
|
91
126
|
// - when expanded and contain an active item parents are expended too
|
|
92
127
|
subItems.forEach(item => {
|
|
93
|
-
if (this.
|
|
128
|
+
if (this.hasStatus(item, Status.ACTIVE)) {
|
|
94
129
|
item.expanded = true;
|
|
95
130
|
}
|
|
96
131
|
});
|
|
97
132
|
}
|
|
98
133
|
}
|
|
99
134
|
}
|
|
135
|
+
validateSize(newValue, oldValue) {
|
|
136
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
137
|
+
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
138
|
+
}
|
|
100
139
|
validateHasChildren(newValue) {
|
|
101
140
|
if (newValue && this.element.href !== undefined) {
|
|
102
141
|
throw new Error(`<${this.name}> prop "href" is unauthorizied when element is a parent.`);
|
|
@@ -111,13 +150,14 @@ export class MgMenuItem {
|
|
|
111
150
|
* @returns {void}
|
|
112
151
|
*/
|
|
113
152
|
componentWillLoad() {
|
|
114
|
-
// has children items that is NOT [slot=
|
|
153
|
+
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
115
154
|
// we store only matching elements
|
|
116
|
-
this.hasChildren = Array.from(this.element.children).
|
|
155
|
+
this.hasChildren = Array.from(this.element.children).some(child => !['image', 'information', 'label', 'metadata'].includes(child.getAttribute('slot')));
|
|
117
156
|
// Validate props
|
|
118
157
|
this.validateSize(this.size);
|
|
119
158
|
this.validateStatus(this.status);
|
|
120
159
|
this.validateExpanded(this.expanded);
|
|
160
|
+
this.badgeLabel = initLocales(this.element).messages.plusMenu.badgeLabel;
|
|
121
161
|
}
|
|
122
162
|
/**
|
|
123
163
|
* Check if component slots configuration
|
|
@@ -141,49 +181,76 @@ export class MgMenuItem {
|
|
|
141
181
|
// return a promise to process action only in the FIRST render().
|
|
142
182
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
143
183
|
return setTimeout(() => {
|
|
144
|
-
var _a
|
|
184
|
+
var _a;
|
|
145
185
|
// define menu-item context states
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.isInMainMenu = this.element.parentElement.
|
|
150
|
-
const hasNextMenuItem = ((_a = this.element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.nodeName) === 'MG-MENU-ITEM';
|
|
151
|
-
const hasPreviousMenuItem = ((_b = this.element.previousElementSibling) === null || _b === void 0 ? void 0 : _b.nodeName) === 'MG-MENU-ITEM';
|
|
152
|
-
// manage last menu item
|
|
153
|
-
if (!hasNextMenuItem && hasPreviousMenuItem && this.isdirection(Direction.HORIZONTAL)) {
|
|
154
|
-
this.element.setAttribute('data-style-position-last', '');
|
|
155
|
-
}
|
|
186
|
+
const menu = this.element.closest('mg-menu');
|
|
187
|
+
this.direction = this.element.getAttribute(OverflowBehaviorElements.MORE) !== null || menu === null ? Direction.HORIZONTAL : menu.direction;
|
|
188
|
+
this.size = menu === null || menu === void 0 ? void 0 : menu.size;
|
|
189
|
+
this.isInMainMenu = this.element.parentElement.closest('mg-menu-item') === null;
|
|
156
190
|
// when main menu item contain an active item it will get the active style
|
|
157
191
|
// AND if item is in vertical menu it will be expanded
|
|
158
|
-
if (this.
|
|
192
|
+
if (this.hasActiveChild()) {
|
|
159
193
|
this.status = Status.ACTIVE;
|
|
160
|
-
|
|
194
|
+
if (this.isInMainMenu)
|
|
195
|
+
this.expanded = this.isDirection(Direction.VERTICAL);
|
|
161
196
|
}
|
|
162
197
|
// manage menu items style depending to parent menu horientation
|
|
163
198
|
this.element.setAttribute(`data-style-direction-${this.direction}`, '');
|
|
164
199
|
this.navigationButtonClassList.add(`${this.navigationButton}--${this.direction}`);
|
|
165
|
-
|
|
166
|
-
|
|
200
|
+
this.updateDisplayNotificationBadge();
|
|
201
|
+
// manage all sub levels child menu-items level with data-level attribut
|
|
202
|
+
if (this.isDirection(Direction.VERTICAL)) {
|
|
203
|
+
Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
|
|
204
|
+
item.dataset.level = `${(Number(item.dataset.level) || 1) + 1}`;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// manage first sub-level menu-items
|
|
208
|
+
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');
|
|
167
209
|
childItems.forEach(item => {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
210
|
+
const updateStatus = () => {
|
|
211
|
+
if (![Status.HIDDEN, Status.DISABLED].includes(this.status)) {
|
|
212
|
+
this.status = this.hasActiveChild() ? Status.ACTIVE : Status.VISIBLE;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
// manage child menu listener
|
|
216
|
+
item.addEventListener('status-change', () => {
|
|
217
|
+
updateStatus();
|
|
218
|
+
});
|
|
219
|
+
new MutationObserver(mutationsList => {
|
|
220
|
+
if (mutationsList.some(mutation => mutation.attributeName === 'hidden'))
|
|
221
|
+
updateStatus();
|
|
222
|
+
this.updateDisplayNotificationBadge();
|
|
223
|
+
}).observe(item, { attributes: true });
|
|
172
224
|
});
|
|
173
225
|
}, 0);
|
|
174
226
|
}
|
|
175
227
|
/**
|
|
176
|
-
* Render
|
|
228
|
+
* Render ineractive element
|
|
177
229
|
*
|
|
178
230
|
* @returns {HTMLElement} HTML Element
|
|
179
231
|
*/
|
|
180
|
-
|
|
232
|
+
renderInteractiveElement() {
|
|
181
233
|
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
182
|
-
return (h(
|
|
234
|
+
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: "text-color", slot: "information" })))), this.size !== 'regular' && h("slot", { name: "metadata" })), this.hasChildren && this.href === undefined && (h("span", { class: {
|
|
183
235
|
[`${this.navigationButton}-chevron`]: true,
|
|
184
236
|
[`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
|
|
185
237
|
'mg-a11y-animation': true,
|
|
186
|
-
} }, h("mg-icon", { icon: "chevron-down" }))))
|
|
238
|
+
} }, h("mg-icon", { icon: "chevron-down" })))));
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Render
|
|
242
|
+
*
|
|
243
|
+
* @returns {HTMLElement} HTML Element
|
|
244
|
+
*/
|
|
245
|
+
render() {
|
|
246
|
+
const getContainerClasses = () => ({
|
|
247
|
+
[`${this.name}__collapse-container`]: true,
|
|
248
|
+
[`${this.name}__collapse-container--first-level`]: this.isInMainMenu && this.isDirection(Direction.HORIZONTAL),
|
|
249
|
+
});
|
|
250
|
+
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()))) : ([
|
|
251
|
+
this.renderInteractiveElement(),
|
|
252
|
+
h("div", { key: "vertical-container", class: getContainerClasses(), hidden: !this.expanded }, this.renderSlot()),
|
|
253
|
+
])));
|
|
187
254
|
}
|
|
188
255
|
static get is() { return "mg-menu-item"; }
|
|
189
256
|
static get encapsulation() { return "shadow"; }
|
|
@@ -211,7 +278,7 @@ export class MgMenuItem {
|
|
|
211
278
|
"optional": false,
|
|
212
279
|
"docs": {
|
|
213
280
|
"tags": [],
|
|
214
|
-
"text": "Define menu-item
|
|
281
|
+
"text": "Define menu-item href\nwhen defined menu-item contain an anchor instead of button"
|
|
215
282
|
},
|
|
216
283
|
"attribute": "href",
|
|
217
284
|
"reflect": false
|
|
@@ -239,29 +306,6 @@ export class MgMenuItem {
|
|
|
239
306
|
"reflect": true,
|
|
240
307
|
"defaultValue": "Status.VISIBLE"
|
|
241
308
|
},
|
|
242
|
-
"size": {
|
|
243
|
-
"type": "string",
|
|
244
|
-
"mutable": false,
|
|
245
|
-
"complexType": {
|
|
246
|
-
"original": "MenuItemSizeType",
|
|
247
|
-
"resolved": "\"large\" | \"medium\" | \"regular\"",
|
|
248
|
-
"references": {
|
|
249
|
-
"MenuItemSizeType": {
|
|
250
|
-
"location": "import",
|
|
251
|
-
"path": "./mg-menu-item.conf"
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
"required": false,
|
|
256
|
-
"optional": false,
|
|
257
|
-
"docs": {
|
|
258
|
-
"tags": [],
|
|
259
|
-
"text": "Define menu-item size. Default: \"large\"."
|
|
260
|
-
},
|
|
261
|
-
"attribute": "size",
|
|
262
|
-
"reflect": false,
|
|
263
|
-
"defaultValue": "'large'"
|
|
264
|
-
},
|
|
265
309
|
"expanded": {
|
|
266
310
|
"type": "boolean",
|
|
267
311
|
"mutable": true,
|
|
@@ -284,23 +328,47 @@ export class MgMenuItem {
|
|
|
284
328
|
}
|
|
285
329
|
static get states() {
|
|
286
330
|
return {
|
|
331
|
+
"size": {},
|
|
287
332
|
"navigationButtonClassList": {},
|
|
288
333
|
"direction": {},
|
|
289
334
|
"isInMainMenu": {},
|
|
290
|
-
"hasChildren": {}
|
|
335
|
+
"hasChildren": {},
|
|
336
|
+
"displayNotificationBadge": {}
|
|
291
337
|
};
|
|
292
338
|
}
|
|
339
|
+
static get events() {
|
|
340
|
+
return [{
|
|
341
|
+
"method": "statusChange",
|
|
342
|
+
"name": "status-change",
|
|
343
|
+
"bubbles": true,
|
|
344
|
+
"cancelable": true,
|
|
345
|
+
"composed": true,
|
|
346
|
+
"docs": {
|
|
347
|
+
"tags": [],
|
|
348
|
+
"text": "Emited event when status change"
|
|
349
|
+
},
|
|
350
|
+
"complexType": {
|
|
351
|
+
"original": "MgMenuItem['status']",
|
|
352
|
+
"resolved": "Status.ACTIVE | Status.DISABLED | Status.HIDDEN | Status.VISIBLE",
|
|
353
|
+
"references": {
|
|
354
|
+
"MgMenuItem": {
|
|
355
|
+
"location": "global"
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}];
|
|
360
|
+
}
|
|
293
361
|
static get elementRef() { return "element"; }
|
|
294
362
|
static get watchers() {
|
|
295
363
|
return [{
|
|
296
364
|
"propName": "status",
|
|
297
365
|
"methodName": "validateStatus"
|
|
298
|
-
}, {
|
|
299
|
-
"propName": "size",
|
|
300
|
-
"methodName": "validateSize"
|
|
301
366
|
}, {
|
|
302
367
|
"propName": "expanded",
|
|
303
368
|
"methodName": "validateExpanded"
|
|
369
|
+
}, {
|
|
370
|
+
"propName": "size",
|
|
371
|
+
"methodName": "validateSize"
|
|
304
372
|
}, {
|
|
305
373
|
"propName": "hasChildren",
|
|
306
374
|
"methodName": "validateHasChildren"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A11Y
|
|
3
|
+
*/
|
|
4
|
+
.sr-only {
|
|
5
|
+
border: 0 !important;
|
|
6
|
+
clip: rect(1px, 1px, 1px, 1px) !important;
|
|
7
|
+
-webkit-clip-path: inset(50%) !important;
|
|
8
|
+
clip-path: inset(50%) !important;
|
|
9
|
+
height: 1px !important;
|
|
10
|
+
margin: -1px !important;
|
|
11
|
+
overflow: hidden !important;
|
|
12
|
+
padding: 0 !important;
|
|
13
|
+
position: absolute !important;
|
|
14
|
+
width: 1px !important;
|
|
15
|
+
white-space: nowrap !important;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
*:focus:not(:focus-visible) {
|
|
19
|
+
outline: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@media (prefers-reduced-motion) {
|
|
23
|
+
.mg-a11y-animation {
|
|
24
|
+
animation: none !important;
|
|
25
|
+
transition: none !important;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
:host {
|
|
29
|
+
--mg-popover-padding-vertical: 1rem;
|
|
30
|
+
--mg-popover-padding-horizontal: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.mg-action-more__chevron {
|
|
34
|
+
transition: 200ms;
|
|
35
|
+
}
|
|
36
|
+
.mg-action-more__chevron--rotate.mg-action-more__chevron {
|
|
37
|
+
transform: rotate(180deg);
|
|
38
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { h, Host } from '@stencil/core';
|
|
2
|
+
import { initLocales } from '../../../locales';
|
|
3
|
+
import { Status } from '../menu/mg-menu-item/mg-menu-item.conf';
|
|
4
|
+
import { Direction } from '../menu/mg-menu/mg-menu.conf';
|
|
5
|
+
import { createID } from '../../../utils/components.utils';
|
|
6
|
+
/**
|
|
7
|
+
* MgActionMore['items'] type guard
|
|
8
|
+
*
|
|
9
|
+
* @param {unknown} prop commponent items prop
|
|
10
|
+
* @returns {boolean} return true if type is valid
|
|
11
|
+
*/
|
|
12
|
+
const isMgActionMoreItems = (prop) => {
|
|
13
|
+
const items = prop;
|
|
14
|
+
return typeof items === 'object' && items.every(item => typeof item === 'object' && typeof item.label === 'string' && typeof item.mouseEventHandler === 'function');
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* MgActionMore['button'] type guard
|
|
18
|
+
*
|
|
19
|
+
* @param {unknown} prop commponent button prop
|
|
20
|
+
* @returns {boolean} return true if type is valid
|
|
21
|
+
*/
|
|
22
|
+
const isMgActionMoreButton = (prop) => {
|
|
23
|
+
const button = prop;
|
|
24
|
+
return typeof button === 'object' && typeof button.variant === 'string' && typeof button.isIcon === 'boolean';
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* MgActionMore['icon'] type guard
|
|
28
|
+
*
|
|
29
|
+
* @param {unknown} prop commponent icon prop
|
|
30
|
+
* @returns {boolean} return true if type is valid
|
|
31
|
+
*/
|
|
32
|
+
const isMgActionMoreIcon = (prop) => {
|
|
33
|
+
const icon = prop;
|
|
34
|
+
return typeof icon === 'object' && typeof icon.icon === 'string';
|
|
35
|
+
};
|
|
36
|
+
export class MgActionMore {
|
|
37
|
+
constructor() {
|
|
38
|
+
/************
|
|
39
|
+
* Internal *
|
|
40
|
+
************/
|
|
41
|
+
this.name = 'mg-action-more';
|
|
42
|
+
this.mgPopoverIdentifier = createID(this.name);
|
|
43
|
+
/************
|
|
44
|
+
* Merthods *
|
|
45
|
+
***********/
|
|
46
|
+
/**
|
|
47
|
+
* Toogle expanded props
|
|
48
|
+
*
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
this.toggleExpanded = () => {
|
|
52
|
+
this.expanded = !this.expanded;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Button click handler
|
|
56
|
+
*
|
|
57
|
+
* @returns {void}
|
|
58
|
+
*/
|
|
59
|
+
this.handleButton = () => {
|
|
60
|
+
this.toggleExpanded();
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Item click handler
|
|
64
|
+
*
|
|
65
|
+
* @param {MouseEvent} event click event
|
|
66
|
+
* @param {MgActionMoreItemType['mouseEventHandler']} customHandler item['mouseEventHandler']
|
|
67
|
+
* @returns {void}
|
|
68
|
+
*/
|
|
69
|
+
this.handleItemClick = (event, customHandler) => {
|
|
70
|
+
this.expanded = false;
|
|
71
|
+
customHandler(event);
|
|
72
|
+
};
|
|
73
|
+
this.icon = { icon: 'ellipsis' };
|
|
74
|
+
this.button = { variant: 'flat', isIcon: true };
|
|
75
|
+
this.items = undefined;
|
|
76
|
+
this.displayChevron = undefined;
|
|
77
|
+
this.expanded = false;
|
|
78
|
+
}
|
|
79
|
+
validateIcon(newValue) {
|
|
80
|
+
if (newValue && !isMgActionMoreIcon(newValue)) {
|
|
81
|
+
throw new Error(`<${this.name}> prop icon must match MgActionMoreIconType.`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
validateButton(newValue) {
|
|
85
|
+
if (newValue && !isMgActionMoreButton(newValue)) {
|
|
86
|
+
throw new Error(`<${this.name}> prop button must match MgActionMoreButtonType.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
validateItems(newValue) {
|
|
90
|
+
if (!isMgActionMoreItems(newValue)) {
|
|
91
|
+
throw new Error(`<${this.name}> prop "items" is required and all values must be the same type, MgActionMoreItemType.`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
validateDisplayChevron(newValue) {
|
|
95
|
+
if (newValue && this.button.isIcon === true) {
|
|
96
|
+
throw new Error(`<${this.name}> prop "displayChevron" can't be used with a 'button" prop "isIcon" attribute.`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/*************
|
|
100
|
+
* Lifecycle *
|
|
101
|
+
*************/
|
|
102
|
+
/**
|
|
103
|
+
* Validate props
|
|
104
|
+
*
|
|
105
|
+
* @returns {void}
|
|
106
|
+
*/
|
|
107
|
+
componentWillLoad() {
|
|
108
|
+
this.messages = initLocales(this.element).messages.actionMore;
|
|
109
|
+
this.validateItems(this.items);
|
|
110
|
+
this.validateButton(this.button);
|
|
111
|
+
this.validateIcon(this.icon);
|
|
112
|
+
this.validateDisplayChevron(this.displayChevron);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Render
|
|
116
|
+
*
|
|
117
|
+
* @returns {HTMLElement} HTML Element
|
|
118
|
+
*/
|
|
119
|
+
render() {
|
|
120
|
+
const buttonLabel = this.button.label || this.messages.label;
|
|
121
|
+
const buttonContent = [buttonLabel];
|
|
122
|
+
if (!this.button.isIcon && this.displayChevron) {
|
|
123
|
+
buttonContent.push(h("span", { class: {
|
|
124
|
+
[`${this.name}__chevron`]: true,
|
|
125
|
+
[`${this.name}__chevron--rotate`]: this.expanded === true,
|
|
126
|
+
'mg-a11y-animation': true,
|
|
127
|
+
} }, h("mg-icon", { icon: "chevron-down", size: "small" })));
|
|
128
|
+
}
|
|
129
|
+
return (h(Host, { "data-mg-popover-guard": this.mgPopoverIdentifier }, h("span", { class: "mg-action-more" }, h("mg-popover", { identifier: this.mgPopoverIdentifier, display: this.expanded }, h("mg-button", { variant: this.button.variant, isIcon: this.button.isIcon, type: "button", label: buttonLabel, onClick: this.handleButton }, h("mg-icon", Object.assign({}, this.icon)), !this.button.isIcon && buttonContent), h("div", { slot: "content" }, h("mg-menu", { direction: Direction.VERTICAL, label: this.messages.label }, this.items.map(item => {
|
|
130
|
+
var _a;
|
|
131
|
+
return (
|
|
132
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
133
|
+
h("mg-menu-item", { key: item.label, status: item.status || Status.VISIBLE, onClick: e => this.handleItemClick(e, item.mouseEventHandler), href: item.href }, item.icon && h("mg-icon", { icon: item.icon, slot: "image" }), h("span", { slot: "label" }, item.label), ((_a = item.badge) === null || _a === void 0 ? void 0 : _a.label) && h("mg-badge", { label: item.badge.label, value: item.badge.value, slot: "information", variant: "text-color" })));
|
|
134
|
+
})))))));
|
|
135
|
+
}
|
|
136
|
+
static get is() { return "mg-action-more"; }
|
|
137
|
+
static get encapsulation() { return "shadow"; }
|
|
138
|
+
static get originalStyleUrls() {
|
|
139
|
+
return {
|
|
140
|
+
"$": ["mg-action-more.scss"]
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
static get styleUrls() {
|
|
144
|
+
return {
|
|
145
|
+
"$": ["mg-action-more.css"]
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
static get properties() {
|
|
149
|
+
return {
|
|
150
|
+
"icon": {
|
|
151
|
+
"type": "unknown",
|
|
152
|
+
"mutable": false,
|
|
153
|
+
"complexType": {
|
|
154
|
+
"original": "MgActionMoreIconType",
|
|
155
|
+
"resolved": "{ icon: string; }",
|
|
156
|
+
"references": {
|
|
157
|
+
"MgActionMoreIconType": {
|
|
158
|
+
"location": "import",
|
|
159
|
+
"path": "./mg-action-more.conf"
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"required": false,
|
|
164
|
+
"optional": false,
|
|
165
|
+
"docs": {
|
|
166
|
+
"tags": [],
|
|
167
|
+
"text": "Define displaied icon\nDefault: {icon: 'ellipsis'}"
|
|
168
|
+
},
|
|
169
|
+
"defaultValue": "{ icon: 'ellipsis' }"
|
|
170
|
+
},
|
|
171
|
+
"button": {
|
|
172
|
+
"type": "unknown",
|
|
173
|
+
"mutable": false,
|
|
174
|
+
"complexType": {
|
|
175
|
+
"original": "MgActionMoreButtonType",
|
|
176
|
+
"resolved": "{ isIcon: boolean; variant: \"flat\" | \"info\" | \"success\" | \"link\" | \"primary\" | \"secondary\" | \"danger\" | \"danger-alt\"; label?: string; }",
|
|
177
|
+
"references": {
|
|
178
|
+
"MgActionMoreButtonType": {
|
|
179
|
+
"location": "import",
|
|
180
|
+
"path": "./mg-action-more.conf"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"required": false,
|
|
185
|
+
"optional": false,
|
|
186
|
+
"docs": {
|
|
187
|
+
"tags": [],
|
|
188
|
+
"text": "Define button properties\nDefault: {variant: 'flat', isIcon: true}."
|
|
189
|
+
},
|
|
190
|
+
"defaultValue": "{ variant: 'flat', isIcon: true }"
|
|
191
|
+
},
|
|
192
|
+
"items": {
|
|
193
|
+
"type": "unknown",
|
|
194
|
+
"mutable": false,
|
|
195
|
+
"complexType": {
|
|
196
|
+
"original": "MgActionMoreItemType[]",
|
|
197
|
+
"resolved": "MgActionMoreItemType[]",
|
|
198
|
+
"references": {
|
|
199
|
+
"MgActionMoreItemType": {
|
|
200
|
+
"location": "import",
|
|
201
|
+
"path": "./mg-action-more.conf"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
"required": true,
|
|
206
|
+
"optional": false,
|
|
207
|
+
"docs": {
|
|
208
|
+
"tags": [],
|
|
209
|
+
"text": "Define the menu-items elements"
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"displayChevron": {
|
|
213
|
+
"type": "boolean",
|
|
214
|
+
"mutable": false,
|
|
215
|
+
"complexType": {
|
|
216
|
+
"original": "boolean",
|
|
217
|
+
"resolved": "boolean",
|
|
218
|
+
"references": {}
|
|
219
|
+
},
|
|
220
|
+
"required": false,
|
|
221
|
+
"optional": false,
|
|
222
|
+
"docs": {
|
|
223
|
+
"tags": [],
|
|
224
|
+
"text": "Define if chevron is display"
|
|
225
|
+
},
|
|
226
|
+
"attribute": "display-chevron",
|
|
227
|
+
"reflect": false
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
static get states() {
|
|
232
|
+
return {
|
|
233
|
+
"expanded": {}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
static get elementRef() { return "element"; }
|
|
237
|
+
static get watchers() {
|
|
238
|
+
return [{
|
|
239
|
+
"propName": "icon",
|
|
240
|
+
"methodName": "validateIcon"
|
|
241
|
+
}, {
|
|
242
|
+
"propName": "button",
|
|
243
|
+
"methodName": "validateButton"
|
|
244
|
+
}, {
|
|
245
|
+
"propName": "items",
|
|
246
|
+
"methodName": "validateItems"
|
|
247
|
+
}, {
|
|
248
|
+
"propName": "displayChevron",
|
|
249
|
+
"methodName": "validateDisplayChevron"
|
|
250
|
+
}];
|
|
251
|
+
}
|
|
252
|
+
}
|
|
@@ -23,12 +23,12 @@ export class MgForm {
|
|
|
23
23
|
// All fields are required
|
|
24
24
|
// mg-input-toggle can not be required
|
|
25
25
|
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
26
|
-
this.requiredMessage = this.messages.form.allRequired;
|
|
26
|
+
this.requiredMessage = requiredInputs.length === 1 ? this.messages.form.allRequiredSingle : this.messages.form.allRequired;
|
|
27
27
|
this.classList.add(this.classAllRequired);
|
|
28
28
|
}
|
|
29
29
|
// Some fields are required
|
|
30
30
|
else if (requiredInputs.length > 0) {
|
|
31
|
-
this.requiredMessage = this.messages.form.required;
|
|
31
|
+
this.requiredMessage = requiredInputs.length === 1 ? this.messages.form.requiredSingle : this.messages.form.required;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
};
|