@mgdis/mg-components 5.8.1 → 5.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_31.cjs.entry.js +197 -64
- package/dist/cjs/mg-components.cjs.js +2 -2
- package/dist/cjs/mg-item-more.cjs.entry.js +3 -2
- package/dist/collection/components/atoms/mg-card/mg-card.conf.js +8 -0
- package/dist/collection/components/atoms/mg-card/mg-card.css +54 -0
- package/dist/collection/components/atoms/mg-card/mg-card.js +106 -4
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +38 -7
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +70 -11
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +57 -21
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +12 -12
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +44 -5
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +12 -9
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +1 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.css +1 -0
- package/dist/collection/components/molecules/mg-details/mg-details.css +0 -3
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +2 -1
- package/dist/collection/components/molecules/mg-message/mg-message.css +1 -19
- package/dist/collection/components/molecules/mg-message/mg-message.js +9 -4
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +1 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -0
- package/dist/collection/styles/reset-mg-card-slotted-variables.scss +1 -0
- package/dist/collection/variables.css +7 -1
- package/dist/components/mg-action-more.js +1 -1
- package/dist/components/mg-card2.js +60 -6
- package/dist/components/mg-details.js +2 -2
- package/dist/components/mg-icon2.js +66 -22
- package/dist/components/mg-input-numeric.js +12 -9
- package/dist/components/mg-item-more.js +2 -1
- package/dist/components/mg-menu-item2.js +2 -2
- package/dist/components/mg-message.js +2 -2
- package/dist/components/mg-modal.js +1 -1
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-popover2.js +1 -1
- package/dist/components/mg-tag.js +1 -1
- package/dist/components/mg-tooltip2.js +44 -5
- package/dist/components/popper.js +3 -4
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_31.entry.js +197 -64
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-item-more.entry.js +3 -2
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-1221773c.entry.js → p-67ce7cb8.entry.js} +1 -1
- package/dist/mg-components/p-9a93b7af.entry.js +1 -0
- package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +1 -0
- package/dist/mg-components/variables.css +7 -1
- package/dist/types/components/atoms/mg-card/mg-card.conf.d.ts +16 -0
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +29 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +10 -2
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +13 -5
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +21 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +5 -5
- package/dist/types/components/molecules/mg-message/mg-message.conf.d.ts +5 -1
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +6 -5
- package/dist/types/components.d.ts +35 -9
- package/package.json +11 -16
- package/dist/mg-components/p-30bc87db.entry.js +0 -1
- /package/dist/cjs/{index-5e7ede97.js → index-9e1091ab.js} +0 -0
- /package/dist/esm/{index-03cceb11.js → index-3249671d.js} +0 -0
- /package/dist/mg-components/{p-e126dd84.js → p-8fbc0d87.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
-
import { icons, sizes, variants } from './mg-icon.conf';
|
|
2
|
+
import { icons, sizes, variants, variantStyles } from './mg-icon.conf';
|
|
3
3
|
import { ClassList } from '../../../utils/components.utils';
|
|
4
4
|
export class MgIcon {
|
|
5
5
|
constructor() {
|
|
@@ -12,40 +12,50 @@ export class MgIcon {
|
|
|
12
12
|
this.icon = undefined;
|
|
13
13
|
this.size = 'regular';
|
|
14
14
|
this.variant = undefined;
|
|
15
|
+
this.variantStyle = undefined;
|
|
15
16
|
this.spin = false;
|
|
16
17
|
this.classList = new ClassList(['mg-icon']);
|
|
17
18
|
}
|
|
18
19
|
validateIcon(newValue, oldValue) {
|
|
19
|
-
if (!Object.keys(icons).includes(newValue))
|
|
20
|
+
if (!Object.keys(icons).includes(newValue))
|
|
20
21
|
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
|
|
21
|
-
}
|
|
22
22
|
else {
|
|
23
|
-
if (oldValue !== undefined)
|
|
23
|
+
if (oldValue !== undefined)
|
|
24
24
|
this.classList.delete(`mg-icon--${oldValue}`);
|
|
25
|
-
}
|
|
26
25
|
this.classList.add(`mg-icon--${newValue}`);
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
validateSize(newValue, oldValue) {
|
|
30
|
-
if (!sizes.includes(newValue))
|
|
29
|
+
if (!sizes.includes(newValue))
|
|
31
30
|
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
32
|
-
}
|
|
33
31
|
else {
|
|
34
|
-
if (oldValue !== undefined)
|
|
32
|
+
if (oldValue !== undefined)
|
|
35
33
|
this.classList.delete(`mg-icon--size-${oldValue}`);
|
|
36
|
-
}
|
|
37
34
|
this.classList.add(`mg-icon--size-${newValue}`);
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
validateVariant(newValue, oldValue) {
|
|
41
|
-
if (
|
|
42
|
-
|
|
38
|
+
if (Boolean(newValue)) {
|
|
39
|
+
if (!variants.includes(newValue))
|
|
40
|
+
throw new Error(`<mg-icon> prop "variant" must be one of: ${variants.join(', ')}`);
|
|
41
|
+
else {
|
|
42
|
+
if (this.variantStyle === undefined)
|
|
43
|
+
this.variantStyle = 'background';
|
|
44
|
+
if (oldValue !== undefined)
|
|
45
|
+
this.classList.delete(`mg-icon--variant-${oldValue}`);
|
|
46
|
+
this.classList.add(`mg-icon--variant-${newValue}`);
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
}
|
|
50
|
+
validateVariantStyle(newValue, oldValue) {
|
|
51
|
+
if (Boolean(newValue)) {
|
|
52
|
+
if (!variantStyles.includes(newValue))
|
|
53
|
+
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
|
|
54
|
+
else {
|
|
55
|
+
if (oldValue !== undefined)
|
|
56
|
+
this.classList.delete(`mg-icon--variant-style-${oldValue}`);
|
|
57
|
+
this.classList.add(`mg-icon--variant-style-${newValue}`);
|
|
47
58
|
}
|
|
48
|
-
this.classList.add(`mg-icon--variant-${newValue}`);
|
|
49
59
|
}
|
|
50
60
|
}
|
|
51
61
|
handleSpin(newValue) {
|
|
@@ -67,6 +77,7 @@ export class MgIcon {
|
|
|
67
77
|
this.validateIcon(this.icon);
|
|
68
78
|
this.validateSize(this.size);
|
|
69
79
|
this.validateVariant(this.variant);
|
|
80
|
+
this.validateVariantStyle(this.variantStyle);
|
|
70
81
|
this.handleSpin(this.spin);
|
|
71
82
|
}
|
|
72
83
|
/**
|
|
@@ -99,11 +110,11 @@ export class MgIcon {
|
|
|
99
110
|
"resolved": "string",
|
|
100
111
|
"references": {}
|
|
101
112
|
},
|
|
102
|
-
"required":
|
|
113
|
+
"required": true,
|
|
103
114
|
"optional": false,
|
|
104
115
|
"docs": {
|
|
105
116
|
"tags": [],
|
|
106
|
-
"text": "Icon to display"
|
|
117
|
+
"text": "Icon to display."
|
|
107
118
|
},
|
|
108
119
|
"attribute": "icon",
|
|
109
120
|
"reflect": false
|
|
@@ -113,7 +124,7 @@ export class MgIcon {
|
|
|
113
124
|
"mutable": false,
|
|
114
125
|
"complexType": {
|
|
115
126
|
"original": "IconSizeType",
|
|
116
|
-
"resolved": "\"extra-large\" | \"large\" | \"regular\" | \"small\"",
|
|
127
|
+
"resolved": "\"extra-large\" | \"large\" | \"medium\" | \"regular\" | \"small\"",
|
|
117
128
|
"references": {
|
|
118
129
|
"IconSizeType": {
|
|
119
130
|
"location": "import",
|
|
@@ -136,7 +147,7 @@ export class MgIcon {
|
|
|
136
147
|
"mutable": false,
|
|
137
148
|
"complexType": {
|
|
138
149
|
"original": "IconVariantType",
|
|
139
|
-
"resolved": "\"danger\" | \"info\" | \"success\" | \"warning\"",
|
|
150
|
+
"resolved": "\"app\" | \"danger\" | \"info\" | \"success\" | \"warning\"",
|
|
140
151
|
"references": {
|
|
141
152
|
"IconVariantType": {
|
|
142
153
|
"location": "import",
|
|
@@ -145,14 +156,36 @@ export class MgIcon {
|
|
|
145
156
|
}
|
|
146
157
|
},
|
|
147
158
|
"required": false,
|
|
148
|
-
"optional":
|
|
159
|
+
"optional": false,
|
|
149
160
|
"docs": {
|
|
150
161
|
"tags": [],
|
|
151
|
-
"text": "Define icon variant
|
|
162
|
+
"text": "Define icon variant color"
|
|
152
163
|
},
|
|
153
164
|
"attribute": "variant",
|
|
154
165
|
"reflect": false
|
|
155
166
|
},
|
|
167
|
+
"variantStyle": {
|
|
168
|
+
"type": "string",
|
|
169
|
+
"mutable": true,
|
|
170
|
+
"complexType": {
|
|
171
|
+
"original": "IconVariantStyleType",
|
|
172
|
+
"resolved": "\"background\" | \"full\" | \"icon\"",
|
|
173
|
+
"references": {
|
|
174
|
+
"IconVariantStyleType": {
|
|
175
|
+
"location": "import",
|
|
176
|
+
"path": "./mg-icon.conf"
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"required": false,
|
|
181
|
+
"optional": false,
|
|
182
|
+
"docs": {
|
|
183
|
+
"tags": [],
|
|
184
|
+
"text": "Define icon color variant style\nAdd a color to the icon based on variant color with given style\n'full': Used to set a circular background with variant soft color and icon variant color\n'background': Used to set a circular background with variant soft color\n'icon': Used to set a color only to the icon"
|
|
185
|
+
},
|
|
186
|
+
"attribute": "variant-style",
|
|
187
|
+
"reflect": false
|
|
188
|
+
},
|
|
156
189
|
"spin": {
|
|
157
190
|
"type": "boolean",
|
|
158
191
|
"mutable": false,
|
|
@@ -188,6 +221,9 @@ export class MgIcon {
|
|
|
188
221
|
}, {
|
|
189
222
|
"propName": "variant",
|
|
190
223
|
"methodName": "validateVariant"
|
|
224
|
+
}, {
|
|
225
|
+
"propName": "variantStyle",
|
|
226
|
+
"methodName": "validateVariantStyle"
|
|
191
227
|
}, {
|
|
192
228
|
"propName": "spin",
|
|
193
229
|
"methodName": "handleSpin"
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
}
|
|
23
23
|
.mg-tag.mg-tag--primary.mg-tag--soft {
|
|
24
24
|
font-weight: 400;
|
|
25
|
-
background-color: hsl(var(--color-dark-h), var(--color-dark-s),
|
|
26
|
-
border-color: hsl(var(--color-dark-h), var(--color-dark-s),
|
|
25
|
+
background-color: hsl(var(--color-dark-h), var(--color-dark-s), var(--mg-color-soft-l));
|
|
26
|
+
border-color: hsl(var(--color-dark-h), var(--color-dark-s), var(--mg-color-soft-l));
|
|
27
27
|
color: hsl(var(--color-dark));
|
|
28
28
|
}
|
|
29
29
|
.mg-tag.mg-tag--primary.mg-tag--soft ::slotted(mg-icon) {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
}
|
|
41
41
|
.mg-tag.mg-tag--secondary.mg-tag--soft {
|
|
42
42
|
font-weight: 400;
|
|
43
|
-
background-color: hsl(var(--color-light-h), var(--color-light-s),
|
|
44
|
-
border-color: hsl(var(--color-light-h), var(--color-light-s),
|
|
43
|
+
background-color: hsl(var(--color-light-h), var(--color-light-s), var(--mg-color-soft-l));
|
|
44
|
+
border-color: hsl(var(--color-light-h), var(--color-light-s), var(--mg-color-soft-l));
|
|
45
45
|
color: hsl(var(--color-dark));
|
|
46
46
|
}
|
|
47
47
|
.mg-tag.mg-tag--secondary.mg-tag--soft ::slotted(mg-icon) {
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
}
|
|
59
59
|
.mg-tag.mg-tag--success.mg-tag--soft {
|
|
60
60
|
font-weight: 400;
|
|
61
|
-
background-color: hsl(var(--color-success-h), var(--color-success-s),
|
|
62
|
-
border-color: hsl(var(--color-success-h), var(--color-success-s),
|
|
61
|
+
background-color: hsl(var(--color-success-h), var(--color-success-s), var(--mg-color-soft-l));
|
|
62
|
+
border-color: hsl(var(--color-success-h), var(--color-success-s), var(--mg-color-soft-l));
|
|
63
63
|
color: hsl(var(--color-dark));
|
|
64
64
|
}
|
|
65
65
|
.mg-tag.mg-tag--success.mg-tag--soft ::slotted(mg-icon) {
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
}
|
|
77
77
|
.mg-tag.mg-tag--warning.mg-tag--soft {
|
|
78
78
|
font-weight: 400;
|
|
79
|
-
background-color: hsl(var(--color-warning-h), var(--color-warning-s),
|
|
80
|
-
border-color: hsl(var(--color-warning-h), var(--color-warning-s),
|
|
79
|
+
background-color: hsl(var(--color-warning-h), var(--color-warning-s), var(--mg-color-soft-l));
|
|
80
|
+
border-color: hsl(var(--color-warning-h), var(--color-warning-s), var(--mg-color-soft-l));
|
|
81
81
|
color: hsl(var(--color-dark));
|
|
82
82
|
}
|
|
83
83
|
.mg-tag.mg-tag--warning.mg-tag--soft ::slotted(mg-icon) {
|
|
@@ -94,8 +94,8 @@
|
|
|
94
94
|
}
|
|
95
95
|
.mg-tag.mg-tag--danger.mg-tag--soft {
|
|
96
96
|
font-weight: 400;
|
|
97
|
-
background-color: hsl(var(--color-danger-h), var(--color-danger-s),
|
|
98
|
-
border-color: hsl(var(--color-danger-h), var(--color-danger-s),
|
|
97
|
+
background-color: hsl(var(--color-danger-h), var(--color-danger-s), var(--mg-color-soft-l));
|
|
98
|
+
border-color: hsl(var(--color-danger-h), var(--color-danger-s), var(--mg-color-soft-l));
|
|
99
99
|
color: hsl(var(--color-dark));
|
|
100
100
|
}
|
|
101
101
|
.mg-tag.mg-tag--danger.mg-tag--soft ::slotted(mg-icon) {
|
|
@@ -112,8 +112,8 @@
|
|
|
112
112
|
}
|
|
113
113
|
.mg-tag.mg-tag--info.mg-tag--soft {
|
|
114
114
|
font-weight: 400;
|
|
115
|
-
background-color: hsl(var(--color-info-h), var(--color-info-s),
|
|
116
|
-
border-color: hsl(var(--color-info-h), var(--color-info-s),
|
|
115
|
+
background-color: hsl(var(--color-info-h), var(--color-info-s), var(--mg-color-soft-l));
|
|
116
|
+
border-color: hsl(var(--color-info-h), var(--color-info-s), var(--mg-color-soft-l));
|
|
117
117
|
color: hsl(var(--color-dark));
|
|
118
118
|
}
|
|
119
119
|
.mg-tag.mg-tag--info.mg-tag--soft ::slotted(mg-icon) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h, Host } from '@stencil/core';
|
|
2
|
-
import { createID, focusableElements } from '../../../utils/components.utils';
|
|
2
|
+
import { createID, focusableElements, getWindows } from '../../../utils/components.utils';
|
|
3
3
|
import { createPopper } from '@popperjs/core';
|
|
4
4
|
import { Guard } from './mg-tooltip.conf';
|
|
5
5
|
export class MgTooltip {
|
|
@@ -16,6 +16,14 @@ export class MgTooltip {
|
|
|
16
16
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
17
17
|
// Update its position
|
|
18
18
|
this.popper.update();
|
|
19
|
+
// hide when click outside
|
|
20
|
+
// setTimeout is used to prevent event to trigger after creation
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
this.windows.forEach((localWindow) => {
|
|
23
|
+
localWindow.addEventListener('click', this.clickOutside, false);
|
|
24
|
+
localWindow.addEventListener('keydown', this.pressEscape, false);
|
|
25
|
+
});
|
|
26
|
+
}, 0);
|
|
19
27
|
};
|
|
20
28
|
/**
|
|
21
29
|
* Hide tooltip
|
|
@@ -27,6 +35,31 @@ export class MgTooltip {
|
|
|
27
35
|
this.tooltip.removeAttribute('data-show');
|
|
28
36
|
// Disable the event listeners
|
|
29
37
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
|
|
38
|
+
// Remove event listener
|
|
39
|
+
this.windows.forEach((localWindow) => {
|
|
40
|
+
localWindow.removeEventListener('click', this.clickOutside, false);
|
|
41
|
+
localWindow.removeEventListener('keyboard', this.pressEscape, false);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Check if clicked outside of component and hidde tooltip
|
|
46
|
+
*
|
|
47
|
+
* @param {MouseEvent} event mouse event
|
|
48
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
this.clickOutside = (event) => {
|
|
51
|
+
if (event.target.closest('mg-tooltip') !== this.element)
|
|
52
|
+
this.setDisplay(false);
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Check if 'Escape' key is pressed of component and hidde tooltip
|
|
56
|
+
*
|
|
57
|
+
* @param {KeyboardEvent} event keyboard event
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
this.pressEscape = (event) => {
|
|
61
|
+
if (event.code === 'Escape')
|
|
62
|
+
this.setDisplay(false);
|
|
30
63
|
};
|
|
31
64
|
/**
|
|
32
65
|
* Method to set display prop
|
|
@@ -130,10 +163,7 @@ export class MgTooltip {
|
|
|
130
163
|
this.resetGuard();
|
|
131
164
|
this.setDisplay(false);
|
|
132
165
|
});
|
|
133
|
-
document.addEventListener('keydown',
|
|
134
|
-
if (event.code === 'Escape')
|
|
135
|
-
this.setDisplay(false);
|
|
136
|
-
});
|
|
166
|
+
document.addEventListener('keydown', this.pressEscape);
|
|
137
167
|
// manage tooltipElement & tooltipedElement mouseenter/mouseleave events
|
|
138
168
|
['mouseenter', 'mouseleave'].forEach(eventType => {
|
|
139
169
|
const isMouseenter = eventType === 'mouseenter';
|
|
@@ -170,6 +200,15 @@ export class MgTooltip {
|
|
|
170
200
|
/*************
|
|
171
201
|
* Lifecycle *
|
|
172
202
|
*************/
|
|
203
|
+
/**
|
|
204
|
+
* set variables
|
|
205
|
+
*
|
|
206
|
+
* @returns {void}
|
|
207
|
+
*/
|
|
208
|
+
componentWillLoad() {
|
|
209
|
+
// Get windows to attach events
|
|
210
|
+
this.windows = getWindows(window);
|
|
211
|
+
}
|
|
173
212
|
/**
|
|
174
213
|
* Get slotted element
|
|
175
214
|
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
@@ -75,22 +75,23 @@ export class MgInputNumeric {
|
|
|
75
75
|
*/
|
|
76
76
|
this.getInputError = () => {
|
|
77
77
|
let inputError = null;
|
|
78
|
-
|
|
78
|
+
const hasNotEmptyValues = (toControl) => !toControl.some(value => [null, undefined].includes(value));
|
|
79
|
+
if (!hasNotEmptyValues([this.input]))
|
|
79
80
|
return inputError;
|
|
80
81
|
// required
|
|
81
82
|
if (!this.input.checkValidity() && this.input.validity.valueMissing) {
|
|
82
83
|
inputError = InputError.REQUIRED;
|
|
83
84
|
}
|
|
84
85
|
// Min & Max
|
|
85
|
-
else if (this.min
|
|
86
|
+
else if (hasNotEmptyValues([this.min, this.numericValue]) && this.numericValue < this.min && this.max === undefined) {
|
|
86
87
|
// Only a min value is set
|
|
87
88
|
inputError = InputError.MIN;
|
|
88
89
|
}
|
|
89
|
-
else if (this.max
|
|
90
|
+
else if (hasNotEmptyValues([this.max, this.numericValue]) && this.numericValue > this.max && this.min === undefined) {
|
|
90
91
|
// Only a max value is set
|
|
91
92
|
inputError = InputError.MAX;
|
|
92
93
|
}
|
|
93
|
-
else if ((this.min
|
|
94
|
+
else if (hasNotEmptyValues([this.min, this.max, this.numericValue]) && (this.numericValue < this.min || this.numericValue > this.max)) {
|
|
94
95
|
// both min and max values are set
|
|
95
96
|
inputError = InputError.MINMAX;
|
|
96
97
|
}
|
|
@@ -140,7 +141,8 @@ export class MgInputNumeric {
|
|
|
140
141
|
this.hasFocus = false;
|
|
141
142
|
}
|
|
142
143
|
validateValue(newValue) {
|
|
143
|
-
|
|
144
|
+
// has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type
|
|
145
|
+
if (typeof newValue === 'string') {
|
|
144
146
|
// Split number and decimal
|
|
145
147
|
const [integer, decimal = ''] = newValue.replace('-', '').split(/[\.,]/);
|
|
146
148
|
// Regex
|
|
@@ -160,7 +162,7 @@ export class MgInputNumeric {
|
|
|
160
162
|
if (this.input !== undefined)
|
|
161
163
|
this.input.value = this.value;
|
|
162
164
|
// emit numeric value
|
|
163
|
-
this.numericValue =
|
|
165
|
+
this.numericValue = !['', null].includes(this.value) ? parseFloat(this.value.replace(',', '.')) : null;
|
|
164
166
|
this.valueChange.emit(this.numericValue);
|
|
165
167
|
// Set readonlyValue
|
|
166
168
|
this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
|
|
@@ -205,7 +207,7 @@ export class MgInputNumeric {
|
|
|
205
207
|
* Displayed value in input
|
|
206
208
|
* Change on focus/blur
|
|
207
209
|
*
|
|
208
|
-
* @returns {
|
|
210
|
+
* @returns {MgInputNumeric['value'] | MgInputNumeric['readonlyValue']} display value
|
|
209
211
|
*/
|
|
210
212
|
displayValue() {
|
|
211
213
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -223,11 +225,12 @@ export class MgInputNumeric {
|
|
|
223
225
|
const locales = initLocales(this.element);
|
|
224
226
|
this.locale = locales.locale;
|
|
225
227
|
this.messages = locales.messages;
|
|
226
|
-
// Validate
|
|
227
|
-
this.validateValue(this.value);
|
|
228
|
+
// Validate component config
|
|
228
229
|
this.validateType(this.type);
|
|
229
230
|
this.validateIntegerLength(this.integerLength);
|
|
230
231
|
this.validateDecimalLength(this.decimalLength);
|
|
232
|
+
// validate value
|
|
233
|
+
this.validateValue(this.value);
|
|
231
234
|
this.validateAppendSlot();
|
|
232
235
|
// Check validity when component is ready
|
|
233
236
|
// return a promise to process action only in the FIRST render().
|
|
@@ -232,7 +232,7 @@ export class MgMenu {
|
|
|
232
232
|
"mutable": false,
|
|
233
233
|
"complexType": {
|
|
234
234
|
"original": "ItemMoreType",
|
|
235
|
-
"resolved": "{ size: \"regular\" | \"
|
|
235
|
+
"resolved": "{ size: \"regular\" | \"medium\" | \"large\"; icon: IconType; slotlabel: SlotLabelType; }",
|
|
236
236
|
"references": {
|
|
237
237
|
"ItemMoreType": {
|
|
238
238
|
"location": "import",
|
|
@@ -294,7 +294,7 @@ export class MgMenuItem {
|
|
|
294
294
|
[`${this.navigationButton}-chevron`]: true,
|
|
295
295
|
[`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
|
|
296
296
|
'mg-a11y-animation': true,
|
|
297
|
-
} }, h("mg-icon", { icon: "chevron-down" })))));
|
|
297
|
+
} }, h("mg-icon", { icon: "chevron-down", size: "small" })))));
|
|
298
298
|
}
|
|
299
299
|
/**
|
|
300
300
|
* Render
|
|
@@ -40,7 +40,7 @@ export class MgDetails {
|
|
|
40
40
|
* @returns {HTMLElement} HTML Element
|
|
41
41
|
*/
|
|
42
42
|
render() {
|
|
43
|
-
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), h("div", { class: "mg-details__details" }, h("slot", { name: "details" }))));
|
|
43
|
+
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down', size: "small" }), h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), h("div", { class: "mg-details__details" }, h("slot", { name: "details" }))));
|
|
44
44
|
}
|
|
45
45
|
static get is() { return "mg-details"; }
|
|
46
46
|
static get encapsulation() { return "shadow"; }
|
|
@@ -26,7 +26,8 @@ export class MgItemMore {
|
|
|
26
26
|
Array.from(moreElementMenuItem.querySelectorAll('mg-menu-item:not([data-overflow-more])')).forEach((proxy, index) => {
|
|
27
27
|
// manage click on proxy to mirror it on initial element
|
|
28
28
|
proxy.addEventListener('click', () => {
|
|
29
|
-
|
|
29
|
+
// be carefull to use element.click() method instead of dispatchEvent to ensure bubbles outside shadowDom
|
|
30
|
+
allMenuItem[index].shadowRoot.querySelector('a, button').click();
|
|
30
31
|
});
|
|
31
32
|
// add id suffix to prevent duplicate key. default html id is: '';
|
|
32
33
|
if (proxy.id.trim() !== '')
|
|
@@ -9,34 +9,15 @@
|
|
|
9
9
|
display: inline-block;
|
|
10
10
|
min-height: var(--default-size);
|
|
11
11
|
}
|
|
12
|
-
.mg-message__bar {
|
|
13
|
-
position: absolute;
|
|
14
|
-
top: 0;
|
|
15
|
-
left: 0;
|
|
16
|
-
width: 0.3rem;
|
|
17
|
-
height: 100%;
|
|
18
|
-
}
|
|
19
|
-
.mg-message.mg-message--info .mg-message__bar {
|
|
20
|
-
background-color: hsl(var(--color-info));
|
|
21
|
-
}
|
|
22
12
|
.mg-message.mg-message--info .mg-message__icon {
|
|
23
13
|
color: hsl(var(--color-info));
|
|
24
14
|
}
|
|
25
|
-
.mg-message.mg-message--warning .mg-message__bar {
|
|
26
|
-
background-color: hsl(var(--color-warning));
|
|
27
|
-
}
|
|
28
15
|
.mg-message.mg-message--warning .mg-message__icon {
|
|
29
16
|
color: hsl(var(--color-warning));
|
|
30
17
|
}
|
|
31
|
-
.mg-message.mg-message--success .mg-message__bar {
|
|
32
|
-
background-color: hsl(var(--color-success));
|
|
33
|
-
}
|
|
34
18
|
.mg-message.mg-message--success .mg-message__icon {
|
|
35
19
|
color: hsl(var(--color-success));
|
|
36
20
|
}
|
|
37
|
-
.mg-message.mg-message--danger .mg-message__bar {
|
|
38
|
-
background-color: hsl(var(--color-danger));
|
|
39
|
-
}
|
|
40
21
|
.mg-message.mg-message--danger .mg-message__icon {
|
|
41
22
|
color: hsl(var(--color-danger));
|
|
42
23
|
}
|
|
@@ -87,6 +68,7 @@
|
|
|
87
68
|
--mg-card-border-radius: var(--mg-card-border-radius-default);
|
|
88
69
|
--mg-card-background: var(--mg-card-background-default);
|
|
89
70
|
--mg-card-box-shadow: var(--mg-card-box-shadow-default);
|
|
71
|
+
--mg-card-max-width: unset;
|
|
90
72
|
}
|
|
91
73
|
|
|
92
74
|
.mg-message,
|
|
@@ -158,7 +158,7 @@ export class MgMessage {
|
|
|
158
158
|
* @returns {HTMLElement} HTML Element
|
|
159
159
|
*/
|
|
160
160
|
render() {
|
|
161
|
-
return (h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("mg-card",
|
|
161
|
+
return (h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("mg-card", { variant: this.variant, "variant-style": "bar-left" }, h("span", { class: "mg-message__icon" }, h("mg-icon", { icon: this.getIcon() })), h("div", { class: "mg-message__content" }, h("span", { class: "mg-message__content-slot" }, h("slot", null)), this.hasActions && h("span", { class: "mg-message__content-separator" }), this.hasActions && (h("span", { class: "mg-message__content-actions-slot" }, h("slot", { name: "actions" })))), this.closeButton && (h("span", { class: "mg-message__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))))));
|
|
162
162
|
}
|
|
163
163
|
static get is() { return "mg-message"; }
|
|
164
164
|
static get encapsulation() { return "shadow"; }
|
|
@@ -213,9 +213,14 @@ export class MgMessage {
|
|
|
213
213
|
"type": "string",
|
|
214
214
|
"mutable": false,
|
|
215
215
|
"complexType": {
|
|
216
|
-
"original": "
|
|
217
|
-
"resolved": "
|
|
218
|
-
"references": {
|
|
216
|
+
"original": "VariantType",
|
|
217
|
+
"resolved": "\"danger\" | \"info\" | \"success\" | \"warning\"",
|
|
218
|
+
"references": {
|
|
219
|
+
"VariantType": {
|
|
220
|
+
"location": "import",
|
|
221
|
+
"path": "./mg-message.conf"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
219
224
|
},
|
|
220
225
|
"required": false,
|
|
221
226
|
"optional": false,
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
color: hsl(var(--mg-popover-font-color));
|
|
18
18
|
}
|
|
19
19
|
.mg-popover mg-card {
|
|
20
|
+
--mg-card-max-width: var(--mg-popover-max-width);
|
|
20
21
|
position: relative;
|
|
21
22
|
}
|
|
22
23
|
.mg-popover[data-show] {
|
|
@@ -115,4 +116,5 @@
|
|
|
115
116
|
--mg-card-border-radius: var(--mg-card-border-radius-default);
|
|
116
117
|
--mg-card-background: var(--mg-card-background-default);
|
|
117
118
|
--mg-card-box-shadow: var(--mg-card-box-shadow-default);
|
|
119
|
+
--mg-card-max-width: unset;
|
|
118
120
|
}
|
|
@@ -98,6 +98,9 @@
|
|
|
98
98
|
/* Shadow */
|
|
99
99
|
--box-shadow: 0 0.3rem 0.8rem 0 hsl(var(--color-dark), 0.15);
|
|
100
100
|
|
|
101
|
+
/* Soft style */
|
|
102
|
+
--mg-color-soft-l: 90%;
|
|
103
|
+
|
|
101
104
|
/*
|
|
102
105
|
Global
|
|
103
106
|
*/
|
|
@@ -109,8 +112,10 @@
|
|
|
109
112
|
*/
|
|
110
113
|
--mg-icon-small-size: 1.2rem;
|
|
111
114
|
--mg-icon-regular-size: 1.6rem;
|
|
115
|
+
--mg-icon-medium-size: 2rem;
|
|
112
116
|
--mg-icon-large-size: 2.4rem;
|
|
113
|
-
--mg-icon-extra-large-size: 3.
|
|
117
|
+
--mg-icon-extra-large-size: 3.2rem;
|
|
118
|
+
--mg-icon-border-radius: 50%;
|
|
114
119
|
|
|
115
120
|
/*
|
|
116
121
|
<mg-button>
|
|
@@ -160,6 +165,7 @@
|
|
|
160
165
|
--mg-popover-background-color: var(--color-light);
|
|
161
166
|
--mg-popover-font-color: var(--color-font-dark);
|
|
162
167
|
--mg-popover-title-font-size: 1.4rem;
|
|
168
|
+
--mg-popover-max-width: 40rem;
|
|
163
169
|
|
|
164
170
|
/*
|
|
165
171
|
<mg-message>
|
|
@@ -10,7 +10,7 @@ import { d as defineCustomElement$5 } from './mg-icon2.js';
|
|
|
10
10
|
import { d as defineCustomElement$4 } from './mg-menu2.js';
|
|
11
11
|
import { d as defineCustomElement$2 } from './mg-popover2.js';
|
|
12
12
|
|
|
13
|
-
const mgActionMoreCss = ".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}}:host{--mg-popover-padding-vertical:1rem;--mg-popover-padding-horizontal:0}.mg-action-more__chevron{transition:200ms}.mg-action-more__chevron--rotate.mg-action-more__chevron{transform:rotate(180deg)}";
|
|
13
|
+
const mgActionMoreCss = ".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}}:host{--mg-popover-padding-vertical:1rem;--mg-popover-padding-horizontal:0;--mg-popover-max-width:unset}.mg-action-more__chevron{transition:200ms}.mg-action-more__chevron--rotate.mg-action-more__chevron{transform:rotate(180deg)}";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* MgActionMore['items'] type guard
|