@mgdis/mg-components 5.10.0 → 5.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_31.cjs.entry.js +318 -427
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +19 -28
- package/dist/cjs/{mg-menu.conf-1942ac70.js → mg-menu.conf-196151fe.js} +16 -16
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +8 -9
- package/dist/collection/components/atoms/mg-button/mg-button.js +16 -20
- package/dist/collection/components/atoms/mg-card/mg-card.js +10 -12
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +1 -2
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +17 -19
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -2
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +11 -13
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +11 -21
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +26 -18
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +10 -14
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +7 -12
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +14 -22
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +6 -10
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -18
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +21 -32
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +16 -31
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +13 -17
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +17 -23
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +11 -18
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +20 -29
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +11 -15
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -3
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -19
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -2
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +4 -7
- package/dist/collection/components/molecules/mg-message/mg-message.js +11 -14
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +7 -11
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +11 -13
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +6 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +7 -13
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +2 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +20 -24
- package/dist/collection/locales/index.js +2 -2
- package/dist/collection/utils/behaviors.utils.js +16 -22
- package/dist/collection/utils/components.utils.js +21 -23
- package/dist/collection/utils/locale.utils.js +14 -14
- package/dist/collection/utils/unit.test.utils.js +7 -10
- package/dist/components/MgInput.js +30 -18
- package/dist/components/components.utils.js +21 -23
- package/dist/components/index2.js +16 -16
- package/dist/components/mg-action-more.js +9 -13
- package/dist/components/mg-badge2.js +8 -9
- package/dist/components/mg-button2.js +16 -20
- package/dist/components/mg-card2.js +8 -10
- package/dist/components/mg-character-left2.js +1 -2
- package/dist/components/mg-details.js +1 -3
- package/dist/components/mg-divider.js +1 -1
- package/dist/components/mg-form.js +7 -15
- package/dist/components/mg-icon2.js +17 -19
- package/dist/components/mg-illustrated-message.js +1 -2
- package/dist/components/mg-input-checkbox.js +9 -10
- package/dist/components/mg-input-date.js +6 -8
- package/dist/components/mg-input-numeric.js +13 -18
- package/dist/components/mg-input-password.js +5 -6
- package/dist/components/mg-input-radio.js +9 -14
- package/dist/components/mg-input-select2.js +20 -28
- package/dist/components/mg-input-text2.js +14 -23
- package/dist/components/mg-input-textarea.js +12 -13
- package/dist/components/mg-input-title2.js +1 -2
- package/dist/components/mg-input-toggle.js +16 -19
- package/dist/components/mg-item-more.js +18 -27
- package/dist/components/mg-menu-item2.js +17 -26
- package/dist/components/mg-menu2.js +9 -16
- package/dist/components/mg-message.js +11 -14
- package/dist/components/mg-modal.js +7 -11
- package/dist/components/mg-pagination.js +11 -13
- package/dist/components/mg-panel.js +6 -15
- package/dist/components/mg-popover2.js +7 -13
- package/dist/components/mg-skip-links.js +2 -4
- package/dist/components/mg-tabs.js +20 -24
- package/dist/components/mg-tag.js +11 -13
- package/dist/components/mg-tooltip2.js +11 -21
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_31.entry.js +318 -427
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +19 -28
- package/dist/esm/{mg-menu.conf-2cc1bb67.js → mg-menu.conf-9ca023ee.js} +16 -16
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-a56a3157.entry.js → p-97aaca3e.entry.js} +1 -1
- package/dist/mg-components/p-d891e707.entry.js +1 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +2 -3
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +5 -9
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +2 -6
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -2
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +3 -5
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -2
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +3 -5
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -21
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -1
- package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -5
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -6
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -6
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +7 -14
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +3 -4
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -10
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +9 -13
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +3 -12
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -5
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -6
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +10 -18
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +21 -31
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +3 -10
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +1 -3
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -11
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +1 -2
- package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +2 -7
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +4 -7
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -7
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +5 -9
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +4 -13
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +3 -9
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +2 -4
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +15 -19
- package/dist/types/components.d.ts +22 -34
- package/dist/types/locales/index.d.ts +2 -2
- package/dist/types/utils/behaviors.utils.d.ts +14 -20
- package/dist/types/utils/components.utils.d.ts +18 -20
- package/dist/types/utils/locale.utils.d.ts +14 -14
- package/dist/types/utils/unit.test.utils.d.ts +11 -17
- package/package.json +1 -1
- package/dist/mg-components/p-eb32bb18.entry.js +0 -1
- /package/dist/mg-components/{p-73156ac9.js → p-0d3146d9.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-3249671d.js';
|
|
2
|
-
import { i as initLocales, D as Direction, l as localeDate, d as dateRegExp, a as localeCurrency, b as localeNumber, s as sizes$2 } from './mg-menu.conf-
|
|
2
|
+
import { i as initLocales, D as Direction, l as localeDate, d as dateRegExp, a as localeCurrency, b as localeNumber, s as sizes$2 } from './mg-menu.conf-9ca023ee.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Available menu-item positions
|
|
@@ -22,9 +22,9 @@ var Status$1;
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Create random ID
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @returns
|
|
25
|
+
* @param prefix - add prefix to created ID
|
|
26
|
+
* @param length - ID length
|
|
27
|
+
* @returns ID
|
|
28
28
|
*/
|
|
29
29
|
const createID = (prefix = '', length = 10) => {
|
|
30
30
|
let ID = '';
|
|
@@ -43,8 +43,7 @@ class ClassList {
|
|
|
43
43
|
constructor(classlist = []) {
|
|
44
44
|
/**
|
|
45
45
|
* Add class
|
|
46
|
-
* @param
|
|
47
|
-
* @returns {void}
|
|
46
|
+
* @param className - class name to add
|
|
48
47
|
*/
|
|
49
48
|
this.add = (className) => {
|
|
50
49
|
if (!this.has(className)) {
|
|
@@ -53,8 +52,7 @@ class ClassList {
|
|
|
53
52
|
};
|
|
54
53
|
/**
|
|
55
54
|
* Delete class
|
|
56
|
-
* @param
|
|
57
|
-
* @returns {void}
|
|
55
|
+
* @param className - class name to delete
|
|
58
56
|
*/
|
|
59
57
|
this.delete = (className) => {
|
|
60
58
|
const index = this.classes.indexOf(className);
|
|
@@ -64,15 +62,15 @@ class ClassList {
|
|
|
64
62
|
};
|
|
65
63
|
/**
|
|
66
64
|
* Check if class exist in list
|
|
67
|
-
* @param
|
|
68
|
-
* @returns
|
|
65
|
+
* @param className - class name to check
|
|
66
|
+
* @returns class name is in the list
|
|
69
67
|
*/
|
|
70
68
|
this.has = (className) => {
|
|
71
69
|
return this.classes.includes(className);
|
|
72
70
|
};
|
|
73
71
|
/**
|
|
74
72
|
* Join classes seperated by spaces
|
|
75
|
-
* @returns
|
|
73
|
+
* @returns joined values
|
|
76
74
|
*/
|
|
77
75
|
this.join = () => {
|
|
78
76
|
return this.classes.join(' ');
|
|
@@ -82,15 +80,15 @@ class ClassList {
|
|
|
82
80
|
}
|
|
83
81
|
/**
|
|
84
82
|
* Check if all items are string
|
|
85
|
-
* @param
|
|
86
|
-
* @returns
|
|
83
|
+
* @param items - items to check
|
|
84
|
+
* @returns all items are string
|
|
87
85
|
*/
|
|
88
86
|
const allItemsAreString = (items) => Array.isArray(items) && items.every(item => typeof item === 'string');
|
|
89
87
|
/**
|
|
90
88
|
* Check if element is a heading
|
|
91
|
-
* @param
|
|
92
|
-
* @param
|
|
93
|
-
* @returns
|
|
89
|
+
* @param element - slotted element
|
|
90
|
+
* @param tagNames - allowed tag names list
|
|
91
|
+
* @returns element is a heading
|
|
94
92
|
*/
|
|
95
93
|
const isTagName = (element, tagNames) => {
|
|
96
94
|
return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
|
|
@@ -101,8 +99,8 @@ const isTagName = (element, tagNames) => {
|
|
|
101
99
|
const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
102
100
|
/**
|
|
103
101
|
* Get windows
|
|
104
|
-
* @param
|
|
105
|
-
* @returns
|
|
102
|
+
* @param localWindow - the window we are lookink for other windows
|
|
103
|
+
* @returns The list of windows found
|
|
106
104
|
*/
|
|
107
105
|
const getWindows = (localWindow) => {
|
|
108
106
|
const parentWindows = getParentWindows(localWindow);
|
|
@@ -111,9 +109,9 @@ const getWindows = (localWindow) => {
|
|
|
111
109
|
};
|
|
112
110
|
/**
|
|
113
111
|
* Get parent windows
|
|
114
|
-
* @param
|
|
115
|
-
* @param
|
|
116
|
-
* @returns
|
|
112
|
+
* @param localWindow - the window we are lookink for parents
|
|
113
|
+
* @param windows - The list of allready found windows
|
|
114
|
+
* @returns The list of windows found
|
|
117
115
|
*/
|
|
118
116
|
const getParentWindows = (localWindow, windows = []) => {
|
|
119
117
|
// Check if is in iframe
|
|
@@ -133,9 +131,9 @@ const getParentWindows = (localWindow, windows = []) => {
|
|
|
133
131
|
};
|
|
134
132
|
/**
|
|
135
133
|
* Get child windows
|
|
136
|
-
* @param
|
|
137
|
-
* @param
|
|
138
|
-
* @returns
|
|
134
|
+
* @param localWindow - the window we are lookink for children
|
|
135
|
+
* @param windows - The list of allready found windows
|
|
136
|
+
* @returns The list of windows found
|
|
139
137
|
*/
|
|
140
138
|
const getChildWindows = (localWindow, windows = []) => {
|
|
141
139
|
if (localWindow.frames.length > 0) {
|
|
@@ -154,8 +152,8 @@ const mgActionMoreCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
154
152
|
|
|
155
153
|
/**
|
|
156
154
|
* MgActionMore['items'] type guard
|
|
157
|
-
* @param
|
|
158
|
-
* @returns
|
|
155
|
+
* @param prop - commponent items prop
|
|
156
|
+
* @returns return true if type is valid
|
|
159
157
|
*/
|
|
160
158
|
const isMgActionMoreItems = (prop) => {
|
|
161
159
|
const items = prop;
|
|
@@ -163,8 +161,8 @@ const isMgActionMoreItems = (prop) => {
|
|
|
163
161
|
};
|
|
164
162
|
/**
|
|
165
163
|
* MgActionMore['button'] type guard
|
|
166
|
-
* @param
|
|
167
|
-
* @returns
|
|
164
|
+
* @param prop - commponent button prop
|
|
165
|
+
* @returns return true if type is valid
|
|
168
166
|
*/
|
|
169
167
|
const isMgActionMoreButton = (prop) => {
|
|
170
168
|
const button = prop;
|
|
@@ -172,8 +170,8 @@ const isMgActionMoreButton = (prop) => {
|
|
|
172
170
|
};
|
|
173
171
|
/**
|
|
174
172
|
* MgActionMore['icon'] type guard
|
|
175
|
-
* @param
|
|
176
|
-
* @returns
|
|
173
|
+
* @param prop - commponent icon prop
|
|
174
|
+
* @returns return true if type is valid
|
|
177
175
|
*/
|
|
178
176
|
const isMgActionMoreIcon = (prop) => {
|
|
179
177
|
const icon = prop;
|
|
@@ -192,23 +190,20 @@ const MgActionMore = class {
|
|
|
192
190
|
***********/
|
|
193
191
|
/**
|
|
194
192
|
* Toogle expanded props
|
|
195
|
-
* @returns {void}
|
|
196
193
|
*/
|
|
197
194
|
this.toggleExpanded = () => {
|
|
198
195
|
this.expanded = !this.expanded;
|
|
199
196
|
};
|
|
200
197
|
/**
|
|
201
198
|
* Button click handler
|
|
202
|
-
* @returns {void}
|
|
203
199
|
*/
|
|
204
200
|
this.handleButton = () => {
|
|
205
201
|
this.toggleExpanded();
|
|
206
202
|
};
|
|
207
203
|
/**
|
|
208
204
|
* Item click handler
|
|
209
|
-
* @param
|
|
210
|
-
* @param
|
|
211
|
-
* @returns {void}
|
|
205
|
+
* @param event - click event
|
|
206
|
+
* @param customHandler - item['mouseEventHandler']
|
|
212
207
|
*/
|
|
213
208
|
this.handleItemClick = (event, customHandler) => {
|
|
214
209
|
this.expanded = false;
|
|
@@ -245,7 +240,6 @@ const MgActionMore = class {
|
|
|
245
240
|
*************/
|
|
246
241
|
/**
|
|
247
242
|
* Validate props
|
|
248
|
-
* @returns {void}
|
|
249
243
|
*/
|
|
250
244
|
componentWillLoad() {
|
|
251
245
|
this.messages = initLocales(this.element).messages.actionMore;
|
|
@@ -256,7 +250,7 @@ const MgActionMore = class {
|
|
|
256
250
|
}
|
|
257
251
|
/**
|
|
258
252
|
* Render
|
|
259
|
-
* @returns
|
|
253
|
+
* @returns HTML Element
|
|
260
254
|
*/
|
|
261
255
|
render() {
|
|
262
256
|
const buttonLabel = this.button.label || this.messages.label;
|
|
@@ -304,7 +298,7 @@ const MgBadge = class {
|
|
|
304
298
|
this.label = undefined;
|
|
305
299
|
this.variant = variants$5[0];
|
|
306
300
|
this.outline = undefined;
|
|
307
|
-
this.
|
|
301
|
+
this.classCollection = new ClassList(['mg-badge']);
|
|
308
302
|
}
|
|
309
303
|
validateValue(newValue) {
|
|
310
304
|
if (`${newValue}`.match(/^(\d+\+*|[?*!a-z])$/i) === null) {
|
|
@@ -322,20 +316,19 @@ const MgBadge = class {
|
|
|
322
316
|
}
|
|
323
317
|
else {
|
|
324
318
|
if (oldValue !== undefined) {
|
|
325
|
-
this.
|
|
319
|
+
this.classCollection.delete(`mg-badge--${oldValue}`);
|
|
326
320
|
}
|
|
327
|
-
this.
|
|
321
|
+
this.classCollection.add(`mg-badge--${newValue}`);
|
|
328
322
|
}
|
|
329
323
|
}
|
|
330
324
|
validateOutline(newValue) {
|
|
331
325
|
if (newValue)
|
|
332
|
-
this.
|
|
326
|
+
this.classCollection.add(this.classOutline);
|
|
333
327
|
else
|
|
334
|
-
this.
|
|
328
|
+
this.classCollection.delete(this.classOutline);
|
|
335
329
|
}
|
|
336
330
|
/**
|
|
337
331
|
* Check if props are well configured on init
|
|
338
|
-
* @returns {void}
|
|
339
332
|
*/
|
|
340
333
|
componentWillLoad() {
|
|
341
334
|
this.validateValue(this.value);
|
|
@@ -345,10 +338,10 @@ const MgBadge = class {
|
|
|
345
338
|
}
|
|
346
339
|
/**
|
|
347
340
|
* Render
|
|
348
|
-
* @returns
|
|
341
|
+
* @returns HTML Element
|
|
349
342
|
*/
|
|
350
343
|
render() {
|
|
351
|
-
return (h("span", { class: this.
|
|
344
|
+
return (h("span", { class: this.classCollection.join() }, h("span", { class: "mg-badge__value" }, this.value), h("span", { class: "sr-only" }, this.label)));
|
|
352
345
|
}
|
|
353
346
|
static get watchers() { return {
|
|
354
347
|
"value": ["validateValue"],
|
|
@@ -379,8 +372,7 @@ const MgButton = class {
|
|
|
379
372
|
this.classFullWidth = 'mg-button--full-width';
|
|
380
373
|
/**
|
|
381
374
|
* Trigger actions onClick event
|
|
382
|
-
* @param
|
|
383
|
-
* @returns {void}
|
|
375
|
+
* @param event - click event
|
|
384
376
|
*/
|
|
385
377
|
this.handleClick = (event) => {
|
|
386
378
|
if (this.disabled)
|
|
@@ -393,8 +385,7 @@ const MgButton = class {
|
|
|
393
385
|
};
|
|
394
386
|
/**
|
|
395
387
|
* Handle onKeydown event
|
|
396
|
-
* @param
|
|
397
|
-
* @returns {void}
|
|
388
|
+
* @param event - keyboard event
|
|
398
389
|
*/
|
|
399
390
|
this.handleKeydown = (event) => {
|
|
400
391
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -407,8 +398,7 @@ const MgButton = class {
|
|
|
407
398
|
};
|
|
408
399
|
/**
|
|
409
400
|
* Handle onKeyup event
|
|
410
|
-
* @param
|
|
411
|
-
* @returns {void}
|
|
401
|
+
* @param event - keyboard event
|
|
412
402
|
*/
|
|
413
403
|
this.handleKeyup = (event) => {
|
|
414
404
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -426,7 +416,7 @@ const MgButton = class {
|
|
|
426
416
|
this.isIcon = false;
|
|
427
417
|
this.disableOnClick = false;
|
|
428
418
|
this.loading = false;
|
|
429
|
-
this.
|
|
419
|
+
this.classCollection = new ClassList(['mg-button']);
|
|
430
420
|
}
|
|
431
421
|
validateVariant(newValue, oldValue) {
|
|
432
422
|
if (!variants$4.includes(newValue)) {
|
|
@@ -434,9 +424,9 @@ const MgButton = class {
|
|
|
434
424
|
}
|
|
435
425
|
else {
|
|
436
426
|
if (oldValue !== undefined) {
|
|
437
|
-
this.
|
|
427
|
+
this.classCollection.delete(`mg-button--${oldValue}`);
|
|
438
428
|
}
|
|
439
|
-
this.
|
|
429
|
+
this.classCollection.add(`mg-button--${newValue}`);
|
|
440
430
|
}
|
|
441
431
|
}
|
|
442
432
|
validateFullWidth(newValue) {
|
|
@@ -444,10 +434,10 @@ const MgButton = class {
|
|
|
444
434
|
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
445
435
|
}
|
|
446
436
|
else if (newValue) {
|
|
447
|
-
this.
|
|
437
|
+
this.classCollection.add(this.classFullWidth);
|
|
448
438
|
}
|
|
449
439
|
else {
|
|
450
|
-
this.
|
|
440
|
+
this.classCollection.delete(this.classFullWidth);
|
|
451
441
|
}
|
|
452
442
|
}
|
|
453
443
|
disabledHandler(isDisabled) {
|
|
@@ -460,10 +450,10 @@ const MgButton = class {
|
|
|
460
450
|
this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
|
|
461
451
|
// apply style
|
|
462
452
|
if (isDisabled) {
|
|
463
|
-
this.
|
|
453
|
+
this.classCollection.add(this.classDisabled);
|
|
464
454
|
}
|
|
465
455
|
else {
|
|
466
|
-
this.
|
|
456
|
+
this.classCollection.delete(this.classDisabled);
|
|
467
457
|
}
|
|
468
458
|
// emit value update
|
|
469
459
|
this.disabledChange.emit(isDisabled);
|
|
@@ -471,21 +461,20 @@ const MgButton = class {
|
|
|
471
461
|
loadingHandler(newValue) {
|
|
472
462
|
// we add loading style if it newvalue is true else we remove it
|
|
473
463
|
if (newValue) {
|
|
474
|
-
this.
|
|
464
|
+
this.classCollection.add(this.classLoading);
|
|
475
465
|
}
|
|
476
466
|
else {
|
|
477
|
-
this.
|
|
467
|
+
this.classCollection.delete(this.classLoading);
|
|
478
468
|
}
|
|
479
469
|
}
|
|
480
470
|
/**
|
|
481
471
|
* Check if props are well configured on init
|
|
482
|
-
* @returns {void}
|
|
483
472
|
*/
|
|
484
473
|
componentWillLoad() {
|
|
485
474
|
this.validateVariant(this.variant);
|
|
486
475
|
this.validateFullWidth(this.fullWidth);
|
|
487
476
|
if (this.isIcon) {
|
|
488
|
-
this.
|
|
477
|
+
this.classCollection.add(`mg-button--icon`);
|
|
489
478
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
490
479
|
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
491
480
|
}
|
|
@@ -496,10 +485,10 @@ const MgButton = class {
|
|
|
496
485
|
}
|
|
497
486
|
/**
|
|
498
487
|
* Render component
|
|
499
|
-
* @returns
|
|
488
|
+
* @returns html element
|
|
500
489
|
*/
|
|
501
490
|
render() {
|
|
502
|
-
return (h(Host, { role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, h("div", { class: this.
|
|
491
|
+
return (h(Host, { role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, h("div", { class: this.classCollection.join(), id: this.identifier }, this.loading && h("mg-icon", { icon: "loader", spin: true }), h("div", { class: "mg-button__content" }, h("slot", null)))));
|
|
503
492
|
}
|
|
504
493
|
get element() { return getElement(this); }
|
|
505
494
|
static get watchers() { return {
|
|
@@ -533,7 +522,6 @@ const MgCard = class {
|
|
|
533
522
|
/**
|
|
534
523
|
* Methode to set default varianStyle props
|
|
535
524
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
536
|
-
* @returns {void}
|
|
537
525
|
*/
|
|
538
526
|
this.setDefaultVariantStyle = () => {
|
|
539
527
|
if (this.variantStyle === undefined)
|
|
@@ -541,17 +529,17 @@ const MgCard = class {
|
|
|
541
529
|
};
|
|
542
530
|
this.variant = undefined;
|
|
543
531
|
this.variantStyle = undefined;
|
|
544
|
-
this.
|
|
532
|
+
this.classCollection = new ClassList([this.baseClass]);
|
|
545
533
|
}
|
|
546
534
|
validateVariant(newValue, oldValue) {
|
|
547
535
|
if (newValue && !variants$3.includes(newValue))
|
|
548
536
|
throw new Error(`<${this.name}> prop "variant" must match VariantType type.`);
|
|
549
537
|
if (Boolean(newValue)) {
|
|
550
538
|
this.setDefaultVariantStyle();
|
|
551
|
-
this.
|
|
539
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
552
540
|
}
|
|
553
541
|
if (Boolean(oldValue))
|
|
554
|
-
this.
|
|
542
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
555
543
|
}
|
|
556
544
|
validateVariantStyle(newValue, oldValue) {
|
|
557
545
|
if (newValue && !variantStyles$1.includes(newValue))
|
|
@@ -559,16 +547,15 @@ const MgCard = class {
|
|
|
559
547
|
else if (Boolean(newValue) && !variants$3.includes(this.variant))
|
|
560
548
|
throw new Error(`<${this.name}> prop "variantStyle" must be paired with ${JSON.stringify(variants$3)} "variant" prop.`);
|
|
561
549
|
if (Boolean(newValue))
|
|
562
|
-
this.
|
|
550
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
563
551
|
if (Boolean(oldValue))
|
|
564
|
-
this.
|
|
552
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
565
553
|
}
|
|
566
554
|
/*************
|
|
567
555
|
* Lifecycle *
|
|
568
556
|
*************/
|
|
569
557
|
/**
|
|
570
558
|
* Check if props are well configured on init
|
|
571
|
-
* @returns {void}
|
|
572
559
|
*/
|
|
573
560
|
componentWillLoad() {
|
|
574
561
|
this.validateVariant(this.variant);
|
|
@@ -576,11 +563,11 @@ const MgCard = class {
|
|
|
576
563
|
}
|
|
577
564
|
/**
|
|
578
565
|
* Render
|
|
579
|
-
* @returns
|
|
566
|
+
* @returns HTML Element
|
|
580
567
|
*/
|
|
581
568
|
render() {
|
|
582
569
|
var _a;
|
|
583
|
-
return (h("div", { class: this.
|
|
570
|
+
return (h("div", { class: this.classCollection.join() }, ((_a = this.variantStyle) === null || _a === void 0 ? void 0 : _a.startsWith('bar-')) && h("span", { class: "mg-card__bar" }), h("slot", null)));
|
|
584
571
|
}
|
|
585
572
|
static get watchers() { return {
|
|
586
573
|
"variant": ["validateVariant"],
|
|
@@ -608,7 +595,6 @@ const MgCharacterLeft = class {
|
|
|
608
595
|
*************/
|
|
609
596
|
/**
|
|
610
597
|
* Check if props are well configured on init
|
|
611
|
-
* @returns {void}
|
|
612
598
|
*/
|
|
613
599
|
componentWillLoad() {
|
|
614
600
|
this.validateMaxlength(this.maxlength);
|
|
@@ -616,7 +602,7 @@ const MgCharacterLeft = class {
|
|
|
616
602
|
}
|
|
617
603
|
/**
|
|
618
604
|
* Render component
|
|
619
|
-
* @returns
|
|
605
|
+
* @returns HTML Element
|
|
620
606
|
*/
|
|
621
607
|
render() {
|
|
622
608
|
return (h("span", { id: this.identifier, "aria-live": "polite" }, h("span", { "aria-hidden": "true" }, this.maxlength - this.characters.length, "/", this.maxlength), h("span", { class: "sr-only" }, this.messages.nbCharLeft.replace('{counter}', this.maxlength - this.characters.length))));
|
|
@@ -636,7 +622,6 @@ const MgDetails = class {
|
|
|
636
622
|
this.expandedChange = createEvent(this, "expanded-change", 7);
|
|
637
623
|
/**
|
|
638
624
|
* Handle details toggle
|
|
639
|
-
* @returns {void}
|
|
640
625
|
*/
|
|
641
626
|
this.handleToggle = () => {
|
|
642
627
|
this.expanded = this.details.open;
|
|
@@ -659,7 +644,6 @@ const MgDetails = class {
|
|
|
659
644
|
*************/
|
|
660
645
|
/**
|
|
661
646
|
* Check if component props are well configured on init
|
|
662
|
-
* @returns {void}
|
|
663
647
|
*/
|
|
664
648
|
componentWillLoad() {
|
|
665
649
|
this.validateTitles(this.toggleClosed);
|
|
@@ -667,7 +651,7 @@ const MgDetails = class {
|
|
|
667
651
|
}
|
|
668
652
|
/**
|
|
669
653
|
* Render
|
|
670
|
-
* @returns
|
|
654
|
+
* @returns HTML Element
|
|
671
655
|
*/
|
|
672
656
|
render() {
|
|
673
657
|
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down', size: "small" }), h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), h("div", { class: "mg-details__details" }, h("slot", { name: "details" }))));
|
|
@@ -689,7 +673,7 @@ const MgDivider = class {
|
|
|
689
673
|
}
|
|
690
674
|
/**
|
|
691
675
|
* Render
|
|
692
|
-
* @returns
|
|
676
|
+
* @returns HTML Element
|
|
693
677
|
*/
|
|
694
678
|
render() {
|
|
695
679
|
return (h("div", { class: {
|
|
@@ -711,13 +695,11 @@ const MgForm = class {
|
|
|
711
695
|
this.classAllRequired = 'mg-form--all-required';
|
|
712
696
|
/**
|
|
713
697
|
* Define required message based on mg-inputs required elements
|
|
714
|
-
* Also
|
|
715
|
-
* @returns {void}
|
|
716
698
|
*/
|
|
717
699
|
this.setRequiredMessage = () => {
|
|
718
700
|
// init required message
|
|
719
701
|
this.requiredMessage = null;
|
|
720
|
-
this.
|
|
702
|
+
this.classCollection.delete(this.classAllRequired);
|
|
721
703
|
// If the form is disabled or readonly none of them are required
|
|
722
704
|
// Check if all fields are not editable (readonly or disabled)
|
|
723
705
|
if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
|
|
@@ -727,7 +709,7 @@ const MgForm = class {
|
|
|
727
709
|
// mg-input-toggle can not be required
|
|
728
710
|
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
729
711
|
this.requiredMessage = requiredInputs.length === 1 ? this.messages.form.allRequiredSingle : this.messages.form.allRequired;
|
|
730
|
-
this.
|
|
712
|
+
this.classCollection.add(this.classAllRequired);
|
|
731
713
|
}
|
|
732
714
|
// Some fields are required
|
|
733
715
|
else if (requiredInputs.length > 0) {
|
|
@@ -737,7 +719,6 @@ const MgForm = class {
|
|
|
737
719
|
};
|
|
738
720
|
/**
|
|
739
721
|
* Check if form is valid
|
|
740
|
-
* @returns {void}
|
|
741
722
|
*/
|
|
742
723
|
this.checkValidity = () => {
|
|
743
724
|
// Update required on input event
|
|
@@ -749,8 +730,7 @@ const MgForm = class {
|
|
|
749
730
|
};
|
|
750
731
|
/**
|
|
751
732
|
* Handle Form Submit
|
|
752
|
-
* @param
|
|
753
|
-
* @returns {void}
|
|
733
|
+
* @param event - submit event
|
|
754
734
|
*/
|
|
755
735
|
this.handleFormSubmit = (event) => {
|
|
756
736
|
event.preventDefault();
|
|
@@ -758,7 +738,6 @@ const MgForm = class {
|
|
|
758
738
|
};
|
|
759
739
|
/**
|
|
760
740
|
* Set mgInputs
|
|
761
|
-
* @returns {void}
|
|
762
741
|
*/
|
|
763
742
|
this.setMgInputs = () => {
|
|
764
743
|
// Get slotted mgInputs
|
|
@@ -780,7 +759,7 @@ const MgForm = class {
|
|
|
780
759
|
this.disabled = false;
|
|
781
760
|
this.valid = undefined;
|
|
782
761
|
this.invalid = undefined;
|
|
783
|
-
this.
|
|
762
|
+
this.classCollection = new ClassList(['mg-form']);
|
|
784
763
|
this.requiredMessage = undefined;
|
|
785
764
|
}
|
|
786
765
|
handleAttributeChange() {
|
|
@@ -789,7 +768,6 @@ const MgForm = class {
|
|
|
789
768
|
}
|
|
790
769
|
/**
|
|
791
770
|
* Public method to display errors
|
|
792
|
-
* @returns {Promise<void>}
|
|
793
771
|
*/
|
|
794
772
|
async displayError() {
|
|
795
773
|
if (!this.readonly) {
|
|
@@ -804,7 +782,6 @@ const MgForm = class {
|
|
|
804
782
|
*************/
|
|
805
783
|
/**
|
|
806
784
|
* Check if component props are well configured on init
|
|
807
|
-
* @returns {void}
|
|
808
785
|
*/
|
|
809
786
|
componentWillLoad() {
|
|
810
787
|
// Get locales
|
|
@@ -831,7 +808,6 @@ const MgForm = class {
|
|
|
831
808
|
}
|
|
832
809
|
/**
|
|
833
810
|
* Add slot listeners
|
|
834
|
-
* @returns {void}
|
|
835
811
|
*/
|
|
836
812
|
componentDidLoad() {
|
|
837
813
|
this.mgButtons.forEach(mgButton => {
|
|
@@ -849,10 +825,10 @@ const MgForm = class {
|
|
|
849
825
|
}
|
|
850
826
|
/**
|
|
851
827
|
* Render
|
|
852
|
-
* @returns
|
|
828
|
+
* @returns HTML Element
|
|
853
829
|
*/
|
|
854
830
|
render() {
|
|
855
|
-
return (h("form", { class: this.
|
|
831
|
+
return (h("form", { class: this.classCollection.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit }, this.requiredMessage && h("p", { innerHTML: this.requiredMessage }), h("slot", null), !this.readonly && !this.disabled && h("slot", { name: "actions" })));
|
|
856
832
|
}
|
|
857
833
|
get element() { return getElement(this); }
|
|
858
834
|
static get watchers() { return {
|
|
@@ -1099,13 +1075,12 @@ const MgIcon = class {
|
|
|
1099
1075
|
registerInstance(this, hostRef);
|
|
1100
1076
|
/**
|
|
1101
1077
|
* getIcon
|
|
1102
|
-
* @returns
|
|
1078
|
+
* @returns icon html
|
|
1103
1079
|
*/
|
|
1104
1080
|
this.getIcon = () => icons[this.icon]();
|
|
1105
1081
|
/**
|
|
1106
1082
|
* Method to set default varianStyle props
|
|
1107
1083
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
1108
|
-
* @returns {void}
|
|
1109
1084
|
*/
|
|
1110
1085
|
this.setDefaultVariantStyle = () => {
|
|
1111
1086
|
if (this.variantStyle === undefined)
|
|
@@ -1116,15 +1091,15 @@ const MgIcon = class {
|
|
|
1116
1091
|
this.variant = undefined;
|
|
1117
1092
|
this.variantStyle = undefined;
|
|
1118
1093
|
this.spin = false;
|
|
1119
|
-
this.
|
|
1094
|
+
this.classCollection = new ClassList(['mg-icon']);
|
|
1120
1095
|
}
|
|
1121
1096
|
validateIcon(newValue, oldValue) {
|
|
1122
1097
|
if (!Object.keys(icons).includes(newValue))
|
|
1123
1098
|
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
|
|
1124
1099
|
else {
|
|
1125
1100
|
if (oldValue !== undefined)
|
|
1126
|
-
this.
|
|
1127
|
-
this.
|
|
1101
|
+
this.classCollection.delete(`mg-icon--${oldValue}`);
|
|
1102
|
+
this.classCollection.add(`mg-icon--${newValue}`);
|
|
1128
1103
|
}
|
|
1129
1104
|
}
|
|
1130
1105
|
validateSize(newValue, oldValue) {
|
|
@@ -1132,8 +1107,8 @@ const MgIcon = class {
|
|
|
1132
1107
|
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes$1.join(', ')}`);
|
|
1133
1108
|
else {
|
|
1134
1109
|
if (oldValue !== undefined)
|
|
1135
|
-
this.
|
|
1136
|
-
this.
|
|
1110
|
+
this.classCollection.delete(`mg-icon--size-${oldValue}`);
|
|
1111
|
+
this.classCollection.add(`mg-icon--size-${newValue}`);
|
|
1137
1112
|
}
|
|
1138
1113
|
}
|
|
1139
1114
|
validateVariant(newValue, oldValue) {
|
|
@@ -1143,8 +1118,8 @@ const MgIcon = class {
|
|
|
1143
1118
|
else {
|
|
1144
1119
|
this.setDefaultVariantStyle();
|
|
1145
1120
|
if (oldValue !== undefined)
|
|
1146
|
-
this.
|
|
1147
|
-
this.
|
|
1121
|
+
this.classCollection.delete(`mg-icon--variant-${oldValue}`);
|
|
1122
|
+
this.classCollection.add(`mg-icon--variant-${newValue}`);
|
|
1148
1123
|
}
|
|
1149
1124
|
}
|
|
1150
1125
|
}
|
|
@@ -1154,24 +1129,23 @@ const MgIcon = class {
|
|
|
1154
1129
|
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
|
|
1155
1130
|
else {
|
|
1156
1131
|
if (oldValue !== undefined)
|
|
1157
|
-
this.
|
|
1158
|
-
this.
|
|
1132
|
+
this.classCollection.delete(`mg-icon--variant-style-${oldValue}`);
|
|
1133
|
+
this.classCollection.add(`mg-icon--variant-style-${newValue}`);
|
|
1159
1134
|
}
|
|
1160
1135
|
}
|
|
1161
1136
|
}
|
|
1162
1137
|
handleSpin(newValue) {
|
|
1163
1138
|
if (newValue) {
|
|
1164
|
-
this.
|
|
1165
|
-
this.
|
|
1139
|
+
this.classCollection.add('mg-icon--spin');
|
|
1140
|
+
this.classCollection.add('mg-a11y-animation');
|
|
1166
1141
|
}
|
|
1167
1142
|
else {
|
|
1168
|
-
this.
|
|
1169
|
-
this.
|
|
1143
|
+
this.classCollection.delete('mg-icon--spin');
|
|
1144
|
+
this.classCollection.delete('mg-a11y-animation');
|
|
1170
1145
|
}
|
|
1171
1146
|
}
|
|
1172
1147
|
/**
|
|
1173
1148
|
* Check if props are well configured on init
|
|
1174
|
-
* @returns {void}
|
|
1175
1149
|
*/
|
|
1176
1150
|
componentWillLoad() {
|
|
1177
1151
|
this.validateIcon(this.icon);
|
|
@@ -1182,10 +1156,10 @@ const MgIcon = class {
|
|
|
1182
1156
|
}
|
|
1183
1157
|
/**
|
|
1184
1158
|
* Render component
|
|
1185
|
-
* @returns
|
|
1159
|
+
* @returns HTML Element
|
|
1186
1160
|
*/
|
|
1187
1161
|
render() {
|
|
1188
|
-
return (h("svg", { class: this.
|
|
1162
|
+
return (h("svg", { class: this.classCollection.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
|
|
1189
1163
|
}
|
|
1190
1164
|
static get watchers() { return {
|
|
1191
1165
|
"icon": ["validateIcon"],
|
|
@@ -1210,7 +1184,6 @@ const MgIllustratedMessage = class {
|
|
|
1210
1184
|
*************/
|
|
1211
1185
|
/**
|
|
1212
1186
|
* Check if component props are well configured on init
|
|
1213
|
-
* @returns {void}
|
|
1214
1187
|
*/
|
|
1215
1188
|
componentDidLoad() {
|
|
1216
1189
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -1225,7 +1198,7 @@ const MgIllustratedMessage = class {
|
|
|
1225
1198
|
}
|
|
1226
1199
|
/**
|
|
1227
1200
|
* Render
|
|
1228
|
-
* @returns
|
|
1201
|
+
* @returns HTML Element
|
|
1229
1202
|
*/
|
|
1230
1203
|
render() {
|
|
1231
1204
|
return (h("div", { class: {
|
|
@@ -1240,12 +1213,17 @@ const MgIllustratedMessage = class {
|
|
|
1240
1213
|
};
|
|
1241
1214
|
MgIllustratedMessage.style = mgIllustratedMessageCss;
|
|
1242
1215
|
|
|
1216
|
+
/**
|
|
1217
|
+
* Possible input width
|
|
1218
|
+
*/
|
|
1219
|
+
const widths = [2, 4, 16, 'full'];
|
|
1220
|
+
|
|
1243
1221
|
/**
|
|
1244
1222
|
* Apply in all input child node the aria-describedby attribute
|
|
1245
|
-
* @param
|
|
1246
|
-
* @param
|
|
1247
|
-
* @param
|
|
1248
|
-
* @returns
|
|
1223
|
+
* @param children - Represent scoped elements
|
|
1224
|
+
* @param ariaDescribedbyIDs - List of IDs
|
|
1225
|
+
* @param utils - Stencil.js utils
|
|
1226
|
+
* @returns Children with aria-describedby attribute
|
|
1249
1227
|
*/
|
|
1250
1228
|
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
1251
1229
|
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
@@ -1258,29 +1236,36 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
|
|
|
1258
1236
|
});
|
|
1259
1237
|
/**
|
|
1260
1238
|
* Add classes based on props
|
|
1261
|
-
* @param
|
|
1239
|
+
* @param props - MgInput Interface Props
|
|
1262
1240
|
*/
|
|
1263
1241
|
const manageClasses = (props) => {
|
|
1264
|
-
props.
|
|
1242
|
+
props.classCollection.add('mg-input');
|
|
1265
1243
|
if (props.labelOnTop)
|
|
1266
|
-
props.
|
|
1244
|
+
props.classCollection.add('mg-input--label-on-top');
|
|
1245
|
+
else
|
|
1246
|
+
props.classCollection.delete('mg-input--label-on-top');
|
|
1267
1247
|
if (props.readonly)
|
|
1268
|
-
props.
|
|
1248
|
+
props.classCollection.add('mg-input--readonly');
|
|
1249
|
+
else
|
|
1250
|
+
props.classCollection.delete('mg-input--readonly');
|
|
1251
|
+
widths.forEach(width => {
|
|
1252
|
+
props.classCollection.delete(`mg-input--width-${width}`);
|
|
1253
|
+
});
|
|
1269
1254
|
if (props.mgWidth !== undefined)
|
|
1270
|
-
props.
|
|
1255
|
+
props.classCollection.add(`mg-input--width-${props.mgWidth}`);
|
|
1271
1256
|
};
|
|
1272
1257
|
/**
|
|
1273
1258
|
* Get tagname
|
|
1274
|
-
* @param
|
|
1275
|
-
* @returns
|
|
1259
|
+
* @param isFieldset - is fieldset
|
|
1260
|
+
* @returns tag name
|
|
1276
1261
|
*/
|
|
1277
1262
|
const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
|
|
1278
1263
|
/**
|
|
1279
1264
|
* Get input template
|
|
1280
|
-
* @param
|
|
1281
|
-
* @param
|
|
1282
|
-
* @param
|
|
1283
|
-
* @returns
|
|
1265
|
+
* @param props - MgInput Interface Props
|
|
1266
|
+
* @param children - Represent scoped elements
|
|
1267
|
+
* @param utils - Stencil.js utils
|
|
1268
|
+
* @returns input template
|
|
1284
1269
|
*/
|
|
1285
1270
|
const MgInput = (props, children, utils) => {
|
|
1286
1271
|
/**
|
|
@@ -1336,17 +1321,17 @@ const MgInput = (props, children, utils) => {
|
|
|
1336
1321
|
const TagName = getTagName(props.isFieldset);
|
|
1337
1322
|
/**
|
|
1338
1323
|
* Get tooltip node
|
|
1339
|
-
* @returns
|
|
1324
|
+
* @returns mg-tooltip
|
|
1340
1325
|
*/
|
|
1341
1326
|
const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
|
|
1342
1327
|
h("mg-icon", { icon: "info-circle" })));
|
|
1343
1328
|
/**
|
|
1344
1329
|
* Get input title (label) node
|
|
1345
1330
|
* Display asterisk only if not disabled and not readonly
|
|
1346
|
-
* @returns
|
|
1331
|
+
* @returns mg-input-title
|
|
1347
1332
|
*/
|
|
1348
1333
|
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
|
|
1349
|
-
return (h(TagName, { class: props.
|
|
1334
|
+
return (h(TagName, { class: props.classCollection.join() },
|
|
1350
1335
|
props.labelOnTop ? (h("div", { class: "mg-input__title" },
|
|
1351
1336
|
getInputTitle(),
|
|
1352
1337
|
!props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
|
|
@@ -1364,8 +1349,8 @@ const mgInputCheckboxCss = ":host{display:block}.mg-input{display:flex;align-ite
|
|
|
1364
1349
|
|
|
1365
1350
|
/**
|
|
1366
1351
|
* type CheckboxItem validation function
|
|
1367
|
-
* @param
|
|
1368
|
-
* @returns
|
|
1352
|
+
* @param items - Checkbox item
|
|
1353
|
+
* @returns match item type
|
|
1369
1354
|
*/
|
|
1370
1355
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
1371
1356
|
items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
|
|
@@ -1383,7 +1368,7 @@ const MgInputCheckbox = class {
|
|
|
1383
1368
|
this.hasDisplayedError = false;
|
|
1384
1369
|
/**
|
|
1385
1370
|
* Handle input event
|
|
1386
|
-
* @param
|
|
1371
|
+
* @param event - input event
|
|
1387
1372
|
*/
|
|
1388
1373
|
this.handleInput = (event) => {
|
|
1389
1374
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -1405,7 +1390,7 @@ const MgInputCheckbox = class {
|
|
|
1405
1390
|
};
|
|
1406
1391
|
/**
|
|
1407
1392
|
* get invalid element
|
|
1408
|
-
* @returns
|
|
1393
|
+
* @returns element
|
|
1409
1394
|
*/
|
|
1410
1395
|
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
1411
1396
|
/**
|
|
@@ -1442,7 +1427,7 @@ const MgInputCheckbox = class {
|
|
|
1442
1427
|
this.helpText = undefined;
|
|
1443
1428
|
this.valid = undefined;
|
|
1444
1429
|
this.invalid = undefined;
|
|
1445
|
-
this.
|
|
1430
|
+
this.classCollection = new ClassList(['mg-input--checkbox']);
|
|
1446
1431
|
this.errorMessage = undefined;
|
|
1447
1432
|
this.checkboxItems = [];
|
|
1448
1433
|
}
|
|
@@ -1472,7 +1457,6 @@ const MgInputCheckbox = class {
|
|
|
1472
1457
|
}
|
|
1473
1458
|
/**
|
|
1474
1459
|
* Public method to display errors
|
|
1475
|
-
* @returns {Promise<void>}
|
|
1476
1460
|
*/
|
|
1477
1461
|
async displayError() {
|
|
1478
1462
|
this.checkValidity();
|
|
@@ -1484,7 +1468,7 @@ const MgInputCheckbox = class {
|
|
|
1484
1468
|
*************/
|
|
1485
1469
|
/**
|
|
1486
1470
|
* Check if component props are well configured on init
|
|
1487
|
-
* @returns
|
|
1471
|
+
* @returns timeout
|
|
1488
1472
|
*/
|
|
1489
1473
|
componentWillLoad() {
|
|
1490
1474
|
// Get locales
|
|
@@ -1500,10 +1484,10 @@ const MgInputCheckbox = class {
|
|
|
1500
1484
|
}
|
|
1501
1485
|
/**
|
|
1502
1486
|
* Render
|
|
1503
|
-
* @returns
|
|
1487
|
+
* @returns HTML Element
|
|
1504
1488
|
*/
|
|
1505
1489
|
render() {
|
|
1506
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
1490
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.checkboxItems
|
|
1507
1491
|
.filter(item => {
|
|
1508
1492
|
return !this.readonly || item.value;
|
|
1509
1493
|
})
|
|
@@ -1567,7 +1551,7 @@ const MgInputDate = class {
|
|
|
1567
1551
|
};
|
|
1568
1552
|
/**
|
|
1569
1553
|
* get input error code
|
|
1570
|
-
* @returns
|
|
1554
|
+
* @returns error code
|
|
1571
1555
|
*/
|
|
1572
1556
|
this.getInputError = () => {
|
|
1573
1557
|
var _a, _b;
|
|
@@ -1592,7 +1576,6 @@ const MgInputDate = class {
|
|
|
1592
1576
|
};
|
|
1593
1577
|
/**
|
|
1594
1578
|
* Check input errors
|
|
1595
|
-
* @returns {void}
|
|
1596
1579
|
*/
|
|
1597
1580
|
this.setErrorMessage = () => {
|
|
1598
1581
|
var _a;
|
|
@@ -1630,7 +1613,7 @@ const MgInputDate = class {
|
|
|
1630
1613
|
this.invalid = undefined;
|
|
1631
1614
|
this.min = undefined;
|
|
1632
1615
|
this.max = undefined;
|
|
1633
|
-
this.
|
|
1616
|
+
this.classCollection = new ClassList(['mg-input--date']);
|
|
1634
1617
|
this.errorMessage = undefined;
|
|
1635
1618
|
}
|
|
1636
1619
|
validateValue(newValue) {
|
|
@@ -1661,7 +1644,6 @@ const MgInputDate = class {
|
|
|
1661
1644
|
}
|
|
1662
1645
|
/**
|
|
1663
1646
|
* Public method to display errors
|
|
1664
|
-
* @returns {Promise<void>}
|
|
1665
1647
|
*/
|
|
1666
1648
|
async displayError() {
|
|
1667
1649
|
this.checkValidity();
|
|
@@ -1673,7 +1655,7 @@ const MgInputDate = class {
|
|
|
1673
1655
|
*************/
|
|
1674
1656
|
/**
|
|
1675
1657
|
* Check if component props are well configured on init
|
|
1676
|
-
* @returns
|
|
1658
|
+
* @returns timeout
|
|
1677
1659
|
*/
|
|
1678
1660
|
componentWillLoad() {
|
|
1679
1661
|
// Get locales
|
|
@@ -1693,10 +1675,10 @@ const MgInputDate = class {
|
|
|
1693
1675
|
}
|
|
1694
1676
|
/**
|
|
1695
1677
|
* Render
|
|
1696
|
-
* @returns
|
|
1678
|
+
* @returns HTML Element
|
|
1697
1679
|
*/
|
|
1698
1680
|
render() {
|
|
1699
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
1681
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
1700
1682
|
if (el !== null)
|
|
1701
1683
|
this.input = el;
|
|
1702
1684
|
} })));
|
|
@@ -1736,7 +1718,6 @@ const MgInputNumeric = class {
|
|
|
1736
1718
|
this.hasDisplayedError = false;
|
|
1737
1719
|
/**
|
|
1738
1720
|
* Handle input event
|
|
1739
|
-
* @returns {void}
|
|
1740
1721
|
*/
|
|
1741
1722
|
this.handleInput = () => {
|
|
1742
1723
|
// Check validity
|
|
@@ -1748,23 +1729,22 @@ const MgInputNumeric = class {
|
|
|
1748
1729
|
};
|
|
1749
1730
|
/**
|
|
1750
1731
|
* Handle focus event
|
|
1751
|
-
* @returns {void}
|
|
1752
1732
|
*/
|
|
1753
1733
|
this.handleFocus = () => {
|
|
1754
1734
|
this.hasFocus = true;
|
|
1755
1735
|
};
|
|
1756
1736
|
/**
|
|
1757
1737
|
* Handle blur event
|
|
1758
|
-
* @returns {void}
|
|
1759
1738
|
*/
|
|
1760
1739
|
this.handleBlur = () => {
|
|
1740
|
+
if (this.value === '-')
|
|
1741
|
+
this.value = '';
|
|
1761
1742
|
// Display Error
|
|
1762
1743
|
this.displayError();
|
|
1763
1744
|
this.hasFocus = false;
|
|
1764
1745
|
};
|
|
1765
1746
|
/**
|
|
1766
1747
|
* Check if input is valid
|
|
1767
|
-
* @returns {void}
|
|
1768
1748
|
*/
|
|
1769
1749
|
this.checkValidity = () => {
|
|
1770
1750
|
this.valid = this.readonly || this.disabled || this.getInputError() === null;
|
|
@@ -1774,7 +1754,6 @@ const MgInputNumeric = class {
|
|
|
1774
1754
|
};
|
|
1775
1755
|
/**
|
|
1776
1756
|
* Set input error message
|
|
1777
|
-
* @returns {void}
|
|
1778
1757
|
*/
|
|
1779
1758
|
this.setErrorMessage = () => {
|
|
1780
1759
|
// Set error message
|
|
@@ -1791,7 +1770,7 @@ const MgInputNumeric = class {
|
|
|
1791
1770
|
};
|
|
1792
1771
|
/**
|
|
1793
1772
|
* Get input error code
|
|
1794
|
-
* @returns
|
|
1773
|
+
* @returns error code
|
|
1795
1774
|
*/
|
|
1796
1775
|
this.getInputError = () => {
|
|
1797
1776
|
let inputError = null;
|
|
@@ -1819,18 +1798,17 @@ const MgInputNumeric = class {
|
|
|
1819
1798
|
};
|
|
1820
1799
|
/**
|
|
1821
1800
|
* Format value based on type
|
|
1822
|
-
* @param
|
|
1823
|
-
* @returns
|
|
1801
|
+
* @param value - value to format
|
|
1802
|
+
* @returns formated local value
|
|
1824
1803
|
*/
|
|
1825
1804
|
this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));
|
|
1826
1805
|
/**
|
|
1827
1806
|
* Validate append slot
|
|
1828
|
-
* @returns {void}
|
|
1829
1807
|
*/
|
|
1830
1808
|
this.validateAppendSlot = () => {
|
|
1831
1809
|
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
1832
1810
|
if (slotAppendInput !== null) {
|
|
1833
|
-
this.
|
|
1811
|
+
this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
1834
1812
|
}
|
|
1835
1813
|
};
|
|
1836
1814
|
this.value = undefined;
|
|
@@ -1854,7 +1832,7 @@ const MgInputNumeric = class {
|
|
|
1854
1832
|
this.decimalLength = 2;
|
|
1855
1833
|
this.valid = undefined;
|
|
1856
1834
|
this.invalid = undefined;
|
|
1857
|
-
this.
|
|
1835
|
+
this.classCollection = new ClassList(['mg-input--numeric']);
|
|
1858
1836
|
this.errorMessage = undefined;
|
|
1859
1837
|
this.hasFocus = false;
|
|
1860
1838
|
}
|
|
@@ -1866,7 +1844,7 @@ const MgInputNumeric = class {
|
|
|
1866
1844
|
// Regex
|
|
1867
1845
|
const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+[.,]?\d*$/;
|
|
1868
1846
|
// Filter input
|
|
1869
|
-
if (
|
|
1847
|
+
if (['', '-'].includes(newValue) || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
1870
1848
|
this.storedValue = newValue;
|
|
1871
1849
|
}
|
|
1872
1850
|
else if (this.storedValue !== undefined) {
|
|
@@ -1913,7 +1891,6 @@ const MgInputNumeric = class {
|
|
|
1913
1891
|
}
|
|
1914
1892
|
/**
|
|
1915
1893
|
* Public method to display errors
|
|
1916
|
-
* @returns {Promise<void>}
|
|
1917
1894
|
*/
|
|
1918
1895
|
async displayError() {
|
|
1919
1896
|
this.checkValidity();
|
|
@@ -1923,7 +1900,7 @@ const MgInputNumeric = class {
|
|
|
1923
1900
|
/**
|
|
1924
1901
|
* Displayed value in input
|
|
1925
1902
|
* Change on focus/blur
|
|
1926
|
-
* @returns
|
|
1903
|
+
* @returns display value
|
|
1927
1904
|
*/
|
|
1928
1905
|
displayValue() {
|
|
1929
1906
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -1933,7 +1910,7 @@ const MgInputNumeric = class {
|
|
|
1933
1910
|
*************/
|
|
1934
1911
|
/**
|
|
1935
1912
|
* Check if component props are well configured on init
|
|
1936
|
-
* @returns
|
|
1913
|
+
* @returns timeout
|
|
1937
1914
|
*/
|
|
1938
1915
|
componentWillLoad() {
|
|
1939
1916
|
// Get locales
|
|
@@ -1956,10 +1933,10 @@ const MgInputNumeric = class {
|
|
|
1956
1933
|
}
|
|
1957
1934
|
/**
|
|
1958
1935
|
* Render
|
|
1959
|
-
* @returns
|
|
1936
|
+
* @returns HTML Element
|
|
1960
1937
|
*/
|
|
1961
1938
|
render() {
|
|
1962
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
1939
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
|
|
1963
1940
|
if (el !== null)
|
|
1964
1941
|
this.input = el;
|
|
1965
1942
|
} }), h("slot", { name: "append-input" })));
|
|
@@ -2038,7 +2015,7 @@ const MgInputPassword = class {
|
|
|
2038
2015
|
this.helpText = undefined;
|
|
2039
2016
|
this.valid = undefined;
|
|
2040
2017
|
this.invalid = undefined;
|
|
2041
|
-
this.
|
|
2018
|
+
this.classCollection = new ClassList(['mg-input--password']);
|
|
2042
2019
|
this.errorMessage = undefined;
|
|
2043
2020
|
}
|
|
2044
2021
|
handleValue(newValue) {
|
|
@@ -2056,7 +2033,6 @@ const MgInputPassword = class {
|
|
|
2056
2033
|
}
|
|
2057
2034
|
/**
|
|
2058
2035
|
* Public method to display errors
|
|
2059
|
-
* @returns {Promise<void>}
|
|
2060
2036
|
*/
|
|
2061
2037
|
async displayError() {
|
|
2062
2038
|
this.checkValidity();
|
|
@@ -2068,7 +2044,7 @@ const MgInputPassword = class {
|
|
|
2068
2044
|
*************/
|
|
2069
2045
|
/**
|
|
2070
2046
|
* Check if component props are well configured on init
|
|
2071
|
-
* @returns
|
|
2047
|
+
* @returns timeout
|
|
2072
2048
|
*/
|
|
2073
2049
|
componentWillLoad() {
|
|
2074
2050
|
// Get locales
|
|
@@ -2082,10 +2058,10 @@ const MgInputPassword = class {
|
|
|
2082
2058
|
}
|
|
2083
2059
|
/**
|
|
2084
2060
|
* Render
|
|
2085
|
-
* @returns
|
|
2061
|
+
* @returns HTML Element
|
|
2086
2062
|
*/
|
|
2087
2063
|
render() {
|
|
2088
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2064
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2089
2065
|
if (el !== null)
|
|
2090
2066
|
this.input = el;
|
|
2091
2067
|
} })));
|
|
@@ -2104,8 +2080,8 @@ const mgInputRadioCss = ":host{display:block}.mg-input{display:flex;align-items:
|
|
|
2104
2080
|
|
|
2105
2081
|
/**
|
|
2106
2082
|
* type Option validation function
|
|
2107
|
-
* @param
|
|
2108
|
-
* @returns
|
|
2083
|
+
* @param option - radio option
|
|
2084
|
+
* @returns radio option type is valid
|
|
2109
2085
|
*/
|
|
2110
2086
|
const isOption$2 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
2111
2087
|
const MgInputRadio = class {
|
|
@@ -2122,8 +2098,7 @@ const MgInputRadio = class {
|
|
|
2122
2098
|
this.hasDisplayedError = false;
|
|
2123
2099
|
/**
|
|
2124
2100
|
* Handle input event
|
|
2125
|
-
* @param
|
|
2126
|
-
* @returns {void}
|
|
2101
|
+
* @param event - input event
|
|
2127
2102
|
*/
|
|
2128
2103
|
this.handleInput = (event) => {
|
|
2129
2104
|
this.checkValidity();
|
|
@@ -2131,7 +2106,6 @@ const MgInputRadio = class {
|
|
|
2131
2106
|
};
|
|
2132
2107
|
/**
|
|
2133
2108
|
* Handle blur event
|
|
2134
|
-
* @returns {void}
|
|
2135
2109
|
*/
|
|
2136
2110
|
this.handleBlur = () => {
|
|
2137
2111
|
this.checkValidity();
|
|
@@ -2139,7 +2113,6 @@ const MgInputRadio = class {
|
|
|
2139
2113
|
};
|
|
2140
2114
|
/**
|
|
2141
2115
|
* Check if input is valid
|
|
2142
|
-
* @returns {void}
|
|
2143
2116
|
*/
|
|
2144
2117
|
this.checkValidity = () => {
|
|
2145
2118
|
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
@@ -2149,7 +2122,6 @@ const MgInputRadio = class {
|
|
|
2149
2122
|
};
|
|
2150
2123
|
/**
|
|
2151
2124
|
* Set input error message
|
|
2152
|
-
* @returns {void}
|
|
2153
2125
|
*/
|
|
2154
2126
|
this.setErrorMessage = () => {
|
|
2155
2127
|
const invalidElement = this.getInvalidElement();
|
|
@@ -2161,7 +2133,7 @@ const MgInputRadio = class {
|
|
|
2161
2133
|
};
|
|
2162
2134
|
/**
|
|
2163
2135
|
* get invalid element
|
|
2164
|
-
* @returns
|
|
2136
|
+
* @returns element
|
|
2165
2137
|
*/
|
|
2166
2138
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
2167
2139
|
this.value = undefined;
|
|
@@ -2179,7 +2151,7 @@ const MgInputRadio = class {
|
|
|
2179
2151
|
this.helpText = undefined;
|
|
2180
2152
|
this.valid = undefined;
|
|
2181
2153
|
this.invalid = undefined;
|
|
2182
|
-
this.
|
|
2154
|
+
this.classCollection = new ClassList(['mg-input--radio']);
|
|
2183
2155
|
this.errorMessage = undefined;
|
|
2184
2156
|
this.options = undefined;
|
|
2185
2157
|
}
|
|
@@ -2215,7 +2187,6 @@ const MgInputRadio = class {
|
|
|
2215
2187
|
}
|
|
2216
2188
|
/**
|
|
2217
2189
|
* Public method to display errors
|
|
2218
|
-
* @returns {Promise<void>}
|
|
2219
2190
|
*/
|
|
2220
2191
|
async displayError() {
|
|
2221
2192
|
this.checkValidity();
|
|
@@ -2227,7 +2198,7 @@ const MgInputRadio = class {
|
|
|
2227
2198
|
*************/
|
|
2228
2199
|
/**
|
|
2229
2200
|
* Check if component props are well configured on init
|
|
2230
|
-
* @returns
|
|
2201
|
+
* @returns timeout
|
|
2231
2202
|
*/
|
|
2232
2203
|
componentWillLoad() {
|
|
2233
2204
|
// Get locales
|
|
@@ -2243,10 +2214,10 @@ const MgInputRadio = class {
|
|
|
2243
2214
|
}
|
|
2244
2215
|
/**
|
|
2245
2216
|
* Render
|
|
2246
|
-
* @returns
|
|
2217
|
+
* @returns HTML Element
|
|
2247
2218
|
*/
|
|
2248
2219
|
render() {
|
|
2249
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2220
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => {
|
|
2250
2221
|
if (el !== null)
|
|
2251
2222
|
this.inputs[index] = el;
|
|
2252
2223
|
} }), h("label", { htmlFor: this.identifier + '_' + index }, input.title)))))));
|
|
@@ -2266,31 +2237,27 @@ const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items
|
|
|
2266
2237
|
|
|
2267
2238
|
/**
|
|
2268
2239
|
* Check if item is a well configured option
|
|
2269
|
-
* @param
|
|
2270
|
-
* @returns
|
|
2240
|
+
* @param option - select option
|
|
2241
|
+
* @returns select option type is valid
|
|
2271
2242
|
*/
|
|
2272
2243
|
const isOption$1 = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
2273
2244
|
/**
|
|
2274
2245
|
* Check if items[] is SelectOption
|
|
2275
|
-
* @param
|
|
2276
|
-
* @returns
|
|
2246
|
+
* @param items - select option
|
|
2247
|
+
* @returns select option array type is valid
|
|
2277
2248
|
*/
|
|
2278
2249
|
const allItemsAreOptions = (items) => Array.isArray(items) && items.every(item => isOption$1(item));
|
|
2279
2250
|
/**
|
|
2280
2251
|
* Check if item is a well configured optgroup
|
|
2281
|
-
* @param
|
|
2282
|
-
* @returns
|
|
2252
|
+
* @param optgroup - select option
|
|
2253
|
+
* @returns select optgroup type is valid
|
|
2283
2254
|
*/
|
|
2284
2255
|
const isOptGroup = (optgroup) => typeof optgroup === 'object' && typeof optgroup.group === 'string' && allItemsAreOptions(optgroup.options);
|
|
2285
2256
|
/**
|
|
2286
2257
|
* Group options
|
|
2287
|
-
* @param
|
|
2288
|
-
* @param
|
|
2289
|
-
* @
|
|
2290
|
-
* @param {string} item.title item title
|
|
2291
|
-
* @param {unknown} item.value item value
|
|
2292
|
-
* @param {boolean} item.disabled is item disabled
|
|
2293
|
-
* @returns {(SelectOption | OptGroup)[]} grouped options
|
|
2258
|
+
* @param acc - reduce accumulator
|
|
2259
|
+
* @param item - item to add
|
|
2260
|
+
* @returns grouped options
|
|
2294
2261
|
*/
|
|
2295
2262
|
const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
2296
2263
|
if (group !== undefined) {
|
|
@@ -2319,7 +2286,6 @@ const MgInputSelect = class {
|
|
|
2319
2286
|
this.hasDisplayedError = false;
|
|
2320
2287
|
/**
|
|
2321
2288
|
* Handle input event
|
|
2322
|
-
* @returns {void}
|
|
2323
2289
|
*/
|
|
2324
2290
|
this.handleInput = () => {
|
|
2325
2291
|
this.updateValue();
|
|
@@ -2328,14 +2294,13 @@ const MgInputSelect = class {
|
|
|
2328
2294
|
};
|
|
2329
2295
|
/**
|
|
2330
2296
|
* Method to compare item.title with input.value
|
|
2331
|
-
* @param
|
|
2332
|
-
* @returns
|
|
2297
|
+
* @param item - item to compare with
|
|
2298
|
+
* @returns truthy if input.value is an item
|
|
2333
2299
|
*/
|
|
2334
2300
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
2335
2301
|
/**
|
|
2336
2302
|
* value props setter
|
|
2337
|
-
* @param
|
|
2338
|
-
* @returns {void}
|
|
2303
|
+
* @param newValue - value to update with
|
|
2339
2304
|
*/
|
|
2340
2305
|
this.setValue = (newValue) => {
|
|
2341
2306
|
this.checkValidity();
|
|
@@ -2343,7 +2308,6 @@ const MgInputSelect = class {
|
|
|
2343
2308
|
};
|
|
2344
2309
|
/**
|
|
2345
2310
|
* Update value from input.value
|
|
2346
|
-
* @returns {void}
|
|
2347
2311
|
*/
|
|
2348
2312
|
this.updateValue = () => {
|
|
2349
2313
|
if (this.input.value === '') {
|
|
@@ -2369,7 +2333,7 @@ const MgInputSelect = class {
|
|
|
2369
2333
|
};
|
|
2370
2334
|
/**
|
|
2371
2335
|
* Input value is disabled
|
|
2372
|
-
* @returns
|
|
2336
|
+
* @returns truthy if input value is disabled
|
|
2373
2337
|
*/
|
|
2374
2338
|
this.isDisabledValue = () => { var _a; return allItemsAreOptions(this.options) && ((_a = this.options.find(this.isInputValue)) === null || _a === void 0 ? void 0 : _a.disabled) === true; };
|
|
2375
2339
|
/**
|
|
@@ -2394,8 +2358,8 @@ const MgInputSelect = class {
|
|
|
2394
2358
|
};
|
|
2395
2359
|
/**
|
|
2396
2360
|
* Render option
|
|
2397
|
-
* @param
|
|
2398
|
-
* @returns
|
|
2361
|
+
* @param option - to render
|
|
2362
|
+
* @returns render option
|
|
2399
2363
|
*/
|
|
2400
2364
|
this.renderOption = (option) => (h("option", { key: option.title, value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title));
|
|
2401
2365
|
this.value = undefined;
|
|
@@ -2416,7 +2380,7 @@ const MgInputSelect = class {
|
|
|
2416
2380
|
this.helpText = undefined;
|
|
2417
2381
|
this.valid = undefined;
|
|
2418
2382
|
this.invalid = undefined;
|
|
2419
|
-
this.
|
|
2383
|
+
this.classCollection = new ClassList(['mg-input--select']);
|
|
2420
2384
|
this.errorMessage = undefined;
|
|
2421
2385
|
this.options = undefined;
|
|
2422
2386
|
this.valueExist = undefined;
|
|
@@ -2474,7 +2438,6 @@ const MgInputSelect = class {
|
|
|
2474
2438
|
}
|
|
2475
2439
|
/**
|
|
2476
2440
|
* Public method to display errors
|
|
2477
|
-
* @returns {Promise<void>}
|
|
2478
2441
|
*/
|
|
2479
2442
|
async displayError() {
|
|
2480
2443
|
this.checkValidity();
|
|
@@ -2486,7 +2449,7 @@ const MgInputSelect = class {
|
|
|
2486
2449
|
*************/
|
|
2487
2450
|
/**
|
|
2488
2451
|
* Check if component props are well configured on init
|
|
2489
|
-
* @returns
|
|
2452
|
+
* @returns timeout
|
|
2490
2453
|
*/
|
|
2491
2454
|
componentWillLoad() {
|
|
2492
2455
|
// Get locales
|
|
@@ -2507,10 +2470,10 @@ const MgInputSelect = class {
|
|
|
2507
2470
|
}
|
|
2508
2471
|
/**
|
|
2509
2472
|
* Render
|
|
2510
|
-
* @returns
|
|
2473
|
+
* @returns HTML Element
|
|
2511
2474
|
*/
|
|
2512
2475
|
render() {
|
|
2513
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2476
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: undefined, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2514
2477
|
if (el !== null)
|
|
2515
2478
|
this.input = el;
|
|
2516
2479
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -2545,7 +2508,6 @@ const MgInputText = class {
|
|
|
2545
2508
|
this.hasDisplayedError = false;
|
|
2546
2509
|
/**
|
|
2547
2510
|
* Handle input event
|
|
2548
|
-
* @returns {void}
|
|
2549
2511
|
*/
|
|
2550
2512
|
this.handleInput = () => {
|
|
2551
2513
|
this.checkValidity();
|
|
@@ -2556,26 +2518,23 @@ const MgInputText = class {
|
|
|
2556
2518
|
};
|
|
2557
2519
|
/**
|
|
2558
2520
|
* Handle focus event
|
|
2559
|
-
* @returns {void}
|
|
2560
2521
|
*/
|
|
2561
2522
|
this.handleFocus = () => {
|
|
2562
|
-
this.
|
|
2563
|
-
this.
|
|
2523
|
+
this.classCollection.add(this.classFocus);
|
|
2524
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2564
2525
|
};
|
|
2565
2526
|
/**
|
|
2566
2527
|
* Handle blur event
|
|
2567
|
-
* @returns {void}
|
|
2568
2528
|
*/
|
|
2569
2529
|
this.handleBlur = () => {
|
|
2570
2530
|
// Manage focus
|
|
2571
|
-
this.
|
|
2572
|
-
this.
|
|
2531
|
+
this.classCollection.delete(this.classFocus);
|
|
2532
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2573
2533
|
// Display Error
|
|
2574
2534
|
this.displayError();
|
|
2575
2535
|
};
|
|
2576
2536
|
/**
|
|
2577
2537
|
* Check if input is valid
|
|
2578
|
-
* @returns {void}
|
|
2579
2538
|
*/
|
|
2580
2539
|
this.checkValidity = () => {
|
|
2581
2540
|
var _a;
|
|
@@ -2586,7 +2545,6 @@ const MgInputText = class {
|
|
|
2586
2545
|
};
|
|
2587
2546
|
/**
|
|
2588
2547
|
* Set input error message
|
|
2589
|
-
* @returns {void}
|
|
2590
2548
|
*/
|
|
2591
2549
|
this.setErrorMessage = () => {
|
|
2592
2550
|
// Set error message
|
|
@@ -2602,7 +2560,6 @@ const MgInputText = class {
|
|
|
2602
2560
|
};
|
|
2603
2561
|
/**
|
|
2604
2562
|
* Validate pattern configuration
|
|
2605
|
-
* @returns {void}
|
|
2606
2563
|
*/
|
|
2607
2564
|
this.validatePattern = () => {
|
|
2608
2565
|
if (this.pattern !== undefined &&
|
|
@@ -2614,16 +2571,15 @@ const MgInputText = class {
|
|
|
2614
2571
|
};
|
|
2615
2572
|
/**
|
|
2616
2573
|
* Validate append slot
|
|
2617
|
-
* @returns {void}
|
|
2618
2574
|
*/
|
|
2619
2575
|
this.validateAppendSlot = () => {
|
|
2620
2576
|
const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
|
|
2621
2577
|
if (slotAppendInput.length === 1) {
|
|
2622
|
-
this.
|
|
2578
|
+
this.classCollection.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.classIsInputGroupAppend : 'mg-input--is-append-input-slot-content');
|
|
2623
2579
|
}
|
|
2624
2580
|
else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
|
|
2625
|
-
this.
|
|
2626
|
-
this.
|
|
2581
|
+
this.classCollection.add(this.classIsInputGroupAppend);
|
|
2582
|
+
this.classCollection.add('mg-input--has-buttons-group-append');
|
|
2627
2583
|
}
|
|
2628
2584
|
};
|
|
2629
2585
|
this.value = undefined;
|
|
@@ -2647,7 +2603,7 @@ const MgInputText = class {
|
|
|
2647
2603
|
this.helpText = undefined;
|
|
2648
2604
|
this.valid = undefined;
|
|
2649
2605
|
this.invalid = undefined;
|
|
2650
|
-
this.
|
|
2606
|
+
this.classCollection = new ClassList(['mg-input--text']);
|
|
2651
2607
|
this.errorMessage = undefined;
|
|
2652
2608
|
}
|
|
2653
2609
|
handleValue(newValue) {
|
|
@@ -2655,10 +2611,10 @@ const MgInputText = class {
|
|
|
2655
2611
|
}
|
|
2656
2612
|
validateIcon(newValue) {
|
|
2657
2613
|
if (newValue !== undefined) {
|
|
2658
|
-
this.
|
|
2614
|
+
this.classCollection.add(this.classHasIcon);
|
|
2659
2615
|
}
|
|
2660
2616
|
else {
|
|
2661
|
-
this.
|
|
2617
|
+
this.classCollection.delete(this.classHasIcon);
|
|
2662
2618
|
}
|
|
2663
2619
|
}
|
|
2664
2620
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -2673,14 +2629,12 @@ const MgInputText = class {
|
|
|
2673
2629
|
}
|
|
2674
2630
|
/**
|
|
2675
2631
|
* Public method to play input focus
|
|
2676
|
-
* @returns {Promise<void>}
|
|
2677
2632
|
*/
|
|
2678
2633
|
async setFocus() {
|
|
2679
2634
|
this.input.focus();
|
|
2680
2635
|
}
|
|
2681
2636
|
/**
|
|
2682
2637
|
* Public method to display errors
|
|
2683
|
-
* @returns {Promise<void>}
|
|
2684
2638
|
*/
|
|
2685
2639
|
async displayError() {
|
|
2686
2640
|
this.checkValidity();
|
|
@@ -2692,7 +2646,7 @@ const MgInputText = class {
|
|
|
2692
2646
|
*************/
|
|
2693
2647
|
/**
|
|
2694
2648
|
* Check if component props are well configured on init
|
|
2695
|
-
* @returns
|
|
2649
|
+
* @returns timeout
|
|
2696
2650
|
*/
|
|
2697
2651
|
componentWillLoad() {
|
|
2698
2652
|
// Get locales
|
|
@@ -2711,10 +2665,10 @@ const MgInputText = class {
|
|
|
2711
2665
|
}
|
|
2712
2666
|
/**
|
|
2713
2667
|
* Render
|
|
2714
|
-
* @returns
|
|
2668
|
+
* @returns HTML Element
|
|
2715
2669
|
*/
|
|
2716
2670
|
render() {
|
|
2717
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2671
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("div", { class: "mg-input__with-character-left", style: {
|
|
2718
2672
|
'--mg-character-left-message-length': (this.displayCharacterLeft
|
|
2719
2673
|
? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
|
|
2720
2674
|
: 0).toString(),
|
|
@@ -2763,23 +2717,23 @@ const MgInputTextarea = class {
|
|
|
2763
2717
|
* Handle focus event
|
|
2764
2718
|
*/
|
|
2765
2719
|
this.handleFocus = () => {
|
|
2766
|
-
this.
|
|
2767
|
-
this.
|
|
2720
|
+
this.classCollection.add(this.classFocus);
|
|
2721
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2768
2722
|
};
|
|
2769
2723
|
/**
|
|
2770
2724
|
* Handle blur event
|
|
2771
2725
|
*/
|
|
2772
2726
|
this.handleBlur = () => {
|
|
2773
2727
|
// Manage focus
|
|
2774
|
-
this.
|
|
2775
|
-
this.
|
|
2728
|
+
this.classCollection.delete(this.classFocus);
|
|
2729
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2776
2730
|
// Display Error
|
|
2777
2731
|
this.displayError();
|
|
2778
2732
|
};
|
|
2779
2733
|
/**
|
|
2780
2734
|
* Get pattern validity
|
|
2781
2735
|
* Pattern is not defined on textarea field: https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
|
|
2782
|
-
* @returns
|
|
2736
|
+
* @returns is pattern valid
|
|
2783
2737
|
*/
|
|
2784
2738
|
this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
|
|
2785
2739
|
/**
|
|
@@ -2839,7 +2793,7 @@ const MgInputTextarea = class {
|
|
|
2839
2793
|
this.valid = undefined;
|
|
2840
2794
|
this.invalid = undefined;
|
|
2841
2795
|
this.resizable = 'none';
|
|
2842
|
-
this.
|
|
2796
|
+
this.classCollection = new ClassList(['mg-input--textarea']);
|
|
2843
2797
|
this.errorMessage = undefined;
|
|
2844
2798
|
}
|
|
2845
2799
|
handleValue(newValue) {
|
|
@@ -2858,15 +2812,14 @@ const MgInputTextarea = class {
|
|
|
2858
2812
|
}
|
|
2859
2813
|
validateDisplayCharacterLeft(newValue) {
|
|
2860
2814
|
if (newValue) {
|
|
2861
|
-
this.
|
|
2815
|
+
this.classCollection.add(this.classHasDisplayCharacterLeft);
|
|
2862
2816
|
}
|
|
2863
2817
|
else {
|
|
2864
|
-
this.
|
|
2818
|
+
this.classCollection.delete(this.classHasDisplayCharacterLeft);
|
|
2865
2819
|
}
|
|
2866
2820
|
}
|
|
2867
2821
|
/**
|
|
2868
2822
|
* Public method to display errors
|
|
2869
|
-
* @returns {Promise<void>}
|
|
2870
2823
|
*/
|
|
2871
2824
|
async displayError() {
|
|
2872
2825
|
this.checkValidity();
|
|
@@ -2878,7 +2831,7 @@ const MgInputTextarea = class {
|
|
|
2878
2831
|
*************/
|
|
2879
2832
|
/**
|
|
2880
2833
|
* Check if component props are well configured on init
|
|
2881
|
-
* @returns
|
|
2834
|
+
* @returns timeout
|
|
2882
2835
|
*/
|
|
2883
2836
|
componentWillLoad() {
|
|
2884
2837
|
// Get locales
|
|
@@ -2896,10 +2849,10 @@ const MgInputTextarea = class {
|
|
|
2896
2849
|
}
|
|
2897
2850
|
/**
|
|
2898
2851
|
* Render
|
|
2899
|
-
* @returns
|
|
2852
|
+
* @returns HTML Element
|
|
2900
2853
|
*/
|
|
2901
2854
|
render() {
|
|
2902
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2855
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("div", { class: "mg-input__with-character-left" }, h("textarea", { class: {
|
|
2903
2856
|
'mg-input__box': true,
|
|
2904
2857
|
'mg-input__box--resizable': this.resizable === 'both',
|
|
2905
2858
|
'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
@@ -2943,7 +2896,6 @@ const MgInputTitle = class {
|
|
|
2943
2896
|
*************/
|
|
2944
2897
|
/**
|
|
2945
2898
|
* Init tag name
|
|
2946
|
-
* @returns {void}
|
|
2947
2899
|
*/
|
|
2948
2900
|
componentWillLoad() {
|
|
2949
2901
|
this.validateIdentifier(this.identifier);
|
|
@@ -2951,7 +2903,7 @@ const MgInputTitle = class {
|
|
|
2951
2903
|
}
|
|
2952
2904
|
/**
|
|
2953
2905
|
* Render
|
|
2954
|
-
* @returns
|
|
2906
|
+
* @returns HTML element
|
|
2955
2907
|
*/
|
|
2956
2908
|
render() {
|
|
2957
2909
|
const TagName = this.tagName;
|
|
@@ -2968,8 +2920,8 @@ const mgInputToggleCss = ":host{display:block}.mg-input{display:flex;align-items
|
|
|
2968
2920
|
|
|
2969
2921
|
/**
|
|
2970
2922
|
* type Option validation function
|
|
2971
|
-
* @param
|
|
2972
|
-
* @returns
|
|
2923
|
+
* @param option - radio option
|
|
2924
|
+
* @returns toggle option type is valid
|
|
2973
2925
|
*/
|
|
2974
2926
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
2975
2927
|
const MgInputToggle = class {
|
|
@@ -2988,14 +2940,12 @@ const MgInputToggle = class {
|
|
|
2988
2940
|
this.classIcon = 'mg-input--toggle-icon';
|
|
2989
2941
|
/**
|
|
2990
2942
|
* Change checked value
|
|
2991
|
-
* @returns {void}
|
|
2992
2943
|
*/
|
|
2993
2944
|
this.toggleChecked = () => {
|
|
2994
2945
|
this.checked = !this.checked;
|
|
2995
2946
|
};
|
|
2996
2947
|
/**
|
|
2997
2948
|
* Slots validation
|
|
2998
|
-
* @returns {void}
|
|
2999
2949
|
*/
|
|
3000
2950
|
this.validateSlots = () => {
|
|
3001
2951
|
const slots = Array.from(this.element.children);
|
|
@@ -3021,7 +2971,7 @@ const MgInputToggle = class {
|
|
|
3021
2971
|
this.disabled = false;
|
|
3022
2972
|
this.tooltip = undefined;
|
|
3023
2973
|
this.helpText = undefined;
|
|
3024
|
-
this.
|
|
2974
|
+
this.classCollection = new ClassList(['mg-input--toggle']);
|
|
3025
2975
|
this.options = undefined;
|
|
3026
2976
|
this.checked = false;
|
|
3027
2977
|
}
|
|
@@ -3049,40 +2999,39 @@ const MgInputToggle = class {
|
|
|
3049
2999
|
}
|
|
3050
3000
|
handleIsOnOff(newValue) {
|
|
3051
3001
|
if (newValue)
|
|
3052
|
-
this.
|
|
3002
|
+
this.classCollection.add(this.classOnOff);
|
|
3053
3003
|
else
|
|
3054
|
-
this.
|
|
3004
|
+
this.classCollection.delete(this.classOnOff);
|
|
3055
3005
|
}
|
|
3056
3006
|
handleIsIcon(newValue) {
|
|
3057
3007
|
if (newValue)
|
|
3058
|
-
this.
|
|
3008
|
+
this.classCollection.add(this.classIcon);
|
|
3059
3009
|
else
|
|
3060
|
-
this.
|
|
3010
|
+
this.classCollection.delete(this.classIcon);
|
|
3061
3011
|
}
|
|
3062
3012
|
handleReadonly(newValue) {
|
|
3063
3013
|
if (newValue)
|
|
3064
|
-
this.
|
|
3014
|
+
this.classCollection.add(this.classReadonly);
|
|
3065
3015
|
else
|
|
3066
|
-
this.
|
|
3016
|
+
this.classCollection.delete(this.classReadonly);
|
|
3067
3017
|
}
|
|
3068
3018
|
handleDisabled(newValue) {
|
|
3069
3019
|
if (newValue)
|
|
3070
|
-
this.
|
|
3020
|
+
this.classCollection.add(this.classDisabled);
|
|
3071
3021
|
else
|
|
3072
|
-
this.
|
|
3022
|
+
this.classCollection.delete(this.classDisabled);
|
|
3073
3023
|
}
|
|
3074
3024
|
handleChecked(newValue) {
|
|
3075
3025
|
// style
|
|
3076
3026
|
if (newValue)
|
|
3077
|
-
this.
|
|
3027
|
+
this.classCollection.add(this.classIsActive);
|
|
3078
3028
|
else
|
|
3079
|
-
this.
|
|
3029
|
+
this.classCollection.delete(this.classIsActive);
|
|
3080
3030
|
// update value
|
|
3081
3031
|
this.value = this.options[newValue ? 1 : 0].value;
|
|
3082
3032
|
}
|
|
3083
3033
|
/**
|
|
3084
3034
|
* set checked state
|
|
3085
|
-
* @returns {void}
|
|
3086
3035
|
*/
|
|
3087
3036
|
setChecked() {
|
|
3088
3037
|
const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);
|
|
@@ -3124,10 +3073,10 @@ const MgInputToggle = class {
|
|
|
3124
3073
|
}
|
|
3125
3074
|
/**
|
|
3126
3075
|
* Render
|
|
3127
|
-
* @returns
|
|
3076
|
+
* @returns HTML Element
|
|
3128
3077
|
*/
|
|
3129
3078
|
render() {
|
|
3130
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
3079
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-2" })))));
|
|
3131
3080
|
}
|
|
3132
3081
|
get element() { return getElement(this); }
|
|
3133
3082
|
static get watchers() { return {
|
|
@@ -3158,9 +3107,8 @@ const MgMenu = class {
|
|
|
3158
3107
|
*************/
|
|
3159
3108
|
/**
|
|
3160
3109
|
* Close matching menu-item
|
|
3161
|
-
* @param
|
|
3162
|
-
* @param
|
|
3163
|
-
* @returns {void}
|
|
3110
|
+
* @param item - menu-item to close
|
|
3111
|
+
* @param condition - addionnal condition
|
|
3164
3112
|
*/
|
|
3165
3113
|
this.closeMenuItem = (item, condition) => {
|
|
3166
3114
|
if (!this.isChildMenu && condition) {
|
|
@@ -3169,19 +3117,18 @@ const MgMenu = class {
|
|
|
3169
3117
|
};
|
|
3170
3118
|
/**
|
|
3171
3119
|
* get mg-item-more element
|
|
3172
|
-
* @returns
|
|
3120
|
+
* @returns mg-item-more element
|
|
3173
3121
|
*/
|
|
3174
3122
|
this.getItemMore = () => this.element.querySelector('mg-item-more');
|
|
3175
3123
|
/**
|
|
3176
|
-
* get mg-item-more
|
|
3177
|
-
* @returns
|
|
3124
|
+
* get mg-item-more child mg-menu-item element
|
|
3125
|
+
* @returns mg-menu-item element
|
|
3178
3126
|
*/
|
|
3179
3127
|
this.getItemMoreMenuItem = () => { var _a, _b; return (_b = (_a = this.getItemMore()) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mg-menu-item'); };
|
|
3180
3128
|
/**
|
|
3181
3129
|
* Set item listend
|
|
3182
|
-
* @param
|
|
3183
|
-
* @param
|
|
3184
|
-
* @returns {void}
|
|
3130
|
+
* @param item - mg-menu-item element
|
|
3131
|
+
* @param index - number
|
|
3185
3132
|
*/
|
|
3186
3133
|
this.setItemListener = (item, index) => {
|
|
3187
3134
|
['click', 'focus'].forEach(trigger => {
|
|
@@ -3196,7 +3143,6 @@ const MgMenu = class {
|
|
|
3196
3143
|
};
|
|
3197
3144
|
/**
|
|
3198
3145
|
* Store menu-items on component init and add listeners
|
|
3199
|
-
* @returns {void}
|
|
3200
3146
|
*/
|
|
3201
3147
|
this.initMenuItemsListeners = () => {
|
|
3202
3148
|
// add listeners on menu item and edit index
|
|
@@ -3206,14 +3152,12 @@ const MgMenu = class {
|
|
|
3206
3152
|
};
|
|
3207
3153
|
/**
|
|
3208
3154
|
* Handle item-loaded event on mg-item-more element
|
|
3209
|
-
* @returns {void}
|
|
3210
3155
|
*/
|
|
3211
3156
|
this.handleItemLoaded = () => {
|
|
3212
3157
|
this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);
|
|
3213
3158
|
};
|
|
3214
3159
|
/**
|
|
3215
3160
|
* render mg-item-more
|
|
3216
|
-
* @returns {void}
|
|
3217
3161
|
*/
|
|
3218
3162
|
this.renderMgItemMore = () => {
|
|
3219
3163
|
// /!\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement
|
|
@@ -3255,7 +3199,6 @@ const MgMenu = class {
|
|
|
3255
3199
|
*************/
|
|
3256
3200
|
/**
|
|
3257
3201
|
* Validate props
|
|
3258
|
-
* @returns {void}
|
|
3259
3202
|
*/
|
|
3260
3203
|
componentWillLoad() {
|
|
3261
3204
|
this.validateDirection(this.direction);
|
|
@@ -3265,7 +3208,7 @@ const MgMenu = class {
|
|
|
3265
3208
|
}
|
|
3266
3209
|
/**
|
|
3267
3210
|
* Check if component slots configuration
|
|
3268
|
-
* @returns
|
|
3211
|
+
* @returns timeout
|
|
3269
3212
|
*/
|
|
3270
3213
|
componentDidLoad() {
|
|
3271
3214
|
// update props and states after componentDidLoad hook
|
|
@@ -3295,14 +3238,13 @@ const MgMenu = class {
|
|
|
3295
3238
|
}
|
|
3296
3239
|
/**
|
|
3297
3240
|
* Add listeners to items
|
|
3298
|
-
* @returns {void}
|
|
3299
3241
|
*/
|
|
3300
3242
|
componentDidRender() {
|
|
3301
3243
|
this.initMenuItemsListeners();
|
|
3302
3244
|
}
|
|
3303
3245
|
/**
|
|
3304
3246
|
* Render
|
|
3305
|
-
* @returns
|
|
3247
|
+
* @returns HTML Element
|
|
3306
3248
|
*/
|
|
3307
3249
|
render() {
|
|
3308
3250
|
return (h(Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, h("slot", null)));
|
|
@@ -3334,29 +3276,27 @@ const MgMenuItem = class {
|
|
|
3334
3276
|
**********/
|
|
3335
3277
|
/**
|
|
3336
3278
|
* Toggle expanded prop value
|
|
3337
|
-
* @returns {void}
|
|
3338
3279
|
*/
|
|
3339
3280
|
this.toggleExpanded = () => {
|
|
3340
3281
|
this.expanded = !this.expanded;
|
|
3341
3282
|
};
|
|
3342
3283
|
/**
|
|
3343
3284
|
* Does an Element have given Status
|
|
3344
|
-
* @param
|
|
3345
|
-
* @param
|
|
3346
|
-
* @returns
|
|
3285
|
+
* @param mgMenuItemElement - to parse
|
|
3286
|
+
* @param status - to check
|
|
3287
|
+
* @returns true if element with status is found
|
|
3347
3288
|
*/
|
|
3348
3289
|
this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
|
|
3349
3290
|
/**
|
|
3350
3291
|
* Is component contextual direction match the given direction
|
|
3351
|
-
* @param
|
|
3352
|
-
* @param
|
|
3353
|
-
* @returns
|
|
3292
|
+
* @param direction - in parent menu
|
|
3293
|
+
* @param compareWith - direction to compare with. Default: `this.direction`
|
|
3294
|
+
* @returns true is direction match the direction propertie
|
|
3354
3295
|
*/
|
|
3355
3296
|
this.isDirection = (direction, compareWith = this.direction) => direction === compareWith;
|
|
3356
3297
|
/**
|
|
3357
3298
|
* Update displayNotificationBadge
|
|
3358
3299
|
* current component notification badge have priority over the slot badge when submenu contain badge
|
|
3359
|
-
* @returns {void} update displayNotificationBadge value
|
|
3360
3300
|
*/
|
|
3361
3301
|
this.updateDisplayNotificationBadge = () => {
|
|
3362
3302
|
const childMenu = this.element.querySelector('mg-menu');
|
|
@@ -3366,7 +3306,7 @@ const MgMenuItem = class {
|
|
|
3366
3306
|
};
|
|
3367
3307
|
/**
|
|
3368
3308
|
* Method to control if one of component children have active status
|
|
3369
|
-
* @returns
|
|
3309
|
+
* @returns truthy if component has active child
|
|
3370
3310
|
*/
|
|
3371
3311
|
this.hasActiveChild = () => {
|
|
3372
3312
|
var _a;
|
|
@@ -3374,8 +3314,7 @@ const MgMenuItem = class {
|
|
|
3374
3314
|
};
|
|
3375
3315
|
/**
|
|
3376
3316
|
* Validate slots
|
|
3377
|
-
* @param
|
|
3378
|
-
* @returns {void}
|
|
3317
|
+
* @param guard - prevent action whith guard. Default: false.
|
|
3379
3318
|
*/
|
|
3380
3319
|
this.validateSlot = (guard = false) => {
|
|
3381
3320
|
// slot title AND metadata validation
|
|
@@ -3393,8 +3332,7 @@ const MgMenuItem = class {
|
|
|
3393
3332
|
};
|
|
3394
3333
|
/**
|
|
3395
3334
|
* Update status
|
|
3396
|
-
* @param
|
|
3397
|
-
* @returns {void}
|
|
3335
|
+
* @param guard - status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
3398
3336
|
*/
|
|
3399
3337
|
this.updateStatus = (guard = []) => {
|
|
3400
3338
|
if (![Status$1.HIDDEN, Status$1.DISABLED, ...guard].includes(this.status)) {
|
|
@@ -3403,7 +3341,6 @@ const MgMenuItem = class {
|
|
|
3403
3341
|
};
|
|
3404
3342
|
/**
|
|
3405
3343
|
* Init event-listeners
|
|
3406
|
-
* @returns {void}
|
|
3407
3344
|
*/
|
|
3408
3345
|
this.initListeners = () => {
|
|
3409
3346
|
var _a;
|
|
@@ -3419,12 +3356,12 @@ const MgMenuItem = class {
|
|
|
3419
3356
|
};
|
|
3420
3357
|
/**
|
|
3421
3358
|
* Get mg-popover identifier
|
|
3422
|
-
* @returns
|
|
3359
|
+
* @returns generated mg-popover identifier
|
|
3423
3360
|
*/
|
|
3424
3361
|
this.getPopoverIdentifier = () => `${this.identifier}-popover`;
|
|
3425
3362
|
/**
|
|
3426
3363
|
* Condition to know if component should display a mg-popover
|
|
3427
|
-
* @returns
|
|
3364
|
+
* @returns truthy if component display popover
|
|
3428
3365
|
*/
|
|
3429
3366
|
this.displayPopover = () => this.isDirection(Direction.HORIZONTAL) && this.hasChildren && this.href === undefined;
|
|
3430
3367
|
/************
|
|
@@ -3432,8 +3369,7 @@ const MgMenuItem = class {
|
|
|
3432
3369
|
************/
|
|
3433
3370
|
/**
|
|
3434
3371
|
* Handle interacrtive element click
|
|
3435
|
-
* @param
|
|
3436
|
-
* @returns {void}
|
|
3372
|
+
* @param event - click on element
|
|
3437
3373
|
*/
|
|
3438
3374
|
this.handleElementCLick = (event) => {
|
|
3439
3375
|
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status$1.DISABLED) {
|
|
@@ -3446,15 +3382,14 @@ const MgMenuItem = class {
|
|
|
3446
3382
|
};
|
|
3447
3383
|
/**
|
|
3448
3384
|
* Handle popover element display-change event
|
|
3449
|
-
* @param
|
|
3450
|
-
* @returns {void}
|
|
3385
|
+
* @param event - popover display event
|
|
3451
3386
|
*/
|
|
3452
3387
|
this.handlePopoverDisplay = (event) => {
|
|
3453
3388
|
this.expanded = event.detail;
|
|
3454
3389
|
};
|
|
3455
3390
|
/**
|
|
3456
3391
|
* Render slot
|
|
3457
|
-
* @returns
|
|
3392
|
+
* @returns HTML Element
|
|
3458
3393
|
*/
|
|
3459
3394
|
this.renderSlot = () => h("slot", null);
|
|
3460
3395
|
this.identifier = createID('mg-menu-item');
|
|
@@ -3520,7 +3455,6 @@ const MgMenuItem = class {
|
|
|
3520
3455
|
}
|
|
3521
3456
|
/**
|
|
3522
3457
|
* Render popover clickoutside guard for content slot
|
|
3523
|
-
* @returns {void}
|
|
3524
3458
|
*/
|
|
3525
3459
|
updatePopoverGuard() {
|
|
3526
3460
|
if (this.displayPopover())
|
|
@@ -3533,7 +3467,6 @@ const MgMenuItem = class {
|
|
|
3533
3467
|
*************/
|
|
3534
3468
|
/**
|
|
3535
3469
|
* Validate props
|
|
3536
|
-
* @returns {void}
|
|
3537
3470
|
*/
|
|
3538
3471
|
componentWillLoad() {
|
|
3539
3472
|
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
@@ -3549,7 +3482,7 @@ const MgMenuItem = class {
|
|
|
3549
3482
|
}
|
|
3550
3483
|
/**
|
|
3551
3484
|
* Check if component slots configuration
|
|
3552
|
-
* @returns
|
|
3485
|
+
* @returns timeout
|
|
3553
3486
|
*/
|
|
3554
3487
|
componentDidLoad() {
|
|
3555
3488
|
// validation
|
|
@@ -3588,7 +3521,7 @@ const MgMenuItem = class {
|
|
|
3588
3521
|
}
|
|
3589
3522
|
/**
|
|
3590
3523
|
* Render ineractive element
|
|
3591
|
-
* @returns
|
|
3524
|
+
* @returns HTML Element
|
|
3592
3525
|
*/
|
|
3593
3526
|
renderInteractiveElement() {
|
|
3594
3527
|
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
@@ -3600,7 +3533,7 @@ const MgMenuItem = class {
|
|
|
3600
3533
|
}
|
|
3601
3534
|
/**
|
|
3602
3535
|
* Render
|
|
3603
|
-
* @returns
|
|
3536
|
+
* @returns HTML Element
|
|
3604
3537
|
*/
|
|
3605
3538
|
render() {
|
|
3606
3539
|
const getContainerClasses = () => ({
|
|
@@ -3649,22 +3582,19 @@ const MgMessage = class {
|
|
|
3649
3582
|
this.isHovered = false;
|
|
3650
3583
|
/**
|
|
3651
3584
|
* Set timer
|
|
3652
|
-
* @returns {void}
|
|
3653
3585
|
*/
|
|
3654
3586
|
this.setTimer = () => {
|
|
3655
3587
|
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
3656
3588
|
};
|
|
3657
3589
|
/**
|
|
3658
3590
|
* Clear timer
|
|
3659
|
-
* @returns {void}
|
|
3660
3591
|
*/
|
|
3661
3592
|
this.clearTimer = () => {
|
|
3662
3593
|
clearTimeout(this.storedTimer);
|
|
3663
3594
|
};
|
|
3664
3595
|
/**
|
|
3665
3596
|
* Event to add on element
|
|
3666
|
-
* @param
|
|
3667
|
-
* @returns {void}
|
|
3597
|
+
* @param event - event
|
|
3668
3598
|
*/
|
|
3669
3599
|
this.timerEvents = (event) => {
|
|
3670
3600
|
this.clearTimer();
|
|
@@ -3687,7 +3617,7 @@ const MgMessage = class {
|
|
|
3687
3617
|
};
|
|
3688
3618
|
/**
|
|
3689
3619
|
* Get icon corresponding to variant
|
|
3690
|
-
* @returns
|
|
3620
|
+
* @returns icon
|
|
3691
3621
|
*/
|
|
3692
3622
|
this.getIcon = () => {
|
|
3693
3623
|
switch (this.variant) {
|
|
@@ -3706,7 +3636,7 @@ const MgMessage = class {
|
|
|
3706
3636
|
this.variant = variants$1[0];
|
|
3707
3637
|
this.closeButton = false;
|
|
3708
3638
|
this.hide = false;
|
|
3709
|
-
this.
|
|
3639
|
+
this.classCollection = new ClassList(['mg-message']);
|
|
3710
3640
|
this.hasActions = false;
|
|
3711
3641
|
}
|
|
3712
3642
|
validateDelay(newValue) {
|
|
@@ -3720,9 +3650,9 @@ const MgMessage = class {
|
|
|
3720
3650
|
}
|
|
3721
3651
|
else {
|
|
3722
3652
|
if (oldValue !== undefined) {
|
|
3723
|
-
this.
|
|
3653
|
+
this.classCollection.delete(`mg-message--${oldValue}`);
|
|
3724
3654
|
}
|
|
3725
|
-
this.
|
|
3655
|
+
this.classCollection.add(`mg-message--${newValue}`);
|
|
3726
3656
|
}
|
|
3727
3657
|
}
|
|
3728
3658
|
validateCloseButton(newValue) {
|
|
@@ -3734,7 +3664,7 @@ const MgMessage = class {
|
|
|
3734
3664
|
validateHide(newValue) {
|
|
3735
3665
|
if (newValue) {
|
|
3736
3666
|
this.componentHide.emit();
|
|
3737
|
-
this.
|
|
3667
|
+
this.classCollection.add(this.classHide);
|
|
3738
3668
|
// Remove event Listener
|
|
3739
3669
|
['focusin', 'mouseenter'].forEach(event => {
|
|
3740
3670
|
this.element.removeEventListener(event, this.timerEvents);
|
|
@@ -3744,7 +3674,7 @@ const MgMessage = class {
|
|
|
3744
3674
|
}
|
|
3745
3675
|
else {
|
|
3746
3676
|
this.componentShow.emit();
|
|
3747
|
-
this.
|
|
3677
|
+
this.classCollection.delete(this.classHide);
|
|
3748
3678
|
// If delay is set
|
|
3749
3679
|
if (this.delay > 1) {
|
|
3750
3680
|
// Start timer
|
|
@@ -3771,7 +3701,7 @@ const MgMessage = class {
|
|
|
3771
3701
|
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
3772
3702
|
this.validateCloseButton(this.closeButton);
|
|
3773
3703
|
if (this.closeButton) {
|
|
3774
|
-
this.
|
|
3704
|
+
this.classCollection.add('mg-message--close-button');
|
|
3775
3705
|
this.closeButtonId = `${this.identifier}-close-button`;
|
|
3776
3706
|
}
|
|
3777
3707
|
this.validateDelay(this.delay);
|
|
@@ -3779,10 +3709,10 @@ const MgMessage = class {
|
|
|
3779
3709
|
}
|
|
3780
3710
|
/**
|
|
3781
3711
|
* Render
|
|
3782
|
-
* @returns
|
|
3712
|
+
* @returns HTML Element
|
|
3783
3713
|
*/
|
|
3784
3714
|
render() {
|
|
3785
|
-
return (h("div", { id: this.identifier, class: this.
|
|
3715
|
+
return (h("div", { id: this.identifier, class: this.classCollection.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("mg-card", { variant: this.variant, "variant-style": "bar-left" }, h("span", { class: "mg-message__icon" }, h("mg-icon", { icon: this.getIcon() })), h("div", { class: "mg-message__content" }, h("span", { class: "mg-message__content-slot" }, h("slot", null)), this.hasActions && h("span", { class: "mg-message__content-separator" }), this.hasActions && (h("span", { class: "mg-message__content-actions-slot" }, h("slot", { name: "actions" })))), this.closeButton && (h("span", { class: "mg-message__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))))));
|
|
3786
3716
|
}
|
|
3787
3717
|
get element() { return getElement(this); }
|
|
3788
3718
|
static get watchers() { return {
|
|
@@ -3842,7 +3772,6 @@ const MgModal = class {
|
|
|
3842
3772
|
*************/
|
|
3843
3773
|
/**
|
|
3844
3774
|
* Handle close button
|
|
3845
|
-
* @returns {void}
|
|
3846
3775
|
*/
|
|
3847
3776
|
this.handleClose = () => {
|
|
3848
3777
|
this.hide = true;
|
|
@@ -3853,7 +3782,7 @@ const MgModal = class {
|
|
|
3853
3782
|
this.hide = false;
|
|
3854
3783
|
this.hasActions = false;
|
|
3855
3784
|
this.hasContent = false;
|
|
3856
|
-
this.
|
|
3785
|
+
this.classCollection = new ClassList(['mg-modal']);
|
|
3857
3786
|
}
|
|
3858
3787
|
validateModalTitle(newValue) {
|
|
3859
3788
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -3863,19 +3792,18 @@ const MgModal = class {
|
|
|
3863
3792
|
validateHide(newValue) {
|
|
3864
3793
|
if (newValue) {
|
|
3865
3794
|
this.componentHide.emit();
|
|
3866
|
-
this.
|
|
3795
|
+
this.classCollection.add(this.classHide);
|
|
3867
3796
|
document.body.style.overflow = this.bodyOverflow;
|
|
3868
3797
|
}
|
|
3869
3798
|
else {
|
|
3870
3799
|
this.componentShow.emit();
|
|
3871
|
-
this.
|
|
3800
|
+
this.classCollection.delete(this.classHide);
|
|
3872
3801
|
document.body.style.overflow = 'hidden';
|
|
3873
3802
|
}
|
|
3874
3803
|
}
|
|
3875
3804
|
/**
|
|
3876
3805
|
* Handle 'escape' key down
|
|
3877
|
-
* @param
|
|
3878
|
-
* @returns {void}
|
|
3806
|
+
* @param event - keydown event
|
|
3879
3807
|
*/
|
|
3880
3808
|
handleKeyDown(event) {
|
|
3881
3809
|
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
@@ -3888,7 +3816,6 @@ const MgModal = class {
|
|
|
3888
3816
|
*************/
|
|
3889
3817
|
/**
|
|
3890
3818
|
* Check if component props are well configured on init
|
|
3891
|
-
* @returns {void}
|
|
3892
3819
|
*/
|
|
3893
3820
|
componentWillLoad() {
|
|
3894
3821
|
// Store body overflow
|
|
@@ -3907,7 +3834,6 @@ const MgModal = class {
|
|
|
3907
3834
|
}
|
|
3908
3835
|
/**
|
|
3909
3836
|
* Add observer on component to set focus when displayed
|
|
3910
|
-
* @returns {void}
|
|
3911
3837
|
*/
|
|
3912
3838
|
componentDidLoad() {
|
|
3913
3839
|
new MutationObserver(mutationList => {
|
|
@@ -3922,10 +3848,10 @@ const MgModal = class {
|
|
|
3922
3848
|
}
|
|
3923
3849
|
/**
|
|
3924
3850
|
* Render
|
|
3925
|
-
* @returns
|
|
3851
|
+
* @returns HTML Element
|
|
3926
3852
|
*/
|
|
3927
3853
|
render() {
|
|
3928
|
-
return (h("div", { role: "alertdialog", id: this.identifier, class: this.
|
|
3854
|
+
return (h("div", { role: "alertdialog", id: this.identifier, class: this.classCollection.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, h("mg-card", null, h("div", { class: "mg-modal__dialog" }, h("header", { class: "mg-modal__header" }, this.closeButton && (h("span", { class: "mg-modal__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))), h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (h("article", { class: "mg-modal__content" }, h("slot", { name: "content" }))), this.hasActions && (h("footer", { class: "mg-modal__footer" }, h("slot", { name: "actions" })))))));
|
|
3929
3855
|
}
|
|
3930
3856
|
get element() { return getElement(this); }
|
|
3931
3857
|
static get watchers() { return {
|
|
@@ -3946,6 +3872,7 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
3946
3872
|
/**
|
|
3947
3873
|
* Range generator
|
|
3948
3874
|
*
|
|
3875
|
+
* ```
|
|
3949
3876
|
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
3950
3877
|
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
3951
3878
|
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
@@ -3953,14 +3880,15 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
3953
3880
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
3954
3881
|
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
3955
3882
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
3883
|
+
* ```
|
|
3956
3884
|
*
|
|
3957
3885
|
* range(1, 1) = [1]
|
|
3958
3886
|
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
3959
3887
|
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
3960
|
-
* @param
|
|
3961
|
-
* @param
|
|
3962
|
-
* @param
|
|
3963
|
-
* @returns
|
|
3888
|
+
* @param start - start range
|
|
3889
|
+
* @param end - start end
|
|
3890
|
+
* @param step - step size
|
|
3891
|
+
* @returns range numbers
|
|
3964
3892
|
*/
|
|
3965
3893
|
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
3966
3894
|
const MgPagination = class {
|
|
@@ -3969,8 +3897,7 @@ const MgPagination = class {
|
|
|
3969
3897
|
this.currentPageChange = createEvent(this, "current-page-change", 7);
|
|
3970
3898
|
/**
|
|
3971
3899
|
* Change current page from target
|
|
3972
|
-
* @param
|
|
3973
|
-
* @returns {void}
|
|
3900
|
+
* @param target - target page
|
|
3974
3901
|
*/
|
|
3975
3902
|
this.goToPage = (target) => {
|
|
3976
3903
|
this.currentPage = target;
|
|
@@ -3980,8 +3907,7 @@ const MgPagination = class {
|
|
|
3980
3907
|
************/
|
|
3981
3908
|
/**
|
|
3982
3909
|
* select handler
|
|
3983
|
-
* @param
|
|
3984
|
-
* @returns {void}
|
|
3910
|
+
* @param event - value change event
|
|
3985
3911
|
*/
|
|
3986
3912
|
this.handleSelect = (event) => {
|
|
3987
3913
|
const to = Number(event.target.value);
|
|
@@ -3989,9 +3915,8 @@ const MgPagination = class {
|
|
|
3989
3915
|
};
|
|
3990
3916
|
/**
|
|
3991
3917
|
* Go to 'previous/next' page button handler
|
|
3992
|
-
* @param
|
|
3993
|
-
* @param
|
|
3994
|
-
* @returns {void}
|
|
3918
|
+
* @param action - navigation action
|
|
3919
|
+
* @param disabled - button disable state
|
|
3995
3920
|
*/
|
|
3996
3921
|
this.handleGoToPage = (action, disabled) => {
|
|
3997
3922
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
@@ -4021,7 +3946,6 @@ const MgPagination = class {
|
|
|
4021
3946
|
*************/
|
|
4022
3947
|
/**
|
|
4023
3948
|
* Check if props are well configured on init
|
|
4024
|
-
* @returns {void}
|
|
4025
3949
|
*/
|
|
4026
3950
|
componentWillLoad() {
|
|
4027
3951
|
// Get locales
|
|
@@ -4036,7 +3960,7 @@ const MgPagination = class {
|
|
|
4036
3960
|
}
|
|
4037
3961
|
/**
|
|
4038
3962
|
* Render
|
|
4039
|
-
* @returns
|
|
3963
|
+
* @returns HTML Element
|
|
4040
3964
|
*/
|
|
4041
3965
|
render() {
|
|
4042
3966
|
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
|
|
@@ -4064,7 +3988,6 @@ const MgPanel = class {
|
|
|
4064
3988
|
************/
|
|
4065
3989
|
/**
|
|
4066
3990
|
* Toggle is editing state
|
|
4067
|
-
* @returns {void}
|
|
4068
3991
|
*/
|
|
4069
3992
|
this.toggleIsEditing = () => {
|
|
4070
3993
|
this.isEditing = !this.isEditing;
|
|
@@ -4074,7 +3997,6 @@ const MgPanel = class {
|
|
|
4074
3997
|
************/
|
|
4075
3998
|
/**
|
|
4076
3999
|
* Collapse button click handler
|
|
4077
|
-
* @returns {void}
|
|
4078
4000
|
*/
|
|
4079
4001
|
this.handleCollapseButton = () => {
|
|
4080
4002
|
if (!this.expandToggleDisabled) {
|
|
@@ -4083,22 +4005,19 @@ const MgPanel = class {
|
|
|
4083
4005
|
};
|
|
4084
4006
|
/**
|
|
4085
4007
|
* Edit button click handler
|
|
4086
|
-
* @returns {void}
|
|
4087
4008
|
*/
|
|
4088
4009
|
this.handleEditButton = () => {
|
|
4089
4010
|
this.toggleIsEditing();
|
|
4090
4011
|
};
|
|
4091
4012
|
/**
|
|
4092
4013
|
* Update title handler
|
|
4093
|
-
* @param
|
|
4094
|
-
* @returns {void}
|
|
4014
|
+
* @param event - input value change event
|
|
4095
4015
|
*/
|
|
4096
4016
|
this.handleUpdateTitle = (event) => {
|
|
4097
4017
|
this.updatedPanelTitle = event.detail;
|
|
4098
4018
|
};
|
|
4099
4019
|
/**
|
|
4100
4020
|
* Cancel edition button handler
|
|
4101
|
-
* @returns {void}
|
|
4102
4021
|
*/
|
|
4103
4022
|
this.handleCancelEditButton = () => {
|
|
4104
4023
|
this.updatedPanelTitle = undefined;
|
|
@@ -4106,7 +4025,6 @@ const MgPanel = class {
|
|
|
4106
4025
|
};
|
|
4107
4026
|
/**
|
|
4108
4027
|
* Validate edition button handler
|
|
4109
|
-
* @returns {void}
|
|
4110
4028
|
*/
|
|
4111
4029
|
this.handleValidateEditButton = () => {
|
|
4112
4030
|
if (this.editInputElement.valid) {
|
|
@@ -4117,8 +4035,7 @@ const MgPanel = class {
|
|
|
4117
4035
|
};
|
|
4118
4036
|
/**
|
|
4119
4037
|
* Header left conditional render
|
|
4120
|
-
* @
|
|
4121
|
-
* @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
|
|
4038
|
+
* @returns header left element
|
|
4122
4039
|
*/
|
|
4123
4040
|
this.headerLeft = () => {
|
|
4124
4041
|
const collapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", identifier: `${this.identifier}-collapse-button`, "aria-expanded": this.expanded !== undefined && this.expanded.toString(), "aria-controls": `${this.identifier}-content`, disabled: this.expandToggleDisabled }, h("span", { class: "mg-panel__collapse-button-content" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle)));
|
|
@@ -4143,7 +4060,7 @@ const MgPanel = class {
|
|
|
4143
4060
|
this.expanded = false;
|
|
4144
4061
|
this.expandToggleDisabled = undefined;
|
|
4145
4062
|
this.titleEditable = false;
|
|
4146
|
-
this.
|
|
4063
|
+
this.classCollection = new ClassList(['mg-panel']);
|
|
4147
4064
|
this.isEditing = false;
|
|
4148
4065
|
this.updatedPanelTitle = undefined;
|
|
4149
4066
|
}
|
|
@@ -4169,7 +4086,6 @@ const MgPanel = class {
|
|
|
4169
4086
|
*************/
|
|
4170
4087
|
/**
|
|
4171
4088
|
* Check if props are well configured on init
|
|
4172
|
-
* @returns {void}
|
|
4173
4089
|
*/
|
|
4174
4090
|
componentWillLoad() {
|
|
4175
4091
|
// Get locales
|
|
@@ -4180,7 +4096,6 @@ const MgPanel = class {
|
|
|
4180
4096
|
}
|
|
4181
4097
|
/**
|
|
4182
4098
|
* Edit DOM after render
|
|
4183
|
-
* @returns {void}
|
|
4184
4099
|
*/
|
|
4185
4100
|
componentDidRender() {
|
|
4186
4101
|
// when we are editing we get focus on edition input
|
|
@@ -4190,10 +4105,10 @@ const MgPanel = class {
|
|
|
4190
4105
|
}
|
|
4191
4106
|
/**
|
|
4192
4107
|
* Render component
|
|
4193
|
-
* @returns
|
|
4108
|
+
* @returns html element
|
|
4194
4109
|
*/
|
|
4195
4110
|
render() {
|
|
4196
|
-
return (h("section", { class: this.
|
|
4111
|
+
return (h("section", { class: this.classCollection.join(), id: this.identifier }, h("mg-card", null, h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), h("div", { class: "mg-panel__header-right" }, h("slot", { name: "header-right" }))), h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, h("slot", null)))));
|
|
4197
4112
|
}
|
|
4198
4113
|
get element() { return getElement(this); }
|
|
4199
4114
|
static get watchers() { return {
|
|
@@ -6012,8 +5927,7 @@ const MgPopover = class {
|
|
|
6012
5927
|
this.classArrowHide = `mg-popover--arrow-hide`;
|
|
6013
5928
|
/**
|
|
6014
5929
|
* Check if clicked outside of component
|
|
6015
|
-
* @param
|
|
6016
|
-
* @returns {void}
|
|
5930
|
+
* @param event - mouse event
|
|
6017
5931
|
*/
|
|
6018
5932
|
this.clickOutside = (event) => {
|
|
6019
5933
|
var _a;
|
|
@@ -6025,7 +5939,6 @@ const MgPopover = class {
|
|
|
6025
5939
|
};
|
|
6026
5940
|
/**
|
|
6027
5941
|
* Show popover
|
|
6028
|
-
* @returns {void}
|
|
6029
5942
|
*/
|
|
6030
5943
|
this.show = () => {
|
|
6031
5944
|
// Make the popover visible
|
|
@@ -6044,7 +5957,6 @@ const MgPopover = class {
|
|
|
6044
5957
|
};
|
|
6045
5958
|
/**
|
|
6046
5959
|
* Hide popover
|
|
6047
|
-
* @returns {void}
|
|
6048
5960
|
*/
|
|
6049
5961
|
this.hide = () => {
|
|
6050
5962
|
// Hide the popover
|
|
@@ -6058,7 +5970,6 @@ const MgPopover = class {
|
|
|
6058
5970
|
};
|
|
6059
5971
|
/**
|
|
6060
5972
|
* Handle action for close button
|
|
6061
|
-
* @returns {void}
|
|
6062
5973
|
*/
|
|
6063
5974
|
this.handleCloseButton = () => {
|
|
6064
5975
|
this.display = false;
|
|
@@ -6069,13 +5980,13 @@ const MgPopover = class {
|
|
|
6069
5980
|
this.closeButton = false;
|
|
6070
5981
|
this.display = false;
|
|
6071
5982
|
this.disabled = false;
|
|
6072
|
-
this.
|
|
5983
|
+
this.classCollection = new ClassList(['mg-popover']);
|
|
6073
5984
|
}
|
|
6074
5985
|
validateArrowHide(newValue) {
|
|
6075
5986
|
if (newValue)
|
|
6076
|
-
this.
|
|
5987
|
+
this.classCollection.add(this.classArrowHide);
|
|
6077
5988
|
else
|
|
6078
|
-
this.
|
|
5989
|
+
this.classCollection.delete(this.classArrowHide);
|
|
6079
5990
|
}
|
|
6080
5991
|
handleDisplay(newValue) {
|
|
6081
5992
|
if (newValue) {
|
|
@@ -6091,7 +6002,6 @@ const MgPopover = class {
|
|
|
6091
6002
|
*************/
|
|
6092
6003
|
/**
|
|
6093
6004
|
* Check if component props are well configured on init
|
|
6094
|
-
* @returns {void} timeout
|
|
6095
6005
|
*/
|
|
6096
6006
|
componentWillLoad() {
|
|
6097
6007
|
// Get windows to attach events
|
|
@@ -6102,7 +6012,6 @@ const MgPopover = class {
|
|
|
6102
6012
|
}
|
|
6103
6013
|
/**
|
|
6104
6014
|
* Check if component props are well configured on init
|
|
6105
|
-
* @returns {void}
|
|
6106
6015
|
*/
|
|
6107
6016
|
componentDidLoad() {
|
|
6108
6017
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -6159,10 +6068,10 @@ const MgPopover = class {
|
|
|
6159
6068
|
}
|
|
6160
6069
|
/**
|
|
6161
6070
|
* Render
|
|
6162
|
-
* @returns
|
|
6071
|
+
* @returns HTML Element
|
|
6163
6072
|
*/
|
|
6164
6073
|
render() {
|
|
6165
|
-
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: this.
|
|
6074
|
+
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: this.classCollection.join() }, h("mg-card", null, this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, h("mg-icon", { icon: "cross" }))), h("div", { class: "mg-popover__title" }, h("slot", { name: "title" })), h("slot", { name: "content" })), !this.arrowHide && h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
6166
6075
|
}
|
|
6167
6076
|
get element() { return getElement(this); }
|
|
6168
6077
|
static get watchers() { return {
|
|
@@ -6183,8 +6092,7 @@ const MgSkipLinks = class {
|
|
|
6183
6092
|
**********/
|
|
6184
6093
|
/**
|
|
6185
6094
|
* Handle link click and emit go-to-anchor event
|
|
6186
|
-
* @param
|
|
6187
|
-
* @returns {void}
|
|
6095
|
+
* @param event - mouse event
|
|
6188
6096
|
*/
|
|
6189
6097
|
this.handleLinkCLick = (event) => {
|
|
6190
6098
|
event.currentTarget.blur();
|
|
@@ -6204,7 +6112,6 @@ const MgSkipLinks = class {
|
|
|
6204
6112
|
*************/
|
|
6205
6113
|
/**
|
|
6206
6114
|
* Check if props are well configured on init
|
|
6207
|
-
* @returns {void}
|
|
6208
6115
|
*/
|
|
6209
6116
|
componentWillLoad() {
|
|
6210
6117
|
this.validateLinks(this.links);
|
|
@@ -6212,7 +6119,7 @@ const MgSkipLinks = class {
|
|
|
6212
6119
|
}
|
|
6213
6120
|
/**
|
|
6214
6121
|
* Render
|
|
6215
|
-
* @returns
|
|
6122
|
+
* @returns HTML Element
|
|
6216
6123
|
*/
|
|
6217
6124
|
render() {
|
|
6218
6125
|
return (h("nav", { class: "mg-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, h("ul", { class: "mg-skip-links__list", role: "list" }, this.links.map(link => (h("li", { key: link.href }, h("a", { class: "mg-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
|
|
@@ -6243,8 +6150,8 @@ const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.m
|
|
|
6243
6150
|
|
|
6244
6151
|
/**
|
|
6245
6152
|
* type TabItem validation function
|
|
6246
|
-
* @param
|
|
6247
|
-
* @returns
|
|
6153
|
+
* @param tab - tab item
|
|
6154
|
+
* @returns tab item type is valid
|
|
6248
6155
|
*/
|
|
6249
6156
|
const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
|
|
6250
6157
|
const MgTabs = class {
|
|
@@ -6260,32 +6167,32 @@ const MgTabs = class {
|
|
|
6260
6167
|
this.startIndex = 1;
|
|
6261
6168
|
/**
|
|
6262
6169
|
* Method to know if given tab has the given status
|
|
6263
|
-
* @param
|
|
6264
|
-
* @param
|
|
6265
|
-
* @returns
|
|
6170
|
+
* @param tab - item tab key to set to ACTIVE status
|
|
6171
|
+
* @param status - status to valide
|
|
6172
|
+
* @returns status comparaison
|
|
6266
6173
|
*/
|
|
6267
6174
|
this.tabHasStatus = (tab, status) => tab.status === status;
|
|
6268
6175
|
/**
|
|
6269
6176
|
* Method to get element id from index
|
|
6270
|
-
* @param
|
|
6271
|
-
* @param
|
|
6272
|
-
* @returns
|
|
6177
|
+
* @param element - to get id
|
|
6178
|
+
* @param index - to generate id
|
|
6179
|
+
* @returns generated element id
|
|
6273
6180
|
*/
|
|
6274
6181
|
this.getElementId = (element, index) => `${element}-${this.getTabItemIndex(index)}`;
|
|
6275
6182
|
/**
|
|
6276
6183
|
* Method to get tab item index
|
|
6277
|
-
* @param
|
|
6278
|
-
* @returns
|
|
6184
|
+
* @param index - to get
|
|
6185
|
+
* @returns index
|
|
6279
6186
|
*/
|
|
6280
6187
|
this.getTabItemIndex = (index) => index + this.startIndex;
|
|
6281
6188
|
/**
|
|
6282
6189
|
* Method to get the active-tab value
|
|
6283
|
-
* @returns
|
|
6190
|
+
* @returns of the active-tab
|
|
6284
6191
|
*/
|
|
6285
6192
|
this.getActiveTab = () => this.activeTab || this.getTabItemIndex(this.tabs.map((tab, index) => (Object.assign(Object.assign({}, tab), { index }))).find(tab => this.tabHasStatus(tab, Status.ACTIVE)).index);
|
|
6286
6193
|
/**
|
|
6287
6194
|
* Handle click events on tabs
|
|
6288
|
-
* @param
|
|
6195
|
+
* @param event - mouse event
|
|
6289
6196
|
*/
|
|
6290
6197
|
this.handleClick = (event) => {
|
|
6291
6198
|
const tabId = event.currentTarget.dataset.index;
|
|
@@ -6300,14 +6207,13 @@ const MgTabs = class {
|
|
|
6300
6207
|
};
|
|
6301
6208
|
/**
|
|
6302
6209
|
* get navigation button class from given status
|
|
6303
|
-
* @param
|
|
6304
|
-
* @returns
|
|
6210
|
+
* @param status - button tab status
|
|
6211
|
+
* @returns button class/selector variant
|
|
6305
6212
|
*/
|
|
6306
6213
|
this.getNavigationButtonClass = (status) => `${this.buttonTabBaseClass}--${status}`;
|
|
6307
6214
|
/**
|
|
6308
6215
|
* Handle keyboard event on tabs
|
|
6309
|
-
* @param
|
|
6310
|
-
* @returns {void}
|
|
6216
|
+
* @param event - mouse event
|
|
6311
6217
|
*/
|
|
6312
6218
|
this.handleKeydown = (event) => {
|
|
6313
6219
|
const parent = event.target.parentElement;
|
|
@@ -6345,7 +6251,6 @@ const MgTabs = class {
|
|
|
6345
6251
|
};
|
|
6346
6252
|
/**
|
|
6347
6253
|
* Method to reset focus behavior
|
|
6348
|
-
* @returns {void}
|
|
6349
6254
|
*/
|
|
6350
6255
|
this.resetFocus = () => {
|
|
6351
6256
|
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
@@ -6370,7 +6275,7 @@ const MgTabs = class {
|
|
|
6370
6275
|
this.items = undefined;
|
|
6371
6276
|
this.activeTab = undefined;
|
|
6372
6277
|
this.tabs = [];
|
|
6373
|
-
this.
|
|
6278
|
+
this.classCollection = new ClassList(['mg-tabs']);
|
|
6374
6279
|
}
|
|
6375
6280
|
validateLabel(newValue) {
|
|
6376
6281
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -6381,7 +6286,7 @@ const MgTabs = class {
|
|
|
6381
6286
|
if (!sizes.includes(newValue)) {
|
|
6382
6287
|
throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
6383
6288
|
}
|
|
6384
|
-
this.
|
|
6289
|
+
this.classCollection.add(`mg-tabs--size-${this.size}`);
|
|
6385
6290
|
}
|
|
6386
6291
|
validateItems(newValue) {
|
|
6387
6292
|
// String array
|
|
@@ -6424,7 +6329,6 @@ const MgTabs = class {
|
|
|
6424
6329
|
*************/
|
|
6425
6330
|
/**
|
|
6426
6331
|
* Check if component props are well configured on init
|
|
6427
|
-
* @returns {void}
|
|
6428
6332
|
*/
|
|
6429
6333
|
componentWillLoad() {
|
|
6430
6334
|
// Check tabs format
|
|
@@ -6436,7 +6340,6 @@ const MgTabs = class {
|
|
|
6436
6340
|
}
|
|
6437
6341
|
/**
|
|
6438
6342
|
* add listners
|
|
6439
|
-
* @returns {void}
|
|
6440
6343
|
*/
|
|
6441
6344
|
componentDidLoad() {
|
|
6442
6345
|
document.addEventListener('click', (event) => {
|
|
@@ -6446,10 +6349,10 @@ const MgTabs = class {
|
|
|
6446
6349
|
}
|
|
6447
6350
|
/**
|
|
6448
6351
|
* Render
|
|
6449
|
-
* @returns
|
|
6352
|
+
* @returns HTML Element
|
|
6450
6353
|
*/
|
|
6451
6354
|
render() {
|
|
6452
|
-
return (h("div", { class: this.
|
|
6355
|
+
return (h("div", { class: this.classCollection.join() }, h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => (h("button", { key: tab.label, role: "tab", id: this.getElementId(this.identifier, index), class: {
|
|
6453
6356
|
[`${this.buttonTabBaseClass}`]: true,
|
|
6454
6357
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
6455
6358
|
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|
|
@@ -6486,7 +6389,7 @@ const MgTag = class {
|
|
|
6486
6389
|
this.variant = variants[0];
|
|
6487
6390
|
this.outline = undefined;
|
|
6488
6391
|
this.soft = undefined;
|
|
6489
|
-
this.
|
|
6392
|
+
this.classCollection = new ClassList(['mg-tag']);
|
|
6490
6393
|
}
|
|
6491
6394
|
validateVariant(newValue, oldValue) {
|
|
6492
6395
|
if (!variants.includes(newValue)) {
|
|
@@ -6494,16 +6397,16 @@ const MgTag = class {
|
|
|
6494
6397
|
}
|
|
6495
6398
|
else {
|
|
6496
6399
|
if (oldValue !== undefined) {
|
|
6497
|
-
this.
|
|
6400
|
+
this.classCollection.delete(`mg-tag--${oldValue}`);
|
|
6498
6401
|
}
|
|
6499
|
-
this.
|
|
6402
|
+
this.classCollection.add(`mg-tag--${newValue}`);
|
|
6500
6403
|
}
|
|
6501
6404
|
}
|
|
6502
6405
|
validateOutline(newValue) {
|
|
6503
6406
|
if (newValue)
|
|
6504
|
-
this.
|
|
6407
|
+
this.classCollection.add(this.classOutline);
|
|
6505
6408
|
else
|
|
6506
|
-
this.
|
|
6409
|
+
this.classCollection.delete(this.classOutline);
|
|
6507
6410
|
}
|
|
6508
6411
|
validateSoft(newValue) {
|
|
6509
6412
|
// usage validation
|
|
@@ -6511,17 +6414,16 @@ const MgTag = class {
|
|
|
6511
6414
|
throw new Error('<mg-tag> prop "soft" can NOT be used with prop "outline".');
|
|
6512
6415
|
// apply class
|
|
6513
6416
|
if (newValue)
|
|
6514
|
-
this.
|
|
6417
|
+
this.classCollection.add(this.classSoft);
|
|
6515
6418
|
else
|
|
6516
|
-
this.
|
|
6419
|
+
this.classCollection.delete(this.classSoft);
|
|
6517
6420
|
}
|
|
6518
6421
|
/*************
|
|
6519
6422
|
* Methods *
|
|
6520
6423
|
*************/
|
|
6521
6424
|
/**
|
|
6522
6425
|
* Validate the given textContent
|
|
6523
|
-
* @param
|
|
6524
|
-
* @returns {void}
|
|
6426
|
+
* @param textContent - html element textContent property
|
|
6525
6427
|
*/
|
|
6526
6428
|
validateTextContent(textContent) {
|
|
6527
6429
|
if (typeof textContent !== 'string' || textContent.trim() === '')
|
|
@@ -6532,7 +6434,6 @@ const MgTag = class {
|
|
|
6532
6434
|
*************/
|
|
6533
6435
|
/**
|
|
6534
6436
|
* Check if props are well configured on init
|
|
6535
|
-
* @returns {void}
|
|
6536
6437
|
*/
|
|
6537
6438
|
componentWillLoad() {
|
|
6538
6439
|
this.validateVariant(this.variant);
|
|
@@ -6542,10 +6443,10 @@ const MgTag = class {
|
|
|
6542
6443
|
}
|
|
6543
6444
|
/**
|
|
6544
6445
|
* Render
|
|
6545
|
-
* @returns
|
|
6446
|
+
* @returns HTML Element
|
|
6546
6447
|
*/
|
|
6547
6448
|
render() {
|
|
6548
|
-
return (h("span", { class: this.
|
|
6449
|
+
return (h("span", { class: this.classCollection.join() }, h("slot", null)));
|
|
6549
6450
|
}
|
|
6550
6451
|
get element() { return getElement(this); }
|
|
6551
6452
|
static get watchers() { return {
|
|
@@ -6570,7 +6471,6 @@ const MgTooltip = class {
|
|
|
6570
6471
|
registerInstance(this, hostRef);
|
|
6571
6472
|
/**
|
|
6572
6473
|
* Show tooltip
|
|
6573
|
-
* @returns {void}
|
|
6574
6474
|
*/
|
|
6575
6475
|
this.show = () => {
|
|
6576
6476
|
// Make the tooltip visible
|
|
@@ -6590,7 +6490,6 @@ const MgTooltip = class {
|
|
|
6590
6490
|
};
|
|
6591
6491
|
/**
|
|
6592
6492
|
* Hide tooltip
|
|
6593
|
-
* @returns {void}
|
|
6594
6493
|
*/
|
|
6595
6494
|
this.hide = () => {
|
|
6596
6495
|
// Hide the tooltip
|
|
@@ -6605,8 +6504,7 @@ const MgTooltip = class {
|
|
|
6605
6504
|
};
|
|
6606
6505
|
/**
|
|
6607
6506
|
* Check if clicked outside of component and hidde tooltip
|
|
6608
|
-
* @param
|
|
6609
|
-
* @returns {void}
|
|
6507
|
+
* @param event - mouse event
|
|
6610
6508
|
*/
|
|
6611
6509
|
this.clickOutside = (event) => {
|
|
6612
6510
|
if (event.target.closest('mg-tooltip') !== this.element)
|
|
@@ -6614,8 +6512,7 @@ const MgTooltip = class {
|
|
|
6614
6512
|
};
|
|
6615
6513
|
/**
|
|
6616
6514
|
* Check if 'Escape' key is pressed of component and hidde tooltip
|
|
6617
|
-
* @param
|
|
6618
|
-
* @returns {void}
|
|
6515
|
+
* @param event - keyboard event
|
|
6619
6516
|
*/
|
|
6620
6517
|
this.pressEscape = (event) => {
|
|
6621
6518
|
if (event.code === 'Escape')
|
|
@@ -6623,9 +6520,8 @@ const MgTooltip = class {
|
|
|
6623
6520
|
};
|
|
6624
6521
|
/**
|
|
6625
6522
|
* Method to set display prop
|
|
6626
|
-
* @param
|
|
6627
|
-
* @param
|
|
6628
|
-
* @returns {void}
|
|
6523
|
+
* @param newValue - display prop new value
|
|
6524
|
+
* @param condition - additionnal condition to apply display prop newValue
|
|
6629
6525
|
*/
|
|
6630
6526
|
this.setDisplay = (newValue, condition = true) => {
|
|
6631
6527
|
if (!this.disabled && condition)
|
|
@@ -6633,10 +6529,9 @@ const MgTooltip = class {
|
|
|
6633
6529
|
};
|
|
6634
6530
|
/**
|
|
6635
6531
|
* Action for tooltip element and tooltiped element mouse listener
|
|
6636
|
-
* @param
|
|
6637
|
-
* @param
|
|
6638
|
-
* @param
|
|
6639
|
-
* @returns {void}
|
|
6532
|
+
* @param elementGuard - tooltip element guard
|
|
6533
|
+
* @param isMouseenter - mouseenter validation
|
|
6534
|
+
* @param conditionalGuard - guard condition
|
|
6640
6535
|
*/
|
|
6641
6536
|
this.tooltipMouseListenerAction = (elementGuard, isMouseenter, conditionalGuard) => {
|
|
6642
6537
|
// we mutate elementGuard
|
|
@@ -6655,15 +6550,13 @@ const MgTooltip = class {
|
|
|
6655
6550
|
};
|
|
6656
6551
|
/**
|
|
6657
6552
|
* Method to reset guard value
|
|
6658
|
-
* @returns {void}
|
|
6659
6553
|
*/
|
|
6660
6554
|
this.resetGuard = () => {
|
|
6661
6555
|
this.guard = undefined;
|
|
6662
6556
|
};
|
|
6663
6557
|
/**
|
|
6664
6558
|
* Update slot content when it is a mg-button
|
|
6665
|
-
* @param
|
|
6666
|
-
* @returns {void}
|
|
6559
|
+
* @param mgButton - slotted mg-button
|
|
6667
6560
|
*/
|
|
6668
6561
|
this.setMgButtonWrapper = (mgButton) => {
|
|
6669
6562
|
if (mgButton.disabled) {
|
|
@@ -6680,8 +6573,8 @@ const MgTooltip = class {
|
|
|
6680
6573
|
};
|
|
6681
6574
|
/**
|
|
6682
6575
|
* Init tooltip
|
|
6683
|
-
* @param
|
|
6684
|
-
* @param
|
|
6576
|
+
* @param slotElement - slotted element
|
|
6577
|
+
* @param interactiveElement - interactive element
|
|
6685
6578
|
*/
|
|
6686
6579
|
this.initTooltip = (slotElement, interactiveElement) => {
|
|
6687
6580
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
@@ -6757,7 +6650,6 @@ const MgTooltip = class {
|
|
|
6757
6650
|
*************/
|
|
6758
6651
|
/**
|
|
6759
6652
|
* set variables
|
|
6760
|
-
* @returns {void}
|
|
6761
6653
|
*/
|
|
6762
6654
|
componentWillLoad() {
|
|
6763
6655
|
// Get windows to attach events
|
|
@@ -6767,7 +6659,6 @@ const MgTooltip = class {
|
|
|
6767
6659
|
* Get slotted element
|
|
6768
6660
|
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
6769
6661
|
* We need to attach the focused element to the tooltip (aria-describedby)
|
|
6770
|
-
* @returns {void}
|
|
6771
6662
|
*/
|
|
6772
6663
|
componentDidLoad() {
|
|
6773
6664
|
var _a;
|
|
@@ -6800,7 +6691,7 @@ const MgTooltip = class {
|
|
|
6800
6691
|
}
|
|
6801
6692
|
/**
|
|
6802
6693
|
* Render
|
|
6803
|
-
* @returns
|
|
6694
|
+
* @returns HTML Element
|
|
6804
6695
|
*/
|
|
6805
6696
|
render() {
|
|
6806
6697
|
return (h(Host, null, h("slot", null), h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip" }, h("span", { innerHTML: this.message }), h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|