@mgdis/mg-components 5.26.0 → 5.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-c585c382.js → index-4b43c17b.js} +97 -81
- package/dist/cjs/index-4b43c17b.js.map +1 -0
- package/dist/cjs/{index-0a2783ee.js → index-83102ab3.js} +23 -10
- package/dist/cjs/index-83102ab3.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{mg-action-more_34.cjs.entry.js → mg-action-more_36.cjs.entry.js} +995 -742
- package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -0
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-components.cjs.js.map +1 -1
- package/dist/cjs/mg-loader.cjs.entry.js +3 -3
- package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
- package/dist/collection/assets/icons/index.js +1 -206
- package/dist/collection/assets/icons/index.js.map +1 -1
- package/dist/collection/collection-manifest.json +4 -3
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +2 -2
- package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +9 -6
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.js +5 -2
- 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 +2 -2
- 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 +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js.map +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +13 -8
- package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +6 -3
- 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 +6 -3
- package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +4 -1
- 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.conf.js +1 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +13 -3
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +21 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +515 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +1 -5
- 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 +7 -7
- 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 +67 -45
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +71 -22
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +52 -19
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +54 -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-radio/mg-input-radio.js +40 -8
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +44 -13
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +72 -24
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +47 -15
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +34 -21
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +26 -24
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +4 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +76 -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.conf.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +41 -41
- 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 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -4
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +8 -3
- 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.conf.js.map +1 -1
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +20 -13
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +3 -3
- package/dist/collection/components/molecules/mg-loader/mg-loader.js.map +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +7 -3
- package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +6 -2
- package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +4 -4
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +8 -4
- package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +4 -1
- 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 +6 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +4 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
- package/dist/collection/locales/en/messages.json +10 -3
- package/dist/collection/locales/fr/messages.json +10 -3
- package/dist/collection/locales/index.conf.js +2 -0
- package/dist/collection/locales/index.conf.js.map +1 -0
- package/dist/collection/utils/playwright.fixture.js +1 -1
- package/dist/collection/utils/playwright.fixture.js.map +1 -1
- package/dist/components/index.es.js +24 -24
- package/dist/components/index.es.js.map +1 -1
- package/dist/components/index2.js +24 -8
- package/dist/components/index2.js.map +1 -1
- package/dist/components/mg-action-more.js +29 -25
- package/dist/components/mg-action-more.js.map +1 -1
- package/dist/components/mg-badge2.js +1 -1
- package/dist/components/mg-badge2.js.map +1 -1
- package/dist/components/mg-button2.js +1 -1
- package/dist/components/mg-button2.js.map +1 -1
- package/dist/components/mg-card2.js +2 -2
- 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 +1 -1
- package/dist/components/mg-details.js.map +1 -1
- package/dist/components/mg-divider.js +1 -1
- package/dist/components/mg-form.js +1 -1
- package/dist/components/mg-form.js.map +1 -1
- package/dist/components/mg-icon2.js +4 -416
- package/dist/components/mg-icon2.js.map +1 -1
- package/dist/components/mg-illustrated-message.js +3 -3
- package/dist/components/mg-illustrated-message.js.map +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +13 -11
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
- package/dist/components/mg-input-checkbox.js +71 -49
- package/dist/components/mg-input-checkbox.js.map +1 -1
- package/dist/components/mg-input-date.js +69 -20
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +42 -13
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-password.js +56 -12
- package/dist/components/mg-input-password.js.map +1 -1
- package/dist/components/mg-input-radio.js +41 -10
- package/dist/components/mg-input-radio.js.map +1 -1
- package/dist/components/mg-input-select2.js +42 -12
- package/dist/components/mg-input-select2.js.map +1 -1
- package/dist/components/mg-input-text2.js +56 -18
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-input-textarea.js +44 -13
- package/dist/components/mg-input-textarea.js.map +1 -1
- package/dist/components/mg-input-title2.js +1 -1
- package/dist/components/mg-input-title2.js.map +1 -1
- package/dist/components/mg-input-toggle.js +35 -22
- package/dist/components/mg-input-toggle.js.map +1 -1
- package/dist/components/mg-input.d.ts +11 -0
- package/dist/components/mg-input.js +8 -0
- package/dist/components/mg-input.js.map +1 -0
- package/dist/components/mg-input2.js +352 -0
- package/dist/components/mg-input2.js.map +1 -0
- package/dist/components/mg-item-more.js +1 -338
- package/dist/components/mg-item-more.js.map +1 -1
- package/dist/components/mg-item-more2.js +592 -0
- package/dist/components/mg-item-more2.js.map +1 -0
- package/dist/components/mg-loader.js +1 -1
- package/dist/components/mg-loader.js.map +1 -1
- package/dist/components/mg-menu-item2.js +47 -8
- package/dist/components/mg-menu-item2.js.map +1 -1
- package/dist/components/mg-menu.js +1 -1
- package/dist/components/mg-message.js +1 -1
- package/dist/components/mg-message.js.map +1 -1
- package/dist/components/mg-modal.js +3 -3
- package/dist/components/mg-modal.js.map +1 -1
- package/dist/components/mg-pagination2.js +12 -6
- package/dist/components/mg-pagination2.js.map +1 -1
- package/dist/components/mg-panel.js +15 -9
- package/dist/components/mg-panel.js.map +1 -1
- package/dist/components/mg-popover-content2.js +1 -1
- package/dist/components/mg-popover-content2.js.map +1 -1
- package/dist/components/mg-popover2.js +2 -2
- package/dist/components/mg-popover2.js.map +1 -1
- package/dist/components/mg-skip-links.js +1 -1
- package/dist/components/mg-tabs.js +1 -1
- package/dist/components/mg-tabs.js.map +1 -1
- package/dist/components/mg-tag.js +1 -1
- 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 +10 -3
- package/dist/components/mg-tooltip2.js.map +1 -1
- package/dist/esm/{index-bb17de92.js → index-c4ed16b2.js} +97 -81
- package/dist/esm/index-c4ed16b2.js.map +1 -0
- package/dist/esm/{index-ad78ece7.js → index-d43d1c5d.js} +23 -10
- package/dist/esm/index-d43d1c5d.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{mg-action-more_34.entry.js → mg-action-more_36.entry.js} +982 -731
- package/dist/esm/mg-action-more_36.entry.js.map +1 -0
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-components.js.map +1 -1
- package/dist/esm/mg-loader.entry.js +3 -3
- package/dist/esm/mg-loader.entry.js.map +1 -1
- package/dist/mg-components/locales/en/messages.json +10 -3
- package/dist/mg-components/locales/fr/messages.json +10 -3
- 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-350454b9.js +2 -0
- package/dist/mg-components/p-350454b9.js.map +1 -0
- package/dist/mg-components/p-9cdd1bc9.entry.js +2 -0
- package/dist/mg-components/p-9cdd1bc9.entry.js.map +1 -0
- package/dist/mg-components/p-cf0b0988.js +3 -0
- package/dist/mg-components/p-cf0b0988.js.map +1 -0
- package/dist/mg-components/{p-d80b844d.entry.js → p-d4084a15.entry.js} +2 -2
- package/dist/mg-components/{p-d80b844d.entry.js.map → p-d4084a15.entry.js.map} +1 -1
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +1 -1
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +8 -5
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +4 -1
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +5 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +3 -3
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +5 -2
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +5 -2
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.d.ts +3 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +2 -1
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +4 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +35 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +145 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.d.ts +5 -5
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +3 -5
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +13 -12
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +2 -1
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +19 -6
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +15 -9
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +16 -5
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +7 -3
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +7 -4
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +21 -12
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +12 -9
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +16 -12
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +4 -1
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +8 -0
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +25 -5
- package/dist/types/components/molecules/mg-action-more/mg-action-more.conf.d.ts +7 -16
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +9 -9
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -3
- package/dist/types/components/molecules/mg-item-more/mg-item-more.conf.d.ts +3 -12
- package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +4 -3
- package/dist/types/components/molecules/mg-loader/mg-loader.d.ts +2 -2
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +2 -2
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +2 -2
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +3 -3
- package/dist/types/components/molecules/mg-popover/mg-popover-content/mg-popover-content.d.ts +3 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +5 -1
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +3 -0
- package/dist/types/components.d.ts +208 -92
- package/dist/types/locales/index.conf.d.ts +4 -0
- package/ide/intellij/web-types.json +260 -96
- package/ide/vscode/html-custom-data.json +2596 -1222
- package/package.json +24 -28
- package/dist/cjs/index-0a2783ee.js.map +0 -1
- package/dist/cjs/index-c585c382.js.map +0 -1
- package/dist/cjs/mg-action-more_34.cjs.entry.js.map +0 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +0 -272
- package/dist/cjs/mg-item-more.cjs.entry.js.map +0 -1
- package/dist/cjs/mg-menu.conf-c291eee6.js +0 -18
- package/dist/cjs/mg-menu.conf-c291eee6.js.map +0 -1
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +0 -14
- package/dist/collection/components/molecules/inputs/MgInput.conf.js.map +0 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +0 -125
- package/dist/collection/components/molecules/inputs/MgInput.js.map +0 -1
- package/dist/collection/utils/playwright.e2e.test.utils.js +0 -100
- package/dist/collection/utils/playwright.e2e.test.utils.js.map +0 -1
- package/dist/components/MgInput.js +0 -155
- package/dist/components/MgInput.js.map +0 -1
- package/dist/components/mg-menu.conf.js +0 -16
- package/dist/components/mg-menu.conf.js.map +0 -1
- package/dist/components/mg-menu2.js +0 -202
- package/dist/components/mg-menu2.js.map +0 -1
- package/dist/esm/index-ad78ece7.js.map +0 -1
- package/dist/esm/index-bb17de92.js.map +0 -1
- package/dist/esm/mg-action-more_34.entry.js.map +0 -1
- package/dist/esm/mg-item-more.entry.js +0 -268
- package/dist/esm/mg-item-more.entry.js.map +0 -1
- package/dist/esm/mg-menu.conf-9609bcb2.js +0 -16
- package/dist/esm/mg-menu.conf-9609bcb2.js.map +0 -1
- package/dist/mg-components/p-2db8355d.entry.js +0 -2
- package/dist/mg-components/p-2db8355d.entry.js.map +0 -1
- package/dist/mg-components/p-95653110.entry.js +0 -2
- package/dist/mg-components/p-95653110.entry.js.map +0 -1
- package/dist/mg-components/p-bc62d75e.js +0 -3
- package/dist/mg-components/p-bc62d75e.js.map +0 -1
- package/dist/mg-components/p-d41aa78b.js +0 -2
- package/dist/mg-components/p-d41aa78b.js.map +0 -1
- package/dist/mg-components/p-fe935e54.js +0 -2
- package/dist/mg-components/p-fe935e54.js.map +0 -1
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +0 -46
- package/dist/types/components/molecules/inputs/MgInput.d.ts +0 -13
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-0a2783ee.js');
|
|
6
|
-
const index$1 = require('./index-c585c382.js');
|
|
7
|
-
const mgMenu_conf = require('./mg-menu.conf-c291eee6.js');
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* MgItemMore type guard
|
|
11
|
-
* @param element - element to control type
|
|
12
|
-
* @returns truthy if element is mg-item-more
|
|
13
|
-
*/
|
|
14
|
-
const isMgItemMore = (element) => element.nodeName === 'MG-ITEM-MORE';
|
|
15
|
-
var OverflowBehaviorElements;
|
|
16
|
-
(function (OverflowBehaviorElements) {
|
|
17
|
-
OverflowBehaviorElements["BASE_INDEX"] = "data-overflow-base-index";
|
|
18
|
-
OverflowBehaviorElements["PROXY_INDEX"] = "data-overflow-proxy-index";
|
|
19
|
-
})(OverflowBehaviorElements || (OverflowBehaviorElements = {}));
|
|
20
|
-
class OverflowBehavior {
|
|
21
|
-
constructor(element, render) {
|
|
22
|
-
this.element = element;
|
|
23
|
-
this.render = render;
|
|
24
|
-
/**********
|
|
25
|
-
* Public *
|
|
26
|
-
**********/
|
|
27
|
-
/**
|
|
28
|
-
* Disconnect ResizeObserver
|
|
29
|
-
*/
|
|
30
|
-
this.disconnect = () => {
|
|
31
|
-
this._resizeObserver.disconnect();
|
|
32
|
-
};
|
|
33
|
-
/************
|
|
34
|
-
* Internal *
|
|
35
|
-
************/
|
|
36
|
-
/**
|
|
37
|
-
* run overflow behavior
|
|
38
|
-
* @param width - width of the container. Optional.
|
|
39
|
-
*/
|
|
40
|
-
this.run = (width) => {
|
|
41
|
-
if (this._moreElement === undefined) {
|
|
42
|
-
// set moreElement
|
|
43
|
-
this._moreElement = this.render();
|
|
44
|
-
// set children
|
|
45
|
-
this._baseChildren = this.getInteractiveItems(this.element);
|
|
46
|
-
if (isMgItemMore(this._moreElement)) {
|
|
47
|
-
this._proxyChildren = this.getInteractiveItems(this._moreElement.shadowRoot.querySelector('mg-menu'));
|
|
48
|
-
}
|
|
49
|
-
// update children
|
|
50
|
-
this._baseChildren.forEach((child, index) => {
|
|
51
|
-
child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);
|
|
52
|
-
// set moreElement children
|
|
53
|
-
this._proxyChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
if (width !== undefined)
|
|
57
|
-
this.updateDisplayedItems(width);
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Get interactive children filtred by authorized nodeName ['MG-MENU-ITEM', 'MG-BUTTON']
|
|
61
|
-
* @param element - element to parse
|
|
62
|
-
* @returns children
|
|
63
|
-
*/
|
|
64
|
-
this.getInteractiveItems = (element) => { var _a; return (((_a = element.children) === null || _a === void 0 ? void 0 : _a.length) > 0 ? Array.from(element.children) : []).filter(element => ['MG-MENU-ITEM', 'MG-BUTTON'].includes(element.nodeName)); };
|
|
65
|
-
/**
|
|
66
|
-
* Update displayed items in container from a given available space
|
|
67
|
-
* @param availableWidth - available width in container to display child items
|
|
68
|
-
*/
|
|
69
|
-
this.updateDisplayedItems = (availableWidth) => {
|
|
70
|
-
this.restoreItems();
|
|
71
|
-
const acc = { accWidth: 0, previousItem: null };
|
|
72
|
-
[...this._baseChildren, this._moreElement].forEach((child) => {
|
|
73
|
-
acc.accWidth += child.offsetWidth;
|
|
74
|
-
const hasPreviuosItem = acc.previousItem !== null;
|
|
75
|
-
const isPreviousItemHidden = hasPreviuosItem && acc.previousItem.getAttribute('hidden') !== null;
|
|
76
|
-
// if previous item is hidden AND is NOT more element we hidde current
|
|
77
|
-
// OR if item has an overflow we hidde current
|
|
78
|
-
// OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item
|
|
79
|
-
// ELSE current is a display item
|
|
80
|
-
this.toggleItem(child, (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden));
|
|
81
|
-
// update previous item with current item
|
|
82
|
-
acc.previousItem = child;
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Utility method to know if item overflow partialy or totaly in the container
|
|
87
|
-
* @param cumulateWidth - previous sibling elements cumulate width + item width
|
|
88
|
-
* @param item - item HTML element
|
|
89
|
-
* @param availableWidth - container available width
|
|
90
|
-
* @returns truthy if element is overflow
|
|
91
|
-
*/
|
|
92
|
-
this.isOverflowElement = (cumulateWidth, item, availableWidth) => {
|
|
93
|
-
if (item.previousElementSibling === null || this.isMoreElement(item))
|
|
94
|
-
return false;
|
|
95
|
-
else if (!this.isMoreElement(item.nextElementSibling))
|
|
96
|
-
return cumulateWidth + this._moreElement.offsetWidth > availableWidth;
|
|
97
|
-
else
|
|
98
|
-
return cumulateWidth > availableWidth;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Utility method to know if a given element is the 'MORE' element
|
|
102
|
-
* @param element - element to match with 'MORE' element
|
|
103
|
-
* @returns truthy if element is the 'MORE' element
|
|
104
|
-
*/
|
|
105
|
-
this.isMoreElement = (element) => element.nodeName === 'MG-ITEM-MORE';
|
|
106
|
-
/**
|
|
107
|
-
* Toggle display item element
|
|
108
|
-
* @param item - item to control
|
|
109
|
-
* @param isHidden - is item hidden
|
|
110
|
-
*/
|
|
111
|
-
this.toggleItem = (item, isHidden) => {
|
|
112
|
-
const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));
|
|
113
|
-
if (this.isMoreElement(item))
|
|
114
|
-
this.toggleElement(this._moreElement, isHidden);
|
|
115
|
-
else if (mgActionMenuindex >= 0) {
|
|
116
|
-
this.toggleElement(item, isHidden);
|
|
117
|
-
this.toggleElement(this._proxyChildren[mgActionMenuindex], !isHidden);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Toggle element's hidde attribute
|
|
122
|
-
* @param element - element to toggle
|
|
123
|
-
* @param isHidden - element is hidden
|
|
124
|
-
*/
|
|
125
|
-
this.toggleElement = (element, isHidden) => {
|
|
126
|
-
if (isHidden)
|
|
127
|
-
element.setAttribute('hidden', '');
|
|
128
|
-
else
|
|
129
|
-
element.removeAttribute('hidden');
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Remove hidden attributes on all items
|
|
133
|
-
*/
|
|
134
|
-
this.restoreItems = () => {
|
|
135
|
-
[...this._baseChildren, this._moreElement].forEach(item => item.removeAttribute('hidden'));
|
|
136
|
-
};
|
|
137
|
-
if (this._resizeObserver === undefined) {
|
|
138
|
-
// add resize observer
|
|
139
|
-
this._resizeObserver = new ResizeObserver(entries => {
|
|
140
|
-
entries.forEach(entry => {
|
|
141
|
-
this.run(entry.contentRect.width);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
this._resizeObserver.observe(this.element);
|
|
145
|
-
}
|
|
146
|
-
this.run();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const mgItemMoreCss = ".mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}:host:not([hidden]){display:flex}";
|
|
151
|
-
const MgItemMoreStyle0 = mgItemMoreCss;
|
|
152
|
-
|
|
153
|
-
const MgItemMore = class {
|
|
154
|
-
constructor(hostRef) {
|
|
155
|
-
index.registerInstance(this, hostRef);
|
|
156
|
-
/************
|
|
157
|
-
* Internal *
|
|
158
|
-
************/
|
|
159
|
-
this.name = 'mg-item-more';
|
|
160
|
-
this.canRenderMgMenuItemOverflowElement = true;
|
|
161
|
-
/***********
|
|
162
|
-
* Methods *
|
|
163
|
-
***********/
|
|
164
|
-
/**
|
|
165
|
-
* render mg-item-more overflow element
|
|
166
|
-
* @returns mg-item-more element
|
|
167
|
-
*/
|
|
168
|
-
this.renderMgMenuItemOverflowElement = () => {
|
|
169
|
-
// create menu items proxy element from item clones
|
|
170
|
-
this.parentMenuItems.forEach((child) => {
|
|
171
|
-
this.moreElementMenuItem.querySelector('mg-menu').appendChild(child.cloneNode(true));
|
|
172
|
-
});
|
|
173
|
-
const allMenuItem = Array.from(this.parentMenu.querySelectorAll('mg-menu-item:not([data-overflow-more])'));
|
|
174
|
-
Array.from(this.moreElementMenuItem.querySelectorAll('mg-menu-item:not([data-overflow-more])')).forEach((proxy, index) => {
|
|
175
|
-
// manage click on proxy to mirror it on initial element
|
|
176
|
-
proxy.addEventListener('click', () => {
|
|
177
|
-
// be carefull to use element.click() method instead of dispatchEvent to ensure bubbles outside shadowDom
|
|
178
|
-
const navElement = allMenuItem[index].shadowRoot.querySelector('a, button');
|
|
179
|
-
if (navElement instanceof HTMLButtonElement || navElement instanceof HTMLAnchorElement)
|
|
180
|
-
navElement.click();
|
|
181
|
-
});
|
|
182
|
-
// add id suffix to prevent duplicate key. default html id is: '';
|
|
183
|
-
if (index$1.Be(proxy.id))
|
|
184
|
-
proxy.id = `${proxy.id}-proxy`;
|
|
185
|
-
// manage status change miror in proxy
|
|
186
|
-
allMenuItem[index].addEventListener('status-change', (event) => {
|
|
187
|
-
proxy.setAttribute('status', event.detail);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
return this.element;
|
|
191
|
-
};
|
|
192
|
-
this.icon = { icon: 'ellipsis-vertical' };
|
|
193
|
-
this.slotlabel = { display: false };
|
|
194
|
-
this.size = undefined;
|
|
195
|
-
this.parentMenu = undefined;
|
|
196
|
-
}
|
|
197
|
-
validateIcon(newValue) {
|
|
198
|
-
if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.icon !== 'string'))
|
|
199
|
-
throw new Error(`<${this.name}> prop "icon" must match MgItemMore['icon'] type.`);
|
|
200
|
-
}
|
|
201
|
-
validateSlotLabel(newValue) {
|
|
202
|
-
if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.display !== 'boolean'))
|
|
203
|
-
throw new Error(`<${this.name}> prop "slotlabel" must match MgItemMore['slotlabel'] type.`);
|
|
204
|
-
else if (typeof newValue.label !== 'string')
|
|
205
|
-
this.slotlabel.label = this.messages.moreLabel;
|
|
206
|
-
}
|
|
207
|
-
validateSize(newValue) {
|
|
208
|
-
if (newValue && typeof newValue !== 'string')
|
|
209
|
-
throw new Error(`<${this.name}> prop "size" must match MgItemMore['size'] type.`);
|
|
210
|
-
}
|
|
211
|
-
/*************
|
|
212
|
-
* Lifecycle *
|
|
213
|
-
*************/
|
|
214
|
-
/**
|
|
215
|
-
* Set variables and validate props
|
|
216
|
-
*/
|
|
217
|
-
componentWillLoad() {
|
|
218
|
-
// init variables
|
|
219
|
-
this.messages = index$1.initLocales(this.element).messages.plusMenu;
|
|
220
|
-
// validate props
|
|
221
|
-
this.validateIcon(this.icon);
|
|
222
|
-
this.validateSlotLabel(this.slotlabel);
|
|
223
|
-
this.validateSize(this.size);
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Ensure parent DOM is fully rendered with timeout method before parse elements
|
|
227
|
-
*/
|
|
228
|
-
componentDidLoad() {
|
|
229
|
-
// ensure parent menu is fully rendered
|
|
230
|
-
return setTimeout(() => {
|
|
231
|
-
this.parentMenu = this.element.closest('mg-menu');
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Set OverflowBehavior when parentMenu state is upate AND defined
|
|
236
|
-
*/
|
|
237
|
-
componentDidUpdate() {
|
|
238
|
-
if (this.parentMenu && this.canRenderMgMenuItemOverflowElement) {
|
|
239
|
-
this.parentMenuItems = Array.from(this.parentMenu.children).filter(item => item.nodeName === 'MG-MENU-ITEM');
|
|
240
|
-
this.overflowBehavior = new OverflowBehavior(this.parentMenu, this.renderMgMenuItemOverflowElement);
|
|
241
|
-
this.canRenderMgMenuItemOverflowElement = false;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Disconnect overflow ResizeObserver
|
|
246
|
-
*/
|
|
247
|
-
disconnectedCallback() {
|
|
248
|
-
var _a;
|
|
249
|
-
(_a = this.overflowBehavior) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Render
|
|
253
|
-
* @returns HTML Element
|
|
254
|
-
*/
|
|
255
|
-
render() {
|
|
256
|
-
return (index.h(index.Host, { key: '2dfe9d844f42403de5120e0db85f3617d9d580a8', role: "listitem" }, this.parentMenu && (index.h("mg-menu-item", { "data-overflow-more": true, "data-size": this.parentMenu.size, ref: el => {
|
|
257
|
-
if (el)
|
|
258
|
-
this.moreElementMenuItem = el;
|
|
259
|
-
} }, index.h("mg-icon", { icon: this.icon.icon, slot: "image" }), index.h("span", { class: { 'mg-u-visually-hidden': !this.slotlabel.display }, slot: "label" }, this.slotlabel.label), index.h("mg-menu", { direction: mgMenu_conf.Direction.VERTICAL, label: this.messages.moreLabel, size: this.size })))));
|
|
260
|
-
}
|
|
261
|
-
get element() { return index.getElement(this); }
|
|
262
|
-
static get watchers() { return {
|
|
263
|
-
"icon": ["validateIcon"],
|
|
264
|
-
"slotlabel": ["validateSlotLabel"],
|
|
265
|
-
"size": ["validateSize"]
|
|
266
|
-
}; }
|
|
267
|
-
};
|
|
268
|
-
MgItemMore.style = MgItemMoreStyle0;
|
|
269
|
-
|
|
270
|
-
exports.mg_item_more = MgItemMore;
|
|
271
|
-
|
|
272
|
-
//# sourceMappingURL=mg-item-more.cjs.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"mg-item-more.entry.cjs.js","mappings":";;;;;;;;AAAA;;;;;AAKA,MAAM,YAAY,GAAG,CAAC,OAAoB,KAAuC,OAAO,CAAC,QAAQ,KAAK,cAAc,CAAC;AAErH,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IAClC,mEAAuC,CAAA;IACvC,qEAAyC,CAAA;AAC3C,CAAC,EAHW,wBAAwB,KAAxB,wBAAwB,QAGnC;MAEY,gBAAgB;IAO3B,YACU,OAAgB,EAChB,MAAyB;QADzB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAmB;;;;;;;QAqB5B,eAAU,GAAG;YAClB,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;SACnC,CAAC;;;;;;;;QAUM,QAAG,GAAG,CAAC,KAAc;YAC3B,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;;gBAEnC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;;gBAGlC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAC5D,IAAI,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;oBACnC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;iBACvG;;gBAGD,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,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SACjD;KACF;;;;IAKD,oBAAoB;;QAClB,MAAA,IAAI,CAAC,gBAAgB,0CAAE,UAAU,EAAE,CAAC;KACrC;;;;;IAMD,MAAM;QACJ,QACEC,QAACC,UAAI,qDAAC,IAAI,EAAC,UAAU,IAClB,IAAI,CAAC,UAAU,KACdD,mEAEa,IAAI,CAAC,UAAU,CAAC,IAAI,EAC/B,GAAG,EAAE,EAAE;gBACL,IAAI,EAAE;oBAAE,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;aACvC,IAEDA,qBAAS,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAC,OAAO,GAAW,EACtDA,kBAAM,KAAK,EAAE,EAAE,sBAAsB,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,IAAI,EAAC,OAAO,IAC3E,IAAI,CAAC,SAAS,CAAC,KAAK,CAChB,EACPA,qBAAS,SAAS,EAAEE,qBAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,GAAY,CACtF,CAChB,CACI,EACP;KACH;;;;;;;;;;;;","names":["isValidString","initLocales","h","Host","Direction"],"sources":["src/utils/behaviors.utils.ts","../styles/dist/components/mg-item-more.css?tag=mg-item-more&encapsulation=shadow","src/components/molecules/mg-item-more/mg-item-more.tsx"],"sourcesContent":["/**\n * MgItemMore type guard\n * @param element - element to control type\n * @returns truthy if element is mg-item-more\n */\nconst isMgItemMore = (element: HTMLElement): element is HTMLMgItemMoreElement => element.nodeName === 'MG-ITEM-MORE';\n\nexport enum OverflowBehaviorElements {\n BASE_INDEX = 'data-overflow-base-index',\n PROXY_INDEX = 'data-overflow-proxy-index',\n}\n\nexport class OverflowBehavior {\n // variables\n private _resizeObserver: ResizeObserver;\n private _moreElement: HTMLElement;\n private _baseChildren: Element[];\n private _proxyChildren: Element[];\n\n constructor(\n private element: Element,\n private render: () => HTMLElement,\n ) {\n if (this._resizeObserver === undefined) {\n // add resize observer\n this._resizeObserver = new ResizeObserver(entries => {\n entries.forEach(entry => {\n this.run(entry.contentRect.width);\n });\n });\n this._resizeObserver.observe(this.element);\n }\n this.run();\n }\n\n /**********\n * Public *\n **********/\n\n /**\n * Disconnect ResizeObserver\n */\n public disconnect = (): void => {\n this._resizeObserver.disconnect();\n };\n\n /************\n * Internal *\n ************/\n\n /**\n * run overflow behavior\n * @param width - width of the container. Optional.\n */\n private run = (width?: number): void => {\n if (this._moreElement === undefined) {\n // set moreElement\n this._moreElement = this.render();\n\n // set children\n this._baseChildren = this.getInteractiveItems(this.element);\n if (isMgItemMore(this._moreElement)) {\n this._proxyChildren = this.getInteractiveItems(this._moreElement.shadowRoot.querySelector('mg-menu'));\n }\n\n // update children\n this._baseChildren.forEach((child, index) => {\n child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);\n // set moreElement children\n this._proxyChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);\n });\n }\n\n if (width !== undefined) this.updateDisplayedItems(width);\n };\n\n /**\n * Get interactive children filtred by authorized nodeName ['MG-MENU-ITEM', 'MG-BUTTON']\n * @param element - element to parse\n * @returns children\n */\n private getInteractiveItems = (element: Element) =>\n (element.children?.length > 0 ? Array.from(element.children) : []).filter(element => ['MG-MENU-ITEM', 'MG-BUTTON'].includes(element.nodeName));\n\n /**\n * Update displayed items in container from a given available space\n * @param availableWidth - available width in container to display child items\n */\n private updateDisplayedItems = (availableWidth: number): void => {\n this.restoreItems();\n const acc = { accWidth: 0, previousItem: null };\n [...this._baseChildren, this._moreElement].forEach((child: HTMLMgMenuItemElement | HTMLMgItemMoreElement) => {\n acc.accWidth += child.offsetWidth;\n const hasPreviuosItem = acc.previousItem !== null;\n const isPreviousItemHidden = hasPreviuosItem && acc.previousItem.getAttribute('hidden') !== null;\n // if previous item is hidden AND is NOT more element we hidde current\n // OR if item has an overflow we hidde current\n // OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item\n // ELSE current is a display item\n this.toggleItem(\n child,\n (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden),\n );\n\n // update previous item with current item\n acc.previousItem = child;\n });\n };\n\n /**\n * Utility method to know if item overflow partialy or totaly in the container\n * @param cumulateWidth - previous sibling elements cumulate width + item width\n * @param item - item HTML element\n * @param availableWidth - container available width\n * @returns truthy if element is overflow\n */\n private isOverflowElement = (cumulateWidth: number, item: HTMLElement, availableWidth: number): boolean => {\n if (item.previousElementSibling === null || this.isMoreElement(item)) return false;\n else if (!this.isMoreElement(item.nextElementSibling)) return cumulateWidth + this._moreElement.offsetWidth > availableWidth;\n else return cumulateWidth > availableWidth;\n };\n\n /**\n * Utility method to know if a given element is the 'MORE' element\n * @param element - element to match with 'MORE' element\n * @returns truthy if element is the 'MORE' element\n */\n private isMoreElement = (element: Element): boolean => element.nodeName === 'MG-ITEM-MORE';\n\n /**\n * Toggle display item element\n * @param item - item to control\n * @param isHidden - is item hidden\n */\n private toggleItem = (item: HTMLElement, isHidden: boolean): void => {\n const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));\n if (this.isMoreElement(item)) this.toggleElement(this._moreElement, isHidden);\n else if (mgActionMenuindex >= 0) {\n this.toggleElement(item, isHidden);\n this.toggleElement(this._proxyChildren[mgActionMenuindex], !isHidden);\n }\n };\n\n /**\n * Toggle element's hidde attribute\n * @param element - element to toggle\n * @param isHidden - element is hidden\n */\n private toggleElement = (element: Element, isHidden: boolean): void => {\n if (isHidden) element.setAttribute('hidden', '');\n else element.removeAttribute('hidden');\n };\n\n /**\n * Remove hidden attributes on all items\n */\n private restoreItems = (): void => {\n [...this._baseChildren, this._moreElement].forEach(item => item.removeAttribute('hidden'));\n };\n}\n",".mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media(prefers-reduced-motion){*{animation:none !important;transition:none !important}}:host:not([hidden]){display:flex}/*# sourceMappingURL=mg-item-more.css.map */\n","import { Component, h, Prop, Element, Host, Watch, State } from '@stencil/core';\nimport { initLocales } from '../../../locales';\nimport { OverflowBehavior } from '../../../utils/behaviors.utils';\nimport { Direction } from '../menu/mg-menu/mg-menu.conf';\nimport type { IconType, MessageType, SizeType, SlotLabelType } from './mg-item-more.conf';\nimport { isValidString } from '@mgdis/stencil-helpers';\n\n@Component({\n tag: 'mg-item-more',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-item-more.css',\n shadow: true,\n})\nexport class MgItemMore {\n /************\n * Internal *\n ************/\n private readonly name = 'mg-item-more';\n private messages: MessageType;\n private parentMenuItems: HTMLMgMenuItemElement[];\n private moreElementMenuItem: HTMLMgMenuItemElement;\n private overflowBehavior: OverflowBehavior;\n private canRenderMgMenuItemOverflowElement = true;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgItemMoreElement;\n\n /**\n * Define icon\n */\n @Prop() icon: IconType = { icon: 'ellipsis-vertical' };\n @Watch('icon')\n validateIcon(newValue: MgItemMore['icon']): void {\n if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.icon !== 'string'))\n throw new Error(`<${this.name}> prop \"icon\" must match MgItemMore['icon'] type.`);\n }\n\n /**\n * Define slot label element\n */\n @Prop() slotlabel: SlotLabelType = { display: false };\n @Watch('slotlabel')\n validateSlotLabel(newValue: MgItemMore['slotlabel']): void {\n if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.display !== 'boolean'))\n throw new Error(`<${this.name}> prop \"slotlabel\" must match MgItemMore['slotlabel'] type.`);\n else if (typeof newValue.label !== 'string') this.slotlabel.label = this.messages.moreLabel;\n }\n\n /**\n * Define component child menu size.\n */\n @Prop() size: SizeType;\n @Watch('size')\n validateSize(newValue: MgItemMore['size']): void {\n if (newValue && typeof newValue !== 'string') throw new Error(`<${this.name}> prop \"size\" must match MgItemMore['size'] type.`);\n }\n\n /**\n * Define component parent menu.\n */\n @State() parentMenu: HTMLMgMenuElement;\n\n /***********\n * Methods *\n ***********/\n\n /**\n * render mg-item-more overflow element\n * @returns mg-item-more element\n */\n private renderMgMenuItemOverflowElement = (): HTMLMgItemMoreElement => {\n // create menu items proxy element from item clones\n this.parentMenuItems.forEach((child: HTMLMgMenuItemElement) => {\n this.moreElementMenuItem.querySelector('mg-menu').appendChild(child.cloneNode(true));\n });\n\n const allMenuItem = Array.from(this.parentMenu.querySelectorAll('mg-menu-item:not([data-overflow-more])'));\n\n Array.from(this.moreElementMenuItem.querySelectorAll('mg-menu-item:not([data-overflow-more])')).forEach((proxy, index) => {\n // manage click on proxy to mirror it on initial element\n proxy.addEventListener('click', () => {\n // be carefull to use element.click() method instead of dispatchEvent to ensure bubbles outside shadowDom\n const navElement = allMenuItem[index].shadowRoot.querySelector('a, button');\n if (navElement instanceof HTMLButtonElement || navElement instanceof HTMLAnchorElement) navElement.click();\n });\n\n // add id suffix to prevent duplicate key. default html id is: '';\n if (isValidString(proxy.id)) proxy.id = `${proxy.id}-proxy`;\n\n // manage status change miror in proxy\n allMenuItem[index].addEventListener('status-change', (event: CustomEvent) => {\n proxy.setAttribute('status', event.detail);\n });\n });\n\n return this.element;\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Set variables and validate props\n */\n componentWillLoad(): void {\n // init variables\n this.messages = (initLocales(this.element).messages as { plusMenu: MessageType }).plusMenu;\n\n // validate props\n this.validateIcon(this.icon);\n this.validateSlotLabel(this.slotlabel);\n this.validateSize(this.size);\n }\n\n /**\n * Ensure parent DOM is fully rendered with timeout method before parse elements\n */\n componentDidLoad(): ReturnType<typeof setTimeout> {\n // ensure parent menu is fully rendered\n return setTimeout(() => {\n this.parentMenu = this.element.closest('mg-menu');\n });\n }\n\n /**\n * Set OverflowBehavior when parentMenu state is upate AND defined\n */\n componentDidUpdate(): void {\n if (this.parentMenu && this.canRenderMgMenuItemOverflowElement) {\n this.parentMenuItems = Array.from(this.parentMenu.children).filter(item => item.nodeName === 'MG-MENU-ITEM') as HTMLMgMenuItemElement[];\n this.overflowBehavior = new OverflowBehavior(this.parentMenu, this.renderMgMenuItemOverflowElement);\n this.canRenderMgMenuItemOverflowElement = false;\n }\n }\n\n /**\n * Disconnect overflow ResizeObserver\n */\n disconnectedCallback(): void {\n this.overflowBehavior?.disconnect();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"listitem\">\n {this.parentMenu && (\n <mg-menu-item\n data-overflow-more\n data-size={this.parentMenu.size}\n ref={el => {\n if (el) this.moreElementMenuItem = el;\n }}\n >\n <mg-icon icon={this.icon.icon} slot=\"image\"></mg-icon>\n <span class={{ 'mg-u-visually-hidden': !this.slotlabel.display }} slot=\"label\">\n {this.slotlabel.label}\n </span>\n <mg-menu direction={Direction.VERTICAL} label={this.messages.moreLabel} size={this.size}></mg-menu>\n </mg-menu-item>\n )}\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Menu direction type
|
|
5
|
-
*/
|
|
6
|
-
exports.Direction = void 0;
|
|
7
|
-
(function (Direction) {
|
|
8
|
-
Direction["VERTICAL"] = "vertical";
|
|
9
|
-
Direction["HORIZONTAL"] = "horizontal";
|
|
10
|
-
})(exports.Direction || (exports.Direction = {}));
|
|
11
|
-
/**
|
|
12
|
-
* List of all possibles sizes
|
|
13
|
-
*/
|
|
14
|
-
const sizes = ['regular', 'medium', 'large'];
|
|
15
|
-
|
|
16
|
-
exports.sizes = sizes;
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=mg-menu.conf-c291eee6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"mg-menu.conf-c291eee6.js","mappings":";;AAEA;;;AAGYA;AAAZ,WAAY,SAAS;IACnB,kCAAqB,CAAA;IACrB,sCAAyB,CAAA;AAC3B,CAAC,EAHWA,iBAAS,KAATA,iBAAS,QAGpB;AAOD;;;MAGa,KAAK,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO;;;;","names":["Direction"],"sources":["src/components/molecules/menu/mg-menu/mg-menu.conf.ts"],"sourcesContent":["import { MgItemMore } from '../../mg-item-more/mg-item-more';\n\n/**\n * Menu direction type\n */\nexport enum Direction {\n VERTICAL = 'vertical',\n HORIZONTAL = 'horizontal',\n}\n\n/**\n * ItemMore prop type\n */\nexport type ItemMoreType = Pick<MgItemMore, 'icon' | 'slotlabel' | 'size'>;\n\n/**\n * List of all possibles sizes\n */\nexport const sizes = ['regular', 'medium', 'large'] as const;\n\n/**\n * item Size from sizes\n */\nexport type MenuSizeType = (typeof sizes)[number];\n"],"version":3}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Possible input width
|
|
3
|
-
*/
|
|
4
|
-
export const widths = [2, 4, 16, 'full'];
|
|
5
|
-
/**
|
|
6
|
-
* Available handlers
|
|
7
|
-
*/
|
|
8
|
-
export var Handler;
|
|
9
|
-
(function (Handler) {
|
|
10
|
-
Handler["BLUR"] = "blur";
|
|
11
|
-
Handler["FOCUS"] = "focus";
|
|
12
|
-
})(Handler || (Handler = {}));
|
|
13
|
-
export const tooltipPositions = ['input', 'label'];
|
|
14
|
-
//# sourceMappingURL=MgInput.conf.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MgInput.conf.js","sourceRoot":"","sources":["../../../../src/components/molecules/inputs/MgInput.conf.ts"],"names":[],"mappings":"AAgCA;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,CAAU,CAAC;AAkBlD;;GAEG;AACH,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,wBAAa,CAAA;IACb,0BAAe,CAAA;AACjB,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAU,CAAC","sourcesContent":["import type { MgInputTitle } from '../../atoms/mg-input-title/mg-input-title';\nimport type { ClassList } from '@mgdis/stencil-helpers';\n\n/**\n * MgInput component props\n */\nexport interface MgInputProps {\n // Global\n identifier: string;\n classCollection: ClassList;\n // Label\n label: string;\n labelOnTop: boolean;\n labelHide: boolean;\n isFieldset: MgInputTitle['isLegend'];\n // Input\n value: string;\n readonlyValue: string | string[];\n required: boolean;\n readonly: boolean;\n mgWidth: Width;\n disabled: boolean;\n // Tooltip\n tooltip: string;\n tooltipPosition: TooltipPosition;\n // Help Text\n helpText: string;\n // Error Message\n errorMessage: string;\n // ariaDescribedbyIDs\n ariaDescribedbyIDs: string[];\n}\n/**\n * Possible input width\n */\nexport const widths = [2, 4, 16, 'full'] as const;\n\nexport type Width = (typeof widths)[number];\n\n/**\n * Possible Input types\n */\nexport type HTMLMgInputsElement =\n | HTMLMgInputCheckboxElement\n | HTMLMgInputDateElement\n | HTMLMgInputNumericElement\n | HTMLMgInputPasswordElement\n | HTMLMgInputRadioElement\n | HTMLMgInputSelectElement\n | HTMLMgInputTextElement\n | HTMLMgInputTextareaElement\n | (HTMLMgInputToggleElement & { required: true; invalid: false; displayError: () => void });\n\n/**\n * Available handlers\n */\nexport enum Handler {\n BLUR = 'blur',\n FOCUS = 'focus',\n}\n\nexport const tooltipPositions = ['input', 'label'] as const;\n\nexport type TooltipPosition = (typeof tooltipPositions)[number];\n"]}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { h } from "@stencil/core";
|
|
2
|
-
import { widths, tooltipPositions } from "./MgInput.conf";
|
|
3
|
-
import { isValidString } from "@mgdis/stencil-helpers";
|
|
4
|
-
/**
|
|
5
|
-
* Apply in all input child node the aria-describedby attribute
|
|
6
|
-
* @param children - Represent scoped elements
|
|
7
|
-
* @param ariaDescribedbyIDs - List of IDs
|
|
8
|
-
* @param utils - Stencil.js utils
|
|
9
|
-
* @returns Children with aria-describedby attribute
|
|
10
|
-
*/
|
|
11
|
-
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
12
|
-
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
13
|
-
return Object.assign(Object.assign({}, child), { vattrs: Object.assign(Object.assign({}, child.vattrs), { 'aria-describedby': [...ariaDescribedbyIDs].join(' ') }) });
|
|
14
|
-
}
|
|
15
|
-
// we recursively apply ariadescribedBy attributes to child input nodes if exists
|
|
16
|
-
if (child.vchildren === null)
|
|
17
|
-
return Object.assign({}, child);
|
|
18
|
-
return Object.assign(Object.assign({}, child), { vchildren: applyAriadescribedBy(child.vchildren, ariaDescribedbyIDs, utils) });
|
|
19
|
-
});
|
|
20
|
-
/**
|
|
21
|
-
* Add classes based on props
|
|
22
|
-
* @param props - MgInput Interface Props
|
|
23
|
-
*/
|
|
24
|
-
const manageClasses = (props) => {
|
|
25
|
-
props.classCollection.add('mg-c-input');
|
|
26
|
-
if (props.labelOnTop)
|
|
27
|
-
props.classCollection.add('mg-c-input--label-on-top');
|
|
28
|
-
else
|
|
29
|
-
props.classCollection.delete('mg-c-input--label-on-top');
|
|
30
|
-
if (props.readonly)
|
|
31
|
-
props.classCollection.add('mg-c-input--readonly');
|
|
32
|
-
else
|
|
33
|
-
props.classCollection.delete('mg-c-input--readonly');
|
|
34
|
-
widths.forEach(width => {
|
|
35
|
-
props.classCollection.delete(`mg-c-input--width-${width}`);
|
|
36
|
-
});
|
|
37
|
-
if (props.mgWidth !== undefined)
|
|
38
|
-
props.classCollection.add(`mg-c-input--width-${props.mgWidth}`);
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Check props configuration
|
|
42
|
-
* @param props - MgInput Interface Props
|
|
43
|
-
*/
|
|
44
|
-
const checkPropsConfig = (props) => {
|
|
45
|
-
if (!isValidString(props.identifier)) {
|
|
46
|
-
throw new Error('<mg-input> prop "identifier" is required.');
|
|
47
|
-
}
|
|
48
|
-
if (!isValidString(props.label)) {
|
|
49
|
-
throw new Error('<mg-input> prop "label" is required.');
|
|
50
|
-
}
|
|
51
|
-
if (props.labelOnTop && props.labelHide) {
|
|
52
|
-
throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide".');
|
|
53
|
-
}
|
|
54
|
-
if (!tooltipPositions.includes(props.tooltipPosition)) {
|
|
55
|
-
throw new Error(`<mg-input> prop "tooltipPosition" must be one of: ${tooltipPositions.join(', ')}`);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Get tagname
|
|
60
|
-
* @param isFieldset - is fieldset
|
|
61
|
-
* @returns tag name
|
|
62
|
-
*/
|
|
63
|
-
const getTagName = (isFieldset, readOnly) => (!isFieldset || readOnly ? 'div' : 'fieldset');
|
|
64
|
-
/**
|
|
65
|
-
* MgInput Interface
|
|
66
|
-
*/
|
|
67
|
-
/**
|
|
68
|
-
* Get input template
|
|
69
|
-
* @param props - MgInput Interface Props
|
|
70
|
-
* @param children - Represent scoped elements
|
|
71
|
-
* @param utils - Stencil.js utils
|
|
72
|
-
* @returns input template
|
|
73
|
-
*/
|
|
74
|
-
export const MgInput = (props, children, utils) => {
|
|
75
|
-
/**
|
|
76
|
-
* Check props config
|
|
77
|
-
*/
|
|
78
|
-
checkPropsConfig(props);
|
|
79
|
-
/**
|
|
80
|
-
* Set readonly value
|
|
81
|
-
*/
|
|
82
|
-
if (props.readonlyValue === undefined)
|
|
83
|
-
props.readonlyValue = props.value;
|
|
84
|
-
/**
|
|
85
|
-
* Component classes
|
|
86
|
-
*/
|
|
87
|
-
manageClasses(props);
|
|
88
|
-
/**
|
|
89
|
-
* a11y IDs
|
|
90
|
-
*/
|
|
91
|
-
const ariaDescribedbyIDs = new Set(props.ariaDescribedbyIDs);
|
|
92
|
-
// Help text
|
|
93
|
-
const helpTextId = `${props.identifier}-help-text`;
|
|
94
|
-
if (typeof props.helpText === 'string' && props.helpText !== '') {
|
|
95
|
-
ariaDescribedbyIDs.add(helpTextId);
|
|
96
|
-
}
|
|
97
|
-
// Error Message
|
|
98
|
-
const helpTextErrorId = `${props.identifier}-error`;
|
|
99
|
-
if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {
|
|
100
|
-
ariaDescribedbyIDs.add(helpTextErrorId);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Return template
|
|
104
|
-
*
|
|
105
|
-
* +--------+---------+--------------+---------+
|
|
106
|
-
* | label | tooltip | input | tooltip |
|
|
107
|
-
* |--------+---------+--------------+---------+
|
|
108
|
-
* | | nb Char Left |
|
|
109
|
-
* | +------------------------+
|
|
110
|
-
* | | Help Text |
|
|
111
|
-
* | +------------------------+
|
|
112
|
-
* | | Error |
|
|
113
|
-
* +------------------+------------------------+
|
|
114
|
-
*
|
|
115
|
-
* Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change
|
|
116
|
-
*/
|
|
117
|
-
const TagName = getTagName(props.isFieldset, props.readonly);
|
|
118
|
-
/**
|
|
119
|
-
* Get tooltip node
|
|
120
|
-
* @returns mg-tooltip
|
|
121
|
-
*/
|
|
122
|
-
const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip }, h("mg-icon", { icon: "info-circle" })));
|
|
123
|
-
return (h(TagName, { class: props.classCollection.join() }, h("div", { class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': props.labelHide } }, h("mg-input-title", { identifier: props.identifier, readonly: props.readonly, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label), props.tooltip && !props.readonly && (props.tooltipPosition === 'label' || props.labelOnTop) && !props.labelHide && getTooltip()), props.readonly ? (h("div", { class: "mg-c-input__input-container" }, Array.isArray(props.readonlyValue) ? (h("ul", null, props.readonlyValue.map(value => (h("li", { key: value }, h("strong", null, value)))))) : (h("strong", null, props.readonlyValue)), children.filter(child => Object.values(child).includes('append-input')))) : (h("div", { class: "mg-c-input__input-container" }, h("div", { class: { 'mg-c-input__input': true, 'mg-c-input__input--has-error': props.errorMessage !== undefined } }, applyAriadescribedBy(children, ariaDescribedbyIDs, utils), props.tooltip && !props.readonly && !props.labelOnTop && (props.tooltipPosition === 'input' || props.labelHide) && getTooltip()), props.helpText && h("div", { id: helpTextId, class: "mg-c-input__help-text", innerHTML: props.helpText }), props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-c-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
|
|
124
|
-
};
|
|
125
|
-
//# sourceMappingURL=MgInput.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MgInput.js","sourceRoot":"","sources":["../../../../src/components/molecules/inputs/MgInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,CAAC,EAA8B,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAqB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,CAAC,QAAiB,EAAE,kBAA+B,EAAE,KAA0B,EAAW,EAAE,CACvH,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE;IAC1B,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAc,CAAC,EAAE,CAAC;QACnE,uCACK,KAAK,KACR,MAAM,kCACD,KAAK,CAAC,MAAM,KACf,kBAAkB,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAEvD;IACJ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\nimport { widths, tooltipPositions, type MgInputProps } from './MgInput.conf';\nimport { isValidString } from '@mgdis/stencil-helpers';\n\n/**\n * Apply in all input child node the aria-describedby attribute\n * @param children - Represent scoped elements\n * @param ariaDescribedbyIDs - List of IDs\n * @param utils - Stencil.js utils\n * @returns Children with aria-describedby attribute\n */\nconst applyAriadescribedBy = (children: VNode[], ariaDescribedbyIDs: Set<string>, utils: FunctionalUtilities): VNode[] =>\n utils.map(children, child => {\n if (['input', 'select', 'textarea'].includes(child.vtag as string)) {\n return {\n ...child,\n vattrs: {\n ...child.vattrs,\n 'aria-describedby': [...ariaDescribedbyIDs].join(' '),\n },\n };\n }\n\n // we recursively apply ariadescribedBy attributes to child input nodes if exists\n if (child.vchildren === null) return { ...child };\n return {\n ...child,\n vchildren: applyAriadescribedBy(child.vchildren, ariaDescribedbyIDs, utils),\n };\n });\n\n/**\n * Add classes based on props\n * @param props - MgInput Interface Props\n */\nconst manageClasses = (props: MgInputProps): void => {\n props.classCollection.add('mg-c-input');\n\n if (props.labelOnTop) props.classCollection.add('mg-c-input--label-on-top');\n else props.classCollection.delete('mg-c-input--label-on-top');\n\n if (props.readonly) props.classCollection.add('mg-c-input--readonly');\n else props.classCollection.delete('mg-c-input--readonly');\n\n widths.forEach(width => {\n props.classCollection.delete(`mg-c-input--width-${width}`);\n });\n if (props.mgWidth !== undefined) props.classCollection.add(`mg-c-input--width-${props.mgWidth}`);\n};\n\n/**\n * Check props configuration\n * @param props - MgInput Interface Props\n */\nconst checkPropsConfig = (props: MgInputProps): void => {\n if (!isValidString(props.identifier)) {\n throw new Error('<mg-input> prop \"identifier\" is required.');\n }\n if (!isValidString(props.label)) {\n throw new Error('<mg-input> prop \"label\" is required.');\n }\n if (props.labelOnTop && props.labelHide) {\n throw new Error('<mg-input> prop \"labelOnTop\" must not be paired with the prop \"labelHide\".');\n }\n if (!tooltipPositions.includes(props.tooltipPosition)) {\n throw new Error(`<mg-input> prop \"tooltipPosition\" must be one of: ${tooltipPositions.join(', ')}`);\n }\n};\n\n/**\n * Get tagname\n * @param isFieldset - is fieldset\n * @returns tag name\n */\nconst getTagName = (isFieldset: MgInputProps['isFieldset'], readOnly: MgInputProps['readonly']): string => (!isFieldset || readOnly ? 'div' : 'fieldset');\n\n/**\n * MgInput Interface\n */\n\n/**\n * Get input template\n * @param props - MgInput Interface Props\n * @param children - Represent scoped elements\n * @param utils - Stencil.js utils\n * @returns input template\n */\nexport const MgInput: FunctionalComponent<MgInputProps> = (props: MgInputProps, children: VNode[], utils: FunctionalUtilities): VNode[] => {\n /**\n * Check props config\n */\n checkPropsConfig(props);\n\n /**\n * Set readonly value\n */\n if (props.readonlyValue === undefined) props.readonlyValue = props.value;\n\n /**\n * Component classes\n */\n manageClasses(props);\n\n /**\n * a11y IDs\n */\n const ariaDescribedbyIDs: Set<string> = new Set(props.ariaDescribedbyIDs);\n\n // Help text\n const helpTextId = `${props.identifier}-help-text`;\n if (typeof props.helpText === 'string' && props.helpText !== '') {\n ariaDescribedbyIDs.add(helpTextId);\n }\n\n // Error Message\n const helpTextErrorId = `${props.identifier}-error`;\n if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {\n ariaDescribedbyIDs.add(helpTextErrorId);\n }\n\n /**\n * Return template\n *\n * +--------+---------+--------------+---------+\n * | label | tooltip | input | tooltip |\n * |--------+---------+--------------+---------+\n * | | nb Char Left |\n * | +------------------------+\n * | | Help Text |\n * | +------------------------+\n * | | Error |\n * +------------------+------------------------+\n *\n * Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change\n */\n\n const TagName = getTagName(props.isFieldset, props.readonly);\n\n /**\n * Get tooltip node\n * @returns mg-tooltip\n */\n const getTooltip = (): VNode[] => (\n <mg-tooltip identifier={`${props.identifier}-tooltip`} message={props.tooltip}>\n <mg-icon icon=\"info-circle\"></mg-icon>\n </mg-tooltip>\n );\n\n return (\n <TagName class={props.classCollection.join()}>\n <div class={{ 'mg-c-input__title': true, 'mg-u-visually-hidden': props.labelHide }}>\n <mg-input-title identifier={props.identifier} readonly={props.readonly} required={props.required && !props.disabled && !props.readonly} is-legend={props.isFieldset}>\n {props.label}\n </mg-input-title>\n {props.tooltip && !props.readonly && (props.tooltipPosition === 'label' || props.labelOnTop) && !props.labelHide && getTooltip()}\n </div>\n {props.readonly ? (\n <div class=\"mg-c-input__input-container\">\n {Array.isArray(props.readonlyValue) ? (\n <ul>\n {props.readonlyValue.map(value => (\n <li key={value}>\n <strong>{value}</strong>\n </li>\n ))}\n </ul>\n ) : (\n <strong>{props.readonlyValue}</strong>\n )}\n {children.filter(child => Object.values(child).includes('append-input'))}\n </div>\n ) : (\n <div class=\"mg-c-input__input-container\">\n <div class={{ 'mg-c-input__input': true, 'mg-c-input__input--has-error': props.errorMessage !== undefined }}>\n {applyAriadescribedBy(children, ariaDescribedbyIDs, utils)}\n {props.tooltip && !props.readonly && !props.labelOnTop && (props.tooltipPosition === 'input' || props.labelHide) && getTooltip()}\n </div>\n {props.helpText && <div id={helpTextId} class=\"mg-c-input__help-text\" innerHTML={props.helpText}></div>}\n {props.errorMessage && !props.readonly && !props.disabled && (\n <div id={helpTextErrorId} class=\"mg-c-input__error\" innerHTML={props.errorMessage} aria-live=\"assertive\"></div>\n )}\n </div>\n )}\n </TagName>\n );\n};\n"]}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { test as playwrightTest, expect as playwrightExpect, devices as playwrightDevices } from "@playwright/test";
|
|
3
|
-
import { readFile } from "fs/promises";
|
|
4
|
-
import { join } from "path";
|
|
5
|
-
/**
|
|
6
|
-
* Add mg-components to browser page
|
|
7
|
-
*
|
|
8
|
-
* @param page - browser page
|
|
9
|
-
* @param html - html to load in page
|
|
10
|
-
*/
|
|
11
|
-
export const setPageContent = async (page, html, viewportSize) => {
|
|
12
|
-
// We need to add mg-components to the e2e page
|
|
13
|
-
// Those solutions wasn't working to add the CSS
|
|
14
|
-
// await page.addStyleTag({ url: 'http://localhost:3333/build/mg-components.css' });
|
|
15
|
-
// CSS
|
|
16
|
-
const css = await readFile(join(__dirname, '../../www/build/mg-components.css'), { encoding: 'utf8' });
|
|
17
|
-
await page.addStyleTag({ content: css });
|
|
18
|
-
// JS
|
|
19
|
-
await page.addScriptTag({ url: 'http://localhost:3333/build/mg-components.esm.js', type: 'module' });
|
|
20
|
-
// Set page size before style setting to prevent "resize" event to be triggered
|
|
21
|
-
if (viewportSize !== undefined)
|
|
22
|
-
await page.setViewportSize(viewportSize);
|
|
23
|
-
// Set page content
|
|
24
|
-
// Added the `e2e-screenshot` class to be able to do the screenshot on this specific one with
|
|
25
|
-
// `await expect(page.locator('.e2e-screenshot')).toHaveScreenshot();`
|
|
26
|
-
await page.setContent(`<style>${css} .e2e-screenshot { display: inline-block; }</style><span class="e2e-screenshot">${html}</span>`);
|
|
27
|
-
// Make sure everything is loaded
|
|
28
|
-
await page.waitForLoadState('networkidle');
|
|
29
|
-
await page.waitForSelector('html.hydrated');
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* playwright 'expect' function definition
|
|
33
|
-
*/
|
|
34
|
-
export const expect = playwrightExpect;
|
|
35
|
-
/**
|
|
36
|
-
* playwright 'describe' function definition
|
|
37
|
-
*/
|
|
38
|
-
export const describe = playwrightTest.describe;
|
|
39
|
-
/**
|
|
40
|
-
* playwright 'test' function definition
|
|
41
|
-
*/
|
|
42
|
-
export const test = playwrightTest;
|
|
43
|
-
/**
|
|
44
|
-
* playwright 'devices' definition
|
|
45
|
-
*/
|
|
46
|
-
export const devices = playwrightDevices;
|
|
47
|
-
/**
|
|
48
|
-
* Value to get in string
|
|
49
|
-
* @param value - valut to stringify
|
|
50
|
-
* @returns stringified value
|
|
51
|
-
*/
|
|
52
|
-
const valueToString = (value) => (typeof value === 'object' ? JSON.stringify(value) : `${value}`);
|
|
53
|
-
/**
|
|
54
|
-
* repeat test over array
|
|
55
|
-
* @param array - array of test
|
|
56
|
-
* @param option - test runner option
|
|
57
|
-
* @returns describe iteration
|
|
58
|
-
*/
|
|
59
|
-
export const describeEach = (array, option) => (title, cb) => {
|
|
60
|
-
array.forEach(value => {
|
|
61
|
-
const displayTitle = title.replace('%s', valueToString(value));
|
|
62
|
-
const fn = () => cb(value);
|
|
63
|
-
if (Boolean(option))
|
|
64
|
-
describe[option](displayTitle, fn);
|
|
65
|
-
else
|
|
66
|
-
describe(displayTitle, fn);
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* repeat test over array
|
|
71
|
-
* @param array - array of test
|
|
72
|
-
* @param option - test runner option
|
|
73
|
-
* @returns test iteration
|
|
74
|
-
*/
|
|
75
|
-
export const testEach = (array, option) => (title, cb) => {
|
|
76
|
-
array.forEach(value => {
|
|
77
|
-
const displayTitle = title.replace('%s', valueToString(value));
|
|
78
|
-
const fn = async ({ page }) => cb(page, value);
|
|
79
|
-
if (Boolean(option))
|
|
80
|
-
test[option](displayTitle, fn);
|
|
81
|
-
else
|
|
82
|
-
test(displayTitle, fn);
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Update .e2e-screenshot style for screenshot needs
|
|
87
|
-
* @param page - playwright Page
|
|
88
|
-
* @param params - css properties to apply
|
|
89
|
-
* @returns class style definition
|
|
90
|
-
*/
|
|
91
|
-
export const updateScreenshotClass = async (page, params) => page.evaluate(params => {
|
|
92
|
-
const css = `.e2e-screenshot { ${Object.keys(params)
|
|
93
|
-
.map(key => `${key}: ${typeof params[key] === 'string' ? params[key] : ''}`)
|
|
94
|
-
.join(';')} }`;
|
|
95
|
-
const body = document.getElementsByTagName('body')[0];
|
|
96
|
-
const style = document.createElement('style');
|
|
97
|
-
body.appendChild(style);
|
|
98
|
-
style.appendChild(document.createTextNode(css));
|
|
99
|
-
}, params);
|
|
100
|
-
//# sourceMappingURL=playwright.e2e.test.utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"playwright.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AC/D,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/C,IAAI,OAAO,CAAC,MAAM,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;;YAC/C,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAU,EAAE,MAAe,EAAiB,EAAE,CACxF,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;IACrB,MAAM,GAAG,GAAG,qBAAqB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SACjD,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,KAAK,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;SAC3E,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IACjB,MAAM,IAAI,GAAG,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACxB,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC,EAAE,MAAM,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type Page, ViewportSize, test as playwrightTest, expect as playwrightExpect, devices as playwrightDevices } from '@playwright/test';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\n\n/**\n * Add mg-components to browser page\n *\n * @param page - browser page\n * @param html - html to load in page\n */\nexport const setPageContent = async (page: Page, html: string, viewportSize?: ViewportSize): Promise<void> => {\n // We need to add mg-components to the e2e page\n // Those solutions wasn't working to add the CSS\n // await page.addStyleTag({ url: 'http://localhost:3333/build/mg-components.css' });\n\n // CSS\n const css = await readFile(join(__dirname, '../../www/build/mg-components.css'), { encoding: 'utf8' });\n await page.addStyleTag({ content: css });\n\n // JS\n await page.addScriptTag({ url: 'http://localhost:3333/build/mg-components.esm.js', type: 'module' });\n\n // Set page size before style setting to prevent \"resize\" event to be triggered\n if (viewportSize !== undefined) await page.setViewportSize(viewportSize);\n\n // Set page content\n // Added the `e2e-screenshot` class to be able to do the screenshot on this specific one with\n // `await expect(page.locator('.e2e-screenshot')).toHaveScreenshot();`\n await page.setContent(`<style>${css} .e2e-screenshot { display: inline-block; }</style><span class=\"e2e-screenshot\">${html}</span>`);\n\n // Make sure everything is loaded\n await page.waitForLoadState('networkidle');\n await page.waitForSelector('html.hydrated');\n};\n\n/**\n * playwright 'expect' function definition\n */\nexport const expect = playwrightExpect;\n\n/**\n * playwright 'describe' function definition\n */\nexport const describe = playwrightTest.describe;\n\n/**\n * playwright 'test' function definition\n */\nexport const test = playwrightTest;\n\n/**\n * playwright 'devices' definition\n */\nexport const devices = playwrightDevices;\n\n/**\n * Value to get in string\n * @param value - valut to stringify\n * @returns stringified value\n */\nconst valueToString = (value: unknown): string => (typeof value === 'object' ? JSON.stringify(value) : `${value}`);\n\n/**\n * Declare page type\n */\nexport type PageType = Page;\n\n/**\n * repeat test over array\n * @param array - array of test\n * @param option - test runner option\n * @returns describe iteration\n */\nexport const describeEach = (array: unknown[] | any, option?: 'skip' | 'only') => (title: string, cb: (param: unknown) => void) => {\n array.forEach(value => {\n const displayTitle = title.replace('%s', valueToString(value));\n const fn = () => cb(value);\n if (Boolean(option)) describe[option](displayTitle, fn);\n else describe(displayTitle, fn);\n });\n};\n\n/**\n * repeat test over array\n * @param array - array of test\n * @param option - test runner option\n * @returns test iteration\n */\nexport const testEach = (array: unknown[] | any, option?: 'skip' | 'only') => (title: string, cb: (page: PageType, param: unknown) => Promise<void>) => {\n array.forEach(value => {\n const displayTitle = title.replace('%s', valueToString(value));\n const fn = async ({ page }) => cb(page, value);\n if (Boolean(option)) test[option](displayTitle, fn);\n else test(displayTitle, fn);\n });\n};\n\n/**\n * Update .e2e-screenshot style for screenshot needs\n * @param page - playwright Page\n * @param params - css properties to apply\n * @returns class style definition\n */\nexport const updateScreenshotClass = async (page: Page, params: unknown): Promise<void> =>\n page.evaluate(params => {\n const css = `.e2e-screenshot { ${Object.keys(params)\n .map(key => `${key}: ${typeof params[key] === 'string' ? params[key] : ''}`)\n .join(';')} }`;\n const body = document.getElementsByTagName('body')[0];\n const style = document.createElement('style');\n body.appendChild(style);\n style.appendChild(document.createTextNode(css));\n }, params);\n"]}
|