@mgdis/mg-components 5.10.0 → 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 +318 -427
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +19 -28
- package/dist/cjs/{mg-menu.conf-1942ac70.js → mg-menu.conf-196151fe.js} +16 -16
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +8 -9
- package/dist/collection/components/atoms/mg-button/mg-button.js +16 -20
- package/dist/collection/components/atoms/mg-card/mg-card.js +10 -12
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +1 -2
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +17 -19
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -2
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +11 -13
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +11 -21
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +26 -18
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +10 -14
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +7 -12
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +14 -22
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +6 -10
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -18
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +21 -32
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +16 -31
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +13 -17
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +17 -23
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +11 -18
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +20 -29
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +11 -15
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -3
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -19
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -2
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +4 -7
- package/dist/collection/components/molecules/mg-message/mg-message.js +11 -14
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +7 -11
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +11 -13
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +6 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +7 -13
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +2 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +20 -24
- package/dist/collection/locales/index.js +2 -2
- package/dist/collection/utils/behaviors.utils.js +16 -22
- package/dist/collection/utils/components.utils.js +21 -23
- package/dist/collection/utils/locale.utils.js +14 -14
- package/dist/collection/utils/unit.test.utils.js +7 -10
- package/dist/components/MgInput.js +30 -18
- package/dist/components/components.utils.js +21 -23
- package/dist/components/index2.js +16 -16
- package/dist/components/mg-action-more.js +9 -13
- package/dist/components/mg-badge2.js +8 -9
- package/dist/components/mg-button2.js +16 -20
- package/dist/components/mg-card2.js +8 -10
- package/dist/components/mg-character-left2.js +1 -2
- package/dist/components/mg-details.js +1 -3
- package/dist/components/mg-divider.js +1 -1
- package/dist/components/mg-form.js +7 -15
- package/dist/components/mg-icon2.js +17 -19
- package/dist/components/mg-illustrated-message.js +1 -2
- package/dist/components/mg-input-checkbox.js +9 -10
- package/dist/components/mg-input-date.js +6 -8
- package/dist/components/mg-input-numeric.js +13 -18
- package/dist/components/mg-input-password.js +5 -6
- package/dist/components/mg-input-radio.js +9 -14
- package/dist/components/mg-input-select2.js +20 -28
- package/dist/components/mg-input-text2.js +14 -23
- package/dist/components/mg-input-textarea.js +12 -13
- package/dist/components/mg-input-title2.js +1 -2
- package/dist/components/mg-input-toggle.js +16 -19
- package/dist/components/mg-item-more.js +18 -27
- package/dist/components/mg-menu-item2.js +17 -26
- package/dist/components/mg-menu2.js +9 -16
- package/dist/components/mg-message.js +11 -14
- package/dist/components/mg-modal.js +7 -11
- package/dist/components/mg-pagination.js +11 -13
- package/dist/components/mg-panel.js +6 -15
- package/dist/components/mg-popover2.js +7 -13
- package/dist/components/mg-skip-links.js +2 -4
- package/dist/components/mg-tabs.js +20 -24
- package/dist/components/mg-tag.js +11 -13
- package/dist/components/mg-tooltip2.js +11 -21
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_31.entry.js +318 -427
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +19 -28
- package/dist/esm/{mg-menu.conf-2cc1bb67.js → mg-menu.conf-9ca023ee.js} +16 -16
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-a56a3157.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 -3
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +5 -9
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +2 -6
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -2
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +3 -5
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -2
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +3 -5
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -21
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -1
- package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -5
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -6
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -6
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +7 -14
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +3 -4
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -10
- 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 -13
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +3 -12
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -5
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -6
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +10 -18
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +21 -31
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +3 -10
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +1 -3
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -11
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +1 -2
- package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +2 -7
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +4 -7
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -7
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +5 -9
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +4 -13
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +3 -9
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +2 -4
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +15 -19
- package/dist/types/components.d.ts +22 -34
- package/dist/types/locales/index.d.ts +2 -2
- package/dist/types/utils/behaviors.utils.d.ts +14 -20
- package/dist/types/utils/components.utils.d.ts +18 -20
- package/dist/types/utils/locale.utils.d.ts +14 -14
- package/dist/types/utils/unit.test.utils.d.ts +11 -17
- package/package.json +1 -1
- package/dist/mg-components/p-eb32bb18.entry.js +0 -1
- /package/dist/mg-components/{p-73156ac9.js → p-0d3146d9.js} +0 -0
|
@@ -150,19 +150,19 @@ const fr = {
|
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* Format number to the locale currency
|
|
153
|
-
* @param
|
|
154
|
-
* @param
|
|
155
|
-
* @param
|
|
156
|
-
* @returns
|
|
153
|
+
* @param number - number to format
|
|
154
|
+
* @param locale - locale to apply
|
|
155
|
+
* @param currency - currency to apply
|
|
156
|
+
* @returns formatted currency
|
|
157
157
|
*/
|
|
158
158
|
const localeCurrency = (number, locale, currency) => {
|
|
159
159
|
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
|
|
160
160
|
};
|
|
161
161
|
/**
|
|
162
162
|
* Format number to locale
|
|
163
|
-
* @param
|
|
164
|
-
* @param
|
|
165
|
-
* @returns
|
|
163
|
+
* @param number - number to format
|
|
164
|
+
* @param locale - locale to apply
|
|
165
|
+
* @returns formatted number
|
|
166
166
|
*/
|
|
167
167
|
const localeNumber = (number, locale) => {
|
|
168
168
|
return new Intl.NumberFormat(locale).format(number);
|
|
@@ -173,9 +173,9 @@ const localeNumber = (number, locale) => {
|
|
|
173
173
|
const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
174
174
|
/**
|
|
175
175
|
* Locale date format
|
|
176
|
-
* @param
|
|
177
|
-
* @param
|
|
178
|
-
* @returns
|
|
176
|
+
* @param date - date to format
|
|
177
|
+
* @param locale - locale to apply
|
|
178
|
+
* @returns formatted date
|
|
179
179
|
*/
|
|
180
180
|
const localeDate = (date, locale) => {
|
|
181
181
|
if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
|
|
@@ -186,10 +186,10 @@ const localeDate = (date, locale) => {
|
|
|
186
186
|
/**
|
|
187
187
|
* Get locale and messages
|
|
188
188
|
* We load the defined locale but for now we only support the first subtag for messages
|
|
189
|
-
* @param
|
|
190
|
-
* @param
|
|
191
|
-
* @param
|
|
192
|
-
* @returns
|
|
189
|
+
* @param element - element we need to get the language
|
|
190
|
+
* @param messages - messages to use
|
|
191
|
+
* @param defaultLocale - default messages locale
|
|
192
|
+
* @returns messages object
|
|
193
193
|
*/
|
|
194
194
|
const getLocaleMessages = (element, messages, defaultLocale) => {
|
|
195
195
|
// Get local
|
|
@@ -209,8 +209,8 @@ const defaultLocale = 'en';
|
|
|
209
209
|
const messages = { en, fr };
|
|
210
210
|
/**
|
|
211
211
|
* Get Intl object
|
|
212
|
-
* @param
|
|
213
|
-
* @returns
|
|
212
|
+
* @param element - element we need to get the language
|
|
213
|
+
* @returns messages object
|
|
214
214
|
*/
|
|
215
215
|
const initLocales = (element) => getLocaleMessages(element, messages, defaultLocale);
|
|
216
216
|
|
|
@@ -14,8 +14,8 @@ const mgActionMoreCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* MgActionMore['items'] type guard
|
|
17
|
-
* @param
|
|
18
|
-
* @returns
|
|
17
|
+
* @param prop - commponent items prop
|
|
18
|
+
* @returns return true if type is valid
|
|
19
19
|
*/
|
|
20
20
|
const isMgActionMoreItems = (prop) => {
|
|
21
21
|
const items = prop;
|
|
@@ -23,8 +23,8 @@ const isMgActionMoreItems = (prop) => {
|
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
25
|
* MgActionMore['button'] type guard
|
|
26
|
-
* @param
|
|
27
|
-
* @returns
|
|
26
|
+
* @param prop - commponent button prop
|
|
27
|
+
* @returns return true if type is valid
|
|
28
28
|
*/
|
|
29
29
|
const isMgActionMoreButton = (prop) => {
|
|
30
30
|
const button = prop;
|
|
@@ -32,8 +32,8 @@ const isMgActionMoreButton = (prop) => {
|
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
* MgActionMore['icon'] type guard
|
|
35
|
-
* @param
|
|
36
|
-
* @returns
|
|
35
|
+
* @param prop - commponent icon prop
|
|
36
|
+
* @returns return true if type is valid
|
|
37
37
|
*/
|
|
38
38
|
const isMgActionMoreIcon = (prop) => {
|
|
39
39
|
const icon = prop;
|
|
@@ -54,23 +54,20 @@ const MgActionMore$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
54
54
|
***********/
|
|
55
55
|
/**
|
|
56
56
|
* Toogle expanded props
|
|
57
|
-
* @returns {void}
|
|
58
57
|
*/
|
|
59
58
|
this.toggleExpanded = () => {
|
|
60
59
|
this.expanded = !this.expanded;
|
|
61
60
|
};
|
|
62
61
|
/**
|
|
63
62
|
* Button click handler
|
|
64
|
-
* @returns {void}
|
|
65
63
|
*/
|
|
66
64
|
this.handleButton = () => {
|
|
67
65
|
this.toggleExpanded();
|
|
68
66
|
};
|
|
69
67
|
/**
|
|
70
68
|
* Item click handler
|
|
71
|
-
* @param
|
|
72
|
-
* @param
|
|
73
|
-
* @returns {void}
|
|
69
|
+
* @param event - click event
|
|
70
|
+
* @param customHandler - item['mouseEventHandler']
|
|
74
71
|
*/
|
|
75
72
|
this.handleItemClick = (event, customHandler) => {
|
|
76
73
|
this.expanded = false;
|
|
@@ -107,7 +104,6 @@ const MgActionMore$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
107
104
|
*************/
|
|
108
105
|
/**
|
|
109
106
|
* Validate props
|
|
110
|
-
* @returns {void}
|
|
111
107
|
*/
|
|
112
108
|
componentWillLoad() {
|
|
113
109
|
this.messages = initLocales(this.element).messages.actionMore;
|
|
@@ -118,7 +114,7 @@ const MgActionMore$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
118
114
|
}
|
|
119
115
|
/**
|
|
120
116
|
* Render
|
|
121
|
-
* @returns
|
|
117
|
+
* @returns HTML Element
|
|
122
118
|
*/
|
|
123
119
|
render() {
|
|
124
120
|
const buttonLabel = this.button.label || this.messages.label;
|
|
@@ -22,7 +22,7 @@ const MgBadge = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
22
22
|
this.label = undefined;
|
|
23
23
|
this.variant = variants[0];
|
|
24
24
|
this.outline = undefined;
|
|
25
|
-
this.
|
|
25
|
+
this.classCollection = new ClassList(['mg-badge']);
|
|
26
26
|
}
|
|
27
27
|
validateValue(newValue) {
|
|
28
28
|
if (`${newValue}`.match(/^(\d+\+*|[?*!a-z])$/i) === null) {
|
|
@@ -40,20 +40,19 @@ const MgBadge = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
42
|
if (oldValue !== undefined) {
|
|
43
|
-
this.
|
|
43
|
+
this.classCollection.delete(`mg-badge--${oldValue}`);
|
|
44
44
|
}
|
|
45
|
-
this.
|
|
45
|
+
this.classCollection.add(`mg-badge--${newValue}`);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
validateOutline(newValue) {
|
|
49
49
|
if (newValue)
|
|
50
|
-
this.
|
|
50
|
+
this.classCollection.add(this.classOutline);
|
|
51
51
|
else
|
|
52
|
-
this.
|
|
52
|
+
this.classCollection.delete(this.classOutline);
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Check if props are well configured on init
|
|
56
|
-
* @returns {void}
|
|
57
56
|
*/
|
|
58
57
|
componentWillLoad() {
|
|
59
58
|
this.validateValue(this.value);
|
|
@@ -63,10 +62,10 @@ const MgBadge = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
65
64
|
* Render
|
|
66
|
-
* @returns
|
|
65
|
+
* @returns HTML Element
|
|
67
66
|
*/
|
|
68
67
|
render() {
|
|
69
|
-
return (h("span", { class: this.
|
|
68
|
+
return (h("span", { class: this.classCollection.join() }, h("span", { class: "mg-badge__value" }, this.value), h("span", { class: "sr-only" }, this.label)));
|
|
70
69
|
}
|
|
71
70
|
static get watchers() { return {
|
|
72
71
|
"value": ["validateValue"],
|
|
@@ -80,7 +79,7 @@ const MgBadge = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
80
79
|
"label": [1],
|
|
81
80
|
"variant": [1],
|
|
82
81
|
"outline": [4],
|
|
83
|
-
"
|
|
82
|
+
"classCollection": [32]
|
|
84
83
|
}]);
|
|
85
84
|
function defineCustomElement() {
|
|
86
85
|
if (typeof customElements === "undefined") {
|
|
@@ -24,8 +24,7 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
24
24
|
this.classFullWidth = 'mg-button--full-width';
|
|
25
25
|
/**
|
|
26
26
|
* Trigger actions onClick event
|
|
27
|
-
* @param
|
|
28
|
-
* @returns {void}
|
|
27
|
+
* @param event - click event
|
|
29
28
|
*/
|
|
30
29
|
this.handleClick = (event) => {
|
|
31
30
|
if (this.disabled)
|
|
@@ -38,8 +37,7 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
38
37
|
};
|
|
39
38
|
/**
|
|
40
39
|
* Handle onKeydown event
|
|
41
|
-
* @param
|
|
42
|
-
* @returns {void}
|
|
40
|
+
* @param event - keyboard event
|
|
43
41
|
*/
|
|
44
42
|
this.handleKeydown = (event) => {
|
|
45
43
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -52,8 +50,7 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
52
50
|
};
|
|
53
51
|
/**
|
|
54
52
|
* Handle onKeyup event
|
|
55
|
-
* @param
|
|
56
|
-
* @returns {void}
|
|
53
|
+
* @param event - keyboard event
|
|
57
54
|
*/
|
|
58
55
|
this.handleKeyup = (event) => {
|
|
59
56
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -71,7 +68,7 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
71
68
|
this.isIcon = false;
|
|
72
69
|
this.disableOnClick = false;
|
|
73
70
|
this.loading = false;
|
|
74
|
-
this.
|
|
71
|
+
this.classCollection = new ClassList(['mg-button']);
|
|
75
72
|
}
|
|
76
73
|
validateVariant(newValue, oldValue) {
|
|
77
74
|
if (!variants.includes(newValue)) {
|
|
@@ -79,9 +76,9 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
79
76
|
}
|
|
80
77
|
else {
|
|
81
78
|
if (oldValue !== undefined) {
|
|
82
|
-
this.
|
|
79
|
+
this.classCollection.delete(`mg-button--${oldValue}`);
|
|
83
80
|
}
|
|
84
|
-
this.
|
|
81
|
+
this.classCollection.add(`mg-button--${newValue}`);
|
|
85
82
|
}
|
|
86
83
|
}
|
|
87
84
|
validateFullWidth(newValue) {
|
|
@@ -89,10 +86,10 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
89
86
|
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
90
87
|
}
|
|
91
88
|
else if (newValue) {
|
|
92
|
-
this.
|
|
89
|
+
this.classCollection.add(this.classFullWidth);
|
|
93
90
|
}
|
|
94
91
|
else {
|
|
95
|
-
this.
|
|
92
|
+
this.classCollection.delete(this.classFullWidth);
|
|
96
93
|
}
|
|
97
94
|
}
|
|
98
95
|
disabledHandler(isDisabled) {
|
|
@@ -105,10 +102,10 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
105
102
|
this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
|
|
106
103
|
// apply style
|
|
107
104
|
if (isDisabled) {
|
|
108
|
-
this.
|
|
105
|
+
this.classCollection.add(this.classDisabled);
|
|
109
106
|
}
|
|
110
107
|
else {
|
|
111
|
-
this.
|
|
108
|
+
this.classCollection.delete(this.classDisabled);
|
|
112
109
|
}
|
|
113
110
|
// emit value update
|
|
114
111
|
this.disabledChange.emit(isDisabled);
|
|
@@ -116,21 +113,20 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
116
113
|
loadingHandler(newValue) {
|
|
117
114
|
// we add loading style if it newvalue is true else we remove it
|
|
118
115
|
if (newValue) {
|
|
119
|
-
this.
|
|
116
|
+
this.classCollection.add(this.classLoading);
|
|
120
117
|
}
|
|
121
118
|
else {
|
|
122
|
-
this.
|
|
119
|
+
this.classCollection.delete(this.classLoading);
|
|
123
120
|
}
|
|
124
121
|
}
|
|
125
122
|
/**
|
|
126
123
|
* Check if props are well configured on init
|
|
127
|
-
* @returns {void}
|
|
128
124
|
*/
|
|
129
125
|
componentWillLoad() {
|
|
130
126
|
this.validateVariant(this.variant);
|
|
131
127
|
this.validateFullWidth(this.fullWidth);
|
|
132
128
|
if (this.isIcon) {
|
|
133
|
-
this.
|
|
129
|
+
this.classCollection.add(`mg-button--icon`);
|
|
134
130
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
135
131
|
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
136
132
|
}
|
|
@@ -141,10 +137,10 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
141
137
|
}
|
|
142
138
|
/**
|
|
143
139
|
* Render component
|
|
144
|
-
* @returns
|
|
140
|
+
* @returns html element
|
|
145
141
|
*/
|
|
146
142
|
render() {
|
|
147
|
-
return (h(Host, { role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, h("div", { class: this.
|
|
143
|
+
return (h(Host, { role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, h("div", { class: this.classCollection.join(), id: this.identifier }, this.loading && h("mg-icon", { icon: "loader", spin: true }), h("div", { class: "mg-button__content" }, h("slot", null)))));
|
|
148
144
|
}
|
|
149
145
|
get element() { return this; }
|
|
150
146
|
static get watchers() { return {
|
|
@@ -165,7 +161,7 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
165
161
|
"isIcon": [4, "is-icon"],
|
|
166
162
|
"disableOnClick": [4, "disable-on-click"],
|
|
167
163
|
"loading": [32],
|
|
168
|
-
"
|
|
164
|
+
"classCollection": [32]
|
|
169
165
|
}]);
|
|
170
166
|
function defineCustomElement() {
|
|
171
167
|
if (typeof customElements === "undefined") {
|
|
@@ -25,7 +25,6 @@ const MgCard = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
25
25
|
/**
|
|
26
26
|
* Methode to set default varianStyle props
|
|
27
27
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
28
|
-
* @returns {void}
|
|
29
28
|
*/
|
|
30
29
|
this.setDefaultVariantStyle = () => {
|
|
31
30
|
if (this.variantStyle === undefined)
|
|
@@ -33,17 +32,17 @@ const MgCard = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
33
32
|
};
|
|
34
33
|
this.variant = undefined;
|
|
35
34
|
this.variantStyle = undefined;
|
|
36
|
-
this.
|
|
35
|
+
this.classCollection = new ClassList([this.baseClass]);
|
|
37
36
|
}
|
|
38
37
|
validateVariant(newValue, oldValue) {
|
|
39
38
|
if (newValue && !variants.includes(newValue))
|
|
40
39
|
throw new Error(`<${this.name}> prop "variant" must match VariantType type.`);
|
|
41
40
|
if (Boolean(newValue)) {
|
|
42
41
|
this.setDefaultVariantStyle();
|
|
43
|
-
this.
|
|
42
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
44
43
|
}
|
|
45
44
|
if (Boolean(oldValue))
|
|
46
|
-
this.
|
|
45
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
47
46
|
}
|
|
48
47
|
validateVariantStyle(newValue, oldValue) {
|
|
49
48
|
if (newValue && !variantStyles.includes(newValue))
|
|
@@ -51,16 +50,15 @@ const MgCard = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
51
50
|
else if (Boolean(newValue) && !variants.includes(this.variant))
|
|
52
51
|
throw new Error(`<${this.name}> prop "variantStyle" must be paired with ${JSON.stringify(variants)} "variant" prop.`);
|
|
53
52
|
if (Boolean(newValue))
|
|
54
|
-
this.
|
|
53
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
55
54
|
if (Boolean(oldValue))
|
|
56
|
-
this.
|
|
55
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
57
56
|
}
|
|
58
57
|
/*************
|
|
59
58
|
* Lifecycle *
|
|
60
59
|
*************/
|
|
61
60
|
/**
|
|
62
61
|
* Check if props are well configured on init
|
|
63
|
-
* @returns {void}
|
|
64
62
|
*/
|
|
65
63
|
componentWillLoad() {
|
|
66
64
|
this.validateVariant(this.variant);
|
|
@@ -68,11 +66,11 @@ const MgCard = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
68
66
|
}
|
|
69
67
|
/**
|
|
70
68
|
* Render
|
|
71
|
-
* @returns
|
|
69
|
+
* @returns HTML Element
|
|
72
70
|
*/
|
|
73
71
|
render() {
|
|
74
72
|
var _a;
|
|
75
|
-
return (h("div", { class: this.
|
|
73
|
+
return (h("div", { class: this.classCollection.join() }, ((_a = this.variantStyle) === null || _a === void 0 ? void 0 : _a.startsWith('bar-')) && h("span", { class: "mg-card__bar" }), h("slot", null)));
|
|
76
74
|
}
|
|
77
75
|
static get watchers() { return {
|
|
78
76
|
"variant": ["validateVariant"],
|
|
@@ -82,7 +80,7 @@ const MgCard = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
82
80
|
}, [1, "mg-card", {
|
|
83
81
|
"variant": [1],
|
|
84
82
|
"variantStyle": [1025, "variant-style"],
|
|
85
|
-
"
|
|
83
|
+
"classCollection": [32]
|
|
86
84
|
}]);
|
|
87
85
|
function defineCustomElement() {
|
|
88
86
|
if (typeof customElements === "undefined") {
|
|
@@ -21,7 +21,6 @@ const MgCharacterLeft = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
21
21
|
*************/
|
|
22
22
|
/**
|
|
23
23
|
* Check if props are well configured on init
|
|
24
|
-
* @returns {void}
|
|
25
24
|
*/
|
|
26
25
|
componentWillLoad() {
|
|
27
26
|
this.validateMaxlength(this.maxlength);
|
|
@@ -29,7 +28,7 @@ const MgCharacterLeft = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* Render component
|
|
32
|
-
* @returns
|
|
31
|
+
* @returns HTML Element
|
|
33
32
|
*/
|
|
34
33
|
render() {
|
|
35
34
|
return (h("span", { id: this.identifier, "aria-live": "polite" }, h("span", { "aria-hidden": "true" }, this.maxlength - this.characters.length, "/", this.maxlength), h("span", { class: "sr-only" }, this.messages.nbCharLeft.replace('{counter}', this.maxlength - this.characters.length))));
|
|
@@ -11,7 +11,6 @@ const MgDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
11
11
|
this.expandedChange = createEvent(this, "expanded-change", 7);
|
|
12
12
|
/**
|
|
13
13
|
* Handle details toggle
|
|
14
|
-
* @returns {void}
|
|
15
14
|
*/
|
|
16
15
|
this.handleToggle = () => {
|
|
17
16
|
this.expanded = this.details.open;
|
|
@@ -34,7 +33,6 @@ const MgDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
34
33
|
*************/
|
|
35
34
|
/**
|
|
36
35
|
* Check if component props are well configured on init
|
|
37
|
-
* @returns {void}
|
|
38
36
|
*/
|
|
39
37
|
componentWillLoad() {
|
|
40
38
|
this.validateTitles(this.toggleClosed);
|
|
@@ -42,7 +40,7 @@ const MgDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
42
40
|
}
|
|
43
41
|
/**
|
|
44
42
|
* Render
|
|
45
|
-
* @returns
|
|
43
|
+
* @returns HTML Element
|
|
46
44
|
*/
|
|
47
45
|
render() {
|
|
48
46
|
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down', size: "small" }), h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), h("div", { class: "mg-details__details" }, h("slot", { name: "details" }))));
|
|
@@ -15,13 +15,11 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
15
15
|
this.classAllRequired = 'mg-form--all-required';
|
|
16
16
|
/**
|
|
17
17
|
* Define required message based on mg-inputs required elements
|
|
18
|
-
* Also
|
|
19
|
-
* @returns {void}
|
|
20
18
|
*/
|
|
21
19
|
this.setRequiredMessage = () => {
|
|
22
20
|
// init required message
|
|
23
21
|
this.requiredMessage = null;
|
|
24
|
-
this.
|
|
22
|
+
this.classCollection.delete(this.classAllRequired);
|
|
25
23
|
// If the form is disabled or readonly none of them are required
|
|
26
24
|
// Check if all fields are not editable (readonly or disabled)
|
|
27
25
|
if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
|
|
@@ -31,7 +29,7 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
31
29
|
// mg-input-toggle can not be required
|
|
32
30
|
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
33
31
|
this.requiredMessage = requiredInputs.length === 1 ? this.messages.form.allRequiredSingle : this.messages.form.allRequired;
|
|
34
|
-
this.
|
|
32
|
+
this.classCollection.add(this.classAllRequired);
|
|
35
33
|
}
|
|
36
34
|
// Some fields are required
|
|
37
35
|
else if (requiredInputs.length > 0) {
|
|
@@ -41,7 +39,6 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
41
39
|
};
|
|
42
40
|
/**
|
|
43
41
|
* Check if form is valid
|
|
44
|
-
* @returns {void}
|
|
45
42
|
*/
|
|
46
43
|
this.checkValidity = () => {
|
|
47
44
|
// Update required on input event
|
|
@@ -53,8 +50,7 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
53
50
|
};
|
|
54
51
|
/**
|
|
55
52
|
* Handle Form Submit
|
|
56
|
-
* @param
|
|
57
|
-
* @returns {void}
|
|
53
|
+
* @param event - submit event
|
|
58
54
|
*/
|
|
59
55
|
this.handleFormSubmit = (event) => {
|
|
60
56
|
event.preventDefault();
|
|
@@ -62,7 +58,6 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
62
58
|
};
|
|
63
59
|
/**
|
|
64
60
|
* Set mgInputs
|
|
65
|
-
* @returns {void}
|
|
66
61
|
*/
|
|
67
62
|
this.setMgInputs = () => {
|
|
68
63
|
// Get slotted mgInputs
|
|
@@ -84,7 +79,7 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
84
79
|
this.disabled = false;
|
|
85
80
|
this.valid = undefined;
|
|
86
81
|
this.invalid = undefined;
|
|
87
|
-
this.
|
|
82
|
+
this.classCollection = new ClassList(['mg-form']);
|
|
88
83
|
this.requiredMessage = undefined;
|
|
89
84
|
}
|
|
90
85
|
handleAttributeChange() {
|
|
@@ -93,7 +88,6 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
93
88
|
}
|
|
94
89
|
/**
|
|
95
90
|
* Public method to display errors
|
|
96
|
-
* @returns {Promise<void>}
|
|
97
91
|
*/
|
|
98
92
|
async displayError() {
|
|
99
93
|
if (!this.readonly) {
|
|
@@ -108,7 +102,6 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
108
102
|
*************/
|
|
109
103
|
/**
|
|
110
104
|
* Check if component props are well configured on init
|
|
111
|
-
* @returns {void}
|
|
112
105
|
*/
|
|
113
106
|
componentWillLoad() {
|
|
114
107
|
// Get locales
|
|
@@ -135,7 +128,6 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
135
128
|
}
|
|
136
129
|
/**
|
|
137
130
|
* Add slot listeners
|
|
138
|
-
* @returns {void}
|
|
139
131
|
*/
|
|
140
132
|
componentDidLoad() {
|
|
141
133
|
this.mgButtons.forEach(mgButton => {
|
|
@@ -153,10 +145,10 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
153
145
|
}
|
|
154
146
|
/**
|
|
155
147
|
* Render
|
|
156
|
-
* @returns
|
|
148
|
+
* @returns HTML Element
|
|
157
149
|
*/
|
|
158
150
|
render() {
|
|
159
|
-
return (h("form", { class: this.
|
|
151
|
+
return (h("form", { class: this.classCollection.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit }, this.requiredMessage && h("p", { innerHTML: this.requiredMessage }), h("slot", null), !this.readonly && !this.disabled && h("slot", { name: "actions" })));
|
|
160
152
|
}
|
|
161
153
|
get element() { return this; }
|
|
162
154
|
static get watchers() { return {
|
|
@@ -171,7 +163,7 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
171
163
|
"disabled": [4],
|
|
172
164
|
"valid": [1028],
|
|
173
165
|
"invalid": [1028],
|
|
174
|
-
"
|
|
166
|
+
"classCollection": [32],
|
|
175
167
|
"requiredMessage": [32],
|
|
176
168
|
"displayError": [64]
|
|
177
169
|
}]);
|
|
@@ -240,13 +240,12 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
240
240
|
this.__attachShadow();
|
|
241
241
|
/**
|
|
242
242
|
* getIcon
|
|
243
|
-
* @returns
|
|
243
|
+
* @returns icon html
|
|
244
244
|
*/
|
|
245
245
|
this.getIcon = () => icons[this.icon]();
|
|
246
246
|
/**
|
|
247
247
|
* Method to set default varianStyle props
|
|
248
248
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
249
|
-
* @returns {void}
|
|
250
249
|
*/
|
|
251
250
|
this.setDefaultVariantStyle = () => {
|
|
252
251
|
if (this.variantStyle === undefined)
|
|
@@ -257,15 +256,15 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
257
256
|
this.variant = undefined;
|
|
258
257
|
this.variantStyle = undefined;
|
|
259
258
|
this.spin = false;
|
|
260
|
-
this.
|
|
259
|
+
this.classCollection = new ClassList(['mg-icon']);
|
|
261
260
|
}
|
|
262
261
|
validateIcon(newValue, oldValue) {
|
|
263
262
|
if (!Object.keys(icons).includes(newValue))
|
|
264
263
|
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
|
|
265
264
|
else {
|
|
266
265
|
if (oldValue !== undefined)
|
|
267
|
-
this.
|
|
268
|
-
this.
|
|
266
|
+
this.classCollection.delete(`mg-icon--${oldValue}`);
|
|
267
|
+
this.classCollection.add(`mg-icon--${newValue}`);
|
|
269
268
|
}
|
|
270
269
|
}
|
|
271
270
|
validateSize(newValue, oldValue) {
|
|
@@ -273,8 +272,8 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
273
272
|
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
274
273
|
else {
|
|
275
274
|
if (oldValue !== undefined)
|
|
276
|
-
this.
|
|
277
|
-
this.
|
|
275
|
+
this.classCollection.delete(`mg-icon--size-${oldValue}`);
|
|
276
|
+
this.classCollection.add(`mg-icon--size-${newValue}`);
|
|
278
277
|
}
|
|
279
278
|
}
|
|
280
279
|
validateVariant(newValue, oldValue) {
|
|
@@ -284,8 +283,8 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
284
283
|
else {
|
|
285
284
|
this.setDefaultVariantStyle();
|
|
286
285
|
if (oldValue !== undefined)
|
|
287
|
-
this.
|
|
288
|
-
this.
|
|
286
|
+
this.classCollection.delete(`mg-icon--variant-${oldValue}`);
|
|
287
|
+
this.classCollection.add(`mg-icon--variant-${newValue}`);
|
|
289
288
|
}
|
|
290
289
|
}
|
|
291
290
|
}
|
|
@@ -295,24 +294,23 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
295
294
|
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
|
|
296
295
|
else {
|
|
297
296
|
if (oldValue !== undefined)
|
|
298
|
-
this.
|
|
299
|
-
this.
|
|
297
|
+
this.classCollection.delete(`mg-icon--variant-style-${oldValue}`);
|
|
298
|
+
this.classCollection.add(`mg-icon--variant-style-${newValue}`);
|
|
300
299
|
}
|
|
301
300
|
}
|
|
302
301
|
}
|
|
303
302
|
handleSpin(newValue) {
|
|
304
303
|
if (newValue) {
|
|
305
|
-
this.
|
|
306
|
-
this.
|
|
304
|
+
this.classCollection.add('mg-icon--spin');
|
|
305
|
+
this.classCollection.add('mg-a11y-animation');
|
|
307
306
|
}
|
|
308
307
|
else {
|
|
309
|
-
this.
|
|
310
|
-
this.
|
|
308
|
+
this.classCollection.delete('mg-icon--spin');
|
|
309
|
+
this.classCollection.delete('mg-a11y-animation');
|
|
311
310
|
}
|
|
312
311
|
}
|
|
313
312
|
/**
|
|
314
313
|
* Check if props are well configured on init
|
|
315
|
-
* @returns {void}
|
|
316
314
|
*/
|
|
317
315
|
componentWillLoad() {
|
|
318
316
|
this.validateIcon(this.icon);
|
|
@@ -323,10 +321,10 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
323
321
|
}
|
|
324
322
|
/**
|
|
325
323
|
* Render component
|
|
326
|
-
* @returns
|
|
324
|
+
* @returns HTML Element
|
|
327
325
|
*/
|
|
328
326
|
render() {
|
|
329
|
-
return (h("svg", { class: this.
|
|
327
|
+
return (h("svg", { class: this.classCollection.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
|
|
330
328
|
}
|
|
331
329
|
static get watchers() { return {
|
|
332
330
|
"icon": ["validateIcon"],
|
|
@@ -342,7 +340,7 @@ const MgIcon = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
342
340
|
"variant": [1],
|
|
343
341
|
"variantStyle": [1025, "variant-style"],
|
|
344
342
|
"spin": [4],
|
|
345
|
-
"
|
|
343
|
+
"classCollection": [32]
|
|
346
344
|
}]);
|
|
347
345
|
function defineCustomElement() {
|
|
348
346
|
if (typeof customElements === "undefined") {
|
|
@@ -16,7 +16,6 @@ const MgIllustratedMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
16
16
|
*************/
|
|
17
17
|
/**
|
|
18
18
|
* Check if component props are well configured on init
|
|
19
|
-
* @returns {void}
|
|
20
19
|
*/
|
|
21
20
|
componentDidLoad() {
|
|
22
21
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -31,7 +30,7 @@ const MgIllustratedMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
32
|
* Render
|
|
34
|
-
* @returns
|
|
33
|
+
* @returns HTML Element
|
|
35
34
|
*/
|
|
36
35
|
render() {
|
|
37
36
|
return (h("div", { class: {
|