@mgdis/mg-components 5.28.2 → 6.0.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/{readme.md → README.md} +1 -1
- package/dist/cjs/{index-ce4f7698.js → index-08ee93bf.js} +57 -77
- package/dist/cjs/index-08ee93bf.js.map +1 -0
- package/dist/cjs/{index-792fd1c1.js → index-d57c96a9.js} +16 -15
- package/dist/cjs/index-d57c96a9.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_36.cjs.entry.js +622 -788
- package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-alert.cjs.entry.js +161 -0
- package/dist/cjs/mg-alert.cjs.entry.js.map +1 -0
- 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 -6
- package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
- package/dist/collection/assets/icons/index.js +1 -1
- package/dist/collection/assets/icons/index.js.map +1 -1
- package/dist/collection/collection-manifest.json +6 -5
- package/dist/collection/components/atoms/{mg-character-left → internals/mg-character-left}/mg-character-left.js +9 -5
- package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js.map +1 -0
- package/dist/collection/components/atoms/{mg-input-title → internals/mg-input-title}/mg-input-title.js +4 -4
- package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js.map +1 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js.map +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +6 -6
- package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +4 -22
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.js +1 -113
- package/dist/collection/components/atoms/mg-card/mg-card.js.map +1 -1
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +9 -9
- package/dist/collection/components/atoms/mg-divider/mg-divider.js.map +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js.map +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +11 -11
- package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js.map +1 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +3 -3
- 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 +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +6 -7
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +36 -20
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +0 -9
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +15 -60
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +1 -3
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +16 -48
- 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.conf.js +5 -23
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +128 -32
- 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.conf.js +1 -8
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +21 -22
- 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.conf.js +1 -8
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +46 -31
- 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 +9 -9
- 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 +27 -16
- 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.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +13 -13
- 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.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +72 -36
- 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 +22 -22
- 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 +7 -7
- 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.conf.js.map +1 -0
- package/dist/collection/components/molecules/{mg-item-more → internals/mg-item-more}/mg-item-more.js +24 -20
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +6 -7
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +21 -16
- 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.conf.js +7 -16
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +17 -17
- 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.conf.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +30 -15
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-alert/mg-alert.conf.js +9 -0
- package/dist/collection/components/molecules/mg-alert/mg-alert.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +270 -0
- package/dist/collection/components/molecules/mg-alert/mg-alert.js.map +1 -0
- package/dist/collection/components/molecules/mg-details/mg-details.js +3 -3
- package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +5 -5
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.conf.js +6 -0
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +16 -10
- 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 +3 -3
- package/dist/collection/components/molecules/mg-loader/mg-loader.js.map +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.conf.js +5 -1
- package/dist/collection/components/molecules/mg-message/mg-message.conf.js.map +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +46 -230
- package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +35 -121
- package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +4 -5
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js.map +1 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +7 -7
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +9 -9
- 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 +2 -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 +4 -3
- package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -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.conf.js +7 -8
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js.map +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +24 -13
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
- package/dist/collection/locales/en/messages.json +1 -1
- package/dist/collection/locales/fr/messages.json +1 -1
- package/dist/collection/types/index.js +2 -0
- package/dist/collection/types/index.js.map +1 -0
- package/dist/collection/utils/behaviors.utils.js +8 -9
- package/dist/collection/utils/behaviors.utils.js.map +1 -1
- package/dist/collection/utils/playwright.fixture.js +3 -3
- package/dist/collection/utils/playwright.fixture.js.map +1 -1
- package/dist/components/index.es.js +7 -7
- package/dist/components/index.es.js.map +1 -1
- package/dist/components/index2.js +6 -6
- package/dist/components/mg-action-more.js +34 -18
- package/dist/components/mg-action-more.js.map +1 -1
- package/dist/components/mg-alert.d.ts +11 -0
- package/dist/components/mg-alert.js +212 -0
- package/dist/components/mg-alert.js.map +1 -0
- package/dist/components/mg-badge2.js +8 -8
- package/dist/components/mg-badge2.js.map +1 -1
- package/dist/components/mg-button2.js +7 -9
- package/dist/components/mg-button2.js.map +1 -1
- package/dist/components/mg-card2.js +3 -68
- package/dist/components/mg-card2.js.map +1 -1
- package/dist/components/mg-character-left2.js +4 -3
- package/dist/components/mg-character-left2.js.map +1 -1
- package/dist/components/mg-details.js +5 -5
- package/dist/components/mg-details.js.map +1 -1
- package/dist/components/mg-divider.js +1 -40
- package/dist/components/mg-divider.js.map +1 -1
- package/dist/components/mg-divider2.js +44 -0
- package/dist/components/mg-divider2.js.map +1 -0
- package/dist/components/mg-form.js +5 -5
- package/dist/components/mg-form.js.map +1 -1
- package/dist/components/mg-icon2.js +11 -11
- package/dist/components/mg-icon2.js.map +1 -1
- package/dist/components/mg-illustrated-message.js +6 -6
- package/dist/components/mg-illustrated-message.js.map +1 -1
- package/dist/components/mg-input-checkbox-paginated.js +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +16 -47
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
- package/dist/components/mg-input-checkbox.js +82 -33
- package/dist/components/mg-input-checkbox.js.map +1 -1
- package/dist/components/mg-input-date.js +29 -38
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +46 -38
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-password.js +11 -11
- package/dist/components/mg-input-password.js.map +1 -1
- package/dist/components/mg-input-radio.js +28 -16
- package/dist/components/mg-input-radio.js.map +1 -1
- package/dist/components/mg-input-select2.js +14 -14
- package/dist/components/mg-input-select2.js.map +1 -1
- package/dist/components/mg-input-text2.js +58 -29
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-input-textarea.js +22 -22
- package/dist/components/mg-input-textarea.js.map +1 -1
- package/dist/components/mg-input-title2.js +4 -4
- package/dist/components/mg-input-title2.js.map +1 -1
- package/dist/components/mg-input-toggle.js +9 -9
- package/dist/components/mg-input-toggle.js.map +1 -1
- package/dist/components/mg-input2.js +19 -57
- package/dist/components/mg-input2.js.map +1 -1
- package/dist/components/mg-item-more2.js +35 -31
- package/dist/components/mg-item-more2.js.map +1 -1
- package/dist/components/mg-loader.js +5 -5
- package/dist/components/mg-loader.js.map +1 -1
- package/dist/components/mg-menu-item2.js +28 -38
- package/dist/components/mg-menu-item2.js.map +1 -1
- package/dist/components/mg-message.js +1 -224
- package/dist/components/mg-message.js.map +1 -1
- package/dist/components/mg-message2.js +135 -0
- package/dist/components/mg-message2.js.map +1 -0
- package/dist/components/mg-modal.js +32 -110
- package/dist/components/mg-modal.js.map +1 -1
- package/dist/components/mg-pagination2.js +12 -13
- package/dist/components/mg-pagination2.js.map +1 -1
- package/dist/components/mg-panel.js +10 -10
- package/dist/components/mg-panel.js.map +1 -1
- package/dist/components/mg-popover-content2.js +3 -3
- package/dist/components/mg-popover-content2.js.map +1 -1
- package/dist/components/mg-popover2.js +7 -6
- package/dist/components/mg-popover2.js.map +1 -1
- package/dist/components/mg-skip-links.js +4 -4
- package/dist/components/mg-skip-links.js.map +1 -1
- package/dist/components/mg-tabs.js +32 -22
- package/dist/components/mg-tabs.js.map +1 -1
- package/dist/components/mg-tag.js +5 -5
- package/dist/components/mg-tag.js.map +1 -1
- package/dist/components/mg-tooltip-content2.js +2 -2
- package/dist/components/mg-tooltip-content2.js.map +1 -1
- package/dist/components/mg-tooltip2.js +47 -32
- package/dist/components/mg-tooltip2.js.map +1 -1
- package/dist/esm/{index-9ed65b6d.js → index-089d0323.js} +57 -78
- package/dist/esm/index-089d0323.js.map +1 -0
- package/dist/esm/{index-2667a5c4.js → index-cc97a562.js} +13 -13
- package/dist/esm/index-cc97a562.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_36.entry.js +622 -788
- package/dist/esm/mg-action-more_36.entry.js.map +1 -1
- package/dist/esm/mg-alert.entry.js +157 -0
- package/dist/esm/mg-alert.entry.js.map +1 -0
- 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 -6
- package/dist/esm/mg-loader.entry.js.map +1 -1
- package/dist/mg-components/locales/en/messages.json +1 -1
- package/dist/mg-components/locales/fr/messages.json +1 -1
- package/dist/mg-components/mg-components.css +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-26b67dfd.entry.js +2 -0
- package/dist/mg-components/p-26b67dfd.entry.js.map +1 -0
- package/dist/mg-components/p-2b89fe8b.entry.js +2 -0
- package/dist/mg-components/p-2b89fe8b.entry.js.map +1 -0
- package/dist/mg-components/p-48e033cf.js +3 -0
- package/dist/mg-components/p-48e033cf.js.map +1 -0
- package/dist/mg-components/p-6f5c7ec5.entry.js +2 -0
- package/dist/mg-components/p-6f5c7ec5.entry.js.map +1 -0
- package/dist/mg-components/p-898d194f.js +2 -0
- package/dist/mg-components/p-898d194f.js.map +1 -0
- package/dist/types/assets/icons/index.d.ts +0 -1
- package/dist/types/components/atoms/{mg-character-left → internals/mg-character-left}/mg-character-left.d.ts +3 -0
- package/dist/types/components/atoms/{mg-input-title → internals/mg-input-title}/mg-input-title.d.ts +1 -1
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +2 -1
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +2 -1
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +0 -4
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +0 -33
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +5 -4
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +2 -1
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +2 -6
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +7 -2
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +2 -6
- package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +0 -9
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.d.ts +6 -13
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +4 -18
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +30 -3
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +2 -7
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +3 -7
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +6 -1
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -1
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -3
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.conf.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +10 -4
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +3 -3
- package/dist/types/components/molecules/{mg-item-more → internals/mg-item-more}/mg-item-more.conf.d.ts +2 -2
- package/dist/types/components/molecules/{mg-item-more → internals/mg-item-more}/mg-item-more.d.ts +3 -0
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +9 -7
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +2 -3
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +5 -17
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +4 -4
- package/dist/types/components/molecules/mg-action-more/mg-action-more.conf.d.ts +7 -1
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +2 -2
- package/dist/types/components/molecules/mg-alert/mg-alert.conf.d.ts +17 -0
- package/dist/types/components/molecules/mg-alert/mg-alert.d.ts +89 -0
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +4 -0
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.conf.d.ts +10 -0
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +7 -1
- package/dist/types/components/molecules/mg-message/mg-message.conf.d.ts +11 -2
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +11 -62
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +13 -39
- package/dist/types/components/molecules/mg-pagination/mg-pagination.conf.d.ts +4 -4
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +4 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +7 -11
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +9 -0
- package/dist/types/components.d.ts +165 -174
- package/dist/types/locales/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +27 -0
- package/dist/types/utils/behaviors.utils.d.ts +5 -5
- package/ide/intellij/web-types.json +791 -671
- package/ide/vscode/css-custom-data.json +389 -0
- package/ide/vscode/html-custom-data.json +217 -547
- package/package.json +26 -23
- package/dist/cjs/index-792fd1c1.js.map +0 -1
- package/dist/cjs/index-ce4f7698.js.map +0 -1
- package/dist/collection/components/atoms/mg-card/mg-card.conf.js +0 -9
- package/dist/collection/components/atoms/mg-card/mg-card.conf.js.map +0 -1
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js.map +0 -1
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js.map +0 -1
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.conf.js.map +0 -1
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +0 -1
- package/dist/collection/fonts/OpenSans-Bold.ttf +0 -0
- package/dist/collection/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/collection/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/collection/styles/fonts.css +0 -1
- package/dist/collection/styles/global.css +0 -1
- package/dist/collection/styles/main.css +0 -1
- package/dist/collection/styles/mg-components-utils.css +0 -1
- package/dist/collection/styles/variables.css +0 -1
- package/dist/collection/variables.css +0 -1
- package/dist/esm/index-2667a5c4.js.map +0 -1
- package/dist/esm/index-9ed65b6d.js.map +0 -1
- package/dist/mg-components/fonts/OpenSans-Bold.ttf +0 -0
- package/dist/mg-components/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/mg-components/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/mg-components/p-06a9d801.js +0 -3
- package/dist/mg-components/p-06a9d801.js.map +0 -1
- package/dist/mg-components/p-56cce4ec.entry.js +0 -2
- package/dist/mg-components/p-56cce4ec.entry.js.map +0 -1
- package/dist/mg-components/p-64eaef9e.entry.js +0 -2
- package/dist/mg-components/p-64eaef9e.entry.js.map +0 -1
- package/dist/mg-components/p-7cda52b6.js +0 -2
- package/dist/mg-components/p-7cda52b6.js.map +0 -1
- package/dist/mg-components/styles/fonts.css +0 -1
- package/dist/mg-components/styles/global.css +0 -1
- package/dist/mg-components/styles/main.css +0 -1
- package/dist/mg-components/styles/mg-components-utils.css +0 -1
- package/dist/mg-components/styles/variables.css +0 -1
- package/dist/mg-components/variables.css +0 -1
- package/dist/types/components/atoms/mg-card/mg-card.conf.d.ts +0 -16
- /package/dist/collection/components/molecules/{mg-item-more → internals/mg-item-more}/mg-item-more.conf.js +0 -0
|
@@ -1 +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AAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,qBAC7B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,EAC1D,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EACxD,KAAK,EAAC,8BAA8B,IAEpC,YAAM,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,KAAK,CAAC,GAAS,CACpD,CACX,CAAC,CACE,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgTabs","nextTick","createID","ClassList","isValidString","allItemsAreString"],"sources":["src/components/molecules/mg-tabs/mg-tabs.conf.ts","../styles/dist/components/mg-tabs.css?tag=mg-tabs&encapsulation=shadow","src/components/molecules/mg-tabs/mg-tabs.tsx"],"sourcesContent":["import { MgBadge } from '../../atoms/mg-badge/mg-badge';\nimport { MgIcon } from '../../atoms/mg-icon/mg-icon';\n\n/**\n * Available tabs items status\n */\nexport enum Status {\n VISIBLE = 'visible',\n HIDDEN = 'hidden',\n DISABLED = 'disabled',\n ACTIVE = 'active',\n}\n\n/**\n * type TabItem\n * use to match tabs items\n */\nexport type TabItem = {\n label: string;\n icon?: MgIcon['icon'];\n badge?: Pick<MgBadge, 'value' | 'variant' | 'label'> & { role: 'notification' | 'information' };\n status: Status;\n};\n\n/**\n * List of all possibles sizes\n */\nexport const sizes = ['regular', 'large'] as const;\n\n/**\n * Variant type from variants\n */\nexport type SizeType = (typeof sizes)[number];\n",".mg-c-tabs.mg-c-tabs--size-regular .mg-c-tabs__navigation-button,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-regular{padding:1rem 2rem}.mg-c-tabs.mg-c-tabs--size-regular .mg-c-tabs__navigation-button,.mg-c-tabs.mg-c-tabs--size-regular .mg-c-tabs__navigation-button ::slotted([slot=label]),.mg-c-tabs.mg-c-tabs--size-regular .mg-c-tabs__navigation-button ::slotted([slot=metadata]),.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-regular,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-regular ::slotted([slot=label]),.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-regular ::slotted([slot=metadata]){font-size:var(--font-size)}.mg-c-tabs.mg-c-tabs--size-regular .mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--horizontal,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-regular.mg-c-tabs__navigation-button--horizontal{padding-bottom:calc(1rem - 0.3rem)}.mg-c-tabs.mg-c-tabs--size-regular .mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--vertical,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-regular.mg-c-tabs__navigation-button--vertical{padding-left:calc(2rem - 0.3rem)}.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large{padding:1.5rem 3rem}.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button,.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button ::slotted([slot=label]),.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button ::slotted([slot=metadata]),.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large ::slotted([slot=label]),.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large ::slotted([slot=metadata]){font-size:calc(var(--font-size) + .2rem)}.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--horizontal,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large.mg-c-tabs__navigation-button--horizontal{padding-bottom:calc(1.5rem - 0.3rem)}.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--vertical,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large.mg-c-tabs__navigation-button--vertical{padding-left:calc(3rem - 0.3rem)}.mg-c-tabs__navigation-button{display:flex;box-sizing:border-box;align-items:center;border:none;background-color:unset;color:hsl(var(--mg-tabs-color-hsl, var(--color-dark)));column-gap:var(--mg-tabs-navigation-button-column-gap, 1rem);cursor:pointer;font-family:var(--font-family);font-weight:400;line-height:var(--line-height);text-decoration:none;white-space:nowrap}.mg-c-tabs__navigation-button:disabled,.mg-c-tabs__navigation-button--disabled{cursor:default;opacity:var(--mg-disabled-opacity)}.mg-c-tabs__navigation-button:focus-visible{z-index:10}.mg-c-tabs__navigation-button:hover:not(.mg-c-tabs__navigation-button--disabled),.mg-c-tabs__navigation-button:focus-visible:not(.mg-c-tabs__navigation-button--disabled){background-color:hsl(var(--mg-tabs-focused-background-color-hsl)/10%)}.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--active{color:hsl(var(--mg-tabs-color-active-hsl));font-weight:600}.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--active.mg-c-tabs__navigation-button--horizontal{border-bottom-color:hsl(var(--mg-tabs-border-color-active-hsl))}.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--active.mg-c-tabs__navigation-button--vertical{border-left-color:hsl(var(--mg-tabs-border-color-active-hsl))}.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--hidden{display:none}.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--horizontal{border-bottom:.3rem solid rgba(0,0,0,0)}.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--vertical{border-left:.3rem solid rgba(0,0,0,0)}.mg-c-tabs__header{display:flex;flex-flow:row wrap;border-bottom:var(--mg-tabs-border-bottom)}.mg-c-tabs__content-container:focus-visible{outline:none}.mg-c-tabs__navigation-button-text{flex:0 0 content}/*# sourceMappingURL=mg-tabs.css.map */\n","import { Component, Event, EventEmitter, h, Prop, State, Element, Watch } from '@stencil/core';\nimport { createID, ClassList, allItemsAreString, isValidString, nextTick } from '@mgdis/stencil-helpers';\nimport { TabItem, sizes, Status, SizeType } from './mg-tabs.conf';\n\n/**\n * type TabItem validation function\n * @param tab - tab item\n * @returns tab item type is valid\n */\nconst isTabItem = (tab: unknown): tab is TabItem => typeof tab === 'object' && typeof (tab as TabItem).label === 'string';\n\n/**\n * @slot tab_content-n - Tab content, where `n` represents the position of the tab content. It starts at 1.\n */\n@Component({\n tag: 'mg-tabs',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-tabs.css',\n shadow: true,\n})\nexport class MgTabs {\n /************\n * Internal *\n ************/\n\n // classes\n private readonly tabPanel = 'panel';\n private readonly buttonTabBaseClass = 'mg-c-tabs__navigation-button';\n\n // variables\n private tabFocus: number;\n private startIndex = 1;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTabsElement;\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n * If not set, it will be created.\n */\n @Prop() identifier: string = createID('mg-tabs');\n\n /**\n * Tabs label. Include short tabs description.\n * Required for accessibility\n */\n @Prop() label!: string;\n @Watch('label')\n validateLabel(newValue: MgTabs['label']): void {\n if (!isValidString(newValue)) {\n throw new Error('<mg-tabs> prop \"label\" is required.');\n }\n }\n\n /**\n * Define tabs size\n */\n @Prop() size: SizeType = 'regular';\n @Watch('size')\n validateSize(newValue: MgTabs['size']): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<mg-tabs> prop \"size\" must be one of: ${sizes.join(', ')}`);\n }\n this.classCollection.add(`mg-c-tabs--size-${this.size}`);\n }\n\n /**\n * Tabs items\n */\n @Prop() items!: string[] | TabItem[];\n @Watch('items')\n validateItems(newValue: MgTabs['items']): void {\n // String array\n if (allItemsAreString(newValue)) this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));\n // Object array\n else if (Array.isArray(newValue) && newValue.length > 0 && newValue.every(isTabItem)) this.tabs = newValue;\n else throw new Error('<mg-tabs> prop \"items\" is required and all items must be the same type: TabItem.');\n }\n\n /**\n * Active tab number\n */\n @Prop({ reflect: true, mutable: true }) activeTab: number;\n @Watch('activeTab')\n validateActiveTab(newValue: MgTabs['activeTab']): void {\n // when `active-tab` is undefined we set default value by searching an item with `Status.ACTIVE` or we use the `startIndex` has fallback value\n // after setting new value to `active-tab` the validate will be triggered again with the updated value and process the tab update\n if (newValue === undefined) {\n this.activeTab = this.tabs.some(tab => this.tabHasStatus(tab, Status.ACTIVE))\n ? this.getTabItemIndex(this.tabs.findIndex(tab => this.tabHasStatus(tab, Status.ACTIVE)))\n : this.startIndex;\n } else if (typeof newValue === 'number' && newValue >= this.startIndex && newValue <= this.tabs.length && this.isActivableTab(this.tabs[newValue - this.startIndex])) {\n // if new 'active-tab' is activable we update tab status to ACTIVE and toggle past ACTIVE to VISIBLE\n this.tabs.forEach((tab, index) => {\n const isNewActiveTab = index === newValue - this.startIndex;\n // reset active tabs\n if (this.tabHasStatus(tab, Status.ACTIVE) && !isNewActiveTab) tab.status = Status.VISIBLE;\n // set active tab from given tab key\n else if (this.isActivableTab(tab) && isNewActiveTab) tab.status = Status.ACTIVE;\n });\n // emit change active tab key event\n this.activeTabChange.emit(newValue);\n } else {\n throw new Error(`<mg-tabs> prop \"activeTab\" must be a number between ${this.startIndex} and ${this.tabs.length} and new value must be \"activable\".`);\n }\n }\n\n /**\n * Component tabs\n */\n @State() tabs: TabItem[] = [];\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-tabs']);\n\n /**\n * Emited event when active tab change\n */\n @Event({ eventName: 'active-tab-change' }) activeTabChange: EventEmitter<HTMLMgTabsElement['activeTab']>;\n\n /**\n * Validate that new tab status can be `Status.ACTIVE`\n * @param tab - tab item\n * @returns true when tab match condition to get a `Status.ACTIVE`\n */\n private isActivableTab = (tab: TabItem): boolean => [undefined, Status.ACTIVE, Status.VISIBLE].includes(tab.status);\n\n /**\n * Method to know if given tab has the given status\n * @param tab - item tab key to set to ACTIVE status\n * @param status - status to valide\n * @returns status comparaison\n */\n private tabHasStatus = (tab: TabItem, status: Status): boolean => tab.status === status;\n\n /**\n * Method to get element id from index\n * @param element - to get id\n * @param index - to generate id\n * @returns generated element id\n */\n private getElementId = (element: string, index: number): string => `${element}-${this.getTabItemIndex(index)}`;\n\n /**\n * Method to get tab item index\n * @param index - to get\n * @returns index\n */\n private getTabItemIndex = (index: number): number => index + this.startIndex;\n\n /**\n * Handle click events on tabs\n * @param event - mouse event\n */\n private handleClick = (event: MouseEvent & { currentTarget: HTMLElement }): void => {\n const tabId = event.currentTarget.dataset.index;\n if (!this.isActivableTab(this.tabs[Number(tabId) - this.startIndex])) {\n event.preventDefault();\n } else {\n this.activeTab = Number(tabId);\n this.tabFocus = undefined;\n }\n };\n\n /**\n * get navigation button class from given status\n * @param status - button tab status\n * @returns button class/selector variant\n */\n private getNavigationButtonClass = (status: Status): string => `${this.buttonTabBaseClass}--${status}`;\n\n /**\n * Handle keyboard event on tabs\n * @param event - mouse event\n */\n private handleKeydown = (event: KeyboardEvent & { target: HTMLElement }): void => {\n const parent = event.target.parentElement;\n if (['ArrowRight', 'ArrowLeft'].includes(event.key)) {\n this.tabFocus = Number(event.target.dataset.index);\n parent.querySelector(`[data-index=\"${this.tabFocus}\"]`).setAttribute('tabindex', '-1');\n\n // Move right\n if (event.key === 'ArrowRight') {\n this.tabFocus++;\n // If we're at the end, go to the start\n if (this.tabFocus > this.tabs.length) this.tabFocus = this.startIndex;\n // Move left\n } else if (event.key === 'ArrowLeft') {\n this.tabFocus--;\n // If we're at the start, move to the end\n if (this.tabFocus < this.startIndex) this.tabFocus = this.tabs.length;\n }\n\n const parentButtonElement: HTMLButtonElement = parent.querySelector(`[data-index=\"${this.tabFocus}\"]`);\n // if focus item is ['hidden'] we recursively repeat action\n if (this.tabHasStatus(this.tabs[this.tabFocus - 1], Status.HIDDEN)) {\n parentButtonElement.dispatchEvent(new KeyboardEvent('keydown', { key: event.key, bubbles: true }));\n // else run focus methods on tabFocus element\n } else {\n parentButtonElement.setAttribute('tabindex', '0');\n parentButtonElement.focus();\n }\n } else if (event.key === 'Tab') {\n this.resetFocus();\n }\n };\n\n /**\n * Method to reset focus behavior\n */\n private resetFocus = (): void => {\n // update asynchronously tabindex to prevent get focus on new tabindex at then end of event process\n nextTick(() => {\n this.tabFocus = undefined;\n Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {\n tab.setAttribute('tabindex', this.activeTab - this.startIndex !== index ? '-1' : '0');\n });\n });\n };\n\n /**\n * Validate slots setting\n */\n private validateSlots = (): void => {\n const slots = Array.from(this.element.children).filter(slot => slot.getAttribute('slot')?.includes('tab_content-'));\n if (slots.length !== this.tabs.length) throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Check tabs format\n this.validateLabel(this.label);\n this.validateItems(this.items);\n this.validateActiveTab(this.activeTab);\n this.validateSize(this.size);\n this.validateSlots();\n }\n\n /**\n * add listners\n */\n componentDidLoad(): void {\n document.addEventListener(\n 'click',\n (event: MouseEvent & { target: HTMLElement }) => {\n if (event.target.closest('mg-tabs') !== this.element) this.resetFocus();\n },\n false,\n );\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <div class={this.classCollection.join()}>\n <header role=\"tablist\" aria-label={this.label} class=\"mg-c-tabs__header\">\n {this.tabs.map((tab, index) => (\n <button\n key={tab.label}\n role=\"tab\"\n id={this.getElementId(this.identifier, index)}\n class={{\n [`${this.buttonTabBaseClass}`]: true,\n [`${this.buttonTabBaseClass}--horizontal`]: true,\n [`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),\n [`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasStatus(tab, Status.DISABLED),\n [`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasStatus(tab, Status.HIDDEN),\n }}\n tabindex={this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1}\n aria-selected={this.tabHasStatus(tab, Status.ACTIVE).toString()}\n aria-controls={this.getElementId(this.tabPanel, index)}\n aria-disabled={this.tabHasStatus(tab, Status.DISABLED)}\n onClick={this.handleClick}\n onKeyDown={this.handleKeydown}\n data-index={this.getTabItemIndex(index)}\n >\n {tab.icon !== undefined && <mg-icon icon={tab.icon}></mg-icon>}\n {tab.label}\n {tab.badge !== undefined && <mg-badge variant=\"text-color\" value={tab.badge.value} label={tab.badge.label} outline={tab.badge.role === 'information'}></mg-badge>}\n </button>\n ))}\n </header>\n {this.tabs.map((tab, index) => (\n <article\n key={tab.label}\n role=\"tabpanel\"\n id={this.getElementId(this.tabPanel, index)}\n hidden={!this.tabHasStatus(tab, Status.ACTIVE)}\n aria-labelledby={this.getElementId(this.identifier, index)}\n tabindex={this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1}\n class=\"mg-c-tabs__content-container\"\n >\n <slot name={this.getElementId('tab_content', index)}></slot>\n </article>\n ))}\n </div>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"mg-tabs.js","mappings":";;;;;AAIA;;;AAGO,MAAM,MAAM,GAA+B;IAChD,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAaF;;;AAGO,MAAM,KAAK,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU;;AC5BjD,MAAM,SAAS,GAAG,2uIAA2uI,CAAC;AAC9vI,qBAAe,SAAS;;ACGxB;;;;;AAKA,MAAM,SAAS,GAAG,CAAC,GAAY,KAAqB,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAQ,GAAe,CAAC,KAAK,KAAK,QAAQ,CAAC;MAU7GA,QAAM;;;;;;;;;;QAMA,aAAQ,GAAG,OAAO,CAAC;QACnB,uBAAkB,G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8BAA8B,IAEpC,YAAM,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,KAAK,CAAC,GAAS,CACpD,CACX,CAAC,CACE,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgTabs","nextTick","createID","ClassList","isValidString","toString","allItemsAreString"],"sources":["src/components/molecules/mg-tabs/mg-tabs.conf.ts","../styles/dist/components/mg-tabs.css?tag=mg-tabs&encapsulation=shadow","src/components/molecules/mg-tabs/mg-tabs.tsx"],"sourcesContent":["import type { Size, Status as StatusType } from '../../../types';\nimport type { MgBadge } from '../../atoms/mg-badge/mg-badge';\nimport type { MgIcon } from '../../atoms/mg-icon/mg-icon';\n\n/**\n * Available tabs items status\n */\nexport const Status: Record<string, StatusType> = {\n VISIBLE: 'visible',\n HIDDEN: 'hidden',\n DISABLED: 'disabled',\n ACTIVE: 'active',\n};\n\n/**\n * type TabItem\n * use to match tabs items\n */\nexport type TabItem = {\n label: string;\n icon?: MgIcon['icon'];\n badge?: Pick<MgBadge, 'value' | 'variant' | 'label'> & { role: 'notification' | 'information' };\n status: StatusType;\n};\n\n/**\n * List of all possibles sizes\n */\nexport const sizes = ['medium', 'large'] as const;\n\n/**\n * Variant type from variants\n */\nexport type SizeType = Size & (typeof sizes)[number];\n","/*!\n * @prop --mg-c-tabs-color: Defines tabs global color, used for bottom line and active tabs. Default value: `--mg-b-color-app`.\n * @prop --mg-c-tabs-color-text: Defines tabs text color. Unset by default, fallback on `--mg-b-color-dark`.\n */.mg-c-tabs.mg-c-tabs--size-medium .mg-c-tabs__navigation-button,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-medium{padding:var(--mg-b-size-12) var(--mg-b-size-16)}.mg-c-tabs.mg-c-tabs--size-medium .mg-c-tabs__navigation-button,.mg-c-tabs.mg-c-tabs--size-medium .mg-c-tabs__navigation-button ::slotted([slot=label]),.mg-c-tabs.mg-c-tabs--size-medium .mg-c-tabs__navigation-button ::slotted([slot=metadata]),.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-medium,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-medium ::slotted([slot=label]),.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-medium ::slotted([slot=metadata]){font-size:var(--mg-b-font-size)}.mg-c-tabs.mg-c-tabs--size-medium .mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--horizontal,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-medium.mg-c-tabs__navigation-button--horizontal{padding-bottom:var(--mg-b-size-12)}.mg-c-tabs.mg-c-tabs--size-medium .mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--vertical,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-medium.mg-c-tabs__navigation-button--vertical{padding-left:var(--mg-b-size-16)}.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large{padding:var(--mg-b-size-16) var(--mg-b-size-32)}.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button,.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button ::slotted([slot=label]),.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button ::slotted([slot=metadata]),.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large ::slotted([slot=label]),.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large ::slotted([slot=metadata]){font-size:var(--mg-b-font-size-h4)}.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--horizontal,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large.mg-c-tabs__navigation-button--horizontal{padding-bottom:var(--mg-b-size-16)}.mg-c-tabs.mg-c-tabs--size-large .mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--vertical,.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--size-large.mg-c-tabs__navigation-button--vertical{padding-left:var(--mg-b-size-32)}.mg-c-tabs__navigation-button{display:flex;box-sizing:border-box;align-items:center;border:none;background-color:unset;color:var(--mg-c-tabs-color-text, var(--mg-b-color-dark));column-gap:var(--mg-c-tabs-navigation-button-column-gap, var(--mg-b-size-8));cursor:pointer;font-family:var(--mg-b-font-family);font-weight:400;line-height:var(--mg-b-line-height);text-decoration:none;white-space:nowrap}.mg-c-tabs__navigation-button:disabled,.mg-c-tabs__navigation-button--disabled{cursor:default;opacity:var(--mg-b-opacity-element-disabled)}.mg-c-tabs__navigation-button:focus-visible{z-index:10}.mg-c-tabs__navigation-button:hover:not(.mg-c-tabs__navigation-button--disabled),.mg-c-tabs__navigation-button:focus-visible:not(.mg-c-tabs__navigation-button--disabled){background-color:color-mix(in srgb, var(--mg-c-tabs-color), transparent 90%)}.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--active{color:var(--mg-c-tabs-color);font-weight:600}.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--active.mg-c-tabs__navigation-button--horizontal{box-shadow:inset 0 calc(-1*var(--mg-b-size-4)) var(--mg-c-tabs-color)}.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--active.mg-c-tabs__navigation-button--vertical{box-shadow:inset var(--mg-b-size-4) 0 var(--mg-c-tabs-color)}.mg-c-tabs__navigation-button.mg-c-tabs__navigation-button--hidden{display:none}.mg-c-tabs__header{display:flex;flex-flow:row wrap;border-bottom:var(--mg-b-size-border) solid color-mix(in srgb, var(--mg-c-tabs-color), transparent 90%)}.mg-c-tabs__content-container:focus-visible{outline:none}.mg-c-tabs__navigation-button-text{flex:0 0 content}/*# sourceMappingURL=mg-tabs.css.map */\n","import { Component, Event, EventEmitter, h, Prop, State, Element, Watch } from '@stencil/core';\nimport { createID, ClassList, allItemsAreString, isValidString, nextTick, toString } from '@mgdis/stencil-helpers';\nimport { TabItem, sizes, Status, SizeType } from './mg-tabs.conf';\n\n/**\n * type TabItem validation function\n * @param tab - tab item\n * @returns tab item type is valid\n */\nconst isTabItem = (tab: unknown): tab is TabItem => typeof tab === 'object' && typeof (tab as TabItem).label === 'string';\n\n/**\n * @slot tab_content-n - Tab content, where `n` represents the position of the tab content. It starts at 1.\n */\n@Component({\n tag: 'mg-tabs',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-tabs.css',\n shadow: true,\n})\nexport class MgTabs {\n /************\n * Internal *\n ************/\n\n // classes\n private readonly tabPanel = 'panel';\n private readonly buttonTabBaseClass = 'mg-c-tabs__navigation-button';\n\n // variables\n private tabFocus: number;\n private startIndex = 1;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTabsElement;\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n * If not set, it will be created.\n */\n @Prop() identifier: string = createID('mg-tabs');\n\n /**\n * Tabs label. Include short tabs description.\n * Required for accessibility\n */\n @Prop() label!: string;\n @Watch('label')\n validateLabel(newValue: MgTabs['label']): void {\n if (!isValidString(newValue)) {\n throw new Error(`<mg-tabs> prop \"label\" is required and must be a string. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Define tabs size\n */\n @Prop() size: SizeType = 'medium';\n @Watch('size')\n validateSize(newValue: MgTabs['size']): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<mg-tabs> prop \"size\" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);\n }\n this.classCollection.add(`mg-c-tabs--size-${this.size}`);\n }\n\n /**\n * Tabs items\n */\n @Prop() items!: string[] | TabItem[];\n @Watch('items')\n validateItems(newValue: MgTabs['items']): void {\n // String array\n if (allItemsAreString(newValue)) this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));\n // Object array\n else if (Array.isArray(newValue) && newValue.length > 0 && newValue.every(isTabItem)) this.tabs = newValue;\n else throw new Error(`<mg-tabs> prop \"items\" is required and all items must be the same type: TabItem. Passed value: ${toString(newValue)}.`);\n }\n\n /**\n * Active tab number\n */\n @Prop({ reflect: true, mutable: true }) activeTab: number;\n @Watch('activeTab')\n validateActiveTab(newValue: MgTabs['activeTab']): void {\n // when `active-tab` is undefined we set default value by searching an item with `Status.ACTIVE` or we use the `startIndex` has fallback value\n // after setting new value to `active-tab` the validate will be triggered again with the updated value and process the tab update\n if (newValue === undefined) {\n this.activeTab = this.tabs.some(tab => this.tabHasStatus(tab, Status.ACTIVE))\n ? this.getTabItemIndex(this.tabs.findIndex(tab => this.tabHasStatus(tab, Status.ACTIVE)))\n : this.startIndex;\n } else if (typeof newValue === 'number' && newValue >= this.startIndex && newValue <= this.tabs.length && this.isActivableTab(this.tabs[newValue - this.startIndex])) {\n // if new 'active-tab' is activable we update tab status to ACTIVE and toggle past ACTIVE to VISIBLE\n this.tabs.forEach((tab, index) => {\n const isNewActiveTab = index === newValue - this.startIndex;\n // reset active tabs\n if (this.tabHasStatus(tab, Status.ACTIVE) && !isNewActiveTab) tab.status = Status.VISIBLE;\n // set active tab from given tab key\n else if (this.isActivableTab(tab) && isNewActiveTab) tab.status = Status.ACTIVE;\n });\n // emit change active tab key event\n this.activeTabChange.emit(newValue);\n } else {\n throw new Error(\n `<mg-tabs> prop \"activeTab\" must be a number between ${this.startIndex} and ${this.tabs.length} and new value must be \"activable\". Passed value: ${toString(newValue)}.`,\n );\n }\n }\n\n /**\n * Component tabs\n */\n @State() tabs: TabItem[] = [];\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-tabs']);\n\n /**\n * Emited event when active tab change\n */\n @Event({ eventName: 'active-tab-change' }) activeTabChange: EventEmitter<HTMLMgTabsElement['activeTab']>;\n\n /**\n * Validate that new tab status can be `Status.ACTIVE`\n * @param tab - tab item\n * @returns true when tab match condition to get a `Status.ACTIVE`\n */\n private isActivableTab = (tab: TabItem): boolean => [undefined, Status.ACTIVE, Status.VISIBLE].includes(tab.status);\n\n /**\n * Method to know if given tab has the given status\n * @param tab - item tab key to set to ACTIVE status\n * @param status - status to valide\n * @returns status comparaison\n */\n private tabHasStatus = (tab: TabItem, status: TabItem['status']): boolean => tab.status === status;\n\n /**\n * Method to get element id from index\n * @param element - to get id\n * @param index - to generate id\n * @returns generated element id\n */\n private getElementId = (element: string, index: number): string => `${element}-${this.getTabItemIndex(index)}`;\n\n /**\n * Method to get tab item index\n * @param index - to get\n * @returns index\n */\n private getTabItemIndex = (index: number): number => index + this.startIndex;\n\n /**\n * Handle click events on tabs\n * @param event - mouse event\n */\n private handleClick = (event: MouseEvent & { currentTarget: HTMLElement }): void => {\n const tabId = event.currentTarget.dataset.index;\n if (!this.isActivableTab(this.tabs[Number(tabId) - this.startIndex])) {\n event.preventDefault();\n } else {\n this.activeTab = Number(tabId);\n this.tabFocus = undefined;\n }\n };\n\n /**\n * get navigation button class from given status\n * @param status - button tab status\n * @returns button class/selector variant\n */\n private getNavigationButtonClass = (status: TabItem['status']): string => `${this.buttonTabBaseClass}--${status}`;\n\n /**\n * Handle keyboard event on tabs\n * @param event - mouse event\n */\n private handleKeydown = (event: KeyboardEvent & { target: HTMLElement }): void => {\n const parent = event.target.parentElement;\n if (['ArrowRight', 'ArrowLeft'].includes(event.key)) {\n this.tabFocus = Number(event.target.dataset.index);\n parent.querySelector(`[data-index=\"${this.tabFocus}\"]`).setAttribute('tabindex', '-1');\n\n // Move right\n if (event.key === 'ArrowRight') {\n this.tabFocus++;\n // If we're at the end, go to the start\n if (this.tabFocus > this.tabs.length) this.tabFocus = this.startIndex;\n // Move left\n } else if (event.key === 'ArrowLeft') {\n this.tabFocus--;\n // If we're at the start, move to the end\n if (this.tabFocus < this.startIndex) this.tabFocus = this.tabs.length;\n }\n\n const parentButtonElement: HTMLButtonElement = parent.querySelector(`[data-index=\"${this.tabFocus}\"]`);\n // if focus item is ['hidden'] we recursively repeat action\n if (this.tabHasStatus(this.tabs[this.tabFocus - 1], Status.HIDDEN)) {\n parentButtonElement.dispatchEvent(new KeyboardEvent('keydown', { key: event.key, bubbles: true }));\n // else run focus methods on tabFocus element\n } else {\n parentButtonElement.setAttribute('tabindex', '0');\n parentButtonElement.focus();\n }\n } else if (event.key === 'Tab') {\n this.resetFocus();\n }\n };\n\n /**\n * Reset focus on document click\n * @param event - mouse event\n */\n private handleDocumentClick = (event: MouseEvent & { target: HTMLElement }): void => {\n if (event.target.closest('mg-tabs') !== this.element) this.resetFocus();\n };\n\n /**\n * Method to reset focus behavior\n */\n private resetFocus = (): void => {\n // update asynchronously tabindex to prevent get focus on new tabindex at then end of event process\n nextTick(() => {\n this.tabFocus = undefined;\n Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {\n tab.setAttribute('tabindex', this.activeTab - this.startIndex !== index ? '-1' : '0');\n });\n });\n };\n\n /**\n * Validate slots setting\n */\n private validateSlots = (): void => {\n const slots = Array.from(this.element.children).filter(slot => slot.getAttribute('slot')?.includes('tab_content-'));\n if (slots.length !== this.tabs.length) throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Check tabs format\n this.validateLabel(this.label);\n this.validateItems(this.items);\n this.validateActiveTab(this.activeTab);\n this.validateSize(this.size);\n this.validateSlots();\n }\n\n /**\n * add listners\n */\n componentDidLoad(): void {\n document.addEventListener('click', this.handleDocumentClick, false);\n }\n\n /**\n * remove listeners\n */\n disconnectedCallback(): void {\n document.removeEventListener('keydown', this.handleDocumentClick);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <div class={this.classCollection.join()}>\n <header role=\"tablist\" aria-label={this.label} class=\"mg-c-tabs__header\">\n {this.tabs.map((tab, index) => (\n <button\n key={tab.label}\n role=\"tab\"\n id={this.getElementId(this.identifier, index)}\n class={{\n [`${this.buttonTabBaseClass}`]: true,\n [`${this.buttonTabBaseClass}--horizontal`]: true,\n [`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),\n [`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasStatus(tab, Status.DISABLED),\n [`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasStatus(tab, Status.HIDDEN),\n }}\n tabindex={this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1}\n aria-selected={this.tabHasStatus(tab, Status.ACTIVE).toString()}\n aria-controls={this.getElementId(this.tabPanel, index)}\n aria-disabled={this.tabHasStatus(tab, Status.DISABLED)}\n onClick={this.handleClick}\n onKeyDown={this.handleKeydown}\n data-index={this.getTabItemIndex(index)}\n >\n {tab.icon !== undefined && <mg-icon icon={tab.icon}></mg-icon>}\n {tab.label}\n {tab.badge !== undefined && <mg-badge variant=\"text-color\" value={tab.badge.value} label={tab.badge.label} outline={tab.badge.role === 'information'}></mg-badge>}\n </button>\n ))}\n </header>\n {this.tabs.map((tab, index) => (\n <article\n key={tab.label}\n role=\"tabpanel\"\n id={this.getElementId(this.tabPanel, index)}\n hidden={!this.tabHasStatus(tab, Status.ACTIVE)}\n aria-labelledby={this.getElementId(this.identifier, index)}\n tabindex={this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1}\n class=\"mg-c-tabs__content-container\"\n >\n <slot name={this.getElementId('tab_content', index)}></slot>\n </article>\n ))}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { I as Ie, Z as Ze } from './index.es.js';
|
|
2
|
+
import { I as Ie, Z as Ze, Q as Qe } from './index.es.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* List of all possibles variants
|
|
6
6
|
*/
|
|
7
7
|
const variants = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'];
|
|
8
8
|
|
|
9
|
-
const mgTagCss = ":host{display:inline-block}.mg-c-tag{display:inline-flex;min-height:var(--mg-tag-height);box-sizing:border-box;align-items:center;padding:calc((var(--mg-tag-height) -
|
|
9
|
+
const mgTagCss = "/*!\n * @prop --mg-c-tag-height: Defines the height of the tag. Default value is `--mg-b-size-24`.\n * @prop --mg-c-tag-border-radius: Defines the border radius of the tag. Default value is `--mg-b-size-radius`.\n * @prop --mg-c-tag-font-size: Defines the font size of the tag. Default value is `--mg-b-font-size-small`.\n */:host{display:inline-block}.mg-c-tag{display:inline-flex;min-height:var(--mg-c-tag-height);box-sizing:border-box;align-items:center;padding:calc((var(--mg-c-tag-height) - 2*var(--mg-b-size-border) - var(--mg-c-tag-font-size)*var(--mg-b-line-height))/2) calc(var(--mg-b-size-8) - var(--mg-b-size-border));border:var(--mg-b-size-border) solid;border-radius:var(--mg-c-tag-border-radius);font-size:var(--mg-c-tag-font-size);font-weight:600;text-align:center;vertical-align:middle}.mg-c-tag.mg-c-tag--primary{border-color:var(--mg-b-color-neutral-110);background-color:var(--mg-b-color-neutral-110);color:var(--mg-b-color-text-on-primary)}.mg-c-tag.mg-c-tag--primary.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-neutral-110)}.mg-c-tag.mg-c-tag--primary.mg-c-tag--soft{border-color:var(--mg-b-color-neutral-20);background-color:var(--mg-b-color-neutral-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--primary.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-neutral-110)}.mg-c-tag.mg-c-tag--secondary{border-color:var(--mg-b-color-neutral-10);background-color:var(--mg-b-color-neutral-10);color:var(--mg-b-color-text-on-secondary)}.mg-c-tag.mg-c-tag--secondary.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-neutral-10)}.mg-c-tag.mg-c-tag--secondary.mg-c-tag--soft{border-color:var(--mg-b-color-neutral-20);background-color:var(--mg-b-color-neutral-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--secondary.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-text-on-secondary)}.mg-c-tag.mg-c-tag--danger{border-color:var(--mg-b-color-danger);background-color:var(--mg-b-color-danger);color:var(--mg-b-color-text-on-danger)}.mg-c-tag.mg-c-tag--danger.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-danger)}.mg-c-tag.mg-c-tag--danger.mg-c-tag--soft{border-color:var(--mg-b-color-red-20);background-color:var(--mg-b-color-red-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--danger.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-danger)}.mg-c-tag.mg-c-tag--info{border-color:var(--mg-b-color-info);background-color:var(--mg-b-color-info);color:var(--mg-b-color-text-on-info)}.mg-c-tag.mg-c-tag--info.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-info)}.mg-c-tag.mg-c-tag--info.mg-c-tag--soft{border-color:var(--mg-b-color-blue-20);background-color:var(--mg-b-color-blue-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--info.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-info)}.mg-c-tag.mg-c-tag--success{border-color:var(--mg-b-color-success);background-color:var(--mg-b-color-success);color:var(--mg-b-color-text-on-success)}.mg-c-tag.mg-c-tag--success.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-success)}.mg-c-tag.mg-c-tag--success.mg-c-tag--soft{border-color:var(--mg-b-color-green-20);background-color:var(--mg-b-color-green-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--success.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-success)}.mg-c-tag.mg-c-tag--warning{border-color:var(--mg-b-color-warning);background-color:var(--mg-b-color-warning);color:var(--mg-b-color-text-on-warning)}.mg-c-tag.mg-c-tag--warning.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-warning)}.mg-c-tag.mg-c-tag--warning.mg-c-tag--soft{border-color:var(--mg-b-color-yellow-20);background-color:var(--mg-b-color-yellow-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--warning.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-warning)}::slotted(mg-icon){margin-right:var(--mg-b-size-4)}slot{display:inline-flex;align-items:center}";
|
|
10
10
|
const MgTagStyle0 = mgTagCss;
|
|
11
11
|
|
|
12
12
|
const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class MgTag extends HTMLElement {
|
|
@@ -27,7 +27,7 @@ const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class MgTag extends HTMLElement
|
|
|
27
27
|
}
|
|
28
28
|
validateVariant(newValue, oldValue) {
|
|
29
29
|
if (!variants.includes(newValue)) {
|
|
30
|
-
throw new Error(`<mg-tag> prop "variant" must be one of: ${variants.join(', ')}.`);
|
|
30
|
+
throw new Error(`<mg-tag> prop "variant" must be one of: ${variants.join(', ')}. Passed value: ${Ze(newValue)}.`);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
if (oldValue !== undefined) {
|
|
@@ -60,7 +60,7 @@ const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class MgTag extends HTMLElement
|
|
|
60
60
|
* @param textContent - html element textContent property
|
|
61
61
|
*/
|
|
62
62
|
validateTextContent(textContent) {
|
|
63
|
-
if (!
|
|
63
|
+
if (!Qe(textContent))
|
|
64
64
|
throw new Error('<mg-tag> slot must contain a text content.');
|
|
65
65
|
}
|
|
66
66
|
/*************
|
|
@@ -80,7 +80,7 @@ const MgTag$1 = /*@__PURE__*/ proxyCustomElement(class MgTag extends HTMLElement
|
|
|
80
80
|
* @returns HTML Element
|
|
81
81
|
*/
|
|
82
82
|
render() {
|
|
83
|
-
return (h("span", { key: '
|
|
83
|
+
return (h("span", { key: 'bb99306c07ea9ef4ee193a6e52c2c211378d34df', class: this.classCollection.join() }, h("slot", { key: '0e427b1189217e5d863daf9ed15d35de4832d8dd' })));
|
|
84
84
|
}
|
|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CAAC,2DAA2D,CAAC,CAAC;;QAG3G,IAAI,QAAQ;YAAE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;;YAClD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KAClD;;;;;;;;IAeO,mBAAmB,CAAC,WAAmB;QAC7C,IAAI,CAACC,EAAa,CAAC,WAAW,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;KAChG;;;;;;;IASD,iBAAiB;QACf,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;KACpD;;;;;IAMD,MAAM;QACJ,QACE,6DAAM,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,IACtC,8DAAa,CACR,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgTag","ClassList","toString","isValidString"],"sources":["src/components/atoms/mg-tag/mg-tag.conf.ts","../styles/dist/components/mg-tag.css?tag=mg-tag&encapsulation=shadow","src/components/atoms/mg-tag/mg-tag.tsx"],"sourcesContent":["import type { Variant } from '../../../types';\n\n/**\n * List of all possibles variants\n */\nexport const variants = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'] as const;\n\n/**\n * TagVariantType type from tag variants\n */\nexport type TagVariantType = Variant & (typeof variants)[number];\n","/*!\n * @prop --mg-c-tag-height: Defines the height of the tag. Default value is `--mg-b-size-24`.\n * @prop --mg-c-tag-border-radius: Defines the border radius of the tag. Default value is `--mg-b-size-radius`.\n * @prop --mg-c-tag-font-size: Defines the font size of the tag. Default value is `--mg-b-font-size-small`.\n */:host{display:inline-block}.mg-c-tag{display:inline-flex;min-height:var(--mg-c-tag-height);box-sizing:border-box;align-items:center;padding:calc((var(--mg-c-tag-height) - 2*var(--mg-b-size-border) - var(--mg-c-tag-font-size)*var(--mg-b-line-height))/2) calc(var(--mg-b-size-8) - var(--mg-b-size-border));border:var(--mg-b-size-border) solid;border-radius:var(--mg-c-tag-border-radius);font-size:var(--mg-c-tag-font-size);font-weight:600;text-align:center;vertical-align:middle}.mg-c-tag.mg-c-tag--primary{border-color:var(--mg-b-color-neutral-110);background-color:var(--mg-b-color-neutral-110);color:var(--mg-b-color-text-on-primary)}.mg-c-tag.mg-c-tag--primary.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-neutral-110)}.mg-c-tag.mg-c-tag--primary.mg-c-tag--soft{border-color:var(--mg-b-color-neutral-20);background-color:var(--mg-b-color-neutral-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--primary.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-neutral-110)}.mg-c-tag.mg-c-tag--secondary{border-color:var(--mg-b-color-neutral-10);background-color:var(--mg-b-color-neutral-10);color:var(--mg-b-color-text-on-secondary)}.mg-c-tag.mg-c-tag--secondary.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-neutral-10)}.mg-c-tag.mg-c-tag--secondary.mg-c-tag--soft{border-color:var(--mg-b-color-neutral-20);background-color:var(--mg-b-color-neutral-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--secondary.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-text-on-secondary)}.mg-c-tag.mg-c-tag--danger{border-color:var(--mg-b-color-danger);background-color:var(--mg-b-color-danger);color:var(--mg-b-color-text-on-danger)}.mg-c-tag.mg-c-tag--danger.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-danger)}.mg-c-tag.mg-c-tag--danger.mg-c-tag--soft{border-color:var(--mg-b-color-red-20);background-color:var(--mg-b-color-red-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--danger.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-danger)}.mg-c-tag.mg-c-tag--info{border-color:var(--mg-b-color-info);background-color:var(--mg-b-color-info);color:var(--mg-b-color-text-on-info)}.mg-c-tag.mg-c-tag--info.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-info)}.mg-c-tag.mg-c-tag--info.mg-c-tag--soft{border-color:var(--mg-b-color-blue-20);background-color:var(--mg-b-color-blue-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--info.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-info)}.mg-c-tag.mg-c-tag--success{border-color:var(--mg-b-color-success);background-color:var(--mg-b-color-success);color:var(--mg-b-color-text-on-success)}.mg-c-tag.mg-c-tag--success.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-success)}.mg-c-tag.mg-c-tag--success.mg-c-tag--soft{border-color:var(--mg-b-color-green-20);background-color:var(--mg-b-color-green-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--success.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-success)}.mg-c-tag.mg-c-tag--warning{border-color:var(--mg-b-color-warning);background-color:var(--mg-b-color-warning);color:var(--mg-b-color-text-on-warning)}.mg-c-tag.mg-c-tag--warning.mg-c-tag--outline{background-color:rgba(0,0,0,0);color:var(--mg-b-color-warning)}.mg-c-tag.mg-c-tag--warning.mg-c-tag--soft{border-color:var(--mg-b-color-yellow-20);background-color:var(--mg-b-color-yellow-20);color:var(--mg-b-color-dark);font-weight:400}.mg-c-tag.mg-c-tag--warning.mg-c-tag--soft ::slotted(mg-icon){color:var(--mg-b-color-warning)}::slotted(mg-icon){margin-right:var(--mg-b-size-4)}slot{display:inline-flex;align-items:center}/*# sourceMappingURL=mg-tag.css.map */\n","import { Component, h, Prop, State, Watch, Element } from '@stencil/core';\nimport { TagVariantType, variants } from './mg-tag.conf';\nimport { ClassList, isValidString, toString } from '@mgdis/stencil-helpers';\n/**\n * @slot - Tag content\n */\n@Component({\n tag: 'mg-tag',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-tag.css',\n shadow: true,\n})\nexport class MgTag {\n /************\n * Internal *\n ************/\n\n // Classes\n private readonly classOutline = 'mg-c-tag--outline';\n private readonly classSoft = 'mg-c-tag--soft';\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTagElement;\n\n /**\n * Define tag variant\n */\n @Prop() variant: TagVariantType = variants[0]; // primary\n @Watch('variant')\n validateVariant(newValue: MgTag['variant'], oldValue?: MgTag['variant']): void {\n if (!variants.includes(newValue)) {\n throw new Error(`<mg-tag> prop \"variant\" must be one of: ${variants.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-tag--${oldValue}`);\n }\n this.classCollection.add(`mg-c-tag--${newValue}`);\n }\n }\n\n /**\n * Define if tag is using outline style\n */\n @Prop() outline?: boolean;\n @Watch('outline')\n validateOutline(newValue: MgTag['outline']): void {\n if (newValue) this.classCollection.add(this.classOutline);\n else this.classCollection.delete(this.classOutline);\n }\n\n /**\n * Define if tag is using soft style\n */\n @Prop() soft?: boolean;\n @Watch('soft')\n validateSoft(newValue: MgTag['soft']): void {\n // usage validation\n if (newValue && this.outline) throw new Error('<mg-tag> prop \"soft\" can NOT be used with prop \"outline\".');\n\n // apply class\n if (newValue) this.classCollection.add(this.classSoft);\n else this.classCollection.delete(this.classSoft);\n }\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-tag']);\n\n /*************\n * Methods *\n *************/\n\n /**\n * Validate the given textContent\n * @param textContent - html element textContent property\n */\n private validateTextContent(textContent: string): void {\n if (!isValidString(textContent)) throw new Error('<mg-tag> slot must contain a text content.');\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if props are well configured on init\n */\n componentWillLoad(): void {\n this.validateVariant(this.variant);\n this.validateOutline(this.outline);\n this.validateSoft(this.soft);\n this.validateTextContent(this.element.textContent);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <span class={this.classCollection.join()}>\n <slot></slot>\n </span>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
2
|
|
|
3
|
-
const mgTooltipContentCss = ":host{z-index:1000;display:none;max-width:
|
|
3
|
+
const mgTooltipContentCss = ":host{z-index:1000;display:none;max-width:var(--mg-b-size-floating-element-max-width);box-sizing:border-box;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-radius:var(--mg-c-tooltip-border-radius);background-color:var(--mg-c-tooltip-color-background);color:var(--mg-c-tooltip-color-text);font-family:var(--mg-b-font-family);font-size:var(--mg-b-font-size);font-weight:400;text-align:start}:host([data-show]){display:block}::slotted([slot=arrow]){visibility:hidden}::slotted([slot=arrow])::before{content:\"\";transform:rotate(45deg);visibility:visible}::slotted([slot=arrow]),::slotted([slot=arrow])::before{position:absolute;z-index:9999;width:var(--mg-b-size-8);height:var(--mg-b-size-8);background-color:var(--mg-c-tooltip-color-background)}:host([data-popper-placement^=top])>::slotted([slot=arrow]){bottom:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=bottom])>::slotted([slot=arrow]){top:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=left])>::slotted([slot=arrow]){right:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=right])>::slotted([slot=arrow]){left:calc(-1*var(--mg-b-size-4))}";
|
|
4
4
|
const MgTooltipContentStyle0 = mgTooltipContentCss;
|
|
5
5
|
|
|
6
6
|
const MgTooltipContent = /*@__PURE__*/ proxyCustomElement(class MgTooltipContent extends HTMLElement {
|
|
@@ -18,7 +18,7 @@ const MgTooltipContent = /*@__PURE__*/ proxyCustomElement(class MgTooltipContent
|
|
|
18
18
|
* @returns HTML Element
|
|
19
19
|
*/
|
|
20
20
|
render() {
|
|
21
|
-
return (h(Host, { key: '
|
|
21
|
+
return (h(Host, { key: '2f94fdb8d48e172cc1d1f069ce12d1508e5e7896', role: "tooltip" }, h("span", { key: 'f075e8392eba2cd1256df7e89b7f20c832dc02e8', innerHTML: this.message, class: "mg-tooltip-content__message" }), h("slot", { key: '5f840ac9a4c9c422dc6e012dd8fbb0637232bd5f', name: "arrow" })));
|
|
22
22
|
}
|
|
23
23
|
static get style() { return MgTooltipContentStyle0; }
|
|
24
24
|
}, [1, "mg-tooltip-content", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"mg-tooltip-content2.js","mappings":";;AAAA,MAAM,mBAAmB,GAAG,
|
|
1
|
+
{"file":"mg-tooltip-content2.js","mappings":";;AAAA,MAAM,mBAAmB,GAAG,2mCAA2mC,CAAC;AACxoC,+BAAe,mBAAmB;;MCSrB,gBAAgB;;;;;;;;;;;;;;IAc3B,MAAM;QACJ,QACE,EAAC,IAAI,qDAAC,IAAI,EAAC,SAAS,IAClB,6DAAM,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAC,6BAA6B,GAAQ,EAC1E,6DAAM,IAAI,EAAC,OAAO,GAAQ,CACrB,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["../styles/dist/components/mg-tooltip-content.css?tag=mg-tooltip-content&encapsulation=shadow","src/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.tsx"],"sourcesContent":[":host{z-index:1000;display:none;max-width:var(--mg-b-size-floating-element-max-width);box-sizing:border-box;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-radius:var(--mg-c-tooltip-border-radius);background-color:var(--mg-c-tooltip-color-background);color:var(--mg-c-tooltip-color-text);font-family:var(--mg-b-font-family);font-size:var(--mg-b-font-size);font-weight:400;text-align:start}:host([data-show]){display:block}::slotted([slot=arrow]){visibility:hidden}::slotted([slot=arrow])::before{content:\"\";transform:rotate(45deg);visibility:visible}::slotted([slot=arrow]),::slotted([slot=arrow])::before{position:absolute;z-index:9999;width:var(--mg-b-size-8);height:var(--mg-b-size-8);background-color:var(--mg-c-tooltip-color-background)}:host([data-popper-placement^=top])>::slotted([slot=arrow]){bottom:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=bottom])>::slotted([slot=arrow]){top:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=left])>::slotted([slot=arrow]){right:calc(-1*var(--mg-b-size-4))}:host([data-popper-placement^=right])>::slotted([slot=arrow]){left:calc(-1*var(--mg-b-size-4))}/*# sourceMappingURL=mg-tooltip-content.css.map */\n","import { Component, h, Host, Prop } from '@stencil/core';\n\n/**\n * @internal\n */\n@Component({\n tag: 'mg-tooltip-content',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-tooltip-content.css',\n shadow: true,\n})\nexport class MgTooltipContent {\n /**\n * Displayed message in the tooltip\n */\n @Prop() message!: string;\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"tooltip\">\n <span innerHTML={this.message} class=\"mg-tooltip-content__message\"></span>\n <slot name=\"arrow\"></slot>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { V as Ve, z as ze, Q as Qe, Z as Ze, K as Ke, J as Je } from './index.es.js';
|
|
3
3
|
import { d as defineCustomElement$1 } from './mg-tooltip-content2.js';
|
|
4
4
|
import { c as createPopper } from './popper.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})(Guard || (Guard = {}));
|
|
6
|
+
const Guard = {
|
|
7
|
+
FOCUS: 'focus',
|
|
8
|
+
HOVER_TOOLTIP_ELEMENT: 'hoverTooltip',
|
|
9
|
+
HOVER_TOOLTIPED_ELEMENT: 'hoverTooltiped',
|
|
10
|
+
DISABLE_ON_CLICK: 'disableOnClick',
|
|
11
|
+
};
|
|
13
12
|
|
|
14
|
-
const mgTooltipCss = ":
|
|
13
|
+
const mgTooltipCss = "/*!\n * @prop --mg-c-tooltip-border-radius: Defines the border radius of the tooltip. Default value: `--mg-b-size-radius`.\n * @prop --mg-c-tooltip-color-background: Defines the background color of the tooltip. Default value: `--mg-b-color-dark`.\n * @prop --mg-c-tooltip-color-text: Defines the font color of the tooltip. Default value: `--mg-b-color-light`.\n */:host{display:inline-block}";
|
|
15
14
|
const MgTooltipStyle0 = mgTooltipCss;
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -34,7 +33,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
34
33
|
// Enable the event listeners
|
|
35
34
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
36
35
|
// hide when click outside on nextTick to prevent event to trigger after creation
|
|
37
|
-
|
|
36
|
+
Ve(() => {
|
|
38
37
|
this.windows.forEach((localWindow) => {
|
|
39
38
|
localWindow.addEventListener('click', this.handleClickOutside, false);
|
|
40
39
|
localWindow.addEventListener('keydown', this.handlePressEscape, false);
|
|
@@ -56,7 +55,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
56
55
|
});
|
|
57
56
|
};
|
|
58
57
|
/**
|
|
59
|
-
* Check if clicked outside of component and
|
|
58
|
+
* Check if clicked outside of component and hide tooltip
|
|
60
59
|
* @param event - mouse event
|
|
61
60
|
*/
|
|
62
61
|
this.handleClickOutside = (event) => {
|
|
@@ -64,7 +63,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
64
63
|
this.setDisplay(false);
|
|
65
64
|
};
|
|
66
65
|
/**
|
|
67
|
-
* Check if 'Escape' key is pressed of component and
|
|
66
|
+
* Check if 'Escape' key is pressed of component and hide tooltip
|
|
68
67
|
* @param event - keyboard event
|
|
69
68
|
*/
|
|
70
69
|
this.handlePressEscape = (event) => {
|
|
@@ -117,24 +116,31 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
117
116
|
* @param mgButton - slotted mg-button
|
|
118
117
|
*/
|
|
119
118
|
this.setMgButtonWrapper = (mgButton) => {
|
|
120
|
-
|
|
119
|
+
const buttonWrapperClass = 'mg-c-tooltip__mg-button-wrapper';
|
|
120
|
+
const hasButtonWrapper = mgButton.parentElement.classList.contains(buttonWrapperClass);
|
|
121
|
+
// For disabled mg-button, we need to wrap it in a new element
|
|
122
|
+
// We bind handlers to this new element to keep listener features as workaround to disabled mg-button `pointer-events: none`
|
|
123
|
+
// AND to prevent multiple nested wrappers from rendering when a new render is called with a disabled mg-button
|
|
124
|
+
if (mgButton.disabled && !hasButtonWrapper) {
|
|
125
|
+
// wrap mg-button in a div
|
|
121
126
|
const div = document.createElement('div');
|
|
122
|
-
div.classList.add(
|
|
127
|
+
div.classList.add(buttonWrapperClass);
|
|
123
128
|
mgButton.parentNode.insertBefore(div, mgButton);
|
|
124
129
|
div.appendChild(mgButton);
|
|
125
|
-
|
|
130
|
+
// update tooltipElement
|
|
131
|
+
this.setTooltipedElement(div);
|
|
126
132
|
}
|
|
127
|
-
else if (mgButton.
|
|
133
|
+
else if (!mgButton.disabled && hasButtonWrapper) {
|
|
128
134
|
this.element.firstElementChild.replaceWith(mgButton);
|
|
129
|
-
|
|
135
|
+
// update tooltipElement
|
|
136
|
+
this.setTooltipedElement(mgButton);
|
|
130
137
|
}
|
|
131
138
|
};
|
|
132
139
|
/**
|
|
133
140
|
* Set popper instance
|
|
141
|
+
* @param strategy - popper strategy to apply on instance
|
|
134
142
|
*/
|
|
135
|
-
this.setPopper = () => {
|
|
136
|
-
// use element data attribute: `data-popper-strategy`, in order to get popper strategy configuration
|
|
137
|
-
const strategy = (this.element.dataset.popperStrategy || 'fixed');
|
|
143
|
+
this.setPopper = (strategy) => {
|
|
138
144
|
// Create popperjs tooltip
|
|
139
145
|
this.popper = createPopper(this.tooltipedElement, this.mgTooltipContent, {
|
|
140
146
|
placement: this.placement,
|
|
@@ -215,13 +221,12 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
215
221
|
*/
|
|
216
222
|
this.setAriaDescribedby = (element) => {
|
|
217
223
|
// Set aria-describedby
|
|
218
|
-
|
|
219
|
-
if (ariaDescribedby === null) {
|
|
224
|
+
if (!element.hasAttribute('aria-describedby')) {
|
|
220
225
|
this.tooltipedElement.setAttribute('aria-describedby', this.identifier);
|
|
221
226
|
}
|
|
222
227
|
else {
|
|
223
228
|
// We ensure to have uniq ids
|
|
224
|
-
element.setAttribute('aria-describedby', `${[...new Set([...
|
|
229
|
+
element.setAttribute('aria-describedby', `${[...new Set([...element.getAttribute('aria-describedby').split(' '), this.identifier])].join(' ')}`);
|
|
225
230
|
}
|
|
226
231
|
};
|
|
227
232
|
this.identifier = ze('mg-tooltip');
|
|
@@ -235,8 +240,8 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
235
240
|
this.renderTooltipContent();
|
|
236
241
|
}
|
|
237
242
|
watchMessage(newValue) {
|
|
238
|
-
if (!
|
|
239
|
-
throw new Error(
|
|
243
|
+
if (!Qe(newValue)) {
|
|
244
|
+
throw new Error(`<mg-tooltip> prop "message" is required and must be a string. Passed value: ${Ze(newValue)}.`);
|
|
240
245
|
}
|
|
241
246
|
this.mgTooltipContent.message = newValue;
|
|
242
247
|
}
|
|
@@ -252,7 +257,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
252
257
|
if (this.hasCustomTabIndex) {
|
|
253
258
|
if (newValue)
|
|
254
259
|
this.tooltipedElement.removeAttribute('tabindex');
|
|
255
|
-
else if (this.tooltipedElement.
|
|
260
|
+
else if (!this.tooltipedElement.hasAttribute('tabindex'))
|
|
256
261
|
this.tooltipedElement.setAttribute('tabindex', '0');
|
|
257
262
|
}
|
|
258
263
|
}
|
|
@@ -260,7 +265,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
260
265
|
* Render tooltip content element and init listeners
|
|
261
266
|
*/
|
|
262
267
|
renderTooltipContent() {
|
|
263
|
-
if (this.mgTooltipContent) {
|
|
268
|
+
if (this.mgTooltipContent !== undefined) {
|
|
264
269
|
this.mgTooltipContent.setAttribute('id', this.identifier);
|
|
265
270
|
}
|
|
266
271
|
else {
|
|
@@ -290,7 +295,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
290
295
|
*/
|
|
291
296
|
componentWillLoad() {
|
|
292
297
|
// Get windows to attach events
|
|
293
|
-
this.windows =
|
|
298
|
+
this.windows = Ke(window);
|
|
294
299
|
// Get tooltip element
|
|
295
300
|
this.renderTooltipContent();
|
|
296
301
|
//validate properties
|
|
@@ -308,7 +313,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
308
313
|
// get slotted element wich is not the tooltip
|
|
309
314
|
const slotElement = this.element.querySelector(`*:not(#${this.identifier})`);
|
|
310
315
|
// Get interactive element
|
|
311
|
-
const interactiveElement = slotElement.matches(
|
|
316
|
+
const interactiveElement = slotElement.matches(Je) ? slotElement : (_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(Je);
|
|
312
317
|
this.setTooltipedElement(interactiveElement || slotElement);
|
|
313
318
|
// Check if slotted element is a disabled mg-button
|
|
314
319
|
// In this case we wrap the mg-button into a div to enable the tooltip
|
|
@@ -317,7 +322,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
317
322
|
this.setMgButtonWrapper(slotElement);
|
|
318
323
|
}
|
|
319
324
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
320
|
-
if (!this.disabled &&
|
|
325
|
+
if (!this.disabled && [undefined, null].includes(interactiveElement)) {
|
|
321
326
|
this.hasCustomTabIndex = true;
|
|
322
327
|
slotElement.tabIndex = 0;
|
|
323
328
|
// Add role on non-interactive element to work with "aria-describedby" for screen readers
|
|
@@ -326,7 +331,7 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
326
331
|
// apply a11y aria
|
|
327
332
|
this.setAriaDescribedby(slotElement);
|
|
328
333
|
// set Tooltip
|
|
329
|
-
this.setPopper();
|
|
334
|
+
this.setPopper(this.element.closest('mg-popover') ? 'absolute' : 'fixed');
|
|
330
335
|
// add document keyboard handler
|
|
331
336
|
document.addEventListener('keydown', this.handlePressEscape);
|
|
332
337
|
// check props
|
|
@@ -338,12 +343,22 @@ const MgTooltip = /*@__PURE__*/ proxyCustomElement(class MgTooltip extends HTMLE
|
|
|
338
343
|
componentDidUpdate() {
|
|
339
344
|
this.popper.update();
|
|
340
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* remove listeners
|
|
348
|
+
*/
|
|
349
|
+
disconnectedCallback() {
|
|
350
|
+
document.removeEventListener('keydown', this.handlePressEscape);
|
|
351
|
+
this.windows.forEach((localWindow) => {
|
|
352
|
+
localWindow.removeEventListener('click', this.handleClickOutside, false);
|
|
353
|
+
localWindow.removeEventListener('keydown', this.handlePressEscape, false);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
341
356
|
/**
|
|
342
357
|
* Render
|
|
343
358
|
* @returns HTML Element
|
|
344
359
|
*/
|
|
345
360
|
render() {
|
|
346
|
-
return (h(Host, { key: '
|
|
361
|
+
return (h(Host, { key: '0a3444cfd3b00efaf216995c39775620e5aeb2fe' }, h("slot", { key: '7c34a4814e2705d5470e61866514450f6238008c' }), h("slot", { key: '0df1ade290b5e84d617b9b628d733e823e2c34de', name: "content" })));
|
|
347
362
|
}
|
|
348
363
|
get element() { return this; }
|
|
349
364
|
static get watchers() { return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"mg-tooltip2.js","mappings":";;;;;AAAA,IAAY,KAKX;AALD,WAAY,KAAK;IACf,wBAAe,CAAA;IACf,oDAA2C,CAAA;IAC3C,wDAA+C,CAAA;IAC/C,4CAAmC,CAAA;AACrC,CAAC,EALW,KAAK,KAAL,KAAK;;ACAjB,MAAM,YAAY,GAAG,0HAA0H,CAAC;AAChJ,wBAAe,YAAY;;ACI3B;;;;;AAKA,MAAM,QAAQ,GAAG,CAAC,OAAgB,KAAqC,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAE,OAAmB,CAAC,OAAO,CAAC,CAAC;MAWxJ,SAAS;;;;;;;;QA+EZ,SAAI,GAAG;;YAEb,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC;;YAExC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,qCACzB,OAAO,KACV,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,IAC5E,CAAC,CAAC;;YAEJA,EAAQ,CAAC;gBACP,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAmB;oBACvC,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;oBACtE,WAAW,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;iBACxE,CAAC,CAAC;aACJ,CAAC,CAAC;SACJ,CAAC;;;;QAKM,SAAI,G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,MAAM,kBAAkB,GAAgB,WAAW,CAAC,OAAO,CAACC,EAAiB,CAAC,GAAG,WAAW,GAAG,MAAA,WAAW,CAAC,UAAU,0CAAE,aAAa,CAACA,EAAiB,CAAC,CAAC;QAExJ,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,IAAI,WAAW,CAAC,CAAC;;;QAI5D,IAAI,QAAQ,CAAC,WAAW,CAAC,EAAE;YACzB,IAAI,CAAC,2BAA2B,CAAC,WAAW,CAAC,CAAC;YAC9C,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;SACtC;;QAGD,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,kBAAkB,EAAE;YACzC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAC9B,WAAW,CAAC,QAAQ,GAAG,CAAC,CAAC;;YAEzB,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;SAC5C;;QAGD,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;;QAGrC,IAAI,CAAC,SAAS,EAAE,CAAC;;QAGjB,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;;QAG7D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KACjC;;;;IAKD,kBAAkB;QAChB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;KACtB;;;;;IAMD,MAAM;QACJ,QACE,EAAC,IAAI,uDACH,8DAAa,EACb,6DAAM,IAAI,EAAC,SAAS,GAAQ,CACvB,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["nextTick","createID","isValidString","getWindows","focusableElements"],"sources":["src/components/atoms/mg-tooltip/mg-tooltip.conf.tsx","../styles/dist/components/mg-tooltip.css?tag=mg-tooltip&encapsulation=shadow","src/components/atoms/mg-tooltip/mg-tooltip.tsx"],"sourcesContent":["export enum Guard {\n FOCUS = 'focus',\n HOVER_TOOLTIP_ELEMENT = 'hoverTooltipGuard',\n HOVER_TOOLTIPED_ELEMENT = 'hoverTooltipedGuard',\n DISABLE_ON_CLICK = 'disableOnClick',\n}\n",":host{display:inline-block}mg-tooltip-content{font-family:var(--font-family);font-size:var(--font-size);font-weight:200}/*# sourceMappingURL=mg-tooltip.css.map */\n","import { Component, Element, h, Host, Prop, Watch } from '@stencil/core';\nimport { createID, focusableElements, getWindows, isValidString, nextTick } from '@mgdis/stencil-helpers';\nimport { Instance as PopperInstance, createPopper, Placement, PositioningStrategy } from '@popperjs/core';\nimport { Guard } from './mg-tooltip.conf';\n\n/**\n * HTMLMgButtonElement type guard\n * @param element - element to check\n * @returns return true if type is HTMLMgButtonElement\n */\nconst isButton = (element: unknown): element is HTMLMgButtonElement => typeof element === 'object' && ['MG-BUTTON', 'BUTTON'].includes((element as Element).tagName);\n\n/**\n * @slot - Element that will display the tooltip\n * @slot content - Tooltip content\n */\n@Component({\n tag: 'mg-tooltip',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-tooltip.css',\n shadow: true,\n})\nexport class MgTooltip {\n /************\n * Internal *\n ************/\n\n private popper: PopperInstance;\n private mgTooltipContent: HTMLMgTooltipContentElement;\n private tooltipedElement: HTMLElement;\n private windows: Window[];\n private hasCustomTabIndex: boolean;\n\n // tooltip actions guards\n private guard: Guard;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTooltipElement;\n\n /**\n * Sets an `id` attribute.\n * Needed by the input for accessibility `aria-decribedby`.\n */\n @Prop() identifier: string = createID('mg-tooltip');\n @Watch('identifier')\n watchIdentifier(): void {\n // use renderTooltipContent to update tooltip-content id\n this.renderTooltipContent();\n }\n\n /**\n * Displayed message in the tooltip\n */\n @Prop() message!: string;\n @Watch('message')\n watchMessage(newValue: MgTooltip['message']): void {\n if (!isValidString(newValue)) {\n throw new Error('<mg-tooltip> prop \"message\" is required.');\n }\n this.mgTooltipContent.message = newValue;\n }\n\n /**\n * Tooltip placement\n */\n @Prop() placement: Placement = 'bottom';\n\n /**\n * Display tooltip\n */\n @Prop({ mutable: true }) display = false;\n @Watch('display')\n watchDisplay(newValue: MgTooltip['display']): void {\n if (newValue) {\n this.show();\n } else {\n this.hide();\n }\n }\n\n /**\n * Disable tooltip\n */\n @Prop() disabled = false;\n @Watch('disabled')\n watchDisabled(newValue: MgTooltip['disabled']): void {\n if (this.hasCustomTabIndex) {\n if (newValue) this.tooltipedElement.removeAttribute('tabindex');\n else if (this.tooltipedElement.getAttribute('tabindex') === null) this.tooltipedElement.setAttribute('tabindex', '0');\n }\n }\n\n /**\n * Show tooltip\n */\n private show = (): void => {\n // Make the tooltip visible\n this.mgTooltipContent.dataset.show = '';\n // Enable the event listeners\n this.popper.setOptions(options => ({\n ...options,\n modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }],\n }));\n // hide when click outside on nextTick to prevent event to trigger after creation\n nextTick(() => {\n this.windows.forEach((localWindow: Window) => {\n localWindow.addEventListener('click', this.handleClickOutside, false);\n localWindow.addEventListener('keydown', this.handlePressEscape, false);\n });\n });\n };\n\n /**\n * Hide tooltip\n */\n private hide = (): void => {\n // Hide the tooltip\n this.mgTooltipContent.removeAttribute('data-show');\n // Disable the event listeners\n this.popper.setOptions(options => ({\n ...options,\n modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }],\n }));\n // Remove event listener\n this.windows.forEach((localWindow: Window) => {\n localWindow.removeEventListener('click', this.handleClickOutside, false);\n localWindow.removeEventListener('keyboard', this.handlePressEscape, false);\n });\n };\n\n /**\n * Check if clicked outside of component and hidde tooltip\n * @param event - mouse event\n */\n private handleClickOutside = (event: MouseEvent & { target: HTMLElement }): void => {\n if (event.target.closest('mg-tooltip') !== this.element) this.setDisplay(false);\n };\n\n /**\n * Check if 'Escape' key is pressed of component and hidde tooltip\n * @param event - keyboard event\n */\n private handlePressEscape = (event: KeyboardEvent): void => {\n if (event.code === 'Escape') {\n this.setDisplay(false);\n this.resetGuard();\n }\n };\n\n /**\n * Method to set display prop\n * @param newValue - display prop new value\n * @param condition - additionnal condition to apply display prop newValue\n */\n private setDisplay = (newValue: MgTooltip['display'], condition = true): void => {\n if (!this.disabled && condition) this.display = newValue;\n };\n\n /**\n * Action for tooltip element and tooltiped element mouse listener\n * @param elementGuard - tooltip element guard\n * @param eventName - event name\n * @param conditionalGuard - guard condition\n */\n private tooltipMouseListenerAction = (elementGuard: Guard, eventName: 'mouseenter' | 'mouseleave', conditionalGuard: Guard): void => {\n // active FOCUS guard cancel process\n if ([Guard.FOCUS, Guard.DISABLE_ON_CLICK].includes(this.guard)) {\n return;\n }\n\n // Update guard by element guard\n this.guard = elementGuard;\n\n if (eventName !== 'mouseenter') {\n // process action in the next event loop macro task\n setTimeout(() => {\n this.setDisplay(false, this.guard !== conditionalGuard);\n this.resetGuard();\n }, 100);\n } else if (this.guard === Guard.HOVER_TOOLTIPED_ELEMENT) {\n this.setDisplay(true);\n }\n };\n\n /**\n * Method to reset guard value\n */\n private resetGuard = (): void => {\n this.guard = undefined;\n };\n\n /**\n * Update slot content when it is a mg-button\n * @param mgButton - slotted mg-button\n */\n private setMgButtonWrapper = (mgButton: HTMLMgButtonElement): void => {\n if (mgButton.disabled) {\n const div = document.createElement('div');\n div.classList.add('mg-c-tooltip__mg-button-wrapper');\n mgButton.parentNode.insertBefore(div, mgButton);\n div.appendChild(mgButton);\n this.tooltipedElement = div;\n } else if (mgButton.parentElement.classList.contains('mg-c-tooltip__mg-button-wrapper')) {\n this.element.firstElementChild.replaceWith(mgButton);\n this.tooltipedElement = mgButton;\n }\n };\n\n /**\n * Set popper instance\n */\n private setPopper = (): void => {\n // use element data attribute: `data-popper-strategy`, in order to get popper strategy configuration\n const strategy = (this.element.dataset.popperStrategy || 'fixed') as PositioningStrategy;\n\n // Create popperjs tooltip\n this.popper = createPopper(this.tooltipedElement, this.mgTooltipContent, {\n placement: this.placement,\n strategy,\n modifiers: [\n {\n name: 'offset',\n options: {\n offset: [0, 8],\n },\n },\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['auto'],\n },\n },\n ],\n });\n };\n\n /**\n * Define selected element to become tooltip selector and init listeners\n * @param element - tooltiped element\n */\n private setTooltipedElement = (element: HTMLElement): void => {\n this.tooltipedElement = element;\n\n // Manage tooltipedElement focus events\n this.tooltipedElement.addEventListener('focus', () => {\n this.guard = Guard.FOCUS;\n this.setDisplay(true);\n });\n\n // as `click` event is the composition of `mousedown` and `mouseup` event,\n // and `click` event trigger `focus` event after a success `mousedown` wich set the `guard` to `Guard.FOCUS`\n // we reset the guard on `mouseup` event to unlock tooltip\n this.tooltipedElement.addEventListener('mouseup', () => {\n this.resetGuard();\n });\n\n this.tooltipedElement.addEventListener('blur', () => {\n this.resetGuard();\n this.setDisplay(false);\n });\n\n // manage tooltipElement & tooltipedElement mouseenter/mouseleave events\n this.tooltipedElement.addEventListener('mouseenter', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, 'mouseenter', Guard.HOVER_TOOLTIP_ELEMENT);\n });\n\n this.tooltipedElement.addEventListener('mouseleave', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, 'mouseleave', Guard.HOVER_TOOLTIP_ELEMENT);\n });\n };\n\n /**\n * Set button mutation observer\n * @param mgButton - mg-button to observe\n */\n private setMgButtonMutationObserver = (mgButton: HTMLMgButtonElement): void => {\n new MutationObserver(mutationList => {\n // stop process when none of mutations attributed is disabled\n if (!mutationList.some(mutation => ['aria-disabled', 'disabled'].includes(mutation.attributeName))) return;\n\n // set guard when one of mutations is for a disabled with disabled-on-click\n if (mutationList.some((mutation: MutationRecord & { target: HTMLMgButtonElement }) => mutation.target.disabled && mutation.target.disableOnClick)) {\n this.guard = Guard.DISABLE_ON_CLICK;\n }\n\n // when the disabled-on-click guard is running we stop process\n if (this.guard === Guard.DISABLE_ON_CLICK) return;\n\n // update button wrapper\n this.setMgButtonWrapper(mgButton);\n\n // Since Firefox doesn't trigger a \"blur\" event when the \"disabled\" attribute is added or removed from a button\n // we have to manually unlock the guard because the \"blur\" handler of the tooltipedElement won't do it.\n this.resetGuard();\n\n // update popper instance\n this.popper.update();\n }).observe(mgButton, { attributes: true });\n };\n\n /**\n * Set tooltiped element aria-describedby\n * @param element - element to update\n */\n private setAriaDescribedby = (element: HTMLElement): void => {\n // Set aria-describedby\n const ariaDescribedby = element.getAttribute('aria-describedby');\n\n if (ariaDescribedby === null) {\n this.tooltipedElement.setAttribute('aria-describedby', this.identifier);\n } else {\n // We ensure to have uniq ids\n element.setAttribute('aria-describedby', `${[...new Set([...ariaDescribedby.split(' '), this.identifier])].join(' ')}`);\n }\n };\n\n /**\n * Render tooltip content element and init listeners\n */\n private renderTooltipContent(): void {\n if (this.mgTooltipContent) {\n this.mgTooltipContent.setAttribute('id', this.identifier);\n } else {\n this.mgTooltipContent = document.createElement('mg-tooltip-content');\n this.mgTooltipContent.setAttribute('slot', 'content');\n this.mgTooltipContent.setAttribute('id', this.identifier);\n\n const arrow = document.createElement('div');\n arrow.setAttribute('slot', 'arrow');\n arrow.dataset.popperArrow = '';\n this.mgTooltipContent.appendChild(arrow);\n\n // manage tooltipElement & tooltipedElement mouseenter/mouseleave events\n this.mgTooltipContent.addEventListener('mouseenter', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, 'mouseenter', Guard.HOVER_TOOLTIPED_ELEMENT);\n });\n this.mgTooltipContent.addEventListener('mouseleave', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, 'mouseleave', Guard.HOVER_TOOLTIPED_ELEMENT);\n });\n\n // append tooltip element to component\n this.element.appendChild(this.mgTooltipContent);\n }\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * set variables\n */\n componentWillLoad(): void {\n // Get windows to attach events\n this.windows = getWindows(window);\n\n // Get tooltip element\n this.renderTooltipContent();\n\n //validate properties\n this.watchDisabled(this.disabled);\n this.watchMessage(this.message);\n this.watchIdentifier();\n }\n\n /**\n * Get slotted element\n * Check if it already contain an interactive element, if not we need to add a tabIndex attribute\n * We need to attach the focused element to the tooltip (aria-describedby)\n */\n componentDidLoad(): void {\n // get slotted element wich is not the tooltip\n const slotElement: HTMLElement = this.element.querySelector(`*:not(#${this.identifier})`);\n\n // Get interactive element\n const interactiveElement: HTMLElement = slotElement.matches(focusableElements) ? slotElement : slotElement.shadowRoot?.querySelector(focusableElements);\n\n this.setTooltipedElement(interactiveElement || slotElement);\n\n // Check if slotted element is a disabled mg-button\n // In this case we wrap the mg-button into a div to enable the tooltip\n if (isButton(slotElement)) {\n this.setMgButtonMutationObserver(slotElement);\n this.setMgButtonWrapper(slotElement);\n }\n\n // Add tabindex to slotted element if we can't find any interactive element\n if (!this.disabled && !interactiveElement) {\n this.hasCustomTabIndex = true;\n slotElement.tabIndex = 0;\n // Add role on non-interactive element to work with \"aria-describedby\" for screen readers\n slotElement.setAttribute('role', 'button');\n }\n\n // apply a11y aria\n this.setAriaDescribedby(slotElement);\n\n // set Tooltip\n this.setPopper();\n\n // add document keyboard handler\n document.addEventListener('keydown', this.handlePressEscape);\n\n // check props\n this.watchDisplay(this.display);\n }\n\n /**\n * update popper position after props change on component did update hook to benefit from render ended\n */\n componentDidUpdate(): void {\n this.popper.update();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host>\n <slot></slot>\n <slot name=\"content\"></slot>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"mg-tooltip2.js","mappings":";;;;;AAEO,MAAM,KAAK,GAA8B;IAC9C,KAAK,EAAE,OAAO;IACd,qBAAqB,EAAE,cAAc;IACrC,uBAAuB,EAAE,gBAAgB;IACzC,gBAAgB,EAAE,gBAAgB;CACnC;;ACPD,MAAM,YAAY,GAAG,yYAAyY,CAAC;AAC/Z,wBAAe,YAAY;;ACI3B;;;;;AAKA,MAAM,QAAQ,GAAG,C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ms/mg-tooltip/mg-tooltip.conf.tsx","../styles/dist/components/mg-tooltip.css?tag=mg-tooltip&encapsulation=shadow","src/components/atoms/mg-tooltip/mg-tooltip.tsx"],"sourcesContent":["export type GuardType = 'focus' | 'hoverTooltip' | 'hoverTooltiped' | 'disableOnClick';\n\nexport const Guard: Record<string, GuardType> = {\n FOCUS: 'focus',\n HOVER_TOOLTIP_ELEMENT: 'hoverTooltip',\n HOVER_TOOLTIPED_ELEMENT: 'hoverTooltiped',\n DISABLE_ON_CLICK: 'disableOnClick',\n};\n","/*!\n * @prop --mg-c-tooltip-border-radius: Defines the border radius of the tooltip. Default value: `--mg-b-size-radius`.\n * @prop --mg-c-tooltip-color-background: Defines the background color of the tooltip. Default value: `--mg-b-color-dark`.\n * @prop --mg-c-tooltip-color-text: Defines the font color of the tooltip. Default value: `--mg-b-color-light`.\n */:host{display:inline-block}/*# sourceMappingURL=mg-tooltip.css.map */\n","import { Component, Element, h, Host, Prop, Watch } from '@stencil/core';\nimport { createID, focusableElements, getWindows, isValidString, nextTick, toString } from '@mgdis/stencil-helpers';\nimport { Instance as PopperInstance, createPopper, Placement, PositioningStrategy } from '@popperjs/core';\nimport { type GuardType, Guard } from './mg-tooltip.conf';\n\n/**\n * HTMLMgButtonElement type guard\n * @param element - element to check\n * @returns return true if type is HTMLMgButtonElement\n */\nconst isButton = (element: unknown): element is HTMLMgButtonElement => typeof element === 'object' && ['MG-BUTTON', 'BUTTON'].includes((element as Element).tagName);\n\n/**\n * @slot - Element that will display the tooltip\n * @slot content - Tooltip content\n */\n@Component({\n tag: 'mg-tooltip',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-tooltip.css',\n shadow: true,\n})\nexport class MgTooltip {\n /************\n * Internal *\n ************/\n\n private popper: PopperInstance;\n private mgTooltipContent: HTMLMgTooltipContentElement;\n private tooltipedElement: HTMLElement;\n private windows: Window[];\n private hasCustomTabIndex: boolean;\n\n // tooltip actions guards\n private guard: GuardType;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTooltipElement;\n\n /**\n * Sets an `id` attribute.\n * Needed by the input for accessibility `aria-decribedby`.\n */\n @Prop() identifier: string = createID('mg-tooltip');\n @Watch('identifier')\n watchIdentifier(): void {\n // use renderTooltipContent to update tooltip-content id\n this.renderTooltipContent();\n }\n\n /**\n * Displayed message in the tooltip\n */\n @Prop() message!: string;\n @Watch('message')\n watchMessage(newValue: MgTooltip['message']): void {\n if (!isValidString(newValue)) {\n throw new Error(`<mg-tooltip> prop \"message\" is required and must be a string. Passed value: ${toString(newValue)}.`);\n }\n this.mgTooltipContent.message = newValue;\n }\n\n /**\n * Tooltip placement\n */\n @Prop() placement: Placement = 'bottom';\n\n /**\n * Display tooltip\n */\n @Prop({ mutable: true }) display = false;\n @Watch('display')\n watchDisplay(newValue: MgTooltip['display']): void {\n if (newValue) {\n this.show();\n } else {\n this.hide();\n }\n }\n\n /**\n * Disable tooltip\n */\n @Prop() disabled = false;\n @Watch('disabled')\n watchDisabled(newValue: MgTooltip['disabled']): void {\n if (this.hasCustomTabIndex) {\n if (newValue) this.tooltipedElement.removeAttribute('tabindex');\n else if (!this.tooltipedElement.hasAttribute('tabindex')) this.tooltipedElement.setAttribute('tabindex', '0');\n }\n }\n\n /**\n * Show tooltip\n */\n private show = (): void => {\n // Make the tooltip visible\n this.mgTooltipContent.dataset.show = '';\n // Enable the event listeners\n this.popper.setOptions(options => ({\n ...options,\n modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }],\n }));\n // hide when click outside on nextTick to prevent event to trigger after creation\n nextTick(() => {\n this.windows.forEach((localWindow: Window) => {\n localWindow.addEventListener('click', this.handleClickOutside, false);\n localWindow.addEventListener('keydown', this.handlePressEscape, false);\n });\n });\n };\n\n /**\n * Hide tooltip\n */\n private hide = (): void => {\n // Hide the tooltip\n this.mgTooltipContent.removeAttribute('data-show');\n // Disable the event listeners\n this.popper.setOptions(options => ({\n ...options,\n modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }],\n }));\n // Remove event listener\n this.windows.forEach((localWindow: Window) => {\n localWindow.removeEventListener('click', this.handleClickOutside, false);\n localWindow.removeEventListener('keyboard', this.handlePressEscape, false);\n });\n };\n\n /**\n * Check if clicked outside of component and hide tooltip\n * @param event - mouse event\n */\n private handleClickOutside = (event: MouseEvent & { target: HTMLElement }): void => {\n if (event.target.closest('mg-tooltip') !== this.element) this.setDisplay(false);\n };\n\n /**\n * Check if 'Escape' key is pressed of component and hide tooltip\n * @param event - keyboard event\n */\n private handlePressEscape = (event: KeyboardEvent): void => {\n if (event.code === 'Escape') {\n this.setDisplay(false);\n this.resetGuard();\n }\n };\n\n /**\n * Method to set display prop\n * @param newValue - display prop new value\n * @param condition - additionnal condition to apply display prop newValue\n */\n private setDisplay = (newValue: MgTooltip['display'], condition = true): void => {\n if (!this.disabled && condition) this.display = newValue;\n };\n\n /**\n * Action for tooltip element and tooltiped element mouse listener\n * @param elementGuard - tooltip element guard\n * @param eventName - event name\n * @param conditionalGuard - guard condition\n */\n private tooltipMouseListenerAction = (elementGuard: GuardType, eventName: 'mouseenter' | 'mouseleave', conditionalGuard: GuardType): void => {\n // active FOCUS guard cancel process\n if ([Guard.FOCUS, Guard.DISABLE_ON_CLICK].includes(this.guard)) {\n return;\n }\n\n // Update guard by element guard\n this.guard = elementGuard;\n\n if (eventName !== 'mouseenter') {\n // process action in the next event loop macro task\n setTimeout(() => {\n this.setDisplay(false, this.guard !== conditionalGuard);\n this.resetGuard();\n }, 100);\n } else if (this.guard === Guard.HOVER_TOOLTIPED_ELEMENT) {\n this.setDisplay(true);\n }\n };\n\n /**\n * Method to reset guard value\n */\n private resetGuard = (): void => {\n this.guard = undefined;\n };\n\n /**\n * Update slot content when it is a mg-button\n * @param mgButton - slotted mg-button\n */\n private setMgButtonWrapper = (mgButton: HTMLMgButtonElement): void => {\n const buttonWrapperClass = 'mg-c-tooltip__mg-button-wrapper';\n const hasButtonWrapper = mgButton.parentElement.classList.contains(buttonWrapperClass);\n // For disabled mg-button, we need to wrap it in a new element\n // We bind handlers to this new element to keep listener features as workaround to disabled mg-button `pointer-events: none`\n // AND to prevent multiple nested wrappers from rendering when a new render is called with a disabled mg-button\n if (mgButton.disabled && !hasButtonWrapper) {\n // wrap mg-button in a div\n const div = document.createElement('div');\n div.classList.add(buttonWrapperClass);\n mgButton.parentNode.insertBefore(div, mgButton);\n div.appendChild(mgButton);\n\n // update tooltipElement\n this.setTooltipedElement(div);\n } else if (!mgButton.disabled && hasButtonWrapper) {\n this.element.firstElementChild.replaceWith(mgButton);\n\n // update tooltipElement\n this.setTooltipedElement(mgButton);\n }\n };\n\n /**\n * Set popper instance\n * @param strategy - popper strategy to apply on instance\n */\n private setPopper = (strategy: PositioningStrategy): void => {\n // Create popperjs tooltip\n this.popper = createPopper(this.tooltipedElement, this.mgTooltipContent, {\n placement: this.placement,\n strategy,\n modifiers: [\n {\n name: 'offset',\n options: {\n offset: [0, 8],\n },\n },\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['auto'],\n },\n },\n ],\n });\n };\n\n /**\n * Define selected element to become tooltip selector and init listeners\n * @param element - tooltiped element\n */\n private setTooltipedElement = (element: HTMLElement): void => {\n this.tooltipedElement = element;\n\n // Manage tooltipedElement focus events\n this.tooltipedElement.addEventListener('focus', () => {\n this.guard = Guard.FOCUS;\n this.setDisplay(true);\n });\n\n // as `click` event is the composition of `mousedown` and `mouseup` event,\n // and `click` event trigger `focus` event after a success `mousedown` wich set the `guard` to `Guard.FOCUS`\n // we reset the guard on `mouseup` event to unlock tooltip\n this.tooltipedElement.addEventListener('mouseup', () => {\n this.resetGuard();\n });\n\n this.tooltipedElement.addEventListener('blur', () => {\n this.resetGuard();\n this.setDisplay(false);\n });\n\n // manage tooltipElement & tooltipedElement mouseenter/mouseleave events\n this.tooltipedElement.addEventListener('mouseenter', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, 'mouseenter', Guard.HOVER_TOOLTIP_ELEMENT);\n });\n\n this.tooltipedElement.addEventListener('mouseleave', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, 'mouseleave', Guard.HOVER_TOOLTIP_ELEMENT);\n });\n };\n\n /**\n * Set button mutation observer\n * @param mgButton - mg-button to observe\n */\n private setMgButtonMutationObserver = (mgButton: HTMLMgButtonElement): void => {\n new MutationObserver(mutationList => {\n // stop process when none of mutations attributed is disabled\n if (!mutationList.some(mutation => ['aria-disabled', 'disabled'].includes(mutation.attributeName))) return;\n\n // set guard when one of mutations is for a disabled with disabled-on-click\n if (mutationList.some((mutation: MutationRecord & { target: HTMLMgButtonElement }) => mutation.target.disabled && mutation.target.disableOnClick)) {\n this.guard = Guard.DISABLE_ON_CLICK;\n }\n\n // when the disabled-on-click guard is running we stop process\n if (this.guard === Guard.DISABLE_ON_CLICK) return;\n\n // update button wrapper\n this.setMgButtonWrapper(mgButton);\n\n // Since Firefox doesn't trigger a \"blur\" event when the \"disabled\" attribute is added or removed from a button\n // we have to manually unlock the guard because the \"blur\" handler of the tooltipedElement won't do it.\n this.resetGuard();\n\n // update popper instance\n this.popper.update();\n }).observe(mgButton, { attributes: true });\n };\n\n /**\n * Set tooltiped element aria-describedby\n * @param element - element to update\n */\n private setAriaDescribedby = (element: HTMLElement): void => {\n // Set aria-describedby\n if (!element.hasAttribute('aria-describedby')) {\n this.tooltipedElement.setAttribute('aria-describedby', this.identifier);\n } else {\n // We ensure to have uniq ids\n element.setAttribute('aria-describedby', `${[...new Set([...element.getAttribute('aria-describedby').split(' '), this.identifier])].join(' ')}`);\n }\n };\n\n /**\n * Render tooltip content element and init listeners\n */\n private renderTooltipContent(): void {\n if (this.mgTooltipContent !== undefined) {\n this.mgTooltipContent.setAttribute('id', this.identifier);\n } else {\n this.mgTooltipContent = document.createElement('mg-tooltip-content');\n this.mgTooltipContent.setAttribute('slot', 'content');\n this.mgTooltipContent.setAttribute('id', this.identifier);\n\n const arrow = document.createElement('div');\n arrow.setAttribute('slot', 'arrow');\n arrow.dataset.popperArrow = '';\n this.mgTooltipContent.appendChild(arrow);\n\n // manage tooltipElement & tooltipedElement mouseenter/mouseleave events\n this.mgTooltipContent.addEventListener('mouseenter', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, 'mouseenter', Guard.HOVER_TOOLTIPED_ELEMENT);\n });\n this.mgTooltipContent.addEventListener('mouseleave', () => {\n this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, 'mouseleave', Guard.HOVER_TOOLTIPED_ELEMENT);\n });\n\n // append tooltip element to component\n this.element.appendChild(this.mgTooltipContent);\n }\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * set variables\n */\n componentWillLoad(): void {\n // Get windows to attach events\n this.windows = getWindows(window);\n\n // Get tooltip element\n this.renderTooltipContent();\n\n //validate properties\n this.watchDisabled(this.disabled);\n this.watchMessage(this.message);\n this.watchIdentifier();\n }\n\n /**\n * Get slotted element\n * Check if it already contain an interactive element, if not we need to add a tabIndex attribute\n * We need to attach the focused element to the tooltip (aria-describedby)\n */\n componentDidLoad(): void {\n // get slotted element wich is not the tooltip\n const slotElement: HTMLElement = this.element.querySelector(`*:not(#${this.identifier})`);\n\n // Get interactive element\n const interactiveElement: HTMLElement = slotElement.matches(focusableElements) ? slotElement : slotElement.shadowRoot?.querySelector(focusableElements);\n\n this.setTooltipedElement(interactiveElement || slotElement);\n\n // Check if slotted element is a disabled mg-button\n // In this case we wrap the mg-button into a div to enable the tooltip\n if (isButton(slotElement)) {\n this.setMgButtonMutationObserver(slotElement);\n this.setMgButtonWrapper(slotElement);\n }\n\n // Add tabindex to slotted element if we can't find any interactive element\n if (!this.disabled && [undefined, null].includes(interactiveElement)) {\n this.hasCustomTabIndex = true;\n slotElement.tabIndex = 0;\n // Add role on non-interactive element to work with \"aria-describedby\" for screen readers\n slotElement.setAttribute('role', 'button');\n }\n\n // apply a11y aria\n this.setAriaDescribedby(slotElement);\n\n // set Tooltip\n this.setPopper(this.element.closest('mg-popover') ? 'absolute' : 'fixed');\n\n // add document keyboard handler\n document.addEventListener('keydown', this.handlePressEscape);\n\n // check props\n this.watchDisplay(this.display);\n }\n\n /**\n * update popper position after props change on component did update hook to benefit from render ended\n */\n componentDidUpdate(): void {\n this.popper.update();\n }\n\n /**\n * remove listeners\n */\n disconnectedCallback(): void {\n document.removeEventListener('keydown', this.handlePressEscape);\n this.windows.forEach((localWindow: Window) => {\n localWindow.removeEventListener('click', this.handleClickOutside, false);\n localWindow.removeEventListener('keydown', this.handlePressEscape, false);\n });\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host>\n <slot></slot>\n <slot name=\"content\"></slot>\n </Host>\n );\n }\n}\n"],"version":3}
|