@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
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { C as ClassList } from './components.utils.js';
|
|
3
|
+
import { i as initLocales } from './index2.js';
|
|
4
|
+
import { d as defineCustomElement$5 } from './mg-badge2.js';
|
|
5
|
+
import { d as defineCustomElement$4 } from './mg-button2.js';
|
|
6
|
+
import { d as defineCustomElement$3 } from './mg-card2.js';
|
|
7
|
+
import { d as defineCustomElement$2 } from './mg-icon2.js';
|
|
8
|
+
import { d as defineCustomElement$1 } from './mg-popover2.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Available menu-item positions
|
|
12
|
+
*/
|
|
13
|
+
var ElementPosition;
|
|
14
|
+
(function (ElementPosition) {
|
|
15
|
+
ElementPosition["FIRST"] = "first";
|
|
16
|
+
ElementPosition["LAST"] = "last";
|
|
17
|
+
})(ElementPosition || (ElementPosition = {}));
|
|
18
|
+
/**
|
|
19
|
+
* Available menu item status
|
|
20
|
+
*/
|
|
21
|
+
var Status;
|
|
22
|
+
(function (Status) {
|
|
23
|
+
Status["VISIBLE"] = "visible";
|
|
24
|
+
Status["HIDDEN"] = "hidden";
|
|
25
|
+
Status["DISABLED"] = "disabled";
|
|
26
|
+
Status["ACTIVE"] = "active";
|
|
27
|
+
})(Status || (Status = {}));
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Menu direction type
|
|
31
|
+
*/
|
|
32
|
+
var Direction;
|
|
33
|
+
(function (Direction) {
|
|
34
|
+
Direction["VERTICAL"] = "vertical";
|
|
35
|
+
Direction["HORIZONTAL"] = "horizontal";
|
|
36
|
+
})(Direction || (Direction = {}));
|
|
37
|
+
/**
|
|
38
|
+
* More item type guard
|
|
39
|
+
*
|
|
40
|
+
* @param {unknown} element element to control
|
|
41
|
+
* @returns {boolean} truthy if element is more-item
|
|
42
|
+
*/
|
|
43
|
+
const isMoreItem = (element) => {
|
|
44
|
+
var _a, _b, _c;
|
|
45
|
+
const item = element;
|
|
46
|
+
return (item === undefined ||
|
|
47
|
+
(typeof item === 'object' &&
|
|
48
|
+
(typeof item.size === 'string' || typeof ((_a = item.mgIcon) === null || _a === void 0 ? void 0 : _a.icon) === 'string' || typeof ((_b = item.slotLabel) === null || _b === void 0 ? void 0 : _b.label) === 'string' || typeof ((_c = item.slotLabel) === null || _c === void 0 ? void 0 : _c.display) === 'boolean')));
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* List of all possibles sizes
|
|
52
|
+
*/
|
|
53
|
+
const sizes = ['regular', 'medium', 'large'];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* MgMenuItem type guard
|
|
57
|
+
*
|
|
58
|
+
* @param {HTMLElement} element element to control type
|
|
59
|
+
* @returns {boolean} truthy if element is mg-menu-item
|
|
60
|
+
*/
|
|
61
|
+
const isMgMenuItem = (element) => element.nodeName === 'MG-MENU-ITEM';
|
|
62
|
+
var OverflowBehaviorElements;
|
|
63
|
+
(function (OverflowBehaviorElements) {
|
|
64
|
+
OverflowBehaviorElements["MORE"] = "data-overflow-more";
|
|
65
|
+
OverflowBehaviorElements["BASE_INDEX"] = "data-overflow-base-index";
|
|
66
|
+
OverflowBehaviorElements["PROXY_INDEX"] = "data-overflow-proxy-index";
|
|
67
|
+
})(OverflowBehaviorElements || (OverflowBehaviorElements = {}));
|
|
68
|
+
class OverflowBehavior {
|
|
69
|
+
constructor(element, render) {
|
|
70
|
+
this.element = element;
|
|
71
|
+
this.render = render;
|
|
72
|
+
/**********
|
|
73
|
+
* Public *
|
|
74
|
+
**********/
|
|
75
|
+
/**
|
|
76
|
+
* Disconnect ResizeObserver
|
|
77
|
+
*
|
|
78
|
+
* @returns {void}
|
|
79
|
+
*/
|
|
80
|
+
this.disconnect = () => {
|
|
81
|
+
this.resizeObserver.disconnect();
|
|
82
|
+
};
|
|
83
|
+
/************
|
|
84
|
+
* Internal *
|
|
85
|
+
************/
|
|
86
|
+
/**
|
|
87
|
+
* run overflow behavior
|
|
88
|
+
*
|
|
89
|
+
* @param {number} width width of the container
|
|
90
|
+
* @returns {void}
|
|
91
|
+
*/
|
|
92
|
+
this.run = (width) => {
|
|
93
|
+
if (this.moreElement === undefined) {
|
|
94
|
+
// set moreElement
|
|
95
|
+
this.moreElement = this.render();
|
|
96
|
+
this.moreElement.setAttribute(OverflowBehaviorElements.MORE, '');
|
|
97
|
+
// set children
|
|
98
|
+
this.children = Array.from(this.element.children);
|
|
99
|
+
let moreElementChildren;
|
|
100
|
+
const allowedElements = ['MG-MENU-ITEM', 'MG-BUTTON'];
|
|
101
|
+
if (isMgMenuItem(this.moreElement)) {
|
|
102
|
+
moreElementChildren = Array.from(this.moreElement.querySelector('mg-menu').children).filter(element => allowedElements.includes(element.nodeName));
|
|
103
|
+
}
|
|
104
|
+
this.children.forEach((child, index) => {
|
|
105
|
+
child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);
|
|
106
|
+
if (child.getAttribute(OverflowBehaviorElements.MORE) === null) {
|
|
107
|
+
// set moreElement children
|
|
108
|
+
moreElementChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
this.updateDisplayedItems(width);
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Update displayed items in container from a given available space
|
|
116
|
+
*
|
|
117
|
+
* @param {number} availableWidth available width in container to display child items
|
|
118
|
+
* @returns {void}
|
|
119
|
+
*/
|
|
120
|
+
this.updateDisplayedItems = (availableWidth) => {
|
|
121
|
+
this.restoreItems();
|
|
122
|
+
const acc = { accWidth: 0, previousItem: null };
|
|
123
|
+
this.children.forEach((child) => {
|
|
124
|
+
acc.accWidth += child.offsetWidth;
|
|
125
|
+
const isPreviousItemHidden = acc.previousItem !== null && acc.previousItem.getAttribute('hidden') !== null;
|
|
126
|
+
// if previous item is hidden AND is NOT more element we hidde current
|
|
127
|
+
// OR if item has an overflow we hidde current
|
|
128
|
+
// OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item
|
|
129
|
+
// ELSE current is a display item
|
|
130
|
+
this.toggleItem(child, (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden));
|
|
131
|
+
// update previous item with current item
|
|
132
|
+
acc.previousItem = child;
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Utility method to know if item overflow partialy or totaly in the container
|
|
137
|
+
*
|
|
138
|
+
* @param {number} cumulateWidth previous sibling elements cumulate width + item width
|
|
139
|
+
* @param {HTMLElement} item item HTML element
|
|
140
|
+
* @param {number} availableWidth container available width
|
|
141
|
+
* @returns {boolean} truthy if element is overflow
|
|
142
|
+
*/
|
|
143
|
+
this.isOverflowElement = (cumulateWidth, item, availableWidth) => {
|
|
144
|
+
if (item.previousElementSibling === null || this.isMoreElement(item))
|
|
145
|
+
return false;
|
|
146
|
+
else if (!this.isMoreElement(item.nextElementSibling))
|
|
147
|
+
return cumulateWidth + this.moreElement.offsetWidth > availableWidth;
|
|
148
|
+
else
|
|
149
|
+
return cumulateWidth > availableWidth;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Utility method to know if a given element is the 'MORE' element
|
|
153
|
+
*
|
|
154
|
+
* @param {Element} element element to match with 'MORE' element
|
|
155
|
+
* @returns {boolean} truthy if element is the 'MORE' element
|
|
156
|
+
*/
|
|
157
|
+
this.isMoreElement = (element) => element.getAttribute(OverflowBehaviorElements.MORE) !== null;
|
|
158
|
+
/**
|
|
159
|
+
* Toggle display item element
|
|
160
|
+
*
|
|
161
|
+
* @param {HTMLElement} item item to control
|
|
162
|
+
* @param {boolean} isHidden is item hidden
|
|
163
|
+
* @returns {void}
|
|
164
|
+
*/
|
|
165
|
+
this.toggleItem = (item, isHidden) => {
|
|
166
|
+
const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));
|
|
167
|
+
if (this.isMoreElement(item))
|
|
168
|
+
this.toggleElement(this.moreElement, isHidden);
|
|
169
|
+
else if (mgActionMenuindex >= 0) {
|
|
170
|
+
this.toggleElement(item, isHidden);
|
|
171
|
+
this.toggleElement(this.moreElement.querySelector(`[${OverflowBehaviorElements.PROXY_INDEX}="${mgActionMenuindex}"]`), !isHidden);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Toggle element's hidde attribute
|
|
176
|
+
*
|
|
177
|
+
* @param {Element} element element to toggle
|
|
178
|
+
* @param {boolean} isHidden element is hidden
|
|
179
|
+
* @returns {void}
|
|
180
|
+
*/
|
|
181
|
+
this.toggleElement = (element, isHidden) => {
|
|
182
|
+
if (isHidden)
|
|
183
|
+
element.setAttribute('hidden', '');
|
|
184
|
+
else
|
|
185
|
+
element.removeAttribute('hidden');
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Remove hidden attributes on all items
|
|
189
|
+
*
|
|
190
|
+
* @returns {void}
|
|
191
|
+
*/
|
|
192
|
+
this.restoreItems = () => {
|
|
193
|
+
this.children.forEach(item => item.removeAttribute('hidden'));
|
|
194
|
+
};
|
|
195
|
+
if (this.resizeObserver === undefined) {
|
|
196
|
+
// add resize observer
|
|
197
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
198
|
+
entries.forEach(entry => {
|
|
199
|
+
this.run(entry.contentRect.width);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
this.resizeObserver.observe(this.element);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const mgMenuItemCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding:1rem 2rem;height:calc(3.8rem)}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button,.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button ::slotted([slot=label]),.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button ::slotted([slot=metadata]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular ::slotted([slot=label]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular ::slotted([slot=metadata]){font-size:var(--font-size)}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular.mg-menu-item__navigation-button--horizontal{padding-bottom:calc(1rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular.mg-menu-item__navigation-button--vertical{padding-left:calc(2rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding:1rem 3rem;height:calc(5.1rem)}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button,.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button ::slotted([slot=label]),.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button ::slotted([slot=metadata]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium ::slotted([slot=label]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium ::slotted([slot=metadata]){font-size:calc(var(--font-size) + 0.2rem)}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium.mg-menu-item__navigation-button--horizontal{padding-bottom:calc(1rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium.mg-menu-item__navigation-button--vertical{padding-left:calc(3rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding:1rem 4rem;height:calc(7.1rem)}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button,.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button ::slotted([slot=label]),.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button ::slotted([slot=metadata]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large ::slotted([slot=label]),.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large ::slotted([slot=metadata]){font-size:calc(var(--font-size) + 0.2rem)}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large.mg-menu-item__navigation-button--horizontal{padding-bottom:calc(1rem - 0.3rem)}.mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,.mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large.mg-menu-item__navigation-button--vertical{padding-left:calc(4rem - 0.3rem)}.mg-menu-item__navigation-button{display:flex;align-items:center;column-gap:var(--mg-menu-item-navigation-button-column-gap, 1rem);background-color:unset;border:none;font-family:var(--font-family);font-weight:400;color:hsl(var(--mg-menu-item-color-hsl, var(--color-dark)));line-height:var(--line-height);text-decoration:none;white-space:nowrap;box-sizing:border-box;cursor:pointer}.mg-menu-item__navigation-button:disabled,.mg-menu-item__navigation-button--disabled{cursor:default;opacity:var(--mg-disabled-opacity)}.mg-menu-item__navigation-button:focus-visible{z-index:10}.mg-menu-item__navigation-button:hover:not(.mg-menu-item__navigation-button--disabled),.mg-menu-item__navigation-button:focus-visible:not(.mg-menu-item__navigation-button--disabled){background-color:hsl(var(--mg-menu-item-focused-background-color-hsl), 0.1)}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--active{color:hsl(var(--mg-menu-item-color-active-hsl));font-weight:600}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--active.mg-menu-item__navigation-button--horizontal{border-bottom-color:hsl(var(--mg-menu-item-border-color-active-hsl))}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--active.mg-menu-item__navigation-button--vertical{border-left-color:hsl(var(--mg-menu-item-border-color-active-hsl))}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--hidden{display:none}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal{border-bottom:0.3rem solid transparent}.mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical{border-left:0.3rem solid transparent}:host([data-style-direction-vertical][data-level=\"1\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(1 * 2rem - 0.3rem)}:host([data-level=\"1\"]) .mg-menu-item__collapse-container{z-index:calc(1 * 10)}:host([data-style-direction-vertical][data-level=\"2\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(2 * 2rem - 0.3rem)}:host([data-level=\"2\"]) .mg-menu-item__collapse-container{z-index:calc(2 * 10)}:host([data-style-direction-vertical][data-level=\"3\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(3 * 2rem - 0.3rem)}:host([data-level=\"3\"]) .mg-menu-item__collapse-container{z-index:calc(3 * 10)}:host([data-style-direction-vertical][data-level=\"4\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(4 * 2rem - 0.3rem)}:host([data-level=\"4\"]) .mg-menu-item__collapse-container{z-index:calc(4 * 10)}:host([data-style-direction-vertical][data-level=\"5\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(5 * 2rem - 0.3rem)}:host([data-level=\"5\"]) .mg-menu-item__collapse-container{z-index:calc(5 * 10)}:host([data-style-direction-vertical][data-level=\"6\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular{padding-left:calc(6 * 2rem - 0.3rem)}:host([data-level=\"6\"]) .mg-menu-item__collapse-container{z-index:calc(6 * 10)}:host([data-style-direction-vertical][data-level=\"1\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(1 * 3rem - 0.3rem)}:host([data-level=\"1\"]) .mg-menu-item__collapse-container{z-index:calc(1 * 10)}:host([data-style-direction-vertical][data-level=\"2\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(2 * 3rem - 0.3rem)}:host([data-level=\"2\"]) .mg-menu-item__collapse-container{z-index:calc(2 * 10)}:host([data-style-direction-vertical][data-level=\"3\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(3 * 3rem - 0.3rem)}:host([data-level=\"3\"]) .mg-menu-item__collapse-container{z-index:calc(3 * 10)}:host([data-style-direction-vertical][data-level=\"4\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(4 * 3rem - 0.3rem)}:host([data-level=\"4\"]) .mg-menu-item__collapse-container{z-index:calc(4 * 10)}:host([data-style-direction-vertical][data-level=\"5\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(5 * 3rem - 0.3rem)}:host([data-level=\"5\"]) .mg-menu-item__collapse-container{z-index:calc(5 * 10)}:host([data-style-direction-vertical][data-level=\"6\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium{padding-left:calc(6 * 3rem - 0.3rem)}:host([data-level=\"6\"]) .mg-menu-item__collapse-container{z-index:calc(6 * 10)}:host([data-style-direction-vertical][data-level=\"1\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(1 * 4rem - 0.3rem)}:host([data-level=\"1\"]) .mg-menu-item__collapse-container{z-index:calc(1 * 10)}:host([data-style-direction-vertical][data-level=\"2\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(2 * 4rem - 0.3rem)}:host([data-level=\"2\"]) .mg-menu-item__collapse-container{z-index:calc(2 * 10)}:host([data-style-direction-vertical][data-level=\"3\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(3 * 4rem - 0.3rem)}:host([data-level=\"3\"]) .mg-menu-item__collapse-container{z-index:calc(3 * 10)}:host([data-style-direction-vertical][data-level=\"4\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(4 * 4rem - 0.3rem)}:host([data-level=\"4\"]) .mg-menu-item__collapse-container{z-index:calc(4 * 10)}:host([data-style-direction-vertical][data-level=\"5\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(5 * 4rem - 0.3rem)}:host([data-level=\"5\"]) .mg-menu-item__collapse-container{z-index:calc(5 * 10)}:host([data-style-direction-vertical][data-level=\"6\"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large{padding-left:calc(6 * 4rem - 0.3rem)}:host([data-level=\"6\"]) .mg-menu-item__collapse-container{z-index:calc(6 * 10)}:host{position:relative;display:flex;--mg-popover-padding-vertical:0;--mg-popover-padding-horizontal:0}:host([data-style-direction-vertical]){flex-direction:column}:host([data-style-direction-vertical]) .mg-menu-item__navigation-button{width:100%}:host([data-style-direction-vertical]) .mg-menu-item__collapse-container{left:unset;top:unset;position:unset;width:unset}:host([data-style-direction-vertical]) .mg-menu-item-chevron{margin-left:auto}:host([data-style-direction-horizontal]) .mg-menu-item__collapse-container.mg-menu-item__collapse-container--first-level{background-color:hsl(var(--color-light))}:host([data-style-direction-horizontal]) .mg-menu-item__collapse-container.mg-menu-item__collapse-container--first-level ::slotted(mg-menu){padding:1rem 0}:host([data-overflow-more]){--mg-menu-item-navigation-button-column-gap:0}:host([data-overflow-more]) .mg-menu-item__navigation-button-chevron{display:none}:host([data-overflow-more]) .mg-menu-item__navigation-button-text-content ::slotted([slot=information]){margin-left:0}:host([data-overflow-more]) ::slotted(mg-menu){--mg-menu-item-navigation-button-column-gap:1rem}.mg-menu-item{max-width:var(--mg-menu-item-navigation-button-max-width)}.mg-menu-item__collapse-container{width:max-content;z-index:10}.mg-menu-item__navigation-button-center{min-width:0}.mg-menu-item__navigation-button-text-content{width:100%;display:flex;align-items:center}.mg-menu-item__navigation-button-text-content-notification,.mg-menu-item__navigation-button-text-content ::slotted([slot=information]){margin-left:1rem;font-size:var(--font-size)}.mg-menu-item__navigation-button-chevron{margin-left:auto;transition:200ms}.mg-menu-item__navigation-button-chevron--rotate.mg-menu-item__navigation-button-chevron{transform:rotate(180deg)}::slotted([slot=label]),::slotted([slot=metadata]){display:block;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}::slotted(*){display:flex;flex-direction:column}:host([status=disabled]){pointer-events:none}:host([hidden]){display:none}";
|
|
208
|
+
|
|
209
|
+
const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
210
|
+
constructor() {
|
|
211
|
+
super();
|
|
212
|
+
this.__registerHost();
|
|
213
|
+
this.__attachShadow();
|
|
214
|
+
this.statusChange = createEvent(this, "status-change", 7);
|
|
215
|
+
/************
|
|
216
|
+
* Internal *
|
|
217
|
+
************/
|
|
218
|
+
this.name = 'mg-menu-item';
|
|
219
|
+
this.navigationButton = `${this.name}__navigation-button`;
|
|
220
|
+
/***********
|
|
221
|
+
* Methods *
|
|
222
|
+
**********/
|
|
223
|
+
/**
|
|
224
|
+
* Toggle expanded prop value
|
|
225
|
+
*
|
|
226
|
+
* @returns {void}
|
|
227
|
+
*/
|
|
228
|
+
this.toggleExpanded = () => {
|
|
229
|
+
this.expanded = !this.expanded;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Does an Element have given Status
|
|
233
|
+
*
|
|
234
|
+
* @param {HTMLMgMenuItemElement} mgMenuItemElement to parse
|
|
235
|
+
* @param {MgMenuItem['status']} status to check
|
|
236
|
+
* @returns {boolean} true if element with status is found
|
|
237
|
+
*/
|
|
238
|
+
this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
|
|
239
|
+
/**
|
|
240
|
+
* Is component contextual direction match the given direction
|
|
241
|
+
*
|
|
242
|
+
* @param {MgMenuItem['direction']} direction in parent menu
|
|
243
|
+
* @returns {boolean} true is direction match the direction propertie
|
|
244
|
+
*/
|
|
245
|
+
this.isDirection = (direction) => this.direction === direction;
|
|
246
|
+
/************
|
|
247
|
+
* Handlers *
|
|
248
|
+
************/
|
|
249
|
+
/**
|
|
250
|
+
* Handle interacrtive element click
|
|
251
|
+
*
|
|
252
|
+
* @param {MouseEvent} event click on element
|
|
253
|
+
* @returns {void}
|
|
254
|
+
*/
|
|
255
|
+
this.handleElementCLick = (event) => {
|
|
256
|
+
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status.DISABLED) {
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
event.stopPropagation();
|
|
259
|
+
}
|
|
260
|
+
// toggle expanded when mg-menu-item has child items
|
|
261
|
+
if (this.hasChildren)
|
|
262
|
+
this.toggleExpanded();
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Handle popover element display-change event
|
|
266
|
+
*
|
|
267
|
+
* @param {CustomEvent} event popover display event
|
|
268
|
+
* @returns {void}
|
|
269
|
+
*/
|
|
270
|
+
this.handlePopoverDisplay = (event) => {
|
|
271
|
+
this.expanded = event.detail;
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Update displayNotificationBadge
|
|
275
|
+
* current component notification badge have priority over the slot badge when submenu contain badge
|
|
276
|
+
*
|
|
277
|
+
* @returns {void} update displayNotificationBadge value
|
|
278
|
+
*/
|
|
279
|
+
this.updateDisplayNotificationBadge = () => {
|
|
280
|
+
const childMenu = this.element.querySelector('mg-menu');
|
|
281
|
+
this.displayNotificationBadge =
|
|
282
|
+
childMenu !== null &&
|
|
283
|
+
Array.from(childMenu.children).some((subItem) => subItem.querySelector('mg-badge') !== null && subItem.getAttribute('hidden') === null);
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* Method to control if one of component children have active status
|
|
287
|
+
*
|
|
288
|
+
* @returns {boolean} truthy if component has active child
|
|
289
|
+
*/
|
|
290
|
+
this.hasActiveChild = () => {
|
|
291
|
+
var _a;
|
|
292
|
+
return Array.from(((_a = this.element.querySelector('mg-menu')) === null || _a === void 0 ? void 0 : _a.children) || [])
|
|
293
|
+
.filter(element => element.nodeName === 'MG-MENU-ITEM')
|
|
294
|
+
.some((element) => this.hasStatus(element, Status.ACTIVE) && element.getAttribute('hidden') === null);
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Render slot
|
|
298
|
+
*
|
|
299
|
+
* @returns {HTMLElement} HTML Element
|
|
300
|
+
*/
|
|
301
|
+
this.renderSlot = () => h("slot", null);
|
|
302
|
+
this.href = undefined;
|
|
303
|
+
this.status = Status.VISIBLE;
|
|
304
|
+
this.expanded = false;
|
|
305
|
+
this.size = 'regular';
|
|
306
|
+
this.navigationButtonClassList = new ClassList([this.navigationButton]);
|
|
307
|
+
this.direction = undefined;
|
|
308
|
+
this.isInMainMenu = undefined;
|
|
309
|
+
this.hasChildren = false;
|
|
310
|
+
this.displayNotificationBadge = undefined;
|
|
311
|
+
}
|
|
312
|
+
validateStatus(newValue, oldValue) {
|
|
313
|
+
if (oldValue !== undefined) {
|
|
314
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
|
|
315
|
+
}
|
|
316
|
+
this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
|
|
317
|
+
this.statusChange.emit(newValue);
|
|
318
|
+
}
|
|
319
|
+
validateExpanded(newValue) {
|
|
320
|
+
if (typeof newValue !== 'boolean')
|
|
321
|
+
throw new Error(`<${this.name}> prop "expanded" must be a boolean.`);
|
|
322
|
+
// if menu-item has sub-menu we have to apply some updates:
|
|
323
|
+
if (this.hasChildren) {
|
|
324
|
+
const subItems = Array.from(this.element.querySelectorAll(this.name));
|
|
325
|
+
if (!newValue) {
|
|
326
|
+
// - when main menu item is NOT expanded we need NOT expanded sub-items and NOT expanded sub-content
|
|
327
|
+
subItems.forEach(item => {
|
|
328
|
+
item.expanded = false;
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
else if (this.element.querySelector(`${this.name}[status="${Status.ACTIVE}"]`) !== null) {
|
|
332
|
+
// - when expanded and contain an active item parents are expended too
|
|
333
|
+
subItems.forEach(item => {
|
|
334
|
+
if (this.hasStatus(item, Status.ACTIVE)) {
|
|
335
|
+
item.expanded = true;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
validateSize(newValue, oldValue) {
|
|
342
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
343
|
+
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
344
|
+
}
|
|
345
|
+
validateHasChildren(newValue) {
|
|
346
|
+
if (newValue && this.element.href !== undefined) {
|
|
347
|
+
throw new Error(`<${this.name}> prop "href" is unauthorizied when element is a parent.`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/*************
|
|
351
|
+
* Lifecycle *
|
|
352
|
+
*************/
|
|
353
|
+
/**
|
|
354
|
+
* Validate props
|
|
355
|
+
*
|
|
356
|
+
* @returns {void}
|
|
357
|
+
*/
|
|
358
|
+
componentWillLoad() {
|
|
359
|
+
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
360
|
+
// we store only matching elements
|
|
361
|
+
this.hasChildren = Array.from(this.element.children).some(child => !['image', 'information', 'label', 'metadata'].includes(child.getAttribute('slot')));
|
|
362
|
+
// Validate props
|
|
363
|
+
this.validateSize(this.size);
|
|
364
|
+
this.validateStatus(this.status);
|
|
365
|
+
this.validateExpanded(this.expanded);
|
|
366
|
+
this.badgeLabel = initLocales(this.element).messages.plusMenu.badgeLabel;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Check if component slots configuration
|
|
370
|
+
*
|
|
371
|
+
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
372
|
+
*/
|
|
373
|
+
componentDidLoad() {
|
|
374
|
+
// slot title AND metadata validation
|
|
375
|
+
// add title on label AND metada slots due to text-overflow on these element
|
|
376
|
+
if (Array.from(this.element.children).find(child => child.getAttribute('slot') === 'label') === undefined)
|
|
377
|
+
throw new Error(`<${this.name}> slot "label" is required.`);
|
|
378
|
+
['label', 'metadata'].forEach(slot => {
|
|
379
|
+
Array.from(this.element.querySelectorAll(`[slot="${slot}"]`)).forEach(element => {
|
|
380
|
+
if (element.textContent.trim().length < 1)
|
|
381
|
+
throw new Error(`<${this.name}> slot "${slot}" must have text content.`);
|
|
382
|
+
if (element.getAttribute('title') === null)
|
|
383
|
+
element.setAttribute('title', element.textContent);
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
// update props and states after componentDidLoad hook
|
|
387
|
+
// return a promise to process action only in the FIRST render().
|
|
388
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
389
|
+
return setTimeout(() => {
|
|
390
|
+
var _a;
|
|
391
|
+
// define menu-item context states
|
|
392
|
+
const menu = this.element.closest('mg-menu');
|
|
393
|
+
this.direction = this.element.getAttribute(OverflowBehaviorElements.MORE) !== null || menu === null ? Direction.HORIZONTAL : menu.direction;
|
|
394
|
+
this.size = menu === null || menu === void 0 ? void 0 : menu.size;
|
|
395
|
+
this.isInMainMenu = this.element.parentElement.closest('mg-menu-item') === null;
|
|
396
|
+
// when main menu item contain an active item it will get the active style
|
|
397
|
+
// AND if item is in vertical menu it will be expanded
|
|
398
|
+
if (this.hasActiveChild()) {
|
|
399
|
+
this.status = Status.ACTIVE;
|
|
400
|
+
if (this.isInMainMenu)
|
|
401
|
+
this.expanded = this.isDirection(Direction.VERTICAL);
|
|
402
|
+
}
|
|
403
|
+
// manage menu items style depending to parent menu horientation
|
|
404
|
+
this.element.setAttribute(`data-style-direction-${this.direction}`, '');
|
|
405
|
+
this.navigationButtonClassList.add(`${this.navigationButton}--${this.direction}`);
|
|
406
|
+
this.updateDisplayNotificationBadge();
|
|
407
|
+
// manage all sub levels child menu-items level with data-level attribut
|
|
408
|
+
if (this.isDirection(Direction.VERTICAL)) {
|
|
409
|
+
Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
|
|
410
|
+
item.dataset.level = `${(Number(item.dataset.level) || 1) + 1}`;
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
// manage first sub-level menu-items
|
|
414
|
+
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');
|
|
415
|
+
childItems.forEach(item => {
|
|
416
|
+
const updateStatus = () => {
|
|
417
|
+
if (![Status.HIDDEN, Status.DISABLED].includes(this.status)) {
|
|
418
|
+
this.status = this.hasActiveChild() ? Status.ACTIVE : Status.VISIBLE;
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
// manage child menu listener
|
|
422
|
+
item.addEventListener('status-change', () => {
|
|
423
|
+
updateStatus();
|
|
424
|
+
});
|
|
425
|
+
new MutationObserver(mutationsList => {
|
|
426
|
+
if (mutationsList.some(mutation => mutation.attributeName === 'hidden'))
|
|
427
|
+
updateStatus();
|
|
428
|
+
this.updateDisplayNotificationBadge();
|
|
429
|
+
}).observe(item, { attributes: true });
|
|
430
|
+
});
|
|
431
|
+
}, 0);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Render ineractive element
|
|
435
|
+
*
|
|
436
|
+
* @returns {HTMLElement} HTML Element
|
|
437
|
+
*/
|
|
438
|
+
renderInteractiveElement() {
|
|
439
|
+
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
440
|
+
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: {
|
|
441
|
+
[`${this.navigationButton}-chevron`]: true,
|
|
442
|
+
[`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
|
|
443
|
+
'mg-a11y-animation': true,
|
|
444
|
+
} }, h("mg-icon", { icon: "chevron-down" })))));
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Render
|
|
448
|
+
*
|
|
449
|
+
* @returns {HTMLElement} HTML Element
|
|
450
|
+
*/
|
|
451
|
+
render() {
|
|
452
|
+
const getContainerClasses = () => ({
|
|
453
|
+
[`${this.name}__collapse-container`]: true,
|
|
454
|
+
[`${this.name}__collapse-container--first-level`]: this.isInMainMenu && this.isDirection(Direction.HORIZONTAL),
|
|
455
|
+
});
|
|
456
|
+
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()))) : ([
|
|
457
|
+
this.renderInteractiveElement(),
|
|
458
|
+
h("div", { key: "vertical-container", class: getContainerClasses(), hidden: !this.expanded }, this.renderSlot()),
|
|
459
|
+
])));
|
|
460
|
+
}
|
|
461
|
+
get element() { return this; }
|
|
462
|
+
static get watchers() { return {
|
|
463
|
+
"status": ["validateStatus"],
|
|
464
|
+
"expanded": ["validateExpanded"],
|
|
465
|
+
"size": ["validateSize"],
|
|
466
|
+
"hasChildren": ["validateHasChildren"]
|
|
467
|
+
}; }
|
|
468
|
+
static get style() { return mgMenuItemCss; }
|
|
469
|
+
}, [1, "mg-menu-item", {
|
|
470
|
+
"href": [1],
|
|
471
|
+
"status": [1537],
|
|
472
|
+
"expanded": [1028],
|
|
473
|
+
"size": [32],
|
|
474
|
+
"navigationButtonClassList": [32],
|
|
475
|
+
"direction": [32],
|
|
476
|
+
"isInMainMenu": [32],
|
|
477
|
+
"hasChildren": [32],
|
|
478
|
+
"displayNotificationBadge": [32]
|
|
479
|
+
}]);
|
|
480
|
+
function defineCustomElement() {
|
|
481
|
+
if (typeof customElements === "undefined") {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const components = ["mg-menu-item", "mg-badge", "mg-button", "mg-card", "mg-icon", "mg-popover"];
|
|
485
|
+
components.forEach(tagName => { switch (tagName) {
|
|
486
|
+
case "mg-menu-item":
|
|
487
|
+
if (!customElements.get(tagName)) {
|
|
488
|
+
customElements.define(tagName, MgMenuItem);
|
|
489
|
+
}
|
|
490
|
+
break;
|
|
491
|
+
case "mg-badge":
|
|
492
|
+
if (!customElements.get(tagName)) {
|
|
493
|
+
defineCustomElement$5();
|
|
494
|
+
}
|
|
495
|
+
break;
|
|
496
|
+
case "mg-button":
|
|
497
|
+
if (!customElements.get(tagName)) {
|
|
498
|
+
defineCustomElement$4();
|
|
499
|
+
}
|
|
500
|
+
break;
|
|
501
|
+
case "mg-card":
|
|
502
|
+
if (!customElements.get(tagName)) {
|
|
503
|
+
defineCustomElement$3();
|
|
504
|
+
}
|
|
505
|
+
break;
|
|
506
|
+
case "mg-icon":
|
|
507
|
+
if (!customElements.get(tagName)) {
|
|
508
|
+
defineCustomElement$2();
|
|
509
|
+
}
|
|
510
|
+
break;
|
|
511
|
+
case "mg-popover":
|
|
512
|
+
if (!customElements.get(tagName)) {
|
|
513
|
+
defineCustomElement$1();
|
|
514
|
+
}
|
|
515
|
+
break;
|
|
516
|
+
} });
|
|
517
|
+
}
|
|
518
|
+
defineCustomElement();
|
|
519
|
+
|
|
520
|
+
export { Direction as D, MgMenuItem as M, OverflowBehaviorElements as O, Status as S, OverflowBehavior as a, defineCustomElement as d, isMoreItem as i, sizes as s };
|
|
@@ -1,132 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { D as Direction } from './mg-menu.conf.js';
|
|
3
|
-
|
|
4
|
-
const mgMenuCss = ":host{display:flex;background-color:hsl(var(--mg-menu-background-color-hsl, var(--color-light)))}:host([direction=vertical]){flex-direction:column;height:100%;overflow-y:auto}";
|
|
5
|
-
|
|
6
|
-
const MgMenu$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
this.__registerHost();
|
|
10
|
-
this.__attachShadow();
|
|
11
|
-
/************
|
|
12
|
-
* Internal *
|
|
13
|
-
************/
|
|
14
|
-
this.name = 'mg-menu';
|
|
15
|
-
this.focusedMenuItem = 0;
|
|
16
|
-
/**
|
|
17
|
-
* Close matching menu-item
|
|
18
|
-
*
|
|
19
|
-
* @param {HTMLMgMenuItemElement} item menu-item to close
|
|
20
|
-
* @param {boolean} condition addionnal condition
|
|
21
|
-
* @returns {void}
|
|
22
|
-
*/
|
|
23
|
-
this.closeMenuItem = (item, condition) => {
|
|
24
|
-
if (!this.isChildMenu && condition) {
|
|
25
|
-
item.expanded = false;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Store menu-items on component init and add listeners
|
|
30
|
-
*/
|
|
31
|
-
this.initMenuItems = () => {
|
|
32
|
-
// store all menu-items
|
|
33
|
-
this.menuItems = Array.from(this.element.children).filter(child => child.nodeName === 'MG-MENU-ITEM');
|
|
34
|
-
// add listeners on menu item and edit index
|
|
35
|
-
this.menuItems.forEach((item, menuItemIndex) => {
|
|
36
|
-
['click', 'focus'].forEach(trigger => {
|
|
37
|
-
(item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, () => {
|
|
38
|
-
this.focusedMenuItem = menuItemIndex;
|
|
39
|
-
// reset expanded on previous active menu item
|
|
40
|
-
this.menuItems.forEach((item, index) => {
|
|
41
|
-
this.closeMenuItem(item, index !== this.focusedMenuItem);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
this.label = undefined;
|
|
48
|
-
this.direction = Direction.HORIZONTAL;
|
|
49
|
-
this.isChildMenu = undefined;
|
|
50
|
-
}
|
|
51
|
-
validateLabel(newValue) {
|
|
52
|
-
if (newValue === undefined) {
|
|
53
|
-
throw new Error(`<${this.name}> prop "label" is required.`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
validateDirection(newValue) {
|
|
57
|
-
if (![Direction.VERTICAL, Direction.HORIZONTAL].includes(newValue)) {
|
|
58
|
-
throw new Error(`<${this.name}> prop "direction" must be one of : ${Direction.HORIZONTAL}, ${Direction.VERTICAL}.`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/*************
|
|
62
|
-
* Lifecycle *
|
|
63
|
-
*************/
|
|
64
|
-
/**
|
|
65
|
-
* Validate props
|
|
66
|
-
*
|
|
67
|
-
* @returns {void}
|
|
68
|
-
*/
|
|
69
|
-
componentWillLoad() {
|
|
70
|
-
this.validateDirection(this.direction);
|
|
71
|
-
this.validateLabel(this.label);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Check if component slots configuration
|
|
75
|
-
*
|
|
76
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
77
|
-
*/
|
|
78
|
-
componentDidLoad() {
|
|
79
|
-
// update props and states after componentDidLoad hook
|
|
80
|
-
// return a promise to process action only in the FIRST render().
|
|
81
|
-
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
82
|
-
return setTimeout(() => {
|
|
83
|
-
this.initMenuItems();
|
|
84
|
-
this.isChildMenu = this.element.closest('mg-menu-item') !== null;
|
|
85
|
-
// click outside management for child vertical menu
|
|
86
|
-
if (!this.isChildMenu && this.direction === Direction.HORIZONTAL) {
|
|
87
|
-
document.addEventListener('click', (event) => {
|
|
88
|
-
if (event.target.closest('mg-menu') === null) {
|
|
89
|
-
this.menuItems.forEach(item => {
|
|
90
|
-
this.closeMenuItem(item, this.direction === Direction.HORIZONTAL);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}, 0);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Render
|
|
99
|
-
*
|
|
100
|
-
* @returns {HTMLElement} HTML Element
|
|
101
|
-
*/
|
|
102
|
-
render() {
|
|
103
|
-
return (h(Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, h("slot", null)));
|
|
104
|
-
}
|
|
105
|
-
get element() { return this; }
|
|
106
|
-
static get watchers() { return {
|
|
107
|
-
"label": ["validateLabel"],
|
|
108
|
-
"direction": ["validateDirection"]
|
|
109
|
-
}; }
|
|
110
|
-
static get style() { return mgMenuCss; }
|
|
111
|
-
}, [1, "mg-menu", {
|
|
112
|
-
"label": [1],
|
|
113
|
-
"direction": [513],
|
|
114
|
-
"isChildMenu": [32]
|
|
115
|
-
}]);
|
|
116
|
-
function defineCustomElement$1() {
|
|
117
|
-
if (typeof customElements === "undefined") {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const components = ["mg-menu"];
|
|
121
|
-
components.forEach(tagName => { switch (tagName) {
|
|
122
|
-
case "mg-menu":
|
|
123
|
-
if (!customElements.get(tagName)) {
|
|
124
|
-
customElements.define(tagName, MgMenu$1);
|
|
125
|
-
}
|
|
126
|
-
break;
|
|
127
|
-
} });
|
|
128
|
-
}
|
|
129
|
-
defineCustomElement$1();
|
|
1
|
+
import { M as MgMenu$1, d as defineCustomElement$1 } from './mg-menu2.js';
|
|
130
2
|
|
|
131
3
|
const MgMenu = MgMenu$1;
|
|
132
4
|
const defineCustomElement = defineCustomElement$1;
|