@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
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
6
|
-
const mgMenu_conf = require('./mg-menu.conf-
|
|
5
|
+
const index = require('./index-03d2557d.js');
|
|
6
|
+
const mgMenu_conf = require('./mg-menu.conf-05ec32a3.js');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Available menu-item positions
|
|
@@ -26,9 +26,9 @@ var Status$1;
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Create random ID
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
-
* @returns
|
|
29
|
+
* @param prefix - add prefix to created ID
|
|
30
|
+
* @param length - ID length
|
|
31
|
+
* @returns ID
|
|
32
32
|
*/
|
|
33
33
|
const createID = (prefix = '', length = 10) => {
|
|
34
34
|
let ID = '';
|
|
@@ -47,8 +47,7 @@ class ClassList {
|
|
|
47
47
|
constructor(classlist = []) {
|
|
48
48
|
/**
|
|
49
49
|
* Add class
|
|
50
|
-
* @param
|
|
51
|
-
* @returns {void}
|
|
50
|
+
* @param className - class name to add
|
|
52
51
|
*/
|
|
53
52
|
this.add = (className) => {
|
|
54
53
|
if (!this.has(className)) {
|
|
@@ -57,8 +56,7 @@ class ClassList {
|
|
|
57
56
|
};
|
|
58
57
|
/**
|
|
59
58
|
* Delete class
|
|
60
|
-
* @param
|
|
61
|
-
* @returns {void}
|
|
59
|
+
* @param className - class name to delete
|
|
62
60
|
*/
|
|
63
61
|
this.delete = (className) => {
|
|
64
62
|
const index = this.classes.indexOf(className);
|
|
@@ -68,15 +66,15 @@ class ClassList {
|
|
|
68
66
|
};
|
|
69
67
|
/**
|
|
70
68
|
* Check if class exist in list
|
|
71
|
-
* @param
|
|
72
|
-
* @returns
|
|
69
|
+
* @param className - class name to check
|
|
70
|
+
* @returns class name is in the list
|
|
73
71
|
*/
|
|
74
72
|
this.has = (className) => {
|
|
75
73
|
return this.classes.includes(className);
|
|
76
74
|
};
|
|
77
75
|
/**
|
|
78
76
|
* Join classes seperated by spaces
|
|
79
|
-
* @returns
|
|
77
|
+
* @returns joined values
|
|
80
78
|
*/
|
|
81
79
|
this.join = () => {
|
|
82
80
|
return this.classes.join(' ');
|
|
@@ -86,15 +84,15 @@ class ClassList {
|
|
|
86
84
|
}
|
|
87
85
|
/**
|
|
88
86
|
* Check if all items are string
|
|
89
|
-
* @param
|
|
90
|
-
* @returns
|
|
87
|
+
* @param items - items to check
|
|
88
|
+
* @returns all items are string
|
|
91
89
|
*/
|
|
92
90
|
const allItemsAreString = (items) => Array.isArray(items) && items.every(item => typeof item === 'string');
|
|
93
91
|
/**
|
|
94
92
|
* Check if element is a heading
|
|
95
|
-
* @param
|
|
96
|
-
* @param
|
|
97
|
-
* @returns
|
|
93
|
+
* @param element - slotted element
|
|
94
|
+
* @param tagNames - allowed tag names list
|
|
95
|
+
* @returns element is a heading
|
|
98
96
|
*/
|
|
99
97
|
const isTagName = (element, tagNames) => {
|
|
100
98
|
return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
|
|
@@ -105,8 +103,8 @@ const isTagName = (element, tagNames) => {
|
|
|
105
103
|
const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
106
104
|
/**
|
|
107
105
|
* Get windows
|
|
108
|
-
* @param
|
|
109
|
-
* @returns
|
|
106
|
+
* @param localWindow - the window we are lookink for other windows
|
|
107
|
+
* @returns The list of windows found
|
|
110
108
|
*/
|
|
111
109
|
const getWindows = (localWindow) => {
|
|
112
110
|
const parentWindows = getParentWindows(localWindow);
|
|
@@ -115,9 +113,9 @@ const getWindows = (localWindow) => {
|
|
|
115
113
|
};
|
|
116
114
|
/**
|
|
117
115
|
* Get parent windows
|
|
118
|
-
* @param
|
|
119
|
-
* @param
|
|
120
|
-
* @returns
|
|
116
|
+
* @param localWindow - the window we are lookink for parents
|
|
117
|
+
* @param windows - The list of allready found windows
|
|
118
|
+
* @returns The list of windows found
|
|
121
119
|
*/
|
|
122
120
|
const getParentWindows = (localWindow, windows = []) => {
|
|
123
121
|
// Check if is in iframe
|
|
@@ -137,9 +135,9 @@ const getParentWindows = (localWindow, windows = []) => {
|
|
|
137
135
|
};
|
|
138
136
|
/**
|
|
139
137
|
* Get child windows
|
|
140
|
-
* @param
|
|
141
|
-
* @param
|
|
142
|
-
* @returns
|
|
138
|
+
* @param localWindow - the window we are lookink for children
|
|
139
|
+
* @param windows - The list of allready found windows
|
|
140
|
+
* @returns The list of windows found
|
|
143
141
|
*/
|
|
144
142
|
const getChildWindows = (localWindow, windows = []) => {
|
|
145
143
|
if (localWindow.frames.length > 0) {
|
|
@@ -158,8 +156,8 @@ const mgActionMoreCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
158
156
|
|
|
159
157
|
/**
|
|
160
158
|
* MgActionMore['items'] type guard
|
|
161
|
-
* @param
|
|
162
|
-
* @returns
|
|
159
|
+
* @param prop - commponent items prop
|
|
160
|
+
* @returns return true if type is valid
|
|
163
161
|
*/
|
|
164
162
|
const isMgActionMoreItems = (prop) => {
|
|
165
163
|
const items = prop;
|
|
@@ -167,8 +165,8 @@ const isMgActionMoreItems = (prop) => {
|
|
|
167
165
|
};
|
|
168
166
|
/**
|
|
169
167
|
* MgActionMore['button'] type guard
|
|
170
|
-
* @param
|
|
171
|
-
* @returns
|
|
168
|
+
* @param prop - commponent button prop
|
|
169
|
+
* @returns return true if type is valid
|
|
172
170
|
*/
|
|
173
171
|
const isMgActionMoreButton = (prop) => {
|
|
174
172
|
const button = prop;
|
|
@@ -176,8 +174,8 @@ const isMgActionMoreButton = (prop) => {
|
|
|
176
174
|
};
|
|
177
175
|
/**
|
|
178
176
|
* MgActionMore['icon'] type guard
|
|
179
|
-
* @param
|
|
180
|
-
* @returns
|
|
177
|
+
* @param prop - commponent icon prop
|
|
178
|
+
* @returns return true if type is valid
|
|
181
179
|
*/
|
|
182
180
|
const isMgActionMoreIcon = (prop) => {
|
|
183
181
|
const icon = prop;
|
|
@@ -196,23 +194,20 @@ const MgActionMore = class {
|
|
|
196
194
|
***********/
|
|
197
195
|
/**
|
|
198
196
|
* Toogle expanded props
|
|
199
|
-
* @returns {void}
|
|
200
197
|
*/
|
|
201
198
|
this.toggleExpanded = () => {
|
|
202
199
|
this.expanded = !this.expanded;
|
|
203
200
|
};
|
|
204
201
|
/**
|
|
205
202
|
* Button click handler
|
|
206
|
-
* @returns {void}
|
|
207
203
|
*/
|
|
208
204
|
this.handleButton = () => {
|
|
209
205
|
this.toggleExpanded();
|
|
210
206
|
};
|
|
211
207
|
/**
|
|
212
208
|
* Item click handler
|
|
213
|
-
* @param
|
|
214
|
-
* @param
|
|
215
|
-
* @returns {void}
|
|
209
|
+
* @param event - click event
|
|
210
|
+
* @param customHandler - item['mouseEventHandler']
|
|
216
211
|
*/
|
|
217
212
|
this.handleItemClick = (event, customHandler) => {
|
|
218
213
|
this.expanded = false;
|
|
@@ -249,7 +244,6 @@ const MgActionMore = class {
|
|
|
249
244
|
*************/
|
|
250
245
|
/**
|
|
251
246
|
* Validate props
|
|
252
|
-
* @returns {void}
|
|
253
247
|
*/
|
|
254
248
|
componentWillLoad() {
|
|
255
249
|
this.messages = mgMenu_conf.initLocales(this.element).messages.actionMore;
|
|
@@ -260,7 +254,7 @@ const MgActionMore = class {
|
|
|
260
254
|
}
|
|
261
255
|
/**
|
|
262
256
|
* Render
|
|
263
|
-
* @returns
|
|
257
|
+
* @returns HTML Element
|
|
264
258
|
*/
|
|
265
259
|
render() {
|
|
266
260
|
const buttonLabel = this.button.label || this.messages.label;
|
|
@@ -308,7 +302,7 @@ const MgBadge = class {
|
|
|
308
302
|
this.label = undefined;
|
|
309
303
|
this.variant = variants$5[0];
|
|
310
304
|
this.outline = undefined;
|
|
311
|
-
this.
|
|
305
|
+
this.classCollection = new ClassList(['mg-badge']);
|
|
312
306
|
}
|
|
313
307
|
validateValue(newValue) {
|
|
314
308
|
if (`${newValue}`.match(/^(\d+\+*|[?*!a-z])$/i) === null) {
|
|
@@ -326,20 +320,19 @@ const MgBadge = class {
|
|
|
326
320
|
}
|
|
327
321
|
else {
|
|
328
322
|
if (oldValue !== undefined) {
|
|
329
|
-
this.
|
|
323
|
+
this.classCollection.delete(`mg-badge--${oldValue}`);
|
|
330
324
|
}
|
|
331
|
-
this.
|
|
325
|
+
this.classCollection.add(`mg-badge--${newValue}`);
|
|
332
326
|
}
|
|
333
327
|
}
|
|
334
328
|
validateOutline(newValue) {
|
|
335
329
|
if (newValue)
|
|
336
|
-
this.
|
|
330
|
+
this.classCollection.add(this.classOutline);
|
|
337
331
|
else
|
|
338
|
-
this.
|
|
332
|
+
this.classCollection.delete(this.classOutline);
|
|
339
333
|
}
|
|
340
334
|
/**
|
|
341
335
|
* Check if props are well configured on init
|
|
342
|
-
* @returns {void}
|
|
343
336
|
*/
|
|
344
337
|
componentWillLoad() {
|
|
345
338
|
this.validateValue(this.value);
|
|
@@ -349,10 +342,10 @@ const MgBadge = class {
|
|
|
349
342
|
}
|
|
350
343
|
/**
|
|
351
344
|
* Render
|
|
352
|
-
* @returns
|
|
345
|
+
* @returns HTML Element
|
|
353
346
|
*/
|
|
354
347
|
render() {
|
|
355
|
-
return (index.h("span", { class: this.
|
|
348
|
+
return (index.h("span", { class: this.classCollection.join() }, index.h("span", { class: "mg-badge__value" }, this.value), index.h("span", { class: "sr-only" }, this.label)));
|
|
356
349
|
}
|
|
357
350
|
static get watchers() { return {
|
|
358
351
|
"value": ["validateValue"],
|
|
@@ -383,8 +376,7 @@ const MgButton = class {
|
|
|
383
376
|
this.classFullWidth = 'mg-button--full-width';
|
|
384
377
|
/**
|
|
385
378
|
* Trigger actions onClick event
|
|
386
|
-
* @param
|
|
387
|
-
* @returns {void}
|
|
379
|
+
* @param event - click event
|
|
388
380
|
*/
|
|
389
381
|
this.handleClick = (event) => {
|
|
390
382
|
if (this.disabled)
|
|
@@ -397,8 +389,7 @@ const MgButton = class {
|
|
|
397
389
|
};
|
|
398
390
|
/**
|
|
399
391
|
* Handle onKeydown event
|
|
400
|
-
* @param
|
|
401
|
-
* @returns {void}
|
|
392
|
+
* @param event - keyboard event
|
|
402
393
|
*/
|
|
403
394
|
this.handleKeydown = (event) => {
|
|
404
395
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -411,8 +402,7 @@ const MgButton = class {
|
|
|
411
402
|
};
|
|
412
403
|
/**
|
|
413
404
|
* Handle onKeyup event
|
|
414
|
-
* @param
|
|
415
|
-
* @returns {void}
|
|
405
|
+
* @param event - keyboard event
|
|
416
406
|
*/
|
|
417
407
|
this.handleKeyup = (event) => {
|
|
418
408
|
if (!this.disabled && event.key === ' ') {
|
|
@@ -430,7 +420,7 @@ const MgButton = class {
|
|
|
430
420
|
this.isIcon = false;
|
|
431
421
|
this.disableOnClick = false;
|
|
432
422
|
this.loading = false;
|
|
433
|
-
this.
|
|
423
|
+
this.classCollection = new ClassList(['mg-button']);
|
|
434
424
|
}
|
|
435
425
|
validateVariant(newValue, oldValue) {
|
|
436
426
|
if (!variants$4.includes(newValue)) {
|
|
@@ -438,9 +428,9 @@ const MgButton = class {
|
|
|
438
428
|
}
|
|
439
429
|
else {
|
|
440
430
|
if (oldValue !== undefined) {
|
|
441
|
-
this.
|
|
431
|
+
this.classCollection.delete(`mg-button--${oldValue}`);
|
|
442
432
|
}
|
|
443
|
-
this.
|
|
433
|
+
this.classCollection.add(`mg-button--${newValue}`);
|
|
444
434
|
}
|
|
445
435
|
}
|
|
446
436
|
validateFullWidth(newValue) {
|
|
@@ -448,10 +438,10 @@ const MgButton = class {
|
|
|
448
438
|
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
449
439
|
}
|
|
450
440
|
else if (newValue) {
|
|
451
|
-
this.
|
|
441
|
+
this.classCollection.add(this.classFullWidth);
|
|
452
442
|
}
|
|
453
443
|
else {
|
|
454
|
-
this.
|
|
444
|
+
this.classCollection.delete(this.classFullWidth);
|
|
455
445
|
}
|
|
456
446
|
}
|
|
457
447
|
disabledHandler(isDisabled) {
|
|
@@ -464,10 +454,10 @@ const MgButton = class {
|
|
|
464
454
|
this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
|
|
465
455
|
// apply style
|
|
466
456
|
if (isDisabled) {
|
|
467
|
-
this.
|
|
457
|
+
this.classCollection.add(this.classDisabled);
|
|
468
458
|
}
|
|
469
459
|
else {
|
|
470
|
-
this.
|
|
460
|
+
this.classCollection.delete(this.classDisabled);
|
|
471
461
|
}
|
|
472
462
|
// emit value update
|
|
473
463
|
this.disabledChange.emit(isDisabled);
|
|
@@ -475,21 +465,20 @@ const MgButton = class {
|
|
|
475
465
|
loadingHandler(newValue) {
|
|
476
466
|
// we add loading style if it newvalue is true else we remove it
|
|
477
467
|
if (newValue) {
|
|
478
|
-
this.
|
|
468
|
+
this.classCollection.add(this.classLoading);
|
|
479
469
|
}
|
|
480
470
|
else {
|
|
481
|
-
this.
|
|
471
|
+
this.classCollection.delete(this.classLoading);
|
|
482
472
|
}
|
|
483
473
|
}
|
|
484
474
|
/**
|
|
485
475
|
* Check if props are well configured on init
|
|
486
|
-
* @returns {void}
|
|
487
476
|
*/
|
|
488
477
|
componentWillLoad() {
|
|
489
478
|
this.validateVariant(this.variant);
|
|
490
479
|
this.validateFullWidth(this.fullWidth);
|
|
491
480
|
if (this.isIcon) {
|
|
492
|
-
this.
|
|
481
|
+
this.classCollection.add(`mg-button--icon`);
|
|
493
482
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
494
483
|
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
495
484
|
}
|
|
@@ -500,10 +489,10 @@ const MgButton = class {
|
|
|
500
489
|
}
|
|
501
490
|
/**
|
|
502
491
|
* Render component
|
|
503
|
-
* @returns
|
|
492
|
+
* @returns html element
|
|
504
493
|
*/
|
|
505
494
|
render() {
|
|
506
|
-
return (index.h(index.Host, { role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, index.h("div", { class: this.
|
|
495
|
+
return (index.h(index.Host, { role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, index.h("div", { class: this.classCollection.join(), id: this.identifier }, this.loading && index.h("mg-icon", { icon: "loader", spin: true }), index.h("div", { class: "mg-button__content" }, index.h("slot", null)))));
|
|
507
496
|
}
|
|
508
497
|
get element() { return index.getElement(this); }
|
|
509
498
|
static get watchers() { return {
|
|
@@ -524,7 +513,7 @@ const variants$3 = ['info', 'warning', 'success', 'danger', 'app'];
|
|
|
524
513
|
*/
|
|
525
514
|
const variantStyles$1 = ['bar-left', 'fill'];
|
|
526
515
|
|
|
527
|
-
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%}";
|
|
516
|
+
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%}";
|
|
528
517
|
|
|
529
518
|
const MgCard = class {
|
|
530
519
|
constructor(hostRef) {
|
|
@@ -537,7 +526,6 @@ const MgCard = class {
|
|
|
537
526
|
/**
|
|
538
527
|
* Methode to set default varianStyle props
|
|
539
528
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
540
|
-
* @returns {void}
|
|
541
529
|
*/
|
|
542
530
|
this.setDefaultVariantStyle = () => {
|
|
543
531
|
if (this.variantStyle === undefined)
|
|
@@ -545,17 +533,17 @@ const MgCard = class {
|
|
|
545
533
|
};
|
|
546
534
|
this.variant = undefined;
|
|
547
535
|
this.variantStyle = undefined;
|
|
548
|
-
this.
|
|
536
|
+
this.classCollection = new ClassList([this.baseClass]);
|
|
549
537
|
}
|
|
550
538
|
validateVariant(newValue, oldValue) {
|
|
551
539
|
if (newValue && !variants$3.includes(newValue))
|
|
552
540
|
throw new Error(`<${this.name}> prop "variant" must match VariantType type.`);
|
|
553
541
|
if (Boolean(newValue)) {
|
|
554
542
|
this.setDefaultVariantStyle();
|
|
555
|
-
this.
|
|
543
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
556
544
|
}
|
|
557
545
|
if (Boolean(oldValue))
|
|
558
|
-
this.
|
|
546
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
559
547
|
}
|
|
560
548
|
validateVariantStyle(newValue, oldValue) {
|
|
561
549
|
if (newValue && !variantStyles$1.includes(newValue))
|
|
@@ -563,16 +551,15 @@ const MgCard = class {
|
|
|
563
551
|
else if (Boolean(newValue) && !variants$3.includes(this.variant))
|
|
564
552
|
throw new Error(`<${this.name}> prop "variantStyle" must be paired with ${JSON.stringify(variants$3)} "variant" prop.`);
|
|
565
553
|
if (Boolean(newValue))
|
|
566
|
-
this.
|
|
554
|
+
this.classCollection.add(`${this.baseClass}--${newValue}`);
|
|
567
555
|
if (Boolean(oldValue))
|
|
568
|
-
this.
|
|
556
|
+
this.classCollection.delete(`${this.baseClass}--${oldValue}`);
|
|
569
557
|
}
|
|
570
558
|
/*************
|
|
571
559
|
* Lifecycle *
|
|
572
560
|
*************/
|
|
573
561
|
/**
|
|
574
562
|
* Check if props are well configured on init
|
|
575
|
-
* @returns {void}
|
|
576
563
|
*/
|
|
577
564
|
componentWillLoad() {
|
|
578
565
|
this.validateVariant(this.variant);
|
|
@@ -580,11 +567,11 @@ const MgCard = class {
|
|
|
580
567
|
}
|
|
581
568
|
/**
|
|
582
569
|
* Render
|
|
583
|
-
* @returns
|
|
570
|
+
* @returns HTML Element
|
|
584
571
|
*/
|
|
585
572
|
render() {
|
|
586
573
|
var _a;
|
|
587
|
-
return (index.h("div", { class: this.
|
|
574
|
+
return (index.h("div", { class: this.classCollection.join() }, ((_a = this.variantStyle) === null || _a === void 0 ? void 0 : _a.startsWith('bar-')) && index.h("span", { class: "mg-card__bar" }), index.h("slot", null)));
|
|
588
575
|
}
|
|
589
576
|
static get watchers() { return {
|
|
590
577
|
"variant": ["validateVariant"],
|
|
@@ -612,7 +599,6 @@ const MgCharacterLeft = class {
|
|
|
612
599
|
*************/
|
|
613
600
|
/**
|
|
614
601
|
* Check if props are well configured on init
|
|
615
|
-
* @returns {void}
|
|
616
602
|
*/
|
|
617
603
|
componentWillLoad() {
|
|
618
604
|
this.validateMaxlength(this.maxlength);
|
|
@@ -620,7 +606,7 @@ const MgCharacterLeft = class {
|
|
|
620
606
|
}
|
|
621
607
|
/**
|
|
622
608
|
* Render component
|
|
623
|
-
* @returns
|
|
609
|
+
* @returns HTML Element
|
|
624
610
|
*/
|
|
625
611
|
render() {
|
|
626
612
|
return (index.h("span", { id: this.identifier, "aria-live": "polite" }, index.h("span", { "aria-hidden": "true" }, this.maxlength - this.characters.length, "/", this.maxlength), index.h("span", { class: "sr-only" }, this.messages.nbCharLeft.replace('{counter}', this.maxlength - this.characters.length))));
|
|
@@ -640,7 +626,6 @@ const MgDetails = class {
|
|
|
640
626
|
this.expandedChange = index.createEvent(this, "expanded-change", 7);
|
|
641
627
|
/**
|
|
642
628
|
* Handle details toggle
|
|
643
|
-
* @returns {void}
|
|
644
629
|
*/
|
|
645
630
|
this.handleToggle = () => {
|
|
646
631
|
this.expanded = this.details.open;
|
|
@@ -663,7 +648,6 @@ const MgDetails = class {
|
|
|
663
648
|
*************/
|
|
664
649
|
/**
|
|
665
650
|
* Check if component props are well configured on init
|
|
666
|
-
* @returns {void}
|
|
667
651
|
*/
|
|
668
652
|
componentWillLoad() {
|
|
669
653
|
this.validateTitles(this.toggleClosed);
|
|
@@ -671,7 +655,7 @@ const MgDetails = class {
|
|
|
671
655
|
}
|
|
672
656
|
/**
|
|
673
657
|
* Render
|
|
674
|
-
* @returns
|
|
658
|
+
* @returns HTML Element
|
|
675
659
|
*/
|
|
676
660
|
render() {
|
|
677
661
|
return (index.h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, index.h("summary", null, index.h("slot", { name: "summary" }), index.h("span", { class: "mg-details__toggle" }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down', size: "small" }), index.h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), index.h("div", { class: "mg-details__details" }, index.h("slot", { name: "details" }))));
|
|
@@ -693,7 +677,7 @@ const MgDivider = class {
|
|
|
693
677
|
}
|
|
694
678
|
/**
|
|
695
679
|
* Render
|
|
696
|
-
* @returns
|
|
680
|
+
* @returns HTML Element
|
|
697
681
|
*/
|
|
698
682
|
render() {
|
|
699
683
|
return (index.h("div", { class: {
|
|
@@ -715,13 +699,11 @@ const MgForm = class {
|
|
|
715
699
|
this.classAllRequired = 'mg-form--all-required';
|
|
716
700
|
/**
|
|
717
701
|
* Define required message based on mg-inputs required elements
|
|
718
|
-
* Also
|
|
719
|
-
* @returns {void}
|
|
720
702
|
*/
|
|
721
703
|
this.setRequiredMessage = () => {
|
|
722
704
|
// init required message
|
|
723
705
|
this.requiredMessage = null;
|
|
724
|
-
this.
|
|
706
|
+
this.classCollection.delete(this.classAllRequired);
|
|
725
707
|
// If the form is disabled or readonly none of them are required
|
|
726
708
|
// Check if all fields are not editable (readonly or disabled)
|
|
727
709
|
if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
|
|
@@ -731,7 +713,7 @@ const MgForm = class {
|
|
|
731
713
|
// mg-input-toggle can not be required
|
|
732
714
|
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
733
715
|
this.requiredMessage = requiredInputs.length === 1 ? this.messages.form.allRequiredSingle : this.messages.form.allRequired;
|
|
734
|
-
this.
|
|
716
|
+
this.classCollection.add(this.classAllRequired);
|
|
735
717
|
}
|
|
736
718
|
// Some fields are required
|
|
737
719
|
else if (requiredInputs.length > 0) {
|
|
@@ -741,7 +723,6 @@ const MgForm = class {
|
|
|
741
723
|
};
|
|
742
724
|
/**
|
|
743
725
|
* Check if form is valid
|
|
744
|
-
* @returns {void}
|
|
745
726
|
*/
|
|
746
727
|
this.checkValidity = () => {
|
|
747
728
|
// Update required on input event
|
|
@@ -753,8 +734,7 @@ const MgForm = class {
|
|
|
753
734
|
};
|
|
754
735
|
/**
|
|
755
736
|
* Handle Form Submit
|
|
756
|
-
* @param
|
|
757
|
-
* @returns {void}
|
|
737
|
+
* @param event - submit event
|
|
758
738
|
*/
|
|
759
739
|
this.handleFormSubmit = (event) => {
|
|
760
740
|
event.preventDefault();
|
|
@@ -762,7 +742,6 @@ const MgForm = class {
|
|
|
762
742
|
};
|
|
763
743
|
/**
|
|
764
744
|
* Set mgInputs
|
|
765
|
-
* @returns {void}
|
|
766
745
|
*/
|
|
767
746
|
this.setMgInputs = () => {
|
|
768
747
|
// Get slotted mgInputs
|
|
@@ -784,7 +763,7 @@ const MgForm = class {
|
|
|
784
763
|
this.disabled = false;
|
|
785
764
|
this.valid = undefined;
|
|
786
765
|
this.invalid = undefined;
|
|
787
|
-
this.
|
|
766
|
+
this.classCollection = new ClassList(['mg-form']);
|
|
788
767
|
this.requiredMessage = undefined;
|
|
789
768
|
}
|
|
790
769
|
handleAttributeChange() {
|
|
@@ -793,7 +772,6 @@ const MgForm = class {
|
|
|
793
772
|
}
|
|
794
773
|
/**
|
|
795
774
|
* Public method to display errors
|
|
796
|
-
* @returns {Promise<void>}
|
|
797
775
|
*/
|
|
798
776
|
async displayError() {
|
|
799
777
|
if (!this.readonly) {
|
|
@@ -808,7 +786,6 @@ const MgForm = class {
|
|
|
808
786
|
*************/
|
|
809
787
|
/**
|
|
810
788
|
* Check if component props are well configured on init
|
|
811
|
-
* @returns {void}
|
|
812
789
|
*/
|
|
813
790
|
componentWillLoad() {
|
|
814
791
|
// Get locales
|
|
@@ -835,7 +812,6 @@ const MgForm = class {
|
|
|
835
812
|
}
|
|
836
813
|
/**
|
|
837
814
|
* Add slot listeners
|
|
838
|
-
* @returns {void}
|
|
839
815
|
*/
|
|
840
816
|
componentDidLoad() {
|
|
841
817
|
this.mgButtons.forEach(mgButton => {
|
|
@@ -853,10 +829,10 @@ const MgForm = class {
|
|
|
853
829
|
}
|
|
854
830
|
/**
|
|
855
831
|
* Render
|
|
856
|
-
* @returns
|
|
832
|
+
* @returns HTML Element
|
|
857
833
|
*/
|
|
858
834
|
render() {
|
|
859
|
-
return (index.h("form", { class: this.
|
|
835
|
+
return (index.h("form", { class: this.classCollection.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit }, this.requiredMessage && index.h("p", { innerHTML: this.requiredMessage }), index.h("slot", null), !this.readonly && !this.disabled && index.h("slot", { name: "actions" })));
|
|
860
836
|
}
|
|
861
837
|
get element() { return index.getElement(this); }
|
|
862
838
|
static get watchers() { return {
|
|
@@ -1103,13 +1079,12 @@ const MgIcon = class {
|
|
|
1103
1079
|
index.registerInstance(this, hostRef);
|
|
1104
1080
|
/**
|
|
1105
1081
|
* getIcon
|
|
1106
|
-
* @returns
|
|
1082
|
+
* @returns icon html
|
|
1107
1083
|
*/
|
|
1108
1084
|
this.getIcon = () => icons[this.icon]();
|
|
1109
1085
|
/**
|
|
1110
1086
|
* Method to set default varianStyle props
|
|
1111
1087
|
* needeed has stencil doesn't know that props is mutated when updated in prop watcher
|
|
1112
|
-
* @returns {void}
|
|
1113
1088
|
*/
|
|
1114
1089
|
this.setDefaultVariantStyle = () => {
|
|
1115
1090
|
if (this.variantStyle === undefined)
|
|
@@ -1120,15 +1095,15 @@ const MgIcon = class {
|
|
|
1120
1095
|
this.variant = undefined;
|
|
1121
1096
|
this.variantStyle = undefined;
|
|
1122
1097
|
this.spin = false;
|
|
1123
|
-
this.
|
|
1098
|
+
this.classCollection = new ClassList(['mg-icon']);
|
|
1124
1099
|
}
|
|
1125
1100
|
validateIcon(newValue, oldValue) {
|
|
1126
1101
|
if (!Object.keys(icons).includes(newValue))
|
|
1127
1102
|
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
|
|
1128
1103
|
else {
|
|
1129
1104
|
if (oldValue !== undefined)
|
|
1130
|
-
this.
|
|
1131
|
-
this.
|
|
1105
|
+
this.classCollection.delete(`mg-icon--${oldValue}`);
|
|
1106
|
+
this.classCollection.add(`mg-icon--${newValue}`);
|
|
1132
1107
|
}
|
|
1133
1108
|
}
|
|
1134
1109
|
validateSize(newValue, oldValue) {
|
|
@@ -1136,8 +1111,8 @@ const MgIcon = class {
|
|
|
1136
1111
|
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes$1.join(', ')}`);
|
|
1137
1112
|
else {
|
|
1138
1113
|
if (oldValue !== undefined)
|
|
1139
|
-
this.
|
|
1140
|
-
this.
|
|
1114
|
+
this.classCollection.delete(`mg-icon--size-${oldValue}`);
|
|
1115
|
+
this.classCollection.add(`mg-icon--size-${newValue}`);
|
|
1141
1116
|
}
|
|
1142
1117
|
}
|
|
1143
1118
|
validateVariant(newValue, oldValue) {
|
|
@@ -1147,8 +1122,8 @@ const MgIcon = class {
|
|
|
1147
1122
|
else {
|
|
1148
1123
|
this.setDefaultVariantStyle();
|
|
1149
1124
|
if (oldValue !== undefined)
|
|
1150
|
-
this.
|
|
1151
|
-
this.
|
|
1125
|
+
this.classCollection.delete(`mg-icon--variant-${oldValue}`);
|
|
1126
|
+
this.classCollection.add(`mg-icon--variant-${newValue}`);
|
|
1152
1127
|
}
|
|
1153
1128
|
}
|
|
1154
1129
|
}
|
|
@@ -1158,24 +1133,23 @@ const MgIcon = class {
|
|
|
1158
1133
|
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
|
|
1159
1134
|
else {
|
|
1160
1135
|
if (oldValue !== undefined)
|
|
1161
|
-
this.
|
|
1162
|
-
this.
|
|
1136
|
+
this.classCollection.delete(`mg-icon--variant-style-${oldValue}`);
|
|
1137
|
+
this.classCollection.add(`mg-icon--variant-style-${newValue}`);
|
|
1163
1138
|
}
|
|
1164
1139
|
}
|
|
1165
1140
|
}
|
|
1166
1141
|
handleSpin(newValue) {
|
|
1167
1142
|
if (newValue) {
|
|
1168
|
-
this.
|
|
1169
|
-
this.
|
|
1143
|
+
this.classCollection.add('mg-icon--spin');
|
|
1144
|
+
this.classCollection.add('mg-a11y-animation');
|
|
1170
1145
|
}
|
|
1171
1146
|
else {
|
|
1172
|
-
this.
|
|
1173
|
-
this.
|
|
1147
|
+
this.classCollection.delete('mg-icon--spin');
|
|
1148
|
+
this.classCollection.delete('mg-a11y-animation');
|
|
1174
1149
|
}
|
|
1175
1150
|
}
|
|
1176
1151
|
/**
|
|
1177
1152
|
* Check if props are well configured on init
|
|
1178
|
-
* @returns {void}
|
|
1179
1153
|
*/
|
|
1180
1154
|
componentWillLoad() {
|
|
1181
1155
|
this.validateIcon(this.icon);
|
|
@@ -1186,10 +1160,10 @@ const MgIcon = class {
|
|
|
1186
1160
|
}
|
|
1187
1161
|
/**
|
|
1188
1162
|
* Render component
|
|
1189
|
-
* @returns
|
|
1163
|
+
* @returns HTML Element
|
|
1190
1164
|
*/
|
|
1191
1165
|
render() {
|
|
1192
|
-
return (index.h("svg", { class: this.
|
|
1166
|
+
return (index.h("svg", { class: this.classCollection.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
|
|
1193
1167
|
}
|
|
1194
1168
|
static get watchers() { return {
|
|
1195
1169
|
"icon": ["validateIcon"],
|
|
@@ -1214,7 +1188,6 @@ const MgIllustratedMessage = class {
|
|
|
1214
1188
|
*************/
|
|
1215
1189
|
/**
|
|
1216
1190
|
* Check if component props are well configured on init
|
|
1217
|
-
* @returns {void}
|
|
1218
1191
|
*/
|
|
1219
1192
|
componentDidLoad() {
|
|
1220
1193
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -1229,7 +1202,7 @@ const MgIllustratedMessage = class {
|
|
|
1229
1202
|
}
|
|
1230
1203
|
/**
|
|
1231
1204
|
* Render
|
|
1232
|
-
* @returns
|
|
1205
|
+
* @returns HTML Element
|
|
1233
1206
|
*/
|
|
1234
1207
|
render() {
|
|
1235
1208
|
return (index.h("div", { class: {
|
|
@@ -1244,12 +1217,17 @@ const MgIllustratedMessage = class {
|
|
|
1244
1217
|
};
|
|
1245
1218
|
MgIllustratedMessage.style = mgIllustratedMessageCss;
|
|
1246
1219
|
|
|
1220
|
+
/**
|
|
1221
|
+
* Possible input width
|
|
1222
|
+
*/
|
|
1223
|
+
const widths = [2, 4, 16, 'full'];
|
|
1224
|
+
|
|
1247
1225
|
/**
|
|
1248
1226
|
* Apply in all input child node the aria-describedby attribute
|
|
1249
|
-
* @param
|
|
1250
|
-
* @param
|
|
1251
|
-
* @param
|
|
1252
|
-
* @returns
|
|
1227
|
+
* @param children - Represent scoped elements
|
|
1228
|
+
* @param ariaDescribedbyIDs - List of IDs
|
|
1229
|
+
* @param utils - Stencil.js utils
|
|
1230
|
+
* @returns Children with aria-describedby attribute
|
|
1253
1231
|
*/
|
|
1254
1232
|
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
1255
1233
|
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
@@ -1262,29 +1240,36 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
|
|
|
1262
1240
|
});
|
|
1263
1241
|
/**
|
|
1264
1242
|
* Add classes based on props
|
|
1265
|
-
* @param
|
|
1243
|
+
* @param props - MgInput Interface Props
|
|
1266
1244
|
*/
|
|
1267
1245
|
const manageClasses = (props) => {
|
|
1268
|
-
props.
|
|
1246
|
+
props.classCollection.add('mg-input');
|
|
1269
1247
|
if (props.labelOnTop)
|
|
1270
|
-
props.
|
|
1248
|
+
props.classCollection.add('mg-input--label-on-top');
|
|
1249
|
+
else
|
|
1250
|
+
props.classCollection.delete('mg-input--label-on-top');
|
|
1271
1251
|
if (props.readonly)
|
|
1272
|
-
props.
|
|
1252
|
+
props.classCollection.add('mg-input--readonly');
|
|
1253
|
+
else
|
|
1254
|
+
props.classCollection.delete('mg-input--readonly');
|
|
1255
|
+
widths.forEach(width => {
|
|
1256
|
+
props.classCollection.delete(`mg-input--width-${width}`);
|
|
1257
|
+
});
|
|
1273
1258
|
if (props.mgWidth !== undefined)
|
|
1274
|
-
props.
|
|
1259
|
+
props.classCollection.add(`mg-input--width-${props.mgWidth}`);
|
|
1275
1260
|
};
|
|
1276
1261
|
/**
|
|
1277
1262
|
* Get tagname
|
|
1278
|
-
* @param
|
|
1279
|
-
* @returns
|
|
1263
|
+
* @param isFieldset - is fieldset
|
|
1264
|
+
* @returns tag name
|
|
1280
1265
|
*/
|
|
1281
1266
|
const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
|
|
1282
1267
|
/**
|
|
1283
1268
|
* Get input template
|
|
1284
|
-
* @param
|
|
1285
|
-
* @param
|
|
1286
|
-
* @param
|
|
1287
|
-
* @returns
|
|
1269
|
+
* @param props - MgInput Interface Props
|
|
1270
|
+
* @param children - Represent scoped elements
|
|
1271
|
+
* @param utils - Stencil.js utils
|
|
1272
|
+
* @returns input template
|
|
1288
1273
|
*/
|
|
1289
1274
|
const MgInput = (props, children, utils) => {
|
|
1290
1275
|
/**
|
|
@@ -1340,17 +1325,17 @@ const MgInput = (props, children, utils) => {
|
|
|
1340
1325
|
const TagName = getTagName(props.isFieldset);
|
|
1341
1326
|
/**
|
|
1342
1327
|
* Get tooltip node
|
|
1343
|
-
* @returns
|
|
1328
|
+
* @returns mg-tooltip
|
|
1344
1329
|
*/
|
|
1345
1330
|
const getTooltip = () => (index.h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
|
|
1346
1331
|
index.h("mg-icon", { icon: "info-circle" })));
|
|
1347
1332
|
/**
|
|
1348
1333
|
* Get input title (label) node
|
|
1349
1334
|
* Display asterisk only if not disabled and not readonly
|
|
1350
|
-
* @returns
|
|
1335
|
+
* @returns mg-input-title
|
|
1351
1336
|
*/
|
|
1352
1337
|
const getInputTitle = () => (index.h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
|
|
1353
|
-
return (index.h(TagName, { class: props.
|
|
1338
|
+
return (index.h(TagName, { class: props.classCollection.join() },
|
|
1354
1339
|
props.labelOnTop ? (index.h("div", { class: "mg-input__title" },
|
|
1355
1340
|
getInputTitle(),
|
|
1356
1341
|
!props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
|
|
@@ -1364,12 +1349,17 @@ const MgInput = (props, children, utils) => {
|
|
|
1364
1349
|
props.errorMessage && !props.readonly && !props.disabled && (index.h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
|
|
1365
1350
|
};
|
|
1366
1351
|
|
|
1367
|
-
|
|
1352
|
+
/**
|
|
1353
|
+
* List of all availables checkbox type
|
|
1354
|
+
*/
|
|
1355
|
+
const checkboxTypes = ['checkbox', 'multi'];
|
|
1356
|
+
|
|
1357
|
+
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}";
|
|
1368
1358
|
|
|
1369
1359
|
/**
|
|
1370
1360
|
* type CheckboxItem validation function
|
|
1371
|
-
* @param
|
|
1372
|
-
* @returns
|
|
1361
|
+
* @param items - Checkbox item
|
|
1362
|
+
* @returns match item type
|
|
1373
1363
|
*/
|
|
1374
1364
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
1375
1365
|
items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
|
|
@@ -1385,9 +1375,11 @@ const MgInputCheckbox = class {
|
|
|
1385
1375
|
this.inputs = [];
|
|
1386
1376
|
// hasDisplayedError (triggered by blur event)
|
|
1387
1377
|
this.hasDisplayedError = false;
|
|
1378
|
+
// style
|
|
1379
|
+
this.baseClassName = 'mg-input--checkbox';
|
|
1388
1380
|
/**
|
|
1389
1381
|
* Handle input event
|
|
1390
|
-
* @param
|
|
1382
|
+
* @param event - input event
|
|
1391
1383
|
*/
|
|
1392
1384
|
this.handleInput = (event) => {
|
|
1393
1385
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -1399,6 +1391,21 @@ const MgInputCheckbox = class {
|
|
|
1399
1391
|
this.value = this.checkboxItems.map(o => ({ value: o.value, title: o.title, disabled: o.disabled }));
|
|
1400
1392
|
this.checkValidity();
|
|
1401
1393
|
};
|
|
1394
|
+
/**
|
|
1395
|
+
* Keyboard handler
|
|
1396
|
+
* @param event - to trak "tab" key
|
|
1397
|
+
*/
|
|
1398
|
+
this.handleKeydown = (event) => {
|
|
1399
|
+
var _a;
|
|
1400
|
+
// track "Tab" key event when popover display (is "multi" type selected)
|
|
1401
|
+
if (event.key === 'Tab' && ((_a = this.popover) === null || _a === void 0 ? void 0 : _a.display)) {
|
|
1402
|
+
const enableInputs = this.checkboxItems.filter(input => !input.disabled).map(({ id }) => id);
|
|
1403
|
+
const originInputIndex = enableInputs.findIndex(id => id === event.target.id);
|
|
1404
|
+
// close popover when tab trigger focus outside its DOM
|
|
1405
|
+
if ((originInputIndex + 1 >= enableInputs.length && !event.shiftKey) || (originInputIndex === 0 && event.shiftKey))
|
|
1406
|
+
this.popover.display = false;
|
|
1407
|
+
}
|
|
1408
|
+
};
|
|
1402
1409
|
/**
|
|
1403
1410
|
* Handle blur event
|
|
1404
1411
|
*/
|
|
@@ -1409,7 +1416,7 @@ const MgInputCheckbox = class {
|
|
|
1409
1416
|
};
|
|
1410
1417
|
/**
|
|
1411
1418
|
* get invalid element
|
|
1412
|
-
* @returns
|
|
1419
|
+
* @returns element
|
|
1413
1420
|
*/
|
|
1414
1421
|
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
1415
1422
|
/**
|
|
@@ -1421,6 +1428,19 @@ const MgInputCheckbox = class {
|
|
|
1421
1428
|
// We need to send valid event even if it is the same value
|
|
1422
1429
|
this.inputValid.emit(this.valid);
|
|
1423
1430
|
};
|
|
1431
|
+
/**
|
|
1432
|
+
* Render button text
|
|
1433
|
+
* @param selectedValuesNb - nb of selected values
|
|
1434
|
+
* @returns translated message
|
|
1435
|
+
*/
|
|
1436
|
+
this.renderButtonText = (selectedValuesNb) => {
|
|
1437
|
+
let messageKey = 'editButton';
|
|
1438
|
+
if (this.disabled)
|
|
1439
|
+
messageKey = 'showButton';
|
|
1440
|
+
else if (selectedValuesNb < 1)
|
|
1441
|
+
messageKey = 'selectButton';
|
|
1442
|
+
return this.messages.input.checkbox[messageKey];
|
|
1443
|
+
};
|
|
1424
1444
|
/**
|
|
1425
1445
|
* Set input error message
|
|
1426
1446
|
*/
|
|
@@ -1432,7 +1452,13 @@ const MgInputCheckbox = class {
|
|
|
1432
1452
|
this.errorMessage = this.messages.errors.required;
|
|
1433
1453
|
}
|
|
1434
1454
|
};
|
|
1455
|
+
/**
|
|
1456
|
+
* Method to get mg-popover identifier
|
|
1457
|
+
* @returns MgPopover identifier
|
|
1458
|
+
*/
|
|
1459
|
+
this.getMgPopoverIdentifier = () => `${this.identifier}-input-mg-popover`;
|
|
1435
1460
|
this.value = undefined;
|
|
1461
|
+
this.type = checkboxTypes[0];
|
|
1436
1462
|
this.identifier = undefined;
|
|
1437
1463
|
this.name = this.identifier;
|
|
1438
1464
|
this.label = undefined;
|
|
@@ -1446,14 +1472,14 @@ const MgInputCheckbox = class {
|
|
|
1446
1472
|
this.helpText = undefined;
|
|
1447
1473
|
this.valid = undefined;
|
|
1448
1474
|
this.invalid = undefined;
|
|
1449
|
-
this.
|
|
1475
|
+
this.classCollection = new ClassList([this.baseClassName]);
|
|
1450
1476
|
this.errorMessage = undefined;
|
|
1451
1477
|
this.checkboxItems = [];
|
|
1452
1478
|
}
|
|
1453
1479
|
validateValue(newValue) {
|
|
1454
1480
|
if (isCheckboxItems(newValue)) {
|
|
1455
1481
|
this.checkboxItems = newValue.map((item, index) => ({
|
|
1456
|
-
id: `${this.identifier}_${index
|
|
1482
|
+
id: `${this.identifier}_${index}`,
|
|
1457
1483
|
title: item.title,
|
|
1458
1484
|
value: item.value,
|
|
1459
1485
|
disabled: item.disabled,
|
|
@@ -1464,6 +1490,18 @@ const MgInputCheckbox = class {
|
|
|
1464
1490
|
throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
|
|
1465
1491
|
}
|
|
1466
1492
|
}
|
|
1493
|
+
validateType(newValue) {
|
|
1494
|
+
if (!checkboxTypes.includes(newValue)) {
|
|
1495
|
+
throw new Error('<mg-input-checkbox> prop "type" must be a CheckboxType.');
|
|
1496
|
+
}
|
|
1497
|
+
else {
|
|
1498
|
+
const className = `${this.baseClassName}-multi`;
|
|
1499
|
+
if (newValue === 'multi')
|
|
1500
|
+
this.classCollection.add(className);
|
|
1501
|
+
else
|
|
1502
|
+
this.classCollection.delete(className);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1467
1505
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
1468
1506
|
this.inputs.forEach(input => {
|
|
1469
1507
|
input[prop] = newValue;
|
|
@@ -1474,9 +1512,15 @@ const MgInputCheckbox = class {
|
|
|
1474
1512
|
this.hasDisplayedError = false;
|
|
1475
1513
|
}
|
|
1476
1514
|
}
|
|
1515
|
+
validateDisabled(newValue) {
|
|
1516
|
+
const className = `${this.baseClassName}-multi-disabled`;
|
|
1517
|
+
if (newValue && this.type === 'multi')
|
|
1518
|
+
this.classCollection.add(className);
|
|
1519
|
+
else
|
|
1520
|
+
this.classCollection.delete(className);
|
|
1521
|
+
}
|
|
1477
1522
|
/**
|
|
1478
1523
|
* Public method to display errors
|
|
1479
|
-
* @returns {Promise<void>}
|
|
1480
1524
|
*/
|
|
1481
1525
|
async displayError() {
|
|
1482
1526
|
this.checkValidity();
|
|
@@ -1488,13 +1532,17 @@ const MgInputCheckbox = class {
|
|
|
1488
1532
|
*************/
|
|
1489
1533
|
/**
|
|
1490
1534
|
* Check if component props are well configured on init
|
|
1491
|
-
* @returns
|
|
1535
|
+
* @returns timeout
|
|
1492
1536
|
*/
|
|
1493
1537
|
componentWillLoad() {
|
|
1494
1538
|
// Get locales
|
|
1495
1539
|
this.messages = mgMenu_conf.initLocales(this.element).messages;
|
|
1540
|
+
if (this.type === 'multi')
|
|
1541
|
+
this.element.dataset.mgPopoverGuard = this.getMgPopoverIdentifier();
|
|
1496
1542
|
// Validate
|
|
1497
1543
|
this.validateValue(this.value);
|
|
1544
|
+
this.validateDisabled(this.disabled);
|
|
1545
|
+
this.validateType(this.type);
|
|
1498
1546
|
// Check validity when component is ready
|
|
1499
1547
|
// return a promise to process action only in the FIRST render().
|
|
1500
1548
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
@@ -1503,25 +1551,48 @@ const MgInputCheckbox = class {
|
|
|
1503
1551
|
}, 0);
|
|
1504
1552
|
}
|
|
1505
1553
|
/**
|
|
1506
|
-
*
|
|
1507
|
-
* @returns
|
|
1554
|
+
* render checkbox multi element
|
|
1555
|
+
* @returns html element
|
|
1508
1556
|
*/
|
|
1509
|
-
|
|
1510
|
-
|
|
1557
|
+
renderCheckboxMulti() {
|
|
1558
|
+
const selectedValuesNb = this.checkboxItems.filter(({ value }) => value).length;
|
|
1559
|
+
return (index.h("div", { class: "mg-input__input-container mg-input__input-checkbox-multi" }, index.h("strong", null, this.messages.input.checkbox[selectedValuesNb > 1 ? 'selectedValues' : 'selectedValue'].replace('{nb}', selectedValuesNb)), index.h("mg-popover", { arrowHide: true, identifier: this.getMgPopoverIdentifier(), ref: el => {
|
|
1560
|
+
if (Boolean(el))
|
|
1561
|
+
this.popover = el;
|
|
1562
|
+
} }, index.h("mg-button", { variant: "secondary" }, index.h("mg-icon", { icon: "list" }), this.renderButtonText(selectedValuesNb)), index.h("div", { slot: "content" }, this.renderCheckboxes()))));
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Render checkbox element
|
|
1566
|
+
* @returns HTML Element
|
|
1567
|
+
*/
|
|
1568
|
+
renderCheckboxes() {
|
|
1569
|
+
return (index.h("ul", { class: {
|
|
1570
|
+
'mg-input__input-group-container': true,
|
|
1571
|
+
'mg-input__input-group-container--vertical': this.inputVerticalList || (this.type === 'multi' && !this.readonly),
|
|
1572
|
+
'mg-input__input-checkbox-multi-inputs': this.type === 'multi' && !this.readonly,
|
|
1573
|
+
}, role: "list" }, this.checkboxItems
|
|
1511
1574
|
.filter(item => {
|
|
1512
1575
|
return !this.readonly || item.value;
|
|
1513
1576
|
})
|
|
1514
|
-
.map((input, index$1) => (index.h("li", { key: input.id, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.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 => {
|
|
1577
|
+
.map((input, index$1) => (index.h("li", { key: input.id, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.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 => {
|
|
1515
1578
|
if (el !== null)
|
|
1516
1579
|
this.inputs[index$1] = el;
|
|
1517
|
-
} }), index.h("label", { htmlFor: input.id }, input.title))))))
|
|
1580
|
+
} }), index.h("label", { htmlFor: input.id }, input.title))))));
|
|
1581
|
+
}
|
|
1582
|
+
/**
|
|
1583
|
+
* Render
|
|
1584
|
+
* @returns HTML Element
|
|
1585
|
+
*/
|
|
1586
|
+
render() {
|
|
1587
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, this.type === 'checkbox' || this.readonly ? this.renderCheckboxes() : this.renderCheckboxMulti()));
|
|
1518
1588
|
}
|
|
1519
1589
|
get element() { return index.getElement(this); }
|
|
1520
1590
|
static get watchers() { return {
|
|
1521
1591
|
"value": ["validateValue"],
|
|
1592
|
+
"type": ["validateType"],
|
|
1522
1593
|
"required": ["handleValidityChange"],
|
|
1523
1594
|
"readonly": ["handleValidityChange"],
|
|
1524
|
-
"disabled": ["handleValidityChange"]
|
|
1595
|
+
"disabled": ["handleValidityChange", "validateDisabled"]
|
|
1525
1596
|
}; }
|
|
1526
1597
|
};
|
|
1527
1598
|
MgInputCheckbox.style = mgInputCheckboxCss;
|
|
@@ -1534,7 +1605,7 @@ var InputError$1;
|
|
|
1534
1605
|
InputError["REQUIRED"] = "required";
|
|
1535
1606
|
})(InputError$1 || (InputError$1 = {}));
|
|
1536
1607
|
|
|
1537
|
-
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}}";
|
|
1608
|
+
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}}";
|
|
1538
1609
|
|
|
1539
1610
|
const MgInputDate = class {
|
|
1540
1611
|
constructor(hostRef) {
|
|
@@ -1571,7 +1642,7 @@ const MgInputDate = class {
|
|
|
1571
1642
|
};
|
|
1572
1643
|
/**
|
|
1573
1644
|
* get input error code
|
|
1574
|
-
* @returns
|
|
1645
|
+
* @returns error code
|
|
1575
1646
|
*/
|
|
1576
1647
|
this.getInputError = () => {
|
|
1577
1648
|
var _a, _b;
|
|
@@ -1596,7 +1667,6 @@ const MgInputDate = class {
|
|
|
1596
1667
|
};
|
|
1597
1668
|
/**
|
|
1598
1669
|
* Check input errors
|
|
1599
|
-
* @returns {void}
|
|
1600
1670
|
*/
|
|
1601
1671
|
this.setErrorMessage = () => {
|
|
1602
1672
|
var _a;
|
|
@@ -1634,7 +1704,7 @@ const MgInputDate = class {
|
|
|
1634
1704
|
this.invalid = undefined;
|
|
1635
1705
|
this.min = undefined;
|
|
1636
1706
|
this.max = undefined;
|
|
1637
|
-
this.
|
|
1707
|
+
this.classCollection = new ClassList(['mg-input--date']);
|
|
1638
1708
|
this.errorMessage = undefined;
|
|
1639
1709
|
}
|
|
1640
1710
|
validateValue(newValue) {
|
|
@@ -1665,7 +1735,6 @@ const MgInputDate = class {
|
|
|
1665
1735
|
}
|
|
1666
1736
|
/**
|
|
1667
1737
|
* Public method to display errors
|
|
1668
|
-
* @returns {Promise<void>}
|
|
1669
1738
|
*/
|
|
1670
1739
|
async displayError() {
|
|
1671
1740
|
this.checkValidity();
|
|
@@ -1677,7 +1746,7 @@ const MgInputDate = class {
|
|
|
1677
1746
|
*************/
|
|
1678
1747
|
/**
|
|
1679
1748
|
* Check if component props are well configured on init
|
|
1680
|
-
* @returns
|
|
1749
|
+
* @returns timeout
|
|
1681
1750
|
*/
|
|
1682
1751
|
componentWillLoad() {
|
|
1683
1752
|
// Get locales
|
|
@@ -1697,10 +1766,10 @@ const MgInputDate = class {
|
|
|
1697
1766
|
}
|
|
1698
1767
|
/**
|
|
1699
1768
|
* Render
|
|
1700
|
-
* @returns
|
|
1769
|
+
* @returns HTML Element
|
|
1701
1770
|
*/
|
|
1702
1771
|
render() {
|
|
1703
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
1772
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: mgMenu_conf.localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
1704
1773
|
if (el !== null)
|
|
1705
1774
|
this.input = el;
|
|
1706
1775
|
} })));
|
|
@@ -1729,7 +1798,7 @@ var InputError;
|
|
|
1729
1798
|
InputError["REQUIRED"] = "required";
|
|
1730
1799
|
})(InputError || (InputError = {}));
|
|
1731
1800
|
|
|
1732
|
-
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)}";
|
|
1801
|
+
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)}";
|
|
1733
1802
|
|
|
1734
1803
|
const MgInputNumeric = class {
|
|
1735
1804
|
constructor(hostRef) {
|
|
@@ -1740,7 +1809,6 @@ const MgInputNumeric = class {
|
|
|
1740
1809
|
this.hasDisplayedError = false;
|
|
1741
1810
|
/**
|
|
1742
1811
|
* Handle input event
|
|
1743
|
-
* @returns {void}
|
|
1744
1812
|
*/
|
|
1745
1813
|
this.handleInput = () => {
|
|
1746
1814
|
// Check validity
|
|
@@ -1752,23 +1820,22 @@ const MgInputNumeric = class {
|
|
|
1752
1820
|
};
|
|
1753
1821
|
/**
|
|
1754
1822
|
* Handle focus event
|
|
1755
|
-
* @returns {void}
|
|
1756
1823
|
*/
|
|
1757
1824
|
this.handleFocus = () => {
|
|
1758
1825
|
this.hasFocus = true;
|
|
1759
1826
|
};
|
|
1760
1827
|
/**
|
|
1761
1828
|
* Handle blur event
|
|
1762
|
-
* @returns {void}
|
|
1763
1829
|
*/
|
|
1764
1830
|
this.handleBlur = () => {
|
|
1831
|
+
if (this.value === '-')
|
|
1832
|
+
this.value = '';
|
|
1765
1833
|
// Display Error
|
|
1766
1834
|
this.displayError();
|
|
1767
1835
|
this.hasFocus = false;
|
|
1768
1836
|
};
|
|
1769
1837
|
/**
|
|
1770
1838
|
* Check if input is valid
|
|
1771
|
-
* @returns {void}
|
|
1772
1839
|
*/
|
|
1773
1840
|
this.checkValidity = () => {
|
|
1774
1841
|
this.valid = this.readonly || this.disabled || this.getInputError() === null;
|
|
@@ -1778,7 +1845,6 @@ const MgInputNumeric = class {
|
|
|
1778
1845
|
};
|
|
1779
1846
|
/**
|
|
1780
1847
|
* Set input error message
|
|
1781
|
-
* @returns {void}
|
|
1782
1848
|
*/
|
|
1783
1849
|
this.setErrorMessage = () => {
|
|
1784
1850
|
// Set error message
|
|
@@ -1795,7 +1861,7 @@ const MgInputNumeric = class {
|
|
|
1795
1861
|
};
|
|
1796
1862
|
/**
|
|
1797
1863
|
* Get input error code
|
|
1798
|
-
* @returns
|
|
1864
|
+
* @returns error code
|
|
1799
1865
|
*/
|
|
1800
1866
|
this.getInputError = () => {
|
|
1801
1867
|
let inputError = null;
|
|
@@ -1823,18 +1889,17 @@ const MgInputNumeric = class {
|
|
|
1823
1889
|
};
|
|
1824
1890
|
/**
|
|
1825
1891
|
* Format value based on type
|
|
1826
|
-
* @param
|
|
1827
|
-
* @returns
|
|
1892
|
+
* @param value - value to format
|
|
1893
|
+
* @returns formated local value
|
|
1828
1894
|
*/
|
|
1829
1895
|
this.formatValue = (value) => (this.type === 'currency' ? mgMenu_conf.localeCurrency(value, this.locale, this.currency) : mgMenu_conf.localeNumber(value, this.locale));
|
|
1830
1896
|
/**
|
|
1831
1897
|
* Validate append slot
|
|
1832
|
-
* @returns {void}
|
|
1833
1898
|
*/
|
|
1834
1899
|
this.validateAppendSlot = () => {
|
|
1835
1900
|
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
1836
1901
|
if (slotAppendInput !== null) {
|
|
1837
|
-
this.
|
|
1902
|
+
this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
1838
1903
|
}
|
|
1839
1904
|
};
|
|
1840
1905
|
this.value = undefined;
|
|
@@ -1858,7 +1923,7 @@ const MgInputNumeric = class {
|
|
|
1858
1923
|
this.decimalLength = 2;
|
|
1859
1924
|
this.valid = undefined;
|
|
1860
1925
|
this.invalid = undefined;
|
|
1861
|
-
this.
|
|
1926
|
+
this.classCollection = new ClassList(['mg-input--numeric']);
|
|
1862
1927
|
this.errorMessage = undefined;
|
|
1863
1928
|
this.hasFocus = false;
|
|
1864
1929
|
}
|
|
@@ -1870,7 +1935,7 @@ const MgInputNumeric = class {
|
|
|
1870
1935
|
// Regex
|
|
1871
1936
|
const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+[.,]?\d*$/;
|
|
1872
1937
|
// Filter input
|
|
1873
|
-
if (
|
|
1938
|
+
if (['', '-'].includes(newValue) || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
1874
1939
|
this.storedValue = newValue;
|
|
1875
1940
|
}
|
|
1876
1941
|
else if (this.storedValue !== undefined) {
|
|
@@ -1917,7 +1982,6 @@ const MgInputNumeric = class {
|
|
|
1917
1982
|
}
|
|
1918
1983
|
/**
|
|
1919
1984
|
* Public method to display errors
|
|
1920
|
-
* @returns {Promise<void>}
|
|
1921
1985
|
*/
|
|
1922
1986
|
async displayError() {
|
|
1923
1987
|
this.checkValidity();
|
|
@@ -1927,7 +1991,7 @@ const MgInputNumeric = class {
|
|
|
1927
1991
|
/**
|
|
1928
1992
|
* Displayed value in input
|
|
1929
1993
|
* Change on focus/blur
|
|
1930
|
-
* @returns
|
|
1994
|
+
* @returns display value
|
|
1931
1995
|
*/
|
|
1932
1996
|
displayValue() {
|
|
1933
1997
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -1937,7 +2001,7 @@ const MgInputNumeric = class {
|
|
|
1937
2001
|
*************/
|
|
1938
2002
|
/**
|
|
1939
2003
|
* Check if component props are well configured on init
|
|
1940
|
-
* @returns
|
|
2004
|
+
* @returns timeout
|
|
1941
2005
|
*/
|
|
1942
2006
|
componentWillLoad() {
|
|
1943
2007
|
// Get locales
|
|
@@ -1960,10 +2024,10 @@ const MgInputNumeric = class {
|
|
|
1960
2024
|
}
|
|
1961
2025
|
/**
|
|
1962
2026
|
* Render
|
|
1963
|
-
* @returns
|
|
2027
|
+
* @returns HTML Element
|
|
1964
2028
|
*/
|
|
1965
2029
|
render() {
|
|
1966
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2030
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
|
|
1967
2031
|
if (el !== null)
|
|
1968
2032
|
this.input = el;
|
|
1969
2033
|
} }), index.h("slot", { name: "append-input" })));
|
|
@@ -1981,7 +2045,7 @@ const MgInputNumeric = class {
|
|
|
1981
2045
|
};
|
|
1982
2046
|
MgInputNumeric.style = mgInputNumericCss;
|
|
1983
2047
|
|
|
1984
|
-
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}}";
|
|
2048
|
+
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}}";
|
|
1985
2049
|
|
|
1986
2050
|
const MgInputPassword = class {
|
|
1987
2051
|
constructor(hostRef) {
|
|
@@ -2042,7 +2106,7 @@ const MgInputPassword = class {
|
|
|
2042
2106
|
this.helpText = undefined;
|
|
2043
2107
|
this.valid = undefined;
|
|
2044
2108
|
this.invalid = undefined;
|
|
2045
|
-
this.
|
|
2109
|
+
this.classCollection = new ClassList(['mg-input--password']);
|
|
2046
2110
|
this.errorMessage = undefined;
|
|
2047
2111
|
}
|
|
2048
2112
|
handleValue(newValue) {
|
|
@@ -2060,7 +2124,6 @@ const MgInputPassword = class {
|
|
|
2060
2124
|
}
|
|
2061
2125
|
/**
|
|
2062
2126
|
* Public method to display errors
|
|
2063
|
-
* @returns {Promise<void>}
|
|
2064
2127
|
*/
|
|
2065
2128
|
async displayError() {
|
|
2066
2129
|
this.checkValidity();
|
|
@@ -2072,7 +2135,7 @@ const MgInputPassword = class {
|
|
|
2072
2135
|
*************/
|
|
2073
2136
|
/**
|
|
2074
2137
|
* Check if component props are well configured on init
|
|
2075
|
-
* @returns
|
|
2138
|
+
* @returns timeout
|
|
2076
2139
|
*/
|
|
2077
2140
|
componentWillLoad() {
|
|
2078
2141
|
// Get locales
|
|
@@ -2086,10 +2149,10 @@ const MgInputPassword = class {
|
|
|
2086
2149
|
}
|
|
2087
2150
|
/**
|
|
2088
2151
|
* Render
|
|
2089
|
-
* @returns
|
|
2152
|
+
* @returns HTML Element
|
|
2090
2153
|
*/
|
|
2091
2154
|
render() {
|
|
2092
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2155
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2093
2156
|
if (el !== null)
|
|
2094
2157
|
this.input = el;
|
|
2095
2158
|
} })));
|
|
@@ -2104,12 +2167,12 @@ const MgInputPassword = class {
|
|
|
2104
2167
|
};
|
|
2105
2168
|
MgInputPassword.style = mgInputPasswordCss;
|
|
2106
2169
|
|
|
2107
|
-
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}}";
|
|
2170
|
+
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}}";
|
|
2108
2171
|
|
|
2109
2172
|
/**
|
|
2110
2173
|
* type Option validation function
|
|
2111
|
-
* @param
|
|
2112
|
-
* @returns
|
|
2174
|
+
* @param option - radio option
|
|
2175
|
+
* @returns radio option type is valid
|
|
2113
2176
|
*/
|
|
2114
2177
|
const isOption$2 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
2115
2178
|
const MgInputRadio = class {
|
|
@@ -2126,8 +2189,7 @@ const MgInputRadio = class {
|
|
|
2126
2189
|
this.hasDisplayedError = false;
|
|
2127
2190
|
/**
|
|
2128
2191
|
* Handle input event
|
|
2129
|
-
* @param
|
|
2130
|
-
* @returns {void}
|
|
2192
|
+
* @param event - input event
|
|
2131
2193
|
*/
|
|
2132
2194
|
this.handleInput = (event) => {
|
|
2133
2195
|
this.checkValidity();
|
|
@@ -2135,7 +2197,6 @@ const MgInputRadio = class {
|
|
|
2135
2197
|
};
|
|
2136
2198
|
/**
|
|
2137
2199
|
* Handle blur event
|
|
2138
|
-
* @returns {void}
|
|
2139
2200
|
*/
|
|
2140
2201
|
this.handleBlur = () => {
|
|
2141
2202
|
this.checkValidity();
|
|
@@ -2143,7 +2204,6 @@ const MgInputRadio = class {
|
|
|
2143
2204
|
};
|
|
2144
2205
|
/**
|
|
2145
2206
|
* Check if input is valid
|
|
2146
|
-
* @returns {void}
|
|
2147
2207
|
*/
|
|
2148
2208
|
this.checkValidity = () => {
|
|
2149
2209
|
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
@@ -2153,7 +2213,6 @@ const MgInputRadio = class {
|
|
|
2153
2213
|
};
|
|
2154
2214
|
/**
|
|
2155
2215
|
* Set input error message
|
|
2156
|
-
* @returns {void}
|
|
2157
2216
|
*/
|
|
2158
2217
|
this.setErrorMessage = () => {
|
|
2159
2218
|
const invalidElement = this.getInvalidElement();
|
|
@@ -2165,7 +2224,7 @@ const MgInputRadio = class {
|
|
|
2165
2224
|
};
|
|
2166
2225
|
/**
|
|
2167
2226
|
* get invalid element
|
|
2168
|
-
* @returns
|
|
2227
|
+
* @returns element
|
|
2169
2228
|
*/
|
|
2170
2229
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
2171
2230
|
this.value = undefined;
|
|
@@ -2183,7 +2242,7 @@ const MgInputRadio = class {
|
|
|
2183
2242
|
this.helpText = undefined;
|
|
2184
2243
|
this.valid = undefined;
|
|
2185
2244
|
this.invalid = undefined;
|
|
2186
|
-
this.
|
|
2245
|
+
this.classCollection = new ClassList(['mg-input--radio']);
|
|
2187
2246
|
this.errorMessage = undefined;
|
|
2188
2247
|
this.options = undefined;
|
|
2189
2248
|
}
|
|
@@ -2219,7 +2278,6 @@ const MgInputRadio = class {
|
|
|
2219
2278
|
}
|
|
2220
2279
|
/**
|
|
2221
2280
|
* Public method to display errors
|
|
2222
|
-
* @returns {Promise<void>}
|
|
2223
2281
|
*/
|
|
2224
2282
|
async displayError() {
|
|
2225
2283
|
this.checkValidity();
|
|
@@ -2231,7 +2289,7 @@ const MgInputRadio = class {
|
|
|
2231
2289
|
*************/
|
|
2232
2290
|
/**
|
|
2233
2291
|
* Check if component props are well configured on init
|
|
2234
|
-
* @returns
|
|
2292
|
+
* @returns timeout
|
|
2235
2293
|
*/
|
|
2236
2294
|
componentWillLoad() {
|
|
2237
2295
|
// Get locales
|
|
@@ -2247,10 +2305,10 @@ const MgInputRadio = class {
|
|
|
2247
2305
|
}
|
|
2248
2306
|
/**
|
|
2249
2307
|
* Render
|
|
2250
|
-
* @returns
|
|
2308
|
+
* @returns HTML Element
|
|
2251
2309
|
*/
|
|
2252
2310
|
render() {
|
|
2253
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2311
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.options.map((input, index$1) => (index.h("li", { key: input.title, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "radio", id: this.identifier + '_' + index$1, name: this.identifier, value: index$1, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index$1].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => {
|
|
2254
2312
|
if (el !== null)
|
|
2255
2313
|
this.inputs[index$1] = el;
|
|
2256
2314
|
} }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title)))))));
|
|
@@ -2266,35 +2324,31 @@ const MgInputRadio = class {
|
|
|
2266
2324
|
};
|
|
2267
2325
|
MgInputRadio.style = mgInputRadioCss;
|
|
2268
2326
|
|
|
2269
|
-
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}";
|
|
2327
|
+
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}";
|
|
2270
2328
|
|
|
2271
2329
|
/**
|
|
2272
2330
|
* Check if item is a well configured option
|
|
2273
|
-
* @param
|
|
2274
|
-
* @returns
|
|
2331
|
+
* @param option - select option
|
|
2332
|
+
* @returns select option type is valid
|
|
2275
2333
|
*/
|
|
2276
2334
|
const isOption$1 = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
2277
2335
|
/**
|
|
2278
2336
|
* Check if items[] is SelectOption
|
|
2279
|
-
* @param
|
|
2280
|
-
* @returns
|
|
2337
|
+
* @param items - select option
|
|
2338
|
+
* @returns select option array type is valid
|
|
2281
2339
|
*/
|
|
2282
2340
|
const allItemsAreOptions = (items) => Array.isArray(items) && items.every(item => isOption$1(item));
|
|
2283
2341
|
/**
|
|
2284
2342
|
* Check if item is a well configured optgroup
|
|
2285
|
-
* @param
|
|
2286
|
-
* @returns
|
|
2343
|
+
* @param optgroup - select option
|
|
2344
|
+
* @returns select optgroup type is valid
|
|
2287
2345
|
*/
|
|
2288
2346
|
const isOptGroup = (optgroup) => typeof optgroup === 'object' && typeof optgroup.group === 'string' && allItemsAreOptions(optgroup.options);
|
|
2289
2347
|
/**
|
|
2290
2348
|
* Group options
|
|
2291
|
-
* @param
|
|
2292
|
-
* @param
|
|
2293
|
-
* @
|
|
2294
|
-
* @param {string} item.title item title
|
|
2295
|
-
* @param {unknown} item.value item value
|
|
2296
|
-
* @param {boolean} item.disabled is item disabled
|
|
2297
|
-
* @returns {(SelectOption | OptGroup)[]} grouped options
|
|
2349
|
+
* @param acc - reduce accumulator
|
|
2350
|
+
* @param item - item to add
|
|
2351
|
+
* @returns grouped options
|
|
2298
2352
|
*/
|
|
2299
2353
|
const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
2300
2354
|
if (group !== undefined) {
|
|
@@ -2323,7 +2377,6 @@ const MgInputSelect = class {
|
|
|
2323
2377
|
this.hasDisplayedError = false;
|
|
2324
2378
|
/**
|
|
2325
2379
|
* Handle input event
|
|
2326
|
-
* @returns {void}
|
|
2327
2380
|
*/
|
|
2328
2381
|
this.handleInput = () => {
|
|
2329
2382
|
this.updateValue();
|
|
@@ -2332,14 +2385,13 @@ const MgInputSelect = class {
|
|
|
2332
2385
|
};
|
|
2333
2386
|
/**
|
|
2334
2387
|
* Method to compare item.title with input.value
|
|
2335
|
-
* @param
|
|
2336
|
-
* @returns
|
|
2388
|
+
* @param item - item to compare with
|
|
2389
|
+
* @returns truthy if input.value is an item
|
|
2337
2390
|
*/
|
|
2338
2391
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
2339
2392
|
/**
|
|
2340
2393
|
* value props setter
|
|
2341
|
-
* @param
|
|
2342
|
-
* @returns {void}
|
|
2394
|
+
* @param newValue - value to update with
|
|
2343
2395
|
*/
|
|
2344
2396
|
this.setValue = (newValue) => {
|
|
2345
2397
|
this.checkValidity();
|
|
@@ -2347,7 +2399,6 @@ const MgInputSelect = class {
|
|
|
2347
2399
|
};
|
|
2348
2400
|
/**
|
|
2349
2401
|
* Update value from input.value
|
|
2350
|
-
* @returns {void}
|
|
2351
2402
|
*/
|
|
2352
2403
|
this.updateValue = () => {
|
|
2353
2404
|
if (this.input.value === '') {
|
|
@@ -2373,7 +2424,7 @@ const MgInputSelect = class {
|
|
|
2373
2424
|
};
|
|
2374
2425
|
/**
|
|
2375
2426
|
* Input value is disabled
|
|
2376
|
-
* @returns
|
|
2427
|
+
* @returns truthy if input value is disabled
|
|
2377
2428
|
*/
|
|
2378
2429
|
this.isDisabledValue = () => { var _a; return allItemsAreOptions(this.options) && ((_a = this.options.find(this.isInputValue)) === null || _a === void 0 ? void 0 : _a.disabled) === true; };
|
|
2379
2430
|
/**
|
|
@@ -2398,8 +2449,8 @@ const MgInputSelect = class {
|
|
|
2398
2449
|
};
|
|
2399
2450
|
/**
|
|
2400
2451
|
* Render option
|
|
2401
|
-
* @param
|
|
2402
|
-
* @returns
|
|
2452
|
+
* @param option - to render
|
|
2453
|
+
* @returns render option
|
|
2403
2454
|
*/
|
|
2404
2455
|
this.renderOption = (option) => (index.h("option", { key: option.title, value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title));
|
|
2405
2456
|
this.value = undefined;
|
|
@@ -2420,7 +2471,7 @@ const MgInputSelect = class {
|
|
|
2420
2471
|
this.helpText = undefined;
|
|
2421
2472
|
this.valid = undefined;
|
|
2422
2473
|
this.invalid = undefined;
|
|
2423
|
-
this.
|
|
2474
|
+
this.classCollection = new ClassList(['mg-input--select']);
|
|
2424
2475
|
this.errorMessage = undefined;
|
|
2425
2476
|
this.options = undefined;
|
|
2426
2477
|
this.valueExist = undefined;
|
|
@@ -2478,7 +2529,6 @@ const MgInputSelect = class {
|
|
|
2478
2529
|
}
|
|
2479
2530
|
/**
|
|
2480
2531
|
* Public method to display errors
|
|
2481
|
-
* @returns {Promise<void>}
|
|
2482
2532
|
*/
|
|
2483
2533
|
async displayError() {
|
|
2484
2534
|
this.checkValidity();
|
|
@@ -2490,7 +2540,7 @@ const MgInputSelect = class {
|
|
|
2490
2540
|
*************/
|
|
2491
2541
|
/**
|
|
2492
2542
|
* Check if component props are well configured on init
|
|
2493
|
-
* @returns
|
|
2543
|
+
* @returns timeout
|
|
2494
2544
|
*/
|
|
2495
2545
|
componentWillLoad() {
|
|
2496
2546
|
// Get locales
|
|
@@ -2511,10 +2561,10 @@ const MgInputSelect = class {
|
|
|
2511
2561
|
}
|
|
2512
2562
|
/**
|
|
2513
2563
|
* Render
|
|
2514
|
-
* @returns
|
|
2564
|
+
* @returns HTML Element
|
|
2515
2565
|
*/
|
|
2516
2566
|
render() {
|
|
2517
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2567
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: undefined, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
2518
2568
|
if (el !== null)
|
|
2519
2569
|
this.input = el;
|
|
2520
2570
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -2531,7 +2581,7 @@ const MgInputSelect = class {
|
|
|
2531
2581
|
};
|
|
2532
2582
|
MgInputSelect.style = mgInputSelectCss;
|
|
2533
2583
|
|
|
2534
|
-
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}";
|
|
2584
|
+
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}";
|
|
2535
2585
|
|
|
2536
2586
|
const MgInputText = class {
|
|
2537
2587
|
constructor(hostRef) {
|
|
@@ -2549,7 +2599,6 @@ const MgInputText = class {
|
|
|
2549
2599
|
this.hasDisplayedError = false;
|
|
2550
2600
|
/**
|
|
2551
2601
|
* Handle input event
|
|
2552
|
-
* @returns {void}
|
|
2553
2602
|
*/
|
|
2554
2603
|
this.handleInput = () => {
|
|
2555
2604
|
this.checkValidity();
|
|
@@ -2560,26 +2609,23 @@ const MgInputText = class {
|
|
|
2560
2609
|
};
|
|
2561
2610
|
/**
|
|
2562
2611
|
* Handle focus event
|
|
2563
|
-
* @returns {void}
|
|
2564
2612
|
*/
|
|
2565
2613
|
this.handleFocus = () => {
|
|
2566
|
-
this.
|
|
2567
|
-
this.
|
|
2614
|
+
this.classCollection.add(this.classFocus);
|
|
2615
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2568
2616
|
};
|
|
2569
2617
|
/**
|
|
2570
2618
|
* Handle blur event
|
|
2571
|
-
* @returns {void}
|
|
2572
2619
|
*/
|
|
2573
2620
|
this.handleBlur = () => {
|
|
2574
2621
|
// Manage focus
|
|
2575
|
-
this.
|
|
2576
|
-
this.
|
|
2622
|
+
this.classCollection.delete(this.classFocus);
|
|
2623
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2577
2624
|
// Display Error
|
|
2578
2625
|
this.displayError();
|
|
2579
2626
|
};
|
|
2580
2627
|
/**
|
|
2581
2628
|
* Check if input is valid
|
|
2582
|
-
* @returns {void}
|
|
2583
2629
|
*/
|
|
2584
2630
|
this.checkValidity = () => {
|
|
2585
2631
|
var _a;
|
|
@@ -2590,7 +2636,6 @@ const MgInputText = class {
|
|
|
2590
2636
|
};
|
|
2591
2637
|
/**
|
|
2592
2638
|
* Set input error message
|
|
2593
|
-
* @returns {void}
|
|
2594
2639
|
*/
|
|
2595
2640
|
this.setErrorMessage = () => {
|
|
2596
2641
|
// Set error message
|
|
@@ -2606,7 +2651,6 @@ const MgInputText = class {
|
|
|
2606
2651
|
};
|
|
2607
2652
|
/**
|
|
2608
2653
|
* Validate pattern configuration
|
|
2609
|
-
* @returns {void}
|
|
2610
2654
|
*/
|
|
2611
2655
|
this.validatePattern = () => {
|
|
2612
2656
|
if (this.pattern !== undefined &&
|
|
@@ -2618,16 +2662,15 @@ const MgInputText = class {
|
|
|
2618
2662
|
};
|
|
2619
2663
|
/**
|
|
2620
2664
|
* Validate append slot
|
|
2621
|
-
* @returns {void}
|
|
2622
2665
|
*/
|
|
2623
2666
|
this.validateAppendSlot = () => {
|
|
2624
2667
|
const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
|
|
2625
2668
|
if (slotAppendInput.length === 1) {
|
|
2626
|
-
this.
|
|
2669
|
+
this.classCollection.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.classIsInputGroupAppend : 'mg-input--is-append-input-slot-content');
|
|
2627
2670
|
}
|
|
2628
2671
|
else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
|
|
2629
|
-
this.
|
|
2630
|
-
this.
|
|
2672
|
+
this.classCollection.add(this.classIsInputGroupAppend);
|
|
2673
|
+
this.classCollection.add('mg-input--has-buttons-group-append');
|
|
2631
2674
|
}
|
|
2632
2675
|
};
|
|
2633
2676
|
this.value = undefined;
|
|
@@ -2651,7 +2694,7 @@ const MgInputText = class {
|
|
|
2651
2694
|
this.helpText = undefined;
|
|
2652
2695
|
this.valid = undefined;
|
|
2653
2696
|
this.invalid = undefined;
|
|
2654
|
-
this.
|
|
2697
|
+
this.classCollection = new ClassList(['mg-input--text']);
|
|
2655
2698
|
this.errorMessage = undefined;
|
|
2656
2699
|
}
|
|
2657
2700
|
handleValue(newValue) {
|
|
@@ -2659,10 +2702,10 @@ const MgInputText = class {
|
|
|
2659
2702
|
}
|
|
2660
2703
|
validateIcon(newValue) {
|
|
2661
2704
|
if (newValue !== undefined) {
|
|
2662
|
-
this.
|
|
2705
|
+
this.classCollection.add(this.classHasIcon);
|
|
2663
2706
|
}
|
|
2664
2707
|
else {
|
|
2665
|
-
this.
|
|
2708
|
+
this.classCollection.delete(this.classHasIcon);
|
|
2666
2709
|
}
|
|
2667
2710
|
}
|
|
2668
2711
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -2677,14 +2720,12 @@ const MgInputText = class {
|
|
|
2677
2720
|
}
|
|
2678
2721
|
/**
|
|
2679
2722
|
* Public method to play input focus
|
|
2680
|
-
* @returns {Promise<void>}
|
|
2681
2723
|
*/
|
|
2682
2724
|
async setFocus() {
|
|
2683
2725
|
this.input.focus();
|
|
2684
2726
|
}
|
|
2685
2727
|
/**
|
|
2686
2728
|
* Public method to display errors
|
|
2687
|
-
* @returns {Promise<void>}
|
|
2688
2729
|
*/
|
|
2689
2730
|
async displayError() {
|
|
2690
2731
|
this.checkValidity();
|
|
@@ -2696,7 +2737,7 @@ const MgInputText = class {
|
|
|
2696
2737
|
*************/
|
|
2697
2738
|
/**
|
|
2698
2739
|
* Check if component props are well configured on init
|
|
2699
|
-
* @returns
|
|
2740
|
+
* @returns timeout
|
|
2700
2741
|
*/
|
|
2701
2742
|
componentWillLoad() {
|
|
2702
2743
|
// Get locales
|
|
@@ -2715,10 +2756,10 @@ const MgInputText = class {
|
|
|
2715
2756
|
}
|
|
2716
2757
|
/**
|
|
2717
2758
|
* Render
|
|
2718
|
-
* @returns
|
|
2759
|
+
* @returns HTML Element
|
|
2719
2760
|
*/
|
|
2720
2761
|
render() {
|
|
2721
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2762
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("div", { class: "mg-input__with-character-left", style: {
|
|
2722
2763
|
'--mg-character-left-message-length': (this.displayCharacterLeft
|
|
2723
2764
|
? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
|
|
2724
2765
|
: 0).toString(),
|
|
@@ -2738,7 +2779,7 @@ const MgInputText = class {
|
|
|
2738
2779
|
};
|
|
2739
2780
|
MgInputText.style = mgInputTextCss;
|
|
2740
2781
|
|
|
2741
|
-
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}}";
|
|
2782
|
+
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}}";
|
|
2742
2783
|
|
|
2743
2784
|
const MgInputTextarea = class {
|
|
2744
2785
|
constructor(hostRef) {
|
|
@@ -2767,23 +2808,23 @@ const MgInputTextarea = class {
|
|
|
2767
2808
|
* Handle focus event
|
|
2768
2809
|
*/
|
|
2769
2810
|
this.handleFocus = () => {
|
|
2770
|
-
this.
|
|
2771
|
-
this.
|
|
2811
|
+
this.classCollection.add(this.classFocus);
|
|
2812
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2772
2813
|
};
|
|
2773
2814
|
/**
|
|
2774
2815
|
* Handle blur event
|
|
2775
2816
|
*/
|
|
2776
2817
|
this.handleBlur = () => {
|
|
2777
2818
|
// Manage focus
|
|
2778
|
-
this.
|
|
2779
|
-
this.
|
|
2819
|
+
this.classCollection.delete(this.classFocus);
|
|
2820
|
+
this.classCollection = new ClassList(this.classCollection.classes);
|
|
2780
2821
|
// Display Error
|
|
2781
2822
|
this.displayError();
|
|
2782
2823
|
};
|
|
2783
2824
|
/**
|
|
2784
2825
|
* Get pattern validity
|
|
2785
2826
|
* Pattern is not defined on textarea field: https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
|
|
2786
|
-
* @returns
|
|
2827
|
+
* @returns is pattern valid
|
|
2787
2828
|
*/
|
|
2788
2829
|
this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
|
|
2789
2830
|
/**
|
|
@@ -2843,7 +2884,7 @@ const MgInputTextarea = class {
|
|
|
2843
2884
|
this.valid = undefined;
|
|
2844
2885
|
this.invalid = undefined;
|
|
2845
2886
|
this.resizable = 'none';
|
|
2846
|
-
this.
|
|
2887
|
+
this.classCollection = new ClassList(['mg-input--textarea']);
|
|
2847
2888
|
this.errorMessage = undefined;
|
|
2848
2889
|
}
|
|
2849
2890
|
handleValue(newValue) {
|
|
@@ -2862,15 +2903,14 @@ const MgInputTextarea = class {
|
|
|
2862
2903
|
}
|
|
2863
2904
|
validateDisplayCharacterLeft(newValue) {
|
|
2864
2905
|
if (newValue) {
|
|
2865
|
-
this.
|
|
2906
|
+
this.classCollection.add(this.classHasDisplayCharacterLeft);
|
|
2866
2907
|
}
|
|
2867
2908
|
else {
|
|
2868
|
-
this.
|
|
2909
|
+
this.classCollection.delete(this.classHasDisplayCharacterLeft);
|
|
2869
2910
|
}
|
|
2870
2911
|
}
|
|
2871
2912
|
/**
|
|
2872
2913
|
* Public method to display errors
|
|
2873
|
-
* @returns {Promise<void>}
|
|
2874
2914
|
*/
|
|
2875
2915
|
async displayError() {
|
|
2876
2916
|
this.checkValidity();
|
|
@@ -2882,7 +2922,7 @@ const MgInputTextarea = class {
|
|
|
2882
2922
|
*************/
|
|
2883
2923
|
/**
|
|
2884
2924
|
* Check if component props are well configured on init
|
|
2885
|
-
* @returns
|
|
2925
|
+
* @returns timeout
|
|
2886
2926
|
*/
|
|
2887
2927
|
componentWillLoad() {
|
|
2888
2928
|
// Get locales
|
|
@@ -2900,10 +2940,10 @@ const MgInputTextarea = class {
|
|
|
2900
2940
|
}
|
|
2901
2941
|
/**
|
|
2902
2942
|
* Render
|
|
2903
|
-
* @returns
|
|
2943
|
+
* @returns HTML Element
|
|
2904
2944
|
*/
|
|
2905
2945
|
render() {
|
|
2906
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
2946
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("div", { class: "mg-input__with-character-left" }, index.h("textarea", { class: {
|
|
2907
2947
|
'mg-input__box': true,
|
|
2908
2948
|
'mg-input__box--resizable': this.resizable === 'both',
|
|
2909
2949
|
'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
@@ -2947,7 +2987,6 @@ const MgInputTitle = class {
|
|
|
2947
2987
|
*************/
|
|
2948
2988
|
/**
|
|
2949
2989
|
* Init tag name
|
|
2950
|
-
* @returns {void}
|
|
2951
2990
|
*/
|
|
2952
2991
|
componentWillLoad() {
|
|
2953
2992
|
this.validateIdentifier(this.identifier);
|
|
@@ -2955,7 +2994,7 @@ const MgInputTitle = class {
|
|
|
2955
2994
|
}
|
|
2956
2995
|
/**
|
|
2957
2996
|
* Render
|
|
2958
|
-
* @returns
|
|
2997
|
+
* @returns HTML element
|
|
2959
2998
|
*/
|
|
2960
2999
|
render() {
|
|
2961
3000
|
const TagName = this.tagName;
|
|
@@ -2968,12 +3007,12 @@ const MgInputTitle = class {
|
|
|
2968
3007
|
};
|
|
2969
3008
|
MgInputTitle.style = mgInputTitleCss;
|
|
2970
3009
|
|
|
2971
|
-
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}";
|
|
3010
|
+
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}";
|
|
2972
3011
|
|
|
2973
3012
|
/**
|
|
2974
3013
|
* type Option validation function
|
|
2975
|
-
* @param
|
|
2976
|
-
* @returns
|
|
3014
|
+
* @param option - radio option
|
|
3015
|
+
* @returns toggle option type is valid
|
|
2977
3016
|
*/
|
|
2978
3017
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
2979
3018
|
const MgInputToggle = class {
|
|
@@ -2992,14 +3031,12 @@ const MgInputToggle = class {
|
|
|
2992
3031
|
this.classIcon = 'mg-input--toggle-icon';
|
|
2993
3032
|
/**
|
|
2994
3033
|
* Change checked value
|
|
2995
|
-
* @returns {void}
|
|
2996
3034
|
*/
|
|
2997
3035
|
this.toggleChecked = () => {
|
|
2998
3036
|
this.checked = !this.checked;
|
|
2999
3037
|
};
|
|
3000
3038
|
/**
|
|
3001
3039
|
* Slots validation
|
|
3002
|
-
* @returns {void}
|
|
3003
3040
|
*/
|
|
3004
3041
|
this.validateSlots = () => {
|
|
3005
3042
|
const slots = Array.from(this.element.children);
|
|
@@ -3025,7 +3062,7 @@ const MgInputToggle = class {
|
|
|
3025
3062
|
this.disabled = false;
|
|
3026
3063
|
this.tooltip = undefined;
|
|
3027
3064
|
this.helpText = undefined;
|
|
3028
|
-
this.
|
|
3065
|
+
this.classCollection = new ClassList(['mg-input--toggle']);
|
|
3029
3066
|
this.options = undefined;
|
|
3030
3067
|
this.checked = false;
|
|
3031
3068
|
}
|
|
@@ -3053,40 +3090,39 @@ const MgInputToggle = class {
|
|
|
3053
3090
|
}
|
|
3054
3091
|
handleIsOnOff(newValue) {
|
|
3055
3092
|
if (newValue)
|
|
3056
|
-
this.
|
|
3093
|
+
this.classCollection.add(this.classOnOff);
|
|
3057
3094
|
else
|
|
3058
|
-
this.
|
|
3095
|
+
this.classCollection.delete(this.classOnOff);
|
|
3059
3096
|
}
|
|
3060
3097
|
handleIsIcon(newValue) {
|
|
3061
3098
|
if (newValue)
|
|
3062
|
-
this.
|
|
3099
|
+
this.classCollection.add(this.classIcon);
|
|
3063
3100
|
else
|
|
3064
|
-
this.
|
|
3101
|
+
this.classCollection.delete(this.classIcon);
|
|
3065
3102
|
}
|
|
3066
3103
|
handleReadonly(newValue) {
|
|
3067
3104
|
if (newValue)
|
|
3068
|
-
this.
|
|
3105
|
+
this.classCollection.add(this.classReadonly);
|
|
3069
3106
|
else
|
|
3070
|
-
this.
|
|
3107
|
+
this.classCollection.delete(this.classReadonly);
|
|
3071
3108
|
}
|
|
3072
3109
|
handleDisabled(newValue) {
|
|
3073
3110
|
if (newValue)
|
|
3074
|
-
this.
|
|
3111
|
+
this.classCollection.add(this.classDisabled);
|
|
3075
3112
|
else
|
|
3076
|
-
this.
|
|
3113
|
+
this.classCollection.delete(this.classDisabled);
|
|
3077
3114
|
}
|
|
3078
3115
|
handleChecked(newValue) {
|
|
3079
3116
|
// style
|
|
3080
3117
|
if (newValue)
|
|
3081
|
-
this.
|
|
3118
|
+
this.classCollection.add(this.classIsActive);
|
|
3082
3119
|
else
|
|
3083
|
-
this.
|
|
3120
|
+
this.classCollection.delete(this.classIsActive);
|
|
3084
3121
|
// update value
|
|
3085
3122
|
this.value = this.options[newValue ? 1 : 0].value;
|
|
3086
3123
|
}
|
|
3087
3124
|
/**
|
|
3088
3125
|
* set checked state
|
|
3089
|
-
* @returns {void}
|
|
3090
3126
|
*/
|
|
3091
3127
|
setChecked() {
|
|
3092
3128
|
const optionTrueValueIndex = this.options.map(option => option.value).findIndex(value => value === true);
|
|
@@ -3128,10 +3164,10 @@ const MgInputToggle = class {
|
|
|
3128
3164
|
}
|
|
3129
3165
|
/**
|
|
3130
3166
|
* Render
|
|
3131
|
-
* @returns
|
|
3167
|
+
* @returns HTML Element
|
|
3132
3168
|
*/
|
|
3133
3169
|
render() {
|
|
3134
|
-
return (index.h(MgInput, { identifier: this.identifier,
|
|
3170
|
+
return (index.h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, index.h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, index.h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, index.h("slot", { name: "item-1" })), index.h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, index.h("slot", { name: "item-2" })))));
|
|
3135
3171
|
}
|
|
3136
3172
|
get element() { return index.getElement(this); }
|
|
3137
3173
|
static get watchers() { return {
|
|
@@ -3162,9 +3198,8 @@ const MgMenu = class {
|
|
|
3162
3198
|
*************/
|
|
3163
3199
|
/**
|
|
3164
3200
|
* Close matching menu-item
|
|
3165
|
-
* @param
|
|
3166
|
-
* @param
|
|
3167
|
-
* @returns {void}
|
|
3201
|
+
* @param item - menu-item to close
|
|
3202
|
+
* @param condition - addionnal condition
|
|
3168
3203
|
*/
|
|
3169
3204
|
this.closeMenuItem = (item, condition) => {
|
|
3170
3205
|
if (!this.isChildMenu && condition) {
|
|
@@ -3173,19 +3208,18 @@ const MgMenu = class {
|
|
|
3173
3208
|
};
|
|
3174
3209
|
/**
|
|
3175
3210
|
* get mg-item-more element
|
|
3176
|
-
* @returns
|
|
3211
|
+
* @returns mg-item-more element
|
|
3177
3212
|
*/
|
|
3178
3213
|
this.getItemMore = () => this.element.querySelector('mg-item-more');
|
|
3179
3214
|
/**
|
|
3180
|
-
* get mg-item-more
|
|
3181
|
-
* @returns
|
|
3215
|
+
* get mg-item-more child mg-menu-item element
|
|
3216
|
+
* @returns mg-menu-item element
|
|
3182
3217
|
*/
|
|
3183
3218
|
this.getItemMoreMenuItem = () => { var _a, _b; return (_b = (_a = this.getItemMore()) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mg-menu-item'); };
|
|
3184
3219
|
/**
|
|
3185
3220
|
* Set item listend
|
|
3186
|
-
* @param
|
|
3187
|
-
* @param
|
|
3188
|
-
* @returns {void}
|
|
3221
|
+
* @param item - mg-menu-item element
|
|
3222
|
+
* @param index - number
|
|
3189
3223
|
*/
|
|
3190
3224
|
this.setItemListener = (item, index) => {
|
|
3191
3225
|
['click', 'focus'].forEach(trigger => {
|
|
@@ -3200,7 +3234,6 @@ const MgMenu = class {
|
|
|
3200
3234
|
};
|
|
3201
3235
|
/**
|
|
3202
3236
|
* Store menu-items on component init and add listeners
|
|
3203
|
-
* @returns {void}
|
|
3204
3237
|
*/
|
|
3205
3238
|
this.initMenuItemsListeners = () => {
|
|
3206
3239
|
// add listeners on menu item and edit index
|
|
@@ -3210,14 +3243,12 @@ const MgMenu = class {
|
|
|
3210
3243
|
};
|
|
3211
3244
|
/**
|
|
3212
3245
|
* Handle item-loaded event on mg-item-more element
|
|
3213
|
-
* @returns {void}
|
|
3214
3246
|
*/
|
|
3215
3247
|
this.handleItemLoaded = () => {
|
|
3216
3248
|
this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);
|
|
3217
3249
|
};
|
|
3218
3250
|
/**
|
|
3219
3251
|
* render mg-item-more
|
|
3220
|
-
* @returns {void}
|
|
3221
3252
|
*/
|
|
3222
3253
|
this.renderMgItemMore = () => {
|
|
3223
3254
|
// /!\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement
|
|
@@ -3259,7 +3290,6 @@ const MgMenu = class {
|
|
|
3259
3290
|
*************/
|
|
3260
3291
|
/**
|
|
3261
3292
|
* Validate props
|
|
3262
|
-
* @returns {void}
|
|
3263
3293
|
*/
|
|
3264
3294
|
componentWillLoad() {
|
|
3265
3295
|
this.validateDirection(this.direction);
|
|
@@ -3269,7 +3299,7 @@ const MgMenu = class {
|
|
|
3269
3299
|
}
|
|
3270
3300
|
/**
|
|
3271
3301
|
* Check if component slots configuration
|
|
3272
|
-
* @returns
|
|
3302
|
+
* @returns timeout
|
|
3273
3303
|
*/
|
|
3274
3304
|
componentDidLoad() {
|
|
3275
3305
|
// update props and states after componentDidLoad hook
|
|
@@ -3299,14 +3329,13 @@ const MgMenu = class {
|
|
|
3299
3329
|
}
|
|
3300
3330
|
/**
|
|
3301
3331
|
* Add listeners to items
|
|
3302
|
-
* @returns {void}
|
|
3303
3332
|
*/
|
|
3304
3333
|
componentDidRender() {
|
|
3305
3334
|
this.initMenuItemsListeners();
|
|
3306
3335
|
}
|
|
3307
3336
|
/**
|
|
3308
3337
|
* Render
|
|
3309
|
-
* @returns
|
|
3338
|
+
* @returns HTML Element
|
|
3310
3339
|
*/
|
|
3311
3340
|
render() {
|
|
3312
3341
|
return (index.h(index.Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, index.h("slot", null)));
|
|
@@ -3338,29 +3367,27 @@ const MgMenuItem = class {
|
|
|
3338
3367
|
**********/
|
|
3339
3368
|
/**
|
|
3340
3369
|
* Toggle expanded prop value
|
|
3341
|
-
* @returns {void}
|
|
3342
3370
|
*/
|
|
3343
3371
|
this.toggleExpanded = () => {
|
|
3344
3372
|
this.expanded = !this.expanded;
|
|
3345
3373
|
};
|
|
3346
3374
|
/**
|
|
3347
3375
|
* Does an Element have given Status
|
|
3348
|
-
* @param
|
|
3349
|
-
* @param
|
|
3350
|
-
* @returns
|
|
3376
|
+
* @param mgMenuItemElement - to parse
|
|
3377
|
+
* @param status - to check
|
|
3378
|
+
* @returns true if element with status is found
|
|
3351
3379
|
*/
|
|
3352
3380
|
this.hasStatus = (mgMenuItemElement, status) => mgMenuItemElement.status === status;
|
|
3353
3381
|
/**
|
|
3354
3382
|
* Is component contextual direction match the given direction
|
|
3355
|
-
* @param
|
|
3356
|
-
* @param
|
|
3357
|
-
* @returns
|
|
3383
|
+
* @param direction - in parent menu
|
|
3384
|
+
* @param compareWith - direction to compare with. Default: `this.direction`
|
|
3385
|
+
* @returns true is direction match the direction propertie
|
|
3358
3386
|
*/
|
|
3359
3387
|
this.isDirection = (direction, compareWith = this.direction) => direction === compareWith;
|
|
3360
3388
|
/**
|
|
3361
3389
|
* Update displayNotificationBadge
|
|
3362
3390
|
* current component notification badge have priority over the slot badge when submenu contain badge
|
|
3363
|
-
* @returns {void} update displayNotificationBadge value
|
|
3364
3391
|
*/
|
|
3365
3392
|
this.updateDisplayNotificationBadge = () => {
|
|
3366
3393
|
const childMenu = this.element.querySelector('mg-menu');
|
|
@@ -3370,7 +3397,7 @@ const MgMenuItem = class {
|
|
|
3370
3397
|
};
|
|
3371
3398
|
/**
|
|
3372
3399
|
* Method to control if one of component children have active status
|
|
3373
|
-
* @returns
|
|
3400
|
+
* @returns truthy if component has active child
|
|
3374
3401
|
*/
|
|
3375
3402
|
this.hasActiveChild = () => {
|
|
3376
3403
|
var _a;
|
|
@@ -3378,8 +3405,7 @@ const MgMenuItem = class {
|
|
|
3378
3405
|
};
|
|
3379
3406
|
/**
|
|
3380
3407
|
* Validate slots
|
|
3381
|
-
* @param
|
|
3382
|
-
* @returns {void}
|
|
3408
|
+
* @param guard - prevent action whith guard. Default: false.
|
|
3383
3409
|
*/
|
|
3384
3410
|
this.validateSlot = (guard = false) => {
|
|
3385
3411
|
// slot title AND metadata validation
|
|
@@ -3397,8 +3423,7 @@ const MgMenuItem = class {
|
|
|
3397
3423
|
};
|
|
3398
3424
|
/**
|
|
3399
3425
|
* Update status
|
|
3400
|
-
* @param
|
|
3401
|
-
* @returns {void}
|
|
3426
|
+
* @param guard - status to exclude from process in addition to [Status.HIDDEN, Status.DISABLED] . Default: [].
|
|
3402
3427
|
*/
|
|
3403
3428
|
this.updateStatus = (guard = []) => {
|
|
3404
3429
|
if (![Status$1.HIDDEN, Status$1.DISABLED, ...guard].includes(this.status)) {
|
|
@@ -3407,7 +3432,6 @@ const MgMenuItem = class {
|
|
|
3407
3432
|
};
|
|
3408
3433
|
/**
|
|
3409
3434
|
* Init event-listeners
|
|
3410
|
-
* @returns {void}
|
|
3411
3435
|
*/
|
|
3412
3436
|
this.initListeners = () => {
|
|
3413
3437
|
var _a;
|
|
@@ -3423,12 +3447,12 @@ const MgMenuItem = class {
|
|
|
3423
3447
|
};
|
|
3424
3448
|
/**
|
|
3425
3449
|
* Get mg-popover identifier
|
|
3426
|
-
* @returns
|
|
3450
|
+
* @returns generated mg-popover identifier
|
|
3427
3451
|
*/
|
|
3428
3452
|
this.getPopoverIdentifier = () => `${this.identifier}-popover`;
|
|
3429
3453
|
/**
|
|
3430
3454
|
* Condition to know if component should display a mg-popover
|
|
3431
|
-
* @returns
|
|
3455
|
+
* @returns truthy if component display popover
|
|
3432
3456
|
*/
|
|
3433
3457
|
this.displayPopover = () => this.isDirection(mgMenu_conf.Direction.HORIZONTAL) && this.hasChildren && this.href === undefined;
|
|
3434
3458
|
/************
|
|
@@ -3436,8 +3460,7 @@ const MgMenuItem = class {
|
|
|
3436
3460
|
************/
|
|
3437
3461
|
/**
|
|
3438
3462
|
* Handle interacrtive element click
|
|
3439
|
-
* @param
|
|
3440
|
-
* @returns {void}
|
|
3463
|
+
* @param event - click on element
|
|
3441
3464
|
*/
|
|
3442
3465
|
this.handleElementCLick = (event) => {
|
|
3443
3466
|
if ((this.hasChildren && !this.isInMainMenu) || this.status === Status$1.DISABLED) {
|
|
@@ -3450,15 +3473,14 @@ const MgMenuItem = class {
|
|
|
3450
3473
|
};
|
|
3451
3474
|
/**
|
|
3452
3475
|
* Handle popover element display-change event
|
|
3453
|
-
* @param
|
|
3454
|
-
* @returns {void}
|
|
3476
|
+
* @param event - popover display event
|
|
3455
3477
|
*/
|
|
3456
3478
|
this.handlePopoverDisplay = (event) => {
|
|
3457
3479
|
this.expanded = event.detail;
|
|
3458
3480
|
};
|
|
3459
3481
|
/**
|
|
3460
3482
|
* Render slot
|
|
3461
|
-
* @returns
|
|
3483
|
+
* @returns HTML Element
|
|
3462
3484
|
*/
|
|
3463
3485
|
this.renderSlot = () => index.h("slot", null);
|
|
3464
3486
|
this.identifier = createID('mg-menu-item');
|
|
@@ -3524,7 +3546,6 @@ const MgMenuItem = class {
|
|
|
3524
3546
|
}
|
|
3525
3547
|
/**
|
|
3526
3548
|
* Render popover clickoutside guard for content slot
|
|
3527
|
-
* @returns {void}
|
|
3528
3549
|
*/
|
|
3529
3550
|
updatePopoverGuard() {
|
|
3530
3551
|
if (this.displayPopover())
|
|
@@ -3537,7 +3558,6 @@ const MgMenuItem = class {
|
|
|
3537
3558
|
*************/
|
|
3538
3559
|
/**
|
|
3539
3560
|
* Validate props
|
|
3540
|
-
* @returns {void}
|
|
3541
3561
|
*/
|
|
3542
3562
|
componentWillLoad() {
|
|
3543
3563
|
// has children items that is NOT [slot='image' | 'information' | 'label' | 'metadata'] element
|
|
@@ -3553,7 +3573,7 @@ const MgMenuItem = class {
|
|
|
3553
3573
|
}
|
|
3554
3574
|
/**
|
|
3555
3575
|
* Check if component slots configuration
|
|
3556
|
-
* @returns
|
|
3576
|
+
* @returns timeout
|
|
3557
3577
|
*/
|
|
3558
3578
|
componentDidLoad() {
|
|
3559
3579
|
// validation
|
|
@@ -3592,7 +3612,7 @@ const MgMenuItem = class {
|
|
|
3592
3612
|
}
|
|
3593
3613
|
/**
|
|
3594
3614
|
* Render ineractive element
|
|
3595
|
-
* @returns
|
|
3615
|
+
* @returns HTML Element
|
|
3596
3616
|
*/
|
|
3597
3617
|
renderInteractiveElement() {
|
|
3598
3618
|
const TagName = this.href !== undefined ? 'a' : 'button';
|
|
@@ -3604,7 +3624,7 @@ const MgMenuItem = class {
|
|
|
3604
3624
|
}
|
|
3605
3625
|
/**
|
|
3606
3626
|
* Render
|
|
3607
|
-
* @returns
|
|
3627
|
+
* @returns HTML Element
|
|
3608
3628
|
*/
|
|
3609
3629
|
render() {
|
|
3610
3630
|
const getContainerClasses = () => ({
|
|
@@ -3632,7 +3652,7 @@ MgMenuItem.style = mgMenuItemCss;
|
|
|
3632
3652
|
*/
|
|
3633
3653
|
const variants$1 = ['info', 'warning', 'success', 'danger'];
|
|
3634
3654
|
|
|
3635
|
-
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%}";
|
|
3655
|
+
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%}";
|
|
3636
3656
|
|
|
3637
3657
|
const MgMessage = class {
|
|
3638
3658
|
constructor(hostRef) {
|
|
@@ -3653,22 +3673,19 @@ const MgMessage = class {
|
|
|
3653
3673
|
this.isHovered = false;
|
|
3654
3674
|
/**
|
|
3655
3675
|
* Set timer
|
|
3656
|
-
* @returns {void}
|
|
3657
3676
|
*/
|
|
3658
3677
|
this.setTimer = () => {
|
|
3659
3678
|
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
3660
3679
|
};
|
|
3661
3680
|
/**
|
|
3662
3681
|
* Clear timer
|
|
3663
|
-
* @returns {void}
|
|
3664
3682
|
*/
|
|
3665
3683
|
this.clearTimer = () => {
|
|
3666
3684
|
clearTimeout(this.storedTimer);
|
|
3667
3685
|
};
|
|
3668
3686
|
/**
|
|
3669
3687
|
* Event to add on element
|
|
3670
|
-
* @param
|
|
3671
|
-
* @returns {void}
|
|
3688
|
+
* @param event - event
|
|
3672
3689
|
*/
|
|
3673
3690
|
this.timerEvents = (event) => {
|
|
3674
3691
|
this.clearTimer();
|
|
@@ -3691,7 +3708,7 @@ const MgMessage = class {
|
|
|
3691
3708
|
};
|
|
3692
3709
|
/**
|
|
3693
3710
|
* Get icon corresponding to variant
|
|
3694
|
-
* @returns
|
|
3711
|
+
* @returns icon
|
|
3695
3712
|
*/
|
|
3696
3713
|
this.getIcon = () => {
|
|
3697
3714
|
switch (this.variant) {
|
|
@@ -3710,7 +3727,7 @@ const MgMessage = class {
|
|
|
3710
3727
|
this.variant = variants$1[0];
|
|
3711
3728
|
this.closeButton = false;
|
|
3712
3729
|
this.hide = false;
|
|
3713
|
-
this.
|
|
3730
|
+
this.classCollection = new ClassList(['mg-message']);
|
|
3714
3731
|
this.hasActions = false;
|
|
3715
3732
|
}
|
|
3716
3733
|
validateDelay(newValue) {
|
|
@@ -3724,9 +3741,9 @@ const MgMessage = class {
|
|
|
3724
3741
|
}
|
|
3725
3742
|
else {
|
|
3726
3743
|
if (oldValue !== undefined) {
|
|
3727
|
-
this.
|
|
3744
|
+
this.classCollection.delete(`mg-message--${oldValue}`);
|
|
3728
3745
|
}
|
|
3729
|
-
this.
|
|
3746
|
+
this.classCollection.add(`mg-message--${newValue}`);
|
|
3730
3747
|
}
|
|
3731
3748
|
}
|
|
3732
3749
|
validateCloseButton(newValue) {
|
|
@@ -3738,7 +3755,7 @@ const MgMessage = class {
|
|
|
3738
3755
|
validateHide(newValue) {
|
|
3739
3756
|
if (newValue) {
|
|
3740
3757
|
this.componentHide.emit();
|
|
3741
|
-
this.
|
|
3758
|
+
this.classCollection.add(this.classHide);
|
|
3742
3759
|
// Remove event Listener
|
|
3743
3760
|
['focusin', 'mouseenter'].forEach(event => {
|
|
3744
3761
|
this.element.removeEventListener(event, this.timerEvents);
|
|
@@ -3748,7 +3765,7 @@ const MgMessage = class {
|
|
|
3748
3765
|
}
|
|
3749
3766
|
else {
|
|
3750
3767
|
this.componentShow.emit();
|
|
3751
|
-
this.
|
|
3768
|
+
this.classCollection.delete(this.classHide);
|
|
3752
3769
|
// If delay is set
|
|
3753
3770
|
if (this.delay > 1) {
|
|
3754
3771
|
// Start timer
|
|
@@ -3775,7 +3792,7 @@ const MgMessage = class {
|
|
|
3775
3792
|
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
3776
3793
|
this.validateCloseButton(this.closeButton);
|
|
3777
3794
|
if (this.closeButton) {
|
|
3778
|
-
this.
|
|
3795
|
+
this.classCollection.add('mg-message--close-button');
|
|
3779
3796
|
this.closeButtonId = `${this.identifier}-close-button`;
|
|
3780
3797
|
}
|
|
3781
3798
|
this.validateDelay(this.delay);
|
|
@@ -3783,10 +3800,10 @@ const MgMessage = class {
|
|
|
3783
3800
|
}
|
|
3784
3801
|
/**
|
|
3785
3802
|
* Render
|
|
3786
|
-
* @returns
|
|
3803
|
+
* @returns HTML Element
|
|
3787
3804
|
*/
|
|
3788
3805
|
render() {
|
|
3789
|
-
return (index.h("div", { id: this.identifier, class: this.
|
|
3806
|
+
return (index.h("div", { id: this.identifier, class: this.classCollection.join(), role: this.variant === 'info' ? 'status' : 'alert' }, index.h("mg-card", { variant: this.variant, "variant-style": "bar-left" }, index.h("span", { class: "mg-message__icon" }, index.h("mg-icon", { icon: this.getIcon() })), index.h("div", { class: "mg-message__content" }, index.h("span", { class: "mg-message__content-slot" }, index.h("slot", null)), this.hasActions && index.h("span", { class: "mg-message__content-separator" }), this.hasActions && (index.h("span", { class: "mg-message__content-actions-slot" }, index.h("slot", { name: "actions" })))), this.closeButton && (index.h("span", { class: "mg-message__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" })))))));
|
|
3790
3807
|
}
|
|
3791
3808
|
get element() { return index.getElement(this); }
|
|
3792
3809
|
static get watchers() { return {
|
|
@@ -3798,7 +3815,7 @@ const MgMessage = class {
|
|
|
3798
3815
|
};
|
|
3799
3816
|
MgMessage.style = mgMessageCss;
|
|
3800
3817
|
|
|
3801
|
-
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}";
|
|
3818
|
+
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}";
|
|
3802
3819
|
|
|
3803
3820
|
const MgModal = class {
|
|
3804
3821
|
constructor(hostRef) {
|
|
@@ -3846,7 +3863,6 @@ const MgModal = class {
|
|
|
3846
3863
|
*************/
|
|
3847
3864
|
/**
|
|
3848
3865
|
* Handle close button
|
|
3849
|
-
* @returns {void}
|
|
3850
3866
|
*/
|
|
3851
3867
|
this.handleClose = () => {
|
|
3852
3868
|
this.hide = true;
|
|
@@ -3857,7 +3873,7 @@ const MgModal = class {
|
|
|
3857
3873
|
this.hide = false;
|
|
3858
3874
|
this.hasActions = false;
|
|
3859
3875
|
this.hasContent = false;
|
|
3860
|
-
this.
|
|
3876
|
+
this.classCollection = new ClassList(['mg-modal']);
|
|
3861
3877
|
}
|
|
3862
3878
|
validateModalTitle(newValue) {
|
|
3863
3879
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -3867,19 +3883,18 @@ const MgModal = class {
|
|
|
3867
3883
|
validateHide(newValue) {
|
|
3868
3884
|
if (newValue) {
|
|
3869
3885
|
this.componentHide.emit();
|
|
3870
|
-
this.
|
|
3886
|
+
this.classCollection.add(this.classHide);
|
|
3871
3887
|
document.body.style.overflow = this.bodyOverflow;
|
|
3872
3888
|
}
|
|
3873
3889
|
else {
|
|
3874
3890
|
this.componentShow.emit();
|
|
3875
|
-
this.
|
|
3891
|
+
this.classCollection.delete(this.classHide);
|
|
3876
3892
|
document.body.style.overflow = 'hidden';
|
|
3877
3893
|
}
|
|
3878
3894
|
}
|
|
3879
3895
|
/**
|
|
3880
3896
|
* Handle 'escape' key down
|
|
3881
|
-
* @param
|
|
3882
|
-
* @returns {void}
|
|
3897
|
+
* @param event - keydown event
|
|
3883
3898
|
*/
|
|
3884
3899
|
handleKeyDown(event) {
|
|
3885
3900
|
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
@@ -3892,7 +3907,6 @@ const MgModal = class {
|
|
|
3892
3907
|
*************/
|
|
3893
3908
|
/**
|
|
3894
3909
|
* Check if component props are well configured on init
|
|
3895
|
-
* @returns {void}
|
|
3896
3910
|
*/
|
|
3897
3911
|
componentWillLoad() {
|
|
3898
3912
|
// Store body overflow
|
|
@@ -3911,7 +3925,6 @@ const MgModal = class {
|
|
|
3911
3925
|
}
|
|
3912
3926
|
/**
|
|
3913
3927
|
* Add observer on component to set focus when displayed
|
|
3914
|
-
* @returns {void}
|
|
3915
3928
|
*/
|
|
3916
3929
|
componentDidLoad() {
|
|
3917
3930
|
new MutationObserver(mutationList => {
|
|
@@ -3926,10 +3939,10 @@ const MgModal = class {
|
|
|
3926
3939
|
}
|
|
3927
3940
|
/**
|
|
3928
3941
|
* Render
|
|
3929
|
-
* @returns
|
|
3942
|
+
* @returns HTML Element
|
|
3930
3943
|
*/
|
|
3931
3944
|
render() {
|
|
3932
|
-
return (index.h("div", { role: "alertdialog", id: this.identifier, class: this.
|
|
3945
|
+
return (index.h("div", { role: "alertdialog", id: this.identifier, class: this.classCollection.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, index.h("mg-card", null, index.h("div", { class: "mg-modal__dialog" }, index.h("header", { class: "mg-modal__header" }, this.closeButton && (index.h("span", { class: "mg-modal__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" })))), index.h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (index.h("article", { class: "mg-modal__content" }, index.h("slot", { name: "content" }))), this.hasActions && (index.h("footer", { class: "mg-modal__footer" }, index.h("slot", { name: "actions" })))))));
|
|
3933
3946
|
}
|
|
3934
3947
|
get element() { return index.getElement(this); }
|
|
3935
3948
|
static get watchers() { return {
|
|
@@ -3950,6 +3963,7 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
3950
3963
|
/**
|
|
3951
3964
|
* Range generator
|
|
3952
3965
|
*
|
|
3966
|
+
* ```
|
|
3953
3967
|
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
3954
3968
|
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
3955
3969
|
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
@@ -3957,14 +3971,15 @@ const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1
|
|
|
3957
3971
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
3958
3972
|
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
3959
3973
|
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
3974
|
+
* ```
|
|
3960
3975
|
*
|
|
3961
3976
|
* range(1, 1) = [1]
|
|
3962
3977
|
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
3963
3978
|
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
3964
|
-
* @param
|
|
3965
|
-
* @param
|
|
3966
|
-
* @param
|
|
3967
|
-
* @returns
|
|
3979
|
+
* @param start - start range
|
|
3980
|
+
* @param end - start end
|
|
3981
|
+
* @param step - step size
|
|
3982
|
+
* @returns range numbers
|
|
3968
3983
|
*/
|
|
3969
3984
|
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
3970
3985
|
const MgPagination = class {
|
|
@@ -3973,8 +3988,7 @@ const MgPagination = class {
|
|
|
3973
3988
|
this.currentPageChange = index.createEvent(this, "current-page-change", 7);
|
|
3974
3989
|
/**
|
|
3975
3990
|
* Change current page from target
|
|
3976
|
-
* @param
|
|
3977
|
-
* @returns {void}
|
|
3991
|
+
* @param target - target page
|
|
3978
3992
|
*/
|
|
3979
3993
|
this.goToPage = (target) => {
|
|
3980
3994
|
this.currentPage = target;
|
|
@@ -3984,8 +3998,7 @@ const MgPagination = class {
|
|
|
3984
3998
|
************/
|
|
3985
3999
|
/**
|
|
3986
4000
|
* select handler
|
|
3987
|
-
* @param
|
|
3988
|
-
* @returns {void}
|
|
4001
|
+
* @param event - value change event
|
|
3989
4002
|
*/
|
|
3990
4003
|
this.handleSelect = (event) => {
|
|
3991
4004
|
const to = Number(event.target.value);
|
|
@@ -3993,9 +4006,8 @@ const MgPagination = class {
|
|
|
3993
4006
|
};
|
|
3994
4007
|
/**
|
|
3995
4008
|
* Go to 'previous/next' page button handler
|
|
3996
|
-
* @param
|
|
3997
|
-
* @param
|
|
3998
|
-
* @returns {void}
|
|
4009
|
+
* @param action - navigation action
|
|
4010
|
+
* @param disabled - button disable state
|
|
3999
4011
|
*/
|
|
4000
4012
|
this.handleGoToPage = (action, disabled) => {
|
|
4001
4013
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
@@ -4025,7 +4037,6 @@ const MgPagination = class {
|
|
|
4025
4037
|
*************/
|
|
4026
4038
|
/**
|
|
4027
4039
|
* Check if props are well configured on init
|
|
4028
|
-
* @returns {void}
|
|
4029
4040
|
*/
|
|
4030
4041
|
componentWillLoad() {
|
|
4031
4042
|
// Get locales
|
|
@@ -4040,7 +4051,7 @@ const MgPagination = class {
|
|
|
4040
4051
|
}
|
|
4041
4052
|
/**
|
|
4042
4053
|
* Render
|
|
4043
|
-
* @returns
|
|
4054
|
+
* @returns HTML Element
|
|
4044
4055
|
*/
|
|
4045
4056
|
render() {
|
|
4046
4057
|
const navigationActionButton = (disabled, action) => (index.h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
|
|
@@ -4056,7 +4067,7 @@ const MgPagination = class {
|
|
|
4056
4067
|
};
|
|
4057
4068
|
MgPagination.style = mgPaginationCss;
|
|
4058
4069
|
|
|
4059
|
-
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}";
|
|
4070
|
+
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}";
|
|
4060
4071
|
|
|
4061
4072
|
const MgPanel = class {
|
|
4062
4073
|
constructor(hostRef) {
|
|
@@ -4068,7 +4079,6 @@ const MgPanel = class {
|
|
|
4068
4079
|
************/
|
|
4069
4080
|
/**
|
|
4070
4081
|
* Toggle is editing state
|
|
4071
|
-
* @returns {void}
|
|
4072
4082
|
*/
|
|
4073
4083
|
this.toggleIsEditing = () => {
|
|
4074
4084
|
this.isEditing = !this.isEditing;
|
|
@@ -4078,7 +4088,6 @@ const MgPanel = class {
|
|
|
4078
4088
|
************/
|
|
4079
4089
|
/**
|
|
4080
4090
|
* Collapse button click handler
|
|
4081
|
-
* @returns {void}
|
|
4082
4091
|
*/
|
|
4083
4092
|
this.handleCollapseButton = () => {
|
|
4084
4093
|
if (!this.expandToggleDisabled) {
|
|
@@ -4087,22 +4096,19 @@ const MgPanel = class {
|
|
|
4087
4096
|
};
|
|
4088
4097
|
/**
|
|
4089
4098
|
* Edit button click handler
|
|
4090
|
-
* @returns {void}
|
|
4091
4099
|
*/
|
|
4092
4100
|
this.handleEditButton = () => {
|
|
4093
4101
|
this.toggleIsEditing();
|
|
4094
4102
|
};
|
|
4095
4103
|
/**
|
|
4096
4104
|
* Update title handler
|
|
4097
|
-
* @param
|
|
4098
|
-
* @returns {void}
|
|
4105
|
+
* @param event - input value change event
|
|
4099
4106
|
*/
|
|
4100
4107
|
this.handleUpdateTitle = (event) => {
|
|
4101
4108
|
this.updatedPanelTitle = event.detail;
|
|
4102
4109
|
};
|
|
4103
4110
|
/**
|
|
4104
4111
|
* Cancel edition button handler
|
|
4105
|
-
* @returns {void}
|
|
4106
4112
|
*/
|
|
4107
4113
|
this.handleCancelEditButton = () => {
|
|
4108
4114
|
this.updatedPanelTitle = undefined;
|
|
@@ -4110,7 +4116,6 @@ const MgPanel = class {
|
|
|
4110
4116
|
};
|
|
4111
4117
|
/**
|
|
4112
4118
|
* Validate edition button handler
|
|
4113
|
-
* @returns {void}
|
|
4114
4119
|
*/
|
|
4115
4120
|
this.handleValidateEditButton = () => {
|
|
4116
4121
|
if (this.editInputElement.valid) {
|
|
@@ -4121,8 +4126,7 @@ const MgPanel = class {
|
|
|
4121
4126
|
};
|
|
4122
4127
|
/**
|
|
4123
4128
|
* Header left conditional render
|
|
4124
|
-
* @
|
|
4125
|
-
* @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
|
|
4129
|
+
* @returns header left element
|
|
4126
4130
|
*/
|
|
4127
4131
|
this.headerLeft = () => {
|
|
4128
4132
|
const collapseButton = () => (index.h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", identifier: `${this.identifier}-collapse-button`, "aria-expanded": this.expanded !== undefined && this.expanded.toString(), "aria-controls": `${this.identifier}-content`, disabled: this.expandToggleDisabled }, index.h("span", { class: "mg-panel__collapse-button-content" }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle)));
|
|
@@ -4147,7 +4151,7 @@ const MgPanel = class {
|
|
|
4147
4151
|
this.expanded = false;
|
|
4148
4152
|
this.expandToggleDisabled = undefined;
|
|
4149
4153
|
this.titleEditable = false;
|
|
4150
|
-
this.
|
|
4154
|
+
this.classCollection = new ClassList(['mg-panel']);
|
|
4151
4155
|
this.isEditing = false;
|
|
4152
4156
|
this.updatedPanelTitle = undefined;
|
|
4153
4157
|
}
|
|
@@ -4173,7 +4177,6 @@ const MgPanel = class {
|
|
|
4173
4177
|
*************/
|
|
4174
4178
|
/**
|
|
4175
4179
|
* Check if props are well configured on init
|
|
4176
|
-
* @returns {void}
|
|
4177
4180
|
*/
|
|
4178
4181
|
componentWillLoad() {
|
|
4179
4182
|
// Get locales
|
|
@@ -4184,7 +4187,6 @@ const MgPanel = class {
|
|
|
4184
4187
|
}
|
|
4185
4188
|
/**
|
|
4186
4189
|
* Edit DOM after render
|
|
4187
|
-
* @returns {void}
|
|
4188
4190
|
*/
|
|
4189
4191
|
componentDidRender() {
|
|
4190
4192
|
// when we are editing we get focus on edition input
|
|
@@ -4194,10 +4196,10 @@ const MgPanel = class {
|
|
|
4194
4196
|
}
|
|
4195
4197
|
/**
|
|
4196
4198
|
* Render component
|
|
4197
|
-
* @returns
|
|
4199
|
+
* @returns html element
|
|
4198
4200
|
*/
|
|
4199
4201
|
render() {
|
|
4200
|
-
return (index.h("section", { class: this.
|
|
4202
|
+
return (index.h("section", { class: this.classCollection.join(), id: this.identifier }, index.h("mg-card", null, index.h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, index.h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), index.h("div", { class: "mg-panel__header-right" }, index.h("slot", { name: "header-right" }))), index.h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, index.h("slot", null)))));
|
|
4201
4203
|
}
|
|
4202
4204
|
get element() { return index.getElement(this); }
|
|
4203
4205
|
static get watchers() { return {
|
|
@@ -6005,7 +6007,7 @@ var createPopper = /*#__PURE__*/popperGenerator({
|
|
|
6005
6007
|
defaultModifiers: defaultModifiers
|
|
6006
6008
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
6007
6009
|
|
|
6008
|
-
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}";
|
|
6010
|
+
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}";
|
|
6009
6011
|
|
|
6010
6012
|
const MgPopover = class {
|
|
6011
6013
|
constructor(hostRef) {
|
|
@@ -6016,8 +6018,7 @@ const MgPopover = class {
|
|
|
6016
6018
|
this.classArrowHide = `mg-popover--arrow-hide`;
|
|
6017
6019
|
/**
|
|
6018
6020
|
* Check if clicked outside of component
|
|
6019
|
-
* @param
|
|
6020
|
-
* @returns {void}
|
|
6021
|
+
* @param event - mouse event
|
|
6021
6022
|
*/
|
|
6022
6023
|
this.clickOutside = (event) => {
|
|
6023
6024
|
var _a;
|
|
@@ -6029,15 +6030,12 @@ const MgPopover = class {
|
|
|
6029
6030
|
};
|
|
6030
6031
|
/**
|
|
6031
6032
|
* Show popover
|
|
6032
|
-
* @returns {void}
|
|
6033
6033
|
*/
|
|
6034
6034
|
this.show = () => {
|
|
6035
6035
|
// Make the popover visible
|
|
6036
6036
|
this.popover.dataset.show = '';
|
|
6037
6037
|
// Enable the event listeners
|
|
6038
6038
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
6039
|
-
// Update its position
|
|
6040
|
-
this.popper.update();
|
|
6041
6039
|
// hide when click outside
|
|
6042
6040
|
// setTimeout is used to prevent event to trigger after creation
|
|
6043
6041
|
setTimeout(() => {
|
|
@@ -6048,7 +6046,6 @@ const MgPopover = class {
|
|
|
6048
6046
|
};
|
|
6049
6047
|
/**
|
|
6050
6048
|
* Hide popover
|
|
6051
|
-
* @returns {void}
|
|
6052
6049
|
*/
|
|
6053
6050
|
this.hide = () => {
|
|
6054
6051
|
// Hide the popover
|
|
@@ -6062,7 +6059,6 @@ const MgPopover = class {
|
|
|
6062
6059
|
};
|
|
6063
6060
|
/**
|
|
6064
6061
|
* Handle action for close button
|
|
6065
|
-
* @returns {void}
|
|
6066
6062
|
*/
|
|
6067
6063
|
this.handleCloseButton = () => {
|
|
6068
6064
|
this.display = false;
|
|
@@ -6073,13 +6069,13 @@ const MgPopover = class {
|
|
|
6073
6069
|
this.closeButton = false;
|
|
6074
6070
|
this.display = false;
|
|
6075
6071
|
this.disabled = false;
|
|
6076
|
-
this.
|
|
6072
|
+
this.classCollection = new ClassList(['mg-popover']);
|
|
6077
6073
|
}
|
|
6078
6074
|
validateArrowHide(newValue) {
|
|
6079
6075
|
if (newValue)
|
|
6080
|
-
this.
|
|
6076
|
+
this.classCollection.add(this.classArrowHide);
|
|
6081
6077
|
else
|
|
6082
|
-
this.
|
|
6078
|
+
this.classCollection.delete(this.classArrowHide);
|
|
6083
6079
|
}
|
|
6084
6080
|
handleDisplay(newValue) {
|
|
6085
6081
|
if (newValue) {
|
|
@@ -6093,9 +6089,14 @@ const MgPopover = class {
|
|
|
6093
6089
|
/*************
|
|
6094
6090
|
* Lifecycle *
|
|
6095
6091
|
*************/
|
|
6092
|
+
/**
|
|
6093
|
+
* update popper position after props change on component did update hook to benefit from render ended
|
|
6094
|
+
*/
|
|
6095
|
+
componentDidUpdate() {
|
|
6096
|
+
this.popper.update();
|
|
6097
|
+
}
|
|
6096
6098
|
/**
|
|
6097
6099
|
* Check if component props are well configured on init
|
|
6098
|
-
* @returns {void} timeout
|
|
6099
6100
|
*/
|
|
6100
6101
|
componentWillLoad() {
|
|
6101
6102
|
// Get windows to attach events
|
|
@@ -6106,7 +6107,6 @@ const MgPopover = class {
|
|
|
6106
6107
|
}
|
|
6107
6108
|
/**
|
|
6108
6109
|
* Check if component props are well configured on init
|
|
6109
|
-
* @returns {void}
|
|
6110
6110
|
*/
|
|
6111
6111
|
componentDidLoad() {
|
|
6112
6112
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
@@ -6156,17 +6156,19 @@ const MgPopover = class {
|
|
|
6156
6156
|
});
|
|
6157
6157
|
// Add events to hide popover
|
|
6158
6158
|
this.element.addEventListener('keydown', e => {
|
|
6159
|
-
if (!this.disabled && e.code === 'Escape')
|
|
6159
|
+
if (!this.disabled && e.code === 'Escape') {
|
|
6160
6160
|
this.display = false;
|
|
6161
|
+
interactiveElement.focus();
|
|
6162
|
+
}
|
|
6161
6163
|
});
|
|
6162
6164
|
this.handleDisplay(this.display);
|
|
6163
6165
|
}
|
|
6164
6166
|
/**
|
|
6165
6167
|
* Render
|
|
6166
|
-
* @returns
|
|
6168
|
+
* @returns HTML Element
|
|
6167
6169
|
*/
|
|
6168
6170
|
render() {
|
|
6169
|
-
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: this.
|
|
6171
|
+
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: this.classCollection.join() }, index.h("mg-card", null, this.closeButton && (index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, index.h("mg-icon", { icon: "cross" }))), index.h("div", { class: "mg-popover__title" }, index.h("slot", { name: "title" })), index.h("slot", { name: "content" })), !this.arrowHide && index.h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
6170
6172
|
}
|
|
6171
6173
|
get element() { return index.getElement(this); }
|
|
6172
6174
|
static get watchers() { return {
|
|
@@ -6187,8 +6189,7 @@ const MgSkipLinks = class {
|
|
|
6187
6189
|
**********/
|
|
6188
6190
|
/**
|
|
6189
6191
|
* Handle link click and emit go-to-anchor event
|
|
6190
|
-
* @param
|
|
6191
|
-
* @returns {void}
|
|
6192
|
+
* @param event - mouse event
|
|
6192
6193
|
*/
|
|
6193
6194
|
this.handleLinkCLick = (event) => {
|
|
6194
6195
|
event.currentTarget.blur();
|
|
@@ -6208,7 +6209,6 @@ const MgSkipLinks = class {
|
|
|
6208
6209
|
*************/
|
|
6209
6210
|
/**
|
|
6210
6211
|
* Check if props are well configured on init
|
|
6211
|
-
* @returns {void}
|
|
6212
6212
|
*/
|
|
6213
6213
|
componentWillLoad() {
|
|
6214
6214
|
this.validateLinks(this.links);
|
|
@@ -6216,7 +6216,7 @@ const MgSkipLinks = class {
|
|
|
6216
6216
|
}
|
|
6217
6217
|
/**
|
|
6218
6218
|
* Render
|
|
6219
|
-
* @returns
|
|
6219
|
+
* @returns HTML Element
|
|
6220
6220
|
*/
|
|
6221
6221
|
render() {
|
|
6222
6222
|
return (index.h("nav", { class: "mg-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, index.h("ul", { class: "mg-skip-links__list", role: "list" }, this.links.map(link => (index.h("li", { key: link.href }, index.h("a", { class: "mg-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
|
|
@@ -6247,8 +6247,8 @@ const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button,.m
|
|
|
6247
6247
|
|
|
6248
6248
|
/**
|
|
6249
6249
|
* type TabItem validation function
|
|
6250
|
-
* @param
|
|
6251
|
-
* @returns
|
|
6250
|
+
* @param tab - tab item
|
|
6251
|
+
* @returns tab item type is valid
|
|
6252
6252
|
*/
|
|
6253
6253
|
const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
|
|
6254
6254
|
const MgTabs = class {
|
|
@@ -6264,32 +6264,32 @@ const MgTabs = class {
|
|
|
6264
6264
|
this.startIndex = 1;
|
|
6265
6265
|
/**
|
|
6266
6266
|
* Method to know if given tab has the given status
|
|
6267
|
-
* @param
|
|
6268
|
-
* @param
|
|
6269
|
-
* @returns
|
|
6267
|
+
* @param tab - item tab key to set to ACTIVE status
|
|
6268
|
+
* @param status - status to valide
|
|
6269
|
+
* @returns status comparaison
|
|
6270
6270
|
*/
|
|
6271
6271
|
this.tabHasStatus = (tab, status) => tab.status === status;
|
|
6272
6272
|
/**
|
|
6273
6273
|
* Method to get element id from index
|
|
6274
|
-
* @param
|
|
6275
|
-
* @param
|
|
6276
|
-
* @returns
|
|
6274
|
+
* @param element - to get id
|
|
6275
|
+
* @param index - to generate id
|
|
6276
|
+
* @returns generated element id
|
|
6277
6277
|
*/
|
|
6278
6278
|
this.getElementId = (element, index) => `${element}-${this.getTabItemIndex(index)}`;
|
|
6279
6279
|
/**
|
|
6280
6280
|
* Method to get tab item index
|
|
6281
|
-
* @param
|
|
6282
|
-
* @returns
|
|
6281
|
+
* @param index - to get
|
|
6282
|
+
* @returns index
|
|
6283
6283
|
*/
|
|
6284
6284
|
this.getTabItemIndex = (index) => index + this.startIndex;
|
|
6285
6285
|
/**
|
|
6286
6286
|
* Method to get the active-tab value
|
|
6287
|
-
* @returns
|
|
6287
|
+
* @returns of the active-tab
|
|
6288
6288
|
*/
|
|
6289
6289
|
this.getActiveTab = () => this.activeTab || this.getTabItemIndex(this.tabs.map((tab, index) => (Object.assign(Object.assign({}, tab), { index }))).find(tab => this.tabHasStatus(tab, Status.ACTIVE)).index);
|
|
6290
6290
|
/**
|
|
6291
6291
|
* Handle click events on tabs
|
|
6292
|
-
* @param
|
|
6292
|
+
* @param event - mouse event
|
|
6293
6293
|
*/
|
|
6294
6294
|
this.handleClick = (event) => {
|
|
6295
6295
|
const tabId = event.currentTarget.dataset.index;
|
|
@@ -6304,14 +6304,13 @@ const MgTabs = class {
|
|
|
6304
6304
|
};
|
|
6305
6305
|
/**
|
|
6306
6306
|
* get navigation button class from given status
|
|
6307
|
-
* @param
|
|
6308
|
-
* @returns
|
|
6307
|
+
* @param status - button tab status
|
|
6308
|
+
* @returns button class/selector variant
|
|
6309
6309
|
*/
|
|
6310
6310
|
this.getNavigationButtonClass = (status) => `${this.buttonTabBaseClass}--${status}`;
|
|
6311
6311
|
/**
|
|
6312
6312
|
* Handle keyboard event on tabs
|
|
6313
|
-
* @param
|
|
6314
|
-
* @returns {void}
|
|
6313
|
+
* @param event - mouse event
|
|
6315
6314
|
*/
|
|
6316
6315
|
this.handleKeydown = (event) => {
|
|
6317
6316
|
const parent = event.target.parentElement;
|
|
@@ -6349,7 +6348,6 @@ const MgTabs = class {
|
|
|
6349
6348
|
};
|
|
6350
6349
|
/**
|
|
6351
6350
|
* Method to reset focus behavior
|
|
6352
|
-
* @returns {void}
|
|
6353
6351
|
*/
|
|
6354
6352
|
this.resetFocus = () => {
|
|
6355
6353
|
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
@@ -6374,7 +6372,7 @@ const MgTabs = class {
|
|
|
6374
6372
|
this.items = undefined;
|
|
6375
6373
|
this.activeTab = undefined;
|
|
6376
6374
|
this.tabs = [];
|
|
6377
|
-
this.
|
|
6375
|
+
this.classCollection = new ClassList(['mg-tabs']);
|
|
6378
6376
|
}
|
|
6379
6377
|
validateLabel(newValue) {
|
|
6380
6378
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
@@ -6385,7 +6383,7 @@ const MgTabs = class {
|
|
|
6385
6383
|
if (!sizes.includes(newValue)) {
|
|
6386
6384
|
throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
6387
6385
|
}
|
|
6388
|
-
this.
|
|
6386
|
+
this.classCollection.add(`mg-tabs--size-${this.size}`);
|
|
6389
6387
|
}
|
|
6390
6388
|
validateItems(newValue) {
|
|
6391
6389
|
// String array
|
|
@@ -6428,7 +6426,6 @@ const MgTabs = class {
|
|
|
6428
6426
|
*************/
|
|
6429
6427
|
/**
|
|
6430
6428
|
* Check if component props are well configured on init
|
|
6431
|
-
* @returns {void}
|
|
6432
6429
|
*/
|
|
6433
6430
|
componentWillLoad() {
|
|
6434
6431
|
// Check tabs format
|
|
@@ -6440,7 +6437,6 @@ const MgTabs = class {
|
|
|
6440
6437
|
}
|
|
6441
6438
|
/**
|
|
6442
6439
|
* add listners
|
|
6443
|
-
* @returns {void}
|
|
6444
6440
|
*/
|
|
6445
6441
|
componentDidLoad() {
|
|
6446
6442
|
document.addEventListener('click', (event) => {
|
|
@@ -6450,10 +6446,10 @@ const MgTabs = class {
|
|
|
6450
6446
|
}
|
|
6451
6447
|
/**
|
|
6452
6448
|
* Render
|
|
6453
|
-
* @returns
|
|
6449
|
+
* @returns HTML Element
|
|
6454
6450
|
*/
|
|
6455
6451
|
render() {
|
|
6456
|
-
return (index.h("div", { class: this.
|
|
6452
|
+
return (index.h("div", { class: this.classCollection.join() }, index.h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index$1) => (index.h("button", { key: tab.label, role: "tab", id: this.getElementId(this.identifier, index$1), class: {
|
|
6457
6453
|
[`${this.buttonTabBaseClass}`]: true,
|
|
6458
6454
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
6459
6455
|
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|
|
@@ -6490,7 +6486,7 @@ const MgTag = class {
|
|
|
6490
6486
|
this.variant = variants[0];
|
|
6491
6487
|
this.outline = undefined;
|
|
6492
6488
|
this.soft = undefined;
|
|
6493
|
-
this.
|
|
6489
|
+
this.classCollection = new ClassList(['mg-tag']);
|
|
6494
6490
|
}
|
|
6495
6491
|
validateVariant(newValue, oldValue) {
|
|
6496
6492
|
if (!variants.includes(newValue)) {
|
|
@@ -6498,16 +6494,16 @@ const MgTag = class {
|
|
|
6498
6494
|
}
|
|
6499
6495
|
else {
|
|
6500
6496
|
if (oldValue !== undefined) {
|
|
6501
|
-
this.
|
|
6497
|
+
this.classCollection.delete(`mg-tag--${oldValue}`);
|
|
6502
6498
|
}
|
|
6503
|
-
this.
|
|
6499
|
+
this.classCollection.add(`mg-tag--${newValue}`);
|
|
6504
6500
|
}
|
|
6505
6501
|
}
|
|
6506
6502
|
validateOutline(newValue) {
|
|
6507
6503
|
if (newValue)
|
|
6508
|
-
this.
|
|
6504
|
+
this.classCollection.add(this.classOutline);
|
|
6509
6505
|
else
|
|
6510
|
-
this.
|
|
6506
|
+
this.classCollection.delete(this.classOutline);
|
|
6511
6507
|
}
|
|
6512
6508
|
validateSoft(newValue) {
|
|
6513
6509
|
// usage validation
|
|
@@ -6515,17 +6511,16 @@ const MgTag = class {
|
|
|
6515
6511
|
throw new Error('<mg-tag> prop "soft" can NOT be used with prop "outline".');
|
|
6516
6512
|
// apply class
|
|
6517
6513
|
if (newValue)
|
|
6518
|
-
this.
|
|
6514
|
+
this.classCollection.add(this.classSoft);
|
|
6519
6515
|
else
|
|
6520
|
-
this.
|
|
6516
|
+
this.classCollection.delete(this.classSoft);
|
|
6521
6517
|
}
|
|
6522
6518
|
/*************
|
|
6523
6519
|
* Methods *
|
|
6524
6520
|
*************/
|
|
6525
6521
|
/**
|
|
6526
6522
|
* Validate the given textContent
|
|
6527
|
-
* @param
|
|
6528
|
-
* @returns {void}
|
|
6523
|
+
* @param textContent - html element textContent property
|
|
6529
6524
|
*/
|
|
6530
6525
|
validateTextContent(textContent) {
|
|
6531
6526
|
if (typeof textContent !== 'string' || textContent.trim() === '')
|
|
@@ -6536,7 +6531,6 @@ const MgTag = class {
|
|
|
6536
6531
|
*************/
|
|
6537
6532
|
/**
|
|
6538
6533
|
* Check if props are well configured on init
|
|
6539
|
-
* @returns {void}
|
|
6540
6534
|
*/
|
|
6541
6535
|
componentWillLoad() {
|
|
6542
6536
|
this.validateVariant(this.variant);
|
|
@@ -6546,10 +6540,10 @@ const MgTag = class {
|
|
|
6546
6540
|
}
|
|
6547
6541
|
/**
|
|
6548
6542
|
* Render
|
|
6549
|
-
* @returns
|
|
6543
|
+
* @returns HTML Element
|
|
6550
6544
|
*/
|
|
6551
6545
|
render() {
|
|
6552
|
-
return (index.h("span", { class: this.
|
|
6546
|
+
return (index.h("span", { class: this.classCollection.join() }, index.h("slot", null)));
|
|
6553
6547
|
}
|
|
6554
6548
|
get element() { return index.getElement(this); }
|
|
6555
6549
|
static get watchers() { return {
|
|
@@ -6574,15 +6568,12 @@ const MgTooltip = class {
|
|
|
6574
6568
|
index.registerInstance(this, hostRef);
|
|
6575
6569
|
/**
|
|
6576
6570
|
* Show tooltip
|
|
6577
|
-
* @returns {void}
|
|
6578
6571
|
*/
|
|
6579
6572
|
this.show = () => {
|
|
6580
6573
|
// Make the tooltip visible
|
|
6581
6574
|
this.tooltip.dataset.show = '';
|
|
6582
6575
|
// Enable the event listeners
|
|
6583
6576
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
6584
|
-
// Update its position
|
|
6585
|
-
this.popper.update();
|
|
6586
6577
|
// hide when click outside
|
|
6587
6578
|
// setTimeout is used to prevent event to trigger after creation
|
|
6588
6579
|
setTimeout(() => {
|
|
@@ -6594,7 +6585,6 @@ const MgTooltip = class {
|
|
|
6594
6585
|
};
|
|
6595
6586
|
/**
|
|
6596
6587
|
* Hide tooltip
|
|
6597
|
-
* @returns {void}
|
|
6598
6588
|
*/
|
|
6599
6589
|
this.hide = () => {
|
|
6600
6590
|
// Hide the tooltip
|
|
@@ -6609,8 +6599,7 @@ const MgTooltip = class {
|
|
|
6609
6599
|
};
|
|
6610
6600
|
/**
|
|
6611
6601
|
* Check if clicked outside of component and hidde tooltip
|
|
6612
|
-
* @param
|
|
6613
|
-
* @returns {void}
|
|
6602
|
+
* @param event - mouse event
|
|
6614
6603
|
*/
|
|
6615
6604
|
this.clickOutside = (event) => {
|
|
6616
6605
|
if (event.target.closest('mg-tooltip') !== this.element)
|
|
@@ -6618,18 +6607,18 @@ const MgTooltip = class {
|
|
|
6618
6607
|
};
|
|
6619
6608
|
/**
|
|
6620
6609
|
* Check if 'Escape' key is pressed of component and hidde tooltip
|
|
6621
|
-
* @param
|
|
6622
|
-
* @returns {void}
|
|
6610
|
+
* @param event - keyboard event
|
|
6623
6611
|
*/
|
|
6624
6612
|
this.pressEscape = (event) => {
|
|
6625
|
-
if (event.code === 'Escape')
|
|
6613
|
+
if (event.code === 'Escape') {
|
|
6626
6614
|
this.setDisplay(false);
|
|
6615
|
+
this.resetGuard();
|
|
6616
|
+
}
|
|
6627
6617
|
};
|
|
6628
6618
|
/**
|
|
6629
6619
|
* Method to set display prop
|
|
6630
|
-
* @param
|
|
6631
|
-
* @param
|
|
6632
|
-
* @returns {void}
|
|
6620
|
+
* @param newValue - display prop new value
|
|
6621
|
+
* @param condition - additionnal condition to apply display prop newValue
|
|
6633
6622
|
*/
|
|
6634
6623
|
this.setDisplay = (newValue, condition = true) => {
|
|
6635
6624
|
if (!this.disabled && condition)
|
|
@@ -6637,10 +6626,9 @@ const MgTooltip = class {
|
|
|
6637
6626
|
};
|
|
6638
6627
|
/**
|
|
6639
6628
|
* Action for tooltip element and tooltiped element mouse listener
|
|
6640
|
-
* @param
|
|
6641
|
-
* @param
|
|
6642
|
-
* @param
|
|
6643
|
-
* @returns {void}
|
|
6629
|
+
* @param elementGuard - tooltip element guard
|
|
6630
|
+
* @param isMouseenter - mouseenter validation
|
|
6631
|
+
* @param conditionalGuard - guard condition
|
|
6644
6632
|
*/
|
|
6645
6633
|
this.tooltipMouseListenerAction = (elementGuard, isMouseenter, conditionalGuard) => {
|
|
6646
6634
|
// we mutate elementGuard
|
|
@@ -6659,15 +6647,13 @@ const MgTooltip = class {
|
|
|
6659
6647
|
};
|
|
6660
6648
|
/**
|
|
6661
6649
|
* Method to reset guard value
|
|
6662
|
-
* @returns {void}
|
|
6663
6650
|
*/
|
|
6664
6651
|
this.resetGuard = () => {
|
|
6665
6652
|
this.guard = undefined;
|
|
6666
6653
|
};
|
|
6667
6654
|
/**
|
|
6668
6655
|
* Update slot content when it is a mg-button
|
|
6669
|
-
* @param
|
|
6670
|
-
* @returns {void}
|
|
6656
|
+
* @param mgButton - slotted mg-button
|
|
6671
6657
|
*/
|
|
6672
6658
|
this.setMgButtonWrapper = (mgButton) => {
|
|
6673
6659
|
if (mgButton.disabled) {
|
|
@@ -6684,8 +6670,8 @@ const MgTooltip = class {
|
|
|
6684
6670
|
};
|
|
6685
6671
|
/**
|
|
6686
6672
|
* Init tooltip
|
|
6687
|
-
* @param
|
|
6688
|
-
* @param
|
|
6673
|
+
* @param slotElement - slotted element
|
|
6674
|
+
* @param interactiveElement - interactive element
|
|
6689
6675
|
*/
|
|
6690
6676
|
this.initTooltip = (slotElement, interactiveElement) => {
|
|
6691
6677
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
@@ -6746,7 +6732,6 @@ const MgTooltip = class {
|
|
|
6746
6732
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
6747
6733
|
throw new Error('<mg-tooltip> prop "message" is required.');
|
|
6748
6734
|
}
|
|
6749
|
-
this.popper.update();
|
|
6750
6735
|
}
|
|
6751
6736
|
handleDisplay(newValue) {
|
|
6752
6737
|
if (newValue) {
|
|
@@ -6761,7 +6746,6 @@ const MgTooltip = class {
|
|
|
6761
6746
|
*************/
|
|
6762
6747
|
/**
|
|
6763
6748
|
* set variables
|
|
6764
|
-
* @returns {void}
|
|
6765
6749
|
*/
|
|
6766
6750
|
componentWillLoad() {
|
|
6767
6751
|
// Get windows to attach events
|
|
@@ -6771,7 +6755,6 @@ const MgTooltip = class {
|
|
|
6771
6755
|
* Get slotted element
|
|
6772
6756
|
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
6773
6757
|
* We need to attach the focused element to the tooltip (aria-describedby)
|
|
6774
|
-
* @returns {void}
|
|
6775
6758
|
*/
|
|
6776
6759
|
componentDidLoad() {
|
|
6777
6760
|
var _a;
|
|
@@ -6802,9 +6785,15 @@ const MgTooltip = class {
|
|
|
6802
6785
|
this.handleDisplay(this.display);
|
|
6803
6786
|
this.validateMessage(this.message);
|
|
6804
6787
|
}
|
|
6788
|
+
/**
|
|
6789
|
+
* update popper position after props change on component did update hook to benefit from render ended
|
|
6790
|
+
*/
|
|
6791
|
+
componentDidUpdate() {
|
|
6792
|
+
this.popper.update();
|
|
6793
|
+
}
|
|
6805
6794
|
/**
|
|
6806
6795
|
* Render
|
|
6807
|
-
* @returns
|
|
6796
|
+
* @returns HTML Element
|
|
6808
6797
|
*/
|
|
6809
6798
|
render() {
|
|
6810
6799
|
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip" }, index.h("span", { innerHTML: this.message }), index.h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|