@mgdis/mg-components 5.10.1 → 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 +129 -31
- package/dist/cjs/mg-components.cjs.js +2 -2
- package/dist/cjs/mg-item-more.cjs.entry.js +2 -2
- package/dist/cjs/{mg-menu.conf-196151fe.js → mg-menu.conf-05ec32a3.js} +14 -0
- package/dist/collection/components/atoms/mg-card/mg-card.css +2 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +9 -4
- 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 +118 -7
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.css +1 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +1 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +9 -3
- package/dist/collection/locales/en/messages.json +7 -0
- package/dist/collection/locales/fr/messages.json +7 -0
- package/dist/collection/styles/reset-mg-card-slotted-variables.scss +1 -0
- package/dist/components/index2.js +14 -0
- package/dist/components/mg-card2.js +1 -1
- package/dist/components/mg-input-checkbox.js +119 -13
- package/dist/components/mg-input-date.js +1 -1
- package/dist/components/mg-input-numeric.js +1 -1
- package/dist/components/mg-input-password.js +1 -1
- package/dist/components/mg-input-radio.js +1 -1
- package/dist/components/mg-input-select2.js +1 -1
- package/dist/components/mg-input-text2.js +1 -1
- package/dist/components/mg-input-textarea.js +1 -1
- package/dist/components/mg-input-toggle.js +1 -1
- package/dist/components/mg-message.js +1 -1
- package/dist/components/mg-modal.js +1 -1
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-popover2.js +10 -4
- package/dist/components/mg-tooltip2.js +9 -4
- 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 +129 -31
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-item-more.entry.js +2 -2
- package/dist/esm/{mg-menu.conf-9ca023ee.js → mg-menu.conf-c8aa56ce.js} +14 -0
- 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-97aaca3e.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-tooltip/mg-tooltip.d.ts +4 -0
- 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 +35 -1
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +4 -0
- package/dist/types/components.d.ts +9 -1
- package/dist/types/locales/index.d.ts +14 -0
- package/package.json +4 -4
- package/dist/mg-components/p-0d3146d9.js +0 -1
- package/dist/mg-components/p-8fbc0d87.js +0 -2
- package/dist/mg-components/p-d891e707.entry.js +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-03d2557d.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Stencil Client Patch Browser v2.22.1 | MIT Licensed | https://stenciljs.com
|
|
@@ -17,7 +17,7 @@ const patchBrowser = () => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
patchBrowser().then(options => {
|
|
20
|
-
return index.bootstrapLazy([["mg-action-more_31.cjs",[[1,"mg-action-more",{"icon":[16],"button":[16],"items":[16],"displayChevron":[4,"display-chevron"],"expanded":[32]}],[1,"mg-panel",{"identifier":[1],"panelTitle":[1025,"panel-title"],"titlePattern":[1,"title-pattern"],"titlePatternErrorMessage":[1,"title-pattern-error-message"],"expanded":[1028],"expandToggleDisabled":[4,"expand-toggle-disabled"],"titleEditable":[4,"title-editable"],"classCollection":[32],"isEditing":[32],"updatedPanelTitle":[32]}],[1,"mg-
|
|
20
|
+
return index.bootstrapLazy([["mg-action-more_31.cjs",[[1,"mg-action-more",{"icon":[16],"button":[16],"items":[16],"displayChevron":[4,"display-chevron"],"expanded":[32]}],[1,"mg-panel",{"identifier":[1],"panelTitle":[1025,"panel-title"],"titlePattern":[1,"title-pattern"],"titlePatternErrorMessage":[1,"title-pattern-error-message"],"expanded":[1028],"expandToggleDisabled":[4,"expand-toggle-disabled"],"titleEditable":[4,"title-editable"],"classCollection":[32],"isEditing":[32],"updatedPanelTitle":[32]}],[1,"mg-input-checkbox",{"value":[1040],"type":[1],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"inputVerticalList":[4,"input-vertical-list"],"required":[4],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classCollection":[32],"errorMessage":[32],"checkboxItems":[32],"displayError":[64]}],[1,"mg-pagination",{"identifier":[1],"label":[1025],"hideNavigationLabels":[4,"hide-navigation-labels"],"totalPages":[2,"total-pages"],"currentPage":[1538,"current-page"]}],[1,"mg-input-textarea",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"maxlength":[2],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"pattern":[1],"patternErrorMessage":[1,"pattern-error-message"],"rows":[2],"tooltip":[1],"displayCharacterLeft":[4,"display-character-left"],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"resizable":[1],"classCollection":[32],"errorMessage":[32],"displayError":[64]}],[1,"mg-input-date",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"required":[4],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"min":[1],"max":[1],"classCollection":[32],"errorMessage":[32],"displayError":[64]}],[1,"mg-input-numeric",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"tooltip":[1],"helpText":[1,"help-text"],"type":[1],"currency":[1],"max":[2],"min":[2],"integerLength":[2,"integer-length"],"decimalLength":[2,"decimal-length"],"valid":[1028],"invalid":[1028],"classCollection":[32],"errorMessage":[32],"hasFocus":[32],"displayError":[64]}],[1,"mg-input-password",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classCollection":[32],"errorMessage":[32],"displayError":[64]}],[1,"mg-input-radio",{"value":[1032],"items":[16],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"inputVerticalList":[4,"input-vertical-list"],"required":[4],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classCollection":[32],"errorMessage":[32],"options":[32],"displayError":[64]}],[1,"mg-input-toggle",{"value":[1032],"items":[16],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"isOnOff":[4,"is-on-off"],"isIcon":[4,"is-icon"],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"classCollection":[32],"options":[32],"checked":[32]}],[1,"mg-message",{"identifier":[1],"delay":[2],"variant":[1],"closeButton":[1028,"close-button"],"hide":[1028],"classCollection":[32],"hasActions":[32]}],[1,"mg-modal",{"identifier":[1],"modalTitle":[1,"modal-title"],"closeButton":[4,"close-button"],"hide":[1028],"hasActions":[32],"hasContent":[32],"classCollection":[32]},[[8,"keydown","handleKeyDown"]]],[1,"mg-tabs",{"identifier":[1],"label":[1],"size":[1],"items":[16],"activeTab":[1538,"active-tab"],"tabs":[32],"classCollection":[32]}],[1,"mg-details",{"toggleClosed":[1,"toggle-closed"],"toggleOpened":[1,"toggle-opened"],"hideSummary":[4,"hide-summary"],"expanded":[1028]}],[1,"mg-divider",{"size":[1]}],[1,"mg-form",{"identifier":[1],"name":[1],"readonly":[4],"disabled":[4],"valid":[1028],"invalid":[1028],"classCollection":[32],"requiredMessage":[32],"displayError":[64]}],[1,"mg-illustrated-message",{"size":[1],"direction":[1]}],[1,"mg-skip-links",{"links":[16]}],[1,"mg-tag",{"variant":[1],"outline":[4],"soft":[4],"classCollection":[32]}],[1,"mg-input-text",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"type":[1],"icon":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"maxlength":[2],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"pattern":[1],"patternErrorMessage":[1,"pattern-error-message"],"tooltip":[1],"displayCharacterLeft":[4,"display-character-left"],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classCollection":[32],"errorMessage":[32],"setFocus":[64],"displayError":[64]}],[1,"mg-input-select",{"value":[1032],"items":[16],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1025],"placeholderHide":[4,"placeholder-hide"],"placeholderDisabled":[4,"placeholder-disabled"],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classCollection":[32],"errorMessage":[32],"options":[32],"valueExist":[32],"readonlyValue":[32],"displayError":[64]}],[1,"mg-menu-item",{"identifier":[1],"href":[1],"status":[1537],"expanded":[1028],"size":[32],"navigationButtonClassList":[32],"direction":[32],"isInMainMenu":[32],"isItemMore":[32],"hasChildren":[32],"displayNotificationBadge":[32]}],[1,"mg-menu",{"label":[1],"direction":[513],"itemmore":[16],"size":[1],"isChildMenu":[32]}],[2,"mg-character-left",{"identifier":[1],"characters":[1],"maxlength":[2]}],[1,"mg-popover",{"identifier":[1],"placement":[1],"arrowHide":[4,"arrow-hide"],"closeButton":[4,"close-button"],"display":[1028],"disabled":[4],"classCollection":[32]}],[1,"mg-badge",{"value":[8],"label":[1],"variant":[1],"outline":[4],"classCollection":[32]}],[1,"mg-card",{"variant":[1],"variantStyle":[1025,"variant-style"],"classCollection":[32]}],[1,"mg-button",{"variant":[1],"identifier":[1],"label":[1],"type":[1],"fullWidth":[4,"full-width"],"form":[1],"disabled":[1028],"isIcon":[4,"is-icon"],"disableOnClick":[4,"disable-on-click"],"loading":[32],"classCollection":[32]}],[6,"mg-input-title",{"identifier":[1],"required":[4],"isLegend":[4,"is-legend"],"tagName":[32]}],[1,"mg-tooltip",{"identifier":[1],"message":[1],"placement":[1],"display":[1028],"disabled":[4]}],[1,"mg-icon",{"icon":[1],"size":[1],"variant":[1],"variantStyle":[1025,"variant-style"],"spin":[4],"classCollection":[32]}]]],["mg-item-more.cjs",[[1,"mg-item-more",{"icon":[16],"slotlabel":[16],"size":[1],"parentMenu":[32]}]]]], options);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
exports.setNonce = index.setNonce;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
6
|
-
const mgMenu_conf = require('./mg-menu.conf-
|
|
5
|
+
const index = require('./index-03d2557d.js');
|
|
6
|
+
const mgMenu_conf = require('./mg-menu.conf-05ec32a3.js');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* MgItemMore type guard
|
|
@@ -18,6 +18,13 @@ const nbCharLeft$1 = "{counter} characters left.";
|
|
|
18
18
|
const input$1 = {
|
|
19
19
|
select: {
|
|
20
20
|
placeholder: "Select a value"
|
|
21
|
+
},
|
|
22
|
+
checkbox: {
|
|
23
|
+
selectedValues: "{nb} selected values",
|
|
24
|
+
selectedValue: "{nb} selected value",
|
|
25
|
+
editButton: "Edit",
|
|
26
|
+
selectButton: "Select values",
|
|
27
|
+
showButton: "Show"
|
|
21
28
|
}
|
|
22
29
|
};
|
|
23
30
|
const form$1 = {
|
|
@@ -93,6 +100,13 @@ const nbCharLeft = "{counter} caractères disponibles.";
|
|
|
93
100
|
const input = {
|
|
94
101
|
select: {
|
|
95
102
|
placeholder: "Sélectionnez une valeur"
|
|
103
|
+
},
|
|
104
|
+
checkbox: {
|
|
105
|
+
selectedValues: "{nb} valeurs selectionnées",
|
|
106
|
+
selectedValue: "{nb} valeur selectionnée",
|
|
107
|
+
editButton: "Modifier",
|
|
108
|
+
selectButton: "Sélectionner des valeurs",
|
|
109
|
+
showButton: "Voir"
|
|
96
110
|
}
|
|
97
111
|
};
|
|
98
112
|
const form = {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
position: relative;
|
|
3
3
|
width: 100%;
|
|
4
4
|
max-width: var(--mg-card-max-width);
|
|
5
|
+
min-width: var(--mg-card-min-width);
|
|
5
6
|
padding: var(--mg-card-padding, var(--mg-card-padding-default));
|
|
6
7
|
overflow: var(--mg-card-overflow, var(--mg-card-overflow-default));
|
|
7
8
|
box-sizing: border-box;
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
--mg-card-background: var(--mg-card-background-default);
|
|
19
20
|
--mg-card-box-shadow: var(--mg-card-box-shadow-default);
|
|
20
21
|
--mg-card-max-width: unset;
|
|
22
|
+
--mg-card-min-width: unset;
|
|
21
23
|
}
|
|
22
24
|
.mg-card.mg-card--info {
|
|
23
25
|
overflow: hidden;
|
|
@@ -12,8 +12,6 @@ export class MgTooltip {
|
|
|
12
12
|
this.tooltip.dataset.show = '';
|
|
13
13
|
// Enable the event listeners
|
|
14
14
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
15
|
-
// Update its position
|
|
16
|
-
this.popper.update();
|
|
17
15
|
// hide when click outside
|
|
18
16
|
// setTimeout is used to prevent event to trigger after creation
|
|
19
17
|
setTimeout(() => {
|
|
@@ -50,8 +48,10 @@ export class MgTooltip {
|
|
|
50
48
|
* @param event - keyboard event
|
|
51
49
|
*/
|
|
52
50
|
this.pressEscape = (event) => {
|
|
53
|
-
if (event.code === 'Escape')
|
|
51
|
+
if (event.code === 'Escape') {
|
|
54
52
|
this.setDisplay(false);
|
|
53
|
+
this.resetGuard();
|
|
54
|
+
}
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
57
|
* Method to set display prop
|
|
@@ -170,7 +170,6 @@ export class MgTooltip {
|
|
|
170
170
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
171
171
|
throw new Error('<mg-tooltip> prop "message" is required.');
|
|
172
172
|
}
|
|
173
|
-
this.popper.update();
|
|
174
173
|
}
|
|
175
174
|
handleDisplay(newValue) {
|
|
176
175
|
if (newValue) {
|
|
@@ -224,6 +223,12 @@ export class MgTooltip {
|
|
|
224
223
|
this.handleDisplay(this.display);
|
|
225
224
|
this.validateMessage(this.message);
|
|
226
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* update popper position after props change on component did update hook to benefit from render ended
|
|
228
|
+
*/
|
|
229
|
+
componentDidUpdate() {
|
|
230
|
+
this.popper.update();
|
|
231
|
+
}
|
|
227
232
|
/**
|
|
228
233
|
* Render
|
|
229
234
|
* @returns HTML Element
|
|
@@ -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
|
|
|
@@ -176,4 +176,21 @@ fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container {
|
|
|
176
176
|
animation: none !important;
|
|
177
177
|
transition: none !important;
|
|
178
178
|
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* checkbox multi
|
|
182
|
+
*/
|
|
183
|
+
.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi {
|
|
184
|
+
display: flex;
|
|
185
|
+
flex-wrap: wrap;
|
|
186
|
+
gap: calc(var(--mg-inputs-spacer) * 1.2);
|
|
187
|
+
}
|
|
188
|
+
.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-inputs {
|
|
189
|
+
margin: 0;
|
|
190
|
+
}
|
|
191
|
+
.mg-input.mg-input--checkbox-multi:not(.mg-input--label-on-top) mg-tooltip {
|
|
192
|
+
margin-left: var(--mg-inputs-spacer);
|
|
193
|
+
}
|
|
194
|
+
.mg-input.mg-input--checkbox-multi mg-popover {
|
|
195
|
+
--mg-popover-min-width: 7rem;
|
|
179
196
|
}
|
|
@@ -3,6 +3,7 @@ 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
9
|
* @param items - Checkbox item
|
|
@@ -19,6 +20,8 @@ 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
27
|
* @param event - input event
|
|
@@ -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
|
*/
|
|
@@ -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.classCollection = new ClassList([
|
|
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,6 +157,13 @@ 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
169
|
*/
|
|
@@ -126,8 +182,12 @@ export class MgInputCheckbox {
|
|
|
126
182
|
componentWillLoad() {
|
|
127
183
|
// Get locales
|
|
128
184
|
this.messages = initLocales(this.element).messages;
|
|
185
|
+
if (this.type === 'multi')
|
|
186
|
+
this.element.dataset.mgPopoverGuard = this.getMgPopoverIdentifier();
|
|
129
187
|
// Validate
|
|
130
188
|
this.validateValue(this.value);
|
|
189
|
+
this.validateDisabled(this.disabled);
|
|
190
|
+
this.validateType(this.type);
|
|
131
191
|
// Check validity when component is ready
|
|
132
192
|
// return a promise to process action only in the FIRST render().
|
|
133
193
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
@@ -136,18 +196,40 @@ export class MgInputCheckbox {
|
|
|
136
196
|
}, 0);
|
|
137
197
|
}
|
|
138
198
|
/**
|
|
139
|
-
*
|
|
199
|
+
* render checkbox multi element
|
|
200
|
+
* @returns html element
|
|
201
|
+
*/
|
|
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
|
|
140
211
|
* @returns HTML Element
|
|
141
212
|
*/
|
|
142
|
-
|
|
143
|
-
return (h(
|
|
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
|
|
144
219
|
.filter(item => {
|
|
145
220
|
return !this.readonly || item.value;
|
|
146
221
|
})
|
|
147
|
-
.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 => {
|
|
148
223
|
if (el !== null)
|
|
149
224
|
this.inputs[index] = el;
|
|
150
|
-
} }), 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()));
|
|
151
233
|
}
|
|
152
234
|
static get is() { return "mg-input-checkbox"; }
|
|
153
235
|
static get encapsulation() { return "shadow"; }
|
|
@@ -183,6 +265,29 @@ export class MgInputCheckbox {
|
|
|
183
265
|
"text": "Component value\nIf item.value is `null`, checkbox will be indeterminate by default\nRequired"
|
|
184
266
|
}
|
|
185
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
|
+
},
|
|
186
291
|
"identifier": {
|
|
187
292
|
"type": "string",
|
|
188
293
|
"mutable": false,
|
|
@@ -485,6 +590,9 @@ export class MgInputCheckbox {
|
|
|
485
590
|
return [{
|
|
486
591
|
"propName": "value",
|
|
487
592
|
"methodName": "validateValue"
|
|
593
|
+
}, {
|
|
594
|
+
"propName": "type",
|
|
595
|
+
"methodName": "validateType"
|
|
488
596
|
}, {
|
|
489
597
|
"propName": "required",
|
|
490
598
|
"methodName": "handleValidityChange"
|
|
@@ -494,6 +602,9 @@ export class MgInputCheckbox {
|
|
|
494
602
|
}, {
|
|
495
603
|
"propName": "disabled",
|
|
496
604
|
"methodName": "handleValidityChange"
|
|
605
|
+
}, {
|
|
606
|
+
"propName": "disabled",
|
|
607
|
+
"methodName": "validateDisabled"
|
|
497
608
|
}];
|
|
498
609
|
}
|
|
499
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
|
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
.mg-popover mg-card {
|
|
20
20
|
--mg-card-max-width: var(--mg-popover-max-width);
|
|
21
|
+
--mg-card-min-width: var(--mg-popover-min-width);
|
|
21
22
|
position: relative;
|
|
22
23
|
}
|
|
23
24
|
.mg-popover[data-show] {
|
|
@@ -117,4 +118,5 @@
|
|
|
117
118
|
--mg-card-background: var(--mg-card-background-default);
|
|
118
119
|
--mg-card-box-shadow: var(--mg-card-box-shadow-default);
|
|
119
120
|
--mg-card-max-width: unset;
|
|
121
|
+
--mg-card-min-width: unset;
|
|
120
122
|
}
|
|
@@ -27,8 +27,6 @@ export class MgPopover {
|
|
|
27
27
|
this.popover.dataset.show = '';
|
|
28
28
|
// Enable the event listeners
|
|
29
29
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
30
|
-
// Update its position
|
|
31
|
-
this.popper.update();
|
|
32
30
|
// hide when click outside
|
|
33
31
|
// setTimeout is used to prevent event to trigger after creation
|
|
34
32
|
setTimeout(() => {
|
|
@@ -82,6 +80,12 @@ export class MgPopover {
|
|
|
82
80
|
/*************
|
|
83
81
|
* Lifecycle *
|
|
84
82
|
*************/
|
|
83
|
+
/**
|
|
84
|
+
* update popper position after props change on component did update hook to benefit from render ended
|
|
85
|
+
*/
|
|
86
|
+
componentDidUpdate() {
|
|
87
|
+
this.popper.update();
|
|
88
|
+
}
|
|
85
89
|
/**
|
|
86
90
|
* Check if component props are well configured on init
|
|
87
91
|
*/
|
|
@@ -143,8 +147,10 @@ export class MgPopover {
|
|
|
143
147
|
});
|
|
144
148
|
// Add events to hide popover
|
|
145
149
|
this.element.addEventListener('keydown', e => {
|
|
146
|
-
if (!this.disabled && e.code === 'Escape')
|
|
150
|
+
if (!this.disabled && e.code === 'Escape') {
|
|
147
151
|
this.display = false;
|
|
152
|
+
interactiveElement.focus();
|
|
153
|
+
}
|
|
148
154
|
});
|
|
149
155
|
this.handleDisplay(this.display);
|
|
150
156
|
}
|
|
@@ -17,6 +17,13 @@
|
|
|
17
17
|
"input": {
|
|
18
18
|
"select": {
|
|
19
19
|
"placeholder": "Select a value"
|
|
20
|
+
},
|
|
21
|
+
"checkbox": {
|
|
22
|
+
"selectedValues": "{nb} selected values",
|
|
23
|
+
"selectedValue": "{nb} selected value",
|
|
24
|
+
"editButton": "Edit",
|
|
25
|
+
"selectButton": "Select values",
|
|
26
|
+
"showButton": "Show"
|
|
20
27
|
}
|
|
21
28
|
},
|
|
22
29
|
"form": {
|
|
@@ -17,6 +17,13 @@
|
|
|
17
17
|
"input": {
|
|
18
18
|
"select": {
|
|
19
19
|
"placeholder": "Sélectionnez une valeur"
|
|
20
|
+
},
|
|
21
|
+
"checkbox": {
|
|
22
|
+
"selectedValues": "{nb} valeurs selectionnées",
|
|
23
|
+
"selectedValue": "{nb} valeur selectionnée",
|
|
24
|
+
"editButton": "Modifier",
|
|
25
|
+
"selectButton": "Sélectionner des valeurs",
|
|
26
|
+
"showButton": "Voir"
|
|
20
27
|
}
|
|
21
28
|
},
|
|
22
29
|
"form": {
|