@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-9e1091ab.js');
|
|
6
|
-
const mgMenu_conf = require('./mg-menu.conf-
|
|
6
|
+
const mgMenu_conf = require('./mg-menu.conf-196151fe.js');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Available menu-item positions
|
|
@@ -26,10 +26,9 @@ var Status$1;
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Create random ID
|
|
29
|
-
*
|
|
30
|
-
* @param
|
|
31
|
-
* @
|
|
32
|
-
* @returns {string} ID
|
|
29
|
+
* @param prefix - add prefix to created ID
|
|
30
|
+
* @param length - ID length
|
|
31
|
+
* @returns ID
|
|
33
32
|
*/
|
|
34
33
|
const createID = (prefix = '', length = 10) => {
|
|
35
34
|
let ID = '';
|
|
@@ -48,9 +47,7 @@ class ClassList {
|
|
|
48
47
|
constructor(classlist = []) {
|
|
49
48
|
/**
|
|
50
49
|
* Add class
|
|
51
|
-
*
|
|
52
|
-
* @param {string} className class name to add
|
|
53
|
-
* @returns {void}
|
|
50
|
+
* @param className - class name to add
|
|
54
51
|
*/
|
|
55
52
|
this.add = (className) => {
|
|
56
53
|
if (!this.has(className)) {
|
|
@@ -59,9 +56,7 @@ class ClassList {
|
|
|
59
56
|
};
|
|
60
57
|
/**
|
|
61
58
|
* Delete class
|
|
62
|
-
*
|
|
63
|
-
* @param {string} className class name to delete
|
|
64
|
-
* @returns {void}
|
|
59
|
+
* @param className - class name to delete
|
|
65
60
|
*/
|
|
66
61
|
this.delete = (className) => {
|
|
67
62
|
const index = this.classes.indexOf(className);
|
|
@@ -71,17 +66,15 @@ class ClassList {
|
|
|
71
66
|
};
|
|
72
67
|
/**
|
|
73
68
|
* Check if class exist in list
|
|
74
|
-
*
|
|
75
|
-
* @
|
|
76
|
-
* @returns {boolean} class name is in the list
|
|
69
|
+
* @param className - class name to check
|
|
70
|
+
* @returns class name is in the list
|
|
77
71
|
*/
|
|
78
72
|
this.has = (className) => {
|
|
79
73
|
return this.classes.includes(className);
|
|
80
74
|
};
|
|
81
75
|
/**
|
|
82
76
|
* Join classes seperated by spaces
|
|
83
|
-
*
|
|
84
|
-
* @returns {string} joined values
|
|
77
|
+
* @returns joined values
|
|
85
78
|
*/
|
|
86
79
|
this.join = () => {
|
|
87
80
|
return this.classes.join(' ');
|
|
@@ -91,17 +84,15 @@ class ClassList {
|
|
|
91
84
|
}
|
|
92
85
|
/**
|
|
93
86
|
* Check if all items are string
|
|
94
|
-
*
|
|
95
|
-
* @
|
|
96
|
-
* @returns {boolean} all items are string
|
|
87
|
+
* @param items - items to check
|
|
88
|
+
* @returns all items are string
|
|
97
89
|
*/
|
|
98
90
|
const allItemsAreString = (items) => Array.isArray(items) && items.every(item => typeof item === 'string');
|
|
99
91
|
/**
|
|
100
92
|
* Check if element is a heading
|
|
101
|
-
*
|
|
102
|
-
* @param
|
|
103
|
-
* @
|
|
104
|
-
* @returns {boolean} element is a heading
|
|
93
|
+
* @param element - slotted element
|
|
94
|
+
* @param tagNames - allowed tag names list
|
|
95
|
+
* @returns element is a heading
|
|
105
96
|
*/
|
|
106
97
|
const isTagName = (element, tagNames) => {
|
|
107
98
|
return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
|
|
@@ -111,9 +102,9 @@ const isTagName = (element, tagNames) => {
|
|
|
111
102
|
*/
|
|
112
103
|
const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
113
104
|
/**
|
|
114
|
-
*
|
|
115
|
-
* @param
|
|
116
|
-
* @returns
|
|
105
|
+
* Get windows
|
|
106
|
+
* @param localWindow - the window we are lookink for other windows
|
|
107
|
+
* @returns The list of windows found
|
|
117
108
|
*/
|
|
118
109
|
const getWindows = (localWindow) => {
|
|
119
110
|
const parentWindows = getParentWindows(localWindow);
|
|
@@ -122,10 +113,9 @@ const getWindows = (localWindow) => {
|
|
|
122
113
|
};
|
|
123
114
|
/**
|
|
124
115
|
* Get parent windows
|
|
125
|
-
*
|
|
126
|
-
* @param
|
|
127
|
-
* @
|
|
128
|
-
* @returns {Window[]} The list of windows found
|
|
116
|
+
* @param localWindow - the window we are lookink for parents
|
|
117
|
+
* @param windows - The list of allready found windows
|
|
118
|
+
* @returns The list of windows found
|
|
129
119
|
*/
|
|
130
120
|
const getParentWindows = (localWindow, windows = []) => {
|
|
131
121
|
// Check if is in iframe
|
|
@@ -145,10 +135,9 @@ const getParentWindows = (localWindow, windows = []) => {
|
|
|
145
135
|
};
|
|
146
136
|
/**
|
|
147
137
|
* Get child windows
|
|
148
|
-
*
|
|
149
|
-
* @param
|
|
150
|
-
* @
|
|
151
|
-
* @returns {Window[]} The list of windows found
|
|
138
|
+
* @param localWindow - the window we are lookink for children
|
|
139
|
+
* @param windows - The list of allready found windows
|
|
140
|
+
* @returns The list of windows found
|
|
152
141
|
*/
|
|
153
142
|
const getChildWindows = (localWindow, windows = []) => {
|
|
154
143
|
if (localWindow.frames.length > 0) {
|
|
@@ -167,9 +156,8 @@ const mgActionMoreCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
167
156
|
|
|
168
157
|
/**
|
|
169
158
|
* MgActionMore['items'] type guard
|
|
170
|
-
*
|
|
171
|
-
* @
|
|
172
|
-
* @returns {boolean} return true if type is valid
|
|
159
|
+
* @param prop - commponent items prop
|
|
160
|
+
* @returns return true if type is valid
|
|
173
161
|
*/
|
|
174
162
|
const isMgActionMoreItems = (prop) => {
|
|
175
163
|
const items = prop;
|
|
@@ -177,9 +165,8 @@ const isMgActionMoreItems = (prop) => {
|
|
|
177
165
|
};
|
|
178
166
|
/**
|
|
179
167
|
* MgActionMore['button'] type guard
|
|
180
|
-
*
|
|
181
|
-
* @
|
|
182
|
-
* @returns {boolean} return true if type is valid
|
|
168
|
+
* @param prop - commponent button prop
|
|
169
|
+
* @returns return true if type is valid
|
|
183
170
|
*/
|
|
184
171
|
const isMgActionMoreButton = (prop) => {
|
|
185
172
|
const button = prop;
|
|
@@ -187,9 +174,8 @@ const isMgActionMoreButton = (prop) => {
|
|
|
187
174
|
};
|
|
188
175
|
/**
|
|
189
176
|
* MgActionMore['icon'] type guard
|
|
190
|
-
*
|
|
191
|
-
* @
|
|
192
|
-
* @returns {boolean} return true if type is valid
|
|
177
|
+
* @param prop - commponent icon prop
|
|
178
|
+
* @returns return true if type is valid
|
|
193
179
|
*/
|
|
194
180
|
const isMgActionMoreIcon = (prop) => {
|
|
195
181
|
const icon = prop;
|
|
@@ -208,26 +194,20 @@ const MgActionMore = class {
|
|
|
208
194
|
***********/
|
|
209
195
|
/**
|
|
210
196
|
* Toogle expanded props
|
|
211
|
-
*
|
|
212
|
-
* @returns {void}
|
|
213
197
|
*/
|
|
214
198
|
this.toggleExpanded = () => {
|
|
215
199
|
this.expanded = !this.expanded;
|
|
216
200
|
};
|
|
217
201
|
/**
|
|
218
202
|
* Button click handler
|
|
219
|
-
*
|
|
220
|
-
* @returns {void}
|
|
221
203
|
*/
|
|
222
204
|
this.handleButton = () => {
|
|
223
205
|
this.toggleExpanded();
|
|
224
206
|
};
|
|
225
207
|
/**
|
|
226
208
|
* Item click handler
|
|
227
|
-
*
|
|
228
|
-
* @param
|
|
229
|
-
* @param {MgActionMoreItemType['mouseEventHandler']} customHandler item['mouseEventHandler']
|
|
230
|
-
* @returns {void}
|
|
209
|
+
* @param event - click event
|
|
210
|
+
* @param customHandler - item['mouseEventHandler']
|
|
231
211
|
*/
|
|
232
212
|
this.handleItemClick = (event, customHandler) => {
|
|
233
213
|
this.expanded = false;
|
|
@@ -264,8 +244,6 @@ const MgActionMore = class {
|
|
|
264
244
|
*************/
|
|
265
245
|
/**
|
|
266
246
|
* Validate props
|
|
267
|
-
*
|
|
268
|
-
* @returns {void}
|
|
269
247
|
*/
|
|
270
248
|
componentWillLoad() {
|
|
271
249
|
this.messages = mgMenu_conf.initLocales(this.element).messages.actionMore;
|
|
@@ -276,8 +254,7 @@ const MgActionMore = class {
|
|
|
276
254
|
}
|
|
277
255
|
/**
|
|
278
256
|
* Render
|
|
279
|
-
*
|
|
280
|
-
* @returns {HTMLElement} HTML Element
|
|
257
|
+
* @returns HTML Element
|
|
281
258
|
*/
|
|
282
259
|
render() {
|
|
283
260
|
const buttonLabel = this.button.label || this.messages.label;
|
|
@@ -325,7 +302,7 @@ const MgBadge = class {
|
|
|
325
302
|
this.label = undefined;
|
|
326
303
|
this.variant = variants$5[0];
|
|
327
304
|
this.outline = undefined;
|
|
328
|
-
this.
|
|
305
|
+
this.classCollection = new ClassList(['mg-badge']);
|
|
329
306
|
}
|
|
330
307
|
validateValue(newValue) {
|
|
331
308
|
if (`${newValue}`.match(/^(\d+\+*|[?*!a-z])$/i) === null) {
|
|
@@ -343,21 +320,19 @@ const MgBadge = class {
|
|
|
343
320
|
}
|
|
344
321
|
else {
|
|
345
322
|
if (oldValue !== undefined) {
|
|
346
|
-
this.
|
|
323
|
+
this.classCollection.delete(`mg-badge--${oldValue}`);
|
|
347
324
|
}
|
|
348
|
-
this.
|
|
325
|
+
this.classCollection.add(`mg-badge--${newValue}`);
|
|
349
326
|
}
|
|
350
327
|
}
|
|
351
328
|
validateOutline(newValue) {
|
|
352
329
|
if (newValue)
|
|
353
|
-
this.
|
|
330
|
+
this.classCollection.add(this.classOutline);
|
|
354
331
|
else
|
|
355
|
-
this.
|
|
332
|
+
this.classCollection.delete(this.classOutline);
|
|
356
333
|
}
|
|
357
334
|
/**
|
|
358
335
|
* Check if props are well configured on init
|
|
359
|
-
*
|
|
360
|
-
* @returns {void}
|
|
361
336
|
*/
|
|
362
337
|
componentWillLoad() {
|
|
363
338
|
this.validateValue(this.value);
|
|
@@ -367,11 +342,10 @@ const MgBadge = class {
|
|
|
367
342
|
}
|
|
368
343
|
/**
|
|
369
344
|
* Render
|
|
370
|
-
*
|
|
371
|
-
* @returns {HTMLElement} HTML Element
|
|
345
|
+
* @returns HTML Element
|
|
372
346
|
*/
|
|
373
347
|
render() {
|
|
374
|
-
return (index.h("span", { class: this.
|
|
348
|
+
return (index.h("span", { class: this.classCollection.join() }, index.h("span", { class: "mg-badge__value" }, this.value), index.h("span", { class: "sr-only" }, this.label)));
|
|
375
349
|
}
|
|
376
350
|
static get watchers() { return {
|
|
377
351
|
"value": ["validateValue"],
|
|
@@ -402,9 +376,7 @@ const MgButton = class {
|
|
|
402
376
|
this.classFullWidth = 'mg-button--full-width';
|
|
403
377
|
/**
|
|
404
378
|
* Trigger actions onClick event
|
|
405
|
-
*
|
|
406
|
-
* @param {MouseEvent} event click event
|
|
407
|
-
* @returns {void}
|
|
379
|
+
* @param event - click event
|
|
408
380
|
*/
|
|
409
381
|
this.handleClick = (event) => {
|
|
410
382
|
if (this.disabled)
|
|
@@ -417,9 +389,7 @@ const MgButton = class {
|
|
|
417
389
|
};
|
|
418
390
|
/**
|
|
419
391
|
* Handle onKeydown event
|
|
420
|
-
*
|
|
421
|
-
* @param {KeyboardEvent} event keyboard event
|
|
422
|
-
* @returns {void}
|
|
392
|
+
* @param event - keyboard event
|
|
423
393
|
*/
|
|
424
394
|
this.handleKeydown = (event) => {
|
|
425
395
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -432,9 +402,7 @@ const MgButton = class {
|
|
|
432
402
|
};
|
|
433
403
|
/**
|
|
434
404
|
* Handle onKeyup event
|
|
435
|
-
*
|
|
436
|
-
* @param {KeyboardEvent} event keyboard event
|
|
437
|
-
* @returns {void}
|
|
405
|
+
* @param event - keyboard event
|
|
438
406
|
*/
|
|
439
407
|
this.handleKeyup = (event) => {
|
|
440
408
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -452,7 +420,7 @@ const MgButton = class {
|
|
|
452
420
|
this.isIcon = false;
|
|
453
421
|
this.disableOnClick = false;
|
|
454
422
|
this.loading = false;
|
|
455
|
-
this.
|
|
423
|
+
this.classCollection = new ClassList(['mg-button']);
|
|
456
424
|
}
|
|
457
425
|
validateVariant(newValue, oldValue) {
|
|
458
426
|
if (!variants$4.includes(newValue)) {
|
|
@@ -460,9 +428,9 @@ const MgButton = class {
|
|
|
460
428
|
}
|
|
461
429
|
else {
|
|
462
430
|
if (oldValue !== undefined) {
|
|
463
|
-
this.
|
|
431
|
+
this.classCollection.delete(`mg-button--${oldValue}`);
|
|
464
432
|
}
|
|
465
|
-
this.
|
|
433
|
+
this.classCollection.add(`mg-button--${newValue}`);
|
|
466
434
|
}
|
|
467
435
|
}
|
|
468
436
|
validateFullWidth(newValue) {
|
|
@@ -470,10 +438,10 @@ const MgButton = class {
|
|
|
470
438
|
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
471
439
|
}
|
|
472
440
|
else if (newValue) {
|
|
473
|
-
this.
|
|
441
|
+
this.classCollection.add(this.classFullWidth);
|
|
474
442
|
}
|
|
475
443
|
else {
|
|
476
|
-
this.
|
|
444
|
+
this.classCollection.delete(this.classFullWidth);
|
|
477
445
|
}
|
|
478
446
|
}
|
|
479
447
|
disabledHandler(isDisabled) {
|
|
@@ -486,10 +454,10 @@ const MgButton = class {
|
|
|
486
454
|
this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
|
|
487
455
|
// apply style
|
|
488
456
|
if (isDisabled) {
|
|
489
|
-
this.
|
|
457
|
+
this.classCollection.add(this.classDisabled);
|
|
490
458
|
}
|
|
491
459
|
else {
|
|
492
|
-
this.
|
|
460
|
+
this.classCollection.delete(this.classDisabled);
|
|
493
461
|
}
|
|
494
462
|
// emit value update
|
|
495
463
|
this.disabledChange.emit(isDisabled);
|
|
@@ -497,22 +465,20 @@ const MgButton = class {
|
|
|
497
465
|
loadingHandler(newValue) {
|
|
498
466
|
// we add loading style if it newvalue is true else we remove it
|
|
499
467
|
if (newValue) {
|
|
500
|
-
this.
|
|
468
|
+
this.classCollection.add(this.classLoading);
|
|
501
469
|
}
|
|
502
470
|
else {
|
|
503
|
-
this.
|
|
471
|
+
this.classCollection.delete(this.classLoading);
|
|
504
472
|
}
|
|
505
473
|
}
|
|
506
474
|
/**
|
|
507
475
|
* Check if props are well configured on init
|
|
508
|
-
*
|
|
509
|
-
* @returns {void}
|
|
510
476
|
*/
|
|
511
477
|
componentWillLoad() {
|
|
512
478
|
this.validateVariant(this.variant);
|
|
513
479
|
this.validateFullWidth(this.fullWidth);
|
|
514
480
|
if (this.isIcon) {
|
|
515
|
-
this.
|
|
481
|
+
this.classCollection.add(`mg-button--icon`);
|
|
516
482
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
517
483
|
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
518
484
|
}
|
|
@@ -523,11 +489,10 @@ const MgButton = class {
|
|
|
523
489
|
}
|
|
524
490
|
/**
|
|
525
491
|
* Render component
|
|
526
|
-
*
|
|
527
|
-
* @returns {HTMLElement} html element
|
|
492
|
+
* @returns html element
|
|
528
493
|
*/
|
|
529
494
|
render() {
|
|
530
|
-
return (index.h(index.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 }, index.h("div", { class: this.
|
|
495
|
+
return (index.h(index.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 }, index.h("div", { class: this.classCollection.join(), id: this.identifier }, this.loading && index.h("mg-icon", { icon: "loader", spin: true }), index.h("div", { class: "mg-button__content" }, index.h("slot", null)))));
|
|
531
496
|
}
|
|
532
497
|
get element() { return index.getElement(this); }
|
|
533
498
|
static get watchers() { return {
|
|
@@ -558,20 +523,27 @@ const MgCard = class {
|
|
|
558
523
|
*************/
|
|
559
524
|
this.name = 'mg-card';
|
|
560
525
|
this.baseClass = this.name;
|
|
526
|
+
/**
|
|
527
|
+
* Methode to set default varianStyle props
|
|
528
|
+
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
529
|
+
*/
|
|
530
|
+
this.setDefaultVariantStyle = () => {
|
|
531
|
+
if (this.variantStyle === undefined)
|
|
532
|
+
this.variantStyle = 'bar-left';
|
|
533
|
+
};
|
|
561
534
|
this.variant = undefined;
|
|
562
535
|
this.variantStyle = undefined;
|
|
563
|
-
this.
|
|
536
|
+
this.classCollection = new ClassList([this.baseClass]);
|
|
564
537
|
}
|
|
565
538
|
validateVariant(newValue, oldValue) {
|
|
566
539
|
if (newValue && !variants$3.includes(newValue))
|
|
567
540
|
throw new Error(`<${this.name}> prop "variant" must match VariantType type.`);
|
|
568
541
|
if (Boolean(newValue)) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
this.classList.add(`${this.baseClass}--${newValue}`);
|
|
542
|
+
this.setDefaultVariantStyle();
|
|
543
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
572
544
|
}
|
|
573
545
|
if (Boolean(oldValue))
|
|
574
|
-
this.
|
|
546
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
575
547
|
}
|
|
576
548
|
validateVariantStyle(newValue, oldValue) {
|
|
577
549
|
if (newValue && !variantStyles$1.includes(newValue))
|
|
@@ -579,14 +551,15 @@ const MgCard = class {
|
|
|
579
551
|
else if (Boolean(newValue) && !variants$3.includes(this.variant))
|
|
580
552
|
throw new Error(`<${this.name}> prop "variantStyle" must be paired with ${JSON.stringify(variants$3)} "variant" prop.`);
|
|
581
553
|
if (Boolean(newValue))
|
|
582
|
-
this.
|
|
554
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
583
555
|
if (Boolean(oldValue))
|
|
584
|
-
this.
|
|
556
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
585
557
|
}
|
|
558
|
+
/*************
|
|
559
|
+
* Lifecycle *
|
|
560
|
+
*************/
|
|
586
561
|
/**
|
|
587
562
|
* Check if props are well configured on init
|
|
588
|
-
*
|
|
589
|
-
* @returns {void}
|
|
590
563
|
*/
|
|
591
564
|
componentWillLoad() {
|
|
592
565
|
this.validateVariant(this.variant);
|
|
@@ -594,12 +567,11 @@ const MgCard = class {
|
|
|
594
567
|
}
|
|
595
568
|
/**
|
|
596
569
|
* Render
|
|
597
|
-
*
|
|
598
|
-
* @returns {HTMLElement} HTML Element
|
|
570
|
+
* @returns HTML Element
|
|
599
571
|
*/
|
|
600
572
|
render() {
|
|
601
573
|
var _a;
|
|
602
|
-
return (index.h("div", { class: this.
|
|
574
|
+
return (index.h("div", { class: this.classCollection.join() }, ((_a = this.variantStyle) === null || _a === void 0 ? void 0 : _a.startsWith('bar-')) && index.h("span", { class: "mg-card__bar" }), index.h("slot", null)));
|
|
603
575
|
}
|
|
604
576
|
static get watchers() { return {
|
|
605
577
|
"variant": ["validateVariant"],
|
|
@@ -627,8 +599,6 @@ const MgCharacterLeft = class {
|
|
|
627
599
|
*************/
|
|
628
600
|
/**
|
|
629
601
|
* Check if props are well configured on init
|
|
630
|
-
*
|
|
631
|
-
* @returns {void}
|
|
632
602
|
*/
|
|
633
603
|
componentWillLoad() {
|
|
634
604
|
this.validateMaxlength(this.maxlength);
|
|
@@ -636,8 +606,7 @@ const MgCharacterLeft = class {
|
|
|
636
606
|
}
|
|
637
607
|
/**
|
|
638
608
|
* Render component
|
|
639
|
-
*
|
|
640
|
-
* @returns {HTMLElement} HTML Element
|
|
609
|
+
* @returns HTML Element
|
|
641
610
|
*/
|
|
642
611
|
render() {
|
|
643
612
|
return (index.h("span", { id: this.identifier, "aria-live": "polite" }, index.h("span", { "aria-hidden": "true" }, this.maxlength - this.characters.length, "/", this.maxlength), index.h("span", { class: "sr-only" }, this.messages.nbCharLeft.replace('{counter}', this.maxlength - this.characters.length))));
|
|
@@ -657,8 +626,6 @@ const MgDetails = class {
|
|
|
657
626
|
this.expandedChange = index.createEvent(this, "expanded-change", 7);
|
|
658
627
|
/**
|
|
659
628
|
* Handle details toggle
|
|
660
|
-
*
|
|
661
|
-
* @returns {void}
|
|
662
629
|
*/
|
|
663
630
|
this.handleToggle = () => {
|
|
664
631
|
this.expanded = this.details.open;
|
|
@@ -681,8 +648,6 @@ const MgDetails = class {
|
|
|
681
648
|
*************/
|
|
682
649
|
/**
|
|
683
650
|
* Check if component props are well configured on init
|
|
684
|
-
*
|
|
685
|
-
* @returns {void}
|
|
686
651
|
*/
|
|
687
652
|
componentWillLoad() {
|
|
688
653
|
this.validateTitles(this.toggleClosed);
|
|
@@ -690,8 +655,7 @@ const MgDetails = class {
|
|
|
690
655
|
}
|
|
691
656
|
/**
|
|
692
657
|
* Render
|
|
693
|
-
*
|
|
694
|
-
* @returns {HTMLElement} HTML Element
|
|
658
|
+
* @returns HTML Element
|
|
695
659
|
*/
|
|
696
660
|
render() {
|
|
697
661
|
return (index.h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, index.h("summary", null, index.h("slot", { name: "summary" }), index.h("span", { class: "mg-details__toggle" }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down', size: "small" }), index.h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), index.h("div", { class: "mg-details__details" }, index.h("slot", { name: "details" }))));
|
|
@@ -713,8 +677,7 @@ const MgDivider = class {
|
|
|
713
677
|
}
|
|
714
678
|
/**
|
|
715
679
|
* Render
|
|
716
|
-
*
|
|
717
|
-
* @returns {HTMLElement} HTML Element
|
|
680
|
+
* @returns HTML Element
|
|
718
681
|
*/
|
|
719
682
|
render() {
|
|
720
683
|
return (index.h("div", { class: {
|
|
@@ -736,14 +699,11 @@ const MgForm = class {
|
|
|
736
699
|
this.classAllRequired = 'mg-form--all-required';
|
|
737
700
|
/**
|
|
738
701
|
* Define required message based on mg-inputs required elements
|
|
739
|
-
* Also
|
|
740
|
-
*
|
|
741
|
-
* @returns {void}
|
|
742
702
|
*/
|
|
743
703
|
this.setRequiredMessage = () => {
|
|
744
704
|
// init required message
|
|
745
705
|
this.requiredMessage = null;
|
|
746
|
-
this.
|
|
706
|
+
this.classCollection.delete(this.classAllRequired);
|
|
747
707
|
// If the form is disabled or readonly none of them are required
|
|
748
708
|
// Check if all fields are not editable (readonly or disabled)
|
|
749
709
|
if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
|
|
@@ -753,7 +713,7 @@ const MgForm = class {
|
|
|
753
713
|
// mg-input-toggle can not be required
|
|
754
714
|
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
755
715
|
this.requiredMessage = requiredInputs.length === 1 ? this.messages.form.allRequiredSingle : this.messages.form.allRequired;
|
|
756
|
-
this.
|
|
716
|
+
this.classCollection.add(this.classAllRequired);
|
|
757
717
|
}
|
|
758
718
|
// Some fields are required
|
|
759
719
|
else if (requiredInputs.length > 0) {
|
|
@@ -763,8 +723,6 @@ const MgForm = class {
|
|
|
763
723
|
};
|
|
764
724
|
/**
|
|
765
725
|
* Check if form is valid
|
|
766
|
-
*
|
|
767
|
-
* @returns {void}
|
|
768
726
|
*/
|
|
769
727
|
this.checkValidity = () => {
|
|
770
728
|
// Update required on input event
|
|
@@ -776,9 +734,7 @@ const MgForm = class {
|
|
|
776
734
|
};
|
|
777
735
|
/**
|
|
778
736
|
* Handle Form Submit
|
|
779
|
-
*
|
|
780
|
-
* @param {SubmitEvent} event submit event
|
|
781
|
-
* @returns {void}
|
|
737
|
+
* @param event - submit event
|
|
782
738
|
*/
|
|
783
739
|
this.handleFormSubmit = (event) => {
|
|
784
740
|
event.preventDefault();
|
|
@@ -786,8 +742,6 @@ const MgForm = class {
|
|
|
786
742
|
};
|
|
787
743
|
/**
|
|
788
744
|
* Set mgInputs
|
|
789
|
-
*
|
|
790
|
-
* @returns {void}
|
|
791
745
|
*/
|
|
792
746
|
this.setMgInputs = () => {
|
|
793
747
|
// Get slotted mgInputs
|
|
@@ -809,7 +763,7 @@ const MgForm = class {
|
|
|
809
763
|
this.disabled = false;
|
|
810
764
|
this.valid = undefined;
|
|
811
765
|
this.invalid = undefined;
|
|
812
|
-
this.
|
|
766
|
+
this.classCollection = new ClassList(['mg-form']);
|
|
813
767
|
this.requiredMessage = undefined;
|
|
814
768
|
}
|
|
815
769
|
handleAttributeChange() {
|
|
@@ -818,8 +772,6 @@ const MgForm = class {
|
|
|
818
772
|
}
|
|
819
773
|
/**
|
|
820
774
|
* Public method to display errors
|
|
821
|
-
*
|
|
822
|
-
* @returns {Promise<void>}
|
|
823
775
|
*/
|
|
824
776
|
async displayError() {
|
|
825
777
|
if (!this.readonly) {
|
|
@@ -834,8 +786,6 @@ const MgForm = class {
|
|
|
834
786
|
*************/
|
|
835
787
|
/**
|
|
836
788
|
* Check if component props are well configured on init
|
|
837
|
-
*
|
|
838
|
-
* @returns {void}
|
|
839
789
|
*/
|
|
840
790
|
componentWillLoad() {
|
|
841
791
|
// Get locales
|
|
@@ -862,8 +812,6 @@ const MgForm = class {
|
|
|
862
812
|
}
|
|
863
813
|
/**
|
|
864
814
|
* Add slot listeners
|
|
865
|
-
*
|
|
866
|
-
* @returns {void}
|
|
867
815
|
*/
|
|
868
816
|
componentDidLoad() {
|
|
869
817
|
this.mgButtons.forEach(mgButton => {
|
|
@@ -881,11 +829,10 @@ const MgForm = class {
|
|
|
881
829
|
}
|
|
882
830
|
/**
|
|
883
831
|
* Render
|
|
884
|
-
*
|
|
885
|
-
* @returns {HTMLElement} HTML Element
|
|
832
|
+
* @returns HTML Element
|
|
886
833
|
*/
|
|
887
834
|
render() {
|
|
888
|
-
return (index.h("form", { class: this.
|
|
835
|
+
return (index.h("form", { class: this.classCollection.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit }, this.requiredMessage && index.h("p", { innerHTML: this.requiredMessage }), index.h("slot", null), !this.readonly && !this.disabled && index.h("slot", { name: "actions" })));
|
|
889
836
|
}
|
|
890
837
|
get element() { return index.getElement(this); }
|
|
891
838
|
static get watchers() { return {
|
|
@@ -1132,24 +1079,31 @@ const MgIcon = class {
|
|
|
1132
1079
|
index.registerInstance(this, hostRef);
|
|
1133
1080
|
/**
|
|
1134
1081
|
* getIcon
|
|
1135
|
-
*
|
|
1136
|
-
* @returns {HTMLElement} icon html
|
|
1082
|
+
* @returns icon html
|
|
1137
1083
|
*/
|
|
1138
1084
|
this.getIcon = () => icons[this.icon]();
|
|
1085
|
+
/**
|
|
1086
|
+
* Method to set default varianStyle props
|
|
1087
|
+
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
1088
|
+
*/
|
|
1089
|
+
this.setDefaultVariantStyle = () => {
|
|
1090
|
+
if (this.variantStyle === undefined)
|
|
1091
|
+
this.variantStyle = 'background';
|
|
1092
|
+
};
|
|
1139
1093
|
this.icon = undefined;
|
|
1140
1094
|
this.size = 'regular';
|
|
1141
1095
|
this.variant = undefined;
|
|
1142
1096
|
this.variantStyle = undefined;
|
|
1143
1097
|
this.spin = false;
|
|
1144
|
-
this.
|
|
1098
|
+
this.classCollection = new ClassList(['mg-icon']);
|
|
1145
1099
|
}
|
|
1146
1100
|
validateIcon(newValue, oldValue) {
|
|
1147
1101
|
if (!Object.keys(icons).includes(newValue))
|
|
1148
1102
|
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
|
|
1149
1103
|
else {
|
|
1150
1104
|
if (oldValue !== undefined)
|
|
1151
|
-
this.
|
|
1152
|
-
this.
|
|
1105
|
+
this.classCollection.delete(`mg-icon--${oldValue}`);
|
|
1106
|
+
this.classCollection.add(`mg-icon--${newValue}`);
|
|
1153
1107
|
}
|
|
1154
1108
|
}
|
|
1155
1109
|
validateSize(newValue, oldValue) {
|
|
@@ -1157,8 +1111,8 @@ const MgIcon = class {
|
|
|
1157
1111
|
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes$1.join(', ')}`);
|
|
1158
1112
|
else {
|
|
1159
1113
|
if (oldValue !== undefined)
|
|
1160
|
-
this.
|
|
1161
|
-
this.
|
|
1114
|
+
this.classCollection.delete(`mg-icon--size-${oldValue}`);
|
|
1115
|
+
this.classCollection.add(`mg-icon--size-${newValue}`);
|
|
1162
1116
|
}
|
|
1163
1117
|
}
|
|
1164
1118
|
validateVariant(newValue, oldValue) {
|
|
@@ -1166,11 +1120,10 @@ const MgIcon = class {
|
|
|
1166
1120
|
if (!variants$2.includes(newValue))
|
|
1167
1121
|
throw new Error(`<mg-icon> prop "variant" must be one of: ${variants$2.join(', ')}`);
|
|
1168
1122
|
else {
|
|
1169
|
-
|
|
1170
|
-
this.variantStyle = 'background';
|
|
1123
|
+
this.setDefaultVariantStyle();
|
|
1171
1124
|
if (oldValue !== undefined)
|
|
1172
|
-
this.
|
|
1173
|
-
this.
|
|
1125
|
+
this.classCollection.delete(`mg-icon--variant-${oldValue}`);
|
|
1126
|
+
this.classCollection.add(`mg-icon--variant-${newValue}`);
|
|
1174
1127
|
}
|
|
1175
1128
|
}
|
|
1176
1129
|
}
|
|
@@ -1180,25 +1133,23 @@ const MgIcon = class {
|
|
|
1180
1133
|
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
|
|
1181
1134
|
else {
|
|
1182
1135
|
if (oldValue !== undefined)
|
|
1183
|
-
this.
|
|
1184
|
-
this.
|
|
1136
|
+
this.classCollection.delete(`mg-icon--variant-style-${oldValue}`);
|
|
1137
|
+
this.classCollection.add(`mg-icon--variant-style-${newValue}`);
|
|
1185
1138
|
}
|
|
1186
1139
|
}
|
|
1187
1140
|
}
|
|
1188
1141
|
handleSpin(newValue) {
|
|
1189
1142
|
if (newValue) {
|
|
1190
|
-
this.
|
|
1191
|
-
this.
|
|
1143
|
+
this.classCollection.add('mg-icon--spin');
|
|
1144
|
+
this.classCollection.add('mg-a11y-animation');
|
|
1192
1145
|
}
|
|
1193
1146
|
else {
|
|
1194
|
-
this.
|
|
1195
|
-
this.
|
|
1147
|
+
this.classCollection.delete('mg-icon--spin');
|
|
1148
|
+
this.classCollection.delete('mg-a11y-animation');
|
|
1196
1149
|
}
|
|
1197
1150
|
}
|
|
1198
1151
|
/**
|
|
1199
1152
|
* Check if props are well configured on init
|
|
1200
|
-
*
|
|
1201
|
-
* @returns {void}
|
|
1202
1153
|
*/
|
|
1203
1154
|
componentWillLoad() {
|
|
1204
1155
|
this.validateIcon(this.icon);
|
|
@@ -1209,11 +1160,10 @@ const MgIcon = class {
|
|
|
1209
1160
|
}
|
|
1210
1161
|
/**
|
|
1211
1162
|
* Render component
|
|
1212
|
-
*
|
|
1213
|
-
* @returns {HTMLElement} HTML Element
|
|
1163
|
+
* @returns HTML Element
|
|
1214
1164
|
*/
|
|
1215
1165
|
render() {
|
|
1216
|
-
return (index.h("svg", { class: this.
|
|
1166
|
+
return (index.h("svg", { class: this.classCollection.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
|
|
1217
1167
|
}
|
|
1218
1168
|
static get watchers() { return {
|
|
1219
1169
|
"icon": ["validateIcon"],
|
|
@@ -1238,8 +1188,6 @@ const MgIllustratedMessage = class {
|
|
|
1238
1188
|
*************/
|
|
1239
1189
|
/**
|
|
1240
1190
|
* Check if component props are well configured on init
|
|
1241
|
-
*
|
|
1242
|
-
* @returns {void}
|
|
1243
1191
|
*/
|
|
1244
1192
|
componentDidLoad() {
|
|
1245
1193
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -1254,8 +1202,7 @@ const MgIllustratedMessage = class {
|
|
|
1254
1202
|
}
|
|
1255
1203
|
/**
|
|
1256
1204
|
* Render
|
|
1257
|
-
*
|
|
1258
|
-
* @returns {HTMLElement} HTML Element
|
|
1205
|
+
* @returns HTML Element
|
|
1259
1206
|
*/
|
|
1260
1207
|
render() {
|
|
1261
1208
|
return (index.h("div", { class: {
|
|
@@ -1270,13 +1217,17 @@ const MgIllustratedMessage = class {
|
|
|
1270
1217
|
};
|
|
1271
1218
|
MgIllustratedMessage.style = mgIllustratedMessageCss;
|
|
1272
1219
|
|
|
1220
|
+
/**
|
|
1221
|
+
* Possible input width
|
|
1222
|
+
*/
|
|
1223
|
+
const widths = [2, 4, 16, 'full'];
|
|
1224
|
+
|
|
1273
1225
|
/**
|
|
1274
1226
|
* Apply in all input child node the aria-describedby attribute
|
|
1275
|
-
*
|
|
1276
|
-
* @param
|
|
1277
|
-
* @param
|
|
1278
|
-
* @
|
|
1279
|
-
* @returns {VNode[]} Children with aria-describedby attribute
|
|
1227
|
+
* @param children - Represent scoped elements
|
|
1228
|
+
* @param ariaDescribedbyIDs - List of IDs
|
|
1229
|
+
* @param utils - Stencil.js utils
|
|
1230
|
+
* @returns Children with aria-describedby attribute
|
|
1280
1231
|
*/
|
|
1281
1232
|
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
1282
1233
|
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
@@ -1289,32 +1240,36 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
|
|
|
1289
1240
|
});
|
|
1290
1241
|
/**
|
|
1291
1242
|
* Add classes based on props
|
|
1292
|
-
*
|
|
1293
|
-
* @param {MgInputProps} props MgInput Interface Props
|
|
1243
|
+
* @param props - MgInput Interface Props
|
|
1294
1244
|
*/
|
|
1295
1245
|
const manageClasses = (props) => {
|
|
1296
|
-
props.
|
|
1246
|
+
props.classCollection.add('mg-input');
|
|
1297
1247
|
if (props.labelOnTop)
|
|
1298
|
-
props.
|
|
1248
|
+
props.classCollection.add('mg-input--label-on-top');
|
|
1249
|
+
else
|
|
1250
|
+
props.classCollection.delete('mg-input--label-on-top');
|
|
1299
1251
|
if (props.readonly)
|
|
1300
|
-
props.
|
|
1252
|
+
props.classCollection.add('mg-input--readonly');
|
|
1253
|
+
else
|
|
1254
|
+
props.classCollection.delete('mg-input--readonly');
|
|
1255
|
+
widths.forEach(width => {
|
|
1256
|
+
props.classCollection.delete(`mg-input--width-${width}`);
|
|
1257
|
+
});
|
|
1301
1258
|
if (props.mgWidth !== undefined)
|
|
1302
|
-
props.
|
|
1259
|
+
props.classCollection.add(`mg-input--width-${props.mgWidth}`);
|
|
1303
1260
|
};
|
|
1304
1261
|
/**
|
|
1305
1262
|
* Get tagname
|
|
1306
|
-
*
|
|
1307
|
-
* @
|
|
1308
|
-
* @returns {string} tag name
|
|
1263
|
+
* @param isFieldset - is fieldset
|
|
1264
|
+
* @returns tag name
|
|
1309
1265
|
*/
|
|
1310
1266
|
const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
|
|
1311
1267
|
/**
|
|
1312
1268
|
* Get input template
|
|
1313
|
-
*
|
|
1314
|
-
* @param
|
|
1315
|
-
* @param
|
|
1316
|
-
* @
|
|
1317
|
-
* @returns {VNode[]} input template
|
|
1269
|
+
* @param props - MgInput Interface Props
|
|
1270
|
+
* @param children - Represent scoped elements
|
|
1271
|
+
* @param utils - Stencil.js utils
|
|
1272
|
+
* @returns input template
|
|
1318
1273
|
*/
|
|
1319
1274
|
const MgInput = (props, children, utils) => {
|
|
1320
1275
|
/**
|
|
@@ -1370,19 +1325,17 @@ const MgInput = (props, children, utils) => {
|
|
|
1370
1325
|
const TagName = getTagName(props.isFieldset);
|
|
1371
1326
|
/**
|
|
1372
1327
|
* Get tooltip node
|
|
1373
|
-
*
|
|
1374
|
-
* @returns {VNode[]} mg-tooltip
|
|
1328
|
+
* @returns mg-tooltip
|
|
1375
1329
|
*/
|
|
1376
1330
|
const getTooltip = () => (index.h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
|
|
1377
1331
|
index.h("mg-icon", { icon: "info-circle" })));
|
|
1378
1332
|
/**
|
|
1379
1333
|
* Get input title (label) node
|
|
1380
1334
|
* Display asterisk only if not disabled and not readonly
|
|
1381
|
-
*
|
|
1382
|
-
* @returns {VNode[]} mg-input-title
|
|
1335
|
+
* @returns mg-input-title
|
|
1383
1336
|
*/
|
|
1384
1337
|
const getInputTitle = () => (index.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));
|
|
1385
|
-
return (index.h(TagName, { class: props.
|
|
1338
|
+
return (index.h(TagName, { class: props.classCollection.join() },
|
|
1386
1339
|
props.labelOnTop ? (index.h("div", { class: "mg-input__title" },
|
|
1387
1340
|
getInputTitle(),
|
|
1388
1341
|
!props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
|
|
@@ -1400,9 +1353,8 @@ const mgInputCheckboxCss = ":host{display:block}.mg-input{display:flex;align-ite
|
|
|
1400
1353
|
|
|
1401
1354
|
/**
|
|
1402
1355
|
* type CheckboxItem validation function
|
|
1403
|
-
*
|
|
1404
|
-
* @
|
|
1405
|
-
* @returns {boolean} match item type
|
|
1356
|
+
* @param items - Checkbox item
|
|
1357
|
+
* @returns match item type
|
|
1406
1358
|
*/
|
|
1407
1359
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
1408
1360
|
items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
|
|
@@ -1420,8 +1372,7 @@ const MgInputCheckbox = class {
|
|
|
1420
1372
|
this.hasDisplayedError = false;
|
|
1421
1373
|
/**
|
|
1422
1374
|
* Handle input event
|
|
1423
|
-
*
|
|
1424
|
-
* @param {InputEvent} event input event
|
|
1375
|
+
* @param event - input event
|
|
1425
1376
|
*/
|
|
1426
1377
|
this.handleInput = (event) => {
|
|
1427
1378
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -1443,8 +1394,7 @@ const MgInputCheckbox = class {
|
|
|
1443
1394
|
};
|
|
1444
1395
|
/**
|
|
1445
1396
|
* get invalid element
|
|
1446
|
-
*
|
|
1447
|
-
* @returns {HTMLInputElement} element
|
|
1397
|
+
* @returns element
|
|
1448
1398
|
*/
|
|
1449
1399
|
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
1450
1400
|
/**
|
|
@@ -1481,7 +1431,7 @@ const MgInputCheckbox = class {
|
|
|
1481
1431
|
this.helpText = undefined;
|
|
1482
1432
|
this.valid = undefined;
|
|
1483
1433
|
this.invalid = undefined;
|
|
1484
|
-
this.
|
|
1434
|
+
this.classCollection = new ClassList(['mg-input--checkbox']);
|
|
1485
1435
|
this.errorMessage = undefined;
|
|
1486
1436
|
this.checkboxItems = [];
|
|
1487
1437
|
}
|
|
@@ -1511,8 +1461,6 @@ const MgInputCheckbox = class {
|
|
|
1511
1461
|
}
|
|
1512
1462
|
/**
|
|
1513
1463
|
* Public method to display errors
|
|
1514
|
-
*
|
|
1515
|
-
* @returns {Promise<void>}
|
|
1516
1464
|
*/
|
|
1517
1465
|
async displayError() {
|
|
1518
1466
|
this.checkValidity();
|
|
@@ -1524,8 +1472,7 @@ const MgInputCheckbox = class {
|
|
|
1524
1472
|
*************/
|
|
1525
1473
|
/**
|
|
1526
1474
|
* Check if component props are well configured on init
|
|
1527
|
-
*
|
|
1528
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
1475
|
+
* @returns timeout
|
|
1529
1476
|
*/
|
|
1530
1477
|
componentWillLoad() {
|
|
1531
1478
|
// Get locales
|
|
@@ -1541,11 +1488,10 @@ const MgInputCheckbox = class {
|
|
|
1541
1488
|
}
|
|
1542
1489
|
/**
|
|
1543
1490
|
* Render
|
|
1544
|
-
*
|
|
1545
|
-
* @returns {HTMLElement} HTML Element
|
|
1491
|
+
* @returns HTML Element
|
|
1546
1492
|
*/
|
|
1547
1493
|
render() {
|
|
1548
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
1494
|
+
return (index.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 }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.checkboxItems
|
|
1549
1495
|
.filter(item => {
|
|
1550
1496
|
return !this.readonly || item.value;
|
|
1551
1497
|
})
|
|
@@ -1609,8 +1555,7 @@ const MgInputDate = class {
|
|
|
1609
1555
|
};
|
|
1610
1556
|
/**
|
|
1611
1557
|
* get input error code
|
|
1612
|
-
*
|
|
1613
|
-
* @returns {null | InputError} error code
|
|
1558
|
+
* @returns error code
|
|
1614
1559
|
*/
|
|
1615
1560
|
this.getInputError = () => {
|
|
1616
1561
|
var _a, _b;
|
|
@@ -1635,8 +1580,6 @@ const MgInputDate = class {
|
|
|
1635
1580
|
};
|
|
1636
1581
|
/**
|
|
1637
1582
|
* Check input errors
|
|
1638
|
-
*
|
|
1639
|
-
* @returns {void}
|
|
1640
1583
|
*/
|
|
1641
1584
|
this.setErrorMessage = () => {
|
|
1642
1585
|
var _a;
|
|
@@ -1674,7 +1617,7 @@ const MgInputDate = class {
|
|
|
1674
1617
|
this.invalid = undefined;
|
|
1675
1618
|
this.min = undefined;
|
|
1676
1619
|
this.max = undefined;
|
|
1677
|
-
this.
|
|
1620
|
+
this.classCollection = new ClassList(['mg-input--date']);
|
|
1678
1621
|
this.errorMessage = undefined;
|
|
1679
1622
|
}
|
|
1680
1623
|
validateValue(newValue) {
|
|
@@ -1705,8 +1648,6 @@ const MgInputDate = class {
|
|
|
1705
1648
|
}
|
|
1706
1649
|
/**
|
|
1707
1650
|
* Public method to display errors
|
|
1708
|
-
*
|
|
1709
|
-
* @returns {Promise<void>}
|
|
1710
1651
|
*/
|
|
1711
1652
|
async displayError() {
|
|
1712
1653
|
this.checkValidity();
|
|
@@ -1718,8 +1659,7 @@ const MgInputDate = class {
|
|
|
1718
1659
|
*************/
|
|
1719
1660
|
/**
|
|
1720
1661
|
* Check if component props are well configured on init
|
|
1721
|
-
*
|
|
1722
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
1662
|
+
* @returns timeout
|
|
1723
1663
|
*/
|
|
1724
1664
|
componentWillLoad() {
|
|
1725
1665
|
// Get locales
|
|
@@ -1739,11 +1679,10 @@ const MgInputDate = class {
|
|
|
1739
1679
|
}
|
|
1740
1680
|
/**
|
|
1741
1681
|
* Render
|
|
1742
|
-
*
|
|
1743
|
-
* @returns {HTMLElement} HTML Element
|
|
1682
|
+
* @returns HTML Element
|
|
1744
1683
|
*/
|
|
1745
1684
|
render() {
|
|
1746
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
1685
|
+
return (index.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: mgMenu_conf.localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.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 => {
|
|
1747
1686
|
if (el !== null)
|
|
1748
1687
|
this.input = el;
|
|
1749
1688
|
} })));
|
|
@@ -1783,8 +1722,6 @@ const MgInputNumeric = class {
|
|
|
1783
1722
|
this.hasDisplayedError = false;
|
|
1784
1723
|
/**
|
|
1785
1724
|
* Handle input event
|
|
1786
|
-
*
|
|
1787
|
-
* @returns {void}
|
|
1788
1725
|
*/
|
|
1789
1726
|
this.handleInput = () => {
|
|
1790
1727
|
// Check validity
|
|
@@ -1796,26 +1733,22 @@ const MgInputNumeric = class {
|
|
|
1796
1733
|
};
|
|
1797
1734
|
/**
|
|
1798
1735
|
* Handle focus event
|
|
1799
|
-
*
|
|
1800
|
-
* @returns {void}
|
|
1801
1736
|
*/
|
|
1802
1737
|
this.handleFocus = () => {
|
|
1803
1738
|
this.hasFocus = true;
|
|
1804
1739
|
};
|
|
1805
1740
|
/**
|
|
1806
1741
|
* Handle blur event
|
|
1807
|
-
*
|
|
1808
|
-
* @returns {void}
|
|
1809
1742
|
*/
|
|
1810
1743
|
this.handleBlur = () => {
|
|
1744
|
+
if (this.value === '-')
|
|
1745
|
+
this.value = '';
|
|
1811
1746
|
// Display Error
|
|
1812
1747
|
this.displayError();
|
|
1813
1748
|
this.hasFocus = false;
|
|
1814
1749
|
};
|
|
1815
1750
|
/**
|
|
1816
1751
|
* Check if input is valid
|
|
1817
|
-
*
|
|
1818
|
-
* @returns {void}
|
|
1819
1752
|
*/
|
|
1820
1753
|
this.checkValidity = () => {
|
|
1821
1754
|
this.valid = this.readonly || this.disabled || this.getInputError() === null;
|
|
@@ -1825,8 +1758,6 @@ const MgInputNumeric = class {
|
|
|
1825
1758
|
};
|
|
1826
1759
|
/**
|
|
1827
1760
|
* Set input error message
|
|
1828
|
-
*
|
|
1829
|
-
* @returns {void}
|
|
1830
1761
|
*/
|
|
1831
1762
|
this.setErrorMessage = () => {
|
|
1832
1763
|
// Set error message
|
|
@@ -1843,8 +1774,7 @@ const MgInputNumeric = class {
|
|
|
1843
1774
|
};
|
|
1844
1775
|
/**
|
|
1845
1776
|
* Get input error code
|
|
1846
|
-
*
|
|
1847
|
-
* @returns {null | InputError} error code
|
|
1777
|
+
* @returns error code
|
|
1848
1778
|
*/
|
|
1849
1779
|
this.getInputError = () => {
|
|
1850
1780
|
let inputError = null;
|
|
@@ -1872,20 +1802,17 @@ const MgInputNumeric = class {
|
|
|
1872
1802
|
};
|
|
1873
1803
|
/**
|
|
1874
1804
|
* Format value based on type
|
|
1875
|
-
*
|
|
1876
|
-
* @
|
|
1877
|
-
* @returns {string} formated local value
|
|
1805
|
+
* @param value - value to format
|
|
1806
|
+
* @returns formated local value
|
|
1878
1807
|
*/
|
|
1879
1808
|
this.formatValue = (value) => (this.type === 'currency' ? mgMenu_conf.localeCurrency(value, this.locale, this.currency) : mgMenu_conf.localeNumber(value, this.locale));
|
|
1880
1809
|
/**
|
|
1881
1810
|
* Validate append slot
|
|
1882
|
-
*
|
|
1883
|
-
* @returns {void}
|
|
1884
1811
|
*/
|
|
1885
1812
|
this.validateAppendSlot = () => {
|
|
1886
1813
|
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
1887
1814
|
if (slotAppendInput !== null) {
|
|
1888
|
-
this.
|
|
1815
|
+
this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
1889
1816
|
}
|
|
1890
1817
|
};
|
|
1891
1818
|
this.value = undefined;
|
|
@@ -1909,7 +1836,7 @@ const MgInputNumeric = class {
|
|
|
1909
1836
|
this.decimalLength = 2;
|
|
1910
1837
|
this.valid = undefined;
|
|
1911
1838
|
this.invalid = undefined;
|
|
1912
|
-
this.
|
|
1839
|
+
this.classCollection = new ClassList(['mg-input--numeric']);
|
|
1913
1840
|
this.errorMessage = undefined;
|
|
1914
1841
|
this.hasFocus = false;
|
|
1915
1842
|
}
|
|
@@ -1921,7 +1848,7 @@ const MgInputNumeric = class {
|
|
|
1921
1848
|
// Regex
|
|
1922
1849
|
const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+[.,]?\d*$/;
|
|
1923
1850
|
// Filter input
|
|
1924
|
-
if (
|
|
1851
|
+
if (['', '-'].includes(newValue) || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
1925
1852
|
this.storedValue = newValue;
|
|
1926
1853
|
}
|
|
1927
1854
|
else if (this.storedValue !== undefined) {
|
|
@@ -1968,8 +1895,6 @@ const MgInputNumeric = class {
|
|
|
1968
1895
|
}
|
|
1969
1896
|
/**
|
|
1970
1897
|
* Public method to display errors
|
|
1971
|
-
*
|
|
1972
|
-
* @returns {Promise<void>}
|
|
1973
1898
|
*/
|
|
1974
1899
|
async displayError() {
|
|
1975
1900
|
this.checkValidity();
|
|
@@ -1979,8 +1904,7 @@ const MgInputNumeric = class {
|
|
|
1979
1904
|
/**
|
|
1980
1905
|
* Displayed value in input
|
|
1981
1906
|
* Change on focus/blur
|
|
1982
|
-
*
|
|
1983
|
-
* @returns {MgInputNumeric['value'] | MgInputNumeric['readonlyValue']} display value
|
|
1907
|
+
* @returns display value
|
|
1984
1908
|
*/
|
|
1985
1909
|
displayValue() {
|
|
1986
1910
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -1990,8 +1914,7 @@ const MgInputNumeric = class {
|
|
|
1990
1914
|
*************/
|
|
1991
1915
|
/**
|
|
1992
1916
|
* Check if component props are well configured on init
|
|
1993
|
-
*
|
|
1994
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
1917
|
+
* @returns timeout
|
|
1995
1918
|
*/
|
|
1996
1919
|
componentWillLoad() {
|
|
1997
1920
|
// Get locales
|
|
@@ -2014,11 +1937,10 @@ const MgInputNumeric = class {
|
|
|
2014
1937
|
}
|
|
2015
1938
|
/**
|
|
2016
1939
|
* Render
|
|
2017
|
-
*
|
|
2018
|
-
* @returns {HTMLElement} HTML Element
|
|
1940
|
+
* @returns HTML Element
|
|
2019
1941
|
*/
|
|
2020
1942
|
render() {
|
|
2021
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
1943
|
+
return (index.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 }, index.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 => {
|
|
2022
1944
|
if (el !== null)
|
|
2023
1945
|
this.input = el;
|
|
2024
1946
|
} }), index.h("slot", { name: "append-input" })));
|
|
@@ -2097,7 +2019,7 @@ const MgInputPassword = class {
|
|
|
2097
2019
|
this.helpText = undefined;
|
|
2098
2020
|
this.valid = undefined;
|
|
2099
2021
|
this.invalid = undefined;
|
|
2100
|
-
this.
|
|
2022
|
+
this.classCollection = new ClassList(['mg-input--password']);
|
|
2101
2023
|
this.errorMessage = undefined;
|
|
2102
2024
|
}
|
|
2103
2025
|
handleValue(newValue) {
|
|
@@ -2115,8 +2037,6 @@ const MgInputPassword = class {
|
|
|
2115
2037
|
}
|
|
2116
2038
|
/**
|
|
2117
2039
|
* Public method to display errors
|
|
2118
|
-
*
|
|
2119
|
-
* @returns {Promise<void>}
|
|
2120
2040
|
*/
|
|
2121
2041
|
async displayError() {
|
|
2122
2042
|
this.checkValidity();
|
|
@@ -2128,8 +2048,7 @@ const MgInputPassword = class {
|
|
|
2128
2048
|
*************/
|
|
2129
2049
|
/**
|
|
2130
2050
|
* Check if component props are well configured on init
|
|
2131
|
-
*
|
|
2132
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2051
|
+
* @returns timeout
|
|
2133
2052
|
*/
|
|
2134
2053
|
componentWillLoad() {
|
|
2135
2054
|
// Get locales
|
|
@@ -2143,11 +2062,10 @@ const MgInputPassword = class {
|
|
|
2143
2062
|
}
|
|
2144
2063
|
/**
|
|
2145
2064
|
* Render
|
|
2146
|
-
*
|
|
2147
|
-
* @returns {HTMLElement} HTML Element
|
|
2065
|
+
* @returns HTML Element
|
|
2148
2066
|
*/
|
|
2149
2067
|
render() {
|
|
2150
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2068
|
+
return (index.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 }, index.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 => {
|
|
2151
2069
|
if (el !== null)
|
|
2152
2070
|
this.input = el;
|
|
2153
2071
|
} })));
|
|
@@ -2166,9 +2084,8 @@ const mgInputRadioCss = ":host{display:block}.mg-input{display:flex;align-items:
|
|
|
2166
2084
|
|
|
2167
2085
|
/**
|
|
2168
2086
|
* type Option validation function
|
|
2169
|
-
*
|
|
2170
|
-
* @
|
|
2171
|
-
* @returns {boolean} radio option type is valid
|
|
2087
|
+
* @param option - radio option
|
|
2088
|
+
* @returns radio option type is valid
|
|
2172
2089
|
*/
|
|
2173
2090
|
const isOption$2 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
2174
2091
|
const MgInputRadio = class {
|
|
@@ -2185,9 +2102,7 @@ const MgInputRadio = class {
|
|
|
2185
2102
|
this.hasDisplayedError = false;
|
|
2186
2103
|
/**
|
|
2187
2104
|
* Handle input event
|
|
2188
|
-
*
|
|
2189
|
-
* @param {event} event input event
|
|
2190
|
-
* @returns {void}
|
|
2105
|
+
* @param event - input event
|
|
2191
2106
|
*/
|
|
2192
2107
|
this.handleInput = (event) => {
|
|
2193
2108
|
this.checkValidity();
|
|
@@ -2195,8 +2110,6 @@ const MgInputRadio = class {
|
|
|
2195
2110
|
};
|
|
2196
2111
|
/**
|
|
2197
2112
|
* Handle blur event
|
|
2198
|
-
*
|
|
2199
|
-
* @returns {void}
|
|
2200
2113
|
*/
|
|
2201
2114
|
this.handleBlur = () => {
|
|
2202
2115
|
this.checkValidity();
|
|
@@ -2204,8 +2117,6 @@ const MgInputRadio = class {
|
|
|
2204
2117
|
};
|
|
2205
2118
|
/**
|
|
2206
2119
|
* Check if input is valid
|
|
2207
|
-
*
|
|
2208
|
-
* @returns {void}
|
|
2209
2120
|
*/
|
|
2210
2121
|
this.checkValidity = () => {
|
|
2211
2122
|
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
@@ -2215,8 +2126,6 @@ const MgInputRadio = class {
|
|
|
2215
2126
|
};
|
|
2216
2127
|
/**
|
|
2217
2128
|
* Set input error message
|
|
2218
|
-
*
|
|
2219
|
-
* @returns {void}
|
|
2220
2129
|
*/
|
|
2221
2130
|
this.setErrorMessage = () => {
|
|
2222
2131
|
const invalidElement = this.getInvalidElement();
|
|
@@ -2228,8 +2137,7 @@ const MgInputRadio = class {
|
|
|
2228
2137
|
};
|
|
2229
2138
|
/**
|
|
2230
2139
|
* get invalid element
|
|
2231
|
-
*
|
|
2232
|
-
* @returns {HTMLInputElement} element
|
|
2140
|
+
* @returns element
|
|
2233
2141
|
*/
|
|
2234
2142
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
2235
2143
|
this.value = undefined;
|
|
@@ -2247,7 +2155,7 @@ const MgInputRadio = class {
|
|
|
2247
2155
|
this.helpText = undefined;
|
|
2248
2156
|
this.valid = undefined;
|
|
2249
2157
|
this.invalid = undefined;
|
|
2250
|
-
this.
|
|
2158
|
+
this.classCollection = new ClassList(['mg-input--radio']);
|
|
2251
2159
|
this.errorMessage = undefined;
|
|
2252
2160
|
this.options = undefined;
|
|
2253
2161
|
}
|
|
@@ -2283,8 +2191,6 @@ const MgInputRadio = class {
|
|
|
2283
2191
|
}
|
|
2284
2192
|
/**
|
|
2285
2193
|
* Public method to display errors
|
|
2286
|
-
*
|
|
2287
|
-
* @returns {Promise<void>}
|
|
2288
2194
|
*/
|
|
2289
2195
|
async displayError() {
|
|
2290
2196
|
this.checkValidity();
|
|
@@ -2296,8 +2202,7 @@ const MgInputRadio = class {
|
|
|
2296
2202
|
*************/
|
|
2297
2203
|
/**
|
|
2298
2204
|
* Check if component props are well configured on init
|
|
2299
|
-
*
|
|
2300
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2205
|
+
* @returns timeout
|
|
2301
2206
|
*/
|
|
2302
2207
|
componentWillLoad() {
|
|
2303
2208
|
// Get locales
|
|
@@ -2313,11 +2218,10 @@ const MgInputRadio = class {
|
|
|
2313
2218
|
}
|
|
2314
2219
|
/**
|
|
2315
2220
|
* Render
|
|
2316
|
-
*
|
|
2317
|
-
* @returns {HTMLElement} HTML Element
|
|
2221
|
+
* @returns HTML Element
|
|
2318
2222
|
*/
|
|
2319
2223
|
render() {
|
|
2320
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2224
|
+
return (index.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 }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.options.map((input, index$1) => (index.h("li", { key: input.title, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "radio", id: this.identifier + '_' + index$1, name: this.identifier, value: index$1, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index$1].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => {
|
|
2321
2225
|
if (el !== null)
|
|
2322
2226
|
this.inputs[index$1] = el;
|
|
2323
2227
|
} }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title)))))));
|
|
@@ -2337,35 +2241,27 @@ const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items
|
|
|
2337
2241
|
|
|
2338
2242
|
/**
|
|
2339
2243
|
* Check if item is a well configured option
|
|
2340
|
-
*
|
|
2341
|
-
* @
|
|
2342
|
-
* @returns {boolean} select option type is valid
|
|
2244
|
+
* @param option - select option
|
|
2245
|
+
* @returns select option type is valid
|
|
2343
2246
|
*/
|
|
2344
2247
|
const isOption$1 = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
2345
2248
|
/**
|
|
2346
2249
|
* Check if items[] is SelectOption
|
|
2347
|
-
*
|
|
2348
|
-
* @
|
|
2349
|
-
* @returns {boolean} select option array type is valid
|
|
2250
|
+
* @param items - select option
|
|
2251
|
+
* @returns select option array type is valid
|
|
2350
2252
|
*/
|
|
2351
2253
|
const allItemsAreOptions = (items) => Array.isArray(items) && items.every(item => isOption$1(item));
|
|
2352
2254
|
/**
|
|
2353
2255
|
* Check if item is a well configured optgroup
|
|
2354
|
-
*
|
|
2355
|
-
* @
|
|
2356
|
-
* @returns {boolean} select optgroup type is valid
|
|
2256
|
+
* @param optgroup - select option
|
|
2257
|
+
* @returns select optgroup type is valid
|
|
2357
2258
|
*/
|
|
2358
2259
|
const isOptGroup = (optgroup) => typeof optgroup === 'object' && typeof optgroup.group === 'string' && allItemsAreOptions(optgroup.options);
|
|
2359
2260
|
/**
|
|
2360
2261
|
* Group options
|
|
2361
|
-
*
|
|
2362
|
-
* @param
|
|
2363
|
-
* @
|
|
2364
|
-
* @param {string} item.group item group
|
|
2365
|
-
* @param {string} item.title item title
|
|
2366
|
-
* @param {unknown} item.value item value
|
|
2367
|
-
* @param {boolean} item.disabled is item disabled
|
|
2368
|
-
* @returns {(SelectOption | OptGroup)[]} grouped options
|
|
2262
|
+
* @param acc - reduce accumulator
|
|
2263
|
+
* @param item - item to add
|
|
2264
|
+
* @returns grouped options
|
|
2369
2265
|
*/
|
|
2370
2266
|
const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
2371
2267
|
if (group !== undefined) {
|
|
@@ -2394,8 +2290,6 @@ const MgInputSelect = class {
|
|
|
2394
2290
|
this.hasDisplayedError = false;
|
|
2395
2291
|
/**
|
|
2396
2292
|
* Handle input event
|
|
2397
|
-
*
|
|
2398
|
-
* @returns {void}
|
|
2399
2293
|
*/
|
|
2400
2294
|
this.handleInput = () => {
|
|
2401
2295
|
this.updateValue();
|
|
@@ -2404,16 +2298,13 @@ const MgInputSelect = class {
|
|
|
2404
2298
|
};
|
|
2405
2299
|
/**
|
|
2406
2300
|
* Method to compare item.title with input.value
|
|
2407
|
-
*
|
|
2408
|
-
* @
|
|
2409
|
-
* @returns {boolean} truthy if input.value is an item
|
|
2301
|
+
* @param item - item to compare with
|
|
2302
|
+
* @returns truthy if input.value is an item
|
|
2410
2303
|
*/
|
|
2411
2304
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
2412
2305
|
/**
|
|
2413
2306
|
* value props setter
|
|
2414
|
-
*
|
|
2415
|
-
* @param {MgInputSelect['value']} newValue value to update with
|
|
2416
|
-
* @returns {void}
|
|
2307
|
+
* @param newValue - value to update with
|
|
2417
2308
|
*/
|
|
2418
2309
|
this.setValue = (newValue) => {
|
|
2419
2310
|
this.checkValidity();
|
|
@@ -2421,8 +2312,6 @@ const MgInputSelect = class {
|
|
|
2421
2312
|
};
|
|
2422
2313
|
/**
|
|
2423
2314
|
* Update value from input.value
|
|
2424
|
-
*
|
|
2425
|
-
* @returns {void}
|
|
2426
2315
|
*/
|
|
2427
2316
|
this.updateValue = () => {
|
|
2428
2317
|
if (this.input.value === '') {
|
|
@@ -2448,8 +2337,7 @@ const MgInputSelect = class {
|
|
|
2448
2337
|
};
|
|
2449
2338
|
/**
|
|
2450
2339
|
* Input value is disabled
|
|
2451
|
-
*
|
|
2452
|
-
* @returns {boolean} truthy if input value is disabled
|
|
2340
|
+
* @returns truthy if input value is disabled
|
|
2453
2341
|
*/
|
|
2454
2342
|
this.isDisabledValue = () => { var _a; return allItemsAreOptions(this.options) && ((_a = this.options.find(this.isInputValue)) === null || _a === void 0 ? void 0 : _a.disabled) === true; };
|
|
2455
2343
|
/**
|
|
@@ -2474,9 +2362,8 @@ const MgInputSelect = class {
|
|
|
2474
2362
|
};
|
|
2475
2363
|
/**
|
|
2476
2364
|
* Render option
|
|
2477
|
-
*
|
|
2478
|
-
* @
|
|
2479
|
-
* @returns {HTMLElement} render option
|
|
2365
|
+
* @param option - to render
|
|
2366
|
+
* @returns render option
|
|
2480
2367
|
*/
|
|
2481
2368
|
this.renderOption = (option) => (index.h("option", { key: option.title, value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title));
|
|
2482
2369
|
this.value = undefined;
|
|
@@ -2497,7 +2384,7 @@ const MgInputSelect = class {
|
|
|
2497
2384
|
this.helpText = undefined;
|
|
2498
2385
|
this.valid = undefined;
|
|
2499
2386
|
this.invalid = undefined;
|
|
2500
|
-
this.
|
|
2387
|
+
this.classCollection = new ClassList(['mg-input--select']);
|
|
2501
2388
|
this.errorMessage = undefined;
|
|
2502
2389
|
this.options = undefined;
|
|
2503
2390
|
this.valueExist = undefined;
|
|
@@ -2555,8 +2442,6 @@ const MgInputSelect = class {
|
|
|
2555
2442
|
}
|
|
2556
2443
|
/**
|
|
2557
2444
|
* Public method to display errors
|
|
2558
|
-
*
|
|
2559
|
-
* @returns {Promise<void>}
|
|
2560
2445
|
*/
|
|
2561
2446
|
async displayError() {
|
|
2562
2447
|
this.checkValidity();
|
|
@@ -2568,8 +2453,7 @@ const MgInputSelect = class {
|
|
|
2568
2453
|
*************/
|
|
2569
2454
|
/**
|
|
2570
2455
|
* Check if component props are well configured on init
|
|
2571
|
-
*
|
|
2572
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2456
|
+
* @returns timeout
|
|
2573
2457
|
*/
|
|
2574
2458
|
componentWillLoad() {
|
|
2575
2459
|
// Get locales
|
|
@@ -2590,11 +2474,10 @@ const MgInputSelect = class {
|
|
|
2590
2474
|
}
|
|
2591
2475
|
/**
|
|
2592
2476
|
* Render
|
|
2593
|
-
*
|
|
2594
|
-
* @returns {HTMLElement} HTML Element
|
|
2477
|
+
* @returns HTML Element
|
|
2595
2478
|
*/
|
|
2596
2479
|
render() {
|
|
2597
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2480
|
+
return (index.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 }, index.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 => {
|
|
2598
2481
|
if (el !== null)
|
|
2599
2482
|
this.input = el;
|
|
2600
2483
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -2629,8 +2512,6 @@ const MgInputText = class {
|
|
|
2629
2512
|
this.hasDisplayedError = false;
|
|
2630
2513
|
/**
|
|
2631
2514
|
* Handle input event
|
|
2632
|
-
*
|
|
2633
|
-
* @returns {void}
|
|
2634
2515
|
*/
|
|
2635
2516
|
this.handleInput = () => {
|
|
2636
2517
|
this.checkValidity();
|
|
@@ -2641,29 +2522,23 @@ const MgInputText = class {
|
|
|
2641
2522
|
};
|
|
2642
2523
|
/**
|
|
2643
2524
|
* Handle focus event
|
|
2644
|
-
*
|
|
2645
|
-
* @returns {void}
|
|
2646
2525
|
*/
|
|
2647
2526
|
this.handleFocus = () => {
|
|
2648
|
-
this.
|
|
2649
|
-
this.
|
|
2527
|
+
this.classCollection.add(this.classFocus);
|
|
2528
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2650
2529
|
};
|
|
2651
2530
|
/**
|
|
2652
2531
|
* Handle blur event
|
|
2653
|
-
*
|
|
2654
|
-
* @returns {void}
|
|
2655
2532
|
*/
|
|
2656
2533
|
this.handleBlur = () => {
|
|
2657
2534
|
// Manage focus
|
|
2658
|
-
this.
|
|
2659
|
-
this.
|
|
2535
|
+
this.classCollection.delete(this.classFocus);
|
|
2536
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2660
2537
|
// Display Error
|
|
2661
2538
|
this.displayError();
|
|
2662
2539
|
};
|
|
2663
2540
|
/**
|
|
2664
2541
|
* Check if input is valid
|
|
2665
|
-
*
|
|
2666
|
-
* @returns {void}
|
|
2667
2542
|
*/
|
|
2668
2543
|
this.checkValidity = () => {
|
|
2669
2544
|
var _a;
|
|
@@ -2674,8 +2549,6 @@ const MgInputText = class {
|
|
|
2674
2549
|
};
|
|
2675
2550
|
/**
|
|
2676
2551
|
* Set input error message
|
|
2677
|
-
*
|
|
2678
|
-
* @returns {void}
|
|
2679
2552
|
*/
|
|
2680
2553
|
this.setErrorMessage = () => {
|
|
2681
2554
|
// Set error message
|
|
@@ -2691,11 +2564,9 @@ const MgInputText = class {
|
|
|
2691
2564
|
};
|
|
2692
2565
|
/**
|
|
2693
2566
|
* Validate pattern configuration
|
|
2694
|
-
*
|
|
2695
|
-
* @returns {void}
|
|
2696
2567
|
*/
|
|
2697
2568
|
this.validatePattern = () => {
|
|
2698
|
-
if (this.pattern &&
|
|
2569
|
+
if (this.pattern !== undefined &&
|
|
2699
2570
|
typeof this.pattern === 'string' &&
|
|
2700
2571
|
this.pattern !== '' &&
|
|
2701
2572
|
(this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
|
|
@@ -2704,17 +2575,15 @@ const MgInputText = class {
|
|
|
2704
2575
|
};
|
|
2705
2576
|
/**
|
|
2706
2577
|
* Validate append slot
|
|
2707
|
-
*
|
|
2708
|
-
* @returns {void}
|
|
2709
2578
|
*/
|
|
2710
2579
|
this.validateAppendSlot = () => {
|
|
2711
2580
|
const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
|
|
2712
2581
|
if (slotAppendInput.length === 1) {
|
|
2713
|
-
this.
|
|
2582
|
+
this.classCollection.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.classIsInputGroupAppend : 'mg-input--is-append-input-slot-content');
|
|
2714
2583
|
}
|
|
2715
2584
|
else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
|
|
2716
|
-
this.
|
|
2717
|
-
this.
|
|
2585
|
+
this.classCollection.add(this.classIsInputGroupAppend);
|
|
2586
|
+
this.classCollection.add('mg-input--has-buttons-group-append');
|
|
2718
2587
|
}
|
|
2719
2588
|
};
|
|
2720
2589
|
this.value = undefined;
|
|
@@ -2738,7 +2607,7 @@ const MgInputText = class {
|
|
|
2738
2607
|
this.helpText = undefined;
|
|
2739
2608
|
this.valid = undefined;
|
|
2740
2609
|
this.invalid = undefined;
|
|
2741
|
-
this.
|
|
2610
|
+
this.classCollection = new ClassList(['mg-input--text']);
|
|
2742
2611
|
this.errorMessage = undefined;
|
|
2743
2612
|
}
|
|
2744
2613
|
handleValue(newValue) {
|
|
@@ -2746,10 +2615,10 @@ const MgInputText = class {
|
|
|
2746
2615
|
}
|
|
2747
2616
|
validateIcon(newValue) {
|
|
2748
2617
|
if (newValue !== undefined) {
|
|
2749
|
-
this.
|
|
2618
|
+
this.classCollection.add(this.classHasIcon);
|
|
2750
2619
|
}
|
|
2751
2620
|
else {
|
|
2752
|
-
this.
|
|
2621
|
+
this.classCollection.delete(this.classHasIcon);
|
|
2753
2622
|
}
|
|
2754
2623
|
}
|
|
2755
2624
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -2764,16 +2633,12 @@ const MgInputText = class {
|
|
|
2764
2633
|
}
|
|
2765
2634
|
/**
|
|
2766
2635
|
* Public method to play input focus
|
|
2767
|
-
*
|
|
2768
|
-
* @returns {Promise<void>}
|
|
2769
2636
|
*/
|
|
2770
2637
|
async setFocus() {
|
|
2771
2638
|
this.input.focus();
|
|
2772
2639
|
}
|
|
2773
2640
|
/**
|
|
2774
2641
|
* Public method to display errors
|
|
2775
|
-
*
|
|
2776
|
-
* @returns {Promise<void>}
|
|
2777
2642
|
*/
|
|
2778
2643
|
async displayError() {
|
|
2779
2644
|
this.checkValidity();
|
|
@@ -2785,8 +2650,7 @@ const MgInputText = class {
|
|
|
2785
2650
|
*************/
|
|
2786
2651
|
/**
|
|
2787
2652
|
* Check if component props are well configured on init
|
|
2788
|
-
*
|
|
2789
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2653
|
+
* @returns timeout
|
|
2790
2654
|
*/
|
|
2791
2655
|
componentWillLoad() {
|
|
2792
2656
|
// Get locales
|
|
@@ -2805,11 +2669,10 @@ const MgInputText = class {
|
|
|
2805
2669
|
}
|
|
2806
2670
|
/**
|
|
2807
2671
|
* Render
|
|
2808
|
-
*
|
|
2809
|
-
* @returns {HTMLElement} HTML Element
|
|
2672
|
+
* @returns HTML Element
|
|
2810
2673
|
*/
|
|
2811
2674
|
render() {
|
|
2812
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2675
|
+
return (index.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 }, index.h("div", { class: "mg-input__with-character-left", style: {
|
|
2813
2676
|
'--mg-character-left-message-length': (this.displayCharacterLeft
|
|
2814
2677
|
? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
|
|
2815
2678
|
: 0).toString(),
|
|
@@ -2858,24 +2721,23 @@ const MgInputTextarea = class {
|
|
|
2858
2721
|
* Handle focus event
|
|
2859
2722
|
*/
|
|
2860
2723
|
this.handleFocus = () => {
|
|
2861
|
-
this.
|
|
2862
|
-
this.
|
|
2724
|
+
this.classCollection.add(this.classFocus);
|
|
2725
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2863
2726
|
};
|
|
2864
2727
|
/**
|
|
2865
2728
|
* Handle blur event
|
|
2866
2729
|
*/
|
|
2867
2730
|
this.handleBlur = () => {
|
|
2868
2731
|
// Manage focus
|
|
2869
|
-
this.
|
|
2870
|
-
this.
|
|
2732
|
+
this.classCollection.delete(this.classFocus);
|
|
2733
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2871
2734
|
// Display Error
|
|
2872
2735
|
this.displayError();
|
|
2873
2736
|
};
|
|
2874
2737
|
/**
|
|
2875
2738
|
* Get pattern validity
|
|
2876
2739
|
* Pattern is not defined on textarea field: https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
|
|
2877
|
-
*
|
|
2878
|
-
* @returns {boolean} is pattern valid
|
|
2740
|
+
* @returns is pattern valid
|
|
2879
2741
|
*/
|
|
2880
2742
|
this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
|
|
2881
2743
|
/**
|
|
@@ -2907,7 +2769,7 @@ const MgInputTextarea = class {
|
|
|
2907
2769
|
* Validate pattern configuration
|
|
2908
2770
|
*/
|
|
2909
2771
|
this.validatePattern = () => {
|
|
2910
|
-
if (this.pattern &&
|
|
2772
|
+
if (this.pattern !== undefined &&
|
|
2911
2773
|
typeof this.pattern === 'string' &&
|
|
2912
2774
|
this.pattern !== '' &&
|
|
2913
2775
|
(this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
|
|
@@ -2935,7 +2797,7 @@ const MgInputTextarea = class {
|
|
|
2935
2797
|
this.valid = undefined;
|
|
2936
2798
|
this.invalid = undefined;
|
|
2937
2799
|
this.resizable = 'none';
|
|
2938
|
-
this.
|
|
2800
|
+
this.classCollection = new ClassList(['mg-input--textarea']);
|
|
2939
2801
|
this.errorMessage = undefined;
|
|
2940
2802
|
}
|
|
2941
2803
|
handleValue(newValue) {
|
|
@@ -2954,16 +2816,14 @@ const MgInputTextarea = class {
|
|
|
2954
2816
|
}
|
|
2955
2817
|
validateDisplayCharacterLeft(newValue) {
|
|
2956
2818
|
if (newValue) {
|
|
2957
|
-
this.
|
|
2819
|
+
this.classCollection.add(this.classHasDisplayCharacterLeft);
|
|
2958
2820
|
}
|
|
2959
2821
|
else {
|
|
2960
|
-
this.
|
|
2822
|
+
this.classCollection.delete(this.classHasDisplayCharacterLeft);
|
|
2961
2823
|
}
|
|
2962
2824
|
}
|
|
2963
2825
|
/**
|
|
2964
2826
|
* Public method to display errors
|
|
2965
|
-
*
|
|
2966
|
-
* @returns {Promise<void>}
|
|
2967
2827
|
*/
|
|
2968
2828
|
async displayError() {
|
|
2969
2829
|
this.checkValidity();
|
|
@@ -2975,8 +2835,7 @@ const MgInputTextarea = class {
|
|
|
2975
2835
|
*************/
|
|
2976
2836
|
/**
|
|
2977
2837
|
* Check if component props are well configured on init
|
|
2978
|
-
*
|
|
2979
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2838
|
+
* @returns timeout
|
|
2980
2839
|
*/
|
|
2981
2840
|
componentWillLoad() {
|
|
2982
2841
|
// Get locales
|
|
@@ -2994,11 +2853,10 @@ const MgInputTextarea = class {
|
|
|
2994
2853
|
}
|
|
2995
2854
|
/**
|
|
2996
2855
|
* Render
|
|
2997
|
-
*
|
|
2998
|
-
* @returns {HTMLElement} HTML Element
|
|
2856
|
+
* @returns HTML Element
|
|
2999
2857
|
*/
|
|
3000
2858
|
render() {
|
|
3001
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2859
|
+
return (index.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 }, index.h("div", { class: "mg-input__with-character-left" }, index.h("textarea", { class: {
|
|
3002
2860
|
'mg-input__box': true,
|
|
3003
2861
|
'mg-input__box--resizable': this.resizable === 'both',
|
|
3004
2862
|
'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
@@ -3042,8 +2900,6 @@ const MgInputTitle = class {
|
|
|
3042
2900
|
*************/
|
|
3043
2901
|
/**
|
|
3044
2902
|
* Init tag name
|
|
3045
|
-
*
|
|
3046
|
-
* @returns {void}
|
|
3047
2903
|
*/
|
|
3048
2904
|
componentWillLoad() {
|
|
3049
2905
|
this.validateIdentifier(this.identifier);
|
|
@@ -3051,8 +2907,7 @@ const MgInputTitle = class {
|
|
|
3051
2907
|
}
|
|
3052
2908
|
/**
|
|
3053
2909
|
* Render
|
|
3054
|
-
*
|
|
3055
|
-
* @returns {HTMLElement} HTML Element
|
|
2910
|
+
* @returns HTML element
|
|
3056
2911
|
*/
|
|
3057
2912
|
render() {
|
|
3058
2913
|
const TagName = this.tagName;
|
|
@@ -3069,9 +2924,8 @@ const mgInputToggleCss = ":host{display:block}.mg-input{display:flex;align-items
|
|
|
3069
2924
|
|
|
3070
2925
|
/**
|
|
3071
2926
|
* type Option validation function
|
|
3072
|
-
*
|
|
3073
|
-
* @
|
|
3074
|
-
* @returns {boolean} toggle option type is valid
|
|
2927
|
+
* @param option - radio option
|
|
2928
|
+
* @returns toggle option type is valid
|
|
3075
2929
|
*/
|
|
3076
2930
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
3077
2931
|
const MgInputToggle = class {
|
|
@@ -3090,16 +2944,12 @@ const MgInputToggle = class {
|
|
|
3090
2944
|
this.classIcon = 'mg-input--toggle-icon';
|
|
3091
2945
|
/**
|
|
3092
2946
|
* Change checked value
|
|
3093
|
-
*
|
|
3094
|
-
* @returns {void}
|
|
3095
2947
|
*/
|
|
3096
2948
|
this.toggleChecked = () => {
|
|
3097
2949
|
this.checked = !this.checked;
|
|
3098
2950
|
};
|
|
3099
2951
|
/**
|
|
3100
2952
|
* Slots validation
|
|
3101
|
-
*
|
|
3102
|
-
* @returns {void}
|
|
3103
2953
|
*/
|
|
3104
2954
|
this.validateSlots = () => {
|
|
3105
2955
|
const slots = Array.from(this.element.children);
|
|
@@ -3125,7 +2975,7 @@ const MgInputToggle = class {
|
|
|
3125
2975
|
this.disabled = false;
|
|
3126
2976
|
this.tooltip = undefined;
|
|
3127
2977
|
this.helpText = undefined;
|
|
3128
|
-
this.
|
|
2978
|
+
this.classCollection = new ClassList(['mg-input--toggle']);
|
|
3129
2979
|
this.options = undefined;
|
|
3130
2980
|
this.checked = false;
|
|
3131
2981
|
}
|
|
@@ -3153,41 +3003,39 @@ const MgInputToggle = class {
|
|
|
3153
3003
|
}
|
|
3154
3004
|
handleIsOnOff(newValue) {
|
|
3155
3005
|
if (newValue)
|
|
3156
|
-
this.
|
|
3006
|
+
this.classCollection.add(this.classOnOff);
|
|
3157
3007
|
else
|
|
3158
|
-
this.
|
|
3008
|
+
this.classCollection.delete(this.classOnOff);
|
|
3159
3009
|
}
|
|
3160
3010
|
handleIsIcon(newValue) {
|
|
3161
3011
|
if (newValue)
|
|
3162
|
-
this.
|
|
3012
|
+
this.classCollection.add(this.classIcon);
|
|
3163
3013
|
else
|
|
3164
|
-
this.
|
|
3014
|
+
this.classCollection.delete(this.classIcon);
|
|
3165
3015
|
}
|
|
3166
3016
|
handleReadonly(newValue) {
|
|
3167
3017
|
if (newValue)
|
|
3168
|
-
this.
|
|
3018
|
+
this.classCollection.add(this.classReadonly);
|
|
3169
3019
|
else
|
|
3170
|
-
this.
|
|
3020
|
+
this.classCollection.delete(this.classReadonly);
|
|
3171
3021
|
}
|
|
3172
3022
|
handleDisabled(newValue) {
|
|
3173
3023
|
if (newValue)
|
|
3174
|
-
this.
|
|
3024
|
+
this.classCollection.add(this.classDisabled);
|
|
3175
3025
|
else
|
|
3176
|
-
this.
|
|
3026
|
+
this.classCollection.delete(this.classDisabled);
|
|
3177
3027
|
}
|
|
3178
3028
|
handleChecked(newValue) {
|
|
3179
3029
|
// style
|
|
3180
3030
|
if (newValue)
|
|
3181
|
-
this.
|
|
3031
|
+
this.classCollection.add(this.classIsActive);
|
|
3182
3032
|
else
|
|
3183
|
-
this.
|
|
3033
|
+
this.classCollection.delete(this.classIsActive);
|
|
3184
3034
|
// update value
|
|
3185
3035
|
this.value = this.options[newValue ? 1 : 0].value;
|
|
3186
3036
|
}
|
|
3187
3037
|
/**
|
|
3188
3038
|
* set checked state
|
|
3189
|
-
*
|
|
3190
|
-
* @returns {void}
|
|
3191
3039
|
*/
|
|
3192
3040
|
setChecked() {
|
|
3193
3041
|
const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);
|
|
@@ -3229,11 +3077,10 @@ const MgInputToggle = class {
|
|
|
3229
3077
|
}
|
|
3230
3078
|
/**
|
|
3231
3079
|
* Render
|
|
3232
|
-
*
|
|
3233
|
-
* @returns {HTMLElement} HTML Element
|
|
3080
|
+
* @returns HTML Element
|
|
3234
3081
|
*/
|
|
3235
3082
|
render() {
|
|
3236
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
3083
|
+
return (index.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 }, index.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 }, index.h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, index.h("slot", { name: "item-1" })), index.h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, index.h("slot", { name: "item-2" })))));
|
|
3237
3084
|
}
|
|
3238
3085
|
get element() { return index.getElement(this); }
|
|
3239
3086
|
static get watchers() { return {
|
|
@@ -3264,10 +3111,8 @@ const MgMenu = class {
|
|
|
3264
3111
|
*************/
|
|
3265
3112
|
/**
|
|
3266
3113
|
* Close matching menu-item
|
|
3267
|
-
*
|
|
3268
|
-
* @param
|
|
3269
|
-
* @param {boolean} condition addionnal condition
|
|
3270
|
-
* @returns {void}
|
|
3114
|
+
* @param item - menu-item to close
|
|
3115
|
+
* @param condition - addionnal condition
|
|
3271
3116
|
*/
|
|
3272
3117
|
this.closeMenuItem = (item, condition) => {
|
|
3273
3118
|
if (!this.isChildMenu && condition) {
|
|
@@ -3276,22 +3121,18 @@ const MgMenu = class {
|
|
|
3276
3121
|
};
|
|
3277
3122
|
/**
|
|
3278
3123
|
* get mg-item-more element
|
|
3279
|
-
*
|
|
3280
|
-
* @returns {HTMLMgItemMoreElement} mg-item-more element
|
|
3124
|
+
* @returns mg-item-more element
|
|
3281
3125
|
*/
|
|
3282
3126
|
this.getItemMore = () => this.element.querySelector('mg-item-more');
|
|
3283
3127
|
/**
|
|
3284
|
-
* get mg-item-more
|
|
3285
|
-
*
|
|
3286
|
-
* @returns {HTMLMgMenuItemElement} mg-item-more >>> mg-menu-item element
|
|
3128
|
+
* get mg-item-more child mg-menu-item element
|
|
3129
|
+
* @returns mg-menu-item element
|
|
3287
3130
|
*/
|
|
3288
3131
|
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'); };
|
|
3289
3132
|
/**
|
|
3290
3133
|
* Set item listend
|
|
3291
|
-
*
|
|
3292
|
-
* @param
|
|
3293
|
-
* @param {MgMenu['focusedMenuItem']} index number
|
|
3294
|
-
* @returns {void}
|
|
3134
|
+
* @param item - mg-menu-item element
|
|
3135
|
+
* @param index - number
|
|
3295
3136
|
*/
|
|
3296
3137
|
this.setItemListener = (item, index) => {
|
|
3297
3138
|
['click', 'focus'].forEach(trigger => {
|
|
@@ -3306,8 +3147,6 @@ const MgMenu = class {
|
|
|
3306
3147
|
};
|
|
3307
3148
|
/**
|
|
3308
3149
|
* Store menu-items on component init and add listeners
|
|
3309
|
-
*
|
|
3310
|
-
* @returns {void}
|
|
3311
3150
|
*/
|
|
3312
3151
|
this.initMenuItemsListeners = () => {
|
|
3313
3152
|
// add listeners on menu item and edit index
|
|
@@ -3317,16 +3156,12 @@ const MgMenu = class {
|
|
|
3317
3156
|
};
|
|
3318
3157
|
/**
|
|
3319
3158
|
* Handle item-loaded event on mg-item-more element
|
|
3320
|
-
*
|
|
3321
|
-
* @returns {void}
|
|
3322
3159
|
*/
|
|
3323
3160
|
this.handleItemLoaded = () => {
|
|
3324
3161
|
this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);
|
|
3325
3162
|
};
|
|
3326
3163
|
/**
|
|
3327
3164
|
* render mg-item-more
|
|
3328
|
-
*
|
|
3329
|
-
* @returns {void}
|
|
3330
3165
|
*/
|
|
3331
3166
|
this.renderMgItemMore = () => {
|
|
3332
3167
|
// /!\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement
|
|
@@ -3368,8 +3203,6 @@ const MgMenu = class {
|
|
|
3368
3203
|
*************/
|
|
3369
3204
|
/**
|
|
3370
3205
|
* Validate props
|
|
3371
|
-
*
|
|
3372
|
-
* @returns {void}
|
|
3373
3206
|
*/
|
|
3374
3207
|
componentWillLoad() {
|
|
3375
3208
|
this.validateDirection(this.direction);
|
|
@@ -3379,8 +3212,7 @@ const MgMenu = class {
|
|
|
3379
3212
|
}
|
|
3380
3213
|
/**
|
|
3381
3214
|
* Check if component slots configuration
|
|
3382
|
-
*
|
|
3383
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
3215
|
+
* @returns timeout
|
|
3384
3216
|
*/
|
|
3385
3217
|
componentDidLoad() {
|
|
3386
3218
|
// update props and states after componentDidLoad hook
|
|
@@ -3410,16 +3242,13 @@ const MgMenu = class {
|
|
|
3410
3242
|
}
|
|
3411
3243
|
/**
|
|
3412
3244
|
* Add listeners to items
|
|
3413
|
-
*
|
|
3414
|
-
* @returns {void}
|
|
3415
3245
|
*/
|
|
3416
3246
|
componentDidRender() {
|
|
3417
3247
|
this.initMenuItemsListeners();
|
|
3418
3248
|
}
|
|
3419
3249
|
/**
|
|
3420
3250
|
* Render
|
|
3421
|
-
*
|
|
3422
|
-
* @returns {HTMLElement} HTML Element
|
|
3251
|
+
* @returns HTML Element
|
|
3423
3252
|
*/
|
|
3424
3253
|
render() {
|
|
3425
3254
|
return (index.h(index.Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, index.h("slot", null)));
|
|
@@ -3451,33 +3280,27 @@ const MgMenuItem = class {
|
|
|
3451
3280
|
**********/
|
|
3452
3281
|
/**
|
|
3453
3282
|
* Toggle expanded prop value
|
|
3454
|
-
*
|
|
3455
|
-
* @returns {void}
|
|
3456
3283
|
*/
|
|
3457
3284
|
this.toggleExpanded = () => {
|
|
3458
3285
|
this.expanded = !this.expanded;
|
|
3459
3286
|
};
|
|
3460
3287
|
/**
|
|
3461
3288
|
* Does an Element have given Status
|
|
3462
|
-
*
|
|
3463
|
-
* @param
|
|
3464
|
-
* @
|
|
3465
|
-
* @returns {boolean} true if element with status is found
|
|
3289
|
+
* @param mgMenuItemElement - to parse
|
|
3290
|
+
* @param status - to check
|
|
3291
|
+
* @returns true if element with status is found
|
|
3466
3292
|
*/
|
|
3467
3293
|
this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
|
|
3468
3294
|
/**
|
|
3469
3295
|
* Is component contextual direction match the given direction
|
|
3470
|
-
*
|
|
3471
|
-
* @param
|
|
3472
|
-
* @
|
|
3473
|
-
* @returns {boolean} true is direction match the direction propertie
|
|
3296
|
+
* @param direction - in parent menu
|
|
3297
|
+
* @param compareWith - direction to compare with. Default: `this.direction`
|
|
3298
|
+
* @returns true is direction match the direction propertie
|
|
3474
3299
|
*/
|
|
3475
3300
|
this.isDirection = (direction, compareWith = this.direction) => direction === compareWith;
|
|
3476
3301
|
/**
|
|
3477
3302
|
* Update displayNotificationBadge
|
|
3478
3303
|
* current component notification badge have priority over the slot badge when submenu contain badge
|
|
3479
|
-
*
|
|
3480
|
-
* @returns {void} update displayNotificationBadge value
|
|
3481
3304
|
*/
|
|
3482
3305
|
this.updateDisplayNotificationBadge = () => {
|
|
3483
3306
|
const childMenu = this.element.querySelector('mg-menu');
|
|
@@ -3487,8 +3310,7 @@ const MgMenuItem = class {
|
|
|
3487
3310
|
};
|
|
3488
3311
|
/**
|
|
3489
3312
|
* Method to control if one of component children have active status
|
|
3490
|
-
*
|
|
3491
|
-
* @returns {boolean} truthy if component has active child
|
|
3313
|
+
* @returns truthy if component has active child
|
|
3492
3314
|
*/
|
|
3493
3315
|
this.hasActiveChild = () => {
|
|
3494
3316
|
var _a;
|
|
@@ -3496,9 +3318,7 @@ const MgMenuItem = class {
|
|
|
3496
3318
|
};
|
|
3497
3319
|
/**
|
|
3498
3320
|
* Validate slots
|
|
3499
|
-
*
|
|
3500
|
-
* @param {boolean} guard prevent action whith guard. Default: false.
|
|
3501
|
-
* @returns {void}
|
|
3321
|
+
* @param guard - prevent action whith guard. Default: false.
|
|
3502
3322
|
*/
|
|
3503
3323
|
this.validateSlot = (guard = false) => {
|
|
3504
3324
|
// slot title AND metadata validation
|
|
@@ -3516,9 +3336,7 @@ const MgMenuItem = class {
|
|
|
3516
3336
|
};
|
|
3517
3337
|
/**
|
|
3518
3338
|
* Update status
|
|
3519
|
-
*
|
|
3520
|
-
* @param {Status[]} guard status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
3521
|
-
* @returns {void}
|
|
3339
|
+
* @param guard - status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
3522
3340
|
*/
|
|
3523
3341
|
this.updateStatus = (guard = []) => {
|
|
3524
3342
|
if (![Status$1.HIDDEN, Status$1.DISABLED, ...guard].includes(this.status)) {
|
|
@@ -3527,8 +3345,6 @@ const MgMenuItem = class {
|
|
|
3527
3345
|
};
|
|
3528
3346
|
/**
|
|
3529
3347
|
* Init event-listeners
|
|
3530
|
-
*
|
|
3531
|
-
* @returns {void}
|
|
3532
3348
|
*/
|
|
3533
3349
|
this.initListeners = () => {
|
|
3534
3350
|
var _a;
|
|
@@ -3544,14 +3360,12 @@ const MgMenuItem = class {
|
|
|
3544
3360
|
};
|
|
3545
3361
|
/**
|
|
3546
3362
|
* Get mg-popover identifier
|
|
3547
|
-
*
|
|
3548
|
-
* @returns {MgPopover['identifier']} generated mg-popover identifier
|
|
3363
|
+
* @returns generated mg-popover identifier
|
|
3549
3364
|
*/
|
|
3550
3365
|
this.getPopoverIdentifier = () => `${this.identifier}-popover`;
|
|
3551
3366
|
/**
|
|
3552
3367
|
* Condition to know if component should display a mg-popover
|
|
3553
|
-
*
|
|
3554
|
-
* @returns {boolean} truthy if component display popover
|
|
3368
|
+
* @returns truthy if component display popover
|
|
3555
3369
|
*/
|
|
3556
3370
|
this.displayPopover = () => this.isDirection(mgMenu_conf.Direction.HORIZONTAL) && this.hasChildren && this.href === undefined;
|
|
3557
3371
|
/************
|
|
@@ -3559,9 +3373,7 @@ const MgMenuItem = class {
|
|
|
3559
3373
|
************/
|
|
3560
3374
|
/**
|
|
3561
3375
|
* Handle interacrtive element click
|
|
3562
|
-
*
|
|
3563
|
-
* @param {MouseEvent} event click on element
|
|
3564
|
-
* @returns {void}
|
|
3376
|
+
* @param event - click on element
|
|
3565
3377
|
*/
|
|
3566
3378
|
this.handleElementCLick = (event) => {
|
|
3567
3379
|
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status$1.DISABLED) {
|
|
@@ -3574,17 +3386,14 @@ const MgMenuItem = class {
|
|
|
3574
3386
|
};
|
|
3575
3387
|
/**
|
|
3576
3388
|
* Handle popover element display-change event
|
|
3577
|
-
*
|
|
3578
|
-
* @param {CustomEvent} event popover display event
|
|
3579
|
-
* @returns {void}
|
|
3389
|
+
* @param event - popover display event
|
|
3580
3390
|
*/
|
|
3581
3391
|
this.handlePopoverDisplay = (event) => {
|
|
3582
3392
|
this.expanded = event.detail;
|
|
3583
3393
|
};
|
|
3584
3394
|
/**
|
|
3585
3395
|
* Render slot
|
|
3586
|
-
*
|
|
3587
|
-
* @returns {HTMLElement} HTML Element
|
|
3396
|
+
* @returns HTML Element
|
|
3588
3397
|
*/
|
|
3589
3398
|
this.renderSlot = () => index.h("slot", null);
|
|
3590
3399
|
this.identifier = createID('mg-menu-item');
|
|
@@ -3650,8 +3459,6 @@ const MgMenuItem = class {
|
|
|
3650
3459
|
}
|
|
3651
3460
|
/**
|
|
3652
3461
|
* Render popover clickoutside guard for content slot
|
|
3653
|
-
*
|
|
3654
|
-
* @returns {void}
|
|
3655
3462
|
*/
|
|
3656
3463
|
updatePopoverGuard() {
|
|
3657
3464
|
if (this.displayPopover())
|
|
@@ -3664,8 +3471,6 @@ const MgMenuItem = class {
|
|
|
3664
3471
|
*************/
|
|
3665
3472
|
/**
|
|
3666
3473
|
* Validate props
|
|
3667
|
-
*
|
|
3668
|
-
* @returns {void}
|
|
3669
3474
|
*/
|
|
3670
3475
|
componentWillLoad() {
|
|
3671
3476
|
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
@@ -3681,8 +3486,7 @@ const MgMenuItem = class {
|
|
|
3681
3486
|
}
|
|
3682
3487
|
/**
|
|
3683
3488
|
* Check if component slots configuration
|
|
3684
|
-
*
|
|
3685
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
3489
|
+
* @returns timeout
|
|
3686
3490
|
*/
|
|
3687
3491
|
componentDidLoad() {
|
|
3688
3492
|
// validation
|
|
@@ -3721,8 +3525,7 @@ const MgMenuItem = class {
|
|
|
3721
3525
|
}
|
|
3722
3526
|
/**
|
|
3723
3527
|
* Render ineractive element
|
|
3724
|
-
*
|
|
3725
|
-
* @returns {HTMLElement} HTML Element
|
|
3528
|
+
* @returns HTML Element
|
|
3726
3529
|
*/
|
|
3727
3530
|
renderInteractiveElement() {
|
|
3728
3531
|
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
@@ -3734,8 +3537,7 @@ const MgMenuItem = class {
|
|
|
3734
3537
|
}
|
|
3735
3538
|
/**
|
|
3736
3539
|
* Render
|
|
3737
|
-
*
|
|
3738
|
-
* @returns {HTMLElement} HTML Element
|
|
3540
|
+
* @returns HTML Element
|
|
3739
3541
|
*/
|
|
3740
3542
|
render() {
|
|
3741
3543
|
const getContainerClasses = () => ({
|
|
@@ -3784,25 +3586,19 @@ const MgMessage = class {
|
|
|
3784
3586
|
this.isHovered = false;
|
|
3785
3587
|
/**
|
|
3786
3588
|
* Set timer
|
|
3787
|
-
*
|
|
3788
|
-
* @returns {void}
|
|
3789
3589
|
*/
|
|
3790
3590
|
this.setTimer = () => {
|
|
3791
3591
|
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
3792
3592
|
};
|
|
3793
3593
|
/**
|
|
3794
3594
|
* Clear timer
|
|
3795
|
-
*
|
|
3796
|
-
* @returns {void}
|
|
3797
3595
|
*/
|
|
3798
3596
|
this.clearTimer = () => {
|
|
3799
3597
|
clearTimeout(this.storedTimer);
|
|
3800
3598
|
};
|
|
3801
3599
|
/**
|
|
3802
3600
|
* Event to add on element
|
|
3803
|
-
*
|
|
3804
|
-
* @param {MouseEvent | FocusEvent} event event
|
|
3805
|
-
* @returns {void}
|
|
3601
|
+
* @param event - event
|
|
3806
3602
|
*/
|
|
3807
3603
|
this.timerEvents = (event) => {
|
|
3808
3604
|
this.clearTimer();
|
|
@@ -3825,8 +3621,7 @@ const MgMessage = class {
|
|
|
3825
3621
|
};
|
|
3826
3622
|
/**
|
|
3827
3623
|
* Get icon corresponding to variant
|
|
3828
|
-
*
|
|
3829
|
-
* @returns {string} icon
|
|
3624
|
+
* @returns icon
|
|
3830
3625
|
*/
|
|
3831
3626
|
this.getIcon = () => {
|
|
3832
3627
|
switch (this.variant) {
|
|
@@ -3845,11 +3640,11 @@ const MgMessage = class {
|
|
|
3845
3640
|
this.variant = variants$1[0];
|
|
3846
3641
|
this.closeButton = false;
|
|
3847
3642
|
this.hide = false;
|
|
3848
|
-
this.
|
|
3643
|
+
this.classCollection = new ClassList(['mg-message']);
|
|
3849
3644
|
this.hasActions = false;
|
|
3850
3645
|
}
|
|
3851
3646
|
validateDelay(newValue) {
|
|
3852
|
-
if (newValue && newValue < 2) {
|
|
3647
|
+
if (newValue !== undefined && newValue < 2) {
|
|
3853
3648
|
throw new Error(`<mg-message> prop "delay" must be greater than 2 seconds.`);
|
|
3854
3649
|
}
|
|
3855
3650
|
}
|
|
@@ -3859,9 +3654,9 @@ const MgMessage = class {
|
|
|
3859
3654
|
}
|
|
3860
3655
|
else {
|
|
3861
3656
|
if (oldValue !== undefined) {
|
|
3862
|
-
this.
|
|
3657
|
+
this.classCollection.delete(`mg-message--${oldValue}`);
|
|
3863
3658
|
}
|
|
3864
|
-
this.
|
|
3659
|
+
this.classCollection.add(`mg-message--${newValue}`);
|
|
3865
3660
|
}
|
|
3866
3661
|
}
|
|
3867
3662
|
validateCloseButton(newValue) {
|
|
@@ -3873,7 +3668,7 @@ const MgMessage = class {
|
|
|
3873
3668
|
validateHide(newValue) {
|
|
3874
3669
|
if (newValue) {
|
|
3875
3670
|
this.componentHide.emit();
|
|
3876
|
-
this.
|
|
3671
|
+
this.classCollection.add(this.classHide);
|
|
3877
3672
|
// Remove event Listener
|
|
3878
3673
|
['focusin', 'mouseenter'].forEach(event => {
|
|
3879
3674
|
this.element.removeEventListener(event, this.timerEvents);
|
|
@@ -3883,7 +3678,7 @@ const MgMessage = class {
|
|
|
3883
3678
|
}
|
|
3884
3679
|
else {
|
|
3885
3680
|
this.componentShow.emit();
|
|
3886
|
-
this.
|
|
3681
|
+
this.classCollection.delete(this.classHide);
|
|
3887
3682
|
// If delay is set
|
|
3888
3683
|
if (this.delay > 1) {
|
|
3889
3684
|
// Start timer
|
|
@@ -3910,7 +3705,7 @@ const MgMessage = class {
|
|
|
3910
3705
|
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
3911
3706
|
this.validateCloseButton(this.closeButton);
|
|
3912
3707
|
if (this.closeButton) {
|
|
3913
|
-
this.
|
|
3708
|
+
this.classCollection.add('mg-message--close-button');
|
|
3914
3709
|
this.closeButtonId = `${this.identifier}-close-button`;
|
|
3915
3710
|
}
|
|
3916
3711
|
this.validateDelay(this.delay);
|
|
@@ -3918,11 +3713,10 @@ const MgMessage = class {
|
|
|
3918
3713
|
}
|
|
3919
3714
|
/**
|
|
3920
3715
|
* Render
|
|
3921
|
-
*
|
|
3922
|
-
* @returns {HTMLElement} HTML Element
|
|
3716
|
+
* @returns HTML Element
|
|
3923
3717
|
*/
|
|
3924
3718
|
render() {
|
|
3925
|
-
return (index.h("div", { id: this.identifier, class: this.
|
|
3719
|
+
return (index.h("div", { id: this.identifier, class: this.classCollection.join(), role: this.variant === 'info' ? 'status' : 'alert' }, index.h("mg-card", { variant: this.variant, "variant-style": "bar-left" }, index.h("span", { class: "mg-message__icon" }, index.h("mg-icon", { icon: this.getIcon() })), index.h("div", { class: "mg-message__content" }, index.h("span", { class: "mg-message__content-slot" }, index.h("slot", null)), this.hasActions && index.h("span", { class: "mg-message__content-separator" }), this.hasActions && (index.h("span", { class: "mg-message__content-actions-slot" }, index.h("slot", { name: "actions" })))), this.closeButton && (index.h("span", { class: "mg-message__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" })))))));
|
|
3926
3720
|
}
|
|
3927
3721
|
get element() { return index.getElement(this); }
|
|
3928
3722
|
static get watchers() { return {
|
|
@@ -3982,8 +3776,6 @@ const MgModal = class {
|
|
|
3982
3776
|
*************/
|
|
3983
3777
|
/**
|
|
3984
3778
|
* Handle close button
|
|
3985
|
-
*
|
|
3986
|
-
* @returns {void}
|
|
3987
3779
|
*/
|
|
3988
3780
|
this.handleClose = () => {
|
|
3989
3781
|
this.hide = true;
|
|
@@ -3994,7 +3786,7 @@ const MgModal = class {
|
|
|
3994
3786
|
this.hide = false;
|
|
3995
3787
|
this.hasActions = false;
|
|
3996
3788
|
this.hasContent = false;
|
|
3997
|
-
this.
|
|
3789
|
+
this.classCollection = new ClassList(['mg-modal']);
|
|
3998
3790
|
}
|
|
3999
3791
|
validateModalTitle(newValue) {
|
|
4000
3792
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -4004,20 +3796,18 @@ const MgModal = class {
|
|
|
4004
3796
|
validateHide(newValue) {
|
|
4005
3797
|
if (newValue) {
|
|
4006
3798
|
this.componentHide.emit();
|
|
4007
|
-
this.
|
|
3799
|
+
this.classCollection.add(this.classHide);
|
|
4008
3800
|
document.body.style.overflow = this.bodyOverflow;
|
|
4009
3801
|
}
|
|
4010
3802
|
else {
|
|
4011
3803
|
this.componentShow.emit();
|
|
4012
|
-
this.
|
|
3804
|
+
this.classCollection.delete(this.classHide);
|
|
4013
3805
|
document.body.style.overflow = 'hidden';
|
|
4014
3806
|
}
|
|
4015
3807
|
}
|
|
4016
3808
|
/**
|
|
4017
3809
|
* Handle 'escape' key down
|
|
4018
|
-
*
|
|
4019
|
-
* @param {KeyboardEvent} event keydown event
|
|
4020
|
-
* @returns {void}
|
|
3810
|
+
* @param event - keydown event
|
|
4021
3811
|
*/
|
|
4022
3812
|
handleKeyDown(event) {
|
|
4023
3813
|
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
@@ -4030,8 +3820,6 @@ const MgModal = class {
|
|
|
4030
3820
|
*************/
|
|
4031
3821
|
/**
|
|
4032
3822
|
* Check if component props are well configured on init
|
|
4033
|
-
*
|
|
4034
|
-
* @returns {void}
|
|
4035
3823
|
*/
|
|
4036
3824
|
componentWillLoad() {
|
|
4037
3825
|
// Store body overflow
|
|
@@ -4050,8 +3838,6 @@ const MgModal = class {
|
|
|
4050
3838
|
}
|
|
4051
3839
|
/**
|
|
4052
3840
|
* Add observer on component to set focus when displayed
|
|
4053
|
-
*
|
|
4054
|
-
* @returns {void}
|
|
4055
3841
|
*/
|
|
4056
3842
|
componentDidLoad() {
|
|
4057
3843
|
new MutationObserver(mutationList => {
|
|
@@ -4066,11 +3852,10 @@ const MgModal = class {
|
|
|
4066
3852
|
}
|
|
4067
3853
|
/**
|
|
4068
3854
|
* Render
|
|
4069
|
-
*
|
|
4070
|
-
* @returns {HTMLElement} HTML Element
|
|
3855
|
+
* @returns HTML Element
|
|
4071
3856
|
*/
|
|
4072
3857
|
render() {
|
|
4073
|
-
return (index.h("div", { role: "alertdialog", id: this.identifier, class: this.
|
|
3858
|
+
return (index.h("div", { role: "alertdialog", id: this.identifier, class: this.classCollection.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, index.h("mg-card", null, index.h("div", { class: "mg-modal__dialog" }, index.h("header", { class: "mg-modal__header" }, this.closeButton && (index.h("span", { class: "mg-modal__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" })))), index.h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (index.h("article", { class: "mg-modal__content" }, index.h("slot", { name: "content" }))), this.hasActions && (index.h("footer", { class: "mg-modal__footer" }, index.h("slot", { name: "actions" })))))));
|
|
4074
3859
|
}
|
|
4075
3860
|
get element() { return index.getElement(this); }
|
|
4076
3861
|
static get watchers() { return {
|
|
@@ -4091,6 +3876,7 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
4091
3876
|
/**
|
|
4092
3877
|
* Range generator
|
|
4093
3878
|
*
|
|
3879
|
+
* ```
|
|
4094
3880
|
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
4095
3881
|
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
4096
3882
|
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
@@ -4098,15 +3884,15 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
4098
3884
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
4099
3885
|
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
4100
3886
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
3887
|
+
* ```
|
|
4101
3888
|
*
|
|
4102
3889
|
* range(1, 1) = [1]
|
|
4103
3890
|
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
4104
3891
|
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
4105
|
-
*
|
|
4106
|
-
* @param
|
|
4107
|
-
* @param
|
|
4108
|
-
* @
|
|
4109
|
-
* @returns {number[]} range numbers
|
|
3892
|
+
* @param start - start range
|
|
3893
|
+
* @param end - start end
|
|
3894
|
+
* @param step - step size
|
|
3895
|
+
* @returns range numbers
|
|
4110
3896
|
*/
|
|
4111
3897
|
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
4112
3898
|
const MgPagination = class {
|
|
@@ -4115,9 +3901,7 @@ const MgPagination = class {
|
|
|
4115
3901
|
this.currentPageChange = index.createEvent(this, "current-page-change", 7);
|
|
4116
3902
|
/**
|
|
4117
3903
|
* Change current page from target
|
|
4118
|
-
*
|
|
4119
|
-
* @param {number} target target page
|
|
4120
|
-
* @returns {void}
|
|
3904
|
+
* @param target - target page
|
|
4121
3905
|
*/
|
|
4122
3906
|
this.goToPage = (target) => {
|
|
4123
3907
|
this.currentPage = target;
|
|
@@ -4127,9 +3911,7 @@ const MgPagination = class {
|
|
|
4127
3911
|
************/
|
|
4128
3912
|
/**
|
|
4129
3913
|
* select handler
|
|
4130
|
-
*
|
|
4131
|
-
* @param {InputEvent} event value change event
|
|
4132
|
-
* @returns {void}
|
|
3914
|
+
* @param event - value change event
|
|
4133
3915
|
*/
|
|
4134
3916
|
this.handleSelect = (event) => {
|
|
4135
3917
|
const to = Number(event.target.value);
|
|
@@ -4137,10 +3919,8 @@ const MgPagination = class {
|
|
|
4137
3919
|
};
|
|
4138
3920
|
/**
|
|
4139
3921
|
* Go to 'previous/next' page button handler
|
|
4140
|
-
*
|
|
4141
|
-
* @param
|
|
4142
|
-
* @param {boolean} disabled button disable state
|
|
4143
|
-
* @returns {void}
|
|
3922
|
+
* @param action - navigation action
|
|
3923
|
+
* @param disabled - button disable state
|
|
4144
3924
|
*/
|
|
4145
3925
|
this.handleGoToPage = (action, disabled) => {
|
|
4146
3926
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
@@ -4170,8 +3950,6 @@ const MgPagination = class {
|
|
|
4170
3950
|
*************/
|
|
4171
3951
|
/**
|
|
4172
3952
|
* Check if props are well configured on init
|
|
4173
|
-
*
|
|
4174
|
-
* @returns {void}
|
|
4175
3953
|
*/
|
|
4176
3954
|
componentWillLoad() {
|
|
4177
3955
|
// Get locales
|
|
@@ -4186,8 +3964,7 @@ const MgPagination = class {
|
|
|
4186
3964
|
}
|
|
4187
3965
|
/**
|
|
4188
3966
|
* Render
|
|
4189
|
-
*
|
|
4190
|
-
* @returns {HTMLElement} HTML Element
|
|
3967
|
+
* @returns HTML Element
|
|
4191
3968
|
*/
|
|
4192
3969
|
render() {
|
|
4193
3970
|
const navigationActionButton = (disabled, action) => (index.h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
|
|
@@ -4215,8 +3992,6 @@ const MgPanel = class {
|
|
|
4215
3992
|
************/
|
|
4216
3993
|
/**
|
|
4217
3994
|
* Toggle is editing state
|
|
4218
|
-
*
|
|
4219
|
-
* @returns {void}
|
|
4220
3995
|
*/
|
|
4221
3996
|
this.toggleIsEditing = () => {
|
|
4222
3997
|
this.isEditing = !this.isEditing;
|
|
@@ -4226,8 +4001,6 @@ const MgPanel = class {
|
|
|
4226
4001
|
************/
|
|
4227
4002
|
/**
|
|
4228
4003
|
* Collapse button click handler
|
|
4229
|
-
*
|
|
4230
|
-
* @returns {void}
|
|
4231
4004
|
*/
|
|
4232
4005
|
this.handleCollapseButton = () => {
|
|
4233
4006
|
if (!this.expandToggleDisabled) {
|
|
@@ -4236,25 +4009,19 @@ const MgPanel = class {
|
|
|
4236
4009
|
};
|
|
4237
4010
|
/**
|
|
4238
4011
|
* Edit button click handler
|
|
4239
|
-
*
|
|
4240
|
-
* @returns {void}
|
|
4241
4012
|
*/
|
|
4242
4013
|
this.handleEditButton = () => {
|
|
4243
4014
|
this.toggleIsEditing();
|
|
4244
4015
|
};
|
|
4245
4016
|
/**
|
|
4246
4017
|
* Update title handler
|
|
4247
|
-
*
|
|
4248
|
-
* @param {CustomEvent<string>} event input value change event
|
|
4249
|
-
* @returns {void}
|
|
4018
|
+
* @param event - input value change event
|
|
4250
4019
|
*/
|
|
4251
4020
|
this.handleUpdateTitle = (event) => {
|
|
4252
4021
|
this.updatedPanelTitle = event.detail;
|
|
4253
4022
|
};
|
|
4254
4023
|
/**
|
|
4255
4024
|
* Cancel edition button handler
|
|
4256
|
-
*
|
|
4257
|
-
* @returns {void}
|
|
4258
4025
|
*/
|
|
4259
4026
|
this.handleCancelEditButton = () => {
|
|
4260
4027
|
this.updatedPanelTitle = undefined;
|
|
@@ -4262,8 +4029,6 @@ const MgPanel = class {
|
|
|
4262
4029
|
};
|
|
4263
4030
|
/**
|
|
4264
4031
|
* Validate edition button handler
|
|
4265
|
-
*
|
|
4266
|
-
* @returns {void}
|
|
4267
4032
|
*/
|
|
4268
4033
|
this.handleValidateEditButton = () => {
|
|
4269
4034
|
if (this.editInputElement.valid) {
|
|
@@ -4274,9 +4039,7 @@ const MgPanel = class {
|
|
|
4274
4039
|
};
|
|
4275
4040
|
/**
|
|
4276
4041
|
* Header left conditional render
|
|
4277
|
-
*
|
|
4278
|
-
* @typedef {HTMLElement} HTMLMgButtonElement
|
|
4279
|
-
* @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
|
|
4042
|
+
* @returns header left element
|
|
4280
4043
|
*/
|
|
4281
4044
|
this.headerLeft = () => {
|
|
4282
4045
|
const collapseButton = () => (index.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 }, index.h("span", { class: "mg-panel__collapse-button-content" }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle)));
|
|
@@ -4301,7 +4064,7 @@ const MgPanel = class {
|
|
|
4301
4064
|
this.expanded = false;
|
|
4302
4065
|
this.expandToggleDisabled = undefined;
|
|
4303
4066
|
this.titleEditable = false;
|
|
4304
|
-
this.
|
|
4067
|
+
this.classCollection = new ClassList(['mg-panel']);
|
|
4305
4068
|
this.isEditing = false;
|
|
4306
4069
|
this.updatedPanelTitle = undefined;
|
|
4307
4070
|
}
|
|
@@ -4312,10 +4075,10 @@ const MgPanel = class {
|
|
|
4312
4075
|
this.titleChange.emit(newValue);
|
|
4313
4076
|
}
|
|
4314
4077
|
validatetitlePattern(newValue) {
|
|
4315
|
-
if (newValue && !this.titleEditable) {
|
|
4078
|
+
if (newValue !== undefined && !this.titleEditable) {
|
|
4316
4079
|
throw new Error('<mg-panel> prop "titleEditable" must be set to `true`.');
|
|
4317
4080
|
}
|
|
4318
|
-
if (newValue && (this.titlePatternErrorMessage === undefined || this.titlePatternErrorMessage.trim() === '')) {
|
|
4081
|
+
if (newValue !== undefined && (this.titlePatternErrorMessage === undefined || this.titlePatternErrorMessage.trim() === '')) {
|
|
4319
4082
|
throw new Error('<mg-panel> prop "titlePattern" must be paired with the prop "titlePatternErrorMessage".');
|
|
4320
4083
|
}
|
|
4321
4084
|
}
|
|
@@ -4327,8 +4090,6 @@ const MgPanel = class {
|
|
|
4327
4090
|
*************/
|
|
4328
4091
|
/**
|
|
4329
4092
|
* Check if props are well configured on init
|
|
4330
|
-
*
|
|
4331
|
-
* @returns {void}
|
|
4332
4093
|
*/
|
|
4333
4094
|
componentWillLoad() {
|
|
4334
4095
|
// Get locales
|
|
@@ -4339,8 +4100,6 @@ const MgPanel = class {
|
|
|
4339
4100
|
}
|
|
4340
4101
|
/**
|
|
4341
4102
|
* Edit DOM after render
|
|
4342
|
-
*
|
|
4343
|
-
* @returns {void}
|
|
4344
4103
|
*/
|
|
4345
4104
|
componentDidRender() {
|
|
4346
4105
|
// when we are editing we get focus on edition input
|
|
@@ -4350,11 +4109,10 @@ const MgPanel = class {
|
|
|
4350
4109
|
}
|
|
4351
4110
|
/**
|
|
4352
4111
|
* Render component
|
|
4353
|
-
*
|
|
4354
|
-
* @returns {HTMLElement} html element
|
|
4112
|
+
* @returns html element
|
|
4355
4113
|
*/
|
|
4356
4114
|
render() {
|
|
4357
|
-
return (index.h("section", { class: this.
|
|
4115
|
+
return (index.h("section", { class: this.classCollection.join(), id: this.identifier }, index.h("mg-card", null, index.h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, index.h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), index.h("div", { class: "mg-panel__header-right" }, index.h("slot", { name: "header-right" }))), index.h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, index.h("slot", null)))));
|
|
4358
4116
|
}
|
|
4359
4117
|
get element() { return index.getElement(this); }
|
|
4360
4118
|
static get watchers() { return {
|
|
@@ -6173,9 +5931,7 @@ const MgPopover = class {
|
|
|
6173
5931
|
this.classArrowHide = `mg-popover--arrow-hide`;
|
|
6174
5932
|
/**
|
|
6175
5933
|
* Check if clicked outside of component
|
|
6176
|
-
*
|
|
6177
|
-
* @param {MouseEvent} event mouse event
|
|
6178
|
-
* @returns {void}
|
|
5934
|
+
* @param event - mouse event
|
|
6179
5935
|
*/
|
|
6180
5936
|
this.clickOutside = (event) => {
|
|
6181
5937
|
var _a;
|
|
@@ -6187,8 +5943,6 @@ const MgPopover = class {
|
|
|
6187
5943
|
};
|
|
6188
5944
|
/**
|
|
6189
5945
|
* Show popover
|
|
6190
|
-
*
|
|
6191
|
-
* @returns {void}
|
|
6192
5946
|
*/
|
|
6193
5947
|
this.show = () => {
|
|
6194
5948
|
// Make the popover visible
|
|
@@ -6207,8 +5961,6 @@ const MgPopover = class {
|
|
|
6207
5961
|
};
|
|
6208
5962
|
/**
|
|
6209
5963
|
* Hide popover
|
|
6210
|
-
*
|
|
6211
|
-
* @returns {void}
|
|
6212
5964
|
*/
|
|
6213
5965
|
this.hide = () => {
|
|
6214
5966
|
// Hide the popover
|
|
@@ -6222,8 +5974,6 @@ const MgPopover = class {
|
|
|
6222
5974
|
};
|
|
6223
5975
|
/**
|
|
6224
5976
|
* Handle action for close button
|
|
6225
|
-
*
|
|
6226
|
-
* @returns {void}
|
|
6227
5977
|
*/
|
|
6228
5978
|
this.handleCloseButton = () => {
|
|
6229
5979
|
this.display = false;
|
|
@@ -6234,13 +5984,13 @@ const MgPopover = class {
|
|
|
6234
5984
|
this.closeButton = false;
|
|
6235
5985
|
this.display = false;
|
|
6236
5986
|
this.disabled = false;
|
|
6237
|
-
this.
|
|
5987
|
+
this.classCollection = new ClassList(['mg-popover']);
|
|
6238
5988
|
}
|
|
6239
5989
|
validateArrowHide(newValue) {
|
|
6240
5990
|
if (newValue)
|
|
6241
|
-
this.
|
|
5991
|
+
this.classCollection.add(this.classArrowHide);
|
|
6242
5992
|
else
|
|
6243
|
-
this.
|
|
5993
|
+
this.classCollection.delete(this.classArrowHide);
|
|
6244
5994
|
}
|
|
6245
5995
|
handleDisplay(newValue) {
|
|
6246
5996
|
if (newValue) {
|
|
@@ -6256,8 +6006,6 @@ const MgPopover = class {
|
|
|
6256
6006
|
*************/
|
|
6257
6007
|
/**
|
|
6258
6008
|
* Check if component props are well configured on init
|
|
6259
|
-
*
|
|
6260
|
-
* @returns {void} timeout
|
|
6261
6009
|
*/
|
|
6262
6010
|
componentWillLoad() {
|
|
6263
6011
|
// Get windows to attach events
|
|
@@ -6268,8 +6016,6 @@ const MgPopover = class {
|
|
|
6268
6016
|
}
|
|
6269
6017
|
/**
|
|
6270
6018
|
* Check if component props are well configured on init
|
|
6271
|
-
*
|
|
6272
|
-
* @returns {void}
|
|
6273
6019
|
*/
|
|
6274
6020
|
componentDidLoad() {
|
|
6275
6021
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -6326,11 +6072,10 @@ const MgPopover = class {
|
|
|
6326
6072
|
}
|
|
6327
6073
|
/**
|
|
6328
6074
|
* Render
|
|
6329
|
-
*
|
|
6330
|
-
* @returns {HTMLElement} HTML Element
|
|
6075
|
+
* @returns HTML Element
|
|
6331
6076
|
*/
|
|
6332
6077
|
render() {
|
|
6333
|
-
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: this.
|
|
6078
|
+
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: this.classCollection.join() }, index.h("mg-card", null, this.closeButton && (index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, index.h("mg-icon", { icon: "cross" }))), index.h("div", { class: "mg-popover__title" }, index.h("slot", { name: "title" })), index.h("slot", { name: "content" })), !this.arrowHide && index.h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
6334
6079
|
}
|
|
6335
6080
|
get element() { return index.getElement(this); }
|
|
6336
6081
|
static get watchers() { return {
|
|
@@ -6351,9 +6096,7 @@ const MgSkipLinks = class {
|
|
|
6351
6096
|
**********/
|
|
6352
6097
|
/**
|
|
6353
6098
|
* Handle link click and emit go-to-anchor event
|
|
6354
|
-
*
|
|
6355
|
-
* @param {MouseEvent} event mouse event
|
|
6356
|
-
* @returns {void}
|
|
6099
|
+
* @param event - mouse event
|
|
6357
6100
|
*/
|
|
6358
6101
|
this.handleLinkCLick = (event) => {
|
|
6359
6102
|
event.currentTarget.blur();
|
|
@@ -6373,8 +6116,6 @@ const MgSkipLinks = class {
|
|
|
6373
6116
|
*************/
|
|
6374
6117
|
/**
|
|
6375
6118
|
* Check if props are well configured on init
|
|
6376
|
-
*
|
|
6377
|
-
* @returns {void}
|
|
6378
6119
|
*/
|
|
6379
6120
|
componentWillLoad() {
|
|
6380
6121
|
this.validateLinks(this.links);
|
|
@@ -6382,8 +6123,7 @@ const MgSkipLinks = class {
|
|
|
6382
6123
|
}
|
|
6383
6124
|
/**
|
|
6384
6125
|
* Render
|
|
6385
|
-
*
|
|
6386
|
-
* @returns {HTMLElement} HTML Element
|
|
6126
|
+
* @returns HTML Element
|
|
6387
6127
|
*/
|
|
6388
6128
|
render() {
|
|
6389
6129
|
return (index.h("nav", { class: "mg-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, index.h("ul", { class: "mg-skip-links__list", role: "list" }, this.links.map(link => (index.h("li", { key: link.href }, index.h("a", { class: "mg-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
|
|
@@ -6414,9 +6154,8 @@ const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.m
|
|
|
6414
6154
|
|
|
6415
6155
|
/**
|
|
6416
6156
|
* type TabItem validation function
|
|
6417
|
-
*
|
|
6418
|
-
* @
|
|
6419
|
-
* @returns {boolean} tab item type is valid
|
|
6157
|
+
* @param tab - tab item
|
|
6158
|
+
* @returns tab item type is valid
|
|
6420
6159
|
*/
|
|
6421
6160
|
const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
|
|
6422
6161
|
const MgTabs = class {
|
|
@@ -6432,37 +6171,32 @@ const MgTabs = class {
|
|
|
6432
6171
|
this.startIndex = 1;
|
|
6433
6172
|
/**
|
|
6434
6173
|
* Method to know if given tab has the given status
|
|
6435
|
-
*
|
|
6436
|
-
* @param
|
|
6437
|
-
* @
|
|
6438
|
-
* @returns {boolean} status comparaison
|
|
6174
|
+
* @param tab - item tab key to set to ACTIVE status
|
|
6175
|
+
* @param status - status to valide
|
|
6176
|
+
* @returns status comparaison
|
|
6439
6177
|
*/
|
|
6440
6178
|
this.tabHasStatus = (tab, status) => tab.status === status;
|
|
6441
6179
|
/**
|
|
6442
6180
|
* Method to get element id from index
|
|
6443
|
-
*
|
|
6444
|
-
* @param
|
|
6445
|
-
* @
|
|
6446
|
-
* @returns {string} generated element id
|
|
6181
|
+
* @param element - to get id
|
|
6182
|
+
* @param index - to generate id
|
|
6183
|
+
* @returns generated element id
|
|
6447
6184
|
*/
|
|
6448
6185
|
this.getElementId = (element, index) => `${element}-${this.getTabItemIndex(index)}`;
|
|
6449
6186
|
/**
|
|
6450
6187
|
* Method to get tab item index
|
|
6451
|
-
*
|
|
6452
|
-
* @
|
|
6453
|
-
* @returns {number} index
|
|
6188
|
+
* @param index - to get
|
|
6189
|
+
* @returns index
|
|
6454
6190
|
*/
|
|
6455
6191
|
this.getTabItemIndex = (index) => index + this.startIndex;
|
|
6456
6192
|
/**
|
|
6457
6193
|
* Method to get the active-tab value
|
|
6458
|
-
*
|
|
6459
|
-
* @returns {number} of the active-tab
|
|
6194
|
+
* @returns of the active-tab
|
|
6460
6195
|
*/
|
|
6461
6196
|
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);
|
|
6462
6197
|
/**
|
|
6463
6198
|
* Handle click events on tabs
|
|
6464
|
-
*
|
|
6465
|
-
* @param {MouseEvent} event mouse event
|
|
6199
|
+
* @param event - mouse event
|
|
6466
6200
|
*/
|
|
6467
6201
|
this.handleClick = (event) => {
|
|
6468
6202
|
const tabId = event.currentTarget.dataset.index;
|
|
@@ -6477,16 +6211,13 @@ const MgTabs = class {
|
|
|
6477
6211
|
};
|
|
6478
6212
|
/**
|
|
6479
6213
|
* get navigation button class from given status
|
|
6480
|
-
*
|
|
6481
|
-
* @
|
|
6482
|
-
* @returns {string} button class/selector variant
|
|
6214
|
+
* @param status - button tab status
|
|
6215
|
+
* @returns button class/selector variant
|
|
6483
6216
|
*/
|
|
6484
6217
|
this.getNavigationButtonClass = (status) => `${this.buttonTabBaseClass}--${status}`;
|
|
6485
6218
|
/**
|
|
6486
6219
|
* Handle keyboard event on tabs
|
|
6487
|
-
*
|
|
6488
|
-
* @param {MouseEvent} event mouse event
|
|
6489
|
-
* @returns {void}
|
|
6220
|
+
* @param event - mouse event
|
|
6490
6221
|
*/
|
|
6491
6222
|
this.handleKeydown = (event) => {
|
|
6492
6223
|
const parent = event.target.parentElement;
|
|
@@ -6524,8 +6255,6 @@ const MgTabs = class {
|
|
|
6524
6255
|
};
|
|
6525
6256
|
/**
|
|
6526
6257
|
* Method to reset focus behavior
|
|
6527
|
-
*
|
|
6528
|
-
* @returns {void}
|
|
6529
6258
|
*/
|
|
6530
6259
|
this.resetFocus = () => {
|
|
6531
6260
|
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
@@ -6550,7 +6279,7 @@ const MgTabs = class {
|
|
|
6550
6279
|
this.items = undefined;
|
|
6551
6280
|
this.activeTab = undefined;
|
|
6552
6281
|
this.tabs = [];
|
|
6553
|
-
this.
|
|
6282
|
+
this.classCollection = new ClassList(['mg-tabs']);
|
|
6554
6283
|
}
|
|
6555
6284
|
validateLabel(newValue) {
|
|
6556
6285
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -6561,7 +6290,7 @@ const MgTabs = class {
|
|
|
6561
6290
|
if (!sizes.includes(newValue)) {
|
|
6562
6291
|
throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
6563
6292
|
}
|
|
6564
|
-
this.
|
|
6293
|
+
this.classCollection.add(`mg-tabs--size-${this.size}`);
|
|
6565
6294
|
}
|
|
6566
6295
|
validateItems(newValue) {
|
|
6567
6296
|
// String array
|
|
@@ -6604,8 +6333,6 @@ const MgTabs = class {
|
|
|
6604
6333
|
*************/
|
|
6605
6334
|
/**
|
|
6606
6335
|
* Check if component props are well configured on init
|
|
6607
|
-
*
|
|
6608
|
-
* @returns {void}
|
|
6609
6336
|
*/
|
|
6610
6337
|
componentWillLoad() {
|
|
6611
6338
|
// Check tabs format
|
|
@@ -6617,8 +6344,6 @@ const MgTabs = class {
|
|
|
6617
6344
|
}
|
|
6618
6345
|
/**
|
|
6619
6346
|
* add listners
|
|
6620
|
-
*
|
|
6621
|
-
* @returns {void}
|
|
6622
6347
|
*/
|
|
6623
6348
|
componentDidLoad() {
|
|
6624
6349
|
document.addEventListener('click', (event) => {
|
|
@@ -6628,11 +6353,10 @@ const MgTabs = class {
|
|
|
6628
6353
|
}
|
|
6629
6354
|
/**
|
|
6630
6355
|
* Render
|
|
6631
|
-
*
|
|
6632
|
-
* @returns {HTMLElement} HTML Element
|
|
6356
|
+
* @returns HTML Element
|
|
6633
6357
|
*/
|
|
6634
6358
|
render() {
|
|
6635
|
-
return (index.h("div", { class: this.
|
|
6359
|
+
return (index.h("div", { class: this.classCollection.join() }, index.h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index$1) => (index.h("button", { key: tab.label, role: "tab", id: this.getElementId(this.identifier, index$1), class: {
|
|
6636
6360
|
[`${this.buttonTabBaseClass}`]: true,
|
|
6637
6361
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
6638
6362
|
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|
|
@@ -6669,7 +6393,7 @@ const MgTag = class {
|
|
|
6669
6393
|
this.variant = variants[0];
|
|
6670
6394
|
this.outline = undefined;
|
|
6671
6395
|
this.soft = undefined;
|
|
6672
|
-
this.
|
|
6396
|
+
this.classCollection = new ClassList(['mg-tag']);
|
|
6673
6397
|
}
|
|
6674
6398
|
validateVariant(newValue, oldValue) {
|
|
6675
6399
|
if (!variants.includes(newValue)) {
|
|
@@ -6677,16 +6401,16 @@ const MgTag = class {
|
|
|
6677
6401
|
}
|
|
6678
6402
|
else {
|
|
6679
6403
|
if (oldValue !== undefined) {
|
|
6680
|
-
this.
|
|
6404
|
+
this.classCollection.delete(`mg-tag--${oldValue}`);
|
|
6681
6405
|
}
|
|
6682
|
-
this.
|
|
6406
|
+
this.classCollection.add(`mg-tag--${newValue}`);
|
|
6683
6407
|
}
|
|
6684
6408
|
}
|
|
6685
6409
|
validateOutline(newValue) {
|
|
6686
6410
|
if (newValue)
|
|
6687
|
-
this.
|
|
6411
|
+
this.classCollection.add(this.classOutline);
|
|
6688
6412
|
else
|
|
6689
|
-
this.
|
|
6413
|
+
this.classCollection.delete(this.classOutline);
|
|
6690
6414
|
}
|
|
6691
6415
|
validateSoft(newValue) {
|
|
6692
6416
|
// usage validation
|
|
@@ -6694,18 +6418,16 @@ const MgTag = class {
|
|
|
6694
6418
|
throw new Error('<mg-tag> prop "soft" can NOT be used with prop "outline".');
|
|
6695
6419
|
// apply class
|
|
6696
6420
|
if (newValue)
|
|
6697
|
-
this.
|
|
6421
|
+
this.classCollection.add(this.classSoft);
|
|
6698
6422
|
else
|
|
6699
|
-
this.
|
|
6423
|
+
this.classCollection.delete(this.classSoft);
|
|
6700
6424
|
}
|
|
6701
6425
|
/*************
|
|
6702
6426
|
* Methods *
|
|
6703
6427
|
*************/
|
|
6704
6428
|
/**
|
|
6705
6429
|
* Validate the given textContent
|
|
6706
|
-
*
|
|
6707
|
-
* @param {string} textContent html element textContent property
|
|
6708
|
-
* @returns {void}
|
|
6430
|
+
* @param textContent - html element textContent property
|
|
6709
6431
|
*/
|
|
6710
6432
|
validateTextContent(textContent) {
|
|
6711
6433
|
if (typeof textContent !== 'string' || textContent.trim() === '')
|
|
@@ -6716,8 +6438,6 @@ const MgTag = class {
|
|
|
6716
6438
|
*************/
|
|
6717
6439
|
/**
|
|
6718
6440
|
* Check if props are well configured on init
|
|
6719
|
-
*
|
|
6720
|
-
* @returns {void}
|
|
6721
6441
|
*/
|
|
6722
6442
|
componentWillLoad() {
|
|
6723
6443
|
this.validateVariant(this.variant);
|
|
@@ -6727,11 +6447,10 @@ const MgTag = class {
|
|
|
6727
6447
|
}
|
|
6728
6448
|
/**
|
|
6729
6449
|
* Render
|
|
6730
|
-
*
|
|
6731
|
-
* @returns {HTMLElement} HTML Element
|
|
6450
|
+
* @returns HTML Element
|
|
6732
6451
|
*/
|
|
6733
6452
|
render() {
|
|
6734
|
-
return (index.h("span", { class: this.
|
|
6453
|
+
return (index.h("span", { class: this.classCollection.join() }, index.h("slot", null)));
|
|
6735
6454
|
}
|
|
6736
6455
|
get element() { return index.getElement(this); }
|
|
6737
6456
|
static get watchers() { return {
|
|
@@ -6756,8 +6475,6 @@ const MgTooltip = class {
|
|
|
6756
6475
|
index.registerInstance(this, hostRef);
|
|
6757
6476
|
/**
|
|
6758
6477
|
* Show tooltip
|
|
6759
|
-
*
|
|
6760
|
-
* @returns {void}
|
|
6761
6478
|
*/
|
|
6762
6479
|
this.show = () => {
|
|
6763
6480
|
// Make the tooltip visible
|
|
@@ -6777,8 +6494,6 @@ const MgTooltip = class {
|
|
|
6777
6494
|
};
|
|
6778
6495
|
/**
|
|
6779
6496
|
* Hide tooltip
|
|
6780
|
-
*
|
|
6781
|
-
* @returns {void}
|
|
6782
6497
|
*/
|
|
6783
6498
|
this.hide = () => {
|
|
6784
6499
|
// Hide the tooltip
|
|
@@ -6793,9 +6508,7 @@ const MgTooltip = class {
|
|
|
6793
6508
|
};
|
|
6794
6509
|
/**
|
|
6795
6510
|
* Check if clicked outside of component and hidde tooltip
|
|
6796
|
-
*
|
|
6797
|
-
* @param {MouseEvent} event mouse event
|
|
6798
|
-
* @returns {void}
|
|
6511
|
+
* @param event - mouse event
|
|
6799
6512
|
*/
|
|
6800
6513
|
this.clickOutside = (event) => {
|
|
6801
6514
|
if (event.target.closest('mg-tooltip') !== this.element)
|
|
@@ -6803,9 +6516,7 @@ const MgTooltip = class {
|
|
|
6803
6516
|
};
|
|
6804
6517
|
/**
|
|
6805
6518
|
* Check if 'Escape' key is pressed of component and hidde tooltip
|
|
6806
|
-
*
|
|
6807
|
-
* @param {KeyboardEvent} event keyboard event
|
|
6808
|
-
* @returns {void}
|
|
6519
|
+
* @param event - keyboard event
|
|
6809
6520
|
*/
|
|
6810
6521
|
this.pressEscape = (event) => {
|
|
6811
6522
|
if (event.code === 'Escape')
|
|
@@ -6813,10 +6524,8 @@ const MgTooltip = class {
|
|
|
6813
6524
|
};
|
|
6814
6525
|
/**
|
|
6815
6526
|
* Method to set display prop
|
|
6816
|
-
*
|
|
6817
|
-
* @param
|
|
6818
|
-
* @param {boolean} condition additionnal condition to apply display prop newValue
|
|
6819
|
-
* @returns {void}
|
|
6527
|
+
* @param newValue - display prop new value
|
|
6528
|
+
* @param condition - additionnal condition to apply display prop newValue
|
|
6820
6529
|
*/
|
|
6821
6530
|
this.setDisplay = (newValue, condition = true) => {
|
|
6822
6531
|
if (!this.disabled && condition)
|
|
@@ -6824,11 +6533,9 @@ const MgTooltip = class {
|
|
|
6824
6533
|
};
|
|
6825
6534
|
/**
|
|
6826
6535
|
* Action for tooltip element and tooltiped element mouse listener
|
|
6827
|
-
*
|
|
6828
|
-
* @param
|
|
6829
|
-
* @param
|
|
6830
|
-
* @param {Guard} conditionalGuard guard condition
|
|
6831
|
-
* @returns {void}
|
|
6536
|
+
* @param elementGuard - tooltip element guard
|
|
6537
|
+
* @param isMouseenter - mouseenter validation
|
|
6538
|
+
* @param conditionalGuard - guard condition
|
|
6832
6539
|
*/
|
|
6833
6540
|
this.tooltipMouseListenerAction = (elementGuard, isMouseenter, conditionalGuard) => {
|
|
6834
6541
|
// we mutate elementGuard
|
|
@@ -6847,17 +6554,13 @@ const MgTooltip = class {
|
|
|
6847
6554
|
};
|
|
6848
6555
|
/**
|
|
6849
6556
|
* Method to reset guard value
|
|
6850
|
-
*
|
|
6851
|
-
* @returns {void}
|
|
6852
6557
|
*/
|
|
6853
6558
|
this.resetGuard = () => {
|
|
6854
6559
|
this.guard = undefined;
|
|
6855
6560
|
};
|
|
6856
6561
|
/**
|
|
6857
6562
|
* Update slot content when it is a mg-button
|
|
6858
|
-
*
|
|
6859
|
-
* @param {HTMLMgButtonElement} mgButton slotted mg-button
|
|
6860
|
-
* @returns {void}
|
|
6563
|
+
* @param mgButton - slotted mg-button
|
|
6861
6564
|
*/
|
|
6862
6565
|
this.setMgButtonWrapper = (mgButton) => {
|
|
6863
6566
|
if (mgButton.disabled) {
|
|
@@ -6874,9 +6577,8 @@ const MgTooltip = class {
|
|
|
6874
6577
|
};
|
|
6875
6578
|
/**
|
|
6876
6579
|
* Init tooltip
|
|
6877
|
-
*
|
|
6878
|
-
* @param
|
|
6879
|
-
* @param {HTMLElement} interactiveElement interactive element
|
|
6580
|
+
* @param slotElement - slotted element
|
|
6581
|
+
* @param interactiveElement - interactive element
|
|
6880
6582
|
*/
|
|
6881
6583
|
this.initTooltip = (slotElement, interactiveElement) => {
|
|
6882
6584
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
@@ -6952,8 +6654,6 @@ const MgTooltip = class {
|
|
|
6952
6654
|
*************/
|
|
6953
6655
|
/**
|
|
6954
6656
|
* set variables
|
|
6955
|
-
*
|
|
6956
|
-
* @returns {void}
|
|
6957
6657
|
*/
|
|
6958
6658
|
componentWillLoad() {
|
|
6959
6659
|
// Get windows to attach events
|
|
@@ -6963,8 +6663,6 @@ const MgTooltip = class {
|
|
|
6963
6663
|
* Get slotted element
|
|
6964
6664
|
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
6965
6665
|
* We need to attach the focused element to the tooltip (aria-describedby)
|
|
6966
|
-
*
|
|
6967
|
-
* @returns {void}
|
|
6968
6666
|
*/
|
|
6969
6667
|
componentDidLoad() {
|
|
6970
6668
|
var _a;
|
|
@@ -6997,8 +6695,7 @@ const MgTooltip = class {
|
|
|
6997
6695
|
}
|
|
6998
6696
|
/**
|
|
6999
6697
|
* Render
|
|
7000
|
-
*
|
|
7001
|
-
* @returns {HTMLElement} HTML Element
|
|
6698
|
+
* @returns HTML Element
|
|
7002
6699
|
*/
|
|
7003
6700
|
render() {
|
|
7004
6701
|
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip" }, index.h("span", { innerHTML: this.message }), index.h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|