@mgdis/mg-components 5.10.0 → 5.11.0
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/{index-9e1091ab.js → index-03d2557d.js} +3 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_31.cjs.entry.js +444 -455
- package/dist/cjs/mg-components.cjs.js +2 -2
- package/dist/cjs/mg-item-more.cjs.entry.js +20 -29
- package/dist/cjs/{mg-menu.conf-1942ac70.js → mg-menu.conf-05ec32a3.js} +30 -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.css +2 -0
- 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 +20 -25
- 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.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +18 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +126 -19
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -1
- 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.css +1 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +11 -14
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +1 -0
- 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.css +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +6 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +16 -16
- 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/en/messages.json +7 -0
- package/dist/collection/locales/fr/messages.json +7 -0
- package/dist/collection/locales/index.js +2 -2
- package/dist/collection/styles/reset-mg-card-slotted-variables.scss +1 -0
- 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 +30 -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 +9 -11
- 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 +126 -21
- package/dist/components/mg-input-date.js +7 -9
- package/dist/components/mg-input-numeric.js +14 -19
- package/dist/components/mg-input-password.js +6 -7
- package/dist/components/mg-input-radio.js +10 -15
- package/dist/components/mg-input-select2.js +21 -29
- package/dist/components/mg-input-text2.js +15 -24
- package/dist/components/mg-input-textarea.js +13 -14
- package/dist/components/mg-input-title2.js +1 -2
- package/dist/components/mg-input-toggle.js +17 -20
- 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 +12 -15
- package/dist/components/mg-modal.js +8 -12
- package/dist/components/mg-pagination.js +11 -13
- package/dist/components/mg-panel.js +7 -16
- package/dist/components/mg-popover2.js +17 -17
- 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 +20 -25
- package/dist/esm/{index-3249671d.js → index-407d5211.js} +3 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_31.entry.js +444 -455
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-item-more.entry.js +20 -29
- package/dist/esm/{mg-menu.conf-2cc1bb67.js → mg-menu.conf-c8aa56ce.js} +30 -16
- package/dist/mg-components/locales/en/messages.json +7 -0
- package/dist/mg-components/locales/fr/messages.json +7 -0
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-3bf533f7.js +2 -0
- package/dist/mg-components/p-51c2def3.entry.js +1 -0
- package/dist/mg-components/p-b14be68b.js +1 -0
- package/dist/mg-components/{p-a56a3157.entry.js → p-d3ed97d3.entry.js} +1 -1
- package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +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 +15 -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.conf.d.ts +8 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +40 -7
- 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 +7 -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 +31 -35
- package/dist/types/locales/index.d.ts +16 -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 +4 -4
- package/dist/mg-components/p-73156ac9.js +0 -1
- package/dist/mg-components/p-8fbc0d87.js +0 -2
- package/dist/mg-components/p-eb32bb18.entry.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-
|
|
2
|
-
import { i as initLocales, D as Direction, l as localeDate, d as dateRegExp, a as localeCurrency, b as localeNumber, s as sizes$2 } from './mg-menu.conf-
|
|
1
|
+
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-407d5211.js';
|
|
2
|
+
import { i as initLocales, D as Direction, l as localeDate, d as dateRegExp, a as localeCurrency, b as localeNumber, s as sizes$2 } from './mg-menu.conf-c8aa56ce.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Available menu-item positions
|
|
@@ -22,9 +22,9 @@ var Status$1;
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Create random ID
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @returns
|
|
25
|
+
* @param prefix - add prefix to created ID
|
|
26
|
+
* @param length - ID length
|
|
27
|
+
* @returns ID
|
|
28
28
|
*/
|
|
29
29
|
const createID = (prefix = '', length = 10) => {
|
|
30
30
|
let ID = '';
|
|
@@ -43,8 +43,7 @@ class ClassList {
|
|
|
43
43
|
constructor(classlist = []) {
|
|
44
44
|
/**
|
|
45
45
|
* Add class
|
|
46
|
-
* @param
|
|
47
|
-
* @returns {void}
|
|
46
|
+
* @param className - class name to add
|
|
48
47
|
*/
|
|
49
48
|
this.add = (className) => {
|
|
50
49
|
if (!this.has(className)) {
|
|
@@ -53,8 +52,7 @@ class ClassList {
|
|
|
53
52
|
};
|
|
54
53
|
/**
|
|
55
54
|
* Delete class
|
|
56
|
-
* @param
|
|
57
|
-
* @returns {void}
|
|
55
|
+
* @param className - class name to delete
|
|
58
56
|
*/
|
|
59
57
|
this.delete = (className) => {
|
|
60
58
|
const index = this.classes.indexOf(className);
|
|
@@ -64,15 +62,15 @@ class ClassList {
|
|
|
64
62
|
};
|
|
65
63
|
/**
|
|
66
64
|
* Check if class exist in list
|
|
67
|
-
* @param
|
|
68
|
-
* @returns
|
|
65
|
+
* @param className - class name to check
|
|
66
|
+
* @returns class name is in the list
|
|
69
67
|
*/
|
|
70
68
|
this.has = (className) => {
|
|
71
69
|
return this.classes.includes(className);
|
|
72
70
|
};
|
|
73
71
|
/**
|
|
74
72
|
* Join classes seperated by spaces
|
|
75
|
-
* @returns
|
|
73
|
+
* @returns joined values
|
|
76
74
|
*/
|
|
77
75
|
this.join = () => {
|
|
78
76
|
return this.classes.join(' ');
|
|
@@ -82,15 +80,15 @@ class ClassList {
|
|
|
82
80
|
}
|
|
83
81
|
/**
|
|
84
82
|
* Check if all items are string
|
|
85
|
-
* @param
|
|
86
|
-
* @returns
|
|
83
|
+
* @param items - items to check
|
|
84
|
+
* @returns all items are string
|
|
87
85
|
*/
|
|
88
86
|
const allItemsAreString = (items) => Array.isArray(items) && items.every(item => typeof item === 'string');
|
|
89
87
|
/**
|
|
90
88
|
* Check if element is a heading
|
|
91
|
-
* @param
|
|
92
|
-
* @param
|
|
93
|
-
* @returns
|
|
89
|
+
* @param element - slotted element
|
|
90
|
+
* @param tagNames - allowed tag names list
|
|
91
|
+
* @returns element is a heading
|
|
94
92
|
*/
|
|
95
93
|
const isTagName = (element, tagNames) => {
|
|
96
94
|
return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
|
|
@@ -101,8 +99,8 @@ const isTagName = (element, tagNames) => {
|
|
|
101
99
|
const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
102
100
|
/**
|
|
103
101
|
* Get windows
|
|
104
|
-
* @param
|
|
105
|
-
* @returns
|
|
102
|
+
* @param localWindow - the window we are lookink for other windows
|
|
103
|
+
* @returns The list of windows found
|
|
106
104
|
*/
|
|
107
105
|
const getWindows = (localWindow) => {
|
|
108
106
|
const parentWindows = getParentWindows(localWindow);
|
|
@@ -111,9 +109,9 @@ const getWindows = (localWindow) => {
|
|
|
111
109
|
};
|
|
112
110
|
/**
|
|
113
111
|
* Get parent windows
|
|
114
|
-
* @param
|
|
115
|
-
* @param
|
|
116
|
-
* @returns
|
|
112
|
+
* @param localWindow - the window we are lookink for parents
|
|
113
|
+
* @param windows - The list of allready found windows
|
|
114
|
+
* @returns The list of windows found
|
|
117
115
|
*/
|
|
118
116
|
const getParentWindows = (localWindow, windows = []) => {
|
|
119
117
|
// Check if is in iframe
|
|
@@ -133,9 +131,9 @@ const getParentWindows = (localWindow, windows = []) => {
|
|
|
133
131
|
};
|
|
134
132
|
/**
|
|
135
133
|
* Get child windows
|
|
136
|
-
* @param
|
|
137
|
-
* @param
|
|
138
|
-
* @returns
|
|
134
|
+
* @param localWindow - the window we are lookink for children
|
|
135
|
+
* @param windows - The list of allready found windows
|
|
136
|
+
* @returns The list of windows found
|
|
139
137
|
*/
|
|
140
138
|
const getChildWindows = (localWindow, windows = []) => {
|
|
141
139
|
if (localWindow.frames.length > 0) {
|
|
@@ -154,8 +152,8 @@ const mgActionMoreCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
154
152
|
|
|
155
153
|
/**
|
|
156
154
|
* MgActionMore['items'] type guard
|
|
157
|
-
* @param
|
|
158
|
-
* @returns
|
|
155
|
+
* @param prop - commponent items prop
|
|
156
|
+
* @returns return true if type is valid
|
|
159
157
|
*/
|
|
160
158
|
const isMgActionMoreItems = (prop) => {
|
|
161
159
|
const items = prop;
|
|
@@ -163,8 +161,8 @@ const isMgActionMoreItems = (prop) => {
|
|
|
163
161
|
};
|
|
164
162
|
/**
|
|
165
163
|
* MgActionMore['button'] type guard
|
|
166
|
-
* @param
|
|
167
|
-
* @returns
|
|
164
|
+
* @param prop - commponent button prop
|
|
165
|
+
* @returns return true if type is valid
|
|
168
166
|
*/
|
|
169
167
|
const isMgActionMoreButton = (prop) => {
|
|
170
168
|
const button = prop;
|
|
@@ -172,8 +170,8 @@ const isMgActionMoreButton = (prop) => {
|
|
|
172
170
|
};
|
|
173
171
|
/**
|
|
174
172
|
* MgActionMore['icon'] type guard
|
|
175
|
-
* @param
|
|
176
|
-
* @returns
|
|
173
|
+
* @param prop - commponent icon prop
|
|
174
|
+
* @returns return true if type is valid
|
|
177
175
|
*/
|
|
178
176
|
const isMgActionMoreIcon = (prop) => {
|
|
179
177
|
const icon = prop;
|
|
@@ -192,23 +190,20 @@ const MgActionMore = class {
|
|
|
192
190
|
***********/
|
|
193
191
|
/**
|
|
194
192
|
* Toogle expanded props
|
|
195
|
-
* @returns {void}
|
|
196
193
|
*/
|
|
197
194
|
this.toggleExpanded = () => {
|
|
198
195
|
this.expanded = !this.expanded;
|
|
199
196
|
};
|
|
200
197
|
/**
|
|
201
198
|
* Button click handler
|
|
202
|
-
* @returns {void}
|
|
203
199
|
*/
|
|
204
200
|
this.handleButton = () => {
|
|
205
201
|
this.toggleExpanded();
|
|
206
202
|
};
|
|
207
203
|
/**
|
|
208
204
|
* Item click handler
|
|
209
|
-
* @param
|
|
210
|
-
* @param
|
|
211
|
-
* @returns {void}
|
|
205
|
+
* @param event - click event
|
|
206
|
+
* @param customHandler - item['mouseEventHandler']
|
|
212
207
|
*/
|
|
213
208
|
this.handleItemClick = (event, customHandler) => {
|
|
214
209
|
this.expanded = false;
|
|
@@ -245,7 +240,6 @@ const MgActionMore = class {
|
|
|
245
240
|
*************/
|
|
246
241
|
/**
|
|
247
242
|
* Validate props
|
|
248
|
-
* @returns {void}
|
|
249
243
|
*/
|
|
250
244
|
componentWillLoad() {
|
|
251
245
|
this.messages = initLocales(this.element).messages.actionMore;
|
|
@@ -256,7 +250,7 @@ const MgActionMore = class {
|
|
|
256
250
|
}
|
|
257
251
|
/**
|
|
258
252
|
* Render
|
|
259
|
-
* @returns
|
|
253
|
+
* @returns HTML Element
|
|
260
254
|
*/
|
|
261
255
|
render() {
|
|
262
256
|
const buttonLabel = this.button.label || this.messages.label;
|
|
@@ -304,7 +298,7 @@ const MgBadge = class {
|
|
|
304
298
|
this.label = undefined;
|
|
305
299
|
this.variant = variants$5[0];
|
|
306
300
|
this.outline = undefined;
|
|
307
|
-
this.
|
|
301
|
+
this.classCollection = new ClassList(['mg-badge']);
|
|
308
302
|
}
|
|
309
303
|
validateValue(newValue) {
|
|
310
304
|
if (`${newValue}`.match(/^(\d+\+*|[?*!a-z])$/i) === null) {
|
|
@@ -322,20 +316,19 @@ const MgBadge = class {
|
|
|
322
316
|
}
|
|
323
317
|
else {
|
|
324
318
|
if (oldValue !== undefined) {
|
|
325
|
-
this.
|
|
319
|
+
this.classCollection.delete(`mg-badge--${oldValue}`);
|
|
326
320
|
}
|
|
327
|
-
this.
|
|
321
|
+
this.classCollection.add(`mg-badge--${newValue}`);
|
|
328
322
|
}
|
|
329
323
|
}
|
|
330
324
|
validateOutline(newValue) {
|
|
331
325
|
if (newValue)
|
|
332
|
-
this.
|
|
326
|
+
this.classCollection.add(this.classOutline);
|
|
333
327
|
else
|
|
334
|
-
this.
|
|
328
|
+
this.classCollection.delete(this.classOutline);
|
|
335
329
|
}
|
|
336
330
|
/**
|
|
337
331
|
* Check if props are well configured on init
|
|
338
|
-
* @returns {void}
|
|
339
332
|
*/
|
|
340
333
|
componentWillLoad() {
|
|
341
334
|
this.validateValue(this.value);
|
|
@@ -345,10 +338,10 @@ const MgBadge = class {
|
|
|
345
338
|
}
|
|
346
339
|
/**
|
|
347
340
|
* Render
|
|
348
|
-
* @returns
|
|
341
|
+
* @returns HTML Element
|
|
349
342
|
*/
|
|
350
343
|
render() {
|
|
351
|
-
return (h("span", { class: this.
|
|
344
|
+
return (h("span", { class: this.classCollection.join() }, h("span", { class: "mg-badge__value" }, this.value), h("span", { class: "sr-only" }, this.label)));
|
|
352
345
|
}
|
|
353
346
|
static get watchers() { return {
|
|
354
347
|
"value": ["validateValue"],
|
|
@@ -379,8 +372,7 @@ const MgButton = class {
|
|
|
379
372
|
this.classFullWidth = 'mg-button--full-width';
|
|
380
373
|
/**
|
|
381
374
|
* Trigger actions onClick event
|
|
382
|
-
* @param
|
|
383
|
-
* @returns {void}
|
|
375
|
+
* @param event - click event
|
|
384
376
|
*/
|
|
385
377
|
this.handleClick = (event) => {
|
|
386
378
|
if (this.disabled)
|
|
@@ -393,8 +385,7 @@ const MgButton = class {
|
|
|
393
385
|
};
|
|
394
386
|
/**
|
|
395
387
|
* Handle onKeydown event
|
|
396
|
-
* @param
|
|
397
|
-
* @returns {void}
|
|
388
|
+
* @param event - keyboard event
|
|
398
389
|
*/
|
|
399
390
|
this.handleKeydown = (event) => {
|
|
400
391
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -407,8 +398,7 @@ const MgButton = class {
|
|
|
407
398
|
};
|
|
408
399
|
/**
|
|
409
400
|
* Handle onKeyup event
|
|
410
|
-
* @param
|
|
411
|
-
* @returns {void}
|
|
401
|
+
* @param event - keyboard event
|
|
412
402
|
*/
|
|
413
403
|
this.handleKeyup = (event) => {
|
|
414
404
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -426,7 +416,7 @@ const MgButton = class {
|
|
|
426
416
|
this.isIcon = false;
|
|
427
417
|
this.disableOnClick = false;
|
|
428
418
|
this.loading = false;
|
|
429
|
-
this.
|
|
419
|
+
this.classCollection = new ClassList(['mg-button']);
|
|
430
420
|
}
|
|
431
421
|
validateVariant(newValue, oldValue) {
|
|
432
422
|
if (!variants$4.includes(newValue)) {
|
|
@@ -434,9 +424,9 @@ const MgButton = class {
|
|
|
434
424
|
}
|
|
435
425
|
else {
|
|
436
426
|
if (oldValue !== undefined) {
|
|
437
|
-
this.
|
|
427
|
+
this.classCollection.delete(`mg-button--${oldValue}`);
|
|
438
428
|
}
|
|
439
|
-
this.
|
|
429
|
+
this.classCollection.add(`mg-button--${newValue}`);
|
|
440
430
|
}
|
|
441
431
|
}
|
|
442
432
|
validateFullWidth(newValue) {
|
|
@@ -444,10 +434,10 @@ const MgButton = class {
|
|
|
444
434
|
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
445
435
|
}
|
|
446
436
|
else if (newValue) {
|
|
447
|
-
this.
|
|
437
|
+
this.classCollection.add(this.classFullWidth);
|
|
448
438
|
}
|
|
449
439
|
else {
|
|
450
|
-
this.
|
|
440
|
+
this.classCollection.delete(this.classFullWidth);
|
|
451
441
|
}
|
|
452
442
|
}
|
|
453
443
|
disabledHandler(isDisabled) {
|
|
@@ -460,10 +450,10 @@ const MgButton = class {
|
|
|
460
450
|
this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
|
|
461
451
|
// apply style
|
|
462
452
|
if (isDisabled) {
|
|
463
|
-
this.
|
|
453
|
+
this.classCollection.add(this.classDisabled);
|
|
464
454
|
}
|
|
465
455
|
else {
|
|
466
|
-
this.
|
|
456
|
+
this.classCollection.delete(this.classDisabled);
|
|
467
457
|
}
|
|
468
458
|
// emit value update
|
|
469
459
|
this.disabledChange.emit(isDisabled);
|
|
@@ -471,21 +461,20 @@ const MgButton = class {
|
|
|
471
461
|
loadingHandler(newValue) {
|
|
472
462
|
// we add loading style if it newvalue is true else we remove it
|
|
473
463
|
if (newValue) {
|
|
474
|
-
this.
|
|
464
|
+
this.classCollection.add(this.classLoading);
|
|
475
465
|
}
|
|
476
466
|
else {
|
|
477
|
-
this.
|
|
467
|
+
this.classCollection.delete(this.classLoading);
|
|
478
468
|
}
|
|
479
469
|
}
|
|
480
470
|
/**
|
|
481
471
|
* Check if props are well configured on init
|
|
482
|
-
* @returns {void}
|
|
483
472
|
*/
|
|
484
473
|
componentWillLoad() {
|
|
485
474
|
this.validateVariant(this.variant);
|
|
486
475
|
this.validateFullWidth(this.fullWidth);
|
|
487
476
|
if (this.isIcon) {
|
|
488
|
-
this.
|
|
477
|
+
this.classCollection.add(`mg-button--icon`);
|
|
489
478
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
490
479
|
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
491
480
|
}
|
|
@@ -496,10 +485,10 @@ const MgButton = class {
|
|
|
496
485
|
}
|
|
497
486
|
/**
|
|
498
487
|
* Render component
|
|
499
|
-
* @returns
|
|
488
|
+
* @returns html element
|
|
500
489
|
*/
|
|
501
490
|
render() {
|
|
502
|
-
return (h(Host, { role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, h("div", { class: this.
|
|
491
|
+
return (h(Host, { role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, h("div", { class: this.classCollection.join(), id: this.identifier }, this.loading && h("mg-icon", { icon: "loader", spin: true }), h("div", { class: "mg-button__content" }, h("slot", null)))));
|
|
503
492
|
}
|
|
504
493
|
get element() { return getElement(this); }
|
|
505
494
|
static get watchers() { return {
|
|
@@ -520,7 +509,7 @@ const variants$3 = ['info', 'warning', 'success', 'danger', 'app'];
|
|
|
520
509
|
*/
|
|
521
510
|
const variantStyles$1 = ['bar-left', 'fill'];
|
|
522
511
|
|
|
523
|
-
const mgCardCss = ".mg-card{position:relative;width:100%;max-width:var(--mg-card-max-width);padding:var(--mg-card-padding, var(--mg-card-padding-default));overflow:var(--mg-card-overflow, var(--mg-card-overflow-default));box-sizing:border-box;z-index:inherit;background:var(--mg-card-background, var(--mg-card-background-default));border:var(--mg-card-border, var(--mg-card-border-default));border-radius:var(--mg-card-border-radius, var(--mg-card-border-radius-default));box-shadow:var(--mg-card-box-shadow, var(--mg-card-box-shadow-default))}.mg-card ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default);--mg-card-max-width:unset}.mg-card.mg-card--info{overflow:hidden}.mg-card.mg-card--info.mg-card--bar-left .mg-card__bar{background-color:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-card.mg-card--info.mg-card--fill{background-color:hsl(var(--color-info-h), var(--color-info-s), var(--mg-color-soft-l))}.mg-card.mg-card--warning{overflow:hidden}.mg-card.mg-card--warning.mg-card--bar-left .mg-card__bar{background-color:hsl(var(--color-warning-h), var(--color-warning-s), var(--color-warning-l))}.mg-card.mg-card--warning.mg-card--fill{background-color:hsl(var(--color-warning-h), var(--color-warning-s), var(--mg-color-soft-l))}.mg-card.mg-card--success{overflow:hidden}.mg-card.mg-card--success.mg-card--bar-left .mg-card__bar{background-color:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))}.mg-card.mg-card--success.mg-card--fill{background-color:hsl(var(--color-success-h), var(--color-success-s), var(--mg-color-soft-l))}.mg-card.mg-card--danger{overflow:hidden}.mg-card.mg-card--danger.mg-card--bar-left .mg-card__bar{background-color:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-card.mg-card--danger.mg-card--fill{background-color:hsl(var(--color-danger-h), var(--color-danger-s), var(--mg-color-soft-l))}.mg-card.mg-card--app{overflow:hidden}.mg-card.mg-card--app.mg-card--bar-left .mg-card__bar{background-color:hsl(var(--mg-color-app-h), var(--mg-color-app-s), var(--mg-color-app-l))}.mg-card.mg-card--app.mg-card--fill{background-color:hsl(var(--mg-color-app-h), var(--mg-color-app-s), var(--mg-color-soft-l))}.mg-card__bar{position:absolute;top:0;left:0;width:0.3rem;height:100%}";
|
|
512
|
+
const mgCardCss = ".mg-card{position:relative;width:100%;max-width:var(--mg-card-max-width);min-width:var(--mg-card-min-width);padding:var(--mg-card-padding, var(--mg-card-padding-default));overflow:var(--mg-card-overflow, var(--mg-card-overflow-default));box-sizing:border-box;z-index:inherit;background:var(--mg-card-background, var(--mg-card-background-default));border:var(--mg-card-border, var(--mg-card-border-default));border-radius:var(--mg-card-border-radius, var(--mg-card-border-radius-default));box-shadow:var(--mg-card-box-shadow, var(--mg-card-box-shadow-default))}.mg-card ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default);--mg-card-max-width:unset;--mg-card-min-width:unset}.mg-card.mg-card--info{overflow:hidden}.mg-card.mg-card--info.mg-card--bar-left .mg-card__bar{background-color:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-card.mg-card--info.mg-card--fill{background-color:hsl(var(--color-info-h), var(--color-info-s), var(--mg-color-soft-l))}.mg-card.mg-card--warning{overflow:hidden}.mg-card.mg-card--warning.mg-card--bar-left .mg-card__bar{background-color:hsl(var(--color-warning-h), var(--color-warning-s), var(--color-warning-l))}.mg-card.mg-card--warning.mg-card--fill{background-color:hsl(var(--color-warning-h), var(--color-warning-s), var(--mg-color-soft-l))}.mg-card.mg-card--success{overflow:hidden}.mg-card.mg-card--success.mg-card--bar-left .mg-card__bar{background-color:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))}.mg-card.mg-card--success.mg-card--fill{background-color:hsl(var(--color-success-h), var(--color-success-s), var(--mg-color-soft-l))}.mg-card.mg-card--danger{overflow:hidden}.mg-card.mg-card--danger.mg-card--bar-left .mg-card__bar{background-color:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-card.mg-card--danger.mg-card--fill{background-color:hsl(var(--color-danger-h), var(--color-danger-s), var(--mg-color-soft-l))}.mg-card.mg-card--app{overflow:hidden}.mg-card.mg-card--app.mg-card--bar-left .mg-card__bar{background-color:hsl(var(--mg-color-app-h), var(--mg-color-app-s), var(--mg-color-app-l))}.mg-card.mg-card--app.mg-card--fill{background-color:hsl(var(--mg-color-app-h), var(--mg-color-app-s), var(--mg-color-soft-l))}.mg-card__bar{position:absolute;top:0;left:0;width:0.3rem;height:100%}";
|
|
524
513
|
|
|
525
514
|
const MgCard = class {
|
|
526
515
|
constructor(hostRef) {
|
|
@@ -533,7 +522,6 @@ const MgCard = class {
|
|
|
533
522
|
/**
|
|
534
523
|
* Methode to set default varianStyle props
|
|
535
524
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
536
|
-
* @returns {void}
|
|
537
525
|
*/
|
|
538
526
|
this.setDefaultVariantStyle = () => {
|
|
539
527
|
if (this.variantStyle === undefined)
|
|
@@ -541,17 +529,17 @@ const MgCard = class {
|
|
|
541
529
|
};
|
|
542
530
|
this.variant = undefined;
|
|
543
531
|
this.variantStyle = undefined;
|
|
544
|
-
this.
|
|
532
|
+
this.classCollection = new ClassList([this.baseClass]);
|
|
545
533
|
}
|
|
546
534
|
validateVariant(newValue, oldValue) {
|
|
547
535
|
if (newValue && !variants$3.includes(newValue))
|
|
548
536
|
throw new Error(`<${this.name}> prop "variant" must match VariantType type.`);
|
|
549
537
|
if (Boolean(newValue)) {
|
|
550
538
|
this.setDefaultVariantStyle();
|
|
551
|
-
this.
|
|
539
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
552
540
|
}
|
|
553
541
|
if (Boolean(oldValue))
|
|
554
|
-
this.
|
|
542
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
555
543
|
}
|
|
556
544
|
validateVariantStyle(newValue, oldValue) {
|
|
557
545
|
if (newValue && !variantStyles$1.includes(newValue))
|
|
@@ -559,16 +547,15 @@ const MgCard = class {
|
|
|
559
547
|
else if (Boolean(newValue) && !variants$3.includes(this.variant))
|
|
560
548
|
throw new Error(`<${this.name}> prop "variantStyle" must be paired with ${JSON.stringify(variants$3)} "variant" prop.`);
|
|
561
549
|
if (Boolean(newValue))
|
|
562
|
-
this.
|
|
550
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
563
551
|
if (Boolean(oldValue))
|
|
564
|
-
this.
|
|
552
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
565
553
|
}
|
|
566
554
|
/*************
|
|
567
555
|
* Lifecycle *
|
|
568
556
|
*************/
|
|
569
557
|
/**
|
|
570
558
|
* Check if props are well configured on init
|
|
571
|
-
* @returns {void}
|
|
572
559
|
*/
|
|
573
560
|
componentWillLoad() {
|
|
574
561
|
this.validateVariant(this.variant);
|
|
@@ -576,11 +563,11 @@ const MgCard = class {
|
|
|
576
563
|
}
|
|
577
564
|
/**
|
|
578
565
|
* Render
|
|
579
|
-
* @returns
|
|
566
|
+
* @returns HTML Element
|
|
580
567
|
*/
|
|
581
568
|
render() {
|
|
582
569
|
var _a;
|
|
583
|
-
return (h("div", { class: this.
|
|
570
|
+
return (h("div", { class: this.classCollection.join() }, ((_a = this.variantStyle) === null || _a === void 0 ? void 0 : _a.startsWith('bar-')) && h("span", { class: "mg-card__bar" }), h("slot", null)));
|
|
584
571
|
}
|
|
585
572
|
static get watchers() { return {
|
|
586
573
|
"variant": ["validateVariant"],
|
|
@@ -608,7 +595,6 @@ const MgCharacterLeft = class {
|
|
|
608
595
|
*************/
|
|
609
596
|
/**
|
|
610
597
|
* Check if props are well configured on init
|
|
611
|
-
* @returns {void}
|
|
612
598
|
*/
|
|
613
599
|
componentWillLoad() {
|
|
614
600
|
this.validateMaxlength(this.maxlength);
|
|
@@ -616,7 +602,7 @@ const MgCharacterLeft = class {
|
|
|
616
602
|
}
|
|
617
603
|
/**
|
|
618
604
|
* Render component
|
|
619
|
-
* @returns
|
|
605
|
+
* @returns HTML Element
|
|
620
606
|
*/
|
|
621
607
|
render() {
|
|
622
608
|
return (h("span", { id: this.identifier, "aria-live": "polite" }, h("span", { "aria-hidden": "true" }, this.maxlength - this.characters.length, "/", this.maxlength), h("span", { class: "sr-only" }, this.messages.nbCharLeft.replace('{counter}', this.maxlength - this.characters.length))));
|
|
@@ -636,7 +622,6 @@ const MgDetails = class {
|
|
|
636
622
|
this.expandedChange = createEvent(this, "expanded-change", 7);
|
|
637
623
|
/**
|
|
638
624
|
* Handle details toggle
|
|
639
|
-
* @returns {void}
|
|
640
625
|
*/
|
|
641
626
|
this.handleToggle = () => {
|
|
642
627
|
this.expanded = this.details.open;
|
|
@@ -659,7 +644,6 @@ const MgDetails = class {
|
|
|
659
644
|
*************/
|
|
660
645
|
/**
|
|
661
646
|
* Check if component props are well configured on init
|
|
662
|
-
* @returns {void}
|
|
663
647
|
*/
|
|
664
648
|
componentWillLoad() {
|
|
665
649
|
this.validateTitles(this.toggleClosed);
|
|
@@ -667,7 +651,7 @@ const MgDetails = class {
|
|
|
667
651
|
}
|
|
668
652
|
/**
|
|
669
653
|
* Render
|
|
670
|
-
* @returns
|
|
654
|
+
* @returns HTML Element
|
|
671
655
|
*/
|
|
672
656
|
render() {
|
|
673
657
|
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down', size: "small" }), h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), h("div", { class: "mg-details__details" }, h("slot", { name: "details" }))));
|
|
@@ -689,7 +673,7 @@ const MgDivider = class {
|
|
|
689
673
|
}
|
|
690
674
|
/**
|
|
691
675
|
* Render
|
|
692
|
-
* @returns
|
|
676
|
+
* @returns HTML Element
|
|
693
677
|
*/
|
|
694
678
|
render() {
|
|
695
679
|
return (h("div", { class: {
|
|
@@ -711,13 +695,11 @@ const MgForm = class {
|
|
|
711
695
|
this.classAllRequired = 'mg-form--all-required';
|
|
712
696
|
/**
|
|
713
697
|
* Define required message based on mg-inputs required elements
|
|
714
|
-
* Also
|
|
715
|
-
* @returns {void}
|
|
716
698
|
*/
|
|
717
699
|
this.setRequiredMessage = () => {
|
|
718
700
|
// init required message
|
|
719
701
|
this.requiredMessage = null;
|
|
720
|
-
this.
|
|
702
|
+
this.classCollection.delete(this.classAllRequired);
|
|
721
703
|
// If the form is disabled or readonly none of them are required
|
|
722
704
|
// Check if all fields are not editable (readonly or disabled)
|
|
723
705
|
if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
|
|
@@ -727,7 +709,7 @@ const MgForm = class {
|
|
|
727
709
|
// mg-input-toggle can not be required
|
|
728
710
|
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
729
711
|
this.requiredMessage = requiredInputs.length === 1 ? this.messages.form.allRequiredSingle : this.messages.form.allRequired;
|
|
730
|
-
this.
|
|
712
|
+
this.classCollection.add(this.classAllRequired);
|
|
731
713
|
}
|
|
732
714
|
// Some fields are required
|
|
733
715
|
else if (requiredInputs.length > 0) {
|
|
@@ -737,7 +719,6 @@ const MgForm = class {
|
|
|
737
719
|
};
|
|
738
720
|
/**
|
|
739
721
|
* Check if form is valid
|
|
740
|
-
* @returns {void}
|
|
741
722
|
*/
|
|
742
723
|
this.checkValidity = () => {
|
|
743
724
|
// Update required on input event
|
|
@@ -749,8 +730,7 @@ const MgForm = class {
|
|
|
749
730
|
};
|
|
750
731
|
/**
|
|
751
732
|
* Handle Form Submit
|
|
752
|
-
* @param
|
|
753
|
-
* @returns {void}
|
|
733
|
+
* @param event - submit event
|
|
754
734
|
*/
|
|
755
735
|
this.handleFormSubmit = (event) => {
|
|
756
736
|
event.preventDefault();
|
|
@@ -758,7 +738,6 @@ const MgForm = class {
|
|
|
758
738
|
};
|
|
759
739
|
/**
|
|
760
740
|
* Set mgInputs
|
|
761
|
-
* @returns {void}
|
|
762
741
|
*/
|
|
763
742
|
this.setMgInputs = () => {
|
|
764
743
|
// Get slotted mgInputs
|
|
@@ -780,7 +759,7 @@ const MgForm = class {
|
|
|
780
759
|
this.disabled = false;
|
|
781
760
|
this.valid = undefined;
|
|
782
761
|
this.invalid = undefined;
|
|
783
|
-
this.
|
|
762
|
+
this.classCollection = new ClassList(['mg-form']);
|
|
784
763
|
this.requiredMessage = undefined;
|
|
785
764
|
}
|
|
786
765
|
handleAttributeChange() {
|
|
@@ -789,7 +768,6 @@ const MgForm = class {
|
|
|
789
768
|
}
|
|
790
769
|
/**
|
|
791
770
|
* Public method to display errors
|
|
792
|
-
* @returns {Promise<void>}
|
|
793
771
|
*/
|
|
794
772
|
async displayError() {
|
|
795
773
|
if (!this.readonly) {
|
|
@@ -804,7 +782,6 @@ const MgForm = class {
|
|
|
804
782
|
*************/
|
|
805
783
|
/**
|
|
806
784
|
* Check if component props are well configured on init
|
|
807
|
-
* @returns {void}
|
|
808
785
|
*/
|
|
809
786
|
componentWillLoad() {
|
|
810
787
|
// Get locales
|
|
@@ -831,7 +808,6 @@ const MgForm = class {
|
|
|
831
808
|
}
|
|
832
809
|
/**
|
|
833
810
|
* Add slot listeners
|
|
834
|
-
* @returns {void}
|
|
835
811
|
*/
|
|
836
812
|
componentDidLoad() {
|
|
837
813
|
this.mgButtons.forEach(mgButton => {
|
|
@@ -849,10 +825,10 @@ const MgForm = class {
|
|
|
849
825
|
}
|
|
850
826
|
/**
|
|
851
827
|
* Render
|
|
852
|
-
* @returns
|
|
828
|
+
* @returns HTML Element
|
|
853
829
|
*/
|
|
854
830
|
render() {
|
|
855
|
-
return (h("form", { class: this.
|
|
831
|
+
return (h("form", { class: this.classCollection.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit }, this.requiredMessage && h("p", { innerHTML: this.requiredMessage }), h("slot", null), !this.readonly && !this.disabled && h("slot", { name: "actions" })));
|
|
856
832
|
}
|
|
857
833
|
get element() { return getElement(this); }
|
|
858
834
|
static get watchers() { return {
|
|
@@ -1099,13 +1075,12 @@ const MgIcon = class {
|
|
|
1099
1075
|
registerInstance(this, hostRef);
|
|
1100
1076
|
/**
|
|
1101
1077
|
* getIcon
|
|
1102
|
-
* @returns
|
|
1078
|
+
* @returns icon html
|
|
1103
1079
|
*/
|
|
1104
1080
|
this.getIcon = () => icons[this.icon]();
|
|
1105
1081
|
/**
|
|
1106
1082
|
* Method to set default varianStyle props
|
|
1107
1083
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
1108
|
-
* @returns {void}
|
|
1109
1084
|
*/
|
|
1110
1085
|
this.setDefaultVariantStyle = () => {
|
|
1111
1086
|
if (this.variantStyle === undefined)
|
|
@@ -1116,15 +1091,15 @@ const MgIcon = class {
|
|
|
1116
1091
|
this.variant = undefined;
|
|
1117
1092
|
this.variantStyle = undefined;
|
|
1118
1093
|
this.spin = false;
|
|
1119
|
-
this.
|
|
1094
|
+
this.classCollection = new ClassList(['mg-icon']);
|
|
1120
1095
|
}
|
|
1121
1096
|
validateIcon(newValue, oldValue) {
|
|
1122
1097
|
if (!Object.keys(icons).includes(newValue))
|
|
1123
1098
|
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
|
|
1124
1099
|
else {
|
|
1125
1100
|
if (oldValue !== undefined)
|
|
1126
|
-
this.
|
|
1127
|
-
this.
|
|
1101
|
+
this.classCollection.delete(`mg-icon--${oldValue}`);
|
|
1102
|
+
this.classCollection.add(`mg-icon--${newValue}`);
|
|
1128
1103
|
}
|
|
1129
1104
|
}
|
|
1130
1105
|
validateSize(newValue, oldValue) {
|
|
@@ -1132,8 +1107,8 @@ const MgIcon = class {
|
|
|
1132
1107
|
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes$1.join(', ')}`);
|
|
1133
1108
|
else {
|
|
1134
1109
|
if (oldValue !== undefined)
|
|
1135
|
-
this.
|
|
1136
|
-
this.
|
|
1110
|
+
this.classCollection.delete(`mg-icon--size-${oldValue}`);
|
|
1111
|
+
this.classCollection.add(`mg-icon--size-${newValue}`);
|
|
1137
1112
|
}
|
|
1138
1113
|
}
|
|
1139
1114
|
validateVariant(newValue, oldValue) {
|
|
@@ -1143,8 +1118,8 @@ const MgIcon = class {
|
|
|
1143
1118
|
else {
|
|
1144
1119
|
this.setDefaultVariantStyle();
|
|
1145
1120
|
if (oldValue !== undefined)
|
|
1146
|
-
this.
|
|
1147
|
-
this.
|
|
1121
|
+
this.classCollection.delete(`mg-icon--variant-${oldValue}`);
|
|
1122
|
+
this.classCollection.add(`mg-icon--variant-${newValue}`);
|
|
1148
1123
|
}
|
|
1149
1124
|
}
|
|
1150
1125
|
}
|
|
@@ -1154,24 +1129,23 @@ const MgIcon = class {
|
|
|
1154
1129
|
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
|
|
1155
1130
|
else {
|
|
1156
1131
|
if (oldValue !== undefined)
|
|
1157
|
-
this.
|
|
1158
|
-
this.
|
|
1132
|
+
this.classCollection.delete(`mg-icon--variant-style-${oldValue}`);
|
|
1133
|
+
this.classCollection.add(`mg-icon--variant-style-${newValue}`);
|
|
1159
1134
|
}
|
|
1160
1135
|
}
|
|
1161
1136
|
}
|
|
1162
1137
|
handleSpin(newValue) {
|
|
1163
1138
|
if (newValue) {
|
|
1164
|
-
this.
|
|
1165
|
-
this.
|
|
1139
|
+
this.classCollection.add('mg-icon--spin');
|
|
1140
|
+
this.classCollection.add('mg-a11y-animation');
|
|
1166
1141
|
}
|
|
1167
1142
|
else {
|
|
1168
|
-
this.
|
|
1169
|
-
this.
|
|
1143
|
+
this.classCollection.delete('mg-icon--spin');
|
|
1144
|
+
this.classCollection.delete('mg-a11y-animation');
|
|
1170
1145
|
}
|
|
1171
1146
|
}
|
|
1172
1147
|
/**
|
|
1173
1148
|
* Check if props are well configured on init
|
|
1174
|
-
* @returns {void}
|
|
1175
1149
|
*/
|
|
1176
1150
|
componentWillLoad() {
|
|
1177
1151
|
this.validateIcon(this.icon);
|
|
@@ -1182,10 +1156,10 @@ const MgIcon = class {
|
|
|
1182
1156
|
}
|
|
1183
1157
|
/**
|
|
1184
1158
|
* Render component
|
|
1185
|
-
* @returns
|
|
1159
|
+
* @returns HTML Element
|
|
1186
1160
|
*/
|
|
1187
1161
|
render() {
|
|
1188
|
-
return (h("svg", { class: this.
|
|
1162
|
+
return (h("svg", { class: this.classCollection.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
|
|
1189
1163
|
}
|
|
1190
1164
|
static get watchers() { return {
|
|
1191
1165
|
"icon": ["validateIcon"],
|
|
@@ -1210,7 +1184,6 @@ const MgIllustratedMessage = class {
|
|
|
1210
1184
|
*************/
|
|
1211
1185
|
/**
|
|
1212
1186
|
* Check if component props are well configured on init
|
|
1213
|
-
* @returns {void}
|
|
1214
1187
|
*/
|
|
1215
1188
|
componentDidLoad() {
|
|
1216
1189
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -1225,7 +1198,7 @@ const MgIllustratedMessage = class {
|
|
|
1225
1198
|
}
|
|
1226
1199
|
/**
|
|
1227
1200
|
* Render
|
|
1228
|
-
* @returns
|
|
1201
|
+
* @returns HTML Element
|
|
1229
1202
|
*/
|
|
1230
1203
|
render() {
|
|
1231
1204
|
return (h("div", { class: {
|
|
@@ -1240,12 +1213,17 @@ const MgIllustratedMessage = class {
|
|
|
1240
1213
|
};
|
|
1241
1214
|
MgIllustratedMessage.style = mgIllustratedMessageCss;
|
|
1242
1215
|
|
|
1216
|
+
/**
|
|
1217
|
+
* Possible input width
|
|
1218
|
+
*/
|
|
1219
|
+
const widths = [2, 4, 16, 'full'];
|
|
1220
|
+
|
|
1243
1221
|
/**
|
|
1244
1222
|
* Apply in all input child node the aria-describedby attribute
|
|
1245
|
-
* @param
|
|
1246
|
-
* @param
|
|
1247
|
-
* @param
|
|
1248
|
-
* @returns
|
|
1223
|
+
* @param children - Represent scoped elements
|
|
1224
|
+
* @param ariaDescribedbyIDs - List of IDs
|
|
1225
|
+
* @param utils - Stencil.js utils
|
|
1226
|
+
* @returns Children with aria-describedby attribute
|
|
1249
1227
|
*/
|
|
1250
1228
|
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
1251
1229
|
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
@@ -1258,29 +1236,36 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
|
|
|
1258
1236
|
});
|
|
1259
1237
|
/**
|
|
1260
1238
|
* Add classes based on props
|
|
1261
|
-
* @param
|
|
1239
|
+
* @param props - MgInput Interface Props
|
|
1262
1240
|
*/
|
|
1263
1241
|
const manageClasses = (props) => {
|
|
1264
|
-
props.
|
|
1242
|
+
props.classCollection.add('mg-input');
|
|
1265
1243
|
if (props.labelOnTop)
|
|
1266
|
-
props.
|
|
1244
|
+
props.classCollection.add('mg-input--label-on-top');
|
|
1245
|
+
else
|
|
1246
|
+
props.classCollection.delete('mg-input--label-on-top');
|
|
1267
1247
|
if (props.readonly)
|
|
1268
|
-
props.
|
|
1248
|
+
props.classCollection.add('mg-input--readonly');
|
|
1249
|
+
else
|
|
1250
|
+
props.classCollection.delete('mg-input--readonly');
|
|
1251
|
+
widths.forEach(width => {
|
|
1252
|
+
props.classCollection.delete(`mg-input--width-${width}`);
|
|
1253
|
+
});
|
|
1269
1254
|
if (props.mgWidth !== undefined)
|
|
1270
|
-
props.
|
|
1255
|
+
props.classCollection.add(`mg-input--width-${props.mgWidth}`);
|
|
1271
1256
|
};
|
|
1272
1257
|
/**
|
|
1273
1258
|
* Get tagname
|
|
1274
|
-
* @param
|
|
1275
|
-
* @returns
|
|
1259
|
+
* @param isFieldset - is fieldset
|
|
1260
|
+
* @returns tag name
|
|
1276
1261
|
*/
|
|
1277
1262
|
const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
|
|
1278
1263
|
/**
|
|
1279
1264
|
* Get input template
|
|
1280
|
-
* @param
|
|
1281
|
-
* @param
|
|
1282
|
-
* @param
|
|
1283
|
-
* @returns
|
|
1265
|
+
* @param props - MgInput Interface Props
|
|
1266
|
+
* @param children - Represent scoped elements
|
|
1267
|
+
* @param utils - Stencil.js utils
|
|
1268
|
+
* @returns input template
|
|
1284
1269
|
*/
|
|
1285
1270
|
const MgInput = (props, children, utils) => {
|
|
1286
1271
|
/**
|
|
@@ -1336,17 +1321,17 @@ const MgInput = (props, children, utils) => {
|
|
|
1336
1321
|
const TagName = getTagName(props.isFieldset);
|
|
1337
1322
|
/**
|
|
1338
1323
|
* Get tooltip node
|
|
1339
|
-
* @returns
|
|
1324
|
+
* @returns mg-tooltip
|
|
1340
1325
|
*/
|
|
1341
1326
|
const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
|
|
1342
1327
|
h("mg-icon", { icon: "info-circle" })));
|
|
1343
1328
|
/**
|
|
1344
1329
|
* Get input title (label) node
|
|
1345
1330
|
* Display asterisk only if not disabled and not readonly
|
|
1346
|
-
* @returns
|
|
1331
|
+
* @returns mg-input-title
|
|
1347
1332
|
*/
|
|
1348
1333
|
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
|
|
1349
|
-
return (h(TagName, { class: props.
|
|
1334
|
+
return (h(TagName, { class: props.classCollection.join() },
|
|
1350
1335
|
props.labelOnTop ? (h("div", { class: "mg-input__title" },
|
|
1351
1336
|
getInputTitle(),
|
|
1352
1337
|
!props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
|
|
@@ -1360,12 +1345,17 @@ const MgInput = (props, children, utils) => {
|
|
|
1360
1345
|
props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
|
|
1361
1346
|
};
|
|
1362
1347
|
|
|
1363
|
-
|
|
1348
|
+
/**
|
|
1349
|
+
* List of all availables checkbox type
|
|
1350
|
+
*/
|
|
1351
|
+
const checkboxTypes = ['checkbox', 'multi'];
|
|
1352
|
+
|
|
1353
|
+
const mgInputCheckboxCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle,.mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}fieldset.mg-input{border:0;margin-left:0;margin-right:0;padding:0}fieldset.mg-input input[type=radio],fieldset.mg-input input[type=checkbox]{flex-shrink:0;width:var(--mg-input-check-size);height:var(--mg-input-check-size);margin-top:calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);margin-right:0.6rem;margin-bottom:0;margin-left:0}fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container{margin-top:0.7rem}.mg-input__input-container mg-tooltip{margin-left:3rem}.mg-input__input-group-container{margin:0;padding:0;list-style:none;display:flex;flex-wrap:wrap;column-gap:2.3rem;row-gap:1rem;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2)}.mg-input__input-group-container--vertical{flex-direction:column}.mg-input__input-group{display:flex;align-items:top}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi{display:flex;flex-wrap:wrap;gap:calc(var(--mg-inputs-spacer) * 1.2)}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-inputs{margin:0}.mg-input.mg-input--checkbox-multi:not(.mg-input--label-on-top) mg-tooltip{margin-left:var(--mg-inputs-spacer)}.mg-input.mg-input--checkbox-multi mg-popover{--mg-popover-min-width:7rem}";
|
|
1364
1354
|
|
|
1365
1355
|
/**
|
|
1366
1356
|
* type CheckboxItem validation function
|
|
1367
|
-
* @param
|
|
1368
|
-
* @returns
|
|
1357
|
+
* @param items - Checkbox item
|
|
1358
|
+
* @returns match item type
|
|
1369
1359
|
*/
|
|
1370
1360
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
1371
1361
|
items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
|
|
@@ -1381,9 +1371,11 @@ const MgInputCheckbox = class {
|
|
|
1381
1371
|
this.inputs = [];
|
|
1382
1372
|
// hasDisplayedError (triggered by blur event)
|
|
1383
1373
|
this.hasDisplayedError = false;
|
|
1374
|
+
// style
|
|
1375
|
+
this.baseClassName = 'mg-input--checkbox';
|
|
1384
1376
|
/**
|
|
1385
1377
|
* Handle input event
|
|
1386
|
-
* @param
|
|
1378
|
+
* @param event - input event
|
|
1387
1379
|
*/
|
|
1388
1380
|
this.handleInput = (event) => {
|
|
1389
1381
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -1395,6 +1387,21 @@ const MgInputCheckbox = class {
|
|
|
1395
1387
|
this.value = this.checkboxItems.map(o => ({ value: o.value, title: o.title, disabled: o.disabled }));
|
|
1396
1388
|
this.checkValidity();
|
|
1397
1389
|
};
|
|
1390
|
+
/**
|
|
1391
|
+
* Keyboard handler
|
|
1392
|
+
* @param event - to trak "tab" key
|
|
1393
|
+
*/
|
|
1394
|
+
this.handleKeydown = (event) => {
|
|
1395
|
+
var _a;
|
|
1396
|
+
// track "Tab" key event when popover display (is "multi" type selected)
|
|
1397
|
+
if (event.key === 'Tab' && ((_a = this.popover) === null || _a === void 0 ? void 0 : _a.display)) {
|
|
1398
|
+
const enableInputs = this.checkboxItems.filter(input => !input.disabled).map(({ id }) => id);
|
|
1399
|
+
const originInputIndex = enableInputs.findIndex(id => id === event.target.id);
|
|
1400
|
+
// close popover when tab trigger focus outside its DOM
|
|
1401
|
+
if ((originInputIndex + 1 >= enableInputs.length && !event.shiftKey) || (originInputIndex === 0 && event.shiftKey))
|
|
1402
|
+
this.popover.display = false;
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1398
1405
|
/**
|
|
1399
1406
|
* Handle blur event
|
|
1400
1407
|
*/
|
|
@@ -1405,7 +1412,7 @@ const MgInputCheckbox = class {
|
|
|
1405
1412
|
};
|
|
1406
1413
|
/**
|
|
1407
1414
|
* get invalid element
|
|
1408
|
-
* @returns
|
|
1415
|
+
* @returns element
|
|
1409
1416
|
*/
|
|
1410
1417
|
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
1411
1418
|
/**
|
|
@@ -1417,6 +1424,19 @@ const MgInputCheckbox = class {
|
|
|
1417
1424
|
// We need to send valid event even if it is the same value
|
|
1418
1425
|
this.inputValid.emit(this.valid);
|
|
1419
1426
|
};
|
|
1427
|
+
/**
|
|
1428
|
+
* Render button text
|
|
1429
|
+
* @param selectedValuesNb - nb of selected values
|
|
1430
|
+
* @returns translated message
|
|
1431
|
+
*/
|
|
1432
|
+
this.renderButtonText = (selectedValuesNb) => {
|
|
1433
|
+
let messageKey = 'editButton';
|
|
1434
|
+
if (this.disabled)
|
|
1435
|
+
messageKey = 'showButton';
|
|
1436
|
+
else if (selectedValuesNb < 1)
|
|
1437
|
+
messageKey = 'selectButton';
|
|
1438
|
+
return this.messages.input.checkbox[messageKey];
|
|
1439
|
+
};
|
|
1420
1440
|
/**
|
|
1421
1441
|
* Set input error message
|
|
1422
1442
|
*/
|
|
@@ -1428,7 +1448,13 @@ const MgInputCheckbox = class {
|
|
|
1428
1448
|
this.errorMessage = this.messages.errors.required;
|
|
1429
1449
|
}
|
|
1430
1450
|
};
|
|
1451
|
+
/**
|
|
1452
|
+
* Method to get mg-popover identifier
|
|
1453
|
+
* @returns MgPopover identifier
|
|
1454
|
+
*/
|
|
1455
|
+
this.getMgPopoverIdentifier = () => `${this.identifier}-input-mg-popover`;
|
|
1431
1456
|
this.value = undefined;
|
|
1457
|
+
this.type = checkboxTypes[0];
|
|
1432
1458
|
this.identifier = undefined;
|
|
1433
1459
|
this.name = this.identifier;
|
|
1434
1460
|
this.label = undefined;
|
|
@@ -1442,14 +1468,14 @@ const MgInputCheckbox = class {
|
|
|
1442
1468
|
this.helpText = undefined;
|
|
1443
1469
|
this.valid = undefined;
|
|
1444
1470
|
this.invalid = undefined;
|
|
1445
|
-
this.
|
|
1471
|
+
this.classCollection = new ClassList([this.baseClassName]);
|
|
1446
1472
|
this.errorMessage = undefined;
|
|
1447
1473
|
this.checkboxItems = [];
|
|
1448
1474
|
}
|
|
1449
1475
|
validateValue(newValue) {
|
|
1450
1476
|
if (isCheckboxItems(newValue)) {
|
|
1451
1477
|
this.checkboxItems = newValue.map((item, index) => ({
|
|
1452
|
-
id: `${this.identifier}_${index
|
|
1478
|
+
id: `${this.identifier}_${index}`,
|
|
1453
1479
|
title: item.title,
|
|
1454
1480
|
value: item.value,
|
|
1455
1481
|
disabled: item.disabled,
|
|
@@ -1460,6 +1486,18 @@ const MgInputCheckbox = class {
|
|
|
1460
1486
|
throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
|
|
1461
1487
|
}
|
|
1462
1488
|
}
|
|
1489
|
+
validateType(newValue) {
|
|
1490
|
+
if (!checkboxTypes.includes(newValue)) {
|
|
1491
|
+
throw new Error('<mg-input-checkbox> prop "type" must be a CheckboxType.');
|
|
1492
|
+
}
|
|
1493
|
+
else {
|
|
1494
|
+
const className = `${this.baseClassName}-multi`;
|
|
1495
|
+
if (newValue === 'multi')
|
|
1496
|
+
this.classCollection.add(className);
|
|
1497
|
+
else
|
|
1498
|
+
this.classCollection.delete(className);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1463
1501
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
1464
1502
|
this.inputs.forEach(input => {
|
|
1465
1503
|
input[prop] = newValue;
|
|
@@ -1470,9 +1508,15 @@ const MgInputCheckbox = class {
|
|
|
1470
1508
|
this.hasDisplayedError = false;
|
|
1471
1509
|
}
|
|
1472
1510
|
}
|
|
1511
|
+
validateDisabled(newValue) {
|
|
1512
|
+
const className = `${this.baseClassName}-multi-disabled`;
|
|
1513
|
+
if (newValue && this.type === 'multi')
|
|
1514
|
+
this.classCollection.add(className);
|
|
1515
|
+
else
|
|
1516
|
+
this.classCollection.delete(className);
|
|
1517
|
+
}
|
|
1473
1518
|
/**
|
|
1474
1519
|
* Public method to display errors
|
|
1475
|
-
* @returns {Promise<void>}
|
|
1476
1520
|
*/
|
|
1477
1521
|
async displayError() {
|
|
1478
1522
|
this.checkValidity();
|
|
@@ -1484,13 +1528,17 @@ const MgInputCheckbox = class {
|
|
|
1484
1528
|
*************/
|
|
1485
1529
|
/**
|
|
1486
1530
|
* Check if component props are well configured on init
|
|
1487
|
-
* @returns
|
|
1531
|
+
* @returns timeout
|
|
1488
1532
|
*/
|
|
1489
1533
|
componentWillLoad() {
|
|
1490
1534
|
// Get locales
|
|
1491
1535
|
this.messages = initLocales(this.element).messages;
|
|
1536
|
+
if (this.type === 'multi')
|
|
1537
|
+
this.element.dataset.mgPopoverGuard = this.getMgPopoverIdentifier();
|
|
1492
1538
|
// Validate
|
|
1493
1539
|
this.validateValue(this.value);
|
|
1540
|
+
this.validateDisabled(this.disabled);
|
|
1541
|
+
this.validateType(this.type);
|
|
1494
1542
|
// Check validity when component is ready
|
|
1495
1543
|
// return a promise to process action only in the FIRST render().
|
|
1496
1544
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
@@ -1499,25 +1547,48 @@ const MgInputCheckbox = class {
|
|
|
1499
1547
|
}, 0);
|
|
1500
1548
|
}
|
|
1501
1549
|
/**
|
|
1502
|
-
*
|
|
1503
|
-
* @returns
|
|
1550
|
+
* render checkbox multi element
|
|
1551
|
+
* @returns html element
|
|
1504
1552
|
*/
|
|
1505
|
-
|
|
1506
|
-
|
|
1553
|
+
renderCheckboxMulti() {
|
|
1554
|
+
const selectedValuesNb = this.checkboxItems.filter(({ value }) => value).length;
|
|
1555
|
+
return (h("div", { class: "mg-input__input-container mg-input__input-checkbox-multi" }, h("strong", null, this.messages.input.checkbox[selectedValuesNb > 1 ? 'selectedValues' : 'selectedValue'].replace('{nb}', selectedValuesNb)), h("mg-popover", { arrowHide: true, identifier: this.getMgPopoverIdentifier(), ref: el => {
|
|
1556
|
+
if (Boolean(el))
|
|
1557
|
+
this.popover = el;
|
|
1558
|
+
} }, h("mg-button", { variant: "secondary" }, h("mg-icon", { icon: "list" }), this.renderButtonText(selectedValuesNb)), h("div", { slot: "content" }, this.renderCheckboxes()))));
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Render checkbox element
|
|
1562
|
+
* @returns HTML Element
|
|
1563
|
+
*/
|
|
1564
|
+
renderCheckboxes() {
|
|
1565
|
+
return (h("ul", { class: {
|
|
1566
|
+
'mg-input__input-group-container': true,
|
|
1567
|
+
'mg-input__input-group-container--vertical': this.inputVerticalList || (this.type === 'multi' && !this.readonly),
|
|
1568
|
+
'mg-input__input-checkbox-multi-inputs': this.type === 'multi' && !this.readonly,
|
|
1569
|
+
}, role: "list" }, this.checkboxItems
|
|
1507
1570
|
.filter(item => {
|
|
1508
1571
|
return !this.readonly || item.value;
|
|
1509
1572
|
})
|
|
1510
|
-
.map((input, index) => (h("li", { key: input.id, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
1573
|
+
.map((input, index) => (h("li", { key: input.id, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeydown, ref: el => {
|
|
1511
1574
|
if (el !== null)
|
|
1512
1575
|
this.inputs[index] = el;
|
|
1513
|
-
} }), h("label", { htmlFor: input.id }, input.title))))))
|
|
1576
|
+
} }), h("label", { htmlFor: input.id }, input.title))))));
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* Render
|
|
1580
|
+
* @returns HTML Element
|
|
1581
|
+
*/
|
|
1582
|
+
render() {
|
|
1583
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, this.type === 'checkbox' || this.readonly ? this.renderCheckboxes() : this.renderCheckboxMulti()));
|
|
1514
1584
|
}
|
|
1515
1585
|
get element() { return getElement(this); }
|
|
1516
1586
|
static get watchers() { return {
|
|
1517
1587
|
"value": ["validateValue"],
|
|
1588
|
+
"type": ["validateType"],
|
|
1518
1589
|
"required": ["handleValidityChange"],
|
|
1519
1590
|
"readonly": ["handleValidityChange"],
|
|
1520
|
-
"disabled": ["handleValidityChange"]
|
|
1591
|
+
"disabled": ["handleValidityChange", "validateDisabled"]
|
|
1521
1592
|
}; }
|
|
1522
1593
|
};
|
|
1523
1594
|
MgInputCheckbox.style = mgInputCheckboxCss;
|
|
@@ -1530,7 +1601,7 @@ var InputError$1;
|
|
|
1530
1601
|
InputError["REQUIRED"] = "required";
|
|
1531
1602
|
})(InputError$1 || (InputError$1 = {}));
|
|
1532
1603
|
|
|
1533
|
-
const mgInputDateCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}";
|
|
1604
|
+
const mgInputDateCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle,.mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}";
|
|
1534
1605
|
|
|
1535
1606
|
const MgInputDate = class {
|
|
1536
1607
|
constructor(hostRef) {
|
|
@@ -1567,7 +1638,7 @@ const MgInputDate = class {
|
|
|
1567
1638
|
};
|
|
1568
1639
|
/**
|
|
1569
1640
|
* get input error code
|
|
1570
|
-
* @returns
|
|
1641
|
+
* @returns error code
|
|
1571
1642
|
*/
|
|
1572
1643
|
this.getInputError = () => {
|
|
1573
1644
|
var _a, _b;
|
|
@@ -1592,7 +1663,6 @@ const MgInputDate = class {
|
|
|
1592
1663
|
};
|
|
1593
1664
|
/**
|
|
1594
1665
|
* Check input errors
|
|
1595
|
-
* @returns {void}
|
|
1596
1666
|
*/
|
|
1597
1667
|
this.setErrorMessage = () => {
|
|
1598
1668
|
var _a;
|
|
@@ -1630,7 +1700,7 @@ const MgInputDate = class {
|
|
|
1630
1700
|
this.invalid = undefined;
|
|
1631
1701
|
this.min = undefined;
|
|
1632
1702
|
this.max = undefined;
|
|
1633
|
-
this.
|
|
1703
|
+
this.classCollection = new ClassList(['mg-input--date']);
|
|
1634
1704
|
this.errorMessage = undefined;
|
|
1635
1705
|
}
|
|
1636
1706
|
validateValue(newValue) {
|
|
@@ -1661,7 +1731,6 @@ const MgInputDate = class {
|
|
|
1661
1731
|
}
|
|
1662
1732
|
/**
|
|
1663
1733
|
* Public method to display errors
|
|
1664
|
-
* @returns {Promise<void>}
|
|
1665
1734
|
*/
|
|
1666
1735
|
async displayError() {
|
|
1667
1736
|
this.checkValidity();
|
|
@@ -1673,7 +1742,7 @@ const MgInputDate = class {
|
|
|
1673
1742
|
*************/
|
|
1674
1743
|
/**
|
|
1675
1744
|
* Check if component props are well configured on init
|
|
1676
|
-
* @returns
|
|
1745
|
+
* @returns timeout
|
|
1677
1746
|
*/
|
|
1678
1747
|
componentWillLoad() {
|
|
1679
1748
|
// Get locales
|
|
@@ -1693,10 +1762,10 @@ const MgInputDate = class {
|
|
|
1693
1762
|
}
|
|
1694
1763
|
/**
|
|
1695
1764
|
* Render
|
|
1696
|
-
* @returns
|
|
1765
|
+
* @returns HTML Element
|
|
1697
1766
|
*/
|
|
1698
1767
|
render() {
|
|
1699
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
1768
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
1700
1769
|
if (el !== null)
|
|
1701
1770
|
this.input = el;
|
|
1702
1771
|
} })));
|
|
@@ -1725,7 +1794,7 @@ var InputError;
|
|
|
1725
1794
|
InputError["REQUIRED"] = "required";
|
|
1726
1795
|
})(InputError || (InputError = {}));
|
|
1727
1796
|
|
|
1728
|
-
const mgInputNumericCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input .mg-input__box{text-align:var(--mg-inputs-text-align, right)}";
|
|
1797
|
+
const mgInputNumericCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle,.mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input .mg-input__box{text-align:var(--mg-inputs-text-align, right)}";
|
|
1729
1798
|
|
|
1730
1799
|
const MgInputNumeric = class {
|
|
1731
1800
|
constructor(hostRef) {
|
|
@@ -1736,7 +1805,6 @@ const MgInputNumeric = class {
|
|
|
1736
1805
|
this.hasDisplayedError = false;
|
|
1737
1806
|
/**
|
|
1738
1807
|
* Handle input event
|
|
1739
|
-
* @returns {void}
|
|
1740
1808
|
*/
|
|
1741
1809
|
this.handleInput = () => {
|
|
1742
1810
|
// Check validity
|
|
@@ -1748,23 +1816,22 @@ const MgInputNumeric = class {
|
|
|
1748
1816
|
};
|
|
1749
1817
|
/**
|
|
1750
1818
|
* Handle focus event
|
|
1751
|
-
* @returns {void}
|
|
1752
1819
|
*/
|
|
1753
1820
|
this.handleFocus = () => {
|
|
1754
1821
|
this.hasFocus = true;
|
|
1755
1822
|
};
|
|
1756
1823
|
/**
|
|
1757
1824
|
* Handle blur event
|
|
1758
|
-
* @returns {void}
|
|
1759
1825
|
*/
|
|
1760
1826
|
this.handleBlur = () => {
|
|
1827
|
+
if (this.value === '-')
|
|
1828
|
+
this.value = '';
|
|
1761
1829
|
// Display Error
|
|
1762
1830
|
this.displayError();
|
|
1763
1831
|
this.hasFocus = false;
|
|
1764
1832
|
};
|
|
1765
1833
|
/**
|
|
1766
1834
|
* Check if input is valid
|
|
1767
|
-
* @returns {void}
|
|
1768
1835
|
*/
|
|
1769
1836
|
this.checkValidity = () => {
|
|
1770
1837
|
this.valid = this.readonly || this.disabled || this.getInputError() === null;
|
|
@@ -1774,7 +1841,6 @@ const MgInputNumeric = class {
|
|
|
1774
1841
|
};
|
|
1775
1842
|
/**
|
|
1776
1843
|
* Set input error message
|
|
1777
|
-
* @returns {void}
|
|
1778
1844
|
*/
|
|
1779
1845
|
this.setErrorMessage = () => {
|
|
1780
1846
|
// Set error message
|
|
@@ -1791,7 +1857,7 @@ const MgInputNumeric = class {
|
|
|
1791
1857
|
};
|
|
1792
1858
|
/**
|
|
1793
1859
|
* Get input error code
|
|
1794
|
-
* @returns
|
|
1860
|
+
* @returns error code
|
|
1795
1861
|
*/
|
|
1796
1862
|
this.getInputError = () => {
|
|
1797
1863
|
let inputError = null;
|
|
@@ -1819,18 +1885,17 @@ const MgInputNumeric = class {
|
|
|
1819
1885
|
};
|
|
1820
1886
|
/**
|
|
1821
1887
|
* Format value based on type
|
|
1822
|
-
* @param
|
|
1823
|
-
* @returns
|
|
1888
|
+
* @param value - value to format
|
|
1889
|
+
* @returns formated local value
|
|
1824
1890
|
*/
|
|
1825
1891
|
this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));
|
|
1826
1892
|
/**
|
|
1827
1893
|
* Validate append slot
|
|
1828
|
-
* @returns {void}
|
|
1829
1894
|
*/
|
|
1830
1895
|
this.validateAppendSlot = () => {
|
|
1831
1896
|
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
1832
1897
|
if (slotAppendInput !== null) {
|
|
1833
|
-
this.
|
|
1898
|
+
this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
1834
1899
|
}
|
|
1835
1900
|
};
|
|
1836
1901
|
this.value = undefined;
|
|
@@ -1854,7 +1919,7 @@ const MgInputNumeric = class {
|
|
|
1854
1919
|
this.decimalLength = 2;
|
|
1855
1920
|
this.valid = undefined;
|
|
1856
1921
|
this.invalid = undefined;
|
|
1857
|
-
this.
|
|
1922
|
+
this.classCollection = new ClassList(['mg-input--numeric']);
|
|
1858
1923
|
this.errorMessage = undefined;
|
|
1859
1924
|
this.hasFocus = false;
|
|
1860
1925
|
}
|
|
@@ -1866,7 +1931,7 @@ const MgInputNumeric = class {
|
|
|
1866
1931
|
// Regex
|
|
1867
1932
|
const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+[.,]?\d*$/;
|
|
1868
1933
|
// Filter input
|
|
1869
|
-
if (
|
|
1934
|
+
if (['', '-'].includes(newValue) || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
1870
1935
|
this.storedValue = newValue;
|
|
1871
1936
|
}
|
|
1872
1937
|
else if (this.storedValue !== undefined) {
|
|
@@ -1913,7 +1978,6 @@ const MgInputNumeric = class {
|
|
|
1913
1978
|
}
|
|
1914
1979
|
/**
|
|
1915
1980
|
* Public method to display errors
|
|
1916
|
-
* @returns {Promise<void>}
|
|
1917
1981
|
*/
|
|
1918
1982
|
async displayError() {
|
|
1919
1983
|
this.checkValidity();
|
|
@@ -1923,7 +1987,7 @@ const MgInputNumeric = class {
|
|
|
1923
1987
|
/**
|
|
1924
1988
|
* Displayed value in input
|
|
1925
1989
|
* Change on focus/blur
|
|
1926
|
-
* @returns
|
|
1990
|
+
* @returns display value
|
|
1927
1991
|
*/
|
|
1928
1992
|
displayValue() {
|
|
1929
1993
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -1933,7 +1997,7 @@ const MgInputNumeric = class {
|
|
|
1933
1997
|
*************/
|
|
1934
1998
|
/**
|
|
1935
1999
|
* Check if component props are well configured on init
|
|
1936
|
-
* @returns
|
|
2000
|
+
* @returns timeout
|
|
1937
2001
|
*/
|
|
1938
2002
|
componentWillLoad() {
|
|
1939
2003
|
// Get locales
|
|
@@ -1956,10 +2020,10 @@ const MgInputNumeric = class {
|
|
|
1956
2020
|
}
|
|
1957
2021
|
/**
|
|
1958
2022
|
* Render
|
|
1959
|
-
* @returns
|
|
2023
|
+
* @returns HTML Element
|
|
1960
2024
|
*/
|
|
1961
2025
|
render() {
|
|
1962
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2026
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
|
|
1963
2027
|
if (el !== null)
|
|
1964
2028
|
this.input = el;
|
|
1965
2029
|
} }), h("slot", { name: "append-input" })));
|
|
@@ -1977,7 +2041,7 @@ const MgInputNumeric = class {
|
|
|
1977
2041
|
};
|
|
1978
2042
|
MgInputNumeric.style = mgInputNumericCss;
|
|
1979
2043
|
|
|
1980
|
-
const mgInputPasswordCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}";
|
|
2044
|
+
const mgInputPasswordCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle,.mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}";
|
|
1981
2045
|
|
|
1982
2046
|
const MgInputPassword = class {
|
|
1983
2047
|
constructor(hostRef) {
|
|
@@ -2038,7 +2102,7 @@ const MgInputPassword = class {
|
|
|
2038
2102
|
this.helpText = undefined;
|
|
2039
2103
|
this.valid = undefined;
|
|
2040
2104
|
this.invalid = undefined;
|
|
2041
|
-
this.
|
|
2105
|
+
this.classCollection = new ClassList(['mg-input--password']);
|
|
2042
2106
|
this.errorMessage = undefined;
|
|
2043
2107
|
}
|
|
2044
2108
|
handleValue(newValue) {
|
|
@@ -2056,7 +2120,6 @@ const MgInputPassword = class {
|
|
|
2056
2120
|
}
|
|
2057
2121
|
/**
|
|
2058
2122
|
* Public method to display errors
|
|
2059
|
-
* @returns {Promise<void>}
|
|
2060
2123
|
*/
|
|
2061
2124
|
async displayError() {
|
|
2062
2125
|
this.checkValidity();
|
|
@@ -2068,7 +2131,7 @@ const MgInputPassword = class {
|
|
|
2068
2131
|
*************/
|
|
2069
2132
|
/**
|
|
2070
2133
|
* Check if component props are well configured on init
|
|
2071
|
-
* @returns
|
|
2134
|
+
* @returns timeout
|
|
2072
2135
|
*/
|
|
2073
2136
|
componentWillLoad() {
|
|
2074
2137
|
// Get locales
|
|
@@ -2082,10 +2145,10 @@ const MgInputPassword = class {
|
|
|
2082
2145
|
}
|
|
2083
2146
|
/**
|
|
2084
2147
|
* Render
|
|
2085
|
-
* @returns
|
|
2148
|
+
* @returns HTML Element
|
|
2086
2149
|
*/
|
|
2087
2150
|
render() {
|
|
2088
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2151
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2089
2152
|
if (el !== null)
|
|
2090
2153
|
this.input = el;
|
|
2091
2154
|
} })));
|
|
@@ -2100,12 +2163,12 @@ const MgInputPassword = class {
|
|
|
2100
2163
|
};
|
|
2101
2164
|
MgInputPassword.style = mgInputPasswordCss;
|
|
2102
2165
|
|
|
2103
|
-
const mgInputRadioCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}fieldset.mg-input{border:0;margin-left:0;margin-right:0;padding:0}fieldset.mg-input input[type=radio],fieldset.mg-input input[type=checkbox]{flex-shrink:0;width:var(--mg-input-check-size);height:var(--mg-input-check-size);margin-top:calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);margin-right:0.6rem;margin-bottom:0;margin-left:0}fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container{margin-top:0.7rem}.mg-input__input-container mg-tooltip{margin-left:3rem}.mg-input__input-group-container{margin:0;padding:0;list-style:none;display:flex;flex-wrap:wrap;column-gap:2.3rem;row-gap:1rem;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2)}.mg-input__input-group-container--vertical{flex-direction:column}.mg-input__input-group{display:flex;align-items:top}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}";
|
|
2166
|
+
const mgInputRadioCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle,.mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}fieldset.mg-input{border:0;margin-left:0;margin-right:0;padding:0}fieldset.mg-input input[type=radio],fieldset.mg-input input[type=checkbox]{flex-shrink:0;width:var(--mg-input-check-size);height:var(--mg-input-check-size);margin-top:calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);margin-right:0.6rem;margin-bottom:0;margin-left:0}fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container{margin-top:0.7rem}.mg-input__input-container mg-tooltip{margin-left:3rem}.mg-input__input-group-container{margin:0;padding:0;list-style:none;display:flex;flex-wrap:wrap;column-gap:2.3rem;row-gap:1rem;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2)}.mg-input__input-group-container--vertical{flex-direction:column}.mg-input__input-group{display:flex;align-items:top}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}";
|
|
2104
2167
|
|
|
2105
2168
|
/**
|
|
2106
2169
|
* type Option validation function
|
|
2107
|
-
* @param
|
|
2108
|
-
* @returns
|
|
2170
|
+
* @param option - radio option
|
|
2171
|
+
* @returns radio option type is valid
|
|
2109
2172
|
*/
|
|
2110
2173
|
const isOption$2 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
2111
2174
|
const MgInputRadio = class {
|
|
@@ -2122,8 +2185,7 @@ const MgInputRadio = class {
|
|
|
2122
2185
|
this.hasDisplayedError = false;
|
|
2123
2186
|
/**
|
|
2124
2187
|
* Handle input event
|
|
2125
|
-
* @param
|
|
2126
|
-
* @returns {void}
|
|
2188
|
+
* @param event - input event
|
|
2127
2189
|
*/
|
|
2128
2190
|
this.handleInput = (event) => {
|
|
2129
2191
|
this.checkValidity();
|
|
@@ -2131,7 +2193,6 @@ const MgInputRadio = class {
|
|
|
2131
2193
|
};
|
|
2132
2194
|
/**
|
|
2133
2195
|
* Handle blur event
|
|
2134
|
-
* @returns {void}
|
|
2135
2196
|
*/
|
|
2136
2197
|
this.handleBlur = () => {
|
|
2137
2198
|
this.checkValidity();
|
|
@@ -2139,7 +2200,6 @@ const MgInputRadio = class {
|
|
|
2139
2200
|
};
|
|
2140
2201
|
/**
|
|
2141
2202
|
* Check if input is valid
|
|
2142
|
-
* @returns {void}
|
|
2143
2203
|
*/
|
|
2144
2204
|
this.checkValidity = () => {
|
|
2145
2205
|
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
@@ -2149,7 +2209,6 @@ const MgInputRadio = class {
|
|
|
2149
2209
|
};
|
|
2150
2210
|
/**
|
|
2151
2211
|
* Set input error message
|
|
2152
|
-
* @returns {void}
|
|
2153
2212
|
*/
|
|
2154
2213
|
this.setErrorMessage = () => {
|
|
2155
2214
|
const invalidElement = this.getInvalidElement();
|
|
@@ -2161,7 +2220,7 @@ const MgInputRadio = class {
|
|
|
2161
2220
|
};
|
|
2162
2221
|
/**
|
|
2163
2222
|
* get invalid element
|
|
2164
|
-
* @returns
|
|
2223
|
+
* @returns element
|
|
2165
2224
|
*/
|
|
2166
2225
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
2167
2226
|
this.value = undefined;
|
|
@@ -2179,7 +2238,7 @@ const MgInputRadio = class {
|
|
|
2179
2238
|
this.helpText = undefined;
|
|
2180
2239
|
this.valid = undefined;
|
|
2181
2240
|
this.invalid = undefined;
|
|
2182
|
-
this.
|
|
2241
|
+
this.classCollection = new ClassList(['mg-input--radio']);
|
|
2183
2242
|
this.errorMessage = undefined;
|
|
2184
2243
|
this.options = undefined;
|
|
2185
2244
|
}
|
|
@@ -2215,7 +2274,6 @@ const MgInputRadio = class {
|
|
|
2215
2274
|
}
|
|
2216
2275
|
/**
|
|
2217
2276
|
* Public method to display errors
|
|
2218
|
-
* @returns {Promise<void>}
|
|
2219
2277
|
*/
|
|
2220
2278
|
async displayError() {
|
|
2221
2279
|
this.checkValidity();
|
|
@@ -2227,7 +2285,7 @@ const MgInputRadio = class {
|
|
|
2227
2285
|
*************/
|
|
2228
2286
|
/**
|
|
2229
2287
|
* Check if component props are well configured on init
|
|
2230
|
-
* @returns
|
|
2288
|
+
* @returns timeout
|
|
2231
2289
|
*/
|
|
2232
2290
|
componentWillLoad() {
|
|
2233
2291
|
// Get locales
|
|
@@ -2243,10 +2301,10 @@ const MgInputRadio = class {
|
|
|
2243
2301
|
}
|
|
2244
2302
|
/**
|
|
2245
2303
|
* Render
|
|
2246
|
-
* @returns
|
|
2304
|
+
* @returns HTML Element
|
|
2247
2305
|
*/
|
|
2248
2306
|
render() {
|
|
2249
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2307
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => {
|
|
2250
2308
|
if (el !== null)
|
|
2251
2309
|
this.inputs[index] = el;
|
|
2252
2310
|
} }), h("label", { htmlFor: this.identifier + '_' + index }, input.title)))))));
|
|
@@ -2262,35 +2320,31 @@ const MgInputRadio = class {
|
|
|
2262
2320
|
};
|
|
2263
2321
|
MgInputRadio.style = mgInputRadioCss;
|
|
2264
2322
|
|
|
2265
|
-
const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input__box{width:100%;padding-top:0;padding-bottom:0;padding-right:1rem}.mg-input.mg-input--select:not(.mg-input--label-on-top) .mg-input__box{max-width:unset}";
|
|
2323
|
+
const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle,.mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input__box{width:100%;padding-top:0;padding-bottom:0;padding-right:1rem}.mg-input.mg-input--select:not(.mg-input--label-on-top) .mg-input__box{max-width:unset}";
|
|
2266
2324
|
|
|
2267
2325
|
/**
|
|
2268
2326
|
* Check if item is a well configured option
|
|
2269
|
-
* @param
|
|
2270
|
-
* @returns
|
|
2327
|
+
* @param option - select option
|
|
2328
|
+
* @returns select option type is valid
|
|
2271
2329
|
*/
|
|
2272
2330
|
const isOption$1 = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
2273
2331
|
/**
|
|
2274
2332
|
* Check if items[] is SelectOption
|
|
2275
|
-
* @param
|
|
2276
|
-
* @returns
|
|
2333
|
+
* @param items - select option
|
|
2334
|
+
* @returns select option array type is valid
|
|
2277
2335
|
*/
|
|
2278
2336
|
const allItemsAreOptions = (items) => Array.isArray(items) && items.every(item => isOption$1(item));
|
|
2279
2337
|
/**
|
|
2280
2338
|
* Check if item is a well configured optgroup
|
|
2281
|
-
* @param
|
|
2282
|
-
* @returns
|
|
2339
|
+
* @param optgroup - select option
|
|
2340
|
+
* @returns select optgroup type is valid
|
|
2283
2341
|
*/
|
|
2284
2342
|
const isOptGroup = (optgroup) => typeof optgroup === 'object' && typeof optgroup.group === 'string' && allItemsAreOptions(optgroup.options);
|
|
2285
2343
|
/**
|
|
2286
2344
|
* Group options
|
|
2287
|
-
* @param
|
|
2288
|
-
* @param
|
|
2289
|
-
* @
|
|
2290
|
-
* @param {string} item.title item title
|
|
2291
|
-
* @param {unknown} item.value item value
|
|
2292
|
-
* @param {boolean} item.disabled is item disabled
|
|
2293
|
-
* @returns {(SelectOption | OptGroup)[]} grouped options
|
|
2345
|
+
* @param acc - reduce accumulator
|
|
2346
|
+
* @param item - item to add
|
|
2347
|
+
* @returns grouped options
|
|
2294
2348
|
*/
|
|
2295
2349
|
const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
2296
2350
|
if (group !== undefined) {
|
|
@@ -2319,7 +2373,6 @@ const MgInputSelect = class {
|
|
|
2319
2373
|
this.hasDisplayedError = false;
|
|
2320
2374
|
/**
|
|
2321
2375
|
* Handle input event
|
|
2322
|
-
* @returns {void}
|
|
2323
2376
|
*/
|
|
2324
2377
|
this.handleInput = () => {
|
|
2325
2378
|
this.updateValue();
|
|
@@ -2328,14 +2381,13 @@ const MgInputSelect = class {
|
|
|
2328
2381
|
};
|
|
2329
2382
|
/**
|
|
2330
2383
|
* Method to compare item.title with input.value
|
|
2331
|
-
* @param
|
|
2332
|
-
* @returns
|
|
2384
|
+
* @param item - item to compare with
|
|
2385
|
+
* @returns truthy if input.value is an item
|
|
2333
2386
|
*/
|
|
2334
2387
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
2335
2388
|
/**
|
|
2336
2389
|
* value props setter
|
|
2337
|
-
* @param
|
|
2338
|
-
* @returns {void}
|
|
2390
|
+
* @param newValue - value to update with
|
|
2339
2391
|
*/
|
|
2340
2392
|
this.setValue = (newValue) => {
|
|
2341
2393
|
this.checkValidity();
|
|
@@ -2343,7 +2395,6 @@ const MgInputSelect = class {
|
|
|
2343
2395
|
};
|
|
2344
2396
|
/**
|
|
2345
2397
|
* Update value from input.value
|
|
2346
|
-
* @returns {void}
|
|
2347
2398
|
*/
|
|
2348
2399
|
this.updateValue = () => {
|
|
2349
2400
|
if (this.input.value === '') {
|
|
@@ -2369,7 +2420,7 @@ const MgInputSelect = class {
|
|
|
2369
2420
|
};
|
|
2370
2421
|
/**
|
|
2371
2422
|
* Input value is disabled
|
|
2372
|
-
* @returns
|
|
2423
|
+
* @returns truthy if input value is disabled
|
|
2373
2424
|
*/
|
|
2374
2425
|
this.isDisabledValue = () => { var _a; return allItemsAreOptions(this.options) && ((_a = this.options.find(this.isInputValue)) === null || _a === void 0 ? void 0 : _a.disabled) === true; };
|
|
2375
2426
|
/**
|
|
@@ -2394,8 +2445,8 @@ const MgInputSelect = class {
|
|
|
2394
2445
|
};
|
|
2395
2446
|
/**
|
|
2396
2447
|
* Render option
|
|
2397
|
-
* @param
|
|
2398
|
-
* @returns
|
|
2448
|
+
* @param option - to render
|
|
2449
|
+
* @returns render option
|
|
2399
2450
|
*/
|
|
2400
2451
|
this.renderOption = (option) => (h("option", { key: option.title, value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title));
|
|
2401
2452
|
this.value = undefined;
|
|
@@ -2416,7 +2467,7 @@ const MgInputSelect = class {
|
|
|
2416
2467
|
this.helpText = undefined;
|
|
2417
2468
|
this.valid = undefined;
|
|
2418
2469
|
this.invalid = undefined;
|
|
2419
|
-
this.
|
|
2470
|
+
this.classCollection = new ClassList(['mg-input--select']);
|
|
2420
2471
|
this.errorMessage = undefined;
|
|
2421
2472
|
this.options = undefined;
|
|
2422
2473
|
this.valueExist = undefined;
|
|
@@ -2474,7 +2525,6 @@ const MgInputSelect = class {
|
|
|
2474
2525
|
}
|
|
2475
2526
|
/**
|
|
2476
2527
|
* Public method to display errors
|
|
2477
|
-
* @returns {Promise<void>}
|
|
2478
2528
|
*/
|
|
2479
2529
|
async displayError() {
|
|
2480
2530
|
this.checkValidity();
|
|
@@ -2486,7 +2536,7 @@ const MgInputSelect = class {
|
|
|
2486
2536
|
*************/
|
|
2487
2537
|
/**
|
|
2488
2538
|
* Check if component props are well configured on init
|
|
2489
|
-
* @returns
|
|
2539
|
+
* @returns timeout
|
|
2490
2540
|
*/
|
|
2491
2541
|
componentWillLoad() {
|
|
2492
2542
|
// Get locales
|
|
@@ -2507,10 +2557,10 @@ const MgInputSelect = class {
|
|
|
2507
2557
|
}
|
|
2508
2558
|
/**
|
|
2509
2559
|
* Render
|
|
2510
|
-
* @returns
|
|
2560
|
+
* @returns HTML Element
|
|
2511
2561
|
*/
|
|
2512
2562
|
render() {
|
|
2513
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2563
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: undefined, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2514
2564
|
if (el !== null)
|
|
2515
2565
|
this.input = el;
|
|
2516
2566
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -2527,7 +2577,7 @@ const MgInputSelect = class {
|
|
|
2527
2577
|
};
|
|
2528
2578
|
MgInputSelect.style = mgInputSelectCss;
|
|
2529
2579
|
|
|
2530
|
-
const mgInputTextCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input.mg-input--has-icon .mg-input__with-character-left>mg-icon{position:absolute;top:50%;left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__with-character-left .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}.mg-input__with-character-left{position:relative;display:inline-flex}.mg-input--width-full .mg-input__with-character-left{width:100%}.mg-input.is-focused .mg-input__with-character-left .mg-input__box{padding-right:calc(var(--mg-character-left-message-length) * 1ch + 0.8rem)}.mg-input__with-character-left mg-character-left{position:absolute;display:none;top:50%;right:1rem;opacity:0.6;transform:translateY(-50%);font-size:1.1rem}.mg-input.is-focused .mg-input__with-character-left mg-character-left{display:block}";
|
|
2580
|
+
const mgInputTextCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle,.mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input.mg-input--has-icon .mg-input__with-character-left>mg-icon{position:absolute;top:50%;left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__with-character-left .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}.mg-input__with-character-left{position:relative;display:inline-flex}.mg-input--width-full .mg-input__with-character-left{width:100%}.mg-input.is-focused .mg-input__with-character-left .mg-input__box{padding-right:calc(var(--mg-character-left-message-length) * 1ch + 0.8rem)}.mg-input__with-character-left mg-character-left{position:absolute;display:none;top:50%;right:1rem;opacity:0.6;transform:translateY(-50%);font-size:1.1rem}.mg-input.is-focused .mg-input__with-character-left mg-character-left{display:block}";
|
|
2531
2581
|
|
|
2532
2582
|
const MgInputText = class {
|
|
2533
2583
|
constructor(hostRef) {
|
|
@@ -2545,7 +2595,6 @@ const MgInputText = class {
|
|
|
2545
2595
|
this.hasDisplayedError = false;
|
|
2546
2596
|
/**
|
|
2547
2597
|
* Handle input event
|
|
2548
|
-
* @returns {void}
|
|
2549
2598
|
*/
|
|
2550
2599
|
this.handleInput = () => {
|
|
2551
2600
|
this.checkValidity();
|
|
@@ -2556,26 +2605,23 @@ const MgInputText = class {
|
|
|
2556
2605
|
};
|
|
2557
2606
|
/**
|
|
2558
2607
|
* Handle focus event
|
|
2559
|
-
* @returns {void}
|
|
2560
2608
|
*/
|
|
2561
2609
|
this.handleFocus = () => {
|
|
2562
|
-
this.
|
|
2563
|
-
this.
|
|
2610
|
+
this.classCollection.add(this.classFocus);
|
|
2611
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2564
2612
|
};
|
|
2565
2613
|
/**
|
|
2566
2614
|
* Handle blur event
|
|
2567
|
-
* @returns {void}
|
|
2568
2615
|
*/
|
|
2569
2616
|
this.handleBlur = () => {
|
|
2570
2617
|
// Manage focus
|
|
2571
|
-
this.
|
|
2572
|
-
this.
|
|
2618
|
+
this.classCollection.delete(this.classFocus);
|
|
2619
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2573
2620
|
// Display Error
|
|
2574
2621
|
this.displayError();
|
|
2575
2622
|
};
|
|
2576
2623
|
/**
|
|
2577
2624
|
* Check if input is valid
|
|
2578
|
-
* @returns {void}
|
|
2579
2625
|
*/
|
|
2580
2626
|
this.checkValidity = () => {
|
|
2581
2627
|
var _a;
|
|
@@ -2586,7 +2632,6 @@ const MgInputText = class {
|
|
|
2586
2632
|
};
|
|
2587
2633
|
/**
|
|
2588
2634
|
* Set input error message
|
|
2589
|
-
* @returns {void}
|
|
2590
2635
|
*/
|
|
2591
2636
|
this.setErrorMessage = () => {
|
|
2592
2637
|
// Set error message
|
|
@@ -2602,7 +2647,6 @@ const MgInputText = class {
|
|
|
2602
2647
|
};
|
|
2603
2648
|
/**
|
|
2604
2649
|
* Validate pattern configuration
|
|
2605
|
-
* @returns {void}
|
|
2606
2650
|
*/
|
|
2607
2651
|
this.validatePattern = () => {
|
|
2608
2652
|
if (this.pattern !== undefined &&
|
|
@@ -2614,16 +2658,15 @@ const MgInputText = class {
|
|
|
2614
2658
|
};
|
|
2615
2659
|
/**
|
|
2616
2660
|
* Validate append slot
|
|
2617
|
-
* @returns {void}
|
|
2618
2661
|
*/
|
|
2619
2662
|
this.validateAppendSlot = () => {
|
|
2620
2663
|
const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
|
|
2621
2664
|
if (slotAppendInput.length === 1) {
|
|
2622
|
-
this.
|
|
2665
|
+
this.classCollection.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.classIsInputGroupAppend : 'mg-input--is-append-input-slot-content');
|
|
2623
2666
|
}
|
|
2624
2667
|
else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
|
|
2625
|
-
this.
|
|
2626
|
-
this.
|
|
2668
|
+
this.classCollection.add(this.classIsInputGroupAppend);
|
|
2669
|
+
this.classCollection.add('mg-input--has-buttons-group-append');
|
|
2627
2670
|
}
|
|
2628
2671
|
};
|
|
2629
2672
|
this.value = undefined;
|
|
@@ -2647,7 +2690,7 @@ const MgInputText = class {
|
|
|
2647
2690
|
this.helpText = undefined;
|
|
2648
2691
|
this.valid = undefined;
|
|
2649
2692
|
this.invalid = undefined;
|
|
2650
|
-
this.
|
|
2693
|
+
this.classCollection = new ClassList(['mg-input--text']);
|
|
2651
2694
|
this.errorMessage = undefined;
|
|
2652
2695
|
}
|
|
2653
2696
|
handleValue(newValue) {
|
|
@@ -2655,10 +2698,10 @@ const MgInputText = class {
|
|
|
2655
2698
|
}
|
|
2656
2699
|
validateIcon(newValue) {
|
|
2657
2700
|
if (newValue !== undefined) {
|
|
2658
|
-
this.
|
|
2701
|
+
this.classCollection.add(this.classHasIcon);
|
|
2659
2702
|
}
|
|
2660
2703
|
else {
|
|
2661
|
-
this.
|
|
2704
|
+
this.classCollection.delete(this.classHasIcon);
|
|
2662
2705
|
}
|
|
2663
2706
|
}
|
|
2664
2707
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -2673,14 +2716,12 @@ const MgInputText = class {
|
|
|
2673
2716
|
}
|
|
2674
2717
|
/**
|
|
2675
2718
|
* Public method to play input focus
|
|
2676
|
-
* @returns {Promise<void>}
|
|
2677
2719
|
*/
|
|
2678
2720
|
async setFocus() {
|
|
2679
2721
|
this.input.focus();
|
|
2680
2722
|
}
|
|
2681
2723
|
/**
|
|
2682
2724
|
* Public method to display errors
|
|
2683
|
-
* @returns {Promise<void>}
|
|
2684
2725
|
*/
|
|
2685
2726
|
async displayError() {
|
|
2686
2727
|
this.checkValidity();
|
|
@@ -2692,7 +2733,7 @@ const MgInputText = class {
|
|
|
2692
2733
|
*************/
|
|
2693
2734
|
/**
|
|
2694
2735
|
* Check if component props are well configured on init
|
|
2695
|
-
* @returns
|
|
2736
|
+
* @returns timeout
|
|
2696
2737
|
*/
|
|
2697
2738
|
componentWillLoad() {
|
|
2698
2739
|
// Get locales
|
|
@@ -2711,10 +2752,10 @@ const MgInputText = class {
|
|
|
2711
2752
|
}
|
|
2712
2753
|
/**
|
|
2713
2754
|
* Render
|
|
2714
|
-
* @returns
|
|
2755
|
+
* @returns HTML Element
|
|
2715
2756
|
*/
|
|
2716
2757
|
render() {
|
|
2717
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2758
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("div", { class: "mg-input__with-character-left", style: {
|
|
2718
2759
|
'--mg-character-left-message-length': (this.displayCharacterLeft
|
|
2719
2760
|
? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
|
|
2720
2761
|
: 0).toString(),
|
|
@@ -2734,7 +2775,7 @@ const MgInputText = class {
|
|
|
2734
2775
|
};
|
|
2735
2776
|
MgInputText.style = mgInputTextCss;
|
|
2736
2777
|
|
|
2737
|
-
const mgInputTextareaCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input .mg-input__box{display:block;height:auto;resize:none}.mg-input .mg-input__box.mg-input__box--resizable{resize:both}.mg-input .mg-input__box.mg-input__box--resizable-horizontal{resize:horizontal}.mg-input .mg-input__box.mg-input__box--resizable-vertical{resize:vertical}.mg-input__with-character-left{width:100%}.mg-input__with-character-left mg-character-left{display:block;visibility:hidden;margin-top:0.2rem;text-align:end}.mg-input.is-focused .mg-input__with-character-left mg-character-left{visibility:visible}@-moz-document url-prefix(){.mg-input__box{overflow-x:hidden}}";
|
|
2778
|
+
const mgInputTextareaCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle,.mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0;border-bottom-right-radius:0}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input .mg-input__box{display:block;height:auto;resize:none}.mg-input .mg-input__box.mg-input__box--resizable{resize:both}.mg-input .mg-input__box.mg-input__box--resizable-horizontal{resize:horizontal}.mg-input .mg-input__box.mg-input__box--resizable-vertical{resize:vertical}.mg-input__with-character-left{width:100%}.mg-input__with-character-left mg-character-left{display:block;visibility:hidden;margin-top:0.2rem;text-align:end}.mg-input.is-focused .mg-input__with-character-left mg-character-left{visibility:visible}@-moz-document url-prefix(){.mg-input__box{overflow-x:hidden}}";
|
|
2738
2779
|
|
|
2739
2780
|
const MgInputTextarea = class {
|
|
2740
2781
|
constructor(hostRef) {
|
|
@@ -2763,23 +2804,23 @@ const MgInputTextarea = class {
|
|
|
2763
2804
|
* Handle focus event
|
|
2764
2805
|
*/
|
|
2765
2806
|
this.handleFocus = () => {
|
|
2766
|
-
this.
|
|
2767
|
-
this.
|
|
2807
|
+
this.classCollection.add(this.classFocus);
|
|
2808
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2768
2809
|
};
|
|
2769
2810
|
/**
|
|
2770
2811
|
* Handle blur event
|
|
2771
2812
|
*/
|
|
2772
2813
|
this.handleBlur = () => {
|
|
2773
2814
|
// Manage focus
|
|
2774
|
-
this.
|
|
2775
|
-
this.
|
|
2815
|
+
this.classCollection.delete(this.classFocus);
|
|
2816
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2776
2817
|
// Display Error
|
|
2777
2818
|
this.displayError();
|
|
2778
2819
|
};
|
|
2779
2820
|
/**
|
|
2780
2821
|
* Get pattern validity
|
|
2781
2822
|
* Pattern is not defined on textarea field: https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
|
|
2782
|
-
* @returns
|
|
2823
|
+
* @returns is pattern valid
|
|
2783
2824
|
*/
|
|
2784
2825
|
this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
|
|
2785
2826
|
/**
|
|
@@ -2839,7 +2880,7 @@ const MgInputTextarea = class {
|
|
|
2839
2880
|
this.valid = undefined;
|
|
2840
2881
|
this.invalid = undefined;
|
|
2841
2882
|
this.resizable = 'none';
|
|
2842
|
-
this.
|
|
2883
|
+
this.classCollection = new ClassList(['mg-input--textarea']);
|
|
2843
2884
|
this.errorMessage = undefined;
|
|
2844
2885
|
}
|
|
2845
2886
|
handleValue(newValue) {
|
|
@@ -2858,15 +2899,14 @@ const MgInputTextarea = class {
|
|
|
2858
2899
|
}
|
|
2859
2900
|
validateDisplayCharacterLeft(newValue) {
|
|
2860
2901
|
if (newValue) {
|
|
2861
|
-
this.
|
|
2902
|
+
this.classCollection.add(this.classHasDisplayCharacterLeft);
|
|
2862
2903
|
}
|
|
2863
2904
|
else {
|
|
2864
|
-
this.
|
|
2905
|
+
this.classCollection.delete(this.classHasDisplayCharacterLeft);
|
|
2865
2906
|
}
|
|
2866
2907
|
}
|
|
2867
2908
|
/**
|
|
2868
2909
|
* Public method to display errors
|
|
2869
|
-
* @returns {Promise<void>}
|
|
2870
2910
|
*/
|
|
2871
2911
|
async displayError() {
|
|
2872
2912
|
this.checkValidity();
|
|
@@ -2878,7 +2918,7 @@ const MgInputTextarea = class {
|
|
|
2878
2918
|
*************/
|
|
2879
2919
|
/**
|
|
2880
2920
|
* Check if component props are well configured on init
|
|
2881
|
-
* @returns
|
|
2921
|
+
* @returns timeout
|
|
2882
2922
|
*/
|
|
2883
2923
|
componentWillLoad() {
|
|
2884
2924
|
// Get locales
|
|
@@ -2896,10 +2936,10 @@ const MgInputTextarea = class {
|
|
|
2896
2936
|
}
|
|
2897
2937
|
/**
|
|
2898
2938
|
* Render
|
|
2899
|
-
* @returns
|
|
2939
|
+
* @returns HTML Element
|
|
2900
2940
|
*/
|
|
2901
2941
|
render() {
|
|
2902
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
2942
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("div", { class: "mg-input__with-character-left" }, h("textarea", { class: {
|
|
2903
2943
|
'mg-input__box': true,
|
|
2904
2944
|
'mg-input__box--resizable': this.resizable === 'both',
|
|
2905
2945
|
'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
@@ -2943,7 +2983,6 @@ const MgInputTitle = class {
|
|
|
2943
2983
|
*************/
|
|
2944
2984
|
/**
|
|
2945
2985
|
* Init tag name
|
|
2946
|
-
* @returns {void}
|
|
2947
2986
|
*/
|
|
2948
2987
|
componentWillLoad() {
|
|
2949
2988
|
this.validateIdentifier(this.identifier);
|
|
@@ -2951,7 +2990,7 @@ const MgInputTitle = class {
|
|
|
2951
2990
|
}
|
|
2952
2991
|
/**
|
|
2953
2992
|
* Render
|
|
2954
|
-
* @returns
|
|
2993
|
+
* @returns HTML element
|
|
2955
2994
|
*/
|
|
2956
2995
|
render() {
|
|
2957
2996
|
const TagName = this.tagName;
|
|
@@ -2964,12 +3003,12 @@ const MgInputTitle = class {
|
|
|
2964
3003
|
};
|
|
2965
3004
|
MgInputTitle.style = mgInputTitleCss;
|
|
2966
3005
|
|
|
2967
|
-
const mgInputToggleCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input.mg-input.mg-input--toggle .mg-input__input-container{flex:auto;min-width:0}.mg-input__button-toggle{display:flex;padding:0.2rem;min-width:0;background-color:hsl(var(--color-light));border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:calc((var(--font-size) * var(--line-height) + 2 * (0.7rem + var(--mg-inputs-border-width))) / var(--mg-input-toggle-border-radius-ratio));font-family:var(--font-family);font-size:inherit;line-height:inherit;cursor:pointer}.mg-input__button-toggle:disabled{cursor:default}.mg-input__toggle-item-container{padding:0.5rem 0.9rem;border:0;box-sizing:border-box;border-radius:calc((var(--font-size) * var(--line-height) + 1rem) / var(--mg-input-toggle-border-radius-ratio));background-color:unset;font-weight:unset;color:hsl(var(--color-dark));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container{display:flex;justify-content:center;align-items:center;width:calc(var(--font-size) * var(--line-height) + 1rem);height:calc(var(--font-size) * var(--line-height) + 1rem);padding:0;visibility:hidden}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container:first-of-type{visibility:visible}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container ::slotted(mg-icon){display:flex}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{visibility:hidden}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{visibility:visible}.mg-input.mg-input--toggle-on-off .mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-dark));background-color:hsl(var(--color-dark-h), calc(var(--color-dark-s) - 30%), calc(var(--color-dark-l) + 75%))}.mg-input.mg-input--toggle-on-off.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-readonly .mg-input__button-toggle{border-color:transparent;background-color:transparent;cursor:initial}.mg-input.mg-input--toggle-readonly .mg-input__toggle-item-container:last-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{display:flex}";
|
|
3006
|
+
const mgInputToggleCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__input .mg-input__box:disabled,.mg-input__input-group--disabled label,.mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle,.mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input.mg-input.mg-input--toggle .mg-input__input-container{flex:auto;min-width:0}.mg-input__button-toggle{display:flex;padding:0.2rem;min-width:0;background-color:hsl(var(--color-light));border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:calc((var(--font-size) * var(--line-height) + 2 * (0.7rem + var(--mg-inputs-border-width))) / var(--mg-input-toggle-border-radius-ratio));font-family:var(--font-family);font-size:inherit;line-height:inherit;cursor:pointer}.mg-input__button-toggle:disabled{cursor:default}.mg-input__toggle-item-container{padding:0.5rem 0.9rem;border:0;box-sizing:border-box;border-radius:calc((var(--font-size) * var(--line-height) + 1rem) / var(--mg-input-toggle-border-radius-ratio));background-color:unset;font-weight:unset;color:hsl(var(--color-dark));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container{display:flex;justify-content:center;align-items:center;width:calc(var(--font-size) * var(--line-height) + 1rem);height:calc(var(--font-size) * var(--line-height) + 1rem);padding:0;visibility:hidden}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container:first-of-type{visibility:visible}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container ::slotted(mg-icon){display:flex}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{visibility:hidden}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{visibility:visible}.mg-input.mg-input--toggle-on-off .mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-dark));background-color:hsl(var(--color-dark-h), calc(var(--color-dark-s) - 30%), calc(var(--color-dark-l) + 75%))}.mg-input.mg-input--toggle-on-off.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-readonly .mg-input__button-toggle{border-color:transparent;background-color:transparent;cursor:initial}.mg-input.mg-input--toggle-readonly .mg-input__toggle-item-container:last-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{display:flex}";
|
|
2968
3007
|
|
|
2969
3008
|
/**
|
|
2970
3009
|
* type Option validation function
|
|
2971
|
-
* @param
|
|
2972
|
-
* @returns
|
|
3010
|
+
* @param option - radio option
|
|
3011
|
+
* @returns toggle option type is valid
|
|
2973
3012
|
*/
|
|
2974
3013
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
2975
3014
|
const MgInputToggle = class {
|
|
@@ -2988,14 +3027,12 @@ const MgInputToggle = class {
|
|
|
2988
3027
|
this.classIcon = 'mg-input--toggle-icon';
|
|
2989
3028
|
/**
|
|
2990
3029
|
* Change checked value
|
|
2991
|
-
* @returns {void}
|
|
2992
3030
|
*/
|
|
2993
3031
|
this.toggleChecked = () => {
|
|
2994
3032
|
this.checked = !this.checked;
|
|
2995
3033
|
};
|
|
2996
3034
|
/**
|
|
2997
3035
|
* Slots validation
|
|
2998
|
-
* @returns {void}
|
|
2999
3036
|
*/
|
|
3000
3037
|
this.validateSlots = () => {
|
|
3001
3038
|
const slots = Array.from(this.element.children);
|
|
@@ -3021,7 +3058,7 @@ const MgInputToggle = class {
|
|
|
3021
3058
|
this.disabled = false;
|
|
3022
3059
|
this.tooltip = undefined;
|
|
3023
3060
|
this.helpText = undefined;
|
|
3024
|
-
this.
|
|
3061
|
+
this.classCollection = new ClassList(['mg-input--toggle']);
|
|
3025
3062
|
this.options = undefined;
|
|
3026
3063
|
this.checked = false;
|
|
3027
3064
|
}
|
|
@@ -3049,40 +3086,39 @@ const MgInputToggle = class {
|
|
|
3049
3086
|
}
|
|
3050
3087
|
handleIsOnOff(newValue) {
|
|
3051
3088
|
if (newValue)
|
|
3052
|
-
this.
|
|
3089
|
+
this.classCollection.add(this.classOnOff);
|
|
3053
3090
|
else
|
|
3054
|
-
this.
|
|
3091
|
+
this.classCollection.delete(this.classOnOff);
|
|
3055
3092
|
}
|
|
3056
3093
|
handleIsIcon(newValue) {
|
|
3057
3094
|
if (newValue)
|
|
3058
|
-
this.
|
|
3095
|
+
this.classCollection.add(this.classIcon);
|
|
3059
3096
|
else
|
|
3060
|
-
this.
|
|
3097
|
+
this.classCollection.delete(this.classIcon);
|
|
3061
3098
|
}
|
|
3062
3099
|
handleReadonly(newValue) {
|
|
3063
3100
|
if (newValue)
|
|
3064
|
-
this.
|
|
3101
|
+
this.classCollection.add(this.classReadonly);
|
|
3065
3102
|
else
|
|
3066
|
-
this.
|
|
3103
|
+
this.classCollection.delete(this.classReadonly);
|
|
3067
3104
|
}
|
|
3068
3105
|
handleDisabled(newValue) {
|
|
3069
3106
|
if (newValue)
|
|
3070
|
-
this.
|
|
3107
|
+
this.classCollection.add(this.classDisabled);
|
|
3071
3108
|
else
|
|
3072
|
-
this.
|
|
3109
|
+
this.classCollection.delete(this.classDisabled);
|
|
3073
3110
|
}
|
|
3074
3111
|
handleChecked(newValue) {
|
|
3075
3112
|
// style
|
|
3076
3113
|
if (newValue)
|
|
3077
|
-
this.
|
|
3114
|
+
this.classCollection.add(this.classIsActive);
|
|
3078
3115
|
else
|
|
3079
|
-
this.
|
|
3116
|
+
this.classCollection.delete(this.classIsActive);
|
|
3080
3117
|
// update value
|
|
3081
3118
|
this.value = this.options[newValue ? 1 : 0].value;
|
|
3082
3119
|
}
|
|
3083
3120
|
/**
|
|
3084
3121
|
* set checked state
|
|
3085
|
-
* @returns {void}
|
|
3086
3122
|
*/
|
|
3087
3123
|
setChecked() {
|
|
3088
3124
|
const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);
|
|
@@ -3124,10 +3160,10 @@ const MgInputToggle = class {
|
|
|
3124
3160
|
}
|
|
3125
3161
|
/**
|
|
3126
3162
|
* Render
|
|
3127
|
-
* @returns
|
|
3163
|
+
* @returns HTML Element
|
|
3128
3164
|
*/
|
|
3129
3165
|
render() {
|
|
3130
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
3166
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-2" })))));
|
|
3131
3167
|
}
|
|
3132
3168
|
get element() { return getElement(this); }
|
|
3133
3169
|
static get watchers() { return {
|
|
@@ -3158,9 +3194,8 @@ const MgMenu = class {
|
|
|
3158
3194
|
*************/
|
|
3159
3195
|
/**
|
|
3160
3196
|
* Close matching menu-item
|
|
3161
|
-
* @param
|
|
3162
|
-
* @param
|
|
3163
|
-
* @returns {void}
|
|
3197
|
+
* @param item - menu-item to close
|
|
3198
|
+
* @param condition - addionnal condition
|
|
3164
3199
|
*/
|
|
3165
3200
|
this.closeMenuItem = (item, condition) => {
|
|
3166
3201
|
if (!this.isChildMenu && condition) {
|
|
@@ -3169,19 +3204,18 @@ const MgMenu = class {
|
|
|
3169
3204
|
};
|
|
3170
3205
|
/**
|
|
3171
3206
|
* get mg-item-more element
|
|
3172
|
-
* @returns
|
|
3207
|
+
* @returns mg-item-more element
|
|
3173
3208
|
*/
|
|
3174
3209
|
this.getItemMore = () => this.element.querySelector('mg-item-more');
|
|
3175
3210
|
/**
|
|
3176
|
-
* get mg-item-more
|
|
3177
|
-
* @returns
|
|
3211
|
+
* get mg-item-more child mg-menu-item element
|
|
3212
|
+
* @returns mg-menu-item element
|
|
3178
3213
|
*/
|
|
3179
3214
|
this.getItemMoreMenuItem = () => { var _a, _b; return (_b = (_a = this.getItemMore()) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mg-menu-item'); };
|
|
3180
3215
|
/**
|
|
3181
3216
|
* Set item listend
|
|
3182
|
-
* @param
|
|
3183
|
-
* @param
|
|
3184
|
-
* @returns {void}
|
|
3217
|
+
* @param item - mg-menu-item element
|
|
3218
|
+
* @param index - number
|
|
3185
3219
|
*/
|
|
3186
3220
|
this.setItemListener = (item, index) => {
|
|
3187
3221
|
['click', 'focus'].forEach(trigger => {
|
|
@@ -3196,7 +3230,6 @@ const MgMenu = class {
|
|
|
3196
3230
|
};
|
|
3197
3231
|
/**
|
|
3198
3232
|
* Store menu-items on component init and add listeners
|
|
3199
|
-
* @returns {void}
|
|
3200
3233
|
*/
|
|
3201
3234
|
this.initMenuItemsListeners = () => {
|
|
3202
3235
|
// add listeners on menu item and edit index
|
|
@@ -3206,14 +3239,12 @@ const MgMenu = class {
|
|
|
3206
3239
|
};
|
|
3207
3240
|
/**
|
|
3208
3241
|
* Handle item-loaded event on mg-item-more element
|
|
3209
|
-
* @returns {void}
|
|
3210
3242
|
*/
|
|
3211
3243
|
this.handleItemLoaded = () => {
|
|
3212
3244
|
this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);
|
|
3213
3245
|
};
|
|
3214
3246
|
/**
|
|
3215
3247
|
* render mg-item-more
|
|
3216
|
-
* @returns {void}
|
|
3217
3248
|
*/
|
|
3218
3249
|
this.renderMgItemMore = () => {
|
|
3219
3250
|
// /!\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement
|
|
@@ -3255,7 +3286,6 @@ const MgMenu = class {
|
|
|
3255
3286
|
*************/
|
|
3256
3287
|
/**
|
|
3257
3288
|
* Validate props
|
|
3258
|
-
* @returns {void}
|
|
3259
3289
|
*/
|
|
3260
3290
|
componentWillLoad() {
|
|
3261
3291
|
this.validateDirection(this.direction);
|
|
@@ -3265,7 +3295,7 @@ const MgMenu = class {
|
|
|
3265
3295
|
}
|
|
3266
3296
|
/**
|
|
3267
3297
|
* Check if component slots configuration
|
|
3268
|
-
* @returns
|
|
3298
|
+
* @returns timeout
|
|
3269
3299
|
*/
|
|
3270
3300
|
componentDidLoad() {
|
|
3271
3301
|
// update props and states after componentDidLoad hook
|
|
@@ -3295,14 +3325,13 @@ const MgMenu = class {
|
|
|
3295
3325
|
}
|
|
3296
3326
|
/**
|
|
3297
3327
|
* Add listeners to items
|
|
3298
|
-
* @returns {void}
|
|
3299
3328
|
*/
|
|
3300
3329
|
componentDidRender() {
|
|
3301
3330
|
this.initMenuItemsListeners();
|
|
3302
3331
|
}
|
|
3303
3332
|
/**
|
|
3304
3333
|
* Render
|
|
3305
|
-
* @returns
|
|
3334
|
+
* @returns HTML Element
|
|
3306
3335
|
*/
|
|
3307
3336
|
render() {
|
|
3308
3337
|
return (h(Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, h("slot", null)));
|
|
@@ -3334,29 +3363,27 @@ const MgMenuItem = class {
|
|
|
3334
3363
|
**********/
|
|
3335
3364
|
/**
|
|
3336
3365
|
* Toggle expanded prop value
|
|
3337
|
-
* @returns {void}
|
|
3338
3366
|
*/
|
|
3339
3367
|
this.toggleExpanded = () => {
|
|
3340
3368
|
this.expanded = !this.expanded;
|
|
3341
3369
|
};
|
|
3342
3370
|
/**
|
|
3343
3371
|
* Does an Element have given Status
|
|
3344
|
-
* @param
|
|
3345
|
-
* @param
|
|
3346
|
-
* @returns
|
|
3372
|
+
* @param mgMenuItemElement - to parse
|
|
3373
|
+
* @param status - to check
|
|
3374
|
+
* @returns true if element with status is found
|
|
3347
3375
|
*/
|
|
3348
3376
|
this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
|
|
3349
3377
|
/**
|
|
3350
3378
|
* Is component contextual direction match the given direction
|
|
3351
|
-
* @param
|
|
3352
|
-
* @param
|
|
3353
|
-
* @returns
|
|
3379
|
+
* @param direction - in parent menu
|
|
3380
|
+
* @param compareWith - direction to compare with. Default: `this.direction`
|
|
3381
|
+
* @returns true is direction match the direction propertie
|
|
3354
3382
|
*/
|
|
3355
3383
|
this.isDirection = (direction, compareWith = this.direction) => direction === compareWith;
|
|
3356
3384
|
/**
|
|
3357
3385
|
* Update displayNotificationBadge
|
|
3358
3386
|
* current component notification badge have priority over the slot badge when submenu contain badge
|
|
3359
|
-
* @returns {void} update displayNotificationBadge value
|
|
3360
3387
|
*/
|
|
3361
3388
|
this.updateDisplayNotificationBadge = () => {
|
|
3362
3389
|
const childMenu = this.element.querySelector('mg-menu');
|
|
@@ -3366,7 +3393,7 @@ const MgMenuItem = class {
|
|
|
3366
3393
|
};
|
|
3367
3394
|
/**
|
|
3368
3395
|
* Method to control if one of component children have active status
|
|
3369
|
-
* @returns
|
|
3396
|
+
* @returns truthy if component has active child
|
|
3370
3397
|
*/
|
|
3371
3398
|
this.hasActiveChild = () => {
|
|
3372
3399
|
var _a;
|
|
@@ -3374,8 +3401,7 @@ const MgMenuItem = class {
|
|
|
3374
3401
|
};
|
|
3375
3402
|
/**
|
|
3376
3403
|
* Validate slots
|
|
3377
|
-
* @param
|
|
3378
|
-
* @returns {void}
|
|
3404
|
+
* @param guard - prevent action whith guard. Default: false.
|
|
3379
3405
|
*/
|
|
3380
3406
|
this.validateSlot = (guard = false) => {
|
|
3381
3407
|
// slot title AND metadata validation
|
|
@@ -3393,8 +3419,7 @@ const MgMenuItem = class {
|
|
|
3393
3419
|
};
|
|
3394
3420
|
/**
|
|
3395
3421
|
* Update status
|
|
3396
|
-
* @param
|
|
3397
|
-
* @returns {void}
|
|
3422
|
+
* @param guard - status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
3398
3423
|
*/
|
|
3399
3424
|
this.updateStatus = (guard = []) => {
|
|
3400
3425
|
if (![Status$1.HIDDEN, Status$1.DISABLED, ...guard].includes(this.status)) {
|
|
@@ -3403,7 +3428,6 @@ const MgMenuItem = class {
|
|
|
3403
3428
|
};
|
|
3404
3429
|
/**
|
|
3405
3430
|
* Init event-listeners
|
|
3406
|
-
* @returns {void}
|
|
3407
3431
|
*/
|
|
3408
3432
|
this.initListeners = () => {
|
|
3409
3433
|
var _a;
|
|
@@ -3419,12 +3443,12 @@ const MgMenuItem = class {
|
|
|
3419
3443
|
};
|
|
3420
3444
|
/**
|
|
3421
3445
|
* Get mg-popover identifier
|
|
3422
|
-
* @returns
|
|
3446
|
+
* @returns generated mg-popover identifier
|
|
3423
3447
|
*/
|
|
3424
3448
|
this.getPopoverIdentifier = () => `${this.identifier}-popover`;
|
|
3425
3449
|
/**
|
|
3426
3450
|
* Condition to know if component should display a mg-popover
|
|
3427
|
-
* @returns
|
|
3451
|
+
* @returns truthy if component display popover
|
|
3428
3452
|
*/
|
|
3429
3453
|
this.displayPopover = () => this.isDirection(Direction.HORIZONTAL) && this.hasChildren && this.href === undefined;
|
|
3430
3454
|
/************
|
|
@@ -3432,8 +3456,7 @@ const MgMenuItem = class {
|
|
|
3432
3456
|
************/
|
|
3433
3457
|
/**
|
|
3434
3458
|
* Handle interacrtive element click
|
|
3435
|
-
* @param
|
|
3436
|
-
* @returns {void}
|
|
3459
|
+
* @param event - click on element
|
|
3437
3460
|
*/
|
|
3438
3461
|
this.handleElementCLick = (event) => {
|
|
3439
3462
|
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status$1.DISABLED) {
|
|
@@ -3446,15 +3469,14 @@ const MgMenuItem = class {
|
|
|
3446
3469
|
};
|
|
3447
3470
|
/**
|
|
3448
3471
|
* Handle popover element display-change event
|
|
3449
|
-
* @param
|
|
3450
|
-
* @returns {void}
|
|
3472
|
+
* @param event - popover display event
|
|
3451
3473
|
*/
|
|
3452
3474
|
this.handlePopoverDisplay = (event) => {
|
|
3453
3475
|
this.expanded = event.detail;
|
|
3454
3476
|
};
|
|
3455
3477
|
/**
|
|
3456
3478
|
* Render slot
|
|
3457
|
-
* @returns
|
|
3479
|
+
* @returns HTML Element
|
|
3458
3480
|
*/
|
|
3459
3481
|
this.renderSlot = () => h("slot", null);
|
|
3460
3482
|
this.identifier = createID('mg-menu-item');
|
|
@@ -3520,7 +3542,6 @@ const MgMenuItem = class {
|
|
|
3520
3542
|
}
|
|
3521
3543
|
/**
|
|
3522
3544
|
* Render popover clickoutside guard for content slot
|
|
3523
|
-
* @returns {void}
|
|
3524
3545
|
*/
|
|
3525
3546
|
updatePopoverGuard() {
|
|
3526
3547
|
if (this.displayPopover())
|
|
@@ -3533,7 +3554,6 @@ const MgMenuItem = class {
|
|
|
3533
3554
|
*************/
|
|
3534
3555
|
/**
|
|
3535
3556
|
* Validate props
|
|
3536
|
-
* @returns {void}
|
|
3537
3557
|
*/
|
|
3538
3558
|
componentWillLoad() {
|
|
3539
3559
|
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
@@ -3549,7 +3569,7 @@ const MgMenuItem = class {
|
|
|
3549
3569
|
}
|
|
3550
3570
|
/**
|
|
3551
3571
|
* Check if component slots configuration
|
|
3552
|
-
* @returns
|
|
3572
|
+
* @returns timeout
|
|
3553
3573
|
*/
|
|
3554
3574
|
componentDidLoad() {
|
|
3555
3575
|
// validation
|
|
@@ -3588,7 +3608,7 @@ const MgMenuItem = class {
|
|
|
3588
3608
|
}
|
|
3589
3609
|
/**
|
|
3590
3610
|
* Render ineractive element
|
|
3591
|
-
* @returns
|
|
3611
|
+
* @returns HTML Element
|
|
3592
3612
|
*/
|
|
3593
3613
|
renderInteractiveElement() {
|
|
3594
3614
|
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
@@ -3600,7 +3620,7 @@ const MgMenuItem = class {
|
|
|
3600
3620
|
}
|
|
3601
3621
|
/**
|
|
3602
3622
|
* Render
|
|
3603
|
-
* @returns
|
|
3623
|
+
* @returns HTML Element
|
|
3604
3624
|
*/
|
|
3605
3625
|
render() {
|
|
3606
3626
|
const getContainerClasses = () => ({
|
|
@@ -3628,7 +3648,7 @@ MgMenuItem.style = mgMenuItemCss;
|
|
|
3628
3648
|
*/
|
|
3629
3649
|
const variants$1 = ['info', 'warning', 'success', 'danger'];
|
|
3630
3650
|
|
|
3631
|
-
const mgMessageCss = ":host{--mg-card-padding:0;--mg-card-border-radius:var(--mg-message-border-radius);--mg-card-border:none;--mg-card-overflow:hidden}.mg-message{display:inline-block;min-height:var(--default-size)}.mg-message.mg-message--info .mg-message__icon{color:hsl(var(--color-info))}.mg-message.mg-message--warning .mg-message__icon{color:hsl(var(--color-warning))}.mg-message.mg-message--success .mg-message__icon{color:hsl(var(--color-success))}.mg-message.mg-message--danger .mg-message__icon{color:hsl(var(--color-danger))}.mg-message.mg-message--close-button{--mg-card-padding:0 3.4rem 0 0}.mg-message.mg-message--hide{display:none}.mg-message ::slotted(*){margin:0;padding:0}.mg-message__icon{position:absolute;top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);left:1.3rem;line-height:1}.mg-message__content{display:flex;flex-wrap:wrap;justify-content:flex-end;align-content:stretch;padding:0 1rem 0 3.8rem}.mg-message__content-slot{flex-grow:1;margin:0.84rem 0}.mg-message__content-separator{display:inline-block;width:4.5rem;height:0}.mg-message__content-actions-slot{padding:1rem 0;text-align:right}.mg-message__close-button{position:absolute;top:0;right:0}.mg-message ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default);--mg-card-max-width:unset}.mg-message,mg-message{max-width:100%}";
|
|
3651
|
+
const mgMessageCss = ":host{--mg-card-padding:0;--mg-card-border-radius:var(--mg-message-border-radius);--mg-card-border:none;--mg-card-overflow:hidden}.mg-message{display:inline-block;min-height:var(--default-size)}.mg-message.mg-message--info .mg-message__icon{color:hsl(var(--color-info))}.mg-message.mg-message--warning .mg-message__icon{color:hsl(var(--color-warning))}.mg-message.mg-message--success .mg-message__icon{color:hsl(var(--color-success))}.mg-message.mg-message--danger .mg-message__icon{color:hsl(var(--color-danger))}.mg-message.mg-message--close-button{--mg-card-padding:0 3.4rem 0 0}.mg-message.mg-message--hide{display:none}.mg-message ::slotted(*){margin:0;padding:0}.mg-message__icon{position:absolute;top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);left:1.3rem;line-height:1}.mg-message__content{display:flex;flex-wrap:wrap;justify-content:flex-end;align-content:stretch;padding:0 1rem 0 3.8rem}.mg-message__content-slot{flex-grow:1;margin:0.84rem 0}.mg-message__content-separator{display:inline-block;width:4.5rem;height:0}.mg-message__content-actions-slot{padding:1rem 0;text-align:right}.mg-message__close-button{position:absolute;top:0;right:0}.mg-message ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default);--mg-card-max-width:unset;--mg-card-min-width:unset}.mg-message,mg-message{max-width:100%}";
|
|
3632
3652
|
|
|
3633
3653
|
const MgMessage = class {
|
|
3634
3654
|
constructor(hostRef) {
|
|
@@ -3649,22 +3669,19 @@ const MgMessage = class {
|
|
|
3649
3669
|
this.isHovered = false;
|
|
3650
3670
|
/**
|
|
3651
3671
|
* Set timer
|
|
3652
|
-
* @returns {void}
|
|
3653
3672
|
*/
|
|
3654
3673
|
this.setTimer = () => {
|
|
3655
3674
|
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
3656
3675
|
};
|
|
3657
3676
|
/**
|
|
3658
3677
|
* Clear timer
|
|
3659
|
-
* @returns {void}
|
|
3660
3678
|
*/
|
|
3661
3679
|
this.clearTimer = () => {
|
|
3662
3680
|
clearTimeout(this.storedTimer);
|
|
3663
3681
|
};
|
|
3664
3682
|
/**
|
|
3665
3683
|
* Event to add on element
|
|
3666
|
-
* @param
|
|
3667
|
-
* @returns {void}
|
|
3684
|
+
* @param event - event
|
|
3668
3685
|
*/
|
|
3669
3686
|
this.timerEvents = (event) => {
|
|
3670
3687
|
this.clearTimer();
|
|
@@ -3687,7 +3704,7 @@ const MgMessage = class {
|
|
|
3687
3704
|
};
|
|
3688
3705
|
/**
|
|
3689
3706
|
* Get icon corresponding to variant
|
|
3690
|
-
* @returns
|
|
3707
|
+
* @returns icon
|
|
3691
3708
|
*/
|
|
3692
3709
|
this.getIcon = () => {
|
|
3693
3710
|
switch (this.variant) {
|
|
@@ -3706,7 +3723,7 @@ const MgMessage = class {
|
|
|
3706
3723
|
this.variant = variants$1[0];
|
|
3707
3724
|
this.closeButton = false;
|
|
3708
3725
|
this.hide = false;
|
|
3709
|
-
this.
|
|
3726
|
+
this.classCollection = new ClassList(['mg-message']);
|
|
3710
3727
|
this.hasActions = false;
|
|
3711
3728
|
}
|
|
3712
3729
|
validateDelay(newValue) {
|
|
@@ -3720,9 +3737,9 @@ const MgMessage = class {
|
|
|
3720
3737
|
}
|
|
3721
3738
|
else {
|
|
3722
3739
|
if (oldValue !== undefined) {
|
|
3723
|
-
this.
|
|
3740
|
+
this.classCollection.delete(`mg-message--${oldValue}`);
|
|
3724
3741
|
}
|
|
3725
|
-
this.
|
|
3742
|
+
this.classCollection.add(`mg-message--${newValue}`);
|
|
3726
3743
|
}
|
|
3727
3744
|
}
|
|
3728
3745
|
validateCloseButton(newValue) {
|
|
@@ -3734,7 +3751,7 @@ const MgMessage = class {
|
|
|
3734
3751
|
validateHide(newValue) {
|
|
3735
3752
|
if (newValue) {
|
|
3736
3753
|
this.componentHide.emit();
|
|
3737
|
-
this.
|
|
3754
|
+
this.classCollection.add(this.classHide);
|
|
3738
3755
|
// Remove event Listener
|
|
3739
3756
|
['focusin', 'mouseenter'].forEach(event => {
|
|
3740
3757
|
this.element.removeEventListener(event, this.timerEvents);
|
|
@@ -3744,7 +3761,7 @@ const MgMessage = class {
|
|
|
3744
3761
|
}
|
|
3745
3762
|
else {
|
|
3746
3763
|
this.componentShow.emit();
|
|
3747
|
-
this.
|
|
3764
|
+
this.classCollection.delete(this.classHide);
|
|
3748
3765
|
// If delay is set
|
|
3749
3766
|
if (this.delay > 1) {
|
|
3750
3767
|
// Start timer
|
|
@@ -3771,7 +3788,7 @@ const MgMessage = class {
|
|
|
3771
3788
|
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
3772
3789
|
this.validateCloseButton(this.closeButton);
|
|
3773
3790
|
if (this.closeButton) {
|
|
3774
|
-
this.
|
|
3791
|
+
this.classCollection.add('mg-message--close-button');
|
|
3775
3792
|
this.closeButtonId = `${this.identifier}-close-button`;
|
|
3776
3793
|
}
|
|
3777
3794
|
this.validateDelay(this.delay);
|
|
@@ -3779,10 +3796,10 @@ const MgMessage = class {
|
|
|
3779
3796
|
}
|
|
3780
3797
|
/**
|
|
3781
3798
|
* Render
|
|
3782
|
-
* @returns
|
|
3799
|
+
* @returns HTML Element
|
|
3783
3800
|
*/
|
|
3784
3801
|
render() {
|
|
3785
|
-
return (h("div", { id: this.identifier, class: this.
|
|
3802
|
+
return (h("div", { id: this.identifier, class: this.classCollection.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("mg-card", { variant: this.variant, "variant-style": "bar-left" }, h("span", { class: "mg-message__icon" }, h("mg-icon", { icon: this.getIcon() })), h("div", { class: "mg-message__content" }, h("span", { class: "mg-message__content-slot" }, h("slot", null)), this.hasActions && h("span", { class: "mg-message__content-separator" }), this.hasActions && (h("span", { class: "mg-message__content-actions-slot" }, h("slot", { name: "actions" })))), this.closeButton && (h("span", { class: "mg-message__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))))));
|
|
3786
3803
|
}
|
|
3787
3804
|
get element() { return getElement(this); }
|
|
3788
3805
|
static get watchers() { return {
|
|
@@ -3794,7 +3811,7 @@ const MgMessage = class {
|
|
|
3794
3811
|
};
|
|
3795
3812
|
MgMessage.style = mgMessageCss;
|
|
3796
3813
|
|
|
3797
|
-
const mgModalCss = ":host{--mg-card-border-radius:var(--mg-modal-border-radius);--mg-card-padding:1.5rem 2.5rem;--mg-card-border:none}.mg-modal{display:flex;justify-content:center;align-items:center;position:fixed;top:0;right:0;bottom:0;left:0;z-index:2000;padding:2rem 0;background-color:hsl(var(--color-light), 0.85)}.mg-modal mg-card{display:flex;width:60rem;max-width:100%;max-height:100%}.mg-modal__dialog{display:flex;position:relative;flex-direction:column;align-self:center;row-gap:3rem;height:fit-content;max-height:100%}.mg-modal__header{margin-bottom:0.5rem}.mg-modal__title{margin:0;font-family:var(--font-family-heading);font-size:var(--mg-modal-title-font-size);font-weight:600}.mg-modal__close-button{float:right;height:var(--mg-modal-title-font-size);margin-top:calc((var(--default-size) - var(--mg-modal-title-font-size) * var(--line-height)) / 2 * -1);margin-right:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2 * -1)}.mg-modal__content{overflow-y:auto}.mg-modal__content::slotted(*){font-size:var(--mg-modal-content-font-size)}.mg-modal.mg-modal--hide{display:none}.mg-modal ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default);--mg-card-max-width:unset}";
|
|
3814
|
+
const mgModalCss = ":host{--mg-card-border-radius:var(--mg-modal-border-radius);--mg-card-padding:1.5rem 2.5rem;--mg-card-border:none}.mg-modal{display:flex;justify-content:center;align-items:center;position:fixed;top:0;right:0;bottom:0;left:0;z-index:2000;padding:2rem 0;background-color:hsl(var(--color-light), 0.85)}.mg-modal mg-card{display:flex;width:60rem;max-width:100%;max-height:100%}.mg-modal__dialog{display:flex;position:relative;flex-direction:column;align-self:center;row-gap:3rem;height:fit-content;max-height:100%}.mg-modal__header{margin-bottom:0.5rem}.mg-modal__title{margin:0;font-family:var(--font-family-heading);font-size:var(--mg-modal-title-font-size);font-weight:600}.mg-modal__close-button{float:right;height:var(--mg-modal-title-font-size);margin-top:calc((var(--default-size) - var(--mg-modal-title-font-size) * var(--line-height)) / 2 * -1);margin-right:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2 * -1)}.mg-modal__content{overflow-y:auto}.mg-modal__content::slotted(*){font-size:var(--mg-modal-content-font-size)}.mg-modal.mg-modal--hide{display:none}.mg-modal ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default);--mg-card-max-width:unset;--mg-card-min-width:unset}";
|
|
3798
3815
|
|
|
3799
3816
|
const MgModal = class {
|
|
3800
3817
|
constructor(hostRef) {
|
|
@@ -3842,7 +3859,6 @@ const MgModal = class {
|
|
|
3842
3859
|
*************/
|
|
3843
3860
|
/**
|
|
3844
3861
|
* Handle close button
|
|
3845
|
-
* @returns {void}
|
|
3846
3862
|
*/
|
|
3847
3863
|
this.handleClose = () => {
|
|
3848
3864
|
this.hide = true;
|
|
@@ -3853,7 +3869,7 @@ const MgModal = class {
|
|
|
3853
3869
|
this.hide = false;
|
|
3854
3870
|
this.hasActions = false;
|
|
3855
3871
|
this.hasContent = false;
|
|
3856
|
-
this.
|
|
3872
|
+
this.classCollection = new ClassList(['mg-modal']);
|
|
3857
3873
|
}
|
|
3858
3874
|
validateModalTitle(newValue) {
|
|
3859
3875
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -3863,19 +3879,18 @@ const MgModal = class {
|
|
|
3863
3879
|
validateHide(newValue) {
|
|
3864
3880
|
if (newValue) {
|
|
3865
3881
|
this.componentHide.emit();
|
|
3866
|
-
this.
|
|
3882
|
+
this.classCollection.add(this.classHide);
|
|
3867
3883
|
document.body.style.overflow = this.bodyOverflow;
|
|
3868
3884
|
}
|
|
3869
3885
|
else {
|
|
3870
3886
|
this.componentShow.emit();
|
|
3871
|
-
this.
|
|
3887
|
+
this.classCollection.delete(this.classHide);
|
|
3872
3888
|
document.body.style.overflow = 'hidden';
|
|
3873
3889
|
}
|
|
3874
3890
|
}
|
|
3875
3891
|
/**
|
|
3876
3892
|
* Handle 'escape' key down
|
|
3877
|
-
* @param
|
|
3878
|
-
* @returns {void}
|
|
3893
|
+
* @param event - keydown event
|
|
3879
3894
|
*/
|
|
3880
3895
|
handleKeyDown(event) {
|
|
3881
3896
|
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
@@ -3888,7 +3903,6 @@ const MgModal = class {
|
|
|
3888
3903
|
*************/
|
|
3889
3904
|
/**
|
|
3890
3905
|
* Check if component props are well configured on init
|
|
3891
|
-
* @returns {void}
|
|
3892
3906
|
*/
|
|
3893
3907
|
componentWillLoad() {
|
|
3894
3908
|
// Store body overflow
|
|
@@ -3907,7 +3921,6 @@ const MgModal = class {
|
|
|
3907
3921
|
}
|
|
3908
3922
|
/**
|
|
3909
3923
|
* Add observer on component to set focus when displayed
|
|
3910
|
-
* @returns {void}
|
|
3911
3924
|
*/
|
|
3912
3925
|
componentDidLoad() {
|
|
3913
3926
|
new MutationObserver(mutationList => {
|
|
@@ -3922,10 +3935,10 @@ const MgModal = class {
|
|
|
3922
3935
|
}
|
|
3923
3936
|
/**
|
|
3924
3937
|
* Render
|
|
3925
|
-
* @returns
|
|
3938
|
+
* @returns HTML Element
|
|
3926
3939
|
*/
|
|
3927
3940
|
render() {
|
|
3928
|
-
return (h("div", { role: "alertdialog", id: this.identifier, class: this.
|
|
3941
|
+
return (h("div", { role: "alertdialog", id: this.identifier, class: this.classCollection.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, h("mg-card", null, h("div", { class: "mg-modal__dialog" }, h("header", { class: "mg-modal__header" }, this.closeButton && (h("span", { class: "mg-modal__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))), h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (h("article", { class: "mg-modal__content" }, h("slot", { name: "content" }))), this.hasActions && (h("footer", { class: "mg-modal__footer" }, h("slot", { name: "actions" })))))));
|
|
3929
3942
|
}
|
|
3930
3943
|
get element() { return getElement(this); }
|
|
3931
3944
|
static get watchers() { return {
|
|
@@ -3946,6 +3959,7 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
3946
3959
|
/**
|
|
3947
3960
|
* Range generator
|
|
3948
3961
|
*
|
|
3962
|
+
* ```
|
|
3949
3963
|
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
3950
3964
|
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
3951
3965
|
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
@@ -3953,14 +3967,15 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
3953
3967
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
3954
3968
|
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
3955
3969
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
3970
|
+
* ```
|
|
3956
3971
|
*
|
|
3957
3972
|
* range(1, 1) = [1]
|
|
3958
3973
|
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
3959
3974
|
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
3960
|
-
* @param
|
|
3961
|
-
* @param
|
|
3962
|
-
* @param
|
|
3963
|
-
* @returns
|
|
3975
|
+
* @param start - start range
|
|
3976
|
+
* @param end - start end
|
|
3977
|
+
* @param step - step size
|
|
3978
|
+
* @returns range numbers
|
|
3964
3979
|
*/
|
|
3965
3980
|
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
3966
3981
|
const MgPagination = class {
|
|
@@ -3969,8 +3984,7 @@ const MgPagination = class {
|
|
|
3969
3984
|
this.currentPageChange = createEvent(this, "current-page-change", 7);
|
|
3970
3985
|
/**
|
|
3971
3986
|
* Change current page from target
|
|
3972
|
-
* @param
|
|
3973
|
-
* @returns {void}
|
|
3987
|
+
* @param target - target page
|
|
3974
3988
|
*/
|
|
3975
3989
|
this.goToPage = (target) => {
|
|
3976
3990
|
this.currentPage = target;
|
|
@@ -3980,8 +3994,7 @@ const MgPagination = class {
|
|
|
3980
3994
|
************/
|
|
3981
3995
|
/**
|
|
3982
3996
|
* select handler
|
|
3983
|
-
* @param
|
|
3984
|
-
* @returns {void}
|
|
3997
|
+
* @param event - value change event
|
|
3985
3998
|
*/
|
|
3986
3999
|
this.handleSelect = (event) => {
|
|
3987
4000
|
const to = Number(event.target.value);
|
|
@@ -3989,9 +4002,8 @@ const MgPagination = class {
|
|
|
3989
4002
|
};
|
|
3990
4003
|
/**
|
|
3991
4004
|
* Go to 'previous/next' page button handler
|
|
3992
|
-
* @param
|
|
3993
|
-
* @param
|
|
3994
|
-
* @returns {void}
|
|
4005
|
+
* @param action - navigation action
|
|
4006
|
+
* @param disabled - button disable state
|
|
3995
4007
|
*/
|
|
3996
4008
|
this.handleGoToPage = (action, disabled) => {
|
|
3997
4009
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
@@ -4021,7 +4033,6 @@ const MgPagination = class {
|
|
|
4021
4033
|
*************/
|
|
4022
4034
|
/**
|
|
4023
4035
|
* Check if props are well configured on init
|
|
4024
|
-
* @returns {void}
|
|
4025
4036
|
*/
|
|
4026
4037
|
componentWillLoad() {
|
|
4027
4038
|
// Get locales
|
|
@@ -4036,7 +4047,7 @@ const MgPagination = class {
|
|
|
4036
4047
|
}
|
|
4037
4048
|
/**
|
|
4038
4049
|
* Render
|
|
4039
|
-
* @returns
|
|
4050
|
+
* @returns HTML Element
|
|
4040
4051
|
*/
|
|
4041
4052
|
render() {
|
|
4042
4053
|
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
|
|
@@ -4052,7 +4063,7 @@ const MgPagination = class {
|
|
|
4052
4063
|
};
|
|
4053
4064
|
MgPagination.style = mgPaginationCss;
|
|
4054
4065
|
|
|
4055
|
-
const mgPanelCss = ":host{--mg-card-border:none;--mg-card-padding:0;--mg-card-border-radius:var(--mg-panel-border-radius);--mg-card-background:hsl(var(--mg-panel-background));--mg-card-box-shadow:var(--mg-panel-box-shadow)}.mg-panel__header{display:flex;flex-wrap:wrap;justify-content:space-between;padding:0 1rem 0 0.3rem;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:flex;margin:0.3rem 0}.mg-panel__header-right{padding-left:0.3rem;flex:1 auto;min-height:var(--default-size);align-items:center}.mg-panel__header-left mg-input-text{flex-grow:1;margin-left:0.3rem}.mg-panel__header-left mg-button+mg-button:not([slot=append-input]){margin-left:0.3rem}.mg-panel__header-left.mg-panel__header-left--full{flex:1 1 auto}.mg-panel__collapse-button-content{--font-size:1.4rem;--mg-button-font-weight:600}.mg-panel__content{padding:var(--mg-panel-content-padding)}.mg-panel ::slotted([slot=header-right]){display:flex;flex-wrap:wrap;gap:1rem;margin-left:auto}.mg-panel ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default);--mg-card-max-width:unset}";
|
|
4066
|
+
const mgPanelCss = ":host{--mg-card-border:none;--mg-card-padding:0;--mg-card-border-radius:var(--mg-panel-border-radius);--mg-card-background:hsl(var(--mg-panel-background));--mg-card-box-shadow:var(--mg-panel-box-shadow)}.mg-panel__header{display:flex;flex-wrap:wrap;justify-content:space-between;padding:0 1rem 0 0.3rem;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:flex;margin:0.3rem 0}.mg-panel__header-right{padding-left:0.3rem;flex:1 auto;min-height:var(--default-size);align-items:center}.mg-panel__header-left mg-input-text{flex-grow:1;margin-left:0.3rem}.mg-panel__header-left mg-button+mg-button:not([slot=append-input]){margin-left:0.3rem}.mg-panel__header-left.mg-panel__header-left--full{flex:1 1 auto}.mg-panel__collapse-button-content{--font-size:1.4rem;--mg-button-font-weight:600}.mg-panel__content{padding:var(--mg-panel-content-padding)}.mg-panel ::slotted([slot=header-right]){display:flex;flex-wrap:wrap;gap:1rem;margin-left:auto}.mg-panel ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default);--mg-card-max-width:unset;--mg-card-min-width:unset}";
|
|
4056
4067
|
|
|
4057
4068
|
const MgPanel = class {
|
|
4058
4069
|
constructor(hostRef) {
|
|
@@ -4064,7 +4075,6 @@ const MgPanel = class {
|
|
|
4064
4075
|
************/
|
|
4065
4076
|
/**
|
|
4066
4077
|
* Toggle is editing state
|
|
4067
|
-
* @returns {void}
|
|
4068
4078
|
*/
|
|
4069
4079
|
this.toggleIsEditing = () => {
|
|
4070
4080
|
this.isEditing = !this.isEditing;
|
|
@@ -4074,7 +4084,6 @@ const MgPanel = class {
|
|
|
4074
4084
|
************/
|
|
4075
4085
|
/**
|
|
4076
4086
|
* Collapse button click handler
|
|
4077
|
-
* @returns {void}
|
|
4078
4087
|
*/
|
|
4079
4088
|
this.handleCollapseButton = () => {
|
|
4080
4089
|
if (!this.expandToggleDisabled) {
|
|
@@ -4083,22 +4092,19 @@ const MgPanel = class {
|
|
|
4083
4092
|
};
|
|
4084
4093
|
/**
|
|
4085
4094
|
* Edit button click handler
|
|
4086
|
-
* @returns {void}
|
|
4087
4095
|
*/
|
|
4088
4096
|
this.handleEditButton = () => {
|
|
4089
4097
|
this.toggleIsEditing();
|
|
4090
4098
|
};
|
|
4091
4099
|
/**
|
|
4092
4100
|
* Update title handler
|
|
4093
|
-
* @param
|
|
4094
|
-
* @returns {void}
|
|
4101
|
+
* @param event - input value change event
|
|
4095
4102
|
*/
|
|
4096
4103
|
this.handleUpdateTitle = (event) => {
|
|
4097
4104
|
this.updatedPanelTitle = event.detail;
|
|
4098
4105
|
};
|
|
4099
4106
|
/**
|
|
4100
4107
|
* Cancel edition button handler
|
|
4101
|
-
* @returns {void}
|
|
4102
4108
|
*/
|
|
4103
4109
|
this.handleCancelEditButton = () => {
|
|
4104
4110
|
this.updatedPanelTitle = undefined;
|
|
@@ -4106,7 +4112,6 @@ const MgPanel = class {
|
|
|
4106
4112
|
};
|
|
4107
4113
|
/**
|
|
4108
4114
|
* Validate edition button handler
|
|
4109
|
-
* @returns {void}
|
|
4110
4115
|
*/
|
|
4111
4116
|
this.handleValidateEditButton = () => {
|
|
4112
4117
|
if (this.editInputElement.valid) {
|
|
@@ -4117,8 +4122,7 @@ const MgPanel = class {
|
|
|
4117
4122
|
};
|
|
4118
4123
|
/**
|
|
4119
4124
|
* Header left conditional render
|
|
4120
|
-
* @
|
|
4121
|
-
* @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
|
|
4125
|
+
* @returns header left element
|
|
4122
4126
|
*/
|
|
4123
4127
|
this.headerLeft = () => {
|
|
4124
4128
|
const collapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", identifier: `${this.identifier}-collapse-button`, "aria-expanded": this.expanded !== undefined && this.expanded.toString(), "aria-controls": `${this.identifier}-content`, disabled: this.expandToggleDisabled }, h("span", { class: "mg-panel__collapse-button-content" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle)));
|
|
@@ -4143,7 +4147,7 @@ const MgPanel = class {
|
|
|
4143
4147
|
this.expanded = false;
|
|
4144
4148
|
this.expandToggleDisabled = undefined;
|
|
4145
4149
|
this.titleEditable = false;
|
|
4146
|
-
this.
|
|
4150
|
+
this.classCollection = new ClassList(['mg-panel']);
|
|
4147
4151
|
this.isEditing = false;
|
|
4148
4152
|
this.updatedPanelTitle = undefined;
|
|
4149
4153
|
}
|
|
@@ -4169,7 +4173,6 @@ const MgPanel = class {
|
|
|
4169
4173
|
*************/
|
|
4170
4174
|
/**
|
|
4171
4175
|
* Check if props are well configured on init
|
|
4172
|
-
* @returns {void}
|
|
4173
4176
|
*/
|
|
4174
4177
|
componentWillLoad() {
|
|
4175
4178
|
// Get locales
|
|
@@ -4180,7 +4183,6 @@ const MgPanel = class {
|
|
|
4180
4183
|
}
|
|
4181
4184
|
/**
|
|
4182
4185
|
* Edit DOM after render
|
|
4183
|
-
* @returns {void}
|
|
4184
4186
|
*/
|
|
4185
4187
|
componentDidRender() {
|
|
4186
4188
|
// when we are editing we get focus on edition input
|
|
@@ -4190,10 +4192,10 @@ const MgPanel = class {
|
|
|
4190
4192
|
}
|
|
4191
4193
|
/**
|
|
4192
4194
|
* Render component
|
|
4193
|
-
* @returns
|
|
4195
|
+
* @returns html element
|
|
4194
4196
|
*/
|
|
4195
4197
|
render() {
|
|
4196
|
-
return (h("section", { class: this.
|
|
4198
|
+
return (h("section", { class: this.classCollection.join(), id: this.identifier }, h("mg-card", null, h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), h("div", { class: "mg-panel__header-right" }, h("slot", { name: "header-right" }))), h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, h("slot", null)))));
|
|
4197
4199
|
}
|
|
4198
4200
|
get element() { return getElement(this); }
|
|
4199
4201
|
static get watchers() { return {
|
|
@@ -6001,7 +6003,7 @@ var createPopper = /*#__PURE__*/popperGenerator({
|
|
|
6001
6003
|
defaultModifiers: defaultModifiers
|
|
6002
6004
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
6003
6005
|
|
|
6004
|
-
const mgPopoverCss = ":host{--mg-card-padding:var(--mg-popover-padding-vertical, 1.5rem) var(--mg-popover-padding-horizontal, var(--mg-popover-padding-vertical, 1.5rem));--mg-card-border:none;--mg-card-border-radius:0.5rem;--mg-card-background:hsl(var(--mg-popover-background-color));position:relative;display:contents}:host::slotted(*){display:inline-block}.mg-popover{display:none;padding:1rem;z-index:2000;color:hsl(var(--mg-popover-font-color))}.mg-popover mg-card{--mg-card-max-width:var(--mg-popover-max-width);position:relative}.mg-popover[data-show]{display:block}.mg-popover mg-button{float:right;margin-right:calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);margin-top:calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);margin-left:3rem}.mg-popover__arrow{position:absolute;visibility:hidden;width:calc(3rem + 2 * var(--mg-card-border-radius) + 2rem);height:calc(3rem + 2 * var(--mg-card-border-radius) + 2rem)}.mg-popover__arrow:before{visibility:visible;content:\"\";position:absolute}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow,.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{height:1rem}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow:before{left:calc(var(--mg-card-border-radius) + 1rem);border-right:calc(3rem / 2) solid transparent;border-left:calc(3rem / 2) solid transparent}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow{bottom:0.1rem;filter:drop-shadow(0 0.5rem 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow:before{border-top:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{top:0.1rem;filter:drop-shadow(0 -0.5rem 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow:before{border-bottom:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{width:1rem}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right]>.mg-popover__arrow:before{top:calc(var(--mg-card-border-radius) + 1rem);border-top:calc(3rem / 2) solid transparent;border-bottom:calc(3rem / 2) solid transparent}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow{right:0.1rem;filter:drop-shadow(0.5rem 0 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow:before{border-left:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{left:0.1rem;filter:drop-shadow(-0.5rem 0 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow:before{border-right:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=left-start],.mg-popover[data-popper-placement^=left-end],.mg-popover[data-popper-placement^=right-start],.mg-popover[data-popper-placement^=right-end]{padding:0 1rem}.mg-popover[data-popper-placement^=left-start]>.mg-popover__arrow,.mg-popover[data-popper-placement^=left-end]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right-start]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right-end]>.mg-popover__arrow{height:calc(3rem + 2 * var(--mg-card-border-radius))}.mg-popover[data-popper-placement^=left-start]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=left-end]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right-start]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right-end]>.mg-popover__arrow:before{top:var(--mg-card-border-radius)}.mg-popover__title ::slotted([slot=title]){margin:0 0 1rem !important;font-size:var(--mg-popover-title-font-size) !important;font-weight:600}.mg-popover--arrow-hide.mg-popover[data-popper-placement^=top]{padding-bottom:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement^=bottom]{padding-top:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement$=end],.mg-popover--arrow-hide.mg-popover[data-popper-placement^=left]{padding-right:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement$=start],.mg-popover--arrow-hide.mg-popover[data-popper-placement^=right]{padding-left:0}.mg-popover ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default);--mg-card-max-width:unset}";
|
|
6006
|
+
const mgPopoverCss = ":host{--mg-card-padding:var(--mg-popover-padding-vertical, 1.5rem) var(--mg-popover-padding-horizontal, var(--mg-popover-padding-vertical, 1.5rem));--mg-card-border:none;--mg-card-border-radius:0.5rem;--mg-card-background:hsl(var(--mg-popover-background-color));position:relative;display:contents}:host::slotted(*){display:inline-block}.mg-popover{display:none;padding:1rem;z-index:2000;color:hsl(var(--mg-popover-font-color))}.mg-popover mg-card{--mg-card-max-width:var(--mg-popover-max-width);--mg-card-min-width:var(--mg-popover-min-width);position:relative}.mg-popover[data-show]{display:block}.mg-popover mg-button{float:right;margin-right:calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);margin-top:calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);margin-left:3rem}.mg-popover__arrow{position:absolute;visibility:hidden;width:calc(3rem + 2 * var(--mg-card-border-radius) + 2rem);height:calc(3rem + 2 * var(--mg-card-border-radius) + 2rem)}.mg-popover__arrow:before{visibility:visible;content:\"\";position:absolute}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow,.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{height:1rem}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow:before{left:calc(var(--mg-card-border-radius) + 1rem);border-right:calc(3rem / 2) solid transparent;border-left:calc(3rem / 2) solid transparent}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow{bottom:0.1rem;filter:drop-shadow(0 0.5rem 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow:before{border-top:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{top:0.1rem;filter:drop-shadow(0 -0.5rem 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow:before{border-bottom:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{width:1rem}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right]>.mg-popover__arrow:before{top:calc(var(--mg-card-border-radius) + 1rem);border-top:calc(3rem / 2) solid transparent;border-bottom:calc(3rem / 2) solid transparent}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow{right:0.1rem;filter:drop-shadow(0.5rem 0 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow:before{border-left:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{left:0.1rem;filter:drop-shadow(-0.5rem 0 0.25rem hsl(var(--color-dark), 0.15))}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow:before{border-right:1rem solid hsl(var(--mg-popover-background-color))}.mg-popover[data-popper-placement^=left-start],.mg-popover[data-popper-placement^=left-end],.mg-popover[data-popper-placement^=right-start],.mg-popover[data-popper-placement^=right-end]{padding:0 1rem}.mg-popover[data-popper-placement^=left-start]>.mg-popover__arrow,.mg-popover[data-popper-placement^=left-end]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right-start]>.mg-popover__arrow,.mg-popover[data-popper-placement^=right-end]>.mg-popover__arrow{height:calc(3rem + 2 * var(--mg-card-border-radius))}.mg-popover[data-popper-placement^=left-start]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=left-end]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right-start]>.mg-popover__arrow:before,.mg-popover[data-popper-placement^=right-end]>.mg-popover__arrow:before{top:var(--mg-card-border-radius)}.mg-popover__title ::slotted([slot=title]){margin:0 0 1rem !important;font-size:var(--mg-popover-title-font-size) !important;font-weight:600}.mg-popover--arrow-hide.mg-popover[data-popper-placement^=top]{padding-bottom:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement^=bottom]{padding-top:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement$=end],.mg-popover--arrow-hide.mg-popover[data-popper-placement^=left]{padding-right:0}.mg-popover--arrow-hide.mg-popover[data-popper-placement$=start],.mg-popover--arrow-hide.mg-popover[data-popper-placement^=right]{padding-left:0}.mg-popover ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default);--mg-card-max-width:unset;--mg-card-min-width:unset}";
|
|
6005
6007
|
|
|
6006
6008
|
const MgPopover = class {
|
|
6007
6009
|
constructor(hostRef) {
|
|
@@ -6012,8 +6014,7 @@ const MgPopover = class {
|
|
|
6012
6014
|
this.classArrowHide = `mg-popover--arrow-hide`;
|
|
6013
6015
|
/**
|
|
6014
6016
|
* Check if clicked outside of component
|
|
6015
|
-
* @param
|
|
6016
|
-
* @returns {void}
|
|
6017
|
+
* @param event - mouse event
|
|
6017
6018
|
*/
|
|
6018
6019
|
this.clickOutside = (event) => {
|
|
6019
6020
|
var _a;
|
|
@@ -6025,15 +6026,12 @@ const MgPopover = class {
|
|
|
6025
6026
|
};
|
|
6026
6027
|
/**
|
|
6027
6028
|
* Show popover
|
|
6028
|
-
* @returns {void}
|
|
6029
6029
|
*/
|
|
6030
6030
|
this.show = () => {
|
|
6031
6031
|
// Make the popover visible
|
|
6032
6032
|
this.popover.dataset.show = '';
|
|
6033
6033
|
// Enable the event listeners
|
|
6034
6034
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
6035
|
-
// Update its position
|
|
6036
|
-
this.popper.update();
|
|
6037
6035
|
// hide when click outside
|
|
6038
6036
|
// setTimeout is used to prevent event to trigger after creation
|
|
6039
6037
|
setTimeout(() => {
|
|
@@ -6044,7 +6042,6 @@ const MgPopover = class {
|
|
|
6044
6042
|
};
|
|
6045
6043
|
/**
|
|
6046
6044
|
* Hide popover
|
|
6047
|
-
* @returns {void}
|
|
6048
6045
|
*/
|
|
6049
6046
|
this.hide = () => {
|
|
6050
6047
|
// Hide the popover
|
|
@@ -6058,7 +6055,6 @@ const MgPopover = class {
|
|
|
6058
6055
|
};
|
|
6059
6056
|
/**
|
|
6060
6057
|
* Handle action for close button
|
|
6061
|
-
* @returns {void}
|
|
6062
6058
|
*/
|
|
6063
6059
|
this.handleCloseButton = () => {
|
|
6064
6060
|
this.display = false;
|
|
@@ -6069,13 +6065,13 @@ const MgPopover = class {
|
|
|
6069
6065
|
this.closeButton = false;
|
|
6070
6066
|
this.display = false;
|
|
6071
6067
|
this.disabled = false;
|
|
6072
|
-
this.
|
|
6068
|
+
this.classCollection = new ClassList(['mg-popover']);
|
|
6073
6069
|
}
|
|
6074
6070
|
validateArrowHide(newValue) {
|
|
6075
6071
|
if (newValue)
|
|
6076
|
-
this.
|
|
6072
|
+
this.classCollection.add(this.classArrowHide);
|
|
6077
6073
|
else
|
|
6078
|
-
this.
|
|
6074
|
+
this.classCollection.delete(this.classArrowHide);
|
|
6079
6075
|
}
|
|
6080
6076
|
handleDisplay(newValue) {
|
|
6081
6077
|
if (newValue) {
|
|
@@ -6089,9 +6085,14 @@ const MgPopover = class {
|
|
|
6089
6085
|
/*************
|
|
6090
6086
|
* Lifecycle *
|
|
6091
6087
|
*************/
|
|
6088
|
+
/**
|
|
6089
|
+
* update popper position after props change on component did update hook to benefit from render ended
|
|
6090
|
+
*/
|
|
6091
|
+
componentDidUpdate() {
|
|
6092
|
+
this.popper.update();
|
|
6093
|
+
}
|
|
6092
6094
|
/**
|
|
6093
6095
|
* Check if component props are well configured on init
|
|
6094
|
-
* @returns {void} timeout
|
|
6095
6096
|
*/
|
|
6096
6097
|
componentWillLoad() {
|
|
6097
6098
|
// Get windows to attach events
|
|
@@ -6102,7 +6103,6 @@ const MgPopover = class {
|
|
|
6102
6103
|
}
|
|
6103
6104
|
/**
|
|
6104
6105
|
* Check if component props are well configured on init
|
|
6105
|
-
* @returns {void}
|
|
6106
6106
|
*/
|
|
6107
6107
|
componentDidLoad() {
|
|
6108
6108
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -6152,17 +6152,19 @@ const MgPopover = class {
|
|
|
6152
6152
|
});
|
|
6153
6153
|
// Add events to hide popover
|
|
6154
6154
|
this.element.addEventListener('keydown', e => {
|
|
6155
|
-
if (!this.disabled && e.code === 'Escape')
|
|
6155
|
+
if (!this.disabled && e.code === 'Escape') {
|
|
6156
6156
|
this.display = false;
|
|
6157
|
+
interactiveElement.focus();
|
|
6158
|
+
}
|
|
6157
6159
|
});
|
|
6158
6160
|
this.handleDisplay(this.display);
|
|
6159
6161
|
}
|
|
6160
6162
|
/**
|
|
6161
6163
|
* Render
|
|
6162
|
-
* @returns
|
|
6164
|
+
* @returns HTML Element
|
|
6163
6165
|
*/
|
|
6164
6166
|
render() {
|
|
6165
|
-
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: this.
|
|
6167
|
+
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: this.classCollection.join() }, h("mg-card", null, this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, h("mg-icon", { icon: "cross" }))), h("div", { class: "mg-popover__title" }, h("slot", { name: "title" })), h("slot", { name: "content" })), !this.arrowHide && h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
6166
6168
|
}
|
|
6167
6169
|
get element() { return getElement(this); }
|
|
6168
6170
|
static get watchers() { return {
|
|
@@ -6183,8 +6185,7 @@ const MgSkipLinks = class {
|
|
|
6183
6185
|
**********/
|
|
6184
6186
|
/**
|
|
6185
6187
|
* Handle link click and emit go-to-anchor event
|
|
6186
|
-
* @param
|
|
6187
|
-
* @returns {void}
|
|
6188
|
+
* @param event - mouse event
|
|
6188
6189
|
*/
|
|
6189
6190
|
this.handleLinkCLick = (event) => {
|
|
6190
6191
|
event.currentTarget.blur();
|
|
@@ -6204,7 +6205,6 @@ const MgSkipLinks = class {
|
|
|
6204
6205
|
*************/
|
|
6205
6206
|
/**
|
|
6206
6207
|
* Check if props are well configured on init
|
|
6207
|
-
* @returns {void}
|
|
6208
6208
|
*/
|
|
6209
6209
|
componentWillLoad() {
|
|
6210
6210
|
this.validateLinks(this.links);
|
|
@@ -6212,7 +6212,7 @@ const MgSkipLinks = class {
|
|
|
6212
6212
|
}
|
|
6213
6213
|
/**
|
|
6214
6214
|
* Render
|
|
6215
|
-
* @returns
|
|
6215
|
+
* @returns HTML Element
|
|
6216
6216
|
*/
|
|
6217
6217
|
render() {
|
|
6218
6218
|
return (h("nav", { class: "mg-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, h("ul", { class: "mg-skip-links__list", role: "list" }, this.links.map(link => (h("li", { key: link.href }, h("a", { class: "mg-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
|
|
@@ -6243,8 +6243,8 @@ const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.m
|
|
|
6243
6243
|
|
|
6244
6244
|
/**
|
|
6245
6245
|
* type TabItem validation function
|
|
6246
|
-
* @param
|
|
6247
|
-
* @returns
|
|
6246
|
+
* @param tab - tab item
|
|
6247
|
+
* @returns tab item type is valid
|
|
6248
6248
|
*/
|
|
6249
6249
|
const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
|
|
6250
6250
|
const MgTabs = class {
|
|
@@ -6260,32 +6260,32 @@ const MgTabs = class {
|
|
|
6260
6260
|
this.startIndex = 1;
|
|
6261
6261
|
/**
|
|
6262
6262
|
* Method to know if given tab has the given status
|
|
6263
|
-
* @param
|
|
6264
|
-
* @param
|
|
6265
|
-
* @returns
|
|
6263
|
+
* @param tab - item tab key to set to ACTIVE status
|
|
6264
|
+
* @param status - status to valide
|
|
6265
|
+
* @returns status comparaison
|
|
6266
6266
|
*/
|
|
6267
6267
|
this.tabHasStatus = (tab, status) => tab.status === status;
|
|
6268
6268
|
/**
|
|
6269
6269
|
* Method to get element id from index
|
|
6270
|
-
* @param
|
|
6271
|
-
* @param
|
|
6272
|
-
* @returns
|
|
6270
|
+
* @param element - to get id
|
|
6271
|
+
* @param index - to generate id
|
|
6272
|
+
* @returns generated element id
|
|
6273
6273
|
*/
|
|
6274
6274
|
this.getElementId = (element, index) => `${element}-${this.getTabItemIndex(index)}`;
|
|
6275
6275
|
/**
|
|
6276
6276
|
* Method to get tab item index
|
|
6277
|
-
* @param
|
|
6278
|
-
* @returns
|
|
6277
|
+
* @param index - to get
|
|
6278
|
+
* @returns index
|
|
6279
6279
|
*/
|
|
6280
6280
|
this.getTabItemIndex = (index) => index + this.startIndex;
|
|
6281
6281
|
/**
|
|
6282
6282
|
* Method to get the active-tab value
|
|
6283
|
-
* @returns
|
|
6283
|
+
* @returns of the active-tab
|
|
6284
6284
|
*/
|
|
6285
6285
|
this.getActiveTab = () => this.activeTab || this.getTabItemIndex(this.tabs.map((tab, index) => (Object.assign(Object.assign({}, tab), { index }))).find(tab => this.tabHasStatus(tab, Status.ACTIVE)).index);
|
|
6286
6286
|
/**
|
|
6287
6287
|
* Handle click events on tabs
|
|
6288
|
-
* @param
|
|
6288
|
+
* @param event - mouse event
|
|
6289
6289
|
*/
|
|
6290
6290
|
this.handleClick = (event) => {
|
|
6291
6291
|
const tabId = event.currentTarget.dataset.index;
|
|
@@ -6300,14 +6300,13 @@ const MgTabs = class {
|
|
|
6300
6300
|
};
|
|
6301
6301
|
/**
|
|
6302
6302
|
* get navigation button class from given status
|
|
6303
|
-
* @param
|
|
6304
|
-
* @returns
|
|
6303
|
+
* @param status - button tab status
|
|
6304
|
+
* @returns button class/selector variant
|
|
6305
6305
|
*/
|
|
6306
6306
|
this.getNavigationButtonClass = (status) => `${this.buttonTabBaseClass}--${status}`;
|
|
6307
6307
|
/**
|
|
6308
6308
|
* Handle keyboard event on tabs
|
|
6309
|
-
* @param
|
|
6310
|
-
* @returns {void}
|
|
6309
|
+
* @param event - mouse event
|
|
6311
6310
|
*/
|
|
6312
6311
|
this.handleKeydown = (event) => {
|
|
6313
6312
|
const parent = event.target.parentElement;
|
|
@@ -6345,7 +6344,6 @@ const MgTabs = class {
|
|
|
6345
6344
|
};
|
|
6346
6345
|
/**
|
|
6347
6346
|
* Method to reset focus behavior
|
|
6348
|
-
* @returns {void}
|
|
6349
6347
|
*/
|
|
6350
6348
|
this.resetFocus = () => {
|
|
6351
6349
|
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
@@ -6370,7 +6368,7 @@ const MgTabs = class {
|
|
|
6370
6368
|
this.items = undefined;
|
|
6371
6369
|
this.activeTab = undefined;
|
|
6372
6370
|
this.tabs = [];
|
|
6373
|
-
this.
|
|
6371
|
+
this.classCollection = new ClassList(['mg-tabs']);
|
|
6374
6372
|
}
|
|
6375
6373
|
validateLabel(newValue) {
|
|
6376
6374
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -6381,7 +6379,7 @@ const MgTabs = class {
|
|
|
6381
6379
|
if (!sizes.includes(newValue)) {
|
|
6382
6380
|
throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
6383
6381
|
}
|
|
6384
|
-
this.
|
|
6382
|
+
this.classCollection.add(`mg-tabs--size-${this.size}`);
|
|
6385
6383
|
}
|
|
6386
6384
|
validateItems(newValue) {
|
|
6387
6385
|
// String array
|
|
@@ -6424,7 +6422,6 @@ const MgTabs = class {
|
|
|
6424
6422
|
*************/
|
|
6425
6423
|
/**
|
|
6426
6424
|
* Check if component props are well configured on init
|
|
6427
|
-
* @returns {void}
|
|
6428
6425
|
*/
|
|
6429
6426
|
componentWillLoad() {
|
|
6430
6427
|
// Check tabs format
|
|
@@ -6436,7 +6433,6 @@ const MgTabs = class {
|
|
|
6436
6433
|
}
|
|
6437
6434
|
/**
|
|
6438
6435
|
* add listners
|
|
6439
|
-
* @returns {void}
|
|
6440
6436
|
*/
|
|
6441
6437
|
componentDidLoad() {
|
|
6442
6438
|
document.addEventListener('click', (event) => {
|
|
@@ -6446,10 +6442,10 @@ const MgTabs = class {
|
|
|
6446
6442
|
}
|
|
6447
6443
|
/**
|
|
6448
6444
|
* Render
|
|
6449
|
-
* @returns
|
|
6445
|
+
* @returns HTML Element
|
|
6450
6446
|
*/
|
|
6451
6447
|
render() {
|
|
6452
|
-
return (h("div", { class: this.
|
|
6448
|
+
return (h("div", { class: this.classCollection.join() }, h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => (h("button", { key: tab.label, role: "tab", id: this.getElementId(this.identifier, index), class: {
|
|
6453
6449
|
[`${this.buttonTabBaseClass}`]: true,
|
|
6454
6450
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
6455
6451
|
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|
|
@@ -6486,7 +6482,7 @@ const MgTag = class {
|
|
|
6486
6482
|
this.variant = variants[0];
|
|
6487
6483
|
this.outline = undefined;
|
|
6488
6484
|
this.soft = undefined;
|
|
6489
|
-
this.
|
|
6485
|
+
this.classCollection = new ClassList(['mg-tag']);
|
|
6490
6486
|
}
|
|
6491
6487
|
validateVariant(newValue, oldValue) {
|
|
6492
6488
|
if (!variants.includes(newValue)) {
|
|
@@ -6494,16 +6490,16 @@ const MgTag = class {
|
|
|
6494
6490
|
}
|
|
6495
6491
|
else {
|
|
6496
6492
|
if (oldValue !== undefined) {
|
|
6497
|
-
this.
|
|
6493
|
+
this.classCollection.delete(`mg-tag--${oldValue}`);
|
|
6498
6494
|
}
|
|
6499
|
-
this.
|
|
6495
|
+
this.classCollection.add(`mg-tag--${newValue}`);
|
|
6500
6496
|
}
|
|
6501
6497
|
}
|
|
6502
6498
|
validateOutline(newValue) {
|
|
6503
6499
|
if (newValue)
|
|
6504
|
-
this.
|
|
6500
|
+
this.classCollection.add(this.classOutline);
|
|
6505
6501
|
else
|
|
6506
|
-
this.
|
|
6502
|
+
this.classCollection.delete(this.classOutline);
|
|
6507
6503
|
}
|
|
6508
6504
|
validateSoft(newValue) {
|
|
6509
6505
|
// usage validation
|
|
@@ -6511,17 +6507,16 @@ const MgTag = class {
|
|
|
6511
6507
|
throw new Error('<mg-tag> prop "soft" can NOT be used with prop "outline".');
|
|
6512
6508
|
// apply class
|
|
6513
6509
|
if (newValue)
|
|
6514
|
-
this.
|
|
6510
|
+
this.classCollection.add(this.classSoft);
|
|
6515
6511
|
else
|
|
6516
|
-
this.
|
|
6512
|
+
this.classCollection.delete(this.classSoft);
|
|
6517
6513
|
}
|
|
6518
6514
|
/*************
|
|
6519
6515
|
* Methods *
|
|
6520
6516
|
*************/
|
|
6521
6517
|
/**
|
|
6522
6518
|
* Validate the given textContent
|
|
6523
|
-
* @param
|
|
6524
|
-
* @returns {void}
|
|
6519
|
+
* @param textContent - html element textContent property
|
|
6525
6520
|
*/
|
|
6526
6521
|
validateTextContent(textContent) {
|
|
6527
6522
|
if (typeof textContent !== 'string' || textContent.trim() === '')
|
|
@@ -6532,7 +6527,6 @@ const MgTag = class {
|
|
|
6532
6527
|
*************/
|
|
6533
6528
|
/**
|
|
6534
6529
|
* Check if props are well configured on init
|
|
6535
|
-
* @returns {void}
|
|
6536
6530
|
*/
|
|
6537
6531
|
componentWillLoad() {
|
|
6538
6532
|
this.validateVariant(this.variant);
|
|
@@ -6542,10 +6536,10 @@ const MgTag = class {
|
|
|
6542
6536
|
}
|
|
6543
6537
|
/**
|
|
6544
6538
|
* Render
|
|
6545
|
-
* @returns
|
|
6539
|
+
* @returns HTML Element
|
|
6546
6540
|
*/
|
|
6547
6541
|
render() {
|
|
6548
|
-
return (h("span", { class: this.
|
|
6542
|
+
return (h("span", { class: this.classCollection.join() }, h("slot", null)));
|
|
6549
6543
|
}
|
|
6550
6544
|
get element() { return getElement(this); }
|
|
6551
6545
|
static get watchers() { return {
|
|
@@ -6570,15 +6564,12 @@ const MgTooltip = class {
|
|
|
6570
6564
|
registerInstance(this, hostRef);
|
|
6571
6565
|
/**
|
|
6572
6566
|
* Show tooltip
|
|
6573
|
-
* @returns {void}
|
|
6574
6567
|
*/
|
|
6575
6568
|
this.show = () => {
|
|
6576
6569
|
// Make the tooltip visible
|
|
6577
6570
|
this.tooltip.dataset.show = '';
|
|
6578
6571
|
// Enable the event listeners
|
|
6579
6572
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
6580
|
-
// Update its position
|
|
6581
|
-
this.popper.update();
|
|
6582
6573
|
// hide when click outside
|
|
6583
6574
|
// setTimeout is used to prevent event to trigger after creation
|
|
6584
6575
|
setTimeout(() => {
|
|
@@ -6590,7 +6581,6 @@ const MgTooltip = class {
|
|
|
6590
6581
|
};
|
|
6591
6582
|
/**
|
|
6592
6583
|
* Hide tooltip
|
|
6593
|
-
* @returns {void}
|
|
6594
6584
|
*/
|
|
6595
6585
|
this.hide = () => {
|
|
6596
6586
|
// Hide the tooltip
|
|
@@ -6605,8 +6595,7 @@ const MgTooltip = class {
|
|
|
6605
6595
|
};
|
|
6606
6596
|
/**
|
|
6607
6597
|
* Check if clicked outside of component and hidde tooltip
|
|
6608
|
-
* @param
|
|
6609
|
-
* @returns {void}
|
|
6598
|
+
* @param event - mouse event
|
|
6610
6599
|
*/
|
|
6611
6600
|
this.clickOutside = (event) => {
|
|
6612
6601
|
if (event.target.closest('mg-tooltip') !== this.element)
|
|
@@ -6614,18 +6603,18 @@ const MgTooltip = class {
|
|
|
6614
6603
|
};
|
|
6615
6604
|
/**
|
|
6616
6605
|
* Check if 'Escape' key is pressed of component and hidde tooltip
|
|
6617
|
-
* @param
|
|
6618
|
-
* @returns {void}
|
|
6606
|
+
* @param event - keyboard event
|
|
6619
6607
|
*/
|
|
6620
6608
|
this.pressEscape = (event) => {
|
|
6621
|
-
if (event.code === 'Escape')
|
|
6609
|
+
if (event.code === 'Escape') {
|
|
6622
6610
|
this.setDisplay(false);
|
|
6611
|
+
this.resetGuard();
|
|
6612
|
+
}
|
|
6623
6613
|
};
|
|
6624
6614
|
/**
|
|
6625
6615
|
* Method to set display prop
|
|
6626
|
-
* @param
|
|
6627
|
-
* @param
|
|
6628
|
-
* @returns {void}
|
|
6616
|
+
* @param newValue - display prop new value
|
|
6617
|
+
* @param condition - additionnal condition to apply display prop newValue
|
|
6629
6618
|
*/
|
|
6630
6619
|
this.setDisplay = (newValue, condition = true) => {
|
|
6631
6620
|
if (!this.disabled && condition)
|
|
@@ -6633,10 +6622,9 @@ const MgTooltip = class {
|
|
|
6633
6622
|
};
|
|
6634
6623
|
/**
|
|
6635
6624
|
* Action for tooltip element and tooltiped element mouse listener
|
|
6636
|
-
* @param
|
|
6637
|
-
* @param
|
|
6638
|
-
* @param
|
|
6639
|
-
* @returns {void}
|
|
6625
|
+
* @param elementGuard - tooltip element guard
|
|
6626
|
+
* @param isMouseenter - mouseenter validation
|
|
6627
|
+
* @param conditionalGuard - guard condition
|
|
6640
6628
|
*/
|
|
6641
6629
|
this.tooltipMouseListenerAction = (elementGuard, isMouseenter, conditionalGuard) => {
|
|
6642
6630
|
// we mutate elementGuard
|
|
@@ -6655,15 +6643,13 @@ const MgTooltip = class {
|
|
|
6655
6643
|
};
|
|
6656
6644
|
/**
|
|
6657
6645
|
* Method to reset guard value
|
|
6658
|
-
* @returns {void}
|
|
6659
6646
|
*/
|
|
6660
6647
|
this.resetGuard = () => {
|
|
6661
6648
|
this.guard = undefined;
|
|
6662
6649
|
};
|
|
6663
6650
|
/**
|
|
6664
6651
|
* Update slot content when it is a mg-button
|
|
6665
|
-
* @param
|
|
6666
|
-
* @returns {void}
|
|
6652
|
+
* @param mgButton - slotted mg-button
|
|
6667
6653
|
*/
|
|
6668
6654
|
this.setMgButtonWrapper = (mgButton) => {
|
|
6669
6655
|
if (mgButton.disabled) {
|
|
@@ -6680,8 +6666,8 @@ const MgTooltip = class {
|
|
|
6680
6666
|
};
|
|
6681
6667
|
/**
|
|
6682
6668
|
* Init tooltip
|
|
6683
|
-
* @param
|
|
6684
|
-
* @param
|
|
6669
|
+
* @param slotElement - slotted element
|
|
6670
|
+
* @param interactiveElement - interactive element
|
|
6685
6671
|
*/
|
|
6686
6672
|
this.initTooltip = (slotElement, interactiveElement) => {
|
|
6687
6673
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
@@ -6742,7 +6728,6 @@ const MgTooltip = class {
|
|
|
6742
6728
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
6743
6729
|
throw new Error('<mg-tooltip> prop "message" is required.');
|
|
6744
6730
|
}
|
|
6745
|
-
this.popper.update();
|
|
6746
6731
|
}
|
|
6747
6732
|
handleDisplay(newValue) {
|
|
6748
6733
|
if (newValue) {
|
|
@@ -6757,7 +6742,6 @@ const MgTooltip = class {
|
|
|
6757
6742
|
*************/
|
|
6758
6743
|
/**
|
|
6759
6744
|
* set variables
|
|
6760
|
-
* @returns {void}
|
|
6761
6745
|
*/
|
|
6762
6746
|
componentWillLoad() {
|
|
6763
6747
|
// Get windows to attach events
|
|
@@ -6767,7 +6751,6 @@ const MgTooltip = class {
|
|
|
6767
6751
|
* Get slotted element
|
|
6768
6752
|
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
6769
6753
|
* We need to attach the focused element to the tooltip (aria-describedby)
|
|
6770
|
-
* @returns {void}
|
|
6771
6754
|
*/
|
|
6772
6755
|
componentDidLoad() {
|
|
6773
6756
|
var _a;
|
|
@@ -6798,9 +6781,15 @@ const MgTooltip = class {
|
|
|
6798
6781
|
this.handleDisplay(this.display);
|
|
6799
6782
|
this.validateMessage(this.message);
|
|
6800
6783
|
}
|
|
6784
|
+
/**
|
|
6785
|
+
* update popper position after props change on component did update hook to benefit from render ended
|
|
6786
|
+
*/
|
|
6787
|
+
componentDidUpdate() {
|
|
6788
|
+
this.popper.update();
|
|
6789
|
+
}
|
|
6801
6790
|
/**
|
|
6802
6791
|
* Render
|
|
6803
|
-
* @returns
|
|
6792
|
+
* @returns HTML Element
|
|
6804
6793
|
*/
|
|
6805
6794
|
render() {
|
|
6806
6795
|
return (h(Host, null, h("slot", null), h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip" }, h("span", { innerHTML: this.message }), h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|