@mgdis/mg-components 5.9.1 → 5.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_31.cjs.entry.js +345 -648
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +19 -43
- package/dist/cjs/{mg-menu.conf-9afe6571.js → mg-menu.conf-196151fe.js} +16 -21
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +9 -12
- package/dist/collection/components/atoms/mg-button/mg-button.js +18 -27
- package/dist/collection/components/atoms/mg-card/mg-card.js +22 -15
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +1 -4
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -2
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +26 -23
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -4
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +11 -16
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +12 -34
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +26 -24
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +10 -20
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +7 -17
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +14 -34
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +6 -13
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -27
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +21 -45
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +17 -43
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +14 -22
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +17 -28
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +11 -29
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +20 -47
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +11 -23
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -6
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -27
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -4
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +4 -12
- package/dist/collection/components/molecules/mg-message/mg-message.js +12 -20
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +8 -17
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +11 -19
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +11 -30
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +8 -21
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +3 -8
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +20 -36
- package/dist/collection/locales/index.js +2 -3
- package/dist/collection/utils/behaviors.utils.js +16 -32
- package/dist/collection/utils/components.utils.js +22 -33
- package/dist/collection/utils/locale.utils.js +14 -18
- package/dist/collection/utils/unit.test.utils.js +7 -15
- package/dist/components/MgInput.js +30 -24
- package/dist/components/components.utils.js +22 -33
- package/dist/components/index2.js +16 -21
- package/dist/components/mg-action-more.js +9 -21
- package/dist/components/mg-badge2.js +9 -12
- package/dist/components/mg-button2.js +18 -27
- package/dist/components/mg-card2.js +20 -13
- package/dist/components/mg-character-left2.js +1 -4
- package/dist/components/mg-details.js +1 -6
- package/dist/components/mg-divider.js +1 -2
- package/dist/components/mg-form.js +7 -23
- package/dist/components/mg-icon2.js +26 -23
- package/dist/components/mg-illustrated-message.js +1 -4
- package/dist/components/mg-input-checkbox.js +9 -16
- package/dist/components/mg-input-date.js +6 -13
- package/dist/components/mg-input-numeric.js +13 -30
- package/dist/components/mg-input-password.js +5 -9
- package/dist/components/mg-input-radio.js +9 -23
- package/dist/components/mg-input-select2.js +20 -41
- package/dist/components/mg-input-text2.js +15 -35
- package/dist/components/mg-input-textarea.js +13 -18
- package/dist/components/mg-input-title2.js +1 -4
- package/dist/components/mg-input-toggle.js +16 -24
- package/dist/components/mg-item-more.js +18 -42
- package/dist/components/mg-menu-item2.js +17 -44
- package/dist/components/mg-menu2.js +9 -27
- package/dist/components/mg-message.js +12 -20
- package/dist/components/mg-modal.js +8 -17
- package/dist/components/mg-pagination.js +11 -19
- package/dist/components/mg-panel.js +11 -30
- package/dist/components/mg-popover2.js +8 -21
- package/dist/components/mg-skip-links.js +3 -8
- package/dist/components/mg-tabs.js +20 -36
- package/dist/components/mg-tag.js +11 -16
- package/dist/components/mg-tooltip2.js +12 -34
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_31.entry.js +345 -648
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +19 -43
- package/dist/esm/{mg-menu.conf-881fbd82.js → mg-menu.conf-9ca023ee.js} +16 -21
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-67ce7cb8.entry.js → p-97aaca3e.entry.js} +1 -1
- package/dist/mg-components/p-d891e707.entry.js +1 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +2 -5
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +5 -14
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +11 -8
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -4
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +1 -2
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +8 -7
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -4
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +3 -8
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -33
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -1
- package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -6
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -11
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -11
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +7 -26
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +3 -7
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -18
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +9 -22
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +3 -23
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -9
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -11
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +10 -29
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +21 -49
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +3 -15
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +1 -6
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -19
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +1 -4
- package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +2 -12
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +4 -12
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -12
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +5 -14
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +4 -23
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +3 -16
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +2 -7
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +15 -30
- package/dist/types/components.d.ts +22 -34
- package/dist/types/locales/index.d.ts +2 -3
- package/dist/types/utils/behaviors.utils.d.ts +14 -29
- package/dist/types/utils/components.utils.d.ts +19 -29
- package/dist/types/utils/locale.utils.d.ts +14 -18
- package/dist/types/utils/unit.test.utils.d.ts +11 -24
- package/package.json +11 -12
- package/dist/mg-components/p-9a93b7af.entry.js +0 -1
- /package/dist/mg-components/{p-367f92d2.js → p-0d3146d9.js} +0 -0
|
@@ -44,8 +44,6 @@ export class MgModal {
|
|
|
44
44
|
*************/
|
|
45
45
|
/**
|
|
46
46
|
* Handle close button
|
|
47
|
-
*
|
|
48
|
-
* @returns {void}
|
|
49
47
|
*/
|
|
50
48
|
this.handleClose = () => {
|
|
51
49
|
this.hide = true;
|
|
@@ -56,7 +54,7 @@ export class MgModal {
|
|
|
56
54
|
this.hide = false;
|
|
57
55
|
this.hasActions = false;
|
|
58
56
|
this.hasContent = false;
|
|
59
|
-
this.
|
|
57
|
+
this.classCollection = new ClassList(['mg-modal']);
|
|
60
58
|
}
|
|
61
59
|
validateModalTitle(newValue) {
|
|
62
60
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -66,20 +64,18 @@ export class MgModal {
|
|
|
66
64
|
validateHide(newValue) {
|
|
67
65
|
if (newValue) {
|
|
68
66
|
this.componentHide.emit();
|
|
69
|
-
this.
|
|
67
|
+
this.classCollection.add(this.classHide);
|
|
70
68
|
document.body.style.overflow = this.bodyOverflow;
|
|
71
69
|
}
|
|
72
70
|
else {
|
|
73
71
|
this.componentShow.emit();
|
|
74
|
-
this.
|
|
72
|
+
this.classCollection.delete(this.classHide);
|
|
75
73
|
document.body.style.overflow = 'hidden';
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
/**
|
|
79
77
|
* Handle 'escape' key down
|
|
80
|
-
*
|
|
81
|
-
* @param {KeyboardEvent} event keydown event
|
|
82
|
-
* @returns {void}
|
|
78
|
+
* @param event - keydown event
|
|
83
79
|
*/
|
|
84
80
|
handleKeyDown(event) {
|
|
85
81
|
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
@@ -92,8 +88,6 @@ export class MgModal {
|
|
|
92
88
|
*************/
|
|
93
89
|
/**
|
|
94
90
|
* Check if component props are well configured on init
|
|
95
|
-
*
|
|
96
|
-
* @returns {void}
|
|
97
91
|
*/
|
|
98
92
|
componentWillLoad() {
|
|
99
93
|
// Store body overflow
|
|
@@ -112,8 +106,6 @@ export class MgModal {
|
|
|
112
106
|
}
|
|
113
107
|
/**
|
|
114
108
|
* Add observer on component to set focus when displayed
|
|
115
|
-
*
|
|
116
|
-
* @returns {void}
|
|
117
109
|
*/
|
|
118
110
|
componentDidLoad() {
|
|
119
111
|
new MutationObserver(mutationList => {
|
|
@@ -128,11 +120,10 @@ export class MgModal {
|
|
|
128
120
|
}
|
|
129
121
|
/**
|
|
130
122
|
* Render
|
|
131
|
-
*
|
|
132
|
-
* @returns {HTMLElement} HTML Element
|
|
123
|
+
* @returns HTML Element
|
|
133
124
|
*/
|
|
134
125
|
render() {
|
|
135
|
-
return (h("div", { role: "alertdialog", id: this.identifier, class: this.
|
|
126
|
+
return (h("div", { role: "alertdialog", id: this.identifier, class: this.classCollection.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, h("mg-card", null, h("div", { class: "mg-modal__dialog" }, h("header", { class: "mg-modal__header" }, this.closeButton && (h("span", { class: "mg-modal__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))), h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (h("article", { class: "mg-modal__content" }, h("slot", { name: "content" }))), this.hasActions && (h("footer", { class: "mg-modal__footer" }, h("slot", { name: "actions" })))))));
|
|
136
127
|
}
|
|
137
128
|
static get is() { return "mg-modal"; }
|
|
138
129
|
static get encapsulation() { return "shadow"; }
|
|
@@ -185,7 +176,7 @@ export class MgModal {
|
|
|
185
176
|
},
|
|
186
177
|
"closeButton": {
|
|
187
178
|
"type": "boolean",
|
|
188
|
-
"mutable":
|
|
179
|
+
"mutable": false,
|
|
189
180
|
"complexType": {
|
|
190
181
|
"original": "boolean",
|
|
191
182
|
"resolved": "boolean",
|
|
@@ -225,7 +216,7 @@ export class MgModal {
|
|
|
225
216
|
return {
|
|
226
217
|
"hasActions": {},
|
|
227
218
|
"hasContent": {},
|
|
228
|
-
"
|
|
219
|
+
"classCollection": {}
|
|
229
220
|
};
|
|
230
221
|
}
|
|
231
222
|
static get events() {
|
|
@@ -5,6 +5,7 @@ import { initLocales } from './../../../locales';
|
|
|
5
5
|
/**
|
|
6
6
|
* Range generator
|
|
7
7
|
*
|
|
8
|
+
* ```
|
|
8
9
|
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
9
10
|
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
10
11
|
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
@@ -12,24 +13,22 @@ import { initLocales } from './../../../locales';
|
|
|
12
13
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
13
14
|
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
14
15
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
16
|
+
* ```
|
|
15
17
|
*
|
|
16
18
|
* range(1, 1) = [1]
|
|
17
19
|
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
18
20
|
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
19
|
-
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
23
|
-
* @returns {number[]} range numbers
|
|
21
|
+
* @param start - start range
|
|
22
|
+
* @param end - start end
|
|
23
|
+
* @param step - step size
|
|
24
|
+
* @returns range numbers
|
|
24
25
|
*/
|
|
25
26
|
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
26
27
|
export class MgPagination {
|
|
27
28
|
constructor() {
|
|
28
29
|
/**
|
|
29
30
|
* Change current page from target
|
|
30
|
-
*
|
|
31
|
-
* @param {number} target target page
|
|
32
|
-
* @returns {void}
|
|
31
|
+
* @param target - target page
|
|
33
32
|
*/
|
|
34
33
|
this.goToPage = (target) => {
|
|
35
34
|
this.currentPage = target;
|
|
@@ -39,9 +38,7 @@ export class MgPagination {
|
|
|
39
38
|
************/
|
|
40
39
|
/**
|
|
41
40
|
* select handler
|
|
42
|
-
*
|
|
43
|
-
* @param {InputEvent} event value change event
|
|
44
|
-
* @returns {void}
|
|
41
|
+
* @param event - value change event
|
|
45
42
|
*/
|
|
46
43
|
this.handleSelect = (event) => {
|
|
47
44
|
const to = Number(event.target.value);
|
|
@@ -49,10 +46,8 @@ export class MgPagination {
|
|
|
49
46
|
};
|
|
50
47
|
/**
|
|
51
48
|
* Go to 'previous/next' page button handler
|
|
52
|
-
*
|
|
53
|
-
* @param
|
|
54
|
-
* @param {boolean} disabled button disable state
|
|
55
|
-
* @returns {void}
|
|
49
|
+
* @param action - navigation action
|
|
50
|
+
* @param disabled - button disable state
|
|
56
51
|
*/
|
|
57
52
|
this.handleGoToPage = (action, disabled) => {
|
|
58
53
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
@@ -82,8 +77,6 @@ export class MgPagination {
|
|
|
82
77
|
*************/
|
|
83
78
|
/**
|
|
84
79
|
* Check if props are well configured on init
|
|
85
|
-
*
|
|
86
|
-
* @returns {void}
|
|
87
80
|
*/
|
|
88
81
|
componentWillLoad() {
|
|
89
82
|
// Get locales
|
|
@@ -98,8 +91,7 @@ export class MgPagination {
|
|
|
98
91
|
}
|
|
99
92
|
/**
|
|
100
93
|
* Render
|
|
101
|
-
*
|
|
102
|
-
* @returns {HTMLElement} HTML Element
|
|
94
|
+
* @returns HTML Element
|
|
103
95
|
*/
|
|
104
96
|
render() {
|
|
105
97
|
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
|
|
@@ -8,8 +8,6 @@ export class MgPanel {
|
|
|
8
8
|
************/
|
|
9
9
|
/**
|
|
10
10
|
* Toggle is editing state
|
|
11
|
-
*
|
|
12
|
-
* @returns {void}
|
|
13
11
|
*/
|
|
14
12
|
this.toggleIsEditing = () => {
|
|
15
13
|
this.isEditing = !this.isEditing;
|
|
@@ -19,8 +17,6 @@ export class MgPanel {
|
|
|
19
17
|
************/
|
|
20
18
|
/**
|
|
21
19
|
* Collapse button click handler
|
|
22
|
-
*
|
|
23
|
-
* @returns {void}
|
|
24
20
|
*/
|
|
25
21
|
this.handleCollapseButton = () => {
|
|
26
22
|
if (!this.expandToggleDisabled) {
|
|
@@ -29,25 +25,19 @@ export class MgPanel {
|
|
|
29
25
|
};
|
|
30
26
|
/**
|
|
31
27
|
* Edit button click handler
|
|
32
|
-
*
|
|
33
|
-
* @returns {void}
|
|
34
28
|
*/
|
|
35
29
|
this.handleEditButton = () => {
|
|
36
30
|
this.toggleIsEditing();
|
|
37
31
|
};
|
|
38
32
|
/**
|
|
39
33
|
* Update title handler
|
|
40
|
-
*
|
|
41
|
-
* @param {CustomEvent<string>} event input value change event
|
|
42
|
-
* @returns {void}
|
|
34
|
+
* @param event - input value change event
|
|
43
35
|
*/
|
|
44
36
|
this.handleUpdateTitle = (event) => {
|
|
45
37
|
this.updatedPanelTitle = event.detail;
|
|
46
38
|
};
|
|
47
39
|
/**
|
|
48
40
|
* Cancel edition button handler
|
|
49
|
-
*
|
|
50
|
-
* @returns {void}
|
|
51
41
|
*/
|
|
52
42
|
this.handleCancelEditButton = () => {
|
|
53
43
|
this.updatedPanelTitle = undefined;
|
|
@@ -55,8 +45,6 @@ export class MgPanel {
|
|
|
55
45
|
};
|
|
56
46
|
/**
|
|
57
47
|
* Validate edition button handler
|
|
58
|
-
*
|
|
59
|
-
* @returns {void}
|
|
60
48
|
*/
|
|
61
49
|
this.handleValidateEditButton = () => {
|
|
62
50
|
if (this.editInputElement.valid) {
|
|
@@ -67,9 +55,7 @@ export class MgPanel {
|
|
|
67
55
|
};
|
|
68
56
|
/**
|
|
69
57
|
* Header left conditional render
|
|
70
|
-
*
|
|
71
|
-
* @typedef {HTMLElement} HTMLMgButtonElement
|
|
72
|
-
* @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
|
|
58
|
+
* @returns header left element
|
|
73
59
|
*/
|
|
74
60
|
this.headerLeft = () => {
|
|
75
61
|
const collapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", identifier: `${this.identifier}-collapse-button`, "aria-expanded": this.expanded !== undefined && this.expanded.toString(), "aria-controls": `${this.identifier}-content`, disabled: this.expandToggleDisabled }, h("span", { class: "mg-panel__collapse-button-content" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle)));
|
|
@@ -94,7 +80,7 @@ export class MgPanel {
|
|
|
94
80
|
this.expanded = false;
|
|
95
81
|
this.expandToggleDisabled = undefined;
|
|
96
82
|
this.titleEditable = false;
|
|
97
|
-
this.
|
|
83
|
+
this.classCollection = new ClassList(['mg-panel']);
|
|
98
84
|
this.isEditing = false;
|
|
99
85
|
this.updatedPanelTitle = undefined;
|
|
100
86
|
}
|
|
@@ -105,10 +91,10 @@ export class MgPanel {
|
|
|
105
91
|
this.titleChange.emit(newValue);
|
|
106
92
|
}
|
|
107
93
|
validatetitlePattern(newValue) {
|
|
108
|
-
if (newValue && !this.titleEditable) {
|
|
94
|
+
if (newValue !== undefined && !this.titleEditable) {
|
|
109
95
|
throw new Error('<mg-panel> prop "titleEditable" must be set to `true`.');
|
|
110
96
|
}
|
|
111
|
-
if (newValue && (this.titlePatternErrorMessage === undefined || this.titlePatternErrorMessage.trim() === '')) {
|
|
97
|
+
if (newValue !== undefined && (this.titlePatternErrorMessage === undefined || this.titlePatternErrorMessage.trim() === '')) {
|
|
112
98
|
throw new Error('<mg-panel> prop "titlePattern" must be paired with the prop "titlePatternErrorMessage".');
|
|
113
99
|
}
|
|
114
100
|
}
|
|
@@ -120,8 +106,6 @@ export class MgPanel {
|
|
|
120
106
|
*************/
|
|
121
107
|
/**
|
|
122
108
|
* Check if props are well configured on init
|
|
123
|
-
*
|
|
124
|
-
* @returns {void}
|
|
125
109
|
*/
|
|
126
110
|
componentWillLoad() {
|
|
127
111
|
// Get locales
|
|
@@ -132,8 +116,6 @@ export class MgPanel {
|
|
|
132
116
|
}
|
|
133
117
|
/**
|
|
134
118
|
* Edit DOM after render
|
|
135
|
-
*
|
|
136
|
-
* @returns {void}
|
|
137
119
|
*/
|
|
138
120
|
componentDidRender() {
|
|
139
121
|
// when we are editing we get focus on edition input
|
|
@@ -143,11 +125,10 @@ export class MgPanel {
|
|
|
143
125
|
}
|
|
144
126
|
/**
|
|
145
127
|
* Render component
|
|
146
|
-
*
|
|
147
|
-
* @returns {HTMLElement} html element
|
|
128
|
+
* @returns html element
|
|
148
129
|
*/
|
|
149
130
|
render() {
|
|
150
|
-
return (h("section", { class: this.
|
|
131
|
+
return (h("section", { class: this.classCollection.join(), id: this.identifier }, h("mg-card", null, h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), h("div", { class: "mg-panel__header-right" }, h("slot", { name: "header-right" }))), h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, h("slot", null)))));
|
|
151
132
|
}
|
|
152
133
|
static get is() { return "mg-panel"; }
|
|
153
134
|
static get encapsulation() { return "shadow"; }
|
|
@@ -200,7 +181,7 @@ export class MgPanel {
|
|
|
200
181
|
},
|
|
201
182
|
"titlePattern": {
|
|
202
183
|
"type": "string",
|
|
203
|
-
"mutable":
|
|
184
|
+
"mutable": false,
|
|
204
185
|
"complexType": {
|
|
205
186
|
"original": "string",
|
|
206
187
|
"resolved": "string",
|
|
@@ -217,7 +198,7 @@ export class MgPanel {
|
|
|
217
198
|
},
|
|
218
199
|
"titlePatternErrorMessage": {
|
|
219
200
|
"type": "string",
|
|
220
|
-
"mutable":
|
|
201
|
+
"mutable": false,
|
|
221
202
|
"complexType": {
|
|
222
203
|
"original": "string",
|
|
223
204
|
"resolved": "string",
|
|
@@ -252,7 +233,7 @@ export class MgPanel {
|
|
|
252
233
|
},
|
|
253
234
|
"expandToggleDisabled": {
|
|
254
235
|
"type": "boolean",
|
|
255
|
-
"mutable":
|
|
236
|
+
"mutable": false,
|
|
256
237
|
"complexType": {
|
|
257
238
|
"original": "boolean",
|
|
258
239
|
"resolved": "boolean",
|
|
@@ -289,7 +270,7 @@ export class MgPanel {
|
|
|
289
270
|
}
|
|
290
271
|
static get states() {
|
|
291
272
|
return {
|
|
292
|
-
"
|
|
273
|
+
"classCollection": {},
|
|
293
274
|
"isEditing": {},
|
|
294
275
|
"updatedPanelTitle": {}
|
|
295
276
|
};
|
|
@@ -9,9 +9,7 @@ export class MgPopover {
|
|
|
9
9
|
this.classArrowHide = `mg-popover--arrow-hide`;
|
|
10
10
|
/**
|
|
11
11
|
* Check if clicked outside of component
|
|
12
|
-
*
|
|
13
|
-
* @param {MouseEvent} event mouse event
|
|
14
|
-
* @returns {void}
|
|
12
|
+
* @param event - mouse event
|
|
15
13
|
*/
|
|
16
14
|
this.clickOutside = (event) => {
|
|
17
15
|
var _a;
|
|
@@ -23,8 +21,6 @@ export class MgPopover {
|
|
|
23
21
|
};
|
|
24
22
|
/**
|
|
25
23
|
* Show popover
|
|
26
|
-
*
|
|
27
|
-
* @returns {void}
|
|
28
24
|
*/
|
|
29
25
|
this.show = () => {
|
|
30
26
|
// Make the popover visible
|
|
@@ -43,8 +39,6 @@ export class MgPopover {
|
|
|
43
39
|
};
|
|
44
40
|
/**
|
|
45
41
|
* Hide popover
|
|
46
|
-
*
|
|
47
|
-
* @returns {void}
|
|
48
42
|
*/
|
|
49
43
|
this.hide = () => {
|
|
50
44
|
// Hide the popover
|
|
@@ -58,8 +52,6 @@ export class MgPopover {
|
|
|
58
52
|
};
|
|
59
53
|
/**
|
|
60
54
|
* Handle action for close button
|
|
61
|
-
*
|
|
62
|
-
* @returns {void}
|
|
63
55
|
*/
|
|
64
56
|
this.handleCloseButton = () => {
|
|
65
57
|
this.display = false;
|
|
@@ -70,13 +62,13 @@ export class MgPopover {
|
|
|
70
62
|
this.closeButton = false;
|
|
71
63
|
this.display = false;
|
|
72
64
|
this.disabled = false;
|
|
73
|
-
this.
|
|
65
|
+
this.classCollection = new ClassList(['mg-popover']);
|
|
74
66
|
}
|
|
75
67
|
validateArrowHide(newValue) {
|
|
76
68
|
if (newValue)
|
|
77
|
-
this.
|
|
69
|
+
this.classCollection.add(this.classArrowHide);
|
|
78
70
|
else
|
|
79
|
-
this.
|
|
71
|
+
this.classCollection.delete(this.classArrowHide);
|
|
80
72
|
}
|
|
81
73
|
handleDisplay(newValue) {
|
|
82
74
|
if (newValue) {
|
|
@@ -92,8 +84,6 @@ export class MgPopover {
|
|
|
92
84
|
*************/
|
|
93
85
|
/**
|
|
94
86
|
* Check if component props are well configured on init
|
|
95
|
-
*
|
|
96
|
-
* @returns {void} timeout
|
|
97
87
|
*/
|
|
98
88
|
componentWillLoad() {
|
|
99
89
|
// Get windows to attach events
|
|
@@ -104,8 +94,6 @@ export class MgPopover {
|
|
|
104
94
|
}
|
|
105
95
|
/**
|
|
106
96
|
* Check if component props are well configured on init
|
|
107
|
-
*
|
|
108
|
-
* @returns {void}
|
|
109
97
|
*/
|
|
110
98
|
componentDidLoad() {
|
|
111
99
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -162,11 +150,10 @@ export class MgPopover {
|
|
|
162
150
|
}
|
|
163
151
|
/**
|
|
164
152
|
* Render
|
|
165
|
-
*
|
|
166
|
-
* @returns {HTMLElement} HTML Element
|
|
153
|
+
* @returns HTML Element
|
|
167
154
|
*/
|
|
168
155
|
render() {
|
|
169
|
-
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: this.
|
|
156
|
+
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: this.classCollection.join() }, h("mg-card", null, this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, h("mg-icon", { icon: "cross" }))), h("div", { class: "mg-popover__title" }, h("slot", { name: "title" })), h("slot", { name: "content" })), !this.arrowHide && h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
170
157
|
}
|
|
171
158
|
static get is() { return "mg-popover"; }
|
|
172
159
|
static get encapsulation() { return "shadow"; }
|
|
@@ -279,7 +266,7 @@ export class MgPopover {
|
|
|
279
266
|
},
|
|
280
267
|
"disabled": {
|
|
281
268
|
"type": "boolean",
|
|
282
|
-
"mutable":
|
|
269
|
+
"mutable": false,
|
|
283
270
|
"complexType": {
|
|
284
271
|
"original": "boolean",
|
|
285
272
|
"resolved": "boolean",
|
|
@@ -299,7 +286,7 @@ export class MgPopover {
|
|
|
299
286
|
}
|
|
300
287
|
static get states() {
|
|
301
288
|
return {
|
|
302
|
-
"
|
|
289
|
+
"classCollection": {}
|
|
303
290
|
};
|
|
304
291
|
}
|
|
305
292
|
static get events() {
|
|
@@ -8,9 +8,7 @@ export class MgSkipLinks {
|
|
|
8
8
|
**********/
|
|
9
9
|
/**
|
|
10
10
|
* Handle link click and emit go-to-anchor event
|
|
11
|
-
*
|
|
12
|
-
* @param {MouseEvent} event mouse event
|
|
13
|
-
* @returns {void}
|
|
11
|
+
* @param event - mouse event
|
|
14
12
|
*/
|
|
15
13
|
this.handleLinkCLick = (event) => {
|
|
16
14
|
event.currentTarget.blur();
|
|
@@ -30,8 +28,6 @@ export class MgSkipLinks {
|
|
|
30
28
|
*************/
|
|
31
29
|
/**
|
|
32
30
|
* Check if props are well configured on init
|
|
33
|
-
*
|
|
34
|
-
* @returns {void}
|
|
35
31
|
*/
|
|
36
32
|
componentWillLoad() {
|
|
37
33
|
this.validateLinks(this.links);
|
|
@@ -39,8 +35,7 @@ export class MgSkipLinks {
|
|
|
39
35
|
}
|
|
40
36
|
/**
|
|
41
37
|
* Render
|
|
42
|
-
*
|
|
43
|
-
* @returns {HTMLElement} HTML Element
|
|
38
|
+
* @returns HTML Element
|
|
44
39
|
*/
|
|
45
40
|
render() {
|
|
46
41
|
return (h("nav", { class: "mg-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, h("ul", { class: "mg-skip-links__list", role: "list" }, this.links.map(link => (h("li", { key: link.href }, h("a", { class: "mg-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
|
|
@@ -61,7 +56,7 @@ export class MgSkipLinks {
|
|
|
61
56
|
return {
|
|
62
57
|
"links": {
|
|
63
58
|
"type": "unknown",
|
|
64
|
-
"mutable":
|
|
59
|
+
"mutable": false,
|
|
65
60
|
"complexType": {
|
|
66
61
|
"original": "SkipLink[]",
|
|
67
62
|
"resolved": "SkipLink[]",
|
|
@@ -3,9 +3,8 @@ import { createID, ClassList, allItemsAreString } from '../../../utils/component
|
|
|
3
3
|
import { sizes, Status } from './mg-tabs.conf';
|
|
4
4
|
/**
|
|
5
5
|
* type TabItem validation function
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
* @returns {boolean} tab item type is valid
|
|
6
|
+
* @param tab - tab item
|
|
7
|
+
* @returns tab item type is valid
|
|
9
8
|
*/
|
|
10
9
|
const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
|
|
11
10
|
export class MgTabs {
|
|
@@ -19,37 +18,32 @@ export class MgTabs {
|
|
|
19
18
|
this.startIndex = 1;
|
|
20
19
|
/**
|
|
21
20
|
* Method to know if given tab has the given status
|
|
22
|
-
*
|
|
23
|
-
* @param
|
|
24
|
-
* @
|
|
25
|
-
* @returns {boolean} status comparaison
|
|
21
|
+
* @param tab - item tab key to set to ACTIVE status
|
|
22
|
+
* @param status - status to valide
|
|
23
|
+
* @returns status comparaison
|
|
26
24
|
*/
|
|
27
25
|
this.tabHasStatus = (tab, status) => tab.status === status;
|
|
28
26
|
/**
|
|
29
27
|
* Method to get element id from index
|
|
30
|
-
*
|
|
31
|
-
* @param
|
|
32
|
-
* @
|
|
33
|
-
* @returns {string} generated element id
|
|
28
|
+
* @param element - to get id
|
|
29
|
+
* @param index - to generate id
|
|
30
|
+
* @returns generated element id
|
|
34
31
|
*/
|
|
35
32
|
this.getElementId = (element, index) => `${element}-${this.getTabItemIndex(index)}`;
|
|
36
33
|
/**
|
|
37
34
|
* Method to get tab item index
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
* @returns {number} index
|
|
35
|
+
* @param index - to get
|
|
36
|
+
* @returns index
|
|
41
37
|
*/
|
|
42
38
|
this.getTabItemIndex = (index) => index + this.startIndex;
|
|
43
39
|
/**
|
|
44
40
|
* Method to get the active-tab value
|
|
45
|
-
*
|
|
46
|
-
* @returns {number} of the active-tab
|
|
41
|
+
* @returns of the active-tab
|
|
47
42
|
*/
|
|
48
43
|
this.getActiveTab = () => this.activeTab || this.getTabItemIndex(this.tabs.map((tab, index) => (Object.assign(Object.assign({}, tab), { index }))).find(tab => this.tabHasStatus(tab, Status.ACTIVE)).index);
|
|
49
44
|
/**
|
|
50
45
|
* Handle click events on tabs
|
|
51
|
-
*
|
|
52
|
-
* @param {MouseEvent} event mouse event
|
|
46
|
+
* @param event - mouse event
|
|
53
47
|
*/
|
|
54
48
|
this.handleClick = (event) => {
|
|
55
49
|
const tabId = event.currentTarget.dataset.index;
|
|
@@ -64,16 +58,13 @@ export class MgTabs {
|
|
|
64
58
|
};
|
|
65
59
|
/**
|
|
66
60
|
* get navigation button class from given status
|
|
67
|
-
*
|
|
68
|
-
* @
|
|
69
|
-
* @returns {string} button class/selector variant
|
|
61
|
+
* @param status - button tab status
|
|
62
|
+
* @returns button class/selector variant
|
|
70
63
|
*/
|
|
71
64
|
this.getNavigationButtonClass = (status) => `${this.buttonTabBaseClass}--${status}`;
|
|
72
65
|
/**
|
|
73
66
|
* Handle keyboard event on tabs
|
|
74
|
-
*
|
|
75
|
-
* @param {MouseEvent} event mouse event
|
|
76
|
-
* @returns {void}
|
|
67
|
+
* @param event - mouse event
|
|
77
68
|
*/
|
|
78
69
|
this.handleKeydown = (event) => {
|
|
79
70
|
const parent = event.target.parentElement;
|
|
@@ -111,8 +102,6 @@ export class MgTabs {
|
|
|
111
102
|
};
|
|
112
103
|
/**
|
|
113
104
|
* Method to reset focus behavior
|
|
114
|
-
*
|
|
115
|
-
* @returns {void}
|
|
116
105
|
*/
|
|
117
106
|
this.resetFocus = () => {
|
|
118
107
|
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
@@ -137,7 +126,7 @@ export class MgTabs {
|
|
|
137
126
|
this.items = undefined;
|
|
138
127
|
this.activeTab = undefined;
|
|
139
128
|
this.tabs = [];
|
|
140
|
-
this.
|
|
129
|
+
this.classCollection = new ClassList(['mg-tabs']);
|
|
141
130
|
}
|
|
142
131
|
validateLabel(newValue) {
|
|
143
132
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -148,7 +137,7 @@ export class MgTabs {
|
|
|
148
137
|
if (!sizes.includes(newValue)) {
|
|
149
138
|
throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
150
139
|
}
|
|
151
|
-
this.
|
|
140
|
+
this.classCollection.add(`mg-tabs--size-${this.size}`);
|
|
152
141
|
}
|
|
153
142
|
validateItems(newValue) {
|
|
154
143
|
// String array
|
|
@@ -191,8 +180,6 @@ export class MgTabs {
|
|
|
191
180
|
*************/
|
|
192
181
|
/**
|
|
193
182
|
* Check if component props are well configured on init
|
|
194
|
-
*
|
|
195
|
-
* @returns {void}
|
|
196
183
|
*/
|
|
197
184
|
componentWillLoad() {
|
|
198
185
|
// Check tabs format
|
|
@@ -204,8 +191,6 @@ export class MgTabs {
|
|
|
204
191
|
}
|
|
205
192
|
/**
|
|
206
193
|
* add listners
|
|
207
|
-
*
|
|
208
|
-
* @returns {void}
|
|
209
194
|
*/
|
|
210
195
|
componentDidLoad() {
|
|
211
196
|
document.addEventListener('click', (event) => {
|
|
@@ -215,11 +200,10 @@ export class MgTabs {
|
|
|
215
200
|
}
|
|
216
201
|
/**
|
|
217
202
|
* Render
|
|
218
|
-
*
|
|
219
|
-
* @returns {HTMLElement} HTML Element
|
|
203
|
+
* @returns HTML Element
|
|
220
204
|
*/
|
|
221
205
|
render() {
|
|
222
|
-
return (h("div", { class: this.
|
|
206
|
+
return (h("div", { class: this.classCollection.join() }, h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => (h("button", { key: tab.label, role: "tab", id: this.getElementId(this.identifier, index), class: {
|
|
223
207
|
[`${this.buttonTabBaseClass}`]: true,
|
|
224
208
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
225
209
|
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|
|
@@ -341,7 +325,7 @@ export class MgTabs {
|
|
|
341
325
|
static get states() {
|
|
342
326
|
return {
|
|
343
327
|
"tabs": {},
|
|
344
|
-
"
|
|
328
|
+
"classCollection": {}
|
|
345
329
|
};
|
|
346
330
|
}
|
|
347
331
|
static get events() {
|
|
@@ -5,8 +5,7 @@ const defaultLocale = 'en';
|
|
|
5
5
|
const messages = { en, fr };
|
|
6
6
|
/**
|
|
7
7
|
* Get Intl object
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @returns {{ locale: string; messages: Record<string, unknown> }} messages object
|
|
8
|
+
* @param element - element we need to get the language
|
|
9
|
+
* @returns messages object
|
|
11
10
|
*/
|
|
12
11
|
export const initLocales = (element) => getLocaleMessages(element, messages, defaultLocale);
|