@mgdis/mg-components 5.10.0 → 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 +318 -427
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +19 -28
- package/dist/cjs/{mg-menu.conf-1942ac70.js → mg-menu.conf-196151fe.js} +16 -16
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +8 -9
- package/dist/collection/components/atoms/mg-button/mg-button.js +16 -20
- package/dist/collection/components/atoms/mg-card/mg-card.js +10 -12
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +1 -2
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +17 -19
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -2
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +11 -13
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +11 -21
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +26 -18
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +10 -14
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +7 -12
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +14 -22
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +6 -10
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -18
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +21 -32
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +16 -31
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +13 -17
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +17 -23
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +11 -18
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +20 -29
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +11 -15
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -3
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -19
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -2
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +4 -7
- package/dist/collection/components/molecules/mg-message/mg-message.js +11 -14
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +7 -11
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +11 -13
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +6 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +7 -13
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +2 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +20 -24
- package/dist/collection/locales/index.js +2 -2
- package/dist/collection/utils/behaviors.utils.js +16 -22
- package/dist/collection/utils/components.utils.js +21 -23
- package/dist/collection/utils/locale.utils.js +14 -14
- package/dist/collection/utils/unit.test.utils.js +7 -10
- package/dist/components/MgInput.js +30 -18
- package/dist/components/components.utils.js +21 -23
- package/dist/components/index2.js +16 -16
- package/dist/components/mg-action-more.js +9 -13
- package/dist/components/mg-badge2.js +8 -9
- package/dist/components/mg-button2.js +16 -20
- package/dist/components/mg-card2.js +8 -10
- package/dist/components/mg-character-left2.js +1 -2
- package/dist/components/mg-details.js +1 -3
- package/dist/components/mg-divider.js +1 -1
- package/dist/components/mg-form.js +7 -15
- package/dist/components/mg-icon2.js +17 -19
- package/dist/components/mg-illustrated-message.js +1 -2
- package/dist/components/mg-input-checkbox.js +9 -10
- package/dist/components/mg-input-date.js +6 -8
- package/dist/components/mg-input-numeric.js +13 -18
- package/dist/components/mg-input-password.js +5 -6
- package/dist/components/mg-input-radio.js +9 -14
- package/dist/components/mg-input-select2.js +20 -28
- package/dist/components/mg-input-text2.js +14 -23
- package/dist/components/mg-input-textarea.js +12 -13
- package/dist/components/mg-input-title2.js +1 -2
- package/dist/components/mg-input-toggle.js +16 -19
- package/dist/components/mg-item-more.js +18 -27
- package/dist/components/mg-menu-item2.js +17 -26
- package/dist/components/mg-menu2.js +9 -16
- package/dist/components/mg-message.js +11 -14
- package/dist/components/mg-modal.js +7 -11
- package/dist/components/mg-pagination.js +11 -13
- package/dist/components/mg-panel.js +6 -15
- package/dist/components/mg-popover2.js +7 -13
- package/dist/components/mg-skip-links.js +2 -4
- package/dist/components/mg-tabs.js +20 -24
- package/dist/components/mg-tag.js +11 -13
- package/dist/components/mg-tooltip2.js +11 -21
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_31.entry.js +318 -427
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +19 -28
- package/dist/esm/{mg-menu.conf-2cc1bb67.js → mg-menu.conf-9ca023ee.js} +16 -16
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-a56a3157.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 -3
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +5 -9
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +2 -6
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -2
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +3 -5
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -2
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +3 -5
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -21
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -1
- package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -5
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -6
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -6
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +7 -14
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +3 -4
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -10
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +9 -13
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +3 -12
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -5
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -6
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +10 -18
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +21 -31
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +3 -10
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +1 -3
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -11
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +1 -2
- package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +2 -7
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +4 -7
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -7
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +5 -9
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +4 -13
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +3 -9
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +2 -4
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +15 -19
- package/dist/types/components.d.ts +22 -34
- package/dist/types/locales/index.d.ts +2 -2
- package/dist/types/utils/behaviors.utils.d.ts +14 -20
- package/dist/types/utils/components.utils.d.ts +18 -20
- package/dist/types/utils/locale.utils.d.ts +14 -14
- package/dist/types/utils/unit.test.utils.d.ts +11 -17
- package/package.json +1 -1
- package/dist/mg-components/p-eb32bb18.entry.js +0 -1
- /package/dist/mg-components/{p-73156ac9.js → p-0d3146d9.js} +0 -0
|
@@ -10,8 +10,8 @@ const mgInputCheckboxCss = ":host{display:block}.mg-input{display:flex;align-ite
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* type CheckboxItem validation function
|
|
13
|
-
* @param
|
|
14
|
-
* @returns
|
|
13
|
+
* @param items - Checkbox item
|
|
14
|
+
* @returns match item type
|
|
15
15
|
*/
|
|
16
16
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
17
17
|
items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
|
|
@@ -31,7 +31,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
31
31
|
this.hasDisplayedError = false;
|
|
32
32
|
/**
|
|
33
33
|
* Handle input event
|
|
34
|
-
* @param
|
|
34
|
+
* @param event - input event
|
|
35
35
|
*/
|
|
36
36
|
this.handleInput = (event) => {
|
|
37
37
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -53,7 +53,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
55
|
* get invalid element
|
|
56
|
-
* @returns
|
|
56
|
+
* @returns element
|
|
57
57
|
*/
|
|
58
58
|
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
59
59
|
/**
|
|
@@ -90,7 +90,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
90
90
|
this.helpText = undefined;
|
|
91
91
|
this.valid = undefined;
|
|
92
92
|
this.invalid = undefined;
|
|
93
|
-
this.
|
|
93
|
+
this.classCollection = new ClassList(['mg-input--checkbox']);
|
|
94
94
|
this.errorMessage = undefined;
|
|
95
95
|
this.checkboxItems = [];
|
|
96
96
|
}
|
|
@@ -120,7 +120,6 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* Public method to display errors
|
|
123
|
-
* @returns {Promise<void>}
|
|
124
123
|
*/
|
|
125
124
|
async displayError() {
|
|
126
125
|
this.checkValidity();
|
|
@@ -132,7 +131,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
132
131
|
*************/
|
|
133
132
|
/**
|
|
134
133
|
* Check if component props are well configured on init
|
|
135
|
-
* @returns
|
|
134
|
+
* @returns timeout
|
|
136
135
|
*/
|
|
137
136
|
componentWillLoad() {
|
|
138
137
|
// Get locales
|
|
@@ -148,10 +147,10 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
148
147
|
}
|
|
149
148
|
/**
|
|
150
149
|
* Render
|
|
151
|
-
* @returns
|
|
150
|
+
* @returns HTML Element
|
|
152
151
|
*/
|
|
153
152
|
render() {
|
|
154
|
-
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
|
|
155
154
|
.filter(item => {
|
|
156
155
|
return !this.readonly || item.value;
|
|
157
156
|
})
|
|
@@ -183,7 +182,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
183
182
|
"helpText": [1, "help-text"],
|
|
184
183
|
"valid": [1028],
|
|
185
184
|
"invalid": [1028],
|
|
186
|
-
"
|
|
185
|
+
"classCollection": [32],
|
|
187
186
|
"errorMessage": [32],
|
|
188
187
|
"checkboxItems": [32],
|
|
189
188
|
"displayError": [64]
|
|
@@ -53,7 +53,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
55
|
* get input error code
|
|
56
|
-
* @returns
|
|
56
|
+
* @returns error code
|
|
57
57
|
*/
|
|
58
58
|
this.getInputError = () => {
|
|
59
59
|
var _a, _b;
|
|
@@ -78,7 +78,6 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
78
78
|
};
|
|
79
79
|
/**
|
|
80
80
|
* Check input errors
|
|
81
|
-
* @returns {void}
|
|
82
81
|
*/
|
|
83
82
|
this.setErrorMessage = () => {
|
|
84
83
|
var _a;
|
|
@@ -116,7 +115,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
116
115
|
this.invalid = undefined;
|
|
117
116
|
this.min = undefined;
|
|
118
117
|
this.max = undefined;
|
|
119
|
-
this.
|
|
118
|
+
this.classCollection = new ClassList(['mg-input--date']);
|
|
120
119
|
this.errorMessage = undefined;
|
|
121
120
|
}
|
|
122
121
|
validateValue(newValue) {
|
|
@@ -147,7 +146,6 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
147
146
|
}
|
|
148
147
|
/**
|
|
149
148
|
* Public method to display errors
|
|
150
|
-
* @returns {Promise<void>}
|
|
151
149
|
*/
|
|
152
150
|
async displayError() {
|
|
153
151
|
this.checkValidity();
|
|
@@ -159,7 +157,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
159
157
|
*************/
|
|
160
158
|
/**
|
|
161
159
|
* Check if component props are well configured on init
|
|
162
|
-
* @returns
|
|
160
|
+
* @returns timeout
|
|
163
161
|
*/
|
|
164
162
|
componentWillLoad() {
|
|
165
163
|
// Get locales
|
|
@@ -179,10 +177,10 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
179
177
|
}
|
|
180
178
|
/**
|
|
181
179
|
* Render
|
|
182
|
-
* @returns
|
|
180
|
+
* @returns HTML Element
|
|
183
181
|
*/
|
|
184
182
|
render() {
|
|
185
|
-
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 => {
|
|
186
184
|
if (el !== null)
|
|
187
185
|
this.input = el;
|
|
188
186
|
} })));
|
|
@@ -213,7 +211,7 @@ const MgInputDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
213
211
|
"invalid": [1028],
|
|
214
212
|
"min": [1],
|
|
215
213
|
"max": [1],
|
|
216
|
-
"
|
|
214
|
+
"classCollection": [32],
|
|
217
215
|
"errorMessage": [32],
|
|
218
216
|
"displayError": [64]
|
|
219
217
|
}]);
|
|
@@ -31,7 +31,6 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
31
31
|
this.hasDisplayedError = false;
|
|
32
32
|
/**
|
|
33
33
|
* Handle input event
|
|
34
|
-
* @returns {void}
|
|
35
34
|
*/
|
|
36
35
|
this.handleInput = () => {
|
|
37
36
|
// Check validity
|
|
@@ -43,23 +42,22 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
43
42
|
};
|
|
44
43
|
/**
|
|
45
44
|
* Handle focus event
|
|
46
|
-
* @returns {void}
|
|
47
45
|
*/
|
|
48
46
|
this.handleFocus = () => {
|
|
49
47
|
this.hasFocus = true;
|
|
50
48
|
};
|
|
51
49
|
/**
|
|
52
50
|
* Handle blur event
|
|
53
|
-
* @returns {void}
|
|
54
51
|
*/
|
|
55
52
|
this.handleBlur = () => {
|
|
53
|
+
if (this.value === '-')
|
|
54
|
+
this.value = '';
|
|
56
55
|
// Display Error
|
|
57
56
|
this.displayError();
|
|
58
57
|
this.hasFocus = false;
|
|
59
58
|
};
|
|
60
59
|
/**
|
|
61
60
|
* Check if input is valid
|
|
62
|
-
* @returns {void}
|
|
63
61
|
*/
|
|
64
62
|
this.checkValidity = () => {
|
|
65
63
|
this.valid = this.readonly || this.disabled || this.getInputError() === null;
|
|
@@ -69,7 +67,6 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
69
67
|
};
|
|
70
68
|
/**
|
|
71
69
|
* Set input error message
|
|
72
|
-
* @returns {void}
|
|
73
70
|
*/
|
|
74
71
|
this.setErrorMessage = () => {
|
|
75
72
|
// Set error message
|
|
@@ -86,7 +83,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
86
83
|
};
|
|
87
84
|
/**
|
|
88
85
|
* Get input error code
|
|
89
|
-
* @returns
|
|
86
|
+
* @returns error code
|
|
90
87
|
*/
|
|
91
88
|
this.getInputError = () => {
|
|
92
89
|
let inputError = null;
|
|
@@ -114,18 +111,17 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
114
111
|
};
|
|
115
112
|
/**
|
|
116
113
|
* Format value based on type
|
|
117
|
-
* @param
|
|
118
|
-
* @returns
|
|
114
|
+
* @param value - value to format
|
|
115
|
+
* @returns formated local value
|
|
119
116
|
*/
|
|
120
117
|
this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));
|
|
121
118
|
/**
|
|
122
119
|
* Validate append slot
|
|
123
|
-
* @returns {void}
|
|
124
120
|
*/
|
|
125
121
|
this.validateAppendSlot = () => {
|
|
126
122
|
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
127
123
|
if (slotAppendInput !== null) {
|
|
128
|
-
this.
|
|
124
|
+
this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
129
125
|
}
|
|
130
126
|
};
|
|
131
127
|
this.value = undefined;
|
|
@@ -149,7 +145,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
149
145
|
this.decimalLength = 2;
|
|
150
146
|
this.valid = undefined;
|
|
151
147
|
this.invalid = undefined;
|
|
152
|
-
this.
|
|
148
|
+
this.classCollection = new ClassList(['mg-input--numeric']);
|
|
153
149
|
this.errorMessage = undefined;
|
|
154
150
|
this.hasFocus = false;
|
|
155
151
|
}
|
|
@@ -161,7 +157,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
161
157
|
// Regex
|
|
162
158
|
const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+[.,]?\d*$/;
|
|
163
159
|
// Filter input
|
|
164
|
-
if (
|
|
160
|
+
if (['', '-'].includes(newValue) || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
165
161
|
this.storedValue = newValue;
|
|
166
162
|
}
|
|
167
163
|
else if (this.storedValue !== undefined) {
|
|
@@ -208,7 +204,6 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
208
204
|
}
|
|
209
205
|
/**
|
|
210
206
|
* Public method to display errors
|
|
211
|
-
* @returns {Promise<void>}
|
|
212
207
|
*/
|
|
213
208
|
async displayError() {
|
|
214
209
|
this.checkValidity();
|
|
@@ -218,7 +213,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
218
213
|
/**
|
|
219
214
|
* Displayed value in input
|
|
220
215
|
* Change on focus/blur
|
|
221
|
-
* @returns
|
|
216
|
+
* @returns display value
|
|
222
217
|
*/
|
|
223
218
|
displayValue() {
|
|
224
219
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -228,7 +223,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
228
223
|
*************/
|
|
229
224
|
/**
|
|
230
225
|
* Check if component props are well configured on init
|
|
231
|
-
* @returns
|
|
226
|
+
* @returns timeout
|
|
232
227
|
*/
|
|
233
228
|
componentWillLoad() {
|
|
234
229
|
// Get locales
|
|
@@ -251,10 +246,10 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
251
246
|
}
|
|
252
247
|
/**
|
|
253
248
|
* Render
|
|
254
|
-
* @returns
|
|
249
|
+
* @returns HTML Element
|
|
255
250
|
*/
|
|
256
251
|
render() {
|
|
257
|
-
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 => {
|
|
258
253
|
if (el !== null)
|
|
259
254
|
this.input = el;
|
|
260
255
|
} }), h("slot", { name: "append-input" })));
|
|
@@ -292,7 +287,7 @@ const MgInputNumeric$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
292
287
|
"decimalLength": [2, "decimal-length"],
|
|
293
288
|
"valid": [1028],
|
|
294
289
|
"invalid": [1028],
|
|
295
|
-
"
|
|
290
|
+
"classCollection": [32],
|
|
296
291
|
"errorMessage": [32],
|
|
297
292
|
"hasFocus": [32],
|
|
298
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,7 +87,6 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Public method to display errors
|
|
90
|
-
* @returns {Promise<void>}
|
|
91
90
|
*/
|
|
92
91
|
async displayError() {
|
|
93
92
|
this.checkValidity();
|
|
@@ -99,7 +98,7 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
99
98
|
*************/
|
|
100
99
|
/**
|
|
101
100
|
* Check if component props are well configured on init
|
|
102
|
-
* @returns
|
|
101
|
+
* @returns timeout
|
|
103
102
|
*/
|
|
104
103
|
componentWillLoad() {
|
|
105
104
|
// Get locales
|
|
@@ -113,10 +112,10 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
113
112
|
}
|
|
114
113
|
/**
|
|
115
114
|
* Render
|
|
116
|
-
* @returns
|
|
115
|
+
* @returns HTML Element
|
|
117
116
|
*/
|
|
118
117
|
render() {
|
|
119
|
-
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 => {
|
|
120
119
|
if (el !== null)
|
|
121
120
|
this.input = el;
|
|
122
121
|
} })));
|
|
@@ -145,7 +144,7 @@ const MgInputPassword$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
145
144
|
"helpText": [1, "help-text"],
|
|
146
145
|
"valid": [1028],
|
|
147
146
|
"invalid": [1028],
|
|
148
|
-
"
|
|
147
|
+
"classCollection": [32],
|
|
149
148
|
"errorMessage": [32],
|
|
150
149
|
"displayError": [64]
|
|
151
150
|
}]);
|
|
@@ -10,8 +10,8 @@ const mgInputRadioCss = ":host{display:block}.mg-input{display:flex;align-items:
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* type Option validation function
|
|
13
|
-
* @param
|
|
14
|
-
* @returns
|
|
13
|
+
* @param option - radio option
|
|
14
|
+
* @returns radio option type is valid
|
|
15
15
|
*/
|
|
16
16
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
17
17
|
const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
@@ -30,8 +30,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
30
30
|
this.hasDisplayedError = false;
|
|
31
31
|
/**
|
|
32
32
|
* Handle input event
|
|
33
|
-
* @param
|
|
34
|
-
* @returns {void}
|
|
33
|
+
* @param event - input event
|
|
35
34
|
*/
|
|
36
35
|
this.handleInput = (event) => {
|
|
37
36
|
this.checkValidity();
|
|
@@ -39,7 +38,6 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
39
38
|
};
|
|
40
39
|
/**
|
|
41
40
|
* Handle blur event
|
|
42
|
-
* @returns {void}
|
|
43
41
|
*/
|
|
44
42
|
this.handleBlur = () => {
|
|
45
43
|
this.checkValidity();
|
|
@@ -47,7 +45,6 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
47
45
|
};
|
|
48
46
|
/**
|
|
49
47
|
* Check if input is valid
|
|
50
|
-
* @returns {void}
|
|
51
48
|
*/
|
|
52
49
|
this.checkValidity = () => {
|
|
53
50
|
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
@@ -57,7 +54,6 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
57
54
|
};
|
|
58
55
|
/**
|
|
59
56
|
* Set input error message
|
|
60
|
-
* @returns {void}
|
|
61
57
|
*/
|
|
62
58
|
this.setErrorMessage = () => {
|
|
63
59
|
const invalidElement = this.getInvalidElement();
|
|
@@ -69,7 +65,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
69
65
|
};
|
|
70
66
|
/**
|
|
71
67
|
* get invalid element
|
|
72
|
-
* @returns
|
|
68
|
+
* @returns element
|
|
73
69
|
*/
|
|
74
70
|
this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
|
|
75
71
|
this.value = undefined;
|
|
@@ -87,7 +83,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
87
83
|
this.helpText = undefined;
|
|
88
84
|
this.valid = undefined;
|
|
89
85
|
this.invalid = undefined;
|
|
90
|
-
this.
|
|
86
|
+
this.classCollection = new ClassList(['mg-input--radio']);
|
|
91
87
|
this.errorMessage = undefined;
|
|
92
88
|
this.options = undefined;
|
|
93
89
|
}
|
|
@@ -123,7 +119,6 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
123
119
|
}
|
|
124
120
|
/**
|
|
125
121
|
* Public method to display errors
|
|
126
|
-
* @returns {Promise<void>}
|
|
127
122
|
*/
|
|
128
123
|
async displayError() {
|
|
129
124
|
this.checkValidity();
|
|
@@ -135,7 +130,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
135
130
|
*************/
|
|
136
131
|
/**
|
|
137
132
|
* Check if component props are well configured on init
|
|
138
|
-
* @returns
|
|
133
|
+
* @returns timeout
|
|
139
134
|
*/
|
|
140
135
|
componentWillLoad() {
|
|
141
136
|
// Get locales
|
|
@@ -151,10 +146,10 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
151
146
|
}
|
|
152
147
|
/**
|
|
153
148
|
* Render
|
|
154
|
-
* @returns
|
|
149
|
+
* @returns HTML Element
|
|
155
150
|
*/
|
|
156
151
|
render() {
|
|
157
|
-
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 => {
|
|
158
153
|
if (el !== null)
|
|
159
154
|
this.inputs[index] = el;
|
|
160
155
|
} }), h("label", { htmlFor: this.identifier + '_' + index }, input.title)))))));
|
|
@@ -184,7 +179,7 @@ const MgInputRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
|
184
179
|
"helpText": [1, "help-text"],
|
|
185
180
|
"valid": [1028],
|
|
186
181
|
"invalid": [1028],
|
|
187
|
-
"
|
|
182
|
+
"classCollection": [32],
|
|
188
183
|
"errorMessage": [32],
|
|
189
184
|
"options": [32],
|
|
190
185
|
"displayError": [64]
|
|
@@ -10,31 +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
|
-
* @param
|
|
14
|
-
* @returns
|
|
13
|
+
* @param option - select option
|
|
14
|
+
* @returns select option type is valid
|
|
15
15
|
*/
|
|
16
16
|
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
17
17
|
/**
|
|
18
18
|
* Check if items[] is SelectOption
|
|
19
|
-
* @param
|
|
20
|
-
* @returns
|
|
19
|
+
* @param items - select option
|
|
20
|
+
* @returns select option array type is valid
|
|
21
21
|
*/
|
|
22
22
|
const allItemsAreOptions = (items) => Array.isArray(items) && items.every(item => isOption(item));
|
|
23
23
|
/**
|
|
24
24
|
* Check if item is a well configured optgroup
|
|
25
|
-
* @param
|
|
26
|
-
* @returns
|
|
25
|
+
* @param optgroup - select option
|
|
26
|
+
* @returns select optgroup type is valid
|
|
27
27
|
*/
|
|
28
28
|
const isOptGroup = (optgroup) => typeof optgroup === 'object' && typeof optgroup.group === 'string' && allItemsAreOptions(optgroup.options);
|
|
29
29
|
/**
|
|
30
30
|
* Group options
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @
|
|
34
|
-
* @param {string} item.title item title
|
|
35
|
-
* @param {unknown} item.value item value
|
|
36
|
-
* @param {boolean} item.disabled is item disabled
|
|
37
|
-
* @returns {(SelectOption | OptGroup)[]} grouped options
|
|
31
|
+
* @param acc - reduce accumulator
|
|
32
|
+
* @param item - item to add
|
|
33
|
+
* @returns grouped options
|
|
38
34
|
*/
|
|
39
35
|
const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
40
36
|
if (group !== undefined) {
|
|
@@ -65,7 +61,6 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
65
61
|
this.hasDisplayedError = false;
|
|
66
62
|
/**
|
|
67
63
|
* Handle input event
|
|
68
|
-
* @returns {void}
|
|
69
64
|
*/
|
|
70
65
|
this.handleInput = () => {
|
|
71
66
|
this.updateValue();
|
|
@@ -74,14 +69,13 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
74
69
|
};
|
|
75
70
|
/**
|
|
76
71
|
* Method to compare item.title with input.value
|
|
77
|
-
* @param
|
|
78
|
-
* @returns
|
|
72
|
+
* @param item - item to compare with
|
|
73
|
+
* @returns truthy if input.value is an item
|
|
79
74
|
*/
|
|
80
75
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
81
76
|
/**
|
|
82
77
|
* value props setter
|
|
83
|
-
* @param
|
|
84
|
-
* @returns {void}
|
|
78
|
+
* @param newValue - value to update with
|
|
85
79
|
*/
|
|
86
80
|
this.setValue = (newValue) => {
|
|
87
81
|
this.checkValidity();
|
|
@@ -89,7 +83,6 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
89
83
|
};
|
|
90
84
|
/**
|
|
91
85
|
* Update value from input.value
|
|
92
|
-
* @returns {void}
|
|
93
86
|
*/
|
|
94
87
|
this.updateValue = () => {
|
|
95
88
|
if (this.input.value === '') {
|
|
@@ -115,7 +108,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
115
108
|
};
|
|
116
109
|
/**
|
|
117
110
|
* Input value is disabled
|
|
118
|
-
* @returns
|
|
111
|
+
* @returns truthy if input value is disabled
|
|
119
112
|
*/
|
|
120
113
|
this.isDisabledValue = () => { var _a; return allItemsAreOptions(this.options) && ((_a = this.options.find(this.isInputValue)) === null || _a === void 0 ? void 0 : _a.disabled) === true; };
|
|
121
114
|
/**
|
|
@@ -140,8 +133,8 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
140
133
|
};
|
|
141
134
|
/**
|
|
142
135
|
* Render option
|
|
143
|
-
* @param
|
|
144
|
-
* @returns
|
|
136
|
+
* @param option - to render
|
|
137
|
+
* @returns render option
|
|
145
138
|
*/
|
|
146
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));
|
|
147
140
|
this.value = undefined;
|
|
@@ -162,7 +155,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
162
155
|
this.helpText = undefined;
|
|
163
156
|
this.valid = undefined;
|
|
164
157
|
this.invalid = undefined;
|
|
165
|
-
this.
|
|
158
|
+
this.classCollection = new ClassList(['mg-input--select']);
|
|
166
159
|
this.errorMessage = undefined;
|
|
167
160
|
this.options = undefined;
|
|
168
161
|
this.valueExist = undefined;
|
|
@@ -220,7 +213,6 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
220
213
|
}
|
|
221
214
|
/**
|
|
222
215
|
* Public method to display errors
|
|
223
|
-
* @returns {Promise<void>}
|
|
224
216
|
*/
|
|
225
217
|
async displayError() {
|
|
226
218
|
this.checkValidity();
|
|
@@ -232,7 +224,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
232
224
|
*************/
|
|
233
225
|
/**
|
|
234
226
|
* Check if component props are well configured on init
|
|
235
|
-
* @returns
|
|
227
|
+
* @returns timeout
|
|
236
228
|
*/
|
|
237
229
|
componentWillLoad() {
|
|
238
230
|
// Get locales
|
|
@@ -253,10 +245,10 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
253
245
|
}
|
|
254
246
|
/**
|
|
255
247
|
* Render
|
|
256
|
-
* @returns
|
|
248
|
+
* @returns HTML Element
|
|
257
249
|
*/
|
|
258
250
|
render() {
|
|
259
|
-
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 => {
|
|
260
252
|
if (el !== null)
|
|
261
253
|
this.input = el;
|
|
262
254
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -290,7 +282,7 @@ const MgInputSelect = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
290
282
|
"helpText": [1, "help-text"],
|
|
291
283
|
"valid": [1028],
|
|
292
284
|
"invalid": [1028],
|
|
293
|
-
"
|
|
285
|
+
"classCollection": [32],
|
|
294
286
|
"errorMessage": [32],
|
|
295
287
|
"options": [32],
|
|
296
288
|
"valueExist": [32],
|