@mgdis/mg-components 6.3.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-a5b2cd1b.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 +1341 -951
- package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-alert.cjs.entry.js +15 -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.js +50 -11
- 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 +108 -31
- 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 +15 -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 +37 -9
- 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 +44 -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 +13 -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 +37 -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 +89 -44
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-password.js +55 -27
- 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 +59 -35
- package/dist/components/mg-input-select2.js.map +1 -1
- package/dist/components/mg-input-text2.js +69 -38
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-input-textarea.js +71 -35
- 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 +33 -15
- 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 +35 -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-eb0e1053.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 +1341 -951
- package/dist/esm/mg-action-more_36.entry.js.map +1 -1
- package/dist/esm/mg-alert.entry.js +15 -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-d0086664.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/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.d.ts +0 -5
- package/dist/types/utils/behaviors.utils.d.ts +15 -44
- package/ide/intellij/web-types.json +3 -7
- package/ide/vscode/html-custom-data.json +2 -2
- package/package.json +22 -22
- package/dist/cjs/index-a5b2cd1b.js.map +0 -1
- package/dist/cjs/index.es-ac7c22e3.js.map +0 -1
- package/dist/esm/index-eb0e1053.js.map +0 -1
- package/dist/esm/index.es-940821a9.js.map +0 -1
- package/dist/mg-components/p-15b6849a.js +0 -3
- package/dist/mg-components/p-15b6849a.js.map +0 -1
- package/dist/mg-components/p-3aecf564.entry.js +0 -2
- package/dist/mg-components/p-3aecf564.entry.js.map +0 -1
- package/dist/mg-components/p-6f3d70b2.entry.js +0 -2
- package/dist/mg-components/p-6f3d70b2.entry.js.map +0 -1
- package/dist/mg-components/p-a17ea0af.entry.js +0 -2
- package/dist/mg-components/p-a17ea0af.entry.js.map +0 -1
- package/dist/mg-components/p-d0086664.entry.js +0 -2
- 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
|
|
@@ -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) {
|
|
@@ -281,6 +287,38 @@ const MgButton = class {
|
|
|
281
287
|
this.classDisabled = 'mg-c-button--disabled';
|
|
282
288
|
this.classLoading = 'mg-c-button--loading';
|
|
283
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']);
|
|
284
322
|
/**
|
|
285
323
|
* Trigger actions onClick event
|
|
286
324
|
* @param event - click event
|
|
@@ -329,17 +367,6 @@ const MgButton = class {
|
|
|
329
367
|
(_b = this.element.querySelector('mg-icon')) === null || _b === void 0 ? void 0 : _b.setAttribute('size', this.size);
|
|
330
368
|
}
|
|
331
369
|
};
|
|
332
|
-
this.variant = variants$3[0];
|
|
333
|
-
this.label = undefined;
|
|
334
|
-
this.type = undefined;
|
|
335
|
-
this.size = sizes$2[0];
|
|
336
|
-
this.fullWidth = false;
|
|
337
|
-
this.form = undefined;
|
|
338
|
-
this.disabled = undefined;
|
|
339
|
-
this.isIcon = false;
|
|
340
|
-
this.disableOnClick = false;
|
|
341
|
-
this.loading = false;
|
|
342
|
-
this.classCollection = new index_es.Xe(['mg-c-button']);
|
|
343
370
|
}
|
|
344
371
|
validateVariant(newValue, oldValue) {
|
|
345
372
|
// validate new value
|
|
@@ -349,7 +376,7 @@ const MgButton = class {
|
|
|
349
376
|
this.variant = variants$3[0];
|
|
350
377
|
return;
|
|
351
378
|
}
|
|
352
|
-
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)}.`);
|
|
353
380
|
}
|
|
354
381
|
else {
|
|
355
382
|
if (oldValue !== undefined) {
|
|
@@ -361,7 +388,7 @@ const MgButton = class {
|
|
|
361
388
|
validateSize(newValue, oldValue) {
|
|
362
389
|
// validate new value
|
|
363
390
|
if (!sizes$2.includes(newValue)) {
|
|
364
|
-
throw new Error(`<mg-button> prop "size" must be one of: ${sizes$2.join(', ')}. Passed value: ${index_es.
|
|
391
|
+
throw new Error(`<mg-button> prop "size" must be one of: ${sizes$2.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
365
392
|
}
|
|
366
393
|
else {
|
|
367
394
|
if (oldValue !== undefined) {
|
|
@@ -422,7 +449,7 @@ const MgButton = class {
|
|
|
422
449
|
this.watchIsIcon();
|
|
423
450
|
if (this.isIcon) {
|
|
424
451
|
this.classCollection.add(`mg-c-button--icon`);
|
|
425
|
-
if (!index_es.
|
|
452
|
+
if (!index_es.ye(this.label)) {
|
|
426
453
|
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
427
454
|
}
|
|
428
455
|
}
|
|
@@ -434,7 +461,7 @@ const MgButton = class {
|
|
|
434
461
|
* Add listners
|
|
435
462
|
*/
|
|
436
463
|
componentDidLoad() {
|
|
437
|
-
index_es.
|
|
464
|
+
index_es.et(() => {
|
|
438
465
|
var _a;
|
|
439
466
|
const closestForm = this.element.closest('form') || ((_a = this.element.closest('mg-form')) === null || _a === void 0 ? void 0 : _a.shadowRoot.querySelector('form'));
|
|
440
467
|
// submit buttons should trigger form submition;
|
|
@@ -480,7 +507,7 @@ const MgCard = class {
|
|
|
480
507
|
* @returns HTML Element
|
|
481
508
|
*/
|
|
482
509
|
render() {
|
|
483
|
-
return (index.h("div", { key: '
|
|
510
|
+
return (index.h("div", { key: 'e59cabb09dbc28c148770b57de98f130c4479b75', class: "mg-c-card" }, index.h("slot", { key: 'b6e679317bddd23e73443c601992b7b344d6dc72' })));
|
|
484
511
|
}
|
|
485
512
|
};
|
|
486
513
|
MgCard.style = MgCardStyle0;
|
|
@@ -491,18 +518,19 @@ const MgCharacterLeftStyle0 = mgCharacterLeftCss;
|
|
|
491
518
|
const MgCharacterLeft = class {
|
|
492
519
|
constructor(hostRef) {
|
|
493
520
|
index.registerInstance(this, hostRef);
|
|
494
|
-
|
|
521
|
+
/**
|
|
522
|
+
* Sets the characters to count
|
|
523
|
+
*/
|
|
495
524
|
this.characters = '';
|
|
496
|
-
this.maxlength = undefined;
|
|
497
525
|
}
|
|
498
526
|
watchIdentifier(newValue) {
|
|
499
|
-
if (newValue !== undefined && !index_es.
|
|
500
|
-
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)}.`);
|
|
501
529
|
}
|
|
502
530
|
}
|
|
503
531
|
validateMaxlength(newValue) {
|
|
504
532
|
if (typeof newValue !== 'number') {
|
|
505
|
-
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)}.`);
|
|
506
534
|
}
|
|
507
535
|
}
|
|
508
536
|
/*************
|
|
@@ -521,7 +549,7 @@ const MgCharacterLeft = class {
|
|
|
521
549
|
* @returns HTML Element
|
|
522
550
|
*/
|
|
523
551
|
render() {
|
|
524
|
-
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))));
|
|
525
553
|
}
|
|
526
554
|
get element() { return index.getElement(this); }
|
|
527
555
|
static get watchers() { return {
|
|
@@ -538,19 +566,23 @@ const MgDetails = class {
|
|
|
538
566
|
constructor(hostRef) {
|
|
539
567
|
index.registerInstance(this, hostRef);
|
|
540
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;
|
|
541
577
|
/**
|
|
542
578
|
* Handle details toggle
|
|
543
579
|
*/
|
|
544
580
|
this.handleToggle = () => {
|
|
545
581
|
this.expanded = this.details.open;
|
|
546
582
|
};
|
|
547
|
-
this.toggleClosed = undefined;
|
|
548
|
-
this.toggleOpened = undefined;
|
|
549
|
-
this.hideSummary = false;
|
|
550
|
-
this.expanded = false;
|
|
551
583
|
}
|
|
552
584
|
validateTitles(newValue) {
|
|
553
|
-
if (!index_es.
|
|
585
|
+
if (!index_es.ye(newValue)) {
|
|
554
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}'".`);
|
|
555
587
|
}
|
|
556
588
|
}
|
|
@@ -572,7 +604,7 @@ const MgDetails = class {
|
|
|
572
604
|
* @returns HTML Element
|
|
573
605
|
*/
|
|
574
606
|
render() {
|
|
575
|
-
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" }))));
|
|
576
608
|
}
|
|
577
609
|
static get watchers() { return {
|
|
578
610
|
"toggleClosed": ["validateTitles"],
|
|
@@ -588,6 +620,12 @@ const MgDividerStyle0 = mgDividerCss;
|
|
|
588
620
|
const MgDivider = class {
|
|
589
621
|
constructor(hostRef) {
|
|
590
622
|
index.registerInstance(this, hostRef);
|
|
623
|
+
/**************
|
|
624
|
+
* Decorators *
|
|
625
|
+
**************/
|
|
626
|
+
/**
|
|
627
|
+
* Define component size
|
|
628
|
+
*/
|
|
591
629
|
this.fullWidth = false;
|
|
592
630
|
}
|
|
593
631
|
/**
|
|
@@ -595,7 +633,7 @@ const MgDivider = class {
|
|
|
595
633
|
* @returns HTML Element
|
|
596
634
|
*/
|
|
597
635
|
render() {
|
|
598
|
-
return (index.h("div", { key: '
|
|
636
|
+
return (index.h("div", { key: '60b987cb329c6db14c2cc4a665e7f32b2696a3ee', class: {
|
|
599
637
|
'mg-c-divider': true,
|
|
600
638
|
'mg-c-divider--full-width': this.fullWidth,
|
|
601
639
|
} }));
|
|
@@ -623,6 +661,28 @@ const MgForm = class {
|
|
|
623
661
|
// Classes
|
|
624
662
|
this.classAllRequired = 'mg-c-form--all-required';
|
|
625
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']);
|
|
626
686
|
/**
|
|
627
687
|
* Define required message based on mg-inputs required elements
|
|
628
688
|
*/
|
|
@@ -708,31 +768,20 @@ const MgForm = class {
|
|
|
708
768
|
}
|
|
709
769
|
});
|
|
710
770
|
};
|
|
711
|
-
this.identifier = index_es.qe('mg-form');
|
|
712
|
-
this.name = this.identifier;
|
|
713
|
-
this.readonly = false;
|
|
714
|
-
this.requiredMessage = undefined;
|
|
715
|
-
this.ariaRole = undefined;
|
|
716
|
-
this.labelOnTop = undefined;
|
|
717
|
-
this.disabled = false;
|
|
718
|
-
this.valid = undefined;
|
|
719
|
-
this.invalid = undefined;
|
|
720
|
-
this.classCollection = new index_es.Xe(['mg-c-form']);
|
|
721
|
-
this.requiredMessageText = undefined;
|
|
722
771
|
}
|
|
723
772
|
watchIdentifier(newValue) {
|
|
724
|
-
if (!index_es.
|
|
725
|
-
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)}.`);
|
|
726
775
|
}
|
|
727
776
|
}
|
|
728
777
|
validateRequiredMessage(newValue) {
|
|
729
778
|
if (newValue && !requiredMessageStatus.includes(newValue)) {
|
|
730
|
-
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)}.`);
|
|
731
780
|
}
|
|
732
781
|
}
|
|
733
782
|
validateAriaRole(newValue) {
|
|
734
783
|
if (newValue && !roles.includes(newValue)) {
|
|
735
|
-
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)}.`);
|
|
736
785
|
}
|
|
737
786
|
}
|
|
738
787
|
handlelabelOnTop(newValue) {
|
|
@@ -808,17 +857,20 @@ const MgForm = class {
|
|
|
808
857
|
*/
|
|
809
858
|
componentDidLoad() {
|
|
810
859
|
// Update mgInputs when mgForm content change
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
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);
|
|
815
867
|
}
|
|
816
868
|
/**
|
|
817
869
|
* Render
|
|
818
870
|
* @returns HTML Element
|
|
819
871
|
*/
|
|
820
872
|
render() {
|
|
821
|
-
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" })));
|
|
822
874
|
}
|
|
823
875
|
get element() { return index.getElement(this); }
|
|
824
876
|
static get watchers() { return {
|
|
@@ -853,6 +905,18 @@ const MgIconStyle0 = mgIconCss;
|
|
|
853
905
|
const MgIcon = class {
|
|
854
906
|
constructor(hostRef) {
|
|
855
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']);
|
|
856
920
|
/**
|
|
857
921
|
* Method to set default varianStyle props
|
|
858
922
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
@@ -873,16 +937,10 @@ const MgIcon = class {
|
|
|
873
937
|
this.svg.setAttribute('focusable', 'false');
|
|
874
938
|
this.svg.setAttribute('class', this.classCollection.join());
|
|
875
939
|
};
|
|
876
|
-
this.icon = undefined;
|
|
877
|
-
this.size = 'medium';
|
|
878
|
-
this.variant = undefined;
|
|
879
|
-
this.variantStyle = undefined;
|
|
880
|
-
this.spin = false;
|
|
881
|
-
this.classCollection = new index_es.Xe(['mg-c-icon']);
|
|
882
940
|
}
|
|
883
941
|
validateIcon(newValue, oldValue) {
|
|
884
942
|
if (!Object.keys(icons).includes(newValue))
|
|
885
|
-
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)}.`);
|
|
886
944
|
else {
|
|
887
945
|
if (oldValue !== undefined)
|
|
888
946
|
this.classCollection.delete(`mg-c-icon--${oldValue}`);
|
|
@@ -892,7 +950,7 @@ const MgIcon = class {
|
|
|
892
950
|
}
|
|
893
951
|
validateSize(newValue, oldValue) {
|
|
894
952
|
if (!sizes$1.includes(newValue))
|
|
895
|
-
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)}.`);
|
|
896
954
|
else {
|
|
897
955
|
if (oldValue !== undefined)
|
|
898
956
|
this.classCollection.delete(`mg-c-icon--size-${oldValue}`);
|
|
@@ -902,7 +960,7 @@ const MgIcon = class {
|
|
|
902
960
|
validateVariant(newValue, oldValue) {
|
|
903
961
|
if (newValue !== undefined) {
|
|
904
962
|
if (!variants$2.includes(newValue))
|
|
905
|
-
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)}.`);
|
|
906
964
|
else {
|
|
907
965
|
this.setDefaultVariantStyle();
|
|
908
966
|
if (oldValue !== undefined)
|
|
@@ -914,7 +972,7 @@ const MgIcon = class {
|
|
|
914
972
|
validateVariantStyle(newValue, oldValue) {
|
|
915
973
|
if (newValue !== undefined) {
|
|
916
974
|
if (!variantStyles$1.includes(newValue))
|
|
917
|
-
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)}.`);
|
|
918
976
|
else {
|
|
919
977
|
if (oldValue !== undefined)
|
|
920
978
|
this.classCollection.delete(`mg-c-icon--variant-style-${oldValue}`);
|
|
@@ -959,13 +1017,19 @@ const MgIcon = class {
|
|
|
959
1017
|
};
|
|
960
1018
|
MgIcon.style = MgIconStyle0;
|
|
961
1019
|
|
|
962
|
-
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}";
|
|
963
1021
|
const MgIllustratedMessageStyle0 = mgIllustratedMessageCss;
|
|
964
1022
|
|
|
965
1023
|
const MgIllustratedMessage = class {
|
|
966
1024
|
constructor(hostRef) {
|
|
967
1025
|
index.registerInstance(this, hostRef);
|
|
1026
|
+
/**
|
|
1027
|
+
* Define illustration size
|
|
1028
|
+
*/
|
|
968
1029
|
this.size = 'medium';
|
|
1030
|
+
/**
|
|
1031
|
+
* Define component orientation
|
|
1032
|
+
*/
|
|
969
1033
|
this.direction = 'vertical';
|
|
970
1034
|
}
|
|
971
1035
|
/*************
|
|
@@ -990,13 +1054,13 @@ const MgIllustratedMessage = class {
|
|
|
990
1054
|
* @returns HTML Element
|
|
991
1055
|
*/
|
|
992
1056
|
render() {
|
|
993
|
-
return (index.h("div", { key: '
|
|
1057
|
+
return (index.h("div", { key: 'ae59b32d798c888eef5f2b3464160177b7a2e9d8', class: {
|
|
994
1058
|
'mg-c-illustrated-message': true,
|
|
995
1059
|
'mg-c-illustrated-message--horizontal': this.direction === 'horizontal',
|
|
996
|
-
} }, index.h("div", { key: '
|
|
1060
|
+
} }, index.h("div", { key: '05d260716090d503dde8e0dddc79db0a5f553f0b', class: {
|
|
997
1061
|
'mg-c-illustrated-message__illustration': true,
|
|
998
1062
|
'mg-c-illustrated-message__illustration--small': this.size === 'small',
|
|
999
|
-
} }, 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" })))));
|
|
1000
1064
|
}
|
|
1001
1065
|
get element() { return index.getElement(this); }
|
|
1002
1066
|
};
|
|
@@ -1029,31 +1093,45 @@ const MgInput = class {
|
|
|
1029
1093
|
this.classHasError = 'mg-c-input--has-error';
|
|
1030
1094
|
this.classLabelOnTop = 'mg-c-input--label-on-top';
|
|
1031
1095
|
/**
|
|
1032
|
-
*
|
|
1033
|
-
* @returns mg-tooltip
|
|
1096
|
+
* Define if label is visible
|
|
1034
1097
|
*/
|
|
1035
|
-
this.renderTooltip = () => (index.h("mg-tooltip", { identifier: `${this.identifier}-tooltip`, message: this.tooltip }, index.h("mg-icon", { icon: "info-circle" })));
|
|
1036
|
-
this.identifier = undefined;
|
|
1037
|
-
this.label = undefined;
|
|
1038
|
-
this.labelOnTop = undefined;
|
|
1039
1098
|
this.labelHide = false;
|
|
1040
|
-
|
|
1099
|
+
/**
|
|
1100
|
+
* Define tooltip position
|
|
1101
|
+
*/
|
|
1041
1102
|
this.tooltipPosition = 'input';
|
|
1103
|
+
/**
|
|
1104
|
+
* Define if input is required
|
|
1105
|
+
*/
|
|
1042
1106
|
this.required = false;
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1107
|
+
/**
|
|
1108
|
+
* Element is fieldset
|
|
1109
|
+
*/
|
|
1046
1110
|
this.isFieldset = false;
|
|
1111
|
+
/**
|
|
1112
|
+
* Element is readonly
|
|
1113
|
+
*/
|
|
1047
1114
|
this.isReadonly = false;
|
|
1115
|
+
/**
|
|
1116
|
+
* Element is disabled
|
|
1117
|
+
*/
|
|
1048
1118
|
this.isDisabled = false;
|
|
1119
|
+
/**
|
|
1120
|
+
* Element is disabled
|
|
1121
|
+
*/
|
|
1049
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" })));
|
|
1050
1128
|
}
|
|
1051
1129
|
watchIdentifier(newValue) {
|
|
1052
|
-
if (!index_es.
|
|
1053
|
-
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)}.`);
|
|
1054
1132
|
}
|
|
1055
|
-
else if (!index_es.
|
|
1056
|
-
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)}.`);
|
|
1057
1135
|
}
|
|
1058
1136
|
else {
|
|
1059
1137
|
this.helpTextId = `${this.identifier}-help-text`;
|
|
@@ -1075,7 +1153,7 @@ const MgInput = class {
|
|
|
1075
1153
|
}
|
|
1076
1154
|
watchTooltipPosition(newValue) {
|
|
1077
1155
|
if (!tooltipPositions.includes(newValue)) {
|
|
1078
|
-
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)}.`);
|
|
1079
1157
|
}
|
|
1080
1158
|
}
|
|
1081
1159
|
watchErrorMessage(newValue) {
|
|
@@ -1118,7 +1196,10 @@ const MgInput = class {
|
|
|
1118
1196
|
ariaDescribedbyIDs.add(this.helpTextErrorId);
|
|
1119
1197
|
}
|
|
1120
1198
|
this.element.querySelectorAll('input,select,textarea,[role="switch"]').forEach(element => {
|
|
1121
|
-
|
|
1199
|
+
if (ariaDescribedbyIDs.size)
|
|
1200
|
+
element.setAttribute('aria-describedby', Array.from(ariaDescribedbyIDs).join(' '));
|
|
1201
|
+
else
|
|
1202
|
+
element.removeAttribute('aria-describedby');
|
|
1122
1203
|
});
|
|
1123
1204
|
}
|
|
1124
1205
|
/**
|
|
@@ -1139,8 +1220,8 @@ const MgInput = class {
|
|
|
1139
1220
|
*/
|
|
1140
1221
|
// eslint-disable-next-line @stencil-community/no-unused-watch
|
|
1141
1222
|
watchLabel() {
|
|
1142
|
-
if (!index_es.
|
|
1143
|
-
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)}.`);
|
|
1144
1225
|
}
|
|
1145
1226
|
else {
|
|
1146
1227
|
this.watchAriaDescribedbyIDs();
|
|
@@ -1232,7 +1313,7 @@ const MgInput = class {
|
|
|
1232
1313
|
*/
|
|
1233
1314
|
render() {
|
|
1234
1315
|
const isGroup = this.isFieldset && !this.isReadonly;
|
|
1235
|
-
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 }))))));
|
|
1236
1317
|
}
|
|
1237
1318
|
get element() { return index.getElement(this); }
|
|
1238
1319
|
static get watchers() { return {
|
|
@@ -1304,6 +1385,55 @@ const MgInputCheckbox = class {
|
|
|
1304
1385
|
this.searchStart = 10;
|
|
1305
1386
|
// popover variables
|
|
1306
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';
|
|
1307
1437
|
/**
|
|
1308
1438
|
* Handle input event
|
|
1309
1439
|
* @param event - input event
|
|
@@ -1405,7 +1535,7 @@ const MgInputCheckbox = class {
|
|
|
1405
1535
|
* Method to update searchResults
|
|
1406
1536
|
*/
|
|
1407
1537
|
this.updateSearchResults = () => {
|
|
1408
|
-
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)));
|
|
1409
1539
|
};
|
|
1410
1540
|
/**
|
|
1411
1541
|
* Method to validate if one of inputs value is checked id required
|
|
@@ -1437,13 +1567,13 @@ const MgInputCheckbox = class {
|
|
|
1437
1567
|
* @returns message to display
|
|
1438
1568
|
*/
|
|
1439
1569
|
this.getSelectValuesButtonMessage = () => {
|
|
1440
|
-
if (this.selectValuesButtonKey === 'editButton' && index_es.
|
|
1570
|
+
if (this.selectValuesButtonKey === 'editButton' && index_es.ye(this.editButtonMessage)) {
|
|
1441
1571
|
return this.editButtonMessage;
|
|
1442
1572
|
}
|
|
1443
|
-
else if (this.selectValuesButtonKey === 'showButton' && index_es.
|
|
1573
|
+
else if (this.selectValuesButtonKey === 'showButton' && index_es.ye(this.showButtonMessage)) {
|
|
1444
1574
|
return this.showButtonMessage;
|
|
1445
1575
|
}
|
|
1446
|
-
else if (this.selectValuesButtonKey === 'selectButton' && index_es.
|
|
1576
|
+
else if (this.selectValuesButtonKey === 'selectButton' && index_es.ye(this.selectButtonMessage)) {
|
|
1447
1577
|
return this.selectButtonMessage;
|
|
1448
1578
|
}
|
|
1449
1579
|
else {
|
|
@@ -1492,33 +1622,6 @@ const MgInputCheckbox = class {
|
|
|
1492
1622
|
* @returns The rendered MgInputCheckboxList component.
|
|
1493
1623
|
*/
|
|
1494
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 }));
|
|
1495
|
-
this.value = undefined;
|
|
1496
|
-
this.type = undefined;
|
|
1497
|
-
this.identifier = undefined;
|
|
1498
|
-
this.name = this.identifier;
|
|
1499
|
-
this.label = undefined;
|
|
1500
|
-
this.labelOnTop = undefined;
|
|
1501
|
-
this.labelHide = false;
|
|
1502
|
-
this.inputVerticalList = false;
|
|
1503
|
-
this.required = false;
|
|
1504
|
-
this.readonly = false;
|
|
1505
|
-
this.displaySelectedValues = undefined;
|
|
1506
|
-
this.disabled = false;
|
|
1507
|
-
this.tooltip = undefined;
|
|
1508
|
-
this.tooltipPosition = 'input';
|
|
1509
|
-
this.helpText = undefined;
|
|
1510
|
-
this.valid = undefined;
|
|
1511
|
-
this.invalid = undefined;
|
|
1512
|
-
this.editButtonMessage = undefined;
|
|
1513
|
-
this.showButtonMessage = undefined;
|
|
1514
|
-
this.selectButtonMessage = undefined;
|
|
1515
|
-
this.classCollection = new index_es.Xe([this.baseClassName, classFieldset]);
|
|
1516
|
-
this.errorMessage = undefined;
|
|
1517
|
-
this.checkboxItems = [];
|
|
1518
|
-
this.displaySearchInput = undefined;
|
|
1519
|
-
this.searchValue = '';
|
|
1520
|
-
this.searchResults = [];
|
|
1521
|
-
this.selectValuesButtonKey = 'editButton';
|
|
1522
1625
|
}
|
|
1523
1626
|
validateValue(newValue) {
|
|
1524
1627
|
if (isCheckboxItems(newValue)) {
|
|
@@ -1526,12 +1629,12 @@ const MgInputCheckbox = class {
|
|
|
1526
1629
|
this.valueChange.emit(newValue);
|
|
1527
1630
|
}
|
|
1528
1631
|
else {
|
|
1529
|
-
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)}.`);
|
|
1530
1633
|
}
|
|
1531
1634
|
}
|
|
1532
1635
|
validateType(newValue) {
|
|
1533
1636
|
if (newValue !== undefined && !checkboxTypes.includes(newValue)) {
|
|
1534
|
-
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)}.`);
|
|
1535
1638
|
}
|
|
1536
1639
|
else if (newValue === undefined) {
|
|
1537
1640
|
this.mode = 'auto';
|
|
@@ -1603,10 +1706,21 @@ const MgInputCheckbox = class {
|
|
|
1603
1706
|
/**
|
|
1604
1707
|
* Display input error if it exists.
|
|
1605
1708
|
*/
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
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
|
+
});
|
|
1610
1724
|
}
|
|
1611
1725
|
/**
|
|
1612
1726
|
* Set an error and display a custom error message.
|
|
@@ -1620,7 +1734,7 @@ const MgInputCheckbox = class {
|
|
|
1620
1734
|
if (typeof valid !== 'boolean') {
|
|
1621
1735
|
throw new Error('<mg-input-checkbox> method "setError()" param "valid" must be a boolean.');
|
|
1622
1736
|
}
|
|
1623
|
-
else if (!index_es.
|
|
1737
|
+
else if (!index_es.ye(errorMessage)) {
|
|
1624
1738
|
throw new Error('<mg-input-checkbox> method "setError()" param "errorMessage" must be a string.');
|
|
1625
1739
|
}
|
|
1626
1740
|
else {
|
|
@@ -1757,7 +1871,7 @@ const MgInputCheckbox = class {
|
|
|
1757
1871
|
else {
|
|
1758
1872
|
inputContent = this.renderCheckboxMulti();
|
|
1759
1873
|
}
|
|
1760
|
-
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));
|
|
1761
1875
|
}
|
|
1762
1876
|
get element() { return index.getElement(this); }
|
|
1763
1877
|
static get watchers() { return {
|
|
@@ -1783,6 +1897,18 @@ const MgInputCheckboxPaginated = class {
|
|
|
1783
1897
|
* Constantes *
|
|
1784
1898
|
*************/
|
|
1785
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;
|
|
1786
1912
|
/***********
|
|
1787
1913
|
* Methods *
|
|
1788
1914
|
***********/
|
|
@@ -1818,14 +1944,6 @@ const MgInputCheckboxPaginated = class {
|
|
|
1818
1944
|
this.handleCurrentPageChange = (event) => {
|
|
1819
1945
|
this.currentPage = Number(event.detail);
|
|
1820
1946
|
};
|
|
1821
|
-
this.readonly = undefined;
|
|
1822
|
-
this.disabled = undefined;
|
|
1823
|
-
this.name = undefined;
|
|
1824
|
-
this.invalid = undefined;
|
|
1825
|
-
this.currentPage = 1;
|
|
1826
|
-
this.checkboxes = [];
|
|
1827
|
-
this.messages = undefined;
|
|
1828
|
-
this.expanded = true;
|
|
1829
1947
|
}
|
|
1830
1948
|
watchCheckboxes(newValue, oldValue) {
|
|
1831
1949
|
const pageCountNewValue = this.getPageCount(newValue);
|
|
@@ -1865,10 +1983,10 @@ const MgInputCheckboxPaginated = class {
|
|
|
1865
1983
|
* @returns HTML Element
|
|
1866
1984
|
*/
|
|
1867
1985
|
render() {
|
|
1868
|
-
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})`));
|
|
1869
1987
|
const [from, to] = this.getFromToIndexes();
|
|
1870
1988
|
const itemsContainerId = `items-${this.sectionKind}-container`;
|
|
1871
|
-
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 }))));
|
|
1872
1990
|
}
|
|
1873
1991
|
static get watchers() { return {
|
|
1874
1992
|
"checkboxes": ["watchCheckboxes"]
|
|
@@ -1885,12 +2003,46 @@ const MgInputDate = class {
|
|
|
1885
2003
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
1886
2004
|
// hasDisplayedError (triggered by blur event)
|
|
1887
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']);
|
|
1888
2040
|
/**
|
|
1889
2041
|
* Method to validate date pattern string
|
|
1890
2042
|
* @param value - value to test
|
|
1891
2043
|
* @returns truthy when value match the pattern
|
|
1892
2044
|
*/
|
|
1893
|
-
this.isValidPattern = (value) => index_es.
|
|
2045
|
+
this.isValidPattern = (value) => index_es.ye(value) && index_es.Be.test(value);
|
|
1894
2046
|
/**
|
|
1895
2047
|
* Format help text to display
|
|
1896
2048
|
* @param helpText - help text format
|
|
@@ -1898,10 +2050,10 @@ const MgInputDate = class {
|
|
|
1898
2050
|
*/
|
|
1899
2051
|
this.formatHelpText = (helpText) => {
|
|
1900
2052
|
const defaultHelpTextVariable = '{defaultHelpText}';
|
|
1901
|
-
let text = index_es.
|
|
2053
|
+
let text = index_es.ye(helpText) ? helpText : this.messages.input.date.helpText;
|
|
1902
2054
|
if (text.includes(defaultHelpTextVariable))
|
|
1903
2055
|
text = text.replace(defaultHelpTextVariable, this.formatHelpText(this.messages.input.date.helpText));
|
|
1904
|
-
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));
|
|
1905
2057
|
};
|
|
1906
2058
|
/**
|
|
1907
2059
|
* Handle input event
|
|
@@ -1932,7 +2084,7 @@ const MgInputDate = class {
|
|
|
1932
2084
|
// when we reset the field we need to test a blank value.
|
|
1933
2085
|
if (['Delete', 'Backspace'].includes(event.key)) {
|
|
1934
2086
|
event.preventDefault();
|
|
1935
|
-
this.value =
|
|
2087
|
+
this.value = null;
|
|
1936
2088
|
this.checkValidity();
|
|
1937
2089
|
if (this.hasDisplayedError) {
|
|
1938
2090
|
this.setErrorMessage();
|
|
@@ -1943,7 +2095,7 @@ const MgInputDate = class {
|
|
|
1943
2095
|
* Check if input is valid
|
|
1944
2096
|
*/
|
|
1945
2097
|
this.checkValidity = () => {
|
|
1946
|
-
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))));
|
|
1947
2099
|
};
|
|
1948
2100
|
/**
|
|
1949
2101
|
* get input error code
|
|
@@ -1952,14 +2104,14 @@ const MgInputDate = class {
|
|
|
1952
2104
|
this.getInputError = () => {
|
|
1953
2105
|
var _a;
|
|
1954
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
|
+
}
|
|
1955
2111
|
// required
|
|
1956
|
-
if (this.input.validity.valueMissing) {
|
|
2112
|
+
else if (this.input.validity.valueMissing) {
|
|
1957
2113
|
inputError = 'required';
|
|
1958
2114
|
}
|
|
1959
|
-
// pattern
|
|
1960
|
-
else if (this.value && !this.isValidPattern(this.value)) {
|
|
1961
|
-
inputError = 'badInput';
|
|
1962
|
-
}
|
|
1963
2115
|
// min & max
|
|
1964
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') {
|
|
1965
2117
|
inputError = 'minMax';
|
|
@@ -1993,8 +2145,8 @@ const MgInputDate = class {
|
|
|
1993
2145
|
// min, max & minMax
|
|
1994
2146
|
else if (['min', 'max', 'minMax'].includes(inputError)) {
|
|
1995
2147
|
this.errorMessage = this.messages.errors.date[inputError]
|
|
1996
|
-
.replace('{min}', index_es.
|
|
1997
|
-
.replace('{max}', index_es.
|
|
2148
|
+
.replace('{min}', index_es.Pe(this.min, this.systemLocale))
|
|
2149
|
+
.replace('{max}', index_es.Pe(this.max, this.systemLocale));
|
|
1998
2150
|
}
|
|
1999
2151
|
// wrong date format
|
|
2000
2152
|
// element.validity.badInput is default error message
|
|
@@ -2008,40 +2160,26 @@ const MgInputDate = class {
|
|
|
2008
2160
|
* @returns translated html pattern
|
|
2009
2161
|
*/
|
|
2010
2162
|
this.renderPattern = () => {
|
|
2011
|
-
let patternLocal = index_es.
|
|
2163
|
+
let patternLocal = index_es.at(this.systemLocale);
|
|
2012
2164
|
for (const key in this.messages.input.date.pattern) {
|
|
2013
2165
|
patternLocal = patternLocal.replace(key, this.messages.input.date.pattern[key]);
|
|
2014
2166
|
}
|
|
2015
2167
|
return `<span aria-hidden="true">${patternLocal}</span><span class="mg-u-visually-hidden">${[...patternLocal].join(' ')}</span>`;
|
|
2016
2168
|
};
|
|
2017
|
-
this.value = undefined;
|
|
2018
|
-
this.identifier = undefined;
|
|
2019
|
-
this.name = this.identifier;
|
|
2020
|
-
this.label = undefined;
|
|
2021
|
-
this.labelOnTop = undefined;
|
|
2022
|
-
this.labelHide = false;
|
|
2023
|
-
this.required = false;
|
|
2024
|
-
this.readonly = false;
|
|
2025
|
-
this.min = undefined;
|
|
2026
|
-
this.max = '9999-12-31';
|
|
2027
|
-
this.disabled = false;
|
|
2028
|
-
this.tooltip = undefined;
|
|
2029
|
-
this.tooltipPosition = 'input';
|
|
2030
|
-
this.helpText = undefined;
|
|
2031
|
-
this.valid = undefined;
|
|
2032
|
-
this.invalid = undefined;
|
|
2033
|
-
this.classCollection = new index_es.Xe(['mg-c-input--date']);
|
|
2034
|
-
this.errorMessage = undefined;
|
|
2035
2169
|
}
|
|
2036
2170
|
validateValue(newValue) {
|
|
2037
2171
|
// When the input is not fully completed or has been cleared, the value becomes an empty string.
|
|
2038
|
-
if (
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
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;
|
|
2043
2177
|
}
|
|
2044
|
-
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)) {
|
|
2045
2183
|
this.valueChange.emit(newValue);
|
|
2046
2184
|
}
|
|
2047
2185
|
else {
|
|
@@ -2056,7 +2194,7 @@ const MgInputDate = class {
|
|
|
2056
2194
|
}
|
|
2057
2195
|
validateMinMax(newValue) {
|
|
2058
2196
|
if (newValue && !this.isValidPattern(newValue)) {
|
|
2059
|
-
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)}.`);
|
|
2060
2198
|
}
|
|
2061
2199
|
}
|
|
2062
2200
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -2078,10 +2216,21 @@ const MgInputDate = class {
|
|
|
2078
2216
|
/**
|
|
2079
2217
|
* Display input error if it exists.
|
|
2080
2218
|
*/
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
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
|
+
});
|
|
2085
2234
|
}
|
|
2086
2235
|
/**
|
|
2087
2236
|
* Set an error and display a custom error message.
|
|
@@ -2095,7 +2244,7 @@ const MgInputDate = class {
|
|
|
2095
2244
|
if (typeof valid !== 'boolean') {
|
|
2096
2245
|
throw new Error('<mg-input-date> method "setError()" param "valid" must be a boolean.');
|
|
2097
2246
|
}
|
|
2098
|
-
else if (!index_es.
|
|
2247
|
+
else if (!index_es.ye(errorMessage)) {
|
|
2099
2248
|
throw new Error('<mg-input-date> method "setError()" param "errorMessage" must be a string.');
|
|
2100
2249
|
}
|
|
2101
2250
|
else {
|
|
@@ -2109,7 +2258,7 @@ const MgInputDate = class {
|
|
|
2109
2258
|
*/
|
|
2110
2259
|
async reset() {
|
|
2111
2260
|
if (!this.readonly) {
|
|
2112
|
-
this.value =
|
|
2261
|
+
this.value = null;
|
|
2113
2262
|
this.checkValidity();
|
|
2114
2263
|
this.invalid = false;
|
|
2115
2264
|
this.errorMessage = undefined;
|
|
@@ -2161,7 +2310,7 @@ const MgInputDate = class {
|
|
|
2161
2310
|
* @returns HTML Element
|
|
2162
2311
|
*/
|
|
2163
2312
|
render() {
|
|
2164
|
-
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) => {
|
|
2165
2314
|
if (el !== null)
|
|
2166
2315
|
this.input = el;
|
|
2167
2316
|
} }))));
|
|
@@ -2194,6 +2343,62 @@ const MgInputNumeric = class {
|
|
|
2194
2343
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
2195
2344
|
// hasDisplayedError (triggered by blur event)
|
|
2196
2345
|
this.hasDisplayedError = false;
|
|
2346
|
+
/**
|
|
2347
|
+
* Input name
|
|
2348
|
+
* If not set the value equals the identifier
|
|
2349
|
+
*/
|
|
2350
|
+
this.name = this.identifier;
|
|
2351
|
+
/**
|
|
2352
|
+
* Define if label is visible
|
|
2353
|
+
*/
|
|
2354
|
+
this.labelHide = false;
|
|
2355
|
+
/**
|
|
2356
|
+
* Define if input is required
|
|
2357
|
+
*/
|
|
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']);
|
|
2197
2402
|
/**
|
|
2198
2403
|
* Handle input event
|
|
2199
2404
|
*/
|
|
@@ -2231,6 +2436,12 @@ const MgInputNumeric = class {
|
|
|
2231
2436
|
this.checkValidity = () => {
|
|
2232
2437
|
this.setValidity(this.readonly || this.disabled || this.getInputError() === null);
|
|
2233
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);
|
|
2234
2445
|
/**
|
|
2235
2446
|
* Set input error message
|
|
2236
2447
|
* @param errorMessage - errorMessage override
|
|
@@ -2247,8 +2458,8 @@ const MgInputNumeric = class {
|
|
|
2247
2458
|
this.errorMessage = this.messages.errors[inputError];
|
|
2248
2459
|
}
|
|
2249
2460
|
else {
|
|
2250
|
-
const formattedMin = this.
|
|
2251
|
-
const formattedMax = this.
|
|
2461
|
+
const formattedMin = this.formatErrorValue(this.min);
|
|
2462
|
+
const formattedMax = this.formatErrorValue(this.max);
|
|
2252
2463
|
this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', formattedMin).replace('{max}', formattedMax);
|
|
2253
2464
|
}
|
|
2254
2465
|
}
|
|
@@ -2287,13 +2498,13 @@ const MgInputNumeric = class {
|
|
|
2287
2498
|
this.formatValue = (value) => {
|
|
2288
2499
|
switch (this.format) {
|
|
2289
2500
|
case 'number':
|
|
2290
|
-
return index_es
|
|
2501
|
+
return index_es.ut(value, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);
|
|
2291
2502
|
case 'currency':
|
|
2292
|
-
return index_es.
|
|
2503
|
+
return index_es.ft(value, this.locale, this.currency);
|
|
2293
2504
|
case 'percent':
|
|
2294
2505
|
return index_es.dt(value / 100, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);
|
|
2295
2506
|
case 'unit':
|
|
2296
|
-
return index_es
|
|
2507
|
+
return index_es.$t(value, this.locale, this.unit, this.unitDisplay, this.type === 'decimal' ? this.decimalLength : undefined);
|
|
2297
2508
|
case 'none':
|
|
2298
2509
|
return value.toString();
|
|
2299
2510
|
}
|
|
@@ -2320,34 +2531,6 @@ const MgInputNumeric = class {
|
|
|
2320
2531
|
this.renderReadonly = () => {
|
|
2321
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));
|
|
2322
2533
|
};
|
|
2323
|
-
this.value = undefined;
|
|
2324
|
-
this.identifier = undefined;
|
|
2325
|
-
this.name = this.identifier;
|
|
2326
|
-
this.label = undefined;
|
|
2327
|
-
this.labelOnTop = undefined;
|
|
2328
|
-
this.labelHide = false;
|
|
2329
|
-
this.placeholder = undefined;
|
|
2330
|
-
this.required = false;
|
|
2331
|
-
this.readonly = false;
|
|
2332
|
-
this.max = undefined;
|
|
2333
|
-
this.min = undefined;
|
|
2334
|
-
this.disabled = false;
|
|
2335
|
-
this.mgWidth = undefined;
|
|
2336
|
-
this.tooltip = undefined;
|
|
2337
|
-
this.tooltipPosition = 'input';
|
|
2338
|
-
this.helpText = undefined;
|
|
2339
|
-
this.type = 'decimal';
|
|
2340
|
-
this.format = 'number';
|
|
2341
|
-
this.currency = 'EUR';
|
|
2342
|
-
this.unit = undefined;
|
|
2343
|
-
this.unitDisplay = 'short';
|
|
2344
|
-
this.integerLength = 13;
|
|
2345
|
-
this.decimalLength = 2;
|
|
2346
|
-
this.valid = undefined;
|
|
2347
|
-
this.invalid = undefined;
|
|
2348
|
-
this.classCollection = new index_es.Xe(['mg-c-input--numeric']);
|
|
2349
|
-
this.errorMessage = undefined;
|
|
2350
|
-
this.hasFocus = undefined;
|
|
2351
2534
|
}
|
|
2352
2535
|
validateValue(newValue) {
|
|
2353
2536
|
// has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type
|
|
@@ -2400,31 +2583,42 @@ const MgInputNumeric = class {
|
|
|
2400
2583
|
}
|
|
2401
2584
|
validateType(newValue) {
|
|
2402
2585
|
if (!types.includes(newValue)) {
|
|
2403
|
-
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)}.`);
|
|
2404
2587
|
}
|
|
2405
2588
|
}
|
|
2406
2589
|
watchFormat(newValue) {
|
|
2407
2590
|
if (!formats.includes(newValue)) {
|
|
2408
|
-
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)}.`);
|
|
2409
2592
|
}
|
|
2410
2593
|
}
|
|
2411
2594
|
validateIntegerLength(newValue) {
|
|
2412
2595
|
if (newValue < 1) {
|
|
2413
|
-
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)}.`);
|
|
2414
2597
|
}
|
|
2415
2598
|
}
|
|
2416
2599
|
validateDecimalLength(newValue) {
|
|
2417
2600
|
if (newValue < 1) {
|
|
2418
|
-
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)}.`);
|
|
2419
2602
|
}
|
|
2420
2603
|
}
|
|
2421
2604
|
/**
|
|
2422
2605
|
* Display input error if it exists.
|
|
2423
2606
|
*/
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
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
|
+
});
|
|
2428
2622
|
}
|
|
2429
2623
|
/**
|
|
2430
2624
|
* Set an error and display a custom error message.
|
|
@@ -2438,7 +2632,7 @@ const MgInputNumeric = class {
|
|
|
2438
2632
|
if (typeof valid !== 'boolean') {
|
|
2439
2633
|
throw new Error('<mg-input-numeric> method "setError()" param "valid" must be a boolean.');
|
|
2440
2634
|
}
|
|
2441
|
-
else if (!index_es.
|
|
2635
|
+
else if (!index_es.ye(errorMessage)) {
|
|
2442
2636
|
throw new Error('<mg-input-numeric> method "setError()" param "errorMessage" must be a string.');
|
|
2443
2637
|
}
|
|
2444
2638
|
else {
|
|
@@ -2544,7 +2738,7 @@ const MgInputNumeric = class {
|
|
|
2544
2738
|
* @returns HTML Element
|
|
2545
2739
|
*/
|
|
2546
2740
|
render() {
|
|
2547
|
-
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
|
|
2548
2742
|
? this.readonlyValue && this.renderReadonly()
|
|
2549
2743
|
: [
|
|
2550
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) => {
|
|
@@ -2581,6 +2775,43 @@ const MgInputPassword = class {
|
|
|
2581
2775
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
2582
2776
|
// hasDisplayedError (triggered by blur event)
|
|
2583
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;
|
|
2584
2815
|
/**
|
|
2585
2816
|
* Handle input event
|
|
2586
2817
|
*/
|
|
@@ -2630,26 +2861,6 @@ const MgInputPassword = class {
|
|
|
2630
2861
|
}
|
|
2631
2862
|
}
|
|
2632
2863
|
};
|
|
2633
|
-
this.value = undefined;
|
|
2634
|
-
this.identifier = undefined;
|
|
2635
|
-
this.name = this.identifier;
|
|
2636
|
-
this.label = undefined;
|
|
2637
|
-
this.labelOnTop = undefined;
|
|
2638
|
-
this.labelHide = false;
|
|
2639
|
-
this.placeholder = undefined;
|
|
2640
|
-
this.maxlength = undefined;
|
|
2641
|
-
this.required = false;
|
|
2642
|
-
this.readonly = false;
|
|
2643
|
-
this.disabled = false;
|
|
2644
|
-
this.mgWidth = 'full';
|
|
2645
|
-
this.tooltip = undefined;
|
|
2646
|
-
this.tooltipPosition = 'input';
|
|
2647
|
-
this.helpText = undefined;
|
|
2648
|
-
this.valid = undefined;
|
|
2649
|
-
this.invalid = undefined;
|
|
2650
|
-
this.classCollection = new index_es.Xe(['mg-c-input--password']);
|
|
2651
|
-
this.errorMessage = undefined;
|
|
2652
|
-
this.displayPassword = false;
|
|
2653
2864
|
}
|
|
2654
2865
|
handleValue(newValue) {
|
|
2655
2866
|
this.valueChange.emit(newValue);
|
|
@@ -2688,10 +2899,21 @@ const MgInputPassword = class {
|
|
|
2688
2899
|
/**
|
|
2689
2900
|
* Display input error if it exists.
|
|
2690
2901
|
*/
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
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
|
+
});
|
|
2695
2917
|
}
|
|
2696
2918
|
/**
|
|
2697
2919
|
* Set an error and display a custom error message.
|
|
@@ -2705,7 +2927,7 @@ const MgInputPassword = class {
|
|
|
2705
2927
|
if (typeof valid !== 'boolean') {
|
|
2706
2928
|
throw new Error('<mg-input-password> method "setError()" param "valid" must be a boolean.');
|
|
2707
2929
|
}
|
|
2708
|
-
else if (!index_es.
|
|
2930
|
+
else if (!index_es.ye(errorMessage)) {
|
|
2709
2931
|
throw new Error('<mg-input-password> method "setError()" param "errorMessage" must be a string.');
|
|
2710
2932
|
}
|
|
2711
2933
|
else {
|
|
@@ -2762,7 +2984,7 @@ const MgInputPassword = class {
|
|
|
2762
2984
|
* @returns HTML Element
|
|
2763
2985
|
*/
|
|
2764
2986
|
render() {
|
|
2765
|
-
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) => {
|
|
2766
2988
|
if (el !== null)
|
|
2767
2989
|
this.input = el;
|
|
2768
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' }))))));
|
|
@@ -2801,6 +3023,43 @@ const MgInputRadio = class {
|
|
|
2801
3023
|
this.classVerticalList = 'mg-c-input--vertical-list';
|
|
2802
3024
|
// hasDisplayedError (triggered by blur event)
|
|
2803
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]);
|
|
2804
3063
|
/**
|
|
2805
3064
|
* Handle input event
|
|
2806
3065
|
* @param event - input event
|
|
@@ -2847,31 +3106,11 @@ const MgInputRadio = class {
|
|
|
2847
3106
|
* @returns element
|
|
2848
3107
|
*/
|
|
2849
3108
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
2850
|
-
this.value = undefined;
|
|
2851
|
-
this.items = undefined;
|
|
2852
|
-
this.identifier = undefined;
|
|
2853
|
-
this.name = this.identifier;
|
|
2854
|
-
this.label = undefined;
|
|
2855
|
-
this.labelOnTop = false;
|
|
2856
|
-
this.labelHide = false;
|
|
2857
|
-
this.inputVerticalList = false;
|
|
2858
|
-
this.required = false;
|
|
2859
|
-
this.readonly = false;
|
|
2860
|
-
this.disabled = false;
|
|
2861
|
-
this.tooltip = undefined;
|
|
2862
|
-
this.tooltipPosition = 'input';
|
|
2863
|
-
this.helpText = undefined;
|
|
2864
|
-
this.valid = undefined;
|
|
2865
|
-
this.invalid = undefined;
|
|
2866
|
-
this.classCollection = new index_es.Xe(['mg-c-input--radio', classFieldset]);
|
|
2867
|
-
this.errorMessage = undefined;
|
|
2868
|
-
this.options = undefined;
|
|
2869
|
-
this.readonlyValue = undefined;
|
|
2870
3109
|
}
|
|
2871
3110
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2872
3111
|
watchValue(newValue) {
|
|
2873
3112
|
var _a;
|
|
2874
|
-
if (index_es.
|
|
3113
|
+
if (index_es.Xe(this.items) && typeof newValue === 'string') {
|
|
2875
3114
|
this.readonlyValue = newValue;
|
|
2876
3115
|
}
|
|
2877
3116
|
else if (Array.isArray(this.items) && this.items.every(isOption$3)) {
|
|
@@ -2885,10 +3124,10 @@ const MgInputRadio = class {
|
|
|
2885
3124
|
validateItems(newValue) {
|
|
2886
3125
|
// Validate if items have required min length
|
|
2887
3126
|
if (typeof newValue === 'object' && newValue.length < 2) {
|
|
2888
|
-
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)}.`);
|
|
2889
3128
|
}
|
|
2890
3129
|
// String array
|
|
2891
|
-
else if (index_es.
|
|
3130
|
+
else if (index_es.Xe(newValue)) {
|
|
2892
3131
|
this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
|
|
2893
3132
|
}
|
|
2894
3133
|
// Object array
|
|
@@ -2896,7 +3135,7 @@ const MgInputRadio = class {
|
|
|
2896
3135
|
this.options = newValue;
|
|
2897
3136
|
}
|
|
2898
3137
|
else {
|
|
2899
|
-
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)}.`);
|
|
2900
3139
|
}
|
|
2901
3140
|
}
|
|
2902
3141
|
watchInputVerticalList(newValue) {
|
|
@@ -2930,10 +3169,21 @@ const MgInputRadio = class {
|
|
|
2930
3169
|
/**
|
|
2931
3170
|
* Display input error if it exists.
|
|
2932
3171
|
*/
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
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
|
+
});
|
|
2937
3187
|
}
|
|
2938
3188
|
/**
|
|
2939
3189
|
* Set an error and display a custom error message.
|
|
@@ -2947,7 +3197,7 @@ const MgInputRadio = class {
|
|
|
2947
3197
|
if (typeof valid !== 'boolean') {
|
|
2948
3198
|
throw new Error('<mg-input-radio> method "setError()" param "valid" must be a boolean.');
|
|
2949
3199
|
}
|
|
2950
|
-
else if (!index_es.
|
|
3200
|
+
else if (!index_es.ye(errorMessage)) {
|
|
2951
3201
|
throw new Error('<mg-input-radio> method "setError()" param "errorMessage" must be a string.');
|
|
2952
3202
|
}
|
|
2953
3203
|
else {
|
|
@@ -3007,7 +3257,7 @@ const MgInputRadio = class {
|
|
|
3007
3257
|
* @returns HTML Element
|
|
3008
3258
|
*/
|
|
3009
3259
|
render() {
|
|
3010
|
-
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) => {
|
|
3011
3261
|
if (el !== null)
|
|
3012
3262
|
this.inputs[index$1] = el;
|
|
3013
3263
|
} }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title))))))));
|
|
@@ -3076,6 +3326,43 @@ const MgInputSelect = class {
|
|
|
3076
3326
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
3077
3327
|
// hasDisplayedError (triggered by blur event)
|
|
3078
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']);
|
|
3079
3366
|
/**
|
|
3080
3367
|
* Handle input event
|
|
3081
3368
|
*/
|
|
@@ -3105,7 +3392,7 @@ const MgInputSelect = class {
|
|
|
3105
3392
|
if (this.input.value === '') {
|
|
3106
3393
|
this.setValue(null);
|
|
3107
3394
|
}
|
|
3108
|
-
else if (index_es.
|
|
3395
|
+
else if (index_es.Xe(this.items) && this.items.includes(this.input.value)) {
|
|
3109
3396
|
this.setValue(this.input.value);
|
|
3110
3397
|
}
|
|
3111
3398
|
else if (allItemsAreOptions(this.items) && typeof this.input.value === 'string' && this.items.some(this.isInputValue)) {
|
|
@@ -3160,34 +3447,10 @@ const MgInputSelect = class {
|
|
|
3160
3447
|
* @returns render option
|
|
3161
3448
|
*/
|
|
3162
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));
|
|
3163
|
-
this.value = undefined;
|
|
3164
|
-
this.items = undefined;
|
|
3165
|
-
this.identifier = undefined;
|
|
3166
|
-
this.name = this.identifier;
|
|
3167
|
-
this.label = undefined;
|
|
3168
|
-
this.labelOnTop = undefined;
|
|
3169
|
-
this.labelHide = false;
|
|
3170
|
-
this.placeholder = undefined;
|
|
3171
|
-
this.placeholderHide = false;
|
|
3172
|
-
this.placeholderDisabled = false;
|
|
3173
|
-
this.required = false;
|
|
3174
|
-
this.readonly = false;
|
|
3175
|
-
this.disabled = false;
|
|
3176
|
-
this.mgWidth = undefined;
|
|
3177
|
-
this.tooltip = undefined;
|
|
3178
|
-
this.tooltipPosition = 'input';
|
|
3179
|
-
this.helpText = undefined;
|
|
3180
|
-
this.valid = undefined;
|
|
3181
|
-
this.invalid = undefined;
|
|
3182
|
-
this.classCollection = new index_es.Xe(['mg-c-input--select']);
|
|
3183
|
-
this.errorMessage = undefined;
|
|
3184
|
-
this.options = undefined;
|
|
3185
|
-
this.valueExist = undefined;
|
|
3186
|
-
this.readonlyValue = undefined;
|
|
3187
3450
|
}
|
|
3188
3451
|
validateValue(newValue) {
|
|
3189
3452
|
var _a, _b;
|
|
3190
|
-
if (index_es.
|
|
3453
|
+
if (index_es.Xe(this.items) && typeof newValue === 'string') {
|
|
3191
3454
|
this.readonlyValue = ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) !== undefined ? this.input.value : newValue;
|
|
3192
3455
|
}
|
|
3193
3456
|
else if (allItemsAreOptions(this.items)) {
|
|
@@ -3204,7 +3467,7 @@ const MgInputSelect = class {
|
|
|
3204
3467
|
this.options = [];
|
|
3205
3468
|
}
|
|
3206
3469
|
// String array
|
|
3207
|
-
else if (index_es.
|
|
3470
|
+
else if (index_es.Xe(newValue)) {
|
|
3208
3471
|
if (typeof this.value === 'string')
|
|
3209
3472
|
this.valueExist = newValue.includes(this.value);
|
|
3210
3473
|
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
@@ -3222,7 +3485,7 @@ const MgInputSelect = class {
|
|
|
3222
3485
|
}
|
|
3223
3486
|
}
|
|
3224
3487
|
else {
|
|
3225
|
-
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)}.`);
|
|
3226
3489
|
}
|
|
3227
3490
|
}
|
|
3228
3491
|
watchReadonly(newValue) {
|
|
@@ -3259,10 +3522,21 @@ const MgInputSelect = class {
|
|
|
3259
3522
|
/**
|
|
3260
3523
|
* Display input error if it exists.
|
|
3261
3524
|
*/
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
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
|
+
});
|
|
3266
3540
|
}
|
|
3267
3541
|
/**
|
|
3268
3542
|
* Set an error and display a custom error message.
|
|
@@ -3276,7 +3550,7 @@ const MgInputSelect = class {
|
|
|
3276
3550
|
if (typeof valid !== 'boolean') {
|
|
3277
3551
|
throw new Error('<mg-input-select> method "setError()" param "valid" must be a boolean.');
|
|
3278
3552
|
}
|
|
3279
|
-
else if (!index_es.
|
|
3553
|
+
else if (!index_es.ye(errorMessage)) {
|
|
3280
3554
|
throw new Error('<mg-input-select> method "setError()" param "errorMessage" must be a string.');
|
|
3281
3555
|
}
|
|
3282
3556
|
else {
|
|
@@ -3340,7 +3614,7 @@ const MgInputSelect = class {
|
|
|
3340
3614
|
* @returns HTML Element
|
|
3341
3615
|
*/
|
|
3342
3616
|
render() {
|
|
3343
|
-
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) => {
|
|
3344
3618
|
if (el !== null)
|
|
3345
3619
|
this.input = el;
|
|
3346
3620
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -3372,7 +3646,7 @@ const isOption$1 = (option) => typeof option === 'object' && typeof option.title
|
|
|
3372
3646
|
* @param options - Datalist options to check.
|
|
3373
3647
|
* @returns True if datalist is well structured.
|
|
3374
3648
|
*/
|
|
3375
|
-
const isDatalistOptions = (options) => index_es.
|
|
3649
|
+
const isDatalistOptions = (options) => index_es.Xe(options) || (Array.isArray(options) && options.every(isOption$1));
|
|
3376
3650
|
const MgInputText = class {
|
|
3377
3651
|
constructor(hostRef) {
|
|
3378
3652
|
index.registerInstance(this, hostRef);
|
|
@@ -3389,6 +3663,51 @@ const MgInputText = class {
|
|
|
3389
3663
|
this.classIsAppendInputSlotContent = 'mg-c-input--is-append-input-slot-content';
|
|
3390
3664
|
// hasDisplayedError (triggered by blur event)
|
|
3391
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']);
|
|
3392
3711
|
/**
|
|
3393
3712
|
* Handle input event
|
|
3394
3713
|
*/
|
|
@@ -3404,7 +3723,7 @@ const MgInputText = class {
|
|
|
3404
3723
|
*/
|
|
3405
3724
|
this.handleFocus = () => {
|
|
3406
3725
|
this.classCollection.add(this.classFocus);
|
|
3407
|
-
this.classCollection = new index_es.
|
|
3726
|
+
this.classCollection = new index_es.Ge(this.classCollection.classes);
|
|
3408
3727
|
};
|
|
3409
3728
|
/**
|
|
3410
3729
|
* Handle blur event
|
|
@@ -3412,7 +3731,7 @@ const MgInputText = class {
|
|
|
3412
3731
|
this.handleBlur = () => {
|
|
3413
3732
|
// Manage focus
|
|
3414
3733
|
this.classCollection.delete(this.classFocus);
|
|
3415
|
-
this.classCollection = new index_es.
|
|
3734
|
+
this.classCollection = new index_es.Ge(this.classCollection.classes);
|
|
3416
3735
|
// Display Error
|
|
3417
3736
|
this.handlerInProgress = 'blur';
|
|
3418
3737
|
this.displayError().finally(() => {
|
|
@@ -3477,31 +3796,6 @@ const MgInputText = class {
|
|
|
3477
3796
|
this.renderReadonly = () => {
|
|
3478
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));
|
|
3479
3798
|
};
|
|
3480
|
-
this.value = undefined;
|
|
3481
|
-
this.identifier = undefined;
|
|
3482
|
-
this.name = this.identifier;
|
|
3483
|
-
this.label = undefined;
|
|
3484
|
-
this.type = 'text';
|
|
3485
|
-
this.icon = undefined;
|
|
3486
|
-
this.labelOnTop = undefined;
|
|
3487
|
-
this.labelHide = false;
|
|
3488
|
-
this.placeholder = undefined;
|
|
3489
|
-
this.datalistoptions = undefined;
|
|
3490
|
-
this.maxlength = 400;
|
|
3491
|
-
this.required = false;
|
|
3492
|
-
this.readonly = false;
|
|
3493
|
-
this.disabled = false;
|
|
3494
|
-
this.mgWidth = 'full';
|
|
3495
|
-
this.pattern = undefined;
|
|
3496
|
-
this.patternErrorMessage = undefined;
|
|
3497
|
-
this.tooltip = undefined;
|
|
3498
|
-
this.tooltipPosition = 'input';
|
|
3499
|
-
this.characterLeftHide = false;
|
|
3500
|
-
this.helpText = undefined;
|
|
3501
|
-
this.valid = undefined;
|
|
3502
|
-
this.invalid = undefined;
|
|
3503
|
-
this.classCollection = new index_es.Xe(['mg-c-input--text']);
|
|
3504
|
-
this.errorMessage = undefined;
|
|
3505
3799
|
}
|
|
3506
3800
|
handleValue(newValue) {
|
|
3507
3801
|
var _a, _b;
|
|
@@ -3522,7 +3816,7 @@ const MgInputText = class {
|
|
|
3522
3816
|
}
|
|
3523
3817
|
validateDatalistoptions(newValue) {
|
|
3524
3818
|
if (Boolean(newValue) && !isDatalistOptions(newValue)) {
|
|
3525
|
-
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)}.`);
|
|
3526
3820
|
}
|
|
3527
3821
|
}
|
|
3528
3822
|
watchReadonly(newValue) {
|
|
@@ -3557,8 +3851,8 @@ const MgInputText = class {
|
|
|
3557
3851
|
this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
|
|
3558
3852
|
}
|
|
3559
3853
|
validatePattern(newValue) {
|
|
3560
|
-
if (newValue !== undefined && !(index_es.
|
|
3561
|
-
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)}'".`);
|
|
3562
3856
|
}
|
|
3563
3857
|
}
|
|
3564
3858
|
/**
|
|
@@ -3570,10 +3864,21 @@ const MgInputText = class {
|
|
|
3570
3864
|
/**
|
|
3571
3865
|
* Display input error if it exists.
|
|
3572
3866
|
*/
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
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
|
+
});
|
|
3577
3882
|
}
|
|
3578
3883
|
/**
|
|
3579
3884
|
* Set an error and display a custom error message.
|
|
@@ -3587,7 +3892,7 @@ const MgInputText = class {
|
|
|
3587
3892
|
if (typeof valid !== 'boolean') {
|
|
3588
3893
|
throw new Error('<mg-input-text> method "setError()" param "valid" must be a boolean.');
|
|
3589
3894
|
}
|
|
3590
|
-
else if (!index_es.
|
|
3895
|
+
else if (!index_es.ye(errorMessage)) {
|
|
3591
3896
|
throw new Error('<mg-input-text> method "setError()" param "errorMessage" must be a string.');
|
|
3592
3897
|
}
|
|
3593
3898
|
else {
|
|
@@ -3652,7 +3957,7 @@ const MgInputText = class {
|
|
|
3652
3957
|
* @returns HTML Element
|
|
3653
3958
|
*/
|
|
3654
3959
|
render() {
|
|
3655
|
-
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
|
|
3656
3961
|
? this.value && this.renderReadonly()
|
|
3657
3962
|
: [
|
|
3658
3963
|
index.h("div", { key: "input", class: "mg-c-input__with-character-left", style: {
|
|
@@ -3697,6 +4002,55 @@ const MgInputTextarea = class {
|
|
|
3697
4002
|
this.classDisplayCharacterLeft = 'mg-c-input--display-character-left';
|
|
3698
4003
|
// hasDisplayedError (triggered by blur event)
|
|
3699
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']);
|
|
3700
4054
|
/**
|
|
3701
4055
|
* Handle input event
|
|
3702
4056
|
*/
|
|
@@ -3712,7 +4066,7 @@ const MgInputTextarea = class {
|
|
|
3712
4066
|
*/
|
|
3713
4067
|
this.handleFocus = () => {
|
|
3714
4068
|
this.classCollection.add(this.classFocus);
|
|
3715
|
-
this.classCollection = new index_es.
|
|
4069
|
+
this.classCollection = new index_es.Ge(this.classCollection.classes);
|
|
3716
4070
|
};
|
|
3717
4071
|
/**
|
|
3718
4072
|
* Handle blur event
|
|
@@ -3720,7 +4074,7 @@ const MgInputTextarea = class {
|
|
|
3720
4074
|
this.handleBlur = () => {
|
|
3721
4075
|
// Manage focus
|
|
3722
4076
|
this.classCollection.delete(this.classFocus);
|
|
3723
|
-
this.classCollection = new index_es.
|
|
4077
|
+
this.classCollection = new index_es.Ge(this.classCollection.classes);
|
|
3724
4078
|
// Display Error
|
|
3725
4079
|
this.handlerInProgress = 'blur';
|
|
3726
4080
|
this.displayError().finally(() => {
|
|
@@ -3761,30 +4115,6 @@ const MgInputTextarea = class {
|
|
|
3761
4115
|
}
|
|
3762
4116
|
}
|
|
3763
4117
|
};
|
|
3764
|
-
this.value = undefined;
|
|
3765
|
-
this.identifier = undefined;
|
|
3766
|
-
this.name = this.identifier;
|
|
3767
|
-
this.label = undefined;
|
|
3768
|
-
this.labelOnTop = undefined;
|
|
3769
|
-
this.labelHide = false;
|
|
3770
|
-
this.placeholder = undefined;
|
|
3771
|
-
this.maxlength = 4000;
|
|
3772
|
-
this.required = false;
|
|
3773
|
-
this.readonly = false;
|
|
3774
|
-
this.disabled = false;
|
|
3775
|
-
this.mgWidth = 'full';
|
|
3776
|
-
this.pattern = undefined;
|
|
3777
|
-
this.patternErrorMessage = undefined;
|
|
3778
|
-
this.rows = 3;
|
|
3779
|
-
this.tooltip = undefined;
|
|
3780
|
-
this.tooltipPosition = 'input';
|
|
3781
|
-
this.characterLeftHide = false;
|
|
3782
|
-
this.helpText = undefined;
|
|
3783
|
-
this.valid = undefined;
|
|
3784
|
-
this.invalid = undefined;
|
|
3785
|
-
this.resizable = 'none';
|
|
3786
|
-
this.classCollection = new index_es.Xe(['mg-c-input--textarea']);
|
|
3787
|
-
this.errorMessage = undefined;
|
|
3788
4118
|
}
|
|
3789
4119
|
handleValue(newValue) {
|
|
3790
4120
|
this.checkValidity();
|
|
@@ -3822,8 +4152,8 @@ const MgInputTextarea = class {
|
|
|
3822
4152
|
this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
|
|
3823
4153
|
}
|
|
3824
4154
|
validatePattern(newValue) {
|
|
3825
|
-
if (newValue !== undefined && !(index_es.
|
|
3826
|
-
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)}'".`);
|
|
3827
4157
|
}
|
|
3828
4158
|
}
|
|
3829
4159
|
validatecharacterLeftHide(newValue) {
|
|
@@ -3837,10 +4167,21 @@ const MgInputTextarea = class {
|
|
|
3837
4167
|
/**
|
|
3838
4168
|
* Display input error if it exists.
|
|
3839
4169
|
*/
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
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
|
+
});
|
|
3844
4185
|
}
|
|
3845
4186
|
/**
|
|
3846
4187
|
* Set an error and display a custom error message.
|
|
@@ -3854,7 +4195,7 @@ const MgInputTextarea = class {
|
|
|
3854
4195
|
if (typeof valid !== 'boolean') {
|
|
3855
4196
|
throw new Error('<mg-input-textarea> method "setError()" param "valid" must be a boolean.');
|
|
3856
4197
|
}
|
|
3857
|
-
else if (!index_es.
|
|
4198
|
+
else if (!index_es.ye(errorMessage)) {
|
|
3858
4199
|
throw new Error('<mg-input-textarea> method "setError()" param "errorMessage" must be a string.');
|
|
3859
4200
|
}
|
|
3860
4201
|
else {
|
|
@@ -3916,7 +4257,7 @@ const MgInputTextarea = class {
|
|
|
3916
4257
|
* @returns HTML Element
|
|
3917
4258
|
*/
|
|
3918
4259
|
render() {
|
|
3919
|
-
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: {
|
|
3920
4261
|
'mg-c-input__box': true,
|
|
3921
4262
|
'mg-c-input__box--width': true,
|
|
3922
4263
|
'mg-c-input__box--resizable': this.resizable === 'both',
|
|
@@ -3947,18 +4288,21 @@ const MgInputTitleStyle0 = mgInputTitleCss;
|
|
|
3947
4288
|
const MgInputTitle = class {
|
|
3948
4289
|
constructor(hostRef) {
|
|
3949
4290
|
index.registerInstance(this, hostRef);
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
4291
|
+
/**
|
|
4292
|
+
* Switch from label to fieldset sementic
|
|
4293
|
+
*/
|
|
3953
4294
|
this.isLegend = false;
|
|
4295
|
+
/**
|
|
4296
|
+
* Component parent tagname
|
|
4297
|
+
*/
|
|
3954
4298
|
this.tagName = 'label';
|
|
3955
4299
|
}
|
|
3956
4300
|
validateIdentifier(newValue) {
|
|
3957
|
-
if (!index_es.
|
|
4301
|
+
if (!index_es.ye(newValue)) {
|
|
3958
4302
|
throw new Error('<mg-input-title> prop "identifier" is required.');
|
|
3959
4303
|
}
|
|
3960
|
-
else if (!index_es.
|
|
3961
|
-
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)}.`);
|
|
3962
4306
|
}
|
|
3963
4307
|
}
|
|
3964
4308
|
validateIsLegend(newValue) {
|
|
@@ -3981,7 +4325,7 @@ const MgInputTitle = class {
|
|
|
3981
4325
|
render() {
|
|
3982
4326
|
const TagName = this.readonly ? 'span' : this.tagName;
|
|
3983
4327
|
// \u00A0 represent a
|
|
3984
|
-
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" }, "*")))));
|
|
3985
4329
|
}
|
|
3986
4330
|
static get watchers() { return {
|
|
3987
4331
|
"identifier": ["validateIdentifier"],
|
|
@@ -4011,6 +4355,43 @@ const MgInputToggle = class {
|
|
|
4011
4355
|
this.classIsActive = 'mg-c-input--toggle-is-active';
|
|
4012
4356
|
this.classOnOff = 'mg-c-input--toggle-on-off';
|
|
4013
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;
|
|
4014
4395
|
/**
|
|
4015
4396
|
* Set input error message
|
|
4016
4397
|
* @param errorMessage - errorMessage override
|
|
@@ -4057,25 +4438,6 @@ const MgInputToggle = class {
|
|
|
4057
4438
|
return null;
|
|
4058
4439
|
}
|
|
4059
4440
|
};
|
|
4060
|
-
this.value = undefined;
|
|
4061
|
-
this.items = undefined;
|
|
4062
|
-
this.identifier = undefined;
|
|
4063
|
-
this.name = this.identifier;
|
|
4064
|
-
this.label = undefined;
|
|
4065
|
-
this.labelOnTop = undefined;
|
|
4066
|
-
this.labelHide = false;
|
|
4067
|
-
this.isOnOff = false;
|
|
4068
|
-
this.isIcon = false;
|
|
4069
|
-
this.readonly = false;
|
|
4070
|
-
this.disabled = false;
|
|
4071
|
-
this.tooltip = undefined;
|
|
4072
|
-
this.tooltipPosition = 'input';
|
|
4073
|
-
this.helpText = undefined;
|
|
4074
|
-
this.classCollection = new index_es.Xe(['mg-c-input--toggle']);
|
|
4075
|
-
this.options = undefined;
|
|
4076
|
-
this.errorMessage = undefined;
|
|
4077
|
-
this.valid = undefined;
|
|
4078
|
-
this.checked = false;
|
|
4079
4441
|
}
|
|
4080
4442
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4081
4443
|
handleValue(newValue) {
|
|
@@ -4086,10 +4448,10 @@ const MgInputToggle = class {
|
|
|
4086
4448
|
}
|
|
4087
4449
|
validateItems(newValue) {
|
|
4088
4450
|
if (typeof newValue === 'object' && this.items.length !== 2) {
|
|
4089
|
-
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)}.`);
|
|
4090
4452
|
}
|
|
4091
4453
|
// String array
|
|
4092
|
-
else if (index_es.
|
|
4454
|
+
else if (index_es.Xe(newValue)) {
|
|
4093
4455
|
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
4094
4456
|
}
|
|
4095
4457
|
// Object array
|
|
@@ -4097,7 +4459,7 @@ const MgInputToggle = class {
|
|
|
4097
4459
|
this.options = newValue;
|
|
4098
4460
|
}
|
|
4099
4461
|
else {
|
|
4100
|
-
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)}.`);
|
|
4101
4463
|
}
|
|
4102
4464
|
}
|
|
4103
4465
|
watchIsOnOff(newValue) {
|
|
@@ -4145,7 +4507,7 @@ const MgInputToggle = class {
|
|
|
4145
4507
|
if (typeof valid !== 'boolean') {
|
|
4146
4508
|
throw new Error('<mg-input-toggle> method "setError()" param "valid" must be a boolean.');
|
|
4147
4509
|
}
|
|
4148
|
-
else if (!index_es.
|
|
4510
|
+
else if (!index_es.ye(errorMessage)) {
|
|
4149
4511
|
throw new Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string.');
|
|
4150
4512
|
}
|
|
4151
4513
|
else {
|
|
@@ -4212,7 +4574,7 @@ const MgInputToggle = class {
|
|
|
4212
4574
|
*/
|
|
4213
4575
|
render() {
|
|
4214
4576
|
const checkedItem = this.getCheckedItem(this.checked);
|
|
4215
|
-
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" }))))));
|
|
4216
4578
|
}
|
|
4217
4579
|
get element() { return index.getElement(this); }
|
|
4218
4580
|
static get watchers() { return {
|
|
@@ -4228,19 +4590,13 @@ const MgInputToggle = class {
|
|
|
4228
4590
|
MgInputToggle.style = MgInputToggleStyle0;
|
|
4229
4591
|
|
|
4230
4592
|
/**
|
|
4231
|
-
*
|
|
4232
|
-
* @param element - element to control type
|
|
4233
|
-
* @returns truthy if element is mg-item-more
|
|
4593
|
+
*
|
|
4234
4594
|
*/
|
|
4235
|
-
const isMgItemMore = (element) => element.nodeName === 'MG-ITEM-MORE';
|
|
4236
|
-
const OverflowBehaviorElements = {
|
|
4237
|
-
BASE_INDEX: 'data-overflow-base-index',
|
|
4238
|
-
PROXY_INDEX: 'data-overflow-proxy-index',
|
|
4239
|
-
};
|
|
4240
4595
|
class OverflowBehavior {
|
|
4241
|
-
constructor(
|
|
4242
|
-
this.
|
|
4243
|
-
this.
|
|
4596
|
+
constructor(parentElement, itemMoreElement, itemMoreContainerElement) {
|
|
4597
|
+
this.parentElement = parentElement;
|
|
4598
|
+
this.itemMoreElement = itemMoreElement;
|
|
4599
|
+
this.itemMoreContainerElement = itemMoreContainerElement;
|
|
4244
4600
|
/**********
|
|
4245
4601
|
* Public *
|
|
4246
4602
|
**********/
|
|
@@ -4254,116 +4610,59 @@ class OverflowBehavior {
|
|
|
4254
4610
|
* Internal *
|
|
4255
4611
|
************/
|
|
4256
4612
|
/**
|
|
4257
|
-
*
|
|
4258
|
-
* @param
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
// set moreElement
|
|
4263
|
-
this._moreElement = this.render();
|
|
4264
|
-
// set children
|
|
4265
|
-
this._baseChildren = this.getInteractiveItems(this.element);
|
|
4266
|
-
if (isMgItemMore(this._moreElement)) {
|
|
4267
|
-
this._proxyChildren = this.getInteractiveItems(this._moreElement.shadowRoot.querySelector('mg-menu'));
|
|
4268
|
-
}
|
|
4269
|
-
// update children
|
|
4270
|
-
this._baseChildren.forEach((child, index) => {
|
|
4271
|
-
child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);
|
|
4272
|
-
// set moreElement children
|
|
4273
|
-
this._proxyChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);
|
|
4274
|
-
});
|
|
4275
|
-
}
|
|
4276
|
-
if (width !== undefined)
|
|
4277
|
-
this.updateDisplayedItems(width);
|
|
4278
|
-
};
|
|
4279
|
-
/**
|
|
4280
|
-
* Get interactive children filtred by authorized nodeName ['MG-MENU-ITEM', 'MG-BUTTON']
|
|
4281
|
-
* @param element - element to parse
|
|
4282
|
-
* @returns children
|
|
4283
|
-
*/
|
|
4284
|
-
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)); };
|
|
4285
|
-
/**
|
|
4286
|
-
* Update displayed items in container from a given available space
|
|
4287
|
-
* @param availableWidth - available width in container to display child items
|
|
4288
|
-
*/
|
|
4289
|
-
this.updateDisplayedItems = (availableWidth) => {
|
|
4290
|
-
this.restoreItems();
|
|
4291
|
-
const acc = { accWidth: 0, previousItem: null };
|
|
4292
|
-
[...this._baseChildren, this._moreElement].forEach((child) => {
|
|
4293
|
-
acc.accWidth += child.offsetWidth;
|
|
4294
|
-
const hasPreviuosItem = acc.previousItem !== null;
|
|
4295
|
-
const isPreviousItemHidden = hasPreviuosItem && acc.previousItem.hasAttribute('hidden');
|
|
4296
|
-
// if previous item is hidden AND is NOT more element we hide current
|
|
4297
|
-
// OR if item has an overflow we hide current
|
|
4298
|
-
// OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item
|
|
4299
|
-
// ELSE current is a display item
|
|
4300
|
-
this.toggleItem(child, (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden));
|
|
4301
|
-
// update previous item with current item
|
|
4302
|
-
acc.previousItem = child;
|
|
4303
|
-
});
|
|
4304
|
-
};
|
|
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;
|
|
4305
4618
|
/**
|
|
4306
4619
|
* Utility method to know if item overflow partialy or totaly in the container
|
|
4307
4620
|
* @param cumulateWidth - previous sibling elements cumulate width + item width
|
|
4308
4621
|
* @param item - item HTML element
|
|
4309
|
-
* @param availableWidth - container available width
|
|
4310
4622
|
* @returns truthy if element is overflow
|
|
4311
4623
|
*/
|
|
4312
|
-
this.isOverflowElement = (cumulateWidth, item
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
};
|
|
4320
|
-
/**
|
|
4321
|
-
* Utility method to know if a given element is the 'MORE' element
|
|
4322
|
-
* @param element - element to match with 'MORE' element
|
|
4323
|
-
* @returns truthy if element is the 'MORE' element
|
|
4324
|
-
*/
|
|
4325
|
-
this.isMoreElement = (element) => element.nodeName === 'MG-ITEM-MORE';
|
|
4326
|
-
/**
|
|
4327
|
-
* Toggle display item element
|
|
4328
|
-
* @param item - item to control
|
|
4329
|
-
* @param isHidden - is item hidden
|
|
4330
|
-
*/
|
|
4331
|
-
this.toggleItem = (item, isHidden) => {
|
|
4332
|
-
const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));
|
|
4333
|
-
if (this.isMoreElement(item))
|
|
4334
|
-
this.toggleElement(this._moreElement, isHidden);
|
|
4335
|
-
else if (mgActionMenuindex >= 0) {
|
|
4336
|
-
this.toggleElement(item, isHidden);
|
|
4337
|
-
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;
|
|
4338
4631
|
}
|
|
4339
|
-
};
|
|
4340
|
-
/**
|
|
4341
|
-
* Toggle element's hide attribute
|
|
4342
|
-
* @param element - element to toggle
|
|
4343
|
-
* @param isHidden - element is hidden
|
|
4344
|
-
*/
|
|
4345
|
-
this.toggleElement = (element, isHidden) => {
|
|
4346
|
-
if (isHidden)
|
|
4347
|
-
element.setAttribute('hidden', '');
|
|
4348
4632
|
else
|
|
4349
|
-
|
|
4633
|
+
return !displayMgItemMore;
|
|
4350
4634
|
};
|
|
4351
4635
|
/**
|
|
4352
|
-
*
|
|
4636
|
+
* Toogle item from isHidden condition
|
|
4637
|
+
* @param item - item to update
|
|
4638
|
+
* @param isHidden - item is hidden
|
|
4353
4639
|
*/
|
|
4354
|
-
this.
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
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));
|
|
4363
4663
|
});
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
this.run();
|
|
4664
|
+
});
|
|
4665
|
+
this._resizeObserver.observe(this.parentElement);
|
|
4367
4666
|
}
|
|
4368
4667
|
}
|
|
4369
4668
|
|
|
@@ -4378,86 +4677,27 @@ const MgItemMore = class {
|
|
|
4378
4677
|
************/
|
|
4379
4678
|
this.name = 'mg-item-more';
|
|
4380
4679
|
/**
|
|
4381
|
-
*
|
|
4382
|
-
* @param proxified - element to proxify from
|
|
4680
|
+
* Define icon
|
|
4383
4681
|
*/
|
|
4384
|
-
this.setProxyElement = (proxified) => {
|
|
4385
|
-
const proxy = this.moreElementMenuItem.querySelector(`[identifier="${proxified.identifier}"]`);
|
|
4386
|
-
if (proxy === null) {
|
|
4387
|
-
return;
|
|
4388
|
-
}
|
|
4389
|
-
// remove proxy id to prevent duplicate key. default html id is: '';
|
|
4390
|
-
if (index_es.me(proxy.id))
|
|
4391
|
-
proxy.id = '';
|
|
4392
|
-
const proxyClickHandler = () => {
|
|
4393
|
-
this.parentMenu
|
|
4394
|
-
.querySelector(`[identifier="${proxy.identifier}"]`)
|
|
4395
|
-
.shadowRoot.querySelector('a, button')
|
|
4396
|
-
.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
4397
|
-
};
|
|
4398
|
-
// Watch the `item-updated` event to keep element needeed properties and innerHTML in sync between the proxified and the proxy elements
|
|
4399
|
-
const updateProxy = (element) => {
|
|
4400
|
-
for (const key in element) {
|
|
4401
|
-
if (['identifier', 'href', 'targer', 'status', 'expanded'].includes(key))
|
|
4402
|
-
element[key] ? proxy.setAttribute(key, element[key]) : proxy.removeAttribute(key);
|
|
4403
|
-
}
|
|
4404
|
-
proxy.innerHTML = element.innerHTML;
|
|
4405
|
-
// When `href` is updated we need to wait the full component re-render before update its handler
|
|
4406
|
-
setTimeout(() => {
|
|
4407
|
-
const interactiveElement = proxy.shadowRoot.querySelector('a, button');
|
|
4408
|
-
interactiveElement === null || interactiveElement === void 0 ? void 0 : interactiveElement.removeEventListener('click', proxyClickHandler);
|
|
4409
|
-
interactiveElement === null || interactiveElement === void 0 ? void 0 : interactiveElement.addEventListener('click', proxyClickHandler);
|
|
4410
|
-
});
|
|
4411
|
-
};
|
|
4412
|
-
updateProxy(proxified);
|
|
4413
|
-
proxified.addEventListener('item-updated', event => {
|
|
4414
|
-
updateProxy(event.target);
|
|
4415
|
-
});
|
|
4416
|
-
// update click event listener on proxy item and mirror the event on the main menu element
|
|
4417
|
-
// we need to wait mg-menu-item to be loaded to ensure the shadowroot is rendered
|
|
4418
|
-
proxy.addEventListener('item-loaded', () => {
|
|
4419
|
-
updateProxy(proxified);
|
|
4420
|
-
});
|
|
4421
|
-
};
|
|
4422
|
-
/***********
|
|
4423
|
-
* Methods *
|
|
4424
|
-
***********/
|
|
4425
|
-
/**
|
|
4426
|
-
* render mg-item-more overflow element
|
|
4427
|
-
* @returns mg-item-more element
|
|
4428
|
-
*/
|
|
4429
|
-
this.renderMgMenuItemOverflowElement = () => {
|
|
4430
|
-
this.parentMenuItems.forEach((child) => {
|
|
4431
|
-
// create item-more menu items element from main menu-items clones
|
|
4432
|
-
this.moreElementMenuItem.querySelector('mg-menu').appendChild(child.cloneNode(true));
|
|
4433
|
-
// we need to get all `mg-menu-item` linked to the cloned one to set mirror process
|
|
4434
|
-
index_es.tt(() => {
|
|
4435
|
-
this.setProxyElement(child);
|
|
4436
|
-
if (child.querySelector('mg-menu') !== null) {
|
|
4437
|
-
child.querySelectorAll('mg-menu-item').forEach(this.setProxyElement);
|
|
4438
|
-
}
|
|
4439
|
-
});
|
|
4440
|
-
});
|
|
4441
|
-
return this.element;
|
|
4442
|
-
};
|
|
4443
4682
|
this.icon = { icon: 'ellipsis-vertical' };
|
|
4683
|
+
/**
|
|
4684
|
+
* Define slot label element
|
|
4685
|
+
*/
|
|
4444
4686
|
this.slotlabel = { display: false };
|
|
4445
|
-
this.size = undefined;
|
|
4446
|
-
this.parentMenu = undefined;
|
|
4447
4687
|
}
|
|
4448
4688
|
validateIcon(newValue) {
|
|
4449
4689
|
if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.icon !== 'string'))
|
|
4450
|
-
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)}.`);
|
|
4451
4691
|
}
|
|
4452
4692
|
validateSlotLabel(newValue) {
|
|
4453
4693
|
if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.display !== 'boolean'))
|
|
4454
|
-
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)}.`);
|
|
4455
4695
|
else if (typeof newValue.label !== 'string')
|
|
4456
4696
|
this.slotlabel.label = this.messages.menuLabel;
|
|
4457
4697
|
}
|
|
4458
4698
|
validateSize(newValue) {
|
|
4459
4699
|
if (newValue && !sizes$3.includes(newValue))
|
|
4460
|
-
throw new Error(`<${this.name}> prop "size" must match MgItemMore['size'] type. Passed value: ${index_es.
|
|
4700
|
+
throw new Error(`<${this.name}> prop "size" must match MgItemMore['size'] type. Passed value: ${index_es.Je(newValue)}.`);
|
|
4461
4701
|
}
|
|
4462
4702
|
/*************
|
|
4463
4703
|
* Lifecycle *
|
|
@@ -4488,8 +4728,7 @@ const MgItemMore = class {
|
|
|
4488
4728
|
*/
|
|
4489
4729
|
componentDidUpdate() {
|
|
4490
4730
|
if (this.parentMenu && this.overflowBehavior === undefined) {
|
|
4491
|
-
this.
|
|
4492
|
-
this.overflowBehavior = new OverflowBehavior(this.parentMenu, this.renderMgMenuItemOverflowElement);
|
|
4731
|
+
this.overflowBehavior = new OverflowBehavior(this.parentMenu, this.element, this.itemMoreContainer);
|
|
4493
4732
|
}
|
|
4494
4733
|
}
|
|
4495
4734
|
/**
|
|
@@ -4504,11 +4743,11 @@ const MgItemMore = class {
|
|
|
4504
4743
|
* @returns HTML Element
|
|
4505
4744
|
*/
|
|
4506
4745
|
render() {
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
} }
|
|
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
|
+
} })))));
|
|
4512
4751
|
}
|
|
4513
4752
|
get element() { return index.getElement(this); }
|
|
4514
4753
|
static get watchers() { return {
|
|
@@ -4519,7 +4758,7 @@ const MgItemMore = class {
|
|
|
4519
4758
|
};
|
|
4520
4759
|
MgItemMore.style = MgItemMoreStyle0;
|
|
4521
4760
|
|
|
4522
|
-
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}";
|
|
4523
4762
|
const MgMenuStyle0 = mgMenuCss;
|
|
4524
4763
|
|
|
4525
4764
|
const MgMenu = class {
|
|
@@ -4529,100 +4768,78 @@ const MgMenu = class {
|
|
|
4529
4768
|
* Internal *
|
|
4530
4769
|
************/
|
|
4531
4770
|
this.name = 'mg-menu';
|
|
4532
|
-
this.menuItems = [];
|
|
4533
|
-
this.focusedMenuItem = 0;
|
|
4534
|
-
/*************
|
|
4535
|
-
* Methods *
|
|
4536
|
-
*************/
|
|
4537
4771
|
/**
|
|
4538
|
-
*
|
|
4539
|
-
* @param item - menu-item to close
|
|
4540
|
-
* @param condition - addionnal condition
|
|
4772
|
+
* Component display direction.
|
|
4541
4773
|
*/
|
|
4542
|
-
this.
|
|
4543
|
-
if (!this.isChildMenu && condition) {
|
|
4544
|
-
item.expanded = false;
|
|
4545
|
-
}
|
|
4546
|
-
};
|
|
4774
|
+
this.direction = Direction.HORIZONTAL;
|
|
4547
4775
|
/**
|
|
4548
|
-
*
|
|
4549
|
-
* @returns mg-menu-item element
|
|
4776
|
+
* Define mg-menu size
|
|
4550
4777
|
*/
|
|
4551
|
-
this.
|
|
4778
|
+
this.size = 'medium';
|
|
4779
|
+
/*************
|
|
4780
|
+
* Methods *
|
|
4781
|
+
*************/
|
|
4552
4782
|
/**
|
|
4553
|
-
*
|
|
4554
|
-
* @
|
|
4555
|
-
* @param index - number
|
|
4783
|
+
* Test if menu is a child menu
|
|
4784
|
+
* @returns truthy if menu is a child menu
|
|
4556
4785
|
*/
|
|
4557
|
-
this.
|
|
4558
|
-
['click', 'focus'].forEach(trigger => {
|
|
4559
|
-
item.shadowRoot.querySelector('button,a').addEventListener(trigger, () => {
|
|
4560
|
-
this.focusedMenuItem = index;
|
|
4561
|
-
// reset expanded on previous active menu item
|
|
4562
|
-
const itemMoreMenuItem = this.getItemMoreMenuItem();
|
|
4563
|
-
(![null, undefined].includes(itemMoreMenuItem) ? [...this.menuItems, itemMoreMenuItem] : this.menuItems).forEach((item, index) => {
|
|
4564
|
-
this.closeMenuItem(item, index !== this.focusedMenuItem);
|
|
4565
|
-
});
|
|
4566
|
-
});
|
|
4567
|
-
});
|
|
4568
|
-
};
|
|
4786
|
+
this.isChildMenu = () => this.element.closest('mg-menu-item') !== null;
|
|
4569
4787
|
/**
|
|
4570
|
-
*
|
|
4788
|
+
* Get menu children items
|
|
4789
|
+
* @returns menu children mg-menu-item
|
|
4571
4790
|
*/
|
|
4572
|
-
this.
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
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;
|
|
4577
4799
|
};
|
|
4578
4800
|
/**
|
|
4579
|
-
*
|
|
4801
|
+
* Update menu items
|
|
4580
4802
|
*/
|
|
4581
|
-
this.
|
|
4582
|
-
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();
|
|
4583
4809
|
};
|
|
4584
4810
|
/**
|
|
4585
4811
|
* render mg-item-more
|
|
4586
4812
|
*/
|
|
4587
4813
|
this.renderMgItemMore = () => {
|
|
4588
4814
|
var _a;
|
|
4589
|
-
if (this.direction
|
|
4815
|
+
if (this.direction === Direction.VERTICAL || this.direction === Direction.HORIZONTAL && this.isChildMenu() || this.element.children.length <= 1) {
|
|
4590
4816
|
return;
|
|
4591
4817
|
}
|
|
4592
4818
|
// Insert mg-item-more outside the mg-menu shadowdom
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
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);
|
|
4597
4823
|
}
|
|
4598
4824
|
// update mg-item-more props
|
|
4599
|
-
for (const
|
|
4600
|
-
|
|
4601
|
-
// to improve rendering we use HTML attributes as much as possible
|
|
4602
|
-
if (['string', 'number'].includes(typeof newValue)) {
|
|
4603
|
-
this.itemMoreElement.setAttribute(attribute, newValue);
|
|
4604
|
-
}
|
|
4605
|
-
else {
|
|
4606
|
-
this.itemMoreElement[attribute] = newValue;
|
|
4607
|
-
}
|
|
4825
|
+
for (const propertie in this.itemmore) {
|
|
4826
|
+
itemMoreElement[propertie] = this.itemmore[propertie];
|
|
4608
4827
|
}
|
|
4609
4828
|
if (((_a = this.itemmore) === null || _a === void 0 ? void 0 : _a.size) === undefined)
|
|
4610
|
-
|
|
4829
|
+
itemMoreElement.size = this.size;
|
|
4611
4830
|
};
|
|
4612
|
-
this.label = undefined;
|
|
4613
|
-
this.direction = Direction.HORIZONTAL;
|
|
4614
|
-
this.itemmore = undefined;
|
|
4615
|
-
this.size = 'medium';
|
|
4616
|
-
this.isChildMenu = undefined;
|
|
4617
4831
|
}
|
|
4618
4832
|
validateLabel(newValue) {
|
|
4619
4833
|
if (newValue === undefined && !this.element.hasAttribute('aria-label')) {
|
|
4620
|
-
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)}.`);
|
|
4621
4835
|
}
|
|
4622
4836
|
}
|
|
4623
4837
|
validateDirection(newValue) {
|
|
4624
4838
|
if (![Direction.VERTICAL, Direction.HORIZONTAL].includes(newValue)) {
|
|
4625
|
-
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();
|
|
4626
4843
|
}
|
|
4627
4844
|
}
|
|
4628
4845
|
validateItemMore(newValue) {
|
|
@@ -4635,9 +4852,30 @@ const MgMenu = class {
|
|
|
4635
4852
|
}
|
|
4636
4853
|
validateSize(newValue) {
|
|
4637
4854
|
if (!sizes$3.includes(newValue)) {
|
|
4638
|
-
throw new Error(`<${this.name}> prop "size" must be one of: ${sizes$3.join(', ')}. Passed value: ${index_es.
|
|
4855
|
+
throw new Error(`<${this.name}> prop "size" must be one of: ${sizes$3.join(', ')}. Passed value: ${index_es.Je(newValue)}.`);
|
|
4639
4856
|
}
|
|
4640
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
|
+
;
|
|
4641
4879
|
/*************
|
|
4642
4880
|
* Lifecycle *
|
|
4643
4881
|
*************/
|
|
@@ -4652,37 +4890,38 @@ const MgMenu = class {
|
|
|
4652
4890
|
}
|
|
4653
4891
|
/**
|
|
4654
4892
|
* Check if component slots configuration
|
|
4655
|
-
* @returns timeout
|
|
4656
4893
|
*/
|
|
4657
4894
|
componentDidLoad() {
|
|
4658
|
-
//
|
|
4659
|
-
|
|
4660
|
-
//
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
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 });
|
|
4679
4918
|
}
|
|
4680
4919
|
/**
|
|
4681
4920
|
* Render
|
|
4682
4921
|
* @returns HTML Element
|
|
4683
4922
|
*/
|
|
4684
4923
|
render() {
|
|
4685
|
-
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' })));
|
|
4686
4925
|
}
|
|
4687
4926
|
get element() { return index.getElement(this); }
|
|
4688
4927
|
static get watchers() { return {
|
|
@@ -4700,7 +4939,6 @@ const MgMenuItemStyle0 = mgMenuItemCss;
|
|
|
4700
4939
|
const MgMenuItem = class {
|
|
4701
4940
|
constructor(hostRef) {
|
|
4702
4941
|
index.registerInstance(this, hostRef);
|
|
4703
|
-
this.statusChange = index.createEvent(this, "status-change", 7);
|
|
4704
4942
|
this.itemLoaded = index.createEvent(this, "item-loaded", 7);
|
|
4705
4943
|
this.itemUpdated = index.createEvent(this, "item-updated", 7);
|
|
4706
4944
|
/************
|
|
@@ -4708,15 +4946,39 @@ const MgMenuItem = class {
|
|
|
4708
4946
|
************/
|
|
4709
4947
|
this.name = 'mg-menu-item';
|
|
4710
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;
|
|
4711
4979
|
/***********
|
|
4712
4980
|
* Methods *
|
|
4713
4981
|
**********/
|
|
4714
|
-
/**
|
|
4715
|
-
* Toggle expanded prop value
|
|
4716
|
-
*/
|
|
4717
|
-
this.toggleExpanded = () => {
|
|
4718
|
-
this.expanded = !this.expanded;
|
|
4719
|
-
};
|
|
4720
4982
|
/**
|
|
4721
4983
|
* Does an Element have given Status
|
|
4722
4984
|
* @param mgMenuItemElement - to parse
|
|
@@ -4724,6 +4986,24 @@ const MgMenuItem = class {
|
|
|
4724
4986
|
* @returns true if element with status is found
|
|
4725
4987
|
*/
|
|
4726
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);
|
|
4727
5007
|
/**
|
|
4728
5008
|
* Is component contextual direction match the given direction
|
|
4729
5009
|
* @param direction - in parent menu
|
|
@@ -4741,25 +5021,37 @@ const MgMenuItem = class {
|
|
|
4741
5021
|
childMenu !== null && Array.from(childMenu.children).some((subItem) => subItem.querySelector('mg-badge') !== null && !subItem.hasAttribute('hidden'));
|
|
4742
5022
|
};
|
|
4743
5023
|
/**
|
|
4744
|
-
*
|
|
4745
|
-
* @
|
|
5024
|
+
* Update expanded prop
|
|
5025
|
+
* @param newValue - expanded new value
|
|
4746
5026
|
*/
|
|
4747
|
-
this.
|
|
4748
|
-
|
|
4749
|
-
|
|
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
|
+
}
|
|
4750
5041
|
};
|
|
4751
5042
|
/**
|
|
4752
|
-
*
|
|
5043
|
+
* Update slots
|
|
4753
5044
|
* @param guard - prevent action with guard. Default: false.
|
|
4754
5045
|
*/
|
|
4755
|
-
this.
|
|
5046
|
+
this.updateSlot = (guard = false) => {
|
|
4756
5047
|
// slot title AND metadata validation
|
|
4757
5048
|
// add title on label AND metada slots due to text-overflow on these element
|
|
4758
|
-
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) {
|
|
4759
5050
|
throw new Error(`<${this.name}> slot "label" is required.`);
|
|
5051
|
+
}
|
|
4760
5052
|
['label', 'metadata'].forEach(slot => {
|
|
4761
5053
|
Array.from(this.element.querySelectorAll(`[slot="${slot}"]`)).forEach(element => {
|
|
4762
|
-
if (!index_es.
|
|
5054
|
+
if (!index_es.ye(element.textContent))
|
|
4763
5055
|
throw new Error(`<${this.name}> slot "${slot}" must have text content.`);
|
|
4764
5056
|
if ((guard && !element.hasAttribute('title')) || !guard)
|
|
4765
5057
|
element.setAttribute('title', element.textContent);
|
|
@@ -4767,39 +5059,23 @@ const MgMenuItem = class {
|
|
|
4767
5059
|
});
|
|
4768
5060
|
};
|
|
4769
5061
|
/**
|
|
4770
|
-
* Update
|
|
4771
|
-
* @param guard -
|
|
4772
|
-
*/
|
|
4773
|
-
this.updateStatus = (guard = []) => {
|
|
4774
|
-
if (![Status$1.HIDDEN, Status$1.DISABLED, ...guard].includes(this.status)) {
|
|
4775
|
-
this.status = this.hasActiveChild() ? Status$1.ACTIVE : Status$1.VISIBLE;
|
|
4776
|
-
}
|
|
4777
|
-
};
|
|
4778
|
-
/**
|
|
4779
|
-
* Init event-listeners
|
|
5062
|
+
* Update menu item
|
|
5063
|
+
* @param guard - prevent action with guard
|
|
4780
5064
|
*/
|
|
4781
|
-
this.
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
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();
|
|
4792
5078
|
};
|
|
4793
|
-
/**
|
|
4794
|
-
* Get mg-popover identifier
|
|
4795
|
-
* @returns generated mg-popover identifier
|
|
4796
|
-
*/
|
|
4797
|
-
this.getPopoverIdentifier = () => `${this.identifier}-popover`;
|
|
4798
|
-
/**
|
|
4799
|
-
* Condition to know if component should display a mg-popover
|
|
4800
|
-
* @returns truthy if component display popover
|
|
4801
|
-
*/
|
|
4802
|
-
this.displayPopover = () => this.isDirection(Direction.HORIZONTAL) && this.hasChildren && this.href === undefined;
|
|
4803
5079
|
/************
|
|
4804
5080
|
* Handlers *
|
|
4805
5081
|
************/
|
|
@@ -4808,106 +5084,123 @@ const MgMenuItem = class {
|
|
|
4808
5084
|
* @param event - click on element
|
|
4809
5085
|
*/
|
|
4810
5086
|
this.handleElementCLick = (event) => {
|
|
4811
|
-
if (
|
|
5087
|
+
if (this.status === Status$1.DISABLED) {
|
|
4812
5088
|
event.preventDefault();
|
|
4813
5089
|
event.stopPropagation();
|
|
4814
5090
|
}
|
|
4815
|
-
//
|
|
4816
|
-
|
|
4817
|
-
|
|
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
|
+
}
|
|
4818
5107
|
};
|
|
4819
5108
|
/**
|
|
4820
5109
|
* Handle popover element display-change event
|
|
4821
5110
|
* @param event - popover display event
|
|
4822
5111
|
*/
|
|
4823
5112
|
this.handlePopoverDisplay = (event) => {
|
|
4824
|
-
this.
|
|
5113
|
+
this.updateExpanded(event.detail);
|
|
4825
5114
|
};
|
|
4826
5115
|
/**
|
|
4827
5116
|
* Render slot
|
|
4828
5117
|
* @returns HTML Element
|
|
4829
5118
|
*/
|
|
4830
5119
|
this.renderSlot = () => index.h("slot", null);
|
|
4831
|
-
this.identifier = index_es.qe('mg-menu-item');
|
|
4832
|
-
this.href = undefined;
|
|
4833
|
-
this.target = undefined;
|
|
4834
|
-
this.status = Status$1.VISIBLE;
|
|
4835
|
-
this.expanded = false;
|
|
4836
|
-
this.size = 'medium';
|
|
4837
|
-
this.navigationButtonClassList = new index_es.Xe([this.navigationButton]);
|
|
4838
|
-
this.direction = undefined;
|
|
4839
|
-
this.isInMainMenu = undefined;
|
|
4840
|
-
this.isItemMore = undefined;
|
|
4841
|
-
this.hasChildren = false;
|
|
4842
|
-
this.displayNotificationBadge = undefined;
|
|
4843
5120
|
}
|
|
4844
5121
|
watchIdentifier(newValue) {
|
|
4845
|
-
if (!index_es.
|
|
4846
|
-
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`;
|
|
4847
5127
|
}
|
|
4848
5128
|
}
|
|
4849
5129
|
watchTarget(newValue) {
|
|
4850
5130
|
if (newValue && !targets.includes(newValue)) {
|
|
4851
|
-
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)}.`);
|
|
4852
5132
|
}
|
|
4853
5133
|
}
|
|
4854
|
-
|
|
4855
|
-
if (oldValue !== undefined)
|
|
5134
|
+
watchStatus(newValue, oldValue) {
|
|
5135
|
+
if (oldValue !== undefined)
|
|
4856
5136
|
this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
|
|
4857
|
-
}
|
|
4858
5137
|
this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
});
|
|
4872
|
-
}
|
|
4873
|
-
else if (this.element.querySelector(`${this.name}[status="${Status$1.ACTIVE}"]`) !== null) {
|
|
4874
|
-
// - when expanded and contain an active item parents are expended too
|
|
4875
|
-
subItems.forEach(item => {
|
|
4876
|
-
if (this.hasStatus(item, Status$1.ACTIVE)) {
|
|
4877
|
-
item.expanded = true;
|
|
4878
|
-
}
|
|
4879
|
-
});
|
|
4880
|
-
}
|
|
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
|
+
});
|
|
4881
5150
|
}
|
|
4882
5151
|
}
|
|
4883
|
-
|
|
4884
|
-
|
|
5152
|
+
watchSize(newValue, oldValue) {
|
|
5153
|
+
if (oldValue !== undefined)
|
|
5154
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
|
|
4885
5155
|
this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
|
|
4886
5156
|
}
|
|
4887
|
-
validateDirection(newValue) {
|
|
4888
|
-
|
|
4889
|
-
|
|
5157
|
+
validateDirection(newValue, oldValue) {
|
|
5158
|
+
if (oldValue !== undefined)
|
|
5159
|
+
this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
|
|
4890
5160
|
this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
|
|
4891
5161
|
// manage all sub levels child menu-items level with data-level attribut
|
|
4892
|
-
|
|
4893
|
-
|
|
5162
|
+
Array.from(this.element.querySelectorAll('mg-menu-item')).forEach(item => {
|
|
5163
|
+
if (this.isDirection(Direction.VERTICAL, newValue)) {
|
|
4894
5164
|
item.dataset.level = `${(Number(item.dataset.level) || 1) + 1}`;
|
|
4895
|
-
}
|
|
4896
|
-
|
|
5165
|
+
}
|
|
5166
|
+
else {
|
|
5167
|
+
delete item.dataset.level;
|
|
5168
|
+
}
|
|
5169
|
+
});
|
|
4897
5170
|
}
|
|
4898
5171
|
validateHasChildren(newValue) {
|
|
4899
5172
|
if (newValue && this.element.href !== undefined) {
|
|
4900
5173
|
throw new Error(`<${this.name}> prop "href" is unauthorizied when element is a parent.`);
|
|
4901
5174
|
}
|
|
4902
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
|
+
}
|
|
4903
5193
|
/**
|
|
4904
5194
|
* Render popover clickoutside guard for content slot
|
|
4905
5195
|
*/
|
|
4906
5196
|
updatePopoverGuard() {
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
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;
|
|
4911
5204
|
}
|
|
4912
5205
|
/*************
|
|
4913
5206
|
* Lifecycle *
|
|
@@ -4921,13 +5214,12 @@ const MgMenuItem = class {
|
|
|
4921
5214
|
this.hasChildren = Array.from(this.element.children).some(child => !['image', 'information', 'label', 'metadata'].includes(child.getAttribute('slot')));
|
|
4922
5215
|
this.messages = index$1.initLocales(this.element).messages.menuItem;
|
|
4923
5216
|
this.isItemMore = this.element.dataset.overflowMore !== undefined;
|
|
4924
|
-
//
|
|
4925
|
-
this.
|
|
4926
|
-
this.
|
|
5217
|
+
// watchers
|
|
5218
|
+
this.watchStatus(this.status);
|
|
5219
|
+
this.watchExpanded(this.expanded);
|
|
4927
5220
|
this.watchTarget(this.target);
|
|
4928
5221
|
this.watchIdentifier(this.identifier);
|
|
4929
|
-
|
|
4930
|
-
this.validateSize(this.size);
|
|
5222
|
+
this.watchSize(this.size);
|
|
4931
5223
|
}
|
|
4932
5224
|
/**
|
|
4933
5225
|
* Check if component slots configuration
|
|
@@ -4935,40 +5227,36 @@ const MgMenuItem = class {
|
|
|
4935
5227
|
*/
|
|
4936
5228
|
componentDidLoad() {
|
|
4937
5229
|
// validation
|
|
4938
|
-
this.
|
|
5230
|
+
this.updateSlot(true);
|
|
4939
5231
|
// update props and states after componentDidLoad hook
|
|
4940
5232
|
// return a promise to process action only in the FIRST render().
|
|
4941
5233
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
4942
5234
|
return setTimeout(() => {
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
this.
|
|
4946
|
-
this.isInMainMenu = menu !== null && this.element.parentElement.closest('mg-menu-item') === null;
|
|
4947
|
-
if ((menu === null || menu === void 0 ? void 0 : menu.size) !== undefined)
|
|
4948
|
-
this.size = menu.size;
|
|
4949
|
-
if (this.isItemMore)
|
|
4950
|
-
this.size = this.element.dataset.size;
|
|
4951
|
-
// when main menu item contain an active item it will get the active style
|
|
4952
|
-
// AND if item is in vertical menu it will be expanded
|
|
4953
|
-
if (this.hasActiveChild() && this.isInMainMenu)
|
|
4954
|
-
this.expanded = this.isDirection(Direction.VERTICAL);
|
|
4955
|
-
this.updateStatus([Status$1.ACTIVE]);
|
|
4956
|
-
this.updateDisplayNotificationBadge();
|
|
4957
|
-
this.updatePopoverGuard();
|
|
4958
|
-
// manage child dom changes with mutationObserver and listners
|
|
4959
|
-
this.initListeners();
|
|
5235
|
+
this.watchDataStyleDirection(this.element.dataset.styleDirection);
|
|
5236
|
+
this.watchDataHasFocus(this.element.dataset.hasFocus);
|
|
5237
|
+
this.updateItem([Status$1.ACTIVE]);
|
|
4960
5238
|
// emit loaded event when component is fully loaded
|
|
4961
5239
|
this.itemLoaded.emit();
|
|
4962
5240
|
new MutationObserver(mutationsList => {
|
|
4963
|
-
if (mutationsList.some(mutation => mutation.attributeName
|
|
5241
|
+
if (mutationsList.some(mutation => ['hidden', 'status'].includes(mutation.attributeName)))
|
|
4964
5242
|
this.updateStatus(this.hasChildren ? undefined : [Status$1.ACTIVE]);
|
|
4965
5243
|
if (mutationsList.some(mutation => mutation.type === 'characterData'))
|
|
4966
|
-
this.
|
|
4967
|
-
|
|
5244
|
+
this.updateSlot();
|
|
5245
|
+
if (mutationsList.some(mutation => mutation.type === 'childList'))
|
|
5246
|
+
this.updateItem();
|
|
4968
5247
|
this.itemUpdated.emit();
|
|
4969
5248
|
}).observe(this.element, { attributes: true, childList: true, characterData: true, subtree: true });
|
|
4970
5249
|
}, 0);
|
|
4971
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
|
+
}
|
|
4972
5260
|
/**
|
|
4973
5261
|
* Render ineractive element
|
|
4974
5262
|
* @returns HTML Element
|
|
@@ -4983,15 +5271,6 @@ const MgMenuItem = class {
|
|
|
4983
5271
|
[`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
|
|
4984
5272
|
} }, index.h("mg-icon", { icon: "chevron-down" })))));
|
|
4985
5273
|
}
|
|
4986
|
-
/**
|
|
4987
|
-
* Emit event when component is updated
|
|
4988
|
-
* @returns promise process wich emit the 'item-updated' event
|
|
4989
|
-
*/
|
|
4990
|
-
componentShouldUpdate() {
|
|
4991
|
-
return index_es.tt(() => {
|
|
4992
|
-
this.itemUpdated.emit();
|
|
4993
|
-
});
|
|
4994
|
-
}
|
|
4995
5274
|
/**
|
|
4996
5275
|
* Render
|
|
4997
5276
|
* @returns HTML Element
|
|
@@ -5001,7 +5280,7 @@ const MgMenuItem = class {
|
|
|
5001
5280
|
['mg-c-menu-item__collapse-container']: true,
|
|
5002
5281
|
['mg-c-menu-item__collapse-container--first-level']: (this.isInMainMenu || this.isItemMore) && this.isDirection(Direction.HORIZONTAL),
|
|
5003
5282
|
});
|
|
5004
|
-
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
|
|
5005
5284
|
}, this.renderInteractiveElement(), index.h("div", { class: getContainerClasses(), slot: "content" }, this.renderSlot()))) : ([
|
|
5006
5285
|
this.renderInteractiveElement(),
|
|
5007
5286
|
index.h("div", { key: "vertical-container", class: getContainerClasses(), hidden: !this.expanded }, this.renderSlot()),
|
|
@@ -5011,11 +5290,13 @@ const MgMenuItem = class {
|
|
|
5011
5290
|
static get watchers() { return {
|
|
5012
5291
|
"identifier": ["watchIdentifier"],
|
|
5013
5292
|
"target": ["watchTarget"],
|
|
5014
|
-
"status": ["
|
|
5015
|
-
"expanded": ["
|
|
5016
|
-
"size": ["
|
|
5293
|
+
"status": ["watchStatus"],
|
|
5294
|
+
"expanded": ["watchExpanded"],
|
|
5295
|
+
"size": ["watchSize"],
|
|
5017
5296
|
"direction": ["validateDirection"],
|
|
5018
|
-
"hasChildren": ["validateHasChildren"]
|
|
5297
|
+
"hasChildren": ["validateHasChildren"],
|
|
5298
|
+
"data-style-direction": ["watchDataStyleDirection"],
|
|
5299
|
+
"data-has-focus": ["watchDataHasFocus"]
|
|
5019
5300
|
}; }
|
|
5020
5301
|
};
|
|
5021
5302
|
MgMenuItem.style = MgMenuItemStyle0;
|
|
@@ -5039,6 +5320,22 @@ const MgMessage = class {
|
|
|
5039
5320
|
* Internal *
|
|
5040
5321
|
************/
|
|
5041
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;
|
|
5042
5339
|
/**
|
|
5043
5340
|
* Get icon corresponding to variant
|
|
5044
5341
|
* @returns icon
|
|
@@ -5055,14 +5352,10 @@ const MgMessage = class {
|
|
|
5055
5352
|
return 'exclamation-circle';
|
|
5056
5353
|
}
|
|
5057
5354
|
};
|
|
5058
|
-
this.variant = 'info';
|
|
5059
|
-
this.variantStyle = 'bar-left';
|
|
5060
|
-
this.classCollection = new index_es.Xe(['mg-c-message']);
|
|
5061
|
-
this.hasActions = false;
|
|
5062
5355
|
}
|
|
5063
5356
|
watchVariant(newValue, oldValue) {
|
|
5064
5357
|
if (!variants$1.includes(newValue)) {
|
|
5065
|
-
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)}.`);
|
|
5066
5359
|
}
|
|
5067
5360
|
else {
|
|
5068
5361
|
if (newValue !== undefined)
|
|
@@ -5073,7 +5366,7 @@ const MgMessage = class {
|
|
|
5073
5366
|
}
|
|
5074
5367
|
watchVariantStyle(newValue, oldValue) {
|
|
5075
5368
|
if (!variantStyles.includes(newValue)) {
|
|
5076
|
-
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)}.`);
|
|
5077
5370
|
}
|
|
5078
5371
|
else {
|
|
5079
5372
|
if (newValue !== undefined)
|
|
@@ -5100,9 +5393,9 @@ const MgMessage = class {
|
|
|
5100
5393
|
* @returns HTML Element
|
|
5101
5394
|
*/
|
|
5102
5395
|
render() {
|
|
5103
|
-
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 && [
|
|
5104
5397
|
index.h("span", { class: "mg-c-message__content-separator", key: "content-separator" }),
|
|
5105
|
-
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" })),
|
|
5106
5399
|
]))));
|
|
5107
5400
|
}
|
|
5108
5401
|
get element() { return index.getElement(this); }
|
|
@@ -5129,6 +5422,31 @@ const MgModal = class {
|
|
|
5129
5422
|
this.componentClose = index.createEvent(this, "component-close", 7);
|
|
5130
5423
|
// IDs
|
|
5131
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']);
|
|
5132
5450
|
/***********
|
|
5133
5451
|
* Handles *
|
|
5134
5452
|
***********/
|
|
@@ -5139,26 +5457,19 @@ const MgModal = class {
|
|
|
5139
5457
|
this.open = false;
|
|
5140
5458
|
this.componentClose.emit();
|
|
5141
5459
|
};
|
|
5142
|
-
this.identifier = index_es.qe('mg-modal');
|
|
5143
|
-
this.dialogRole = dialogRoles[0];
|
|
5144
|
-
this.modalTitle = undefined;
|
|
5145
|
-
this.closeButton = false;
|
|
5146
|
-
this.open = false;
|
|
5147
|
-
this.hasActions = false;
|
|
5148
|
-
this.classCollection = new index_es.Xe(['mg-c-modal']);
|
|
5149
5460
|
}
|
|
5150
5461
|
watchIdentifier(newValue) {
|
|
5151
|
-
if (!index_es.
|
|
5152
|
-
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)}.`);
|
|
5153
5464
|
}
|
|
5154
5465
|
}
|
|
5155
5466
|
validateDialogRole(newValue) {
|
|
5156
5467
|
if (!dialogRoles.includes(newValue))
|
|
5157
|
-
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)}.`);
|
|
5158
5469
|
}
|
|
5159
5470
|
validateModalTitle(newValue) {
|
|
5160
|
-
if (!index_es.
|
|
5161
|
-
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)}.`);
|
|
5162
5473
|
}
|
|
5163
5474
|
}
|
|
5164
5475
|
watchOpen(newValue) {
|
|
@@ -5207,11 +5518,11 @@ const MgModal = class {
|
|
|
5207
5518
|
* @returns HTML Element
|
|
5208
5519
|
*/
|
|
5209
5520
|
render() {
|
|
5210
|
-
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) => {
|
|
5211
5522
|
if (el !== null) {
|
|
5212
5523
|
this.dialog = el;
|
|
5213
5524
|
}
|
|
5214
|
-
} }, index.h("mg-card", { key: '
|
|
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" })))))));
|
|
5215
5526
|
}
|
|
5216
5527
|
get element() { return index.getElement(this); }
|
|
5217
5528
|
static get watchers() { return {
|
|
@@ -5257,6 +5568,19 @@ const MgPagination = class {
|
|
|
5257
5568
|
constructor(hostRef) {
|
|
5258
5569
|
index.registerInstance(this, hostRef);
|
|
5259
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;
|
|
5260
5584
|
/**
|
|
5261
5585
|
* Change current page from target
|
|
5262
5586
|
* @param target - target page
|
|
@@ -5283,26 +5607,20 @@ const MgPagination = class {
|
|
|
5283
5607
|
this.handleGoToPage = (action, disabled) => {
|
|
5284
5608
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
5285
5609
|
};
|
|
5286
|
-
this.identifier = index_es.qe('mg-pagination');
|
|
5287
|
-
this.label = undefined;
|
|
5288
|
-
this.hideNavigationLabels = undefined;
|
|
5289
|
-
this.hidePageCount = undefined;
|
|
5290
|
-
this.totalPages = 1;
|
|
5291
|
-
this.currentPage = 1;
|
|
5292
5610
|
}
|
|
5293
5611
|
watchIdentifier(newValue) {
|
|
5294
|
-
if (!index_es.
|
|
5295
|
-
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)}.`);
|
|
5296
5614
|
}
|
|
5297
5615
|
}
|
|
5298
5616
|
validateTotalPages(newValue) {
|
|
5299
5617
|
if (newValue < 1) {
|
|
5300
|
-
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)}.`);
|
|
5301
5619
|
}
|
|
5302
5620
|
}
|
|
5303
5621
|
validateCurrentPage(newValue) {
|
|
5304
5622
|
if (newValue < 1) {
|
|
5305
|
-
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)}.`);
|
|
5306
5624
|
}
|
|
5307
5625
|
else if (newValue > this.totalPages) {
|
|
5308
5626
|
throw new Error('<mg-pagination> prop "currentPage" can not be greater than total page.');
|
|
@@ -5332,10 +5650,10 @@ const MgPagination = class {
|
|
|
5332
5650
|
* @returns HTML Element
|
|
5333
5651
|
*/
|
|
5334
5652
|
render() {
|
|
5335
|
-
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`],
|
|
5336
5654
|
// eslint-disable-next-line react/jsx-no-bind
|
|
5337
|
-
onClick: () => this.handleGoToPage(action, disabled), disabled: disabled, variant: "flat", isIcon: this.hideNavigationLabels }, action === NavigationAction.PREVIOUS && index.h("mg-icon", { key: '
|
|
5338
|
-
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))));
|
|
5339
5657
|
}
|
|
5340
5658
|
get element() { return index.getElement(this); }
|
|
5341
5659
|
static get watchers() { return {
|
|
@@ -5363,6 +5681,35 @@ const MgPanel = class {
|
|
|
5363
5681
|
index.registerInstance(this, hostRef);
|
|
5364
5682
|
this.titleChange = index.createEvent(this, "title-change", 7);
|
|
5365
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;
|
|
5366
5713
|
/************
|
|
5367
5714
|
* Methods *
|
|
5368
5715
|
************/
|
|
@@ -5455,27 +5802,15 @@ const MgPanel = class {
|
|
|
5455
5802
|
];
|
|
5456
5803
|
return this.titlePosition === 'right' ? children.reverse() : children;
|
|
5457
5804
|
};
|
|
5458
|
-
this.identifier = index_es.qe('mg-panel');
|
|
5459
|
-
this.panelTitle = undefined;
|
|
5460
|
-
this.titlePattern = undefined;
|
|
5461
|
-
this.titlePatternErrorMessage = undefined;
|
|
5462
|
-
this.titleEditable = false;
|
|
5463
|
-
this.titlePosition = titlePositions[0];
|
|
5464
|
-
this.expanded = false;
|
|
5465
|
-
this.expandToggleDisplay = expandToggleDisplays[0];
|
|
5466
|
-
this.expandToggleDisabled = undefined;
|
|
5467
|
-
this.classCollection = new index_es.Xe(['mg-c-panel']);
|
|
5468
|
-
this.isEditing = false;
|
|
5469
|
-
this.updatedPanelTitle = undefined;
|
|
5470
5805
|
}
|
|
5471
5806
|
watchIdentifier(newValue) {
|
|
5472
|
-
if (!index_es.
|
|
5473
|
-
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)}.`);
|
|
5474
5809
|
}
|
|
5475
5810
|
}
|
|
5476
5811
|
validatePanelTitle(newValue) {
|
|
5477
|
-
if (!index_es.
|
|
5478
|
-
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)}.`);
|
|
5479
5814
|
this.titleChange.emit(newValue);
|
|
5480
5815
|
}
|
|
5481
5816
|
validateTitlePattern(newValue) {
|
|
@@ -5484,14 +5819,14 @@ const MgPanel = class {
|
|
|
5484
5819
|
}
|
|
5485
5820
|
validateTitlePosition(newValue) {
|
|
5486
5821
|
if (!titlePositions.includes(newValue))
|
|
5487
|
-
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)}.`);
|
|
5488
5823
|
}
|
|
5489
5824
|
handleExpanded(newValue) {
|
|
5490
5825
|
this.expandedChange.emit(newValue);
|
|
5491
5826
|
}
|
|
5492
5827
|
validateExpandToggleDisplay(newValue) {
|
|
5493
5828
|
if (!expandToggleDisplays.includes(newValue))
|
|
5494
|
-
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)}.`);
|
|
5495
5830
|
if (newValue === 'icon' && this.titleEditable)
|
|
5496
5831
|
this.titleEditable = false;
|
|
5497
5832
|
}
|
|
@@ -5526,7 +5861,7 @@ const MgPanel = class {
|
|
|
5526
5861
|
*/
|
|
5527
5862
|
render() {
|
|
5528
5863
|
const headerId = `${this.identifier}-header`;
|
|
5529
|
-
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' })))));
|
|
5530
5865
|
}
|
|
5531
5866
|
get element() { return index.getElement(this); }
|
|
5532
5867
|
static get watchers() { return {
|
|
@@ -7340,6 +7675,31 @@ const MgPopover = class {
|
|
|
7340
7675
|
index.registerInstance(this, hostRef);
|
|
7341
7676
|
this.displayChange = index.createEvent(this, "display-change", 7);
|
|
7342
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;
|
|
7343
7703
|
/**
|
|
7344
7704
|
* Check if clicked outside of component
|
|
7345
7705
|
* @param event - mouse event
|
|
@@ -7432,16 +7792,10 @@ const MgPopover = class {
|
|
|
7432
7792
|
mgPopoverContent.setAttribute('id', this.identifier);
|
|
7433
7793
|
}
|
|
7434
7794
|
};
|
|
7435
|
-
this.identifier = index_es.qe('mg-popover');
|
|
7436
|
-
this.placement = 'bottom';
|
|
7437
|
-
this.arrowHide = false;
|
|
7438
|
-
this.closeButton = false;
|
|
7439
|
-
this.display = false;
|
|
7440
|
-
this.disabled = false;
|
|
7441
7795
|
}
|
|
7442
7796
|
validateIdentifier(newValue) {
|
|
7443
|
-
if (!index_es.
|
|
7444
|
-
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)}.`);
|
|
7445
7799
|
}
|
|
7446
7800
|
// use renderPopoverContent to update popover-content id
|
|
7447
7801
|
this.renderPopoverContent();
|
|
@@ -7530,6 +7884,12 @@ const MgPopover = class {
|
|
|
7530
7884
|
if (!this.disabled)
|
|
7531
7885
|
this.display = !this.display;
|
|
7532
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
|
+
});
|
|
7533
7893
|
// Add events to hide popover
|
|
7534
7894
|
this.element.addEventListener('keydown', e => {
|
|
7535
7895
|
if (!this.disabled && e.code === 'Escape') {
|
|
@@ -7545,7 +7905,7 @@ const MgPopover = class {
|
|
|
7545
7905
|
* @returns HTML Element
|
|
7546
7906
|
*/
|
|
7547
7907
|
render() {
|
|
7548
|
-
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" })));
|
|
7549
7909
|
}
|
|
7550
7910
|
get element() { return index.getElement(this); }
|
|
7551
7911
|
static get watchers() { return {
|
|
@@ -7564,14 +7924,20 @@ const MgPopoverContent = class {
|
|
|
7564
7924
|
constructor(hostRef) {
|
|
7565
7925
|
index.registerInstance(this, hostRef);
|
|
7566
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']);
|
|
7567
7935
|
/**
|
|
7568
7936
|
* Handle action for close button
|
|
7569
7937
|
*/
|
|
7570
7938
|
this.handleCloseButton = () => {
|
|
7571
7939
|
this.hideContent.emit();
|
|
7572
7940
|
};
|
|
7573
|
-
this.closeButton = false;
|
|
7574
|
-
this.classCollection = new index_es.Xe(['mg-c-popover-content']);
|
|
7575
7941
|
}
|
|
7576
7942
|
/*************
|
|
7577
7943
|
* Lifecycle *
|
|
@@ -7622,10 +7988,9 @@ const MgSkipLinks = class {
|
|
|
7622
7988
|
event.currentTarget.blur();
|
|
7623
7989
|
this.goToAnchor.emit(event.currentTarget.getAttribute('href'));
|
|
7624
7990
|
};
|
|
7625
|
-
this.links = undefined;
|
|
7626
7991
|
}
|
|
7627
7992
|
validateLinks(links) {
|
|
7628
|
-
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))) {
|
|
7629
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.`);
|
|
7630
7995
|
}
|
|
7631
7996
|
}
|
|
@@ -7687,6 +8052,23 @@ const MgTabs = class {
|
|
|
7687
8052
|
this.tabPanel = 'panel';
|
|
7688
8053
|
this.buttonTabBaseClass = 'mg-c-tabs__navigation-button';
|
|
7689
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']);
|
|
7690
8072
|
/**
|
|
7691
8073
|
* Validate that new tab status can be `Status.ACTIVE`
|
|
7692
8074
|
* @param tab - tab item
|
|
@@ -7784,7 +8166,7 @@ const MgTabs = class {
|
|
|
7784
8166
|
*/
|
|
7785
8167
|
this.resetFocus = () => {
|
|
7786
8168
|
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
7787
|
-
index_es.
|
|
8169
|
+
index_es.et(() => {
|
|
7788
8170
|
this.tabFocus = undefined;
|
|
7789
8171
|
Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {
|
|
7790
8172
|
tab.setAttribute('tabindex', this.activeTab - this.startIndex !== index ? '-1' : '0');
|
|
@@ -7799,39 +8181,32 @@ const MgTabs = class {
|
|
|
7799
8181
|
if (slots.length !== this.tabs.length)
|
|
7800
8182
|
throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
|
|
7801
8183
|
};
|
|
7802
|
-
this.identifier = index_es.qe('mg-tabs');
|
|
7803
|
-
this.label = undefined;
|
|
7804
|
-
this.size = 'medium';
|
|
7805
|
-
this.items = undefined;
|
|
7806
|
-
this.activeTab = undefined;
|
|
7807
|
-
this.tabs = [];
|
|
7808
|
-
this.classCollection = new index_es.Xe(['mg-c-tabs']);
|
|
7809
8184
|
}
|
|
7810
8185
|
watchIdentifier(newValue) {
|
|
7811
|
-
if (!index_es.
|
|
7812
|
-
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)}.`);
|
|
7813
8188
|
}
|
|
7814
8189
|
}
|
|
7815
8190
|
validateLabel(newValue) {
|
|
7816
|
-
if (!index_es.
|
|
7817
|
-
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)}.`);
|
|
7818
8193
|
}
|
|
7819
8194
|
}
|
|
7820
8195
|
validateSize(newValue) {
|
|
7821
8196
|
if (!sizes.includes(newValue)) {
|
|
7822
|
-
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)}.`);
|
|
7823
8198
|
}
|
|
7824
8199
|
this.classCollection.add(`mg-c-tabs--size-${this.size}`);
|
|
7825
8200
|
}
|
|
7826
8201
|
validateItems(newValue) {
|
|
7827
8202
|
// String array
|
|
7828
|
-
if (index_es.
|
|
8203
|
+
if (index_es.Xe(newValue))
|
|
7829
8204
|
this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
|
|
7830
8205
|
// Object array
|
|
7831
8206
|
else if (Array.isArray(newValue) && newValue.length > 0 && newValue.every(isTabItem))
|
|
7832
8207
|
this.tabs = newValue;
|
|
7833
8208
|
else
|
|
7834
|
-
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)}.`);
|
|
7835
8210
|
}
|
|
7836
8211
|
validateActiveTab(newValue) {
|
|
7837
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
|
|
@@ -7856,7 +8231,7 @@ const MgTabs = class {
|
|
|
7856
8231
|
this.activeTabChange.emit(newValue);
|
|
7857
8232
|
}
|
|
7858
8233
|
else {
|
|
7859
|
-
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)}.`);
|
|
7860
8235
|
}
|
|
7861
8236
|
}
|
|
7862
8237
|
/*************
|
|
@@ -7927,14 +8302,18 @@ const MgTag = class {
|
|
|
7927
8302
|
// Classes
|
|
7928
8303
|
this.classOutline = 'mg-c-tag--outline';
|
|
7929
8304
|
this.classSoft = 'mg-c-tag--soft';
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
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']);
|
|
7934
8313
|
}
|
|
7935
8314
|
validateVariant(newValue, oldValue) {
|
|
7936
8315
|
if (!variants.includes(newValue)) {
|
|
7937
|
-
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)}.`);
|
|
7938
8317
|
}
|
|
7939
8318
|
else {
|
|
7940
8319
|
if (oldValue !== undefined) {
|
|
@@ -7967,7 +8346,7 @@ const MgTag = class {
|
|
|
7967
8346
|
* @param textContent - html element textContent property
|
|
7968
8347
|
*/
|
|
7969
8348
|
validateTextContent(textContent) {
|
|
7970
|
-
if (!index_es.
|
|
8349
|
+
if (!index_es.ye(textContent))
|
|
7971
8350
|
throw new Error('<mg-tag> slot must contain a text content.');
|
|
7972
8351
|
}
|
|
7973
8352
|
/*************
|
|
@@ -7987,7 +8366,7 @@ const MgTag = class {
|
|
|
7987
8366
|
* @returns HTML Element
|
|
7988
8367
|
*/
|
|
7989
8368
|
render() {
|
|
7990
|
-
return (index.h("span", { key: '
|
|
8369
|
+
return (index.h("span", { key: 'b3269e3baec3a281bdbe65f8b62636b7ea2fa84c', class: this.classCollection.join() }, index.h("slot", { key: 'bcca2d8653dbcd6a96d322055a4e2773d85ca87d' })));
|
|
7991
8370
|
}
|
|
7992
8371
|
get element() { return index.getElement(this); }
|
|
7993
8372
|
static get watchers() { return {
|
|
@@ -8017,6 +8396,23 @@ const isButton = (element) => typeof element === 'object' && ['MG-BUTTON', 'BUTT
|
|
|
8017
8396
|
const MgTooltip = class {
|
|
8018
8397
|
constructor(hostRef) {
|
|
8019
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;
|
|
8020
8416
|
/**
|
|
8021
8417
|
* Show tooltip
|
|
8022
8418
|
*/
|
|
@@ -8026,7 +8422,7 @@ const MgTooltip = class {
|
|
|
8026
8422
|
// Enable the event listeners
|
|
8027
8423
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
8028
8424
|
// hide when click outside on nextTick to prevent event to trigger after creation
|
|
8029
|
-
index_es.
|
|
8425
|
+
index_es.et(() => {
|
|
8030
8426
|
this.windows.forEach((localWindow) => {
|
|
8031
8427
|
localWindow.addEventListener('click', this.handleClickOutside, false);
|
|
8032
8428
|
localWindow.addEventListener('keydown', this.handlePressEscape, false);
|
|
@@ -8222,22 +8618,17 @@ const MgTooltip = class {
|
|
|
8222
8618
|
element.setAttribute('aria-describedby', `${[...new Set([...element.getAttribute('aria-describedby').split(' '), this.identifier])].join(' ')}`);
|
|
8223
8619
|
}
|
|
8224
8620
|
};
|
|
8225
|
-
this.identifier = index_es.qe('mg-tooltip');
|
|
8226
|
-
this.message = undefined;
|
|
8227
|
-
this.placement = 'bottom';
|
|
8228
|
-
this.display = false;
|
|
8229
|
-
this.disabled = false;
|
|
8230
8621
|
}
|
|
8231
8622
|
watchIdentifier(newValue) {
|
|
8232
|
-
if (!index_es.
|
|
8233
|
-
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)}.`);
|
|
8234
8625
|
}
|
|
8235
8626
|
// use renderTooltipContent to update tooltip-content id
|
|
8236
8627
|
this.renderTooltipContent();
|
|
8237
8628
|
}
|
|
8238
8629
|
watchMessage(newValue) {
|
|
8239
|
-
if (!index_es.
|
|
8240
|
-
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)}.`);
|
|
8241
8632
|
}
|
|
8242
8633
|
if (this.mgTooltipContent !== undefined)
|
|
8243
8634
|
this.mgTooltipContent.message = newValue;
|
|
@@ -8356,7 +8747,7 @@ const MgTooltip = class {
|
|
|
8356
8747
|
* @returns HTML Element
|
|
8357
8748
|
*/
|
|
8358
8749
|
render() {
|
|
8359
|
-
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" })));
|
|
8360
8751
|
}
|
|
8361
8752
|
get element() { return index.getElement(this); }
|
|
8362
8753
|
static get watchers() { return {
|
|
@@ -8374,7 +8765,6 @@ const MgTooltipContentStyle0 = mgTooltipContentCss;
|
|
|
8374
8765
|
const MgTooltipContent = class {
|
|
8375
8766
|
constructor(hostRef) {
|
|
8376
8767
|
index.registerInstance(this, hostRef);
|
|
8377
|
-
this.message = undefined;
|
|
8378
8768
|
}
|
|
8379
8769
|
/*************
|
|
8380
8770
|
* Lifecycle *
|
|
@@ -8384,7 +8774,7 @@ const MgTooltipContent = class {
|
|
|
8384
8774
|
* @returns HTML Element
|
|
8385
8775
|
*/
|
|
8386
8776
|
render() {
|
|
8387
|
-
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" })));
|
|
8388
8778
|
}
|
|
8389
8779
|
};
|
|
8390
8780
|
MgTooltipContent.style = MgTooltipContentStyle0;
|