@mgdis/mg-components 5.9.1 → 5.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_31.cjs.entry.js +345 -648
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +19 -43
- package/dist/cjs/{mg-menu.conf-9afe6571.js → mg-menu.conf-196151fe.js} +16 -21
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +9 -12
- package/dist/collection/components/atoms/mg-button/mg-button.js +18 -27
- package/dist/collection/components/atoms/mg-card/mg-card.js +22 -15
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +1 -4
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -2
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +26 -23
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -4
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +11 -16
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +12 -34
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +26 -24
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +10 -20
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +7 -17
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +14 -34
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +6 -13
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -27
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +21 -45
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +17 -43
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +14 -22
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +17 -28
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +11 -29
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +20 -47
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +11 -23
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -6
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -27
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -4
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +4 -12
- package/dist/collection/components/molecules/mg-message/mg-message.js +12 -20
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +8 -17
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +11 -19
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +11 -30
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +8 -21
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +3 -8
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +20 -36
- package/dist/collection/locales/index.js +2 -3
- package/dist/collection/utils/behaviors.utils.js +16 -32
- package/dist/collection/utils/components.utils.js +22 -33
- package/dist/collection/utils/locale.utils.js +14 -18
- package/dist/collection/utils/unit.test.utils.js +7 -15
- package/dist/components/MgInput.js +30 -24
- package/dist/components/components.utils.js +22 -33
- package/dist/components/index2.js +16 -21
- package/dist/components/mg-action-more.js +9 -21
- package/dist/components/mg-badge2.js +9 -12
- package/dist/components/mg-button2.js +18 -27
- package/dist/components/mg-card2.js +20 -13
- package/dist/components/mg-character-left2.js +1 -4
- package/dist/components/mg-details.js +1 -6
- package/dist/components/mg-divider.js +1 -2
- package/dist/components/mg-form.js +7 -23
- package/dist/components/mg-icon2.js +26 -23
- package/dist/components/mg-illustrated-message.js +1 -4
- package/dist/components/mg-input-checkbox.js +9 -16
- package/dist/components/mg-input-date.js +6 -13
- package/dist/components/mg-input-numeric.js +13 -30
- package/dist/components/mg-input-password.js +5 -9
- package/dist/components/mg-input-radio.js +9 -23
- package/dist/components/mg-input-select2.js +20 -41
- package/dist/components/mg-input-text2.js +15 -35
- package/dist/components/mg-input-textarea.js +13 -18
- package/dist/components/mg-input-title2.js +1 -4
- package/dist/components/mg-input-toggle.js +16 -24
- package/dist/components/mg-item-more.js +18 -42
- package/dist/components/mg-menu-item2.js +17 -44
- package/dist/components/mg-menu2.js +9 -27
- package/dist/components/mg-message.js +12 -20
- package/dist/components/mg-modal.js +8 -17
- package/dist/components/mg-pagination.js +11 -19
- package/dist/components/mg-panel.js +11 -30
- package/dist/components/mg-popover2.js +8 -21
- package/dist/components/mg-skip-links.js +3 -8
- package/dist/components/mg-tabs.js +20 -36
- package/dist/components/mg-tag.js +11 -16
- package/dist/components/mg-tooltip2.js +12 -34
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_31.entry.js +345 -648
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +19 -43
- package/dist/esm/{mg-menu.conf-881fbd82.js → mg-menu.conf-9ca023ee.js} +16 -21
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-67ce7cb8.entry.js → p-97aaca3e.entry.js} +1 -1
- package/dist/mg-components/p-d891e707.entry.js +1 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +2 -5
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +5 -14
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +11 -8
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -4
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +1 -2
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +8 -7
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -4
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +3 -8
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -33
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -1
- package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -6
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -11
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -11
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +7 -26
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +3 -7
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -18
- 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 -22
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +3 -23
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -9
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -11
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +10 -29
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +21 -49
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +3 -15
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +1 -6
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -19
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +1 -4
- package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +2 -12
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +4 -12
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -12
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +5 -14
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +4 -23
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +3 -16
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +2 -7
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +15 -30
- package/dist/types/components.d.ts +22 -34
- package/dist/types/locales/index.d.ts +2 -3
- package/dist/types/utils/behaviors.utils.d.ts +14 -29
- package/dist/types/utils/components.utils.d.ts +19 -29
- package/dist/types/utils/locale.utils.d.ts +14 -18
- package/dist/types/utils/unit.test.utils.d.ts +11 -24
- package/package.json +11 -12
- package/dist/mg-components/p-9a93b7af.entry.js +0 -1
- /package/dist/mg-components/{p-367f92d2.js → p-0d3146d9.js} +0 -0
|
@@ -10,9 +10,8 @@ const mgInputCheckboxCss = ":host{display:block}.mg-input{display:flex;align-ite
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* type CheckboxItem validation function
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
* @returns {boolean} match item type
|
|
13
|
+
* @param items - Checkbox item
|
|
14
|
+
* @returns match item type
|
|
16
15
|
*/
|
|
17
16
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
18
17
|
items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
|
|
@@ -32,8 +31,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
32
31
|
this.hasDisplayedError = false;
|
|
33
32
|
/**
|
|
34
33
|
* Handle input event
|
|
35
|
-
*
|
|
36
|
-
* @param {InputEvent} event input event
|
|
34
|
+
* @param event - input event
|
|
37
35
|
*/
|
|
38
36
|
this.handleInput = (event) => {
|
|
39
37
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -55,8 +53,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
55
53
|
};
|
|
56
54
|
/**
|
|
57
55
|
* get invalid element
|
|
58
|
-
*
|
|
59
|
-
* @returns {HTMLInputElement} element
|
|
56
|
+
* @returns element
|
|
60
57
|
*/
|
|
61
58
|
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
62
59
|
/**
|
|
@@ -93,7 +90,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
93
90
|
this.helpText = undefined;
|
|
94
91
|
this.valid = undefined;
|
|
95
92
|
this.invalid = undefined;
|
|
96
|
-
this.
|
|
93
|
+
this.classCollection = new ClassList(['mg-input--checkbox']);
|
|
97
94
|
this.errorMessage = undefined;
|
|
98
95
|
this.checkboxItems = [];
|
|
99
96
|
}
|
|
@@ -123,8 +120,6 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
123
120
|
}
|
|
124
121
|
/**
|
|
125
122
|
* Public method to display errors
|
|
126
|
-
*
|
|
127
|
-
* @returns {Promise<void>}
|
|
128
123
|
*/
|
|
129
124
|
async displayError() {
|
|
130
125
|
this.checkValidity();
|
|
@@ -136,8 +131,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
136
131
|
*************/
|
|
137
132
|
/**
|
|
138
133
|
* Check if component props are well configured on init
|
|
139
|
-
*
|
|
140
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
134
|
+
* @returns timeout
|
|
141
135
|
*/
|
|
142
136
|
componentWillLoad() {
|
|
143
137
|
// Get locales
|
|
@@ -153,11 +147,10 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
153
147
|
}
|
|
154
148
|
/**
|
|
155
149
|
* Render
|
|
156
|
-
*
|
|
157
|
-
* @returns {HTMLElement} HTML Element
|
|
150
|
+
* @returns HTML Element
|
|
158
151
|
*/
|
|
159
152
|
render() {
|
|
160
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
153
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.checkboxItems
|
|
161
154
|
.filter(item => {
|
|
162
155
|
return !this.readonly || item.value;
|
|
163
156
|
})
|
|
@@ -189,7 +182,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
189
182
|
"helpText": [1, "help-text"],
|
|
190
183
|
"valid": [1028],
|
|
191
184
|
"invalid": [1028],
|
|
192
|
-
"
|
|
185
|
+
"classCollection": [32],
|
|
193
186
|
"errorMessage": [32],
|
|
194
187
|
"checkboxItems": [32],
|
|
195
188
|
"displayError": [64]
|
|
@@ -53,8 +53,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
55
|
* get input error code
|
|
56
|
-
*
|
|
57
|
-
* @returns {null | InputError} error code
|
|
56
|
+
* @returns error code
|
|
58
57
|
*/
|
|
59
58
|
this.getInputError = () => {
|
|
60
59
|
var _a, _b;
|
|
@@ -79,8 +78,6 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
79
78
|
};
|
|
80
79
|
/**
|
|
81
80
|
* Check input errors
|
|
82
|
-
*
|
|
83
|
-
* @returns {void}
|
|
84
81
|
*/
|
|
85
82
|
this.setErrorMessage = () => {
|
|
86
83
|
var _a;
|
|
@@ -118,7 +115,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
118
115
|
this.invalid = undefined;
|
|
119
116
|
this.min = undefined;
|
|
120
117
|
this.max = undefined;
|
|
121
|
-
this.
|
|
118
|
+
this.classCollection = new ClassList(['mg-input--date']);
|
|
122
119
|
this.errorMessage = undefined;
|
|
123
120
|
}
|
|
124
121
|
validateValue(newValue) {
|
|
@@ -149,8 +146,6 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
149
146
|
}
|
|
150
147
|
/**
|
|
151
148
|
* Public method to display errors
|
|
152
|
-
*
|
|
153
|
-
* @returns {Promise<void>}
|
|
154
149
|
*/
|
|
155
150
|
async displayError() {
|
|
156
151
|
this.checkValidity();
|
|
@@ -162,8 +157,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
162
157
|
*************/
|
|
163
158
|
/**
|
|
164
159
|
* Check if component props are well configured on init
|
|
165
|
-
*
|
|
166
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
160
|
+
* @returns timeout
|
|
167
161
|
*/
|
|
168
162
|
componentWillLoad() {
|
|
169
163
|
// Get locales
|
|
@@ -183,11 +177,10 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
183
177
|
}
|
|
184
178
|
/**
|
|
185
179
|
* Render
|
|
186
|
-
*
|
|
187
|
-
* @returns {HTMLElement} HTML Element
|
|
180
|
+
* @returns HTML Element
|
|
188
181
|
*/
|
|
189
182
|
render() {
|
|
190
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
183
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
191
184
|
if (el !== null)
|
|
192
185
|
this.input = el;
|
|
193
186
|
} })));
|
|
@@ -218,7 +211,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
218
211
|
"invalid": [1028],
|
|
219
212
|
"min": [1],
|
|
220
213
|
"max": [1],
|
|
221
|
-
"
|
|
214
|
+
"classCollection": [32],
|
|
222
215
|
"errorMessage": [32],
|
|
223
216
|
"displayError": [64]
|
|
224
217
|
}]);
|
|
@@ -31,8 +31,6 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
31
31
|
this.hasDisplayedError = false;
|
|
32
32
|
/**
|
|
33
33
|
* Handle input event
|
|
34
|
-
*
|
|
35
|
-
* @returns {void}
|
|
36
34
|
*/
|
|
37
35
|
this.handleInput = () => {
|
|
38
36
|
// Check validity
|
|
@@ -44,26 +42,22 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
44
42
|
};
|
|
45
43
|
/**
|
|
46
44
|
* Handle focus event
|
|
47
|
-
*
|
|
48
|
-
* @returns {void}
|
|
49
45
|
*/
|
|
50
46
|
this.handleFocus = () => {
|
|
51
47
|
this.hasFocus = true;
|
|
52
48
|
};
|
|
53
49
|
/**
|
|
54
50
|
* Handle blur event
|
|
55
|
-
*
|
|
56
|
-
* @returns {void}
|
|
57
51
|
*/
|
|
58
52
|
this.handleBlur = () => {
|
|
53
|
+
if (this.value === '-')
|
|
54
|
+
this.value = '';
|
|
59
55
|
// Display Error
|
|
60
56
|
this.displayError();
|
|
61
57
|
this.hasFocus = false;
|
|
62
58
|
};
|
|
63
59
|
/**
|
|
64
60
|
* Check if input is valid
|
|
65
|
-
*
|
|
66
|
-
* @returns {void}
|
|
67
61
|
*/
|
|
68
62
|
this.checkValidity = () => {
|
|
69
63
|
this.valid = this.readonly || this.disabled || this.getInputError() === null;
|
|
@@ -73,8 +67,6 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
73
67
|
};
|
|
74
68
|
/**
|
|
75
69
|
* Set input error message
|
|
76
|
-
*
|
|
77
|
-
* @returns {void}
|
|
78
70
|
*/
|
|
79
71
|
this.setErrorMessage = () => {
|
|
80
72
|
// Set error message
|
|
@@ -91,8 +83,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
91
83
|
};
|
|
92
84
|
/**
|
|
93
85
|
* Get input error code
|
|
94
|
-
*
|
|
95
|
-
* @returns {null | InputError} error code
|
|
86
|
+
* @returns error code
|
|
96
87
|
*/
|
|
97
88
|
this.getInputError = () => {
|
|
98
89
|
let inputError = null;
|
|
@@ -120,20 +111,17 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
120
111
|
};
|
|
121
112
|
/**
|
|
122
113
|
* Format value based on type
|
|
123
|
-
*
|
|
124
|
-
* @
|
|
125
|
-
* @returns {string} formated local value
|
|
114
|
+
* @param value - value to format
|
|
115
|
+
* @returns formated local value
|
|
126
116
|
*/
|
|
127
117
|
this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));
|
|
128
118
|
/**
|
|
129
119
|
* Validate append slot
|
|
130
|
-
*
|
|
131
|
-
* @returns {void}
|
|
132
120
|
*/
|
|
133
121
|
this.validateAppendSlot = () => {
|
|
134
122
|
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
135
123
|
if (slotAppendInput !== null) {
|
|
136
|
-
this.
|
|
124
|
+
this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
137
125
|
}
|
|
138
126
|
};
|
|
139
127
|
this.value = undefined;
|
|
@@ -157,7 +145,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
157
145
|
this.decimalLength = 2;
|
|
158
146
|
this.valid = undefined;
|
|
159
147
|
this.invalid = undefined;
|
|
160
|
-
this.
|
|
148
|
+
this.classCollection = new ClassList(['mg-input--numeric']);
|
|
161
149
|
this.errorMessage = undefined;
|
|
162
150
|
this.hasFocus = false;
|
|
163
151
|
}
|
|
@@ -169,7 +157,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
169
157
|
// Regex
|
|
170
158
|
const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+[.,]?\d*$/;
|
|
171
159
|
// Filter input
|
|
172
|
-
if (
|
|
160
|
+
if (['', '-'].includes(newValue) || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
173
161
|
this.storedValue = newValue;
|
|
174
162
|
}
|
|
175
163
|
else if (this.storedValue !== undefined) {
|
|
@@ -216,8 +204,6 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
216
204
|
}
|
|
217
205
|
/**
|
|
218
206
|
* Public method to display errors
|
|
219
|
-
*
|
|
220
|
-
* @returns {Promise<void>}
|
|
221
207
|
*/
|
|
222
208
|
async displayError() {
|
|
223
209
|
this.checkValidity();
|
|
@@ -227,8 +213,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
227
213
|
/**
|
|
228
214
|
* Displayed value in input
|
|
229
215
|
* Change on focus/blur
|
|
230
|
-
*
|
|
231
|
-
* @returns {MgInputNumeric['value'] | MgInputNumeric['readonlyValue']} display value
|
|
216
|
+
* @returns display value
|
|
232
217
|
*/
|
|
233
218
|
displayValue() {
|
|
234
219
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -238,8 +223,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
238
223
|
*************/
|
|
239
224
|
/**
|
|
240
225
|
* Check if component props are well configured on init
|
|
241
|
-
*
|
|
242
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
226
|
+
* @returns timeout
|
|
243
227
|
*/
|
|
244
228
|
componentWillLoad() {
|
|
245
229
|
// Get locales
|
|
@@ -262,11 +246,10 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
262
246
|
}
|
|
263
247
|
/**
|
|
264
248
|
* Render
|
|
265
|
-
*
|
|
266
|
-
* @returns {HTMLElement} HTML Element
|
|
249
|
+
* @returns HTML Element
|
|
267
250
|
*/
|
|
268
251
|
render() {
|
|
269
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
252
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
|
|
270
253
|
if (el !== null)
|
|
271
254
|
this.input = el;
|
|
272
255
|
} }), h("slot", { name: "append-input" })));
|
|
@@ -304,7 +287,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
304
287
|
"decimalLength": [2, "decimal-length"],
|
|
305
288
|
"valid": [1028],
|
|
306
289
|
"invalid": [1028],
|
|
307
|
-
"
|
|
290
|
+
"classCollection": [32],
|
|
308
291
|
"errorMessage": [32],
|
|
309
292
|
"hasFocus": [32],
|
|
310
293
|
"displayError": [64]
|
|
@@ -69,7 +69,7 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
69
69
|
this.helpText = undefined;
|
|
70
70
|
this.valid = undefined;
|
|
71
71
|
this.invalid = undefined;
|
|
72
|
-
this.
|
|
72
|
+
this.classCollection = new ClassList(['mg-input--password']);
|
|
73
73
|
this.errorMessage = undefined;
|
|
74
74
|
}
|
|
75
75
|
handleValue(newValue) {
|
|
@@ -87,8 +87,6 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Public method to display errors
|
|
90
|
-
*
|
|
91
|
-
* @returns {Promise<void>}
|
|
92
90
|
*/
|
|
93
91
|
async displayError() {
|
|
94
92
|
this.checkValidity();
|
|
@@ -100,8 +98,7 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
100
98
|
*************/
|
|
101
99
|
/**
|
|
102
100
|
* Check if component props are well configured on init
|
|
103
|
-
*
|
|
104
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
101
|
+
* @returns timeout
|
|
105
102
|
*/
|
|
106
103
|
componentWillLoad() {
|
|
107
104
|
// Get locales
|
|
@@ -115,11 +112,10 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
115
112
|
}
|
|
116
113
|
/**
|
|
117
114
|
* Render
|
|
118
|
-
*
|
|
119
|
-
* @returns {HTMLElement} HTML Element
|
|
115
|
+
* @returns HTML Element
|
|
120
116
|
*/
|
|
121
117
|
render() {
|
|
122
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
118
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
123
119
|
if (el !== null)
|
|
124
120
|
this.input = el;
|
|
125
121
|
} })));
|
|
@@ -148,7 +144,7 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
148
144
|
"helpText": [1, "help-text"],
|
|
149
145
|
"valid": [1028],
|
|
150
146
|
"invalid": [1028],
|
|
151
|
-
"
|
|
147
|
+
"classCollection": [32],
|
|
152
148
|
"errorMessage": [32],
|
|
153
149
|
"displayError": [64]
|
|
154
150
|
}]);
|
|
@@ -10,9 +10,8 @@ const mgInputRadioCss = ":host{display:block}.mg-input{display:flex;align-items:
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* type Option validation function
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
* @returns {boolean} radio option type is valid
|
|
13
|
+
* @param option - radio option
|
|
14
|
+
* @returns radio option type is valid
|
|
16
15
|
*/
|
|
17
16
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
18
17
|
const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
@@ -31,9 +30,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
31
30
|
this.hasDisplayedError = false;
|
|
32
31
|
/**
|
|
33
32
|
* Handle input event
|
|
34
|
-
*
|
|
35
|
-
* @param {event} event input event
|
|
36
|
-
* @returns {void}
|
|
33
|
+
* @param event - input event
|
|
37
34
|
*/
|
|
38
35
|
this.handleInput = (event) => {
|
|
39
36
|
this.checkValidity();
|
|
@@ -41,8 +38,6 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
41
38
|
};
|
|
42
39
|
/**
|
|
43
40
|
* Handle blur event
|
|
44
|
-
*
|
|
45
|
-
* @returns {void}
|
|
46
41
|
*/
|
|
47
42
|
this.handleBlur = () => {
|
|
48
43
|
this.checkValidity();
|
|
@@ -50,8 +45,6 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
50
45
|
};
|
|
51
46
|
/**
|
|
52
47
|
* Check if input is valid
|
|
53
|
-
*
|
|
54
|
-
* @returns {void}
|
|
55
48
|
*/
|
|
56
49
|
this.checkValidity = () => {
|
|
57
50
|
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
@@ -61,8 +54,6 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
61
54
|
};
|
|
62
55
|
/**
|
|
63
56
|
* Set input error message
|
|
64
|
-
*
|
|
65
|
-
* @returns {void}
|
|
66
57
|
*/
|
|
67
58
|
this.setErrorMessage = () => {
|
|
68
59
|
const invalidElement = this.getInvalidElement();
|
|
@@ -74,8 +65,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
74
65
|
};
|
|
75
66
|
/**
|
|
76
67
|
* get invalid element
|
|
77
|
-
*
|
|
78
|
-
* @returns {HTMLInputElement} element
|
|
68
|
+
* @returns element
|
|
79
69
|
*/
|
|
80
70
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
81
71
|
this.value = undefined;
|
|
@@ -93,7 +83,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
93
83
|
this.helpText = undefined;
|
|
94
84
|
this.valid = undefined;
|
|
95
85
|
this.invalid = undefined;
|
|
96
|
-
this.
|
|
86
|
+
this.classCollection = new ClassList(['mg-input--radio']);
|
|
97
87
|
this.errorMessage = undefined;
|
|
98
88
|
this.options = undefined;
|
|
99
89
|
}
|
|
@@ -129,8 +119,6 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
129
119
|
}
|
|
130
120
|
/**
|
|
131
121
|
* Public method to display errors
|
|
132
|
-
*
|
|
133
|
-
* @returns {Promise<void>}
|
|
134
122
|
*/
|
|
135
123
|
async displayError() {
|
|
136
124
|
this.checkValidity();
|
|
@@ -142,8 +130,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
142
130
|
*************/
|
|
143
131
|
/**
|
|
144
132
|
* Check if component props are well configured on init
|
|
145
|
-
*
|
|
146
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
133
|
+
* @returns timeout
|
|
147
134
|
*/
|
|
148
135
|
componentWillLoad() {
|
|
149
136
|
// Get locales
|
|
@@ -159,11 +146,10 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
159
146
|
}
|
|
160
147
|
/**
|
|
161
148
|
* Render
|
|
162
|
-
*
|
|
163
|
-
* @returns {HTMLElement} HTML Element
|
|
149
|
+
* @returns HTML Element
|
|
164
150
|
*/
|
|
165
151
|
render() {
|
|
166
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
152
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => {
|
|
167
153
|
if (el !== null)
|
|
168
154
|
this.inputs[index] = el;
|
|
169
155
|
} }), h("label", { htmlFor: this.identifier + '_' + index }, input.title)))))));
|
|
@@ -193,7 +179,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
193
179
|
"helpText": [1, "help-text"],
|
|
194
180
|
"valid": [1028],
|
|
195
181
|
"invalid": [1028],
|
|
196
|
-
"
|
|
182
|
+
"classCollection": [32],
|
|
197
183
|
"errorMessage": [32],
|
|
198
184
|
"options": [32],
|
|
199
185
|
"displayError": [64]
|
|
@@ -10,35 +10,27 @@ const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Check if item is a well configured option
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
* @returns {boolean} select option type is valid
|
|
13
|
+
* @param option - select option
|
|
14
|
+
* @returns select option type is valid
|
|
16
15
|
*/
|
|
17
16
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
18
17
|
/**
|
|
19
18
|
* Check if items[] is SelectOption
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
22
|
-
* @returns {boolean} select option array type is valid
|
|
19
|
+
* @param items - select option
|
|
20
|
+
* @returns select option array type is valid
|
|
23
21
|
*/
|
|
24
22
|
const allItemsAreOptions = (items) => Array.isArray(items) && items.every(item => isOption(item));
|
|
25
23
|
/**
|
|
26
24
|
* Check if item is a well configured optgroup
|
|
27
|
-
*
|
|
28
|
-
* @
|
|
29
|
-
* @returns {boolean} select optgroup type is valid
|
|
25
|
+
* @param optgroup - select option
|
|
26
|
+
* @returns select optgroup type is valid
|
|
30
27
|
*/
|
|
31
28
|
const isOptGroup = (optgroup) => typeof optgroup === 'object' && typeof optgroup.group === 'string' && allItemsAreOptions(optgroup.options);
|
|
32
29
|
/**
|
|
33
30
|
* Group options
|
|
34
|
-
*
|
|
35
|
-
* @param
|
|
36
|
-
* @
|
|
37
|
-
* @param {string} item.group item group
|
|
38
|
-
* @param {string} item.title item title
|
|
39
|
-
* @param {unknown} item.value item value
|
|
40
|
-
* @param {boolean} item.disabled is item disabled
|
|
41
|
-
* @returns {(SelectOption | OptGroup)[]} grouped options
|
|
31
|
+
* @param acc - reduce accumulator
|
|
32
|
+
* @param item - item to add
|
|
33
|
+
* @returns grouped options
|
|
42
34
|
*/
|
|
43
35
|
const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
44
36
|
if (group !== undefined) {
|
|
@@ -69,8 +61,6 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
69
61
|
this.hasDisplayedError = false;
|
|
70
62
|
/**
|
|
71
63
|
* Handle input event
|
|
72
|
-
*
|
|
73
|
-
* @returns {void}
|
|
74
64
|
*/
|
|
75
65
|
this.handleInput = () => {
|
|
76
66
|
this.updateValue();
|
|
@@ -79,16 +69,13 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
79
69
|
};
|
|
80
70
|
/**
|
|
81
71
|
* Method to compare item.title with input.value
|
|
82
|
-
*
|
|
83
|
-
* @
|
|
84
|
-
* @returns {boolean} truthy if input.value is an item
|
|
72
|
+
* @param item - item to compare with
|
|
73
|
+
* @returns truthy if input.value is an item
|
|
85
74
|
*/
|
|
86
75
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
87
76
|
/**
|
|
88
77
|
* value props setter
|
|
89
|
-
*
|
|
90
|
-
* @param {MgInputSelect['value']} newValue value to update with
|
|
91
|
-
* @returns {void}
|
|
78
|
+
* @param newValue - value to update with
|
|
92
79
|
*/
|
|
93
80
|
this.setValue = (newValue) => {
|
|
94
81
|
this.checkValidity();
|
|
@@ -96,8 +83,6 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
96
83
|
};
|
|
97
84
|
/**
|
|
98
85
|
* Update value from input.value
|
|
99
|
-
*
|
|
100
|
-
* @returns {void}
|
|
101
86
|
*/
|
|
102
87
|
this.updateValue = () => {
|
|
103
88
|
if (this.input.value === '') {
|
|
@@ -123,8 +108,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
123
108
|
};
|
|
124
109
|
/**
|
|
125
110
|
* Input value is disabled
|
|
126
|
-
*
|
|
127
|
-
* @returns {boolean} truthy if input value is disabled
|
|
111
|
+
* @returns truthy if input value is disabled
|
|
128
112
|
*/
|
|
129
113
|
this.isDisabledValue = () => { var _a; return allItemsAreOptions(this.options) && ((_a = this.options.find(this.isInputValue)) === null || _a === void 0 ? void 0 : _a.disabled) === true; };
|
|
130
114
|
/**
|
|
@@ -149,9 +133,8 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
149
133
|
};
|
|
150
134
|
/**
|
|
151
135
|
* Render option
|
|
152
|
-
*
|
|
153
|
-
* @
|
|
154
|
-
* @returns {HTMLElement} render option
|
|
136
|
+
* @param option - to render
|
|
137
|
+
* @returns render option
|
|
155
138
|
*/
|
|
156
139
|
this.renderOption = (option) => (h("option", { key: option.title, value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title));
|
|
157
140
|
this.value = undefined;
|
|
@@ -172,7 +155,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
172
155
|
this.helpText = undefined;
|
|
173
156
|
this.valid = undefined;
|
|
174
157
|
this.invalid = undefined;
|
|
175
|
-
this.
|
|
158
|
+
this.classCollection = new ClassList(['mg-input--select']);
|
|
176
159
|
this.errorMessage = undefined;
|
|
177
160
|
this.options = undefined;
|
|
178
161
|
this.valueExist = undefined;
|
|
@@ -230,8 +213,6 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
230
213
|
}
|
|
231
214
|
/**
|
|
232
215
|
* Public method to display errors
|
|
233
|
-
*
|
|
234
|
-
* @returns {Promise<void>}
|
|
235
216
|
*/
|
|
236
217
|
async displayError() {
|
|
237
218
|
this.checkValidity();
|
|
@@ -243,8 +224,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
243
224
|
*************/
|
|
244
225
|
/**
|
|
245
226
|
* Check if component props are well configured on init
|
|
246
|
-
*
|
|
247
|
-
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
227
|
+
* @returns timeout
|
|
248
228
|
*/
|
|
249
229
|
componentWillLoad() {
|
|
250
230
|
// Get locales
|
|
@@ -265,11 +245,10 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
265
245
|
}
|
|
266
246
|
/**
|
|
267
247
|
* Render
|
|
268
|
-
*
|
|
269
|
-
* @returns {HTMLElement} HTML Element
|
|
248
|
+
* @returns HTML Element
|
|
270
249
|
*/
|
|
271
250
|
render() {
|
|
272
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
251
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: undefined, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
273
252
|
if (el !== null)
|
|
274
253
|
this.input = el;
|
|
275
254
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -303,7 +282,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
303
282
|
"helpText": [1, "help-text"],
|
|
304
283
|
"valid": [1028],
|
|
305
284
|
"invalid": [1028],
|
|
306
|
-
"
|
|
285
|
+
"classCollection": [32],
|
|
307
286
|
"errorMessage": [32],
|
|
308
287
|
"options": [32],
|
|
309
288
|
"valueExist": [32],
|