@mgdis/mg-components 6.2.0 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-52d5f3d4.js → index-911898e4.js} +410 -266
- package/dist/cjs/index-911898e4.js.map +1 -0
- package/dist/cjs/{index-cc11af95.js → index-a3269bfc.js} +3 -3
- package/dist/cjs/{index-cc11af95.js.map → index-a3269bfc.js.map} +1 -1
- package/dist/cjs/{index.es-ac7c22e3.js → index.es-325100d7.js} +47 -47
- package/dist/cjs/index.es-325100d7.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_36.cjs.entry.js +1414 -983
- package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-alert.cjs.entry.js +17 -12
- package/dist/cjs/mg-alert.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-components.cjs.js.map +1 -1
- package/dist/cjs/mg-loader.cjs.entry.js +6 -8
- package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-progress.cjs.entry.js +27 -12
- package/dist/cjs/mg-progress.cjs.entry.js.map +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js +10 -3
- package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js.map +1 -1
- package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js +15 -4
- package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js.map +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +15 -4
- package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +112 -12
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.js +1 -1
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +9 -1
- package/dist/collection/components/atoms/mg-divider/mg-divider.js.map +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +22 -6
- package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +14 -4
- package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +3 -4
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +28 -6
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +50 -13
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +29 -11
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +106 -33
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +99 -36
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +130 -35
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +87 -25
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +86 -26
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +92 -30
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +109 -32
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +109 -29
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +67 -21
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +16 -70
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +101 -89
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +194 -157
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +19 -8
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +31 -6
- package/dist/collection/components/molecules/mg-alert/mg-alert.js.map +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js +17 -5
- package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +48 -16
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +13 -3
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +5 -5
- package/dist/collection/components/molecules/mg-loader/mg-loader.js.map +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +22 -6
- package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +54 -11
- package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +28 -9
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +48 -13
- package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +10 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +61 -7
- package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +26 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js.map +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +3 -2
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js.map +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +28 -8
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
- package/dist/collection/utils/behaviors.utils.js +44 -107
- package/dist/collection/utils/behaviors.utils.js.map +1 -1
- package/dist/components/index.es.js +42 -42
- package/dist/components/index.es.js.map +1 -1
- package/dist/components/index2.js +2 -2
- package/dist/components/mg-action-more.js +15 -12
- package/dist/components/mg-action-more.js.map +1 -1
- package/dist/components/mg-alert.js +15 -10
- package/dist/components/mg-alert.js.map +1 -1
- package/dist/components/mg-badge2.js +13 -10
- package/dist/components/mg-badge2.js.map +1 -1
- package/dist/components/mg-button2.js +77 -16
- package/dist/components/mg-button2.js.map +1 -1
- package/dist/components/mg-card2.js +1 -1
- package/dist/components/mg-character-left2.js +8 -7
- package/dist/components/mg-character-left2.js.map +1 -1
- package/dist/components/mg-details.js +11 -7
- package/dist/components/mg-details.js.map +1 -1
- package/dist/components/mg-divider2.js +7 -1
- package/dist/components/mg-divider2.js.map +1 -1
- package/dist/components/mg-form.js +35 -21
- package/dist/components/mg-form.js.map +1 -1
- package/dist/components/mg-icon2.js +17 -11
- package/dist/components/mg-icon2.js.map +1 -1
- package/dist/components/mg-illustrated-message.js +10 -4
- package/dist/components/mg-illustrated-message.js.map +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +14 -10
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
- package/dist/components/mg-input-checkbox.js +73 -40
- package/dist/components/mg-input-checkbox.js.map +1 -1
- package/dist/components/mg-input-date.js +77 -46
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +90 -45
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-password.js +56 -28
- package/dist/components/mg-input-password.js.map +1 -1
- package/dist/components/mg-input-radio.js +59 -31
- package/dist/components/mg-input-radio.js.map +1 -1
- package/dist/components/mg-input-select2.js +60 -36
- package/dist/components/mg-input-select2.js.map +1 -1
- package/dist/components/mg-input-text2.js +71 -40
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-input-textarea.js +72 -36
- package/dist/components/mg-input-textarea.js.map +1 -1
- package/dist/components/mg-input-title2.js +11 -8
- package/dist/components/mg-input-title2.js.map +1 -1
- package/dist/components/mg-input-toggle.js +43 -25
- package/dist/components/mg-input-toggle.js.map +1 -1
- package/dist/components/mg-input2.js +37 -20
- package/dist/components/mg-input2.js.map +1 -1
- package/dist/components/mg-item-more2.js +146 -270
- package/dist/components/mg-item-more2.js.map +1 -1
- package/dist/components/mg-loader.js +4 -6
- package/dist/components/mg-loader.js.map +1 -1
- package/dist/components/mg-menu-item2.js +193 -149
- package/dist/components/mg-menu-item2.js.map +1 -1
- package/dist/components/mg-message2.js +21 -9
- package/dist/components/mg-message2.js.map +1 -1
- package/dist/components/mg-modal.js +36 -17
- package/dist/components/mg-modal.js.map +1 -1
- package/dist/components/mg-pagination2.js +21 -14
- package/dist/components/mg-pagination2.js.map +1 -1
- package/dist/components/mg-panel.js +37 -20
- package/dist/components/mg-panel.js.map +1 -1
- package/dist/components/mg-popover-content2.js +9 -3
- package/dist/components/mg-popover-content2.js.map +1 -1
- package/dist/components/mg-popover2.js +38 -10
- package/dist/components/mg-popover2.js.map +1 -1
- package/dist/components/mg-progress.js +26 -11
- package/dist/components/mg-progress.js.map +1 -1
- package/dist/components/mg-skip-links.js +2 -3
- package/dist/components/mg-skip-links.js.map +1 -1
- package/dist/components/mg-tabs.js +27 -17
- package/dist/components/mg-tabs.js.map +1 -1
- package/dist/components/mg-tag.js +12 -8
- package/dist/components/mg-tag.js.map +1 -1
- package/dist/components/mg-tooltip-content2.js +1 -2
- package/dist/components/mg-tooltip-content2.js.map +1 -1
- package/dist/components/mg-tooltip2.js +24 -12
- package/dist/components/mg-tooltip2.js.map +1 -1
- package/dist/esm/{index-81752ffe.js → index-1f32332a.js} +410 -266
- package/dist/esm/index-1f32332a.js.map +1 -0
- package/dist/esm/{index-f3d3fb70.js → index-9bd10f5d.js} +3 -3
- package/dist/esm/{index-f3d3fb70.js.map → index-9bd10f5d.js.map} +1 -1
- package/dist/esm/{index.es-940821a9.js → index.es-a2587b72.js} +43 -43
- package/dist/esm/index.es-a2587b72.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_36.entry.js +1414 -983
- package/dist/esm/mg-action-more_36.entry.js.map +1 -1
- package/dist/esm/mg-alert.entry.js +17 -12
- package/dist/esm/mg-alert.entry.js.map +1 -1
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-components.js.map +1 -1
- package/dist/esm/mg-loader.entry.js +6 -8
- package/dist/esm/mg-loader.entry.js.map +1 -1
- package/dist/esm/mg-progress.entry.js +27 -12
- package/dist/esm/mg-progress.entry.js.map +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/mg-components.esm.js.map +1 -1
- package/dist/mg-components/p-0ead5317.entry.js +2 -0
- package/dist/mg-components/{p-31e6c1a7.entry.js.map → p-0ead5317.entry.js.map} +1 -1
- package/dist/mg-components/p-35898742.js +3 -0
- package/dist/mg-components/p-35898742.js.map +1 -0
- package/dist/mg-components/p-3b052ac0.entry.js +2 -0
- package/dist/mg-components/p-3b052ac0.entry.js.map +1 -0
- package/dist/mg-components/p-6810a565.entry.js +2 -0
- package/dist/mg-components/p-6810a565.entry.js.map +1 -0
- package/dist/mg-components/{p-ee51ec5e.js → p-b986c107.js} +2 -2
- package/dist/mg-components/p-b986c107.js.map +1 -0
- package/dist/mg-components/{p-a49e2b74.js → p-dc436f3c.js} +2 -2
- package/dist/mg-components/p-f48d964f.entry.js +2 -0
- package/dist/mg-components/p-f48d964f.entry.js.map +1 -0
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +9 -1
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +11 -1
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +6 -0
- package/dist/types/components/molecules/internals/mg-item-more/mg-item-more.d.ts +1 -15
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +14 -30
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +46 -37
- package/dist/types/components/molecules/mg-alert/mg-alert.d.ts +4 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +4 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +4 -0
- package/dist/types/components.d.ts +33 -15
- package/dist/types/utils/behaviors.utils.d.ts +15 -44
- package/ide/intellij/web-types.json +39 -11
- package/ide/vscode/html-custom-data.json +28 -6
- package/package.json +27 -37
- package/dist/cjs/index-52d5f3d4.js.map +0 -1
- package/dist/cjs/index.es-ac7c22e3.js.map +0 -1
- package/dist/esm/index-81752ffe.js.map +0 -1
- package/dist/esm/index.es-940821a9.js.map +0 -1
- package/dist/mg-components/p-2298352f.js +0 -3
- package/dist/mg-components/p-2298352f.js.map +0 -1
- package/dist/mg-components/p-31e6c1a7.entry.js +0 -2
- package/dist/mg-components/p-67c9be27.entry.js +0 -2
- package/dist/mg-components/p-67c9be27.entry.js.map +0 -1
- package/dist/mg-components/p-95895169.entry.js +0 -2
- package/dist/mg-components/p-95895169.entry.js.map +0 -1
- package/dist/mg-components/p-abddacc2.entry.js +0 -2
- package/dist/mg-components/p-abddacc2.entry.js.map +0 -1
- package/dist/mg-components/p-ee51ec5e.js.map +0 -1
- /package/dist/mg-components/{p-a49e2b74.js.map → p-dc436f3c.js.map} +0 -0
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
6
|
-
const index_es = require('./index.es-
|
|
7
|
-
const index$1 = require('./index-
|
|
5
|
+
const index = require('./index-911898e4.js');
|
|
6
|
+
const index_es = require('./index.es-325100d7.js');
|
|
7
|
+
const index$1 = require('./index-a3269bfc.js');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Available menu item status values
|
|
@@ -30,7 +30,7 @@ const Direction = {
|
|
|
30
30
|
/**
|
|
31
31
|
* List of all possibles sizes
|
|
32
32
|
*/
|
|
33
|
-
const sizes$
|
|
33
|
+
const sizes$3 = ['medium', 'large', 'xlarge'];
|
|
34
34
|
|
|
35
35
|
const mgActionMoreCss = ".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{--mg-c-popover-padding-vertical:var(--mg-b-size-8);--mg-c-popover-padding-horizontal:0;--mg-c-popover-max-width:unset}.mg-c-action-more__divider{--mg-c-divider-spacing-vertical:var(--mg-b-size-4)}.mg-c-action-more__chevron{transition:200ms}.mg-c-action-more__chevron--rotate.mg-c-action-more__chevron{transform:rotate(180deg)}";
|
|
36
36
|
const MgActionMoreStyle0 = mgActionMoreCss;
|
|
@@ -77,7 +77,15 @@ const MgActionMore = class {
|
|
|
77
77
|
************/
|
|
78
78
|
this.name = 'mg-action-more';
|
|
79
79
|
this.classBase = 'mg-c-action-more';
|
|
80
|
-
this.mgPopoverIdentifier = index_es.
|
|
80
|
+
this.mgPopoverIdentifier = index_es.ze(this.name);
|
|
81
|
+
/**
|
|
82
|
+
* Define button properties
|
|
83
|
+
*/
|
|
84
|
+
this.button = { variant: 'flat', isIcon: true };
|
|
85
|
+
/**
|
|
86
|
+
* Menu expanded state
|
|
87
|
+
*/
|
|
88
|
+
this.expanded = false;
|
|
81
89
|
/************
|
|
82
90
|
* Methods *
|
|
83
91
|
***********/
|
|
@@ -109,23 +117,18 @@ const MgActionMore = class {
|
|
|
109
117
|
this.expanded = false;
|
|
110
118
|
customHandler(event);
|
|
111
119
|
};
|
|
112
|
-
this.items = undefined;
|
|
113
|
-
this.icon = undefined;
|
|
114
|
-
this.button = { variant: 'flat', isIcon: true };
|
|
115
|
-
this.displayChevron = undefined;
|
|
116
|
-
this.expanded = false;
|
|
117
120
|
}
|
|
118
121
|
validateItems(newValue) {
|
|
119
122
|
if (!isMgActionMoreItems(newValue)) {
|
|
120
|
-
throw new Error(`<${this.name}> prop "items" is required and all values must be the same type, MgActionMoreItemType or MgActionMoreDividerType. Passed value: ${index_es.
|
|
123
|
+
throw new Error(`<${this.name}> prop "items" is required and all values must be the same type, MgActionMoreItemType or MgActionMoreDividerType. Passed value: ${index_es.Je(newValue)}.`);
|
|
121
124
|
}
|
|
122
125
|
else if (isMgActionMoreItems(newValue) && newValue.length > 0 && (isMgActionMoreDivider(newValue[0]) || isMgActionMoreDivider(newValue[newValue.length - 1]))) {
|
|
123
|
-
throw new Error(`<${this.name}> prop "items" can’t have a divider at the beginning or the end of the array. Passed value: ${index_es.
|
|
126
|
+
throw new Error(`<${this.name}> prop "items" can’t have a divider at the beginning or the end of the array. Passed value: ${index_es.Je(newValue)}.`);
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
validateIcon(newValue) {
|
|
127
130
|
if (newValue && !isMgActionMoreIcon(newValue)) {
|
|
128
|
-
throw new Error(`<${this.name}> prop "icon" must match MgActionMoreIconType. Passed value: ${index_es.
|
|
131
|
+
throw new Error(`<${this.name}> prop "icon" must match MgActionMoreIconType. Passed value: ${index_es.Je(newValue)}.`);
|
|
129
132
|
}
|
|
130
133
|
else if ((newValue === null || newValue === void 0 ? void 0 : newValue.icon) === undefined && Boolean(this.button.isIcon)) {
|
|
131
134
|
this.icon = { icon: 'ellipsis' };
|
|
@@ -133,7 +136,7 @@ const MgActionMore = class {
|
|
|
133
136
|
}
|
|
134
137
|
validateButton(newValue) {
|
|
135
138
|
if (newValue && !isMgActionMoreButton(newValue)) {
|
|
136
|
-
throw new Error(`<${this.name}> prop "button" must match MgActionMoreButtonType. Passed value: ${index_es.
|
|
139
|
+
throw new Error(`<${this.name}> prop "button" must match MgActionMoreButtonType. Passed value: ${index_es.Je(newValue)}.`);
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
142
|
validateDisplayChevron(newValue) {
|
|
@@ -167,7 +170,7 @@ const MgActionMore = class {
|
|
|
167
170
|
[`${this.classBase}__chevron--rotate`]: this.expanded === true,
|
|
168
171
|
} }, index.h("mg-icon", { icon: "chevron-down" })));
|
|
169
172
|
}
|
|
170
|
-
return (index.h(index.Host, { key: '
|
|
173
|
+
return (index.h(index.Host, { key: '2255b4416986c17b4c51162e60f2d69599d730fe', "data-mg-popover-guard": this.mgPopoverIdentifier }, index.h("span", { key: '06e117e65bd8bbe404478c657cd96709b83e9283', class: this.classBase }, index.h("mg-popover", { key: '3001fb13f7d6d43c40194698c3f6b081ad7e7ab4', identifier: this.mgPopoverIdentifier, display: this.expanded, "onDisplay-change": this.handleDisplayChange }, index.h("mg-button", { key: '7b1031a98bddbe7f1e567c42be7ce595512db2ce', variant: this.button.variant, isIcon: this.button.isIcon, disabled: this.button.disabled, type: "button", label: buttonLabel, onClick: this.handleButton }, this.icon && index.h("mg-icon", Object.assign({ key: '756b408413f748ad8bc32e1d573ab2d7f54a9ce1' }, this.icon)), !this.button.isIcon && buttonContent), index.h("div", { key: '623b5084381a0ff4e3b8ec06892dcb8d16cb060a', slot: "content" }, index.h("mg-menu", { key: '34bcf9213d4d076246270daaebbef75ec0f92b07', direction: Direction.VERTICAL, label: this.messages.label }, this.items.map(item => {
|
|
171
174
|
var _a, _b;
|
|
172
175
|
return isMgActionMoreDivider(item) ? (index.h("mg-divider", { class: "mg-c-action-more__divider", key: "divider" })) : (index.h("mg-menu-item", { key: item.label, status: item.status || Status$1.VISIBLE, target: item.target, href: item.href,
|
|
173
176
|
// eslint-disable-next-line react/jsx-no-bind
|
|
@@ -200,25 +203,28 @@ const MgBadge = class {
|
|
|
200
203
|
************/
|
|
201
204
|
// Classes
|
|
202
205
|
this.classOutline = `mg-c-badge--outline`;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
this.
|
|
207
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Define badge variant
|
|
208
|
+
*/
|
|
209
|
+
this.variant = variants$4[0]; // info
|
|
210
|
+
/**
|
|
211
|
+
* Component classes
|
|
212
|
+
*/
|
|
213
|
+
this.classCollection = new index_es.Ge(['mg-c-badge']);
|
|
208
214
|
}
|
|
209
215
|
validateValue(newValue) {
|
|
210
216
|
if (/^[^A-Z]+$/i.exec(`${newValue}`) === null) {
|
|
211
|
-
throw new Error(`<mg-badge> prop "value" is required and must be integer and/or special character. Passed value: ${index_es.
|
|
217
|
+
throw new Error(`<mg-badge> prop "value" is required and must be integer and/or special character. Passed value: ${index_es.Je(newValue)}.`);
|
|
212
218
|
}
|
|
213
219
|
}
|
|
214
220
|
validateLabel(newValue) {
|
|
215
|
-
if (!index_es.
|
|
216
|
-
throw new Error(`<mg-badge> prop "label" is required and must be a string. Passed value: ${index_es.
|
|
221
|
+
if (!index_es.ye(newValue)) {
|
|
222
|
+
throw new Error(`<mg-badge> prop "label" is required and must be a string. Passed value: ${index_es.Je(newValue)}.`);
|
|
217
223
|
}
|
|
218
224
|
}
|
|
219
225
|
validateVariant(newValue, oldValue) {
|
|
220
226
|
if (!variants$4.includes(newValue)) {
|
|
221
|
-
throw new Error(`<mg-badge> prop "variant" must be one of: ${variants$4.join(', ')}. Passed value: ${index_es.
|
|
227
|
+
throw new Error(`<mg-badge> prop "variant" must be one of: ${variants$4.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
222
228
|
}
|
|
223
229
|
else {
|
|
224
230
|
if (oldValue !== undefined) {
|
|
@@ -258,12 +264,16 @@ const MgBadge = class {
|
|
|
258
264
|
};
|
|
259
265
|
MgBadge.style = MgBadgeStyle0;
|
|
260
266
|
|
|
267
|
+
/**
|
|
268
|
+
* List of all possibles sizes
|
|
269
|
+
*/
|
|
270
|
+
const sizes$2 = ['medium', 'large'];
|
|
261
271
|
/**
|
|
262
272
|
* List of all possibles variants
|
|
263
273
|
*/
|
|
264
274
|
const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success', 'link'];
|
|
265
275
|
|
|
266
|
-
const mgButtonCss = "/*!\n * @prop --mg-c-button-border-radius: Defines the border radius of the button. The default value is `--mg-b-size-radius`.\n * @prop --mg-c-button-border-top-width: Defines the top border width of the button. Unset by default, fallback on `--mg-b-size-border`.\n * @prop --mg-c-button-border-right-width: Defines the right border width of the button. Unset by default, fallback on `--mg-b-size-border`.\n * @prop --mg-c-button-border-bottom-width: Defines the bottom border width of the button. Unset by default, fallback on `--mg-b-size-border`.\n * @prop --mg-c-button-border-left-width: Defines the left border width of the button. Unset by default, fallback on `--mg-b-size-border`.\n * @prop --mg-c-button-border-radius-top-left: Defines the top left border radius of the button. Unset by default, fallback on `--mg-c-button-border-radius`.\n * @prop --mg-c-button-border-radius-top-right: Defines the top right border radius of the button. Unset by default, fallback on `--mg-c-button-border-radius`.\n * @prop --mg-c-button-border-radius-bottom-right: Defines the bottom right border radius of the button. Unset by default, fallback on `--mg-c-button-border-radius`.\n * @prop --mg-c-button-border-radius-bottom-left: Defines the bottom left border radius of the button. Unset by default, fallback on `--mg-c-button-border-radius`.\n * @prop --mg-c-button-font-weight: Defines the font weight of the button. Unset by default, fallback on `normal`.\n * @prop --mg-c-button-icon-border-radius: Defines the border radius of the button in icon mode. The default value is `--mg-b-size-min-height`.\n */:host{display:inline-block;max-width:100%;vertical-align:middle}:host(:hover) .mg-c-button--flat:not(.mg-c-button--disabled){background:color-mix(in srgb, var(--mg-b-color-dark), transparent 90%)}:host([full-width]){display:block}:host([disabled]),:host([aria-disabled=true]){pointer-events:none}.mg-c-button.mg-c-button--primary{/*!\n * @prop --mg-c-button-color-background-primary: Defines the background color for the primary variant button.\n * @prop --mg-c-button-color-border-primary: Defines the border color for the primary variant button.\n * @prop --mg-c-button-color-gradient-primary: Defines the gradient color for the primary variant button.\n * @prop --mg-c-button-color-text-primary: Defines the font color for the primary variant button.\n */border-color:var(--mg-c-button-color-border-primary);background:linear-gradient(to bottom, var(--mg-c-button-color-background-primary), var(--mg-c-button-color-gradient-primary));color:var(--mg-c-button-color-text-primary)}:host(:hover) .mg-c-button.mg-c-button--primary:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-primary)}.mg-c-button.mg-c-button--secondary{/*!\n * @prop --mg-c-button-color-background-secondary: Defines the background color for the secondary variant button.\n * @prop --mg-c-button-color-border-secondary: Defines the border color for the secondary variant button.\n * @prop --mg-c-button-color-gradient-secondary: Defines the gradient color for the secondary variant button.\n * @prop --mg-c-button-color-text-secondary: Defines the font color for the secondary variant button.\n */border-color:var(--mg-c-button-color-border-secondary);background:linear-gradient(to bottom, var(--mg-c-button-color-background-secondary), var(--mg-c-button-color-gradient-secondary));color:var(--mg-c-button-color-text-secondary)}:host(:hover) .mg-c-button.mg-c-button--secondary:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-secondary)}.mg-c-button.mg-c-button--danger{/*!\n * @prop --mg-c-button-color-background-danger: Defines the background color for the danger variant button.\n * @prop --mg-c-button-color-border-danger: Defines the border color for the danger variant button.\n * @prop --mg-c-button-color-gradient-danger: Defines the gradient color for the danger variant button.\n * @prop --mg-c-button-color-text-danger: Defines the font color for the danger variant button.\n */border-color:var(--mg-c-button-color-border-danger);background:linear-gradient(to bottom, var(--mg-c-button-color-background-danger), var(--mg-c-button-color-gradient-danger));color:var(--mg-c-button-color-text-danger)}:host(:hover) .mg-c-button.mg-c-button--danger:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-danger)}.mg-c-button.mg-c-button--info{/*!\n * @prop --mg-c-button-color-background-info: Defines the background color for the info variant button.\n * @prop --mg-c-button-color-border-info: Defines the border color for the info variant button.\n * @prop --mg-c-button-color-gradient-info: Defines the gradient color for the info variant button.\n * @prop --mg-c-button-color-text-info: Defines the font color for the info variant button.\n */border-color:var(--mg-c-button-color-border-info);background:linear-gradient(to bottom, var(--mg-c-button-color-background-info), var(--mg-c-button-color-gradient-info));color:var(--mg-c-button-color-text-info)}:host(:hover) .mg-c-button.mg-c-button--info:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-info)}.mg-c-button.mg-c-button--success{/*!\n * @prop --mg-c-button-color-background-success: Defines the background color for the success variant button.\n * @prop --mg-c-button-color-border-success: Defines the border color for the success variant button.\n * @prop --mg-c-button-color-gradient-success: Defines the gradient color for the success variant button.\n * @prop --mg-c-button-color-text-success: Defines the font color for the success variant button.\n */border-color:var(--mg-c-button-color-border-success);background:linear-gradient(to bottom, var(--mg-c-button-color-background-success), var(--mg-c-button-color-gradient-success));color:var(--mg-c-button-color-text-success)}:host(:hover) .mg-c-button.mg-c-button--success:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-success)}.mg-c-button.mg-c-button--warning{/*!\n * @prop --mg-c-button-color-background-warning: Defines the background color for the warning variant button.\n * @prop --mg-c-button-color-border-warning: Defines the border color for the warning variant button.\n * @prop --mg-c-button-color-gradient-warning: Defines the gradient color for the warning variant button.\n * @prop --mg-c-button-color-text-warning: Defines the font color for the warning variant button.\n */border-color:var(--mg-c-button-color-border-warning);background:linear-gradient(to bottom, var(--mg-c-button-color-background-warning), var(--mg-c-button-color-gradient-warning));color:var(--mg-c-button-color-text-warning)}:host(:hover) .mg-c-button.mg-c-button--warning:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-warning)}.mg-c-button.mg-c-button--danger-alt{/*!\n * @prop --mg-c-button-color-background-danger-alt: Defines the background color for the danger-alt variant button.\n * @prop --mg-c-button-color-border-danger-alt: Defines the border color for the danger-alt variant button.\n * @prop --mg-c-button-color-gradient-danger-alt: Defines the gradient color for the danger-alt variant button.\n * @prop --mg-c-button-color-text-danger-alt: Defines the font color for the danger-alt variant button.\n */border-color:var(--mg-c-button-color-border-danger-alt);background:linear-gradient(to bottom, var(--mg-c-button-color-background-danger-alt), var(--mg-c-button-color-gradient-danger-alt));color:var(--mg-c-button-color-text-danger-alt)}:host(:hover) .mg-c-button.mg-c-button--danger-alt:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-danger-alt)}.mg-c-button{position:relative;display:inline-flex;min-height:var(--mg-b-size-min-height);box-sizing:border-box;align-items:center;padding:calc((var(--mg-b-size-min-height) - 2*var(--mg-b-size-border) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-12);border-width:var(--mg-c-button-border-top-width, var(--mg-b-size-border)) var(--mg-c-button-border-right-width, var(--mg-b-size-border)) var(--mg-c-button-border-bottom-width, var(--mg-b-size-border)) var(--mg-c-button-border-left-width, var(--mg-b-size-border));border-style:solid;border-radius:var(--mg-c-button-border-radius-top-left, var(--mg-c-button-border-radius)) var(--mg-c-button-border-radius-top-right, var(--mg-c-button-border-radius)) var(--mg-c-button-border-radius-bottom-right, var(--mg-c-button-border-radius)) var(--mg-c-button-border-radius-bottom-left, var(--mg-c-button-border-radius));background-image:none;column-gap:var(--mg-b-size-8);cursor:pointer;touch-action:manipulation;font-family:inherit;font-size:var(--mg-b-font-size);font-weight:var(--mg-c-button-font-weight, normal);text-align:left;text-decoration:none}.mg-c-button.mg-c-button--disabled{cursor:default;opacity:var(--mg-b-opacity-element-disabled)}.mg-c-button.mg-c-button--icon{width:var(--mg-b-size-min-height);height:var(--mg-b-size-min-height);justify-content:center;padding:0;border-radius:var(--mg-c-button-border-radius-top-left, var(--mg-c-button-icon-border-radius)) var(--mg-c-button-border-radius-top-right, var(--mg-c-button-icon-border-radius)) var(--mg-c-button-border-radius-bottom-right, var(--mg-c-button-icon-border-radius)) var(--mg-c-button-border-radius-bottom-left, var(--mg-c-button-icon-border-radius));font-size:var(--mg-b-font-size);line-height:var(--mg-b-font-size)}.mg-c-button.mg-c-button--flat{border:none;background:none}.mg-c-button slot,.mg-c-button ::slotted(*:not(mg-icon)){font-family:inherit;font-size:var(--mg-b-font-size);font-weight:var(--mg-c-button-font-weight, normal);text-align:left;text-decoration:none;display:flex;align-items:center;column-gap:var(--mg-b-size-8)}.mg-c-button.mg-c-button--link{min-height:unset;padding:unset;border:unset;border-radius:unset;background:unset;text-decoration:underline}.mg-c-button.mg-c-button--link slot{font-weight:600}.mg-c-button.mg-c-button--link:hover{text-decoration:none}.mg-c-button.mg-c-button--full-width{display:flex;justify-content:center}.mg-c-button mg-icon:only-child,.mg-c-button ::slotted(mg-icon){display:inline-flex;flex-shrink:0;margin:auto 0;line-height:1}.mg-c-button.mg-c-button--loading>mg-icon:first-of-type{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%)}.mg-c-button.mg-c-button--loading .mg-c-button__content{opacity:0}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-c-button{outline-color:-webkit-focus-ring-color;outline-style:auto;outline-width:.2rem}";
|
|
276
|
+
const mgButtonCss = "/*!\n * @prop --mg-c-button-border-radius: Defines the border radius of the button. The default value is `--mg-b-size-radius`.\n * @prop --mg-c-button-border-top-width: Defines the top border width of the button. Unset by default, fallback on `--mg-b-size-border`.\n * @prop --mg-c-button-border-right-width: Defines the right border width of the button. Unset by default, fallback on `--mg-b-size-border`.\n * @prop --mg-c-button-border-bottom-width: Defines the bottom border width of the button. Unset by default, fallback on `--mg-b-size-border`.\n * @prop --mg-c-button-border-left-width: Defines the left border width of the button. Unset by default, fallback on `--mg-b-size-border`.\n * @prop --mg-c-button-border-radius-top-left: Defines the top left border radius of the button. Unset by default, fallback on `--mg-c-button-border-radius`.\n * @prop --mg-c-button-border-radius-top-right: Defines the top right border radius of the button. Unset by default, fallback on `--mg-c-button-border-radius`.\n * @prop --mg-c-button-border-radius-bottom-right: Defines the bottom right border radius of the button. Unset by default, fallback on `--mg-c-button-border-radius`.\n * @prop --mg-c-button-border-radius-bottom-left: Defines the bottom left border radius of the button. Unset by default, fallback on `--mg-c-button-border-radius`.\n * @prop --mg-c-button-font-weight: Defines the font weight of the button. Unset by default, fallback on `normal`.\n * @prop --mg-c-button-icon-border-radius: Defines the border radius of the button in icon mode. The default value is `--mg-b-size-min-height`.\n */:host{display:inline-block;max-width:100%;vertical-align:middle}:host(:hover) .mg-c-button--flat:not(.mg-c-button--disabled){background:color-mix(in srgb, var(--mg-b-color-dark), transparent 90%)}:host([full-width]){display:block}:host([disabled]),:host([aria-disabled=true]){pointer-events:none}.mg-c-button.mg-c-button--primary{/*!\n * @prop --mg-c-button-color-background-primary: Defines the background color for the primary variant button.\n * @prop --mg-c-button-color-border-primary: Defines the border color for the primary variant button.\n * @prop --mg-c-button-color-gradient-primary: Defines the gradient color for the primary variant button.\n * @prop --mg-c-button-color-text-primary: Defines the font color for the primary variant button.\n */border-color:var(--mg-c-button-color-border-primary);background:linear-gradient(to bottom, var(--mg-c-button-color-background-primary), var(--mg-c-button-color-gradient-primary));color:var(--mg-c-button-color-text-primary)}:host(:hover) .mg-c-button.mg-c-button--primary:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-primary)}.mg-c-button.mg-c-button--secondary{/*!\n * @prop --mg-c-button-color-background-secondary: Defines the background color for the secondary variant button.\n * @prop --mg-c-button-color-border-secondary: Defines the border color for the secondary variant button.\n * @prop --mg-c-button-color-gradient-secondary: Defines the gradient color for the secondary variant button.\n * @prop --mg-c-button-color-text-secondary: Defines the font color for the secondary variant button.\n */border-color:var(--mg-c-button-color-border-secondary);background:linear-gradient(to bottom, var(--mg-c-button-color-background-secondary), var(--mg-c-button-color-gradient-secondary));color:var(--mg-c-button-color-text-secondary)}:host(:hover) .mg-c-button.mg-c-button--secondary:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-secondary)}.mg-c-button.mg-c-button--danger{/*!\n * @prop --mg-c-button-color-background-danger: Defines the background color for the danger variant button.\n * @prop --mg-c-button-color-border-danger: Defines the border color for the danger variant button.\n * @prop --mg-c-button-color-gradient-danger: Defines the gradient color for the danger variant button.\n * @prop --mg-c-button-color-text-danger: Defines the font color for the danger variant button.\n */border-color:var(--mg-c-button-color-border-danger);background:linear-gradient(to bottom, var(--mg-c-button-color-background-danger), var(--mg-c-button-color-gradient-danger));color:var(--mg-c-button-color-text-danger)}:host(:hover) .mg-c-button.mg-c-button--danger:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-danger)}.mg-c-button.mg-c-button--info{/*!\n * @prop --mg-c-button-color-background-info: Defines the background color for the info variant button.\n * @prop --mg-c-button-color-border-info: Defines the border color for the info variant button.\n * @prop --mg-c-button-color-gradient-info: Defines the gradient color for the info variant button.\n * @prop --mg-c-button-color-text-info: Defines the font color for the info variant button.\n */border-color:var(--mg-c-button-color-border-info);background:linear-gradient(to bottom, var(--mg-c-button-color-background-info), var(--mg-c-button-color-gradient-info));color:var(--mg-c-button-color-text-info)}:host(:hover) .mg-c-button.mg-c-button--info:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-info)}.mg-c-button.mg-c-button--success{/*!\n * @prop --mg-c-button-color-background-success: Defines the background color for the success variant button.\n * @prop --mg-c-button-color-border-success: Defines the border color for the success variant button.\n * @prop --mg-c-button-color-gradient-success: Defines the gradient color for the success variant button.\n * @prop --mg-c-button-color-text-success: Defines the font color for the success variant button.\n */border-color:var(--mg-c-button-color-border-success);background:linear-gradient(to bottom, var(--mg-c-button-color-background-success), var(--mg-c-button-color-gradient-success));color:var(--mg-c-button-color-text-success)}:host(:hover) .mg-c-button.mg-c-button--success:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-success)}.mg-c-button.mg-c-button--warning{/*!\n * @prop --mg-c-button-color-background-warning: Defines the background color for the warning variant button.\n * @prop --mg-c-button-color-border-warning: Defines the border color for the warning variant button.\n * @prop --mg-c-button-color-gradient-warning: Defines the gradient color for the warning variant button.\n * @prop --mg-c-button-color-text-warning: Defines the font color for the warning variant button.\n */border-color:var(--mg-c-button-color-border-warning);background:linear-gradient(to bottom, var(--mg-c-button-color-background-warning), var(--mg-c-button-color-gradient-warning));color:var(--mg-c-button-color-text-warning)}:host(:hover) .mg-c-button.mg-c-button--warning:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-warning)}.mg-c-button.mg-c-button--danger-alt{/*!\n * @prop --mg-c-button-color-background-danger-alt: Defines the background color for the danger-alt variant button.\n * @prop --mg-c-button-color-border-danger-alt: Defines the border color for the danger-alt variant button.\n * @prop --mg-c-button-color-gradient-danger-alt: Defines the gradient color for the danger-alt variant button.\n * @prop --mg-c-button-color-text-danger-alt: Defines the font color for the danger-alt variant button.\n */border-color:var(--mg-c-button-color-border-danger-alt);background:linear-gradient(to bottom, var(--mg-c-button-color-background-danger-alt), var(--mg-c-button-color-gradient-danger-alt));color:var(--mg-c-button-color-text-danger-alt)}:host(:hover) .mg-c-button.mg-c-button--danger-alt:not(.mg-c-button--disabled){background:var(--mg-c-button-color-background-danger-alt)}.mg-c-button{position:relative;display:inline-flex;min-height:var(--mg-b-size-min-height);box-sizing:border-box;align-items:center;padding:calc((var(--mg-b-size-min-height) - 2*var(--mg-b-size-border) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-12);border-width:var(--mg-c-button-border-top-width, var(--mg-b-size-border)) var(--mg-c-button-border-right-width, var(--mg-b-size-border)) var(--mg-c-button-border-bottom-width, var(--mg-b-size-border)) var(--mg-c-button-border-left-width, var(--mg-b-size-border));border-style:solid;border-radius:var(--mg-c-button-border-radius-top-left, var(--mg-c-button-border-radius)) var(--mg-c-button-border-radius-top-right, var(--mg-c-button-border-radius)) var(--mg-c-button-border-radius-bottom-right, var(--mg-c-button-border-radius)) var(--mg-c-button-border-radius-bottom-left, var(--mg-c-button-border-radius));background-image:none;column-gap:var(--mg-b-size-8);cursor:pointer;touch-action:manipulation;font-family:inherit;font-size:var(--mg-b-font-size);font-weight:var(--mg-c-button-font-weight, normal);text-align:left;text-decoration:none}.mg-c-button slot,.mg-c-button ::slotted(*:not(mg-icon)){font-family:inherit;font-size:var(--mg-b-font-size);font-weight:var(--mg-c-button-font-weight, normal);text-align:left;text-decoration:none;display:flex;align-items:center;column-gap:var(--mg-b-size-8)}.mg-c-button mg-icon:only-child,.mg-c-button ::slotted(mg-icon){display:inline-flex;flex-shrink:0;margin:auto 0;line-height:1}.mg-c-button.mg-c-button--disabled{cursor:default;opacity:var(--mg-b-opacity-element-disabled)}.mg-c-button.mg-c-button--flat{border:none;background:none}.mg-c-button.mg-c-button--link{min-height:unset;padding:unset;border:unset;border-radius:unset;background:unset;text-decoration:underline}.mg-c-button.mg-c-button--link slot{font-weight:600}.mg-c-button.mg-c-button--link:hover{text-decoration:none}.mg-c-button.mg-c-button--large{padding:calc(var(--mg-b-size-12) - var(--mg-b-size-border)) calc(var(--mg-b-size-24) - var(--mg-b-size-border))}.mg-c-button.mg-c-button--large:not(.mg-c-button--icon){line-height:var(--mg-b-size-24)}.mg-c-button.mg-c-button--large:not(.mg-c-button--icon) slot,.mg-c-button.mg-c-button--large:not(.mg-c-button--icon) ::slotted(*){font-size:var(--mg-b-size-16)}.mg-c-button.mg-c-button--icon{width:var(--mg-b-size-min-height);height:var(--mg-b-size-min-height);justify-content:center;padding:0;border-radius:var(--mg-c-button-border-radius-top-left, var(--mg-c-button-icon-border-radius)) var(--mg-c-button-border-radius-top-right, var(--mg-c-button-icon-border-radius)) var(--mg-c-button-border-radius-bottom-right, var(--mg-c-button-icon-border-radius)) var(--mg-c-button-border-radius-bottom-left, var(--mg-c-button-icon-border-radius));font-size:var(--mg-b-font-size);line-height:var(--mg-b-font-size)}.mg-c-button.mg-c-button--icon.mg-c-button--large{width:unset;height:unset;padding:calc(var(--mg-b-size-12) - var(--mg-b-size-border))}.mg-c-button.mg-c-button--icon.mg-c-button--large ::slotted(*){min-width:var(--mg-b-size-24);min-height:var(--mg-b-size-24);align-items:center;justify-content:center}.mg-c-button.mg-c-button--full-width{display:flex;justify-content:center}.mg-c-button.mg-c-button--loading>mg-icon:first-of-type{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%)}.mg-c-button.mg-c-button--loading .mg-c-button__content{opacity:0}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-c-button{outline-color:-webkit-focus-ring-color;outline-style:auto;outline-width:.2rem}";
|
|
267
277
|
const MgButtonStyle0 = mgButtonCss;
|
|
268
278
|
|
|
269
279
|
const MgButton = class {
|
|
@@ -277,6 +287,38 @@ const MgButton = class {
|
|
|
277
287
|
this.classDisabled = 'mg-c-button--disabled';
|
|
278
288
|
this.classLoading = 'mg-c-button--loading';
|
|
279
289
|
this.classFullWidth = 'mg-c-button--full-width';
|
|
290
|
+
/**
|
|
291
|
+
* Define button variant
|
|
292
|
+
*/
|
|
293
|
+
this.variant = variants$3[0]; // Primary
|
|
294
|
+
/**
|
|
295
|
+
* Define button size
|
|
296
|
+
*/
|
|
297
|
+
this.size = sizes$2[0]; // medium
|
|
298
|
+
/**
|
|
299
|
+
* Set button to full-width
|
|
300
|
+
*/
|
|
301
|
+
this.fullWidth = false;
|
|
302
|
+
/**
|
|
303
|
+
* Define if button is round.
|
|
304
|
+
* Used for icon button.
|
|
305
|
+
*/
|
|
306
|
+
this.isIcon = false;
|
|
307
|
+
/**
|
|
308
|
+
* Option to set input disable on click, in order to prevent multi-click.
|
|
309
|
+
* Parent component have to remove the attribute 'disabled' when the process ends.
|
|
310
|
+
*/
|
|
311
|
+
this.disableOnClick = false;
|
|
312
|
+
/**
|
|
313
|
+
* Define if button is loading, default to false.
|
|
314
|
+
* Trigger when button is clicked or key-up ['enter', 'space], then value change to true.
|
|
315
|
+
* It's required to reset to false when action/promise in parent is done to stop the loading state
|
|
316
|
+
*/
|
|
317
|
+
this.loading = false;
|
|
318
|
+
/**
|
|
319
|
+
* Component classes
|
|
320
|
+
*/
|
|
321
|
+
this.classCollection = new index_es.Ge(['mg-c-button']);
|
|
280
322
|
/**
|
|
281
323
|
* Trigger actions onClick event
|
|
282
324
|
* @param event - click event
|
|
@@ -313,16 +355,18 @@ const MgButton = class {
|
|
|
313
355
|
this.element.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
314
356
|
}
|
|
315
357
|
};
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
this.
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
358
|
+
/**
|
|
359
|
+
* Set child `<mg-icon>` element `size` prop to follow the current `size` prop
|
|
360
|
+
*/
|
|
361
|
+
this.setIconSize = () => {
|
|
362
|
+
var _a, _b;
|
|
363
|
+
if (this.size === 'medium') {
|
|
364
|
+
(_a = this.element.querySelector('mg-icon')) === null || _a === void 0 ? void 0 : _a.removeAttribute('size');
|
|
365
|
+
}
|
|
366
|
+
else if (this.isIcon) {
|
|
367
|
+
(_b = this.element.querySelector('mg-icon')) === null || _b === void 0 ? void 0 : _b.setAttribute('size', this.size);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
326
370
|
}
|
|
327
371
|
validateVariant(newValue, oldValue) {
|
|
328
372
|
// validate new value
|
|
@@ -332,13 +376,26 @@ const MgButton = class {
|
|
|
332
376
|
this.variant = variants$3[0];
|
|
333
377
|
return;
|
|
334
378
|
}
|
|
335
|
-
throw new Error(`<mg-button> prop "variant" must be one of: ${variants$3.join(', ')}. Passed value: ${index_es.
|
|
379
|
+
throw new Error(`<mg-button> prop "variant" must be one of: ${variants$3.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
if (oldValue !== undefined) {
|
|
383
|
+
this.classCollection.delete(`mg-c-button--${oldValue}`);
|
|
384
|
+
}
|
|
385
|
+
this.classCollection.add(`mg-c-button--${newValue}`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
validateSize(newValue, oldValue) {
|
|
389
|
+
// validate new value
|
|
390
|
+
if (!sizes$2.includes(newValue)) {
|
|
391
|
+
throw new Error(`<mg-button> prop "size" must be one of: ${sizes$2.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
336
392
|
}
|
|
337
393
|
else {
|
|
338
394
|
if (oldValue !== undefined) {
|
|
339
395
|
this.classCollection.delete(`mg-c-button--${oldValue}`);
|
|
340
396
|
}
|
|
341
397
|
this.classCollection.add(`mg-c-button--${newValue}`);
|
|
398
|
+
this.setIconSize();
|
|
342
399
|
}
|
|
343
400
|
}
|
|
344
401
|
validateFullWidth(newValue) {
|
|
@@ -370,6 +427,9 @@ const MgButton = class {
|
|
|
370
427
|
// emit value update
|
|
371
428
|
this.disabledChange.emit(isDisabled);
|
|
372
429
|
}
|
|
430
|
+
watchIsIcon() {
|
|
431
|
+
this.setIconSize();
|
|
432
|
+
}
|
|
373
433
|
loadingHandler(newValue) {
|
|
374
434
|
// we add loading style if it newvalue is true else we remove it
|
|
375
435
|
if (newValue) {
|
|
@@ -385,9 +445,11 @@ const MgButton = class {
|
|
|
385
445
|
componentWillLoad() {
|
|
386
446
|
this.validateVariant(this.variant);
|
|
387
447
|
this.validateFullWidth(this.fullWidth);
|
|
448
|
+
this.validateSize(this.size);
|
|
449
|
+
this.watchIsIcon();
|
|
388
450
|
if (this.isIcon) {
|
|
389
451
|
this.classCollection.add(`mg-c-button--icon`);
|
|
390
|
-
if (!index_es.
|
|
452
|
+
if (!index_es.ye(this.label)) {
|
|
391
453
|
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
392
454
|
}
|
|
393
455
|
}
|
|
@@ -399,7 +461,7 @@ const MgButton = class {
|
|
|
399
461
|
* Add listners
|
|
400
462
|
*/
|
|
401
463
|
componentDidLoad() {
|
|
402
|
-
index_es.
|
|
464
|
+
index_es.et(() => {
|
|
403
465
|
var _a;
|
|
404
466
|
const closestForm = this.element.closest('form') || ((_a = this.element.closest('mg-form')) === null || _a === void 0 ? void 0 : _a.shadowRoot.querySelector('form'));
|
|
405
467
|
// submit buttons should trigger form submition;
|
|
@@ -416,13 +478,15 @@ const MgButton = class {
|
|
|
416
478
|
*/
|
|
417
479
|
render() {
|
|
418
480
|
var _a;
|
|
419
|
-
return (index.h(index.Host, { key: '
|
|
481
|
+
return (index.h(index.Host, { key: 'a56efb7c3e49a4aadf6751b10bacb39f20c260df', role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": (_a = this.disabled) === null || _a === void 0 ? void 0 : _a.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, index.h("div", { key: '2d47d068d188161b603b26117256d0e828393348', class: this.classCollection.join() }, this.loading && index.h("mg-icon", { key: 'ba84820c70834f1e345af506265222340659f8ec', icon: "loader", spin: true }), index.h("div", { key: 'db6c3437d5de7f828cca7df9d83670de9d3a8ed6', class: "mg-c-button__content" }, index.h("slot", { key: 'b00f76d92e1e2f9e4dd834bf41419c68c2635d1a' })))));
|
|
420
482
|
}
|
|
421
483
|
get element() { return index.getElement(this); }
|
|
422
484
|
static get watchers() { return {
|
|
423
485
|
"variant": ["validateVariant"],
|
|
486
|
+
"size": ["validateSize"],
|
|
424
487
|
"fullWidth": ["validateFullWidth"],
|
|
425
488
|
"disabled": ["disabledHandler"],
|
|
489
|
+
"isIcon": ["watchIsIcon"],
|
|
426
490
|
"loading": ["loadingHandler"]
|
|
427
491
|
}; }
|
|
428
492
|
};
|
|
@@ -443,7 +507,7 @@ const MgCard = class {
|
|
|
443
507
|
* @returns HTML Element
|
|
444
508
|
*/
|
|
445
509
|
render() {
|
|
446
|
-
return (index.h("div", { key: '
|
|
510
|
+
return (index.h("div", { key: 'e59cabb09dbc28c148770b57de98f130c4479b75', class: "mg-c-card" }, index.h("slot", { key: 'b6e679317bddd23e73443c601992b7b344d6dc72' })));
|
|
447
511
|
}
|
|
448
512
|
};
|
|
449
513
|
MgCard.style = MgCardStyle0;
|
|
@@ -454,18 +518,19 @@ const MgCharacterLeftStyle0 = mgCharacterLeftCss;
|
|
|
454
518
|
const MgCharacterLeft = class {
|
|
455
519
|
constructor(hostRef) {
|
|
456
520
|
index.registerInstance(this, hostRef);
|
|
457
|
-
|
|
521
|
+
/**
|
|
522
|
+
* Sets the characters to count
|
|
523
|
+
*/
|
|
458
524
|
this.characters = '';
|
|
459
|
-
this.maxlength = undefined;
|
|
460
525
|
}
|
|
461
526
|
watchIdentifier(newValue) {
|
|
462
|
-
if (newValue !== undefined && !index_es.
|
|
463
|
-
console.error(`<mg-character-left> prop "identifier" value is invalid. Passed value: ${index_es.
|
|
527
|
+
if (newValue !== undefined && !index_es.Ie(newValue)) {
|
|
528
|
+
console.error(`<mg-character-left> prop "identifier" value is invalid. Passed value: ${index_es.Je(newValue)}.`);
|
|
464
529
|
}
|
|
465
530
|
}
|
|
466
531
|
validateMaxlength(newValue) {
|
|
467
532
|
if (typeof newValue !== 'number') {
|
|
468
|
-
throw new Error(`<mg-character-left> prop "maxlength" is required and must be a number. Passed value: ${index_es.
|
|
533
|
+
throw new Error(`<mg-character-left> prop "maxlength" is required and must be a number. Passed value: ${index_es.Je(newValue)}.`);
|
|
469
534
|
}
|
|
470
535
|
}
|
|
471
536
|
/*************
|
|
@@ -484,7 +549,7 @@ const MgCharacterLeft = class {
|
|
|
484
549
|
* @returns HTML Element
|
|
485
550
|
*/
|
|
486
551
|
render() {
|
|
487
|
-
return (index.h("span", { key: '
|
|
552
|
+
return (index.h("span", { key: '38d0a5617735f7f451d8f07f7e4840ccc2539d6b', id: this.identifier, "aria-live": "polite" }, index.h("span", { key: '382dc20170c5285afdc0c73a76f5797703ffdf9a', "aria-hidden": "true" }, this.maxlength - this.characters.length, "/", this.maxlength), index.h("span", { key: '8f57b75c08c3da4353f194dc174dff4a3f7e06e4', class: "mg-u-visually-hidden" }, this.messages.nbCharLeft.replace('{counter}', this.maxlength - this.characters.length))));
|
|
488
553
|
}
|
|
489
554
|
get element() { return index.getElement(this); }
|
|
490
555
|
static get watchers() { return {
|
|
@@ -501,19 +566,23 @@ const MgDetails = class {
|
|
|
501
566
|
constructor(hostRef) {
|
|
502
567
|
index.registerInstance(this, hostRef);
|
|
503
568
|
this.expandedChange = index.createEvent(this, "expanded-change", 7);
|
|
569
|
+
/**
|
|
570
|
+
* Hide summary element
|
|
571
|
+
*/
|
|
572
|
+
this.hideSummary = false;
|
|
573
|
+
/**
|
|
574
|
+
* Define if details are diplayed
|
|
575
|
+
*/
|
|
576
|
+
this.expanded = false;
|
|
504
577
|
/**
|
|
505
578
|
* Handle details toggle
|
|
506
579
|
*/
|
|
507
580
|
this.handleToggle = () => {
|
|
508
581
|
this.expanded = this.details.open;
|
|
509
582
|
};
|
|
510
|
-
this.toggleClosed = undefined;
|
|
511
|
-
this.toggleOpened = undefined;
|
|
512
|
-
this.hideSummary = false;
|
|
513
|
-
this.expanded = false;
|
|
514
583
|
}
|
|
515
584
|
validateTitles(newValue) {
|
|
516
|
-
if (!index_es.
|
|
585
|
+
if (!index_es.ye(newValue)) {
|
|
517
586
|
throw new Error(`<mg-details> prop "toggleClosed" and "toggleOpened" is required and must be a valid string. Passed value: "toggleClosed='${this.toggleClosed}'" and "toggleOpened='${this.toggleOpened}'".`);
|
|
518
587
|
}
|
|
519
588
|
}
|
|
@@ -535,7 +604,7 @@ const MgDetails = class {
|
|
|
535
604
|
* @returns HTML Element
|
|
536
605
|
*/
|
|
537
606
|
render() {
|
|
538
|
-
return (index.h("details", { key: '
|
|
607
|
+
return (index.h("details", { key: '88fc8b0e86b70ba906ee85b41c2fcc3cb628a9e3', class: "mg-c-details", onToggle: this.handleToggle, open: this.expanded, ref: (el) => (this.details = el) }, index.h("summary", { key: '54b17765416f8f48df9dbdf845fd17b4512a6f8f' }, index.h("slot", { key: 'c6a873a83bb7a83ee056cb0d65d92f41241c4776', name: "summary" }), index.h("span", { key: '9cd5700ebfdd142c3b23ef603a2ee857c9361259', class: "mg-c-details__toggle" }, index.h("mg-icon", { key: '1d24c1a83a002f2a9cb8d61324ab7f46a189190f', icon: "chevron-up", class: { 'mg-c-details__toggle-icon': true, 'mg-c-details__toggle-icon--reverse': !this.expanded } }), index.h("span", { key: 'ee3ac65c4dcf801183b786a739f99c00e90192e7', class: { 'mg-u-visually-hidden': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), index.h("div", { key: '8c30ce444d7c83d022ac29ef5a2fcccfd9f534ea', class: "mg-c-details__details" }, index.h("slot", { key: 'cfefe3169934e4fd5e3c539e8f0482ad6a4e082b', name: "details" }))));
|
|
539
608
|
}
|
|
540
609
|
static get watchers() { return {
|
|
541
610
|
"toggleClosed": ["validateTitles"],
|
|
@@ -551,6 +620,12 @@ const MgDividerStyle0 = mgDividerCss;
|
|
|
551
620
|
const MgDivider = class {
|
|
552
621
|
constructor(hostRef) {
|
|
553
622
|
index.registerInstance(this, hostRef);
|
|
623
|
+
/**************
|
|
624
|
+
* Decorators *
|
|
625
|
+
**************/
|
|
626
|
+
/**
|
|
627
|
+
* Define component size
|
|
628
|
+
*/
|
|
554
629
|
this.fullWidth = false;
|
|
555
630
|
}
|
|
556
631
|
/**
|
|
@@ -558,7 +633,7 @@ const MgDivider = class {
|
|
|
558
633
|
* @returns HTML Element
|
|
559
634
|
*/
|
|
560
635
|
render() {
|
|
561
|
-
return (index.h("div", { key: '
|
|
636
|
+
return (index.h("div", { key: '60b987cb329c6db14c2cc4a665e7f32b2696a3ee', class: {
|
|
562
637
|
'mg-c-divider': true,
|
|
563
638
|
'mg-c-divider--full-width': this.fullWidth,
|
|
564
639
|
} }));
|
|
@@ -586,6 +661,28 @@ const MgForm = class {
|
|
|
586
661
|
// Classes
|
|
587
662
|
this.classAllRequired = 'mg-c-form--all-required';
|
|
588
663
|
this.classLabelOnTop = 'mg-c-form--label-on-top';
|
|
664
|
+
/**
|
|
665
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
666
|
+
* If not set, it will be created.
|
|
667
|
+
*/
|
|
668
|
+
this.identifier = index_es.ze('mg-form');
|
|
669
|
+
/**
|
|
670
|
+
* Input name
|
|
671
|
+
* If not set the value equals the identifier
|
|
672
|
+
*/
|
|
673
|
+
this.name = this.identifier;
|
|
674
|
+
/**
|
|
675
|
+
* Define if form is readonly
|
|
676
|
+
*/
|
|
677
|
+
this.readonly = false;
|
|
678
|
+
/**
|
|
679
|
+
* Define if form is disabled
|
|
680
|
+
*/
|
|
681
|
+
this.disabled = false;
|
|
682
|
+
/**
|
|
683
|
+
* Component classes
|
|
684
|
+
*/
|
|
685
|
+
this.classCollection = new index_es.Ge(['mg-c-form']);
|
|
589
686
|
/**
|
|
590
687
|
* Define required message based on mg-inputs required elements
|
|
591
688
|
*/
|
|
@@ -671,31 +768,20 @@ const MgForm = class {
|
|
|
671
768
|
}
|
|
672
769
|
});
|
|
673
770
|
};
|
|
674
|
-
this.identifier = index_es.qe('mg-form');
|
|
675
|
-
this.name = this.identifier;
|
|
676
|
-
this.readonly = false;
|
|
677
|
-
this.requiredMessage = undefined;
|
|
678
|
-
this.ariaRole = undefined;
|
|
679
|
-
this.labelOnTop = undefined;
|
|
680
|
-
this.disabled = false;
|
|
681
|
-
this.valid = undefined;
|
|
682
|
-
this.invalid = undefined;
|
|
683
|
-
this.classCollection = new index_es.Xe(['mg-c-form']);
|
|
684
|
-
this.requiredMessageText = undefined;
|
|
685
771
|
}
|
|
686
772
|
watchIdentifier(newValue) {
|
|
687
|
-
if (!index_es.
|
|
688
|
-
console.error(`<mg-form> prop "identifier" value is invalid. Passed value: ${index_es.
|
|
773
|
+
if (!index_es.Ie(newValue)) {
|
|
774
|
+
console.error(`<mg-form> prop "identifier" value is invalid. Passed value: ${index_es.Je(newValue)}.`);
|
|
689
775
|
}
|
|
690
776
|
}
|
|
691
777
|
validateRequiredMessage(newValue) {
|
|
692
778
|
if (newValue && !requiredMessageStatus.includes(newValue)) {
|
|
693
|
-
throw new Error(`<mg-form> prop "requiredMessage" must be one of: ${requiredMessageStatus.join(', ')}. Passed value: ${index_es.
|
|
779
|
+
throw new Error(`<mg-form> prop "requiredMessage" must be one of: ${requiredMessageStatus.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
694
780
|
}
|
|
695
781
|
}
|
|
696
782
|
validateAriaRole(newValue) {
|
|
697
783
|
if (newValue && !roles.includes(newValue)) {
|
|
698
|
-
throw new Error(`<mg-form> prop "ariaRole" must be one of: ${roles.join(', ')}. Passed value: ${index_es.
|
|
784
|
+
throw new Error(`<mg-form> prop "ariaRole" must be one of: ${roles.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
699
785
|
}
|
|
700
786
|
}
|
|
701
787
|
handlelabelOnTop(newValue) {
|
|
@@ -771,17 +857,20 @@ const MgForm = class {
|
|
|
771
857
|
*/
|
|
772
858
|
componentDidLoad() {
|
|
773
859
|
// Update mgInputs when mgForm content change
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
860
|
+
const observerOptions = { childList: true, subtree: true };
|
|
861
|
+
new MutationObserver((mutations) => {
|
|
862
|
+
if (mutations.some(mutation => Object.keys(observerOptions).includes(mutation.type))) {
|
|
863
|
+
this.setMgInputs();
|
|
864
|
+
this.checkValidity();
|
|
865
|
+
}
|
|
866
|
+
}).observe(this.element, observerOptions);
|
|
778
867
|
}
|
|
779
868
|
/**
|
|
780
869
|
* Render
|
|
781
870
|
* @returns HTML Element
|
|
782
871
|
*/
|
|
783
872
|
render() {
|
|
784
|
-
return (index.h("form", { key: '
|
|
873
|
+
return (index.h("form", { key: 'e61304b43787fba050014fd223f82e36aa76a133', class: this.classCollection.join(), id: this.identifier, name: this.name, onSubmit: this.handleFormSubmit, role: this.ariaRole }, this.requiredMessageText && index.h("p", { key: '4ff8cc35336c0943584b717c6c5717fb517b4301', innerHTML: this.requiredMessageText }), index.h("slot", { key: '214cbf3473b2bb00534b315e4faae164e07a14a4' }), !this.readonly && !this.disabled && index.h("slot", { key: 'db314dd5d606da7dc5fce4c8663f4064586b34be', name: "actions" })));
|
|
785
874
|
}
|
|
786
875
|
get element() { return index.getElement(this); }
|
|
787
876
|
static get watchers() { return {
|
|
@@ -816,6 +905,18 @@ const MgIconStyle0 = mgIconCss;
|
|
|
816
905
|
const MgIcon = class {
|
|
817
906
|
constructor(hostRef) {
|
|
818
907
|
index.registerInstance(this, hostRef);
|
|
908
|
+
/**
|
|
909
|
+
* Define icon size
|
|
910
|
+
*/
|
|
911
|
+
this.size = 'medium';
|
|
912
|
+
/**
|
|
913
|
+
* Make the icon spin
|
|
914
|
+
*/
|
|
915
|
+
this.spin = false;
|
|
916
|
+
/**
|
|
917
|
+
* Component classes
|
|
918
|
+
*/
|
|
919
|
+
this.classCollection = new index_es.Ge(['mg-c-icon']);
|
|
819
920
|
/**
|
|
820
921
|
* Method to set default varianStyle props
|
|
821
922
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
@@ -836,16 +937,10 @@ const MgIcon = class {
|
|
|
836
937
|
this.svg.setAttribute('focusable', 'false');
|
|
837
938
|
this.svg.setAttribute('class', this.classCollection.join());
|
|
838
939
|
};
|
|
839
|
-
this.icon = undefined;
|
|
840
|
-
this.size = 'medium';
|
|
841
|
-
this.variant = undefined;
|
|
842
|
-
this.variantStyle = undefined;
|
|
843
|
-
this.spin = false;
|
|
844
|
-
this.classCollection = new index_es.Xe(['mg-c-icon']);
|
|
845
940
|
}
|
|
846
941
|
validateIcon(newValue, oldValue) {
|
|
847
942
|
if (!Object.keys(icons).includes(newValue))
|
|
848
|
-
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}. Passed value: ${index_es.
|
|
943
|
+
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
849
944
|
else {
|
|
850
945
|
if (oldValue !== undefined)
|
|
851
946
|
this.classCollection.delete(`mg-c-icon--${oldValue}`);
|
|
@@ -855,7 +950,7 @@ const MgIcon = class {
|
|
|
855
950
|
}
|
|
856
951
|
validateSize(newValue, oldValue) {
|
|
857
952
|
if (!sizes$1.includes(newValue))
|
|
858
|
-
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes$1.join(', ')}. Passed value: ${index_es.
|
|
953
|
+
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes$1.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
859
954
|
else {
|
|
860
955
|
if (oldValue !== undefined)
|
|
861
956
|
this.classCollection.delete(`mg-c-icon--size-${oldValue}`);
|
|
@@ -865,7 +960,7 @@ const MgIcon = class {
|
|
|
865
960
|
validateVariant(newValue, oldValue) {
|
|
866
961
|
if (newValue !== undefined) {
|
|
867
962
|
if (!variants$2.includes(newValue))
|
|
868
|
-
throw new Error(`<mg-icon> prop "variant" must be one of: ${variants$2.join(', ')}. Passed value: ${index_es.
|
|
963
|
+
throw new Error(`<mg-icon> prop "variant" must be one of: ${variants$2.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
869
964
|
else {
|
|
870
965
|
this.setDefaultVariantStyle();
|
|
871
966
|
if (oldValue !== undefined)
|
|
@@ -877,7 +972,7 @@ const MgIcon = class {
|
|
|
877
972
|
validateVariantStyle(newValue, oldValue) {
|
|
878
973
|
if (newValue !== undefined) {
|
|
879
974
|
if (!variantStyles$1.includes(newValue))
|
|
880
|
-
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles$1.join(', ')}. Passed value: ${index_es.
|
|
975
|
+
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles$1.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
881
976
|
else {
|
|
882
977
|
if (oldValue !== undefined)
|
|
883
978
|
this.classCollection.delete(`mg-c-icon--variant-style-${oldValue}`);
|
|
@@ -922,13 +1017,19 @@ const MgIcon = class {
|
|
|
922
1017
|
};
|
|
923
1018
|
MgIcon.style = MgIconStyle0;
|
|
924
1019
|
|
|
925
|
-
const mgIllustratedMessageCss = "/*!\n * @prop --mg-c-illustrated-message-spacing-vertical: Defines the vertical padding of the illustrated message. Default value: `--mg-b-size-40`.\n */.mg-c-illustrated-message{display:flex;max-width:calc(60*var(--mg-b-size-8));box-sizing:border-box;flex-direction:column;justify-content:center;padding:var(--mg-c-illustrated-message-spacing-vertical) var(--mg-b-size-16);margin:auto;gap:var(--mg-b-size-32) var(--mg-b-size-64);text-align:center}.mg-c-illustrated-message__illustration{max-height:calc(23*var(--mg-b-size-8))}.mg-c-illustrated-message__illustration ::slotted([slot=illustration]){width:
|
|
1020
|
+
const mgIllustratedMessageCss = "/*!\n * @prop --mg-c-illustrated-message-spacing-vertical: Defines the vertical padding of the illustrated message. Default value: `--mg-b-size-40`.\n */.mg-c-illustrated-message{display:flex;max-width:calc(60*var(--mg-b-size-8));box-sizing:border-box;flex-direction:column;justify-content:center;padding:var(--mg-c-illustrated-message-spacing-vertical) var(--mg-b-size-16);margin:auto;gap:var(--mg-b-size-32) var(--mg-b-size-64);text-align:center}.mg-c-illustrated-message__illustration{max-height:calc(23*var(--mg-b-size-8))}.mg-c-illustrated-message__illustration ::slotted([slot=illustration]){width:100%;max-width:100%;height:auto;max-height:calc(23*var(--mg-b-size-8))}.mg-c-illustrated-message__illustration.mg-c-illustrated-message__illustration--small{max-height:var(--mg-b-size-64)}.mg-c-illustrated-message__illustration.mg-c-illustrated-message__illustration--small ::slotted([slot=illustration]){max-height:var(--mg-b-size-64)}.mg-c-illustrated-message.mg-c-illustrated-message--horizontal{max-width:unset;flex-flow:row wrap;align-items:center}.mg-c-illustrated-message.mg-c-illustrated-message--horizontal .mg-c-illustrated-message__slots,.mg-c-illustrated-message.mg-c-illustrated-message--horizontal .mg-c-illustrated-message__illustration{max-width:calc(60*var(--mg-b-size-8))}.mg-c-illustrated-message__title ::slotted([slot=title]){margin:0;font-family:var(--mg-b-font-family) !important;font-size:var(--mg-b-font-size-h2) !important;font-weight:400 !important}.mg-c-illustrated-message__details ::slotted([slot=details]){margin:var(--mg-b-size-16) 0 0}";
|
|
926
1021
|
const MgIllustratedMessageStyle0 = mgIllustratedMessageCss;
|
|
927
1022
|
|
|
928
1023
|
const MgIllustratedMessage = class {
|
|
929
1024
|
constructor(hostRef) {
|
|
930
1025
|
index.registerInstance(this, hostRef);
|
|
1026
|
+
/**
|
|
1027
|
+
* Define illustration size
|
|
1028
|
+
*/
|
|
931
1029
|
this.size = 'medium';
|
|
1030
|
+
/**
|
|
1031
|
+
* Define component orientation
|
|
1032
|
+
*/
|
|
932
1033
|
this.direction = 'vertical';
|
|
933
1034
|
}
|
|
934
1035
|
/*************
|
|
@@ -953,13 +1054,13 @@ const MgIllustratedMessage = class {
|
|
|
953
1054
|
* @returns HTML Element
|
|
954
1055
|
*/
|
|
955
1056
|
render() {
|
|
956
|
-
return (index.h("div", { key: '
|
|
1057
|
+
return (index.h("div", { key: 'ae59b32d798c888eef5f2b3464160177b7a2e9d8', class: {
|
|
957
1058
|
'mg-c-illustrated-message': true,
|
|
958
1059
|
'mg-c-illustrated-message--horizontal': this.direction === 'horizontal',
|
|
959
|
-
} }, index.h("div", { key: '
|
|
1060
|
+
} }, index.h("div", { key: '05d260716090d503dde8e0dddc79db0a5f553f0b', class: {
|
|
960
1061
|
'mg-c-illustrated-message__illustration': true,
|
|
961
1062
|
'mg-c-illustrated-message__illustration--small': this.size === 'small',
|
|
962
|
-
} }, index.h("slot", { key: '
|
|
1063
|
+
} }, index.h("slot", { key: '119f517d66d9d4fe1bbc84341fccab9db1070c06', name: "illustration" })), index.h("div", { key: 'cc00f05411b3d8103e566d01d48a6ab66438027c', class: "mg-c-illustrated-message__slots" }, index.h("div", { key: '1832b69ce391c8c018bfc3acad75ded56dc0d484', class: "mg-c-illustrated-message__title" }, index.h("slot", { key: 'd0dfb8c433246571c140797f99f434cb64c67e7e', name: "title" })), index.h("div", { key: '75b18511e74d1d4d049e698c3fb43ad4f00450c3', class: "mg-c-illustrated-message__details" }, index.h("slot", { key: '78e11fa31da149666973e03fe707e302d60f8989', name: "details" })))));
|
|
963
1064
|
}
|
|
964
1065
|
get element() { return index.getElement(this); }
|
|
965
1066
|
};
|
|
@@ -992,31 +1093,45 @@ const MgInput = class {
|
|
|
992
1093
|
this.classHasError = 'mg-c-input--has-error';
|
|
993
1094
|
this.classLabelOnTop = 'mg-c-input--label-on-top';
|
|
994
1095
|
/**
|
|
995
|
-
*
|
|
996
|
-
* @returns mg-tooltip
|
|
1096
|
+
* Define if label is visible
|
|
997
1097
|
*/
|
|
998
|
-
this.renderTooltip = () => (index.h("mg-tooltip", { identifier: `${this.identifier}-tooltip`, message: this.tooltip }, index.h("mg-icon", { icon: "info-circle" })));
|
|
999
|
-
this.identifier = undefined;
|
|
1000
|
-
this.label = undefined;
|
|
1001
|
-
this.labelOnTop = undefined;
|
|
1002
1098
|
this.labelHide = false;
|
|
1003
|
-
|
|
1099
|
+
/**
|
|
1100
|
+
* Define tooltip position
|
|
1101
|
+
*/
|
|
1004
1102
|
this.tooltipPosition = 'input';
|
|
1103
|
+
/**
|
|
1104
|
+
* Define if input is required
|
|
1105
|
+
*/
|
|
1005
1106
|
this.required = false;
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1107
|
+
/**
|
|
1108
|
+
* Element is fieldset
|
|
1109
|
+
*/
|
|
1009
1110
|
this.isFieldset = false;
|
|
1111
|
+
/**
|
|
1112
|
+
* Element is readonly
|
|
1113
|
+
*/
|
|
1010
1114
|
this.isReadonly = false;
|
|
1115
|
+
/**
|
|
1116
|
+
* Element is disabled
|
|
1117
|
+
*/
|
|
1011
1118
|
this.isDisabled = false;
|
|
1119
|
+
/**
|
|
1120
|
+
* Element is disabled
|
|
1121
|
+
*/
|
|
1012
1122
|
this.isVerticalList = false;
|
|
1123
|
+
/**
|
|
1124
|
+
* Get tooltip node
|
|
1125
|
+
* @returns mg-tooltip
|
|
1126
|
+
*/
|
|
1127
|
+
this.renderTooltip = () => (index.h("mg-tooltip", { identifier: `${this.identifier}-tooltip`, message: this.tooltip }, index.h("mg-icon", { icon: "info-circle" })));
|
|
1013
1128
|
}
|
|
1014
1129
|
watchIdentifier(newValue) {
|
|
1015
|
-
if (!index_es.
|
|
1016
|
-
throw new Error(`<mg-input> prop "identifier" is required and must be a string. Passed value: ${index_es.
|
|
1130
|
+
if (!index_es.ye(newValue)) {
|
|
1131
|
+
throw new Error(`<mg-input> prop "identifier" is required and must be a string. Passed value: ${index_es.Je(newValue)}.`);
|
|
1017
1132
|
}
|
|
1018
|
-
else if (!index_es.
|
|
1019
|
-
console.error(`<mg-input> prop "identifier" value is invalid. Passed value: ${index_es.
|
|
1133
|
+
else if (!index_es.Ie(newValue)) {
|
|
1134
|
+
console.error(`<mg-input> prop "identifier" value is invalid. Passed value: ${index_es.Je(newValue)}.`);
|
|
1020
1135
|
}
|
|
1021
1136
|
else {
|
|
1022
1137
|
this.helpTextId = `${this.identifier}-help-text`;
|
|
@@ -1038,7 +1153,7 @@ const MgInput = class {
|
|
|
1038
1153
|
}
|
|
1039
1154
|
watchTooltipPosition(newValue) {
|
|
1040
1155
|
if (!tooltipPositions.includes(newValue)) {
|
|
1041
|
-
throw new Error(`<mg-input> prop "tooltipPosition" must be one of: ${tooltipPositions.join(', ')}. Passed value: ${index_es.
|
|
1156
|
+
throw new Error(`<mg-input> prop "tooltipPosition" must be one of: ${tooltipPositions.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
1042
1157
|
}
|
|
1043
1158
|
}
|
|
1044
1159
|
watchErrorMessage(newValue) {
|
|
@@ -1081,7 +1196,10 @@ const MgInput = class {
|
|
|
1081
1196
|
ariaDescribedbyIDs.add(this.helpTextErrorId);
|
|
1082
1197
|
}
|
|
1083
1198
|
this.element.querySelectorAll('input,select,textarea,[role="switch"]').forEach(element => {
|
|
1084
|
-
|
|
1199
|
+
if (ariaDescribedbyIDs.size)
|
|
1200
|
+
element.setAttribute('aria-describedby', Array.from(ariaDescribedbyIDs).join(' '));
|
|
1201
|
+
else
|
|
1202
|
+
element.removeAttribute('aria-describedby');
|
|
1085
1203
|
});
|
|
1086
1204
|
}
|
|
1087
1205
|
/**
|
|
@@ -1102,8 +1220,8 @@ const MgInput = class {
|
|
|
1102
1220
|
*/
|
|
1103
1221
|
// eslint-disable-next-line @stencil-community/no-unused-watch
|
|
1104
1222
|
watchLabel() {
|
|
1105
|
-
if (!index_es.
|
|
1106
|
-
throw new Error(`<mg-input> prop "label" is required and must be a string. Passed value: ${index_es.
|
|
1223
|
+
if (!index_es.ye(this.label)) {
|
|
1224
|
+
throw new Error(`<mg-input> prop "label" is required and must be a string. Passed value: ${index_es.Je(this.label)}.`);
|
|
1107
1225
|
}
|
|
1108
1226
|
else {
|
|
1109
1227
|
this.watchAriaDescribedbyIDs();
|
|
@@ -1195,7 +1313,7 @@ const MgInput = class {
|
|
|
1195
1313
|
*/
|
|
1196
1314
|
render() {
|
|
1197
1315
|
const isGroup = this.isFieldset && !this.isReadonly;
|
|
1198
|
-
return (index.h(index.Host, { key: '
|
|
1316
|
+
return (index.h(index.Host, { key: '2b69235bf675e431e61261d1a4465e216675bbb2', class: this.element.classList.toString(), role: isGroup ? 'group' : undefined, "aria-labelledby": isGroup ? `${this.identifier}-title` : undefined }, index.h("div", { key: '7cbe4343e2d6ebbad943b4562c69b8e2f583fe23', class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': this.labelHide } }, index.h("slot", { key: 'af2c9482dd4a66c62047edc8fecef17efeeb6537', name: this.slotLabel }), this.tooltip && (this.tooltipPosition === 'label' || this.labelOnTop) && !this.labelHide && this.renderTooltip()), index.h("div", { key: 'b48eaa21ea25c08b3a04c1f0d22c9c59bd535e26', class: "mg-c-input__input-container" }, index.h("div", { key: '3f61784438dd63b5ccf7fd8cbb50b51ae3ac982e', class: "mg-c-input__input" }, index.h("slot", { key: '05bed4a07201b7fe65c82886ebf8ac63b004be4e' }), this.tooltip && !this.labelOnTop && (this.tooltipPosition === 'input' || this.labelHide) && this.renderTooltip()), this.helptextMessageSlotElement && (index.h("div", { key: 'b27e2ae017422b7408780521a1d38f9b094c341c', class: "mg-c-input__help-text" }, index.h("slot", { key: '3798d38bcbdabfeec3b0e9f97c2074734ffd7149', name: this.slotHelpText }))), !this.isDisabled && this.errorMessage && (index.h("div", { key: '70f4ea8fda4fb884934e3d3c9d34c67eb6db9ab9', class: "mg-c-input__error", "aria-live": "assertive" }, index.h("slot", { key: '90c13c82e7b7a9c820bcab5cdad7f09ce95b8512', name: this.slotError }))))));
|
|
1199
1317
|
}
|
|
1200
1318
|
get element() { return index.getElement(this); }
|
|
1201
1319
|
static get watchers() { return {
|
|
@@ -1267,6 +1385,55 @@ const MgInputCheckbox = class {
|
|
|
1267
1385
|
this.searchStart = 10;
|
|
1268
1386
|
// popover variables
|
|
1269
1387
|
this.hasOpenedPopover = false;
|
|
1388
|
+
/**
|
|
1389
|
+
* Define input name
|
|
1390
|
+
* If not set the value equals the identifier
|
|
1391
|
+
*/
|
|
1392
|
+
this.name = this.identifier;
|
|
1393
|
+
/**
|
|
1394
|
+
* Define if label is visible
|
|
1395
|
+
*/
|
|
1396
|
+
this.labelHide = false;
|
|
1397
|
+
/**
|
|
1398
|
+
* Define if inputs are display verticaly
|
|
1399
|
+
*/
|
|
1400
|
+
this.inputVerticalList = false;
|
|
1401
|
+
/**
|
|
1402
|
+
* Define if mg-input-checkbox is required
|
|
1403
|
+
*/
|
|
1404
|
+
this.required = false;
|
|
1405
|
+
/**
|
|
1406
|
+
* Define if mg-input-checkbox is readonly
|
|
1407
|
+
*/
|
|
1408
|
+
this.readonly = false;
|
|
1409
|
+
/**
|
|
1410
|
+
* Define if input is disabled
|
|
1411
|
+
*/
|
|
1412
|
+
this.disabled = false;
|
|
1413
|
+
/**
|
|
1414
|
+
* Define tooltip position
|
|
1415
|
+
*/
|
|
1416
|
+
this.tooltipPosition = 'input';
|
|
1417
|
+
/**
|
|
1418
|
+
* Component classes
|
|
1419
|
+
*/
|
|
1420
|
+
this.classCollection = new index_es.Ge([this.baseClassName, classFieldset]);
|
|
1421
|
+
/**
|
|
1422
|
+
* Formated value to display in list
|
|
1423
|
+
*/
|
|
1424
|
+
this.checkboxItems = [];
|
|
1425
|
+
/**
|
|
1426
|
+
* Search value query
|
|
1427
|
+
*/
|
|
1428
|
+
this.searchValue = '';
|
|
1429
|
+
/**
|
|
1430
|
+
* Search current page
|
|
1431
|
+
*/
|
|
1432
|
+
this.searchResults = [];
|
|
1433
|
+
/**
|
|
1434
|
+
* Select values button text local key
|
|
1435
|
+
*/
|
|
1436
|
+
this.selectValuesButtonKey = 'editButton';
|
|
1270
1437
|
/**
|
|
1271
1438
|
* Handle input event
|
|
1272
1439
|
* @param event - input event
|
|
@@ -1368,7 +1535,7 @@ const MgInputCheckbox = class {
|
|
|
1368
1535
|
* Method to update searchResults
|
|
1369
1536
|
*/
|
|
1370
1537
|
this.updateSearchResults = () => {
|
|
1371
|
-
this.searchResults = this.checkboxItems.filter(item => index_es.
|
|
1538
|
+
this.searchResults = this.checkboxItems.filter(item => index_es.Ve(item.title).includes(index_es.Ve(this.searchValue)));
|
|
1372
1539
|
};
|
|
1373
1540
|
/**
|
|
1374
1541
|
* Method to validate if one of inputs value is checked id required
|
|
@@ -1400,13 +1567,13 @@ const MgInputCheckbox = class {
|
|
|
1400
1567
|
* @returns message to display
|
|
1401
1568
|
*/
|
|
1402
1569
|
this.getSelectValuesButtonMessage = () => {
|
|
1403
|
-
if (this.selectValuesButtonKey === 'editButton' && index_es.
|
|
1570
|
+
if (this.selectValuesButtonKey === 'editButton' && index_es.ye(this.editButtonMessage)) {
|
|
1404
1571
|
return this.editButtonMessage;
|
|
1405
1572
|
}
|
|
1406
|
-
else if (this.selectValuesButtonKey === 'showButton' && index_es.
|
|
1573
|
+
else if (this.selectValuesButtonKey === 'showButton' && index_es.ye(this.showButtonMessage)) {
|
|
1407
1574
|
return this.showButtonMessage;
|
|
1408
1575
|
}
|
|
1409
|
-
else if (this.selectValuesButtonKey === 'selectButton' && index_es.
|
|
1576
|
+
else if (this.selectValuesButtonKey === 'selectButton' && index_es.ye(this.selectButtonMessage)) {
|
|
1410
1577
|
return this.selectButtonMessage;
|
|
1411
1578
|
}
|
|
1412
1579
|
else {
|
|
@@ -1455,33 +1622,6 @@ const MgInputCheckbox = class {
|
|
|
1455
1622
|
* @returns The rendered MgInputCheckboxList component.
|
|
1456
1623
|
*/
|
|
1457
1624
|
this.renderMgInputCheckboxList = () => (index.h(MgInputCheckboxList, { checkboxes: this.checkboxItems, displaySearchInput: this.displaySearchInput, messages: this.messages.input.checkbox, id: "checkboxes-list", disabled: this.disabled, name: this.name, invalid: this.invalid }));
|
|
1458
|
-
this.value = undefined;
|
|
1459
|
-
this.type = undefined;
|
|
1460
|
-
this.identifier = undefined;
|
|
1461
|
-
this.name = this.identifier;
|
|
1462
|
-
this.label = undefined;
|
|
1463
|
-
this.labelOnTop = undefined;
|
|
1464
|
-
this.labelHide = false;
|
|
1465
|
-
this.inputVerticalList = false;
|
|
1466
|
-
this.required = false;
|
|
1467
|
-
this.readonly = false;
|
|
1468
|
-
this.displaySelectedValues = undefined;
|
|
1469
|
-
this.disabled = false;
|
|
1470
|
-
this.tooltip = undefined;
|
|
1471
|
-
this.tooltipPosition = 'input';
|
|
1472
|
-
this.helpText = undefined;
|
|
1473
|
-
this.valid = undefined;
|
|
1474
|
-
this.invalid = undefined;
|
|
1475
|
-
this.editButtonMessage = undefined;
|
|
1476
|
-
this.showButtonMessage = undefined;
|
|
1477
|
-
this.selectButtonMessage = undefined;
|
|
1478
|
-
this.classCollection = new index_es.Xe([this.baseClassName, classFieldset]);
|
|
1479
|
-
this.errorMessage = undefined;
|
|
1480
|
-
this.checkboxItems = [];
|
|
1481
|
-
this.displaySearchInput = undefined;
|
|
1482
|
-
this.searchValue = '';
|
|
1483
|
-
this.searchResults = [];
|
|
1484
|
-
this.selectValuesButtonKey = 'editButton';
|
|
1485
1625
|
}
|
|
1486
1626
|
validateValue(newValue) {
|
|
1487
1627
|
if (isCheckboxItems(newValue)) {
|
|
@@ -1489,12 +1629,12 @@ const MgInputCheckbox = class {
|
|
|
1489
1629
|
this.valueChange.emit(newValue);
|
|
1490
1630
|
}
|
|
1491
1631
|
else {
|
|
1492
|
-
throw new Error(`<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem. Passed value: ${index_es.
|
|
1632
|
+
throw new Error(`<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem. Passed value: ${index_es.Je(newValue)}.`);
|
|
1493
1633
|
}
|
|
1494
1634
|
}
|
|
1495
1635
|
validateType(newValue) {
|
|
1496
1636
|
if (newValue !== undefined && !checkboxTypes.includes(newValue)) {
|
|
1497
|
-
throw new Error(`<mg-input-checkbox> prop "type" must be a CheckboxType. Passed value: ${index_es.
|
|
1637
|
+
throw new Error(`<mg-input-checkbox> prop "type" must be a CheckboxType. Passed value: ${index_es.Je(newValue)}.`);
|
|
1498
1638
|
}
|
|
1499
1639
|
else if (newValue === undefined) {
|
|
1500
1640
|
this.mode = 'auto';
|
|
@@ -1566,10 +1706,21 @@ const MgInputCheckbox = class {
|
|
|
1566
1706
|
/**
|
|
1567
1707
|
* Display input error if it exists.
|
|
1568
1708
|
*/
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1709
|
+
displayError() {
|
|
1710
|
+
// Use `Promise` as requested for stencil method
|
|
1711
|
+
// Use `requestAnimationFrame` to ensure:
|
|
1712
|
+
// - DOM is fully updated before validation
|
|
1713
|
+
// - Async operations are completed
|
|
1714
|
+
// - No timing issues with Stencil's render cycle
|
|
1715
|
+
// - Keep everything in sync both inside and outside the component
|
|
1716
|
+
return new Promise(resolve => {
|
|
1717
|
+
requestAnimationFrame(() => {
|
|
1718
|
+
this.checkValidity();
|
|
1719
|
+
this.setErrorMessage();
|
|
1720
|
+
this.hasDisplayedError = this.invalid;
|
|
1721
|
+
resolve();
|
|
1722
|
+
});
|
|
1723
|
+
});
|
|
1573
1724
|
}
|
|
1574
1725
|
/**
|
|
1575
1726
|
* Set an error and display a custom error message.
|
|
@@ -1583,7 +1734,7 @@ const MgInputCheckbox = class {
|
|
|
1583
1734
|
if (typeof valid !== 'boolean') {
|
|
1584
1735
|
throw new Error('<mg-input-checkbox> method "setError()" param "valid" must be a boolean.');
|
|
1585
1736
|
}
|
|
1586
|
-
else if (!index_es.
|
|
1737
|
+
else if (!index_es.ye(errorMessage)) {
|
|
1587
1738
|
throw new Error('<mg-input-checkbox> method "setError()" param "errorMessage" must be a string.');
|
|
1588
1739
|
}
|
|
1589
1740
|
else {
|
|
@@ -1720,7 +1871,7 @@ const MgInputCheckbox = class {
|
|
|
1720
1871
|
else {
|
|
1721
1872
|
inputContent = this.renderCheckboxMulti();
|
|
1722
1873
|
}
|
|
1723
|
-
return (index.h("mg-input", { key: '
|
|
1874
|
+
return (index.h("mg-input", { key: '08c3ca7708ff929696a83a8d7c4fe627e7651963', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, tooltip: this.tooltip, tooltipPosition: this.readonly && readonlyValue.length === 0 ? 'label' : this.tooltipPosition, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined }, inputContent));
|
|
1724
1875
|
}
|
|
1725
1876
|
get element() { return index.getElement(this); }
|
|
1726
1877
|
static get watchers() { return {
|
|
@@ -1746,6 +1897,18 @@ const MgInputCheckboxPaginated = class {
|
|
|
1746
1897
|
* Constantes *
|
|
1747
1898
|
*************/
|
|
1748
1899
|
this.offset = 10;
|
|
1900
|
+
/**
|
|
1901
|
+
* Current page
|
|
1902
|
+
*/
|
|
1903
|
+
this.currentPage = 1;
|
|
1904
|
+
/**
|
|
1905
|
+
* Define checkboxes to paginate
|
|
1906
|
+
*/
|
|
1907
|
+
this.checkboxes = [];
|
|
1908
|
+
/**
|
|
1909
|
+
* Is checked items values expanded
|
|
1910
|
+
*/
|
|
1911
|
+
this.expanded = true;
|
|
1749
1912
|
/***********
|
|
1750
1913
|
* Methods *
|
|
1751
1914
|
***********/
|
|
@@ -1781,14 +1944,6 @@ const MgInputCheckboxPaginated = class {
|
|
|
1781
1944
|
this.handleCurrentPageChange = (event) => {
|
|
1782
1945
|
this.currentPage = Number(event.detail);
|
|
1783
1946
|
};
|
|
1784
|
-
this.readonly = undefined;
|
|
1785
|
-
this.disabled = undefined;
|
|
1786
|
-
this.name = undefined;
|
|
1787
|
-
this.invalid = undefined;
|
|
1788
|
-
this.currentPage = 1;
|
|
1789
|
-
this.checkboxes = [];
|
|
1790
|
-
this.messages = undefined;
|
|
1791
|
-
this.expanded = true;
|
|
1792
1947
|
}
|
|
1793
1948
|
watchCheckboxes(newValue, oldValue) {
|
|
1794
1949
|
const pageCountNewValue = this.getPageCount(newValue);
|
|
@@ -1828,10 +1983,10 @@ const MgInputCheckboxPaginated = class {
|
|
|
1828
1983
|
* @returns HTML Element
|
|
1829
1984
|
*/
|
|
1830
1985
|
render() {
|
|
1831
|
-
const getText = (checkboxes) => (index.h("em", { key: '
|
|
1986
|
+
const getText = (checkboxes) => (index.h("em", { key: '8f20e5be81047106e04cd101385b9c6555c0c38d', class: "mg-c-input__section-header-title-label" }, `${this.messages[checkboxes.length > 1 ? 'titlePlurial' : 'title']} (${checkboxes.length})`));
|
|
1832
1987
|
const [from, to] = this.getFromToIndexes();
|
|
1833
1988
|
const itemsContainerId = `items-${this.sectionKind}-container`;
|
|
1834
|
-
return (index.h(index.Host, { key: '
|
|
1989
|
+
return (index.h(index.Host, { key: '39d0fc41abe4b537b240bdc14e80fc42cb41033d', hidden: this.checkboxes.length < 1 }, index.h("div", { key: 'fec430cfffc005a217694f9a4ba68412a6a08c7b', class: "mg-c-input__section-header" }, this.sectionKind === SectionKind.SELECTED ? (index.h("mg-button", { variant: "flat", onClick: this.handleToggleClick, "aria-controls": itemsContainerId, "aria-expanded": this.expanded.toString() }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), index.h("span", { class: "mg-c-input__section-header-title" }, getText(this.checkboxes)))) : (index.h("p", { class: "mg-c-input__section-header-title mg-c-input__section-header-title--static" }, getText(this.checkboxes))), ((this.sectionKind === SectionKind.SELECTED && this.expanded) || this.sectionKind === SectionKind.NOT_SELECTED) && (index.h("mg-tooltip", { key: 'e1b38d93875962af3024ac27e1892c040dbf9bdb', class: "mg-c-input__section-header-tootlip", message: this.messages.tooltip }, index.h("mg-button", { key: 'f593b3d5ca5bd8b3080253842a5c513709f16e3a', variant: "link", onClick: this.massActionHandler }, this.messages.action))), this.expanded && this.getPageCount(this.checkboxes) > 1 && (index.h("mg-pagination", { key: "search-pagination", totalPages: this.getPageCount(this.checkboxes), currentPage: this.currentPage, "onCurrent-page-change": this.handleCurrentPageChange, hideNavigationLabels: true, hidePageCount: true, identifier: `input-checkbox-pagination-${this.sectionKind}` }))), index.h("div", { key: '74c18984938188e2861cd79b56d919a94f32064f', hidden: !this.expanded, id: itemsContainerId, class: "mg-c-input__section-content" }, index.h(MgInputCheckboxList, { key: '15c2f6fe98d772ce5b0a0d4ec448986e91592107', checkboxes: this.getArrayRange(this.checkboxes, from, to), displaySearchInput: true, messages: this.messages, id: `items-${this.sectionKind}`, disabled: this.disabled, name: this.name, invalid: this.invalid }))));
|
|
1835
1990
|
}
|
|
1836
1991
|
static get watchers() { return {
|
|
1837
1992
|
"checkboxes": ["watchCheckboxes"]
|
|
@@ -1848,12 +2003,46 @@ const MgInputDate = class {
|
|
|
1848
2003
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
1849
2004
|
// hasDisplayedError (triggered by blur event)
|
|
1850
2005
|
this.hasDisplayedError = false;
|
|
2006
|
+
/**
|
|
2007
|
+
* Input name
|
|
2008
|
+
* If not set the value equals the identifier
|
|
2009
|
+
*/
|
|
2010
|
+
this.name = this.identifier;
|
|
2011
|
+
/**
|
|
2012
|
+
* Define if label is visible
|
|
2013
|
+
*/
|
|
2014
|
+
this.labelHide = false;
|
|
2015
|
+
/**
|
|
2016
|
+
* Define if input is required
|
|
2017
|
+
*/
|
|
2018
|
+
this.required = false;
|
|
2019
|
+
/**
|
|
2020
|
+
* Define if input is readonly
|
|
2021
|
+
*/
|
|
2022
|
+
this.readonly = false;
|
|
2023
|
+
/**
|
|
2024
|
+
* Define input maximum date
|
|
2025
|
+
* format: yyyy-mm-dd
|
|
2026
|
+
*/
|
|
2027
|
+
this.max = '9999-12-31';
|
|
2028
|
+
/**
|
|
2029
|
+
* Define if input is disabled
|
|
2030
|
+
*/
|
|
2031
|
+
this.disabled = false;
|
|
2032
|
+
/**
|
|
2033
|
+
* Define tooltip position
|
|
2034
|
+
*/
|
|
2035
|
+
this.tooltipPosition = 'input';
|
|
2036
|
+
/**
|
|
2037
|
+
* Component classes
|
|
2038
|
+
*/
|
|
2039
|
+
this.classCollection = new index_es.Ge(['mg-c-input--date']);
|
|
1851
2040
|
/**
|
|
1852
2041
|
* Method to validate date pattern string
|
|
1853
2042
|
* @param value - value to test
|
|
1854
2043
|
* @returns truthy when value match the pattern
|
|
1855
2044
|
*/
|
|
1856
|
-
this.isValidPattern = (value) => index_es.
|
|
2045
|
+
this.isValidPattern = (value) => index_es.ye(value) && index_es.Be.test(value);
|
|
1857
2046
|
/**
|
|
1858
2047
|
* Format help text to display
|
|
1859
2048
|
* @param helpText - help text format
|
|
@@ -1861,10 +2050,10 @@ const MgInputDate = class {
|
|
|
1861
2050
|
*/
|
|
1862
2051
|
this.formatHelpText = (helpText) => {
|
|
1863
2052
|
const defaultHelpTextVariable = '{defaultHelpText}';
|
|
1864
|
-
let text = index_es.
|
|
2053
|
+
let text = index_es.ye(helpText) ? helpText : this.messages.input.date.helpText;
|
|
1865
2054
|
if (text.includes(defaultHelpTextVariable))
|
|
1866
2055
|
text = text.replace(defaultHelpTextVariable, this.formatHelpText(this.messages.input.date.helpText));
|
|
1867
|
-
return text.replace('{pattern}', this.renderPattern()).replace('{date}', index_es.
|
|
2056
|
+
return text.replace('{pattern}', this.renderPattern()).replace('{date}', index_es.Pe(index_es.ct(new Date('2023-12-24')), this.systemLocale));
|
|
1868
2057
|
};
|
|
1869
2058
|
/**
|
|
1870
2059
|
* Handle input event
|
|
@@ -1895,7 +2084,7 @@ const MgInputDate = class {
|
|
|
1895
2084
|
// when we reset the field we need to test a blank value.
|
|
1896
2085
|
if (['Delete', 'Backspace'].includes(event.key)) {
|
|
1897
2086
|
event.preventDefault();
|
|
1898
|
-
this.value =
|
|
2087
|
+
this.value = null;
|
|
1899
2088
|
this.checkValidity();
|
|
1900
2089
|
if (this.hasDisplayedError) {
|
|
1901
2090
|
this.setErrorMessage();
|
|
@@ -1906,7 +2095,7 @@ const MgInputDate = class {
|
|
|
1906
2095
|
* Check if input is valid
|
|
1907
2096
|
*/
|
|
1908
2097
|
this.checkValidity = () => {
|
|
1909
|
-
this.setValidity(this.readonly || this.disabled || (this.input.checkValidity() && (
|
|
2098
|
+
this.setValidity(this.readonly || this.disabled || (this.input.checkValidity() && (this.value === null || this.isValidPattern(this.value))));
|
|
1910
2099
|
};
|
|
1911
2100
|
/**
|
|
1912
2101
|
* get input error code
|
|
@@ -1915,14 +2104,14 @@ const MgInputDate = class {
|
|
|
1915
2104
|
this.getInputError = () => {
|
|
1916
2105
|
var _a;
|
|
1917
2106
|
let inputError = null;
|
|
2107
|
+
// bad input or pattern
|
|
2108
|
+
if (this.input.validity.badInput || (this.value && !this.isValidPattern(this.value))) {
|
|
2109
|
+
inputError = 'badInput';
|
|
2110
|
+
}
|
|
1918
2111
|
// required
|
|
1919
|
-
if (this.input.validity.valueMissing) {
|
|
2112
|
+
else if (this.input.validity.valueMissing) {
|
|
1920
2113
|
inputError = 'required';
|
|
1921
2114
|
}
|
|
1922
|
-
// pattern
|
|
1923
|
-
else if (this.value && !this.isValidPattern(this.value)) {
|
|
1924
|
-
inputError = 'badInput';
|
|
1925
|
-
}
|
|
1926
2115
|
// min & max
|
|
1927
2116
|
else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== '9999-12-31') {
|
|
1928
2117
|
inputError = 'minMax';
|
|
@@ -1956,8 +2145,8 @@ const MgInputDate = class {
|
|
|
1956
2145
|
// min, max & minMax
|
|
1957
2146
|
else if (['min', 'max', 'minMax'].includes(inputError)) {
|
|
1958
2147
|
this.errorMessage = this.messages.errors.date[inputError]
|
|
1959
|
-
.replace('{min}', index_es.
|
|
1960
|
-
.replace('{max}', index_es.
|
|
2148
|
+
.replace('{min}', index_es.Pe(this.min, this.systemLocale))
|
|
2149
|
+
.replace('{max}', index_es.Pe(this.max, this.systemLocale));
|
|
1961
2150
|
}
|
|
1962
2151
|
// wrong date format
|
|
1963
2152
|
// element.validity.badInput is default error message
|
|
@@ -1971,40 +2160,26 @@ const MgInputDate = class {
|
|
|
1971
2160
|
* @returns translated html pattern
|
|
1972
2161
|
*/
|
|
1973
2162
|
this.renderPattern = () => {
|
|
1974
|
-
let patternLocal = index_es.
|
|
2163
|
+
let patternLocal = index_es.at(this.systemLocale);
|
|
1975
2164
|
for (const key in this.messages.input.date.pattern) {
|
|
1976
2165
|
patternLocal = patternLocal.replace(key, this.messages.input.date.pattern[key]);
|
|
1977
2166
|
}
|
|
1978
2167
|
return `<span aria-hidden="true">${patternLocal}</span><span class="mg-u-visually-hidden">${[...patternLocal].join(' ')}</span>`;
|
|
1979
2168
|
};
|
|
1980
|
-
this.value = undefined;
|
|
1981
|
-
this.identifier = undefined;
|
|
1982
|
-
this.name = this.identifier;
|
|
1983
|
-
this.label = undefined;
|
|
1984
|
-
this.labelOnTop = undefined;
|
|
1985
|
-
this.labelHide = false;
|
|
1986
|
-
this.required = false;
|
|
1987
|
-
this.readonly = false;
|
|
1988
|
-
this.min = undefined;
|
|
1989
|
-
this.max = '9999-12-31';
|
|
1990
|
-
this.disabled = false;
|
|
1991
|
-
this.tooltip = undefined;
|
|
1992
|
-
this.tooltipPosition = 'input';
|
|
1993
|
-
this.helpText = undefined;
|
|
1994
|
-
this.valid = undefined;
|
|
1995
|
-
this.invalid = undefined;
|
|
1996
|
-
this.classCollection = new index_es.Xe(['mg-c-input--date']);
|
|
1997
|
-
this.errorMessage = undefined;
|
|
1998
2169
|
}
|
|
1999
2170
|
validateValue(newValue) {
|
|
2000
2171
|
// When the input is not fully completed or has been cleared, the value becomes an empty string.
|
|
2001
|
-
if (
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2172
|
+
if (['', undefined].includes(newValue)) {
|
|
2173
|
+
// need to force value update to `null` to prevent extra render
|
|
2174
|
+
// - `''` is not a valide value
|
|
2175
|
+
// - `undefined` is not allowed in CustomEvent['detail']
|
|
2176
|
+
this.value = null;
|
|
2006
2177
|
}
|
|
2007
|
-
else if (
|
|
2178
|
+
else if (newValue && !index_es.ye(newValue)) {
|
|
2179
|
+
// check value validity
|
|
2180
|
+
throw new Error(`<mg-input-date> props 'value' must be a valid string. Passed value: ${index_es.Je(newValue)}.`);
|
|
2181
|
+
}
|
|
2182
|
+
else if (newValue === null || this.isValidPattern(newValue)) {
|
|
2008
2183
|
this.valueChange.emit(newValue);
|
|
2009
2184
|
}
|
|
2010
2185
|
else {
|
|
@@ -2019,7 +2194,7 @@ const MgInputDate = class {
|
|
|
2019
2194
|
}
|
|
2020
2195
|
validateMinMax(newValue) {
|
|
2021
2196
|
if (newValue && !this.isValidPattern(newValue)) {
|
|
2022
|
-
throw new Error(`<mg-input-date> props 'min/max' doesn't match pattern: 'yyyy-mm-dd'. Passed value: ${index_es.
|
|
2197
|
+
throw new Error(`<mg-input-date> props 'min/max' doesn't match pattern: 'yyyy-mm-dd'. Passed value: ${index_es.Je(newValue)}.`);
|
|
2023
2198
|
}
|
|
2024
2199
|
}
|
|
2025
2200
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -2041,10 +2216,21 @@ const MgInputDate = class {
|
|
|
2041
2216
|
/**
|
|
2042
2217
|
* Display input error if it exists.
|
|
2043
2218
|
*/
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2219
|
+
displayError() {
|
|
2220
|
+
// Use `Promise` as requested for stencil method
|
|
2221
|
+
// Use `requestAnimationFrame` to ensure:
|
|
2222
|
+
// - DOM is fully updated before validation
|
|
2223
|
+
// - Async operations are completed
|
|
2224
|
+
// - No timing issues with Stencil's render cycle
|
|
2225
|
+
// - Keep everything in sync both inside and outside the component
|
|
2226
|
+
return new Promise(resolve => {
|
|
2227
|
+
requestAnimationFrame(() => {
|
|
2228
|
+
this.checkValidity();
|
|
2229
|
+
this.setErrorMessage();
|
|
2230
|
+
this.hasDisplayedError = this.invalid;
|
|
2231
|
+
resolve();
|
|
2232
|
+
});
|
|
2233
|
+
});
|
|
2048
2234
|
}
|
|
2049
2235
|
/**
|
|
2050
2236
|
* Set an error and display a custom error message.
|
|
@@ -2058,7 +2244,7 @@ const MgInputDate = class {
|
|
|
2058
2244
|
if (typeof valid !== 'boolean') {
|
|
2059
2245
|
throw new Error('<mg-input-date> method "setError()" param "valid" must be a boolean.');
|
|
2060
2246
|
}
|
|
2061
|
-
else if (!index_es.
|
|
2247
|
+
else if (!index_es.ye(errorMessage)) {
|
|
2062
2248
|
throw new Error('<mg-input-date> method "setError()" param "errorMessage" must be a string.');
|
|
2063
2249
|
}
|
|
2064
2250
|
else {
|
|
@@ -2072,7 +2258,7 @@ const MgInputDate = class {
|
|
|
2072
2258
|
*/
|
|
2073
2259
|
async reset() {
|
|
2074
2260
|
if (!this.readonly) {
|
|
2075
|
-
this.value =
|
|
2261
|
+
this.value = null;
|
|
2076
2262
|
this.checkValidity();
|
|
2077
2263
|
this.invalid = false;
|
|
2078
2264
|
this.errorMessage = undefined;
|
|
@@ -2124,7 +2310,7 @@ const MgInputDate = class {
|
|
|
2124
2310
|
* @returns HTML Element
|
|
2125
2311
|
*/
|
|
2126
2312
|
render() {
|
|
2127
|
-
return (index.h("mg-input", { key: '
|
|
2313
|
+
return (index.h("mg-input", { key: '09d07883b178cd1196c2be110c8fcfdde8fef01d', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === null ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly ? (this.value && index.h("b", { class: "mg-c-input__readonly-value" }, index_es.Pe(this.value, this.locale))) : (index.h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, ref: (el) => {
|
|
2128
2314
|
if (el !== null)
|
|
2129
2315
|
this.input = el;
|
|
2130
2316
|
} }))));
|
|
@@ -2147,7 +2333,7 @@ MgInputDate.style = MgInputDateStyle0;
|
|
|
2147
2333
|
const types = ['decimal', 'integer'];
|
|
2148
2334
|
const formats = ['none', 'number', 'currency', 'percent', 'unit'];
|
|
2149
2335
|
|
|
2150
|
-
const mgInputNumericCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);word-break:break-word}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)
|
|
2336
|
+
const mgInputNumericCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);word-break:break-word}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.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}}.mg-c-input .mg-c-input__box{width:auto;text-align:var(--mg-c-input-text-align, right)}";
|
|
2151
2337
|
const MgInputNumericStyle0 = mgInputNumericCss;
|
|
2152
2338
|
|
|
2153
2339
|
const MgInputNumeric = class {
|
|
@@ -2158,32 +2344,88 @@ const MgInputNumeric = class {
|
|
|
2158
2344
|
// hasDisplayedError (triggered by blur event)
|
|
2159
2345
|
this.hasDisplayedError = false;
|
|
2160
2346
|
/**
|
|
2161
|
-
*
|
|
2347
|
+
* Input name
|
|
2348
|
+
* If not set the value equals the identifier
|
|
2162
2349
|
*/
|
|
2163
|
-
this.
|
|
2164
|
-
// Check validity
|
|
2165
|
-
this.checkValidity();
|
|
2166
|
-
if (this.hasDisplayedError) {
|
|
2167
|
-
this.setErrorMessage();
|
|
2168
|
-
}
|
|
2169
|
-
this.value = this.input.value;
|
|
2170
|
-
};
|
|
2350
|
+
this.name = this.identifier;
|
|
2171
2351
|
/**
|
|
2172
|
-
*
|
|
2352
|
+
* Define if label is visible
|
|
2173
2353
|
*/
|
|
2174
|
-
this.
|
|
2175
|
-
this.hasFocus = true;
|
|
2176
|
-
};
|
|
2354
|
+
this.labelHide = false;
|
|
2177
2355
|
/**
|
|
2178
|
-
*
|
|
2356
|
+
* Define if input is required
|
|
2179
2357
|
*/
|
|
2180
|
-
this.
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2358
|
+
this.required = false;
|
|
2359
|
+
/**
|
|
2360
|
+
* Define if input is readonly
|
|
2361
|
+
*/
|
|
2362
|
+
this.readonly = false;
|
|
2363
|
+
/**
|
|
2364
|
+
* Define if input is disabled
|
|
2365
|
+
*/
|
|
2366
|
+
this.disabled = false;
|
|
2367
|
+
/**
|
|
2368
|
+
* Define tooltip position
|
|
2369
|
+
*/
|
|
2370
|
+
this.tooltipPosition = 'input';
|
|
2371
|
+
/**
|
|
2372
|
+
* Define numeric type
|
|
2373
|
+
*/
|
|
2374
|
+
this.type = 'decimal';
|
|
2375
|
+
/**
|
|
2376
|
+
* Set local formatting.
|
|
2377
|
+
* Numbers are formatted based on the locale.
|
|
2378
|
+
*/
|
|
2379
|
+
this.format = 'number';
|
|
2380
|
+
/**
|
|
2381
|
+
* Define currency
|
|
2382
|
+
*/
|
|
2383
|
+
this.currency = 'EUR';
|
|
2384
|
+
/**
|
|
2385
|
+
* Define unit display format ('short', 'long', 'narrow')
|
|
2386
|
+
*/
|
|
2387
|
+
this.unitDisplay = 'short';
|
|
2388
|
+
/**
|
|
2389
|
+
* Override integer length
|
|
2390
|
+
* integer is the number before the decimal point
|
|
2391
|
+
*/
|
|
2392
|
+
this.integerLength = 13;
|
|
2393
|
+
/**
|
|
2394
|
+
* Override decimal length
|
|
2395
|
+
* decimal is the number after the decimal point
|
|
2396
|
+
*/
|
|
2397
|
+
this.decimalLength = 2;
|
|
2398
|
+
/**
|
|
2399
|
+
* Component classes
|
|
2400
|
+
*/
|
|
2401
|
+
this.classCollection = new index_es.Ge(['mg-c-input--numeric']);
|
|
2402
|
+
/**
|
|
2403
|
+
* Handle input event
|
|
2404
|
+
*/
|
|
2405
|
+
this.handleInput = () => {
|
|
2406
|
+
// Check validity
|
|
2407
|
+
this.checkValidity();
|
|
2408
|
+
if (this.hasDisplayedError) {
|
|
2409
|
+
this.setErrorMessage();
|
|
2410
|
+
}
|
|
2411
|
+
this.value = this.input.value;
|
|
2412
|
+
};
|
|
2413
|
+
/**
|
|
2414
|
+
* Handle focus event
|
|
2415
|
+
*/
|
|
2416
|
+
this.handleFocus = () => {
|
|
2417
|
+
this.hasFocus = true;
|
|
2418
|
+
};
|
|
2419
|
+
/**
|
|
2420
|
+
* Handle blur event
|
|
2421
|
+
*/
|
|
2422
|
+
this.handleBlur = () => {
|
|
2423
|
+
if (this.value === '-')
|
|
2424
|
+
this.value = '';
|
|
2425
|
+
// Display Error
|
|
2426
|
+
this.handlerInProgress = 'blur';
|
|
2427
|
+
this.displayError().finally(() => {
|
|
2428
|
+
// reset guard
|
|
2187
2429
|
this.handlerInProgress = undefined;
|
|
2188
2430
|
this.hasFocus = false;
|
|
2189
2431
|
});
|
|
@@ -2194,6 +2436,12 @@ const MgInputNumeric = class {
|
|
|
2194
2436
|
this.checkValidity = () => {
|
|
2195
2437
|
this.setValidity(this.readonly || this.disabled || this.getInputError() === null);
|
|
2196
2438
|
};
|
|
2439
|
+
/**
|
|
2440
|
+
* Format min/max value for error message
|
|
2441
|
+
* @param value - value to format
|
|
2442
|
+
* @returns formatted value according to locale
|
|
2443
|
+
*/
|
|
2444
|
+
this.formatErrorValue = (value) => index_es.ut(value, this.locale, !Number.isInteger(value) && this.type === 'decimal' ? this.decimalLength : 0);
|
|
2197
2445
|
/**
|
|
2198
2446
|
* Set input error message
|
|
2199
2447
|
* @param errorMessage - errorMessage override
|
|
@@ -2210,8 +2458,8 @@ const MgInputNumeric = class {
|
|
|
2210
2458
|
this.errorMessage = this.messages.errors[inputError];
|
|
2211
2459
|
}
|
|
2212
2460
|
else {
|
|
2213
|
-
const formattedMin = this.
|
|
2214
|
-
const formattedMax = this.
|
|
2461
|
+
const formattedMin = this.formatErrorValue(this.min);
|
|
2462
|
+
const formattedMax = this.formatErrorValue(this.max);
|
|
2215
2463
|
this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', formattedMin).replace('{max}', formattedMax);
|
|
2216
2464
|
}
|
|
2217
2465
|
}
|
|
@@ -2250,13 +2498,13 @@ const MgInputNumeric = class {
|
|
|
2250
2498
|
this.formatValue = (value) => {
|
|
2251
2499
|
switch (this.format) {
|
|
2252
2500
|
case 'number':
|
|
2253
|
-
return index_es
|
|
2501
|
+
return index_es.ut(value, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);
|
|
2254
2502
|
case 'currency':
|
|
2255
|
-
return index_es.
|
|
2503
|
+
return index_es.ft(value, this.locale, this.currency);
|
|
2256
2504
|
case 'percent':
|
|
2257
2505
|
return index_es.dt(value / 100, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);
|
|
2258
2506
|
case 'unit':
|
|
2259
|
-
return index_es
|
|
2507
|
+
return index_es.$t(value, this.locale, this.unit, this.unitDisplay, this.type === 'decimal' ? this.decimalLength : undefined);
|
|
2260
2508
|
case 'none':
|
|
2261
2509
|
return value.toString();
|
|
2262
2510
|
}
|
|
@@ -2283,34 +2531,6 @@ const MgInputNumeric = class {
|
|
|
2283
2531
|
this.renderReadonly = () => {
|
|
2284
2532
|
return this.slotContent !== undefined ? (index.h("span", { class: "mg-c-input__readonly-value" }, index.h("b", null, this.readonlyValue), this.slotContent)) : (index.h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue));
|
|
2285
2533
|
};
|
|
2286
|
-
this.value = undefined;
|
|
2287
|
-
this.identifier = undefined;
|
|
2288
|
-
this.name = this.identifier;
|
|
2289
|
-
this.label = undefined;
|
|
2290
|
-
this.labelOnTop = undefined;
|
|
2291
|
-
this.labelHide = false;
|
|
2292
|
-
this.placeholder = undefined;
|
|
2293
|
-
this.required = false;
|
|
2294
|
-
this.readonly = false;
|
|
2295
|
-
this.max = undefined;
|
|
2296
|
-
this.min = undefined;
|
|
2297
|
-
this.disabled = false;
|
|
2298
|
-
this.mgWidth = undefined;
|
|
2299
|
-
this.tooltip = undefined;
|
|
2300
|
-
this.tooltipPosition = 'input';
|
|
2301
|
-
this.helpText = undefined;
|
|
2302
|
-
this.type = 'decimal';
|
|
2303
|
-
this.format = 'number';
|
|
2304
|
-
this.currency = 'EUR';
|
|
2305
|
-
this.unit = undefined;
|
|
2306
|
-
this.unitDisplay = 'short';
|
|
2307
|
-
this.integerLength = 13;
|
|
2308
|
-
this.decimalLength = 2;
|
|
2309
|
-
this.valid = undefined;
|
|
2310
|
-
this.invalid = undefined;
|
|
2311
|
-
this.classCollection = new index_es.Xe(['mg-c-input--numeric']);
|
|
2312
|
-
this.errorMessage = undefined;
|
|
2313
|
-
this.hasFocus = undefined;
|
|
2314
2534
|
}
|
|
2315
2535
|
validateValue(newValue) {
|
|
2316
2536
|
// has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type
|
|
@@ -2363,31 +2583,42 @@ const MgInputNumeric = class {
|
|
|
2363
2583
|
}
|
|
2364
2584
|
validateType(newValue) {
|
|
2365
2585
|
if (!types.includes(newValue)) {
|
|
2366
|
-
throw new Error(`<mg-input-numeric> prop "type" must be one of: ${types.join(', ')}. Passed value: ${index_es.
|
|
2586
|
+
throw new Error(`<mg-input-numeric> prop "type" must be one of: ${types.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
2367
2587
|
}
|
|
2368
2588
|
}
|
|
2369
2589
|
watchFormat(newValue) {
|
|
2370
2590
|
if (!formats.includes(newValue)) {
|
|
2371
|
-
throw new Error(`<mg-input-numeric> prop "format" must be one of: ${formats.join(', ')}. Passed value: ${index_es.
|
|
2591
|
+
throw new Error(`<mg-input-numeric> prop "format" must be one of: ${formats.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
2372
2592
|
}
|
|
2373
2593
|
}
|
|
2374
2594
|
validateIntegerLength(newValue) {
|
|
2375
2595
|
if (newValue < 1) {
|
|
2376
|
-
throw new Error(`<mg-input-numeric> prop "integer-length" must be a positive number. Passed value: ${index_es.
|
|
2596
|
+
throw new Error(`<mg-input-numeric> prop "integer-length" must be a positive number. Passed value: ${index_es.Je(newValue)}.`);
|
|
2377
2597
|
}
|
|
2378
2598
|
}
|
|
2379
2599
|
validateDecimalLength(newValue) {
|
|
2380
2600
|
if (newValue < 1) {
|
|
2381
|
-
throw new Error(`<mg-input-numeric> prop "decimal-length" must be a positive number, consider using prop "type" to "integer" instead. Passed value: ${index_es.
|
|
2601
|
+
throw new Error(`<mg-input-numeric> prop "decimal-length" must be a positive number, consider using prop "type" to "integer" instead. Passed value: ${index_es.Je(newValue)}.`);
|
|
2382
2602
|
}
|
|
2383
2603
|
}
|
|
2384
2604
|
/**
|
|
2385
2605
|
* Display input error if it exists.
|
|
2386
2606
|
*/
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2607
|
+
displayError() {
|
|
2608
|
+
// Use `Promise` as requested for stencil method
|
|
2609
|
+
// Use `requestAnimationFrame` to ensure:
|
|
2610
|
+
// - DOM is fully updated before validation
|
|
2611
|
+
// - Async operations are completed
|
|
2612
|
+
// - No timing issues with Stencil's render cycle
|
|
2613
|
+
// - Keep everything in sync both inside and outside the component
|
|
2614
|
+
return new Promise(resolve => {
|
|
2615
|
+
requestAnimationFrame(() => {
|
|
2616
|
+
this.checkValidity();
|
|
2617
|
+
this.setErrorMessage();
|
|
2618
|
+
this.hasDisplayedError = this.invalid;
|
|
2619
|
+
resolve();
|
|
2620
|
+
});
|
|
2621
|
+
});
|
|
2391
2622
|
}
|
|
2392
2623
|
/**
|
|
2393
2624
|
* Set an error and display a custom error message.
|
|
@@ -2401,7 +2632,7 @@ const MgInputNumeric = class {
|
|
|
2401
2632
|
if (typeof valid !== 'boolean') {
|
|
2402
2633
|
throw new Error('<mg-input-numeric> method "setError()" param "valid" must be a boolean.');
|
|
2403
2634
|
}
|
|
2404
|
-
else if (!index_es.
|
|
2635
|
+
else if (!index_es.ye(errorMessage)) {
|
|
2405
2636
|
throw new Error('<mg-input-numeric> method "setError()" param "errorMessage" must be a string.');
|
|
2406
2637
|
}
|
|
2407
2638
|
else {
|
|
@@ -2507,7 +2738,7 @@ const MgInputNumeric = class {
|
|
|
2507
2738
|
* @returns HTML Element
|
|
2508
2739
|
*/
|
|
2509
2740
|
render() {
|
|
2510
|
-
return (index.h("mg-input", { key: '
|
|
2741
|
+
return (index.h("mg-input", { key: 'b3f1b0e8a78d2f61146f052db1636d98e89271d1', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly
|
|
2511
2742
|
? this.readonlyValue && this.renderReadonly()
|
|
2512
2743
|
: [
|
|
2513
2744
|
index.h("input", { key: "input", type: "text", class: "mg-c-input__box mg-c-input__box--width", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
@@ -2534,7 +2765,7 @@ const MgInputNumeric = class {
|
|
|
2534
2765
|
};
|
|
2535
2766
|
MgInputNumeric.style = MgInputNumericStyle0;
|
|
2536
2767
|
|
|
2537
|
-
const mgInputPasswordCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);word-break:break-word}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)
|
|
2768
|
+
const mgInputPasswordCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);word-break:break-word}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.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}}.mg-c-input.mg-c-input--password .mg-c-input__input-icon{color:var(--mg-b-color-dark)}.mg-c-input.mg-c-input--password .mg-c-input__input-group{position:relative;flex-grow:1}.mg-c-input.mg-c-input--password .mg-c-input__append-button{position:absolute;right:0}.mg-c-input.mg-c-input--password .mg-c-input__box{padding-right:calc(var(--mg-b-size-min-height) + var(--mg-b-size-8))}.mg-c-input.mg-c-input--password .mg-c-input__box::-ms-reveal{display:none}";
|
|
2538
2769
|
const MgInputPasswordStyle0 = mgInputPasswordCss;
|
|
2539
2770
|
|
|
2540
2771
|
const MgInputPassword = class {
|
|
@@ -2544,6 +2775,43 @@ const MgInputPassword = class {
|
|
|
2544
2775
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
2545
2776
|
// hasDisplayedError (triggered by blur event)
|
|
2546
2777
|
this.hasDisplayedError = false;
|
|
2778
|
+
/**
|
|
2779
|
+
* Input name
|
|
2780
|
+
* If not set the value equals the identifier
|
|
2781
|
+
*/
|
|
2782
|
+
this.name = this.identifier;
|
|
2783
|
+
/**
|
|
2784
|
+
* Define if label is visible
|
|
2785
|
+
*/
|
|
2786
|
+
this.labelHide = false;
|
|
2787
|
+
/**
|
|
2788
|
+
* Define if input is required
|
|
2789
|
+
*/
|
|
2790
|
+
this.required = false;
|
|
2791
|
+
/**
|
|
2792
|
+
* Define if input is readonly
|
|
2793
|
+
*/
|
|
2794
|
+
this.readonly = false;
|
|
2795
|
+
/**
|
|
2796
|
+
* Define if input is disabled
|
|
2797
|
+
*/
|
|
2798
|
+
this.disabled = false;
|
|
2799
|
+
/**
|
|
2800
|
+
* Define input width
|
|
2801
|
+
*/
|
|
2802
|
+
this.mgWidth = 'full';
|
|
2803
|
+
/**
|
|
2804
|
+
* Define tooltip position
|
|
2805
|
+
*/
|
|
2806
|
+
this.tooltipPosition = 'input';
|
|
2807
|
+
/**
|
|
2808
|
+
* Component classes
|
|
2809
|
+
*/
|
|
2810
|
+
this.classCollection = new index_es.Ge(['mg-c-input--password']);
|
|
2811
|
+
/**
|
|
2812
|
+
* Indicates if password is displayed or not
|
|
2813
|
+
*/
|
|
2814
|
+
this.displayPassword = false;
|
|
2547
2815
|
/**
|
|
2548
2816
|
* Handle input event
|
|
2549
2817
|
*/
|
|
@@ -2593,26 +2861,6 @@ const MgInputPassword = class {
|
|
|
2593
2861
|
}
|
|
2594
2862
|
}
|
|
2595
2863
|
};
|
|
2596
|
-
this.value = undefined;
|
|
2597
|
-
this.identifier = undefined;
|
|
2598
|
-
this.name = this.identifier;
|
|
2599
|
-
this.label = undefined;
|
|
2600
|
-
this.labelOnTop = undefined;
|
|
2601
|
-
this.labelHide = false;
|
|
2602
|
-
this.placeholder = undefined;
|
|
2603
|
-
this.maxlength = undefined;
|
|
2604
|
-
this.required = false;
|
|
2605
|
-
this.readonly = false;
|
|
2606
|
-
this.disabled = false;
|
|
2607
|
-
this.mgWidth = 'full';
|
|
2608
|
-
this.tooltip = undefined;
|
|
2609
|
-
this.tooltipPosition = 'input';
|
|
2610
|
-
this.helpText = undefined;
|
|
2611
|
-
this.valid = undefined;
|
|
2612
|
-
this.invalid = undefined;
|
|
2613
|
-
this.classCollection = new index_es.Xe(['mg-c-input--password']);
|
|
2614
|
-
this.errorMessage = undefined;
|
|
2615
|
-
this.displayPassword = false;
|
|
2616
2864
|
}
|
|
2617
2865
|
handleValue(newValue) {
|
|
2618
2866
|
this.valueChange.emit(newValue);
|
|
@@ -2651,10 +2899,21 @@ const MgInputPassword = class {
|
|
|
2651
2899
|
/**
|
|
2652
2900
|
* Display input error if it exists.
|
|
2653
2901
|
*/
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2902
|
+
displayError() {
|
|
2903
|
+
// Use `Promise` as requested for stencil method
|
|
2904
|
+
// Use `requestAnimationFrame` to ensure:
|
|
2905
|
+
// - DOM is fully updated before validation
|
|
2906
|
+
// - Async operations are completed
|
|
2907
|
+
// - No timing issues with Stencil's render cycle
|
|
2908
|
+
// - Keep everything in sync both inside and outside the component
|
|
2909
|
+
return new Promise(resolve => {
|
|
2910
|
+
requestAnimationFrame(() => {
|
|
2911
|
+
this.checkValidity();
|
|
2912
|
+
this.setErrorMessage();
|
|
2913
|
+
this.hasDisplayedError = this.invalid;
|
|
2914
|
+
resolve();
|
|
2915
|
+
});
|
|
2916
|
+
});
|
|
2658
2917
|
}
|
|
2659
2918
|
/**
|
|
2660
2919
|
* Set an error and display a custom error message.
|
|
@@ -2668,7 +2927,7 @@ const MgInputPassword = class {
|
|
|
2668
2927
|
if (typeof valid !== 'boolean') {
|
|
2669
2928
|
throw new Error('<mg-input-password> method "setError()" param "valid" must be a boolean.');
|
|
2670
2929
|
}
|
|
2671
|
-
else if (!index_es.
|
|
2930
|
+
else if (!index_es.ye(errorMessage)) {
|
|
2672
2931
|
throw new Error('<mg-input-password> method "setError()" param "errorMessage" must be a string.');
|
|
2673
2932
|
}
|
|
2674
2933
|
else {
|
|
@@ -2725,7 +2984,7 @@ const MgInputPassword = class {
|
|
|
2725
2984
|
* @returns HTML Element
|
|
2726
2985
|
*/
|
|
2727
2986
|
render() {
|
|
2728
|
-
return (index.h("mg-input", { key: '
|
|
2987
|
+
return (index.h("mg-input", { key: '3c494aa50f437d261e7d006f395c5b7c3cbead5d', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.value !== undefined && index.h("b", { class: "mg-c-input__readonly-value" }, '•'.repeat(this.value.length))) : (index.h("span", { class: "mg-c-input__input-group" }, index.h("input", { type: this.displayPassword ? 'text' : 'password', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, maxlength: this.maxlength, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
2729
2988
|
if (el !== null)
|
|
2730
2989
|
this.input = el;
|
|
2731
2990
|
} }), index.h("mg-button", { label: this.messages.input.password[this.displayPassword ? 'hide' : 'display'], disabled: this.disabled, variant: "flat", class: "mg-c-input__append-button", "is-icon": true, onClick: this.toggleDisplayPassword, "aria-controls": this.identifier }, index.h("mg-icon", { class: "mg-c-input__input-icon", icon: this.displayPassword ? 'eye-slash' : 'eye' }))))));
|
|
@@ -2764,6 +3023,43 @@ const MgInputRadio = class {
|
|
|
2764
3023
|
this.classVerticalList = 'mg-c-input--vertical-list';
|
|
2765
3024
|
// hasDisplayedError (triggered by blur event)
|
|
2766
3025
|
this.hasDisplayedError = false;
|
|
3026
|
+
/**
|
|
3027
|
+
* Input name
|
|
3028
|
+
* If not set the value equals the identifier
|
|
3029
|
+
*/
|
|
3030
|
+
this.name = this.identifier;
|
|
3031
|
+
/**
|
|
3032
|
+
* Define if label is displayed on top
|
|
3033
|
+
*/
|
|
3034
|
+
this.labelOnTop = false;
|
|
3035
|
+
/**
|
|
3036
|
+
* Define if label is visible
|
|
3037
|
+
*/
|
|
3038
|
+
this.labelHide = false;
|
|
3039
|
+
/**
|
|
3040
|
+
* Define if inputs are display verticaly
|
|
3041
|
+
*/
|
|
3042
|
+
this.inputVerticalList = false;
|
|
3043
|
+
/**
|
|
3044
|
+
* Define if input is required
|
|
3045
|
+
*/
|
|
3046
|
+
this.required = false;
|
|
3047
|
+
/**
|
|
3048
|
+
* Define if input is readonly
|
|
3049
|
+
*/
|
|
3050
|
+
this.readonly = false;
|
|
3051
|
+
/**
|
|
3052
|
+
* Define if input is disabled
|
|
3053
|
+
*/
|
|
3054
|
+
this.disabled = false;
|
|
3055
|
+
/**
|
|
3056
|
+
* Define tooltip position
|
|
3057
|
+
*/
|
|
3058
|
+
this.tooltipPosition = 'input';
|
|
3059
|
+
/**
|
|
3060
|
+
* Component classes
|
|
3061
|
+
*/
|
|
3062
|
+
this.classCollection = new index_es.Ge(['mg-c-input--radio', classFieldset]);
|
|
2767
3063
|
/**
|
|
2768
3064
|
* Handle input event
|
|
2769
3065
|
* @param event - input event
|
|
@@ -2810,31 +3106,11 @@ const MgInputRadio = class {
|
|
|
2810
3106
|
* @returns element
|
|
2811
3107
|
*/
|
|
2812
3108
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
2813
|
-
this.value = undefined;
|
|
2814
|
-
this.items = undefined;
|
|
2815
|
-
this.identifier = undefined;
|
|
2816
|
-
this.name = this.identifier;
|
|
2817
|
-
this.label = undefined;
|
|
2818
|
-
this.labelOnTop = false;
|
|
2819
|
-
this.labelHide = false;
|
|
2820
|
-
this.inputVerticalList = false;
|
|
2821
|
-
this.required = false;
|
|
2822
|
-
this.readonly = false;
|
|
2823
|
-
this.disabled = false;
|
|
2824
|
-
this.tooltip = undefined;
|
|
2825
|
-
this.tooltipPosition = 'input';
|
|
2826
|
-
this.helpText = undefined;
|
|
2827
|
-
this.valid = undefined;
|
|
2828
|
-
this.invalid = undefined;
|
|
2829
|
-
this.classCollection = new index_es.Xe(['mg-c-input--radio', classFieldset]);
|
|
2830
|
-
this.errorMessage = undefined;
|
|
2831
|
-
this.options = undefined;
|
|
2832
|
-
this.readonlyValue = undefined;
|
|
2833
3109
|
}
|
|
2834
3110
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2835
3111
|
watchValue(newValue) {
|
|
2836
3112
|
var _a;
|
|
2837
|
-
if (index_es.
|
|
3113
|
+
if (index_es.Xe(this.items) && typeof newValue === 'string') {
|
|
2838
3114
|
this.readonlyValue = newValue;
|
|
2839
3115
|
}
|
|
2840
3116
|
else if (Array.isArray(this.items) && this.items.every(isOption$3)) {
|
|
@@ -2848,10 +3124,10 @@ const MgInputRadio = class {
|
|
|
2848
3124
|
validateItems(newValue) {
|
|
2849
3125
|
// Validate if items have required min length
|
|
2850
3126
|
if (typeof newValue === 'object' && newValue.length < 2) {
|
|
2851
|
-
throw new Error(`<mg-input-radio> prop "items" require at least 2 items. Passed value: ${index_es.
|
|
3127
|
+
throw new Error(`<mg-input-radio> prop "items" require at least 2 items. Passed value: ${index_es.Je(newValue)}.`);
|
|
2852
3128
|
}
|
|
2853
3129
|
// String array
|
|
2854
|
-
else if (index_es.
|
|
3130
|
+
else if (index_es.Xe(newValue)) {
|
|
2855
3131
|
this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
|
|
2856
3132
|
}
|
|
2857
3133
|
// Object array
|
|
@@ -2859,7 +3135,7 @@ const MgInputRadio = class {
|
|
|
2859
3135
|
this.options = newValue;
|
|
2860
3136
|
}
|
|
2861
3137
|
else {
|
|
2862
|
-
throw new Error(`<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption. Passed value: ${index_es.
|
|
3138
|
+
throw new Error(`<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption. Passed value: ${index_es.Je(newValue)}.`);
|
|
2863
3139
|
}
|
|
2864
3140
|
}
|
|
2865
3141
|
watchInputVerticalList(newValue) {
|
|
@@ -2893,10 +3169,21 @@ const MgInputRadio = class {
|
|
|
2893
3169
|
/**
|
|
2894
3170
|
* Display input error if it exists.
|
|
2895
3171
|
*/
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
3172
|
+
displayError() {
|
|
3173
|
+
// Use `Promise` as requested for stencil method
|
|
3174
|
+
// Use `requestAnimationFrame` to ensure:
|
|
3175
|
+
// - DOM is fully updated before validation
|
|
3176
|
+
// - Async operations are completed
|
|
3177
|
+
// - No timing issues with Stencil's render cycle
|
|
3178
|
+
// - Keep everything in sync both inside and outside the component
|
|
3179
|
+
return new Promise(resolve => {
|
|
3180
|
+
requestAnimationFrame(() => {
|
|
3181
|
+
this.checkValidity();
|
|
3182
|
+
this.setErrorMessage();
|
|
3183
|
+
this.hasDisplayedError = this.invalid;
|
|
3184
|
+
resolve();
|
|
3185
|
+
});
|
|
3186
|
+
});
|
|
2900
3187
|
}
|
|
2901
3188
|
/**
|
|
2902
3189
|
* Set an error and display a custom error message.
|
|
@@ -2910,7 +3197,7 @@ const MgInputRadio = class {
|
|
|
2910
3197
|
if (typeof valid !== 'boolean') {
|
|
2911
3198
|
throw new Error('<mg-input-radio> method "setError()" param "valid" must be a boolean.');
|
|
2912
3199
|
}
|
|
2913
|
-
else if (!index_es.
|
|
3200
|
+
else if (!index_es.ye(errorMessage)) {
|
|
2914
3201
|
throw new Error('<mg-input-radio> method "setError()" param "errorMessage" must be a string.');
|
|
2915
3202
|
}
|
|
2916
3203
|
else {
|
|
@@ -2970,7 +3257,7 @@ const MgInputRadio = class {
|
|
|
2970
3257
|
* @returns HTML Element
|
|
2971
3258
|
*/
|
|
2972
3259
|
render() {
|
|
2973
|
-
return (index.h("mg-input", { key: '
|
|
3260
|
+
return (index.h("mg-input", { key: 'df8daa3c340c0410d092029685e195256a523b31', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && !this.value ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.readonlyValue && index.h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue)) : (index.h("ul", { class: "mg-c-input__input-group-container", role: "list" }, this.options.map((input, index$1) => (index.h("li", { key: input.title, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "radio", id: this.identifier + '_' + index$1, name: this.identifier, value: index$1, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index$1].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: (el) => {
|
|
2974
3261
|
if (el !== null)
|
|
2975
3262
|
this.inputs[index$1] = el;
|
|
2976
3263
|
} }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title))))))));
|
|
@@ -2987,7 +3274,7 @@ const MgInputRadio = class {
|
|
|
2987
3274
|
};
|
|
2988
3275
|
MgInputRadio.style = MgInputRadioStyle0;
|
|
2989
3276
|
|
|
2990
|
-
const mgInputSelectCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);word-break:break-word}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)
|
|
3277
|
+
const mgInputSelectCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);word-break:break-word}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.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}}.mg-c-input__box{padding-top:0;padding-right:var(--mg-b-size-8);padding-bottom:0}@media screen and (max-width: 767px){.mg-c-input__box{width:100%}}";
|
|
2991
3278
|
const MgInputSelectStyle0 = mgInputSelectCss;
|
|
2992
3279
|
|
|
2993
3280
|
/**
|
|
@@ -3039,6 +3326,43 @@ const MgInputSelect = class {
|
|
|
3039
3326
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
3040
3327
|
// hasDisplayedError (triggered by blur event)
|
|
3041
3328
|
this.hasDisplayedError = false;
|
|
3329
|
+
/**
|
|
3330
|
+
* Input name
|
|
3331
|
+
* If not set the value equals the identifier
|
|
3332
|
+
*/
|
|
3333
|
+
this.name = this.identifier;
|
|
3334
|
+
/**
|
|
3335
|
+
* Define if label is visible
|
|
3336
|
+
*/
|
|
3337
|
+
this.labelHide = false;
|
|
3338
|
+
/**
|
|
3339
|
+
* Option to remove placeholder
|
|
3340
|
+
*/
|
|
3341
|
+
this.placeholderHide = false;
|
|
3342
|
+
/**
|
|
3343
|
+
* Option to disable placeholder
|
|
3344
|
+
*/
|
|
3345
|
+
this.placeholderDisabled = false;
|
|
3346
|
+
/**
|
|
3347
|
+
* Define if input is required
|
|
3348
|
+
*/
|
|
3349
|
+
this.required = false;
|
|
3350
|
+
/**
|
|
3351
|
+
* Define if input is readonly
|
|
3352
|
+
*/
|
|
3353
|
+
this.readonly = false;
|
|
3354
|
+
/**
|
|
3355
|
+
* Define if input is disabled
|
|
3356
|
+
*/
|
|
3357
|
+
this.disabled = false;
|
|
3358
|
+
/**
|
|
3359
|
+
* Define tooltip position
|
|
3360
|
+
*/
|
|
3361
|
+
this.tooltipPosition = 'input';
|
|
3362
|
+
/**
|
|
3363
|
+
* Component classes
|
|
3364
|
+
*/
|
|
3365
|
+
this.classCollection = new index_es.Ge(['mg-c-input--select']);
|
|
3042
3366
|
/**
|
|
3043
3367
|
* Handle input event
|
|
3044
3368
|
*/
|
|
@@ -3068,7 +3392,7 @@ const MgInputSelect = class {
|
|
|
3068
3392
|
if (this.input.value === '') {
|
|
3069
3393
|
this.setValue(null);
|
|
3070
3394
|
}
|
|
3071
|
-
else if (index_es.
|
|
3395
|
+
else if (index_es.Xe(this.items) && this.items.includes(this.input.value)) {
|
|
3072
3396
|
this.setValue(this.input.value);
|
|
3073
3397
|
}
|
|
3074
3398
|
else if (allItemsAreOptions(this.items) && typeof this.input.value === 'string' && this.items.some(this.isInputValue)) {
|
|
@@ -3123,34 +3447,10 @@ const MgInputSelect = class {
|
|
|
3123
3447
|
* @returns render option
|
|
3124
3448
|
*/
|
|
3125
3449
|
this.renderOption = (option) => (index.h("option", { key: option.title, value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title));
|
|
3126
|
-
this.value = undefined;
|
|
3127
|
-
this.items = undefined;
|
|
3128
|
-
this.identifier = undefined;
|
|
3129
|
-
this.name = this.identifier;
|
|
3130
|
-
this.label = undefined;
|
|
3131
|
-
this.labelOnTop = undefined;
|
|
3132
|
-
this.labelHide = false;
|
|
3133
|
-
this.placeholder = undefined;
|
|
3134
|
-
this.placeholderHide = false;
|
|
3135
|
-
this.placeholderDisabled = false;
|
|
3136
|
-
this.required = false;
|
|
3137
|
-
this.readonly = false;
|
|
3138
|
-
this.disabled = false;
|
|
3139
|
-
this.mgWidth = undefined;
|
|
3140
|
-
this.tooltip = undefined;
|
|
3141
|
-
this.tooltipPosition = 'input';
|
|
3142
|
-
this.helpText = undefined;
|
|
3143
|
-
this.valid = undefined;
|
|
3144
|
-
this.invalid = undefined;
|
|
3145
|
-
this.classCollection = new index_es.Xe(['mg-c-input--select']);
|
|
3146
|
-
this.errorMessage = undefined;
|
|
3147
|
-
this.options = undefined;
|
|
3148
|
-
this.valueExist = undefined;
|
|
3149
|
-
this.readonlyValue = undefined;
|
|
3150
3450
|
}
|
|
3151
3451
|
validateValue(newValue) {
|
|
3152
3452
|
var _a, _b;
|
|
3153
|
-
if (index_es.
|
|
3453
|
+
if (index_es.Xe(this.items) && typeof newValue === 'string') {
|
|
3154
3454
|
this.readonlyValue = ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) !== undefined ? this.input.value : newValue;
|
|
3155
3455
|
}
|
|
3156
3456
|
else if (allItemsAreOptions(this.items)) {
|
|
@@ -3167,7 +3467,7 @@ const MgInputSelect = class {
|
|
|
3167
3467
|
this.options = [];
|
|
3168
3468
|
}
|
|
3169
3469
|
// String array
|
|
3170
|
-
else if (index_es.
|
|
3470
|
+
else if (index_es.Xe(newValue)) {
|
|
3171
3471
|
if (typeof this.value === 'string')
|
|
3172
3472
|
this.valueExist = newValue.includes(this.value);
|
|
3173
3473
|
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
@@ -3185,7 +3485,7 @@ const MgInputSelect = class {
|
|
|
3185
3485
|
}
|
|
3186
3486
|
}
|
|
3187
3487
|
else {
|
|
3188
|
-
throw new Error(`<mg-input-select> prop "items" is required, can be an empty Array or all items must be the same type: string or Option. Passed value: ${index_es.
|
|
3488
|
+
throw new Error(`<mg-input-select> prop "items" is required, can be an empty Array or all items must be the same type: string or Option. Passed value: ${index_es.Je(newValue)}.`);
|
|
3189
3489
|
}
|
|
3190
3490
|
}
|
|
3191
3491
|
watchReadonly(newValue) {
|
|
@@ -3222,10 +3522,21 @@ const MgInputSelect = class {
|
|
|
3222
3522
|
/**
|
|
3223
3523
|
* Display input error if it exists.
|
|
3224
3524
|
*/
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3525
|
+
displayError() {
|
|
3526
|
+
// Use `Promise` as requested for stencil method
|
|
3527
|
+
// Use `requestAnimationFrame` to ensure:
|
|
3528
|
+
// - DOM is fully updated before validation
|
|
3529
|
+
// - Async operations are completed
|
|
3530
|
+
// - No timing issues with Stencil's render cycle
|
|
3531
|
+
// - Keep everything in sync both inside and outside the component
|
|
3532
|
+
return new Promise(resolve => {
|
|
3533
|
+
requestAnimationFrame(() => {
|
|
3534
|
+
this.checkValidity();
|
|
3535
|
+
this.setErrorMessage();
|
|
3536
|
+
this.hasDisplayedError = this.invalid;
|
|
3537
|
+
resolve();
|
|
3538
|
+
});
|
|
3539
|
+
});
|
|
3229
3540
|
}
|
|
3230
3541
|
/**
|
|
3231
3542
|
* Set an error and display a custom error message.
|
|
@@ -3239,7 +3550,7 @@ const MgInputSelect = class {
|
|
|
3239
3550
|
if (typeof valid !== 'boolean') {
|
|
3240
3551
|
throw new Error('<mg-input-select> method "setError()" param "valid" must be a boolean.');
|
|
3241
3552
|
}
|
|
3242
|
-
else if (!index_es.
|
|
3553
|
+
else if (!index_es.ye(errorMessage)) {
|
|
3243
3554
|
throw new Error('<mg-input-select> method "setError()" param "errorMessage" must be a string.');
|
|
3244
3555
|
}
|
|
3245
3556
|
else {
|
|
@@ -3303,7 +3614,7 @@ const MgInputSelect = class {
|
|
|
3303
3614
|
* @returns HTML Element
|
|
3304
3615
|
*/
|
|
3305
3616
|
render() {
|
|
3306
|
-
return (index.h("mg-input", { key: '
|
|
3617
|
+
return (index.h("mg-input", { key: '11584b2acab392278a9c26cb9ba49ae1e638a877', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.readonlyValue === null ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.readonlyValue && index.h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue)) : (index.h("select", { class: "mg-c-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
3307
3618
|
if (el !== null)
|
|
3308
3619
|
this.input = el;
|
|
3309
3620
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -3321,7 +3632,7 @@ const MgInputSelect = class {
|
|
|
3321
3632
|
};
|
|
3322
3633
|
MgInputSelect.style = MgInputSelectStyle0;
|
|
3323
3634
|
|
|
3324
|
-
const mgInputTextCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)
|
|
3635
|
+
const mgInputTextCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);word-break:break-word}.mg-c-input.mg-c-input--display-character-left mg-character-left{font-size:var(--mg-b-font-size-small);opacity:.6}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__help-text ::slotted(*),.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__error ::slotted(*){margin-top:0}.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}}.mg-c-input__with-character-left{position:relative;width:100%}.mg-c-input.mg-u-is-focused .mg-c-input__with-character-left .mg-c-input__box{padding-right:max(var(--mg-c-character-left-message-length)*(.35ch + .3rem) + var(--mg-b-size-16)*clamp(0,var(--mg-c-character-left-message-length),1),var(--mg-b-size-8))}.mg-c-input__with-character-left mg-character-left{position:absolute;top:50%;right:var(--mg-b-size-8);display:none;font-size:var(--mg-b-font-size-small);opacity:.6;transform:translateY(-50%)}.mg-c-input.mg-u-is-focused .mg-c-input__with-character-left mg-character-left{display:block}.mg-c-input.mg-c-input--readonly b{min-height:var(--mg-b-font-size);margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__with-character-left>mg-icon{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__with-character-left .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}";
|
|
3325
3636
|
const MgInputTextStyle0 = mgInputTextCss;
|
|
3326
3637
|
|
|
3327
3638
|
/**
|
|
@@ -3335,7 +3646,7 @@ const isOption$1 = (option) => typeof option === 'object' && typeof option.title
|
|
|
3335
3646
|
* @param options - Datalist options to check.
|
|
3336
3647
|
* @returns True if datalist is well structured.
|
|
3337
3648
|
*/
|
|
3338
|
-
const isDatalistOptions = (options) => index_es.
|
|
3649
|
+
const isDatalistOptions = (options) => index_es.Xe(options) || (Array.isArray(options) && options.every(isOption$1));
|
|
3339
3650
|
const MgInputText = class {
|
|
3340
3651
|
constructor(hostRef) {
|
|
3341
3652
|
index.registerInstance(this, hostRef);
|
|
@@ -3352,6 +3663,51 @@ const MgInputText = class {
|
|
|
3352
3663
|
this.classIsAppendInputSlotContent = 'mg-c-input--is-append-input-slot-content';
|
|
3353
3664
|
// hasDisplayedError (triggered by blur event)
|
|
3354
3665
|
this.hasDisplayedError = false;
|
|
3666
|
+
/**
|
|
3667
|
+
* Input name
|
|
3668
|
+
* If not set the value equals the identifier
|
|
3669
|
+
*/
|
|
3670
|
+
this.name = this.identifier;
|
|
3671
|
+
/**
|
|
3672
|
+
* Input type
|
|
3673
|
+
*/
|
|
3674
|
+
this.type = 'text';
|
|
3675
|
+
/**
|
|
3676
|
+
* Define if label is visible
|
|
3677
|
+
*/
|
|
3678
|
+
this.labelHide = false;
|
|
3679
|
+
/**
|
|
3680
|
+
* Input max length
|
|
3681
|
+
*/
|
|
3682
|
+
this.maxlength = 400;
|
|
3683
|
+
/**
|
|
3684
|
+
* Define if input is required
|
|
3685
|
+
*/
|
|
3686
|
+
this.required = false;
|
|
3687
|
+
/**
|
|
3688
|
+
* Define if input is readonly
|
|
3689
|
+
*/
|
|
3690
|
+
this.readonly = false;
|
|
3691
|
+
/**
|
|
3692
|
+
* Define if input is disabled
|
|
3693
|
+
*/
|
|
3694
|
+
this.disabled = false;
|
|
3695
|
+
/**
|
|
3696
|
+
* Define input width
|
|
3697
|
+
*/
|
|
3698
|
+
this.mgWidth = 'full';
|
|
3699
|
+
/**
|
|
3700
|
+
* Define tooltip position
|
|
3701
|
+
*/
|
|
3702
|
+
this.tooltipPosition = 'input';
|
|
3703
|
+
/**
|
|
3704
|
+
* Define if component should display character left
|
|
3705
|
+
*/
|
|
3706
|
+
this.characterLeftHide = false;
|
|
3707
|
+
/**
|
|
3708
|
+
* Component classes
|
|
3709
|
+
*/
|
|
3710
|
+
this.classCollection = new index_es.Ge(['mg-c-input--text']);
|
|
3355
3711
|
/**
|
|
3356
3712
|
* Handle input event
|
|
3357
3713
|
*/
|
|
@@ -3367,7 +3723,7 @@ const MgInputText = class {
|
|
|
3367
3723
|
*/
|
|
3368
3724
|
this.handleFocus = () => {
|
|
3369
3725
|
this.classCollection.add(this.classFocus);
|
|
3370
|
-
this.classCollection = new index_es.
|
|
3726
|
+
this.classCollection = new index_es.Ge(this.classCollection.classes);
|
|
3371
3727
|
};
|
|
3372
3728
|
/**
|
|
3373
3729
|
* Handle blur event
|
|
@@ -3375,7 +3731,7 @@ const MgInputText = class {
|
|
|
3375
3731
|
this.handleBlur = () => {
|
|
3376
3732
|
// Manage focus
|
|
3377
3733
|
this.classCollection.delete(this.classFocus);
|
|
3378
|
-
this.classCollection = new index_es.
|
|
3734
|
+
this.classCollection = new index_es.Ge(this.classCollection.classes);
|
|
3379
3735
|
// Display Error
|
|
3380
3736
|
this.handlerInProgress = 'blur';
|
|
3381
3737
|
this.displayError().finally(() => {
|
|
@@ -3440,31 +3796,6 @@ const MgInputText = class {
|
|
|
3440
3796
|
this.renderReadonly = () => {
|
|
3441
3797
|
return this.slotContent !== undefined ? (index.h("span", { class: "mg-c-input__readonly-value" }, index.h("b", null, this.value), this.slotContent)) : (index.h("b", { class: "mg-c-input__readonly-value" }, this.value));
|
|
3442
3798
|
};
|
|
3443
|
-
this.value = undefined;
|
|
3444
|
-
this.identifier = undefined;
|
|
3445
|
-
this.name = this.identifier;
|
|
3446
|
-
this.label = undefined;
|
|
3447
|
-
this.type = 'text';
|
|
3448
|
-
this.icon = undefined;
|
|
3449
|
-
this.labelOnTop = undefined;
|
|
3450
|
-
this.labelHide = false;
|
|
3451
|
-
this.placeholder = undefined;
|
|
3452
|
-
this.datalistoptions = undefined;
|
|
3453
|
-
this.maxlength = 400;
|
|
3454
|
-
this.required = false;
|
|
3455
|
-
this.readonly = false;
|
|
3456
|
-
this.disabled = false;
|
|
3457
|
-
this.mgWidth = 'full';
|
|
3458
|
-
this.pattern = undefined;
|
|
3459
|
-
this.patternErrorMessage = undefined;
|
|
3460
|
-
this.tooltip = undefined;
|
|
3461
|
-
this.tooltipPosition = 'input';
|
|
3462
|
-
this.characterLeftHide = false;
|
|
3463
|
-
this.helpText = undefined;
|
|
3464
|
-
this.valid = undefined;
|
|
3465
|
-
this.invalid = undefined;
|
|
3466
|
-
this.classCollection = new index_es.Xe(['mg-c-input--text']);
|
|
3467
|
-
this.errorMessage = undefined;
|
|
3468
3799
|
}
|
|
3469
3800
|
handleValue(newValue) {
|
|
3470
3801
|
var _a, _b;
|
|
@@ -3485,7 +3816,7 @@ const MgInputText = class {
|
|
|
3485
3816
|
}
|
|
3486
3817
|
validateDatalistoptions(newValue) {
|
|
3487
3818
|
if (Boolean(newValue) && !isDatalistOptions(newValue)) {
|
|
3488
|
-
throw new Error(`<mg-input-text> prop "datalistoptions" values must be the same type, string or OptionType. Passed value: ${index_es.
|
|
3819
|
+
throw new Error(`<mg-input-text> prop "datalistoptions" values must be the same type, string or OptionType. Passed value: ${index_es.Je(newValue)}.`);
|
|
3489
3820
|
}
|
|
3490
3821
|
}
|
|
3491
3822
|
watchReadonly(newValue) {
|
|
@@ -3520,8 +3851,8 @@ const MgInputText = class {
|
|
|
3520
3851
|
this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
|
|
3521
3852
|
}
|
|
3522
3853
|
validatePattern(newValue) {
|
|
3523
|
-
if (newValue !== undefined && !(index_es.
|
|
3524
|
-
throw new Error(`<mg-input-text> props "pattern" and "patternErrorMessage" must be non-empty string and paired. Passed value: "pattern='${index_es.
|
|
3854
|
+
if (newValue !== undefined && !(index_es.ye(this.pattern) && index_es.ye(this.patternErrorMessage))) {
|
|
3855
|
+
throw new Error(`<mg-input-text> props "pattern" and "patternErrorMessage" must be non-empty string and paired. Passed value: "pattern='${index_es.Je(this.pattern)}'" and "patternErrorMessage='${index_es.Je(this.patternErrorMessage)}'".`);
|
|
3525
3856
|
}
|
|
3526
3857
|
}
|
|
3527
3858
|
/**
|
|
@@ -3533,10 +3864,21 @@ const MgInputText = class {
|
|
|
3533
3864
|
/**
|
|
3534
3865
|
* Display input error if it exists.
|
|
3535
3866
|
*/
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3867
|
+
displayError() {
|
|
3868
|
+
// Use `Promise` as requested for stencil method
|
|
3869
|
+
// Use `requestAnimationFrame` to ensure:
|
|
3870
|
+
// - DOM is fully updated before validation
|
|
3871
|
+
// - Async operations are completed
|
|
3872
|
+
// - No timing issues with Stencil's render cycle
|
|
3873
|
+
// - Keep everything in sync both inside and outside the component
|
|
3874
|
+
return new Promise(resolve => {
|
|
3875
|
+
requestAnimationFrame(() => {
|
|
3876
|
+
this.checkValidity();
|
|
3877
|
+
this.setErrorMessage();
|
|
3878
|
+
this.hasDisplayedError = this.invalid;
|
|
3879
|
+
resolve();
|
|
3880
|
+
});
|
|
3881
|
+
});
|
|
3540
3882
|
}
|
|
3541
3883
|
/**
|
|
3542
3884
|
* Set an error and display a custom error message.
|
|
@@ -3550,7 +3892,7 @@ const MgInputText = class {
|
|
|
3550
3892
|
if (typeof valid !== 'boolean') {
|
|
3551
3893
|
throw new Error('<mg-input-text> method "setError()" param "valid" must be a boolean.');
|
|
3552
3894
|
}
|
|
3553
|
-
else if (!index_es.
|
|
3895
|
+
else if (!index_es.ye(errorMessage)) {
|
|
3554
3896
|
throw new Error('<mg-input-text> method "setError()" param "errorMessage" must be a string.');
|
|
3555
3897
|
}
|
|
3556
3898
|
else {
|
|
@@ -3615,12 +3957,12 @@ const MgInputText = class {
|
|
|
3615
3957
|
* @returns HTML Element
|
|
3616
3958
|
*/
|
|
3617
3959
|
render() {
|
|
3618
|
-
return (index.h("mg-input", { key: '
|
|
3960
|
+
return (index.h("mg-input", { key: '11cdf9ff3675c7e130a46bce025b7c8b5f4e0d02', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [this.characterLeftId], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly
|
|
3619
3961
|
? this.value && this.renderReadonly()
|
|
3620
3962
|
: [
|
|
3621
3963
|
index.h("div", { key: "input", class: "mg-c-input__with-character-left", style: {
|
|
3622
3964
|
'--mg-c-character-left-message-length': (!this.characterLeftHide
|
|
3623
|
-
? (this.maxlength
|
|
3965
|
+
? (this.maxlength.toString().length * 2 + 1)
|
|
3624
3966
|
: 0).toString(),
|
|
3625
3967
|
} }, this.icon !== undefined && index.h("mg-icon", { icon: this.icon }), index.h("input", { type: this.type, class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, list: this.hasDatalist() ? this.datalistId : undefined, autocomplete: this.hasDatalist() ? 'off' : undefined, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
3626
3968
|
if (el !== null)
|
|
@@ -3644,7 +3986,7 @@ const MgInputText = class {
|
|
|
3644
3986
|
};
|
|
3645
3987
|
MgInputText.style = MgInputTextStyle0;
|
|
3646
3988
|
|
|
3647
|
-
const mgInputTextareaCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)
|
|
3989
|
+
const mgInputTextareaCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);word-break:break-word}.mg-c-input.mg-c-input--display-character-left mg-character-left{font-size:var(--mg-b-font-size-small);opacity:.6}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__help-text ::slotted(*),.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__error ::slotted(*){margin-top:0}.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}}.mg-c-input__input{align-items:start}.mg-c-input__box{display:block;height:auto;resize:none}.mg-c-input__box.mg-c-input__box--resizable{resize:both}.mg-c-input__box.mg-c-input__box--resizable-horizontal{resize:horizontal}.mg-c-input__box.mg-c-input__box--resizable-vertical{resize:vertical}.mg-c-input__readonly-value{white-space:pre-line}.mg-c-input__with-character-left{flex-grow:1}.mg-c-input__with-character-left mg-character-left{display:block;text-align:end;visibility:hidden}.mg-c-input.mg-u-is-focused .mg-c-input__with-character-left mg-character-left{visibility:visible}@-moz-document url-prefix(){.mg-c-input__box{overflow-x:hidden}}";
|
|
3648
3990
|
const MgInputTextareaStyle0 = mgInputTextareaCss;
|
|
3649
3991
|
|
|
3650
3992
|
const MgInputTextarea = class {
|
|
@@ -3660,6 +4002,55 @@ const MgInputTextarea = class {
|
|
|
3660
4002
|
this.classDisplayCharacterLeft = 'mg-c-input--display-character-left';
|
|
3661
4003
|
// hasDisplayedError (triggered by blur event)
|
|
3662
4004
|
this.hasDisplayedError = false;
|
|
4005
|
+
/**
|
|
4006
|
+
* Input name
|
|
4007
|
+
* If not set the value equals the identifier
|
|
4008
|
+
*/
|
|
4009
|
+
this.name = this.identifier;
|
|
4010
|
+
/**
|
|
4011
|
+
* Define if label is visible
|
|
4012
|
+
*/
|
|
4013
|
+
this.labelHide = false;
|
|
4014
|
+
/**
|
|
4015
|
+
* Input max length
|
|
4016
|
+
*/
|
|
4017
|
+
this.maxlength = 4000;
|
|
4018
|
+
/**
|
|
4019
|
+
* Define if input is required
|
|
4020
|
+
*/
|
|
4021
|
+
this.required = false;
|
|
4022
|
+
/**
|
|
4023
|
+
* Define if input is readonly
|
|
4024
|
+
*/
|
|
4025
|
+
this.readonly = false;
|
|
4026
|
+
/**
|
|
4027
|
+
* Define if input is disabled
|
|
4028
|
+
*/
|
|
4029
|
+
this.disabled = false;
|
|
4030
|
+
/**
|
|
4031
|
+
* Define input width
|
|
4032
|
+
*/
|
|
4033
|
+
this.mgWidth = 'full';
|
|
4034
|
+
/**
|
|
4035
|
+
* Define the number of visible text lines for the control
|
|
4036
|
+
*/
|
|
4037
|
+
this.rows = 3;
|
|
4038
|
+
/**
|
|
4039
|
+
* Define tooltip position
|
|
4040
|
+
*/
|
|
4041
|
+
this.tooltipPosition = 'input';
|
|
4042
|
+
/**
|
|
4043
|
+
* Define if component should display character left
|
|
4044
|
+
*/
|
|
4045
|
+
this.characterLeftHide = false;
|
|
4046
|
+
/**
|
|
4047
|
+
* Define if input is resizable
|
|
4048
|
+
*/
|
|
4049
|
+
this.resizable = 'none';
|
|
4050
|
+
/**
|
|
4051
|
+
* Component classes
|
|
4052
|
+
*/
|
|
4053
|
+
this.classCollection = new index_es.Ge(['mg-c-input--textarea']);
|
|
3663
4054
|
/**
|
|
3664
4055
|
* Handle input event
|
|
3665
4056
|
*/
|
|
@@ -3675,7 +4066,7 @@ const MgInputTextarea = class {
|
|
|
3675
4066
|
*/
|
|
3676
4067
|
this.handleFocus = () => {
|
|
3677
4068
|
this.classCollection.add(this.classFocus);
|
|
3678
|
-
this.classCollection = new index_es.
|
|
4069
|
+
this.classCollection = new index_es.Ge(this.classCollection.classes);
|
|
3679
4070
|
};
|
|
3680
4071
|
/**
|
|
3681
4072
|
* Handle blur event
|
|
@@ -3683,7 +4074,7 @@ const MgInputTextarea = class {
|
|
|
3683
4074
|
this.handleBlur = () => {
|
|
3684
4075
|
// Manage focus
|
|
3685
4076
|
this.classCollection.delete(this.classFocus);
|
|
3686
|
-
this.classCollection = new index_es.
|
|
4077
|
+
this.classCollection = new index_es.Ge(this.classCollection.classes);
|
|
3687
4078
|
// Display Error
|
|
3688
4079
|
this.handlerInProgress = 'blur';
|
|
3689
4080
|
this.displayError().finally(() => {
|
|
@@ -3724,30 +4115,6 @@ const MgInputTextarea = class {
|
|
|
3724
4115
|
}
|
|
3725
4116
|
}
|
|
3726
4117
|
};
|
|
3727
|
-
this.value = undefined;
|
|
3728
|
-
this.identifier = undefined;
|
|
3729
|
-
this.name = this.identifier;
|
|
3730
|
-
this.label = undefined;
|
|
3731
|
-
this.labelOnTop = undefined;
|
|
3732
|
-
this.labelHide = false;
|
|
3733
|
-
this.placeholder = undefined;
|
|
3734
|
-
this.maxlength = 4000;
|
|
3735
|
-
this.required = false;
|
|
3736
|
-
this.readonly = false;
|
|
3737
|
-
this.disabled = false;
|
|
3738
|
-
this.mgWidth = 'full';
|
|
3739
|
-
this.pattern = undefined;
|
|
3740
|
-
this.patternErrorMessage = undefined;
|
|
3741
|
-
this.rows = 3;
|
|
3742
|
-
this.tooltip = undefined;
|
|
3743
|
-
this.tooltipPosition = 'input';
|
|
3744
|
-
this.characterLeftHide = false;
|
|
3745
|
-
this.helpText = undefined;
|
|
3746
|
-
this.valid = undefined;
|
|
3747
|
-
this.invalid = undefined;
|
|
3748
|
-
this.resizable = 'none';
|
|
3749
|
-
this.classCollection = new index_es.Xe(['mg-c-input--textarea']);
|
|
3750
|
-
this.errorMessage = undefined;
|
|
3751
4118
|
}
|
|
3752
4119
|
handleValue(newValue) {
|
|
3753
4120
|
this.checkValidity();
|
|
@@ -3785,8 +4152,8 @@ const MgInputTextarea = class {
|
|
|
3785
4152
|
this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
|
|
3786
4153
|
}
|
|
3787
4154
|
validatePattern(newValue) {
|
|
3788
|
-
if (newValue !== undefined && !(index_es.
|
|
3789
|
-
throw new Error(`<mg-input-textarea> props "pattern" and "patternErrorMessage" must be non-empty string and paired. Passed value: "pattern='${index_es.
|
|
4155
|
+
if (newValue !== undefined && !(index_es.ye(this.pattern) && index_es.ye(this.patternErrorMessage))) {
|
|
4156
|
+
throw new Error(`<mg-input-textarea> props "pattern" and "patternErrorMessage" must be non-empty string and paired. Passed value: "pattern='${index_es.Je(this.pattern)}'" and "patternErrorMessage='${index_es.Je(this.patternErrorMessage)}'".`);
|
|
3790
4157
|
}
|
|
3791
4158
|
}
|
|
3792
4159
|
validatecharacterLeftHide(newValue) {
|
|
@@ -3800,10 +4167,21 @@ const MgInputTextarea = class {
|
|
|
3800
4167
|
/**
|
|
3801
4168
|
* Display input error if it exists.
|
|
3802
4169
|
*/
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
4170
|
+
displayError() {
|
|
4171
|
+
// Use `Promise` as requested for stencil method
|
|
4172
|
+
// Use `requestAnimationFrame` to ensure:
|
|
4173
|
+
// - DOM is fully updated before validation
|
|
4174
|
+
// - Async operations are completed
|
|
4175
|
+
// - No timing issues with Stencil's render cycle
|
|
4176
|
+
// - Keep everything in sync both inside and outside the component
|
|
4177
|
+
return new Promise(resolve => {
|
|
4178
|
+
requestAnimationFrame(() => {
|
|
4179
|
+
this.checkValidity();
|
|
4180
|
+
this.setErrorMessage();
|
|
4181
|
+
this.hasDisplayedError = this.invalid;
|
|
4182
|
+
resolve();
|
|
4183
|
+
});
|
|
4184
|
+
});
|
|
3807
4185
|
}
|
|
3808
4186
|
/**
|
|
3809
4187
|
* Set an error and display a custom error message.
|
|
@@ -3817,7 +4195,7 @@ const MgInputTextarea = class {
|
|
|
3817
4195
|
if (typeof valid !== 'boolean') {
|
|
3818
4196
|
throw new Error('<mg-input-textarea> method "setError()" param "valid" must be a boolean.');
|
|
3819
4197
|
}
|
|
3820
|
-
else if (!index_es.
|
|
4198
|
+
else if (!index_es.ye(errorMessage)) {
|
|
3821
4199
|
throw new Error('<mg-input-textarea> method "setError()" param "errorMessage" must be a string.');
|
|
3822
4200
|
}
|
|
3823
4201
|
else {
|
|
@@ -3879,7 +4257,7 @@ const MgInputTextarea = class {
|
|
|
3879
4257
|
* @returns HTML Element
|
|
3880
4258
|
*/
|
|
3881
4259
|
render() {
|
|
3882
|
-
return (index.h("mg-input", { key: '
|
|
4260
|
+
return (index.h("mg-input", { key: 'a7c6657511d21d8df9e11f7fb1bf3d2d42a01fa0', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [this.characterLeftId], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.value && index.h("b", { class: "mg-c-input__readonly-value" }, this.value)) : (index.h("div", { class: "mg-c-input__with-character-left" }, index.h("textarea", { class: {
|
|
3883
4261
|
'mg-c-input__box': true,
|
|
3884
4262
|
'mg-c-input__box--width': true,
|
|
3885
4263
|
'mg-c-input__box--resizable': this.resizable === 'both',
|
|
@@ -3910,18 +4288,21 @@ const MgInputTitleStyle0 = mgInputTitleCss;
|
|
|
3910
4288
|
const MgInputTitle = class {
|
|
3911
4289
|
constructor(hostRef) {
|
|
3912
4290
|
index.registerInstance(this, hostRef);
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
4291
|
+
/**
|
|
4292
|
+
* Switch from label to fieldset sementic
|
|
4293
|
+
*/
|
|
3916
4294
|
this.isLegend = false;
|
|
4295
|
+
/**
|
|
4296
|
+
* Component parent tagname
|
|
4297
|
+
*/
|
|
3917
4298
|
this.tagName = 'label';
|
|
3918
4299
|
}
|
|
3919
4300
|
validateIdentifier(newValue) {
|
|
3920
|
-
if (!index_es.
|
|
4301
|
+
if (!index_es.ye(newValue)) {
|
|
3921
4302
|
throw new Error('<mg-input-title> prop "identifier" is required.');
|
|
3922
4303
|
}
|
|
3923
|
-
else if (!index_es.
|
|
3924
|
-
console.error(`<mg-input-title> prop "identifier" value is invalid. Passed value: ${index_es.
|
|
4304
|
+
else if (!index_es.Ie(newValue)) {
|
|
4305
|
+
console.error(`<mg-input-title> prop "identifier" value is invalid. Passed value: ${index_es.Je(newValue)}.`);
|
|
3925
4306
|
}
|
|
3926
4307
|
}
|
|
3927
4308
|
validateIsLegend(newValue) {
|
|
@@ -3944,7 +4325,7 @@ const MgInputTitle = class {
|
|
|
3944
4325
|
render() {
|
|
3945
4326
|
const TagName = this.readonly ? 'span' : this.tagName;
|
|
3946
4327
|
// \u00A0 represent a
|
|
3947
|
-
return (index.h(TagName, { key: '
|
|
4328
|
+
return (index.h(TagName, { key: 'f8f8baaeb87e7c2cc77e71781f4d33ea5a63f760', class: "mg-c-input-title", htmlFor: !this.isLegend && this.identifier, id: this.isLegend ? `${this.identifier}-title` : undefined }, index.h("slot", { key: '7f6c0f451dfe789d924e9f608813e03bc72ad88a' }), this.required && !this.readonly && (index.h("span", { key: 'a78c5191995399e3e2ad346fec8546277581ca9d', class: "mg-c-input-title__required" }, "\u00A0", index.h("span", { key: 'ae8df5f13d54a1b8419d0d01048ff91dda601ab6', class: "mg-u-is-asterisk" }, "*")))));
|
|
3948
4329
|
}
|
|
3949
4330
|
static get watchers() { return {
|
|
3950
4331
|
"identifier": ["validateIdentifier"],
|
|
@@ -3974,6 +4355,43 @@ const MgInputToggle = class {
|
|
|
3974
4355
|
this.classIsActive = 'mg-c-input--toggle-is-active';
|
|
3975
4356
|
this.classOnOff = 'mg-c-input--toggle-on-off';
|
|
3976
4357
|
this.classIcon = 'mg-c-input--toggle-icon';
|
|
4358
|
+
/**
|
|
4359
|
+
* Input name
|
|
4360
|
+
* If not set the value equals the identifier
|
|
4361
|
+
*/
|
|
4362
|
+
this.name = this.identifier;
|
|
4363
|
+
/**
|
|
4364
|
+
* Define if label is visible
|
|
4365
|
+
*/
|
|
4366
|
+
this.labelHide = false;
|
|
4367
|
+
/**
|
|
4368
|
+
* Define if toggle have on/off style
|
|
4369
|
+
*/
|
|
4370
|
+
this.isOnOff = false;
|
|
4371
|
+
/**
|
|
4372
|
+
* Define if toggle display icon
|
|
4373
|
+
*/
|
|
4374
|
+
this.isIcon = false;
|
|
4375
|
+
/**
|
|
4376
|
+
* Define if input is readonly
|
|
4377
|
+
*/
|
|
4378
|
+
this.readonly = false;
|
|
4379
|
+
/**
|
|
4380
|
+
* Define if input is disabled
|
|
4381
|
+
*/
|
|
4382
|
+
this.disabled = false;
|
|
4383
|
+
/**
|
|
4384
|
+
* Define tooltip position
|
|
4385
|
+
*/
|
|
4386
|
+
this.tooltipPosition = 'input';
|
|
4387
|
+
/**
|
|
4388
|
+
* Component classes
|
|
4389
|
+
*/
|
|
4390
|
+
this.classCollection = new index_es.Ge(['mg-c-input--toggle']);
|
|
4391
|
+
/**
|
|
4392
|
+
* Checked internal value
|
|
4393
|
+
*/
|
|
4394
|
+
this.checked = false;
|
|
3977
4395
|
/**
|
|
3978
4396
|
* Set input error message
|
|
3979
4397
|
* @param errorMessage - errorMessage override
|
|
@@ -4020,25 +4438,6 @@ const MgInputToggle = class {
|
|
|
4020
4438
|
return null;
|
|
4021
4439
|
}
|
|
4022
4440
|
};
|
|
4023
|
-
this.value = undefined;
|
|
4024
|
-
this.items = undefined;
|
|
4025
|
-
this.identifier = undefined;
|
|
4026
|
-
this.name = this.identifier;
|
|
4027
|
-
this.label = undefined;
|
|
4028
|
-
this.labelOnTop = undefined;
|
|
4029
|
-
this.labelHide = false;
|
|
4030
|
-
this.isOnOff = false;
|
|
4031
|
-
this.isIcon = false;
|
|
4032
|
-
this.readonly = false;
|
|
4033
|
-
this.disabled = false;
|
|
4034
|
-
this.tooltip = undefined;
|
|
4035
|
-
this.tooltipPosition = 'input';
|
|
4036
|
-
this.helpText = undefined;
|
|
4037
|
-
this.classCollection = new index_es.Xe(['mg-c-input--toggle']);
|
|
4038
|
-
this.options = undefined;
|
|
4039
|
-
this.errorMessage = undefined;
|
|
4040
|
-
this.valid = undefined;
|
|
4041
|
-
this.checked = false;
|
|
4042
4441
|
}
|
|
4043
4442
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4044
4443
|
handleValue(newValue) {
|
|
@@ -4049,10 +4448,10 @@ const MgInputToggle = class {
|
|
|
4049
4448
|
}
|
|
4050
4449
|
validateItems(newValue) {
|
|
4051
4450
|
if (typeof newValue === 'object' && this.items.length !== 2) {
|
|
4052
|
-
throw new Error(`<mg-input-toggle> prop "items" require 2 items. Passed value: ${index_es.
|
|
4451
|
+
throw new Error(`<mg-input-toggle> prop "items" require 2 items. Passed value: ${index_es.Je(newValue)}.`);
|
|
4053
4452
|
}
|
|
4054
4453
|
// String array
|
|
4055
|
-
else if (index_es.
|
|
4454
|
+
else if (index_es.Xe(newValue)) {
|
|
4056
4455
|
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
4057
4456
|
}
|
|
4058
4457
|
// Object array
|
|
@@ -4060,7 +4459,7 @@ const MgInputToggle = class {
|
|
|
4060
4459
|
this.options = newValue;
|
|
4061
4460
|
}
|
|
4062
4461
|
else {
|
|
4063
|
-
throw new Error(`<mg-input-toggle> prop "items" is required and all items must be the same type: ToggleValue. Passed value: ${index_es.
|
|
4462
|
+
throw new Error(`<mg-input-toggle> prop "items" is required and all items must be the same type: ToggleValue. Passed value: ${index_es.Je(newValue)}.`);
|
|
4064
4463
|
}
|
|
4065
4464
|
}
|
|
4066
4465
|
watchIsOnOff(newValue) {
|
|
@@ -4108,7 +4507,7 @@ const MgInputToggle = class {
|
|
|
4108
4507
|
if (typeof valid !== 'boolean') {
|
|
4109
4508
|
throw new Error('<mg-input-toggle> method "setError()" param "valid" must be a boolean.');
|
|
4110
4509
|
}
|
|
4111
|
-
else if (!index_es.
|
|
4510
|
+
else if (!index_es.ye(errorMessage)) {
|
|
4112
4511
|
throw new Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string.');
|
|
4113
4512
|
}
|
|
4114
4513
|
else {
|
|
@@ -4175,7 +4574,7 @@ const MgInputToggle = class {
|
|
|
4175
4574
|
*/
|
|
4176
4575
|
render() {
|
|
4177
4576
|
const checkedItem = this.getCheckedItem(this.checked);
|
|
4178
|
-
return (index.h("mg-input", { key: '
|
|
4577
|
+
return (index.h("mg-input", { key: '769507fe4a474312d399cc356682221b5d8f3267', label: this.label, helpText: this.helpText, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, errorMessage: this.errorMessage }, this.readonly ? (checkedItem && index.h("b", { class: "mg-c-input__readonly-value" }, checkedItem.title)) : (index.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 }, index.h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, index.h("slot", { name: "item-1" })), index.h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, index.h("slot", { name: "item-2" }))))));
|
|
4179
4578
|
}
|
|
4180
4579
|
get element() { return index.getElement(this); }
|
|
4181
4580
|
static get watchers() { return {
|
|
@@ -4191,19 +4590,13 @@ const MgInputToggle = class {
|
|
|
4191
4590
|
MgInputToggle.style = MgInputToggleStyle0;
|
|
4192
4591
|
|
|
4193
4592
|
/**
|
|
4194
|
-
*
|
|
4195
|
-
* @param element - element to control type
|
|
4196
|
-
* @returns truthy if element is mg-item-more
|
|
4593
|
+
*
|
|
4197
4594
|
*/
|
|
4198
|
-
const isMgItemMore = (element) => element.nodeName === 'MG-ITEM-MORE';
|
|
4199
|
-
const OverflowBehaviorElements = {
|
|
4200
|
-
BASE_INDEX: 'data-overflow-base-index',
|
|
4201
|
-
PROXY_INDEX: 'data-overflow-proxy-index',
|
|
4202
|
-
};
|
|
4203
4595
|
class OverflowBehavior {
|
|
4204
|
-
constructor(
|
|
4205
|
-
this.
|
|
4206
|
-
this.
|
|
4596
|
+
constructor(parentElement, itemMoreElement, itemMoreContainerElement) {
|
|
4597
|
+
this.parentElement = parentElement;
|
|
4598
|
+
this.itemMoreElement = itemMoreElement;
|
|
4599
|
+
this.itemMoreContainerElement = itemMoreContainerElement;
|
|
4207
4600
|
/**********
|
|
4208
4601
|
* Public *
|
|
4209
4602
|
**********/
|
|
@@ -4217,116 +4610,59 @@ class OverflowBehavior {
|
|
|
4217
4610
|
* Internal *
|
|
4218
4611
|
************/
|
|
4219
4612
|
/**
|
|
4220
|
-
*
|
|
4221
|
-
* @param
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
// set moreElement
|
|
4226
|
-
this._moreElement = this.render();
|
|
4227
|
-
// set children
|
|
4228
|
-
this._baseChildren = this.getInteractiveItems(this.element);
|
|
4229
|
-
if (isMgItemMore(this._moreElement)) {
|
|
4230
|
-
this._proxyChildren = this.getInteractiveItems(this._moreElement.shadowRoot.querySelector('mg-menu'));
|
|
4231
|
-
}
|
|
4232
|
-
// update children
|
|
4233
|
-
this._baseChildren.forEach((child, index) => {
|
|
4234
|
-
child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);
|
|
4235
|
-
// set moreElement children
|
|
4236
|
-
this._proxyChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);
|
|
4237
|
-
});
|
|
4238
|
-
}
|
|
4239
|
-
if (width !== undefined)
|
|
4240
|
-
this.updateDisplayedItems(width);
|
|
4241
|
-
};
|
|
4242
|
-
/**
|
|
4243
|
-
* Get interactive children filtred by authorized nodeName ['MG-MENU-ITEM', 'MG-BUTTON']
|
|
4244
|
-
* @param element - element to parse
|
|
4245
|
-
* @returns children
|
|
4246
|
-
*/
|
|
4247
|
-
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)); };
|
|
4248
|
-
/**
|
|
4249
|
-
* Update displayed items in container from a given available space
|
|
4250
|
-
* @param availableWidth - available width in container to display child items
|
|
4251
|
-
*/
|
|
4252
|
-
this.updateDisplayedItems = (availableWidth) => {
|
|
4253
|
-
this.restoreItems();
|
|
4254
|
-
const acc = { accWidth: 0, previousItem: null };
|
|
4255
|
-
[...this._baseChildren, this._moreElement].forEach((child) => {
|
|
4256
|
-
acc.accWidth += child.offsetWidth;
|
|
4257
|
-
const hasPreviuosItem = acc.previousItem !== null;
|
|
4258
|
-
const isPreviousItemHidden = hasPreviuosItem && acc.previousItem.hasAttribute('hidden');
|
|
4259
|
-
// if previous item is hidden AND is NOT more element we hide current
|
|
4260
|
-
// OR if item has an overflow we hide current
|
|
4261
|
-
// OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item
|
|
4262
|
-
// ELSE current is a display item
|
|
4263
|
-
this.toggleItem(child, (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden));
|
|
4264
|
-
// update previous item with current item
|
|
4265
|
-
acc.previousItem = child;
|
|
4266
|
-
});
|
|
4267
|
-
};
|
|
4613
|
+
* Utility method to know if element is HTMLMgItemMoreElement
|
|
4614
|
+
* @param element - element to match with 'MORE' element
|
|
4615
|
+
* @returns truthy if element is the 'MORE' element
|
|
4616
|
+
*/
|
|
4617
|
+
this.isMoreElement = (element) => element === this.itemMoreElement;
|
|
4268
4618
|
/**
|
|
4269
4619
|
* Utility method to know if item overflow partialy or totaly in the container
|
|
4270
4620
|
* @param cumulateWidth - previous sibling elements cumulate width + item width
|
|
4271
4621
|
* @param item - item HTML element
|
|
4272
|
-
* @param availableWidth - container available width
|
|
4273
4622
|
* @returns truthy if element is overflow
|
|
4274
4623
|
*/
|
|
4275
|
-
this.isOverflowElement = (cumulateWidth, item
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
};
|
|
4283
|
-
/**
|
|
4284
|
-
* Utility method to know if a given element is the 'MORE' element
|
|
4285
|
-
* @param element - element to match with 'MORE' element
|
|
4286
|
-
* @returns truthy if element is the 'MORE' element
|
|
4287
|
-
*/
|
|
4288
|
-
this.isMoreElement = (element) => element.nodeName === 'MG-ITEM-MORE';
|
|
4289
|
-
/**
|
|
4290
|
-
* Toggle display item element
|
|
4291
|
-
* @param item - item to control
|
|
4292
|
-
* @param isHidden - is item hidden
|
|
4293
|
-
*/
|
|
4294
|
-
this.toggleItem = (item, isHidden) => {
|
|
4295
|
-
const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));
|
|
4296
|
-
if (this.isMoreElement(item))
|
|
4297
|
-
this.toggleElement(this._moreElement, isHidden);
|
|
4298
|
-
else if (mgActionMenuindex >= 0) {
|
|
4299
|
-
this.toggleElement(item, isHidden);
|
|
4300
|
-
this.toggleElement(this._proxyChildren[mgActionMenuindex], !isHidden);
|
|
4624
|
+
this.isOverflowElement = (cumulateWidth, item) => {
|
|
4625
|
+
const displayMgItemMore = this.itemMoreContainerElement.children.length > 0;
|
|
4626
|
+
if (!this.isMoreElement(item)) {
|
|
4627
|
+
if (item.nextElementSibling.nodeName !== 'MG-ITEM-MORE' && !displayMgItemMore)
|
|
4628
|
+
return cumulateWidth + this.itemMoreElement.offsetWidth > this._availableWidth;
|
|
4629
|
+
else
|
|
4630
|
+
return cumulateWidth > this._availableWidth;
|
|
4301
4631
|
}
|
|
4302
|
-
};
|
|
4303
|
-
/**
|
|
4304
|
-
* Toggle element's hide attribute
|
|
4305
|
-
* @param element - element to toggle
|
|
4306
|
-
* @param isHidden - element is hidden
|
|
4307
|
-
*/
|
|
4308
|
-
this.toggleElement = (element, isHidden) => {
|
|
4309
|
-
if (isHidden)
|
|
4310
|
-
element.setAttribute('hidden', '');
|
|
4311
4632
|
else
|
|
4312
|
-
|
|
4633
|
+
return !displayMgItemMore;
|
|
4313
4634
|
};
|
|
4314
4635
|
/**
|
|
4315
|
-
*
|
|
4636
|
+
* Toogle item from isHidden condition
|
|
4637
|
+
* @param item - item to update
|
|
4638
|
+
* @param isHidden - item is hidden
|
|
4316
4639
|
*/
|
|
4317
|
-
this.
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4640
|
+
this.toggleItem = (item, isHidden) => {
|
|
4641
|
+
if (this.isMoreElement(item) && isHidden)
|
|
4642
|
+
item.setAttribute('hidden', '');
|
|
4643
|
+
else if (this.isMoreElement(item) && !isHidden)
|
|
4644
|
+
item.removeAttribute('hidden');
|
|
4645
|
+
else if (!this.isMoreElement(item) && isHidden)
|
|
4646
|
+
this.itemMoreContainerElement.appendChild(item);
|
|
4647
|
+
else if (!this.isMoreElement(item) && item.parentElement !== this.parentElement)
|
|
4648
|
+
this.parentElement.insertBefore(item, this.itemMoreElement);
|
|
4649
|
+
};
|
|
4650
|
+
if (!this.parentElement || !this.itemMoreElement || !this.itemMoreContainerElement) {
|
|
4651
|
+
throw new Error('OverflowBehavior - all construtor params are required');
|
|
4652
|
+
}
|
|
4653
|
+
const items = Array.from(this.parentElement.children);
|
|
4654
|
+
this._resizeObserver = new ResizeObserver(entries => {
|
|
4655
|
+
this._availableWidth = entries.map(entry => entry.contentRect.width).sort((a, b) => a - b).shift();
|
|
4656
|
+
// reset items
|
|
4657
|
+
items.forEach(item => this.toggleItem(item, false));
|
|
4658
|
+
let accWidth = 0;
|
|
4659
|
+
items.forEach((item, index) => {
|
|
4660
|
+
accWidth += item.offsetWidth;
|
|
4661
|
+
if (index)
|
|
4662
|
+
this.toggleItem(item, this.isOverflowElement(accWidth, item));
|
|
4326
4663
|
});
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
this.run();
|
|
4664
|
+
});
|
|
4665
|
+
this._resizeObserver.observe(this.parentElement);
|
|
4330
4666
|
}
|
|
4331
4667
|
}
|
|
4332
4668
|
|
|
@@ -4341,86 +4677,27 @@ const MgItemMore = class {
|
|
|
4341
4677
|
************/
|
|
4342
4678
|
this.name = 'mg-item-more';
|
|
4343
4679
|
/**
|
|
4344
|
-
*
|
|
4345
|
-
* @param proxified - element to proxify from
|
|
4680
|
+
* Define icon
|
|
4346
4681
|
*/
|
|
4347
|
-
this.setProxyElement = (proxified) => {
|
|
4348
|
-
const proxy = this.moreElementMenuItem.querySelector(`[identifier="${proxified.identifier}"]`);
|
|
4349
|
-
if (proxy === null) {
|
|
4350
|
-
return;
|
|
4351
|
-
}
|
|
4352
|
-
// remove proxy id to prevent duplicate key. default html id is: '';
|
|
4353
|
-
if (index_es.me(proxy.id))
|
|
4354
|
-
proxy.id = '';
|
|
4355
|
-
const proxyClickHandler = () => {
|
|
4356
|
-
this.parentMenu
|
|
4357
|
-
.querySelector(`[identifier="${proxy.identifier}"]`)
|
|
4358
|
-
.shadowRoot.querySelector('a, button')
|
|
4359
|
-
.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
4360
|
-
};
|
|
4361
|
-
// Watch the `item-updated` event to keep element needeed properties and innerHTML in sync between the proxified and the proxy elements
|
|
4362
|
-
const updateProxy = (element) => {
|
|
4363
|
-
for (const key in element) {
|
|
4364
|
-
if (['identifier', 'href', 'targer', 'status', 'expanded'].includes(key))
|
|
4365
|
-
element[key] ? proxy.setAttribute(key, element[key]) : proxy.removeAttribute(key);
|
|
4366
|
-
}
|
|
4367
|
-
proxy.innerHTML = element.innerHTML;
|
|
4368
|
-
// When `href` is updated we need to wait the full component re-render before update its handler
|
|
4369
|
-
setTimeout(() => {
|
|
4370
|
-
const interactiveElement = proxy.shadowRoot.querySelector('a, button');
|
|
4371
|
-
interactiveElement === null || interactiveElement === void 0 ? void 0 : interactiveElement.removeEventListener('click', proxyClickHandler);
|
|
4372
|
-
interactiveElement === null || interactiveElement === void 0 ? void 0 : interactiveElement.addEventListener('click', proxyClickHandler);
|
|
4373
|
-
});
|
|
4374
|
-
};
|
|
4375
|
-
updateProxy(proxified);
|
|
4376
|
-
proxified.addEventListener('item-updated', event => {
|
|
4377
|
-
updateProxy(event.target);
|
|
4378
|
-
});
|
|
4379
|
-
// update click event listener on proxy item and mirror the event on the main menu element
|
|
4380
|
-
// we need to wait mg-menu-item to be loaded to ensure the shadowroot is rendered
|
|
4381
|
-
proxy.addEventListener('item-loaded', () => {
|
|
4382
|
-
updateProxy(proxified);
|
|
4383
|
-
});
|
|
4384
|
-
};
|
|
4385
|
-
/***********
|
|
4386
|
-
* Methods *
|
|
4387
|
-
***********/
|
|
4388
|
-
/**
|
|
4389
|
-
* render mg-item-more overflow element
|
|
4390
|
-
* @returns mg-item-more element
|
|
4391
|
-
*/
|
|
4392
|
-
this.renderMgMenuItemOverflowElement = () => {
|
|
4393
|
-
this.parentMenuItems.forEach((child) => {
|
|
4394
|
-
// create item-more menu items element from main menu-items clones
|
|
4395
|
-
this.moreElementMenuItem.querySelector('mg-menu').appendChild(child.cloneNode(true));
|
|
4396
|
-
// we need to get all `mg-menu-item` linked to the cloned one to set mirror process
|
|
4397
|
-
index_es.tt(() => {
|
|
4398
|
-
this.setProxyElement(child);
|
|
4399
|
-
if (child.querySelector('mg-menu') !== null) {
|
|
4400
|
-
child.querySelectorAll('mg-menu-item').forEach(this.setProxyElement);
|
|
4401
|
-
}
|
|
4402
|
-
});
|
|
4403
|
-
});
|
|
4404
|
-
return this.element;
|
|
4405
|
-
};
|
|
4406
4682
|
this.icon = { icon: 'ellipsis-vertical' };
|
|
4683
|
+
/**
|
|
4684
|
+
* Define slot label element
|
|
4685
|
+
*/
|
|
4407
4686
|
this.slotlabel = { display: false };
|
|
4408
|
-
this.size = undefined;
|
|
4409
|
-
this.parentMenu = undefined;
|
|
4410
4687
|
}
|
|
4411
4688
|
validateIcon(newValue) {
|
|
4412
4689
|
if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.icon !== 'string'))
|
|
4413
|
-
throw new Error(`<${this.name}> prop "icon" must match MgItemMore['icon'] type. Passed value: ${index_es.
|
|
4690
|
+
throw new Error(`<${this.name}> prop "icon" must match MgItemMore['icon'] type. Passed value: ${index_es.Je(newValue)}.`);
|
|
4414
4691
|
}
|
|
4415
4692
|
validateSlotLabel(newValue) {
|
|
4416
4693
|
if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.display !== 'boolean'))
|
|
4417
|
-
throw new Error(`<${this.name}> prop "slotlabel" must match MgItemMore['slotlabel'] type. Passed value: ${index_es.
|
|
4694
|
+
throw new Error(`<${this.name}> prop "slotlabel" must match MgItemMore['slotlabel'] type. Passed value: ${index_es.Je(newValue)}.`);
|
|
4418
4695
|
else if (typeof newValue.label !== 'string')
|
|
4419
4696
|
this.slotlabel.label = this.messages.menuLabel;
|
|
4420
4697
|
}
|
|
4421
4698
|
validateSize(newValue) {
|
|
4422
|
-
if (newValue && !sizes$
|
|
4423
|
-
throw new Error(`<${this.name}> prop "size" must match MgItemMore['size'] type. Passed value: ${index_es.
|
|
4699
|
+
if (newValue && !sizes$3.includes(newValue))
|
|
4700
|
+
throw new Error(`<${this.name}> prop "size" must match MgItemMore['size'] type. Passed value: ${index_es.Je(newValue)}.`);
|
|
4424
4701
|
}
|
|
4425
4702
|
/*************
|
|
4426
4703
|
* Lifecycle *
|
|
@@ -4451,8 +4728,7 @@ const MgItemMore = class {
|
|
|
4451
4728
|
*/
|
|
4452
4729
|
componentDidUpdate() {
|
|
4453
4730
|
if (this.parentMenu && this.overflowBehavior === undefined) {
|
|
4454
|
-
this.
|
|
4455
|
-
this.overflowBehavior = new OverflowBehavior(this.parentMenu, this.renderMgMenuItemOverflowElement);
|
|
4731
|
+
this.overflowBehavior = new OverflowBehavior(this.parentMenu, this.element, this.itemMoreContainer);
|
|
4456
4732
|
}
|
|
4457
4733
|
}
|
|
4458
4734
|
/**
|
|
@@ -4467,11 +4743,11 @@ const MgItemMore = class {
|
|
|
4467
4743
|
* @returns HTML Element
|
|
4468
4744
|
*/
|
|
4469
4745
|
render() {
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
} }
|
|
4746
|
+
const menuItemIdentifier = "mg-item-more";
|
|
4747
|
+
return (index.h(index.Host, { key: '522fc142a992fa450b2d102e2c053fcd25704dcc', role: "listitem", "data-mg-popover-guard": `${menuItemIdentifier}-popover` }, this.parentMenu && (index.h("mg-menu-item", { key: 'c05fb5c0379656b9634beca745b3b74d36c8e46c', "data-overflow-more": true, "data-size": this.parentMenu.size, "data-style-direction": Direction.HORIZONTAL, identifier: menuItemIdentifier }, index.h("mg-icon", { key: 'e40f07ce8c55c30ef79a42ddb973d884ab289427', icon: this.icon.icon, size: this.size, slot: "image" }), index.h("span", { key: '3b38b9362a023df9e53733bf810c4f37a0016a93', class: { 'mg-u-visually-hidden': !this.slotlabel.display }, slot: "label" }, this.slotlabel.label), index.h("mg-menu", { key: '4f20389326507261356d897dd25e676ac37ca5bb', direction: Direction.VERTICAL, label: this.messages.menuLabel, size: this.size, ref: (ref) => {
|
|
4748
|
+
if (ref !== null)
|
|
4749
|
+
this.itemMoreContainer = ref;
|
|
4750
|
+
} })))));
|
|
4475
4751
|
}
|
|
4476
4752
|
get element() { return index.getElement(this); }
|
|
4477
4753
|
static get watchers() { return {
|
|
@@ -4482,7 +4758,7 @@ const MgItemMore = class {
|
|
|
4482
4758
|
};
|
|
4483
4759
|
MgItemMore.style = MgItemMoreStyle0;
|
|
4484
4760
|
|
|
4485
|
-
const mgMenuCss = ".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}}/*!\n * @prop --mg-c-menu-color-background: Defines the background color of the menu. Unset by default, fallback on `--mg-b-color-light`.\n */:host{display:flex;background-color:var(--mg-c-menu-color-background, var(--mg-b-color-light))}:host([direction=vertical]){height:100%;flex-direction:column;overflow-y:auto}";
|
|
4761
|
+
const mgMenuCss = ".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}}/*!\n * @prop --mg-c-menu-color-background: Defines the background color of the menu. Unset by default, fallback on `--mg-b-color-light`.\n */:host{display:inline-flex;width:100%;background-color:var(--mg-c-menu-color-background, var(--mg-b-color-light))}:host([direction=vertical]){display:flex;height:100%;flex-direction:column;overflow-y:auto}";
|
|
4486
4762
|
const MgMenuStyle0 = mgMenuCss;
|
|
4487
4763
|
|
|
4488
4764
|
const MgMenu = class {
|
|
@@ -4492,100 +4768,78 @@ const MgMenu = class {
|
|
|
4492
4768
|
* Internal *
|
|
4493
4769
|
************/
|
|
4494
4770
|
this.name = 'mg-menu';
|
|
4495
|
-
this.menuItems = [];
|
|
4496
|
-
this.focusedMenuItem = 0;
|
|
4497
|
-
/*************
|
|
4498
|
-
* Methods *
|
|
4499
|
-
*************/
|
|
4500
4771
|
/**
|
|
4501
|
-
*
|
|
4502
|
-
* @param item - menu-item to close
|
|
4503
|
-
* @param condition - addionnal condition
|
|
4772
|
+
* Component display direction.
|
|
4504
4773
|
*/
|
|
4505
|
-
this.
|
|
4506
|
-
if (!this.isChildMenu && condition) {
|
|
4507
|
-
item.expanded = false;
|
|
4508
|
-
}
|
|
4509
|
-
};
|
|
4774
|
+
this.direction = Direction.HORIZONTAL;
|
|
4510
4775
|
/**
|
|
4511
|
-
*
|
|
4512
|
-
* @returns mg-menu-item element
|
|
4776
|
+
* Define mg-menu size
|
|
4513
4777
|
*/
|
|
4514
|
-
this.
|
|
4778
|
+
this.size = 'medium';
|
|
4779
|
+
/*************
|
|
4780
|
+
* Methods *
|
|
4781
|
+
*************/
|
|
4515
4782
|
/**
|
|
4516
|
-
*
|
|
4517
|
-
* @
|
|
4518
|
-
* @param index - number
|
|
4783
|
+
* Test if menu is a child menu
|
|
4784
|
+
* @returns truthy if menu is a child menu
|
|
4519
4785
|
*/
|
|
4520
|
-
this.
|
|
4521
|
-
['click', 'focus'].forEach(trigger => {
|
|
4522
|
-
item.shadowRoot.querySelector('button,a').addEventListener(trigger, () => {
|
|
4523
|
-
this.focusedMenuItem = index;
|
|
4524
|
-
// reset expanded on previous active menu item
|
|
4525
|
-
const itemMoreMenuItem = this.getItemMoreMenuItem();
|
|
4526
|
-
(![null, undefined].includes(itemMoreMenuItem) ? [...this.menuItems, itemMoreMenuItem] : this.menuItems).forEach((item, index) => {
|
|
4527
|
-
this.closeMenuItem(item, index !== this.focusedMenuItem);
|
|
4528
|
-
});
|
|
4529
|
-
});
|
|
4530
|
-
});
|
|
4531
|
-
};
|
|
4786
|
+
this.isChildMenu = () => this.element.closest('mg-menu-item') !== null;
|
|
4532
4787
|
/**
|
|
4533
|
-
*
|
|
4788
|
+
* Get menu children items
|
|
4789
|
+
* @returns menu children mg-menu-item
|
|
4534
4790
|
*/
|
|
4535
|
-
this.
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4791
|
+
this.getMenuItems = (menu = this.element) => {
|
|
4792
|
+
var _a, _b;
|
|
4793
|
+
const menuItems = Array.from(menu.children).filter(child => child.nodeName === 'MG-MENU-ITEM');
|
|
4794
|
+
const itemMoreMenuItem = (_b = (_a = menu.querySelector('mg-item-more')) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mg-menu-item');
|
|
4795
|
+
if (itemMoreMenuItem) {
|
|
4796
|
+
menuItems.push(itemMoreMenuItem);
|
|
4797
|
+
}
|
|
4798
|
+
return menuItems;
|
|
4540
4799
|
};
|
|
4541
4800
|
/**
|
|
4542
|
-
*
|
|
4801
|
+
* Update menu items
|
|
4543
4802
|
*/
|
|
4544
|
-
this.
|
|
4545
|
-
this.
|
|
4803
|
+
this.updateMenuItems = () => {
|
|
4804
|
+
this.getMenuItems().forEach((item) => {
|
|
4805
|
+
item.dataset.styleDirection = this.direction;
|
|
4806
|
+
});
|
|
4807
|
+
// render mg-item-more to manage OverflowBehavior
|
|
4808
|
+
this.renderMgItemMore();
|
|
4546
4809
|
};
|
|
4547
4810
|
/**
|
|
4548
4811
|
* render mg-item-more
|
|
4549
4812
|
*/
|
|
4550
4813
|
this.renderMgItemMore = () => {
|
|
4551
4814
|
var _a;
|
|
4552
|
-
if (this.direction
|
|
4815
|
+
if (this.direction === Direction.VERTICAL || this.direction === Direction.HORIZONTAL && this.isChildMenu() || this.element.children.length <= 1) {
|
|
4553
4816
|
return;
|
|
4554
4817
|
}
|
|
4555
4818
|
// Insert mg-item-more outside the mg-menu shadowdom
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
this.element.appendChild(
|
|
4819
|
+
let itemMoreElement = this.element.querySelector('mg-item-more');
|
|
4820
|
+
if (itemMoreElement === null) {
|
|
4821
|
+
itemMoreElement = document.createElement('mg-item-more');
|
|
4822
|
+
this.element.appendChild(itemMoreElement);
|
|
4560
4823
|
}
|
|
4561
4824
|
// update mg-item-more props
|
|
4562
|
-
for (const
|
|
4563
|
-
|
|
4564
|
-
// to improve rendering we use HTML attributes as much as possible
|
|
4565
|
-
if (['string', 'number'].includes(typeof newValue)) {
|
|
4566
|
-
this.itemMoreElement.setAttribute(attribute, newValue);
|
|
4567
|
-
}
|
|
4568
|
-
else {
|
|
4569
|
-
this.itemMoreElement[attribute] = newValue;
|
|
4570
|
-
}
|
|
4825
|
+
for (const propertie in this.itemmore) {
|
|
4826
|
+
itemMoreElement[propertie] = this.itemmore[propertie];
|
|
4571
4827
|
}
|
|
4572
4828
|
if (((_a = this.itemmore) === null || _a === void 0 ? void 0 : _a.size) === undefined)
|
|
4573
|
-
|
|
4829
|
+
itemMoreElement.size = this.size;
|
|
4574
4830
|
};
|
|
4575
|
-
this.label = undefined;
|
|
4576
|
-
this.direction = Direction.HORIZONTAL;
|
|
4577
|
-
this.itemmore = undefined;
|
|
4578
|
-
this.size = 'medium';
|
|
4579
|
-
this.isChildMenu = undefined;
|
|
4580
4831
|
}
|
|
4581
4832
|
validateLabel(newValue) {
|
|
4582
4833
|
if (newValue === undefined && !this.element.hasAttribute('aria-label')) {
|
|
4583
|
-
throw new Error(`<${this.name}> prop "label" is required. Passed value: ${index_es.
|
|
4834
|
+
throw new Error(`<${this.name}> prop "label" is required. Passed value: ${index_es.Je(newValue)}.`);
|
|
4584
4835
|
}
|
|
4585
4836
|
}
|
|
4586
4837
|
validateDirection(newValue) {
|
|
4587
4838
|
if (![Direction.VERTICAL, Direction.HORIZONTAL].includes(newValue)) {
|
|
4588
|
-
throw new Error(`<${this.name}> prop "direction" must be one of: ${Direction.HORIZONTAL}, ${Direction.VERTICAL}. Passed value: ${index_es.
|
|
4839
|
+
throw new Error(`<${this.name}> prop "direction" must be one of: ${Direction.HORIZONTAL}, ${Direction.VERTICAL}. Passed value: ${index_es.Je(newValue)}.`);
|
|
4840
|
+
}
|
|
4841
|
+
else {
|
|
4842
|
+
this.updateMenuItems();
|
|
4589
4843
|
}
|
|
4590
4844
|
}
|
|
4591
4845
|
validateItemMore(newValue) {
|
|
@@ -4597,10 +4851,31 @@ const MgMenu = class {
|
|
|
4597
4851
|
}
|
|
4598
4852
|
}
|
|
4599
4853
|
validateSize(newValue) {
|
|
4600
|
-
if (!sizes$
|
|
4601
|
-
throw new Error(`<${this.name}> prop "size" must be one of: ${sizes$
|
|
4854
|
+
if (!sizes$3.includes(newValue)) {
|
|
4855
|
+
throw new Error(`<${this.name}> prop "size" must be one of: ${sizes$3.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
4602
4856
|
}
|
|
4603
4857
|
}
|
|
4858
|
+
/**
|
|
4859
|
+
* Define mg-menu-item listener when they are loaded
|
|
4860
|
+
* @param event - mg-item-loaded "item-loaded" custom event
|
|
4861
|
+
*/
|
|
4862
|
+
updateItemListener(event) {
|
|
4863
|
+
const itemToWatch = event.target.nodeName === 'MG-ITEM-MORE' ? event.target.shadowRoot.querySelector('mg-menu-item') : event.target;
|
|
4864
|
+
['click', 'focus'].forEach(trigger => {
|
|
4865
|
+
itemToWatch.addEventListener(trigger, () => {
|
|
4866
|
+
const focusedItem = event.target.closest('mg-menu').querySelector('[data-has-focus]');
|
|
4867
|
+
// exit process if new focused item in the current menu children
|
|
4868
|
+
if (focusedItem === itemToWatch)
|
|
4869
|
+
return;
|
|
4870
|
+
// reset expanded on previous active menu item
|
|
4871
|
+
if (focusedItem)
|
|
4872
|
+
focusedItem.removeAttribute("data-has-focus");
|
|
4873
|
+
// update focusedMenuItem with new value
|
|
4874
|
+
itemToWatch.setAttribute('data-has-focus', 'true');
|
|
4875
|
+
});
|
|
4876
|
+
});
|
|
4877
|
+
}
|
|
4878
|
+
;
|
|
4604
4879
|
/*************
|
|
4605
4880
|
* Lifecycle *
|
|
4606
4881
|
*************/
|
|
@@ -4615,37 +4890,38 @@ const MgMenu = class {
|
|
|
4615
4890
|
}
|
|
4616
4891
|
/**
|
|
4617
4892
|
* Check if component slots configuration
|
|
4618
|
-
* @returns timeout
|
|
4619
4893
|
*/
|
|
4620
4894
|
componentDidLoad() {
|
|
4621
|
-
//
|
|
4622
|
-
|
|
4623
|
-
//
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4895
|
+
// set menu-items
|
|
4896
|
+
this.updateMenuItems();
|
|
4897
|
+
// add listener to close main menu when focus leave it
|
|
4898
|
+
if (!this.isChildMenu() && this.direction === Direction.HORIZONTAL) {
|
|
4899
|
+
document.addEventListener('focusin', (event) => {
|
|
4900
|
+
const isElementChild = (element) => {
|
|
4901
|
+
if (element === this.element)
|
|
4902
|
+
return true;
|
|
4903
|
+
else if (!element.parentElement)
|
|
4904
|
+
return false;
|
|
4905
|
+
else
|
|
4906
|
+
return isElementChild(element.parentElement);
|
|
4907
|
+
};
|
|
4908
|
+
if (!event.target.closest('mg-menu') || !isElementChild(event.target)) {
|
|
4909
|
+
const focusedItem = this.element.querySelector('[data-has-focus]');
|
|
4910
|
+
// reset expanded on previous active menu item
|
|
4911
|
+
if (focusedItem)
|
|
4912
|
+
focusedItem.removeAttribute('data-has-focus');
|
|
4913
|
+
}
|
|
4914
|
+
});
|
|
4915
|
+
}
|
|
4916
|
+
// add mutation observer to improve global reactivity
|
|
4917
|
+
new MutationObserver(this.updateMenuItems).observe(this.element, { childList: true });
|
|
4642
4918
|
}
|
|
4643
4919
|
/**
|
|
4644
4920
|
* Render
|
|
4645
4921
|
* @returns HTML Element
|
|
4646
4922
|
*/
|
|
4647
4923
|
render() {
|
|
4648
|
-
return (index.h(index.Host, { key: '
|
|
4924
|
+
return (index.h(index.Host, { key: 'eb78530a80f841391df90167523b6d446cd5405e', role: "list", "aria-label": this.label }, index.h("slot", { key: '1a8839c831a81915de8a5b03ebe1481a32762217' })));
|
|
4649
4925
|
}
|
|
4650
4926
|
get element() { return index.getElement(this); }
|
|
4651
4927
|
static get watchers() { return {
|
|
@@ -4663,7 +4939,6 @@ const MgMenuItemStyle0 = mgMenuItemCss;
|
|
|
4663
4939
|
const MgMenuItem = class {
|
|
4664
4940
|
constructor(hostRef) {
|
|
4665
4941
|
index.registerInstance(this, hostRef);
|
|
4666
|
-
this.statusChange = index.createEvent(this, "status-change", 7);
|
|
4667
4942
|
this.itemLoaded = index.createEvent(this, "item-loaded", 7);
|
|
4668
4943
|
this.itemUpdated = index.createEvent(this, "item-updated", 7);
|
|
4669
4944
|
/************
|
|
@@ -4671,15 +4946,39 @@ const MgMenuItem = class {
|
|
|
4671
4946
|
************/
|
|
4672
4947
|
this.name = 'mg-menu-item';
|
|
4673
4948
|
this.navigationButton = 'mg-c-menu-item__navigation-button';
|
|
4949
|
+
/************
|
|
4950
|
+
* Props *
|
|
4951
|
+
************/
|
|
4952
|
+
/**
|
|
4953
|
+
* Identifier is used to control mg-popover
|
|
4954
|
+
*/
|
|
4955
|
+
this.identifier = index_es.ze('mg-menu-item');
|
|
4956
|
+
/**
|
|
4957
|
+
* Define menu-item status.
|
|
4958
|
+
*/
|
|
4959
|
+
this.status = Status$1.VISIBLE;
|
|
4960
|
+
/**
|
|
4961
|
+
* Define menu-item content expanded.
|
|
4962
|
+
*/
|
|
4963
|
+
this.expanded = false;
|
|
4964
|
+
/**********
|
|
4965
|
+
* States *
|
|
4966
|
+
*********/
|
|
4967
|
+
/**
|
|
4968
|
+
* Define menu-item size.
|
|
4969
|
+
*/
|
|
4970
|
+
this.size = 'medium';
|
|
4971
|
+
/**
|
|
4972
|
+
* Component button classes
|
|
4973
|
+
*/
|
|
4974
|
+
this.navigationButtonClassList = new index_es.Ge([this.navigationButton]);
|
|
4975
|
+
/**
|
|
4976
|
+
* Does component have children.
|
|
4977
|
+
*/
|
|
4978
|
+
this.hasChildren = false;
|
|
4674
4979
|
/***********
|
|
4675
4980
|
* Methods *
|
|
4676
4981
|
**********/
|
|
4677
|
-
/**
|
|
4678
|
-
* Toggle expanded prop value
|
|
4679
|
-
*/
|
|
4680
|
-
this.toggleExpanded = () => {
|
|
4681
|
-
this.expanded = !this.expanded;
|
|
4682
|
-
};
|
|
4683
4982
|
/**
|
|
4684
4983
|
* Does an Element have given Status
|
|
4685
4984
|
* @param mgMenuItemElement - to parse
|
|
@@ -4687,6 +4986,24 @@ const MgMenuItem = class {
|
|
|
4687
4986
|
* @returns true if element with status is found
|
|
4688
4987
|
*/
|
|
4689
4988
|
this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
|
|
4989
|
+
/**
|
|
4990
|
+
* Condition to know if component should display a mg-popover
|
|
4991
|
+
* @returns truthy if component display popover
|
|
4992
|
+
*/
|
|
4993
|
+
this.hasPopover = () => this.isDirection(Direction.HORIZONTAL) && (this.isInMainMenu && Array.from(this.element.children).some(element => !element.querySelector('[slot]')) || this.isItemMore) && this.href === undefined;
|
|
4994
|
+
/**
|
|
4995
|
+
* Method to control if one of component children have active status
|
|
4996
|
+
* @returns truthy if component has active child
|
|
4997
|
+
*/
|
|
4998
|
+
this.hasActiveChild = () => {
|
|
4999
|
+
var _a;
|
|
5000
|
+
return Array.from(((_a = this.element.querySelector('mg-menu')) === null || _a === void 0 ? void 0 : _a.children) || []).some((element) => element.nodeName === 'MG-MENU-ITEM' && this.hasStatus(element, Status$1.ACTIVE) && !element.hasAttribute('hidden'));
|
|
5001
|
+
};
|
|
5002
|
+
/**
|
|
5003
|
+
* Is component an interactive item
|
|
5004
|
+
* @returns truthy if element is clickable
|
|
5005
|
+
*/
|
|
5006
|
+
this.isInteractiveItem = () => this.hasChildren || !index_es.ye(this.href);
|
|
4690
5007
|
/**
|
|
4691
5008
|
* Is component contextual direction match the given direction
|
|
4692
5009
|
* @param direction - in parent menu
|
|
@@ -4704,25 +5021,37 @@ const MgMenuItem = class {
|
|
|
4704
5021
|
childMenu !== null && Array.from(childMenu.children).some((subItem) => subItem.querySelector('mg-badge') !== null && !subItem.hasAttribute('hidden'));
|
|
4705
5022
|
};
|
|
4706
5023
|
/**
|
|
4707
|
-
*
|
|
4708
|
-
* @
|
|
5024
|
+
* Update expanded prop
|
|
5025
|
+
* @param newValue - expanded new value
|
|
4709
5026
|
*/
|
|
4710
|
-
this.
|
|
4711
|
-
|
|
4712
|
-
|
|
5027
|
+
this.updateExpanded = (newValue) => {
|
|
5028
|
+
if (this.isInteractiveItem()) {
|
|
5029
|
+
// item is always expanded in vertical menu when has active child
|
|
5030
|
+
this.expanded = this.isDirection(Direction.VERTICAL) && this.hasActiveChild() || newValue;
|
|
5031
|
+
}
|
|
5032
|
+
};
|
|
5033
|
+
/**
|
|
5034
|
+
* Update status
|
|
5035
|
+
* @param guard - status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
5036
|
+
*/
|
|
5037
|
+
this.updateStatus = (guard = []) => {
|
|
5038
|
+
if (![Status$1.HIDDEN, Status$1.DISABLED, ...guard].includes(this.status)) {
|
|
5039
|
+
this.status = this.hasActiveChild() ? Status$1.ACTIVE : Status$1.VISIBLE;
|
|
5040
|
+
}
|
|
4713
5041
|
};
|
|
4714
5042
|
/**
|
|
4715
|
-
*
|
|
5043
|
+
* Update slots
|
|
4716
5044
|
* @param guard - prevent action with guard. Default: false.
|
|
4717
5045
|
*/
|
|
4718
|
-
this.
|
|
5046
|
+
this.updateSlot = (guard = false) => {
|
|
4719
5047
|
// slot title AND metadata validation
|
|
4720
5048
|
// add title on label AND metada slots due to text-overflow on these element
|
|
4721
|
-
if (Array.from(this.element.children).find(child => child.getAttribute('slot') === 'label') === undefined)
|
|
5049
|
+
if (Array.from(this.element.children).find(child => child.getAttribute('slot') === 'label') === undefined) {
|
|
4722
5050
|
throw new Error(`<${this.name}> slot "label" is required.`);
|
|
5051
|
+
}
|
|
4723
5052
|
['label', 'metadata'].forEach(slot => {
|
|
4724
5053
|
Array.from(this.element.querySelectorAll(`[slot="${slot}"]`)).forEach(element => {
|
|
4725
|
-
if (!index_es.
|
|
5054
|
+
if (!index_es.ye(element.textContent))
|
|
4726
5055
|
throw new Error(`<${this.name}> slot "${slot}" must have text content.`);
|
|
4727
5056
|
if ((guard && !element.hasAttribute('title')) || !guard)
|
|
4728
5057
|
element.setAttribute('title', element.textContent);
|
|
@@ -4730,39 +5059,23 @@ const MgMenuItem = class {
|
|
|
4730
5059
|
});
|
|
4731
5060
|
};
|
|
4732
5061
|
/**
|
|
4733
|
-
* Update
|
|
4734
|
-
* @param guard -
|
|
4735
|
-
*/
|
|
4736
|
-
this.updateStatus = (guard = []) => {
|
|
4737
|
-
if (![Status$1.HIDDEN, Status$1.DISABLED, ...guard].includes(this.status)) {
|
|
4738
|
-
this.status = this.hasActiveChild() ? Status$1.ACTIVE : Status$1.VISIBLE;
|
|
4739
|
-
}
|
|
4740
|
-
};
|
|
4741
|
-
/**
|
|
4742
|
-
* Init event-listeners
|
|
5062
|
+
* Update menu item
|
|
5063
|
+
* @param guard - prevent action with guard
|
|
4743
5064
|
*/
|
|
4744
|
-
this.
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
5065
|
+
this.updateItem = (guard) => {
|
|
5066
|
+
const menu = this.element.closest('mg-menu');
|
|
5067
|
+
this.isInMainMenu = menu !== null && this.element.parentElement.closest('mg-menu-item') === null;
|
|
5068
|
+
// define element size
|
|
5069
|
+
if ((menu === null || menu === void 0 ? void 0 : menu.size) !== undefined && !this.isItemMore)
|
|
5070
|
+
this.size = menu.size;
|
|
5071
|
+
else if (this.isItemMore)
|
|
5072
|
+
this.size = this.element.dataset.size;
|
|
5073
|
+
// when vertical main menu item contain an active item we force expanded
|
|
5074
|
+
this.updateExpanded(this.expanded);
|
|
5075
|
+
this.updateStatus(guard);
|
|
5076
|
+
this.updatePopoverGuard();
|
|
5077
|
+
this.updateDisplayNotificationBadge();
|
|
4755
5078
|
};
|
|
4756
|
-
/**
|
|
4757
|
-
* Get mg-popover identifier
|
|
4758
|
-
* @returns generated mg-popover identifier
|
|
4759
|
-
*/
|
|
4760
|
-
this.getPopoverIdentifier = () => `${this.identifier}-popover`;
|
|
4761
|
-
/**
|
|
4762
|
-
* Condition to know if component should display a mg-popover
|
|
4763
|
-
* @returns truthy if component display popover
|
|
4764
|
-
*/
|
|
4765
|
-
this.displayPopover = () => this.isDirection(Direction.HORIZONTAL) && this.hasChildren && this.href === undefined;
|
|
4766
5079
|
/************
|
|
4767
5080
|
* Handlers *
|
|
4768
5081
|
************/
|
|
@@ -4771,106 +5084,123 @@ const MgMenuItem = class {
|
|
|
4771
5084
|
* @param event - click on element
|
|
4772
5085
|
*/
|
|
4773
5086
|
this.handleElementCLick = (event) => {
|
|
4774
|
-
if (
|
|
5087
|
+
if (this.status === Status$1.DISABLED) {
|
|
4775
5088
|
event.preventDefault();
|
|
4776
5089
|
event.stopPropagation();
|
|
4777
5090
|
}
|
|
4778
|
-
//
|
|
4779
|
-
|
|
4780
|
-
|
|
5091
|
+
// for non "poperized" menu-item we toggle expanded manualy
|
|
5092
|
+
this.updateExpanded(!this.expanded);
|
|
5093
|
+
// when item is the last clickable item we close the parent popover
|
|
5094
|
+
if (!this.isInteractiveItem()) {
|
|
5095
|
+
const closePopover = (element) => {
|
|
5096
|
+
if (!element)
|
|
5097
|
+
return;
|
|
5098
|
+
else if (element !== this.element && element.expanded && element.shadowRoot.querySelector('mg-popover') !== null) {
|
|
5099
|
+
element.expanded = false;
|
|
5100
|
+
}
|
|
5101
|
+
else {
|
|
5102
|
+
closePopover(element.parentElement.closest('mg-menu-item'));
|
|
5103
|
+
}
|
|
5104
|
+
};
|
|
5105
|
+
closePopover(this.element);
|
|
5106
|
+
}
|
|
4781
5107
|
};
|
|
4782
5108
|
/**
|
|
4783
5109
|
* Handle popover element display-change event
|
|
4784
5110
|
* @param event - popover display event
|
|
4785
5111
|
*/
|
|
4786
5112
|
this.handlePopoverDisplay = (event) => {
|
|
4787
|
-
this.
|
|
5113
|
+
this.updateExpanded(event.detail);
|
|
4788
5114
|
};
|
|
4789
5115
|
/**
|
|
4790
5116
|
* Render slot
|
|
4791
5117
|
* @returns HTML Element
|
|
4792
5118
|
*/
|
|
4793
5119
|
this.renderSlot = () => index.h("slot", null);
|
|
4794
|
-
this.identifier = index_es.qe('mg-menu-item');
|
|
4795
|
-
this.href = undefined;
|
|
4796
|
-
this.target = undefined;
|
|
4797
|
-
this.status = Status$1.VISIBLE;
|
|
4798
|
-
this.expanded = false;
|
|
4799
|
-
this.size = 'medium';
|
|
4800
|
-
this.navigationButtonClassList = new index_es.Xe([this.navigationButton]);
|
|
4801
|
-
this.direction = undefined;
|
|
4802
|
-
this.isInMainMenu = undefined;
|
|
4803
|
-
this.isItemMore = undefined;
|
|
4804
|
-
this.hasChildren = false;
|
|
4805
|
-
this.displayNotificationBadge = undefined;
|
|
4806
5120
|
}
|
|
4807
5121
|
watchIdentifier(newValue) {
|
|
4808
|
-
if (!index_es.
|
|
4809
|
-
console.error(`<mg-menu-item> prop "identifier" value is invalid. Passed value: ${index_es.
|
|
5122
|
+
if (!index_es.Ie(newValue)) {
|
|
5123
|
+
console.error(`<mg-menu-item> prop "identifier" value is invalid. Passed value: ${index_es.Je(newValue)}.`);
|
|
5124
|
+
}
|
|
5125
|
+
else {
|
|
5126
|
+
this.popoverIdentifier = `${this.identifier}-popover`;
|
|
4810
5127
|
}
|
|
4811
5128
|
}
|
|
4812
5129
|
watchTarget(newValue) {
|
|
4813
5130
|
if (newValue && !targets.includes(newValue)) {
|
|
4814
|
-
throw new Error(`<mg-link> prop "target" must be one of: ${targets.join(', ')}. Passed value: ${index_es.
|
|
5131
|
+
throw new Error(`<mg-link> prop "target" must be one of: ${targets.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
4815
5132
|
}
|
|
4816
5133
|
}
|
|
4817
|
-
|
|
4818
|
-
if (oldValue !== undefined)
|
|
5134
|
+
watchStatus(newValue, oldValue) {
|
|
5135
|
+
if (oldValue !== undefined)
|
|
4819
5136
|
this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
|
|
4820
|
-
}
|
|
4821
5137
|
this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
});
|
|
4835
|
-
}
|
|
4836
|
-
else if (this.element.querySelector(`${this.name}[status="${Status$1.ACTIVE}"]`) !== null) {
|
|
4837
|
-
// - when expanded and contain an active item parents are expended too
|
|
4838
|
-
subItems.forEach(item => {
|
|
4839
|
-
if (this.hasStatus(item, Status$1.ACTIVE)) {
|
|
4840
|
-
item.expanded = true;
|
|
4841
|
-
}
|
|
4842
|
-
});
|
|
4843
|
-
}
|
|
5138
|
+
}
|
|
5139
|
+
watchExpanded(newValue) {
|
|
5140
|
+
if (typeof newValue !== 'boolean') {
|
|
5141
|
+
throw new Error(`<${this.name}> prop "expanded" must be a boolean. Passed value: ${index_es.Je(newValue)}.`);
|
|
5142
|
+
}
|
|
5143
|
+
else {
|
|
5144
|
+
this.updateExpanded(newValue);
|
|
5145
|
+
// when expanded all actives sub-items need to be expanded and non active closed
|
|
5146
|
+
Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
|
|
5147
|
+
if (item !== this.element)
|
|
5148
|
+
item.expanded = newValue ? this.hasStatus(item, Status$1.ACTIVE) : false;
|
|
5149
|
+
});
|
|
4844
5150
|
}
|
|
4845
5151
|
}
|
|
4846
|
-
|
|
4847
|
-
|
|
5152
|
+
watchSize(newValue, oldValue) {
|
|
5153
|
+
if (oldValue !== undefined)
|
|
5154
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
4848
5155
|
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
4849
5156
|
}
|
|
4850
|
-
validateDirection(newValue) {
|
|
4851
|
-
|
|
4852
|
-
|
|
5157
|
+
validateDirection(newValue, oldValue) {
|
|
5158
|
+
if (oldValue !== undefined)
|
|
5159
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
|
|
4853
5160
|
this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
|
|
4854
5161
|
// manage all sub levels child menu-items level with data-level attribut
|
|
4855
|
-
|
|
4856
|
-
|
|
5162
|
+
Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
|
|
5163
|
+
if (this.isDirection(Direction.VERTICAL, newValue)) {
|
|
4857
5164
|
item.dataset.level = `${(Number(item.dataset.level) || 1) + 1}`;
|
|
4858
|
-
}
|
|
4859
|
-
|
|
5165
|
+
}
|
|
5166
|
+
else {
|
|
5167
|
+
delete item.dataset.level;
|
|
5168
|
+
}
|
|
5169
|
+
});
|
|
4860
5170
|
}
|
|
4861
5171
|
validateHasChildren(newValue) {
|
|
4862
5172
|
if (newValue && this.element.href !== undefined) {
|
|
4863
5173
|
throw new Error(`<${this.name}> prop "href" is unauthorizied when element is a parent.`);
|
|
4864
5174
|
}
|
|
4865
5175
|
}
|
|
5176
|
+
/**
|
|
5177
|
+
* direction value in dataset
|
|
5178
|
+
* @param newValue - new direction value
|
|
5179
|
+
*/
|
|
5180
|
+
// eslint-disable-next-line @stencil-community/no-unused-watch
|
|
5181
|
+
watchDataStyleDirection(newValue) {
|
|
5182
|
+
this.direction = newValue;
|
|
5183
|
+
}
|
|
5184
|
+
/**
|
|
5185
|
+
* has focus value in dataset
|
|
5186
|
+
* @param newValue - new direction value
|
|
5187
|
+
*/
|
|
5188
|
+
// eslint-disable-next-line @stencil-community/no-unused-watch
|
|
5189
|
+
watchDataHasFocus(newValue) {
|
|
5190
|
+
if (!newValue)
|
|
5191
|
+
this.updateExpanded(Boolean(newValue));
|
|
5192
|
+
}
|
|
4866
5193
|
/**
|
|
4867
5194
|
* Render popover clickoutside guard for content slot
|
|
4868
5195
|
*/
|
|
4869
5196
|
updatePopoverGuard() {
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
5197
|
+
const subItem = this.element.querySelector('*:not([slot])');
|
|
5198
|
+
if (!subItem)
|
|
5199
|
+
return;
|
|
5200
|
+
if (this.hasPopover())
|
|
5201
|
+
subItem.dataset.mgPopoverGuard = this.popoverIdentifier;
|
|
5202
|
+
else
|
|
5203
|
+
delete subItem.dataset.mgPopoverGuard;
|
|
4874
5204
|
}
|
|
4875
5205
|
/*************
|
|
4876
5206
|
* Lifecycle *
|
|
@@ -4884,13 +5214,12 @@ const MgMenuItem = class {
|
|
|
4884
5214
|
this.hasChildren = Array.from(this.element.children).some(child => !['image', 'information', 'label', 'metadata'].includes(child.getAttribute('slot')));
|
|
4885
5215
|
this.messages = index$1.initLocales(this.element).messages.menuItem;
|
|
4886
5216
|
this.isItemMore = this.element.dataset.overflowMore !== undefined;
|
|
4887
|
-
//
|
|
4888
|
-
this.
|
|
4889
|
-
this.
|
|
5217
|
+
// watchers
|
|
5218
|
+
this.watchStatus(this.status);
|
|
5219
|
+
this.watchExpanded(this.expanded);
|
|
4890
5220
|
this.watchTarget(this.target);
|
|
4891
5221
|
this.watchIdentifier(this.identifier);
|
|
4892
|
-
|
|
4893
|
-
this.validateSize(this.size);
|
|
5222
|
+
this.watchSize(this.size);
|
|
4894
5223
|
}
|
|
4895
5224
|
/**
|
|
4896
5225
|
* Check if component slots configuration
|
|
@@ -4898,40 +5227,36 @@ const MgMenuItem = class {
|
|
|
4898
5227
|
*/
|
|
4899
5228
|
componentDidLoad() {
|
|
4900
5229
|
// validation
|
|
4901
|
-
this.
|
|
5230
|
+
this.updateSlot(true);
|
|
4902
5231
|
// update props and states after componentDidLoad hook
|
|
4903
5232
|
// return a promise to process action only in the FIRST render().
|
|
4904
5233
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
4905
5234
|
return setTimeout(() => {
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
this.
|
|
4909
|
-
this.isInMainMenu = menu !== null && this.element.parentElement.closest('mg-menu-item') === null;
|
|
4910
|
-
if ((menu === null || menu === void 0 ? void 0 : menu.size) !== undefined)
|
|
4911
|
-
this.size = menu.size;
|
|
4912
|
-
if (this.isItemMore)
|
|
4913
|
-
this.size = this.element.dataset.size;
|
|
4914
|
-
// when main menu item contain an active item it will get the active style
|
|
4915
|
-
// AND if item is in vertical menu it will be expanded
|
|
4916
|
-
if (this.hasActiveChild() && this.isInMainMenu)
|
|
4917
|
-
this.expanded = this.isDirection(Direction.VERTICAL);
|
|
4918
|
-
this.updateStatus([Status$1.ACTIVE]);
|
|
4919
|
-
this.updateDisplayNotificationBadge();
|
|
4920
|
-
this.updatePopoverGuard();
|
|
4921
|
-
// manage child dom changes with mutationObserver and listners
|
|
4922
|
-
this.initListeners();
|
|
5235
|
+
this.watchDataStyleDirection(this.element.dataset.styleDirection);
|
|
5236
|
+
this.watchDataHasFocus(this.element.dataset.hasFocus);
|
|
5237
|
+
this.updateItem([Status$1.ACTIVE]);
|
|
4923
5238
|
// emit loaded event when component is fully loaded
|
|
4924
5239
|
this.itemLoaded.emit();
|
|
4925
5240
|
new MutationObserver(mutationsList => {
|
|
4926
|
-
if (mutationsList.some(mutation => mutation.attributeName
|
|
5241
|
+
if (mutationsList.some(mutation => ['hidden', 'status'].includes(mutation.attributeName)))
|
|
4927
5242
|
this.updateStatus(this.hasChildren ? undefined : [Status$1.ACTIVE]);
|
|
4928
5243
|
if (mutationsList.some(mutation => mutation.type === 'characterData'))
|
|
4929
|
-
this.
|
|
4930
|
-
|
|
5244
|
+
this.updateSlot();
|
|
5245
|
+
if (mutationsList.some(mutation => mutation.type === 'childList'))
|
|
5246
|
+
this.updateItem();
|
|
4931
5247
|
this.itemUpdated.emit();
|
|
4932
5248
|
}).observe(this.element, { attributes: true, childList: true, characterData: true, subtree: true });
|
|
4933
5249
|
}, 0);
|
|
4934
5250
|
}
|
|
5251
|
+
/**
|
|
5252
|
+
* Emit event when component is updated
|
|
5253
|
+
* @returns promise process wich emit the 'item-updated' event
|
|
5254
|
+
*/
|
|
5255
|
+
componentShouldUpdate() {
|
|
5256
|
+
return index_es.et(() => {
|
|
5257
|
+
this.itemUpdated.emit();
|
|
5258
|
+
});
|
|
5259
|
+
}
|
|
4935
5260
|
/**
|
|
4936
5261
|
* Render ineractive element
|
|
4937
5262
|
* @returns HTML Element
|
|
@@ -4946,15 +5271,6 @@ const MgMenuItem = class {
|
|
|
4946
5271
|
[`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
|
|
4947
5272
|
} }, index.h("mg-icon", { icon: "chevron-down" })))));
|
|
4948
5273
|
}
|
|
4949
|
-
/**
|
|
4950
|
-
* Emit event when component is updated
|
|
4951
|
-
* @returns promise process wich emit the 'item-updated' event
|
|
4952
|
-
*/
|
|
4953
|
-
componentShouldUpdate() {
|
|
4954
|
-
return index_es.tt(() => {
|
|
4955
|
-
this.itemUpdated.emit();
|
|
4956
|
-
});
|
|
4957
|
-
}
|
|
4958
5274
|
/**
|
|
4959
5275
|
* Render
|
|
4960
5276
|
* @returns HTML Element
|
|
@@ -4964,7 +5280,7 @@ const MgMenuItem = class {
|
|
|
4964
5280
|
['mg-c-menu-item__collapse-container']: true,
|
|
4965
5281
|
['mg-c-menu-item__collapse-container--first-level']: (this.isInMainMenu || this.isItemMore) && this.isDirection(Direction.HORIZONTAL),
|
|
4966
5282
|
});
|
|
4967
|
-
return (index.h(index.Host, { key: '
|
|
5283
|
+
return (index.h(index.Host, { key: '1bfbcc26638508e5fff8d0a9b0bd1956e06cb9ae', role: this.isItemMore ? 'presentation' : 'listitem' }, this.hasPopover() ? (index.h("mg-popover", { display: this.expanded, placement: "bottom-start", arrowHide: true, "onDisplay-change": this.handlePopoverDisplay, identifier: this.popoverIdentifier, "data-fallback-placement": "bottom-end" // use for the last element of the menu if it is placed on the right side
|
|
4968
5284
|
}, this.renderInteractiveElement(), index.h("div", { class: getContainerClasses(), slot: "content" }, this.renderSlot()))) : ([
|
|
4969
5285
|
this.renderInteractiveElement(),
|
|
4970
5286
|
index.h("div", { key: "vertical-container", class: getContainerClasses(), hidden: !this.expanded }, this.renderSlot()),
|
|
@@ -4974,11 +5290,13 @@ const MgMenuItem = class {
|
|
|
4974
5290
|
static get watchers() { return {
|
|
4975
5291
|
"identifier": ["watchIdentifier"],
|
|
4976
5292
|
"target": ["watchTarget"],
|
|
4977
|
-
"status": ["
|
|
4978
|
-
"expanded": ["
|
|
4979
|
-
"size": ["
|
|
5293
|
+
"status": ["watchStatus"],
|
|
5294
|
+
"expanded": ["watchExpanded"],
|
|
5295
|
+
"size": ["watchSize"],
|
|
4980
5296
|
"direction": ["validateDirection"],
|
|
4981
|
-
"hasChildren": ["validateHasChildren"]
|
|
5297
|
+
"hasChildren": ["validateHasChildren"],
|
|
5298
|
+
"data-style-direction": ["watchDataStyleDirection"],
|
|
5299
|
+
"data-has-focus": ["watchDataHasFocus"]
|
|
4982
5300
|
}; }
|
|
4983
5301
|
};
|
|
4984
5302
|
MgMenuItem.style = MgMenuItemStyle0;
|
|
@@ -5002,6 +5320,22 @@ const MgMessage = class {
|
|
|
5002
5320
|
* Internal *
|
|
5003
5321
|
************/
|
|
5004
5322
|
this.classBase = 'mg-c-message';
|
|
5323
|
+
/**
|
|
5324
|
+
* Define variant
|
|
5325
|
+
*/
|
|
5326
|
+
this.variant = 'info';
|
|
5327
|
+
/**
|
|
5328
|
+
* Define variant style
|
|
5329
|
+
*/
|
|
5330
|
+
this.variantStyle = 'bar-left';
|
|
5331
|
+
/**
|
|
5332
|
+
* Component classes
|
|
5333
|
+
*/
|
|
5334
|
+
this.classCollection = new index_es.Ge(['mg-c-message']);
|
|
5335
|
+
/**
|
|
5336
|
+
* Define if component is using actions slot
|
|
5337
|
+
*/
|
|
5338
|
+
this.hasActions = false;
|
|
5005
5339
|
/**
|
|
5006
5340
|
* Get icon corresponding to variant
|
|
5007
5341
|
* @returns icon
|
|
@@ -5018,14 +5352,10 @@ const MgMessage = class {
|
|
|
5018
5352
|
return 'exclamation-circle';
|
|
5019
5353
|
}
|
|
5020
5354
|
};
|
|
5021
|
-
this.variant = 'info';
|
|
5022
|
-
this.variantStyle = 'bar-left';
|
|
5023
|
-
this.classCollection = new index_es.Xe(['mg-c-message']);
|
|
5024
|
-
this.hasActions = false;
|
|
5025
5355
|
}
|
|
5026
5356
|
watchVariant(newValue, oldValue) {
|
|
5027
5357
|
if (!variants$1.includes(newValue)) {
|
|
5028
|
-
throw new Error(`<mg-message> prop "variant" must be one of: ${variants$1.join(', ')}. Passed value: ${index_es.
|
|
5358
|
+
throw new Error(`<mg-message> prop "variant" must be one of: ${variants$1.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
5029
5359
|
}
|
|
5030
5360
|
else {
|
|
5031
5361
|
if (newValue !== undefined)
|
|
@@ -5036,7 +5366,7 @@ const MgMessage = class {
|
|
|
5036
5366
|
}
|
|
5037
5367
|
watchVariantStyle(newValue, oldValue) {
|
|
5038
5368
|
if (!variantStyles.includes(newValue)) {
|
|
5039
|
-
throw new Error(`<mg-message> prop "variantStyle" must be one of: ${variantStyles.join(', ')}. Passed value: ${index_es.
|
|
5369
|
+
throw new Error(`<mg-message> prop "variantStyle" must be one of: ${variantStyles.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
5040
5370
|
}
|
|
5041
5371
|
else {
|
|
5042
5372
|
if (newValue !== undefined)
|
|
@@ -5063,9 +5393,9 @@ const MgMessage = class {
|
|
|
5063
5393
|
* @returns HTML Element
|
|
5064
5394
|
*/
|
|
5065
5395
|
render() {
|
|
5066
|
-
return (index.h("div", { key: '
|
|
5396
|
+
return (index.h("div", { key: '851d97fde6f05799e1420f8825fcff986d9af1d6', class: this.classCollection.join() }, index.h("mg-card", { key: '40f85f1fb3240ab709b1ab46286e9a953f2d5dc8' }, this.variantStyle === 'bar-left' && index.h("span", { key: '50b078ec379c7774d2f409c64b56108041bf3053', class: "mg-c-message__bar" }), index.h("span", { key: 'bc6b1019e1103fc8cd5e4e92f95b62374207be2b', class: "mg-c-message__icon" }, index.h("mg-icon", { key: 'e461ddc1eb1ddcb7ecc673f59dc59f400efbe916', icon: this.getIcon() })), index.h("div", { key: 'edf836b375d7f1fd413b53711b99acbe2bef3e92', class: "mg-c-message__content" }, index.h("span", { key: 'c6ce4628e450b7e89ef3715126b3a2dee081224e', class: "mg-c-message__content-slot" }, index.h("slot", { key: '36ecf7417e61ab84695078e2fd4ebe829bd769a7' })), this.hasActions && [
|
|
5067
5397
|
index.h("span", { class: "mg-c-message__content-separator", key: "content-separator" }),
|
|
5068
|
-
index.h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, index.h("slot", { key: '
|
|
5398
|
+
index.h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, index.h("slot", { key: '43be5769165cac1ab702b2ba80fb885c2ec1834f', name: "actions" })),
|
|
5069
5399
|
]))));
|
|
5070
5400
|
}
|
|
5071
5401
|
get element() { return index.getElement(this); }
|
|
@@ -5089,8 +5419,34 @@ const MgModal = class {
|
|
|
5089
5419
|
index.registerInstance(this, hostRef);
|
|
5090
5420
|
this.componentShow = index.createEvent(this, "component-show", 7);
|
|
5091
5421
|
this.componentHide = index.createEvent(this, "component-hide", 7);
|
|
5422
|
+
this.componentClose = index.createEvent(this, "component-close", 7);
|
|
5092
5423
|
// IDs
|
|
5093
5424
|
this.titleId = '';
|
|
5425
|
+
/**
|
|
5426
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
5427
|
+
* If not set, it will be created.
|
|
5428
|
+
*/
|
|
5429
|
+
this.identifier = index_es.ze('mg-modal');
|
|
5430
|
+
/**
|
|
5431
|
+
* Modal dialog role.
|
|
5432
|
+
*/
|
|
5433
|
+
this.dialogRole = dialogRoles[0];
|
|
5434
|
+
/**
|
|
5435
|
+
* Define if modal has a cross button
|
|
5436
|
+
*/
|
|
5437
|
+
this.closeButton = false;
|
|
5438
|
+
/**
|
|
5439
|
+
* Define if modal is open
|
|
5440
|
+
*/
|
|
5441
|
+
this.open = false;
|
|
5442
|
+
/**
|
|
5443
|
+
* Define if component is using actions slot
|
|
5444
|
+
*/
|
|
5445
|
+
this.hasActions = false;
|
|
5446
|
+
/**
|
|
5447
|
+
* Component classes
|
|
5448
|
+
*/
|
|
5449
|
+
this.classCollection = new index_es.Ge(['mg-c-modal']);
|
|
5094
5450
|
/***********
|
|
5095
5451
|
* Handles *
|
|
5096
5452
|
***********/
|
|
@@ -5099,27 +5455,21 @@ const MgModal = class {
|
|
|
5099
5455
|
*/
|
|
5100
5456
|
this.handleClose = () => {
|
|
5101
5457
|
this.open = false;
|
|
5458
|
+
this.componentClose.emit();
|
|
5102
5459
|
};
|
|
5103
|
-
this.identifier = index_es.qe('mg-modal');
|
|
5104
|
-
this.dialogRole = dialogRoles[0];
|
|
5105
|
-
this.modalTitle = undefined;
|
|
5106
|
-
this.closeButton = false;
|
|
5107
|
-
this.open = false;
|
|
5108
|
-
this.hasActions = false;
|
|
5109
|
-
this.classCollection = new index_es.Xe(['mg-c-modal']);
|
|
5110
5460
|
}
|
|
5111
5461
|
watchIdentifier(newValue) {
|
|
5112
|
-
if (!index_es.
|
|
5113
|
-
throw new Error(`<mg-modal> prop "identifier" value is invalid. Passed value: ${index_es.
|
|
5462
|
+
if (!index_es.Ie(newValue)) {
|
|
5463
|
+
throw new Error(`<mg-modal> prop "identifier" value is invalid. Passed value: ${index_es.Je(newValue)}.`);
|
|
5114
5464
|
}
|
|
5115
5465
|
}
|
|
5116
5466
|
validateDialogRole(newValue) {
|
|
5117
5467
|
if (!dialogRoles.includes(newValue))
|
|
5118
|
-
throw new Error(`<mg-modal> prop "dialogRole" must be one of: ${dialogRoles.join(', ')}. Passed value: ${index_es.
|
|
5468
|
+
throw new Error(`<mg-modal> prop "dialogRole" must be one of: ${dialogRoles.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
5119
5469
|
}
|
|
5120
5470
|
validateModalTitle(newValue) {
|
|
5121
|
-
if (!index_es.
|
|
5122
|
-
throw new Error(`<mg-modal> prop "modalTitle" is required. Passed value: ${index_es.
|
|
5471
|
+
if (!index_es.ye(newValue)) {
|
|
5472
|
+
throw new Error(`<mg-modal> prop "modalTitle" is required. Passed value: ${index_es.Je(newValue)}.`);
|
|
5123
5473
|
}
|
|
5124
5474
|
}
|
|
5125
5475
|
watchOpen(newValue) {
|
|
@@ -5160,6 +5510,7 @@ const MgModal = class {
|
|
|
5160
5510
|
// update open prop when use escape key
|
|
5161
5511
|
this.dialog.addEventListener('close', () => {
|
|
5162
5512
|
this.open = false;
|
|
5513
|
+
this.componentClose.emit();
|
|
5163
5514
|
});
|
|
5164
5515
|
}
|
|
5165
5516
|
/**
|
|
@@ -5167,13 +5518,11 @@ const MgModal = class {
|
|
|
5167
5518
|
* @returns HTML Element
|
|
5168
5519
|
*/
|
|
5169
5520
|
render() {
|
|
5170
|
-
return (index.h("dialog", { key: '
|
|
5521
|
+
return (index.h("dialog", { key: 'f927a4473e69d4034433e170b6279e027fc9c9d3', role: this.dialogRole, id: this.identifier, class: this.classCollection.join(), "aria-labelledby": this.titleId, ref: (el) => {
|
|
5171
5522
|
if (el !== null) {
|
|
5172
5523
|
this.dialog = el;
|
|
5173
5524
|
}
|
|
5174
|
-
} }, index.h("mg-card", { key: '
|
|
5175
|
-
// eslint-disable-next-line react/jsx-no-bind
|
|
5176
|
-
onClick: this.handleClose }, index.h("mg-icon", { key: '256f467d254ba056505d8b0fdffbbef0bc426b37', icon: "cross" })))), index.h("h1", { key: '9812cb37e4cc713309191d53a83526b1970389c1', class: "mg-c-modal__title", id: this.titleId }, this.modalTitle)), index.h("article", { key: 'a83b1be738c8556d60e1c0c74c7adb24c751bdf9', class: "mg-c-modal__content" }, index.h("slot", { key: '3431c31ac066e43748063cc28daa785ae39f7b25' })), this.hasActions && (index.h("footer", { key: '0080243246ca901e0566fd947e74737c12fc2426', class: "mg-c-modal__footer" }, index.h("slot", { key: '044104989259ebd5a3ca8b84a24b7b1e844b7d7e', name: "actions" })))))));
|
|
5525
|
+
} }, index.h("mg-card", { key: '36e09b525447abd8b810c8d4b770597e354fc3c3' }, index.h("div", { key: '4e8188bd2f7c4db85b902b58079ea45a863929eb', class: "mg-c-modal__dialog" }, index.h("header", { key: 'bd0512246a56379a63d7be10fd9e7999d26b578a', class: "mg-c-modal__header" }, this.closeButton && (index.h("span", { key: 'f115aca533d59950c9b340f1e71d58cfe631b63d', class: "mg-c-modal__close-button" }, index.h("mg-button", { key: '691ed3f1b20978e302ebd7a793adeac23ccd87f4', "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, index.h("mg-icon", { key: 'aa1bc4cc8906234144fa2944ff5d2b7eab2df11e', icon: "cross" })))), index.h("h1", { key: 'cfab5ec91d14b904e68f4e8dfe973067f0e2af4e', class: "mg-c-modal__title", id: this.titleId }, this.modalTitle)), index.h("article", { key: 'c829f024a77f9c49d84cf7a05a34561b94fc6e47', class: "mg-c-modal__content" }, index.h("slot", { key: '4c2cf29eac6523b23e0d144fded17c38afab4a0a' })), this.hasActions && (index.h("footer", { key: 'e414e21afe1a4a3de720876b71d56efd267bd964', class: "mg-c-modal__footer" }, index.h("slot", { key: 'e71d2578822f3fbaf990fbb3e2878ab850bf4141', name: "actions" })))))));
|
|
5177
5526
|
}
|
|
5178
5527
|
get element() { return index.getElement(this); }
|
|
5179
5528
|
static get watchers() { return {
|
|
@@ -5219,6 +5568,19 @@ const MgPagination = class {
|
|
|
5219
5568
|
constructor(hostRef) {
|
|
5220
5569
|
index.registerInstance(this, hostRef);
|
|
5221
5570
|
this.currentPageChange = index.createEvent(this, "current-page-change", 7);
|
|
5571
|
+
/**
|
|
5572
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
5573
|
+
* If not set, it will be created.
|
|
5574
|
+
*/
|
|
5575
|
+
this.identifier = index_es.ze('mg-pagination');
|
|
5576
|
+
/**
|
|
5577
|
+
* Component total pages
|
|
5578
|
+
*/
|
|
5579
|
+
this.totalPages = 1;
|
|
5580
|
+
/**
|
|
5581
|
+
* Component current page
|
|
5582
|
+
*/
|
|
5583
|
+
this.currentPage = 1;
|
|
5222
5584
|
/**
|
|
5223
5585
|
* Change current page from target
|
|
5224
5586
|
* @param target - target page
|
|
@@ -5245,26 +5607,20 @@ const MgPagination = class {
|
|
|
5245
5607
|
this.handleGoToPage = (action, disabled) => {
|
|
5246
5608
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
5247
5609
|
};
|
|
5248
|
-
this.identifier = index_es.qe('mg-pagination');
|
|
5249
|
-
this.label = undefined;
|
|
5250
|
-
this.hideNavigationLabels = undefined;
|
|
5251
|
-
this.hidePageCount = undefined;
|
|
5252
|
-
this.totalPages = 1;
|
|
5253
|
-
this.currentPage = 1;
|
|
5254
5610
|
}
|
|
5255
5611
|
watchIdentifier(newValue) {
|
|
5256
|
-
if (!index_es.
|
|
5257
|
-
console.error(`<mg-pagination> prop "identifier" value is invalid. Passed value: ${index_es.
|
|
5612
|
+
if (!index_es.Ie(newValue)) {
|
|
5613
|
+
console.error(`<mg-pagination> prop "identifier" value is invalid. Passed value: ${index_es.Je(newValue)}.`);
|
|
5258
5614
|
}
|
|
5259
5615
|
}
|
|
5260
5616
|
validateTotalPages(newValue) {
|
|
5261
5617
|
if (newValue < 1) {
|
|
5262
|
-
throw new Error(`<mg-pagination> prop "totalPages" must be greater than 0. Passed value: ${index_es.
|
|
5618
|
+
throw new Error(`<mg-pagination> prop "totalPages" must be greater than 0. Passed value: ${index_es.Je(newValue)}.`);
|
|
5263
5619
|
}
|
|
5264
5620
|
}
|
|
5265
5621
|
validateCurrentPage(newValue) {
|
|
5266
5622
|
if (newValue < 1) {
|
|
5267
|
-
throw new Error(`<mg-pagination> prop "currentPage" must be greater than 0. Passed value: ${index_es.
|
|
5623
|
+
throw new Error(`<mg-pagination> prop "currentPage" must be greater than 0. Passed value: ${index_es.Je(newValue)}.`);
|
|
5268
5624
|
}
|
|
5269
5625
|
else if (newValue > this.totalPages) {
|
|
5270
5626
|
throw new Error('<mg-pagination> prop "currentPage" can not be greater than total page.');
|
|
@@ -5294,10 +5650,10 @@ const MgPagination = class {
|
|
|
5294
5650
|
* @returns HTML Element
|
|
5295
5651
|
*/
|
|
5296
5652
|
render() {
|
|
5297
|
-
const navigationActionButton = (disabled, action) => (index.h("mg-button", { key: '
|
|
5653
|
+
const navigationActionButton = (disabled, action) => (index.h("mg-button", { key: '223001cd79932ca02a46d6cc8be58346bd535f98', label: this.messages.pagination[`${action}Page`],
|
|
5298
5654
|
// eslint-disable-next-line react/jsx-no-bind
|
|
5299
|
-
onClick: () => this.handleGoToPage(action, disabled), disabled: disabled, variant: "flat", isIcon: this.hideNavigationLabels }, action === NavigationAction.PREVIOUS && index.h("mg-icon", { key: '
|
|
5300
|
-
return (index.h(index.Host, { key: '
|
|
5655
|
+
onClick: () => this.handleGoToPage(action, disabled), disabled: disabled, variant: "flat", isIcon: this.hideNavigationLabels }, action === NavigationAction.PREVIOUS && index.h("mg-icon", { key: '6dd38be4df1a9c540c1e04567f6a6ff858805014', icon: "chevron-left" }), !this.hideNavigationLabels && this.messages.general[action], action === NavigationAction.NEXT && index.h("mg-icon", { key: '226f0fcd8ce73dbcae38300bc9e559968c6413d7', icon: "chevron-right" })));
|
|
5656
|
+
return (index.h(index.Host, { key: '871b799015c76975770cc775c0a7c0a58551b491', hidden: this.totalPages < 2 }, index.h("nav", { key: 'faff3bc618af20b0273fe0272c3437198df0dc53', role: "navigation", "aria-label": this.label, id: this.identifier, class: { 'mg-c-pagination': true, 'mg-c-pagination--hide-page-count': this.hidePageCount } }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), !this.hidePageCount && (index.h("div", { key: 'c4dabd89aa82b89436fdc3405090a635e51384aa', class: "mg-c-pagination__page-count" }, index.h("mg-input-select", { key: '6a3796ec81c0b862837750c6ecd71986fb77a9c1', identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), index.h("span", { key: '5e6555ab6fb9da09ebf4687c652177c5040c4f0d', class: "mg-u-visually-hidden" }, this.messages.pagination.page, " ", this.currentPage), "/ ", this.totalPages, " ", this.totalPages > 1 ? this.messages.pagination.pages : this.messages.pagination.page)), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT))));
|
|
5301
5657
|
}
|
|
5302
5658
|
get element() { return index.getElement(this); }
|
|
5303
5659
|
static get watchers() { return {
|
|
@@ -5325,6 +5681,35 @@ const MgPanel = class {
|
|
|
5325
5681
|
index.registerInstance(this, hostRef);
|
|
5326
5682
|
this.titleChange = index.createEvent(this, "title-change", 7);
|
|
5327
5683
|
this.expandedChange = index.createEvent(this, "expanded-change", 7);
|
|
5684
|
+
/**
|
|
5685
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
5686
|
+
* If not set, it will be created.
|
|
5687
|
+
*/
|
|
5688
|
+
this.identifier = index_es.ze('mg-panel');
|
|
5689
|
+
/**
|
|
5690
|
+
* Define if panel title is editable
|
|
5691
|
+
*/
|
|
5692
|
+
this.titleEditable = false;
|
|
5693
|
+
/**
|
|
5694
|
+
* Define title position
|
|
5695
|
+
*/
|
|
5696
|
+
this.titlePosition = titlePositions[0];
|
|
5697
|
+
/**
|
|
5698
|
+
* Panel is opened
|
|
5699
|
+
*/
|
|
5700
|
+
this.expanded = false;
|
|
5701
|
+
/**
|
|
5702
|
+
* Define expand toggle button display
|
|
5703
|
+
*/
|
|
5704
|
+
this.expandToggleDisplay = expandToggleDisplays[0];
|
|
5705
|
+
/**
|
|
5706
|
+
* Component classes
|
|
5707
|
+
*/
|
|
5708
|
+
this.classCollection = new index_es.Ge(['mg-c-panel']);
|
|
5709
|
+
/**
|
|
5710
|
+
* Title is in edition mode
|
|
5711
|
+
*/
|
|
5712
|
+
this.isEditing = false;
|
|
5328
5713
|
/************
|
|
5329
5714
|
* Methods *
|
|
5330
5715
|
************/
|
|
@@ -5417,27 +5802,15 @@ const MgPanel = class {
|
|
|
5417
5802
|
];
|
|
5418
5803
|
return this.titlePosition === 'right' ? children.reverse() : children;
|
|
5419
5804
|
};
|
|
5420
|
-
this.identifier = index_es.qe('mg-panel');
|
|
5421
|
-
this.panelTitle = undefined;
|
|
5422
|
-
this.titlePattern = undefined;
|
|
5423
|
-
this.titlePatternErrorMessage = undefined;
|
|
5424
|
-
this.titleEditable = false;
|
|
5425
|
-
this.titlePosition = titlePositions[0];
|
|
5426
|
-
this.expanded = false;
|
|
5427
|
-
this.expandToggleDisplay = expandToggleDisplays[0];
|
|
5428
|
-
this.expandToggleDisabled = undefined;
|
|
5429
|
-
this.classCollection = new index_es.Xe(['mg-c-panel']);
|
|
5430
|
-
this.isEditing = false;
|
|
5431
|
-
this.updatedPanelTitle = undefined;
|
|
5432
5805
|
}
|
|
5433
5806
|
watchIdentifier(newValue) {
|
|
5434
|
-
if (!index_es.
|
|
5435
|
-
console.error(`<mg-panel> prop "identifier" value is invalid. Passed value: ${index_es.
|
|
5807
|
+
if (!index_es.Ie(newValue)) {
|
|
5808
|
+
console.error(`<mg-panel> prop "identifier" value is invalid. Passed value: ${index_es.Je(newValue)}.`);
|
|
5436
5809
|
}
|
|
5437
5810
|
}
|
|
5438
5811
|
validatePanelTitle(newValue) {
|
|
5439
|
-
if (!index_es.
|
|
5440
|
-
throw new Error(`<mg-panel> prop "panelTitle" is required and must be a string. Passed value: ${index_es.
|
|
5812
|
+
if (!index_es.ye(newValue))
|
|
5813
|
+
throw new Error(`<mg-panel> prop "panelTitle" is required and must be a string. Passed value: ${index_es.Je(newValue)}.`);
|
|
5441
5814
|
this.titleChange.emit(newValue);
|
|
5442
5815
|
}
|
|
5443
5816
|
validateTitlePattern(newValue) {
|
|
@@ -5446,14 +5819,14 @@ const MgPanel = class {
|
|
|
5446
5819
|
}
|
|
5447
5820
|
validateTitlePosition(newValue) {
|
|
5448
5821
|
if (!titlePositions.includes(newValue))
|
|
5449
|
-
throw new Error(`<mg-panel> prop "titlePosition" must be one of: ${titlePositions.join(', ')}. Passed value: ${index_es.
|
|
5822
|
+
throw new Error(`<mg-panel> prop "titlePosition" must be one of: ${titlePositions.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
5450
5823
|
}
|
|
5451
5824
|
handleExpanded(newValue) {
|
|
5452
5825
|
this.expandedChange.emit(newValue);
|
|
5453
5826
|
}
|
|
5454
5827
|
validateExpandToggleDisplay(newValue) {
|
|
5455
5828
|
if (!expandToggleDisplays.includes(newValue))
|
|
5456
|
-
throw new Error(`<mg-panel> prop "expandToggleDisplay" must be one of: ${expandToggleDisplays.join(', ')}. Passed value: ${index_es.
|
|
5829
|
+
throw new Error(`<mg-panel> prop "expandToggleDisplay" must be one of: ${expandToggleDisplays.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
5457
5830
|
if (newValue === 'icon' && this.titleEditable)
|
|
5458
5831
|
this.titleEditable = false;
|
|
5459
5832
|
}
|
|
@@ -5488,7 +5861,7 @@ const MgPanel = class {
|
|
|
5488
5861
|
*/
|
|
5489
5862
|
render() {
|
|
5490
5863
|
const headerId = `${this.identifier}-header`;
|
|
5491
|
-
return (index.h("section", { key: '
|
|
5864
|
+
return (index.h("section", { key: 'b4471d72f38c4e6f5b21aef7cc08696f745fd6b7', class: this.classCollection.join(), id: this.identifier }, index.h("mg-card", { key: 'f51e3e4c51d56b9019ed4a3bc91fbb4b9ffcb543' }, index.h("header", { key: '9cfcb8fb0e01b570cddee46b2ef9737440c7e192', class: { 'mg-c-panel__header': true, 'mg-c-panel__header--reverse': this.titlePosition === 'right' }, id: headerId }, this.renderHeaderChildren()), index.h("article", { key: 'b5f8c6cb02f97f24b45b567ca25c00cf6930ca2f', class: "mg-c-panel__content", id: `${this.identifier}-content`, "aria-labelledby": headerId, hidden: !this.expanded }, index.h("slot", { key: '5efc9246ad9d6c457abc9a80705df00a5d9e1cb1' })))));
|
|
5492
5865
|
}
|
|
5493
5866
|
get element() { return index.getElement(this); }
|
|
5494
5867
|
static get watchers() { return {
|
|
@@ -7301,6 +7674,32 @@ const MgPopover = class {
|
|
|
7301
7674
|
constructor(hostRef) {
|
|
7302
7675
|
index.registerInstance(this, hostRef);
|
|
7303
7676
|
this.displayChange = index.createEvent(this, "display-change", 7);
|
|
7677
|
+
this.componentClose = index.createEvent(this, "component-close", 7);
|
|
7678
|
+
/**
|
|
7679
|
+
* Sets an `id` attribute.
|
|
7680
|
+
* Needed by the input for accessibility `aria-decribedby`.
|
|
7681
|
+
*/
|
|
7682
|
+
this.identifier = index_es.ze('mg-popover');
|
|
7683
|
+
/**
|
|
7684
|
+
* Popover placement
|
|
7685
|
+
*/
|
|
7686
|
+
this.placement = 'bottom';
|
|
7687
|
+
/**
|
|
7688
|
+
* Hide popover arrow
|
|
7689
|
+
*/
|
|
7690
|
+
this.arrowHide = false;
|
|
7691
|
+
/**
|
|
7692
|
+
* Define if popover has a cross button
|
|
7693
|
+
*/
|
|
7694
|
+
this.closeButton = false;
|
|
7695
|
+
/**
|
|
7696
|
+
* Display popover
|
|
7697
|
+
*/
|
|
7698
|
+
this.display = false;
|
|
7699
|
+
/**
|
|
7700
|
+
* Disable popover
|
|
7701
|
+
*/
|
|
7702
|
+
this.disabled = false;
|
|
7304
7703
|
/**
|
|
7305
7704
|
* Check if clicked outside of component
|
|
7306
7705
|
* @param event - mouse event
|
|
@@ -7365,6 +7764,7 @@ const MgPopover = class {
|
|
|
7365
7764
|
*/
|
|
7366
7765
|
this.handleHideContent = () => {
|
|
7367
7766
|
this.display = false;
|
|
7767
|
+
this.componentClose.emit();
|
|
7368
7768
|
};
|
|
7369
7769
|
/**
|
|
7370
7770
|
* Render popover content element
|
|
@@ -7392,16 +7792,10 @@ const MgPopover = class {
|
|
|
7392
7792
|
mgPopoverContent.setAttribute('id', this.identifier);
|
|
7393
7793
|
}
|
|
7394
7794
|
};
|
|
7395
|
-
this.identifier = index_es.qe('mg-popover');
|
|
7396
|
-
this.placement = 'bottom';
|
|
7397
|
-
this.arrowHide = false;
|
|
7398
|
-
this.closeButton = false;
|
|
7399
|
-
this.display = false;
|
|
7400
|
-
this.disabled = false;
|
|
7401
7795
|
}
|
|
7402
7796
|
validateIdentifier(newValue) {
|
|
7403
|
-
if (!index_es.
|
|
7404
|
-
throw new Error(`<mg-popover> prop "identifier" value is invalid. Passed value: ${index_es.
|
|
7797
|
+
if (!index_es.Ie(newValue)) {
|
|
7798
|
+
throw new Error(`<mg-popover> prop "identifier" value is invalid. Passed value: ${index_es.Je(newValue)}.`);
|
|
7405
7799
|
}
|
|
7406
7800
|
// use renderPopoverContent to update popover-content id
|
|
7407
7801
|
this.renderPopoverContent();
|
|
@@ -7490,10 +7884,17 @@ const MgPopover = class {
|
|
|
7490
7884
|
if (!this.disabled)
|
|
7491
7885
|
this.display = !this.display;
|
|
7492
7886
|
});
|
|
7887
|
+
this.element.addEventListener('click', (event) => {
|
|
7888
|
+
const target = event.target.closest('[popovertargetaction]');
|
|
7889
|
+
if (this.display === true && target !== null && target.getAttribute('popovertargetaction') === 'hide') {
|
|
7890
|
+
this.display = false;
|
|
7891
|
+
}
|
|
7892
|
+
});
|
|
7493
7893
|
// Add events to hide popover
|
|
7494
7894
|
this.element.addEventListener('keydown', e => {
|
|
7495
7895
|
if (!this.disabled && e.code === 'Escape') {
|
|
7496
7896
|
this.display = false;
|
|
7897
|
+
this.componentClose.emit();
|
|
7497
7898
|
interactiveElement.focus();
|
|
7498
7899
|
}
|
|
7499
7900
|
});
|
|
@@ -7504,7 +7905,7 @@ const MgPopover = class {
|
|
|
7504
7905
|
* @returns HTML Element
|
|
7505
7906
|
*/
|
|
7506
7907
|
render() {
|
|
7507
|
-
return (index.h(index.Host, { key: '
|
|
7908
|
+
return (index.h(index.Host, { key: '29e8b74394c1a3f620b4119912d5038feb87b873' }, index.h("slot", { key: '8a3fc0141c2b48db2bf5bd526c1ce289797aaede' }), index.h("slot", { key: '32ef24ddf19e932ae40f1263da121244c969ce0c', name: "content" })));
|
|
7508
7909
|
}
|
|
7509
7910
|
get element() { return index.getElement(this); }
|
|
7510
7911
|
static get watchers() { return {
|
|
@@ -7523,14 +7924,20 @@ const MgPopoverContent = class {
|
|
|
7523
7924
|
constructor(hostRef) {
|
|
7524
7925
|
index.registerInstance(this, hostRef);
|
|
7525
7926
|
this.hideContent = index.createEvent(this, "hide-content", 7);
|
|
7927
|
+
/**
|
|
7928
|
+
* Define if popover has a cross button
|
|
7929
|
+
*/
|
|
7930
|
+
this.closeButton = false;
|
|
7931
|
+
/**
|
|
7932
|
+
* Component classes
|
|
7933
|
+
*/
|
|
7934
|
+
this.classCollection = new index_es.Ge(['mg-c-popover-content']);
|
|
7526
7935
|
/**
|
|
7527
7936
|
* Handle action for close button
|
|
7528
7937
|
*/
|
|
7529
7938
|
this.handleCloseButton = () => {
|
|
7530
7939
|
this.hideContent.emit();
|
|
7531
7940
|
};
|
|
7532
|
-
this.closeButton = false;
|
|
7533
|
-
this.classCollection = new index_es.Xe(['mg-c-popover-content']);
|
|
7534
7941
|
}
|
|
7535
7942
|
/*************
|
|
7536
7943
|
* Lifecycle *
|
|
@@ -7581,10 +7988,9 @@ const MgSkipLinks = class {
|
|
|
7581
7988
|
event.currentTarget.blur();
|
|
7582
7989
|
this.goToAnchor.emit(event.currentTarget.getAttribute('href'));
|
|
7583
7990
|
};
|
|
7584
|
-
this.links = undefined;
|
|
7585
7991
|
}
|
|
7586
7992
|
validateLinks(links) {
|
|
7587
|
-
if (links === undefined || links.length === 0 || links.some(link => !index_es.
|
|
7993
|
+
if (links === undefined || links.length === 0 || links.some(link => !index_es.ye(link.href) || !link.href.startsWith('#') || !index_es.ye(link.label))) {
|
|
7588
7994
|
throw new Error(`<mg-skip-links> prop "links": Cannot be empty and each link must contains an href starting with a "#" and a non empty label attributes.`);
|
|
7589
7995
|
}
|
|
7590
7996
|
}
|
|
@@ -7646,6 +8052,23 @@ const MgTabs = class {
|
|
|
7646
8052
|
this.tabPanel = 'panel';
|
|
7647
8053
|
this.buttonTabBaseClass = 'mg-c-tabs__navigation-button';
|
|
7648
8054
|
this.startIndex = 1;
|
|
8055
|
+
/**
|
|
8056
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
8057
|
+
* If not set, it will be created.
|
|
8058
|
+
*/
|
|
8059
|
+
this.identifier = index_es.ze('mg-tabs');
|
|
8060
|
+
/**
|
|
8061
|
+
* Define tabs size
|
|
8062
|
+
*/
|
|
8063
|
+
this.size = 'medium';
|
|
8064
|
+
/**
|
|
8065
|
+
* Component tabs
|
|
8066
|
+
*/
|
|
8067
|
+
this.tabs = [];
|
|
8068
|
+
/**
|
|
8069
|
+
* Component classes
|
|
8070
|
+
*/
|
|
8071
|
+
this.classCollection = new index_es.Ge(['mg-c-tabs']);
|
|
7649
8072
|
/**
|
|
7650
8073
|
* Validate that new tab status can be `Status.ACTIVE`
|
|
7651
8074
|
* @param tab - tab item
|
|
@@ -7743,7 +8166,7 @@ const MgTabs = class {
|
|
|
7743
8166
|
*/
|
|
7744
8167
|
this.resetFocus = () => {
|
|
7745
8168
|
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
7746
|
-
index_es.
|
|
8169
|
+
index_es.et(() => {
|
|
7747
8170
|
this.tabFocus = undefined;
|
|
7748
8171
|
Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {
|
|
7749
8172
|
tab.setAttribute('tabindex', this.activeTab - this.startIndex !== index ? '-1' : '0');
|
|
@@ -7758,39 +8181,32 @@ const MgTabs = class {
|
|
|
7758
8181
|
if (slots.length !== this.tabs.length)
|
|
7759
8182
|
throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
|
|
7760
8183
|
};
|
|
7761
|
-
this.identifier = index_es.qe('mg-tabs');
|
|
7762
|
-
this.label = undefined;
|
|
7763
|
-
this.size = 'medium';
|
|
7764
|
-
this.items = undefined;
|
|
7765
|
-
this.activeTab = undefined;
|
|
7766
|
-
this.tabs = [];
|
|
7767
|
-
this.classCollection = new index_es.Xe(['mg-c-tabs']);
|
|
7768
8184
|
}
|
|
7769
8185
|
watchIdentifier(newValue) {
|
|
7770
|
-
if (!index_es.
|
|
7771
|
-
console.error(`<mg-tabs> prop "identifier" value is invalid. Passed value: ${index_es.
|
|
8186
|
+
if (!index_es.Ie(newValue)) {
|
|
8187
|
+
console.error(`<mg-tabs> prop "identifier" value is invalid. Passed value: ${index_es.Je(newValue)}.`);
|
|
7772
8188
|
}
|
|
7773
8189
|
}
|
|
7774
8190
|
validateLabel(newValue) {
|
|
7775
|
-
if (!index_es.
|
|
7776
|
-
throw new Error(`<mg-tabs> prop "label" is required and must be a string. Passed value: ${index_es.
|
|
8191
|
+
if (!index_es.ye(newValue)) {
|
|
8192
|
+
throw new Error(`<mg-tabs> prop "label" is required and must be a string. Passed value: ${index_es.Je(newValue)}.`);
|
|
7777
8193
|
}
|
|
7778
8194
|
}
|
|
7779
8195
|
validateSize(newValue) {
|
|
7780
8196
|
if (!sizes.includes(newValue)) {
|
|
7781
|
-
throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}. Passed value: ${index_es.
|
|
8197
|
+
throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
7782
8198
|
}
|
|
7783
8199
|
this.classCollection.add(`mg-c-tabs--size-${this.size}`);
|
|
7784
8200
|
}
|
|
7785
8201
|
validateItems(newValue) {
|
|
7786
8202
|
// String array
|
|
7787
|
-
if (index_es.
|
|
8203
|
+
if (index_es.Xe(newValue))
|
|
7788
8204
|
this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
|
|
7789
8205
|
// Object array
|
|
7790
8206
|
else if (Array.isArray(newValue) && newValue.length > 0 && newValue.every(isTabItem))
|
|
7791
8207
|
this.tabs = newValue;
|
|
7792
8208
|
else
|
|
7793
|
-
throw new Error(`<mg-tabs> prop "items" is required and all items must be the same type: TabItem. Passed value: ${index_es.
|
|
8209
|
+
throw new Error(`<mg-tabs> prop "items" is required and all items must be the same type: TabItem. Passed value: ${index_es.Je(newValue)}.`);
|
|
7794
8210
|
}
|
|
7795
8211
|
validateActiveTab(newValue) {
|
|
7796
8212
|
// when `active-tab` is undefined we set default value by searching an item with `Status.ACTIVE` or we use the `startIndex` has fallback value
|
|
@@ -7815,7 +8231,7 @@ const MgTabs = class {
|
|
|
7815
8231
|
this.activeTabChange.emit(newValue);
|
|
7816
8232
|
}
|
|
7817
8233
|
else {
|
|
7818
|
-
throw new Error(`<mg-tabs> prop "activeTab" must be a number between ${this.startIndex} and ${this.tabs.length} and new value must be "activable". Passed value: ${index_es.
|
|
8234
|
+
throw new Error(`<mg-tabs> prop "activeTab" must be a number between ${this.startIndex} and ${this.tabs.length} and new value must be "activable". Passed value: ${index_es.Je(newValue)}.`);
|
|
7819
8235
|
}
|
|
7820
8236
|
}
|
|
7821
8237
|
/*************
|
|
@@ -7886,14 +8302,18 @@ const MgTag = class {
|
|
|
7886
8302
|
// Classes
|
|
7887
8303
|
this.classOutline = 'mg-c-tag--outline';
|
|
7888
8304
|
this.classSoft = 'mg-c-tag--soft';
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
this.
|
|
8305
|
+
/**
|
|
8306
|
+
* Define tag variant
|
|
8307
|
+
*/
|
|
8308
|
+
this.variant = variants[0]; // primary
|
|
8309
|
+
/**
|
|
8310
|
+
* Component classes
|
|
8311
|
+
*/
|
|
8312
|
+
this.classCollection = new index_es.Ge(['mg-c-tag']);
|
|
7893
8313
|
}
|
|
7894
8314
|
validateVariant(newValue, oldValue) {
|
|
7895
8315
|
if (!variants.includes(newValue)) {
|
|
7896
|
-
throw new Error(`<mg-tag> prop "variant" must be one of: ${variants.join(', ')}. Passed value: ${index_es.
|
|
8316
|
+
throw new Error(`<mg-tag> prop "variant" must be one of: ${variants.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
7897
8317
|
}
|
|
7898
8318
|
else {
|
|
7899
8319
|
if (oldValue !== undefined) {
|
|
@@ -7926,7 +8346,7 @@ const MgTag = class {
|
|
|
7926
8346
|
* @param textContent - html element textContent property
|
|
7927
8347
|
*/
|
|
7928
8348
|
validateTextContent(textContent) {
|
|
7929
|
-
if (!index_es.
|
|
8349
|
+
if (!index_es.ye(textContent))
|
|
7930
8350
|
throw new Error('<mg-tag> slot must contain a text content.');
|
|
7931
8351
|
}
|
|
7932
8352
|
/*************
|
|
@@ -7946,7 +8366,7 @@ const MgTag = class {
|
|
|
7946
8366
|
* @returns HTML Element
|
|
7947
8367
|
*/
|
|
7948
8368
|
render() {
|
|
7949
|
-
return (index.h("span", { key: '
|
|
8369
|
+
return (index.h("span", { key: 'b3269e3baec3a281bdbe65f8b62636b7ea2fa84c', class: this.classCollection.join() }, index.h("slot", { key: 'bcca2d8653dbcd6a96d322055a4e2773d85ca87d' })));
|
|
7950
8370
|
}
|
|
7951
8371
|
get element() { return index.getElement(this); }
|
|
7952
8372
|
static get watchers() { return {
|
|
@@ -7976,6 +8396,23 @@ const isButton = (element) => typeof element === 'object' && ['MG-BUTTON', 'BUTT
|
|
|
7976
8396
|
const MgTooltip = class {
|
|
7977
8397
|
constructor(hostRef) {
|
|
7978
8398
|
index.registerInstance(this, hostRef);
|
|
8399
|
+
/**
|
|
8400
|
+
* Sets an `id` attribute.
|
|
8401
|
+
* Needed by the input for accessibility `aria-decribedby`.
|
|
8402
|
+
*/
|
|
8403
|
+
this.identifier = index_es.ze('mg-tooltip');
|
|
8404
|
+
/**
|
|
8405
|
+
* Tooltip placement
|
|
8406
|
+
*/
|
|
8407
|
+
this.placement = 'bottom';
|
|
8408
|
+
/**
|
|
8409
|
+
* Display tooltip
|
|
8410
|
+
*/
|
|
8411
|
+
this.display = false;
|
|
8412
|
+
/**
|
|
8413
|
+
* Disable tooltip
|
|
8414
|
+
*/
|
|
8415
|
+
this.disabled = false;
|
|
7979
8416
|
/**
|
|
7980
8417
|
* Show tooltip
|
|
7981
8418
|
*/
|
|
@@ -7985,7 +8422,7 @@ const MgTooltip = class {
|
|
|
7985
8422
|
// Enable the event listeners
|
|
7986
8423
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
7987
8424
|
// hide when click outside on nextTick to prevent event to trigger after creation
|
|
7988
|
-
index_es.
|
|
8425
|
+
index_es.et(() => {
|
|
7989
8426
|
this.windows.forEach((localWindow) => {
|
|
7990
8427
|
localWindow.addEventListener('click', this.handleClickOutside, false);
|
|
7991
8428
|
localWindow.addEventListener('keydown', this.handlePressEscape, false);
|
|
@@ -8181,22 +8618,17 @@ const MgTooltip = class {
|
|
|
8181
8618
|
element.setAttribute('aria-describedby', `${[...new Set([...element.getAttribute('aria-describedby').split(' '), this.identifier])].join(' ')}`);
|
|
8182
8619
|
}
|
|
8183
8620
|
};
|
|
8184
|
-
this.identifier = index_es.qe('mg-tooltip');
|
|
8185
|
-
this.message = undefined;
|
|
8186
|
-
this.placement = 'bottom';
|
|
8187
|
-
this.display = false;
|
|
8188
|
-
this.disabled = false;
|
|
8189
8621
|
}
|
|
8190
8622
|
watchIdentifier(newValue) {
|
|
8191
|
-
if (!index_es.
|
|
8192
|
-
throw new Error(`<mg-tooltip> prop "identifier" value is invalid. Passed value: ${index_es.
|
|
8623
|
+
if (!index_es.Ie(newValue)) {
|
|
8624
|
+
throw new Error(`<mg-tooltip> prop "identifier" value is invalid. Passed value: ${index_es.Je(newValue)}.`);
|
|
8193
8625
|
}
|
|
8194
8626
|
// use renderTooltipContent to update tooltip-content id
|
|
8195
8627
|
this.renderTooltipContent();
|
|
8196
8628
|
}
|
|
8197
8629
|
watchMessage(newValue) {
|
|
8198
|
-
if (!index_es.
|
|
8199
|
-
throw new Error(`<mg-tooltip> prop "message" is required and must be a string. Passed value: ${index_es.
|
|
8630
|
+
if (!index_es.ye(newValue)) {
|
|
8631
|
+
throw new Error(`<mg-tooltip> prop "message" is required and must be a string. Passed value: ${index_es.Je(newValue)}.`);
|
|
8200
8632
|
}
|
|
8201
8633
|
if (this.mgTooltipContent !== undefined)
|
|
8202
8634
|
this.mgTooltipContent.message = newValue;
|
|
@@ -8315,7 +8747,7 @@ const MgTooltip = class {
|
|
|
8315
8747
|
* @returns HTML Element
|
|
8316
8748
|
*/
|
|
8317
8749
|
render() {
|
|
8318
|
-
return (index.h(index.Host, { key: '
|
|
8750
|
+
return (index.h(index.Host, { key: '7868f7704c0f1ccd9d0d67d45eac6aa8901f4d5d' }, index.h("slot", { key: '4f865f9e153c5d01259ca83b81772dce302f5c05' }), index.h("slot", { key: '2032e81f60a7b7818a7220f0b00cec81ca0a84ed', name: "content" })));
|
|
8319
8751
|
}
|
|
8320
8752
|
get element() { return index.getElement(this); }
|
|
8321
8753
|
static get watchers() { return {
|
|
@@ -8333,7 +8765,6 @@ const MgTooltipContentStyle0 = mgTooltipContentCss;
|
|
|
8333
8765
|
const MgTooltipContent = class {
|
|
8334
8766
|
constructor(hostRef) {
|
|
8335
8767
|
index.registerInstance(this, hostRef);
|
|
8336
|
-
this.message = undefined;
|
|
8337
8768
|
}
|
|
8338
8769
|
/*************
|
|
8339
8770
|
* Lifecycle *
|
|
@@ -8343,7 +8774,7 @@ const MgTooltipContent = class {
|
|
|
8343
8774
|
* @returns HTML Element
|
|
8344
8775
|
*/
|
|
8345
8776
|
render() {
|
|
8346
|
-
return (index.h(index.Host, { key: '
|
|
8777
|
+
return (index.h(index.Host, { key: '2221de3ca0ef7c9d6e46e24b19c69007fababf81', role: "tooltip" }, index.h("span", { key: '9e14f7f5b3f5e5060ed9f42e8d7259b17575168e', innerHTML: this.message, class: "mg-tooltip-content__message" }), index.h("slot", { key: 'bc083567d77e8f4ffccee98b96036ba8ac494fb6', name: "arrow" })));
|
|
8347
8778
|
}
|
|
8348
8779
|
};
|
|
8349
8780
|
MgTooltipContent.style = MgTooltipContentStyle0;
|