@mgdis/mg-components 5.8.2 → 5.10.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/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_31.cjs.entry.js +216 -277
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +1 -16
- package/dist/cjs/{mg-menu.conf-9afe6571.js → mg-menu.conf-1942ac70.js} +0 -5
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -3
- package/dist/collection/components/atoms/mg-button/mg-button.js +2 -7
- 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 +113 -2
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +0 -2
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +0 -1
- 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 +65 -24
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +0 -2
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +12 -12
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +0 -3
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +42 -15
- package/dist/collection/components/molecules/inputs/MgInput.js +0 -6
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +0 -6
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +0 -5
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +12 -21
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +0 -3
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +0 -9
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +0 -13
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +1 -12
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -5
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +0 -5
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +1 -12
- 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 -19
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.css +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +0 -8
- package/dist/collection/components/molecules/mg-details/mg-details.css +0 -3
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -4
- package/dist/collection/components/molecules/mg-form/mg-form.js +0 -8
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +0 -2
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +0 -5
- package/dist/collection/components/molecules/mg-message/mg-message.css +1 -19
- package/dist/collection/components/molecules/mg-message/mg-message.js +11 -11
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +1 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +1 -6
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +0 -6
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +5 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -8
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +0 -12
- package/dist/collection/locales/index.js +0 -1
- package/dist/collection/styles/reset-mg-card-slotted-variables.scss +1 -0
- package/dist/collection/utils/behaviors.utils.js +0 -10
- package/dist/collection/utils/components.utils.js +1 -10
- package/dist/collection/utils/locale.utils.js +0 -4
- package/dist/collection/utils/unit.test.utils.js +0 -5
- package/dist/collection/variables.css +7 -1
- package/dist/components/MgInput.js +0 -6
- package/dist/components/components.utils.js +1 -10
- package/dist/components/index2.js +0 -5
- package/dist/components/mg-action-more.js +1 -9
- package/dist/components/mg-badge2.js +1 -3
- package/dist/components/mg-button2.js +2 -7
- package/dist/components/mg-card2.js +67 -4
- package/dist/components/mg-character-left2.js +0 -2
- package/dist/components/mg-details.js +2 -5
- package/dist/components/mg-divider.js +0 -1
- package/dist/components/mg-form.js +0 -8
- package/dist/components/mg-icon2.js +74 -25
- package/dist/components/mg-illustrated-message.js +0 -2
- package/dist/components/mg-input-checkbox.js +0 -6
- package/dist/components/mg-input-date.js +0 -5
- package/dist/components/mg-input-numeric.js +12 -21
- package/dist/components/mg-input-password.js +0 -3
- package/dist/components/mg-input-radio.js +0 -9
- package/dist/components/mg-input-select2.js +0 -13
- package/dist/components/mg-input-text2.js +1 -12
- package/dist/components/mg-input-textarea.js +1 -5
- package/dist/components/mg-input-title2.js +0 -2
- package/dist/components/mg-input-toggle.js +0 -5
- package/dist/components/mg-item-more.js +0 -15
- package/dist/components/mg-menu-item2.js +2 -20
- package/dist/components/mg-menu2.js +0 -11
- package/dist/components/mg-message.js +4 -9
- package/dist/components/mg-modal.js +2 -7
- package/dist/components/mg-pagination.js +0 -6
- package/dist/components/mg-panel.js +6 -16
- package/dist/components/mg-popover2.js +2 -9
- package/dist/components/mg-skip-links.js +1 -4
- package/dist/components/mg-tabs.js +0 -12
- package/dist/components/mg-tag.js +1 -4
- package/dist/components/mg-tooltip2.js +42 -15
- package/dist/components/popper.js +3 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_31.entry.js +216 -277
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +1 -16
- package/dist/esm/{mg-menu.conf-881fbd82.js → mg-menu.conf-2cc1bb67.js} +0 -5
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-67ce7cb8.entry.js → p-a56a3157.entry.js} +1 -1
- package/dist/mg-components/p-eb32bb18.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-badge/mg-badge.d.ts +0 -2
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +0 -5
- 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 +37 -1
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +0 -2
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +0 -1
- 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 +19 -8
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +0 -2
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +0 -3
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +18 -9
- package/dist/types/components/molecules/inputs/MgInput.d.ts +0 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +0 -5
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +0 -5
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +5 -17
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +0 -3
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +0 -8
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +0 -9
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +0 -11
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +0 -4
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +0 -5
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +0 -11
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +0 -18
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +0 -5
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +0 -3
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +0 -8
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +0 -2
- package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +0 -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 +7 -11
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +0 -5
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +0 -5
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +0 -10
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +0 -7
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +0 -3
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +0 -11
- package/dist/types/components.d.ts +35 -9
- package/dist/types/locales/index.d.ts +0 -1
- package/dist/types/utils/behaviors.utils.d.ts +0 -9
- package/dist/types/utils/components.utils.d.ts +1 -9
- package/dist/types/utils/locale.utils.d.ts +0 -4
- package/dist/types/utils/unit.test.utils.d.ts +0 -7
- package/package.json +15 -16
- package/dist/mg-components/p-0b68c4b4.entry.js +0 -1
- /package/dist/mg-components/{p-367f92d2.js → p-73156ac9.js} +0 -0
|
@@ -10,7 +10,6 @@ export class MgInputNumeric {
|
|
|
10
10
|
this.hasDisplayedError = false;
|
|
11
11
|
/**
|
|
12
12
|
* Handle input event
|
|
13
|
-
*
|
|
14
13
|
* @returns {void}
|
|
15
14
|
*/
|
|
16
15
|
this.handleInput = () => {
|
|
@@ -23,7 +22,6 @@ export class MgInputNumeric {
|
|
|
23
22
|
};
|
|
24
23
|
/**
|
|
25
24
|
* Handle focus event
|
|
26
|
-
*
|
|
27
25
|
* @returns {void}
|
|
28
26
|
*/
|
|
29
27
|
this.handleFocus = () => {
|
|
@@ -31,7 +29,6 @@ export class MgInputNumeric {
|
|
|
31
29
|
};
|
|
32
30
|
/**
|
|
33
31
|
* Handle blur event
|
|
34
|
-
*
|
|
35
32
|
* @returns {void}
|
|
36
33
|
*/
|
|
37
34
|
this.handleBlur = () => {
|
|
@@ -41,7 +38,6 @@ export class MgInputNumeric {
|
|
|
41
38
|
};
|
|
42
39
|
/**
|
|
43
40
|
* Check if input is valid
|
|
44
|
-
*
|
|
45
41
|
* @returns {void}
|
|
46
42
|
*/
|
|
47
43
|
this.checkValidity = () => {
|
|
@@ -52,7 +48,6 @@ export class MgInputNumeric {
|
|
|
52
48
|
};
|
|
53
49
|
/**
|
|
54
50
|
* Set input error message
|
|
55
|
-
*
|
|
56
51
|
* @returns {void}
|
|
57
52
|
*/
|
|
58
53
|
this.setErrorMessage = () => {
|
|
@@ -70,27 +65,27 @@ export class MgInputNumeric {
|
|
|
70
65
|
};
|
|
71
66
|
/**
|
|
72
67
|
* Get input error code
|
|
73
|
-
*
|
|
74
68
|
* @returns {null | InputError} error code
|
|
75
69
|
*/
|
|
76
70
|
this.getInputError = () => {
|
|
77
71
|
let inputError = null;
|
|
78
|
-
|
|
72
|
+
const hasNotEmptyValues = (toControl) => !toControl.some(value => [null, undefined].includes(value));
|
|
73
|
+
if (!hasNotEmptyValues([this.input]))
|
|
79
74
|
return inputError;
|
|
80
75
|
// required
|
|
81
76
|
if (!this.input.checkValidity() && this.input.validity.valueMissing) {
|
|
82
77
|
inputError = InputError.REQUIRED;
|
|
83
78
|
}
|
|
84
79
|
// Min & Max
|
|
85
|
-
else if (this.min
|
|
80
|
+
else if (hasNotEmptyValues([this.min, this.numericValue]) && this.numericValue < this.min && this.max === undefined) {
|
|
86
81
|
// Only a min value is set
|
|
87
82
|
inputError = InputError.MIN;
|
|
88
83
|
}
|
|
89
|
-
else if (this.max
|
|
84
|
+
else if (hasNotEmptyValues([this.max, this.numericValue]) && this.numericValue > this.max && this.min === undefined) {
|
|
90
85
|
// Only a max value is set
|
|
91
86
|
inputError = InputError.MAX;
|
|
92
87
|
}
|
|
93
|
-
else if ((this.min
|
|
88
|
+
else if (hasNotEmptyValues([this.min, this.max, this.numericValue]) && (this.numericValue < this.min || this.numericValue > this.max)) {
|
|
94
89
|
// both min and max values are set
|
|
95
90
|
inputError = InputError.MINMAX;
|
|
96
91
|
}
|
|
@@ -98,14 +93,12 @@ export class MgInputNumeric {
|
|
|
98
93
|
};
|
|
99
94
|
/**
|
|
100
95
|
* Format value based on type
|
|
101
|
-
*
|
|
102
96
|
* @param {number} value value to format
|
|
103
97
|
* @returns {string} formated local value
|
|
104
98
|
*/
|
|
105
99
|
this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));
|
|
106
100
|
/**
|
|
107
101
|
* Validate append slot
|
|
108
|
-
*
|
|
109
102
|
* @returns {void}
|
|
110
103
|
*/
|
|
111
104
|
this.validateAppendSlot = () => {
|
|
@@ -140,7 +133,8 @@ export class MgInputNumeric {
|
|
|
140
133
|
this.hasFocus = false;
|
|
141
134
|
}
|
|
142
135
|
validateValue(newValue) {
|
|
143
|
-
|
|
136
|
+
// has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type
|
|
137
|
+
if (typeof newValue === 'string') {
|
|
144
138
|
// Split number and decimal
|
|
145
139
|
const [integer, decimal = ''] = newValue.replace('-', '').split(/[\.,]/);
|
|
146
140
|
// Regex
|
|
@@ -160,7 +154,7 @@ export class MgInputNumeric {
|
|
|
160
154
|
if (this.input !== undefined)
|
|
161
155
|
this.input.value = this.value;
|
|
162
156
|
// emit numeric value
|
|
163
|
-
this.numericValue =
|
|
157
|
+
this.numericValue = !['', null].includes(this.value) ? parseFloat(this.value.replace(',', '.')) : null;
|
|
164
158
|
this.valueChange.emit(this.numericValue);
|
|
165
159
|
// Set readonlyValue
|
|
166
160
|
this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
|
|
@@ -193,7 +187,6 @@ export class MgInputNumeric {
|
|
|
193
187
|
}
|
|
194
188
|
/**
|
|
195
189
|
* Public method to display errors
|
|
196
|
-
*
|
|
197
190
|
* @returns {Promise<void>}
|
|
198
191
|
*/
|
|
199
192
|
async displayError() {
|
|
@@ -204,8 +197,7 @@ export class MgInputNumeric {
|
|
|
204
197
|
/**
|
|
205
198
|
* Displayed value in input
|
|
206
199
|
* Change on focus/blur
|
|
207
|
-
*
|
|
208
|
-
* @returns {string} display value
|
|
200
|
+
* @returns {MgInputNumeric['value'] | MgInputNumeric['readonlyValue']} display value
|
|
209
201
|
*/
|
|
210
202
|
displayValue() {
|
|
211
203
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -215,7 +207,6 @@ export class MgInputNumeric {
|
|
|
215
207
|
*************/
|
|
216
208
|
/**
|
|
217
209
|
* Check if component props are well configured on init
|
|
218
|
-
*
|
|
219
210
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
220
211
|
*/
|
|
221
212
|
componentWillLoad() {
|
|
@@ -223,11 +214,12 @@ export class MgInputNumeric {
|
|
|
223
214
|
const locales = initLocales(this.element);
|
|
224
215
|
this.locale = locales.locale;
|
|
225
216
|
this.messages = locales.messages;
|
|
226
|
-
// Validate
|
|
227
|
-
this.validateValue(this.value);
|
|
217
|
+
// Validate component config
|
|
228
218
|
this.validateType(this.type);
|
|
229
219
|
this.validateIntegerLength(this.integerLength);
|
|
230
220
|
this.validateDecimalLength(this.decimalLength);
|
|
221
|
+
// validate value
|
|
222
|
+
this.validateValue(this.value);
|
|
231
223
|
this.validateAppendSlot();
|
|
232
224
|
// Check validity when component is ready
|
|
233
225
|
// return a promise to process action only in the FIRST render().
|
|
@@ -238,7 +230,6 @@ export class MgInputNumeric {
|
|
|
238
230
|
}
|
|
239
231
|
/**
|
|
240
232
|
* Render
|
|
241
|
-
*
|
|
242
233
|
* @returns {HTMLElement} HTML Element
|
|
243
234
|
*/
|
|
244
235
|
render() {
|
|
@@ -76,7 +76,6 @@ export class MgInputPassword {
|
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Public method to display errors
|
|
79
|
-
*
|
|
80
79
|
* @returns {Promise<void>}
|
|
81
80
|
*/
|
|
82
81
|
async displayError() {
|
|
@@ -89,7 +88,6 @@ export class MgInputPassword {
|
|
|
89
88
|
*************/
|
|
90
89
|
/**
|
|
91
90
|
* Check if component props are well configured on init
|
|
92
|
-
*
|
|
93
91
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
94
92
|
*/
|
|
95
93
|
componentWillLoad() {
|
|
@@ -104,7 +102,6 @@ export class MgInputPassword {
|
|
|
104
102
|
}
|
|
105
103
|
/**
|
|
106
104
|
* Render
|
|
107
|
-
*
|
|
108
105
|
* @returns {HTMLElement} HTML Element
|
|
109
106
|
*/
|
|
110
107
|
render() {
|
|
@@ -7,7 +7,6 @@ import { ClassList, allItemsAreString } from '../../../../utils/components.utils
|
|
|
7
7
|
import { initLocales } from '../../../../locales';
|
|
8
8
|
/**
|
|
9
9
|
* type Option validation function
|
|
10
|
-
*
|
|
11
10
|
* @param {RadioOption} option radio option
|
|
12
11
|
* @returns {boolean} radio option type is valid
|
|
13
12
|
*/
|
|
@@ -23,7 +22,6 @@ export class MgInputRadio {
|
|
|
23
22
|
this.hasDisplayedError = false;
|
|
24
23
|
/**
|
|
25
24
|
* Handle input event
|
|
26
|
-
*
|
|
27
25
|
* @param {event} event input event
|
|
28
26
|
* @returns {void}
|
|
29
27
|
*/
|
|
@@ -33,7 +31,6 @@ export class MgInputRadio {
|
|
|
33
31
|
};
|
|
34
32
|
/**
|
|
35
33
|
* Handle blur event
|
|
36
|
-
*
|
|
37
34
|
* @returns {void}
|
|
38
35
|
*/
|
|
39
36
|
this.handleBlur = () => {
|
|
@@ -42,7 +39,6 @@ export class MgInputRadio {
|
|
|
42
39
|
};
|
|
43
40
|
/**
|
|
44
41
|
* Check if input is valid
|
|
45
|
-
*
|
|
46
42
|
* @returns {void}
|
|
47
43
|
*/
|
|
48
44
|
this.checkValidity = () => {
|
|
@@ -53,7 +49,6 @@ export class MgInputRadio {
|
|
|
53
49
|
};
|
|
54
50
|
/**
|
|
55
51
|
* Set input error message
|
|
56
|
-
*
|
|
57
52
|
* @returns {void}
|
|
58
53
|
*/
|
|
59
54
|
this.setErrorMessage = () => {
|
|
@@ -66,7 +61,6 @@ export class MgInputRadio {
|
|
|
66
61
|
};
|
|
67
62
|
/**
|
|
68
63
|
* get invalid element
|
|
69
|
-
*
|
|
70
64
|
* @returns {HTMLInputElement} element
|
|
71
65
|
*/
|
|
72
66
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
@@ -121,7 +115,6 @@ export class MgInputRadio {
|
|
|
121
115
|
}
|
|
122
116
|
/**
|
|
123
117
|
* Public method to display errors
|
|
124
|
-
*
|
|
125
118
|
* @returns {Promise<void>}
|
|
126
119
|
*/
|
|
127
120
|
async displayError() {
|
|
@@ -134,7 +127,6 @@ export class MgInputRadio {
|
|
|
134
127
|
*************/
|
|
135
128
|
/**
|
|
136
129
|
* Check if component props are well configured on init
|
|
137
|
-
*
|
|
138
130
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
139
131
|
*/
|
|
140
132
|
componentWillLoad() {
|
|
@@ -151,7 +143,6 @@ export class MgInputRadio {
|
|
|
151
143
|
}
|
|
152
144
|
/**
|
|
153
145
|
* Render
|
|
154
|
-
*
|
|
155
146
|
* @returns {HTMLElement} HTML Element
|
|
156
147
|
*/
|
|
157
148
|
render() {
|
|
@@ -6,28 +6,24 @@ import { ClassList, allItemsAreString } from '../../../../utils/components.utils
|
|
|
6
6
|
import { initLocales } from '../../../../locales';
|
|
7
7
|
/**
|
|
8
8
|
* Check if item is a well configured option
|
|
9
|
-
*
|
|
10
9
|
* @param {unknown} option select option
|
|
11
10
|
* @returns {boolean} select option type is valid
|
|
12
11
|
*/
|
|
13
12
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
14
13
|
/**
|
|
15
14
|
* Check if items[] is SelectOption
|
|
16
|
-
*
|
|
17
15
|
* @param {unknown[]} items select option
|
|
18
16
|
* @returns {boolean} select option array type is valid
|
|
19
17
|
*/
|
|
20
18
|
const allItemsAreOptions = (items) => Array.isArray(items) && items.every(item => isOption(item));
|
|
21
19
|
/**
|
|
22
20
|
* Check if item is a well configured optgroup
|
|
23
|
-
*
|
|
24
21
|
* @param {unknown} optgroup select option
|
|
25
22
|
* @returns {boolean} select optgroup type is valid
|
|
26
23
|
*/
|
|
27
24
|
const isOptGroup = (optgroup) => typeof optgroup === 'object' && typeof optgroup.group === 'string' && allItemsAreOptions(optgroup.options);
|
|
28
25
|
/**
|
|
29
26
|
* Group options
|
|
30
|
-
*
|
|
31
27
|
* @param {(SelectOption | OptGroup)[]} acc reduce accumulator
|
|
32
28
|
* @param {SelectOption} item item to add
|
|
33
29
|
* @param {string} item.group item group
|
|
@@ -60,7 +56,6 @@ export class MgInputSelect {
|
|
|
60
56
|
this.hasDisplayedError = false;
|
|
61
57
|
/**
|
|
62
58
|
* Handle input event
|
|
63
|
-
*
|
|
64
59
|
* @returns {void}
|
|
65
60
|
*/
|
|
66
61
|
this.handleInput = () => {
|
|
@@ -70,14 +65,12 @@ export class MgInputSelect {
|
|
|
70
65
|
};
|
|
71
66
|
/**
|
|
72
67
|
* Method to compare item.title with input.value
|
|
73
|
-
*
|
|
74
68
|
* @param {SelectOption} item item to compare with
|
|
75
69
|
* @returns {boolean} truthy if input.value is an item
|
|
76
70
|
*/
|
|
77
71
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
78
72
|
/**
|
|
79
73
|
* value props setter
|
|
80
|
-
*
|
|
81
74
|
* @param {MgInputSelect['value']} newValue value to update with
|
|
82
75
|
* @returns {void}
|
|
83
76
|
*/
|
|
@@ -87,7 +80,6 @@ export class MgInputSelect {
|
|
|
87
80
|
};
|
|
88
81
|
/**
|
|
89
82
|
* Update value from input.value
|
|
90
|
-
*
|
|
91
83
|
* @returns {void}
|
|
92
84
|
*/
|
|
93
85
|
this.updateValue = () => {
|
|
@@ -114,7 +106,6 @@ export class MgInputSelect {
|
|
|
114
106
|
};
|
|
115
107
|
/**
|
|
116
108
|
* Input value is disabled
|
|
117
|
-
*
|
|
118
109
|
* @returns {boolean} truthy if input value is disabled
|
|
119
110
|
*/
|
|
120
111
|
this.isDisabledValue = () => { var _a; return allItemsAreOptions(this.options) && ((_a = this.options.find(this.isInputValue)) === null || _a === void 0 ? void 0 : _a.disabled) === true; };
|
|
@@ -140,7 +131,6 @@ export class MgInputSelect {
|
|
|
140
131
|
};
|
|
141
132
|
/**
|
|
142
133
|
* Render option
|
|
143
|
-
*
|
|
144
134
|
* @param {SelectOption} option to render
|
|
145
135
|
* @returns {HTMLElement} render option
|
|
146
136
|
*/
|
|
@@ -221,7 +211,6 @@ export class MgInputSelect {
|
|
|
221
211
|
}
|
|
222
212
|
/**
|
|
223
213
|
* Public method to display errors
|
|
224
|
-
*
|
|
225
214
|
* @returns {Promise<void>}
|
|
226
215
|
*/
|
|
227
216
|
async displayError() {
|
|
@@ -234,7 +223,6 @@ export class MgInputSelect {
|
|
|
234
223
|
*************/
|
|
235
224
|
/**
|
|
236
225
|
* Check if component props are well configured on init
|
|
237
|
-
*
|
|
238
226
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
239
227
|
*/
|
|
240
228
|
componentWillLoad() {
|
|
@@ -256,7 +244,6 @@ export class MgInputSelect {
|
|
|
256
244
|
}
|
|
257
245
|
/**
|
|
258
246
|
* Render
|
|
259
|
-
*
|
|
260
247
|
* @returns {HTMLElement} HTML Element
|
|
261
248
|
*/
|
|
262
249
|
render() {
|
|
@@ -15,7 +15,6 @@ export class MgInputText {
|
|
|
15
15
|
this.hasDisplayedError = false;
|
|
16
16
|
/**
|
|
17
17
|
* Handle input event
|
|
18
|
-
*
|
|
19
18
|
* @returns {void}
|
|
20
19
|
*/
|
|
21
20
|
this.handleInput = () => {
|
|
@@ -27,7 +26,6 @@ export class MgInputText {
|
|
|
27
26
|
};
|
|
28
27
|
/**
|
|
29
28
|
* Handle focus event
|
|
30
|
-
*
|
|
31
29
|
* @returns {void}
|
|
32
30
|
*/
|
|
33
31
|
this.handleFocus = () => {
|
|
@@ -36,7 +34,6 @@ export class MgInputText {
|
|
|
36
34
|
};
|
|
37
35
|
/**
|
|
38
36
|
* Handle blur event
|
|
39
|
-
*
|
|
40
37
|
* @returns {void}
|
|
41
38
|
*/
|
|
42
39
|
this.handleBlur = () => {
|
|
@@ -48,7 +45,6 @@ export class MgInputText {
|
|
|
48
45
|
};
|
|
49
46
|
/**
|
|
50
47
|
* Check if input is valid
|
|
51
|
-
*
|
|
52
48
|
* @returns {void}
|
|
53
49
|
*/
|
|
54
50
|
this.checkValidity = () => {
|
|
@@ -60,7 +56,6 @@ export class MgInputText {
|
|
|
60
56
|
};
|
|
61
57
|
/**
|
|
62
58
|
* Set input error message
|
|
63
|
-
*
|
|
64
59
|
* @returns {void}
|
|
65
60
|
*/
|
|
66
61
|
this.setErrorMessage = () => {
|
|
@@ -77,11 +72,10 @@ export class MgInputText {
|
|
|
77
72
|
};
|
|
78
73
|
/**
|
|
79
74
|
* Validate pattern configuration
|
|
80
|
-
*
|
|
81
75
|
* @returns {void}
|
|
82
76
|
*/
|
|
83
77
|
this.validatePattern = () => {
|
|
84
|
-
if (this.pattern &&
|
|
78
|
+
if (this.pattern !== undefined &&
|
|
85
79
|
typeof this.pattern === 'string' &&
|
|
86
80
|
this.pattern !== '' &&
|
|
87
81
|
(this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
|
|
@@ -90,7 +84,6 @@ export class MgInputText {
|
|
|
90
84
|
};
|
|
91
85
|
/**
|
|
92
86
|
* Validate append slot
|
|
93
|
-
*
|
|
94
87
|
* @returns {void}
|
|
95
88
|
*/
|
|
96
89
|
this.validateAppendSlot = () => {
|
|
@@ -150,7 +143,6 @@ export class MgInputText {
|
|
|
150
143
|
}
|
|
151
144
|
/**
|
|
152
145
|
* Public method to play input focus
|
|
153
|
-
*
|
|
154
146
|
* @returns {Promise<void>}
|
|
155
147
|
*/
|
|
156
148
|
async setFocus() {
|
|
@@ -158,7 +150,6 @@ export class MgInputText {
|
|
|
158
150
|
}
|
|
159
151
|
/**
|
|
160
152
|
* Public method to display errors
|
|
161
|
-
*
|
|
162
153
|
* @returns {Promise<void>}
|
|
163
154
|
*/
|
|
164
155
|
async displayError() {
|
|
@@ -171,7 +162,6 @@ export class MgInputText {
|
|
|
171
162
|
*************/
|
|
172
163
|
/**
|
|
173
164
|
* Check if component props are well configured on init
|
|
174
|
-
*
|
|
175
165
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
176
166
|
*/
|
|
177
167
|
componentWillLoad() {
|
|
@@ -191,7 +181,6 @@ export class MgInputText {
|
|
|
191
181
|
}
|
|
192
182
|
/**
|
|
193
183
|
* Render
|
|
194
|
-
*
|
|
195
184
|
* @returns {HTMLElement} HTML Element
|
|
196
185
|
*/
|
|
197
186
|
render() {
|
|
@@ -42,7 +42,6 @@ export class MgInputTextarea {
|
|
|
42
42
|
/**
|
|
43
43
|
* Get pattern validity
|
|
44
44
|
* Pattern is not defined on textarea field: https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
|
|
45
|
-
*
|
|
46
45
|
* @returns {boolean} is pattern valid
|
|
47
46
|
*/
|
|
48
47
|
this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
|
|
@@ -75,7 +74,7 @@ export class MgInputTextarea {
|
|
|
75
74
|
* Validate pattern configuration
|
|
76
75
|
*/
|
|
77
76
|
this.validatePattern = () => {
|
|
78
|
-
if (this.pattern &&
|
|
77
|
+
if (this.pattern !== undefined &&
|
|
79
78
|
typeof this.pattern === 'string' &&
|
|
80
79
|
this.pattern !== '' &&
|
|
81
80
|
(this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
|
|
@@ -130,7 +129,6 @@ export class MgInputTextarea {
|
|
|
130
129
|
}
|
|
131
130
|
/**
|
|
132
131
|
* Public method to display errors
|
|
133
|
-
*
|
|
134
132
|
* @returns {Promise<void>}
|
|
135
133
|
*/
|
|
136
134
|
async displayError() {
|
|
@@ -143,7 +141,6 @@ export class MgInputTextarea {
|
|
|
143
141
|
*************/
|
|
144
142
|
/**
|
|
145
143
|
* Check if component props are well configured on init
|
|
146
|
-
*
|
|
147
144
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
148
145
|
*/
|
|
149
146
|
componentWillLoad() {
|
|
@@ -162,7 +159,6 @@ export class MgInputTextarea {
|
|
|
162
159
|
}
|
|
163
160
|
/**
|
|
164
161
|
* Render
|
|
165
|
-
*
|
|
166
162
|
* @returns {HTMLElement} HTML Element
|
|
167
163
|
*/
|
|
168
164
|
render() {
|
|
@@ -5,7 +5,6 @@ import { MgInput } from '../MgInput';
|
|
|
5
5
|
import { ClassList, allItemsAreString } from '../../../../utils/components.utils';
|
|
6
6
|
/**
|
|
7
7
|
* type Option validation function
|
|
8
|
-
*
|
|
9
8
|
* @param {ToggleValue} option radio option
|
|
10
9
|
* @returns {boolean} toggle option type is valid
|
|
11
10
|
*/
|
|
@@ -23,7 +22,6 @@ export class MgInputToggle {
|
|
|
23
22
|
this.classIcon = 'mg-input--toggle-icon';
|
|
24
23
|
/**
|
|
25
24
|
* Change checked value
|
|
26
|
-
*
|
|
27
25
|
* @returns {void}
|
|
28
26
|
*/
|
|
29
27
|
this.toggleChecked = () => {
|
|
@@ -31,7 +29,6 @@ export class MgInputToggle {
|
|
|
31
29
|
};
|
|
32
30
|
/**
|
|
33
31
|
* Slots validation
|
|
34
|
-
*
|
|
35
32
|
* @returns {void}
|
|
36
33
|
*/
|
|
37
34
|
this.validateSlots = () => {
|
|
@@ -119,7 +116,6 @@ export class MgInputToggle {
|
|
|
119
116
|
}
|
|
120
117
|
/**
|
|
121
118
|
* set checked state
|
|
122
|
-
*
|
|
123
119
|
* @returns {void}
|
|
124
120
|
*/
|
|
125
121
|
setChecked() {
|
|
@@ -162,7 +158,6 @@ export class MgInputToggle {
|
|
|
162
158
|
}
|
|
163
159
|
/**
|
|
164
160
|
* Render
|
|
165
|
-
*
|
|
166
161
|
* @returns {HTMLElement} HTML Element
|
|
167
162
|
*/
|
|
168
163
|
render() {
|
|
@@ -13,7 +13,6 @@ export class MgMenu {
|
|
|
13
13
|
*************/
|
|
14
14
|
/**
|
|
15
15
|
* Close matching menu-item
|
|
16
|
-
*
|
|
17
16
|
* @param {HTMLElement} item menu-item to close
|
|
18
17
|
* @param {boolean} condition addionnal condition
|
|
19
18
|
* @returns {void}
|
|
@@ -25,19 +24,16 @@ export class MgMenu {
|
|
|
25
24
|
};
|
|
26
25
|
/**
|
|
27
26
|
* get mg-item-more element
|
|
28
|
-
*
|
|
29
27
|
* @returns {HTMLMgItemMoreElement} mg-item-more element
|
|
30
28
|
*/
|
|
31
29
|
this.getItemMore = () => this.element.querySelector('mg-item-more');
|
|
32
30
|
/**
|
|
33
31
|
* get mg-item-more >>> mg-menu-item element
|
|
34
|
-
*
|
|
35
32
|
* @returns {HTMLMgMenuItemElement} mg-item-more >>> mg-menu-item element
|
|
36
33
|
*/
|
|
37
34
|
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'); };
|
|
38
35
|
/**
|
|
39
36
|
* Set item listend
|
|
40
|
-
*
|
|
41
37
|
* @param {HTMLMgMenuItemElement} item mg-menu-item element
|
|
42
38
|
* @param {MgMenu['focusedMenuItem']} index number
|
|
43
39
|
* @returns {void}
|
|
@@ -55,7 +51,6 @@ export class MgMenu {
|
|
|
55
51
|
};
|
|
56
52
|
/**
|
|
57
53
|
* Store menu-items on component init and add listeners
|
|
58
|
-
*
|
|
59
54
|
* @returns {void}
|
|
60
55
|
*/
|
|
61
56
|
this.initMenuItemsListeners = () => {
|
|
@@ -66,7 +61,6 @@ export class MgMenu {
|
|
|
66
61
|
};
|
|
67
62
|
/**
|
|
68
63
|
* Handle item-loaded event on mg-item-more element
|
|
69
|
-
*
|
|
70
64
|
* @returns {void}
|
|
71
65
|
*/
|
|
72
66
|
this.handleItemLoaded = () => {
|
|
@@ -74,7 +68,6 @@ export class MgMenu {
|
|
|
74
68
|
};
|
|
75
69
|
/**
|
|
76
70
|
* render mg-item-more
|
|
77
|
-
*
|
|
78
71
|
* @returns {void}
|
|
79
72
|
*/
|
|
80
73
|
this.renderMgItemMore = () => {
|
|
@@ -117,7 +110,6 @@ export class MgMenu {
|
|
|
117
110
|
*************/
|
|
118
111
|
/**
|
|
119
112
|
* Validate props
|
|
120
|
-
*
|
|
121
113
|
* @returns {void}
|
|
122
114
|
*/
|
|
123
115
|
componentWillLoad() {
|
|
@@ -128,7 +120,6 @@ export class MgMenu {
|
|
|
128
120
|
}
|
|
129
121
|
/**
|
|
130
122
|
* Check if component slots configuration
|
|
131
|
-
*
|
|
132
123
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
133
124
|
*/
|
|
134
125
|
componentDidLoad() {
|
|
@@ -159,7 +150,6 @@ export class MgMenu {
|
|
|
159
150
|
}
|
|
160
151
|
/**
|
|
161
152
|
* Add listeners to items
|
|
162
|
-
*
|
|
163
153
|
* @returns {void}
|
|
164
154
|
*/
|
|
165
155
|
componentDidRender() {
|
|
@@ -167,7 +157,6 @@ export class MgMenu {
|
|
|
167
157
|
}
|
|
168
158
|
/**
|
|
169
159
|
* Render
|
|
170
|
-
*
|
|
171
160
|
* @returns {HTMLElement} HTML Element
|
|
172
161
|
*/
|
|
173
162
|
render() {
|
|
@@ -232,7 +221,7 @@ export class MgMenu {
|
|
|
232
221
|
"mutable": false,
|
|
233
222
|
"complexType": {
|
|
234
223
|
"original": "ItemMoreType",
|
|
235
|
-
"resolved": "{ size: \"regular\" | \"
|
|
224
|
+
"resolved": "{ size: \"regular\" | \"medium\" | \"large\"; icon: IconType; slotlabel: SlotLabelType; }",
|
|
236
225
|
"references": {
|
|
237
226
|
"ItemMoreType": {
|
|
238
227
|
"location": "import",
|