@mgdis/mg-components 6.2.0 → 6.4.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-52d5f3d4.js → index-911898e4.js} +410 -266
- package/dist/cjs/index-911898e4.js.map +1 -0
- package/dist/cjs/{index-cc11af95.js → index-a3269bfc.js} +3 -3
- package/dist/cjs/{index-cc11af95.js.map → index-a3269bfc.js.map} +1 -1
- package/dist/cjs/{index.es-ac7c22e3.js → index.es-325100d7.js} +47 -47
- package/dist/cjs/index.es-325100d7.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_36.cjs.entry.js +1414 -983
- package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-alert.cjs.entry.js +17 -12
- package/dist/cjs/mg-alert.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-components.cjs.js.map +1 -1
- package/dist/cjs/mg-loader.cjs.entry.js +6 -8
- package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-progress.cjs.entry.js +27 -12
- package/dist/cjs/mg-progress.cjs.entry.js.map +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js +10 -3
- package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js.map +1 -1
- package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js +15 -4
- package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js.map +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +15 -4
- package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +112 -12
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.js +1 -1
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +9 -1
- package/dist/collection/components/atoms/mg-divider/mg-divider.js.map +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +22 -6
- package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +14 -4
- package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +3 -4
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +28 -6
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +50 -13
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +29 -11
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +106 -33
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +99 -36
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +130 -35
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +87 -25
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +86 -26
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +92 -30
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +109 -32
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +109 -29
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +67 -21
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +16 -70
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +101 -89
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +194 -157
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +19 -8
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +31 -6
- package/dist/collection/components/molecules/mg-alert/mg-alert.js.map +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js +17 -5
- package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +48 -16
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +13 -3
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +5 -5
- package/dist/collection/components/molecules/mg-loader/mg-loader.js.map +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +22 -6
- package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +54 -11
- package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +28 -9
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +48 -13
- package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +10 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +61 -7
- package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +26 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js.map +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +3 -2
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +28 -8
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
- package/dist/collection/utils/behaviors.utils.js +44 -107
- package/dist/collection/utils/behaviors.utils.js.map +1 -1
- package/dist/components/index.es.js +42 -42
- package/dist/components/index.es.js.map +1 -1
- package/dist/components/index2.js +2 -2
- package/dist/components/mg-action-more.js +15 -12
- package/dist/components/mg-action-more.js.map +1 -1
- package/dist/components/mg-alert.js +15 -10
- package/dist/components/mg-alert.js.map +1 -1
- package/dist/components/mg-badge2.js +13 -10
- package/dist/components/mg-badge2.js.map +1 -1
- package/dist/components/mg-button2.js +77 -16
- package/dist/components/mg-button2.js.map +1 -1
- package/dist/components/mg-card2.js +1 -1
- package/dist/components/mg-character-left2.js +8 -7
- package/dist/components/mg-character-left2.js.map +1 -1
- package/dist/components/mg-details.js +11 -7
- package/dist/components/mg-details.js.map +1 -1
- package/dist/components/mg-divider2.js +7 -1
- package/dist/components/mg-divider2.js.map +1 -1
- package/dist/components/mg-form.js +35 -21
- package/dist/components/mg-form.js.map +1 -1
- package/dist/components/mg-icon2.js +17 -11
- package/dist/components/mg-icon2.js.map +1 -1
- package/dist/components/mg-illustrated-message.js +10 -4
- package/dist/components/mg-illustrated-message.js.map +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +14 -10
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
- package/dist/components/mg-input-checkbox.js +73 -40
- package/dist/components/mg-input-checkbox.js.map +1 -1
- package/dist/components/mg-input-date.js +77 -46
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +90 -45
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-password.js +56 -28
- package/dist/components/mg-input-password.js.map +1 -1
- package/dist/components/mg-input-radio.js +59 -31
- package/dist/components/mg-input-radio.js.map +1 -1
- package/dist/components/mg-input-select2.js +60 -36
- package/dist/components/mg-input-select2.js.map +1 -1
- package/dist/components/mg-input-text2.js +71 -40
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-input-textarea.js +72 -36
- package/dist/components/mg-input-textarea.js.map +1 -1
- package/dist/components/mg-input-title2.js +11 -8
- package/dist/components/mg-input-title2.js.map +1 -1
- package/dist/components/mg-input-toggle.js +43 -25
- package/dist/components/mg-input-toggle.js.map +1 -1
- package/dist/components/mg-input2.js +37 -20
- package/dist/components/mg-input2.js.map +1 -1
- package/dist/components/mg-item-more2.js +146 -270
- package/dist/components/mg-item-more2.js.map +1 -1
- package/dist/components/mg-loader.js +4 -6
- package/dist/components/mg-loader.js.map +1 -1
- package/dist/components/mg-menu-item2.js +193 -149
- package/dist/components/mg-menu-item2.js.map +1 -1
- package/dist/components/mg-message2.js +21 -9
- package/dist/components/mg-message2.js.map +1 -1
- package/dist/components/mg-modal.js +36 -17
- package/dist/components/mg-modal.js.map +1 -1
- package/dist/components/mg-pagination2.js +21 -14
- package/dist/components/mg-pagination2.js.map +1 -1
- package/dist/components/mg-panel.js +37 -20
- package/dist/components/mg-panel.js.map +1 -1
- package/dist/components/mg-popover-content2.js +9 -3
- package/dist/components/mg-popover-content2.js.map +1 -1
- package/dist/components/mg-popover2.js +38 -10
- package/dist/components/mg-popover2.js.map +1 -1
- package/dist/components/mg-progress.js +26 -11
- package/dist/components/mg-progress.js.map +1 -1
- package/dist/components/mg-skip-links.js +2 -3
- package/dist/components/mg-skip-links.js.map +1 -1
- package/dist/components/mg-tabs.js +27 -17
- package/dist/components/mg-tabs.js.map +1 -1
- package/dist/components/mg-tag.js +12 -8
- package/dist/components/mg-tag.js.map +1 -1
- package/dist/components/mg-tooltip-content2.js +1 -2
- package/dist/components/mg-tooltip-content2.js.map +1 -1
- package/dist/components/mg-tooltip2.js +24 -12
- package/dist/components/mg-tooltip2.js.map +1 -1
- package/dist/esm/{index-81752ffe.js → index-1f32332a.js} +410 -266
- package/dist/esm/index-1f32332a.js.map +1 -0
- package/dist/esm/{index-f3d3fb70.js → index-9bd10f5d.js} +3 -3
- package/dist/esm/{index-f3d3fb70.js.map → index-9bd10f5d.js.map} +1 -1
- package/dist/esm/{index.es-940821a9.js → index.es-a2587b72.js} +43 -43
- package/dist/esm/index.es-a2587b72.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_36.entry.js +1414 -983
- package/dist/esm/mg-action-more_36.entry.js.map +1 -1
- package/dist/esm/mg-alert.entry.js +17 -12
- package/dist/esm/mg-alert.entry.js.map +1 -1
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-components.js.map +1 -1
- package/dist/esm/mg-loader.entry.js +6 -8
- package/dist/esm/mg-loader.entry.js.map +1 -1
- package/dist/esm/mg-progress.entry.js +27 -12
- package/dist/esm/mg-progress.entry.js.map +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/mg-components.esm.js.map +1 -1
- package/dist/mg-components/p-0ead5317.entry.js +2 -0
- package/dist/mg-components/{p-31e6c1a7.entry.js.map → p-0ead5317.entry.js.map} +1 -1
- package/dist/mg-components/p-35898742.js +3 -0
- package/dist/mg-components/p-35898742.js.map +1 -0
- package/dist/mg-components/p-3b052ac0.entry.js +2 -0
- package/dist/mg-components/p-3b052ac0.entry.js.map +1 -0
- package/dist/mg-components/p-6810a565.entry.js +2 -0
- package/dist/mg-components/p-6810a565.entry.js.map +1 -0
- package/dist/mg-components/{p-ee51ec5e.js → p-b986c107.js} +2 -2
- package/dist/mg-components/p-b986c107.js.map +1 -0
- package/dist/mg-components/{p-a49e2b74.js → p-dc436f3c.js} +2 -2
- package/dist/mg-components/p-f48d964f.entry.js +2 -0
- package/dist/mg-components/p-f48d964f.entry.js.map +1 -0
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +9 -1
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +11 -1
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +6 -0
- package/dist/types/components/molecules/internals/mg-item-more/mg-item-more.d.ts +1 -15
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +14 -30
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +46 -37
- package/dist/types/components/molecules/mg-alert/mg-alert.d.ts +4 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +4 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +4 -0
- package/dist/types/components.d.ts +33 -15
- package/dist/types/utils/behaviors.utils.d.ts +15 -44
- package/ide/intellij/web-types.json +39 -11
- package/ide/vscode/html-custom-data.json +28 -6
- package/package.json +27 -37
- package/dist/cjs/index-52d5f3d4.js.map +0 -1
- package/dist/cjs/index.es-ac7c22e3.js.map +0 -1
- package/dist/esm/index-81752ffe.js.map +0 -1
- package/dist/esm/index.es-940821a9.js.map +0 -1
- package/dist/mg-components/p-2298352f.js +0 -3
- package/dist/mg-components/p-2298352f.js.map +0 -1
- package/dist/mg-components/p-31e6c1a7.entry.js +0 -2
- package/dist/mg-components/p-67c9be27.entry.js +0 -2
- package/dist/mg-components/p-67c9be27.entry.js.map +0 -1
- package/dist/mg-components/p-95895169.entry.js +0 -2
- package/dist/mg-components/p-95895169.entry.js.map +0 -1
- package/dist/mg-components/p-abddacc2.entry.js +0 -2
- package/dist/mg-components/p-abddacc2.entry.js.map +0 -1
- package/dist/mg-components/p-ee51ec5e.js.map +0 -1
- /package/dist/mg-components/{p-a49e2b74.js.map → p-dc436f3c.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-menu.js","sourceRoot":"","sources":["../../../../../src/components/molecules/menu/mg-menu/mg-menu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD;;GAEG;AAMH,MAAM,OAAO,MAAM;;QACjB;;sBAEc;QAEG,SAAI,GAAG,SAAS,CAAC;QAC1B,cAAS,GAA4B,EAAE,CAAC;QACxC,oBAAe,GAAG,CAAC,CAAC;QAiE5B;;uBAEe;QAEf;;;;WAIG;QACK,kBAAa,GAAG,CAAC,IAA2B,EAAE,SAAkB,EAAQ,EAAE;YAChF,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,SAAS,EAAE,CAAC;gBACnC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACxB,CAAC;QACH,CAAC,CAAC;QAEF;;;WAGG;QACK,wBAAmB,GAAG,GAA0B,EAAE,eAAC,OAAA,MAAA,MAAA,IAAI,CAAC,e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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Element, Watch, Host } from '@stencil/core';\nimport { Direction, sizes } from './mg-menu.conf';\nimport type { MenuSizeType, ItemMoreType, DirectionType } from './mg-menu.conf';\nimport { toString } from '@mgdis/stencil-helpers';\n\n/**\n * @slot - Menu content\n */\n@Component({\n tag: 'mg-menu',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-menu.css',\n shadow: true,\n})\nexport class MgMenu {\n /************\n * Internal *\n ************/\n\n private readonly name = 'mg-menu';\n private menuItems: HTMLMgMenuItemElement[] = [];\n private focusedMenuItem = 0;\n private itemMoreElement: HTMLMgItemMoreElement;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgMenuElement;\n\n /**\n * Menu label. Include short menu description.\n * Required to define accessibility required attribute `aria-label`\n */\n @Prop() label!: string;\n @Watch('label')\n validateLabel(newValue: MgMenu['label']): void {\n if (newValue === undefined && !this.element.hasAttribute('aria-label')) {\n throw new Error(`<${this.name}> prop \"label\" is required. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Component display direction.\n */\n @Prop({ reflect: true }) direction: DirectionType = Direction.HORIZONTAL;\n @Watch('direction')\n validateDirection(newValue: MgMenu['direction']): void {\n if (![Direction.VERTICAL, Direction.HORIZONTAL].includes(newValue)) {\n throw new Error(`<${this.name}> prop \"direction\" must be one of: ${Direction.HORIZONTAL}, ${Direction.VERTICAL}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Customize \"mg-item-more\" element\n * Used with direction: 'vertical' to manage overflow\n */\n @Prop() itemmore?: ItemMoreType;\n @Watch('itemmore')\n validateItemMore(newValue: MgMenu['itemmore']): void {\n if (newValue !== undefined && this.direction !== Direction.HORIZONTAL) {\n throw new Error(`<${this.name}> prop \"itemmore\" must be paired with direction ${Direction.HORIZONTAL}.`);\n } else if (newValue !== undefined) {\n this.renderMgItemMore();\n }\n }\n\n /**\n * Define mg-menu size\n */\n @Prop() size: MenuSizeType = 'medium';\n @Watch('size')\n validateSize(newValue: MgMenu['size']): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<${this.name}> prop \"size\" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * is this menu a child menu. Used for conditional render.\n */\n @State() isChildMenu: boolean;\n\n /*************\n * Methods *\n *************/\n\n /**\n * Close matching menu-item\n * @param item - menu-item to close\n * @param condition - addionnal condition\n */\n private closeMenuItem = (item: HTMLMgMenuItemElement, condition: boolean): void => {\n if (!this.isChildMenu && condition) {\n item.expanded = false;\n }\n };\n\n /**\n * get mg-item-more child mg-menu-item element\n * @returns mg-menu-item element\n */\n private getItemMoreMenuItem = (): HTMLMgMenuItemElement => this.itemMoreElement?.shadowRoot?.querySelector('mg-menu-item');\n\n /**\n * Set item listend\n * @param item - mg-menu-item element\n * @param index - number\n */\n private setItemListener = (item: HTMLMgMenuItemElement, index: MgMenu['focusedMenuItem']): void => {\n ['click', 'focus'].forEach(trigger => {\n item.shadowRoot.querySelector('button,a').addEventListener(trigger, () => {\n this.focusedMenuItem = index;\n // reset expanded on previous active menu item\n const itemMoreMenuItem = this.getItemMoreMenuItem();\n (![null, undefined].includes(itemMoreMenuItem) ? [...this.menuItems, itemMoreMenuItem] : this.menuItems).forEach((item, index) => {\n this.closeMenuItem(item, index !== this.focusedMenuItem);\n });\n });\n });\n };\n\n /**\n * Store menu-items on component init and add listeners\n */\n private initMenuItemsListeners = (): void => {\n // add listeners on menu item and edit index\n this.menuItems.forEach((item, index) => {\n this.setItemListener(item, index);\n });\n };\n\n /**\n * Handle item-loaded event on mg-item-more element\n */\n private handleItemLoaded = (): void => {\n this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);\n };\n\n /**\n * render mg-item-more\n */\n private renderMgItemMore = (): void => {\n if (this.direction !== Direction.HORIZONTAL || this.isChildMenu || this.element.children.length <= 1) {\n return;\n }\n\n // Insert mg-item-more outside the mg-menu shadowdom\n if (this.itemMoreElement === undefined) {\n this.itemMoreElement = document.createElement('mg-item-more');\n this.itemMoreElement.addEventListener('item-loaded', this.handleItemLoaded);\n this.element.appendChild(this.itemMoreElement);\n }\n\n // update mg-item-more props\n for (const attribute in this.itemmore) {\n const newValue = this.itemmore[attribute];\n // to improve rendering we use HTML attributes as much as possible\n if (['string', 'number'].includes(typeof newValue)) {\n this.itemMoreElement.setAttribute(attribute, newValue);\n } else {\n this.itemMoreElement[attribute] = newValue;\n }\n }\n if (this.itemmore?.size === undefined) this.itemMoreElement.size = this.size;\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Validate props\n */\n componentWillLoad(): void {\n this.validateDirection(this.direction);\n this.validateLabel(this.label);\n this.validateItemMore(this.itemmore);\n this.validateSize(this.size);\n }\n\n /**\n * Check if component slots configuration\n * @returns timeout\n */\n componentDidLoad(): ReturnType<typeof setTimeout> {\n // update props and states after componentDidLoad hook\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n // store all menu-items\n this.menuItems = Array.from(this.element.children).filter(child => child.nodeName === 'MG-MENU-ITEM') as HTMLMgMenuItemElement[];\n this.isChildMenu = this.element.closest('mg-menu-item') !== null;\n\n // add mg-item-more to manage OverflowBehavior\n // when all props, states and DOM are already rendered we can render the mg-item-more\n this.renderMgItemMore();\n // then use mutation observer on children to improve reactivity\n new MutationObserver(() => {\n this.renderMgItemMore();\n }).observe(this.element, { childList: true });\n });\n }\n\n /**\n * Add listeners to items\n */\n componentDidRender(): void {\n this.initMenuItemsListeners();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"list\" aria-label={this.label}>\n <slot></slot>\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mg-menu.js","sourceRoot":"","sources":["../../../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AO,KAAK,IAAI,CAAC,OAAO;wBAAE,OAAO,IAAI,CAAC;yBACrC,IAAG,CAAC,OAAO,CAAC,aAAa;wBAAE,OAAO,KAAK,CAAC;;wBACxC,OAAO,cAAc,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;gBACpD,CAAC,CAAC;gBAEF,IAAG,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;oBACrE,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAA;oBAClE,8CAA8C;oBAC9C,IAAG,WAAW;wBAAE,WAAW,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;gBAChE,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,qDAAqD;QACrD,IAAI,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxF,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,OAAO,CACL,EAAC,IAAI,qDAAC,IAAI,EAAC,MAAM,gBAAa,IAAI,CAAC,KAAK;YACtC,8DAAa,CACR,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, Element, Watch, Host, Listen } from '@stencil/core';\nimport { Direction, sizes } from './mg-menu.conf';\nimport type { MenuSizeType, ItemMoreType, DirectionType } from './mg-menu.conf';\nimport { toString } from '@mgdis/stencil-helpers';\n\n/**\n * @slot - Menu content\n */\n@Component({\n tag: 'mg-menu',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-menu.css',\n shadow: true,\n})\nexport class MgMenu {\n /************\n * Internal *\n ************/\n\n private readonly name = 'mg-menu';\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgMenuElement;\n\n /**\n * Menu label. Include short menu description.\n * Required to define accessibility required attribute `aria-label`\n */\n @Prop() label!: string;\n @Watch('label')\n validateLabel(newValue: MgMenu['label']): void {\n if (newValue === undefined && !this.element.hasAttribute('aria-label')) {\n throw new Error(`<${this.name}> prop \"label\" is required. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Component display direction.\n */\n @Prop({ reflect: true }) direction: DirectionType = Direction.HORIZONTAL;\n @Watch('direction')\n validateDirection(newValue: MgMenu['direction']): void {\n if (![Direction.VERTICAL, Direction.HORIZONTAL].includes(newValue)) {\n throw new Error(`<${this.name}> prop \"direction\" must be one of: ${Direction.HORIZONTAL}, ${Direction.VERTICAL}. Passed value: ${toString(newValue)}.`);\n } else {\n this.updateMenuItems();\n }\n }\n\n /**\n * Customize \"mg-item-more\" element\n * Used with direction: 'vertical' to manage overflow\n */\n @Prop() itemmore?: ItemMoreType;\n @Watch('itemmore')\n validateItemMore(newValue: MgMenu['itemmore']): void {\n if (newValue !== undefined && this.direction !== Direction.HORIZONTAL) {\n throw new Error(`<${this.name}> prop \"itemmore\" must be paired with direction ${Direction.HORIZONTAL}.`);\n } else if (newValue !== undefined) {\n this.renderMgItemMore();\n }\n }\n\n /**\n * Define mg-menu size\n */\n @Prop() size: MenuSizeType = 'medium';\n @Watch('size')\n validateSize(newValue: MgMenu['size']): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<${this.name}> prop \"size\" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define mg-menu-item listener when they are loaded\n * @param event - mg-item-loaded \"item-loaded\" custom event\n */\n @Listen('item-loaded')\n updateItemListener(event: CustomEvent & { target: HTMLMgMenuItemElement}): void {\n const itemToWatch = event.target.nodeName === 'MG-ITEM-MORE' ? event.target.shadowRoot.querySelector('mg-menu-item') : event.target;\n\n ['click', 'focus'].forEach(trigger => {\n itemToWatch.addEventListener(trigger, ():void => {\n const focusedItem: HTMLMgMenuItemElement = event.target.closest('mg-menu').querySelector('[data-has-focus]')\n // exit process if new focused item in the current menu children\n if(focusedItem === itemToWatch) return;\n\n // reset expanded on previous active menu item\n if(focusedItem) focusedItem.removeAttribute(\"data-has-focus\");\n\n // update focusedMenuItem with new value\n itemToWatch.setAttribute('data-has-focus','true');\n });\n })\n };\n\n /*************\n * Methods *\n *************/\n\n /**\n * Test if menu is a child menu\n * @returns truthy if menu is a child menu\n */\n private isChildMenu = (): boolean => this.element.closest('mg-menu-item') !== null;\n\n /**\n * Get menu children items\n * @returns menu children mg-menu-item\n */\n private getMenuItems = (menu = this.element): HTMLMgMenuItemElement[] => {\n const menuItems = Array.from(menu.children).filter(child => child.nodeName === 'MG-MENU-ITEM') as HTMLMgMenuItemElement[];\n const itemMoreMenuItem = menu.querySelector('mg-item-more')?.shadowRoot?.querySelector('mg-menu-item');\n if(itemMoreMenuItem) {\n menuItems.push(itemMoreMenuItem)\n }\n return menuItems;\n }\n\n /**\n * Update menu items\n */\n private updateMenuItems = (): void => {\n this.getMenuItems().forEach((item) => {\n item.dataset.styleDirection = this.direction\n })\n\n // render mg-item-more to manage OverflowBehavior\n this.renderMgItemMore();\n }\n\n /**\n * render mg-item-more\n */\n private renderMgItemMore = (): void => {\n if (this.direction === Direction.VERTICAL || this.direction === Direction.HORIZONTAL && this.isChildMenu() || this.element.children.length <= 1) {\n return;\n }\n\n // Insert mg-item-more outside the mg-menu shadowdom\n let itemMoreElement = this.element.querySelector('mg-item-more')\n if (itemMoreElement === null) {\n itemMoreElement = document.createElement('mg-item-more');\n this.element.appendChild(itemMoreElement);\n }\n\n // update mg-item-more props\n for (const propertie in this.itemmore) {\n itemMoreElement[propertie] = this.itemmore[propertie];\n }\n if (this.itemmore?.size === undefined) itemMoreElement.size = this.size;\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Validate props\n */\n componentWillLoad(): void {\n this.validateDirection(this.direction);\n this.validateLabel(this.label);\n this.validateItemMore(this.itemmore);\n this.validateSize(this.size);\n }\n\n /**\n * Check if component slots configuration\n */\n componentDidLoad(): void {\n // set menu-items\n this.updateMenuItems();\n\n // add listener to close main menu when focus leave it\n if(!this.isChildMenu() && this.direction === Direction.HORIZONTAL) {\n document.addEventListener('focusin', (event: FocusEvent & { target: HTMLElement}):void => {\n const isElementChild = (element: HTMLElement):boolean => {\n if (element === this.element) return true;\n else if(!element.parentElement) return false;\n else return isElementChild(element.parentElement);\n };\n \n if(!event.target.closest('mg-menu') || !isElementChild(event.target)) {\n const focusedItem = this.element.querySelector('[data-has-focus]')\n // reset expanded on previous active menu item\n if(focusedItem) focusedItem.removeAttribute('data-has-focus');\n }\n })\n }\n // add mutation observer to improve global reactivity\n new MutationObserver(this.updateMenuItems).observe(this.element, { childList: true });\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"list\" aria-label={this.label}>\n <slot></slot>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -17,15 +17,39 @@ export class MgMenuItem {
|
|
|
17
17
|
************/
|
|
18
18
|
this.name = 'mg-menu-item';
|
|
19
19
|
this.navigationButton = 'mg-c-menu-item__navigation-button';
|
|
20
|
+
/************
|
|
21
|
+
* Props *
|
|
22
|
+
************/
|
|
23
|
+
/**
|
|
24
|
+
* Identifier is used to control mg-popover
|
|
25
|
+
*/
|
|
26
|
+
this.identifier = createID('mg-menu-item');
|
|
27
|
+
/**
|
|
28
|
+
* Define menu-item status.
|
|
29
|
+
*/
|
|
30
|
+
this.status = Status.VISIBLE;
|
|
31
|
+
/**
|
|
32
|
+
* Define menu-item content expanded.
|
|
33
|
+
*/
|
|
34
|
+
this.expanded = false;
|
|
35
|
+
/**********
|
|
36
|
+
* States *
|
|
37
|
+
*********/
|
|
38
|
+
/**
|
|
39
|
+
* Define menu-item size.
|
|
40
|
+
*/
|
|
41
|
+
this.size = 'medium';
|
|
42
|
+
/**
|
|
43
|
+
* Component button classes
|
|
44
|
+
*/
|
|
45
|
+
this.navigationButtonClassList = new ClassList([this.navigationButton]);
|
|
46
|
+
/**
|
|
47
|
+
* Does component have children.
|
|
48
|
+
*/
|
|
49
|
+
this.hasChildren = false;
|
|
20
50
|
/***********
|
|
21
51
|
* Methods *
|
|
22
52
|
**********/
|
|
23
|
-
/**
|
|
24
|
-
* Toggle expanded prop value
|
|
25
|
-
*/
|
|
26
|
-
this.toggleExpanded = () => {
|
|
27
|
-
this.expanded = !this.expanded;
|
|
28
|
-
};
|
|
29
53
|
/**
|
|
30
54
|
* Does an Element have given Status
|
|
31
55
|
* @param mgMenuItemElement - to parse
|
|
@@ -33,6 +57,24 @@ export class MgMenuItem {
|
|
|
33
57
|
* @returns true if element with status is found
|
|
34
58
|
*/
|
|
35
59
|
this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
|
|
60
|
+
/**
|
|
61
|
+
* Condition to know if component should display a mg-popover
|
|
62
|
+
* @returns truthy if component display popover
|
|
63
|
+
*/
|
|
64
|
+
this.hasPopover = () => this.isDirection(Direction.HORIZONTAL) && (this.isInMainMenu && Array.from(this.element.children).some(element => !element.querySelector('[slot]')) || this.isItemMore) && this.href === undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Method to control if one of component children have active status
|
|
67
|
+
* @returns truthy if component has active child
|
|
68
|
+
*/
|
|
69
|
+
this.hasActiveChild = () => {
|
|
70
|
+
var _a;
|
|
71
|
+
return Array.from(((_a = this.element.querySelector('mg-menu')) === null || _a === void 0 ? void 0 : _a.children) || []).some((element) => element.nodeName === 'MG-MENU-ITEM' && this.hasStatus(element, Status.ACTIVE) && !element.hasAttribute('hidden'));
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Is component an interactive item
|
|
75
|
+
* @returns truthy if element is clickable
|
|
76
|
+
*/
|
|
77
|
+
this.isInteractiveItem = () => this.hasChildren || !isValidString(this.href);
|
|
36
78
|
/**
|
|
37
79
|
* Is component contextual direction match the given direction
|
|
38
80
|
* @param direction - in parent menu
|
|
@@ -50,22 +92,34 @@ export class MgMenuItem {
|
|
|
50
92
|
childMenu !== null && Array.from(childMenu.children).some((subItem) => subItem.querySelector('mg-badge') !== null && !subItem.hasAttribute('hidden'));
|
|
51
93
|
};
|
|
52
94
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @
|
|
95
|
+
* Update expanded prop
|
|
96
|
+
* @param newValue - expanded new value
|
|
55
97
|
*/
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
|
|
98
|
+
this.updateExpanded = (newValue) => {
|
|
99
|
+
if (this.isInteractiveItem()) {
|
|
100
|
+
// item is always expanded in vertical menu when has active child
|
|
101
|
+
this.expanded = this.isDirection(Direction.VERTICAL) && this.hasActiveChild() || newValue;
|
|
102
|
+
}
|
|
59
103
|
};
|
|
60
104
|
/**
|
|
61
|
-
*
|
|
105
|
+
* Update status
|
|
106
|
+
* @param guard - status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
107
|
+
*/
|
|
108
|
+
this.updateStatus = (guard = []) => {
|
|
109
|
+
if (![Status.HIDDEN, Status.DISABLED, ...guard].includes(this.status)) {
|
|
110
|
+
this.status = this.hasActiveChild() ? Status.ACTIVE : Status.VISIBLE;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Update slots
|
|
62
115
|
* @param guard - prevent action with guard. Default: false.
|
|
63
116
|
*/
|
|
64
|
-
this.
|
|
117
|
+
this.updateSlot = (guard = false) => {
|
|
65
118
|
// slot title AND metadata validation
|
|
66
119
|
// add title on label AND metada slots due to text-overflow on these element
|
|
67
|
-
if (Array.from(this.element.children).find(child => child.getAttribute('slot') === 'label') === undefined)
|
|
120
|
+
if (Array.from(this.element.children).find(child => child.getAttribute('slot') === 'label') === undefined) {
|
|
68
121
|
throw new Error(`<${this.name}> slot "label" is required.`);
|
|
122
|
+
}
|
|
69
123
|
['label', 'metadata'].forEach(slot => {
|
|
70
124
|
Array.from(this.element.querySelectorAll(`[slot="${slot}"]`)).forEach(element => {
|
|
71
125
|
if (!isValidString(element.textContent))
|
|
@@ -76,39 +130,23 @@ export class MgMenuItem {
|
|
|
76
130
|
});
|
|
77
131
|
};
|
|
78
132
|
/**
|
|
79
|
-
* Update
|
|
80
|
-
* @param guard -
|
|
133
|
+
* Update menu item
|
|
134
|
+
* @param guard - prevent action with guard
|
|
81
135
|
*/
|
|
82
|
-
this.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// manage child menu listener
|
|
96
|
-
item.addEventListener('status-change', () => {
|
|
97
|
-
this.updateStatus();
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
});
|
|
136
|
+
this.updateItem = (guard) => {
|
|
137
|
+
const menu = this.element.closest('mg-menu');
|
|
138
|
+
this.isInMainMenu = menu !== null && this.element.parentElement.closest('mg-menu-item') === null;
|
|
139
|
+
// define element size
|
|
140
|
+
if ((menu === null || menu === void 0 ? void 0 : menu.size) !== undefined && !this.isItemMore)
|
|
141
|
+
this.size = menu.size;
|
|
142
|
+
else if (this.isItemMore)
|
|
143
|
+
this.size = this.element.dataset.size;
|
|
144
|
+
// when vertical main menu item contain an active item we force expanded
|
|
145
|
+
this.updateExpanded(this.expanded);
|
|
146
|
+
this.updateStatus(guard);
|
|
147
|
+
this.updatePopoverGuard();
|
|
148
|
+
this.updateDisplayNotificationBadge();
|
|
101
149
|
};
|
|
102
|
-
/**
|
|
103
|
-
* Get mg-popover identifier
|
|
104
|
-
* @returns generated mg-popover identifier
|
|
105
|
-
*/
|
|
106
|
-
this.getPopoverIdentifier = () => `${this.identifier}-popover`;
|
|
107
|
-
/**
|
|
108
|
-
* Condition to know if component should display a mg-popover
|
|
109
|
-
* @returns truthy if component display popover
|
|
110
|
-
*/
|
|
111
|
-
this.displayPopover = () => this.isDirection(Direction.HORIZONTAL) && this.hasChildren && this.href === undefined;
|
|
112
150
|
/************
|
|
113
151
|
* Handlers *
|
|
114
152
|
************/
|
|
@@ -117,106 +155,123 @@ export class MgMenuItem {
|
|
|
117
155
|
* @param event - click on element
|
|
118
156
|
*/
|
|
119
157
|
this.handleElementCLick = (event) => {
|
|
120
|
-
if (
|
|
158
|
+
if (this.status === Status.DISABLED) {
|
|
121
159
|
event.preventDefault();
|
|
122
160
|
event.stopPropagation();
|
|
123
161
|
}
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
162
|
+
// for non "poperized" menu-item we toggle expanded manualy
|
|
163
|
+
this.updateExpanded(!this.expanded);
|
|
164
|
+
// when item is the last clickable item we close the parent popover
|
|
165
|
+
if (!this.isInteractiveItem()) {
|
|
166
|
+
const closePopover = (element) => {
|
|
167
|
+
if (!element)
|
|
168
|
+
return;
|
|
169
|
+
else if (element !== this.element && element.expanded && element.shadowRoot.querySelector('mg-popover') !== null) {
|
|
170
|
+
element.expanded = false;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
closePopover(element.parentElement.closest('mg-menu-item'));
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
closePopover(this.element);
|
|
177
|
+
}
|
|
127
178
|
};
|
|
128
179
|
/**
|
|
129
180
|
* Handle popover element display-change event
|
|
130
181
|
* @param event - popover display event
|
|
131
182
|
*/
|
|
132
183
|
this.handlePopoverDisplay = (event) => {
|
|
133
|
-
this.
|
|
184
|
+
this.updateExpanded(event.detail);
|
|
134
185
|
};
|
|
135
186
|
/**
|
|
136
187
|
* Render slot
|
|
137
188
|
* @returns HTML Element
|
|
138
189
|
*/
|
|
139
190
|
this.renderSlot = () => h("slot", null);
|
|
140
|
-
this.identifier = createID('mg-menu-item');
|
|
141
|
-
this.href = undefined;
|
|
142
|
-
this.target = undefined;
|
|
143
|
-
this.status = Status.VISIBLE;
|
|
144
|
-
this.expanded = false;
|
|
145
|
-
this.size = 'medium';
|
|
146
|
-
this.navigationButtonClassList = new ClassList([this.navigationButton]);
|
|
147
|
-
this.direction = undefined;
|
|
148
|
-
this.isInMainMenu = undefined;
|
|
149
|
-
this.isItemMore = undefined;
|
|
150
|
-
this.hasChildren = false;
|
|
151
|
-
this.displayNotificationBadge = undefined;
|
|
152
191
|
}
|
|
153
192
|
watchIdentifier(newValue) {
|
|
154
193
|
if (!isValideID(newValue)) {
|
|
155
194
|
console.error(`<mg-menu-item> prop "identifier" value is invalid. Passed value: ${toString(newValue)}.`);
|
|
156
195
|
}
|
|
196
|
+
else {
|
|
197
|
+
this.popoverIdentifier = `${this.identifier}-popover`;
|
|
198
|
+
}
|
|
157
199
|
}
|
|
158
200
|
watchTarget(newValue) {
|
|
159
201
|
if (newValue && !targets.includes(newValue)) {
|
|
160
202
|
throw new Error(`<mg-link> prop "target" must be one of: ${targets.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
161
203
|
}
|
|
162
204
|
}
|
|
163
|
-
|
|
164
|
-
if (oldValue !== undefined)
|
|
205
|
+
watchStatus(newValue, oldValue) {
|
|
206
|
+
if (oldValue !== undefined)
|
|
165
207
|
this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
|
|
166
|
-
}
|
|
167
208
|
this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
|
|
168
|
-
this.statusChange.emit(newValue);
|
|
169
209
|
}
|
|
170
|
-
|
|
171
|
-
if (typeof newValue !== 'boolean')
|
|
210
|
+
watchExpanded(newValue) {
|
|
211
|
+
if (typeof newValue !== 'boolean') {
|
|
172
212
|
throw new Error(`<${this.name}> prop "expanded" must be a boolean. Passed value: ${toString(newValue)}.`);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
item.expanded = false;
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
else if (this.element.querySelector(`${this.name}[status="${Status.ACTIVE}"]`) !== null) {
|
|
183
|
-
// - when expanded and contain an active item parents are expended too
|
|
184
|
-
subItems.forEach(item => {
|
|
185
|
-
if (this.hasStatus(item, Status.ACTIVE)) {
|
|
186
|
-
item.expanded = true;
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
this.updateExpanded(newValue);
|
|
216
|
+
// when expanded all actives sub-items need to be expanded and non active closed
|
|
217
|
+
Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
|
|
218
|
+
if (item !== this.element)
|
|
219
|
+
item.expanded = newValue ? this.hasStatus(item, Status.ACTIVE) : false;
|
|
220
|
+
});
|
|
190
221
|
}
|
|
191
222
|
}
|
|
192
|
-
|
|
193
|
-
|
|
223
|
+
watchSize(newValue, oldValue) {
|
|
224
|
+
if (oldValue !== undefined)
|
|
225
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
194
226
|
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
195
227
|
}
|
|
196
|
-
validateDirection(newValue) {
|
|
197
|
-
|
|
198
|
-
|
|
228
|
+
validateDirection(newValue, oldValue) {
|
|
229
|
+
if (oldValue !== undefined)
|
|
230
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
|
|
199
231
|
this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
|
|
200
232
|
// manage all sub levels child menu-items level with data-level attribut
|
|
201
|
-
|
|
202
|
-
|
|
233
|
+
Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
|
|
234
|
+
if (this.isDirection(Direction.VERTICAL, newValue)) {
|
|
203
235
|
item.dataset.level = `${(Number(item.dataset.level) || 1) + 1}`;
|
|
204
|
-
}
|
|
205
|
-
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
delete item.dataset.level;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
206
241
|
}
|
|
207
242
|
validateHasChildren(newValue) {
|
|
208
243
|
if (newValue && this.element.href !== undefined) {
|
|
209
244
|
throw new Error(`<${this.name}> prop "href" is unauthorizied when element is a parent.`);
|
|
210
245
|
}
|
|
211
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* direction value in dataset
|
|
249
|
+
* @param newValue - new direction value
|
|
250
|
+
*/
|
|
251
|
+
// eslint-disable-next-line @stencil-community/no-unused-watch
|
|
252
|
+
watchDataStyleDirection(newValue) {
|
|
253
|
+
this.direction = newValue;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* has focus value in dataset
|
|
257
|
+
* @param newValue - new direction value
|
|
258
|
+
*/
|
|
259
|
+
// eslint-disable-next-line @stencil-community/no-unused-watch
|
|
260
|
+
watchDataHasFocus(newValue) {
|
|
261
|
+
if (!newValue)
|
|
262
|
+
this.updateExpanded(Boolean(newValue));
|
|
263
|
+
}
|
|
212
264
|
/**
|
|
213
265
|
* Render popover clickoutside guard for content slot
|
|
214
266
|
*/
|
|
215
267
|
updatePopoverGuard() {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
268
|
+
const subItem = this.element.querySelector('*:not([slot])');
|
|
269
|
+
if (!subItem)
|
|
270
|
+
return;
|
|
271
|
+
if (this.hasPopover())
|
|
272
|
+
subItem.dataset.mgPopoverGuard = this.popoverIdentifier;
|
|
273
|
+
else
|
|
274
|
+
delete subItem.dataset.mgPopoverGuard;
|
|
220
275
|
}
|
|
221
276
|
/*************
|
|
222
277
|
* Lifecycle *
|
|
@@ -230,13 +285,12 @@ export class MgMenuItem {
|
|
|
230
285
|
this.hasChildren = Array.from(this.element.children).some(child => !['image', 'information', 'label', 'metadata'].includes(child.getAttribute('slot')));
|
|
231
286
|
this.messages = initLocales(this.element).messages.menuItem;
|
|
232
287
|
this.isItemMore = this.element.dataset.overflowMore !== undefined;
|
|
233
|
-
//
|
|
234
|
-
this.
|
|
235
|
-
this.
|
|
288
|
+
// watchers
|
|
289
|
+
this.watchStatus(this.status);
|
|
290
|
+
this.watchExpanded(this.expanded);
|
|
236
291
|
this.watchTarget(this.target);
|
|
237
292
|
this.watchIdentifier(this.identifier);
|
|
238
|
-
|
|
239
|
-
this.validateSize(this.size);
|
|
293
|
+
this.watchSize(this.size);
|
|
240
294
|
}
|
|
241
295
|
/**
|
|
242
296
|
* Check if component slots configuration
|
|
@@ -244,40 +298,36 @@ export class MgMenuItem {
|
|
|
244
298
|
*/
|
|
245
299
|
componentDidLoad() {
|
|
246
300
|
// validation
|
|
247
|
-
this.
|
|
301
|
+
this.updateSlot(true);
|
|
248
302
|
// update props and states after componentDidLoad hook
|
|
249
303
|
// return a promise to process action only in the FIRST render().
|
|
250
304
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
251
305
|
return setTimeout(() => {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
this.
|
|
255
|
-
this.isInMainMenu = menu !== null && this.element.parentElement.closest('mg-menu-item') === null;
|
|
256
|
-
if ((menu === null || menu === void 0 ? void 0 : menu.size) !== undefined)
|
|
257
|
-
this.size = menu.size;
|
|
258
|
-
if (this.isItemMore)
|
|
259
|
-
this.size = this.element.dataset.size;
|
|
260
|
-
// when main menu item contain an active item it will get the active style
|
|
261
|
-
// AND if item is in vertical menu it will be expanded
|
|
262
|
-
if (this.hasActiveChild() && this.isInMainMenu)
|
|
263
|
-
this.expanded = this.isDirection(Direction.VERTICAL);
|
|
264
|
-
this.updateStatus([Status.ACTIVE]);
|
|
265
|
-
this.updateDisplayNotificationBadge();
|
|
266
|
-
this.updatePopoverGuard();
|
|
267
|
-
// manage child dom changes with mutationObserver and listners
|
|
268
|
-
this.initListeners();
|
|
306
|
+
this.watchDataStyleDirection(this.element.dataset.styleDirection);
|
|
307
|
+
this.watchDataHasFocus(this.element.dataset.hasFocus);
|
|
308
|
+
this.updateItem([Status.ACTIVE]);
|
|
269
309
|
// emit loaded event when component is fully loaded
|
|
270
310
|
this.itemLoaded.emit();
|
|
271
311
|
new MutationObserver(mutationsList => {
|
|
272
|
-
if (mutationsList.some(mutation => mutation.attributeName
|
|
312
|
+
if (mutationsList.some(mutation => ['hidden', 'status'].includes(mutation.attributeName)))
|
|
273
313
|
this.updateStatus(this.hasChildren ? undefined : [Status.ACTIVE]);
|
|
274
314
|
if (mutationsList.some(mutation => mutation.type === 'characterData'))
|
|
275
|
-
this.
|
|
276
|
-
|
|
315
|
+
this.updateSlot();
|
|
316
|
+
if (mutationsList.some(mutation => mutation.type === 'childList'))
|
|
317
|
+
this.updateItem();
|
|
277
318
|
this.itemUpdated.emit();
|
|
278
319
|
}).observe(this.element, { attributes: true, childList: true, characterData: true, subtree: true });
|
|
279
320
|
}, 0);
|
|
280
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* Emit event when component is updated
|
|
324
|
+
* @returns promise process wich emit the 'item-updated' event
|
|
325
|
+
*/
|
|
326
|
+
componentShouldUpdate() {
|
|
327
|
+
return nextTick(() => {
|
|
328
|
+
this.itemUpdated.emit();
|
|
329
|
+
});
|
|
330
|
+
}
|
|
281
331
|
/**
|
|
282
332
|
* Render ineractive element
|
|
283
333
|
* @returns HTML Element
|
|
@@ -292,15 +342,6 @@ export class MgMenuItem {
|
|
|
292
342
|
[`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
|
|
293
343
|
} }, h("mg-icon", { icon: "chevron-down" })))));
|
|
294
344
|
}
|
|
295
|
-
/**
|
|
296
|
-
* Emit event when component is updated
|
|
297
|
-
* @returns promise process wich emit the 'item-updated' event
|
|
298
|
-
*/
|
|
299
|
-
componentShouldUpdate() {
|
|
300
|
-
return nextTick(() => {
|
|
301
|
-
this.itemUpdated.emit();
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
345
|
/**
|
|
305
346
|
* Render
|
|
306
347
|
* @returns HTML Element
|
|
@@ -310,7 +351,7 @@ export class MgMenuItem {
|
|
|
310
351
|
['mg-c-menu-item__collapse-container']: true,
|
|
311
352
|
['mg-c-menu-item__collapse-container--first-level']: (this.isInMainMenu || this.isItemMore) && this.isDirection(Direction.HORIZONTAL),
|
|
312
353
|
});
|
|
313
|
-
return (h(Host, { key: '
|
|
354
|
+
return (h(Host, { key: '1bfbcc26638508e5fff8d0a9b0bd1956e06cb9ae', role: this.isItemMore ? 'presentation' : 'listitem' }, this.hasPopover() ? (h("mg-popover", { display: this.expanded, placement: "bottom-start", arrowHide: true, "onDisplay-change": this.handlePopoverDisplay, identifier: this.popoverIdentifier, "data-fallback-placement": "bottom-end" // use for the last element of the menu if it is placed on the right side
|
|
314
355
|
}, this.renderInteractiveElement(), h("div", { class: getContainerClasses(), slot: "content" }, this.renderSlot()))) : ([
|
|
315
356
|
this.renderInteractiveElement(),
|
|
316
357
|
h("div", { key: "vertical-container", class: getContainerClasses(), hidden: !this.expanded }, this.renderSlot()),
|
|
@@ -344,6 +385,8 @@ export class MgMenuItem {
|
|
|
344
385
|
"tags": [],
|
|
345
386
|
"text": "Identifier is used to control mg-popover"
|
|
346
387
|
},
|
|
388
|
+
"getter": false,
|
|
389
|
+
"setter": false,
|
|
347
390
|
"attribute": "identifier",
|
|
348
391
|
"reflect": true,
|
|
349
392
|
"defaultValue": "createID('mg-menu-item')"
|
|
@@ -362,6 +405,8 @@ export class MgMenuItem {
|
|
|
362
405
|
"tags": [],
|
|
363
406
|
"text": "Define menu-item href\nwhen defined menu-item contain an anchor instead of button"
|
|
364
407
|
},
|
|
408
|
+
"getter": false,
|
|
409
|
+
"setter": false,
|
|
365
410
|
"attribute": "href",
|
|
366
411
|
"reflect": false
|
|
367
412
|
},
|
|
@@ -385,6 +430,8 @@ export class MgMenuItem {
|
|
|
385
430
|
"tags": [],
|
|
386
431
|
"text": "Define target type"
|
|
387
432
|
},
|
|
433
|
+
"getter": false,
|
|
434
|
+
"setter": false,
|
|
388
435
|
"attribute": "target",
|
|
389
436
|
"reflect": false
|
|
390
437
|
},
|
|
@@ -408,6 +455,8 @@ export class MgMenuItem {
|
|
|
408
455
|
"tags": [],
|
|
409
456
|
"text": "Define menu-item status."
|
|
410
457
|
},
|
|
458
|
+
"getter": false,
|
|
459
|
+
"setter": false,
|
|
411
460
|
"attribute": "status",
|
|
412
461
|
"reflect": true,
|
|
413
462
|
"defaultValue": "Status.VISIBLE"
|
|
@@ -426,6 +475,8 @@ export class MgMenuItem {
|
|
|
426
475
|
"tags": [],
|
|
427
476
|
"text": "Define menu-item content expanded."
|
|
428
477
|
},
|
|
478
|
+
"getter": false,
|
|
479
|
+
"setter": false,
|
|
429
480
|
"attribute": "expanded",
|
|
430
481
|
"reflect": false,
|
|
431
482
|
"defaultValue": "false"
|
|
@@ -445,26 +496,6 @@ export class MgMenuItem {
|
|
|
445
496
|
}
|
|
446
497
|
static get events() {
|
|
447
498
|
return [{
|
|
448
|
-
"method": "statusChange",
|
|
449
|
-
"name": "status-change",
|
|
450
|
-
"bubbles": true,
|
|
451
|
-
"cancelable": true,
|
|
452
|
-
"composed": true,
|
|
453
|
-
"docs": {
|
|
454
|
-
"tags": [],
|
|
455
|
-
"text": "Emited event when status change"
|
|
456
|
-
},
|
|
457
|
-
"complexType": {
|
|
458
|
-
"original": "HTMLMgMenuItemElement['status']",
|
|
459
|
-
"resolved": "\"active\" | \"disabled\" | \"hidden\" | \"visible\"",
|
|
460
|
-
"references": {
|
|
461
|
-
"HTMLMgMenuItemElement": {
|
|
462
|
-
"location": "global",
|
|
463
|
-
"id": "global::HTMLMgMenuItemElement"
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}, {
|
|
468
499
|
"method": "itemLoaded",
|
|
469
500
|
"name": "item-loaded",
|
|
470
501
|
"bubbles": true,
|
|
@@ -506,19 +537,25 @@ export class MgMenuItem {
|
|
|
506
537
|
"methodName": "watchTarget"
|
|
507
538
|
}, {
|
|
508
539
|
"propName": "status",
|
|
509
|
-
"methodName": "
|
|
540
|
+
"methodName": "watchStatus"
|
|
510
541
|
}, {
|
|
511
542
|
"propName": "expanded",
|
|
512
|
-
"methodName": "
|
|
543
|
+
"methodName": "watchExpanded"
|
|
513
544
|
}, {
|
|
514
545
|
"propName": "size",
|
|
515
|
-
"methodName": "
|
|
546
|
+
"methodName": "watchSize"
|
|
516
547
|
}, {
|
|
517
548
|
"propName": "direction",
|
|
518
549
|
"methodName": "validateDirection"
|
|
519
550
|
}, {
|
|
520
551
|
"propName": "hasChildren",
|
|
521
552
|
"methodName": "validateHasChildren"
|
|
553
|
+
}, {
|
|
554
|
+
"propName": "data-style-direction",
|
|
555
|
+
"methodName": "watchDataStyleDirection"
|
|
556
|
+
}, {
|
|
557
|
+
"propName": "data-has-focus",
|
|
558
|
+
"methodName": "watchDataHasFocus"
|
|
522
559
|
}];
|
|
523
560
|
}
|
|
524
561
|
}
|