@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-3249671d.js';
|
|
2
|
-
import { i as initLocales, D as Direction, l as localeDate, d as dateRegExp, a as localeCurrency, b as localeNumber, s as sizes$2 } from './mg-menu.conf-
|
|
2
|
+
import { i as initLocales, D as Direction, l as localeDate, d as dateRegExp, a as localeCurrency, b as localeNumber, s as sizes$2 } from './mg-menu.conf-9ca023ee.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Available menu-item positions
|
|
@@ -22,10 +22,9 @@ var Status$1;
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Create random ID
|
|
25
|
-
*
|
|
26
|
-
* @param
|
|
27
|
-
* @
|
|
28
|
-
* @returns {string} ID
|
|
25
|
+
* @param prefix - add prefix to created ID
|
|
26
|
+
* @param length - ID length
|
|
27
|
+
* @returns ID
|
|
29
28
|
*/
|
|
30
29
|
const createID = (prefix = '', length = 10) => {
|
|
31
30
|
let ID = '';
|
|
@@ -44,9 +43,7 @@ class ClassList {
|
|
|
44
43
|
constructor(classlist = []) {
|
|
45
44
|
/**
|
|
46
45
|
* Add class
|
|
47
|
-
*
|
|
48
|
-
* @param {string} className class name to add
|
|
49
|
-
* @returns {void}
|
|
46
|
+
* @param className - class name to add
|
|
50
47
|
*/
|
|
51
48
|
this.add = (className) => {
|
|
52
49
|
if (!this.has(className)) {
|
|
@@ -55,9 +52,7 @@ class ClassList {
|
|
|
55
52
|
};
|
|
56
53
|
/**
|
|
57
54
|
* Delete class
|
|
58
|
-
*
|
|
59
|
-
* @param {string} className class name to delete
|
|
60
|
-
* @returns {void}
|
|
55
|
+
* @param className - class name to delete
|
|
61
56
|
*/
|
|
62
57
|
this.delete = (className) => {
|
|
63
58
|
const index = this.classes.indexOf(className);
|
|
@@ -67,17 +62,15 @@ class ClassList {
|
|
|
67
62
|
};
|
|
68
63
|
/**
|
|
69
64
|
* Check if class exist in list
|
|
70
|
-
*
|
|
71
|
-
* @
|
|
72
|
-
* @returns {boolean} class name is in the list
|
|
65
|
+
* @param className - class name to check
|
|
66
|
+
* @returns class name is in the list
|
|
73
67
|
*/
|
|
74
68
|
this.has = (className) => {
|
|
75
69
|
return this.classes.includes(className);
|
|
76
70
|
};
|
|
77
71
|
/**
|
|
78
72
|
* Join classes seperated by spaces
|
|
79
|
-
*
|
|
80
|
-
* @returns {string} joined values
|
|
73
|
+
* @returns joined values
|
|
81
74
|
*/
|
|
82
75
|
this.join = () => {
|
|
83
76
|
return this.classes.join(' ');
|
|
@@ -87,17 +80,15 @@ class ClassList {
|
|
|
87
80
|
}
|
|
88
81
|
/**
|
|
89
82
|
* Check if all items are string
|
|
90
|
-
*
|
|
91
|
-
* @
|
|
92
|
-
* @returns {boolean} all items are string
|
|
83
|
+
* @param items - items to check
|
|
84
|
+
* @returns all items are string
|
|
93
85
|
*/
|
|
94
86
|
const allItemsAreString = (items) => Array.isArray(items) && items.every(item => typeof item === 'string');
|
|
95
87
|
/**
|
|
96
88
|
* Check if element is a heading
|
|
97
|
-
*
|
|
98
|
-
* @param
|
|
99
|
-
* @
|
|
100
|
-
* @returns {boolean} element is a heading
|
|
89
|
+
* @param element - slotted element
|
|
90
|
+
* @param tagNames - allowed tag names list
|
|
91
|
+
* @returns element is a heading
|
|
101
92
|
*/
|
|
102
93
|
const isTagName = (element, tagNames) => {
|
|
103
94
|
return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
|
|
@@ -107,9 +98,9 @@ const isTagName = (element, tagNames) => {
|
|
|
107
98
|
*/
|
|
108
99
|
const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
109
100
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param
|
|
112
|
-
* @returns
|
|
101
|
+
* Get windows
|
|
102
|
+
* @param localWindow - the window we are lookink for other windows
|
|
103
|
+
* @returns The list of windows found
|
|
113
104
|
*/
|
|
114
105
|
const getWindows = (localWindow) => {
|
|
115
106
|
const parentWindows = getParentWindows(localWindow);
|
|
@@ -118,10 +109,9 @@ const getWindows = (localWindow) => {
|
|
|
118
109
|
};
|
|
119
110
|
/**
|
|
120
111
|
* Get parent windows
|
|
121
|
-
*
|
|
122
|
-
* @param
|
|
123
|
-
* @
|
|
124
|
-
* @returns {Window[]} The list of windows found
|
|
112
|
+
* @param localWindow - the window we are lookink for parents
|
|
113
|
+
* @param windows - The list of allready found windows
|
|
114
|
+
* @returns The list of windows found
|
|
125
115
|
*/
|
|
126
116
|
const getParentWindows = (localWindow, windows = []) => {
|
|
127
117
|
// Check if is in iframe
|
|
@@ -141,10 +131,9 @@ const getParentWindows = (localWindow, windows = []) => {
|
|
|
141
131
|
};
|
|
142
132
|
/**
|
|
143
133
|
* Get child windows
|
|
144
|
-
*
|
|
145
|
-
* @param
|
|
146
|
-
* @
|
|
147
|
-
* @returns {Window[]} The list of windows found
|
|
134
|
+
* @param localWindow - the window we are lookink for children
|
|
135
|
+
* @param windows - The list of allready found windows
|
|
136
|
+
* @returns The list of windows found
|
|
148
137
|
*/
|
|
149
138
|
const getChildWindows = (localWindow, windows = []) => {
|
|
150
139
|
if (localWindow.frames.length > 0) {
|
|
@@ -163,9 +152,8 @@ const mgActionMoreCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
163
152
|
|
|
164
153
|
/**
|
|
165
154
|
* MgActionMore['items'] type guard
|
|
166
|
-
*
|
|
167
|
-
* @
|
|
168
|
-
* @returns {boolean} return true if type is valid
|
|
155
|
+
* @param prop - commponent items prop
|
|
156
|
+
* @returns return true if type is valid
|
|
169
157
|
*/
|
|
170
158
|
const isMgActionMoreItems = (prop) => {
|
|
171
159
|
const items = prop;
|
|
@@ -173,9 +161,8 @@ const isMgActionMoreItems = (prop) => {
|
|
|
173
161
|
};
|
|
174
162
|
/**
|
|
175
163
|
* MgActionMore['button'] type guard
|
|
176
|
-
*
|
|
177
|
-
* @
|
|
178
|
-
* @returns {boolean} return true if type is valid
|
|
164
|
+
* @param prop - commponent button prop
|
|
165
|
+
* @returns return true if type is valid
|
|
179
166
|
*/
|
|
180
167
|
const isMgActionMoreButton = (prop) => {
|
|
181
168
|
const button = prop;
|
|
@@ -183,9 +170,8 @@ const isMgActionMoreButton = (prop) => {
|
|
|
183
170
|
};
|
|
184
171
|
/**
|
|
185
172
|
* MgActionMore['icon'] type guard
|
|
186
|
-
*
|
|
187
|
-
* @
|
|
188
|
-
* @returns {boolean} return true if type is valid
|
|
173
|
+
* @param prop - commponent icon prop
|
|
174
|
+
* @returns return true if type is valid
|
|
189
175
|
*/
|
|
190
176
|
const isMgActionMoreIcon = (prop) => {
|
|
191
177
|
const icon = prop;
|
|
@@ -204,26 +190,20 @@ const MgActionMore = class {
|
|
|
204
190
|
***********/
|
|
205
191
|
/**
|
|
206
192
|
* Toogle expanded props
|
|
207
|
-
*
|
|
208
|
-
* @returns {void}
|
|
209
193
|
*/
|
|
210
194
|
this.toggleExpanded = () => {
|
|
211
195
|
this.expanded = !this.expanded;
|
|
212
196
|
};
|
|
213
197
|
/**
|
|
214
198
|
* Button click handler
|
|
215
|
-
*
|
|
216
|
-
* @returns {void}
|
|
217
199
|
*/
|
|
218
200
|
this.handleButton = () => {
|
|
219
201
|
this.toggleExpanded();
|
|
220
202
|
};
|
|
221
203
|
/**
|
|
222
204
|
* Item click handler
|
|
223
|
-
*
|
|
224
|
-
* @param
|
|
225
|
-
* @param {MgActionMoreItemType['mouseEventHandler']} customHandler item['mouseEventHandler']
|
|
226
|
-
* @returns {void}
|
|
205
|
+
* @param event - click event
|
|
206
|
+
* @param customHandler - item['mouseEventHandler']
|
|
227
207
|
*/
|
|
228
208
|
this.handleItemClick = (event, customHandler) => {
|
|
229
209
|
this.expanded = false;
|
|
@@ -260,8 +240,6 @@ const MgActionMore = class {
|
|
|
260
240
|
*************/
|
|
261
241
|
/**
|
|
262
242
|
* Validate props
|
|
263
|
-
*
|
|
264
|
-
* @returns {void}
|
|
265
243
|
*/
|
|
266
244
|
componentWillLoad() {
|
|
267
245
|
this.messages = initLocales(this.element).messages.actionMore;
|
|
@@ -272,8 +250,7 @@ const MgActionMore = class {
|
|
|
272
250
|
}
|
|
273
251
|
/**
|
|
274
252
|
* Render
|
|
275
|
-
*
|
|
276
|
-
* @returns {HTMLElement} HTML Element
|
|
253
|
+
* @returns HTML Element
|
|
277
254
|
*/
|
|
278
255
|
render() {
|
|
279
256
|
const buttonLabel = this.button.label || this.messages.label;
|
|
@@ -321,7 +298,7 @@ const MgBadge = class {
|
|
|
321
298
|
this.label = undefined;
|
|
322
299
|
this.variant = variants$5[0];
|
|
323
300
|
this.outline = undefined;
|
|
324
|
-
this.
|
|
301
|
+
this.classCollection = new ClassList(['mg-badge']);
|
|
325
302
|
}
|
|
326
303
|
validateValue(newValue) {
|
|
327
304
|
if (`${newValue}`.match(/^(\d+\+*|[?*!a-z])$/i) === null) {
|
|
@@ -339,21 +316,19 @@ const MgBadge = class {
|
|
|
339
316
|
}
|
|
340
317
|
else {
|
|
341
318
|
if (oldValue !== undefined) {
|
|
342
|
-
this.
|
|
319
|
+
this.classCollection.delete(`mg-badge--${oldValue}`);
|
|
343
320
|
}
|
|
344
|
-
this.
|
|
321
|
+
this.classCollection.add(`mg-badge--${newValue}`);
|
|
345
322
|
}
|
|
346
323
|
}
|
|
347
324
|
validateOutline(newValue) {
|
|
348
325
|
if (newValue)
|
|
349
|
-
this.
|
|
326
|
+
this.classCollection.add(this.classOutline);
|
|
350
327
|
else
|
|
351
|
-
this.
|
|
328
|
+
this.classCollection.delete(this.classOutline);
|
|
352
329
|
}
|
|
353
330
|
/**
|
|
354
331
|
* Check if props are well configured on init
|
|
355
|
-
*
|
|
356
|
-
* @returns {void}
|
|
357
332
|
*/
|
|
358
333
|
componentWillLoad() {
|
|
359
334
|
this.validateValue(this.value);
|
|
@@ -363,11 +338,10 @@ const MgBadge = class {
|
|
|
363
338
|
}
|
|
364
339
|
/**
|
|
365
340
|
* Render
|
|
366
|
-
*
|
|
367
|
-
* @returns {HTMLElement} HTML Element
|
|
341
|
+
* @returns HTML Element
|
|
368
342
|
*/
|
|
369
343
|
render() {
|
|
370
|
-
return (h("span", { class: this.
|
|
344
|
+
return (h("span", { class: this.classCollection.join() }, h("span", { class: "mg-badge__value" }, this.value), h("span", { class: "sr-only" }, this.label)));
|
|
371
345
|
}
|
|
372
346
|
static get watchers() { return {
|
|
373
347
|
"value": ["validateValue"],
|
|
@@ -398,9 +372,7 @@ const MgButton = class {
|
|
|
398
372
|
this.classFullWidth = 'mg-button--full-width';
|
|
399
373
|
/**
|
|
400
374
|
* Trigger actions onClick event
|
|
401
|
-
*
|
|
402
|
-
* @param {MouseEvent} event click event
|
|
403
|
-
* @returns {void}
|
|
375
|
+
* @param event - click event
|
|
404
376
|
*/
|
|
405
377
|
this.handleClick = (event) => {
|
|
406
378
|
if (this.disabled)
|
|
@@ -413,9 +385,7 @@ const MgButton = class {
|
|
|
413
385
|
};
|
|
414
386
|
/**
|
|
415
387
|
* Handle onKeydown event
|
|
416
|
-
*
|
|
417
|
-
* @param {KeyboardEvent} event keyboard event
|
|
418
|
-
* @returns {void}
|
|
388
|
+
* @param event - keyboard event
|
|
419
389
|
*/
|
|
420
390
|
this.handleKeydown = (event) => {
|
|
421
391
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -428,9 +398,7 @@ const MgButton = class {
|
|
|
428
398
|
};
|
|
429
399
|
/**
|
|
430
400
|
* Handle onKeyup event
|
|
431
|
-
*
|
|
432
|
-
* @param {KeyboardEvent} event keyboard event
|
|
433
|
-
* @returns {void}
|
|
401
|
+
* @param event - keyboard event
|
|
434
402
|
*/
|
|
435
403
|
this.handleKeyup = (event) => {
|
|
436
404
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -448,7 +416,7 @@ const MgButton = class {
|
|
|
448
416
|
this.isIcon = false;
|
|
449
417
|
this.disableOnClick = false;
|
|
450
418
|
this.loading = false;
|
|
451
|
-
this.
|
|
419
|
+
this.classCollection = new ClassList(['mg-button']);
|
|
452
420
|
}
|
|
453
421
|
validateVariant(newValue, oldValue) {
|
|
454
422
|
if (!variants$4.includes(newValue)) {
|
|
@@ -456,9 +424,9 @@ const MgButton = class {
|
|
|
456
424
|
}
|
|
457
425
|
else {
|
|
458
426
|
if (oldValue !== undefined) {
|
|
459
|
-
this.
|
|
427
|
+
this.classCollection.delete(`mg-button--${oldValue}`);
|
|
460
428
|
}
|
|
461
|
-
this.
|
|
429
|
+
this.classCollection.add(`mg-button--${newValue}`);
|
|
462
430
|
}
|
|
463
431
|
}
|
|
464
432
|
validateFullWidth(newValue) {
|
|
@@ -466,10 +434,10 @@ const MgButton = class {
|
|
|
466
434
|
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
467
435
|
}
|
|
468
436
|
else if (newValue) {
|
|
469
|
-
this.
|
|
437
|
+
this.classCollection.add(this.classFullWidth);
|
|
470
438
|
}
|
|
471
439
|
else {
|
|
472
|
-
this.
|
|
440
|
+
this.classCollection.delete(this.classFullWidth);
|
|
473
441
|
}
|
|
474
442
|
}
|
|
475
443
|
disabledHandler(isDisabled) {
|
|
@@ -482,10 +450,10 @@ const MgButton = class {
|
|
|
482
450
|
this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
|
|
483
451
|
// apply style
|
|
484
452
|
if (isDisabled) {
|
|
485
|
-
this.
|
|
453
|
+
this.classCollection.add(this.classDisabled);
|
|
486
454
|
}
|
|
487
455
|
else {
|
|
488
|
-
this.
|
|
456
|
+
this.classCollection.delete(this.classDisabled);
|
|
489
457
|
}
|
|
490
458
|
// emit value update
|
|
491
459
|
this.disabledChange.emit(isDisabled);
|
|
@@ -493,22 +461,20 @@ const MgButton = class {
|
|
|
493
461
|
loadingHandler(newValue) {
|
|
494
462
|
// we add loading style if it newvalue is true else we remove it
|
|
495
463
|
if (newValue) {
|
|
496
|
-
this.
|
|
464
|
+
this.classCollection.add(this.classLoading);
|
|
497
465
|
}
|
|
498
466
|
else {
|
|
499
|
-
this.
|
|
467
|
+
this.classCollection.delete(this.classLoading);
|
|
500
468
|
}
|
|
501
469
|
}
|
|
502
470
|
/**
|
|
503
471
|
* Check if props are well configured on init
|
|
504
|
-
*
|
|
505
|
-
* @returns {void}
|
|
506
472
|
*/
|
|
507
473
|
componentWillLoad() {
|
|
508
474
|
this.validateVariant(this.variant);
|
|
509
475
|
this.validateFullWidth(this.fullWidth);
|
|
510
476
|
if (this.isIcon) {
|
|
511
|
-
this.
|
|
477
|
+
this.classCollection.add(`mg-button--icon`);
|
|
512
478
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
513
479
|
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
514
480
|
}
|
|
@@ -519,11 +485,10 @@ const MgButton = class {
|
|
|
519
485
|
}
|
|
520
486
|
/**
|
|
521
487
|
* Render component
|
|
522
|
-
*
|
|
523
|
-
* @returns {HTMLElement} html element
|
|
488
|
+
* @returns html element
|
|
524
489
|
*/
|
|
525
490
|
render() {
|
|
526
|
-
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.
|
|
491
|
+
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)))));
|
|
527
492
|
}
|
|
528
493
|
get element() { return getElement(this); }
|
|
529
494
|
static get watchers() { return {
|
|
@@ -554,20 +519,27 @@ const MgCard = class {
|
|
|
554
519
|
*************/
|
|
555
520
|
this.name = 'mg-card';
|
|
556
521
|
this.baseClass = this.name;
|
|
522
|
+
/**
|
|
523
|
+
* Methode to set default varianStyle props
|
|
524
|
+
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
525
|
+
*/
|
|
526
|
+
this.setDefaultVariantStyle = () => {
|
|
527
|
+
if (this.variantStyle === undefined)
|
|
528
|
+
this.variantStyle = 'bar-left';
|
|
529
|
+
};
|
|
557
530
|
this.variant = undefined;
|
|
558
531
|
this.variantStyle = undefined;
|
|
559
|
-
this.
|
|
532
|
+
this.classCollection = new ClassList([this.baseClass]);
|
|
560
533
|
}
|
|
561
534
|
validateVariant(newValue, oldValue) {
|
|
562
535
|
if (newValue && !variants$3.includes(newValue))
|
|
563
536
|
throw new Error(`<${this.name}> prop "variant" must match VariantType type.`);
|
|
564
537
|
if (Boolean(newValue)) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
this.classList.add(`${this.baseClass}--${newValue}`);
|
|
538
|
+
this.setDefaultVariantStyle();
|
|
539
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
568
540
|
}
|
|
569
541
|
if (Boolean(oldValue))
|
|
570
|
-
this.
|
|
542
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
571
543
|
}
|
|
572
544
|
validateVariantStyle(newValue, oldValue) {
|
|
573
545
|
if (newValue && !variantStyles$1.includes(newValue))
|
|
@@ -575,14 +547,15 @@ const MgCard = class {
|
|
|
575
547
|
else if (Boolean(newValue) && !variants$3.includes(this.variant))
|
|
576
548
|
throw new Error(`<${this.name}> prop "variantStyle" must be paired with ${JSON.stringify(variants$3)} "variant" prop.`);
|
|
577
549
|
if (Boolean(newValue))
|
|
578
|
-
this.
|
|
550
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
579
551
|
if (Boolean(oldValue))
|
|
580
|
-
this.
|
|
552
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
581
553
|
}
|
|
554
|
+
/*************
|
|
555
|
+
* Lifecycle *
|
|
556
|
+
*************/
|
|
582
557
|
/**
|
|
583
558
|
* Check if props are well configured on init
|
|
584
|
-
*
|
|
585
|
-
* @returns {void}
|
|
586
559
|
*/
|
|
587
560
|
componentWillLoad() {
|
|
588
561
|
this.validateVariant(this.variant);
|
|
@@ -590,12 +563,11 @@ const MgCard = class {
|
|
|
590
563
|
}
|
|
591
564
|
/**
|
|
592
565
|
* Render
|
|
593
|
-
*
|
|
594
|
-
* @returns {HTMLElement} HTML Element
|
|
566
|
+
* @returns HTML Element
|
|
595
567
|
*/
|
|
596
568
|
render() {
|
|
597
569
|
var _a;
|
|
598
|
-
return (h("div", { class: this.
|
|
570
|
+
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)));
|
|
599
571
|
}
|
|
600
572
|
static get watchers() { return {
|
|
601
573
|
"variant": ["validateVariant"],
|
|
@@ -623,8 +595,6 @@ const MgCharacterLeft = class {
|
|
|
623
595
|
*************/
|
|
624
596
|
/**
|
|
625
597
|
* Check if props are well configured on init
|
|
626
|
-
*
|
|
627
|
-
* @returns {void}
|
|
628
598
|
*/
|
|
629
599
|
componentWillLoad() {
|
|
630
600
|
this.validateMaxlength(this.maxlength);
|
|
@@ -632,8 +602,7 @@ const MgCharacterLeft = class {
|
|
|
632
602
|
}
|
|
633
603
|
/**
|
|
634
604
|
* Render component
|
|
635
|
-
*
|
|
636
|
-
* @returns {HTMLElement} HTML Element
|
|
605
|
+
* @returns HTML Element
|
|
637
606
|
*/
|
|
638
607
|
render() {
|
|
639
608
|
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))));
|
|
@@ -653,8 +622,6 @@ const MgDetails = class {
|
|
|
653
622
|
this.expandedChange = createEvent(this, "expanded-change", 7);
|
|
654
623
|
/**
|
|
655
624
|
* Handle details toggle
|
|
656
|
-
*
|
|
657
|
-
* @returns {void}
|
|
658
625
|
*/
|
|
659
626
|
this.handleToggle = () => {
|
|
660
627
|
this.expanded = this.details.open;
|
|
@@ -677,8 +644,6 @@ const MgDetails = class {
|
|
|
677
644
|
*************/
|
|
678
645
|
/**
|
|
679
646
|
* Check if component props are well configured on init
|
|
680
|
-
*
|
|
681
|
-
* @returns {void}
|
|
682
647
|
*/
|
|
683
648
|
componentWillLoad() {
|
|
684
649
|
this.validateTitles(this.toggleClosed);
|
|
@@ -686,8 +651,7 @@ const MgDetails = class {
|
|
|
686
651
|
}
|
|
687
652
|
/**
|
|
688
653
|
* Render
|
|
689
|
-
*
|
|
690
|
-
* @returns {HTMLElement} HTML Element
|
|
654
|
+
* @returns HTML Element
|
|
691
655
|
*/
|
|
692
656
|
render() {
|
|
693
657
|
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" }))));
|
|
@@ -709,8 +673,7 @@ const MgDivider = class {
|
|
|
709
673
|
}
|
|
710
674
|
/**
|
|
711
675
|
* Render
|
|
712
|
-
*
|
|
713
|
-
* @returns {HTMLElement} HTML Element
|
|
676
|
+
* @returns HTML Element
|
|
714
677
|
*/
|
|
715
678
|
render() {
|
|
716
679
|
return (h("div", { class: {
|
|
@@ -732,14 +695,11 @@ const MgForm = class {
|
|
|
732
695
|
this.classAllRequired = 'mg-form--all-required';
|
|
733
696
|
/**
|
|
734
697
|
* Define required message based on mg-inputs required elements
|
|
735
|
-
* Also
|
|
736
|
-
*
|
|
737
|
-
* @returns {void}
|
|
738
698
|
*/
|
|
739
699
|
this.setRequiredMessage = () => {
|
|
740
700
|
// init required message
|
|
741
701
|
this.requiredMessage = null;
|
|
742
|
-
this.
|
|
702
|
+
this.classCollection.delete(this.classAllRequired);
|
|
743
703
|
// If the form is disabled or readonly none of them are required
|
|
744
704
|
// Check if all fields are not editable (readonly or disabled)
|
|
745
705
|
if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
|
|
@@ -749,7 +709,7 @@ const MgForm = class {
|
|
|
749
709
|
// mg-input-toggle can not be required
|
|
750
710
|
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
751
711
|
this.requiredMessage = requiredInputs.length === 1 ? this.messages.form.allRequiredSingle : this.messages.form.allRequired;
|
|
752
|
-
this.
|
|
712
|
+
this.classCollection.add(this.classAllRequired);
|
|
753
713
|
}
|
|
754
714
|
// Some fields are required
|
|
755
715
|
else if (requiredInputs.length > 0) {
|
|
@@ -759,8 +719,6 @@ const MgForm = class {
|
|
|
759
719
|
};
|
|
760
720
|
/**
|
|
761
721
|
* Check if form is valid
|
|
762
|
-
*
|
|
763
|
-
* @returns {void}
|
|
764
722
|
*/
|
|
765
723
|
this.checkValidity = () => {
|
|
766
724
|
// Update required on input event
|
|
@@ -772,9 +730,7 @@ const MgForm = class {
|
|
|
772
730
|
};
|
|
773
731
|
/**
|
|
774
732
|
* Handle Form Submit
|
|
775
|
-
*
|
|
776
|
-
* @param {SubmitEvent} event submit event
|
|
777
|
-
* @returns {void}
|
|
733
|
+
* @param event - submit event
|
|
778
734
|
*/
|
|
779
735
|
this.handleFormSubmit = (event) => {
|
|
780
736
|
event.preventDefault();
|
|
@@ -782,8 +738,6 @@ const MgForm = class {
|
|
|
782
738
|
};
|
|
783
739
|
/**
|
|
784
740
|
* Set mgInputs
|
|
785
|
-
*
|
|
786
|
-
* @returns {void}
|
|
787
741
|
*/
|
|
788
742
|
this.setMgInputs = () => {
|
|
789
743
|
// Get slotted mgInputs
|
|
@@ -805,7 +759,7 @@ const MgForm = class {
|
|
|
805
759
|
this.disabled = false;
|
|
806
760
|
this.valid = undefined;
|
|
807
761
|
this.invalid = undefined;
|
|
808
|
-
this.
|
|
762
|
+
this.classCollection = new ClassList(['mg-form']);
|
|
809
763
|
this.requiredMessage = undefined;
|
|
810
764
|
}
|
|
811
765
|
handleAttributeChange() {
|
|
@@ -814,8 +768,6 @@ const MgForm = class {
|
|
|
814
768
|
}
|
|
815
769
|
/**
|
|
816
770
|
* Public method to display errors
|
|
817
|
-
*
|
|
818
|
-
* @returns {Promise<void>}
|
|
819
771
|
*/
|
|
820
772
|
async displayError() {
|
|
821
773
|
if (!this.readonly) {
|
|
@@ -830,8 +782,6 @@ const MgForm = class {
|
|
|
830
782
|
*************/
|
|
831
783
|
/**
|
|
832
784
|
* Check if component props are well configured on init
|
|
833
|
-
*
|
|
834
|
-
* @returns {void}
|
|
835
785
|
*/
|
|
836
786
|
componentWillLoad() {
|
|
837
787
|
// Get locales
|
|
@@ -858,8 +808,6 @@ const MgForm = class {
|
|
|
858
808
|
}
|
|
859
809
|
/**
|
|
860
810
|
* Add slot listeners
|
|
861
|
-
*
|
|
862
|
-
* @returns {void}
|
|
863
811
|
*/
|
|
864
812
|
componentDidLoad() {
|
|
865
813
|
this.mgButtons.forEach(mgButton => {
|
|
@@ -877,11 +825,10 @@ const MgForm = class {
|
|
|
877
825
|
}
|
|
878
826
|
/**
|
|
879
827
|
* Render
|
|
880
|
-
*
|
|
881
|
-
* @returns {HTMLElement} HTML Element
|
|
828
|
+
* @returns HTML Element
|
|
882
829
|
*/
|
|
883
830
|
render() {
|
|
884
|
-
return (h("form", { class: this.
|
|
831
|
+
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" })));
|
|
885
832
|
}
|
|
886
833
|
get element() { return getElement(this); }
|
|
887
834
|
static get watchers() { return {
|
|
@@ -1128,24 +1075,31 @@ const MgIcon = class {
|
|
|
1128
1075
|
registerInstance(this, hostRef);
|
|
1129
1076
|
/**
|
|
1130
1077
|
* getIcon
|
|
1131
|
-
*
|
|
1132
|
-
* @returns {HTMLElement} icon html
|
|
1078
|
+
* @returns icon html
|
|
1133
1079
|
*/
|
|
1134
1080
|
this.getIcon = () => icons[this.icon]();
|
|
1081
|
+
/**
|
|
1082
|
+
* Method to set default varianStyle props
|
|
1083
|
+
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
1084
|
+
*/
|
|
1085
|
+
this.setDefaultVariantStyle = () => {
|
|
1086
|
+
if (this.variantStyle === undefined)
|
|
1087
|
+
this.variantStyle = 'background';
|
|
1088
|
+
};
|
|
1135
1089
|
this.icon = undefined;
|
|
1136
1090
|
this.size = 'regular';
|
|
1137
1091
|
this.variant = undefined;
|
|
1138
1092
|
this.variantStyle = undefined;
|
|
1139
1093
|
this.spin = false;
|
|
1140
|
-
this.
|
|
1094
|
+
this.classCollection = new ClassList(['mg-icon']);
|
|
1141
1095
|
}
|
|
1142
1096
|
validateIcon(newValue, oldValue) {
|
|
1143
1097
|
if (!Object.keys(icons).includes(newValue))
|
|
1144
1098
|
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
|
|
1145
1099
|
else {
|
|
1146
1100
|
if (oldValue !== undefined)
|
|
1147
|
-
this.
|
|
1148
|
-
this.
|
|
1101
|
+
this.classCollection.delete(`mg-icon--${oldValue}`);
|
|
1102
|
+
this.classCollection.add(`mg-icon--${newValue}`);
|
|
1149
1103
|
}
|
|
1150
1104
|
}
|
|
1151
1105
|
validateSize(newValue, oldValue) {
|
|
@@ -1153,8 +1107,8 @@ const MgIcon = class {
|
|
|
1153
1107
|
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes$1.join(', ')}`);
|
|
1154
1108
|
else {
|
|
1155
1109
|
if (oldValue !== undefined)
|
|
1156
|
-
this.
|
|
1157
|
-
this.
|
|
1110
|
+
this.classCollection.delete(`mg-icon--size-${oldValue}`);
|
|
1111
|
+
this.classCollection.add(`mg-icon--size-${newValue}`);
|
|
1158
1112
|
}
|
|
1159
1113
|
}
|
|
1160
1114
|
validateVariant(newValue, oldValue) {
|
|
@@ -1162,11 +1116,10 @@ const MgIcon = class {
|
|
|
1162
1116
|
if (!variants$2.includes(newValue))
|
|
1163
1117
|
throw new Error(`<mg-icon> prop "variant" must be one of: ${variants$2.join(', ')}`);
|
|
1164
1118
|
else {
|
|
1165
|
-
|
|
1166
|
-
this.variantStyle = 'background';
|
|
1119
|
+
this.setDefaultVariantStyle();
|
|
1167
1120
|
if (oldValue !== undefined)
|
|
1168
|
-
this.
|
|
1169
|
-
this.
|
|
1121
|
+
this.classCollection.delete(`mg-icon--variant-${oldValue}`);
|
|
1122
|
+
this.classCollection.add(`mg-icon--variant-${newValue}`);
|
|
1170
1123
|
}
|
|
1171
1124
|
}
|
|
1172
1125
|
}
|
|
@@ -1176,25 +1129,23 @@ const MgIcon = class {
|
|
|
1176
1129
|
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
|
|
1177
1130
|
else {
|
|
1178
1131
|
if (oldValue !== undefined)
|
|
1179
|
-
this.
|
|
1180
|
-
this.
|
|
1132
|
+
this.classCollection.delete(`mg-icon--variant-style-${oldValue}`);
|
|
1133
|
+
this.classCollection.add(`mg-icon--variant-style-${newValue}`);
|
|
1181
1134
|
}
|
|
1182
1135
|
}
|
|
1183
1136
|
}
|
|
1184
1137
|
handleSpin(newValue) {
|
|
1185
1138
|
if (newValue) {
|
|
1186
|
-
this.
|
|
1187
|
-
this.
|
|
1139
|
+
this.classCollection.add('mg-icon--spin');
|
|
1140
|
+
this.classCollection.add('mg-a11y-animation');
|
|
1188
1141
|
}
|
|
1189
1142
|
else {
|
|
1190
|
-
this.
|
|
1191
|
-
this.
|
|
1143
|
+
this.classCollection.delete('mg-icon--spin');
|
|
1144
|
+
this.classCollection.delete('mg-a11y-animation');
|
|
1192
1145
|
}
|
|
1193
1146
|
}
|
|
1194
1147
|
/**
|
|
1195
1148
|
* Check if props are well configured on init
|
|
1196
|
-
*
|
|
1197
|
-
* @returns {void}
|
|
1198
1149
|
*/
|
|
1199
1150
|
componentWillLoad() {
|
|
1200
1151
|
this.validateIcon(this.icon);
|
|
@@ -1205,11 +1156,10 @@ const MgIcon = class {
|
|
|
1205
1156
|
}
|
|
1206
1157
|
/**
|
|
1207
1158
|
* Render component
|
|
1208
|
-
*
|
|
1209
|
-
* @returns {HTMLElement} HTML Element
|
|
1159
|
+
* @returns HTML Element
|
|
1210
1160
|
*/
|
|
1211
1161
|
render() {
|
|
1212
|
-
return (h("svg", { class: this.
|
|
1162
|
+
return (h("svg", { class: this.classCollection.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
|
|
1213
1163
|
}
|
|
1214
1164
|
static get watchers() { return {
|
|
1215
1165
|
"icon": ["validateIcon"],
|
|
@@ -1234,8 +1184,6 @@ const MgIllustratedMessage = class {
|
|
|
1234
1184
|
*************/
|
|
1235
1185
|
/**
|
|
1236
1186
|
* Check if component props are well configured on init
|
|
1237
|
-
*
|
|
1238
|
-
* @returns {void}
|
|
1239
1187
|
*/
|
|
1240
1188
|
componentDidLoad() {
|
|
1241
1189
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -1250,8 +1198,7 @@ const MgIllustratedMessage = class {
|
|
|
1250
1198
|
}
|
|
1251
1199
|
/**
|
|
1252
1200
|
* Render
|
|
1253
|
-
*
|
|
1254
|
-
* @returns {HTMLElement} HTML Element
|
|
1201
|
+
* @returns HTML Element
|
|
1255
1202
|
*/
|
|
1256
1203
|
render() {
|
|
1257
1204
|
return (h("div", { class: {
|
|
@@ -1266,13 +1213,17 @@ const MgIllustratedMessage = class {
|
|
|
1266
1213
|
};
|
|
1267
1214
|
MgIllustratedMessage.style = mgIllustratedMessageCss;
|
|
1268
1215
|
|
|
1216
|
+
/**
|
|
1217
|
+
* Possible input width
|
|
1218
|
+
*/
|
|
1219
|
+
const widths = [2, 4, 16, 'full'];
|
|
1220
|
+
|
|
1269
1221
|
/**
|
|
1270
1222
|
* Apply in all input child node the aria-describedby attribute
|
|
1271
|
-
*
|
|
1272
|
-
* @param
|
|
1273
|
-
* @param
|
|
1274
|
-
* @
|
|
1275
|
-
* @returns {VNode[]} Children with aria-describedby attribute
|
|
1223
|
+
* @param children - Represent scoped elements
|
|
1224
|
+
* @param ariaDescribedbyIDs - List of IDs
|
|
1225
|
+
* @param utils - Stencil.js utils
|
|
1226
|
+
* @returns Children with aria-describedby attribute
|
|
1276
1227
|
*/
|
|
1277
1228
|
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
1278
1229
|
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
@@ -1285,32 +1236,36 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
|
|
|
1285
1236
|
});
|
|
1286
1237
|
/**
|
|
1287
1238
|
* Add classes based on props
|
|
1288
|
-
*
|
|
1289
|
-
* @param {MgInputProps} props MgInput Interface Props
|
|
1239
|
+
* @param props - MgInput Interface Props
|
|
1290
1240
|
*/
|
|
1291
1241
|
const manageClasses = (props) => {
|
|
1292
|
-
props.
|
|
1242
|
+
props.classCollection.add('mg-input');
|
|
1293
1243
|
if (props.labelOnTop)
|
|
1294
|
-
props.
|
|
1244
|
+
props.classCollection.add('mg-input--label-on-top');
|
|
1245
|
+
else
|
|
1246
|
+
props.classCollection.delete('mg-input--label-on-top');
|
|
1295
1247
|
if (props.readonly)
|
|
1296
|
-
props.
|
|
1248
|
+
props.classCollection.add('mg-input--readonly');
|
|
1249
|
+
else
|
|
1250
|
+
props.classCollection.delete('mg-input--readonly');
|
|
1251
|
+
widths.forEach(width => {
|
|
1252
|
+
props.classCollection.delete(`mg-input--width-${width}`);
|
|
1253
|
+
});
|
|
1297
1254
|
if (props.mgWidth !== undefined)
|
|
1298
|
-
props.
|
|
1255
|
+
props.classCollection.add(`mg-input--width-${props.mgWidth}`);
|
|
1299
1256
|
};
|
|
1300
1257
|
/**
|
|
1301
1258
|
* Get tagname
|
|
1302
|
-
*
|
|
1303
|
-
* @
|
|
1304
|
-
* @returns {string} tag name
|
|
1259
|
+
* @param isFieldset - is fieldset
|
|
1260
|
+
* @returns tag name
|
|
1305
1261
|
*/
|
|
1306
1262
|
const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
|
|
1307
1263
|
/**
|
|
1308
1264
|
* Get input template
|
|
1309
|
-
*
|
|
1310
|
-
* @param
|
|
1311
|
-
* @param
|
|
1312
|
-
* @
|
|
1313
|
-
* @returns {VNode[]} input template
|
|
1265
|
+
* @param props - MgInput Interface Props
|
|
1266
|
+
* @param children - Represent scoped elements
|
|
1267
|
+
* @param utils - Stencil.js utils
|
|
1268
|
+
* @returns input template
|
|
1314
1269
|
*/
|
|
1315
1270
|
const MgInput = (props, children, utils) => {
|
|
1316
1271
|
/**
|
|
@@ -1366,19 +1321,17 @@ const MgInput = (props, children, utils) => {
|
|
|
1366
1321
|
const TagName = getTagName(props.isFieldset);
|
|
1367
1322
|
/**
|
|
1368
1323
|
* Get tooltip node
|
|
1369
|
-
*
|
|
1370
|
-
* @returns {VNode[]} mg-tooltip
|
|
1324
|
+
* @returns mg-tooltip
|
|
1371
1325
|
*/
|
|
1372
1326
|
const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
|
|
1373
1327
|
h("mg-icon", { icon: "info-circle" })));
|
|
1374
1328
|
/**
|
|
1375
1329
|
* Get input title (label) node
|
|
1376
1330
|
* Display asterisk only if not disabled and not readonly
|
|
1377
|
-
*
|
|
1378
|
-
* @returns {VNode[]} mg-input-title
|
|
1331
|
+
* @returns mg-input-title
|
|
1379
1332
|
*/
|
|
1380
1333
|
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
|
|
1381
|
-
return (h(TagName, { class: props.
|
|
1334
|
+
return (h(TagName, { class: props.classCollection.join() },
|
|
1382
1335
|
props.labelOnTop ? (h("div", { class: "mg-input__title" },
|
|
1383
1336
|
getInputTitle(),
|
|
1384
1337
|
!props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
|
|
@@ -1396,9 +1349,8 @@ const mgInputCheckboxCss = ":host{display:block}.mg-input{display:flex;align-ite
|
|
|
1396
1349
|
|
|
1397
1350
|
/**
|
|
1398
1351
|
* type CheckboxItem validation function
|
|
1399
|
-
*
|
|
1400
|
-
* @
|
|
1401
|
-
* @returns {boolean} match item type
|
|
1352
|
+
* @param items - Checkbox item
|
|
1353
|
+
* @returns match item type
|
|
1402
1354
|
*/
|
|
1403
1355
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
1404
1356
|
items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
|
|
@@ -1416,8 +1368,7 @@ const MgInputCheckbox = class {
|
|
|
1416
1368
|
this.hasDisplayedError = false;
|
|
1417
1369
|
/**
|
|
1418
1370
|
* Handle input event
|
|
1419
|
-
*
|
|
1420
|
-
* @param {InputEvent} event input event
|
|
1371
|
+
* @param event - input event
|
|
1421
1372
|
*/
|
|
1422
1373
|
this.handleInput = (event) => {
|
|
1423
1374
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -1439,8 +1390,7 @@ const MgInputCheckbox = class {
|
|
|
1439
1390
|
};
|
|
1440
1391
|
/**
|
|
1441
1392
|
* get invalid element
|
|
1442
|
-
*
|
|
1443
|
-
* @returns {HTMLInputElement} element
|
|
1393
|
+
* @returns element
|
|
1444
1394
|
*/
|
|
1445
1395
|
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
1446
1396
|
/**
|
|
@@ -1477,7 +1427,7 @@ const MgInputCheckbox = class {
|
|
|
1477
1427
|
this.helpText = undefined;
|
|
1478
1428
|
this.valid = undefined;
|
|
1479
1429
|
this.invalid = undefined;
|
|
1480
|
-
this.
|
|
1430
|
+
this.classCollection = new ClassList(['mg-input--checkbox']);
|
|
1481
1431
|
this.errorMessage = undefined;
|
|
1482
1432
|
this.checkboxItems = [];
|
|
1483
1433
|
}
|
|
@@ -1507,8 +1457,6 @@ const MgInputCheckbox = class {
|
|
|
1507
1457
|
}
|
|
1508
1458
|
/**
|
|
1509
1459
|
* Public method to display errors
|
|
1510
|
-
*
|
|
1511
|
-
* @returns {Promise<void>}
|
|
1512
1460
|
*/
|
|
1513
1461
|
async displayError() {
|
|
1514
1462
|
this.checkValidity();
|
|
@@ -1520,8 +1468,7 @@ const MgInputCheckbox = class {
|
|
|
1520
1468
|
*************/
|
|
1521
1469
|
/**
|
|
1522
1470
|
* Check if component props are well configured on init
|
|
1523
|
-
*
|
|
1524
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
1471
|
+
* @returns timeout
|
|
1525
1472
|
*/
|
|
1526
1473
|
componentWillLoad() {
|
|
1527
1474
|
// Get locales
|
|
@@ -1537,11 +1484,10 @@ const MgInputCheckbox = class {
|
|
|
1537
1484
|
}
|
|
1538
1485
|
/**
|
|
1539
1486
|
* Render
|
|
1540
|
-
*
|
|
1541
|
-
* @returns {HTMLElement} HTML Element
|
|
1487
|
+
* @returns HTML Element
|
|
1542
1488
|
*/
|
|
1543
1489
|
render() {
|
|
1544
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
1490
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.checkboxItems
|
|
1545
1491
|
.filter(item => {
|
|
1546
1492
|
return !this.readonly || item.value;
|
|
1547
1493
|
})
|
|
@@ -1605,8 +1551,7 @@ const MgInputDate = class {
|
|
|
1605
1551
|
};
|
|
1606
1552
|
/**
|
|
1607
1553
|
* get input error code
|
|
1608
|
-
*
|
|
1609
|
-
* @returns {null | InputError} error code
|
|
1554
|
+
* @returns error code
|
|
1610
1555
|
*/
|
|
1611
1556
|
this.getInputError = () => {
|
|
1612
1557
|
var _a, _b;
|
|
@@ -1631,8 +1576,6 @@ const MgInputDate = class {
|
|
|
1631
1576
|
};
|
|
1632
1577
|
/**
|
|
1633
1578
|
* Check input errors
|
|
1634
|
-
*
|
|
1635
|
-
* @returns {void}
|
|
1636
1579
|
*/
|
|
1637
1580
|
this.setErrorMessage = () => {
|
|
1638
1581
|
var _a;
|
|
@@ -1670,7 +1613,7 @@ const MgInputDate = class {
|
|
|
1670
1613
|
this.invalid = undefined;
|
|
1671
1614
|
this.min = undefined;
|
|
1672
1615
|
this.max = undefined;
|
|
1673
|
-
this.
|
|
1616
|
+
this.classCollection = new ClassList(['mg-input--date']);
|
|
1674
1617
|
this.errorMessage = undefined;
|
|
1675
1618
|
}
|
|
1676
1619
|
validateValue(newValue) {
|
|
@@ -1701,8 +1644,6 @@ const MgInputDate = class {
|
|
|
1701
1644
|
}
|
|
1702
1645
|
/**
|
|
1703
1646
|
* Public method to display errors
|
|
1704
|
-
*
|
|
1705
|
-
* @returns {Promise<void>}
|
|
1706
1647
|
*/
|
|
1707
1648
|
async displayError() {
|
|
1708
1649
|
this.checkValidity();
|
|
@@ -1714,8 +1655,7 @@ const MgInputDate = class {
|
|
|
1714
1655
|
*************/
|
|
1715
1656
|
/**
|
|
1716
1657
|
* Check if component props are well configured on init
|
|
1717
|
-
*
|
|
1718
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
1658
|
+
* @returns timeout
|
|
1719
1659
|
*/
|
|
1720
1660
|
componentWillLoad() {
|
|
1721
1661
|
// Get locales
|
|
@@ -1735,11 +1675,10 @@ const MgInputDate = class {
|
|
|
1735
1675
|
}
|
|
1736
1676
|
/**
|
|
1737
1677
|
* Render
|
|
1738
|
-
*
|
|
1739
|
-
* @returns {HTMLElement} HTML Element
|
|
1678
|
+
* @returns HTML Element
|
|
1740
1679
|
*/
|
|
1741
1680
|
render() {
|
|
1742
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
1681
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
1743
1682
|
if (el !== null)
|
|
1744
1683
|
this.input = el;
|
|
1745
1684
|
} })));
|
|
@@ -1779,8 +1718,6 @@ const MgInputNumeric = class {
|
|
|
1779
1718
|
this.hasDisplayedError = false;
|
|
1780
1719
|
/**
|
|
1781
1720
|
* Handle input event
|
|
1782
|
-
*
|
|
1783
|
-
* @returns {void}
|
|
1784
1721
|
*/
|
|
1785
1722
|
this.handleInput = () => {
|
|
1786
1723
|
// Check validity
|
|
@@ -1792,26 +1729,22 @@ const MgInputNumeric = class {
|
|
|
1792
1729
|
};
|
|
1793
1730
|
/**
|
|
1794
1731
|
* Handle focus event
|
|
1795
|
-
*
|
|
1796
|
-
* @returns {void}
|
|
1797
1732
|
*/
|
|
1798
1733
|
this.handleFocus = () => {
|
|
1799
1734
|
this.hasFocus = true;
|
|
1800
1735
|
};
|
|
1801
1736
|
/**
|
|
1802
1737
|
* Handle blur event
|
|
1803
|
-
*
|
|
1804
|
-
* @returns {void}
|
|
1805
1738
|
*/
|
|
1806
1739
|
this.handleBlur = () => {
|
|
1740
|
+
if (this.value === '-')
|
|
1741
|
+
this.value = '';
|
|
1807
1742
|
// Display Error
|
|
1808
1743
|
this.displayError();
|
|
1809
1744
|
this.hasFocus = false;
|
|
1810
1745
|
};
|
|
1811
1746
|
/**
|
|
1812
1747
|
* Check if input is valid
|
|
1813
|
-
*
|
|
1814
|
-
* @returns {void}
|
|
1815
1748
|
*/
|
|
1816
1749
|
this.checkValidity = () => {
|
|
1817
1750
|
this.valid = this.readonly || this.disabled || this.getInputError() === null;
|
|
@@ -1821,8 +1754,6 @@ const MgInputNumeric = class {
|
|
|
1821
1754
|
};
|
|
1822
1755
|
/**
|
|
1823
1756
|
* Set input error message
|
|
1824
|
-
*
|
|
1825
|
-
* @returns {void}
|
|
1826
1757
|
*/
|
|
1827
1758
|
this.setErrorMessage = () => {
|
|
1828
1759
|
// Set error message
|
|
@@ -1839,8 +1770,7 @@ const MgInputNumeric = class {
|
|
|
1839
1770
|
};
|
|
1840
1771
|
/**
|
|
1841
1772
|
* Get input error code
|
|
1842
|
-
*
|
|
1843
|
-
* @returns {null | InputError} error code
|
|
1773
|
+
* @returns error code
|
|
1844
1774
|
*/
|
|
1845
1775
|
this.getInputError = () => {
|
|
1846
1776
|
let inputError = null;
|
|
@@ -1868,20 +1798,17 @@ const MgInputNumeric = class {
|
|
|
1868
1798
|
};
|
|
1869
1799
|
/**
|
|
1870
1800
|
* Format value based on type
|
|
1871
|
-
*
|
|
1872
|
-
* @
|
|
1873
|
-
* @returns {string} formated local value
|
|
1801
|
+
* @param value - value to format
|
|
1802
|
+
* @returns formated local value
|
|
1874
1803
|
*/
|
|
1875
1804
|
this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));
|
|
1876
1805
|
/**
|
|
1877
1806
|
* Validate append slot
|
|
1878
|
-
*
|
|
1879
|
-
* @returns {void}
|
|
1880
1807
|
*/
|
|
1881
1808
|
this.validateAppendSlot = () => {
|
|
1882
1809
|
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
1883
1810
|
if (slotAppendInput !== null) {
|
|
1884
|
-
this.
|
|
1811
|
+
this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
1885
1812
|
}
|
|
1886
1813
|
};
|
|
1887
1814
|
this.value = undefined;
|
|
@@ -1905,7 +1832,7 @@ const MgInputNumeric = class {
|
|
|
1905
1832
|
this.decimalLength = 2;
|
|
1906
1833
|
this.valid = undefined;
|
|
1907
1834
|
this.invalid = undefined;
|
|
1908
|
-
this.
|
|
1835
|
+
this.classCollection = new ClassList(['mg-input--numeric']);
|
|
1909
1836
|
this.errorMessage = undefined;
|
|
1910
1837
|
this.hasFocus = false;
|
|
1911
1838
|
}
|
|
@@ -1917,7 +1844,7 @@ const MgInputNumeric = class {
|
|
|
1917
1844
|
// Regex
|
|
1918
1845
|
const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+[.,]?\d*$/;
|
|
1919
1846
|
// Filter input
|
|
1920
|
-
if (
|
|
1847
|
+
if (['', '-'].includes(newValue) || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
1921
1848
|
this.storedValue = newValue;
|
|
1922
1849
|
}
|
|
1923
1850
|
else if (this.storedValue !== undefined) {
|
|
@@ -1964,8 +1891,6 @@ const MgInputNumeric = class {
|
|
|
1964
1891
|
}
|
|
1965
1892
|
/**
|
|
1966
1893
|
* Public method to display errors
|
|
1967
|
-
*
|
|
1968
|
-
* @returns {Promise<void>}
|
|
1969
1894
|
*/
|
|
1970
1895
|
async displayError() {
|
|
1971
1896
|
this.checkValidity();
|
|
@@ -1975,8 +1900,7 @@ const MgInputNumeric = class {
|
|
|
1975
1900
|
/**
|
|
1976
1901
|
* Displayed value in input
|
|
1977
1902
|
* Change on focus/blur
|
|
1978
|
-
*
|
|
1979
|
-
* @returns {MgInputNumeric['value'] | MgInputNumeric['readonlyValue']} display value
|
|
1903
|
+
* @returns display value
|
|
1980
1904
|
*/
|
|
1981
1905
|
displayValue() {
|
|
1982
1906
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -1986,8 +1910,7 @@ const MgInputNumeric = class {
|
|
|
1986
1910
|
*************/
|
|
1987
1911
|
/**
|
|
1988
1912
|
* Check if component props are well configured on init
|
|
1989
|
-
*
|
|
1990
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
1913
|
+
* @returns timeout
|
|
1991
1914
|
*/
|
|
1992
1915
|
componentWillLoad() {
|
|
1993
1916
|
// Get locales
|
|
@@ -2010,11 +1933,10 @@ const MgInputNumeric = class {
|
|
|
2010
1933
|
}
|
|
2011
1934
|
/**
|
|
2012
1935
|
* Render
|
|
2013
|
-
*
|
|
2014
|
-
* @returns {HTMLElement} HTML Element
|
|
1936
|
+
* @returns HTML Element
|
|
2015
1937
|
*/
|
|
2016
1938
|
render() {
|
|
2017
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
1939
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
|
|
2018
1940
|
if (el !== null)
|
|
2019
1941
|
this.input = el;
|
|
2020
1942
|
} }), h("slot", { name: "append-input" })));
|
|
@@ -2093,7 +2015,7 @@ const MgInputPassword = class {
|
|
|
2093
2015
|
this.helpText = undefined;
|
|
2094
2016
|
this.valid = undefined;
|
|
2095
2017
|
this.invalid = undefined;
|
|
2096
|
-
this.
|
|
2018
|
+
this.classCollection = new ClassList(['mg-input--password']);
|
|
2097
2019
|
this.errorMessage = undefined;
|
|
2098
2020
|
}
|
|
2099
2021
|
handleValue(newValue) {
|
|
@@ -2111,8 +2033,6 @@ const MgInputPassword = class {
|
|
|
2111
2033
|
}
|
|
2112
2034
|
/**
|
|
2113
2035
|
* Public method to display errors
|
|
2114
|
-
*
|
|
2115
|
-
* @returns {Promise<void>}
|
|
2116
2036
|
*/
|
|
2117
2037
|
async displayError() {
|
|
2118
2038
|
this.checkValidity();
|
|
@@ -2124,8 +2044,7 @@ const MgInputPassword = class {
|
|
|
2124
2044
|
*************/
|
|
2125
2045
|
/**
|
|
2126
2046
|
* Check if component props are well configured on init
|
|
2127
|
-
*
|
|
2128
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2047
|
+
* @returns timeout
|
|
2129
2048
|
*/
|
|
2130
2049
|
componentWillLoad() {
|
|
2131
2050
|
// Get locales
|
|
@@ -2139,11 +2058,10 @@ const MgInputPassword = class {
|
|
|
2139
2058
|
}
|
|
2140
2059
|
/**
|
|
2141
2060
|
* Render
|
|
2142
|
-
*
|
|
2143
|
-
* @returns {HTMLElement} HTML Element
|
|
2061
|
+
* @returns HTML Element
|
|
2144
2062
|
*/
|
|
2145
2063
|
render() {
|
|
2146
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2064
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2147
2065
|
if (el !== null)
|
|
2148
2066
|
this.input = el;
|
|
2149
2067
|
} })));
|
|
@@ -2162,9 +2080,8 @@ const mgInputRadioCss = ":host{display:block}.mg-input{display:flex;align-items:
|
|
|
2162
2080
|
|
|
2163
2081
|
/**
|
|
2164
2082
|
* type Option validation function
|
|
2165
|
-
*
|
|
2166
|
-
* @
|
|
2167
|
-
* @returns {boolean} radio option type is valid
|
|
2083
|
+
* @param option - radio option
|
|
2084
|
+
* @returns radio option type is valid
|
|
2168
2085
|
*/
|
|
2169
2086
|
const isOption$2 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
2170
2087
|
const MgInputRadio = class {
|
|
@@ -2181,9 +2098,7 @@ const MgInputRadio = class {
|
|
|
2181
2098
|
this.hasDisplayedError = false;
|
|
2182
2099
|
/**
|
|
2183
2100
|
* Handle input event
|
|
2184
|
-
*
|
|
2185
|
-
* @param {event} event input event
|
|
2186
|
-
* @returns {void}
|
|
2101
|
+
* @param event - input event
|
|
2187
2102
|
*/
|
|
2188
2103
|
this.handleInput = (event) => {
|
|
2189
2104
|
this.checkValidity();
|
|
@@ -2191,8 +2106,6 @@ const MgInputRadio = class {
|
|
|
2191
2106
|
};
|
|
2192
2107
|
/**
|
|
2193
2108
|
* Handle blur event
|
|
2194
|
-
*
|
|
2195
|
-
* @returns {void}
|
|
2196
2109
|
*/
|
|
2197
2110
|
this.handleBlur = () => {
|
|
2198
2111
|
this.checkValidity();
|
|
@@ -2200,8 +2113,6 @@ const MgInputRadio = class {
|
|
|
2200
2113
|
};
|
|
2201
2114
|
/**
|
|
2202
2115
|
* Check if input is valid
|
|
2203
|
-
*
|
|
2204
|
-
* @returns {void}
|
|
2205
2116
|
*/
|
|
2206
2117
|
this.checkValidity = () => {
|
|
2207
2118
|
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
@@ -2211,8 +2122,6 @@ const MgInputRadio = class {
|
|
|
2211
2122
|
};
|
|
2212
2123
|
/**
|
|
2213
2124
|
* Set input error message
|
|
2214
|
-
*
|
|
2215
|
-
* @returns {void}
|
|
2216
2125
|
*/
|
|
2217
2126
|
this.setErrorMessage = () => {
|
|
2218
2127
|
const invalidElement = this.getInvalidElement();
|
|
@@ -2224,8 +2133,7 @@ const MgInputRadio = class {
|
|
|
2224
2133
|
};
|
|
2225
2134
|
/**
|
|
2226
2135
|
* get invalid element
|
|
2227
|
-
*
|
|
2228
|
-
* @returns {HTMLInputElement} element
|
|
2136
|
+
* @returns element
|
|
2229
2137
|
*/
|
|
2230
2138
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
2231
2139
|
this.value = undefined;
|
|
@@ -2243,7 +2151,7 @@ const MgInputRadio = class {
|
|
|
2243
2151
|
this.helpText = undefined;
|
|
2244
2152
|
this.valid = undefined;
|
|
2245
2153
|
this.invalid = undefined;
|
|
2246
|
-
this.
|
|
2154
|
+
this.classCollection = new ClassList(['mg-input--radio']);
|
|
2247
2155
|
this.errorMessage = undefined;
|
|
2248
2156
|
this.options = undefined;
|
|
2249
2157
|
}
|
|
@@ -2279,8 +2187,6 @@ const MgInputRadio = class {
|
|
|
2279
2187
|
}
|
|
2280
2188
|
/**
|
|
2281
2189
|
* Public method to display errors
|
|
2282
|
-
*
|
|
2283
|
-
* @returns {Promise<void>}
|
|
2284
2190
|
*/
|
|
2285
2191
|
async displayError() {
|
|
2286
2192
|
this.checkValidity();
|
|
@@ -2292,8 +2198,7 @@ const MgInputRadio = class {
|
|
|
2292
2198
|
*************/
|
|
2293
2199
|
/**
|
|
2294
2200
|
* Check if component props are well configured on init
|
|
2295
|
-
*
|
|
2296
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2201
|
+
* @returns timeout
|
|
2297
2202
|
*/
|
|
2298
2203
|
componentWillLoad() {
|
|
2299
2204
|
// Get locales
|
|
@@ -2309,11 +2214,10 @@ const MgInputRadio = class {
|
|
|
2309
2214
|
}
|
|
2310
2215
|
/**
|
|
2311
2216
|
* Render
|
|
2312
|
-
*
|
|
2313
|
-
* @returns {HTMLElement} HTML Element
|
|
2217
|
+
* @returns HTML Element
|
|
2314
2218
|
*/
|
|
2315
2219
|
render() {
|
|
2316
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2220
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => {
|
|
2317
2221
|
if (el !== null)
|
|
2318
2222
|
this.inputs[index] = el;
|
|
2319
2223
|
} }), h("label", { htmlFor: this.identifier + '_' + index }, input.title)))))));
|
|
@@ -2333,35 +2237,27 @@ const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items
|
|
|
2333
2237
|
|
|
2334
2238
|
/**
|
|
2335
2239
|
* Check if item is a well configured option
|
|
2336
|
-
*
|
|
2337
|
-
* @
|
|
2338
|
-
* @returns {boolean} select option type is valid
|
|
2240
|
+
* @param option - select option
|
|
2241
|
+
* @returns select option type is valid
|
|
2339
2242
|
*/
|
|
2340
2243
|
const isOption$1 = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
2341
2244
|
/**
|
|
2342
2245
|
* Check if items[] is SelectOption
|
|
2343
|
-
*
|
|
2344
|
-
* @
|
|
2345
|
-
* @returns {boolean} select option array type is valid
|
|
2246
|
+
* @param items - select option
|
|
2247
|
+
* @returns select option array type is valid
|
|
2346
2248
|
*/
|
|
2347
2249
|
const allItemsAreOptions = (items) => Array.isArray(items) && items.every(item => isOption$1(item));
|
|
2348
2250
|
/**
|
|
2349
2251
|
* Check if item is a well configured optgroup
|
|
2350
|
-
*
|
|
2351
|
-
* @
|
|
2352
|
-
* @returns {boolean} select optgroup type is valid
|
|
2252
|
+
* @param optgroup - select option
|
|
2253
|
+
* @returns select optgroup type is valid
|
|
2353
2254
|
*/
|
|
2354
2255
|
const isOptGroup = (optgroup) => typeof optgroup === 'object' && typeof optgroup.group === 'string' && allItemsAreOptions(optgroup.options);
|
|
2355
2256
|
/**
|
|
2356
2257
|
* Group options
|
|
2357
|
-
*
|
|
2358
|
-
* @param
|
|
2359
|
-
* @
|
|
2360
|
-
* @param {string} item.group item group
|
|
2361
|
-
* @param {string} item.title item title
|
|
2362
|
-
* @param {unknown} item.value item value
|
|
2363
|
-
* @param {boolean} item.disabled is item disabled
|
|
2364
|
-
* @returns {(SelectOption | OptGroup)[]} grouped options
|
|
2258
|
+
* @param acc - reduce accumulator
|
|
2259
|
+
* @param item - item to add
|
|
2260
|
+
* @returns grouped options
|
|
2365
2261
|
*/
|
|
2366
2262
|
const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
2367
2263
|
if (group !== undefined) {
|
|
@@ -2390,8 +2286,6 @@ const MgInputSelect = class {
|
|
|
2390
2286
|
this.hasDisplayedError = false;
|
|
2391
2287
|
/**
|
|
2392
2288
|
* Handle input event
|
|
2393
|
-
*
|
|
2394
|
-
* @returns {void}
|
|
2395
2289
|
*/
|
|
2396
2290
|
this.handleInput = () => {
|
|
2397
2291
|
this.updateValue();
|
|
@@ -2400,16 +2294,13 @@ const MgInputSelect = class {
|
|
|
2400
2294
|
};
|
|
2401
2295
|
/**
|
|
2402
2296
|
* Method to compare item.title with input.value
|
|
2403
|
-
*
|
|
2404
|
-
* @
|
|
2405
|
-
* @returns {boolean} truthy if input.value is an item
|
|
2297
|
+
* @param item - item to compare with
|
|
2298
|
+
* @returns truthy if input.value is an item
|
|
2406
2299
|
*/
|
|
2407
2300
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
2408
2301
|
/**
|
|
2409
2302
|
* value props setter
|
|
2410
|
-
*
|
|
2411
|
-
* @param {MgInputSelect['value']} newValue value to update with
|
|
2412
|
-
* @returns {void}
|
|
2303
|
+
* @param newValue - value to update with
|
|
2413
2304
|
*/
|
|
2414
2305
|
this.setValue = (newValue) => {
|
|
2415
2306
|
this.checkValidity();
|
|
@@ -2417,8 +2308,6 @@ const MgInputSelect = class {
|
|
|
2417
2308
|
};
|
|
2418
2309
|
/**
|
|
2419
2310
|
* Update value from input.value
|
|
2420
|
-
*
|
|
2421
|
-
* @returns {void}
|
|
2422
2311
|
*/
|
|
2423
2312
|
this.updateValue = () => {
|
|
2424
2313
|
if (this.input.value === '') {
|
|
@@ -2444,8 +2333,7 @@ const MgInputSelect = class {
|
|
|
2444
2333
|
};
|
|
2445
2334
|
/**
|
|
2446
2335
|
* Input value is disabled
|
|
2447
|
-
*
|
|
2448
|
-
* @returns {boolean} truthy if input value is disabled
|
|
2336
|
+
* @returns truthy if input value is disabled
|
|
2449
2337
|
*/
|
|
2450
2338
|
this.isDisabledValue = () => { var _a; return allItemsAreOptions(this.options) && ((_a = this.options.find(this.isInputValue)) === null || _a === void 0 ? void 0 : _a.disabled) === true; };
|
|
2451
2339
|
/**
|
|
@@ -2470,9 +2358,8 @@ const MgInputSelect = class {
|
|
|
2470
2358
|
};
|
|
2471
2359
|
/**
|
|
2472
2360
|
* Render option
|
|
2473
|
-
*
|
|
2474
|
-
* @
|
|
2475
|
-
* @returns {HTMLElement} render option
|
|
2361
|
+
* @param option - to render
|
|
2362
|
+
* @returns render option
|
|
2476
2363
|
*/
|
|
2477
2364
|
this.renderOption = (option) => (h("option", { key: option.title, value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title));
|
|
2478
2365
|
this.value = undefined;
|
|
@@ -2493,7 +2380,7 @@ const MgInputSelect = class {
|
|
|
2493
2380
|
this.helpText = undefined;
|
|
2494
2381
|
this.valid = undefined;
|
|
2495
2382
|
this.invalid = undefined;
|
|
2496
|
-
this.
|
|
2383
|
+
this.classCollection = new ClassList(['mg-input--select']);
|
|
2497
2384
|
this.errorMessage = undefined;
|
|
2498
2385
|
this.options = undefined;
|
|
2499
2386
|
this.valueExist = undefined;
|
|
@@ -2551,8 +2438,6 @@ const MgInputSelect = class {
|
|
|
2551
2438
|
}
|
|
2552
2439
|
/**
|
|
2553
2440
|
* Public method to display errors
|
|
2554
|
-
*
|
|
2555
|
-
* @returns {Promise<void>}
|
|
2556
2441
|
*/
|
|
2557
2442
|
async displayError() {
|
|
2558
2443
|
this.checkValidity();
|
|
@@ -2564,8 +2449,7 @@ const MgInputSelect = class {
|
|
|
2564
2449
|
*************/
|
|
2565
2450
|
/**
|
|
2566
2451
|
* Check if component props are well configured on init
|
|
2567
|
-
*
|
|
2568
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2452
|
+
* @returns timeout
|
|
2569
2453
|
*/
|
|
2570
2454
|
componentWillLoad() {
|
|
2571
2455
|
// Get locales
|
|
@@ -2586,11 +2470,10 @@ const MgInputSelect = class {
|
|
|
2586
2470
|
}
|
|
2587
2471
|
/**
|
|
2588
2472
|
* Render
|
|
2589
|
-
*
|
|
2590
|
-
* @returns {HTMLElement} HTML Element
|
|
2473
|
+
* @returns HTML Element
|
|
2591
2474
|
*/
|
|
2592
2475
|
render() {
|
|
2593
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2476
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: undefined, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2594
2477
|
if (el !== null)
|
|
2595
2478
|
this.input = el;
|
|
2596
2479
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -2625,8 +2508,6 @@ const MgInputText = class {
|
|
|
2625
2508
|
this.hasDisplayedError = false;
|
|
2626
2509
|
/**
|
|
2627
2510
|
* Handle input event
|
|
2628
|
-
*
|
|
2629
|
-
* @returns {void}
|
|
2630
2511
|
*/
|
|
2631
2512
|
this.handleInput = () => {
|
|
2632
2513
|
this.checkValidity();
|
|
@@ -2637,29 +2518,23 @@ const MgInputText = class {
|
|
|
2637
2518
|
};
|
|
2638
2519
|
/**
|
|
2639
2520
|
* Handle focus event
|
|
2640
|
-
*
|
|
2641
|
-
* @returns {void}
|
|
2642
2521
|
*/
|
|
2643
2522
|
this.handleFocus = () => {
|
|
2644
|
-
this.
|
|
2645
|
-
this.
|
|
2523
|
+
this.classCollection.add(this.classFocus);
|
|
2524
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2646
2525
|
};
|
|
2647
2526
|
/**
|
|
2648
2527
|
* Handle blur event
|
|
2649
|
-
*
|
|
2650
|
-
* @returns {void}
|
|
2651
2528
|
*/
|
|
2652
2529
|
this.handleBlur = () => {
|
|
2653
2530
|
// Manage focus
|
|
2654
|
-
this.
|
|
2655
|
-
this.
|
|
2531
|
+
this.classCollection.delete(this.classFocus);
|
|
2532
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2656
2533
|
// Display Error
|
|
2657
2534
|
this.displayError();
|
|
2658
2535
|
};
|
|
2659
2536
|
/**
|
|
2660
2537
|
* Check if input is valid
|
|
2661
|
-
*
|
|
2662
|
-
* @returns {void}
|
|
2663
2538
|
*/
|
|
2664
2539
|
this.checkValidity = () => {
|
|
2665
2540
|
var _a;
|
|
@@ -2670,8 +2545,6 @@ const MgInputText = class {
|
|
|
2670
2545
|
};
|
|
2671
2546
|
/**
|
|
2672
2547
|
* Set input error message
|
|
2673
|
-
*
|
|
2674
|
-
* @returns {void}
|
|
2675
2548
|
*/
|
|
2676
2549
|
this.setErrorMessage = () => {
|
|
2677
2550
|
// Set error message
|
|
@@ -2687,11 +2560,9 @@ const MgInputText = class {
|
|
|
2687
2560
|
};
|
|
2688
2561
|
/**
|
|
2689
2562
|
* Validate pattern configuration
|
|
2690
|
-
*
|
|
2691
|
-
* @returns {void}
|
|
2692
2563
|
*/
|
|
2693
2564
|
this.validatePattern = () => {
|
|
2694
|
-
if (this.pattern &&
|
|
2565
|
+
if (this.pattern !== undefined &&
|
|
2695
2566
|
typeof this.pattern === 'string' &&
|
|
2696
2567
|
this.pattern !== '' &&
|
|
2697
2568
|
(this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
|
|
@@ -2700,17 +2571,15 @@ const MgInputText = class {
|
|
|
2700
2571
|
};
|
|
2701
2572
|
/**
|
|
2702
2573
|
* Validate append slot
|
|
2703
|
-
*
|
|
2704
|
-
* @returns {void}
|
|
2705
2574
|
*/
|
|
2706
2575
|
this.validateAppendSlot = () => {
|
|
2707
2576
|
const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
|
|
2708
2577
|
if (slotAppendInput.length === 1) {
|
|
2709
|
-
this.
|
|
2578
|
+
this.classCollection.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.classIsInputGroupAppend : 'mg-input--is-append-input-slot-content');
|
|
2710
2579
|
}
|
|
2711
2580
|
else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
|
|
2712
|
-
this.
|
|
2713
|
-
this.
|
|
2581
|
+
this.classCollection.add(this.classIsInputGroupAppend);
|
|
2582
|
+
this.classCollection.add('mg-input--has-buttons-group-append');
|
|
2714
2583
|
}
|
|
2715
2584
|
};
|
|
2716
2585
|
this.value = undefined;
|
|
@@ -2734,7 +2603,7 @@ const MgInputText = class {
|
|
|
2734
2603
|
this.helpText = undefined;
|
|
2735
2604
|
this.valid = undefined;
|
|
2736
2605
|
this.invalid = undefined;
|
|
2737
|
-
this.
|
|
2606
|
+
this.classCollection = new ClassList(['mg-input--text']);
|
|
2738
2607
|
this.errorMessage = undefined;
|
|
2739
2608
|
}
|
|
2740
2609
|
handleValue(newValue) {
|
|
@@ -2742,10 +2611,10 @@ const MgInputText = class {
|
|
|
2742
2611
|
}
|
|
2743
2612
|
validateIcon(newValue) {
|
|
2744
2613
|
if (newValue !== undefined) {
|
|
2745
|
-
this.
|
|
2614
|
+
this.classCollection.add(this.classHasIcon);
|
|
2746
2615
|
}
|
|
2747
2616
|
else {
|
|
2748
|
-
this.
|
|
2617
|
+
this.classCollection.delete(this.classHasIcon);
|
|
2749
2618
|
}
|
|
2750
2619
|
}
|
|
2751
2620
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -2760,16 +2629,12 @@ const MgInputText = class {
|
|
|
2760
2629
|
}
|
|
2761
2630
|
/**
|
|
2762
2631
|
* Public method to play input focus
|
|
2763
|
-
*
|
|
2764
|
-
* @returns {Promise<void>}
|
|
2765
2632
|
*/
|
|
2766
2633
|
async setFocus() {
|
|
2767
2634
|
this.input.focus();
|
|
2768
2635
|
}
|
|
2769
2636
|
/**
|
|
2770
2637
|
* Public method to display errors
|
|
2771
|
-
*
|
|
2772
|
-
* @returns {Promise<void>}
|
|
2773
2638
|
*/
|
|
2774
2639
|
async displayError() {
|
|
2775
2640
|
this.checkValidity();
|
|
@@ -2781,8 +2646,7 @@ const MgInputText = class {
|
|
|
2781
2646
|
*************/
|
|
2782
2647
|
/**
|
|
2783
2648
|
* Check if component props are well configured on init
|
|
2784
|
-
*
|
|
2785
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2649
|
+
* @returns timeout
|
|
2786
2650
|
*/
|
|
2787
2651
|
componentWillLoad() {
|
|
2788
2652
|
// Get locales
|
|
@@ -2801,11 +2665,10 @@ const MgInputText = class {
|
|
|
2801
2665
|
}
|
|
2802
2666
|
/**
|
|
2803
2667
|
* Render
|
|
2804
|
-
*
|
|
2805
|
-
* @returns {HTMLElement} HTML Element
|
|
2668
|
+
* @returns HTML Element
|
|
2806
2669
|
*/
|
|
2807
2670
|
render() {
|
|
2808
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2671
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("div", { class: "mg-input__with-character-left", style: {
|
|
2809
2672
|
'--mg-character-left-message-length': (this.displayCharacterLeft
|
|
2810
2673
|
? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
|
|
2811
2674
|
: 0).toString(),
|
|
@@ -2854,24 +2717,23 @@ const MgInputTextarea = class {
|
|
|
2854
2717
|
* Handle focus event
|
|
2855
2718
|
*/
|
|
2856
2719
|
this.handleFocus = () => {
|
|
2857
|
-
this.
|
|
2858
|
-
this.
|
|
2720
|
+
this.classCollection.add(this.classFocus);
|
|
2721
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2859
2722
|
};
|
|
2860
2723
|
/**
|
|
2861
2724
|
* Handle blur event
|
|
2862
2725
|
*/
|
|
2863
2726
|
this.handleBlur = () => {
|
|
2864
2727
|
// Manage focus
|
|
2865
|
-
this.
|
|
2866
|
-
this.
|
|
2728
|
+
this.classCollection.delete(this.classFocus);
|
|
2729
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2867
2730
|
// Display Error
|
|
2868
2731
|
this.displayError();
|
|
2869
2732
|
};
|
|
2870
2733
|
/**
|
|
2871
2734
|
* Get pattern validity
|
|
2872
2735
|
* Pattern is not defined on textarea field: https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
|
|
2873
|
-
*
|
|
2874
|
-
* @returns {boolean} is pattern valid
|
|
2736
|
+
* @returns is pattern valid
|
|
2875
2737
|
*/
|
|
2876
2738
|
this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
|
|
2877
2739
|
/**
|
|
@@ -2903,7 +2765,7 @@ const MgInputTextarea = class {
|
|
|
2903
2765
|
* Validate pattern configuration
|
|
2904
2766
|
*/
|
|
2905
2767
|
this.validatePattern = () => {
|
|
2906
|
-
if (this.pattern &&
|
|
2768
|
+
if (this.pattern !== undefined &&
|
|
2907
2769
|
typeof this.pattern === 'string' &&
|
|
2908
2770
|
this.pattern !== '' &&
|
|
2909
2771
|
(this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
|
|
@@ -2931,7 +2793,7 @@ const MgInputTextarea = class {
|
|
|
2931
2793
|
this.valid = undefined;
|
|
2932
2794
|
this.invalid = undefined;
|
|
2933
2795
|
this.resizable = 'none';
|
|
2934
|
-
this.
|
|
2796
|
+
this.classCollection = new ClassList(['mg-input--textarea']);
|
|
2935
2797
|
this.errorMessage = undefined;
|
|
2936
2798
|
}
|
|
2937
2799
|
handleValue(newValue) {
|
|
@@ -2950,16 +2812,14 @@ const MgInputTextarea = class {
|
|
|
2950
2812
|
}
|
|
2951
2813
|
validateDisplayCharacterLeft(newValue) {
|
|
2952
2814
|
if (newValue) {
|
|
2953
|
-
this.
|
|
2815
|
+
this.classCollection.add(this.classHasDisplayCharacterLeft);
|
|
2954
2816
|
}
|
|
2955
2817
|
else {
|
|
2956
|
-
this.
|
|
2818
|
+
this.classCollection.delete(this.classHasDisplayCharacterLeft);
|
|
2957
2819
|
}
|
|
2958
2820
|
}
|
|
2959
2821
|
/**
|
|
2960
2822
|
* Public method to display errors
|
|
2961
|
-
*
|
|
2962
|
-
* @returns {Promise<void>}
|
|
2963
2823
|
*/
|
|
2964
2824
|
async displayError() {
|
|
2965
2825
|
this.checkValidity();
|
|
@@ -2971,8 +2831,7 @@ const MgInputTextarea = class {
|
|
|
2971
2831
|
*************/
|
|
2972
2832
|
/**
|
|
2973
2833
|
* Check if component props are well configured on init
|
|
2974
|
-
*
|
|
2975
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2834
|
+
* @returns timeout
|
|
2976
2835
|
*/
|
|
2977
2836
|
componentWillLoad() {
|
|
2978
2837
|
// Get locales
|
|
@@ -2990,11 +2849,10 @@ const MgInputTextarea = class {
|
|
|
2990
2849
|
}
|
|
2991
2850
|
/**
|
|
2992
2851
|
* Render
|
|
2993
|
-
*
|
|
2994
|
-
* @returns {HTMLElement} HTML Element
|
|
2852
|
+
* @returns HTML Element
|
|
2995
2853
|
*/
|
|
2996
2854
|
render() {
|
|
2997
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2855
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("div", { class: "mg-input__with-character-left" }, h("textarea", { class: {
|
|
2998
2856
|
'mg-input__box': true,
|
|
2999
2857
|
'mg-input__box--resizable': this.resizable === 'both',
|
|
3000
2858
|
'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
@@ -3038,8 +2896,6 @@ const MgInputTitle = class {
|
|
|
3038
2896
|
*************/
|
|
3039
2897
|
/**
|
|
3040
2898
|
* Init tag name
|
|
3041
|
-
*
|
|
3042
|
-
* @returns {void}
|
|
3043
2899
|
*/
|
|
3044
2900
|
componentWillLoad() {
|
|
3045
2901
|
this.validateIdentifier(this.identifier);
|
|
@@ -3047,8 +2903,7 @@ const MgInputTitle = class {
|
|
|
3047
2903
|
}
|
|
3048
2904
|
/**
|
|
3049
2905
|
* Render
|
|
3050
|
-
*
|
|
3051
|
-
* @returns {HTMLElement} HTML Element
|
|
2906
|
+
* @returns HTML element
|
|
3052
2907
|
*/
|
|
3053
2908
|
render() {
|
|
3054
2909
|
const TagName = this.tagName;
|
|
@@ -3065,9 +2920,8 @@ const mgInputToggleCss = ":host{display:block}.mg-input{display:flex;align-items
|
|
|
3065
2920
|
|
|
3066
2921
|
/**
|
|
3067
2922
|
* type Option validation function
|
|
3068
|
-
*
|
|
3069
|
-
* @
|
|
3070
|
-
* @returns {boolean} toggle option type is valid
|
|
2923
|
+
* @param option - radio option
|
|
2924
|
+
* @returns toggle option type is valid
|
|
3071
2925
|
*/
|
|
3072
2926
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
3073
2927
|
const MgInputToggle = class {
|
|
@@ -3086,16 +2940,12 @@ const MgInputToggle = class {
|
|
|
3086
2940
|
this.classIcon = 'mg-input--toggle-icon';
|
|
3087
2941
|
/**
|
|
3088
2942
|
* Change checked value
|
|
3089
|
-
*
|
|
3090
|
-
* @returns {void}
|
|
3091
2943
|
*/
|
|
3092
2944
|
this.toggleChecked = () => {
|
|
3093
2945
|
this.checked = !this.checked;
|
|
3094
2946
|
};
|
|
3095
2947
|
/**
|
|
3096
2948
|
* Slots validation
|
|
3097
|
-
*
|
|
3098
|
-
* @returns {void}
|
|
3099
2949
|
*/
|
|
3100
2950
|
this.validateSlots = () => {
|
|
3101
2951
|
const slots = Array.from(this.element.children);
|
|
@@ -3121,7 +2971,7 @@ const MgInputToggle = class {
|
|
|
3121
2971
|
this.disabled = false;
|
|
3122
2972
|
this.tooltip = undefined;
|
|
3123
2973
|
this.helpText = undefined;
|
|
3124
|
-
this.
|
|
2974
|
+
this.classCollection = new ClassList(['mg-input--toggle']);
|
|
3125
2975
|
this.options = undefined;
|
|
3126
2976
|
this.checked = false;
|
|
3127
2977
|
}
|
|
@@ -3149,41 +2999,39 @@ const MgInputToggle = class {
|
|
|
3149
2999
|
}
|
|
3150
3000
|
handleIsOnOff(newValue) {
|
|
3151
3001
|
if (newValue)
|
|
3152
|
-
this.
|
|
3002
|
+
this.classCollection.add(this.classOnOff);
|
|
3153
3003
|
else
|
|
3154
|
-
this.
|
|
3004
|
+
this.classCollection.delete(this.classOnOff);
|
|
3155
3005
|
}
|
|
3156
3006
|
handleIsIcon(newValue) {
|
|
3157
3007
|
if (newValue)
|
|
3158
|
-
this.
|
|
3008
|
+
this.classCollection.add(this.classIcon);
|
|
3159
3009
|
else
|
|
3160
|
-
this.
|
|
3010
|
+
this.classCollection.delete(this.classIcon);
|
|
3161
3011
|
}
|
|
3162
3012
|
handleReadonly(newValue) {
|
|
3163
3013
|
if (newValue)
|
|
3164
|
-
this.
|
|
3014
|
+
this.classCollection.add(this.classReadonly);
|
|
3165
3015
|
else
|
|
3166
|
-
this.
|
|
3016
|
+
this.classCollection.delete(this.classReadonly);
|
|
3167
3017
|
}
|
|
3168
3018
|
handleDisabled(newValue) {
|
|
3169
3019
|
if (newValue)
|
|
3170
|
-
this.
|
|
3020
|
+
this.classCollection.add(this.classDisabled);
|
|
3171
3021
|
else
|
|
3172
|
-
this.
|
|
3022
|
+
this.classCollection.delete(this.classDisabled);
|
|
3173
3023
|
}
|
|
3174
3024
|
handleChecked(newValue) {
|
|
3175
3025
|
// style
|
|
3176
3026
|
if (newValue)
|
|
3177
|
-
this.
|
|
3027
|
+
this.classCollection.add(this.classIsActive);
|
|
3178
3028
|
else
|
|
3179
|
-
this.
|
|
3029
|
+
this.classCollection.delete(this.classIsActive);
|
|
3180
3030
|
// update value
|
|
3181
3031
|
this.value = this.options[newValue ? 1 : 0].value;
|
|
3182
3032
|
}
|
|
3183
3033
|
/**
|
|
3184
3034
|
* set checked state
|
|
3185
|
-
*
|
|
3186
|
-
* @returns {void}
|
|
3187
3035
|
*/
|
|
3188
3036
|
setChecked() {
|
|
3189
3037
|
const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);
|
|
@@ -3225,11 +3073,10 @@ const MgInputToggle = class {
|
|
|
3225
3073
|
}
|
|
3226
3074
|
/**
|
|
3227
3075
|
* Render
|
|
3228
|
-
*
|
|
3229
|
-
* @returns {HTMLElement} HTML Element
|
|
3076
|
+
* @returns HTML Element
|
|
3230
3077
|
*/
|
|
3231
3078
|
render() {
|
|
3232
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
3079
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-2" })))));
|
|
3233
3080
|
}
|
|
3234
3081
|
get element() { return getElement(this); }
|
|
3235
3082
|
static get watchers() { return {
|
|
@@ -3260,10 +3107,8 @@ const MgMenu = class {
|
|
|
3260
3107
|
*************/
|
|
3261
3108
|
/**
|
|
3262
3109
|
* Close matching menu-item
|
|
3263
|
-
*
|
|
3264
|
-
* @param
|
|
3265
|
-
* @param {boolean} condition addionnal condition
|
|
3266
|
-
* @returns {void}
|
|
3110
|
+
* @param item - menu-item to close
|
|
3111
|
+
* @param condition - addionnal condition
|
|
3267
3112
|
*/
|
|
3268
3113
|
this.closeMenuItem = (item, condition) => {
|
|
3269
3114
|
if (!this.isChildMenu && condition) {
|
|
@@ -3272,22 +3117,18 @@ const MgMenu = class {
|
|
|
3272
3117
|
};
|
|
3273
3118
|
/**
|
|
3274
3119
|
* get mg-item-more element
|
|
3275
|
-
*
|
|
3276
|
-
* @returns {HTMLMgItemMoreElement} mg-item-more element
|
|
3120
|
+
* @returns mg-item-more element
|
|
3277
3121
|
*/
|
|
3278
3122
|
this.getItemMore = () => this.element.querySelector('mg-item-more');
|
|
3279
3123
|
/**
|
|
3280
|
-
* get mg-item-more
|
|
3281
|
-
*
|
|
3282
|
-
* @returns {HTMLMgMenuItemElement} mg-item-more >>> mg-menu-item element
|
|
3124
|
+
* get mg-item-more child mg-menu-item element
|
|
3125
|
+
* @returns mg-menu-item element
|
|
3283
3126
|
*/
|
|
3284
3127
|
this.getItemMoreMenuItem = () => { var _a, _b; return (_b = (_a = this.getItemMore()) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mg-menu-item'); };
|
|
3285
3128
|
/**
|
|
3286
3129
|
* Set item listend
|
|
3287
|
-
*
|
|
3288
|
-
* @param
|
|
3289
|
-
* @param {MgMenu['focusedMenuItem']} index number
|
|
3290
|
-
* @returns {void}
|
|
3130
|
+
* @param item - mg-menu-item element
|
|
3131
|
+
* @param index - number
|
|
3291
3132
|
*/
|
|
3292
3133
|
this.setItemListener = (item, index) => {
|
|
3293
3134
|
['click', 'focus'].forEach(trigger => {
|
|
@@ -3302,8 +3143,6 @@ const MgMenu = class {
|
|
|
3302
3143
|
};
|
|
3303
3144
|
/**
|
|
3304
3145
|
* Store menu-items on component init and add listeners
|
|
3305
|
-
*
|
|
3306
|
-
* @returns {void}
|
|
3307
3146
|
*/
|
|
3308
3147
|
this.initMenuItemsListeners = () => {
|
|
3309
3148
|
// add listeners on menu item and edit index
|
|
@@ -3313,16 +3152,12 @@ const MgMenu = class {
|
|
|
3313
3152
|
};
|
|
3314
3153
|
/**
|
|
3315
3154
|
* Handle item-loaded event on mg-item-more element
|
|
3316
|
-
*
|
|
3317
|
-
* @returns {void}
|
|
3318
3155
|
*/
|
|
3319
3156
|
this.handleItemLoaded = () => {
|
|
3320
3157
|
this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);
|
|
3321
3158
|
};
|
|
3322
3159
|
/**
|
|
3323
3160
|
* render mg-item-more
|
|
3324
|
-
*
|
|
3325
|
-
* @returns {void}
|
|
3326
3161
|
*/
|
|
3327
3162
|
this.renderMgItemMore = () => {
|
|
3328
3163
|
// /!\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement
|
|
@@ -3364,8 +3199,6 @@ const MgMenu = class {
|
|
|
3364
3199
|
*************/
|
|
3365
3200
|
/**
|
|
3366
3201
|
* Validate props
|
|
3367
|
-
*
|
|
3368
|
-
* @returns {void}
|
|
3369
3202
|
*/
|
|
3370
3203
|
componentWillLoad() {
|
|
3371
3204
|
this.validateDirection(this.direction);
|
|
@@ -3375,8 +3208,7 @@ const MgMenu = class {
|
|
|
3375
3208
|
}
|
|
3376
3209
|
/**
|
|
3377
3210
|
* Check if component slots configuration
|
|
3378
|
-
*
|
|
3379
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
3211
|
+
* @returns timeout
|
|
3380
3212
|
*/
|
|
3381
3213
|
componentDidLoad() {
|
|
3382
3214
|
// update props and states after componentDidLoad hook
|
|
@@ -3406,16 +3238,13 @@ const MgMenu = class {
|
|
|
3406
3238
|
}
|
|
3407
3239
|
/**
|
|
3408
3240
|
* Add listeners to items
|
|
3409
|
-
*
|
|
3410
|
-
* @returns {void}
|
|
3411
3241
|
*/
|
|
3412
3242
|
componentDidRender() {
|
|
3413
3243
|
this.initMenuItemsListeners();
|
|
3414
3244
|
}
|
|
3415
3245
|
/**
|
|
3416
3246
|
* Render
|
|
3417
|
-
*
|
|
3418
|
-
* @returns {HTMLElement} HTML Element
|
|
3247
|
+
* @returns HTML Element
|
|
3419
3248
|
*/
|
|
3420
3249
|
render() {
|
|
3421
3250
|
return (h(Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, h("slot", null)));
|
|
@@ -3447,33 +3276,27 @@ const MgMenuItem = class {
|
|
|
3447
3276
|
**********/
|
|
3448
3277
|
/**
|
|
3449
3278
|
* Toggle expanded prop value
|
|
3450
|
-
*
|
|
3451
|
-
* @returns {void}
|
|
3452
3279
|
*/
|
|
3453
3280
|
this.toggleExpanded = () => {
|
|
3454
3281
|
this.expanded = !this.expanded;
|
|
3455
3282
|
};
|
|
3456
3283
|
/**
|
|
3457
3284
|
* Does an Element have given Status
|
|
3458
|
-
*
|
|
3459
|
-
* @param
|
|
3460
|
-
* @
|
|
3461
|
-
* @returns {boolean} true if element with status is found
|
|
3285
|
+
* @param mgMenuItemElement - to parse
|
|
3286
|
+
* @param status - to check
|
|
3287
|
+
* @returns true if element with status is found
|
|
3462
3288
|
*/
|
|
3463
3289
|
this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
|
|
3464
3290
|
/**
|
|
3465
3291
|
* Is component contextual direction match the given direction
|
|
3466
|
-
*
|
|
3467
|
-
* @param
|
|
3468
|
-
* @
|
|
3469
|
-
* @returns {boolean} true is direction match the direction propertie
|
|
3292
|
+
* @param direction - in parent menu
|
|
3293
|
+
* @param compareWith - direction to compare with. Default: `this.direction`
|
|
3294
|
+
* @returns true is direction match the direction propertie
|
|
3470
3295
|
*/
|
|
3471
3296
|
this.isDirection = (direction, compareWith = this.direction) => direction === compareWith;
|
|
3472
3297
|
/**
|
|
3473
3298
|
* Update displayNotificationBadge
|
|
3474
3299
|
* current component notification badge have priority over the slot badge when submenu contain badge
|
|
3475
|
-
*
|
|
3476
|
-
* @returns {void} update displayNotificationBadge value
|
|
3477
3300
|
*/
|
|
3478
3301
|
this.updateDisplayNotificationBadge = () => {
|
|
3479
3302
|
const childMenu = this.element.querySelector('mg-menu');
|
|
@@ -3483,8 +3306,7 @@ const MgMenuItem = class {
|
|
|
3483
3306
|
};
|
|
3484
3307
|
/**
|
|
3485
3308
|
* Method to control if one of component children have active status
|
|
3486
|
-
*
|
|
3487
|
-
* @returns {boolean} truthy if component has active child
|
|
3309
|
+
* @returns truthy if component has active child
|
|
3488
3310
|
*/
|
|
3489
3311
|
this.hasActiveChild = () => {
|
|
3490
3312
|
var _a;
|
|
@@ -3492,9 +3314,7 @@ const MgMenuItem = class {
|
|
|
3492
3314
|
};
|
|
3493
3315
|
/**
|
|
3494
3316
|
* Validate slots
|
|
3495
|
-
*
|
|
3496
|
-
* @param {boolean} guard prevent action whith guard. Default: false.
|
|
3497
|
-
* @returns {void}
|
|
3317
|
+
* @param guard - prevent action whith guard. Default: false.
|
|
3498
3318
|
*/
|
|
3499
3319
|
this.validateSlot = (guard = false) => {
|
|
3500
3320
|
// slot title AND metadata validation
|
|
@@ -3512,9 +3332,7 @@ const MgMenuItem = class {
|
|
|
3512
3332
|
};
|
|
3513
3333
|
/**
|
|
3514
3334
|
* Update status
|
|
3515
|
-
*
|
|
3516
|
-
* @param {Status[]} guard status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
3517
|
-
* @returns {void}
|
|
3335
|
+
* @param guard - status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
3518
3336
|
*/
|
|
3519
3337
|
this.updateStatus = (guard = []) => {
|
|
3520
3338
|
if (![Status$1.HIDDEN, Status$1.DISABLED, ...guard].includes(this.status)) {
|
|
@@ -3523,8 +3341,6 @@ const MgMenuItem = class {
|
|
|
3523
3341
|
};
|
|
3524
3342
|
/**
|
|
3525
3343
|
* Init event-listeners
|
|
3526
|
-
*
|
|
3527
|
-
* @returns {void}
|
|
3528
3344
|
*/
|
|
3529
3345
|
this.initListeners = () => {
|
|
3530
3346
|
var _a;
|
|
@@ -3540,14 +3356,12 @@ const MgMenuItem = class {
|
|
|
3540
3356
|
};
|
|
3541
3357
|
/**
|
|
3542
3358
|
* Get mg-popover identifier
|
|
3543
|
-
*
|
|
3544
|
-
* @returns {MgPopover['identifier']} generated mg-popover identifier
|
|
3359
|
+
* @returns generated mg-popover identifier
|
|
3545
3360
|
*/
|
|
3546
3361
|
this.getPopoverIdentifier = () => `${this.identifier}-popover`;
|
|
3547
3362
|
/**
|
|
3548
3363
|
* Condition to know if component should display a mg-popover
|
|
3549
|
-
*
|
|
3550
|
-
* @returns {boolean} truthy if component display popover
|
|
3364
|
+
* @returns truthy if component display popover
|
|
3551
3365
|
*/
|
|
3552
3366
|
this.displayPopover = () => this.isDirection(Direction.HORIZONTAL) && this.hasChildren && this.href === undefined;
|
|
3553
3367
|
/************
|
|
@@ -3555,9 +3369,7 @@ const MgMenuItem = class {
|
|
|
3555
3369
|
************/
|
|
3556
3370
|
/**
|
|
3557
3371
|
* Handle interacrtive element click
|
|
3558
|
-
*
|
|
3559
|
-
* @param {MouseEvent} event click on element
|
|
3560
|
-
* @returns {void}
|
|
3372
|
+
* @param event - click on element
|
|
3561
3373
|
*/
|
|
3562
3374
|
this.handleElementCLick = (event) => {
|
|
3563
3375
|
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status$1.DISABLED) {
|
|
@@ -3570,17 +3382,14 @@ const MgMenuItem = class {
|
|
|
3570
3382
|
};
|
|
3571
3383
|
/**
|
|
3572
3384
|
* Handle popover element display-change event
|
|
3573
|
-
*
|
|
3574
|
-
* @param {CustomEvent} event popover display event
|
|
3575
|
-
* @returns {void}
|
|
3385
|
+
* @param event - popover display event
|
|
3576
3386
|
*/
|
|
3577
3387
|
this.handlePopoverDisplay = (event) => {
|
|
3578
3388
|
this.expanded = event.detail;
|
|
3579
3389
|
};
|
|
3580
3390
|
/**
|
|
3581
3391
|
* Render slot
|
|
3582
|
-
*
|
|
3583
|
-
* @returns {HTMLElement} HTML Element
|
|
3392
|
+
* @returns HTML Element
|
|
3584
3393
|
*/
|
|
3585
3394
|
this.renderSlot = () => h("slot", null);
|
|
3586
3395
|
this.identifier = createID('mg-menu-item');
|
|
@@ -3646,8 +3455,6 @@ const MgMenuItem = class {
|
|
|
3646
3455
|
}
|
|
3647
3456
|
/**
|
|
3648
3457
|
* Render popover clickoutside guard for content slot
|
|
3649
|
-
*
|
|
3650
|
-
* @returns {void}
|
|
3651
3458
|
*/
|
|
3652
3459
|
updatePopoverGuard() {
|
|
3653
3460
|
if (this.displayPopover())
|
|
@@ -3660,8 +3467,6 @@ const MgMenuItem = class {
|
|
|
3660
3467
|
*************/
|
|
3661
3468
|
/**
|
|
3662
3469
|
* Validate props
|
|
3663
|
-
*
|
|
3664
|
-
* @returns {void}
|
|
3665
3470
|
*/
|
|
3666
3471
|
componentWillLoad() {
|
|
3667
3472
|
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
@@ -3677,8 +3482,7 @@ const MgMenuItem = class {
|
|
|
3677
3482
|
}
|
|
3678
3483
|
/**
|
|
3679
3484
|
* Check if component slots configuration
|
|
3680
|
-
*
|
|
3681
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
3485
|
+
* @returns timeout
|
|
3682
3486
|
*/
|
|
3683
3487
|
componentDidLoad() {
|
|
3684
3488
|
// validation
|
|
@@ -3717,8 +3521,7 @@ const MgMenuItem = class {
|
|
|
3717
3521
|
}
|
|
3718
3522
|
/**
|
|
3719
3523
|
* Render ineractive element
|
|
3720
|
-
*
|
|
3721
|
-
* @returns {HTMLElement} HTML Element
|
|
3524
|
+
* @returns HTML Element
|
|
3722
3525
|
*/
|
|
3723
3526
|
renderInteractiveElement() {
|
|
3724
3527
|
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
@@ -3730,8 +3533,7 @@ const MgMenuItem = class {
|
|
|
3730
3533
|
}
|
|
3731
3534
|
/**
|
|
3732
3535
|
* Render
|
|
3733
|
-
*
|
|
3734
|
-
* @returns {HTMLElement} HTML Element
|
|
3536
|
+
* @returns HTML Element
|
|
3735
3537
|
*/
|
|
3736
3538
|
render() {
|
|
3737
3539
|
const getContainerClasses = () => ({
|
|
@@ -3780,25 +3582,19 @@ const MgMessage = class {
|
|
|
3780
3582
|
this.isHovered = false;
|
|
3781
3583
|
/**
|
|
3782
3584
|
* Set timer
|
|
3783
|
-
*
|
|
3784
|
-
* @returns {void}
|
|
3785
3585
|
*/
|
|
3786
3586
|
this.setTimer = () => {
|
|
3787
3587
|
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
3788
3588
|
};
|
|
3789
3589
|
/**
|
|
3790
3590
|
* Clear timer
|
|
3791
|
-
*
|
|
3792
|
-
* @returns {void}
|
|
3793
3591
|
*/
|
|
3794
3592
|
this.clearTimer = () => {
|
|
3795
3593
|
clearTimeout(this.storedTimer);
|
|
3796
3594
|
};
|
|
3797
3595
|
/**
|
|
3798
3596
|
* Event to add on element
|
|
3799
|
-
*
|
|
3800
|
-
* @param {MouseEvent | FocusEvent} event event
|
|
3801
|
-
* @returns {void}
|
|
3597
|
+
* @param event - event
|
|
3802
3598
|
*/
|
|
3803
3599
|
this.timerEvents = (event) => {
|
|
3804
3600
|
this.clearTimer();
|
|
@@ -3821,8 +3617,7 @@ const MgMessage = class {
|
|
|
3821
3617
|
};
|
|
3822
3618
|
/**
|
|
3823
3619
|
* Get icon corresponding to variant
|
|
3824
|
-
*
|
|
3825
|
-
* @returns {string} icon
|
|
3620
|
+
* @returns icon
|
|
3826
3621
|
*/
|
|
3827
3622
|
this.getIcon = () => {
|
|
3828
3623
|
switch (this.variant) {
|
|
@@ -3841,11 +3636,11 @@ const MgMessage = class {
|
|
|
3841
3636
|
this.variant = variants$1[0];
|
|
3842
3637
|
this.closeButton = false;
|
|
3843
3638
|
this.hide = false;
|
|
3844
|
-
this.
|
|
3639
|
+
this.classCollection = new ClassList(['mg-message']);
|
|
3845
3640
|
this.hasActions = false;
|
|
3846
3641
|
}
|
|
3847
3642
|
validateDelay(newValue) {
|
|
3848
|
-
if (newValue && newValue < 2) {
|
|
3643
|
+
if (newValue !== undefined && newValue < 2) {
|
|
3849
3644
|
throw new Error(`<mg-message> prop "delay" must be greater than 2 seconds.`);
|
|
3850
3645
|
}
|
|
3851
3646
|
}
|
|
@@ -3855,9 +3650,9 @@ const MgMessage = class {
|
|
|
3855
3650
|
}
|
|
3856
3651
|
else {
|
|
3857
3652
|
if (oldValue !== undefined) {
|
|
3858
|
-
this.
|
|
3653
|
+
this.classCollection.delete(`mg-message--${oldValue}`);
|
|
3859
3654
|
}
|
|
3860
|
-
this.
|
|
3655
|
+
this.classCollection.add(`mg-message--${newValue}`);
|
|
3861
3656
|
}
|
|
3862
3657
|
}
|
|
3863
3658
|
validateCloseButton(newValue) {
|
|
@@ -3869,7 +3664,7 @@ const MgMessage = class {
|
|
|
3869
3664
|
validateHide(newValue) {
|
|
3870
3665
|
if (newValue) {
|
|
3871
3666
|
this.componentHide.emit();
|
|
3872
|
-
this.
|
|
3667
|
+
this.classCollection.add(this.classHide);
|
|
3873
3668
|
// Remove event Listener
|
|
3874
3669
|
['focusin', 'mouseenter'].forEach(event => {
|
|
3875
3670
|
this.element.removeEventListener(event, this.timerEvents);
|
|
@@ -3879,7 +3674,7 @@ const MgMessage = class {
|
|
|
3879
3674
|
}
|
|
3880
3675
|
else {
|
|
3881
3676
|
this.componentShow.emit();
|
|
3882
|
-
this.
|
|
3677
|
+
this.classCollection.delete(this.classHide);
|
|
3883
3678
|
// If delay is set
|
|
3884
3679
|
if (this.delay > 1) {
|
|
3885
3680
|
// Start timer
|
|
@@ -3906,7 +3701,7 @@ const MgMessage = class {
|
|
|
3906
3701
|
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
3907
3702
|
this.validateCloseButton(this.closeButton);
|
|
3908
3703
|
if (this.closeButton) {
|
|
3909
|
-
this.
|
|
3704
|
+
this.classCollection.add('mg-message--close-button');
|
|
3910
3705
|
this.closeButtonId = `${this.identifier}-close-button`;
|
|
3911
3706
|
}
|
|
3912
3707
|
this.validateDelay(this.delay);
|
|
@@ -3914,11 +3709,10 @@ const MgMessage = class {
|
|
|
3914
3709
|
}
|
|
3915
3710
|
/**
|
|
3916
3711
|
* Render
|
|
3917
|
-
*
|
|
3918
|
-
* @returns {HTMLElement} HTML Element
|
|
3712
|
+
* @returns HTML Element
|
|
3919
3713
|
*/
|
|
3920
3714
|
render() {
|
|
3921
|
-
return (h("div", { id: this.identifier, class: this.
|
|
3715
|
+
return (h("div", { id: this.identifier, class: this.classCollection.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("mg-card", { variant: this.variant, "variant-style": "bar-left" }, h("span", { class: "mg-message__icon" }, h("mg-icon", { icon: this.getIcon() })), h("div", { class: "mg-message__content" }, h("span", { class: "mg-message__content-slot" }, h("slot", null)), this.hasActions && h("span", { class: "mg-message__content-separator" }), this.hasActions && (h("span", { class: "mg-message__content-actions-slot" }, h("slot", { name: "actions" })))), this.closeButton && (h("span", { class: "mg-message__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))))));
|
|
3922
3716
|
}
|
|
3923
3717
|
get element() { return getElement(this); }
|
|
3924
3718
|
static get watchers() { return {
|
|
@@ -3978,8 +3772,6 @@ const MgModal = class {
|
|
|
3978
3772
|
*************/
|
|
3979
3773
|
/**
|
|
3980
3774
|
* Handle close button
|
|
3981
|
-
*
|
|
3982
|
-
* @returns {void}
|
|
3983
3775
|
*/
|
|
3984
3776
|
this.handleClose = () => {
|
|
3985
3777
|
this.hide = true;
|
|
@@ -3990,7 +3782,7 @@ const MgModal = class {
|
|
|
3990
3782
|
this.hide = false;
|
|
3991
3783
|
this.hasActions = false;
|
|
3992
3784
|
this.hasContent = false;
|
|
3993
|
-
this.
|
|
3785
|
+
this.classCollection = new ClassList(['mg-modal']);
|
|
3994
3786
|
}
|
|
3995
3787
|
validateModalTitle(newValue) {
|
|
3996
3788
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -4000,20 +3792,18 @@ const MgModal = class {
|
|
|
4000
3792
|
validateHide(newValue) {
|
|
4001
3793
|
if (newValue) {
|
|
4002
3794
|
this.componentHide.emit();
|
|
4003
|
-
this.
|
|
3795
|
+
this.classCollection.add(this.classHide);
|
|
4004
3796
|
document.body.style.overflow = this.bodyOverflow;
|
|
4005
3797
|
}
|
|
4006
3798
|
else {
|
|
4007
3799
|
this.componentShow.emit();
|
|
4008
|
-
this.
|
|
3800
|
+
this.classCollection.delete(this.classHide);
|
|
4009
3801
|
document.body.style.overflow = 'hidden';
|
|
4010
3802
|
}
|
|
4011
3803
|
}
|
|
4012
3804
|
/**
|
|
4013
3805
|
* Handle 'escape' key down
|
|
4014
|
-
*
|
|
4015
|
-
* @param {KeyboardEvent} event keydown event
|
|
4016
|
-
* @returns {void}
|
|
3806
|
+
* @param event - keydown event
|
|
4017
3807
|
*/
|
|
4018
3808
|
handleKeyDown(event) {
|
|
4019
3809
|
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
@@ -4026,8 +3816,6 @@ const MgModal = class {
|
|
|
4026
3816
|
*************/
|
|
4027
3817
|
/**
|
|
4028
3818
|
* Check if component props are well configured on init
|
|
4029
|
-
*
|
|
4030
|
-
* @returns {void}
|
|
4031
3819
|
*/
|
|
4032
3820
|
componentWillLoad() {
|
|
4033
3821
|
// Store body overflow
|
|
@@ -4046,8 +3834,6 @@ const MgModal = class {
|
|
|
4046
3834
|
}
|
|
4047
3835
|
/**
|
|
4048
3836
|
* Add observer on component to set focus when displayed
|
|
4049
|
-
*
|
|
4050
|
-
* @returns {void}
|
|
4051
3837
|
*/
|
|
4052
3838
|
componentDidLoad() {
|
|
4053
3839
|
new MutationObserver(mutationList => {
|
|
@@ -4062,11 +3848,10 @@ const MgModal = class {
|
|
|
4062
3848
|
}
|
|
4063
3849
|
/**
|
|
4064
3850
|
* Render
|
|
4065
|
-
*
|
|
4066
|
-
* @returns {HTMLElement} HTML Element
|
|
3851
|
+
* @returns HTML Element
|
|
4067
3852
|
*/
|
|
4068
3853
|
render() {
|
|
4069
|
-
return (h("div", { role: "alertdialog", id: this.identifier, class: this.
|
|
3854
|
+
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" })))))));
|
|
4070
3855
|
}
|
|
4071
3856
|
get element() { return getElement(this); }
|
|
4072
3857
|
static get watchers() { return {
|
|
@@ -4087,6 +3872,7 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
4087
3872
|
/**
|
|
4088
3873
|
* Range generator
|
|
4089
3874
|
*
|
|
3875
|
+
* ```
|
|
4090
3876
|
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
4091
3877
|
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
4092
3878
|
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
@@ -4094,15 +3880,15 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
4094
3880
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
4095
3881
|
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
4096
3882
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
3883
|
+
* ```
|
|
4097
3884
|
*
|
|
4098
3885
|
* range(1, 1) = [1]
|
|
4099
3886
|
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
4100
3887
|
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
4101
|
-
*
|
|
4102
|
-
* @param
|
|
4103
|
-
* @param
|
|
4104
|
-
* @
|
|
4105
|
-
* @returns {number[]} range numbers
|
|
3888
|
+
* @param start - start range
|
|
3889
|
+
* @param end - start end
|
|
3890
|
+
* @param step - step size
|
|
3891
|
+
* @returns range numbers
|
|
4106
3892
|
*/
|
|
4107
3893
|
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
4108
3894
|
const MgPagination = class {
|
|
@@ -4111,9 +3897,7 @@ const MgPagination = class {
|
|
|
4111
3897
|
this.currentPageChange = createEvent(this, "current-page-change", 7);
|
|
4112
3898
|
/**
|
|
4113
3899
|
* Change current page from target
|
|
4114
|
-
*
|
|
4115
|
-
* @param {number} target target page
|
|
4116
|
-
* @returns {void}
|
|
3900
|
+
* @param target - target page
|
|
4117
3901
|
*/
|
|
4118
3902
|
this.goToPage = (target) => {
|
|
4119
3903
|
this.currentPage = target;
|
|
@@ -4123,9 +3907,7 @@ const MgPagination = class {
|
|
|
4123
3907
|
************/
|
|
4124
3908
|
/**
|
|
4125
3909
|
* select handler
|
|
4126
|
-
*
|
|
4127
|
-
* @param {InputEvent} event value change event
|
|
4128
|
-
* @returns {void}
|
|
3910
|
+
* @param event - value change event
|
|
4129
3911
|
*/
|
|
4130
3912
|
this.handleSelect = (event) => {
|
|
4131
3913
|
const to = Number(event.target.value);
|
|
@@ -4133,10 +3915,8 @@ const MgPagination = class {
|
|
|
4133
3915
|
};
|
|
4134
3916
|
/**
|
|
4135
3917
|
* Go to 'previous/next' page button handler
|
|
4136
|
-
*
|
|
4137
|
-
* @param
|
|
4138
|
-
* @param {boolean} disabled button disable state
|
|
4139
|
-
* @returns {void}
|
|
3918
|
+
* @param action - navigation action
|
|
3919
|
+
* @param disabled - button disable state
|
|
4140
3920
|
*/
|
|
4141
3921
|
this.handleGoToPage = (action, disabled) => {
|
|
4142
3922
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
@@ -4166,8 +3946,6 @@ const MgPagination = class {
|
|
|
4166
3946
|
*************/
|
|
4167
3947
|
/**
|
|
4168
3948
|
* Check if props are well configured on init
|
|
4169
|
-
*
|
|
4170
|
-
* @returns {void}
|
|
4171
3949
|
*/
|
|
4172
3950
|
componentWillLoad() {
|
|
4173
3951
|
// Get locales
|
|
@@ -4182,8 +3960,7 @@ const MgPagination = class {
|
|
|
4182
3960
|
}
|
|
4183
3961
|
/**
|
|
4184
3962
|
* Render
|
|
4185
|
-
*
|
|
4186
|
-
* @returns {HTMLElement} HTML Element
|
|
3963
|
+
* @returns HTML Element
|
|
4187
3964
|
*/
|
|
4188
3965
|
render() {
|
|
4189
3966
|
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
|
|
@@ -4211,8 +3988,6 @@ const MgPanel = class {
|
|
|
4211
3988
|
************/
|
|
4212
3989
|
/**
|
|
4213
3990
|
* Toggle is editing state
|
|
4214
|
-
*
|
|
4215
|
-
* @returns {void}
|
|
4216
3991
|
*/
|
|
4217
3992
|
this.toggleIsEditing = () => {
|
|
4218
3993
|
this.isEditing = !this.isEditing;
|
|
@@ -4222,8 +3997,6 @@ const MgPanel = class {
|
|
|
4222
3997
|
************/
|
|
4223
3998
|
/**
|
|
4224
3999
|
* Collapse button click handler
|
|
4225
|
-
*
|
|
4226
|
-
* @returns {void}
|
|
4227
4000
|
*/
|
|
4228
4001
|
this.handleCollapseButton = () => {
|
|
4229
4002
|
if (!this.expandToggleDisabled) {
|
|
@@ -4232,25 +4005,19 @@ const MgPanel = class {
|
|
|
4232
4005
|
};
|
|
4233
4006
|
/**
|
|
4234
4007
|
* Edit button click handler
|
|
4235
|
-
*
|
|
4236
|
-
* @returns {void}
|
|
4237
4008
|
*/
|
|
4238
4009
|
this.handleEditButton = () => {
|
|
4239
4010
|
this.toggleIsEditing();
|
|
4240
4011
|
};
|
|
4241
4012
|
/**
|
|
4242
4013
|
* Update title handler
|
|
4243
|
-
*
|
|
4244
|
-
* @param {CustomEvent<string>} event input value change event
|
|
4245
|
-
* @returns {void}
|
|
4014
|
+
* @param event - input value change event
|
|
4246
4015
|
*/
|
|
4247
4016
|
this.handleUpdateTitle = (event) => {
|
|
4248
4017
|
this.updatedPanelTitle = event.detail;
|
|
4249
4018
|
};
|
|
4250
4019
|
/**
|
|
4251
4020
|
* Cancel edition button handler
|
|
4252
|
-
*
|
|
4253
|
-
* @returns {void}
|
|
4254
4021
|
*/
|
|
4255
4022
|
this.handleCancelEditButton = () => {
|
|
4256
4023
|
this.updatedPanelTitle = undefined;
|
|
@@ -4258,8 +4025,6 @@ const MgPanel = class {
|
|
|
4258
4025
|
};
|
|
4259
4026
|
/**
|
|
4260
4027
|
* Validate edition button handler
|
|
4261
|
-
*
|
|
4262
|
-
* @returns {void}
|
|
4263
4028
|
*/
|
|
4264
4029
|
this.handleValidateEditButton = () => {
|
|
4265
4030
|
if (this.editInputElement.valid) {
|
|
@@ -4270,9 +4035,7 @@ const MgPanel = class {
|
|
|
4270
4035
|
};
|
|
4271
4036
|
/**
|
|
4272
4037
|
* Header left conditional render
|
|
4273
|
-
*
|
|
4274
|
-
* @typedef {HTMLElement} HTMLMgButtonElement
|
|
4275
|
-
* @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
|
|
4038
|
+
* @returns header left element
|
|
4276
4039
|
*/
|
|
4277
4040
|
this.headerLeft = () => {
|
|
4278
4041
|
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)));
|
|
@@ -4297,7 +4060,7 @@ const MgPanel = class {
|
|
|
4297
4060
|
this.expanded = false;
|
|
4298
4061
|
this.expandToggleDisabled = undefined;
|
|
4299
4062
|
this.titleEditable = false;
|
|
4300
|
-
this.
|
|
4063
|
+
this.classCollection = new ClassList(['mg-panel']);
|
|
4301
4064
|
this.isEditing = false;
|
|
4302
4065
|
this.updatedPanelTitle = undefined;
|
|
4303
4066
|
}
|
|
@@ -4308,10 +4071,10 @@ const MgPanel = class {
|
|
|
4308
4071
|
this.titleChange.emit(newValue);
|
|
4309
4072
|
}
|
|
4310
4073
|
validatetitlePattern(newValue) {
|
|
4311
|
-
if (newValue && !this.titleEditable) {
|
|
4074
|
+
if (newValue !== undefined && !this.titleEditable) {
|
|
4312
4075
|
throw new Error('<mg-panel> prop "titleEditable" must be set to `true`.');
|
|
4313
4076
|
}
|
|
4314
|
-
if (newValue && (this.titlePatternErrorMessage === undefined || this.titlePatternErrorMessage.trim() === '')) {
|
|
4077
|
+
if (newValue !== undefined && (this.titlePatternErrorMessage === undefined || this.titlePatternErrorMessage.trim() === '')) {
|
|
4315
4078
|
throw new Error('<mg-panel> prop "titlePattern" must be paired with the prop "titlePatternErrorMessage".');
|
|
4316
4079
|
}
|
|
4317
4080
|
}
|
|
@@ -4323,8 +4086,6 @@ const MgPanel = class {
|
|
|
4323
4086
|
*************/
|
|
4324
4087
|
/**
|
|
4325
4088
|
* Check if props are well configured on init
|
|
4326
|
-
*
|
|
4327
|
-
* @returns {void}
|
|
4328
4089
|
*/
|
|
4329
4090
|
componentWillLoad() {
|
|
4330
4091
|
// Get locales
|
|
@@ -4335,8 +4096,6 @@ const MgPanel = class {
|
|
|
4335
4096
|
}
|
|
4336
4097
|
/**
|
|
4337
4098
|
* Edit DOM after render
|
|
4338
|
-
*
|
|
4339
|
-
* @returns {void}
|
|
4340
4099
|
*/
|
|
4341
4100
|
componentDidRender() {
|
|
4342
4101
|
// when we are editing we get focus on edition input
|
|
@@ -4346,11 +4105,10 @@ const MgPanel = class {
|
|
|
4346
4105
|
}
|
|
4347
4106
|
/**
|
|
4348
4107
|
* Render component
|
|
4349
|
-
*
|
|
4350
|
-
* @returns {HTMLElement} html element
|
|
4108
|
+
* @returns html element
|
|
4351
4109
|
*/
|
|
4352
4110
|
render() {
|
|
4353
|
-
return (h("section", { class: this.
|
|
4111
|
+
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)))));
|
|
4354
4112
|
}
|
|
4355
4113
|
get element() { return getElement(this); }
|
|
4356
4114
|
static get watchers() { return {
|
|
@@ -6169,9 +5927,7 @@ const MgPopover = class {
|
|
|
6169
5927
|
this.classArrowHide = `mg-popover--arrow-hide`;
|
|
6170
5928
|
/**
|
|
6171
5929
|
* Check if clicked outside of component
|
|
6172
|
-
*
|
|
6173
|
-
* @param {MouseEvent} event mouse event
|
|
6174
|
-
* @returns {void}
|
|
5930
|
+
* @param event - mouse event
|
|
6175
5931
|
*/
|
|
6176
5932
|
this.clickOutside = (event) => {
|
|
6177
5933
|
var _a;
|
|
@@ -6183,8 +5939,6 @@ const MgPopover = class {
|
|
|
6183
5939
|
};
|
|
6184
5940
|
/**
|
|
6185
5941
|
* Show popover
|
|
6186
|
-
*
|
|
6187
|
-
* @returns {void}
|
|
6188
5942
|
*/
|
|
6189
5943
|
this.show = () => {
|
|
6190
5944
|
// Make the popover visible
|
|
@@ -6203,8 +5957,6 @@ const MgPopover = class {
|
|
|
6203
5957
|
};
|
|
6204
5958
|
/**
|
|
6205
5959
|
* Hide popover
|
|
6206
|
-
*
|
|
6207
|
-
* @returns {void}
|
|
6208
5960
|
*/
|
|
6209
5961
|
this.hide = () => {
|
|
6210
5962
|
// Hide the popover
|
|
@@ -6218,8 +5970,6 @@ const MgPopover = class {
|
|
|
6218
5970
|
};
|
|
6219
5971
|
/**
|
|
6220
5972
|
* Handle action for close button
|
|
6221
|
-
*
|
|
6222
|
-
* @returns {void}
|
|
6223
5973
|
*/
|
|
6224
5974
|
this.handleCloseButton = () => {
|
|
6225
5975
|
this.display = false;
|
|
@@ -6230,13 +5980,13 @@ const MgPopover = class {
|
|
|
6230
5980
|
this.closeButton = false;
|
|
6231
5981
|
this.display = false;
|
|
6232
5982
|
this.disabled = false;
|
|
6233
|
-
this.
|
|
5983
|
+
this.classCollection = new ClassList(['mg-popover']);
|
|
6234
5984
|
}
|
|
6235
5985
|
validateArrowHide(newValue) {
|
|
6236
5986
|
if (newValue)
|
|
6237
|
-
this.
|
|
5987
|
+
this.classCollection.add(this.classArrowHide);
|
|
6238
5988
|
else
|
|
6239
|
-
this.
|
|
5989
|
+
this.classCollection.delete(this.classArrowHide);
|
|
6240
5990
|
}
|
|
6241
5991
|
handleDisplay(newValue) {
|
|
6242
5992
|
if (newValue) {
|
|
@@ -6252,8 +6002,6 @@ const MgPopover = class {
|
|
|
6252
6002
|
*************/
|
|
6253
6003
|
/**
|
|
6254
6004
|
* Check if component props are well configured on init
|
|
6255
|
-
*
|
|
6256
|
-
* @returns {void} timeout
|
|
6257
6005
|
*/
|
|
6258
6006
|
componentWillLoad() {
|
|
6259
6007
|
// Get windows to attach events
|
|
@@ -6264,8 +6012,6 @@ const MgPopover = class {
|
|
|
6264
6012
|
}
|
|
6265
6013
|
/**
|
|
6266
6014
|
* Check if component props are well configured on init
|
|
6267
|
-
*
|
|
6268
|
-
* @returns {void}
|
|
6269
6015
|
*/
|
|
6270
6016
|
componentDidLoad() {
|
|
6271
6017
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -6322,11 +6068,10 @@ const MgPopover = class {
|
|
|
6322
6068
|
}
|
|
6323
6069
|
/**
|
|
6324
6070
|
* Render
|
|
6325
|
-
*
|
|
6326
|
-
* @returns {HTMLElement} HTML Element
|
|
6071
|
+
* @returns HTML Element
|
|
6327
6072
|
*/
|
|
6328
6073
|
render() {
|
|
6329
|
-
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: this.
|
|
6074
|
+
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 }))));
|
|
6330
6075
|
}
|
|
6331
6076
|
get element() { return getElement(this); }
|
|
6332
6077
|
static get watchers() { return {
|
|
@@ -6347,9 +6092,7 @@ const MgSkipLinks = class {
|
|
|
6347
6092
|
**********/
|
|
6348
6093
|
/**
|
|
6349
6094
|
* Handle link click and emit go-to-anchor event
|
|
6350
|
-
*
|
|
6351
|
-
* @param {MouseEvent} event mouse event
|
|
6352
|
-
* @returns {void}
|
|
6095
|
+
* @param event - mouse event
|
|
6353
6096
|
*/
|
|
6354
6097
|
this.handleLinkCLick = (event) => {
|
|
6355
6098
|
event.currentTarget.blur();
|
|
@@ -6369,8 +6112,6 @@ const MgSkipLinks = class {
|
|
|
6369
6112
|
*************/
|
|
6370
6113
|
/**
|
|
6371
6114
|
* Check if props are well configured on init
|
|
6372
|
-
*
|
|
6373
|
-
* @returns {void}
|
|
6374
6115
|
*/
|
|
6375
6116
|
componentWillLoad() {
|
|
6376
6117
|
this.validateLinks(this.links);
|
|
@@ -6378,8 +6119,7 @@ const MgSkipLinks = class {
|
|
|
6378
6119
|
}
|
|
6379
6120
|
/**
|
|
6380
6121
|
* Render
|
|
6381
|
-
*
|
|
6382
|
-
* @returns {HTMLElement} HTML Element
|
|
6122
|
+
* @returns HTML Element
|
|
6383
6123
|
*/
|
|
6384
6124
|
render() {
|
|
6385
6125
|
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)))))));
|
|
@@ -6410,9 +6150,8 @@ const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.m
|
|
|
6410
6150
|
|
|
6411
6151
|
/**
|
|
6412
6152
|
* type TabItem validation function
|
|
6413
|
-
*
|
|
6414
|
-
* @
|
|
6415
|
-
* @returns {boolean} tab item type is valid
|
|
6153
|
+
* @param tab - tab item
|
|
6154
|
+
* @returns tab item type is valid
|
|
6416
6155
|
*/
|
|
6417
6156
|
const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
|
|
6418
6157
|
const MgTabs = class {
|
|
@@ -6428,37 +6167,32 @@ const MgTabs = class {
|
|
|
6428
6167
|
this.startIndex = 1;
|
|
6429
6168
|
/**
|
|
6430
6169
|
* Method to know if given tab has the given status
|
|
6431
|
-
*
|
|
6432
|
-
* @param
|
|
6433
|
-
* @
|
|
6434
|
-
* @returns {boolean} status comparaison
|
|
6170
|
+
* @param tab - item tab key to set to ACTIVE status
|
|
6171
|
+
* @param status - status to valide
|
|
6172
|
+
* @returns status comparaison
|
|
6435
6173
|
*/
|
|
6436
6174
|
this.tabHasStatus = (tab, status) => tab.status === status;
|
|
6437
6175
|
/**
|
|
6438
6176
|
* Method to get element id from index
|
|
6439
|
-
*
|
|
6440
|
-
* @param
|
|
6441
|
-
* @
|
|
6442
|
-
* @returns {string} generated element id
|
|
6177
|
+
* @param element - to get id
|
|
6178
|
+
* @param index - to generate id
|
|
6179
|
+
* @returns generated element id
|
|
6443
6180
|
*/
|
|
6444
6181
|
this.getElementId = (element, index) => `${element}-${this.getTabItemIndex(index)}`;
|
|
6445
6182
|
/**
|
|
6446
6183
|
* Method to get tab item index
|
|
6447
|
-
*
|
|
6448
|
-
* @
|
|
6449
|
-
* @returns {number} index
|
|
6184
|
+
* @param index - to get
|
|
6185
|
+
* @returns index
|
|
6450
6186
|
*/
|
|
6451
6187
|
this.getTabItemIndex = (index) => index + this.startIndex;
|
|
6452
6188
|
/**
|
|
6453
6189
|
* Method to get the active-tab value
|
|
6454
|
-
*
|
|
6455
|
-
* @returns {number} of the active-tab
|
|
6190
|
+
* @returns of the active-tab
|
|
6456
6191
|
*/
|
|
6457
6192
|
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);
|
|
6458
6193
|
/**
|
|
6459
6194
|
* Handle click events on tabs
|
|
6460
|
-
*
|
|
6461
|
-
* @param {MouseEvent} event mouse event
|
|
6195
|
+
* @param event - mouse event
|
|
6462
6196
|
*/
|
|
6463
6197
|
this.handleClick = (event) => {
|
|
6464
6198
|
const tabId = event.currentTarget.dataset.index;
|
|
@@ -6473,16 +6207,13 @@ const MgTabs = class {
|
|
|
6473
6207
|
};
|
|
6474
6208
|
/**
|
|
6475
6209
|
* get navigation button class from given status
|
|
6476
|
-
*
|
|
6477
|
-
* @
|
|
6478
|
-
* @returns {string} button class/selector variant
|
|
6210
|
+
* @param status - button tab status
|
|
6211
|
+
* @returns button class/selector variant
|
|
6479
6212
|
*/
|
|
6480
6213
|
this.getNavigationButtonClass = (status) => `${this.buttonTabBaseClass}--${status}`;
|
|
6481
6214
|
/**
|
|
6482
6215
|
* Handle keyboard event on tabs
|
|
6483
|
-
*
|
|
6484
|
-
* @param {MouseEvent} event mouse event
|
|
6485
|
-
* @returns {void}
|
|
6216
|
+
* @param event - mouse event
|
|
6486
6217
|
*/
|
|
6487
6218
|
this.handleKeydown = (event) => {
|
|
6488
6219
|
const parent = event.target.parentElement;
|
|
@@ -6520,8 +6251,6 @@ const MgTabs = class {
|
|
|
6520
6251
|
};
|
|
6521
6252
|
/**
|
|
6522
6253
|
* Method to reset focus behavior
|
|
6523
|
-
*
|
|
6524
|
-
* @returns {void}
|
|
6525
6254
|
*/
|
|
6526
6255
|
this.resetFocus = () => {
|
|
6527
6256
|
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
@@ -6546,7 +6275,7 @@ const MgTabs = class {
|
|
|
6546
6275
|
this.items = undefined;
|
|
6547
6276
|
this.activeTab = undefined;
|
|
6548
6277
|
this.tabs = [];
|
|
6549
|
-
this.
|
|
6278
|
+
this.classCollection = new ClassList(['mg-tabs']);
|
|
6550
6279
|
}
|
|
6551
6280
|
validateLabel(newValue) {
|
|
6552
6281
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -6557,7 +6286,7 @@ const MgTabs = class {
|
|
|
6557
6286
|
if (!sizes.includes(newValue)) {
|
|
6558
6287
|
throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
6559
6288
|
}
|
|
6560
|
-
this.
|
|
6289
|
+
this.classCollection.add(`mg-tabs--size-${this.size}`);
|
|
6561
6290
|
}
|
|
6562
6291
|
validateItems(newValue) {
|
|
6563
6292
|
// String array
|
|
@@ -6600,8 +6329,6 @@ const MgTabs = class {
|
|
|
6600
6329
|
*************/
|
|
6601
6330
|
/**
|
|
6602
6331
|
* Check if component props are well configured on init
|
|
6603
|
-
*
|
|
6604
|
-
* @returns {void}
|
|
6605
6332
|
*/
|
|
6606
6333
|
componentWillLoad() {
|
|
6607
6334
|
// Check tabs format
|
|
@@ -6613,8 +6340,6 @@ const MgTabs = class {
|
|
|
6613
6340
|
}
|
|
6614
6341
|
/**
|
|
6615
6342
|
* add listners
|
|
6616
|
-
*
|
|
6617
|
-
* @returns {void}
|
|
6618
6343
|
*/
|
|
6619
6344
|
componentDidLoad() {
|
|
6620
6345
|
document.addEventListener('click', (event) => {
|
|
@@ -6624,11 +6349,10 @@ const MgTabs = class {
|
|
|
6624
6349
|
}
|
|
6625
6350
|
/**
|
|
6626
6351
|
* Render
|
|
6627
|
-
*
|
|
6628
|
-
* @returns {HTMLElement} HTML Element
|
|
6352
|
+
* @returns HTML Element
|
|
6629
6353
|
*/
|
|
6630
6354
|
render() {
|
|
6631
|
-
return (h("div", { class: this.
|
|
6355
|
+
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: {
|
|
6632
6356
|
[`${this.buttonTabBaseClass}`]: true,
|
|
6633
6357
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
6634
6358
|
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|
|
@@ -6665,7 +6389,7 @@ const MgTag = class {
|
|
|
6665
6389
|
this.variant = variants[0];
|
|
6666
6390
|
this.outline = undefined;
|
|
6667
6391
|
this.soft = undefined;
|
|
6668
|
-
this.
|
|
6392
|
+
this.classCollection = new ClassList(['mg-tag']);
|
|
6669
6393
|
}
|
|
6670
6394
|
validateVariant(newValue, oldValue) {
|
|
6671
6395
|
if (!variants.includes(newValue)) {
|
|
@@ -6673,16 +6397,16 @@ const MgTag = class {
|
|
|
6673
6397
|
}
|
|
6674
6398
|
else {
|
|
6675
6399
|
if (oldValue !== undefined) {
|
|
6676
|
-
this.
|
|
6400
|
+
this.classCollection.delete(`mg-tag--${oldValue}`);
|
|
6677
6401
|
}
|
|
6678
|
-
this.
|
|
6402
|
+
this.classCollection.add(`mg-tag--${newValue}`);
|
|
6679
6403
|
}
|
|
6680
6404
|
}
|
|
6681
6405
|
validateOutline(newValue) {
|
|
6682
6406
|
if (newValue)
|
|
6683
|
-
this.
|
|
6407
|
+
this.classCollection.add(this.classOutline);
|
|
6684
6408
|
else
|
|
6685
|
-
this.
|
|
6409
|
+
this.classCollection.delete(this.classOutline);
|
|
6686
6410
|
}
|
|
6687
6411
|
validateSoft(newValue) {
|
|
6688
6412
|
// usage validation
|
|
@@ -6690,18 +6414,16 @@ const MgTag = class {
|
|
|
6690
6414
|
throw new Error('<mg-tag> prop "soft" can NOT be used with prop "outline".');
|
|
6691
6415
|
// apply class
|
|
6692
6416
|
if (newValue)
|
|
6693
|
-
this.
|
|
6417
|
+
this.classCollection.add(this.classSoft);
|
|
6694
6418
|
else
|
|
6695
|
-
this.
|
|
6419
|
+
this.classCollection.delete(this.classSoft);
|
|
6696
6420
|
}
|
|
6697
6421
|
/*************
|
|
6698
6422
|
* Methods *
|
|
6699
6423
|
*************/
|
|
6700
6424
|
/**
|
|
6701
6425
|
* Validate the given textContent
|
|
6702
|
-
*
|
|
6703
|
-
* @param {string} textContent html element textContent property
|
|
6704
|
-
* @returns {void}
|
|
6426
|
+
* @param textContent - html element textContent property
|
|
6705
6427
|
*/
|
|
6706
6428
|
validateTextContent(textContent) {
|
|
6707
6429
|
if (typeof textContent !== 'string' || textContent.trim() === '')
|
|
@@ -6712,8 +6434,6 @@ const MgTag = class {
|
|
|
6712
6434
|
*************/
|
|
6713
6435
|
/**
|
|
6714
6436
|
* Check if props are well configured on init
|
|
6715
|
-
*
|
|
6716
|
-
* @returns {void}
|
|
6717
6437
|
*/
|
|
6718
6438
|
componentWillLoad() {
|
|
6719
6439
|
this.validateVariant(this.variant);
|
|
@@ -6723,11 +6443,10 @@ const MgTag = class {
|
|
|
6723
6443
|
}
|
|
6724
6444
|
/**
|
|
6725
6445
|
* Render
|
|
6726
|
-
*
|
|
6727
|
-
* @returns {HTMLElement} HTML Element
|
|
6446
|
+
* @returns HTML Element
|
|
6728
6447
|
*/
|
|
6729
6448
|
render() {
|
|
6730
|
-
return (h("span", { class: this.
|
|
6449
|
+
return (h("span", { class: this.classCollection.join() }, h("slot", null)));
|
|
6731
6450
|
}
|
|
6732
6451
|
get element() { return getElement(this); }
|
|
6733
6452
|
static get watchers() { return {
|
|
@@ -6752,8 +6471,6 @@ const MgTooltip = class {
|
|
|
6752
6471
|
registerInstance(this, hostRef);
|
|
6753
6472
|
/**
|
|
6754
6473
|
* Show tooltip
|
|
6755
|
-
*
|
|
6756
|
-
* @returns {void}
|
|
6757
6474
|
*/
|
|
6758
6475
|
this.show = () => {
|
|
6759
6476
|
// Make the tooltip visible
|
|
@@ -6773,8 +6490,6 @@ const MgTooltip = class {
|
|
|
6773
6490
|
};
|
|
6774
6491
|
/**
|
|
6775
6492
|
* Hide tooltip
|
|
6776
|
-
*
|
|
6777
|
-
* @returns {void}
|
|
6778
6493
|
*/
|
|
6779
6494
|
this.hide = () => {
|
|
6780
6495
|
// Hide the tooltip
|
|
@@ -6789,9 +6504,7 @@ const MgTooltip = class {
|
|
|
6789
6504
|
};
|
|
6790
6505
|
/**
|
|
6791
6506
|
* Check if clicked outside of component and hidde tooltip
|
|
6792
|
-
*
|
|
6793
|
-
* @param {MouseEvent} event mouse event
|
|
6794
|
-
* @returns {void}
|
|
6507
|
+
* @param event - mouse event
|
|
6795
6508
|
*/
|
|
6796
6509
|
this.clickOutside = (event) => {
|
|
6797
6510
|
if (event.target.closest('mg-tooltip') !== this.element)
|
|
@@ -6799,9 +6512,7 @@ const MgTooltip = class {
|
|
|
6799
6512
|
};
|
|
6800
6513
|
/**
|
|
6801
6514
|
* Check if 'Escape' key is pressed of component and hidde tooltip
|
|
6802
|
-
*
|
|
6803
|
-
* @param {KeyboardEvent} event keyboard event
|
|
6804
|
-
* @returns {void}
|
|
6515
|
+
* @param event - keyboard event
|
|
6805
6516
|
*/
|
|
6806
6517
|
this.pressEscape = (event) => {
|
|
6807
6518
|
if (event.code === 'Escape')
|
|
@@ -6809,10 +6520,8 @@ const MgTooltip = class {
|
|
|
6809
6520
|
};
|
|
6810
6521
|
/**
|
|
6811
6522
|
* Method to set display prop
|
|
6812
|
-
*
|
|
6813
|
-
* @param
|
|
6814
|
-
* @param {boolean} condition additionnal condition to apply display prop newValue
|
|
6815
|
-
* @returns {void}
|
|
6523
|
+
* @param newValue - display prop new value
|
|
6524
|
+
* @param condition - additionnal condition to apply display prop newValue
|
|
6816
6525
|
*/
|
|
6817
6526
|
this.setDisplay = (newValue, condition = true) => {
|
|
6818
6527
|
if (!this.disabled && condition)
|
|
@@ -6820,11 +6529,9 @@ const MgTooltip = class {
|
|
|
6820
6529
|
};
|
|
6821
6530
|
/**
|
|
6822
6531
|
* Action for tooltip element and tooltiped element mouse listener
|
|
6823
|
-
*
|
|
6824
|
-
* @param
|
|
6825
|
-
* @param
|
|
6826
|
-
* @param {Guard} conditionalGuard guard condition
|
|
6827
|
-
* @returns {void}
|
|
6532
|
+
* @param elementGuard - tooltip element guard
|
|
6533
|
+
* @param isMouseenter - mouseenter validation
|
|
6534
|
+
* @param conditionalGuard - guard condition
|
|
6828
6535
|
*/
|
|
6829
6536
|
this.tooltipMouseListenerAction = (elementGuard, isMouseenter, conditionalGuard) => {
|
|
6830
6537
|
// we mutate elementGuard
|
|
@@ -6843,17 +6550,13 @@ const MgTooltip = class {
|
|
|
6843
6550
|
};
|
|
6844
6551
|
/**
|
|
6845
6552
|
* Method to reset guard value
|
|
6846
|
-
*
|
|
6847
|
-
* @returns {void}
|
|
6848
6553
|
*/
|
|
6849
6554
|
this.resetGuard = () => {
|
|
6850
6555
|
this.guard = undefined;
|
|
6851
6556
|
};
|
|
6852
6557
|
/**
|
|
6853
6558
|
* Update slot content when it is a mg-button
|
|
6854
|
-
*
|
|
6855
|
-
* @param {HTMLMgButtonElement} mgButton slotted mg-button
|
|
6856
|
-
* @returns {void}
|
|
6559
|
+
* @param mgButton - slotted mg-button
|
|
6857
6560
|
*/
|
|
6858
6561
|
this.setMgButtonWrapper = (mgButton) => {
|
|
6859
6562
|
if (mgButton.disabled) {
|
|
@@ -6870,9 +6573,8 @@ const MgTooltip = class {
|
|
|
6870
6573
|
};
|
|
6871
6574
|
/**
|
|
6872
6575
|
* Init tooltip
|
|
6873
|
-
*
|
|
6874
|
-
* @param
|
|
6875
|
-
* @param {HTMLElement} interactiveElement interactive element
|
|
6576
|
+
* @param slotElement - slotted element
|
|
6577
|
+
* @param interactiveElement - interactive element
|
|
6876
6578
|
*/
|
|
6877
6579
|
this.initTooltip = (slotElement, interactiveElement) => {
|
|
6878
6580
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
@@ -6948,8 +6650,6 @@ const MgTooltip = class {
|
|
|
6948
6650
|
*************/
|
|
6949
6651
|
/**
|
|
6950
6652
|
* set variables
|
|
6951
|
-
*
|
|
6952
|
-
* @returns {void}
|
|
6953
6653
|
*/
|
|
6954
6654
|
componentWillLoad() {
|
|
6955
6655
|
// Get windows to attach events
|
|
@@ -6959,8 +6659,6 @@ const MgTooltip = class {
|
|
|
6959
6659
|
* Get slotted element
|
|
6960
6660
|
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
6961
6661
|
* We need to attach the focused element to the tooltip (aria-describedby)
|
|
6962
|
-
*
|
|
6963
|
-
* @returns {void}
|
|
6964
6662
|
*/
|
|
6965
6663
|
componentDidLoad() {
|
|
6966
6664
|
var _a;
|
|
@@ -6993,8 +6691,7 @@ const MgTooltip = class {
|
|
|
6993
6691
|
}
|
|
6994
6692
|
/**
|
|
6995
6693
|
* Render
|
|
6996
|
-
*
|
|
6997
|
-
* @returns {HTMLElement} HTML Element
|
|
6694
|
+
* @returns HTML Element
|
|
6998
6695
|
*/
|
|
6999
6696
|
render() {
|
|
7000
6697
|
return (h(Host, null, h("slot", null), h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip" }, h("span", { innerHTML: this.message }), h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|