@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-9e1091ab.js');
|
|
6
|
-
const mgMenu_conf = require('./mg-menu.conf-
|
|
6
|
+
const mgMenu_conf = require('./mg-menu.conf-196151fe.js');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Available menu-item positions
|
|
@@ -26,9 +26,9 @@ var Status$1;
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Create random ID
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
-
* @returns
|
|
29
|
+
* @param prefix - add prefix to created ID
|
|
30
|
+
* @param length - ID length
|
|
31
|
+
* @returns ID
|
|
32
32
|
*/
|
|
33
33
|
const createID = (prefix = '', length = 10) => {
|
|
34
34
|
let ID = '';
|
|
@@ -47,8 +47,7 @@ class ClassList {
|
|
|
47
47
|
constructor(classlist = []) {
|
|
48
48
|
/**
|
|
49
49
|
* Add class
|
|
50
|
-
* @param
|
|
51
|
-
* @returns {void}
|
|
50
|
+
* @param className - class name to add
|
|
52
51
|
*/
|
|
53
52
|
this.add = (className) => {
|
|
54
53
|
if (!this.has(className)) {
|
|
@@ -57,8 +56,7 @@ class ClassList {
|
|
|
57
56
|
};
|
|
58
57
|
/**
|
|
59
58
|
* Delete class
|
|
60
|
-
* @param
|
|
61
|
-
* @returns {void}
|
|
59
|
+
* @param className - class name to delete
|
|
62
60
|
*/
|
|
63
61
|
this.delete = (className) => {
|
|
64
62
|
const index = this.classes.indexOf(className);
|
|
@@ -68,15 +66,15 @@ class ClassList {
|
|
|
68
66
|
};
|
|
69
67
|
/**
|
|
70
68
|
* Check if class exist in list
|
|
71
|
-
* @param
|
|
72
|
-
* @returns
|
|
69
|
+
* @param className - class name to check
|
|
70
|
+
* @returns class name is in the list
|
|
73
71
|
*/
|
|
74
72
|
this.has = (className) => {
|
|
75
73
|
return this.classes.includes(className);
|
|
76
74
|
};
|
|
77
75
|
/**
|
|
78
76
|
* Join classes seperated by spaces
|
|
79
|
-
* @returns
|
|
77
|
+
* @returns joined values
|
|
80
78
|
*/
|
|
81
79
|
this.join = () => {
|
|
82
80
|
return this.classes.join(' ');
|
|
@@ -86,15 +84,15 @@ class ClassList {
|
|
|
86
84
|
}
|
|
87
85
|
/**
|
|
88
86
|
* Check if all items are string
|
|
89
|
-
* @param
|
|
90
|
-
* @returns
|
|
87
|
+
* @param items - items to check
|
|
88
|
+
* @returns all items are string
|
|
91
89
|
*/
|
|
92
90
|
const allItemsAreString = (items) => Array.isArray(items) && items.every(item => typeof item === 'string');
|
|
93
91
|
/**
|
|
94
92
|
* Check if element is a heading
|
|
95
|
-
* @param
|
|
96
|
-
* @param
|
|
97
|
-
* @returns
|
|
93
|
+
* @param element - slotted element
|
|
94
|
+
* @param tagNames - allowed tag names list
|
|
95
|
+
* @returns element is a heading
|
|
98
96
|
*/
|
|
99
97
|
const isTagName = (element, tagNames) => {
|
|
100
98
|
return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
|
|
@@ -105,8 +103,8 @@ const isTagName = (element, tagNames) => {
|
|
|
105
103
|
const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
106
104
|
/**
|
|
107
105
|
* Get windows
|
|
108
|
-
* @param
|
|
109
|
-
* @returns
|
|
106
|
+
* @param localWindow - the window we are lookink for other windows
|
|
107
|
+
* @returns The list of windows found
|
|
110
108
|
*/
|
|
111
109
|
const getWindows = (localWindow) => {
|
|
112
110
|
const parentWindows = getParentWindows(localWindow);
|
|
@@ -115,9 +113,9 @@ const getWindows = (localWindow) => {
|
|
|
115
113
|
};
|
|
116
114
|
/**
|
|
117
115
|
* Get parent windows
|
|
118
|
-
* @param
|
|
119
|
-
* @param
|
|
120
|
-
* @returns
|
|
116
|
+
* @param localWindow - the window we are lookink for parents
|
|
117
|
+
* @param windows - The list of allready found windows
|
|
118
|
+
* @returns The list of windows found
|
|
121
119
|
*/
|
|
122
120
|
const getParentWindows = (localWindow, windows = []) => {
|
|
123
121
|
// Check if is in iframe
|
|
@@ -137,9 +135,9 @@ const getParentWindows = (localWindow, windows = []) => {
|
|
|
137
135
|
};
|
|
138
136
|
/**
|
|
139
137
|
* Get child windows
|
|
140
|
-
* @param
|
|
141
|
-
* @param
|
|
142
|
-
* @returns
|
|
138
|
+
* @param localWindow - the window we are lookink for children
|
|
139
|
+
* @param windows - The list of allready found windows
|
|
140
|
+
* @returns The list of windows found
|
|
143
141
|
*/
|
|
144
142
|
const getChildWindows = (localWindow, windows = []) => {
|
|
145
143
|
if (localWindow.frames.length > 0) {
|
|
@@ -158,8 +156,8 @@ const mgActionMoreCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
158
156
|
|
|
159
157
|
/**
|
|
160
158
|
* MgActionMore['items'] type guard
|
|
161
|
-
* @param
|
|
162
|
-
* @returns
|
|
159
|
+
* @param prop - commponent items prop
|
|
160
|
+
* @returns return true if type is valid
|
|
163
161
|
*/
|
|
164
162
|
const isMgActionMoreItems = (prop) => {
|
|
165
163
|
const items = prop;
|
|
@@ -167,8 +165,8 @@ const isMgActionMoreItems = (prop) => {
|
|
|
167
165
|
};
|
|
168
166
|
/**
|
|
169
167
|
* MgActionMore['button'] type guard
|
|
170
|
-
* @param
|
|
171
|
-
* @returns
|
|
168
|
+
* @param prop - commponent button prop
|
|
169
|
+
* @returns return true if type is valid
|
|
172
170
|
*/
|
|
173
171
|
const isMgActionMoreButton = (prop) => {
|
|
174
172
|
const button = prop;
|
|
@@ -176,8 +174,8 @@ const isMgActionMoreButton = (prop) => {
|
|
|
176
174
|
};
|
|
177
175
|
/**
|
|
178
176
|
* MgActionMore['icon'] type guard
|
|
179
|
-
* @param
|
|
180
|
-
* @returns
|
|
177
|
+
* @param prop - commponent icon prop
|
|
178
|
+
* @returns return true if type is valid
|
|
181
179
|
*/
|
|
182
180
|
const isMgActionMoreIcon = (prop) => {
|
|
183
181
|
const icon = prop;
|
|
@@ -196,23 +194,20 @@ const MgActionMore = class {
|
|
|
196
194
|
***********/
|
|
197
195
|
/**
|
|
198
196
|
* Toogle expanded props
|
|
199
|
-
* @returns {void}
|
|
200
197
|
*/
|
|
201
198
|
this.toggleExpanded = () => {
|
|
202
199
|
this.expanded = !this.expanded;
|
|
203
200
|
};
|
|
204
201
|
/**
|
|
205
202
|
* Button click handler
|
|
206
|
-
* @returns {void}
|
|
207
203
|
*/
|
|
208
204
|
this.handleButton = () => {
|
|
209
205
|
this.toggleExpanded();
|
|
210
206
|
};
|
|
211
207
|
/**
|
|
212
208
|
* Item click handler
|
|
213
|
-
* @param
|
|
214
|
-
* @param
|
|
215
|
-
* @returns {void}
|
|
209
|
+
* @param event - click event
|
|
210
|
+
* @param customHandler - item['mouseEventHandler']
|
|
216
211
|
*/
|
|
217
212
|
this.handleItemClick = (event, customHandler) => {
|
|
218
213
|
this.expanded = false;
|
|
@@ -249,7 +244,6 @@ const MgActionMore = class {
|
|
|
249
244
|
*************/
|
|
250
245
|
/**
|
|
251
246
|
* Validate props
|
|
252
|
-
* @returns {void}
|
|
253
247
|
*/
|
|
254
248
|
componentWillLoad() {
|
|
255
249
|
this.messages = mgMenu_conf.initLocales(this.element).messages.actionMore;
|
|
@@ -260,7 +254,7 @@ const MgActionMore = class {
|
|
|
260
254
|
}
|
|
261
255
|
/**
|
|
262
256
|
* Render
|
|
263
|
-
* @returns
|
|
257
|
+
* @returns HTML Element
|
|
264
258
|
*/
|
|
265
259
|
render() {
|
|
266
260
|
const buttonLabel = this.button.label || this.messages.label;
|
|
@@ -308,7 +302,7 @@ const MgBadge = class {
|
|
|
308
302
|
this.label = undefined;
|
|
309
303
|
this.variant = variants$5[0];
|
|
310
304
|
this.outline = undefined;
|
|
311
|
-
this.
|
|
305
|
+
this.classCollection = new ClassList(['mg-badge']);
|
|
312
306
|
}
|
|
313
307
|
validateValue(newValue) {
|
|
314
308
|
if (`${newValue}`.match(/^(\d+\+*|[?*!a-z])$/i) === null) {
|
|
@@ -326,20 +320,19 @@ const MgBadge = class {
|
|
|
326
320
|
}
|
|
327
321
|
else {
|
|
328
322
|
if (oldValue !== undefined) {
|
|
329
|
-
this.
|
|
323
|
+
this.classCollection.delete(`mg-badge--${oldValue}`);
|
|
330
324
|
}
|
|
331
|
-
this.
|
|
325
|
+
this.classCollection.add(`mg-badge--${newValue}`);
|
|
332
326
|
}
|
|
333
327
|
}
|
|
334
328
|
validateOutline(newValue) {
|
|
335
329
|
if (newValue)
|
|
336
|
-
this.
|
|
330
|
+
this.classCollection.add(this.classOutline);
|
|
337
331
|
else
|
|
338
|
-
this.
|
|
332
|
+
this.classCollection.delete(this.classOutline);
|
|
339
333
|
}
|
|
340
334
|
/**
|
|
341
335
|
* Check if props are well configured on init
|
|
342
|
-
* @returns {void}
|
|
343
336
|
*/
|
|
344
337
|
componentWillLoad() {
|
|
345
338
|
this.validateValue(this.value);
|
|
@@ -349,10 +342,10 @@ const MgBadge = class {
|
|
|
349
342
|
}
|
|
350
343
|
/**
|
|
351
344
|
* Render
|
|
352
|
-
* @returns
|
|
345
|
+
* @returns HTML Element
|
|
353
346
|
*/
|
|
354
347
|
render() {
|
|
355
|
-
return (index.h("span", { class: this.
|
|
348
|
+
return (index.h("span", { class: this.classCollection.join() }, index.h("span", { class: "mg-badge__value" }, this.value), index.h("span", { class: "sr-only" }, this.label)));
|
|
356
349
|
}
|
|
357
350
|
static get watchers() { return {
|
|
358
351
|
"value": ["validateValue"],
|
|
@@ -383,8 +376,7 @@ const MgButton = class {
|
|
|
383
376
|
this.classFullWidth = 'mg-button--full-width';
|
|
384
377
|
/**
|
|
385
378
|
* Trigger actions onClick event
|
|
386
|
-
* @param
|
|
387
|
-
* @returns {void}
|
|
379
|
+
* @param event - click event
|
|
388
380
|
*/
|
|
389
381
|
this.handleClick = (event) => {
|
|
390
382
|
if (this.disabled)
|
|
@@ -397,8 +389,7 @@ const MgButton = class {
|
|
|
397
389
|
};
|
|
398
390
|
/**
|
|
399
391
|
* Handle onKeydown event
|
|
400
|
-
* @param
|
|
401
|
-
* @returns {void}
|
|
392
|
+
* @param event - keyboard event
|
|
402
393
|
*/
|
|
403
394
|
this.handleKeydown = (event) => {
|
|
404
395
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -411,8 +402,7 @@ const MgButton = class {
|
|
|
411
402
|
};
|
|
412
403
|
/**
|
|
413
404
|
* Handle onKeyup event
|
|
414
|
-
* @param
|
|
415
|
-
* @returns {void}
|
|
405
|
+
* @param event - keyboard event
|
|
416
406
|
*/
|
|
417
407
|
this.handleKeyup = (event) => {
|
|
418
408
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -430,7 +420,7 @@ const MgButton = class {
|
|
|
430
420
|
this.isIcon = false;
|
|
431
421
|
this.disableOnClick = false;
|
|
432
422
|
this.loading = false;
|
|
433
|
-
this.
|
|
423
|
+
this.classCollection = new ClassList(['mg-button']);
|
|
434
424
|
}
|
|
435
425
|
validateVariant(newValue, oldValue) {
|
|
436
426
|
if (!variants$4.includes(newValue)) {
|
|
@@ -438,9 +428,9 @@ const MgButton = class {
|
|
|
438
428
|
}
|
|
439
429
|
else {
|
|
440
430
|
if (oldValue !== undefined) {
|
|
441
|
-
this.
|
|
431
|
+
this.classCollection.delete(`mg-button--${oldValue}`);
|
|
442
432
|
}
|
|
443
|
-
this.
|
|
433
|
+
this.classCollection.add(`mg-button--${newValue}`);
|
|
444
434
|
}
|
|
445
435
|
}
|
|
446
436
|
validateFullWidth(newValue) {
|
|
@@ -448,10 +438,10 @@ const MgButton = class {
|
|
|
448
438
|
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
449
439
|
}
|
|
450
440
|
else if (newValue) {
|
|
451
|
-
this.
|
|
441
|
+
this.classCollection.add(this.classFullWidth);
|
|
452
442
|
}
|
|
453
443
|
else {
|
|
454
|
-
this.
|
|
444
|
+
this.classCollection.delete(this.classFullWidth);
|
|
455
445
|
}
|
|
456
446
|
}
|
|
457
447
|
disabledHandler(isDisabled) {
|
|
@@ -464,10 +454,10 @@ const MgButton = class {
|
|
|
464
454
|
this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
|
|
465
455
|
// apply style
|
|
466
456
|
if (isDisabled) {
|
|
467
|
-
this.
|
|
457
|
+
this.classCollection.add(this.classDisabled);
|
|
468
458
|
}
|
|
469
459
|
else {
|
|
470
|
-
this.
|
|
460
|
+
this.classCollection.delete(this.classDisabled);
|
|
471
461
|
}
|
|
472
462
|
// emit value update
|
|
473
463
|
this.disabledChange.emit(isDisabled);
|
|
@@ -475,21 +465,20 @@ const MgButton = class {
|
|
|
475
465
|
loadingHandler(newValue) {
|
|
476
466
|
// we add loading style if it newvalue is true else we remove it
|
|
477
467
|
if (newValue) {
|
|
478
|
-
this.
|
|
468
|
+
this.classCollection.add(this.classLoading);
|
|
479
469
|
}
|
|
480
470
|
else {
|
|
481
|
-
this.
|
|
471
|
+
this.classCollection.delete(this.classLoading);
|
|
482
472
|
}
|
|
483
473
|
}
|
|
484
474
|
/**
|
|
485
475
|
* Check if props are well configured on init
|
|
486
|
-
* @returns {void}
|
|
487
476
|
*/
|
|
488
477
|
componentWillLoad() {
|
|
489
478
|
this.validateVariant(this.variant);
|
|
490
479
|
this.validateFullWidth(this.fullWidth);
|
|
491
480
|
if (this.isIcon) {
|
|
492
|
-
this.
|
|
481
|
+
this.classCollection.add(`mg-button--icon`);
|
|
493
482
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
494
483
|
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
495
484
|
}
|
|
@@ -500,10 +489,10 @@ const MgButton = class {
|
|
|
500
489
|
}
|
|
501
490
|
/**
|
|
502
491
|
* Render component
|
|
503
|
-
* @returns
|
|
492
|
+
* @returns html element
|
|
504
493
|
*/
|
|
505
494
|
render() {
|
|
506
|
-
return (index.h(index.Host, { role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, index.h("div", { class: this.
|
|
495
|
+
return (index.h(index.Host, { role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, index.h("div", { class: this.classCollection.join(), id: this.identifier }, this.loading && index.h("mg-icon", { icon: "loader", spin: true }), index.h("div", { class: "mg-button__content" }, index.h("slot", null)))));
|
|
507
496
|
}
|
|
508
497
|
get element() { return index.getElement(this); }
|
|
509
498
|
static get watchers() { return {
|
|
@@ -537,7 +526,6 @@ const MgCard = class {
|
|
|
537
526
|
/**
|
|
538
527
|
* Methode to set default varianStyle props
|
|
539
528
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
540
|
-
* @returns {void}
|
|
541
529
|
*/
|
|
542
530
|
this.setDefaultVariantStyle = () => {
|
|
543
531
|
if (this.variantStyle === undefined)
|
|
@@ -545,17 +533,17 @@ const MgCard = class {
|
|
|
545
533
|
};
|
|
546
534
|
this.variant = undefined;
|
|
547
535
|
this.variantStyle = undefined;
|
|
548
|
-
this.
|
|
536
|
+
this.classCollection = new ClassList([this.baseClass]);
|
|
549
537
|
}
|
|
550
538
|
validateVariant(newValue, oldValue) {
|
|
551
539
|
if (newValue && !variants$3.includes(newValue))
|
|
552
540
|
throw new Error(`<${this.name}> prop "variant" must match VariantType type.`);
|
|
553
541
|
if (Boolean(newValue)) {
|
|
554
542
|
this.setDefaultVariantStyle();
|
|
555
|
-
this.
|
|
543
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
556
544
|
}
|
|
557
545
|
if (Boolean(oldValue))
|
|
558
|
-
this.
|
|
546
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
559
547
|
}
|
|
560
548
|
validateVariantStyle(newValue, oldValue) {
|
|
561
549
|
if (newValue && !variantStyles$1.includes(newValue))
|
|
@@ -563,16 +551,15 @@ const MgCard = class {
|
|
|
563
551
|
else if (Boolean(newValue) && !variants$3.includes(this.variant))
|
|
564
552
|
throw new Error(`<${this.name}> prop "variantStyle" must be paired with ${JSON.stringify(variants$3)} "variant" prop.`);
|
|
565
553
|
if (Boolean(newValue))
|
|
566
|
-
this.
|
|
554
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
567
555
|
if (Boolean(oldValue))
|
|
568
|
-
this.
|
|
556
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
569
557
|
}
|
|
570
558
|
/*************
|
|
571
559
|
* Lifecycle *
|
|
572
560
|
*************/
|
|
573
561
|
/**
|
|
574
562
|
* Check if props are well configured on init
|
|
575
|
-
* @returns {void}
|
|
576
563
|
*/
|
|
577
564
|
componentWillLoad() {
|
|
578
565
|
this.validateVariant(this.variant);
|
|
@@ -580,11 +567,11 @@ const MgCard = class {
|
|
|
580
567
|
}
|
|
581
568
|
/**
|
|
582
569
|
* Render
|
|
583
|
-
* @returns
|
|
570
|
+
* @returns HTML Element
|
|
584
571
|
*/
|
|
585
572
|
render() {
|
|
586
573
|
var _a;
|
|
587
|
-
return (index.h("div", { class: this.
|
|
574
|
+
return (index.h("div", { class: this.classCollection.join() }, ((_a = this.variantStyle) === null || _a === void 0 ? void 0 : _a.startsWith('bar-')) && index.h("span", { class: "mg-card__bar" }), index.h("slot", null)));
|
|
588
575
|
}
|
|
589
576
|
static get watchers() { return {
|
|
590
577
|
"variant": ["validateVariant"],
|
|
@@ -612,7 +599,6 @@ const MgCharacterLeft = class {
|
|
|
612
599
|
*************/
|
|
613
600
|
/**
|
|
614
601
|
* Check if props are well configured on init
|
|
615
|
-
* @returns {void}
|
|
616
602
|
*/
|
|
617
603
|
componentWillLoad() {
|
|
618
604
|
this.validateMaxlength(this.maxlength);
|
|
@@ -620,7 +606,7 @@ const MgCharacterLeft = class {
|
|
|
620
606
|
}
|
|
621
607
|
/**
|
|
622
608
|
* Render component
|
|
623
|
-
* @returns
|
|
609
|
+
* @returns HTML Element
|
|
624
610
|
*/
|
|
625
611
|
render() {
|
|
626
612
|
return (index.h("span", { id: this.identifier, "aria-live": "polite" }, index.h("span", { "aria-hidden": "true" }, this.maxlength - this.characters.length, "/", this.maxlength), index.h("span", { class: "sr-only" }, this.messages.nbCharLeft.replace('{counter}', this.maxlength - this.characters.length))));
|
|
@@ -640,7 +626,6 @@ const MgDetails = class {
|
|
|
640
626
|
this.expandedChange = index.createEvent(this, "expanded-change", 7);
|
|
641
627
|
/**
|
|
642
628
|
* Handle details toggle
|
|
643
|
-
* @returns {void}
|
|
644
629
|
*/
|
|
645
630
|
this.handleToggle = () => {
|
|
646
631
|
this.expanded = this.details.open;
|
|
@@ -663,7 +648,6 @@ const MgDetails = class {
|
|
|
663
648
|
*************/
|
|
664
649
|
/**
|
|
665
650
|
* Check if component props are well configured on init
|
|
666
|
-
* @returns {void}
|
|
667
651
|
*/
|
|
668
652
|
componentWillLoad() {
|
|
669
653
|
this.validateTitles(this.toggleClosed);
|
|
@@ -671,7 +655,7 @@ const MgDetails = class {
|
|
|
671
655
|
}
|
|
672
656
|
/**
|
|
673
657
|
* Render
|
|
674
|
-
* @returns
|
|
658
|
+
* @returns HTML Element
|
|
675
659
|
*/
|
|
676
660
|
render() {
|
|
677
661
|
return (index.h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, index.h("summary", null, index.h("slot", { name: "summary" }), index.h("span", { class: "mg-details__toggle" }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down', size: "small" }), index.h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), index.h("div", { class: "mg-details__details" }, index.h("slot", { name: "details" }))));
|
|
@@ -693,7 +677,7 @@ const MgDivider = class {
|
|
|
693
677
|
}
|
|
694
678
|
/**
|
|
695
679
|
* Render
|
|
696
|
-
* @returns
|
|
680
|
+
* @returns HTML Element
|
|
697
681
|
*/
|
|
698
682
|
render() {
|
|
699
683
|
return (index.h("div", { class: {
|
|
@@ -715,13 +699,11 @@ const MgForm = class {
|
|
|
715
699
|
this.classAllRequired = 'mg-form--all-required';
|
|
716
700
|
/**
|
|
717
701
|
* Define required message based on mg-inputs required elements
|
|
718
|
-
* Also
|
|
719
|
-
* @returns {void}
|
|
720
702
|
*/
|
|
721
703
|
this.setRequiredMessage = () => {
|
|
722
704
|
// init required message
|
|
723
705
|
this.requiredMessage = null;
|
|
724
|
-
this.
|
|
706
|
+
this.classCollection.delete(this.classAllRequired);
|
|
725
707
|
// If the form is disabled or readonly none of them are required
|
|
726
708
|
// Check if all fields are not editable (readonly or disabled)
|
|
727
709
|
if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
|
|
@@ -731,7 +713,7 @@ const MgForm = class {
|
|
|
731
713
|
// mg-input-toggle can not be required
|
|
732
714
|
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
733
715
|
this.requiredMessage = requiredInputs.length === 1 ? this.messages.form.allRequiredSingle : this.messages.form.allRequired;
|
|
734
|
-
this.
|
|
716
|
+
this.classCollection.add(this.classAllRequired);
|
|
735
717
|
}
|
|
736
718
|
// Some fields are required
|
|
737
719
|
else if (requiredInputs.length > 0) {
|
|
@@ -741,7 +723,6 @@ const MgForm = class {
|
|
|
741
723
|
};
|
|
742
724
|
/**
|
|
743
725
|
* Check if form is valid
|
|
744
|
-
* @returns {void}
|
|
745
726
|
*/
|
|
746
727
|
this.checkValidity = () => {
|
|
747
728
|
// Update required on input event
|
|
@@ -753,8 +734,7 @@ const MgForm = class {
|
|
|
753
734
|
};
|
|
754
735
|
/**
|
|
755
736
|
* Handle Form Submit
|
|
756
|
-
* @param
|
|
757
|
-
* @returns {void}
|
|
737
|
+
* @param event - submit event
|
|
758
738
|
*/
|
|
759
739
|
this.handleFormSubmit = (event) => {
|
|
760
740
|
event.preventDefault();
|
|
@@ -762,7 +742,6 @@ const MgForm = class {
|
|
|
762
742
|
};
|
|
763
743
|
/**
|
|
764
744
|
* Set mgInputs
|
|
765
|
-
* @returns {void}
|
|
766
745
|
*/
|
|
767
746
|
this.setMgInputs = () => {
|
|
768
747
|
// Get slotted mgInputs
|
|
@@ -784,7 +763,7 @@ const MgForm = class {
|
|
|
784
763
|
this.disabled = false;
|
|
785
764
|
this.valid = undefined;
|
|
786
765
|
this.invalid = undefined;
|
|
787
|
-
this.
|
|
766
|
+
this.classCollection = new ClassList(['mg-form']);
|
|
788
767
|
this.requiredMessage = undefined;
|
|
789
768
|
}
|
|
790
769
|
handleAttributeChange() {
|
|
@@ -793,7 +772,6 @@ const MgForm = class {
|
|
|
793
772
|
}
|
|
794
773
|
/**
|
|
795
774
|
* Public method to display errors
|
|
796
|
-
* @returns {Promise<void>}
|
|
797
775
|
*/
|
|
798
776
|
async displayError() {
|
|
799
777
|
if (!this.readonly) {
|
|
@@ -808,7 +786,6 @@ const MgForm = class {
|
|
|
808
786
|
*************/
|
|
809
787
|
/**
|
|
810
788
|
* Check if component props are well configured on init
|
|
811
|
-
* @returns {void}
|
|
812
789
|
*/
|
|
813
790
|
componentWillLoad() {
|
|
814
791
|
// Get locales
|
|
@@ -835,7 +812,6 @@ const MgForm = class {
|
|
|
835
812
|
}
|
|
836
813
|
/**
|
|
837
814
|
* Add slot listeners
|
|
838
|
-
* @returns {void}
|
|
839
815
|
*/
|
|
840
816
|
componentDidLoad() {
|
|
841
817
|
this.mgButtons.forEach(mgButton => {
|
|
@@ -853,10 +829,10 @@ const MgForm = class {
|
|
|
853
829
|
}
|
|
854
830
|
/**
|
|
855
831
|
* Render
|
|
856
|
-
* @returns
|
|
832
|
+
* @returns HTML Element
|
|
857
833
|
*/
|
|
858
834
|
render() {
|
|
859
|
-
return (index.h("form", { class: this.
|
|
835
|
+
return (index.h("form", { class: this.classCollection.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit }, this.requiredMessage && index.h("p", { innerHTML: this.requiredMessage }), index.h("slot", null), !this.readonly && !this.disabled && index.h("slot", { name: "actions" })));
|
|
860
836
|
}
|
|
861
837
|
get element() { return index.getElement(this); }
|
|
862
838
|
static get watchers() { return {
|
|
@@ -1103,13 +1079,12 @@ const MgIcon = class {
|
|
|
1103
1079
|
index.registerInstance(this, hostRef);
|
|
1104
1080
|
/**
|
|
1105
1081
|
* getIcon
|
|
1106
|
-
* @returns
|
|
1082
|
+
* @returns icon html
|
|
1107
1083
|
*/
|
|
1108
1084
|
this.getIcon = () => icons[this.icon]();
|
|
1109
1085
|
/**
|
|
1110
1086
|
* Method to set default varianStyle props
|
|
1111
1087
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
1112
|
-
* @returns {void}
|
|
1113
1088
|
*/
|
|
1114
1089
|
this.setDefaultVariantStyle = () => {
|
|
1115
1090
|
if (this.variantStyle === undefined)
|
|
@@ -1120,15 +1095,15 @@ const MgIcon = class {
|
|
|
1120
1095
|
this.variant = undefined;
|
|
1121
1096
|
this.variantStyle = undefined;
|
|
1122
1097
|
this.spin = false;
|
|
1123
|
-
this.
|
|
1098
|
+
this.classCollection = new ClassList(['mg-icon']);
|
|
1124
1099
|
}
|
|
1125
1100
|
validateIcon(newValue, oldValue) {
|
|
1126
1101
|
if (!Object.keys(icons).includes(newValue))
|
|
1127
1102
|
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
|
|
1128
1103
|
else {
|
|
1129
1104
|
if (oldValue !== undefined)
|
|
1130
|
-
this.
|
|
1131
|
-
this.
|
|
1105
|
+
this.classCollection.delete(`mg-icon--${oldValue}`);
|
|
1106
|
+
this.classCollection.add(`mg-icon--${newValue}`);
|
|
1132
1107
|
}
|
|
1133
1108
|
}
|
|
1134
1109
|
validateSize(newValue, oldValue) {
|
|
@@ -1136,8 +1111,8 @@ const MgIcon = class {
|
|
|
1136
1111
|
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes$1.join(', ')}`);
|
|
1137
1112
|
else {
|
|
1138
1113
|
if (oldValue !== undefined)
|
|
1139
|
-
this.
|
|
1140
|
-
this.
|
|
1114
|
+
this.classCollection.delete(`mg-icon--size-${oldValue}`);
|
|
1115
|
+
this.classCollection.add(`mg-icon--size-${newValue}`);
|
|
1141
1116
|
}
|
|
1142
1117
|
}
|
|
1143
1118
|
validateVariant(newValue, oldValue) {
|
|
@@ -1147,8 +1122,8 @@ const MgIcon = class {
|
|
|
1147
1122
|
else {
|
|
1148
1123
|
this.setDefaultVariantStyle();
|
|
1149
1124
|
if (oldValue !== undefined)
|
|
1150
|
-
this.
|
|
1151
|
-
this.
|
|
1125
|
+
this.classCollection.delete(`mg-icon--variant-${oldValue}`);
|
|
1126
|
+
this.classCollection.add(`mg-icon--variant-${newValue}`);
|
|
1152
1127
|
}
|
|
1153
1128
|
}
|
|
1154
1129
|
}
|
|
@@ -1158,24 +1133,23 @@ const MgIcon = class {
|
|
|
1158
1133
|
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
|
|
1159
1134
|
else {
|
|
1160
1135
|
if (oldValue !== undefined)
|
|
1161
|
-
this.
|
|
1162
|
-
this.
|
|
1136
|
+
this.classCollection.delete(`mg-icon--variant-style-${oldValue}`);
|
|
1137
|
+
this.classCollection.add(`mg-icon--variant-style-${newValue}`);
|
|
1163
1138
|
}
|
|
1164
1139
|
}
|
|
1165
1140
|
}
|
|
1166
1141
|
handleSpin(newValue) {
|
|
1167
1142
|
if (newValue) {
|
|
1168
|
-
this.
|
|
1169
|
-
this.
|
|
1143
|
+
this.classCollection.add('mg-icon--spin');
|
|
1144
|
+
this.classCollection.add('mg-a11y-animation');
|
|
1170
1145
|
}
|
|
1171
1146
|
else {
|
|
1172
|
-
this.
|
|
1173
|
-
this.
|
|
1147
|
+
this.classCollection.delete('mg-icon--spin');
|
|
1148
|
+
this.classCollection.delete('mg-a11y-animation');
|
|
1174
1149
|
}
|
|
1175
1150
|
}
|
|
1176
1151
|
/**
|
|
1177
1152
|
* Check if props are well configured on init
|
|
1178
|
-
* @returns {void}
|
|
1179
1153
|
*/
|
|
1180
1154
|
componentWillLoad() {
|
|
1181
1155
|
this.validateIcon(this.icon);
|
|
@@ -1186,10 +1160,10 @@ const MgIcon = class {
|
|
|
1186
1160
|
}
|
|
1187
1161
|
/**
|
|
1188
1162
|
* Render component
|
|
1189
|
-
* @returns
|
|
1163
|
+
* @returns HTML Element
|
|
1190
1164
|
*/
|
|
1191
1165
|
render() {
|
|
1192
|
-
return (index.h("svg", { class: this.
|
|
1166
|
+
return (index.h("svg", { class: this.classCollection.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
|
|
1193
1167
|
}
|
|
1194
1168
|
static get watchers() { return {
|
|
1195
1169
|
"icon": ["validateIcon"],
|
|
@@ -1214,7 +1188,6 @@ const MgIllustratedMessage = class {
|
|
|
1214
1188
|
*************/
|
|
1215
1189
|
/**
|
|
1216
1190
|
* Check if component props are well configured on init
|
|
1217
|
-
* @returns {void}
|
|
1218
1191
|
*/
|
|
1219
1192
|
componentDidLoad() {
|
|
1220
1193
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -1229,7 +1202,7 @@ const MgIllustratedMessage = class {
|
|
|
1229
1202
|
}
|
|
1230
1203
|
/**
|
|
1231
1204
|
* Render
|
|
1232
|
-
* @returns
|
|
1205
|
+
* @returns HTML Element
|
|
1233
1206
|
*/
|
|
1234
1207
|
render() {
|
|
1235
1208
|
return (index.h("div", { class: {
|
|
@@ -1244,12 +1217,17 @@ const MgIllustratedMessage = class {
|
|
|
1244
1217
|
};
|
|
1245
1218
|
MgIllustratedMessage.style = mgIllustratedMessageCss;
|
|
1246
1219
|
|
|
1220
|
+
/**
|
|
1221
|
+
* Possible input width
|
|
1222
|
+
*/
|
|
1223
|
+
const widths = [2, 4, 16, 'full'];
|
|
1224
|
+
|
|
1247
1225
|
/**
|
|
1248
1226
|
* Apply in all input child node the aria-describedby attribute
|
|
1249
|
-
* @param
|
|
1250
|
-
* @param
|
|
1251
|
-
* @param
|
|
1252
|
-
* @returns
|
|
1227
|
+
* @param children - Represent scoped elements
|
|
1228
|
+
* @param ariaDescribedbyIDs - List of IDs
|
|
1229
|
+
* @param utils - Stencil.js utils
|
|
1230
|
+
* @returns Children with aria-describedby attribute
|
|
1253
1231
|
*/
|
|
1254
1232
|
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
1255
1233
|
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
@@ -1262,29 +1240,36 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
|
|
|
1262
1240
|
});
|
|
1263
1241
|
/**
|
|
1264
1242
|
* Add classes based on props
|
|
1265
|
-
* @param
|
|
1243
|
+
* @param props - MgInput Interface Props
|
|
1266
1244
|
*/
|
|
1267
1245
|
const manageClasses = (props) => {
|
|
1268
|
-
props.
|
|
1246
|
+
props.classCollection.add('mg-input');
|
|
1269
1247
|
if (props.labelOnTop)
|
|
1270
|
-
props.
|
|
1248
|
+
props.classCollection.add('mg-input--label-on-top');
|
|
1249
|
+
else
|
|
1250
|
+
props.classCollection.delete('mg-input--label-on-top');
|
|
1271
1251
|
if (props.readonly)
|
|
1272
|
-
props.
|
|
1252
|
+
props.classCollection.add('mg-input--readonly');
|
|
1253
|
+
else
|
|
1254
|
+
props.classCollection.delete('mg-input--readonly');
|
|
1255
|
+
widths.forEach(width => {
|
|
1256
|
+
props.classCollection.delete(`mg-input--width-${width}`);
|
|
1257
|
+
});
|
|
1273
1258
|
if (props.mgWidth !== undefined)
|
|
1274
|
-
props.
|
|
1259
|
+
props.classCollection.add(`mg-input--width-${props.mgWidth}`);
|
|
1275
1260
|
};
|
|
1276
1261
|
/**
|
|
1277
1262
|
* Get tagname
|
|
1278
|
-
* @param
|
|
1279
|
-
* @returns
|
|
1263
|
+
* @param isFieldset - is fieldset
|
|
1264
|
+
* @returns tag name
|
|
1280
1265
|
*/
|
|
1281
1266
|
const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
|
|
1282
1267
|
/**
|
|
1283
1268
|
* Get input template
|
|
1284
|
-
* @param
|
|
1285
|
-
* @param
|
|
1286
|
-
* @param
|
|
1287
|
-
* @returns
|
|
1269
|
+
* @param props - MgInput Interface Props
|
|
1270
|
+
* @param children - Represent scoped elements
|
|
1271
|
+
* @param utils - Stencil.js utils
|
|
1272
|
+
* @returns input template
|
|
1288
1273
|
*/
|
|
1289
1274
|
const MgInput = (props, children, utils) => {
|
|
1290
1275
|
/**
|
|
@@ -1340,17 +1325,17 @@ const MgInput = (props, children, utils) => {
|
|
|
1340
1325
|
const TagName = getTagName(props.isFieldset);
|
|
1341
1326
|
/**
|
|
1342
1327
|
* Get tooltip node
|
|
1343
|
-
* @returns
|
|
1328
|
+
* @returns mg-tooltip
|
|
1344
1329
|
*/
|
|
1345
1330
|
const getTooltip = () => (index.h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
|
|
1346
1331
|
index.h("mg-icon", { icon: "info-circle" })));
|
|
1347
1332
|
/**
|
|
1348
1333
|
* Get input title (label) node
|
|
1349
1334
|
* Display asterisk only if not disabled and not readonly
|
|
1350
|
-
* @returns
|
|
1335
|
+
* @returns mg-input-title
|
|
1351
1336
|
*/
|
|
1352
1337
|
const getInputTitle = () => (index.h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
|
|
1353
|
-
return (index.h(TagName, { class: props.
|
|
1338
|
+
return (index.h(TagName, { class: props.classCollection.join() },
|
|
1354
1339
|
props.labelOnTop ? (index.h("div", { class: "mg-input__title" },
|
|
1355
1340
|
getInputTitle(),
|
|
1356
1341
|
!props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
|
|
@@ -1368,8 +1353,8 @@ const mgInputCheckboxCss = ":host{display:block}.mg-input{display:flex;align-ite
|
|
|
1368
1353
|
|
|
1369
1354
|
/**
|
|
1370
1355
|
* type CheckboxItem validation function
|
|
1371
|
-
* @param
|
|
1372
|
-
* @returns
|
|
1356
|
+
* @param items - Checkbox item
|
|
1357
|
+
* @returns match item type
|
|
1373
1358
|
*/
|
|
1374
1359
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
1375
1360
|
items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
|
|
@@ -1387,7 +1372,7 @@ const MgInputCheckbox = class {
|
|
|
1387
1372
|
this.hasDisplayedError = false;
|
|
1388
1373
|
/**
|
|
1389
1374
|
* Handle input event
|
|
1390
|
-
* @param
|
|
1375
|
+
* @param event - input event
|
|
1391
1376
|
*/
|
|
1392
1377
|
this.handleInput = (event) => {
|
|
1393
1378
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -1409,7 +1394,7 @@ const MgInputCheckbox = class {
|
|
|
1409
1394
|
};
|
|
1410
1395
|
/**
|
|
1411
1396
|
* get invalid element
|
|
1412
|
-
* @returns
|
|
1397
|
+
* @returns element
|
|
1413
1398
|
*/
|
|
1414
1399
|
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
1415
1400
|
/**
|
|
@@ -1446,7 +1431,7 @@ const MgInputCheckbox = class {
|
|
|
1446
1431
|
this.helpText = undefined;
|
|
1447
1432
|
this.valid = undefined;
|
|
1448
1433
|
this.invalid = undefined;
|
|
1449
|
-
this.
|
|
1434
|
+
this.classCollection = new ClassList(['mg-input--checkbox']);
|
|
1450
1435
|
this.errorMessage = undefined;
|
|
1451
1436
|
this.checkboxItems = [];
|
|
1452
1437
|
}
|
|
@@ -1476,7 +1461,6 @@ const MgInputCheckbox = class {
|
|
|
1476
1461
|
}
|
|
1477
1462
|
/**
|
|
1478
1463
|
* Public method to display errors
|
|
1479
|
-
* @returns {Promise<void>}
|
|
1480
1464
|
*/
|
|
1481
1465
|
async displayError() {
|
|
1482
1466
|
this.checkValidity();
|
|
@@ -1488,7 +1472,7 @@ const MgInputCheckbox = class {
|
|
|
1488
1472
|
*************/
|
|
1489
1473
|
/**
|
|
1490
1474
|
* Check if component props are well configured on init
|
|
1491
|
-
* @returns
|
|
1475
|
+
* @returns timeout
|
|
1492
1476
|
*/
|
|
1493
1477
|
componentWillLoad() {
|
|
1494
1478
|
// Get locales
|
|
@@ -1504,10 +1488,10 @@ const MgInputCheckbox = class {
|
|
|
1504
1488
|
}
|
|
1505
1489
|
/**
|
|
1506
1490
|
* Render
|
|
1507
|
-
* @returns
|
|
1491
|
+
* @returns HTML Element
|
|
1508
1492
|
*/
|
|
1509
1493
|
render() {
|
|
1510
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
1494
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.checkboxItems
|
|
1511
1495
|
.filter(item => {
|
|
1512
1496
|
return !this.readonly || item.value;
|
|
1513
1497
|
})
|
|
@@ -1571,7 +1555,7 @@ const MgInputDate = class {
|
|
|
1571
1555
|
};
|
|
1572
1556
|
/**
|
|
1573
1557
|
* get input error code
|
|
1574
|
-
* @returns
|
|
1558
|
+
* @returns error code
|
|
1575
1559
|
*/
|
|
1576
1560
|
this.getInputError = () => {
|
|
1577
1561
|
var _a, _b;
|
|
@@ -1596,7 +1580,6 @@ const MgInputDate = class {
|
|
|
1596
1580
|
};
|
|
1597
1581
|
/**
|
|
1598
1582
|
* Check input errors
|
|
1599
|
-
* @returns {void}
|
|
1600
1583
|
*/
|
|
1601
1584
|
this.setErrorMessage = () => {
|
|
1602
1585
|
var _a;
|
|
@@ -1634,7 +1617,7 @@ const MgInputDate = class {
|
|
|
1634
1617
|
this.invalid = undefined;
|
|
1635
1618
|
this.min = undefined;
|
|
1636
1619
|
this.max = undefined;
|
|
1637
|
-
this.
|
|
1620
|
+
this.classCollection = new ClassList(['mg-input--date']);
|
|
1638
1621
|
this.errorMessage = undefined;
|
|
1639
1622
|
}
|
|
1640
1623
|
validateValue(newValue) {
|
|
@@ -1665,7 +1648,6 @@ const MgInputDate = class {
|
|
|
1665
1648
|
}
|
|
1666
1649
|
/**
|
|
1667
1650
|
* Public method to display errors
|
|
1668
|
-
* @returns {Promise<void>}
|
|
1669
1651
|
*/
|
|
1670
1652
|
async displayError() {
|
|
1671
1653
|
this.checkValidity();
|
|
@@ -1677,7 +1659,7 @@ const MgInputDate = class {
|
|
|
1677
1659
|
*************/
|
|
1678
1660
|
/**
|
|
1679
1661
|
* Check if component props are well configured on init
|
|
1680
|
-
* @returns
|
|
1662
|
+
* @returns timeout
|
|
1681
1663
|
*/
|
|
1682
1664
|
componentWillLoad() {
|
|
1683
1665
|
// Get locales
|
|
@@ -1697,10 +1679,10 @@ const MgInputDate = class {
|
|
|
1697
1679
|
}
|
|
1698
1680
|
/**
|
|
1699
1681
|
* Render
|
|
1700
|
-
* @returns
|
|
1682
|
+
* @returns HTML Element
|
|
1701
1683
|
*/
|
|
1702
1684
|
render() {
|
|
1703
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
1685
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: mgMenu_conf.localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
1704
1686
|
if (el !== null)
|
|
1705
1687
|
this.input = el;
|
|
1706
1688
|
} })));
|
|
@@ -1740,7 +1722,6 @@ const MgInputNumeric = class {
|
|
|
1740
1722
|
this.hasDisplayedError = false;
|
|
1741
1723
|
/**
|
|
1742
1724
|
* Handle input event
|
|
1743
|
-
* @returns {void}
|
|
1744
1725
|
*/
|
|
1745
1726
|
this.handleInput = () => {
|
|
1746
1727
|
// Check validity
|
|
@@ -1752,23 +1733,22 @@ const MgInputNumeric = class {
|
|
|
1752
1733
|
};
|
|
1753
1734
|
/**
|
|
1754
1735
|
* Handle focus event
|
|
1755
|
-
* @returns {void}
|
|
1756
1736
|
*/
|
|
1757
1737
|
this.handleFocus = () => {
|
|
1758
1738
|
this.hasFocus = true;
|
|
1759
1739
|
};
|
|
1760
1740
|
/**
|
|
1761
1741
|
* Handle blur event
|
|
1762
|
-
* @returns {void}
|
|
1763
1742
|
*/
|
|
1764
1743
|
this.handleBlur = () => {
|
|
1744
|
+
if (this.value === '-')
|
|
1745
|
+
this.value = '';
|
|
1765
1746
|
// Display Error
|
|
1766
1747
|
this.displayError();
|
|
1767
1748
|
this.hasFocus = false;
|
|
1768
1749
|
};
|
|
1769
1750
|
/**
|
|
1770
1751
|
* Check if input is valid
|
|
1771
|
-
* @returns {void}
|
|
1772
1752
|
*/
|
|
1773
1753
|
this.checkValidity = () => {
|
|
1774
1754
|
this.valid = this.readonly || this.disabled || this.getInputError() === null;
|
|
@@ -1778,7 +1758,6 @@ const MgInputNumeric = class {
|
|
|
1778
1758
|
};
|
|
1779
1759
|
/**
|
|
1780
1760
|
* Set input error message
|
|
1781
|
-
* @returns {void}
|
|
1782
1761
|
*/
|
|
1783
1762
|
this.setErrorMessage = () => {
|
|
1784
1763
|
// Set error message
|
|
@@ -1795,7 +1774,7 @@ const MgInputNumeric = class {
|
|
|
1795
1774
|
};
|
|
1796
1775
|
/**
|
|
1797
1776
|
* Get input error code
|
|
1798
|
-
* @returns
|
|
1777
|
+
* @returns error code
|
|
1799
1778
|
*/
|
|
1800
1779
|
this.getInputError = () => {
|
|
1801
1780
|
let inputError = null;
|
|
@@ -1823,18 +1802,17 @@ const MgInputNumeric = class {
|
|
|
1823
1802
|
};
|
|
1824
1803
|
/**
|
|
1825
1804
|
* Format value based on type
|
|
1826
|
-
* @param
|
|
1827
|
-
* @returns
|
|
1805
|
+
* @param value - value to format
|
|
1806
|
+
* @returns formated local value
|
|
1828
1807
|
*/
|
|
1829
1808
|
this.formatValue = (value) => (this.type === 'currency' ? mgMenu_conf.localeCurrency(value, this.locale, this.currency) : mgMenu_conf.localeNumber(value, this.locale));
|
|
1830
1809
|
/**
|
|
1831
1810
|
* Validate append slot
|
|
1832
|
-
* @returns {void}
|
|
1833
1811
|
*/
|
|
1834
1812
|
this.validateAppendSlot = () => {
|
|
1835
1813
|
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
1836
1814
|
if (slotAppendInput !== null) {
|
|
1837
|
-
this.
|
|
1815
|
+
this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
1838
1816
|
}
|
|
1839
1817
|
};
|
|
1840
1818
|
this.value = undefined;
|
|
@@ -1858,7 +1836,7 @@ const MgInputNumeric = class {
|
|
|
1858
1836
|
this.decimalLength = 2;
|
|
1859
1837
|
this.valid = undefined;
|
|
1860
1838
|
this.invalid = undefined;
|
|
1861
|
-
this.
|
|
1839
|
+
this.classCollection = new ClassList(['mg-input--numeric']);
|
|
1862
1840
|
this.errorMessage = undefined;
|
|
1863
1841
|
this.hasFocus = false;
|
|
1864
1842
|
}
|
|
@@ -1870,7 +1848,7 @@ const MgInputNumeric = class {
|
|
|
1870
1848
|
// Regex
|
|
1871
1849
|
const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+[.,]?\d*$/;
|
|
1872
1850
|
// Filter input
|
|
1873
|
-
if (
|
|
1851
|
+
if (['', '-'].includes(newValue) || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
1874
1852
|
this.storedValue = newValue;
|
|
1875
1853
|
}
|
|
1876
1854
|
else if (this.storedValue !== undefined) {
|
|
@@ -1917,7 +1895,6 @@ const MgInputNumeric = class {
|
|
|
1917
1895
|
}
|
|
1918
1896
|
/**
|
|
1919
1897
|
* Public method to display errors
|
|
1920
|
-
* @returns {Promise<void>}
|
|
1921
1898
|
*/
|
|
1922
1899
|
async displayError() {
|
|
1923
1900
|
this.checkValidity();
|
|
@@ -1927,7 +1904,7 @@ const MgInputNumeric = class {
|
|
|
1927
1904
|
/**
|
|
1928
1905
|
* Displayed value in input
|
|
1929
1906
|
* Change on focus/blur
|
|
1930
|
-
* @returns
|
|
1907
|
+
* @returns display value
|
|
1931
1908
|
*/
|
|
1932
1909
|
displayValue() {
|
|
1933
1910
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -1937,7 +1914,7 @@ const MgInputNumeric = class {
|
|
|
1937
1914
|
*************/
|
|
1938
1915
|
/**
|
|
1939
1916
|
* Check if component props are well configured on init
|
|
1940
|
-
* @returns
|
|
1917
|
+
* @returns timeout
|
|
1941
1918
|
*/
|
|
1942
1919
|
componentWillLoad() {
|
|
1943
1920
|
// Get locales
|
|
@@ -1960,10 +1937,10 @@ const MgInputNumeric = class {
|
|
|
1960
1937
|
}
|
|
1961
1938
|
/**
|
|
1962
1939
|
* Render
|
|
1963
|
-
* @returns
|
|
1940
|
+
* @returns HTML Element
|
|
1964
1941
|
*/
|
|
1965
1942
|
render() {
|
|
1966
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
1943
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
|
|
1967
1944
|
if (el !== null)
|
|
1968
1945
|
this.input = el;
|
|
1969
1946
|
} }), index.h("slot", { name: "append-input" })));
|
|
@@ -2042,7 +2019,7 @@ const MgInputPassword = class {
|
|
|
2042
2019
|
this.helpText = undefined;
|
|
2043
2020
|
this.valid = undefined;
|
|
2044
2021
|
this.invalid = undefined;
|
|
2045
|
-
this.
|
|
2022
|
+
this.classCollection = new ClassList(['mg-input--password']);
|
|
2046
2023
|
this.errorMessage = undefined;
|
|
2047
2024
|
}
|
|
2048
2025
|
handleValue(newValue) {
|
|
@@ -2060,7 +2037,6 @@ const MgInputPassword = class {
|
|
|
2060
2037
|
}
|
|
2061
2038
|
/**
|
|
2062
2039
|
* Public method to display errors
|
|
2063
|
-
* @returns {Promise<void>}
|
|
2064
2040
|
*/
|
|
2065
2041
|
async displayError() {
|
|
2066
2042
|
this.checkValidity();
|
|
@@ -2072,7 +2048,7 @@ const MgInputPassword = class {
|
|
|
2072
2048
|
*************/
|
|
2073
2049
|
/**
|
|
2074
2050
|
* Check if component props are well configured on init
|
|
2075
|
-
* @returns
|
|
2051
|
+
* @returns timeout
|
|
2076
2052
|
*/
|
|
2077
2053
|
componentWillLoad() {
|
|
2078
2054
|
// Get locales
|
|
@@ -2086,10 +2062,10 @@ const MgInputPassword = class {
|
|
|
2086
2062
|
}
|
|
2087
2063
|
/**
|
|
2088
2064
|
* Render
|
|
2089
|
-
* @returns
|
|
2065
|
+
* @returns HTML Element
|
|
2090
2066
|
*/
|
|
2091
2067
|
render() {
|
|
2092
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2068
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2093
2069
|
if (el !== null)
|
|
2094
2070
|
this.input = el;
|
|
2095
2071
|
} })));
|
|
@@ -2108,8 +2084,8 @@ const mgInputRadioCss = ":host{display:block}.mg-input{display:flex;align-items:
|
|
|
2108
2084
|
|
|
2109
2085
|
/**
|
|
2110
2086
|
* type Option validation function
|
|
2111
|
-
* @param
|
|
2112
|
-
* @returns
|
|
2087
|
+
* @param option - radio option
|
|
2088
|
+
* @returns radio option type is valid
|
|
2113
2089
|
*/
|
|
2114
2090
|
const isOption$2 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
2115
2091
|
const MgInputRadio = class {
|
|
@@ -2126,8 +2102,7 @@ const MgInputRadio = class {
|
|
|
2126
2102
|
this.hasDisplayedError = false;
|
|
2127
2103
|
/**
|
|
2128
2104
|
* Handle input event
|
|
2129
|
-
* @param
|
|
2130
|
-
* @returns {void}
|
|
2105
|
+
* @param event - input event
|
|
2131
2106
|
*/
|
|
2132
2107
|
this.handleInput = (event) => {
|
|
2133
2108
|
this.checkValidity();
|
|
@@ -2135,7 +2110,6 @@ const MgInputRadio = class {
|
|
|
2135
2110
|
};
|
|
2136
2111
|
/**
|
|
2137
2112
|
* Handle blur event
|
|
2138
|
-
* @returns {void}
|
|
2139
2113
|
*/
|
|
2140
2114
|
this.handleBlur = () => {
|
|
2141
2115
|
this.checkValidity();
|
|
@@ -2143,7 +2117,6 @@ const MgInputRadio = class {
|
|
|
2143
2117
|
};
|
|
2144
2118
|
/**
|
|
2145
2119
|
* Check if input is valid
|
|
2146
|
-
* @returns {void}
|
|
2147
2120
|
*/
|
|
2148
2121
|
this.checkValidity = () => {
|
|
2149
2122
|
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
@@ -2153,7 +2126,6 @@ const MgInputRadio = class {
|
|
|
2153
2126
|
};
|
|
2154
2127
|
/**
|
|
2155
2128
|
* Set input error message
|
|
2156
|
-
* @returns {void}
|
|
2157
2129
|
*/
|
|
2158
2130
|
this.setErrorMessage = () => {
|
|
2159
2131
|
const invalidElement = this.getInvalidElement();
|
|
@@ -2165,7 +2137,7 @@ const MgInputRadio = class {
|
|
|
2165
2137
|
};
|
|
2166
2138
|
/**
|
|
2167
2139
|
* get invalid element
|
|
2168
|
-
* @returns
|
|
2140
|
+
* @returns element
|
|
2169
2141
|
*/
|
|
2170
2142
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
2171
2143
|
this.value = undefined;
|
|
@@ -2183,7 +2155,7 @@ const MgInputRadio = class {
|
|
|
2183
2155
|
this.helpText = undefined;
|
|
2184
2156
|
this.valid = undefined;
|
|
2185
2157
|
this.invalid = undefined;
|
|
2186
|
-
this.
|
|
2158
|
+
this.classCollection = new ClassList(['mg-input--radio']);
|
|
2187
2159
|
this.errorMessage = undefined;
|
|
2188
2160
|
this.options = undefined;
|
|
2189
2161
|
}
|
|
@@ -2219,7 +2191,6 @@ const MgInputRadio = class {
|
|
|
2219
2191
|
}
|
|
2220
2192
|
/**
|
|
2221
2193
|
* Public method to display errors
|
|
2222
|
-
* @returns {Promise<void>}
|
|
2223
2194
|
*/
|
|
2224
2195
|
async displayError() {
|
|
2225
2196
|
this.checkValidity();
|
|
@@ -2231,7 +2202,7 @@ const MgInputRadio = class {
|
|
|
2231
2202
|
*************/
|
|
2232
2203
|
/**
|
|
2233
2204
|
* Check if component props are well configured on init
|
|
2234
|
-
* @returns
|
|
2205
|
+
* @returns timeout
|
|
2235
2206
|
*/
|
|
2236
2207
|
componentWillLoad() {
|
|
2237
2208
|
// Get locales
|
|
@@ -2247,10 +2218,10 @@ const MgInputRadio = class {
|
|
|
2247
2218
|
}
|
|
2248
2219
|
/**
|
|
2249
2220
|
* Render
|
|
2250
|
-
* @returns
|
|
2221
|
+
* @returns HTML Element
|
|
2251
2222
|
*/
|
|
2252
2223
|
render() {
|
|
2253
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2224
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.options.map((input, index$1) => (index.h("li", { key: input.title, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "radio", id: this.identifier + '_' + index$1, name: this.identifier, value: index$1, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index$1].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => {
|
|
2254
2225
|
if (el !== null)
|
|
2255
2226
|
this.inputs[index$1] = el;
|
|
2256
2227
|
} }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title)))))));
|
|
@@ -2270,31 +2241,27 @@ const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items
|
|
|
2270
2241
|
|
|
2271
2242
|
/**
|
|
2272
2243
|
* Check if item is a well configured option
|
|
2273
|
-
* @param
|
|
2274
|
-
* @returns
|
|
2244
|
+
* @param option - select option
|
|
2245
|
+
* @returns select option type is valid
|
|
2275
2246
|
*/
|
|
2276
2247
|
const isOption$1 = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
2277
2248
|
/**
|
|
2278
2249
|
* Check if items[] is SelectOption
|
|
2279
|
-
* @param
|
|
2280
|
-
* @returns
|
|
2250
|
+
* @param items - select option
|
|
2251
|
+
* @returns select option array type is valid
|
|
2281
2252
|
*/
|
|
2282
2253
|
const allItemsAreOptions = (items) => Array.isArray(items) && items.every(item => isOption$1(item));
|
|
2283
2254
|
/**
|
|
2284
2255
|
* Check if item is a well configured optgroup
|
|
2285
|
-
* @param
|
|
2286
|
-
* @returns
|
|
2256
|
+
* @param optgroup - select option
|
|
2257
|
+
* @returns select optgroup type is valid
|
|
2287
2258
|
*/
|
|
2288
2259
|
const isOptGroup = (optgroup) => typeof optgroup === 'object' && typeof optgroup.group === 'string' && allItemsAreOptions(optgroup.options);
|
|
2289
2260
|
/**
|
|
2290
2261
|
* Group options
|
|
2291
|
-
* @param
|
|
2292
|
-
* @param
|
|
2293
|
-
* @
|
|
2294
|
-
* @param {string} item.title item title
|
|
2295
|
-
* @param {unknown} item.value item value
|
|
2296
|
-
* @param {boolean} item.disabled is item disabled
|
|
2297
|
-
* @returns {(SelectOption | OptGroup)[]} grouped options
|
|
2262
|
+
* @param acc - reduce accumulator
|
|
2263
|
+
* @param item - item to add
|
|
2264
|
+
* @returns grouped options
|
|
2298
2265
|
*/
|
|
2299
2266
|
const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
2300
2267
|
if (group !== undefined) {
|
|
@@ -2323,7 +2290,6 @@ const MgInputSelect = class {
|
|
|
2323
2290
|
this.hasDisplayedError = false;
|
|
2324
2291
|
/**
|
|
2325
2292
|
* Handle input event
|
|
2326
|
-
* @returns {void}
|
|
2327
2293
|
*/
|
|
2328
2294
|
this.handleInput = () => {
|
|
2329
2295
|
this.updateValue();
|
|
@@ -2332,14 +2298,13 @@ const MgInputSelect = class {
|
|
|
2332
2298
|
};
|
|
2333
2299
|
/**
|
|
2334
2300
|
* Method to compare item.title with input.value
|
|
2335
|
-
* @param
|
|
2336
|
-
* @returns
|
|
2301
|
+
* @param item - item to compare with
|
|
2302
|
+
* @returns truthy if input.value is an item
|
|
2337
2303
|
*/
|
|
2338
2304
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
2339
2305
|
/**
|
|
2340
2306
|
* value props setter
|
|
2341
|
-
* @param
|
|
2342
|
-
* @returns {void}
|
|
2307
|
+
* @param newValue - value to update with
|
|
2343
2308
|
*/
|
|
2344
2309
|
this.setValue = (newValue) => {
|
|
2345
2310
|
this.checkValidity();
|
|
@@ -2347,7 +2312,6 @@ const MgInputSelect = class {
|
|
|
2347
2312
|
};
|
|
2348
2313
|
/**
|
|
2349
2314
|
* Update value from input.value
|
|
2350
|
-
* @returns {void}
|
|
2351
2315
|
*/
|
|
2352
2316
|
this.updateValue = () => {
|
|
2353
2317
|
if (this.input.value === '') {
|
|
@@ -2373,7 +2337,7 @@ const MgInputSelect = class {
|
|
|
2373
2337
|
};
|
|
2374
2338
|
/**
|
|
2375
2339
|
* Input value is disabled
|
|
2376
|
-
* @returns
|
|
2340
|
+
* @returns truthy if input value is disabled
|
|
2377
2341
|
*/
|
|
2378
2342
|
this.isDisabledValue = () => { var _a; return allItemsAreOptions(this.options) && ((_a = this.options.find(this.isInputValue)) === null || _a === void 0 ? void 0 : _a.disabled) === true; };
|
|
2379
2343
|
/**
|
|
@@ -2398,8 +2362,8 @@ const MgInputSelect = class {
|
|
|
2398
2362
|
};
|
|
2399
2363
|
/**
|
|
2400
2364
|
* Render option
|
|
2401
|
-
* @param
|
|
2402
|
-
* @returns
|
|
2365
|
+
* @param option - to render
|
|
2366
|
+
* @returns render option
|
|
2403
2367
|
*/
|
|
2404
2368
|
this.renderOption = (option) => (index.h("option", { key: option.title, value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title));
|
|
2405
2369
|
this.value = undefined;
|
|
@@ -2420,7 +2384,7 @@ const MgInputSelect = class {
|
|
|
2420
2384
|
this.helpText = undefined;
|
|
2421
2385
|
this.valid = undefined;
|
|
2422
2386
|
this.invalid = undefined;
|
|
2423
|
-
this.
|
|
2387
|
+
this.classCollection = new ClassList(['mg-input--select']);
|
|
2424
2388
|
this.errorMessage = undefined;
|
|
2425
2389
|
this.options = undefined;
|
|
2426
2390
|
this.valueExist = undefined;
|
|
@@ -2478,7 +2442,6 @@ const MgInputSelect = class {
|
|
|
2478
2442
|
}
|
|
2479
2443
|
/**
|
|
2480
2444
|
* Public method to display errors
|
|
2481
|
-
* @returns {Promise<void>}
|
|
2482
2445
|
*/
|
|
2483
2446
|
async displayError() {
|
|
2484
2447
|
this.checkValidity();
|
|
@@ -2490,7 +2453,7 @@ const MgInputSelect = class {
|
|
|
2490
2453
|
*************/
|
|
2491
2454
|
/**
|
|
2492
2455
|
* Check if component props are well configured on init
|
|
2493
|
-
* @returns
|
|
2456
|
+
* @returns timeout
|
|
2494
2457
|
*/
|
|
2495
2458
|
componentWillLoad() {
|
|
2496
2459
|
// Get locales
|
|
@@ -2511,10 +2474,10 @@ const MgInputSelect = class {
|
|
|
2511
2474
|
}
|
|
2512
2475
|
/**
|
|
2513
2476
|
* Render
|
|
2514
|
-
* @returns
|
|
2477
|
+
* @returns HTML Element
|
|
2515
2478
|
*/
|
|
2516
2479
|
render() {
|
|
2517
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2480
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: undefined, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2518
2481
|
if (el !== null)
|
|
2519
2482
|
this.input = el;
|
|
2520
2483
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -2549,7 +2512,6 @@ const MgInputText = class {
|
|
|
2549
2512
|
this.hasDisplayedError = false;
|
|
2550
2513
|
/**
|
|
2551
2514
|
* Handle input event
|
|
2552
|
-
* @returns {void}
|
|
2553
2515
|
*/
|
|
2554
2516
|
this.handleInput = () => {
|
|
2555
2517
|
this.checkValidity();
|
|
@@ -2560,26 +2522,23 @@ const MgInputText = class {
|
|
|
2560
2522
|
};
|
|
2561
2523
|
/**
|
|
2562
2524
|
* Handle focus event
|
|
2563
|
-
* @returns {void}
|
|
2564
2525
|
*/
|
|
2565
2526
|
this.handleFocus = () => {
|
|
2566
|
-
this.
|
|
2567
|
-
this.
|
|
2527
|
+
this.classCollection.add(this.classFocus);
|
|
2528
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2568
2529
|
};
|
|
2569
2530
|
/**
|
|
2570
2531
|
* Handle blur event
|
|
2571
|
-
* @returns {void}
|
|
2572
2532
|
*/
|
|
2573
2533
|
this.handleBlur = () => {
|
|
2574
2534
|
// Manage focus
|
|
2575
|
-
this.
|
|
2576
|
-
this.
|
|
2535
|
+
this.classCollection.delete(this.classFocus);
|
|
2536
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2577
2537
|
// Display Error
|
|
2578
2538
|
this.displayError();
|
|
2579
2539
|
};
|
|
2580
2540
|
/**
|
|
2581
2541
|
* Check if input is valid
|
|
2582
|
-
* @returns {void}
|
|
2583
2542
|
*/
|
|
2584
2543
|
this.checkValidity = () => {
|
|
2585
2544
|
var _a;
|
|
@@ -2590,7 +2549,6 @@ const MgInputText = class {
|
|
|
2590
2549
|
};
|
|
2591
2550
|
/**
|
|
2592
2551
|
* Set input error message
|
|
2593
|
-
* @returns {void}
|
|
2594
2552
|
*/
|
|
2595
2553
|
this.setErrorMessage = () => {
|
|
2596
2554
|
// Set error message
|
|
@@ -2606,7 +2564,6 @@ const MgInputText = class {
|
|
|
2606
2564
|
};
|
|
2607
2565
|
/**
|
|
2608
2566
|
* Validate pattern configuration
|
|
2609
|
-
* @returns {void}
|
|
2610
2567
|
*/
|
|
2611
2568
|
this.validatePattern = () => {
|
|
2612
2569
|
if (this.pattern !== undefined &&
|
|
@@ -2618,16 +2575,15 @@ const MgInputText = class {
|
|
|
2618
2575
|
};
|
|
2619
2576
|
/**
|
|
2620
2577
|
* Validate append slot
|
|
2621
|
-
* @returns {void}
|
|
2622
2578
|
*/
|
|
2623
2579
|
this.validateAppendSlot = () => {
|
|
2624
2580
|
const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
|
|
2625
2581
|
if (slotAppendInput.length === 1) {
|
|
2626
|
-
this.
|
|
2582
|
+
this.classCollection.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.classIsInputGroupAppend : 'mg-input--is-append-input-slot-content');
|
|
2627
2583
|
}
|
|
2628
2584
|
else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
|
|
2629
|
-
this.
|
|
2630
|
-
this.
|
|
2585
|
+
this.classCollection.add(this.classIsInputGroupAppend);
|
|
2586
|
+
this.classCollection.add('mg-input--has-buttons-group-append');
|
|
2631
2587
|
}
|
|
2632
2588
|
};
|
|
2633
2589
|
this.value = undefined;
|
|
@@ -2651,7 +2607,7 @@ const MgInputText = class {
|
|
|
2651
2607
|
this.helpText = undefined;
|
|
2652
2608
|
this.valid = undefined;
|
|
2653
2609
|
this.invalid = undefined;
|
|
2654
|
-
this.
|
|
2610
|
+
this.classCollection = new ClassList(['mg-input--text']);
|
|
2655
2611
|
this.errorMessage = undefined;
|
|
2656
2612
|
}
|
|
2657
2613
|
handleValue(newValue) {
|
|
@@ -2659,10 +2615,10 @@ const MgInputText = class {
|
|
|
2659
2615
|
}
|
|
2660
2616
|
validateIcon(newValue) {
|
|
2661
2617
|
if (newValue !== undefined) {
|
|
2662
|
-
this.
|
|
2618
|
+
this.classCollection.add(this.classHasIcon);
|
|
2663
2619
|
}
|
|
2664
2620
|
else {
|
|
2665
|
-
this.
|
|
2621
|
+
this.classCollection.delete(this.classHasIcon);
|
|
2666
2622
|
}
|
|
2667
2623
|
}
|
|
2668
2624
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -2677,14 +2633,12 @@ const MgInputText = class {
|
|
|
2677
2633
|
}
|
|
2678
2634
|
/**
|
|
2679
2635
|
* Public method to play input focus
|
|
2680
|
-
* @returns {Promise<void>}
|
|
2681
2636
|
*/
|
|
2682
2637
|
async setFocus() {
|
|
2683
2638
|
this.input.focus();
|
|
2684
2639
|
}
|
|
2685
2640
|
/**
|
|
2686
2641
|
* Public method to display errors
|
|
2687
|
-
* @returns {Promise<void>}
|
|
2688
2642
|
*/
|
|
2689
2643
|
async displayError() {
|
|
2690
2644
|
this.checkValidity();
|
|
@@ -2696,7 +2650,7 @@ const MgInputText = class {
|
|
|
2696
2650
|
*************/
|
|
2697
2651
|
/**
|
|
2698
2652
|
* Check if component props are well configured on init
|
|
2699
|
-
* @returns
|
|
2653
|
+
* @returns timeout
|
|
2700
2654
|
*/
|
|
2701
2655
|
componentWillLoad() {
|
|
2702
2656
|
// Get locales
|
|
@@ -2715,10 +2669,10 @@ const MgInputText = class {
|
|
|
2715
2669
|
}
|
|
2716
2670
|
/**
|
|
2717
2671
|
* Render
|
|
2718
|
-
* @returns
|
|
2672
|
+
* @returns HTML Element
|
|
2719
2673
|
*/
|
|
2720
2674
|
render() {
|
|
2721
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2675
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("div", { class: "mg-input__with-character-left", style: {
|
|
2722
2676
|
'--mg-character-left-message-length': (this.displayCharacterLeft
|
|
2723
2677
|
? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
|
|
2724
2678
|
: 0).toString(),
|
|
@@ -2767,23 +2721,23 @@ const MgInputTextarea = class {
|
|
|
2767
2721
|
* Handle focus event
|
|
2768
2722
|
*/
|
|
2769
2723
|
this.handleFocus = () => {
|
|
2770
|
-
this.
|
|
2771
|
-
this.
|
|
2724
|
+
this.classCollection.add(this.classFocus);
|
|
2725
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2772
2726
|
};
|
|
2773
2727
|
/**
|
|
2774
2728
|
* Handle blur event
|
|
2775
2729
|
*/
|
|
2776
2730
|
this.handleBlur = () => {
|
|
2777
2731
|
// Manage focus
|
|
2778
|
-
this.
|
|
2779
|
-
this.
|
|
2732
|
+
this.classCollection.delete(this.classFocus);
|
|
2733
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2780
2734
|
// Display Error
|
|
2781
2735
|
this.displayError();
|
|
2782
2736
|
};
|
|
2783
2737
|
/**
|
|
2784
2738
|
* Get pattern validity
|
|
2785
2739
|
* Pattern is not defined on textarea field: https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
|
|
2786
|
-
* @returns
|
|
2740
|
+
* @returns is pattern valid
|
|
2787
2741
|
*/
|
|
2788
2742
|
this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
|
|
2789
2743
|
/**
|
|
@@ -2843,7 +2797,7 @@ const MgInputTextarea = class {
|
|
|
2843
2797
|
this.valid = undefined;
|
|
2844
2798
|
this.invalid = undefined;
|
|
2845
2799
|
this.resizable = 'none';
|
|
2846
|
-
this.
|
|
2800
|
+
this.classCollection = new ClassList(['mg-input--textarea']);
|
|
2847
2801
|
this.errorMessage = undefined;
|
|
2848
2802
|
}
|
|
2849
2803
|
handleValue(newValue) {
|
|
@@ -2862,15 +2816,14 @@ const MgInputTextarea = class {
|
|
|
2862
2816
|
}
|
|
2863
2817
|
validateDisplayCharacterLeft(newValue) {
|
|
2864
2818
|
if (newValue) {
|
|
2865
|
-
this.
|
|
2819
|
+
this.classCollection.add(this.classHasDisplayCharacterLeft);
|
|
2866
2820
|
}
|
|
2867
2821
|
else {
|
|
2868
|
-
this.
|
|
2822
|
+
this.classCollection.delete(this.classHasDisplayCharacterLeft);
|
|
2869
2823
|
}
|
|
2870
2824
|
}
|
|
2871
2825
|
/**
|
|
2872
2826
|
* Public method to display errors
|
|
2873
|
-
* @returns {Promise<void>}
|
|
2874
2827
|
*/
|
|
2875
2828
|
async displayError() {
|
|
2876
2829
|
this.checkValidity();
|
|
@@ -2882,7 +2835,7 @@ const MgInputTextarea = class {
|
|
|
2882
2835
|
*************/
|
|
2883
2836
|
/**
|
|
2884
2837
|
* Check if component props are well configured on init
|
|
2885
|
-
* @returns
|
|
2838
|
+
* @returns timeout
|
|
2886
2839
|
*/
|
|
2887
2840
|
componentWillLoad() {
|
|
2888
2841
|
// Get locales
|
|
@@ -2900,10 +2853,10 @@ const MgInputTextarea = class {
|
|
|
2900
2853
|
}
|
|
2901
2854
|
/**
|
|
2902
2855
|
* Render
|
|
2903
|
-
* @returns
|
|
2856
|
+
* @returns HTML Element
|
|
2904
2857
|
*/
|
|
2905
2858
|
render() {
|
|
2906
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2859
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("div", { class: "mg-input__with-character-left" }, index.h("textarea", { class: {
|
|
2907
2860
|
'mg-input__box': true,
|
|
2908
2861
|
'mg-input__box--resizable': this.resizable === 'both',
|
|
2909
2862
|
'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
@@ -2947,7 +2900,6 @@ const MgInputTitle = class {
|
|
|
2947
2900
|
*************/
|
|
2948
2901
|
/**
|
|
2949
2902
|
* Init tag name
|
|
2950
|
-
* @returns {void}
|
|
2951
2903
|
*/
|
|
2952
2904
|
componentWillLoad() {
|
|
2953
2905
|
this.validateIdentifier(this.identifier);
|
|
@@ -2955,7 +2907,7 @@ const MgInputTitle = class {
|
|
|
2955
2907
|
}
|
|
2956
2908
|
/**
|
|
2957
2909
|
* Render
|
|
2958
|
-
* @returns
|
|
2910
|
+
* @returns HTML element
|
|
2959
2911
|
*/
|
|
2960
2912
|
render() {
|
|
2961
2913
|
const TagName = this.tagName;
|
|
@@ -2972,8 +2924,8 @@ const mgInputToggleCss = ":host{display:block}.mg-input{display:flex;align-items
|
|
|
2972
2924
|
|
|
2973
2925
|
/**
|
|
2974
2926
|
* type Option validation function
|
|
2975
|
-
* @param
|
|
2976
|
-
* @returns
|
|
2927
|
+
* @param option - radio option
|
|
2928
|
+
* @returns toggle option type is valid
|
|
2977
2929
|
*/
|
|
2978
2930
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
2979
2931
|
const MgInputToggle = class {
|
|
@@ -2992,14 +2944,12 @@ const MgInputToggle = class {
|
|
|
2992
2944
|
this.classIcon = 'mg-input--toggle-icon';
|
|
2993
2945
|
/**
|
|
2994
2946
|
* Change checked value
|
|
2995
|
-
* @returns {void}
|
|
2996
2947
|
*/
|
|
2997
2948
|
this.toggleChecked = () => {
|
|
2998
2949
|
this.checked = !this.checked;
|
|
2999
2950
|
};
|
|
3000
2951
|
/**
|
|
3001
2952
|
* Slots validation
|
|
3002
|
-
* @returns {void}
|
|
3003
2953
|
*/
|
|
3004
2954
|
this.validateSlots = () => {
|
|
3005
2955
|
const slots = Array.from(this.element.children);
|
|
@@ -3025,7 +2975,7 @@ const MgInputToggle = class {
|
|
|
3025
2975
|
this.disabled = false;
|
|
3026
2976
|
this.tooltip = undefined;
|
|
3027
2977
|
this.helpText = undefined;
|
|
3028
|
-
this.
|
|
2978
|
+
this.classCollection = new ClassList(['mg-input--toggle']);
|
|
3029
2979
|
this.options = undefined;
|
|
3030
2980
|
this.checked = false;
|
|
3031
2981
|
}
|
|
@@ -3053,40 +3003,39 @@ const MgInputToggle = class {
|
|
|
3053
3003
|
}
|
|
3054
3004
|
handleIsOnOff(newValue) {
|
|
3055
3005
|
if (newValue)
|
|
3056
|
-
this.
|
|
3006
|
+
this.classCollection.add(this.classOnOff);
|
|
3057
3007
|
else
|
|
3058
|
-
this.
|
|
3008
|
+
this.classCollection.delete(this.classOnOff);
|
|
3059
3009
|
}
|
|
3060
3010
|
handleIsIcon(newValue) {
|
|
3061
3011
|
if (newValue)
|
|
3062
|
-
this.
|
|
3012
|
+
this.classCollection.add(this.classIcon);
|
|
3063
3013
|
else
|
|
3064
|
-
this.
|
|
3014
|
+
this.classCollection.delete(this.classIcon);
|
|
3065
3015
|
}
|
|
3066
3016
|
handleReadonly(newValue) {
|
|
3067
3017
|
if (newValue)
|
|
3068
|
-
this.
|
|
3018
|
+
this.classCollection.add(this.classReadonly);
|
|
3069
3019
|
else
|
|
3070
|
-
this.
|
|
3020
|
+
this.classCollection.delete(this.classReadonly);
|
|
3071
3021
|
}
|
|
3072
3022
|
handleDisabled(newValue) {
|
|
3073
3023
|
if (newValue)
|
|
3074
|
-
this.
|
|
3024
|
+
this.classCollection.add(this.classDisabled);
|
|
3075
3025
|
else
|
|
3076
|
-
this.
|
|
3026
|
+
this.classCollection.delete(this.classDisabled);
|
|
3077
3027
|
}
|
|
3078
3028
|
handleChecked(newValue) {
|
|
3079
3029
|
// style
|
|
3080
3030
|
if (newValue)
|
|
3081
|
-
this.
|
|
3031
|
+
this.classCollection.add(this.classIsActive);
|
|
3082
3032
|
else
|
|
3083
|
-
this.
|
|
3033
|
+
this.classCollection.delete(this.classIsActive);
|
|
3084
3034
|
// update value
|
|
3085
3035
|
this.value = this.options[newValue ? 1 : 0].value;
|
|
3086
3036
|
}
|
|
3087
3037
|
/**
|
|
3088
3038
|
* set checked state
|
|
3089
|
-
* @returns {void}
|
|
3090
3039
|
*/
|
|
3091
3040
|
setChecked() {
|
|
3092
3041
|
const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);
|
|
@@ -3128,10 +3077,10 @@ const MgInputToggle = class {
|
|
|
3128
3077
|
}
|
|
3129
3078
|
/**
|
|
3130
3079
|
* Render
|
|
3131
|
-
* @returns
|
|
3080
|
+
* @returns HTML Element
|
|
3132
3081
|
*/
|
|
3133
3082
|
render() {
|
|
3134
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
3083
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, index.h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, index.h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, index.h("slot", { name: "item-1" })), index.h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, index.h("slot", { name: "item-2" })))));
|
|
3135
3084
|
}
|
|
3136
3085
|
get element() { return index.getElement(this); }
|
|
3137
3086
|
static get watchers() { return {
|
|
@@ -3162,9 +3111,8 @@ const MgMenu = class {
|
|
|
3162
3111
|
*************/
|
|
3163
3112
|
/**
|
|
3164
3113
|
* Close matching menu-item
|
|
3165
|
-
* @param
|
|
3166
|
-
* @param
|
|
3167
|
-
* @returns {void}
|
|
3114
|
+
* @param item - menu-item to close
|
|
3115
|
+
* @param condition - addionnal condition
|
|
3168
3116
|
*/
|
|
3169
3117
|
this.closeMenuItem = (item, condition) => {
|
|
3170
3118
|
if (!this.isChildMenu && condition) {
|
|
@@ -3173,19 +3121,18 @@ const MgMenu = class {
|
|
|
3173
3121
|
};
|
|
3174
3122
|
/**
|
|
3175
3123
|
* get mg-item-more element
|
|
3176
|
-
* @returns
|
|
3124
|
+
* @returns mg-item-more element
|
|
3177
3125
|
*/
|
|
3178
3126
|
this.getItemMore = () => this.element.querySelector('mg-item-more');
|
|
3179
3127
|
/**
|
|
3180
|
-
* get mg-item-more
|
|
3181
|
-
* @returns
|
|
3128
|
+
* get mg-item-more child mg-menu-item element
|
|
3129
|
+
* @returns mg-menu-item element
|
|
3182
3130
|
*/
|
|
3183
3131
|
this.getItemMoreMenuItem = () => { var _a, _b; return (_b = (_a = this.getItemMore()) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mg-menu-item'); };
|
|
3184
3132
|
/**
|
|
3185
3133
|
* Set item listend
|
|
3186
|
-
* @param
|
|
3187
|
-
* @param
|
|
3188
|
-
* @returns {void}
|
|
3134
|
+
* @param item - mg-menu-item element
|
|
3135
|
+
* @param index - number
|
|
3189
3136
|
*/
|
|
3190
3137
|
this.setItemListener = (item, index) => {
|
|
3191
3138
|
['click', 'focus'].forEach(trigger => {
|
|
@@ -3200,7 +3147,6 @@ const MgMenu = class {
|
|
|
3200
3147
|
};
|
|
3201
3148
|
/**
|
|
3202
3149
|
* Store menu-items on component init and add listeners
|
|
3203
|
-
* @returns {void}
|
|
3204
3150
|
*/
|
|
3205
3151
|
this.initMenuItemsListeners = () => {
|
|
3206
3152
|
// add listeners on menu item and edit index
|
|
@@ -3210,14 +3156,12 @@ const MgMenu = class {
|
|
|
3210
3156
|
};
|
|
3211
3157
|
/**
|
|
3212
3158
|
* Handle item-loaded event on mg-item-more element
|
|
3213
|
-
* @returns {void}
|
|
3214
3159
|
*/
|
|
3215
3160
|
this.handleItemLoaded = () => {
|
|
3216
3161
|
this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);
|
|
3217
3162
|
};
|
|
3218
3163
|
/**
|
|
3219
3164
|
* render mg-item-more
|
|
3220
|
-
* @returns {void}
|
|
3221
3165
|
*/
|
|
3222
3166
|
this.renderMgItemMore = () => {
|
|
3223
3167
|
// /!\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement
|
|
@@ -3259,7 +3203,6 @@ const MgMenu = class {
|
|
|
3259
3203
|
*************/
|
|
3260
3204
|
/**
|
|
3261
3205
|
* Validate props
|
|
3262
|
-
* @returns {void}
|
|
3263
3206
|
*/
|
|
3264
3207
|
componentWillLoad() {
|
|
3265
3208
|
this.validateDirection(this.direction);
|
|
@@ -3269,7 +3212,7 @@ const MgMenu = class {
|
|
|
3269
3212
|
}
|
|
3270
3213
|
/**
|
|
3271
3214
|
* Check if component slots configuration
|
|
3272
|
-
* @returns
|
|
3215
|
+
* @returns timeout
|
|
3273
3216
|
*/
|
|
3274
3217
|
componentDidLoad() {
|
|
3275
3218
|
// update props and states after componentDidLoad hook
|
|
@@ -3299,14 +3242,13 @@ const MgMenu = class {
|
|
|
3299
3242
|
}
|
|
3300
3243
|
/**
|
|
3301
3244
|
* Add listeners to items
|
|
3302
|
-
* @returns {void}
|
|
3303
3245
|
*/
|
|
3304
3246
|
componentDidRender() {
|
|
3305
3247
|
this.initMenuItemsListeners();
|
|
3306
3248
|
}
|
|
3307
3249
|
/**
|
|
3308
3250
|
* Render
|
|
3309
|
-
* @returns
|
|
3251
|
+
* @returns HTML Element
|
|
3310
3252
|
*/
|
|
3311
3253
|
render() {
|
|
3312
3254
|
return (index.h(index.Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, index.h("slot", null)));
|
|
@@ -3338,29 +3280,27 @@ const MgMenuItem = class {
|
|
|
3338
3280
|
**********/
|
|
3339
3281
|
/**
|
|
3340
3282
|
* Toggle expanded prop value
|
|
3341
|
-
* @returns {void}
|
|
3342
3283
|
*/
|
|
3343
3284
|
this.toggleExpanded = () => {
|
|
3344
3285
|
this.expanded = !this.expanded;
|
|
3345
3286
|
};
|
|
3346
3287
|
/**
|
|
3347
3288
|
* Does an Element have given Status
|
|
3348
|
-
* @param
|
|
3349
|
-
* @param
|
|
3350
|
-
* @returns
|
|
3289
|
+
* @param mgMenuItemElement - to parse
|
|
3290
|
+
* @param status - to check
|
|
3291
|
+
* @returns true if element with status is found
|
|
3351
3292
|
*/
|
|
3352
3293
|
this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
|
|
3353
3294
|
/**
|
|
3354
3295
|
* Is component contextual direction match the given direction
|
|
3355
|
-
* @param
|
|
3356
|
-
* @param
|
|
3357
|
-
* @returns
|
|
3296
|
+
* @param direction - in parent menu
|
|
3297
|
+
* @param compareWith - direction to compare with. Default: `this.direction`
|
|
3298
|
+
* @returns true is direction match the direction propertie
|
|
3358
3299
|
*/
|
|
3359
3300
|
this.isDirection = (direction, compareWith = this.direction) => direction === compareWith;
|
|
3360
3301
|
/**
|
|
3361
3302
|
* Update displayNotificationBadge
|
|
3362
3303
|
* current component notification badge have priority over the slot badge when submenu contain badge
|
|
3363
|
-
* @returns {void} update displayNotificationBadge value
|
|
3364
3304
|
*/
|
|
3365
3305
|
this.updateDisplayNotificationBadge = () => {
|
|
3366
3306
|
const childMenu = this.element.querySelector('mg-menu');
|
|
@@ -3370,7 +3310,7 @@ const MgMenuItem = class {
|
|
|
3370
3310
|
};
|
|
3371
3311
|
/**
|
|
3372
3312
|
* Method to control if one of component children have active status
|
|
3373
|
-
* @returns
|
|
3313
|
+
* @returns truthy if component has active child
|
|
3374
3314
|
*/
|
|
3375
3315
|
this.hasActiveChild = () => {
|
|
3376
3316
|
var _a;
|
|
@@ -3378,8 +3318,7 @@ const MgMenuItem = class {
|
|
|
3378
3318
|
};
|
|
3379
3319
|
/**
|
|
3380
3320
|
* Validate slots
|
|
3381
|
-
* @param
|
|
3382
|
-
* @returns {void}
|
|
3321
|
+
* @param guard - prevent action whith guard. Default: false.
|
|
3383
3322
|
*/
|
|
3384
3323
|
this.validateSlot = (guard = false) => {
|
|
3385
3324
|
// slot title AND metadata validation
|
|
@@ -3397,8 +3336,7 @@ const MgMenuItem = class {
|
|
|
3397
3336
|
};
|
|
3398
3337
|
/**
|
|
3399
3338
|
* Update status
|
|
3400
|
-
* @param
|
|
3401
|
-
* @returns {void}
|
|
3339
|
+
* @param guard - status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
3402
3340
|
*/
|
|
3403
3341
|
this.updateStatus = (guard = []) => {
|
|
3404
3342
|
if (![Status$1.HIDDEN, Status$1.DISABLED, ...guard].includes(this.status)) {
|
|
@@ -3407,7 +3345,6 @@ const MgMenuItem = class {
|
|
|
3407
3345
|
};
|
|
3408
3346
|
/**
|
|
3409
3347
|
* Init event-listeners
|
|
3410
|
-
* @returns {void}
|
|
3411
3348
|
*/
|
|
3412
3349
|
this.initListeners = () => {
|
|
3413
3350
|
var _a;
|
|
@@ -3423,12 +3360,12 @@ const MgMenuItem = class {
|
|
|
3423
3360
|
};
|
|
3424
3361
|
/**
|
|
3425
3362
|
* Get mg-popover identifier
|
|
3426
|
-
* @returns
|
|
3363
|
+
* @returns generated mg-popover identifier
|
|
3427
3364
|
*/
|
|
3428
3365
|
this.getPopoverIdentifier = () => `${this.identifier}-popover`;
|
|
3429
3366
|
/**
|
|
3430
3367
|
* Condition to know if component should display a mg-popover
|
|
3431
|
-
* @returns
|
|
3368
|
+
* @returns truthy if component display popover
|
|
3432
3369
|
*/
|
|
3433
3370
|
this.displayPopover = () => this.isDirection(mgMenu_conf.Direction.HORIZONTAL) && this.hasChildren && this.href === undefined;
|
|
3434
3371
|
/************
|
|
@@ -3436,8 +3373,7 @@ const MgMenuItem = class {
|
|
|
3436
3373
|
************/
|
|
3437
3374
|
/**
|
|
3438
3375
|
* Handle interacrtive element click
|
|
3439
|
-
* @param
|
|
3440
|
-
* @returns {void}
|
|
3376
|
+
* @param event - click on element
|
|
3441
3377
|
*/
|
|
3442
3378
|
this.handleElementCLick = (event) => {
|
|
3443
3379
|
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status$1.DISABLED) {
|
|
@@ -3450,15 +3386,14 @@ const MgMenuItem = class {
|
|
|
3450
3386
|
};
|
|
3451
3387
|
/**
|
|
3452
3388
|
* Handle popover element display-change event
|
|
3453
|
-
* @param
|
|
3454
|
-
* @returns {void}
|
|
3389
|
+
* @param event - popover display event
|
|
3455
3390
|
*/
|
|
3456
3391
|
this.handlePopoverDisplay = (event) => {
|
|
3457
3392
|
this.expanded = event.detail;
|
|
3458
3393
|
};
|
|
3459
3394
|
/**
|
|
3460
3395
|
* Render slot
|
|
3461
|
-
* @returns
|
|
3396
|
+
* @returns HTML Element
|
|
3462
3397
|
*/
|
|
3463
3398
|
this.renderSlot = () => index.h("slot", null);
|
|
3464
3399
|
this.identifier = createID('mg-menu-item');
|
|
@@ -3524,7 +3459,6 @@ const MgMenuItem = class {
|
|
|
3524
3459
|
}
|
|
3525
3460
|
/**
|
|
3526
3461
|
* Render popover clickoutside guard for content slot
|
|
3527
|
-
* @returns {void}
|
|
3528
3462
|
*/
|
|
3529
3463
|
updatePopoverGuard() {
|
|
3530
3464
|
if (this.displayPopover())
|
|
@@ -3537,7 +3471,6 @@ const MgMenuItem = class {
|
|
|
3537
3471
|
*************/
|
|
3538
3472
|
/**
|
|
3539
3473
|
* Validate props
|
|
3540
|
-
* @returns {void}
|
|
3541
3474
|
*/
|
|
3542
3475
|
componentWillLoad() {
|
|
3543
3476
|
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
@@ -3553,7 +3486,7 @@ const MgMenuItem = class {
|
|
|
3553
3486
|
}
|
|
3554
3487
|
/**
|
|
3555
3488
|
* Check if component slots configuration
|
|
3556
|
-
* @returns
|
|
3489
|
+
* @returns timeout
|
|
3557
3490
|
*/
|
|
3558
3491
|
componentDidLoad() {
|
|
3559
3492
|
// validation
|
|
@@ -3592,7 +3525,7 @@ const MgMenuItem = class {
|
|
|
3592
3525
|
}
|
|
3593
3526
|
/**
|
|
3594
3527
|
* Render ineractive element
|
|
3595
|
-
* @returns
|
|
3528
|
+
* @returns HTML Element
|
|
3596
3529
|
*/
|
|
3597
3530
|
renderInteractiveElement() {
|
|
3598
3531
|
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
@@ -3604,7 +3537,7 @@ const MgMenuItem = class {
|
|
|
3604
3537
|
}
|
|
3605
3538
|
/**
|
|
3606
3539
|
* Render
|
|
3607
|
-
* @returns
|
|
3540
|
+
* @returns HTML Element
|
|
3608
3541
|
*/
|
|
3609
3542
|
render() {
|
|
3610
3543
|
const getContainerClasses = () => ({
|
|
@@ -3653,22 +3586,19 @@ const MgMessage = class {
|
|
|
3653
3586
|
this.isHovered = false;
|
|
3654
3587
|
/**
|
|
3655
3588
|
* Set timer
|
|
3656
|
-
* @returns {void}
|
|
3657
3589
|
*/
|
|
3658
3590
|
this.setTimer = () => {
|
|
3659
3591
|
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
3660
3592
|
};
|
|
3661
3593
|
/**
|
|
3662
3594
|
* Clear timer
|
|
3663
|
-
* @returns {void}
|
|
3664
3595
|
*/
|
|
3665
3596
|
this.clearTimer = () => {
|
|
3666
3597
|
clearTimeout(this.storedTimer);
|
|
3667
3598
|
};
|
|
3668
3599
|
/**
|
|
3669
3600
|
* Event to add on element
|
|
3670
|
-
* @param
|
|
3671
|
-
* @returns {void}
|
|
3601
|
+
* @param event - event
|
|
3672
3602
|
*/
|
|
3673
3603
|
this.timerEvents = (event) => {
|
|
3674
3604
|
this.clearTimer();
|
|
@@ -3691,7 +3621,7 @@ const MgMessage = class {
|
|
|
3691
3621
|
};
|
|
3692
3622
|
/**
|
|
3693
3623
|
* Get icon corresponding to variant
|
|
3694
|
-
* @returns
|
|
3624
|
+
* @returns icon
|
|
3695
3625
|
*/
|
|
3696
3626
|
this.getIcon = () => {
|
|
3697
3627
|
switch (this.variant) {
|
|
@@ -3710,7 +3640,7 @@ const MgMessage = class {
|
|
|
3710
3640
|
this.variant = variants$1[0];
|
|
3711
3641
|
this.closeButton = false;
|
|
3712
3642
|
this.hide = false;
|
|
3713
|
-
this.
|
|
3643
|
+
this.classCollection = new ClassList(['mg-message']);
|
|
3714
3644
|
this.hasActions = false;
|
|
3715
3645
|
}
|
|
3716
3646
|
validateDelay(newValue) {
|
|
@@ -3724,9 +3654,9 @@ const MgMessage = class {
|
|
|
3724
3654
|
}
|
|
3725
3655
|
else {
|
|
3726
3656
|
if (oldValue !== undefined) {
|
|
3727
|
-
this.
|
|
3657
|
+
this.classCollection.delete(`mg-message--${oldValue}`);
|
|
3728
3658
|
}
|
|
3729
|
-
this.
|
|
3659
|
+
this.classCollection.add(`mg-message--${newValue}`);
|
|
3730
3660
|
}
|
|
3731
3661
|
}
|
|
3732
3662
|
validateCloseButton(newValue) {
|
|
@@ -3738,7 +3668,7 @@ const MgMessage = class {
|
|
|
3738
3668
|
validateHide(newValue) {
|
|
3739
3669
|
if (newValue) {
|
|
3740
3670
|
this.componentHide.emit();
|
|
3741
|
-
this.
|
|
3671
|
+
this.classCollection.add(this.classHide);
|
|
3742
3672
|
// Remove event Listener
|
|
3743
3673
|
['focusin', 'mouseenter'].forEach(event => {
|
|
3744
3674
|
this.element.removeEventListener(event, this.timerEvents);
|
|
@@ -3748,7 +3678,7 @@ const MgMessage = class {
|
|
|
3748
3678
|
}
|
|
3749
3679
|
else {
|
|
3750
3680
|
this.componentShow.emit();
|
|
3751
|
-
this.
|
|
3681
|
+
this.classCollection.delete(this.classHide);
|
|
3752
3682
|
// If delay is set
|
|
3753
3683
|
if (this.delay > 1) {
|
|
3754
3684
|
// Start timer
|
|
@@ -3775,7 +3705,7 @@ const MgMessage = class {
|
|
|
3775
3705
|
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
3776
3706
|
this.validateCloseButton(this.closeButton);
|
|
3777
3707
|
if (this.closeButton) {
|
|
3778
|
-
this.
|
|
3708
|
+
this.classCollection.add('mg-message--close-button');
|
|
3779
3709
|
this.closeButtonId = `${this.identifier}-close-button`;
|
|
3780
3710
|
}
|
|
3781
3711
|
this.validateDelay(this.delay);
|
|
@@ -3783,10 +3713,10 @@ const MgMessage = class {
|
|
|
3783
3713
|
}
|
|
3784
3714
|
/**
|
|
3785
3715
|
* Render
|
|
3786
|
-
* @returns
|
|
3716
|
+
* @returns HTML Element
|
|
3787
3717
|
*/
|
|
3788
3718
|
render() {
|
|
3789
|
-
return (index.h("div", { id: this.identifier, class: this.
|
|
3719
|
+
return (index.h("div", { id: this.identifier, class: this.classCollection.join(), role: this.variant === 'info' ? 'status' : 'alert' }, index.h("mg-card", { variant: this.variant, "variant-style": "bar-left" }, index.h("span", { class: "mg-message__icon" }, index.h("mg-icon", { icon: this.getIcon() })), index.h("div", { class: "mg-message__content" }, index.h("span", { class: "mg-message__content-slot" }, index.h("slot", null)), this.hasActions && index.h("span", { class: "mg-message__content-separator" }), this.hasActions && (index.h("span", { class: "mg-message__content-actions-slot" }, index.h("slot", { name: "actions" })))), this.closeButton && (index.h("span", { class: "mg-message__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" })))))));
|
|
3790
3720
|
}
|
|
3791
3721
|
get element() { return index.getElement(this); }
|
|
3792
3722
|
static get watchers() { return {
|
|
@@ -3846,7 +3776,6 @@ const MgModal = class {
|
|
|
3846
3776
|
*************/
|
|
3847
3777
|
/**
|
|
3848
3778
|
* Handle close button
|
|
3849
|
-
* @returns {void}
|
|
3850
3779
|
*/
|
|
3851
3780
|
this.handleClose = () => {
|
|
3852
3781
|
this.hide = true;
|
|
@@ -3857,7 +3786,7 @@ const MgModal = class {
|
|
|
3857
3786
|
this.hide = false;
|
|
3858
3787
|
this.hasActions = false;
|
|
3859
3788
|
this.hasContent = false;
|
|
3860
|
-
this.
|
|
3789
|
+
this.classCollection = new ClassList(['mg-modal']);
|
|
3861
3790
|
}
|
|
3862
3791
|
validateModalTitle(newValue) {
|
|
3863
3792
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -3867,19 +3796,18 @@ const MgModal = class {
|
|
|
3867
3796
|
validateHide(newValue) {
|
|
3868
3797
|
if (newValue) {
|
|
3869
3798
|
this.componentHide.emit();
|
|
3870
|
-
this.
|
|
3799
|
+
this.classCollection.add(this.classHide);
|
|
3871
3800
|
document.body.style.overflow = this.bodyOverflow;
|
|
3872
3801
|
}
|
|
3873
3802
|
else {
|
|
3874
3803
|
this.componentShow.emit();
|
|
3875
|
-
this.
|
|
3804
|
+
this.classCollection.delete(this.classHide);
|
|
3876
3805
|
document.body.style.overflow = 'hidden';
|
|
3877
3806
|
}
|
|
3878
3807
|
}
|
|
3879
3808
|
/**
|
|
3880
3809
|
* Handle 'escape' key down
|
|
3881
|
-
* @param
|
|
3882
|
-
* @returns {void}
|
|
3810
|
+
* @param event - keydown event
|
|
3883
3811
|
*/
|
|
3884
3812
|
handleKeyDown(event) {
|
|
3885
3813
|
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
@@ -3892,7 +3820,6 @@ const MgModal = class {
|
|
|
3892
3820
|
*************/
|
|
3893
3821
|
/**
|
|
3894
3822
|
* Check if component props are well configured on init
|
|
3895
|
-
* @returns {void}
|
|
3896
3823
|
*/
|
|
3897
3824
|
componentWillLoad() {
|
|
3898
3825
|
// Store body overflow
|
|
@@ -3911,7 +3838,6 @@ const MgModal = class {
|
|
|
3911
3838
|
}
|
|
3912
3839
|
/**
|
|
3913
3840
|
* Add observer on component to set focus when displayed
|
|
3914
|
-
* @returns {void}
|
|
3915
3841
|
*/
|
|
3916
3842
|
componentDidLoad() {
|
|
3917
3843
|
new MutationObserver(mutationList => {
|
|
@@ -3926,10 +3852,10 @@ const MgModal = class {
|
|
|
3926
3852
|
}
|
|
3927
3853
|
/**
|
|
3928
3854
|
* Render
|
|
3929
|
-
* @returns
|
|
3855
|
+
* @returns HTML Element
|
|
3930
3856
|
*/
|
|
3931
3857
|
render() {
|
|
3932
|
-
return (index.h("div", { role: "alertdialog", id: this.identifier, class: this.
|
|
3858
|
+
return (index.h("div", { role: "alertdialog", id: this.identifier, class: this.classCollection.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, index.h("mg-card", null, index.h("div", { class: "mg-modal__dialog" }, index.h("header", { class: "mg-modal__header" }, this.closeButton && (index.h("span", { class: "mg-modal__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" })))), index.h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (index.h("article", { class: "mg-modal__content" }, index.h("slot", { name: "content" }))), this.hasActions && (index.h("footer", { class: "mg-modal__footer" }, index.h("slot", { name: "actions" })))))));
|
|
3933
3859
|
}
|
|
3934
3860
|
get element() { return index.getElement(this); }
|
|
3935
3861
|
static get watchers() { return {
|
|
@@ -3950,6 +3876,7 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
3950
3876
|
/**
|
|
3951
3877
|
* Range generator
|
|
3952
3878
|
*
|
|
3879
|
+
* ```
|
|
3953
3880
|
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
3954
3881
|
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
3955
3882
|
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
@@ -3957,14 +3884,15 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
3957
3884
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
3958
3885
|
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
3959
3886
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
3887
|
+
* ```
|
|
3960
3888
|
*
|
|
3961
3889
|
* range(1, 1) = [1]
|
|
3962
3890
|
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
3963
3891
|
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
3964
|
-
* @param
|
|
3965
|
-
* @param
|
|
3966
|
-
* @param
|
|
3967
|
-
* @returns
|
|
3892
|
+
* @param start - start range
|
|
3893
|
+
* @param end - start end
|
|
3894
|
+
* @param step - step size
|
|
3895
|
+
* @returns range numbers
|
|
3968
3896
|
*/
|
|
3969
3897
|
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
3970
3898
|
const MgPagination = class {
|
|
@@ -3973,8 +3901,7 @@ const MgPagination = class {
|
|
|
3973
3901
|
this.currentPageChange = index.createEvent(this, "current-page-change", 7);
|
|
3974
3902
|
/**
|
|
3975
3903
|
* Change current page from target
|
|
3976
|
-
* @param
|
|
3977
|
-
* @returns {void}
|
|
3904
|
+
* @param target - target page
|
|
3978
3905
|
*/
|
|
3979
3906
|
this.goToPage = (target) => {
|
|
3980
3907
|
this.currentPage = target;
|
|
@@ -3984,8 +3911,7 @@ const MgPagination = class {
|
|
|
3984
3911
|
************/
|
|
3985
3912
|
/**
|
|
3986
3913
|
* select handler
|
|
3987
|
-
* @param
|
|
3988
|
-
* @returns {void}
|
|
3914
|
+
* @param event - value change event
|
|
3989
3915
|
*/
|
|
3990
3916
|
this.handleSelect = (event) => {
|
|
3991
3917
|
const to = Number(event.target.value);
|
|
@@ -3993,9 +3919,8 @@ const MgPagination = class {
|
|
|
3993
3919
|
};
|
|
3994
3920
|
/**
|
|
3995
3921
|
* Go to 'previous/next' page button handler
|
|
3996
|
-
* @param
|
|
3997
|
-
* @param
|
|
3998
|
-
* @returns {void}
|
|
3922
|
+
* @param action - navigation action
|
|
3923
|
+
* @param disabled - button disable state
|
|
3999
3924
|
*/
|
|
4000
3925
|
this.handleGoToPage = (action, disabled) => {
|
|
4001
3926
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
@@ -4025,7 +3950,6 @@ const MgPagination = class {
|
|
|
4025
3950
|
*************/
|
|
4026
3951
|
/**
|
|
4027
3952
|
* Check if props are well configured on init
|
|
4028
|
-
* @returns {void}
|
|
4029
3953
|
*/
|
|
4030
3954
|
componentWillLoad() {
|
|
4031
3955
|
// Get locales
|
|
@@ -4040,7 +3964,7 @@ const MgPagination = class {
|
|
|
4040
3964
|
}
|
|
4041
3965
|
/**
|
|
4042
3966
|
* Render
|
|
4043
|
-
* @returns
|
|
3967
|
+
* @returns HTML Element
|
|
4044
3968
|
*/
|
|
4045
3969
|
render() {
|
|
4046
3970
|
const navigationActionButton = (disabled, action) => (index.h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
|
|
@@ -4068,7 +3992,6 @@ const MgPanel = class {
|
|
|
4068
3992
|
************/
|
|
4069
3993
|
/**
|
|
4070
3994
|
* Toggle is editing state
|
|
4071
|
-
* @returns {void}
|
|
4072
3995
|
*/
|
|
4073
3996
|
this.toggleIsEditing = () => {
|
|
4074
3997
|
this.isEditing = !this.isEditing;
|
|
@@ -4078,7 +4001,6 @@ const MgPanel = class {
|
|
|
4078
4001
|
************/
|
|
4079
4002
|
/**
|
|
4080
4003
|
* Collapse button click handler
|
|
4081
|
-
* @returns {void}
|
|
4082
4004
|
*/
|
|
4083
4005
|
this.handleCollapseButton = () => {
|
|
4084
4006
|
if (!this.expandToggleDisabled) {
|
|
@@ -4087,22 +4009,19 @@ const MgPanel = class {
|
|
|
4087
4009
|
};
|
|
4088
4010
|
/**
|
|
4089
4011
|
* Edit button click handler
|
|
4090
|
-
* @returns {void}
|
|
4091
4012
|
*/
|
|
4092
4013
|
this.handleEditButton = () => {
|
|
4093
4014
|
this.toggleIsEditing();
|
|
4094
4015
|
};
|
|
4095
4016
|
/**
|
|
4096
4017
|
* Update title handler
|
|
4097
|
-
* @param
|
|
4098
|
-
* @returns {void}
|
|
4018
|
+
* @param event - input value change event
|
|
4099
4019
|
*/
|
|
4100
4020
|
this.handleUpdateTitle = (event) => {
|
|
4101
4021
|
this.updatedPanelTitle = event.detail;
|
|
4102
4022
|
};
|
|
4103
4023
|
/**
|
|
4104
4024
|
* Cancel edition button handler
|
|
4105
|
-
* @returns {void}
|
|
4106
4025
|
*/
|
|
4107
4026
|
this.handleCancelEditButton = () => {
|
|
4108
4027
|
this.updatedPanelTitle = undefined;
|
|
@@ -4110,7 +4029,6 @@ const MgPanel = class {
|
|
|
4110
4029
|
};
|
|
4111
4030
|
/**
|
|
4112
4031
|
* Validate edition button handler
|
|
4113
|
-
* @returns {void}
|
|
4114
4032
|
*/
|
|
4115
4033
|
this.handleValidateEditButton = () => {
|
|
4116
4034
|
if (this.editInputElement.valid) {
|
|
@@ -4121,8 +4039,7 @@ const MgPanel = class {
|
|
|
4121
4039
|
};
|
|
4122
4040
|
/**
|
|
4123
4041
|
* Header left conditional render
|
|
4124
|
-
* @
|
|
4125
|
-
* @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
|
|
4042
|
+
* @returns header left element
|
|
4126
4043
|
*/
|
|
4127
4044
|
this.headerLeft = () => {
|
|
4128
4045
|
const collapseButton = () => (index.h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", identifier: `${this.identifier}-collapse-button`, "aria-expanded": this.expanded !== undefined && this.expanded.toString(), "aria-controls": `${this.identifier}-content`, disabled: this.expandToggleDisabled }, index.h("span", { class: "mg-panel__collapse-button-content" }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle)));
|
|
@@ -4147,7 +4064,7 @@ const MgPanel = class {
|
|
|
4147
4064
|
this.expanded = false;
|
|
4148
4065
|
this.expandToggleDisabled = undefined;
|
|
4149
4066
|
this.titleEditable = false;
|
|
4150
|
-
this.
|
|
4067
|
+
this.classCollection = new ClassList(['mg-panel']);
|
|
4151
4068
|
this.isEditing = false;
|
|
4152
4069
|
this.updatedPanelTitle = undefined;
|
|
4153
4070
|
}
|
|
@@ -4173,7 +4090,6 @@ const MgPanel = class {
|
|
|
4173
4090
|
*************/
|
|
4174
4091
|
/**
|
|
4175
4092
|
* Check if props are well configured on init
|
|
4176
|
-
* @returns {void}
|
|
4177
4093
|
*/
|
|
4178
4094
|
componentWillLoad() {
|
|
4179
4095
|
// Get locales
|
|
@@ -4184,7 +4100,6 @@ const MgPanel = class {
|
|
|
4184
4100
|
}
|
|
4185
4101
|
/**
|
|
4186
4102
|
* Edit DOM after render
|
|
4187
|
-
* @returns {void}
|
|
4188
4103
|
*/
|
|
4189
4104
|
componentDidRender() {
|
|
4190
4105
|
// when we are editing we get focus on edition input
|
|
@@ -4194,10 +4109,10 @@ const MgPanel = class {
|
|
|
4194
4109
|
}
|
|
4195
4110
|
/**
|
|
4196
4111
|
* Render component
|
|
4197
|
-
* @returns
|
|
4112
|
+
* @returns html element
|
|
4198
4113
|
*/
|
|
4199
4114
|
render() {
|
|
4200
|
-
return (index.h("section", { class: this.
|
|
4115
|
+
return (index.h("section", { class: this.classCollection.join(), id: this.identifier }, index.h("mg-card", null, index.h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, index.h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), index.h("div", { class: "mg-panel__header-right" }, index.h("slot", { name: "header-right" }))), index.h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, index.h("slot", null)))));
|
|
4201
4116
|
}
|
|
4202
4117
|
get element() { return index.getElement(this); }
|
|
4203
4118
|
static get watchers() { return {
|
|
@@ -6016,8 +5931,7 @@ const MgPopover = class {
|
|
|
6016
5931
|
this.classArrowHide = `mg-popover--arrow-hide`;
|
|
6017
5932
|
/**
|
|
6018
5933
|
* Check if clicked outside of component
|
|
6019
|
-
* @param
|
|
6020
|
-
* @returns {void}
|
|
5934
|
+
* @param event - mouse event
|
|
6021
5935
|
*/
|
|
6022
5936
|
this.clickOutside = (event) => {
|
|
6023
5937
|
var _a;
|
|
@@ -6029,7 +5943,6 @@ const MgPopover = class {
|
|
|
6029
5943
|
};
|
|
6030
5944
|
/**
|
|
6031
5945
|
* Show popover
|
|
6032
|
-
* @returns {void}
|
|
6033
5946
|
*/
|
|
6034
5947
|
this.show = () => {
|
|
6035
5948
|
// Make the popover visible
|
|
@@ -6048,7 +5961,6 @@ const MgPopover = class {
|
|
|
6048
5961
|
};
|
|
6049
5962
|
/**
|
|
6050
5963
|
* Hide popover
|
|
6051
|
-
* @returns {void}
|
|
6052
5964
|
*/
|
|
6053
5965
|
this.hide = () => {
|
|
6054
5966
|
// Hide the popover
|
|
@@ -6062,7 +5974,6 @@ const MgPopover = class {
|
|
|
6062
5974
|
};
|
|
6063
5975
|
/**
|
|
6064
5976
|
* Handle action for close button
|
|
6065
|
-
* @returns {void}
|
|
6066
5977
|
*/
|
|
6067
5978
|
this.handleCloseButton = () => {
|
|
6068
5979
|
this.display = false;
|
|
@@ -6073,13 +5984,13 @@ const MgPopover = class {
|
|
|
6073
5984
|
this.closeButton = false;
|
|
6074
5985
|
this.display = false;
|
|
6075
5986
|
this.disabled = false;
|
|
6076
|
-
this.
|
|
5987
|
+
this.classCollection = new ClassList(['mg-popover']);
|
|
6077
5988
|
}
|
|
6078
5989
|
validateArrowHide(newValue) {
|
|
6079
5990
|
if (newValue)
|
|
6080
|
-
this.
|
|
5991
|
+
this.classCollection.add(this.classArrowHide);
|
|
6081
5992
|
else
|
|
6082
|
-
this.
|
|
5993
|
+
this.classCollection.delete(this.classArrowHide);
|
|
6083
5994
|
}
|
|
6084
5995
|
handleDisplay(newValue) {
|
|
6085
5996
|
if (newValue) {
|
|
@@ -6095,7 +6006,6 @@ const MgPopover = class {
|
|
|
6095
6006
|
*************/
|
|
6096
6007
|
/**
|
|
6097
6008
|
* Check if component props are well configured on init
|
|
6098
|
-
* @returns {void} timeout
|
|
6099
6009
|
*/
|
|
6100
6010
|
componentWillLoad() {
|
|
6101
6011
|
// Get windows to attach events
|
|
@@ -6106,7 +6016,6 @@ const MgPopover = class {
|
|
|
6106
6016
|
}
|
|
6107
6017
|
/**
|
|
6108
6018
|
* Check if component props are well configured on init
|
|
6109
|
-
* @returns {void}
|
|
6110
6019
|
*/
|
|
6111
6020
|
componentDidLoad() {
|
|
6112
6021
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -6163,10 +6072,10 @@ const MgPopover = class {
|
|
|
6163
6072
|
}
|
|
6164
6073
|
/**
|
|
6165
6074
|
* Render
|
|
6166
|
-
* @returns
|
|
6075
|
+
* @returns HTML Element
|
|
6167
6076
|
*/
|
|
6168
6077
|
render() {
|
|
6169
|
-
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: this.
|
|
6078
|
+
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: this.classCollection.join() }, index.h("mg-card", null, this.closeButton && (index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, index.h("mg-icon", { icon: "cross" }))), index.h("div", { class: "mg-popover__title" }, index.h("slot", { name: "title" })), index.h("slot", { name: "content" })), !this.arrowHide && index.h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
6170
6079
|
}
|
|
6171
6080
|
get element() { return index.getElement(this); }
|
|
6172
6081
|
static get watchers() { return {
|
|
@@ -6187,8 +6096,7 @@ const MgSkipLinks = class {
|
|
|
6187
6096
|
**********/
|
|
6188
6097
|
/**
|
|
6189
6098
|
* Handle link click and emit go-to-anchor event
|
|
6190
|
-
* @param
|
|
6191
|
-
* @returns {void}
|
|
6099
|
+
* @param event - mouse event
|
|
6192
6100
|
*/
|
|
6193
6101
|
this.handleLinkCLick = (event) => {
|
|
6194
6102
|
event.currentTarget.blur();
|
|
@@ -6208,7 +6116,6 @@ const MgSkipLinks = class {
|
|
|
6208
6116
|
*************/
|
|
6209
6117
|
/**
|
|
6210
6118
|
* Check if props are well configured on init
|
|
6211
|
-
* @returns {void}
|
|
6212
6119
|
*/
|
|
6213
6120
|
componentWillLoad() {
|
|
6214
6121
|
this.validateLinks(this.links);
|
|
@@ -6216,7 +6123,7 @@ const MgSkipLinks = class {
|
|
|
6216
6123
|
}
|
|
6217
6124
|
/**
|
|
6218
6125
|
* Render
|
|
6219
|
-
* @returns
|
|
6126
|
+
* @returns HTML Element
|
|
6220
6127
|
*/
|
|
6221
6128
|
render() {
|
|
6222
6129
|
return (index.h("nav", { class: "mg-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, index.h("ul", { class: "mg-skip-links__list", role: "list" }, this.links.map(link => (index.h("li", { key: link.href }, index.h("a", { class: "mg-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
|
|
@@ -6247,8 +6154,8 @@ const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.m
|
|
|
6247
6154
|
|
|
6248
6155
|
/**
|
|
6249
6156
|
* type TabItem validation function
|
|
6250
|
-
* @param
|
|
6251
|
-
* @returns
|
|
6157
|
+
* @param tab - tab item
|
|
6158
|
+
* @returns tab item type is valid
|
|
6252
6159
|
*/
|
|
6253
6160
|
const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
|
|
6254
6161
|
const MgTabs = class {
|
|
@@ -6264,32 +6171,32 @@ const MgTabs = class {
|
|
|
6264
6171
|
this.startIndex = 1;
|
|
6265
6172
|
/**
|
|
6266
6173
|
* Method to know if given tab has the given status
|
|
6267
|
-
* @param
|
|
6268
|
-
* @param
|
|
6269
|
-
* @returns
|
|
6174
|
+
* @param tab - item tab key to set to ACTIVE status
|
|
6175
|
+
* @param status - status to valide
|
|
6176
|
+
* @returns status comparaison
|
|
6270
6177
|
*/
|
|
6271
6178
|
this.tabHasStatus = (tab, status) => tab.status === status;
|
|
6272
6179
|
/**
|
|
6273
6180
|
* Method to get element id from index
|
|
6274
|
-
* @param
|
|
6275
|
-
* @param
|
|
6276
|
-
* @returns
|
|
6181
|
+
* @param element - to get id
|
|
6182
|
+
* @param index - to generate id
|
|
6183
|
+
* @returns generated element id
|
|
6277
6184
|
*/
|
|
6278
6185
|
this.getElementId = (element, index) => `${element}-${this.getTabItemIndex(index)}`;
|
|
6279
6186
|
/**
|
|
6280
6187
|
* Method to get tab item index
|
|
6281
|
-
* @param
|
|
6282
|
-
* @returns
|
|
6188
|
+
* @param index - to get
|
|
6189
|
+
* @returns index
|
|
6283
6190
|
*/
|
|
6284
6191
|
this.getTabItemIndex = (index) => index + this.startIndex;
|
|
6285
6192
|
/**
|
|
6286
6193
|
* Method to get the active-tab value
|
|
6287
|
-
* @returns
|
|
6194
|
+
* @returns of the active-tab
|
|
6288
6195
|
*/
|
|
6289
6196
|
this.getActiveTab = () => this.activeTab || this.getTabItemIndex(this.tabs.map((tab, index) => (Object.assign(Object.assign({}, tab), { index }))).find(tab => this.tabHasStatus(tab, Status.ACTIVE)).index);
|
|
6290
6197
|
/**
|
|
6291
6198
|
* Handle click events on tabs
|
|
6292
|
-
* @param
|
|
6199
|
+
* @param event - mouse event
|
|
6293
6200
|
*/
|
|
6294
6201
|
this.handleClick = (event) => {
|
|
6295
6202
|
const tabId = event.currentTarget.dataset.index;
|
|
@@ -6304,14 +6211,13 @@ const MgTabs = class {
|
|
|
6304
6211
|
};
|
|
6305
6212
|
/**
|
|
6306
6213
|
* get navigation button class from given status
|
|
6307
|
-
* @param
|
|
6308
|
-
* @returns
|
|
6214
|
+
* @param status - button tab status
|
|
6215
|
+
* @returns button class/selector variant
|
|
6309
6216
|
*/
|
|
6310
6217
|
this.getNavigationButtonClass = (status) => `${this.buttonTabBaseClass}--${status}`;
|
|
6311
6218
|
/**
|
|
6312
6219
|
* Handle keyboard event on tabs
|
|
6313
|
-
* @param
|
|
6314
|
-
* @returns {void}
|
|
6220
|
+
* @param event - mouse event
|
|
6315
6221
|
*/
|
|
6316
6222
|
this.handleKeydown = (event) => {
|
|
6317
6223
|
const parent = event.target.parentElement;
|
|
@@ -6349,7 +6255,6 @@ const MgTabs = class {
|
|
|
6349
6255
|
};
|
|
6350
6256
|
/**
|
|
6351
6257
|
* Method to reset focus behavior
|
|
6352
|
-
* @returns {void}
|
|
6353
6258
|
*/
|
|
6354
6259
|
this.resetFocus = () => {
|
|
6355
6260
|
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
@@ -6374,7 +6279,7 @@ const MgTabs = class {
|
|
|
6374
6279
|
this.items = undefined;
|
|
6375
6280
|
this.activeTab = undefined;
|
|
6376
6281
|
this.tabs = [];
|
|
6377
|
-
this.
|
|
6282
|
+
this.classCollection = new ClassList(['mg-tabs']);
|
|
6378
6283
|
}
|
|
6379
6284
|
validateLabel(newValue) {
|
|
6380
6285
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -6385,7 +6290,7 @@ const MgTabs = class {
|
|
|
6385
6290
|
if (!sizes.includes(newValue)) {
|
|
6386
6291
|
throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
6387
6292
|
}
|
|
6388
|
-
this.
|
|
6293
|
+
this.classCollection.add(`mg-tabs--size-${this.size}`);
|
|
6389
6294
|
}
|
|
6390
6295
|
validateItems(newValue) {
|
|
6391
6296
|
// String array
|
|
@@ -6428,7 +6333,6 @@ const MgTabs = class {
|
|
|
6428
6333
|
*************/
|
|
6429
6334
|
/**
|
|
6430
6335
|
* Check if component props are well configured on init
|
|
6431
|
-
* @returns {void}
|
|
6432
6336
|
*/
|
|
6433
6337
|
componentWillLoad() {
|
|
6434
6338
|
// Check tabs format
|
|
@@ -6440,7 +6344,6 @@ const MgTabs = class {
|
|
|
6440
6344
|
}
|
|
6441
6345
|
/**
|
|
6442
6346
|
* add listners
|
|
6443
|
-
* @returns {void}
|
|
6444
6347
|
*/
|
|
6445
6348
|
componentDidLoad() {
|
|
6446
6349
|
document.addEventListener('click', (event) => {
|
|
@@ -6450,10 +6353,10 @@ const MgTabs = class {
|
|
|
6450
6353
|
}
|
|
6451
6354
|
/**
|
|
6452
6355
|
* Render
|
|
6453
|
-
* @returns
|
|
6356
|
+
* @returns HTML Element
|
|
6454
6357
|
*/
|
|
6455
6358
|
render() {
|
|
6456
|
-
return (index.h("div", { class: this.
|
|
6359
|
+
return (index.h("div", { class: this.classCollection.join() }, index.h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index$1) => (index.h("button", { key: tab.label, role: "tab", id: this.getElementId(this.identifier, index$1), class: {
|
|
6457
6360
|
[`${this.buttonTabBaseClass}`]: true,
|
|
6458
6361
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
6459
6362
|
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|
|
@@ -6490,7 +6393,7 @@ const MgTag = class {
|
|
|
6490
6393
|
this.variant = variants[0];
|
|
6491
6394
|
this.outline = undefined;
|
|
6492
6395
|
this.soft = undefined;
|
|
6493
|
-
this.
|
|
6396
|
+
this.classCollection = new ClassList(['mg-tag']);
|
|
6494
6397
|
}
|
|
6495
6398
|
validateVariant(newValue, oldValue) {
|
|
6496
6399
|
if (!variants.includes(newValue)) {
|
|
@@ -6498,16 +6401,16 @@ const MgTag = class {
|
|
|
6498
6401
|
}
|
|
6499
6402
|
else {
|
|
6500
6403
|
if (oldValue !== undefined) {
|
|
6501
|
-
this.
|
|
6404
|
+
this.classCollection.delete(`mg-tag--${oldValue}`);
|
|
6502
6405
|
}
|
|
6503
|
-
this.
|
|
6406
|
+
this.classCollection.add(`mg-tag--${newValue}`);
|
|
6504
6407
|
}
|
|
6505
6408
|
}
|
|
6506
6409
|
validateOutline(newValue) {
|
|
6507
6410
|
if (newValue)
|
|
6508
|
-
this.
|
|
6411
|
+
this.classCollection.add(this.classOutline);
|
|
6509
6412
|
else
|
|
6510
|
-
this.
|
|
6413
|
+
this.classCollection.delete(this.classOutline);
|
|
6511
6414
|
}
|
|
6512
6415
|
validateSoft(newValue) {
|
|
6513
6416
|
// usage validation
|
|
@@ -6515,17 +6418,16 @@ const MgTag = class {
|
|
|
6515
6418
|
throw new Error('<mg-tag> prop "soft" can NOT be used with prop "outline".');
|
|
6516
6419
|
// apply class
|
|
6517
6420
|
if (newValue)
|
|
6518
|
-
this.
|
|
6421
|
+
this.classCollection.add(this.classSoft);
|
|
6519
6422
|
else
|
|
6520
|
-
this.
|
|
6423
|
+
this.classCollection.delete(this.classSoft);
|
|
6521
6424
|
}
|
|
6522
6425
|
/*************
|
|
6523
6426
|
* Methods *
|
|
6524
6427
|
*************/
|
|
6525
6428
|
/**
|
|
6526
6429
|
* Validate the given textContent
|
|
6527
|
-
* @param
|
|
6528
|
-
* @returns {void}
|
|
6430
|
+
* @param textContent - html element textContent property
|
|
6529
6431
|
*/
|
|
6530
6432
|
validateTextContent(textContent) {
|
|
6531
6433
|
if (typeof textContent !== 'string' || textContent.trim() === '')
|
|
@@ -6536,7 +6438,6 @@ const MgTag = class {
|
|
|
6536
6438
|
*************/
|
|
6537
6439
|
/**
|
|
6538
6440
|
* Check if props are well configured on init
|
|
6539
|
-
* @returns {void}
|
|
6540
6441
|
*/
|
|
6541
6442
|
componentWillLoad() {
|
|
6542
6443
|
this.validateVariant(this.variant);
|
|
@@ -6546,10 +6447,10 @@ const MgTag = class {
|
|
|
6546
6447
|
}
|
|
6547
6448
|
/**
|
|
6548
6449
|
* Render
|
|
6549
|
-
* @returns
|
|
6450
|
+
* @returns HTML Element
|
|
6550
6451
|
*/
|
|
6551
6452
|
render() {
|
|
6552
|
-
return (index.h("span", { class: this.
|
|
6453
|
+
return (index.h("span", { class: this.classCollection.join() }, index.h("slot", null)));
|
|
6553
6454
|
}
|
|
6554
6455
|
get element() { return index.getElement(this); }
|
|
6555
6456
|
static get watchers() { return {
|
|
@@ -6574,7 +6475,6 @@ const MgTooltip = class {
|
|
|
6574
6475
|
index.registerInstance(this, hostRef);
|
|
6575
6476
|
/**
|
|
6576
6477
|
* Show tooltip
|
|
6577
|
-
* @returns {void}
|
|
6578
6478
|
*/
|
|
6579
6479
|
this.show = () => {
|
|
6580
6480
|
// Make the tooltip visible
|
|
@@ -6594,7 +6494,6 @@ const MgTooltip = class {
|
|
|
6594
6494
|
};
|
|
6595
6495
|
/**
|
|
6596
6496
|
* Hide tooltip
|
|
6597
|
-
* @returns {void}
|
|
6598
6497
|
*/
|
|
6599
6498
|
this.hide = () => {
|
|
6600
6499
|
// Hide the tooltip
|
|
@@ -6609,8 +6508,7 @@ const MgTooltip = class {
|
|
|
6609
6508
|
};
|
|
6610
6509
|
/**
|
|
6611
6510
|
* Check if clicked outside of component and hidde tooltip
|
|
6612
|
-
* @param
|
|
6613
|
-
* @returns {void}
|
|
6511
|
+
* @param event - mouse event
|
|
6614
6512
|
*/
|
|
6615
6513
|
this.clickOutside = (event) => {
|
|
6616
6514
|
if (event.target.closest('mg-tooltip') !== this.element)
|
|
@@ -6618,8 +6516,7 @@ const MgTooltip = class {
|
|
|
6618
6516
|
};
|
|
6619
6517
|
/**
|
|
6620
6518
|
* Check if 'Escape' key is pressed of component and hidde tooltip
|
|
6621
|
-
* @param
|
|
6622
|
-
* @returns {void}
|
|
6519
|
+
* @param event - keyboard event
|
|
6623
6520
|
*/
|
|
6624
6521
|
this.pressEscape = (event) => {
|
|
6625
6522
|
if (event.code === 'Escape')
|
|
@@ -6627,9 +6524,8 @@ const MgTooltip = class {
|
|
|
6627
6524
|
};
|
|
6628
6525
|
/**
|
|
6629
6526
|
* Method to set display prop
|
|
6630
|
-
* @param
|
|
6631
|
-
* @param
|
|
6632
|
-
* @returns {void}
|
|
6527
|
+
* @param newValue - display prop new value
|
|
6528
|
+
* @param condition - additionnal condition to apply display prop newValue
|
|
6633
6529
|
*/
|
|
6634
6530
|
this.setDisplay = (newValue, condition = true) => {
|
|
6635
6531
|
if (!this.disabled && condition)
|
|
@@ -6637,10 +6533,9 @@ const MgTooltip = class {
|
|
|
6637
6533
|
};
|
|
6638
6534
|
/**
|
|
6639
6535
|
* Action for tooltip element and tooltiped element mouse listener
|
|
6640
|
-
* @param
|
|
6641
|
-
* @param
|
|
6642
|
-
* @param
|
|
6643
|
-
* @returns {void}
|
|
6536
|
+
* @param elementGuard - tooltip element guard
|
|
6537
|
+
* @param isMouseenter - mouseenter validation
|
|
6538
|
+
* @param conditionalGuard - guard condition
|
|
6644
6539
|
*/
|
|
6645
6540
|
this.tooltipMouseListenerAction = (elementGuard, isMouseenter, conditionalGuard) => {
|
|
6646
6541
|
// we mutate elementGuard
|
|
@@ -6659,15 +6554,13 @@ const MgTooltip = class {
|
|
|
6659
6554
|
};
|
|
6660
6555
|
/**
|
|
6661
6556
|
* Method to reset guard value
|
|
6662
|
-
* @returns {void}
|
|
6663
6557
|
*/
|
|
6664
6558
|
this.resetGuard = () => {
|
|
6665
6559
|
this.guard = undefined;
|
|
6666
6560
|
};
|
|
6667
6561
|
/**
|
|
6668
6562
|
* Update slot content when it is a mg-button
|
|
6669
|
-
* @param
|
|
6670
|
-
* @returns {void}
|
|
6563
|
+
* @param mgButton - slotted mg-button
|
|
6671
6564
|
*/
|
|
6672
6565
|
this.setMgButtonWrapper = (mgButton) => {
|
|
6673
6566
|
if (mgButton.disabled) {
|
|
@@ -6684,8 +6577,8 @@ const MgTooltip = class {
|
|
|
6684
6577
|
};
|
|
6685
6578
|
/**
|
|
6686
6579
|
* Init tooltip
|
|
6687
|
-
* @param
|
|
6688
|
-
* @param
|
|
6580
|
+
* @param slotElement - slotted element
|
|
6581
|
+
* @param interactiveElement - interactive element
|
|
6689
6582
|
*/
|
|
6690
6583
|
this.initTooltip = (slotElement, interactiveElement) => {
|
|
6691
6584
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
@@ -6761,7 +6654,6 @@ const MgTooltip = class {
|
|
|
6761
6654
|
*************/
|
|
6762
6655
|
/**
|
|
6763
6656
|
* set variables
|
|
6764
|
-
* @returns {void}
|
|
6765
6657
|
*/
|
|
6766
6658
|
componentWillLoad() {
|
|
6767
6659
|
// Get windows to attach events
|
|
@@ -6771,7 +6663,6 @@ const MgTooltip = class {
|
|
|
6771
6663
|
* Get slotted element
|
|
6772
6664
|
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
6773
6665
|
* We need to attach the focused element to the tooltip (aria-describedby)
|
|
6774
|
-
* @returns {void}
|
|
6775
6666
|
*/
|
|
6776
6667
|
componentDidLoad() {
|
|
6777
6668
|
var _a;
|
|
@@ -6804,7 +6695,7 @@ const MgTooltip = class {
|
|
|
6804
6695
|
}
|
|
6805
6696
|
/**
|
|
6806
6697
|
* Render
|
|
6807
|
-
* @returns
|
|
6698
|
+
* @returns HTML Element
|
|
6808
6699
|
*/
|
|
6809
6700
|
render() {
|
|
6810
6701
|
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip" }, index.h("span", { innerHTML: this.message }), index.h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|