@mgdis/mg-components 5.17.0 → 5.19.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/{mg-menu.conf-43aacf30.js → components.utils-dc9c8a53.js} +160 -7
- package/dist/cjs/components.utils-dc9c8a53.js.map +1 -0
- package/dist/cjs/index-c042e24b.js +18 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_34.cjs.entry.js +761 -582
- package/dist/cjs/mg-action-more_34.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +5 -5
- package/dist/cjs/mg-item-more.cjs.entry.js.map +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +9 -9
- package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
- package/dist/collection/components/atoms/mg-badge/test/mg-badge.spec.js +5 -5
- package/dist/collection/components/atoms/mg-badge/test/mg-badge.spec.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +12 -12
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js +4 -4
- package/dist/collection/components/atoms/mg-button/test/mg-button.e2e.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js +3 -3
- package/dist/collection/components/atoms/mg-button/test/mg-button.spec.js.map +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.js +9 -9
- package/dist/collection/components/atoms/mg-card/mg-card.js.map +1 -1
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +3 -3
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js.map +1 -1
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +4 -4
- package/dist/collection/components/atoms/mg-divider/mg-divider.js.map +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +13 -15
- package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
- package/dist/collection/components/atoms/mg-icon/test/mg-icon.spec.js +4 -4
- package/dist/collection/components/atoms/mg-icon/test/mg-icon.spec.js.map +1 -1
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +5 -4
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js.map +1 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +9 -9
- package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.playwright.js +23 -0
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.playwright.js.map +1 -0
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.spec.js +5 -5
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.spec.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +2 -2
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +37 -17
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.e2e.js +7 -1
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.e2e.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js +9 -1
- package/dist/collection/components/atoms/mg-tooltip/test/mg-tooltip.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +12 -11
- package/dist/collection/components/molecules/inputs/MgInput.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +4 -4
- 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 +2 -2
- 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.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +111 -38
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.js +21 -27
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.e2e.playwright.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js +62 -6
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +84 -13
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js +55 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/test/mg-input-date.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +115 -44
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js +55 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/test/mg-input-numeric.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +88 -15
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js +55 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/test/mg-input-password.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +87 -14
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.e2e.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.e2e.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.spec.js +60 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/test/mg-input-radio.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +87 -14
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js +55 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/test/mg-input-select.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js +5 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +151 -34
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.playwright.js +147 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js +80 -7
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +110 -36
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js +69 -6
- package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +9 -9
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +2 -2
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +8 -9
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +6 -6
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js +5 -4
- package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
- package/dist/collection/components/molecules/mg-details/test/mg-details.spec.js +1 -1
- package/dist/collection/components/molecules/mg-details/test/mg-details.spec.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +6 -6
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js +4 -4
- package/dist/collection/components/molecules/mg-form/test/mg-form.spec.js.map +1 -1
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +7 -7
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -1
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +5 -4
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +8 -8
- package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
- package/dist/collection/components/molecules/mg-message/test/mg-message.spec.js +11 -11
- package/dist/collection/components/molecules/mg-message/test/mg-message.spec.js.map +1 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +8 -8
- package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js +7 -7
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.e2e.playwright.js.map +1 -1
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.js +3 -3
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.firefox.e2e.playwright.js.map +1 -1
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.spec.js +1 -1
- package/dist/collection/components/molecules/mg-modal/test/mg-modal.spec.js.map +1 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +3 -3
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +17 -15
- package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js +3 -3
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.e2e.playwright.js.map +1 -1
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.spec.js +11 -21
- package/dist/collection/components/molecules/mg-panel/test/mg-panel.spec.js.map +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +4 -4
- 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 +36 -16
- package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
- package/dist/collection/components/molecules/mg-popover/test/{mg-popover.e2e.js → mg-popover.e2e.playwright.js} +54 -62
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.spec.js +12 -0
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.spec.js.map +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +5 -6
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +34 -34
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
- package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.spec.js +13 -13
- package/dist/collection/components/molecules/mg-tabs/test/mg-tabs.spec.js.map +1 -1
- package/dist/collection/locales/en/messages.json +3 -3
- package/dist/collection/locales/fr/messages.json +3 -3
- package/dist/collection/utils/components.utils.js +16 -0
- package/dist/collection/utils/components.utils.js.map +1 -1
- package/dist/collection/utils/components.utils.spec.js +22 -1
- package/dist/collection/utils/components.utils.spec.js.map +1 -1
- package/dist/collection/variables.css +1 -275
- package/dist/components/MgInput.js +17 -16
- package/dist/components/MgInput.js.map +1 -1
- package/dist/components/components.utils.js +17 -1
- package/dist/components/components.utils.js.map +1 -1
- package/dist/components/index2.js +6 -6
- package/dist/components/mg-action-more.js +5 -5
- package/dist/components/mg-action-more.js.map +1 -1
- package/dist/components/mg-badge2.js +8 -8
- package/dist/components/mg-badge2.js.map +1 -1
- package/dist/components/mg-button2.js +11 -11
- package/dist/components/mg-button2.js.map +1 -1
- package/dist/components/mg-card2.js +8 -8
- package/dist/components/mg-card2.js.map +1 -1
- package/dist/components/mg-character-left2.js +1 -1
- package/dist/components/mg-character-left2.js.map +1 -1
- package/dist/components/mg-details.js +4 -3
- package/dist/components/mg-details.js.map +1 -1
- package/dist/components/mg-divider.js +3 -3
- package/dist/components/mg-divider.js.map +1 -1
- package/dist/components/mg-form.js +4 -4
- package/dist/components/mg-form.js.map +1 -1
- package/dist/components/mg-icon2.js +12 -14
- package/dist/components/mg-icon2.js.map +1 -1
- package/dist/components/mg-illustrated-message.js +7 -7
- package/dist/components/mg-illustrated-message.js.map +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +8 -8
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
- package/dist/components/mg-input-checkbox.js +70 -34
- package/dist/components/mg-input-checkbox.js.map +1 -1
- package/dist/components/mg-input-date.js +45 -12
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +76 -43
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-password.js +49 -14
- package/dist/components/mg-input-password.js.map +1 -1
- package/dist/components/mg-input-radio.js +48 -13
- package/dist/components/mg-input-radio.js.map +1 -1
- package/dist/components/mg-input-select2.js +48 -13
- package/dist/components/mg-input-select2.js.map +1 -1
- package/dist/components/mg-input-text2.js +83 -33
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-input-textarea.js +69 -35
- package/dist/components/mg-input-textarea.js.map +1 -1
- package/dist/components/mg-input-title2.js +4 -3
- 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-item-more.js +4 -3
- package/dist/components/mg-item-more.js.map +1 -1
- package/dist/components/mg-menu-item2.js +7 -8
- package/dist/components/mg-menu-item2.js.map +1 -1
- package/dist/components/mg-menu2.js +1 -1
- package/dist/components/mg-menu2.js.map +1 -1
- package/dist/components/mg-message.js +7 -7
- package/dist/components/mg-message.js.map +1 -1
- package/dist/components/mg-modal.js +7 -7
- package/dist/components/mg-modal.js.map +1 -1
- package/dist/components/mg-pagination2.js +2 -2
- package/dist/components/mg-pagination2.js.map +1 -1
- package/dist/components/mg-panel.js +16 -15
- package/dist/components/mg-panel.js.map +1 -1
- package/dist/components/mg-popover-content2.js +4 -4
- package/dist/components/mg-popover-content2.js.map +1 -1
- package/dist/components/mg-popover2.js +33 -14
- package/dist/components/mg-popover2.js.map +1 -1
- package/dist/components/mg-skip-links.js +4 -5
- package/dist/components/mg-skip-links.js.map +1 -1
- package/dist/components/mg-tabs.js +33 -33
- package/dist/components/mg-tabs.js.map +1 -1
- package/dist/components/mg-tag.js +8 -8
- package/dist/components/mg-tag.js.map +1 -1
- package/dist/components/mg-tooltip-content2.js +1 -1
- package/dist/components/mg-tooltip-content2.js.map +1 -1
- package/dist/components/mg-tooltip2.js +34 -15
- package/dist/components/mg-tooltip2.js.map +1 -1
- package/dist/esm/{mg-menu.conf-012fc9b4.js → components.utils-0f76010d.js} +153 -8
- package/dist/esm/components.utils-0f76010d.js.map +1 -0
- package/dist/esm/index-ce01e63b.js +18 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_34.entry.js +697 -518
- package/dist/esm/mg-action-more_34.entry.js.map +1 -1
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +4 -4
- package/dist/esm/mg-item-more.entry.js.map +1 -1
- package/dist/mg-components/locales/en/messages.json +3 -3
- package/dist/mg-components/locales/fr/messages.json +3 -3
- 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-768fc594.entry.js +2 -0
- package/dist/mg-components/p-768fc594.entry.js.map +1 -0
- package/dist/mg-components/p-c9e2c669.js +2 -0
- package/dist/mg-components/p-c9e2c669.js.map +1 -0
- package/dist/mg-components/p-d2d6afec.entry.js +2 -0
- package/dist/mg-components/p-d2d6afec.entry.js.map +1 -0
- package/dist/mg-components/variables.css +1 -275
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +1 -1
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -1
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +4 -4
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +22 -1
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +17 -2
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +35 -20
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +16 -1
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +16 -1
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +16 -1
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.conf.d.ts +12 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +30 -6
- package/dist/types/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +17 -5
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +2 -1
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +3 -3
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +2 -1
- package/dist/types/components/molecules/mg-popover/test/mg-popover.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +6 -5
- package/dist/types/components.d.ts +71 -13
- package/dist/types/utils/components.utils.d.ts +12 -0
- package/package.json +17 -18
- package/readme.md +0 -31
- package/dist/cjs/mg-menu.conf-43aacf30.js.map +0 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -116
- package/dist/collection/components/atoms/mg-button/mg-button.css +0 -182
- package/dist/collection/components/atoms/mg-card/mg-card.css +0 -75
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.css +0 -3
- package/dist/collection/components/atoms/mg-divider/mg-divider.css +0 -9
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +0 -138
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +0 -12
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +0 -131
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.js +0 -37
- package/dist/collection/components/atoms/mg-tag/test/mg-tag.e2e.js.map +0 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.css +0 -43
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +0 -3
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +0 -268
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +0 -211
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +0 -257
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +0 -254
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +0 -179
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +0 -264
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +0 -304
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.js +0 -171
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.e2e.js.map +0 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +0 -303
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +0 -233
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +0 -37
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +0 -377
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.css +0 -39
- package/dist/collection/components/molecules/mg-details/mg-details.css +0 -64
- package/dist/collection/components/molecules/mg-form/mg-form.css +0 -19
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.css +0 -45
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.css +0 -30
- package/dist/collection/components/molecules/mg-message/mg-message.css +0 -82
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +0 -67
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +0 -47
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +0 -64
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.css +0 -135
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +0 -11
- package/dist/collection/components/molecules/mg-popover/test/mg-popover.e2e.js.map +0 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.css +0 -28
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +0 -99
- package/dist/collection/styles/a11y.scss +0 -36
- package/dist/collection/styles/fonts.scss +0 -21
- package/dist/collection/styles/form.scss +0 -3
- package/dist/collection/styles/global.scss +0 -80
- package/dist/collection/styles/layout.scss +0 -29
- package/dist/collection/styles/main.scss +0 -23
- package/dist/collection/styles/mg-icon-animation.scss +0 -6
- package/dist/collection/styles/navigation-button.scss +0 -77
- package/dist/collection/styles/reset-mg-card-slotted-variables.scss +0 -11
- package/dist/collection/styles/typography.scss +0 -82
- package/dist/collection/styles/utilities.scss +0 -21
- package/dist/collection/test/typography.e2e.playwright.js +0 -12
- package/dist/collection/test/typography.e2e.playwright.js.map +0 -1
- package/dist/esm/mg-menu.conf-012fc9b4.js.map +0 -1
- package/dist/mg-components/p-1d7d6fa0.js +0 -2
- package/dist/mg-components/p-1d7d6fa0.js.map +0 -1
- package/dist/mg-components/p-9257e8f1.entry.js +0 -2
- package/dist/mg-components/p-9257e8f1.entry.js.map +0 -1
- package/dist/mg-components/p-caafc9cf.entry.js +0 -2
- package/dist/mg-components/p-caafc9cf.entry.js.map +0 -1
- package/dist/mg-components/styles/a11y.scss +0 -36
- package/dist/mg-components/styles/fonts.scss +0 -21
- package/dist/mg-components/styles/form.scss +0 -3
- package/dist/mg-components/styles/global.scss +0 -80
- package/dist/mg-components/styles/layout.scss +0 -29
- package/dist/mg-components/styles/main.scss +0 -23
- package/dist/mg-components/styles/mg-icon-animation.scss +0 -6
- package/dist/mg-components/styles/navigation-button.scss +0 -77
- package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +0 -11
- package/dist/mg-components/styles/typography.scss +0 -82
- package/dist/mg-components/styles/utilities.scss +0 -21
- /package/dist/types/{test/typography.e2e.playwright.d.ts → components/atoms/mg-tag/test/mg-tag.e2e.playwright.d.ts} +0 -0
package/dist/collection/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.js
CHANGED
|
@@ -60,14 +60,22 @@ describe('mg-input-textarea', () => {
|
|
|
60
60
|
expect(err.message).toMatch('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide"');
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
-
test.each(['', undefined])('Should throw an error when pattern is used with patternErrorMessage: %s', async (
|
|
63
|
+
test.each(['', ' ', null, undefined])('Should throw an error when pattern is used with patternErrorMessage: %s', async (patternErrorMessage) => {
|
|
64
64
|
expect.assertions(1);
|
|
65
65
|
try {
|
|
66
|
-
|
|
67
|
-
expect(root).toMatchSnapshot();
|
|
66
|
+
await getPage({ identifier: 'identifier', label: 'blu', pattern: '[a-z]*', patternErrorMessage });
|
|
68
67
|
}
|
|
69
68
|
catch (err) {
|
|
70
|
-
expect(err.message).toMatch('<mg-input-textarea>
|
|
69
|
+
expect(err.message).toMatch('<mg-input-textarea> props "pattern" and "patternErrorMessage" must be non-empty string and paired.');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
test.each(['', ' ', null, undefined])('Should throw an error when patternErrorMessage is used with invalid pattern: %s', async (pattern) => {
|
|
73
|
+
expect.assertions(1);
|
|
74
|
+
try {
|
|
75
|
+
await getPage({ identifier: 'identifier', label: 'blu', pattern, patternErrorMessage: 'pattern error message' });
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
expect(err.message).toMatch('<mg-input-textarea> props "pattern" and "patternErrorMessage" must be non-empty string and paired.');
|
|
71
79
|
}
|
|
72
80
|
});
|
|
73
81
|
test('Should trigger events', async () => {
|
|
@@ -86,7 +94,7 @@ describe('mg-input-textarea', () => {
|
|
|
86
94
|
jest.spyOn(page.rootInstance.valueChange, 'emit');
|
|
87
95
|
input.dispatchEvent(new CustomEvent('focus', { bubbles: true }));
|
|
88
96
|
await page.waitForChanges();
|
|
89
|
-
expect(page.rootInstance.classCollection.has('is-focused')).toEqual(true);
|
|
97
|
+
expect(page.rootInstance.classCollection.has('mg-u-is-focused')).toEqual(true);
|
|
90
98
|
expect(page.root).toMatchSnapshot(); //Snapshot on focus
|
|
91
99
|
input.value = inputValue;
|
|
92
100
|
input.dispatchEvent(new CustomEvent('input', { bubbles: true }));
|
|
@@ -94,7 +102,7 @@ describe('mg-input-textarea', () => {
|
|
|
94
102
|
expect(page.rootInstance.valueChange.emit).toHaveBeenCalledWith(inputValue);
|
|
95
103
|
input.dispatchEvent(new CustomEvent('blur', { bubbles: true }));
|
|
96
104
|
await page.waitForChanges();
|
|
97
|
-
expect(page.rootInstance.classCollection.has('is-focused')).toEqual(false);
|
|
105
|
+
expect(page.rootInstance.classCollection.has('mg-u-is-focused')).toEqual(false);
|
|
98
106
|
});
|
|
99
107
|
describe.each(['readonly', 'disabled'])('validity, case next state is %s', nextState => {
|
|
100
108
|
test.each([
|
|
@@ -150,6 +158,61 @@ describe('mg-input-textarea', () => {
|
|
|
150
158
|
await page.waitForChanges();
|
|
151
159
|
expect(page.root).toMatchSnapshot();
|
|
152
160
|
});
|
|
161
|
+
test.each([
|
|
162
|
+
{
|
|
163
|
+
valid: true,
|
|
164
|
+
errorMessage: 'Override error',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
valid: false,
|
|
168
|
+
errorMessage: 'Override error',
|
|
169
|
+
},
|
|
170
|
+
])("should display override error with setError component's public method", async (params) => {
|
|
171
|
+
const page = await getPage({ label: 'label', identifier: 'identifier', required: true });
|
|
172
|
+
expect(page.root).toMatchSnapshot();
|
|
173
|
+
const element = page.doc.querySelector('mg-input-textarea');
|
|
174
|
+
const input = element.shadowRoot.querySelector('textarea');
|
|
175
|
+
//mock validity
|
|
176
|
+
Object.defineProperty(input, 'validity', {
|
|
177
|
+
get: () => ({}),
|
|
178
|
+
});
|
|
179
|
+
await element.setError(params.valid, params.errorMessage);
|
|
180
|
+
await page.waitForChanges();
|
|
181
|
+
expect(page.root).toMatchSnapshot();
|
|
182
|
+
});
|
|
183
|
+
test.each([
|
|
184
|
+
{
|
|
185
|
+
valid: '',
|
|
186
|
+
errorMessage: 'Override error',
|
|
187
|
+
error: '<mg-input-textarea> method "setError()" param "valid" must be a boolean',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
valid: undefined,
|
|
191
|
+
errorMessage: 'Override error',
|
|
192
|
+
error: '<mg-input-textarea> method "setError()" param "valid" must be a boolean',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
valid: true,
|
|
196
|
+
errorMessage: ' ',
|
|
197
|
+
error: '<mg-input-textarea> method "setError()" param "errorMessage" must be a string',
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
valid: true,
|
|
201
|
+
errorMessage: true,
|
|
202
|
+
error: '<mg-input-textarea> method "setError()" param "errorMessage" must be a string',
|
|
203
|
+
},
|
|
204
|
+
])("shloud throw error with setError component's public method invalid params", async (params) => {
|
|
205
|
+
expect.assertions(1);
|
|
206
|
+
try {
|
|
207
|
+
const page = await getPage({ label: 'label', identifier: 'identifier', required: true });
|
|
208
|
+
const element = page.doc.querySelector('mg-input-textarea');
|
|
209
|
+
await element.setError(params.valid, params.errorMessage);
|
|
210
|
+
await page.waitForChanges();
|
|
211
|
+
}
|
|
212
|
+
catch (err) {
|
|
213
|
+
expect(err.message).toMatch(params.error);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
153
216
|
test.each(['fr', 'xx'])('display error message with locale: %s', async (lang) => {
|
|
154
217
|
const page = await getPage({ label: 'label', identifier: 'identifier', required: true, lang });
|
|
155
218
|
const element = page.doc.querySelector('mg-input-textarea');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-input-textarea.spec.js","sourceRoot":"","sources":["../../../../../../src/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,QAAQ,MAAM,yCAAyC,CAAC;AAE/D,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE;EACrB,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AAC,eAAe,EAAE,CAAC;IAEpC,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;IACpB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAE5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IAEpC,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;IACrB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAE5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IAEpC,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 { MgInputTextarea } from '../mg-input-textarea';\nimport messages from '../../../../../locales/en/messages.json';\n\nconst getPage = args => {\n const page = newSpecPage({\n components: [MgInputTextarea],\n template: () => <mg-input-textarea {...args}></mg-input-textarea>,\n });\n\n jest.runAllTimers();\n\n return page;\n};\n\ndescribe('mg-input-textarea', () => {\n beforeEach(() => jest.useFakeTimers());\n afterEach(() => jest.runOnlyPendingTimers());\n test.each([\n { label: 'label', identifier: 'identifier' },\n { label: 'label', identifier: 'identifier', labelHide: true },\n { label: 'label', identifier: 'identifier', labelOnTop: true },\n { label: 'label', identifier: 'identifier', readonly: true },\n { label: 'label', identifier: 'identifier', readonly: true, labelOnTop: true, tooltip: 'Tooltip message' },\n { label: 'label', identifier: 'identifier', readonly: true, value: 'blu' },\n { label: 'label', identifier: 'identifier', required: true, value: 'blu', helpText: 'My help text' },\n { label: 'label', identifier: 'identifier', required: true, readonly: true, value: 'blu', helpText: 'My help text' },\n { label: 'label', identifier: 'identifier', required: true, disabled: true, value: 'blu', helpText: 'My help text' },\n { label: 'label', identifier: 'identifier', tooltip: 'My Tooltip Message' },\n { label: 'label', identifier: 'identifier', tooltip: 'My Tooltip Message', labelOnTop: true },\n { label: 'label', identifier: 'identifier', resizable: 'both' },\n { label: 'label', identifier: 'identifier', resizable: 'vertical' },\n { label: 'label', identifier: 'identifier', resizable: 'horizontal' },\n { label: 'label', identifier: 'identifier', displayCharacterLeft: false },\n ])('Should render with args %s:', async args => {\n const { root } = await getPage(args);\n expect(root).toMatchSnapshot();\n });\n\n test.each(['', ' ', undefined])('Should not render with invalid identifier property: %s', async identifier => {\n expect.assertions(1);\n try {\n await getPage({ identifier });\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"identifier\" is required.');\n }\n });\n\n test.each(['', ' ', undefined])('Should throw error with invalid label property: %s', async label => {\n expect.assertions(1);\n try {\n await getPage({ identifier: 'identifier', label });\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"label\" is required.');\n }\n });\n\n test('Should throw an error with labelOnTop & labelHide set to true', async () => {\n expect.assertions(1);\n try {\n await getPage({ identifier: 'identifier', label: 'batman', labelOnTop: true, labelHide: true });\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"labelOnTop\" must not be paired with the prop \"labelHide\"');\n }\n });\n\n test.each(['', undefined])('Should throw an error when pattern is used with patternErrorMessage: %s', async value => {\n expect.assertions(1);\n try {\n const { root } = await getPage({ identifier: 'identifier', label: 'blu', pattern: '[a-z]*', patternErrorMessage: value });\n expect(root).toMatchSnapshot();\n } catch (err) {\n expect(err.message).toMatch('<mg-input-textarea> prop \"pattern\" must be paired with the prop \"patternErrorMessage\"');\n }\n });\n\n test('Should trigger events', async () => {\n const inputValue = 'Blu';\n const args = { label: 'label', identifier: 'identifier', helpText: 'My help text' };\n const page = await getPage(args);\n\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn(() => true);\n Object.defineProperty(input, 'validity', {\n get: jest.fn(() => ({\n valueMissing: false,\n })),\n });\n\n jest.spyOn(page.rootInstance.valueChange, 'emit');\n\n input.dispatchEvent(new CustomEvent('focus', { bubbles: true }));\n await page.waitForChanges();\n expect(page.rootInstance.classCollection.has('is-focused')).toEqual(true);\n\n expect(page.root).toMatchSnapshot(); //Snapshot on focus\n\n input.value = inputValue;\n input.dispatchEvent(new CustomEvent('input', { bubbles: true }));\n await page.waitForChanges();\n expect(page.rootInstance.valueChange.emit).toHaveBeenCalledWith(inputValue);\n\n input.dispatchEvent(new CustomEvent('blur', { bubbles: true }));\n await page.waitForChanges();\n expect(page.rootInstance.classCollection.has('is-focused')).toEqual(false);\n });\n\n describe.each(['readonly', 'disabled'])('validity, case next state is %s', nextState => {\n test.each([\n { validity: true, valueMissing: false },\n { validity: false, valueMissing: true },\n { validity: false, valueMissing: false, value: 'Blu', pattern: '[a-z]*', patternErrorMessage: 'Non' },\n ])('validity (%s), valueMissing (%s)', async ({ validity, valueMissing, value, pattern, patternErrorMessage }) => {\n const args = { label: 'label', identifier: 'identifier', value, pattern, patternErrorMessage };\n const page = await getPage(args);\n\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn(() => validity);\n Object.defineProperty(input, 'validity', {\n get: jest.fn(() => ({\n valueMissing,\n })),\n });\n\n input.dispatchEvent(new CustomEvent('blur', { bubbles: true }));\n await page.waitForChanges();\n\n if (validity) {\n expect(page.rootInstance.errorMessage).toBeUndefined();\n } else if (valueMissing) {\n expect(page.rootInstance.errorMessage).toEqual(messages.errors.required);\n } else if (pattern !== undefined) {\n expect(page.rootInstance.errorMessage).toEqual(patternErrorMessage);\n }\n expect(page.rootInstance.valid).toEqual(validity);\n expect(page.rootInstance.invalid).toEqual(!validity);\n if (valueMissing) {\n expect(page.root).toMatchSnapshot(); //Snapshot with readonly/disabled FALSE\n element[nextState] = true;\n await page.waitForChanges();\n expect(page.root).toMatchSnapshot(); //Snapshot with readonly/disabled TRUE\n }\n });\n });\n\n test(\"display error with displayError component's public method\", async () => {\n const page = await getPage({ label: 'label', identifier: 'identifier', required: true });\n\n expect(page.root).toMatchSnapshot();\n\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn(() => false);\n Object.defineProperty(input, 'validity', {\n get: jest.fn(() => ({\n valueMissing: true,\n })),\n });\n\n await element.displayError();\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n });\n\n test.each(['fr', 'xx'])('display error message with locale: %s', async lang => {\n const page = await getPage({ label: 'label', identifier: 'identifier', required: true, lang });\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn(() => false);\n Object.defineProperty(input, 'validity', {\n get: jest.fn(() => ({\n valueMissing: true,\n })),\n });\n\n await element.displayError();\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n });\n\n test('Should remove error on input', async () => {\n const page = await getPage({ label: 'label', identifier: 'identifier', required: true });\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn().mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValueOnce(true).mockReturnValueOnce(true);\n Object.defineProperty(input, 'validity', {\n get: jest\n .fn()\n .mockReturnValueOnce({\n valueMissing: true,\n })\n .mockReturnValueOnce({\n valueMissing: true,\n })\n .mockReturnValueOnce({\n valueMissing: false,\n })\n .mockReturnValueOnce({\n valueMissing: false,\n }),\n });\n\n await element.displayError();\n\n await page.waitForChanges();\n\n expect(page.rootInstance.hasDisplayedError).toEqual(true);\n expect(page.rootInstance.errorMessage).toEqual(messages.errors.required);\n\n input.value = 'blu';\n input.dispatchEvent(new CustomEvent('input', { bubbles: true }));\n await page.waitForChanges();\n\n expect(page.rootInstance.hasDisplayedError).toEqual(true);\n expect(page.rootInstance.errorMessage).toBeUndefined();\n\n input.dispatchEvent(new CustomEvent('blur', { bubbles: true }));\n await page.waitForChanges();\n\n expect(page.rootInstance.hasDisplayedError).toEqual(false);\n });\n\n test('Should remove error on input when required change dynamically', async () => {\n const page = await getPage({ label: 'label', identifier: 'identifier', required: true });\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn().mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValueOnce(true);\n Object.defineProperty(input, 'validity', {\n get: jest\n .fn()\n .mockReturnValueOnce({\n valueMissing: true,\n })\n .mockReturnValueOnce({\n valueMissing: true,\n })\n .mockReturnValueOnce({\n valueMissing: false,\n })\n .mockReturnValueOnce({\n valueMissing: false,\n }),\n });\n\n await element.displayError();\n await page.waitForChanges();\n\n expect(page.rootInstance.hasDisplayedError).toEqual(true);\n expect(page.rootInstance.errorMessage).toEqual(messages.errors.required);\n\n element.required = false;\n await page.waitForChanges();\n\n // Error message should disapear and change the hasDisplayedError status\n expect(page.rootInstance.hasDisplayedError).toEqual(false);\n expect(page.rootInstance.errorMessage).toBeUndefined();\n\n element.required = true;\n await page.waitForChanges();\n\n // If back on required the message is still not displayed\n expect(page.rootInstance.hasDisplayedError).toEqual(false);\n expect(page.rootInstance.errorMessage).toBeUndefined();\n });\n\n test('Should update mg-width', async () => {\n const page = await getPage({ label: 'label', identifier: 'identifier' });\n const element = page.doc.querySelector('mg-input-textarea');\n\n element.mgWidth = 2;\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n\n element.mgWidth = 4;\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n\n element.mgWidth = 16;\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n\n expect(page.root).toMatchSnapshot();\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"mg-input-textarea.spec.js","sourceRoot":"","sources":["../../../../../../src/components/molecules/inputs/mg-input-textarea/test/mg-input-textarea.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,u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C,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IAEpC,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;IACpB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAE5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IAEpC,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;IACrB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAE5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IAEpC,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 { MgInputTextarea } from '../mg-input-textarea';\nimport messages from '../../../../../locales/en/messages.json';\n\nconst getPage = args => {\n const page = newSpecPage({\n components: [MgInputTextarea],\n template: () => <mg-input-textarea {...args}></mg-input-textarea>,\n });\n\n jest.runAllTimers();\n\n return page;\n};\n\ndescribe('mg-input-textarea', () => {\n beforeEach(() => jest.useFakeTimers());\n afterEach(() => jest.runOnlyPendingTimers());\n test.each([\n { label: 'label', identifier: 'identifier' },\n { label: 'label', identifier: 'identifier', labelHide: true },\n { label: 'label', identifier: 'identifier', labelOnTop: true },\n { label: 'label', identifier: 'identifier', readonly: true },\n { label: 'label', identifier: 'identifier', readonly: true, labelOnTop: true, tooltip: 'Tooltip message' },\n { label: 'label', identifier: 'identifier', readonly: true, value: 'blu' },\n { label: 'label', identifier: 'identifier', required: true, value: 'blu', helpText: 'My help text' },\n { label: 'label', identifier: 'identifier', required: true, readonly: true, value: 'blu', helpText: 'My help text' },\n { label: 'label', identifier: 'identifier', required: true, disabled: true, value: 'blu', helpText: 'My help text' },\n { label: 'label', identifier: 'identifier', tooltip: 'My Tooltip Message' },\n { label: 'label', identifier: 'identifier', tooltip: 'My Tooltip Message', labelOnTop: true },\n { label: 'label', identifier: 'identifier', resizable: 'both' },\n { label: 'label', identifier: 'identifier', resizable: 'vertical' },\n { label: 'label', identifier: 'identifier', resizable: 'horizontal' },\n { label: 'label', identifier: 'identifier', displayCharacterLeft: false },\n ])('Should render with args %s:', async args => {\n const { root } = await getPage(args);\n expect(root).toMatchSnapshot();\n });\n\n test.each(['', ' ', undefined])('Should not render with invalid identifier property: %s', async identifier => {\n expect.assertions(1);\n try {\n await getPage({ identifier });\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"identifier\" is required.');\n }\n });\n\n test.each(['', ' ', undefined])('Should throw error with invalid label property: %s', async label => {\n expect.assertions(1);\n try {\n await getPage({ identifier: 'identifier', label });\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"label\" is required.');\n }\n });\n\n test('Should throw an error with labelOnTop & labelHide set to true', async () => {\n expect.assertions(1);\n try {\n await getPage({ identifier: 'identifier', label: 'batman', labelOnTop: true, labelHide: true });\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"labelOnTop\" must not be paired with the prop \"labelHide\"');\n }\n });\n\n test.each(['', ' ', null, undefined])('Should throw an error when pattern is used with patternErrorMessage: %s', async patternErrorMessage => {\n expect.assertions(1);\n try {\n await getPage({ identifier: 'identifier', label: 'blu', pattern: '[a-z]*', patternErrorMessage });\n } catch (err) {\n expect(err.message).toMatch('<mg-input-textarea> props \"pattern\" and \"patternErrorMessage\" must be non-empty string and paired.');\n }\n });\n\n test.each(['', ' ', null, undefined])('Should throw an error when patternErrorMessage is used with invalid pattern: %s', async pattern => {\n expect.assertions(1);\n try {\n await getPage({ identifier: 'identifier', label: 'blu', pattern, patternErrorMessage: 'pattern error message' });\n } catch (err) {\n expect(err.message).toMatch('<mg-input-textarea> props \"pattern\" and \"patternErrorMessage\" must be non-empty string and paired.');\n }\n });\n\n test('Should trigger events', async () => {\n const inputValue = 'Blu';\n const args = { label: 'label', identifier: 'identifier', helpText: 'My help text' };\n const page = await getPage(args);\n\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn(() => true);\n Object.defineProperty(input, 'validity', {\n get: jest.fn(() => ({\n valueMissing: false,\n })),\n });\n\n jest.spyOn(page.rootInstance.valueChange, 'emit');\n\n input.dispatchEvent(new CustomEvent('focus', { bubbles: true }));\n await page.waitForChanges();\n expect(page.rootInstance.classCollection.has('mg-u-is-focused')).toEqual(true);\n\n expect(page.root).toMatchSnapshot(); //Snapshot on focus\n\n input.value = inputValue;\n input.dispatchEvent(new CustomEvent('input', { bubbles: true }));\n await page.waitForChanges();\n expect(page.rootInstance.valueChange.emit).toHaveBeenCalledWith(inputValue);\n\n input.dispatchEvent(new CustomEvent('blur', { bubbles: true }));\n await page.waitForChanges();\n expect(page.rootInstance.classCollection.has('mg-u-is-focused')).toEqual(false);\n });\n\n describe.each(['readonly', 'disabled'])('validity, case next state is %s', nextState => {\n test.each([\n { validity: true, valueMissing: false },\n { validity: false, valueMissing: true },\n { validity: false, valueMissing: false, value: 'Blu', pattern: '[a-z]*', patternErrorMessage: 'Non' },\n ])('validity (%s), valueMissing (%s)', async ({ validity, valueMissing, value, pattern, patternErrorMessage }) => {\n const args = { label: 'label', identifier: 'identifier', value, pattern, patternErrorMessage };\n const page = await getPage(args);\n\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn(() => validity);\n Object.defineProperty(input, 'validity', {\n get: jest.fn(() => ({\n valueMissing,\n })),\n });\n\n input.dispatchEvent(new CustomEvent('blur', { bubbles: true }));\n await page.waitForChanges();\n\n if (validity) {\n expect(page.rootInstance.errorMessage).toBeUndefined();\n } else if (valueMissing) {\n expect(page.rootInstance.errorMessage).toEqual(messages.errors.required);\n } else if (pattern !== undefined) {\n expect(page.rootInstance.errorMessage).toEqual(patternErrorMessage);\n }\n expect(page.rootInstance.valid).toEqual(validity);\n expect(page.rootInstance.invalid).toEqual(!validity);\n if (valueMissing) {\n expect(page.root).toMatchSnapshot(); //Snapshot with readonly/disabled FALSE\n element[nextState] = true;\n await page.waitForChanges();\n expect(page.root).toMatchSnapshot(); //Snapshot with readonly/disabled TRUE\n }\n });\n });\n\n test(\"display error with displayError component's public method\", async () => {\n const page = await getPage({ label: 'label', identifier: 'identifier', required: true });\n\n expect(page.root).toMatchSnapshot();\n\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn(() => false);\n Object.defineProperty(input, 'validity', {\n get: jest.fn(() => ({\n valueMissing: true,\n })),\n });\n\n await element.displayError();\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n });\n\n test.each([\n {\n valid: true,\n errorMessage: 'Override error',\n },\n {\n valid: false,\n errorMessage: 'Override error',\n },\n ])(\"should display override error with setError component's public method\", async params => {\n const page = await getPage({ label: 'label', identifier: 'identifier', required: true });\n\n expect(page.root).toMatchSnapshot();\n\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n Object.defineProperty(input, 'validity', {\n get: () => ({}),\n });\n\n await element.setError(params.valid, params.errorMessage);\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n });\n\n test.each([\n {\n valid: '',\n errorMessage: 'Override error',\n error: '<mg-input-textarea> method \"setError()\" param \"valid\" must be a boolean',\n },\n {\n valid: undefined,\n errorMessage: 'Override error',\n error: '<mg-input-textarea> method \"setError()\" param \"valid\" must be a boolean',\n },\n {\n valid: true,\n errorMessage: ' ',\n error: '<mg-input-textarea> method \"setError()\" param \"errorMessage\" must be a string',\n },\n {\n valid: true,\n errorMessage: true,\n error: '<mg-input-textarea> method \"setError()\" param \"errorMessage\" must be a string',\n },\n ])(\"shloud throw error with setError component's public method invalid params\", async params => {\n expect.assertions(1);\n try {\n const page = await getPage({ label: 'label', identifier: 'identifier', required: true });\n const element = page.doc.querySelector('mg-input-textarea');\n\n await element.setError(params.valid as unknown as boolean, params.errorMessage as unknown as string);\n await page.waitForChanges();\n } catch (err) {\n expect(err.message).toMatch(params.error);\n }\n });\n\n test.each(['fr', 'xx'])('display error message with locale: %s', async lang => {\n const page = await getPage({ label: 'label', identifier: 'identifier', required: true, lang });\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn(() => false);\n Object.defineProperty(input, 'validity', {\n get: jest.fn(() => ({\n valueMissing: true,\n })),\n });\n\n await element.displayError();\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n });\n\n test('Should remove error on input', async () => {\n const page = await getPage({ label: 'label', identifier: 'identifier', required: true });\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn().mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValueOnce(true).mockReturnValueOnce(true);\n Object.defineProperty(input, 'validity', {\n get: jest\n .fn()\n .mockReturnValueOnce({\n valueMissing: true,\n })\n .mockReturnValueOnce({\n valueMissing: true,\n })\n .mockReturnValueOnce({\n valueMissing: false,\n })\n .mockReturnValueOnce({\n valueMissing: false,\n }),\n });\n\n await element.displayError();\n\n await page.waitForChanges();\n\n expect(page.rootInstance.hasDisplayedError).toEqual(true);\n expect(page.rootInstance.errorMessage).toEqual(messages.errors.required);\n\n input.value = 'blu';\n input.dispatchEvent(new CustomEvent('input', { bubbles: true }));\n await page.waitForChanges();\n\n expect(page.rootInstance.hasDisplayedError).toEqual(true);\n expect(page.rootInstance.errorMessage).toBeUndefined();\n\n input.dispatchEvent(new CustomEvent('blur', { bubbles: true }));\n await page.waitForChanges();\n\n expect(page.rootInstance.hasDisplayedError).toEqual(false);\n });\n\n test('Should remove error on input when required change dynamically', async () => {\n const page = await getPage({ label: 'label', identifier: 'identifier', required: true });\n const element = page.doc.querySelector('mg-input-textarea');\n const input = element.shadowRoot.querySelector('textarea');\n\n //mock validity\n input.checkValidity = jest.fn().mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValueOnce(true);\n Object.defineProperty(input, 'validity', {\n get: jest\n .fn()\n .mockReturnValueOnce({\n valueMissing: true,\n })\n .mockReturnValueOnce({\n valueMissing: true,\n })\n .mockReturnValueOnce({\n valueMissing: false,\n })\n .mockReturnValueOnce({\n valueMissing: false,\n }),\n });\n\n await element.displayError();\n await page.waitForChanges();\n\n expect(page.rootInstance.hasDisplayedError).toEqual(true);\n expect(page.rootInstance.errorMessage).toEqual(messages.errors.required);\n\n element.required = false;\n await page.waitForChanges();\n\n // Error message should disapear and change the hasDisplayedError status\n expect(page.rootInstance.hasDisplayedError).toEqual(false);\n expect(page.rootInstance.errorMessage).toBeUndefined();\n\n element.required = true;\n await page.waitForChanges();\n\n // If back on required the message is still not displayed\n expect(page.rootInstance.hasDisplayedError).toEqual(false);\n expect(page.rootInstance.errorMessage).toBeUndefined();\n });\n\n test('Should update mg-width', async () => {\n const page = await getPage({ label: 'label', identifier: 'identifier' });\n const element = page.doc.querySelector('mg-input-textarea');\n\n element.mgWidth = 2;\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n\n element.mgWidth = 4;\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n\n element.mgWidth = 16;\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n\n expect(page.root).toMatchSnapshot();\n });\n});\n"]}
|
|
@@ -15,11 +15,11 @@ export class MgInputToggle {
|
|
|
15
15
|
* Internal *
|
|
16
16
|
************/
|
|
17
17
|
// Classes
|
|
18
|
-
this.classReadonly = 'mg-input--toggle-readonly';
|
|
19
|
-
this.classDisabled = 'mg-input--toggle-disabled';
|
|
20
|
-
this.classIsActive = 'mg-input--toggle-is-active';
|
|
21
|
-
this.classOnOff = 'mg-input--toggle-on-off';
|
|
22
|
-
this.classIcon = 'mg-input--toggle-icon';
|
|
18
|
+
this.classReadonly = 'mg-c-input--toggle-readonly';
|
|
19
|
+
this.classDisabled = 'mg-c-input--toggle-disabled';
|
|
20
|
+
this.classIsActive = 'mg-c-input--toggle-is-active';
|
|
21
|
+
this.classOnOff = 'mg-c-input--toggle-on-off';
|
|
22
|
+
this.classIcon = 'mg-c-input--toggle-icon';
|
|
23
23
|
/**
|
|
24
24
|
* Change checked value
|
|
25
25
|
*/
|
|
@@ -53,7 +53,7 @@ export class MgInputToggle {
|
|
|
53
53
|
this.disabled = false;
|
|
54
54
|
this.tooltip = undefined;
|
|
55
55
|
this.helpText = undefined;
|
|
56
|
-
this.classCollection = new ClassList(['mg-input--toggle']);
|
|
56
|
+
this.classCollection = new ClassList(['mg-c-input--toggle']);
|
|
57
57
|
this.options = undefined;
|
|
58
58
|
this.checked = false;
|
|
59
59
|
}
|
|
@@ -158,18 +158,18 @@ export class MgInputToggle {
|
|
|
158
158
|
* @returns HTML Element
|
|
159
159
|
*/
|
|
160
160
|
render() {
|
|
161
|
-
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-2" })))));
|
|
161
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-c-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-2" })))));
|
|
162
162
|
}
|
|
163
163
|
static get is() { return "mg-input-toggle"; }
|
|
164
164
|
static get encapsulation() { return "shadow"; }
|
|
165
165
|
static get originalStyleUrls() {
|
|
166
166
|
return {
|
|
167
|
-
"$": ["mg-input-toggle.
|
|
167
|
+
"$": ["../../../../../node_modules/@mgdis/styles/dist/components/mg-input-toggle.css"]
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
static get styleUrls() {
|
|
171
171
|
return {
|
|
172
|
-
"$": ["mg-input-toggle.css"]
|
|
172
|
+
"$": ["../../../../../node_modules/@mgdis/styles/dist/components/mg-input-toggle.css"]
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
175
|
static get properties() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-input-toggle.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-toggle/mg-input-toggle.tsx"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,uDAAuD;AACvD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGlF;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAW,E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K,EAAE,IAAI,CAAC,KAAe,EAC3B,aAAa,EAAE,SAAS,EACxB,OAAO,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,SAAS,EACvB,UAAU,EAAE,KAAK;MAEjB,cACE,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,QAAQ,kBACC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,mBACtB,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAC7C,EAAE,EAAE,IAAI,CAAC,UAAU,EACnB,KAAK,EAAC,yBAAyB,EAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EACxC,OAAO,EAAE,IAAI,CAAC,aAAa;QAE3B,2BAAkB,MAAM,EAAC,KAAK,EAAC,iCAAiC;UAC9D,YAAM,IAAI,EAAC,QAAQ,GAAQ,CACtB;QACP,2BAAkB,MAAM,EAAC,KAAK,EAAC,iCAAiC;UAC9D,YAAM,IAAI,EAAC,QAAQ,GAAQ,CACtB,CACA,CACD,CACX,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Component, Event, h, Prop, EventEmitter, State, Watch, Element } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { ClassList, allItemsAreString } from '../../../../utils/components.utils';\nimport { ToggleValue } from './mg-input-toggle.conf';\n\n/**\n * type Option validation function\n * @param option - radio option\n * @returns toggle option type is valid\n */\nconst isOption = (option: ToggleValue): boolean => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;\n\n@Component({\n tag: 'mg-input-toggle',\n styleUrl: 'mg-input-toggle.scss',\n shadow: true,\n})\nexport class MgInputToggle {\n /************\n * Internal *\n ************/\n\n // Classes\n private classReadonly = 'mg-input--toggle-readonly';\n private classDisabled = 'mg-input--toggle-disabled';\n private classIsActive = 'mg-input--toggle-is-active';\n private classOnOff = 'mg-input--toggle-on-off';\n private classIcon = 'mg-input--toggle-icon';\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputToggleElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true }) value: any;\n @Watch('value')\n handleValue(newValue: any): void {\n // Swich to the right option\n this.setChecked();\n // Emit value-change event\n this.valueChange.emit(newValue);\n }\n\n /**\n * Items are the possible options to select\n */\n @Prop() items!: string[] | ToggleValue[];\n @Watch('items')\n validateItems(newValue: string[] | ToggleValue[]): void {\n if (typeof newValue === 'object' && this.items.length !== 2) {\n throw new Error('<mg-input-toggle> prop \"items\" require 2 items.');\n }\n // String array\n else if (allItemsAreString(newValue as string[])) {\n this.options = (newValue as string[]).map(item => ({ title: item, value: item }));\n }\n // Object array\n else if (newValue && (newValue as ToggleValue[]).every(item => isOption(item))) {\n this.options = newValue as ToggleValue[];\n } else {\n throw new Error('<mg-input-toggle> prop \"items\" is required and all items must be the same type: ToggleValue.');\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Define if toggle have on/off style\n */\n @Prop() isOnOff = false;\n @Watch('isOnOff')\n handleIsOnOff(newValue: boolean): void {\n if (newValue) this.classCollection.add(this.classOnOff);\n else this.classCollection.delete(this.classOnOff);\n }\n\n /**\n * Define if toggle display icon\n */\n @Prop() isIcon = false;\n @Watch('isIcon')\n handleIsIcon(newValue: boolean): void {\n if (newValue) this.classCollection.add(this.classIcon);\n else this.classCollection.delete(this.classIcon);\n }\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n @Watch('readonly')\n handleReadonly(newValue: boolean): void {\n if (newValue) this.classCollection.add(this.classReadonly);\n else this.classCollection.delete(this.classReadonly);\n }\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('disabled')\n handleDisabled(newValue: boolean): void {\n if (newValue) this.classCollection.add(this.classDisabled);\n else this.classCollection.delete(this.classDisabled);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-input--toggle']);\n\n /**\n * Formated items for display\n */\n @State() options: ToggleValue[];\n\n /**\n * Checked internal value\n */\n @State() checked = false;\n @Watch('checked')\n handleChecked(newValue: boolean): void {\n // style\n if (newValue) this.classCollection.add(this.classIsActive);\n else this.classCollection.delete(this.classIsActive);\n\n // update value\n this.value = this.options[newValue ? 1 : 0].value;\n }\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<any>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<boolean>;\n\n /**\n * Change checked value\n */\n private toggleChecked = (): void => {\n this.checked = !this.checked;\n };\n\n /**\n * Slots validation\n */\n private validateSlots = (): void => {\n const slots = Array.from(this.element.children);\n if (slots.length !== 2) {\n throw new Error('<mg-input-toggle> 2 slots are required.');\n } else if (!this.isIcon) {\n // Due to text-overflow set to ellipsis\n // we need to ensure that slot element have title to display value on mouse over\n slots.forEach(slot => slot.setAttribute('title', slot.textContent));\n }\n };\n\n /**\n * set checked state\n */\n private setChecked(): void {\n const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);\n\n if ([0, 1].includes(optionTrueValueIndex)) {\n // has \"value\" props type is not a boolean, it is bind/render as an attributes/props\n // true props will be represent by \"true\" string so we convert it has boolean\n // true attribute will be represent by \"\" string so we convert it has boolean\n // https://stenciljs.com/docs/properties\n if (['', 'true'].includes(this.value as string) && this.options.find(option => option.value) !== undefined) {\n this.value = true;\n }\n\n // when options are boolean values and ordered as [true,false] instead [false,true]\n // we need to reversed the checked value logic\n const selectedValue = this.value === this.options[optionTrueValueIndex].value;\n this.checked = optionTrueValueIndex === 0 ? !selectedValue : selectedValue;\n } else {\n this.checked = this.value === this.options[1].value;\n }\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Check items format\n this.validateItems(this.items);\n // Check slots\n this.validateSlots();\n // init checked value\n this.setChecked();\n // apply handler\n this.handleIsOnOff(this.isOnOff);\n this.handleIsIcon(this.isIcon);\n this.handleReadonly(this.readonly);\n this.handleDisabled(this.disabled);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={undefined}\n readonly={undefined}\n mgWidth={undefined}\n disabled={this.disabled}\n value={this.value as string}\n readonlyValue={undefined}\n tooltip={!this.readonly && this.tooltip}\n helpText={this.helpText}\n errorMessage={undefined}\n isFieldset={false}\n >\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={this.checked.toString()}\n aria-readonly={this.disabled || this.readonly}\n id={this.identifier}\n class=\"mg-input__button-toggle\"\n disabled={this.disabled || this.readonly}\n onClick={this.toggleChecked}\n >\n <span aria-hidden=\"true\" class=\"mg-input__toggle-item-container\">\n <slot name=\"item-1\"></slot>\n </span>\n <span aria-hidden=\"true\" class=\"mg-input__toggle-item-container\">\n <slot name=\"item-2\"></slot>\n </span>\n </button>\n </MgInput>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mg-input-toggle.js","sourceRoot":"","sources":["../../../../../src/components/molecules/inputs/mg-input-toggle/mg-input-toggle.tsx"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,uDAAuD;AACvD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAgB,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGlF;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAW,EAAE,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC;AAOhJ,MAAM,OAAO,aAAa;;IACxB;;kBAEc;IAEd,UAAU;IACF,kBAAa,GAAG,6BAA6B,CAAC;IAC9C,kBAAa,GAAG,6BAA6B,CAAC;IAC9C,kBAAa,GAAG,8BAA8B,CAAC;IAC/C,eAAU,GAAG,2BAA2B,CAAC;IACzC,cAAS,GAAG,yBAAyB,CAAC;IA0J9C;;OAEG;IACK,kBAAa,GAAG,GAAS,EAAE;MACjC,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/B,CAAC,CAAC;IAEF;;OAEG;IACK,kBAAa,GAAG,GAAS,EAAE;MACjC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC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mCAAmC;UAChE,YAAM,IAAI,EAAC,QAAQ,GAAQ,CACtB;QACP,2BAAkB,MAAM,EAAC,KAAK,EAAC,mCAAmC;UAChE,YAAM,IAAI,EAAC,QAAQ,GAAQ,CACtB,CACA,CACD,CACX,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Component, Event, h, Prop, EventEmitter, State, Watch, Element } from '@stencil/core';\nimport { MgInput } from '../MgInput';\nimport { ClassList, allItemsAreString } from '../../../../utils/components.utils';\nimport { ToggleValue } from './mg-input-toggle.conf';\n\n/**\n * type Option validation function\n * @param option - radio option\n * @returns toggle option type is valid\n */\nconst isOption = (option: ToggleValue): boolean => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;\n\n@Component({\n tag: 'mg-input-toggle',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-input-toggle.css',\n shadow: true,\n})\nexport class MgInputToggle {\n /************\n * Internal *\n ************/\n\n // Classes\n private classReadonly = 'mg-c-input--toggle-readonly';\n private classDisabled = 'mg-c-input--toggle-disabled';\n private classIsActive = 'mg-c-input--toggle-is-active';\n private classOnOff = 'mg-c-input--toggle-on-off';\n private classIcon = 'mg-c-input--toggle-icon';\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgInputToggleElement;\n\n /**\n * Component value\n */\n @Prop({ mutable: true }) value: any;\n @Watch('value')\n handleValue(newValue: any): void {\n // Swich to the right option\n this.setChecked();\n // Emit value-change event\n this.valueChange.emit(newValue);\n }\n\n /**\n * Items are the possible options to select\n */\n @Prop() items!: string[] | ToggleValue[];\n @Watch('items')\n validateItems(newValue: string[] | ToggleValue[]): void {\n if (typeof newValue === 'object' && this.items.length !== 2) {\n throw new Error('<mg-input-toggle> prop \"items\" require 2 items.');\n }\n // String array\n else if (allItemsAreString(newValue as string[])) {\n this.options = (newValue as string[]).map(item => ({ title: item, value: item }));\n }\n // Object array\n else if (newValue && (newValue as ToggleValue[]).every(item => isOption(item))) {\n this.options = newValue as ToggleValue[];\n } else {\n throw new Error('<mg-input-toggle> prop \"items\" is required and all items must be the same type: ToggleValue.');\n }\n }\n\n /**\n * Identifier is used for the element ID (id is a reserved prop in Stencil.js)\n */\n @Prop() identifier!: string;\n\n /**\n * Input name\n * If not set the value equals the identifier\n */\n @Prop() name: string = this.identifier;\n\n /**\n * Input label\n */\n @Prop() label!: string;\n\n /**\n * Define if label is displayed on top\n */\n @Prop() labelOnTop: boolean;\n\n /**\n * Define if label is visible\n */\n @Prop() labelHide = false;\n\n /**\n * Define if toggle have on/off style\n */\n @Prop() isOnOff = false;\n @Watch('isOnOff')\n handleIsOnOff(newValue: boolean): void {\n if (newValue) this.classCollection.add(this.classOnOff);\n else this.classCollection.delete(this.classOnOff);\n }\n\n /**\n * Define if toggle display icon\n */\n @Prop() isIcon = false;\n @Watch('isIcon')\n handleIsIcon(newValue: boolean): void {\n if (newValue) this.classCollection.add(this.classIcon);\n else this.classCollection.delete(this.classIcon);\n }\n\n /**\n * Define if input is readonly\n */\n @Prop() readonly = false;\n @Watch('readonly')\n handleReadonly(newValue: boolean): void {\n if (newValue) this.classCollection.add(this.classReadonly);\n else this.classCollection.delete(this.classReadonly);\n }\n\n /**\n * Define if input is disabled\n */\n @Prop() disabled = false;\n @Watch('disabled')\n handleDisabled(newValue: boolean): void {\n if (newValue) this.classCollection.add(this.classDisabled);\n else this.classCollection.delete(this.classDisabled);\n }\n\n /**\n * Add a tooltip message next to the input\n */\n @Prop() tooltip: string;\n\n /**\n * Add a help text under the input, usually expected data format and example\n */\n @Prop() helpText: string;\n\n /**\n * Component classes\n */\n @State() classCollection: ClassList = new ClassList(['mg-c-input--toggle']);\n\n /**\n * Formated items for display\n */\n @State() options: ToggleValue[];\n\n /**\n * Checked internal value\n */\n @State() checked = false;\n @Watch('checked')\n handleChecked(newValue: boolean): void {\n // style\n if (newValue) this.classCollection.add(this.classIsActive);\n else this.classCollection.delete(this.classIsActive);\n\n // update value\n this.value = this.options[newValue ? 1 : 0].value;\n }\n\n /**\n * Emited event when value change\n */\n @Event({ eventName: 'value-change' }) valueChange: EventEmitter<any>;\n\n /**\n * Emited event when checking validity\n */\n @Event({ eventName: 'input-valid' }) inputValid: EventEmitter<boolean>;\n\n /**\n * Change checked value\n */\n private toggleChecked = (): void => {\n this.checked = !this.checked;\n };\n\n /**\n * Slots validation\n */\n private validateSlots = (): void => {\n const slots = Array.from(this.element.children);\n if (slots.length !== 2) {\n throw new Error('<mg-input-toggle> 2 slots are required.');\n } else if (!this.isIcon) {\n // Due to text-overflow set to ellipsis\n // we need to ensure that slot element have title to display value on mouse over\n slots.forEach(slot => slot.setAttribute('title', slot.textContent));\n }\n };\n\n /**\n * set checked state\n */\n private setChecked(): void {\n const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);\n\n if ([0, 1].includes(optionTrueValueIndex)) {\n // has \"value\" props type is not a boolean, it is bind/render as an attributes/props\n // true props will be represent by \"true\" string so we convert it has boolean\n // true attribute will be represent by \"\" string so we convert it has boolean\n // https://stenciljs.com/docs/properties\n if (['', 'true'].includes(this.value as string) && this.options.find(option => option.value) !== undefined) {\n this.value = true;\n }\n\n // when options are boolean values and ordered as [true,false] instead [false,true]\n // we need to reversed the checked value logic\n const selectedValue = this.value === this.options[optionTrueValueIndex].value;\n this.checked = optionTrueValueIndex === 0 ? !selectedValue : selectedValue;\n } else {\n this.checked = this.value === this.options[1].value;\n }\n }\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Check items format\n this.validateItems(this.items);\n // Check slots\n this.validateSlots();\n // init checked value\n this.setChecked();\n // apply handler\n this.handleIsOnOff(this.isOnOff);\n this.handleIsIcon(this.isIcon);\n this.handleReadonly(this.readonly);\n this.handleDisabled(this.disabled);\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <MgInput\n identifier={this.identifier}\n classCollection={this.classCollection}\n ariaDescribedbyIDs={[]}\n label={this.label}\n labelOnTop={this.labelOnTop}\n labelHide={this.labelHide}\n required={undefined}\n readonly={undefined}\n mgWidth={undefined}\n disabled={this.disabled}\n value={this.value as string}\n readonlyValue={undefined}\n tooltip={!this.readonly && this.tooltip}\n helpText={this.helpText}\n errorMessage={undefined}\n isFieldset={false}\n >\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={this.checked.toString()}\n aria-readonly={this.disabled || this.readonly}\n id={this.identifier}\n class=\"mg-c-input__button-toggle\"\n disabled={this.disabled || this.readonly}\n onClick={this.toggleChecked}\n >\n <span aria-hidden=\"true\" class=\"mg-c-input__toggle-item-container\">\n <slot name=\"item-1\"></slot>\n </span>\n <span aria-hidden=\"true\" class=\"mg-c-input__toggle-item-container\">\n <slot name=\"item-2\"></slot>\n </span>\n </button>\n </MgInput>\n );\n }\n}\n"]}
|
package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js
CHANGED
|
@@ -188,8 +188,8 @@ describe('mg-input-toggle', () => {
|
|
|
188
188
|
])('Should trigger events for items with inputValue: %s', async ({ items, expected, value }) => {
|
|
189
189
|
const args = { label: 'label', items, identifier: 'identifier', helpText: 'My help text', value };
|
|
190
190
|
const page = await getPage(args, defaultSlots);
|
|
191
|
-
const
|
|
192
|
-
const button =
|
|
191
|
+
const mgInputToggle = page.doc.querySelector('mg-input-toggle');
|
|
192
|
+
const button = mgInputToggle.shadowRoot.querySelector('button');
|
|
193
193
|
jest.spyOn(page.rootInstance.valueChange, 'emit');
|
|
194
194
|
button.dispatchEvent(new CustomEvent('focus', { bubbles: true }));
|
|
195
195
|
await page.waitForChanges();
|
package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-input-toggle.spec.js","sourceRoot":"","sources":["../../../../../../src/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAE3D,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,KAAM,EAAE,EAAE,CAC/B,WAAW,CAAC;EACV,UAAU,EAAE,CAAC,aAAa,EAAE,MAAM,CAAC;EACnC,QAAQ,EAAE,GAAG,EAAE,CAAC,uCAAqB,IAAI,GAAG,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAmB;CAClG,CAAC,CAAC;AAEL,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,CAAC,YAAM,IAAI,EAAC,QAAQ,aAAc,EAAE,GAAG,EAAE,CAAC,YAAM,IAAI,EAAC,QAAQ,YAAa,CAAC,CAAC;AACvG,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,CAAC,YAAM,IAAI,EAAC,QAAQ,UAAW,EAAE,GAAG,EAAE,CAAC,YAAM,IAAI,EAAC,QAAQ,UAAW,CAAC,CAAC;AAChG,MAAM,SAAS,GAAG;EAChB,GAAG,EA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C","sourcesContent":["import { h } from '@stencil/core';\nimport { newSpecPage } from '@stencil/core/testing';\nimport { MgInputToggle } from '../mg-input-toggle';\nimport { MgIcon } from '../../../../atoms/mg-icon/mg-icon';\n\nconst getPage = (args, slots?) =>\n newSpecPage({\n components: [MgInputToggle, MgIcon],\n template: () => <mg-input-toggle {...args}>{slots && slots.map(slot => slot())}</mg-input-toggle>,\n });\n\nconst defaultSlots = [() => <span slot=\"item-1\">Batman</span>, () => <span slot=\"item-2\">Joker</span>];\nconst onOffSlots = [() => <span slot=\"item-1\">Non</span>, () => <span slot=\"item-2\">Oui</span>];\nconst iconSlots = [\n () => (\n <span slot=\"item-1\">\n <mg-icon icon=\"cross\"></mg-icon>\n </span>\n ),\n () => (\n <span slot=\"item-2\">\n <mg-icon icon=\"check\"></mg-icon>\n </span>\n ),\n];\n\nconst defaultProps = {\n label: 'label',\n identifier: 'identifier',\n items: [\n { title: 'batman', value: false },\n { title: 'joker', value: true },\n ],\n};\n\ndescribe('mg-input-toggle', () => {\n describe.each([\n {\n props: {\n ...defaultProps,\n },\n slots: defaultSlots,\n },\n {\n props: {\n ...defaultProps,\n value: '',\n },\n slots: defaultSlots,\n },\n {\n props: {\n ...defaultProps,\n value: true,\n },\n slots: defaultSlots,\n },\n {\n props: {\n ...defaultProps,\n value: 'true',\n },\n slots: defaultSlots,\n },\n {\n props: {\n ...defaultProps,\n isOnOff: false,\n },\n slots: onOffSlots,\n },\n {\n props: {\n ...defaultProps,\n isIcon: true,\n isOnOff: true,\n },\n slots: iconSlots,\n },\n ])('template', ({ props, slots }) => {\n test.each([\n {\n ...props,\n },\n {\n ...props,\n labelOnTop: true,\n },\n {\n ...props,\n labelHide: true,\n },\n {\n ...props,\n readonly: true,\n },\n {\n ...props,\n disabled: true,\n },\n {\n ...props,\n helpText: 'Hello joker',\n },\n {\n ...props,\n tooltip: 'My Tooltip Message',\n },\n {\n ...props,\n tooltip: 'My Tooltip Message',\n labelOnTop: true,\n },\n ])('Should render with args %s:', async args => {\n const { root } = await getPage(args, slots);\n expect(root).toMatchSnapshot();\n });\n });\n\n describe('errors', () => {\n test.each(['', ' ', undefined])('Should not render with invalid identifier property: %s', async identifier => {\n expect.assertions(1);\n try {\n await getPage(\n {\n identifier,\n label: 'label',\n items: [\n { title: 'batman', value: false },\n { title: 'joker', value: true },\n ],\n },\n defaultSlots,\n );\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"identifier\" is required.');\n }\n });\n\n test.each(['', ' ', undefined])('Should throw error with invalid label property: %s', async label => {\n expect.assertions(1);\n try {\n await getPage(\n {\n identifier: 'identifier',\n label,\n items: [\n { title: 'batman', value: false },\n { title: 'joker', value: true },\n ],\n },\n defaultSlots,\n );\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"label\" is required.');\n }\n });\n\n test('Should throw an error with labelOnTop & labelHide set to true', async () => {\n expect.assertions(1);\n try {\n await getPage({ identifier: 'identifier', label: 'batman', labelOnTop: true, labelHide: true, items: ['batman', 'joker'] }, defaultSlots);\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"labelOnTop\" must not be paired with the prop \"labelHide\"');\n }\n });\n\n test('Should throw an error with less than 2 items, case %s', async () => {\n expect.assertions(1);\n try {\n await getPage({ label: 'batman', items: [{ title: 'batman' }] }, defaultSlots);\n } catch (err) {\n expect(err.message).toMatch('<mg-input-toggle> prop \"items\" require 2 items.');\n }\n });\n\n test.each([undefined, [defaultSlots[0]], [...defaultSlots, ...defaultSlots]])('Should throw an error with blank slots', async () => {\n expect.assertions(1);\n try {\n await getPage({ label: 'batman', items: ['batman', 'joker'] });\n } catch (err) {\n expect(err.message).toMatch('<mg-input-toggle> 2 slots are required.');\n }\n });\n\n test.each([\n [['batman', { title: 'batman', value: 'batman' }]],\n [['batman', { batman: 'batman' }]],\n [[true, false]],\n [[1, 2]],\n [[true, 'batman']],\n [[{ title: 'batman', value: 'batman' }, { batman: 'batman' }]],\n [\n [\n { title: 'batman', value: undefined },\n { title: 'batman', value: 'test' },\n ],\n ],\n ])('Should throw error with invalid items property: %s', async items => {\n expect.assertions(1);\n try {\n await getPage({ label: 'Label', items }, defaultSlots);\n } catch (err) {\n expect(err.message).toMatch('<mg-input-toggle> prop \"items\" is required and all items must be the same type: ToggleValue.');\n }\n });\n });\n\n test.each([\n {\n items: [\n { title: 'batman', value: 'a' },\n { title: 'joker', value: 'b' },\n ],\n expected: 'b',\n value: undefined,\n },\n {\n items: [\n { title: 'batman', value: 'a' },\n { title: 'joker', value: 'b' },\n ],\n expected: 'a',\n value: 'b',\n },\n {\n items: [\n { title: 'batman', value: 1 },\n { title: 'joker', value: 2 },\n ],\n expected: 2,\n value: 1,\n },\n {\n items: [\n { title: 'batman', value: false },\n { title: 'robin', value: true },\n ],\n expected: false,\n value: true,\n },\n {\n items: [\n { title: 'batman', value: true },\n { title: 'robin', value: false },\n ],\n expected: true,\n value: false,\n },\n ])('Should trigger events for items with inputValue: %s', async ({ items, expected, value }) => {\n const args = { label: 'label', items, identifier: 'identifier', helpText: 'My help text', value };\n const page = await getPage(args, defaultSlots);\n\n const mgInputToogle = page.doc.querySelector('mg-input-toggle');\n const button = mgInputToogle.shadowRoot.querySelector('button');\n\n jest.spyOn(page.rootInstance.valueChange, 'emit');\n\n button.dispatchEvent(new CustomEvent('focus', { bubbles: true }));\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot(); //Snapshot on focus\n\n button.dispatchEvent(new CustomEvent('click', { bubbles: true }));\n await page.waitForChanges();\n\n expect(page.rootInstance.valueChange.emit).toHaveBeenCalledWith(expected);\n expect(page.rootInstance.valueChange.emit).toHaveBeenCalledTimes(1);\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"mg-input-toggle.spec.js","sourceRoot":"","sources":["../../../../../../src/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,uB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C,CAAC;IAEhE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAElD,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAClE,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAE5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,mBAAmB;IAExD,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAClE,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAE5B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC1E,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;EACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { h } from '@stencil/core';\nimport { newSpecPage } from '@stencil/core/testing';\nimport { MgInputToggle } from '../mg-input-toggle';\nimport { MgIcon } from '../../../../atoms/mg-icon/mg-icon';\n\nconst getPage = (args, slots?) =>\n newSpecPage({\n components: [MgInputToggle, MgIcon],\n template: () => <mg-input-toggle {...args}>{slots && slots.map(slot => slot())}</mg-input-toggle>,\n });\n\nconst defaultSlots = [() => <span slot=\"item-1\">Batman</span>, () => <span slot=\"item-2\">Joker</span>];\nconst onOffSlots = [() => <span slot=\"item-1\">Non</span>, () => <span slot=\"item-2\">Oui</span>];\nconst iconSlots = [\n () => (\n <span slot=\"item-1\">\n <mg-icon icon=\"cross\"></mg-icon>\n </span>\n ),\n () => (\n <span slot=\"item-2\">\n <mg-icon icon=\"check\"></mg-icon>\n </span>\n ),\n];\n\nconst defaultProps = {\n label: 'label',\n identifier: 'identifier',\n items: [\n { title: 'batman', value: false },\n { title: 'joker', value: true },\n ],\n};\n\ndescribe('mg-input-toggle', () => {\n describe.each([\n {\n props: {\n ...defaultProps,\n },\n slots: defaultSlots,\n },\n {\n props: {\n ...defaultProps,\n value: '',\n },\n slots: defaultSlots,\n },\n {\n props: {\n ...defaultProps,\n value: true,\n },\n slots: defaultSlots,\n },\n {\n props: {\n ...defaultProps,\n value: 'true',\n },\n slots: defaultSlots,\n },\n {\n props: {\n ...defaultProps,\n isOnOff: false,\n },\n slots: onOffSlots,\n },\n {\n props: {\n ...defaultProps,\n isIcon: true,\n isOnOff: true,\n },\n slots: iconSlots,\n },\n ])('template', ({ props, slots }) => {\n test.each([\n {\n ...props,\n },\n {\n ...props,\n labelOnTop: true,\n },\n {\n ...props,\n labelHide: true,\n },\n {\n ...props,\n readonly: true,\n },\n {\n ...props,\n disabled: true,\n },\n {\n ...props,\n helpText: 'Hello joker',\n },\n {\n ...props,\n tooltip: 'My Tooltip Message',\n },\n {\n ...props,\n tooltip: 'My Tooltip Message',\n labelOnTop: true,\n },\n ])('Should render with args %s:', async args => {\n const { root } = await getPage(args, slots);\n expect(root).toMatchSnapshot();\n });\n });\n\n describe('errors', () => {\n test.each(['', ' ', undefined])('Should not render with invalid identifier property: %s', async identifier => {\n expect.assertions(1);\n try {\n await getPage(\n {\n identifier,\n label: 'label',\n items: [\n { title: 'batman', value: false },\n { title: 'joker', value: true },\n ],\n },\n defaultSlots,\n );\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"identifier\" is required.');\n }\n });\n\n test.each(['', ' ', undefined])('Should throw error with invalid label property: %s', async label => {\n expect.assertions(1);\n try {\n await getPage(\n {\n identifier: 'identifier',\n label,\n items: [\n { title: 'batman', value: false },\n { title: 'joker', value: true },\n ],\n },\n defaultSlots,\n );\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"label\" is required.');\n }\n });\n\n test('Should throw an error with labelOnTop & labelHide set to true', async () => {\n expect.assertions(1);\n try {\n await getPage({ identifier: 'identifier', label: 'batman', labelOnTop: true, labelHide: true, items: ['batman', 'joker'] }, defaultSlots);\n } catch (err) {\n expect(err.message).toMatch('<mg-input> prop \"labelOnTop\" must not be paired with the prop \"labelHide\"');\n }\n });\n\n test('Should throw an error with less than 2 items, case %s', async () => {\n expect.assertions(1);\n try {\n await getPage({ label: 'batman', items: [{ title: 'batman' }] }, defaultSlots);\n } catch (err) {\n expect(err.message).toMatch('<mg-input-toggle> prop \"items\" require 2 items.');\n }\n });\n\n test.each([undefined, [defaultSlots[0]], [...defaultSlots, ...defaultSlots]])('Should throw an error with blank slots', async () => {\n expect.assertions(1);\n try {\n await getPage({ label: 'batman', items: ['batman', 'joker'] });\n } catch (err) {\n expect(err.message).toMatch('<mg-input-toggle> 2 slots are required.');\n }\n });\n\n test.each([\n [['batman', { title: 'batman', value: 'batman' }]],\n [['batman', { batman: 'batman' }]],\n [[true, false]],\n [[1, 2]],\n [[true, 'batman']],\n [[{ title: 'batman', value: 'batman' }, { batman: 'batman' }]],\n [\n [\n { title: 'batman', value: undefined },\n { title: 'batman', value: 'test' },\n ],\n ],\n ])('Should throw error with invalid items property: %s', async items => {\n expect.assertions(1);\n try {\n await getPage({ label: 'Label', items }, defaultSlots);\n } catch (err) {\n expect(err.message).toMatch('<mg-input-toggle> prop \"items\" is required and all items must be the same type: ToggleValue.');\n }\n });\n });\n\n test.each([\n {\n items: [\n { title: 'batman', value: 'a' },\n { title: 'joker', value: 'b' },\n ],\n expected: 'b',\n value: undefined,\n },\n {\n items: [\n { title: 'batman', value: 'a' },\n { title: 'joker', value: 'b' },\n ],\n expected: 'a',\n value: 'b',\n },\n {\n items: [\n { title: 'batman', value: 1 },\n { title: 'joker', value: 2 },\n ],\n expected: 2,\n value: 1,\n },\n {\n items: [\n { title: 'batman', value: false },\n { title: 'robin', value: true },\n ],\n expected: false,\n value: true,\n },\n {\n items: [\n { title: 'batman', value: true },\n { title: 'robin', value: false },\n ],\n expected: true,\n value: false,\n },\n ])('Should trigger events for items with inputValue: %s', async ({ items, expected, value }) => {\n const args = { label: 'label', items, identifier: 'identifier', helpText: 'My help text', value };\n const page = await getPage(args, defaultSlots);\n\n const mgInputToggle = page.doc.querySelector('mg-input-toggle');\n const button = mgInputToggle.shadowRoot.querySelector('button');\n\n jest.spyOn(page.rootInstance.valueChange, 'emit');\n\n button.dispatchEvent(new CustomEvent('focus', { bubbles: true }));\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot(); //Snapshot on focus\n\n button.dispatchEvent(new CustomEvent('click', { bubbles: true }));\n await page.waitForChanges();\n\n expect(page.rootInstance.valueChange.emit).toHaveBeenCalledWith(expected);\n expect(page.rootInstance.valueChange.emit).toHaveBeenCalledTimes(1);\n });\n});\n"]}
|
|
@@ -159,12 +159,12 @@ export class MgMenu {
|
|
|
159
159
|
static get encapsulation() { return "shadow"; }
|
|
160
160
|
static get originalStyleUrls() {
|
|
161
161
|
return {
|
|
162
|
-
"$": ["mg-menu.
|
|
162
|
+
"$": ["../../../../../node_modules/@mgdis/styles/dist/components/mg-menu.css"]
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
static get styleUrls() {
|
|
166
166
|
return {
|
|
167
|
-
"$": ["mg-menu.css"]
|
|
167
|
+
"$": ["../../../../../node_modules/@mgdis/styles/dist/components/mg-menu.css"]
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
static get properties() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mg-menu.js","sourceRoot":"","sources":["../../../../../src/components/molecules/menu/mg-menu/mg-menu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,gBAAgB,CA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BAAa,IAAI,CAAC,KAAK;MACtC,eAAa,CACR,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Element, Watch, Host } from '@stencil/core';\nimport { Direction, sizes } from './mg-menu.conf';\nimport type { MenuSizeType, ItemMoreType } from './mg-menu.conf';\n\n@Component({\n tag: 'mg-menu',\n styleUrl: 'mg-menu.scss',\n shadow: true,\n})\nexport class MgMenu {\n /************\n * Internal *\n ************/\n\n private readonly name = 'mg-menu';\n private menuItems: HTMLMgMenuItemElement[] = [];\n private focusedMenuItem = 0;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgMenuElement;\n\n /**\n * Menu label. Include short menu description.\n * Required for accessibility\n */\n @Prop() label!: string;\n @Watch('label')\n validateLabel(newValue: MgMenu['label']): void {\n if (newValue === undefined) {\n throw new Error(`<${this.name}> prop \"label\" is required.`);\n }\n }\n\n /**\n * Component display direction.\n */\n @Prop({ reflect: true }) direction: Direction = Direction.HORIZONTAL;\n @Watch('direction')\n validateDirection(newValue: MgMenu['direction']): void {\n if (![Direction.VERTICAL, Direction.HORIZONTAL].includes(newValue)) {\n throw new Error(`<${this.name}> prop \"direction\" must be one of: ${Direction.HORIZONTAL}, ${Direction.VERTICAL}.`);\n }\n }\n\n /**\n * Customize \"mg-item-more\" element\n * Used with direction: 'vertical' to manage overflow\n */\n @Prop() itemmore: ItemMoreType;\n @Watch('itemmore')\n validateItemMore(newValue: MgMenu['itemmore']): void {\n if (newValue !== undefined && this.direction !== Direction.HORIZONTAL) {\n throw new Error(`<${this.name}> prop \"itemmore\" must be paired with direction ${Direction.HORIZONTAL}.`);\n }\n }\n\n /**\n * Define mg-menu size\n */\n @Prop() size: MenuSizeType = 'regular';\n @Watch('size')\n validateSize(newValue: MgMenu['size']): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<${this.name}> prop \"size\" must be one of: ${sizes.join(', ')}.`);\n }\n }\n\n /**\n * is this menu a child menu. Used for conditional render.\n */\n @State() isChildMenu: boolean;\n\n /*************\n * Methods *\n *************/\n\n /**\n * Close matching menu-item\n * @param item - menu-item to close\n * @param condition - addionnal condition\n */\n private closeMenuItem = (item: HTMLMgMenuItemElement, condition: boolean): void => {\n if (!this.isChildMenu && condition) {\n item.expanded = false;\n }\n };\n\n /**\n * get mg-item-more element\n * @returns mg-item-more element\n */\n private getItemMore = (): HTMLMgItemMoreElement => this.element.querySelector('mg-item-more');\n\n /**\n * get mg-item-more child mg-menu-item element\n * @returns mg-menu-item element\n */\n private getItemMoreMenuItem = (): HTMLMgMenuItemElement => this.getItemMore()?.shadowRoot?.querySelector('mg-menu-item');\n\n /**\n * Set item listend\n * @param item - mg-menu-item element\n * @param index - number\n */\n private setItemListener = (item: HTMLMgMenuItemElement, index: MgMenu['focusedMenuItem']): void => {\n ['click', 'focus'].forEach(trigger => {\n (item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, () => {\n this.focusedMenuItem = index;\n // reset expanded on previous active menu item\n (Boolean(this.getItemMoreMenuItem()) ? [...this.menuItems, this.getItemMoreMenuItem()] : this.menuItems).forEach((item, index) => {\n this.closeMenuItem(item, index !== this.focusedMenuItem);\n });\n });\n });\n };\n\n /**\n * Store menu-items on component init and add listeners\n */\n private initMenuItemsListeners = (): void => {\n // add listeners on menu item and edit index\n this.menuItems.forEach((item, index) => {\n this.setItemListener(item, index);\n });\n };\n\n /**\n * Handle item-loaded event on mg-item-more element\n */\n private handleItemLoaded = (): void => {\n this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);\n };\n\n /**\n * render mg-item-more\n */\n private renderMgItemMore = (): void => {\n // /!\\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement\n // by doing this we prevent stencil to generate a circular dependencies graph at build time with mg-item-more component.\n const item = 'mg-item-more';\n const mgItemMore = document.createElement(item);\n Object.assign(mgItemMore, this.itemmore);\n mgItemMore.addEventListener('item-loaded', this.handleItemLoaded);\n this.element.appendChild(mgItemMore);\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Validate props\n */\n componentWillLoad(): void {\n this.validateDirection(this.direction);\n this.validateLabel(this.label);\n this.validateItemMore(this.itemmore);\n this.validateSize(this.size);\n }\n\n /**\n * Check if component slots configuration\n * @returns timeout\n */\n componentDidLoad(): ReturnType<typeof setTimeout> {\n // update props and states after componentDidLoad hook\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n // store all menu-items\n this.menuItems = Array.from(this.element.children).filter(child => child.nodeName === 'MG-MENU-ITEM') as HTMLMgMenuItemElement[];\n this.isChildMenu = this.element.closest('mg-menu-item') !== null;\n\n // add mg-item-more to manage OverflowBehavior\n if (this.direction === Direction.HORIZONTAL && !this.isChildMenu) this.renderMgItemMore();\n\n // use mutation observer to improve reactivity\n new MutationObserver(entries => {\n const mgItemMore = this.getItemMore();\n // prevent infinit loop by exclude mg-item-more deletion entry\n if (entries.some(entry => entry.type === 'childList' && Array.from(entry.removedNodes).some(node => node.nodeName === 'MG-ITEM-MORE'))) return;\n else if (mgItemMore !== null) {\n // render a new mg-item-more\n mgItemMore.remove();\n mgItemMore.removeEventListener('item-loaded', this.handleItemLoaded);\n this.renderMgItemMore();\n }\n }).observe(this.element, { childList: true, characterData: true, subtree: true });\n }, 0);\n }\n\n /**\n * Add listeners to items\n */\n componentDidRender(): void {\n this.initMenuItemsListeners();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"list\" aria-label={this.label}>\n <slot></slot>\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mg-menu.js","sourceRoot":"","sources":["../../../../../src/components/molecules/menu/mg-menu/mg-menu.tsx"],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AC,EAAE,CAAC,CAAC,CAAC;EACR,CAAC;EAED;;KAEG;EACH,kBAAkB;IAChB,IAAI,CAAC,sBAAsB,EAAE,CAAC;EAChC,CAAC;EAED;;;KAGG;EACH,MAAM;IACJ,OAAO,CACL,EAAC,IAAI,IAAC,IAAI,EAAC,MAAM,gBAAa,IAAI,CAAC,KAAK;MACtC,eAAa,CACR,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Element, Watch, Host } from '@stencil/core';\nimport { Direction, sizes } from './mg-menu.conf';\nimport type { MenuSizeType, ItemMoreType } from './mg-menu.conf';\n\n@Component({\n tag: 'mg-menu',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-menu.css',\n shadow: true,\n})\nexport class MgMenu {\n /************\n * Internal *\n ************/\n\n private readonly name = 'mg-menu';\n private menuItems: HTMLMgMenuItemElement[] = [];\n private focusedMenuItem = 0;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgMenuElement;\n\n /**\n * Menu label. Include short menu description.\n * Required for accessibility\n */\n @Prop() label!: string;\n @Watch('label')\n validateLabel(newValue: MgMenu['label']): void {\n if (newValue === undefined) {\n throw new Error(`<${this.name}> prop \"label\" is required.`);\n }\n }\n\n /**\n * Component display direction.\n */\n @Prop({ reflect: true }) direction: Direction = Direction.HORIZONTAL;\n @Watch('direction')\n validateDirection(newValue: MgMenu['direction']): void {\n if (![Direction.VERTICAL, Direction.HORIZONTAL].includes(newValue)) {\n throw new Error(`<${this.name}> prop \"direction\" must be one of: ${Direction.HORIZONTAL}, ${Direction.VERTICAL}.`);\n }\n }\n\n /**\n * Customize \"mg-item-more\" element\n * Used with direction: 'vertical' to manage overflow\n */\n @Prop() itemmore: ItemMoreType;\n @Watch('itemmore')\n validateItemMore(newValue: MgMenu['itemmore']): void {\n if (newValue !== undefined && this.direction !== Direction.HORIZONTAL) {\n throw new Error(`<${this.name}> prop \"itemmore\" must be paired with direction ${Direction.HORIZONTAL}.`);\n }\n }\n\n /**\n * Define mg-menu size\n */\n @Prop() size: MenuSizeType = 'regular';\n @Watch('size')\n validateSize(newValue: MgMenu['size']): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<${this.name}> prop \"size\" must be one of: ${sizes.join(', ')}.`);\n }\n }\n\n /**\n * is this menu a child menu. Used for conditional render.\n */\n @State() isChildMenu: boolean;\n\n /*************\n * Methods *\n *************/\n\n /**\n * Close matching menu-item\n * @param item - menu-item to close\n * @param condition - addionnal condition\n */\n private closeMenuItem = (item: HTMLMgMenuItemElement, condition: boolean): void => {\n if (!this.isChildMenu && condition) {\n item.expanded = false;\n }\n };\n\n /**\n * get mg-item-more element\n * @returns mg-item-more element\n */\n private getItemMore = (): HTMLMgItemMoreElement => this.element.querySelector('mg-item-more');\n\n /**\n * get mg-item-more child mg-menu-item element\n * @returns mg-menu-item element\n */\n private getItemMoreMenuItem = (): HTMLMgMenuItemElement => this.getItemMore()?.shadowRoot?.querySelector('mg-menu-item');\n\n /**\n * Set item listend\n * @param item - mg-menu-item element\n * @param index - number\n */\n private setItemListener = (item: HTMLMgMenuItemElement, index: MgMenu['focusedMenuItem']): void => {\n ['click', 'focus'].forEach(trigger => {\n (item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, () => {\n this.focusedMenuItem = index;\n // reset expanded on previous active menu item\n (Boolean(this.getItemMoreMenuItem()) ? [...this.menuItems, this.getItemMoreMenuItem()] : this.menuItems).forEach((item, index) => {\n this.closeMenuItem(item, index !== this.focusedMenuItem);\n });\n });\n });\n };\n\n /**\n * Store menu-items on component init and add listeners\n */\n private initMenuItemsListeners = (): void => {\n // add listeners on menu item and edit index\n this.menuItems.forEach((item, index) => {\n this.setItemListener(item, index);\n });\n };\n\n /**\n * Handle item-loaded event on mg-item-more element\n */\n private handleItemLoaded = (): void => {\n this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);\n };\n\n /**\n * render mg-item-more\n */\n private renderMgItemMore = (): void => {\n // /!\\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement\n // by doing this we prevent stencil to generate a circular dependencies graph at build time with mg-item-more component.\n const item = 'mg-item-more';\n const mgItemMore = document.createElement(item);\n Object.assign(mgItemMore, this.itemmore);\n mgItemMore.addEventListener('item-loaded', this.handleItemLoaded);\n this.element.appendChild(mgItemMore);\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Validate props\n */\n componentWillLoad(): void {\n this.validateDirection(this.direction);\n this.validateLabel(this.label);\n this.validateItemMore(this.itemmore);\n this.validateSize(this.size);\n }\n\n /**\n * Check if component slots configuration\n * @returns timeout\n */\n componentDidLoad(): ReturnType<typeof setTimeout> {\n // update props and states after componentDidLoad hook\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n // store all menu-items\n this.menuItems = Array.from(this.element.children).filter(child => child.nodeName === 'MG-MENU-ITEM') as HTMLMgMenuItemElement[];\n this.isChildMenu = this.element.closest('mg-menu-item') !== null;\n\n // add mg-item-more to manage OverflowBehavior\n if (this.direction === Direction.HORIZONTAL && !this.isChildMenu) this.renderMgItemMore();\n\n // use mutation observer to improve reactivity\n new MutationObserver(entries => {\n const mgItemMore = this.getItemMore();\n // prevent infinit loop by exclude mg-item-more deletion entry\n if (entries.some(entry => entry.type === 'childList' && Array.from(entry.removedNodes).some(node => node.nodeName === 'MG-ITEM-MORE'))) return;\n else if (mgItemMore !== null) {\n // render a new mg-item-more\n mgItemMore.remove();\n mgItemMore.removeEventListener('item-loaded', this.handleItemLoaded);\n this.renderMgItemMore();\n }\n }).observe(this.element, { childList: true, characterData: true, subtree: true });\n }, 0);\n }\n\n /**\n * Add listeners to items\n */\n componentDidRender(): void {\n this.initMenuItemsListeners();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"list\" aria-label={this.label}>\n <slot></slot>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
|
-
import { ClassList, createID } from "../../../../utils/components.utils";
|
|
2
|
+
import { ClassList, createID, isValidString } from "../../../../utils/components.utils";
|
|
3
3
|
import { initLocales } from "../../../../locales";
|
|
4
4
|
import { Direction } from "../mg-menu/mg-menu.conf";
|
|
5
5
|
import { Status } from "./mg-menu-item.conf";
|
|
@@ -9,7 +9,7 @@ export class MgMenuItem {
|
|
|
9
9
|
* Internal *
|
|
10
10
|
************/
|
|
11
11
|
this.name = 'mg-menu-item';
|
|
12
|
-
this.navigationButton =
|
|
12
|
+
this.navigationButton = 'mg-c-menu-item__navigation-button';
|
|
13
13
|
/***********
|
|
14
14
|
* Methods *
|
|
15
15
|
**********/
|
|
@@ -62,7 +62,7 @@ export class MgMenuItem {
|
|
|
62
62
|
throw new Error(`<${this.name}> slot "label" is required.`);
|
|
63
63
|
['label', 'metadata'].forEach(slot => {
|
|
64
64
|
Array.from(this.element.querySelectorAll(`[slot="${slot}"]`)).forEach(element => {
|
|
65
|
-
if (element.textContent
|
|
65
|
+
if (!isValidString(element.textContent))
|
|
66
66
|
throw new Error(`<${this.name}> slot "${slot}" must have text content.`);
|
|
67
67
|
if ((guard && element.getAttribute('title') === null) || !guard)
|
|
68
68
|
element.setAttribute('title', element.textContent);
|
|
@@ -264,10 +264,9 @@ export class MgMenuItem {
|
|
|
264
264
|
*/
|
|
265
265
|
renderInteractiveElement() {
|
|
266
266
|
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
267
|
-
return (h(TagName, { href: this.href, class: this.navigationButtonClassList.join(), tabindex: [Status.DISABLED, Status.HIDDEN].includes(this.status) ? -1 : undefined, disabled: this.status === Status.DISABLED, hidden: this.status === Status.HIDDEN, "aria-expanded": this.hasChildren && this.expanded.toString(), "aria-current": this.status === Status.ACTIVE && 'page', onClick: this.handleElementCLick }, h("slot", { name: "image" }), h("div", { class: `${this.navigationButton}-center` }, h("div", { class: `${this.navigationButton}-text-content` }, h("slot", { name: "label" }), !this.displayNotificationBadge && h("slot", { name: "information" }), this.displayNotificationBadge && (h("span", { class:
|
|
267
|
+
return (h(TagName, { href: this.href, class: this.navigationButtonClassList.join(), tabindex: [Status.DISABLED, Status.HIDDEN].includes(this.status) ? -1 : undefined, disabled: this.status === Status.DISABLED, hidden: this.status === Status.HIDDEN, "aria-expanded": this.hasChildren && this.expanded.toString(), "aria-current": this.status === Status.ACTIVE && 'page', onClick: this.handleElementCLick }, h("slot", { name: "image" }), h("div", { class: `${this.navigationButton}-center` }, h("div", { class: `${this.navigationButton}-text-content` }, h("slot", { name: "label" }), !this.displayNotificationBadge && h("slot", { name: "information" }), this.displayNotificationBadge && (h("span", { class: `${this.navigationButton}-text-content-notification` }, h("mg-badge", { label: this.badgeLabel, value: "!", variant: "text-color", slot: "information" })))), this.size !== 'regular' && h("slot", { name: "metadata" })), this.hasChildren && this.href === undefined && (h("span", { class: {
|
|
268
268
|
[`${this.navigationButton}-chevron`]: true,
|
|
269
269
|
[`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
|
|
270
|
-
'mg-a11y-animation': true,
|
|
271
270
|
} }, h("mg-icon", { icon: "chevron-down", size: "small" })))));
|
|
272
271
|
}
|
|
273
272
|
/**
|
|
@@ -276,8 +275,8 @@ export class MgMenuItem {
|
|
|
276
275
|
*/
|
|
277
276
|
render() {
|
|
278
277
|
const getContainerClasses = () => ({
|
|
279
|
-
[
|
|
280
|
-
[
|
|
278
|
+
['mg-c-menu-item__collapse-container']: true,
|
|
279
|
+
['mg-c-menu-item__collapse-container--first-level']: (this.isInMainMenu || this.isItemMore) && this.isDirection(Direction.HORIZONTAL),
|
|
281
280
|
});
|
|
282
281
|
return (h(Host, { role: this.isItemMore ? 'presentation' : 'listitem' }, this.displayPopover() ? (h("mg-popover", { display: this.expanded, placement: "bottom-start", arrowHide: true, "onDisplay-change": this.handlePopoverDisplay, identifier: this.getPopoverIdentifier() }, this.renderInteractiveElement(), h("div", { class: getContainerClasses(), slot: "content" }, this.renderSlot()))) : ([
|
|
283
282
|
this.renderInteractiveElement(),
|
|
@@ -288,12 +287,12 @@ export class MgMenuItem {
|
|
|
288
287
|
static get encapsulation() { return "shadow"; }
|
|
289
288
|
static get originalStyleUrls() {
|
|
290
289
|
return {
|
|
291
|
-
"$": ["mg-menu-item.
|
|
290
|
+
"$": ["../../../../../node_modules/@mgdis/styles/dist/components/mg-menu-item.css"]
|
|
292
291
|
};
|
|
293
292
|
}
|
|
294
293
|
static get styleUrls() {
|
|
295
294
|
return {
|
|
296
|
-
"$": ["mg-menu-item.css"]
|
|
295
|
+
"$": ["../../../../../node_modules/@mgdis/styles/dist/components/mg-menu-item.css"]
|
|
297
296
|
};
|
|
298
297
|
}
|
|
299
298
|
static get properties() {
|