@mgdis/mg-components 5.15.0 → 5.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-fede8ee2.js → index-c042e24b.js} +321 -68
- package/dist/cjs/index-c042e24b.js.map +1 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +5 -12
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/{mg-action-more_32.cjs.entry.js → mg-action-more_34.cjs.entry.js} +341 -112
- package/dist/cjs/mg-action-more_34.cjs.entry.js.map +1 -0
- package/dist/cjs/mg-components.cjs.js +5 -3
- package/dist/cjs/mg-components.cjs.js.map +1 -0
- package/dist/cjs/mg-item-more.cjs.entry.js +8 -4
- package/dist/cjs/mg-item-more.cjs.entry.js.map +1 -0
- package/dist/cjs/{mg-menu.conf-f9d0ddec.js → mg-menu.conf-43aacf30.js} +2 -0
- package/dist/cjs/mg-menu.conf-43aacf30.js.map +1 -0
- package/dist/collection/assets/icons/index.js +184 -0
- package/dist/collection/collection-manifest.json +37 -35
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +6 -4
- package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -0
- package/dist/collection/components/atoms/mg-badge/test/mg-badge.e2e.playwright.js +33 -0
- package/dist/collection/components/atoms/mg-badge/test/mg-badge.e2e.playwright.js.map +1 -0
- package/dist/collection/components/atoms/mg-badge/test/mg-badge.spec.js +70 -0
- package/dist/collection/components/atoms/mg-badge/test/mg-badge.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +10 -6
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -0
- package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js +91 -0
- package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js +142 -0
- package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-card/mg-card.conf.js +1 -0
- package/dist/collection/components/atoms/mg-card/mg-card.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-card/mg-card.js +8 -5
- package/dist/collection/components/atoms/mg-card/mg-card.js.map +1 -0
- package/dist/collection/components/atoms/mg-card/test/mg-card.e2e.js +36 -0
- package/dist/collection/components/atoms/mg-card/test/mg-card.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-card/test/mg-card.spec.js +43 -0
- package/dist/collection/components/atoms/mg-card/test/mg-card.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +3 -2
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js.map +1 -0
- package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.e2e.js +15 -0
- package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.spec.js +42 -0
- package/dist/collection/components/atoms/mg-character-left/test/mg-character-left.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +2 -1
- package/dist/collection/components/atoms/mg-divider/mg-divider.js.map +1 -0
- package/dist/collection/components/atoms/mg-divider/test/mg-divider.e2e.js +11 -0
- package/dist/collection/components/atoms/mg-divider/test/mg-divider.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-divider/test/mg-divider.spec.js +14 -0
- package/dist/collection/components/atoms/mg-divider/test/mg-divider.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +1 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +11 -7
- package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -0
- package/dist/collection/components/atoms/mg-icon/test/mg-icon.e2e.js +55 -0
- package/dist/collection/components/atoms/mg-icon/test/mg-icon.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-icon/test/mg-icon.spec.js +84 -0
- package/dist/collection/components/atoms/mg-icon/test/mg-icon.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +2 -1
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js.map +1 -0
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.js +18 -0
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.spec.js +27 -0
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js +1 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +6 -4
- package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -0
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.js +37 -0
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.spec.js +71 -0
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.spec.js.map +1 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.css +43 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +50 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js.map +1 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +1 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +0 -43
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +64 -17
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -0
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.e2e.js +132 -0
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.e2e.js.map +1 -0
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js +264 -0
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/MgInput.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/MgInput.js +3 -2
- package/dist/collection/components/molecules/inputs/MgInput.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +2 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +12 -7
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +18 -12
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.js +243 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js +581 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +10 -8
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.e2e.js +123 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js +324 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +46 -23
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.e2e.js +212 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js +401 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +10 -7
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.e2e.js +115 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js +234 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -7
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.e2e.js +154 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.spec.js +295 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +14 -9
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.e2e.js +194 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js +344 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +12 -8
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.js +171 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js +280 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +10 -7
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.e2e.js +129 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js +255 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +6 -4
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.js +125 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js +203 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +1 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +9 -5
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.e2e.js +268 -0
- package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.e2e.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.spec.js +175 -0
- package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.spec.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +12 -9
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.js +119 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.spec.js +295 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +27 -14
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -0
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.js +128 -0
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.spec.js +187 -0
- package/dist/collection/components/molecules/mg-action-more/test/mg-action-more.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-details/mg-details.js +3 -2
- package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -0
- package/dist/collection/components/molecules/mg-details/test/mg-details.e2e.playwright.js +30 -0
- package/dist/collection/components/molecules/mg-details/test/mg-details.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-details/test/mg-details.spec.js +42 -0
- package/dist/collection/components/molecules/mg-details/test/mg-details.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +17 -7
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -0
- package/dist/collection/components/molecules/mg-form/test/mg-form.e2e.js +169 -0
- package/dist/collection/components/molecules/mg-form/test/mg-form.e2e.js.map +1 -0
- package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js +277 -0
- package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +3 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -0
- package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.e2e.js +39 -0
- package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.e2e.js.map +1 -0
- package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.spec.js +36 -0
- package/dist/collection/components/molecules/mg-illustrated-message/test/mg-illustrated-message.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.conf.js +1 -0
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +15 -9
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +1 -0
- package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.js +85 -0
- package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.spec.js +106 -0
- package/dist/collection/components/molecules/mg-item-more/test/mg-item-more.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-message/mg-message.conf.js +1 -0
- package/dist/collection/components/molecules/mg-message/mg-message.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +7 -5
- package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -0
- package/dist/collection/components/molecules/mg-message/test/mg-message.e2e.js +64 -0
- package/dist/collection/components/molecules/mg-message/test/mg-message.e2e.js.map +1 -0
- package/dist/collection/components/molecules/mg-message/test/mg-message.spec.js +109 -0
- package/dist/collection/components/molecules/mg-message/test/mg-message.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.conf.js +5 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +42 -8
- package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js +62 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.template.js +40 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.template.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.js +26 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.spec.js +122 -0
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +1 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +5 -4
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -0
- package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.js +57 -0
- package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.spec.js +121 -0
- package/dist/collection/components/molecules/mg-pagination/test/mg-pagination.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.conf.js +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +10 -7
- package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -0
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js +106 -0
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.spec.js +223 -0
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.css +135 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +101 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +0 -111
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +47 -46
- package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -0
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.e2e.js +148 -0
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.e2e.js.map +1 -0
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.spec.js +130 -0
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.conf.js +1 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +5 -3
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -0
- package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.e2e.js +55 -0
- package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.e2e.js.map +1 -0
- package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.spec.js +55 -0
- package/dist/collection/components/molecules/mg-skip-links/test/mg-skip-links.spec.js.map +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +8 -5
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -0
- package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.js +76 -0
- package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.spec.js +332 -0
- package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.spec.js.map +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/locales/index.js +4 -3
- package/dist/collection/locales/index.js.map +1 -0
- package/dist/collection/locales/index.spec.js +27 -0
- package/dist/collection/locales/index.spec.js.map +1 -0
- package/dist/collection/stories/icon-gallery.js +4 -3
- package/dist/collection/stories/icon-gallery.js.map +1 -0
- package/dist/collection/test/typography.e2e.playwright.js +12 -0
- package/dist/collection/test/typography.e2e.playwright.js.map +1 -0
- package/dist/collection/utils/behaviors.utils.js +1 -0
- package/dist/collection/utils/behaviors.utils.js.map +1 -0
- package/dist/collection/utils/behaviors.utils.spec.js +57 -0
- package/dist/collection/utils/behaviors.utils.spec.js.map +1 -0
- package/dist/collection/utils/components.utils.js +9 -7
- package/dist/collection/utils/components.utils.js.map +1 -0
- package/dist/collection/utils/components.utils.spec.js +120 -0
- package/dist/collection/utils/components.utils.spec.js.map +1 -0
- package/dist/collection/utils/e2e.test.utils.js +46 -0
- package/dist/collection/utils/e2e.test.utils.js.map +1 -0
- package/dist/collection/utils/locale.utils.js +1 -0
- package/dist/collection/utils/locale.utils.js.map +1 -0
- package/dist/collection/utils/locale.utils.spec.js +52 -0
- package/dist/collection/utils/locale.utils.spec.js.map +1 -0
- package/dist/collection/utils/playwright.e2e.test.utils.js +100 -0
- package/dist/collection/utils/playwright.e2e.test.utils.js.map +1 -0
- package/dist/collection/utils/stencil.e2e.test.utils.js +33 -0
- package/dist/collection/utils/stencil.e2e.test.utils.js.map +1 -0
- package/dist/collection/utils/unit.test.utils.js +8 -6
- package/dist/collection/utils/unit.test.utils.js.map +1 -0
- package/dist/components/MgInput.js +2 -0
- package/dist/components/MgInput.js.map +1 -0
- package/dist/components/components.utils.js +10 -7
- package/dist/components/components.utils.js.map +1 -0
- package/dist/components/index.d.ts +5 -35
- package/dist/components/index.js +3 -34
- package/dist/components/index.js.map +1 -0
- package/dist/components/index2.js +2 -0
- package/dist/components/index2.js.map +1 -0
- package/dist/components/mg-action-more.js +42 -19
- package/dist/components/mg-action-more.js.map +1 -0
- package/dist/components/mg-badge.js +2 -0
- package/dist/components/mg-badge.js.map +1 -0
- package/dist/components/mg-badge2.js +8 -1
- package/dist/components/mg-badge2.js.map +1 -0
- package/dist/components/mg-button.js +2 -0
- package/dist/components/mg-button.js.map +1 -0
- package/dist/components/mg-button2.js +8 -1
- package/dist/components/mg-button2.js.map +1 -0
- package/dist/components/mg-card.js +2 -0
- package/dist/components/mg-card.js.map +1 -0
- package/dist/components/mg-card2.js +6 -1
- package/dist/components/mg-card2.js.map +1 -0
- package/dist/components/mg-character-left.js +2 -0
- package/dist/components/mg-character-left.js.map +1 -0
- package/dist/components/mg-character-left2.js +5 -1
- package/dist/components/mg-character-left2.js.map +1 -0
- package/dist/components/mg-details.js +8 -2
- package/dist/components/mg-details.js.map +1 -0
- package/dist/components/mg-divider.js +3 -1
- package/dist/components/mg-divider.js.map +1 -0
- package/dist/components/mg-form.js +17 -4
- package/dist/components/mg-form.js.map +1 -0
- package/dist/components/mg-icon.js +2 -0
- package/dist/components/mg-icon.js.map +1 -0
- package/dist/components/mg-icon2.js +87 -17
- package/dist/components/mg-icon2.js.map +1 -0
- package/dist/components/mg-illustrated-message.js +3 -1
- package/dist/components/mg-illustrated-message.js.map +1 -0
- package/dist/components/mg-input-checkbox-paginated.js +2 -0
- package/dist/components/mg-input-checkbox-paginated.js.map +1 -0
- package/dist/components/mg-input-checkbox-paginated2.js +24 -13
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -0
- package/dist/components/mg-input-checkbox.js +48 -25
- package/dist/components/mg-input-checkbox.js.map +1 -0
- package/dist/components/mg-input-date.js +23 -8
- package/dist/components/mg-input-date.js.map +1 -0
- package/dist/components/mg-input-numeric.js +58 -22
- package/dist/components/mg-input-numeric.js.map +1 -0
- package/dist/components/mg-input-password.js +21 -8
- package/dist/components/mg-input-password.js.map +1 -0
- package/dist/components/mg-input-radio.js +22 -8
- package/dist/components/mg-input-radio.js.map +1 -0
- package/dist/components/mg-input-select.js +2 -0
- package/dist/components/mg-input-select.js.map +1 -0
- package/dist/components/mg-input-select2.js +22 -8
- package/dist/components/mg-input-select2.js.map +1 -0
- package/dist/components/mg-input-text.js +2 -0
- package/dist/components/mg-input-text.js.map +1 -0
- package/dist/components/mg-input-text2.js +24 -10
- package/dist/components/mg-input-text2.js.map +1 -0
- package/dist/components/mg-input-textarea.js +24 -10
- package/dist/components/mg-input-textarea.js.map +1 -0
- package/dist/components/mg-input-title.js +2 -0
- package/dist/components/mg-input-title.js.map +1 -0
- package/dist/components/mg-input-title2.js +6 -1
- package/dist/components/mg-input-title2.js.map +1 -0
- package/dist/components/mg-input-toggle.js +23 -7
- package/dist/components/mg-input-toggle.js.map +1 -0
- package/dist/components/mg-item-more.js +31 -17
- package/dist/components/mg-item-more.js.map +1 -0
- package/dist/components/mg-menu-item.js +2 -0
- package/dist/components/mg-menu-item.js.map +1 -0
- package/dist/components/mg-menu-item2.js +27 -13
- package/dist/components/mg-menu-item2.js.map +1 -0
- package/dist/components/mg-menu.conf.js +2 -0
- package/dist/components/mg-menu.conf.js.map +1 -0
- package/dist/components/mg-menu.js +2 -0
- package/dist/components/mg-menu.js.map +1 -0
- package/dist/components/mg-menu2.js +8 -1
- package/dist/components/mg-menu2.js.map +1 -0
- package/dist/components/mg-message.js +8 -1
- package/dist/components/mg-message.js.map +1 -0
- package/dist/components/mg-modal.js +24 -5
- package/dist/components/mg-modal.js.map +1 -0
- package/dist/components/mg-pagination.js +2 -0
- package/dist/components/mg-pagination.js.map +1 -0
- package/dist/components/mg-pagination2.js +22 -11
- package/dist/components/mg-pagination2.js.map +1 -0
- package/dist/components/mg-panel.js +30 -16
- package/dist/components/mg-panel.js.map +1 -0
- package/dist/components/mg-popover-content.d.ts +11 -0
- package/dist/components/mg-popover-content.js +8 -0
- package/dist/components/mg-popover-content.js.map +1 -0
- package/dist/components/mg-popover-content2.js +90 -0
- package/dist/components/mg-popover-content2.js.map +1 -0
- package/dist/components/mg-popover.js +2 -0
- package/dist/components/mg-popover.js.map +1 -0
- package/dist/components/mg-popover2.js +61 -48
- package/dist/components/mg-popover2.js.map +1 -0
- package/dist/components/mg-skip-links.js +5 -1
- package/dist/components/mg-skip-links.js.map +1 -0
- package/dist/components/mg-tabs.js +8 -1
- package/dist/components/mg-tabs.js.map +1 -0
- package/dist/components/mg-tag.js +7 -1
- package/dist/components/mg-tag.js.map +1 -0
- package/dist/components/mg-tooltip-content.d.ts +11 -0
- package/dist/components/mg-tooltip-content.js +8 -0
- package/dist/components/mg-tooltip-content.js.map +1 -0
- package/dist/components/mg-tooltip-content2.js +43 -0
- package/dist/components/mg-tooltip-content2.js.map +1 -0
- package/dist/components/mg-tooltip.js +2 -0
- package/dist/components/mg-tooltip.js.map +1 -0
- package/dist/components/mg-tooltip2.js +71 -16
- package/dist/components/mg-tooltip2.js.map +1 -0
- package/dist/components/popper.js +2 -0
- package/dist/components/popper.js.map +1 -0
- package/dist/esm/{index-1d40b052.js → index-ce01e63b.js} +321 -68
- package/dist/esm/index-ce01e63b.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +6 -13
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/{mg-action-more_32.entry.js → mg-action-more_34.entry.js} +340 -113
- package/dist/esm/mg-action-more_34.entry.js.map +1 -0
- package/dist/esm/mg-components.js +6 -4
- package/dist/esm/mg-components.js.map +1 -0
- package/dist/esm/mg-item-more.entry.js +8 -4
- package/dist/esm/mg-item-more.entry.js.map +1 -0
- package/dist/esm/{mg-menu.conf-2cc079ae.js → mg-menu.conf-012fc9b4.js} +2 -0
- package/dist/esm/mg-menu.conf-012fc9b4.js.map +1 -0
- package/dist/mg-components/index.esm.js +2 -0
- package/dist/mg-components/index.esm.js.map +1 -0
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +2 -1
- package/dist/mg-components/mg-components.esm.js.map +1 -0
- package/dist/mg-components/p-1aa89acf.js +3 -0
- package/dist/mg-components/p-1aa89acf.js.map +1 -0
- package/dist/mg-components/p-1d7d6fa0.js +2 -0
- package/dist/mg-components/p-1d7d6fa0.js.map +1 -0
- package/dist/mg-components/p-9257e8f1.entry.js +2 -0
- package/dist/mg-components/p-9257e8f1.entry.js.map +1 -0
- package/dist/mg-components/p-caafc9cf.entry.js +2 -0
- package/dist/mg-components/p-caafc9cf.entry.js.map +1 -0
- package/dist/types/components/atoms/mg-badge/test/mg-badge.e2e.playwright.d.ts +1 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.d.ts +14 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +7 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +19 -0
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +6 -1
- package/dist/types/components/molecules/mg-action-more/test/mg-action-more.e2e.playwright.d.ts +2 -0
- package/dist/types/components/molecules/mg-details/test/mg-details.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +8 -0
- package/dist/types/components/molecules/mg-item-more/test/mg-item-more.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.conf.d.ts +8 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +8 -2
- package/dist/types/components/molecules/mg-modal/test/mg-modal.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-modal/test/mg-modal.e2e.template.d.ts +12 -0
- package/dist/types/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-pagination/test/mg-pagination.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-panel/test/mg-panel.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-popover/mg-popover-content/mg-popover-content.d.ts +47 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +8 -11
- package/dist/types/components/molecules/mg-tabs/test/mg-tabs.e2e.playwright.d.ts +1 -0
- package/dist/types/components.d.ts +79 -0
- package/dist/types/stencil-public-runtime.d.ts +43 -17
- package/dist/types/test/typography.e2e.playwright.d.ts +1 -0
- package/dist/types/utils/e2e.test.utils.d.ts +22 -0
- package/dist/types/utils/stencil.e2e.test.utils.d.ts +14 -0
- package/loader/index.d.ts +2 -2
- package/package.json +7 -7
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/mg-components/p-067080e4.js +0 -1
- package/dist/mg-components/p-3bf1e2f0.js +0 -2
- package/dist/mg-components/p-4ae1130f.entry.js +0 -1
- package/dist/mg-components/p-6672f590.entry.js +0 -1
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { Host, h } from
|
|
2
|
-
import { createID,
|
|
3
|
-
import { createPopper } from
|
|
4
|
-
import { initLocales } from '../../../locales';
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { createID, getWindows } from "../../../utils/components.utils";
|
|
3
|
+
import { createPopper } from "@popperjs/core";
|
|
5
4
|
export class MgPopover {
|
|
6
5
|
constructor() {
|
|
7
|
-
this.closeButtonId = '';
|
|
8
|
-
// Classes
|
|
9
|
-
this.classArrowHide = `mg-popover--arrow-hide`;
|
|
10
6
|
/**
|
|
11
7
|
* Check if clicked outside of component
|
|
12
8
|
* @param event - mouse event
|
|
13
9
|
*/
|
|
14
10
|
this.clickOutside = (event) => {
|
|
15
|
-
|
|
16
|
-
if (!this.disabled &&
|
|
17
|
-
event.target.closest('mg-popover') !== this.element &&
|
|
18
|
-
!(((_a = event.target.closest(`[data-mg-popover-guard]`)) === null || _a === void 0 ? void 0 : _a.dataset.mgPopoverGuard) === this.identifier)) {
|
|
11
|
+
const closestElement = event.target.closest(`[data-mg-popover-guard]`);
|
|
12
|
+
if (!this.disabled && event.target.closest('mg-popover') !== this.element && (closestElement === null || closestElement === void 0 ? void 0 : closestElement.dataset.mgPopoverGuard) !== this.identifier) {
|
|
19
13
|
this.display = false;
|
|
20
14
|
}
|
|
21
15
|
};
|
|
@@ -49,24 +43,46 @@ export class MgPopover {
|
|
|
49
43
|
});
|
|
50
44
|
};
|
|
51
45
|
/**
|
|
52
|
-
* Handle
|
|
46
|
+
* Handle content hide event
|
|
53
47
|
*/
|
|
54
|
-
this.
|
|
48
|
+
this.handleHideContent = () => {
|
|
55
49
|
this.display = false;
|
|
56
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Render popover content element
|
|
53
|
+
*/
|
|
54
|
+
this.renderPopoverContent = () => {
|
|
55
|
+
this.mgPopoverContent = document.createElement('mg-popover-content');
|
|
56
|
+
this.mgPopoverContent.setAttribute('slot', 'content');
|
|
57
|
+
this.mgPopoverContent.setAttribute('id', this.identifier);
|
|
58
|
+
this.mgPopoverContent.addEventListener('hide-content', this.handleHideContent);
|
|
59
|
+
const arrow = document.createElement('div');
|
|
60
|
+
arrow.setAttribute('slot', 'arrow');
|
|
61
|
+
arrow.dataset.popperArrow = '';
|
|
62
|
+
this.mgPopoverContent.appendChild(arrow);
|
|
63
|
+
// insert elements in DOM
|
|
64
|
+
['[slot="title"]', '[slot="content"]:not(mg-popover-content)'].forEach(slotType => {
|
|
65
|
+
Array.from(this.element.querySelectorAll(slotType)).forEach(slot => {
|
|
66
|
+
this.mgPopoverContent.appendChild(slot);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
this.element.appendChild(this.mgPopoverContent);
|
|
70
|
+
};
|
|
57
71
|
this.identifier = createID('mg-popover');
|
|
58
72
|
this.placement = 'bottom';
|
|
59
73
|
this.arrowHide = false;
|
|
60
74
|
this.closeButton = false;
|
|
61
75
|
this.display = false;
|
|
62
76
|
this.disabled = false;
|
|
63
|
-
this.classCollection = new ClassList(['mg-popover']);
|
|
64
77
|
}
|
|
65
78
|
validateArrowHide(newValue) {
|
|
66
79
|
if (newValue)
|
|
67
|
-
this.
|
|
80
|
+
this.mgPopoverContent.dataset.arrowHide = '';
|
|
68
81
|
else
|
|
69
|
-
this.
|
|
82
|
+
delete this.mgPopoverContent.dataset.arrowHide;
|
|
83
|
+
}
|
|
84
|
+
validateCloseButton(newValue) {
|
|
85
|
+
this.mgPopoverContent.closeButton = newValue;
|
|
70
86
|
}
|
|
71
87
|
handleDisplay(newValue) {
|
|
72
88
|
if (newValue) {
|
|
@@ -92,25 +108,17 @@ export class MgPopover {
|
|
|
92
108
|
componentWillLoad() {
|
|
93
109
|
// Get windows to attach events
|
|
94
110
|
this.windows = getWindows(window);
|
|
95
|
-
//
|
|
96
|
-
this.
|
|
111
|
+
// render mg-popover-content slot
|
|
112
|
+
this.renderPopoverContent();
|
|
113
|
+
this.validateCloseButton(this.closeButton);
|
|
97
114
|
this.validateArrowHide(this.arrowHide);
|
|
98
115
|
}
|
|
99
116
|
/**
|
|
100
117
|
* Check if component props are well configured on init
|
|
101
118
|
*/
|
|
102
119
|
componentDidLoad() {
|
|
103
|
-
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
104
|
-
const slottedTitleElement = this.element.querySelector('[slot="title"]');
|
|
105
|
-
if (slottedTitleElement && !isTagName(slottedTitleElement, headingTags)) {
|
|
106
|
-
throw new Error(`<mg-popover> Slotted title must be a heading: ${headingTags.join(', ')}`);
|
|
107
|
-
}
|
|
108
|
-
// Set close button id
|
|
109
|
-
if (this.closeButton) {
|
|
110
|
-
this.closeButtonId = `${this.identifier}-close-button`;
|
|
111
|
-
}
|
|
112
120
|
// Get popover content
|
|
113
|
-
this.mgPopover = this.element.
|
|
121
|
+
this.mgPopover = this.element.querySelector(`#${this.identifier}`);
|
|
114
122
|
//Get interactive element (first element without slot attribute)
|
|
115
123
|
const interactiveElement = this.element.querySelector(':not([slot])');
|
|
116
124
|
// Add aria attributes
|
|
@@ -129,17 +137,10 @@ export class MgPopover {
|
|
|
129
137
|
},
|
|
130
138
|
],
|
|
131
139
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.
|
|
135
|
-
|
|
136
|
-
this.popper.update();
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
Array.from(this.element.querySelectorAll('[slot]')).forEach(element => {
|
|
140
|
-
this.resizeObserver.observe(element);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
140
|
+
// add resize observer
|
|
141
|
+
new ResizeObserver(() => {
|
|
142
|
+
this.popper.update();
|
|
143
|
+
}).observe(this.element.querySelector('mg-popover-content'));
|
|
143
144
|
// Add events to toggle display
|
|
144
145
|
interactiveElement.addEventListener('click', () => {
|
|
145
146
|
if (!this.disabled)
|
|
@@ -159,7 +160,7 @@ export class MgPopover {
|
|
|
159
160
|
* @returns HTML Element
|
|
160
161
|
*/
|
|
161
162
|
render() {
|
|
162
|
-
return (h(Host, null, h("slot", null), h("
|
|
163
|
+
return (h(Host, null, h("slot", null), h("slot", { name: "content" })));
|
|
163
164
|
}
|
|
164
165
|
static get is() { return "mg-popover"; }
|
|
165
166
|
static get encapsulation() { return "shadow"; }
|
|
@@ -202,7 +203,8 @@ export class MgPopover {
|
|
|
202
203
|
"references": {
|
|
203
204
|
"Placement": {
|
|
204
205
|
"location": "import",
|
|
205
|
-
"path": "@popperjs/core"
|
|
206
|
+
"path": "@popperjs/core",
|
|
207
|
+
"id": "../../node_modules/.pnpm/@popperjs+core@2.11.7/node_modules/@popperjs/core/index.d.ts::Placement"
|
|
206
208
|
}
|
|
207
209
|
}
|
|
208
210
|
},
|
|
@@ -290,11 +292,6 @@ export class MgPopover {
|
|
|
290
292
|
}
|
|
291
293
|
};
|
|
292
294
|
}
|
|
293
|
-
static get states() {
|
|
294
|
-
return {
|
|
295
|
-
"classCollection": {}
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
295
|
static get events() {
|
|
299
296
|
return [{
|
|
300
297
|
"method": "displayChange",
|
|
@@ -318,9 +315,13 @@ export class MgPopover {
|
|
|
318
315
|
return [{
|
|
319
316
|
"propName": "arrowHide",
|
|
320
317
|
"methodName": "validateArrowHide"
|
|
318
|
+
}, {
|
|
319
|
+
"propName": "closeButton",
|
|
320
|
+
"methodName": "validateCloseButton"
|
|
321
321
|
}, {
|
|
322
322
|
"propName": "display",
|
|
323
323
|
"methodName": "handleDisplay"
|
|
324
324
|
}];
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
+
//# sourceMappingURL=mg-popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-popover.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-popover/mg-popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAA8B,YAAY,EAAa,MAAM,gBAAgB,CAAC;AAOrF,MAAM,OAAO,SAAS;;IAyEpB;;;OAGG;IACK,iBAAY,GAAG,CAAC,KAA2C,EAAQ,EAAE;MAC3E,MAAM,cAAc,GAAgB,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;MACpF,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC,OAAO,IAAI,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,CAAC,cAAc,MAAK,IAAI,CAAC,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M;IACJ,OAAO,CACL,EAAC,IAAI;MACH,eAAa;MACb,YAAM,IAAI,EAAC,SAAS,GAAQ,CACvB,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Host, h, Prop, Watch, EventEmitter, Event } from '@stencil/core';\nimport { createID, getWindows } from '../../../utils/components.utils';\nimport { Instance as PopperInstance, createPopper, Placement } from '@popperjs/core';\n\n@Component({\n tag: 'mg-popover',\n styleUrl: 'mg-popover.scss',\n shadow: true,\n})\nexport class MgPopover {\n /************\n * Internal *\n ************/\n\n private popper: PopperInstance;\n private mgPopover: HTMLElement;\n private mgPopoverContent: HTMLMgPopoverContentElement;\n private windows: Window[];\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgPopoverElement;\n\n /**\n * Sets an `id` attribute.\n * Needed by the input for accessibility `aria-decribedby`.\n */\n @Prop() identifier: string = createID('mg-popover');\n\n /**\n * Popover placement\n */\n @Prop() placement: Placement = 'bottom';\n\n /**\n * Hide popover arrow\n */\n @Prop() arrowHide = false;\n @Watch('arrowHide')\n validateArrowHide(newValue: MgPopover['arrowHide']): void {\n if (newValue) this.mgPopoverContent.dataset.arrowHide = '';\n else delete this.mgPopoverContent.dataset.arrowHide;\n }\n\n /**\n * Define if popover has a cross button\n */\n @Prop() closeButton = false;\n @Watch('closeButton')\n validateCloseButton(newValue: MgPopover['arrowHide']): void {\n this.mgPopoverContent.closeButton = newValue;\n }\n\n /**\n * Display popover\n */\n @Prop({ mutable: true }) display = false;\n @Watch('display')\n handleDisplay(newValue: boolean): void {\n if (newValue) {\n this.show();\n } else {\n this.hide();\n }\n this.displayChange.emit(newValue);\n }\n\n /**\n * Disable popover\n */\n @Prop() disabled = false;\n\n /**\n * Emited event when display value change\n */\n @Event({ eventName: 'display-change' }) displayChange: EventEmitter<boolean>;\n\n /**\n * Check if clicked outside of component\n * @param event - mouse event\n */\n private clickOutside = (event: MouseEvent & { target: HTMLElement }): void => {\n const closestElement: HTMLElement = event.target.closest(`[data-mg-popover-guard]`);\n if (!this.disabled && event.target.closest('mg-popover') !== this.element && closestElement?.dataset.mgPopoverGuard !== this.identifier) {\n this.display = false;\n }\n };\n\n /**\n * Show popover\n */\n private show = (): void => {\n // Make the popover visible\n this.mgPopover.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\n // setTimeout is used to prevent event to trigger after creation\n setTimeout(() => {\n this.windows.forEach((localWindow: Window) => {\n localWindow.addEventListener('click', this.clickOutside, false);\n });\n }, 0);\n };\n\n /**\n * Hide popover\n */\n private hide = (): void => {\n // Hide the popover\n this.mgPopover.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.clickOutside, false);\n });\n };\n\n /**\n * Handle content hide event\n */\n private handleHideContent = (): void => {\n this.display = false;\n };\n\n /**\n * Render popover content element\n */\n private renderPopoverContent = (): void => {\n this.mgPopoverContent = document.createElement('mg-popover-content');\n this.mgPopoverContent.setAttribute('slot', 'content');\n this.mgPopoverContent.setAttribute('id', this.identifier);\n this.mgPopoverContent.addEventListener('hide-content', this.handleHideContent);\n\n const arrow = document.createElement('div');\n arrow.setAttribute('slot', 'arrow');\n arrow.dataset.popperArrow = '';\n this.mgPopoverContent.appendChild(arrow);\n\n // insert elements in DOM\n ['[slot=\"title\"]', '[slot=\"content\"]:not(mg-popover-content)'].forEach(slotType => {\n Array.from(this.element.querySelectorAll(slotType)).forEach(slot => {\n this.mgPopoverContent.appendChild(slot);\n });\n });\n this.element.appendChild(this.mgPopoverContent);\n };\n\n /*************\n * Lifecycle *\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 * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Get windows to attach events\n this.windows = getWindows(window);\n // render mg-popover-content slot\n this.renderPopoverContent();\n this.validateCloseButton(this.closeButton);\n this.validateArrowHide(this.arrowHide);\n }\n\n /**\n * Check if component props are well configured on init\n */\n componentDidLoad(): void {\n // Get popover content\n this.mgPopover = this.element.querySelector(`#${this.identifier}`);\n\n //Get interactive element (first element without slot attribute)\n const interactiveElement: HTMLElement = this.element.querySelector(':not([slot])');\n // Add aria attributes\n interactiveElement.setAttribute('aria-controls', this.identifier);\n interactiveElement.setAttribute('aria-expanded', `${this.display}`);\n\n // Create popperjs popover\n this.popper = createPopper(interactiveElement, this.mgPopover, {\n placement: this.placement,\n strategy: 'fixed',\n modifiers: [\n {\n name: 'offset',\n options: {\n offset: [0, 0],\n },\n },\n ],\n });\n\n // add resize observer\n new ResizeObserver(() => {\n this.popper.update();\n }).observe(this.element.querySelector('mg-popover-content'));\n\n // Add events to toggle display\n interactiveElement.addEventListener('click', () => {\n if (!this.disabled) this.display = !this.display;\n });\n\n // Add events to hide popover\n this.element.addEventListener('keydown', e => {\n if (!this.disabled && e.code === 'Escape') {\n this.display = false;\n interactiveElement.focus();\n }\n });\n\n this.handleDisplay(this.display);\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"]}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { createPage } from "../../../../utils/stencil.e2e.test.utils";
|
|
2
|
+
import { renderAttributes } from "../../../../utils/e2e.test.utils";
|
|
3
|
+
describe('mg-popover', () => {
|
|
4
|
+
describe.each([
|
|
5
|
+
'auto',
|
|
6
|
+
'auto-start',
|
|
7
|
+
'auto-end',
|
|
8
|
+
'top',
|
|
9
|
+
'top-start',
|
|
10
|
+
'top-end',
|
|
11
|
+
'bottom',
|
|
12
|
+
'bottom-start',
|
|
13
|
+
'bottom-end',
|
|
14
|
+
'right',
|
|
15
|
+
'right-start',
|
|
16
|
+
'right-end',
|
|
17
|
+
'left',
|
|
18
|
+
'left-start',
|
|
19
|
+
'left-end',
|
|
20
|
+
])('placement %s', placement => {
|
|
21
|
+
test.each([true, false])('Should render, case hide arrow %s', async (arrowHide) => {
|
|
22
|
+
const page = await createPage(`<style>mg-button{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%)}</style>
|
|
23
|
+
<mg-popover ${renderAttributes({ placement, arrowHide })}>
|
|
24
|
+
<mg-button>Button</mg-button>
|
|
25
|
+
<h2 slot="title">Blu bli blo bla</h2>
|
|
26
|
+
<p slot="content">
|
|
27
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
|
|
28
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
|
29
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
30
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
|
31
|
+
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
|
|
32
|
+
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
33
|
+
</p>
|
|
34
|
+
</mg-popover>`);
|
|
35
|
+
const mgPopover = await page.find('mg-popover');
|
|
36
|
+
const mgButton = await page.find('mg-button');
|
|
37
|
+
const popover = await page.find('mg-popover mg-popover-content');
|
|
38
|
+
expect(mgPopover).toHaveClass('hydrated');
|
|
39
|
+
// display popover on click on slotted element
|
|
40
|
+
mgButton.triggerEvent('click');
|
|
41
|
+
await page.waitForChanges();
|
|
42
|
+
await page.waitForNetworkIdle();
|
|
43
|
+
expect(popover).toHaveAttribute('data-show');
|
|
44
|
+
await page.setViewport({ width: 800, height: 800 });
|
|
45
|
+
const screenshot = await page.screenshot();
|
|
46
|
+
expect(screenshot).toMatchImageSnapshot();
|
|
47
|
+
// hide popover on click on slotted element
|
|
48
|
+
mgButton.triggerEvent('click');
|
|
49
|
+
await page.waitForChanges();
|
|
50
|
+
await page.waitForNetworkIdle();
|
|
51
|
+
expect(popover).not.toHaveAttribute('data-show');
|
|
52
|
+
// display popover on keyboad click event on slotted element
|
|
53
|
+
await page.keyboard.down('Tab');
|
|
54
|
+
await page.keyboard.down('Enter');
|
|
55
|
+
await page.waitForChanges();
|
|
56
|
+
await page.waitForNetworkIdle();
|
|
57
|
+
expect(popover).toHaveAttribute('data-show');
|
|
58
|
+
// hide popover on keyboad escape key
|
|
59
|
+
await page.keyboard.down('Escape');
|
|
60
|
+
await page.waitForChanges();
|
|
61
|
+
await page.waitForNetworkIdle();
|
|
62
|
+
expect(popover).not.toHaveAttribute('data-show');
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe.each([
|
|
66
|
+
'',
|
|
67
|
+
'<h2 slot="title">Titre un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long</h2>',
|
|
68
|
+
])('with or without title', title => {
|
|
69
|
+
test('Should render with close button', async () => {
|
|
70
|
+
const page = await createPage(`<mg-popover display close-button>
|
|
71
|
+
<mg-button>Button</mg-button>
|
|
72
|
+
${title}
|
|
73
|
+
<p slot="content">
|
|
74
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
|
|
75
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
|
76
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
77
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
|
78
|
+
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
|
|
79
|
+
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
80
|
+
</p>
|
|
81
|
+
</mg-popover>`);
|
|
82
|
+
const mgPopover = await page.find('mg-popover');
|
|
83
|
+
expect(mgPopover).toHaveClass('hydrated');
|
|
84
|
+
await page.setViewport({ width: 500, height: 350 });
|
|
85
|
+
const screenshot = await page.screenshot();
|
|
86
|
+
expect(screenshot).toMatchImageSnapshot();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
describe.each(['title', 'content'])('re-position %s slot', slot => {
|
|
90
|
+
test('should re-position when slot size change', async () => {
|
|
91
|
+
const tagName = slot === 'title' ? 'h2' : 'p';
|
|
92
|
+
const page = await createPage(`<style>mg-button{position:fixed;left:50%;transform:translateX(-50%)}</style>
|
|
93
|
+
<mg-popover ${renderAttributes({ placement: 'bottom-start', display: true })}>
|
|
94
|
+
<mg-button>Button</mg-button>
|
|
95
|
+
<${tagName} slot="${slot}">
|
|
96
|
+
Lorem ipsum
|
|
97
|
+
</${tagName}>
|
|
98
|
+
</mg-popover>`, { width: 400, height: 100 });
|
|
99
|
+
let screenshot = await page.screenshot();
|
|
100
|
+
expect(screenshot).toMatchImageSnapshot();
|
|
101
|
+
await page.$eval(`mg-popover-content [slot="${slot}"]`, el => {
|
|
102
|
+
el.textContent = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
|
|
103
|
+
});
|
|
104
|
+
await page.waitForChanges();
|
|
105
|
+
screenshot = await page.screenshot();
|
|
106
|
+
expect(screenshot).toMatchImageSnapshot();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
describe('style', () => {
|
|
110
|
+
test('Should render with child mg-card', async () => {
|
|
111
|
+
const page = await createPage(`<mg-popover display close-button class="custom-popover-card">
|
|
112
|
+
<mg-button>Button</mg-button>
|
|
113
|
+
<mg-card slot="content">
|
|
114
|
+
My custom card
|
|
115
|
+
</mg-card>
|
|
116
|
+
</mg-popover>
|
|
117
|
+
<style>
|
|
118
|
+
.custom-popover-card {
|
|
119
|
+
--mg-popover-background-color: var(--color-danger);
|
|
120
|
+
}
|
|
121
|
+
</style>
|
|
122
|
+
`);
|
|
123
|
+
const mgPopover = await page.find('mg-popover');
|
|
124
|
+
expect(mgPopover).toHaveClass('hydrated');
|
|
125
|
+
await page.setViewport({ width: 500, height: 300 });
|
|
126
|
+
const screenshot = await page.screenshot();
|
|
127
|
+
expect(screenshot).toMatchImageSnapshot();
|
|
128
|
+
});
|
|
129
|
+
test.each(['content', 'title'])('Should render with --mg-popover-max-width', async (slot) => {
|
|
130
|
+
const page = await createPage(`<mg-popover display close-button class="custom-popover">
|
|
131
|
+
<mg-button>Button</mg-button>
|
|
132
|
+
<h2 slot="${slot}">Titre un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long</h2>
|
|
133
|
+
</mg-popover>
|
|
134
|
+
<style>
|
|
135
|
+
.custom-popover {
|
|
136
|
+
--mg-popover-max-width: 10rem;
|
|
137
|
+
}
|
|
138
|
+
</style>
|
|
139
|
+
`);
|
|
140
|
+
const mgPopover = await page.find('mg-popover');
|
|
141
|
+
expect(mgPopover).toHaveClass('hydrated');
|
|
142
|
+
await page.setViewport({ width: 500, height: 300 });
|
|
143
|
+
const screenshot = await page.screenshot();
|
|
144
|
+
expect(screenshot).toMatchImageSnapshot();
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
//# sourceMappingURL=mg-popover.e2e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-popover.e2e.js","sourceRoot":"","sources":["../../../../../src/components/molecules/mg-popover/test/mg-popover.e2e.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;EAC1B,QAAQ,CAAC,IAAI,CAAC;IACZ,MAA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rB,IAAI,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;MAClD,MAAM,IAAI,GAAG,MAAM,UAAU,CAC3B;;;;;;;;;;;SAWC,CACF,CAAC;MAEF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;MAEhD,MAAM,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;MAE1C,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;MAEpD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;MAC3C,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,EAAE,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,2CAA2C,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE;MACxF,MAAM,IAAI,GAAG,MAAM,UAAU,CAC3B;;oBAEY,IAAI;;;;;;;SAOf,CACF,CAAC;MAEF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;MAEhD,MAAM,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;MAE1C,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;MAEpD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;MAC3C,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,EAAE,CAAC;IAC5C,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { createPage } from '../../../../utils/stencil.e2e.test.utils';\nimport { renderAttributes } from '../../../../utils/e2e.test.utils';\n\ndescribe('mg-popover', () => {\n describe.each([\n 'auto',\n 'auto-start',\n 'auto-end',\n 'top',\n 'top-start',\n 'top-end',\n 'bottom',\n 'bottom-start',\n 'bottom-end',\n 'right',\n 'right-start',\n 'right-end',\n 'left',\n 'left-start',\n 'left-end',\n ])('placement %s', placement => {\n test.each([true, false])('Should render, case hide arrow %s', async arrowHide => {\n const page = await createPage(\n `<style>mg-button{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%)}</style>\n <mg-popover ${renderAttributes({ placement, arrowHide })}>\n <mg-button>Button</mg-button>\n <h2 slot=\"title\">Blu bli blo bla</h2>\n <p slot=\"content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\n quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\n consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\n cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat\n non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n </p>\n </mg-popover>`,\n );\n\n const mgPopover = await page.find('mg-popover');\n const mgButton = await page.find('mg-button');\n const popover = await page.find('mg-popover mg-popover-content');\n\n expect(mgPopover).toHaveClass('hydrated');\n\n // display popover on click on slotted element\n mgButton.triggerEvent('click');\n await page.waitForChanges();\n await page.waitForNetworkIdle();\n\n expect(popover).toHaveAttribute('data-show');\n\n await page.setViewport({ width: 800, height: 800 });\n\n const screenshot = await page.screenshot();\n expect(screenshot).toMatchImageSnapshot();\n\n // hide popover on click on slotted element\n mgButton.triggerEvent('click');\n await page.waitForChanges();\n await page.waitForNetworkIdle();\n\n expect(popover).not.toHaveAttribute('data-show');\n\n // display popover on keyboad click event on slotted element\n await page.keyboard.down('Tab');\n await page.keyboard.down('Enter');\n await page.waitForChanges();\n await page.waitForNetworkIdle();\n\n expect(popover).toHaveAttribute('data-show');\n\n // hide popover on keyboad escape key\n await page.keyboard.down('Escape');\n await page.waitForChanges();\n await page.waitForNetworkIdle();\n\n expect(popover).not.toHaveAttribute('data-show');\n });\n });\n\n describe.each([\n '',\n '<h2 slot=\"title\">Titre un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long</h2>',\n ])('with or without title', title => {\n test('Should render with close button', async () => {\n const page = await createPage(\n `<mg-popover display close-button>\n <mg-button>Button</mg-button>\n ${title}\n <p slot=\"content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\n quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\n consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\n cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat\n non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n </p>\n </mg-popover>`,\n );\n\n const mgPopover = await page.find('mg-popover');\n\n expect(mgPopover).toHaveClass('hydrated');\n\n await page.setViewport({ width: 500, height: 350 });\n\n const screenshot = await page.screenshot();\n expect(screenshot).toMatchImageSnapshot();\n });\n });\n\n describe.each(['title', 'content'])('re-position %s slot', slot => {\n test('should re-position when slot size change', async () => {\n const tagName = slot === 'title' ? 'h2' : 'p';\n const page = await createPage(\n `<style>mg-button{position:fixed;left:50%;transform:translateX(-50%)}</style>\n <mg-popover ${renderAttributes({ placement: 'bottom-start', display: true })}>\n <mg-button>Button</mg-button>\n <${tagName} slot=\"${slot}\">\n Lorem ipsum\n </${tagName}>\n </mg-popover>`,\n { width: 400, height: 100 },\n );\n\n let screenshot = await page.screenshot();\n expect(screenshot).toMatchImageSnapshot();\n\n await page.$eval(`mg-popover-content [slot=\"${slot}\"]`, el => {\n el.textContent = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';\n });\n\n await page.waitForChanges();\n\n screenshot = await page.screenshot();\n expect(screenshot).toMatchImageSnapshot();\n });\n });\n\n describe('style', () => {\n test('Should render with child mg-card', async () => {\n const page = await createPage(\n `<mg-popover display close-button class=\"custom-popover-card\">\n <mg-button>Button</mg-button>\n <mg-card slot=\"content\">\n My custom card\n </mg-card>\n </mg-popover>\n <style>\n .custom-popover-card {\n --mg-popover-background-color: var(--color-danger);\n }\n </style>\n `,\n );\n\n const mgPopover = await page.find('mg-popover');\n\n expect(mgPopover).toHaveClass('hydrated');\n\n await page.setViewport({ width: 500, height: 300 });\n\n const screenshot = await page.screenshot();\n expect(screenshot).toMatchImageSnapshot();\n });\n\n test.each(['content', 'title'])('Should render with --mg-popover-max-width', async slot => {\n const page = await createPage(\n `<mg-popover display close-button class=\"custom-popover\">\n <mg-button>Button</mg-button>\n <h2 slot=\"${slot}\">Titre un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long un peu plus long</h2>\n </mg-popover>\n <style>\n .custom-popover {\n --mg-popover-max-width: 10rem;\n }\n </style>\n `,\n );\n\n const mgPopover = await page.find('mg-popover');\n\n expect(mgPopover).toHaveClass('hydrated');\n\n await page.setViewport({ width: 500, height: 300 });\n\n const screenshot = await page.screenshot();\n expect(screenshot).toMatchImageSnapshot();\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { newSpecPage } from "@stencil/core/testing";
|
|
3
|
+
import { MgPopover } from "../mg-popover";
|
|
4
|
+
import { MgButton } from "../../../atoms/mg-button/mg-button";
|
|
5
|
+
import { mockConsoleError, mockWindowFrames, setupResizeObserverMock } from "../../../../utils/unit.test.utils";
|
|
6
|
+
import { MgPopoverContent } from "../mg-popover-content/mg-popover-content";
|
|
7
|
+
mockConsoleError();
|
|
8
|
+
mockWindowFrames();
|
|
9
|
+
const getPage = (args, slot, parent) => {
|
|
10
|
+
const popover = () => h("mg-popover", Object.assign({}, args), slot);
|
|
11
|
+
return newSpecPage({
|
|
12
|
+
components: [MgPopover, MgPopoverContent, MgButton],
|
|
13
|
+
template: () => (parent ? h("span", { "data-mg-popover-guard": args.identifier }, popover()) : popover()),
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
describe('mg-popover', () => {
|
|
17
|
+
let fireRo;
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
jest.useFakeTimers();
|
|
20
|
+
setupResizeObserverMock({
|
|
21
|
+
observe: function () {
|
|
22
|
+
fireRo = this.cb;
|
|
23
|
+
},
|
|
24
|
+
disconnect: function () {
|
|
25
|
+
return null;
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
afterEach(() => jest.clearAllTimers());
|
|
30
|
+
test.each([
|
|
31
|
+
{ identifier: 'identifier' },
|
|
32
|
+
{ identifier: 'identifier', placement: 'auto' },
|
|
33
|
+
{ identifier: 'identifier', display: true },
|
|
34
|
+
{ identifier: 'identifier', closeButton: true },
|
|
35
|
+
{ identifier: 'identifier', display: true },
|
|
36
|
+
{ identifier: 'identifier', closeButton: true, lang: 'fr' },
|
|
37
|
+
{ identifier: 'identifier', closeButton: true, lang: 'xx' },
|
|
38
|
+
{ identifier: 'identifier', arrowHide: true },
|
|
39
|
+
])('Should render with element', async (args) => {
|
|
40
|
+
const { root } = await getPage(args, [
|
|
41
|
+
h("h2", { slot: "title" }, "Blu bli blo bla"),
|
|
42
|
+
h("p", { slot: "content" }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."),
|
|
43
|
+
h("mg-button", { identifier: "identifier-btn" }, "mg-button"),
|
|
44
|
+
]);
|
|
45
|
+
expect(root).toMatchSnapshot();
|
|
46
|
+
});
|
|
47
|
+
test.each([
|
|
48
|
+
{ eventIn: 'click', eventOut: 'clickBtn' },
|
|
49
|
+
{ eventIn: 'click', eventOut: { code: 'Escape' } },
|
|
50
|
+
{ eventIn: 'click', eventOut: 'clickCross' },
|
|
51
|
+
{ eventIn: 'click', eventOut: 'clickDocument' },
|
|
52
|
+
{ eventIn: 'click', eventOut: 'clickPopover' },
|
|
53
|
+
{ eventIn: 'click', eventOut: 'clickGuard' },
|
|
54
|
+
])('Should manage display on events %s', async ({ eventIn, eventOut }) => {
|
|
55
|
+
const args = { identifier: 'identifier', closeButton: true };
|
|
56
|
+
const page = await getPage(args, [
|
|
57
|
+
h("h2", { slot: "title" }, "Blu bli blo bla"),
|
|
58
|
+
h("p", { slot: "content" }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."),
|
|
59
|
+
h("mg-button", { identifier: "identifier-btn" }, "mg-button"),
|
|
60
|
+
], eventOut === 'clickGuard');
|
|
61
|
+
const mgPopover = page.doc.querySelector('mg-popover');
|
|
62
|
+
const interactiveElement = mgPopover.querySelector(`[aria-controls*='${args.identifier}']`);
|
|
63
|
+
const popover = mgPopover.querySelector(`#${args.identifier}`);
|
|
64
|
+
const popoverButton = popover.shadowRoot.querySelector(`mg-button`);
|
|
65
|
+
const dataGuard = page.doc.querySelector('[data-mg-popover-guard]');
|
|
66
|
+
const focusSpy = jest.spyOn(interactiveElement, 'focus');
|
|
67
|
+
const displayChangeSpy = jest.spyOn(page.rootInstance.displayChange, 'emit');
|
|
68
|
+
interactiveElement.dispatchEvent(new CustomEvent(eventIn, { bubbles: true }));
|
|
69
|
+
await page.waitForChanges();
|
|
70
|
+
jest.runAllTimers();
|
|
71
|
+
expect(popover).toHaveAttribute('data-show');
|
|
72
|
+
if (typeof eventOut === 'string') {
|
|
73
|
+
if (eventOut === 'clickBtn') {
|
|
74
|
+
interactiveElement.dispatchEvent(new Event('click', { bubbles: true }));
|
|
75
|
+
}
|
|
76
|
+
else if (eventOut === 'clickCross') {
|
|
77
|
+
popoverButton.dispatchEvent(new Event('click', { bubbles: true }));
|
|
78
|
+
}
|
|
79
|
+
else if (eventOut === 'clickDocument') {
|
|
80
|
+
document.dispatchEvent(new Event('click', { bubbles: true }));
|
|
81
|
+
}
|
|
82
|
+
else if (eventOut === 'clickPopover') {
|
|
83
|
+
popover.dispatchEvent(new Event('click', { bubbles: true }));
|
|
84
|
+
}
|
|
85
|
+
else if (eventOut === 'clickGuard') {
|
|
86
|
+
dataGuard.dispatchEvent(new Event('click', { bubbles: true }));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
mgPopover.dispatchEvent(new KeyboardEvent('keydown', { code: eventOut.code }));
|
|
91
|
+
expect(focusSpy).toHaveBeenCalled();
|
|
92
|
+
}
|
|
93
|
+
await page.waitForChanges();
|
|
94
|
+
if (typeof eventOut === 'string' && ['clickPopover', 'clickGuard'].includes(eventOut)) {
|
|
95
|
+
expect(popover).toHaveAttribute('data-show');
|
|
96
|
+
expect(displayChangeSpy).toHaveBeenCalledWith(true);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
expect(popover).not.toHaveAttribute('data-show');
|
|
100
|
+
expect(displayChangeSpy).toHaveBeenCalledWith(false);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
test('Should throw error if slot title element is not a heading', async () => {
|
|
104
|
+
expect.assertions(1);
|
|
105
|
+
try {
|
|
106
|
+
const args = { identifier: 'identifier', closeButton: true };
|
|
107
|
+
await getPage(args, [
|
|
108
|
+
h("span", { slot: "title" }, "Blu bli blo bla"),
|
|
109
|
+
h("p", { slot: "content" }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."),
|
|
110
|
+
h("mg-button", { identifier: "identifier-btn" }, "mg-button"),
|
|
111
|
+
]);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
expect(err.message).toContain('<mg-popover> Slotted title must be a heading: ');
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
test('should update popper instance when slot %s update', async () => {
|
|
118
|
+
const page = await getPage({ identifier: 'identifier', display: true }, [
|
|
119
|
+
h("h2", { slot: "title" }, "Blu bli blo bla"),
|
|
120
|
+
h("p", { slot: "content" }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."),
|
|
121
|
+
h("mg-button", { identifier: "identifier-btn" }, "mg-button"),
|
|
122
|
+
]);
|
|
123
|
+
expect(page.root).toMatchSnapshot();
|
|
124
|
+
const spy = jest.spyOn(page.rootInstance.popper, 'update');
|
|
125
|
+
fireRo([]);
|
|
126
|
+
expect(spy).toHaveBeenCalled();
|
|
127
|
+
expect(page.root).toMatchSnapshot();
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=mg-popover.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-popover.spec.js","sourceRoot":"","sources":["../../../../../src/components/molecules/mg-popover/test/mg-popover.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC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Y,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE3D,MAAM,CAAC,EAAE,CAAC,CAAC;IAEX,MAAM,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC/B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;EACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { h } from '@stencil/core';\nimport { newSpecPage } from '@stencil/core/testing';\nimport { MgPopover } from '../mg-popover';\nimport { MgButton } from '../../../atoms/mg-button/mg-button';\nimport { mockConsoleError, mockWindowFrames, setupResizeObserverMock } from '../../../../utils/unit.test.utils';\nimport { MgPopoverContent } from '../mg-popover-content/mg-popover-content';\n\nmockConsoleError();\nmockWindowFrames();\n\nconst getPage = (args, slot, parent?: boolean) => {\n const popover = () => <mg-popover {...args}>{slot}</mg-popover>;\n return newSpecPage({\n components: [MgPopover, MgPopoverContent, MgButton],\n template: () => (parent ? <span data-mg-popover-guard={args.identifier}>{popover()}</span> : popover()),\n });\n};\n\ndescribe('mg-popover', () => {\n let fireRo;\n beforeEach(() => {\n jest.useFakeTimers();\n setupResizeObserverMock({\n observe: function () {\n fireRo = this.cb;\n },\n disconnect: function () {\n return null;\n },\n });\n });\n afterEach(() => jest.clearAllTimers());\n\n test.each([\n { identifier: 'identifier' },\n { identifier: 'identifier', placement: 'auto' },\n { identifier: 'identifier', display: true },\n { identifier: 'identifier', closeButton: true },\n { identifier: 'identifier', display: true },\n { identifier: 'identifier', closeButton: true, lang: 'fr' },\n { identifier: 'identifier', closeButton: true, lang: 'xx' },\n { identifier: 'identifier', arrowHide: true },\n ])('Should render with element', async args => {\n const { root } = await getPage(args, [\n <h2 slot=\"title\">Blu bli blo bla</h2>,\n <p slot=\"content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud\n exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n </p>,\n <mg-button identifier=\"identifier-btn\">mg-button</mg-button>,\n ]);\n expect(root).toMatchSnapshot();\n });\n\n test.each([\n { eventIn: 'click', eventOut: 'clickBtn' },\n { eventIn: 'click', eventOut: { code: 'Escape' } },\n { eventIn: 'click', eventOut: 'clickCross' },\n { eventIn: 'click', eventOut: 'clickDocument' },\n { eventIn: 'click', eventOut: 'clickPopover' },\n { eventIn: 'click', eventOut: 'clickGuard' },\n ])('Should manage display on events %s', async ({ eventIn, eventOut }) => {\n const args = { identifier: 'identifier', closeButton: true };\n const page = await getPage(\n args,\n [\n <h2 slot=\"title\">Blu bli blo bla</h2>,\n <p slot=\"content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud\n exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\n pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n </p>,\n <mg-button identifier=\"identifier-btn\">mg-button</mg-button>,\n ],\n eventOut === 'clickGuard',\n );\n\n const mgPopover = page.doc.querySelector('mg-popover');\n const interactiveElement = mgPopover.querySelector(`[aria-controls*='${args.identifier}']`) as HTMLElement;\n const popover = mgPopover.querySelector(`#${args.identifier}`);\n const popoverButton = popover.shadowRoot.querySelector(`mg-button`);\n const dataGuard = page.doc.querySelector('[data-mg-popover-guard]');\n\n const focusSpy = jest.spyOn(interactiveElement, 'focus');\n const displayChangeSpy = jest.spyOn(page.rootInstance.displayChange, 'emit');\n\n interactiveElement.dispatchEvent(new CustomEvent(eventIn, { bubbles: true }));\n await page.waitForChanges();\n jest.runAllTimers();\n\n expect(popover).toHaveAttribute('data-show');\n\n if (typeof eventOut === 'string') {\n if (eventOut === 'clickBtn') {\n interactiveElement.dispatchEvent(new Event('click', { bubbles: true }));\n } else if (eventOut === 'clickCross') {\n popoverButton.dispatchEvent(new Event('click', { bubbles: true }));\n } else if (eventOut === 'clickDocument') {\n document.dispatchEvent(new Event('click', { bubbles: true }));\n } else if (eventOut === 'clickPopover') {\n popover.dispatchEvent(new Event('click', { bubbles: true }));\n } else if (eventOut === 'clickGuard') {\n dataGuard.dispatchEvent(new Event('click', { bubbles: true }));\n }\n } else {\n mgPopover.dispatchEvent(new KeyboardEvent('keydown', { code: eventOut.code }));\n expect(focusSpy).toHaveBeenCalled();\n }\n await page.waitForChanges();\n\n if (typeof eventOut === 'string' && ['clickPopover', 'clickGuard'].includes(eventOut)) {\n expect(popover).toHaveAttribute('data-show');\n expect(displayChangeSpy).toHaveBeenCalledWith(true);\n } else {\n expect(popover).not.toHaveAttribute('data-show');\n expect(displayChangeSpy).toHaveBeenCalledWith(false);\n }\n });\n\n test('Should throw error if slot title element is not a heading', async () => {\n expect.assertions(1);\n try {\n const args = { identifier: 'identifier', closeButton: true };\n await getPage(args, [\n <span slot=\"title\">Blu bli blo bla</span>,\n <p slot=\"content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud\n exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\n pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n </p>,\n <mg-button identifier=\"identifier-btn\">mg-button</mg-button>,\n ]);\n } catch (err) {\n expect(err.message).toContain('<mg-popover> Slotted title must be a heading: ');\n }\n });\n\n test('should update popper instance when slot %s update', async () => {\n const page = await getPage({ identifier: 'identifier', display: true }, [\n <h2 slot=\"title\">Blu bli blo bla</h2>,\n <p slot=\"content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud\n exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n </p>,\n <mg-button identifier=\"identifier-btn\">mg-button</mg-button>,\n ]);\n expect(page.root).toMatchSnapshot();\n\n const spy = jest.spyOn(page.rootInstance.popper, 'update');\n\n fireRo([]);\n\n expect(spy).toHaveBeenCalled();\n expect(page.root).toMatchSnapshot();\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-skip-links.conf.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-skip-links/mg-skip-links.conf.tsx"],"names":[],"mappings":"","sourcesContent":["/**\n * type SkipLink\n */\nexport type SkipLink = {\n href: string;\n label: string;\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable jsx-a11y/no-redundant-roles */
|
|
2
|
-
import { h } from
|
|
3
|
-
import { initLocales } from
|
|
2
|
+
import { h } from "@stencil/core";
|
|
3
|
+
import { initLocales } from "../../../locales";
|
|
4
4
|
export class MgSkipLinks {
|
|
5
5
|
constructor() {
|
|
6
6
|
/***********
|
|
@@ -63,7 +63,8 @@ export class MgSkipLinks {
|
|
|
63
63
|
"references": {
|
|
64
64
|
"SkipLink": {
|
|
65
65
|
"location": "import",
|
|
66
|
-
"path": "./mg-skip-links.conf"
|
|
66
|
+
"path": "./mg-skip-links.conf",
|
|
67
|
+
"id": "src/components/molecules/mg-skip-links/mg-skip-links.conf.tsx::SkipLink"
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
},
|
|
@@ -102,3 +103,4 @@ export class MgSkipLinks {
|
|
|
102
103
|
}];
|
|
103
104
|
}
|
|
104
105
|
}
|
|
106
|
+
//# sourceMappingURL=mg-skip-links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mg-skip-links.js","sourceRoot":"","sources":["../../../../src/components/molecules/mg-skip-links/mg-skip-links.tsx"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAO/C,MAAM,OAAO,WAAW;;IAoCtB;;gBAEY;IAEZ;;;OAGG;IACK,oBAAe,GAAG,CAAC,KAAkD,EAAQ,EAAE;MACrF,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;MAC3B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC;;;EA1BF,aAAa,CAAC,KAAiB;IAC7B,IACE,KAAK,KAAK,SAAS;MACnB,KAAK,CAAC,MAAM,KAAK,CAAC;MAClB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EACjI;MACA,MAAM,IAAI,KAAK,CAAC,yIAAyI,CAAC,CAAC;KAC5J;EACH,CAAC;EAoBD;;iBAEe;EAEf;;KAEG;EACH,iBAAiB;IACf,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC;EACrD,CAAC;EAED;;;KAGG;EACH,MAAM;IACJ,OAAO,CACL,WAAK,KAAK,EAAC,eAAe,EAAC,IAAI,EAAC,YAAY,gBAAa,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ;MACvF,UAAI,KAAK,EAAC,qBAAqB,EAAC,IAAI,EAAC,MAAM,IACxC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CACtB,UAAI,GAAG,EAAE,IAAI,CAAC,IAAI;QAChB,SAAG,KAAK,EAAC,qBAAqB,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,eAAe,IAC1E,IAAI,CAAC,KAAK,CACT,CACD,CACN,CAAC,CACC,CACD,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["/* eslint-disable jsx-a11y/no-redundant-roles */\nimport { Component, Element, Event, EventEmitter, h, Prop, Watch } from '@stencil/core';\nimport { SkipLink } from './mg-skip-links.conf';\nimport { initLocales } from '../../../locales';\n\n@Component({\n tag: 'mg-skip-links',\n styleUrl: 'mg-skip-links.scss',\n shadow: true,\n})\nexport class MgSkipLinks {\n /************\n * Internal *\n ************/\n\n private messages;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgSkipLinksElement;\n\n /**\n * Skip links\n */\n @Prop() links: SkipLink[];\n @Watch('links')\n validateLinks(links: SkipLink[]): void {\n if (\n links === undefined ||\n links.length === 0 ||\n links.some(link => link.href === undefined || !link.href.startsWith('#') || link.label === undefined || link.label.trim() === '')\n ) {\n throw new Error(`<mg-skip-links> prop \"links\": Cannot be empty and each link must contains an href starting with a \"#\" and a non empty label attributes.`);\n }\n }\n\n /**\n * Emited event when link is clicked\n */\n @Event({ eventName: 'go-to-anchor' }) goToAnchor: EventEmitter<string>;\n\n /***********\n * Methods *\n **********/\n\n /**\n * Handle link click and emit go-to-anchor event\n * @param event - mouse event\n */\n private handleLinkCLick = (event: MouseEvent & { currentTarget: HTMLElement }): void => {\n event.currentTarget.blur();\n this.goToAnchor.emit(event.currentTarget.getAttribute('href'));\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if props are well configured on init\n */\n componentWillLoad(): void {\n this.validateLinks(this.links);\n this.messages = initLocales(this.element).messages;\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <nav class=\"mg-skip-links\" role=\"navigation\" aria-label={this.messages.skipLinks.navLabel}>\n <ul class=\"mg-skip-links__list\" role=\"list\">\n {this.links.map(link => (\n <li key={link.href}>\n <a class=\"mg-skip-links__link\" href={link.href} onClick={this.handleLinkCLick}>\n {link.label}\n </a>\n </li>\n ))}\n </ul>\n </nav>\n );\n }\n}\n"]}
|