@mgdis/mg-components 5.10.0 → 5.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-9e1091ab.js → index-03d2557d.js} +3 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_31.cjs.entry.js +444 -455
- package/dist/cjs/mg-components.cjs.js +2 -2
- package/dist/cjs/mg-item-more.cjs.entry.js +20 -29
- package/dist/cjs/{mg-menu.conf-1942ac70.js → mg-menu.conf-05ec32a3.js} +30 -16
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +8 -9
- package/dist/collection/components/atoms/mg-button/mg-button.js +16 -20
- package/dist/collection/components/atoms/mg-card/mg-card.css +2 -0
- package/dist/collection/components/atoms/mg-card/mg-card.js +10 -12
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +1 -2
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +17 -19
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -2
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +11 -13
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +20 -25
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +26 -18
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +4 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +18 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +126 -19
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +7 -12
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +14 -22
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +6 -10
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -18
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +21 -32
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +16 -31
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +13 -17
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +17 -23
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +11 -18
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +20 -29
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +11 -15
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -3
- package/dist/collection/components/molecules/mg-form/mg-form.js +8 -19
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -2
- package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +4 -7
- package/dist/collection/components/molecules/mg-message/mg-message.css +1 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +11 -14
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +1 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +7 -11
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +11 -13
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +6 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +16 -16
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +2 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +20 -24
- package/dist/collection/locales/en/messages.json +7 -0
- package/dist/collection/locales/fr/messages.json +7 -0
- package/dist/collection/locales/index.js +2 -2
- package/dist/collection/styles/reset-mg-card-slotted-variables.scss +1 -0
- package/dist/collection/utils/behaviors.utils.js +16 -22
- package/dist/collection/utils/components.utils.js +21 -23
- package/dist/collection/utils/locale.utils.js +14 -14
- package/dist/collection/utils/unit.test.utils.js +7 -10
- package/dist/components/MgInput.js +30 -18
- package/dist/components/components.utils.js +21 -23
- package/dist/components/index2.js +30 -16
- package/dist/components/mg-action-more.js +9 -13
- package/dist/components/mg-badge2.js +8 -9
- package/dist/components/mg-button2.js +16 -20
- package/dist/components/mg-card2.js +9 -11
- package/dist/components/mg-character-left2.js +1 -2
- package/dist/components/mg-details.js +1 -3
- package/dist/components/mg-divider.js +1 -1
- package/dist/components/mg-form.js +7 -15
- package/dist/components/mg-icon2.js +17 -19
- package/dist/components/mg-illustrated-message.js +1 -2
- package/dist/components/mg-input-checkbox.js +126 -21
- package/dist/components/mg-input-date.js +7 -9
- package/dist/components/mg-input-numeric.js +14 -19
- package/dist/components/mg-input-password.js +6 -7
- package/dist/components/mg-input-radio.js +10 -15
- package/dist/components/mg-input-select2.js +21 -29
- package/dist/components/mg-input-text2.js +15 -24
- package/dist/components/mg-input-textarea.js +13 -14
- package/dist/components/mg-input-title2.js +1 -2
- package/dist/components/mg-input-toggle.js +17 -20
- package/dist/components/mg-item-more.js +18 -27
- package/dist/components/mg-menu-item2.js +17 -26
- package/dist/components/mg-menu2.js +9 -16
- package/dist/components/mg-message.js +12 -15
- package/dist/components/mg-modal.js +8 -12
- package/dist/components/mg-pagination.js +11 -13
- package/dist/components/mg-panel.js +7 -16
- package/dist/components/mg-popover2.js +17 -17
- package/dist/components/mg-skip-links.js +2 -4
- package/dist/components/mg-tabs.js +20 -24
- package/dist/components/mg-tag.js +11 -13
- package/dist/components/mg-tooltip2.js +20 -25
- package/dist/esm/{index-3249671d.js → index-407d5211.js} +3 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_31.entry.js +444 -455
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-item-more.entry.js +20 -29
- package/dist/esm/{mg-menu.conf-2cc1bb67.js → mg-menu.conf-c8aa56ce.js} +30 -16
- package/dist/mg-components/locales/en/messages.json +7 -0
- package/dist/mg-components/locales/fr/messages.json +7 -0
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-3bf533f7.js +2 -0
- package/dist/mg-components/p-51c2def3.entry.js +1 -0
- package/dist/mg-components/p-b14be68b.js +1 -0
- package/dist/mg-components/{p-a56a3157.entry.js → p-d3ed97d3.entry.js} +1 -1
- package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +1 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +2 -3
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +5 -9
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +2 -6
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -2
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +3 -5
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -2
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +3 -5
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +15 -21
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -1
- package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -5
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +8 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +40 -7
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -6
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +7 -14
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +3 -4
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -10
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +9 -13
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +3 -12
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -5
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -6
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +10 -18
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +21 -31
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +3 -10
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +1 -3
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -11
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +1 -2
- package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +2 -7
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +4 -7
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -7
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +5 -9
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +4 -13
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +7 -9
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +2 -4
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +15 -19
- package/dist/types/components.d.ts +31 -35
- package/dist/types/locales/index.d.ts +16 -2
- package/dist/types/utils/behaviors.utils.d.ts +14 -20
- package/dist/types/utils/components.utils.d.ts +18 -20
- package/dist/types/utils/locale.utils.d.ts +14 -14
- package/dist/types/utils/unit.test.utils.d.ts +11 -17
- package/package.json +4 -4
- package/dist/mg-components/p-73156ac9.js +0 -1
- package/dist/mg-components/p-8fbc0d87.js +0 -2
- package/dist/mg-components/p-eb32bb18.entry.js +0 -1
|
@@ -3,10 +3,11 @@ import { h } from '@stencil/core';
|
|
|
3
3
|
import { MgInput } from '../MgInput';
|
|
4
4
|
import { ClassList } from '../../../../utils/components.utils';
|
|
5
5
|
import { initLocales } from '../../../../locales';
|
|
6
|
+
import { checkboxTypes } from './mg-input-checkbox.conf';
|
|
6
7
|
/**
|
|
7
8
|
* type CheckboxItem validation function
|
|
8
|
-
* @param
|
|
9
|
-
* @returns
|
|
9
|
+
* @param items - Checkbox item
|
|
10
|
+
* @returns match item type
|
|
10
11
|
*/
|
|
11
12
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
12
13
|
items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
|
|
@@ -19,9 +20,11 @@ export class MgInputCheckbox {
|
|
|
19
20
|
this.inputs = [];
|
|
20
21
|
// hasDisplayedError (triggered by blur event)
|
|
21
22
|
this.hasDisplayedError = false;
|
|
23
|
+
// style
|
|
24
|
+
this.baseClassName = 'mg-input--checkbox';
|
|
22
25
|
/**
|
|
23
26
|
* Handle input event
|
|
24
|
-
* @param
|
|
27
|
+
* @param event - input event
|
|
25
28
|
*/
|
|
26
29
|
this.handleInput = (event) => {
|
|
27
30
|
this.checkboxItems = this.checkboxItems.map(item => {
|
|
@@ -33,6 +36,21 @@ export class MgInputCheckbox {
|
|
|
33
36
|
this.value = this.checkboxItems.map(o => ({ value: o.value, title: o.title, disabled: o.disabled }));
|
|
34
37
|
this.checkValidity();
|
|
35
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Keyboard handler
|
|
41
|
+
* @param event - to trak "tab" key
|
|
42
|
+
*/
|
|
43
|
+
this.handleKeydown = (event) => {
|
|
44
|
+
var _a;
|
|
45
|
+
// track "Tab" key event when popover display (is "multi" type selected)
|
|
46
|
+
if (event.key === 'Tab' && ((_a = this.popover) === null || _a === void 0 ? void 0 : _a.display)) {
|
|
47
|
+
const enableInputs = this.checkboxItems.filter(input => !input.disabled).map(({ id }) => id);
|
|
48
|
+
const originInputIndex = enableInputs.findIndex(id => id === event.target.id);
|
|
49
|
+
// close popover when tab trigger focus outside its DOM
|
|
50
|
+
if ((originInputIndex + 1 >= enableInputs.length && !event.shiftKey) || (originInputIndex === 0 && event.shiftKey))
|
|
51
|
+
this.popover.display = false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
36
54
|
/**
|
|
37
55
|
* Handle blur event
|
|
38
56
|
*/
|
|
@@ -43,7 +61,7 @@ export class MgInputCheckbox {
|
|
|
43
61
|
};
|
|
44
62
|
/**
|
|
45
63
|
* get invalid element
|
|
46
|
-
* @returns
|
|
64
|
+
* @returns element
|
|
47
65
|
*/
|
|
48
66
|
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
49
67
|
/**
|
|
@@ -55,6 +73,19 @@ export class MgInputCheckbox {
|
|
|
55
73
|
// We need to send valid event even if it is the same value
|
|
56
74
|
this.inputValid.emit(this.valid);
|
|
57
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Render button text
|
|
78
|
+
* @param selectedValuesNb - nb of selected values
|
|
79
|
+
* @returns translated message
|
|
80
|
+
*/
|
|
81
|
+
this.renderButtonText = (selectedValuesNb) => {
|
|
82
|
+
let messageKey = 'editButton';
|
|
83
|
+
if (this.disabled)
|
|
84
|
+
messageKey = 'showButton';
|
|
85
|
+
else if (selectedValuesNb < 1)
|
|
86
|
+
messageKey = 'selectButton';
|
|
87
|
+
return this.messages.input.checkbox[messageKey];
|
|
88
|
+
};
|
|
58
89
|
/**
|
|
59
90
|
* Set input error message
|
|
60
91
|
*/
|
|
@@ -66,7 +97,13 @@ export class MgInputCheckbox {
|
|
|
66
97
|
this.errorMessage = this.messages.errors.required;
|
|
67
98
|
}
|
|
68
99
|
};
|
|
100
|
+
/**
|
|
101
|
+
* Method to get mg-popover identifier
|
|
102
|
+
* @returns MgPopover identifier
|
|
103
|
+
*/
|
|
104
|
+
this.getMgPopoverIdentifier = () => `${this.identifier}-input-mg-popover`;
|
|
69
105
|
this.value = undefined;
|
|
106
|
+
this.type = checkboxTypes[0];
|
|
70
107
|
this.identifier = undefined;
|
|
71
108
|
this.name = this.identifier;
|
|
72
109
|
this.label = undefined;
|
|
@@ -80,14 +117,14 @@ export class MgInputCheckbox {
|
|
|
80
117
|
this.helpText = undefined;
|
|
81
118
|
this.valid = undefined;
|
|
82
119
|
this.invalid = undefined;
|
|
83
|
-
this.
|
|
120
|
+
this.classCollection = new ClassList([this.baseClassName]);
|
|
84
121
|
this.errorMessage = undefined;
|
|
85
122
|
this.checkboxItems = [];
|
|
86
123
|
}
|
|
87
124
|
validateValue(newValue) {
|
|
88
125
|
if (isCheckboxItems(newValue)) {
|
|
89
126
|
this.checkboxItems = newValue.map((item, index) => ({
|
|
90
|
-
id: `${this.identifier}_${index
|
|
127
|
+
id: `${this.identifier}_${index}`,
|
|
91
128
|
title: item.title,
|
|
92
129
|
value: item.value,
|
|
93
130
|
disabled: item.disabled,
|
|
@@ -98,6 +135,18 @@ export class MgInputCheckbox {
|
|
|
98
135
|
throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
|
|
99
136
|
}
|
|
100
137
|
}
|
|
138
|
+
validateType(newValue) {
|
|
139
|
+
if (!checkboxTypes.includes(newValue)) {
|
|
140
|
+
throw new Error('<mg-input-checkbox> prop "type" must be a CheckboxType.');
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const className = `${this.baseClassName}-multi`;
|
|
144
|
+
if (newValue === 'multi')
|
|
145
|
+
this.classCollection.add(className);
|
|
146
|
+
else
|
|
147
|
+
this.classCollection.delete(className);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
101
150
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
102
151
|
this.inputs.forEach(input => {
|
|
103
152
|
input[prop] = newValue;
|
|
@@ -108,9 +157,15 @@ export class MgInputCheckbox {
|
|
|
108
157
|
this.hasDisplayedError = false;
|
|
109
158
|
}
|
|
110
159
|
}
|
|
160
|
+
validateDisabled(newValue) {
|
|
161
|
+
const className = `${this.baseClassName}-multi-disabled`;
|
|
162
|
+
if (newValue && this.type === 'multi')
|
|
163
|
+
this.classCollection.add(className);
|
|
164
|
+
else
|
|
165
|
+
this.classCollection.delete(className);
|
|
166
|
+
}
|
|
111
167
|
/**
|
|
112
168
|
* Public method to display errors
|
|
113
|
-
* @returns {Promise<void>}
|
|
114
169
|
*/
|
|
115
170
|
async displayError() {
|
|
116
171
|
this.checkValidity();
|
|
@@ -122,13 +177,17 @@ export class MgInputCheckbox {
|
|
|
122
177
|
*************/
|
|
123
178
|
/**
|
|
124
179
|
* Check if component props are well configured on init
|
|
125
|
-
* @returns
|
|
180
|
+
* @returns timeout
|
|
126
181
|
*/
|
|
127
182
|
componentWillLoad() {
|
|
128
183
|
// Get locales
|
|
129
184
|
this.messages = initLocales(this.element).messages;
|
|
185
|
+
if (this.type === 'multi')
|
|
186
|
+
this.element.dataset.mgPopoverGuard = this.getMgPopoverIdentifier();
|
|
130
187
|
// Validate
|
|
131
188
|
this.validateValue(this.value);
|
|
189
|
+
this.validateDisabled(this.disabled);
|
|
190
|
+
this.validateType(this.type);
|
|
132
191
|
// Check validity when component is ready
|
|
133
192
|
// return a promise to process action only in the FIRST render().
|
|
134
193
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
@@ -137,18 +196,40 @@ export class MgInputCheckbox {
|
|
|
137
196
|
}, 0);
|
|
138
197
|
}
|
|
139
198
|
/**
|
|
140
|
-
*
|
|
141
|
-
* @returns
|
|
199
|
+
* render checkbox multi element
|
|
200
|
+
* @returns html element
|
|
142
201
|
*/
|
|
143
|
-
|
|
144
|
-
|
|
202
|
+
renderCheckboxMulti() {
|
|
203
|
+
const selectedValuesNb = this.checkboxItems.filter(({ value }) => value).length;
|
|
204
|
+
return (h("div", { class: "mg-input__input-container mg-input__input-checkbox-multi" }, h("strong", null, this.messages.input.checkbox[selectedValuesNb > 1 ? 'selectedValues' : 'selectedValue'].replace('{nb}', selectedValuesNb)), h("mg-popover", { arrowHide: true, identifier: this.getMgPopoverIdentifier(), ref: el => {
|
|
205
|
+
if (Boolean(el))
|
|
206
|
+
this.popover = el;
|
|
207
|
+
} }, h("mg-button", { variant: "secondary" }, h("mg-icon", { icon: "list" }), this.renderButtonText(selectedValuesNb)), h("div", { slot: "content" }, this.renderCheckboxes()))));
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Render checkbox element
|
|
211
|
+
* @returns HTML Element
|
|
212
|
+
*/
|
|
213
|
+
renderCheckboxes() {
|
|
214
|
+
return (h("ul", { class: {
|
|
215
|
+
'mg-input__input-group-container': true,
|
|
216
|
+
'mg-input__input-group-container--vertical': this.inputVerticalList || (this.type === 'multi' && !this.readonly),
|
|
217
|
+
'mg-input__input-checkbox-multi-inputs': this.type === 'multi' && !this.readonly,
|
|
218
|
+
}, role: "list" }, this.checkboxItems
|
|
145
219
|
.filter(item => {
|
|
146
220
|
return !this.readonly || item.value;
|
|
147
221
|
})
|
|
148
|
-
.map((input, index) => (h("li", { key: input.id, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
222
|
+
.map((input, index) => (h("li", { key: input.id, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeydown, ref: el => {
|
|
149
223
|
if (el !== null)
|
|
150
224
|
this.inputs[index] = el;
|
|
151
|
-
} }), h("label", { htmlFor: input.id }, input.title))))))
|
|
225
|
+
} }), h("label", { htmlFor: input.id }, input.title))))));
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Render
|
|
229
|
+
* @returns HTML Element
|
|
230
|
+
*/
|
|
231
|
+
render() {
|
|
232
|
+
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 }, this.type === 'checkbox' || this.readonly ? this.renderCheckboxes() : this.renderCheckboxMulti()));
|
|
152
233
|
}
|
|
153
234
|
static get is() { return "mg-input-checkbox"; }
|
|
154
235
|
static get encapsulation() { return "shadow"; }
|
|
@@ -184,6 +265,29 @@ export class MgInputCheckbox {
|
|
|
184
265
|
"text": "Component value\nIf item.value is `null`, checkbox will be indeterminate by default\nRequired"
|
|
185
266
|
}
|
|
186
267
|
},
|
|
268
|
+
"type": {
|
|
269
|
+
"type": "string",
|
|
270
|
+
"mutable": false,
|
|
271
|
+
"complexType": {
|
|
272
|
+
"original": "CheckboxType",
|
|
273
|
+
"resolved": "\"checkbox\" | \"multi\"",
|
|
274
|
+
"references": {
|
|
275
|
+
"CheckboxType": {
|
|
276
|
+
"location": "import",
|
|
277
|
+
"path": "./mg-input-checkbox.conf"
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
"required": false,
|
|
282
|
+
"optional": false,
|
|
283
|
+
"docs": {
|
|
284
|
+
"tags": [],
|
|
285
|
+
"text": "Define checkbox type"
|
|
286
|
+
},
|
|
287
|
+
"attribute": "type",
|
|
288
|
+
"reflect": false,
|
|
289
|
+
"defaultValue": "checkboxTypes[0]"
|
|
290
|
+
},
|
|
187
291
|
"identifier": {
|
|
188
292
|
"type": "string",
|
|
189
293
|
"mutable": false,
|
|
@@ -415,7 +519,7 @@ export class MgInputCheckbox {
|
|
|
415
519
|
}
|
|
416
520
|
static get states() {
|
|
417
521
|
return {
|
|
418
|
-
"
|
|
522
|
+
"classCollection": {},
|
|
419
523
|
"errorMessage": {},
|
|
420
524
|
"checkboxItems": {}
|
|
421
525
|
};
|
|
@@ -476,10 +580,7 @@ export class MgInputCheckbox {
|
|
|
476
580
|
},
|
|
477
581
|
"docs": {
|
|
478
582
|
"text": "Public method to display errors",
|
|
479
|
-
"tags": [
|
|
480
|
-
"name": "returns",
|
|
481
|
-
"text": undefined
|
|
482
|
-
}]
|
|
583
|
+
"tags": []
|
|
483
584
|
}
|
|
484
585
|
}
|
|
485
586
|
};
|
|
@@ -489,6 +590,9 @@ export class MgInputCheckbox {
|
|
|
489
590
|
return [{
|
|
490
591
|
"propName": "value",
|
|
491
592
|
"methodName": "validateValue"
|
|
593
|
+
}, {
|
|
594
|
+
"propName": "type",
|
|
595
|
+
"methodName": "validateType"
|
|
492
596
|
}, {
|
|
493
597
|
"propName": "required",
|
|
494
598
|
"methodName": "handleValidityChange"
|
|
@@ -498,6 +602,9 @@ export class MgInputCheckbox {
|
|
|
498
602
|
}, {
|
|
499
603
|
"propName": "disabled",
|
|
500
604
|
"methodName": "handleValidityChange"
|
|
605
|
+
}, {
|
|
606
|
+
"propName": "disabled",
|
|
607
|
+
"methodName": "validateDisabled"
|
|
501
608
|
}];
|
|
502
609
|
}
|
|
503
610
|
}
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
85
85
|
margin-top: 0.5rem;
|
|
86
86
|
}
|
|
87
|
-
.mg-input__input .mg-input__box:disabled, .mg-input__input-group--disabled label, .mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle {
|
|
87
|
+
.mg-input__input .mg-input__box:disabled, .mg-input__input-group--disabled label, .mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle, .mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong {
|
|
88
88
|
opacity: var(--mg-disabled-opacity);
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -36,7 +36,7 @@ export class MgInputDate {
|
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
* get input error code
|
|
39
|
-
* @returns
|
|
39
|
+
* @returns error code
|
|
40
40
|
*/
|
|
41
41
|
this.getInputError = () => {
|
|
42
42
|
var _a, _b;
|
|
@@ -61,7 +61,6 @@ export class MgInputDate {
|
|
|
61
61
|
};
|
|
62
62
|
/**
|
|
63
63
|
* Check input errors
|
|
64
|
-
* @returns {void}
|
|
65
64
|
*/
|
|
66
65
|
this.setErrorMessage = () => {
|
|
67
66
|
var _a;
|
|
@@ -99,7 +98,7 @@ export class MgInputDate {
|
|
|
99
98
|
this.invalid = undefined;
|
|
100
99
|
this.min = undefined;
|
|
101
100
|
this.max = undefined;
|
|
102
|
-
this.
|
|
101
|
+
this.classCollection = new ClassList(['mg-input--date']);
|
|
103
102
|
this.errorMessage = undefined;
|
|
104
103
|
}
|
|
105
104
|
validateValue(newValue) {
|
|
@@ -130,7 +129,6 @@ export class MgInputDate {
|
|
|
130
129
|
}
|
|
131
130
|
/**
|
|
132
131
|
* Public method to display errors
|
|
133
|
-
* @returns {Promise<void>}
|
|
134
132
|
*/
|
|
135
133
|
async displayError() {
|
|
136
134
|
this.checkValidity();
|
|
@@ -142,7 +140,7 @@ export class MgInputDate {
|
|
|
142
140
|
*************/
|
|
143
141
|
/**
|
|
144
142
|
* Check if component props are well configured on init
|
|
145
|
-
* @returns
|
|
143
|
+
* @returns timeout
|
|
146
144
|
*/
|
|
147
145
|
componentWillLoad() {
|
|
148
146
|
// Get locales
|
|
@@ -162,10 +160,10 @@ export class MgInputDate {
|
|
|
162
160
|
}
|
|
163
161
|
/**
|
|
164
162
|
* Render
|
|
165
|
-
* @returns
|
|
163
|
+
* @returns HTML Element
|
|
166
164
|
*/
|
|
167
165
|
render() {
|
|
168
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
166
|
+
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 => {
|
|
169
167
|
if (el !== null)
|
|
170
168
|
this.input = el;
|
|
171
169
|
} })));
|
|
@@ -448,7 +446,7 @@ export class MgInputDate {
|
|
|
448
446
|
}
|
|
449
447
|
static get states() {
|
|
450
448
|
return {
|
|
451
|
-
"
|
|
449
|
+
"classCollection": {},
|
|
452
450
|
"errorMessage": {}
|
|
453
451
|
};
|
|
454
452
|
}
|
|
@@ -500,10 +498,7 @@ export class MgInputDate {
|
|
|
500
498
|
},
|
|
501
499
|
"docs": {
|
|
502
500
|
"text": "Public method to display errors",
|
|
503
|
-
"tags": [
|
|
504
|
-
"name": "returns",
|
|
505
|
-
"text": undefined
|
|
506
|
-
}]
|
|
501
|
+
"tags": []
|
|
507
502
|
}
|
|
508
503
|
}
|
|
509
504
|
};
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
85
85
|
margin-top: 0.5rem;
|
|
86
86
|
}
|
|
87
|
-
.mg-input__input .mg-input__box:disabled, .mg-input__input-group--disabled label, .mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle {
|
|
87
|
+
.mg-input__input .mg-input__box:disabled, .mg-input__input-group--disabled label, .mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle, .mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong {
|
|
88
88
|
opacity: var(--mg-disabled-opacity);
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -10,7 +10,6 @@ export class MgInputNumeric {
|
|
|
10
10
|
this.hasDisplayedError = false;
|
|
11
11
|
/**
|
|
12
12
|
* Handle input event
|
|
13
|
-
* @returns {void}
|
|
14
13
|
*/
|
|
15
14
|
this.handleInput = () => {
|
|
16
15
|
// Check validity
|
|
@@ -22,23 +21,22 @@ export class MgInputNumeric {
|
|
|
22
21
|
};
|
|
23
22
|
/**
|
|
24
23
|
* Handle focus event
|
|
25
|
-
* @returns {void}
|
|
26
24
|
*/
|
|
27
25
|
this.handleFocus = () => {
|
|
28
26
|
this.hasFocus = true;
|
|
29
27
|
};
|
|
30
28
|
/**
|
|
31
29
|
* Handle blur event
|
|
32
|
-
* @returns {void}
|
|
33
30
|
*/
|
|
34
31
|
this.handleBlur = () => {
|
|
32
|
+
if (this.value === '-')
|
|
33
|
+
this.value = '';
|
|
35
34
|
// Display Error
|
|
36
35
|
this.displayError();
|
|
37
36
|
this.hasFocus = false;
|
|
38
37
|
};
|
|
39
38
|
/**
|
|
40
39
|
* Check if input is valid
|
|
41
|
-
* @returns {void}
|
|
42
40
|
*/
|
|
43
41
|
this.checkValidity = () => {
|
|
44
42
|
this.valid = this.readonly || this.disabled || this.getInputError() === null;
|
|
@@ -48,7 +46,6 @@ export class MgInputNumeric {
|
|
|
48
46
|
};
|
|
49
47
|
/**
|
|
50
48
|
* Set input error message
|
|
51
|
-
* @returns {void}
|
|
52
49
|
*/
|
|
53
50
|
this.setErrorMessage = () => {
|
|
54
51
|
// Set error message
|
|
@@ -65,7 +62,7 @@ export class MgInputNumeric {
|
|
|
65
62
|
};
|
|
66
63
|
/**
|
|
67
64
|
* Get input error code
|
|
68
|
-
* @returns
|
|
65
|
+
* @returns error code
|
|
69
66
|
*/
|
|
70
67
|
this.getInputError = () => {
|
|
71
68
|
let inputError = null;
|
|
@@ -93,18 +90,17 @@ export class MgInputNumeric {
|
|
|
93
90
|
};
|
|
94
91
|
/**
|
|
95
92
|
* Format value based on type
|
|
96
|
-
* @param
|
|
97
|
-
* @returns
|
|
93
|
+
* @param value - value to format
|
|
94
|
+
* @returns formated local value
|
|
98
95
|
*/
|
|
99
96
|
this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));
|
|
100
97
|
/**
|
|
101
98
|
* Validate append slot
|
|
102
|
-
* @returns {void}
|
|
103
99
|
*/
|
|
104
100
|
this.validateAppendSlot = () => {
|
|
105
101
|
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
106
102
|
if (slotAppendInput !== null) {
|
|
107
|
-
this.
|
|
103
|
+
this.classCollection.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
108
104
|
}
|
|
109
105
|
};
|
|
110
106
|
this.value = undefined;
|
|
@@ -128,7 +124,7 @@ export class MgInputNumeric {
|
|
|
128
124
|
this.decimalLength = 2;
|
|
129
125
|
this.valid = undefined;
|
|
130
126
|
this.invalid = undefined;
|
|
131
|
-
this.
|
|
127
|
+
this.classCollection = new ClassList(['mg-input--numeric']);
|
|
132
128
|
this.errorMessage = undefined;
|
|
133
129
|
this.hasFocus = false;
|
|
134
130
|
}
|
|
@@ -140,7 +136,7 @@ export class MgInputNumeric {
|
|
|
140
136
|
// Regex
|
|
141
137
|
const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+[.,]?\d*$/;
|
|
142
138
|
// Filter input
|
|
143
|
-
if (
|
|
139
|
+
if (['', '-'].includes(newValue) || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
144
140
|
this.storedValue = newValue;
|
|
145
141
|
}
|
|
146
142
|
else if (this.storedValue !== undefined) {
|
|
@@ -187,7 +183,6 @@ export class MgInputNumeric {
|
|
|
187
183
|
}
|
|
188
184
|
/**
|
|
189
185
|
* Public method to display errors
|
|
190
|
-
* @returns {Promise<void>}
|
|
191
186
|
*/
|
|
192
187
|
async displayError() {
|
|
193
188
|
this.checkValidity();
|
|
@@ -197,7 +192,7 @@ export class MgInputNumeric {
|
|
|
197
192
|
/**
|
|
198
193
|
* Displayed value in input
|
|
199
194
|
* Change on focus/blur
|
|
200
|
-
* @returns
|
|
195
|
+
* @returns display value
|
|
201
196
|
*/
|
|
202
197
|
displayValue() {
|
|
203
198
|
return this.hasFocus ? this.value : this.readonlyValue;
|
|
@@ -207,7 +202,7 @@ export class MgInputNumeric {
|
|
|
207
202
|
*************/
|
|
208
203
|
/**
|
|
209
204
|
* Check if component props are well configured on init
|
|
210
|
-
* @returns
|
|
205
|
+
* @returns timeout
|
|
211
206
|
*/
|
|
212
207
|
componentWillLoad() {
|
|
213
208
|
// Get locales
|
|
@@ -230,10 +225,10 @@ export class MgInputNumeric {
|
|
|
230
225
|
}
|
|
231
226
|
/**
|
|
232
227
|
* Render
|
|
233
|
-
* @returns
|
|
228
|
+
* @returns HTML Element
|
|
234
229
|
*/
|
|
235
230
|
render() {
|
|
236
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
231
|
+
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 => {
|
|
237
232
|
if (el !== null)
|
|
238
233
|
this.input = el;
|
|
239
234
|
} }), h("slot", { name: "append-input" })));
|
|
@@ -627,7 +622,7 @@ export class MgInputNumeric {
|
|
|
627
622
|
}
|
|
628
623
|
static get states() {
|
|
629
624
|
return {
|
|
630
|
-
"
|
|
625
|
+
"classCollection": {},
|
|
631
626
|
"errorMessage": {},
|
|
632
627
|
"hasFocus": {}
|
|
633
628
|
};
|
|
@@ -680,10 +675,7 @@ export class MgInputNumeric {
|
|
|
680
675
|
},
|
|
681
676
|
"docs": {
|
|
682
677
|
"text": "Public method to display errors",
|
|
683
|
-
"tags": [
|
|
684
|
-
"name": "returns",
|
|
685
|
-
"text": undefined
|
|
686
|
-
}]
|
|
678
|
+
"tags": []
|
|
687
679
|
}
|
|
688
680
|
}
|
|
689
681
|
};
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
85
85
|
margin-top: 0.5rem;
|
|
86
86
|
}
|
|
87
|
-
.mg-input__input .mg-input__box:disabled, .mg-input__input-group--disabled label, .mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle {
|
|
87
|
+
.mg-input__input .mg-input__box:disabled, .mg-input__input-group--disabled label, .mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle, .mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong {
|
|
88
88
|
opacity: var(--mg-disabled-opacity);
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -58,7 +58,7 @@ export class MgInputPassword {
|
|
|
58
58
|
this.helpText = undefined;
|
|
59
59
|
this.valid = undefined;
|
|
60
60
|
this.invalid = undefined;
|
|
61
|
-
this.
|
|
61
|
+
this.classCollection = new ClassList(['mg-input--password']);
|
|
62
62
|
this.errorMessage = undefined;
|
|
63
63
|
}
|
|
64
64
|
handleValue(newValue) {
|
|
@@ -76,7 +76,6 @@ export class MgInputPassword {
|
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Public method to display errors
|
|
79
|
-
* @returns {Promise<void>}
|
|
80
79
|
*/
|
|
81
80
|
async displayError() {
|
|
82
81
|
this.checkValidity();
|
|
@@ -88,7 +87,7 @@ export class MgInputPassword {
|
|
|
88
87
|
*************/
|
|
89
88
|
/**
|
|
90
89
|
* Check if component props are well configured on init
|
|
91
|
-
* @returns
|
|
90
|
+
* @returns timeout
|
|
92
91
|
*/
|
|
93
92
|
componentWillLoad() {
|
|
94
93
|
// Get locales
|
|
@@ -102,10 +101,10 @@ export class MgInputPassword {
|
|
|
102
101
|
}
|
|
103
102
|
/**
|
|
104
103
|
* Render
|
|
105
|
-
* @returns
|
|
104
|
+
* @returns HTML Element
|
|
106
105
|
*/
|
|
107
106
|
render() {
|
|
108
|
-
return (h(MgInput, { identifier: this.identifier,
|
|
107
|
+
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 => {
|
|
109
108
|
if (el !== null)
|
|
110
109
|
this.input = el;
|
|
111
110
|
} })));
|
|
@@ -394,7 +393,7 @@ export class MgInputPassword {
|
|
|
394
393
|
}
|
|
395
394
|
static get states() {
|
|
396
395
|
return {
|
|
397
|
-
"
|
|
396
|
+
"classCollection": {},
|
|
398
397
|
"errorMessage": {}
|
|
399
398
|
};
|
|
400
399
|
}
|
|
@@ -446,10 +445,7 @@ export class MgInputPassword {
|
|
|
446
445
|
},
|
|
447
446
|
"docs": {
|
|
448
447
|
"text": "Public method to display errors",
|
|
449
|
-
"tags": [
|
|
450
|
-
"name": "returns",
|
|
451
|
-
"text": undefined
|
|
452
|
-
}]
|
|
448
|
+
"tags": []
|
|
453
449
|
}
|
|
454
450
|
}
|
|
455
451
|
};
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
85
85
|
margin-top: 0.5rem;
|
|
86
86
|
}
|
|
87
|
-
.mg-input__input .mg-input__box:disabled, .mg-input__input-group--disabled label, .mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle {
|
|
87
|
+
.mg-input__input .mg-input__box:disabled, .mg-input__input-group--disabled label, .mg-input.mg-input--toggle-disabled .mg-input__input .mg-input__button-toggle, .mg-input.mg-input--checkbox-multi-disabled .mg-input__input strong {
|
|
88
88
|
opacity: var(--mg-disabled-opacity);
|
|
89
89
|
}
|
|
90
90
|
|