@mgdis/mg-components 5.12.0 → 5.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{mg-action-more_31.cjs.entry.js → mg-action-more_32.cjs.entry.js} +325 -137
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +1 -1
- package/dist/cjs/{mg-menu.conf-79f0c761.js → mg-menu.conf-857748e1.js} +20 -2
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +15 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +259 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +16 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +41 -3
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +106 -100
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +1 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.css +3 -5
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +1 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +3 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +19 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.conf.js +8 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +9 -5
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +133 -47
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
- package/dist/collection/locales/en/messages.json +13 -1
- package/dist/collection/locales/fr/messages.json +7 -1
- package/dist/collection/stories/icon-gallery.js +9 -0
- package/dist/collection/variables.css +7 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index2.js +20 -2
- package/dist/components/mg-details.js +1 -1
- package/dist/components/mg-input-checkbox-paginated.d.ts +11 -0
- package/dist/components/mg-input-checkbox-paginated.js +6 -0
- package/dist/components/mg-input-checkbox-paginated2.js +205 -0
- package/dist/components/mg-input-checkbox.js +114 -108
- package/dist/components/mg-menu-item2.js +1 -1
- package/dist/components/mg-menu2.js +1 -1
- package/dist/components/mg-pagination2.js +4 -2
- package/dist/components/mg-panel.js +83 -37
- package/dist/components/mg-tabs.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mg-action-more_31.entry.js → mg-action-more_32.entry.js} +325 -138
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +1 -1
- package/dist/esm/{mg-menu.conf-850d4c6e.js → mg-menu.conf-c31828ca.js} +20 -2
- package/dist/mg-components/locales/en/messages.json +13 -1
- package/dist/mg-components/locales/fr/messages.json +7 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-622e2323.js +1 -0
- package/dist/mg-components/p-bda0b795.entry.js +1 -0
- package/dist/mg-components/{p-67ba5d05.entry.js → p-d37b29bb.entry.js} +1 -1
- package/dist/mg-components/variables.css +7 -2
- package/dist/types/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.d.ts +8 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.d.ts +103 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +50 -12
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +48 -53
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +0 -1
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +0 -1
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +4 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.conf.d.ts +16 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +44 -10
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +0 -1
- package/dist/types/components.d.ts +125 -19
- package/dist/types/locales/index.d.ts +18 -0
- package/dist/types/stories/icon-gallery.d.ts +6 -0
- package/package.json +23 -13
- package/dist/mg-components/p-60b7afd9.entry.js +0 -1
- package/dist/mg-components/p-689503fc.js +0 -1
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { h, proxyCustomElement, HTMLElement, createEvent, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { d as defineCustomElement$6 } from './mg-button2.js';
|
|
3
|
+
import { d as defineCustomElement$5 } from './mg-icon2.js';
|
|
4
|
+
import { d as defineCustomElement$4 } from './mg-input-select2.js';
|
|
5
|
+
import { d as defineCustomElement$3 } from './mg-input-title2.js';
|
|
6
|
+
import { d as defineCustomElement$2 } from './mg-pagination2.js';
|
|
7
|
+
import { d as defineCustomElement$1 } from './mg-tooltip2.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* List of all availables checkbox type
|
|
11
|
+
*/
|
|
12
|
+
const checkboxTypes = ['checkbox', 'multi'];
|
|
13
|
+
/**
|
|
14
|
+
* mg-input-checkbox-paginated section kind
|
|
15
|
+
*/
|
|
16
|
+
var SectionKind;
|
|
17
|
+
(function (SectionKind) {
|
|
18
|
+
SectionKind["SELECTED"] = "selected";
|
|
19
|
+
SectionKind["NOT_SELECTED"] = "not-selected";
|
|
20
|
+
})(SectionKind || (SectionKind = {}));
|
|
21
|
+
/**
|
|
22
|
+
* mg-input-checkbox-paginated section title kind
|
|
23
|
+
*/
|
|
24
|
+
var SectionTitleKind;
|
|
25
|
+
(function (SectionTitleKind) {
|
|
26
|
+
SectionTitleKind["BUTTON"] = "button";
|
|
27
|
+
SectionTitleKind["TEXT"] = "text";
|
|
28
|
+
})(SectionTitleKind || (SectionTitleKind = {}));
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get checkboxes list template
|
|
32
|
+
* @param props - MgInputCheckboxList Interface Props
|
|
33
|
+
* @returns input template
|
|
34
|
+
*/
|
|
35
|
+
const MgInputCheckboxList = (props) => (
|
|
36
|
+
// eslint-disable-next-line jsx-a11y/no-redundant-roles
|
|
37
|
+
h("ul", { class: {
|
|
38
|
+
'mg-input__input-group-container': true,
|
|
39
|
+
'mg-input__input-group-container--vertical': props.inputVerticalList || (props.type === 'multi' && !props.readonly),
|
|
40
|
+
'mg-input__input-checkbox-multi-inputs': props.type === 'multi' && !props.readonly,
|
|
41
|
+
}, role: "list", "aria-describedby": props.displaySearchInput ? 'search-results' : undefined, "aria-label": props.displaySearchInput ? props.messages.searchResults : undefined, "aria-live": props.displaySearchInput ? 'polite' : undefined, id: props.id }, props.checkboxes
|
|
42
|
+
.filter(item => !props.readonly || item.value)
|
|
43
|
+
.map(input => (h("li", { key: input.id, class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': props.disabled || input.disabled } },
|
|
44
|
+
h("input", { type: "checkbox", id: input.id, name: props.name, value: input.value && input.value.toString(), checked: Boolean(input.value), required: input.required, disabled: props.readonly || props.disabled || input.disabled, indeterminate: input.value === null, onInput: input.handleInput, onBlur: input.handleBlur, onKeyDown: input.handleKeydown }),
|
|
45
|
+
h("label", { htmlFor: input.id }, input.title))))));
|
|
46
|
+
|
|
47
|
+
const MgInputCheckboxPaginated = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
48
|
+
constructor() {
|
|
49
|
+
super();
|
|
50
|
+
this.__registerHost();
|
|
51
|
+
this.massAction = createEvent(this, "mass-action", 7);
|
|
52
|
+
/*************
|
|
53
|
+
* Constantes *
|
|
54
|
+
*************/
|
|
55
|
+
this.offset = 10;
|
|
56
|
+
/***********
|
|
57
|
+
* Methods *
|
|
58
|
+
***********/
|
|
59
|
+
/**
|
|
60
|
+
* Mass action handler
|
|
61
|
+
*/
|
|
62
|
+
this.massActionHandler = () => {
|
|
63
|
+
this.massAction.emit(this.sectionKind);
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Toogle items button handler
|
|
67
|
+
*/
|
|
68
|
+
this.handleToggleClick = () => {
|
|
69
|
+
this.itemsExpanded = !this.itemsExpanded;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Method to get a array range
|
|
73
|
+
* @param from - array start index
|
|
74
|
+
* @param to - array end index
|
|
75
|
+
* @returns array's range
|
|
76
|
+
*/
|
|
77
|
+
this.getArrayRange = (array, from, to) => array.slice(from, to);
|
|
78
|
+
/**
|
|
79
|
+
* Method to get page count from items
|
|
80
|
+
* @param items - items to count
|
|
81
|
+
* @returns page count from items
|
|
82
|
+
*/
|
|
83
|
+
this.getPageCount = (item) => Math.ceil(item.length / this.offset);
|
|
84
|
+
/**
|
|
85
|
+
* Handle mg-pagination current page change event
|
|
86
|
+
* @param event - pagination current page change event
|
|
87
|
+
*/
|
|
88
|
+
this.handleCurrentPageChange = (event) => {
|
|
89
|
+
this.currentPage = Number(event.detail);
|
|
90
|
+
};
|
|
91
|
+
this.readonly = undefined;
|
|
92
|
+
this.disabled = undefined;
|
|
93
|
+
this.name = undefined;
|
|
94
|
+
this.checkboxes = [];
|
|
95
|
+
this.sectionKind = undefined;
|
|
96
|
+
this.messages = undefined;
|
|
97
|
+
this.titleKind = undefined;
|
|
98
|
+
this.currentPage = 1;
|
|
99
|
+
this.itemsExpanded = true;
|
|
100
|
+
}
|
|
101
|
+
validateCheckboxes(newValue, oldValue) {
|
|
102
|
+
// after each array.length update we reset pagination
|
|
103
|
+
// when items fill on page, we set current page to 1
|
|
104
|
+
if (this.getPageCount(newValue) === 1)
|
|
105
|
+
this.currentPage = 1;
|
|
106
|
+
// when old items page numbers match the current page AND new items page number is lower than current page, we set the new last page
|
|
107
|
+
else if (this.getPageCount(oldValue) === this.currentPage && this.getPageCount(newValue) < this.currentPage)
|
|
108
|
+
this.currentPage = this.getPageCount(newValue);
|
|
109
|
+
}
|
|
110
|
+
validateSectionKind(newValue) {
|
|
111
|
+
if (newValue === SectionKind.SELECTED)
|
|
112
|
+
this.titleKind = SectionTitleKind.BUTTON;
|
|
113
|
+
else
|
|
114
|
+
this.titleKind = SectionTitleKind.TEXT;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get from and to index
|
|
118
|
+
* @returns [from,to] index
|
|
119
|
+
*/
|
|
120
|
+
getFromToIndexes() {
|
|
121
|
+
const isFirstPage = this.currentPage === 1;
|
|
122
|
+
const checkboxItemsFromIndex = isFirstPage ? 0 : (this.currentPage - 1) * this.offset;
|
|
123
|
+
const checkboxItemsToIndex = isFirstPage ? this.offset : this.currentPage * this.offset;
|
|
124
|
+
return [checkboxItemsFromIndex, checkboxItemsToIndex];
|
|
125
|
+
}
|
|
126
|
+
/*************
|
|
127
|
+
* Lifecycle *
|
|
128
|
+
*************/
|
|
129
|
+
/**
|
|
130
|
+
* Check if component props are well configured on init
|
|
131
|
+
*/
|
|
132
|
+
componentWillLoad() {
|
|
133
|
+
this.validateSectionKind(this.sectionKind);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Render
|
|
137
|
+
* @returns HTML Element
|
|
138
|
+
*/
|
|
139
|
+
render() {
|
|
140
|
+
const [checkboxItemsFromIndex, checkboxItemsToIndex] = this.getFromToIndexes();
|
|
141
|
+
const itemsContainerId = `items-${this.sectionKind}-container`;
|
|
142
|
+
const getText = (checkboxes) => h("em", null, `${this.messages[checkboxes.length > 1 ? 'titlePlurial' : 'title']} (${checkboxes.length})`);
|
|
143
|
+
return (h(Host, { hidden: this.checkboxes.length < 1 }, h("div", { class: "mg-input__input-checkbox-multi-section-header" }, this.titleKind === SectionTitleKind.BUTTON ? (h("mg-button", { variant: "flat", onClick: this.handleToggleClick, "aria-controls": itemsContainerId, "aria-expanded": this.itemsExpanded.toString() }, h("mg-icon", { icon: this.itemsExpanded ? 'chevron-up' : 'chevron-down', size: "small" }), h("span", { class: "mg-input__input-checkbox-multi-text" }, getText(this.checkboxes)))) : (h("p", { class: "mg-input__input-checkbox-multi-title" }, getText(this.checkboxes))), ((this.sectionKind === SectionKind.SELECTED && this.itemsExpanded) || this.sectionKind === SectionKind.NOT_SELECTED) && (h("mg-button", { variant: "link", onClick: this.massActionHandler }, this.messages.action)), this.getPageCount(this.checkboxes) > 1 && (h("mg-pagination", { key: "search-pagination", totalPages: this.getPageCount(this.checkboxes), currentPage: this.currentPage > 1 ? this.currentPage : 1, "onCurrent-page-change": this.handleCurrentPageChange, hideNavigationLabels: true, hidePageCount: true, identifier: `input-checkbox-pagination-${this.sectionKind}` }))), h("div", { hidden: !this.itemsExpanded, id: itemsContainerId, class: "mg-input__input-checkbox-multi-section-content" }, h(MgInputCheckboxList, { checkboxes: this.getArrayRange(this.checkboxes, checkboxItemsFromIndex, checkboxItemsToIndex), inputVerticalList: true, type: 'multi', displaySearchInput: true, messages: this.messages, id: `items-${this.sectionKind}`, readonly: this.readonly, disabled: this.disabled, name: this.name }))));
|
|
144
|
+
}
|
|
145
|
+
static get watchers() { return {
|
|
146
|
+
"checkboxes": ["validateCheckboxes"],
|
|
147
|
+
"sectionKind": ["validateSectionKind"]
|
|
148
|
+
}; }
|
|
149
|
+
}, [2, "mg-input-checkbox-paginated", {
|
|
150
|
+
"readonly": [4],
|
|
151
|
+
"disabled": [4],
|
|
152
|
+
"name": [1],
|
|
153
|
+
"checkboxes": [16],
|
|
154
|
+
"sectionKind": [1, "section-kind"],
|
|
155
|
+
"messages": [16],
|
|
156
|
+
"titleKind": [32],
|
|
157
|
+
"currentPage": [32],
|
|
158
|
+
"itemsExpanded": [32]
|
|
159
|
+
}]);
|
|
160
|
+
function defineCustomElement() {
|
|
161
|
+
if (typeof customElements === "undefined") {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const components = ["mg-input-checkbox-paginated", "mg-button", "mg-icon", "mg-input-select", "mg-input-title", "mg-pagination", "mg-tooltip"];
|
|
165
|
+
components.forEach(tagName => { switch (tagName) {
|
|
166
|
+
case "mg-input-checkbox-paginated":
|
|
167
|
+
if (!customElements.get(tagName)) {
|
|
168
|
+
customElements.define(tagName, MgInputCheckboxPaginated);
|
|
169
|
+
}
|
|
170
|
+
break;
|
|
171
|
+
case "mg-button":
|
|
172
|
+
if (!customElements.get(tagName)) {
|
|
173
|
+
defineCustomElement$6();
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
case "mg-icon":
|
|
177
|
+
if (!customElements.get(tagName)) {
|
|
178
|
+
defineCustomElement$5();
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
case "mg-input-select":
|
|
182
|
+
if (!customElements.get(tagName)) {
|
|
183
|
+
defineCustomElement$4();
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
case "mg-input-title":
|
|
187
|
+
if (!customElements.get(tagName)) {
|
|
188
|
+
defineCustomElement$3();
|
|
189
|
+
}
|
|
190
|
+
break;
|
|
191
|
+
case "mg-pagination":
|
|
192
|
+
if (!customElements.get(tagName)) {
|
|
193
|
+
defineCustomElement$2();
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
case "mg-tooltip":
|
|
197
|
+
if (!customElements.get(tagName)) {
|
|
198
|
+
defineCustomElement$1();
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
} });
|
|
202
|
+
}
|
|
203
|
+
defineCustomElement();
|
|
204
|
+
|
|
205
|
+
export { MgInputCheckboxList as M, SectionKind as S, MgInputCheckboxPaginated as a, checkboxTypes as c, defineCustomElement as d };
|
|
@@ -2,10 +2,11 @@ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/i
|
|
|
2
2
|
import { M as MgInput } from './MgInput.js';
|
|
3
3
|
import { C as ClassList } from './components.utils.js';
|
|
4
4
|
import { i as initLocales } from './index2.js';
|
|
5
|
-
import { d as defineCustomElement$
|
|
6
|
-
import { d as defineCustomElement$
|
|
7
|
-
import { d as defineCustomElement$
|
|
8
|
-
import { d as defineCustomElement$
|
|
5
|
+
import { c as checkboxTypes, S as SectionKind, M as MgInputCheckboxList, d as defineCustomElement$8 } from './mg-input-checkbox-paginated2.js';
|
|
6
|
+
import { d as defineCustomElement$c } from './mg-button2.js';
|
|
7
|
+
import { d as defineCustomElement$b } from './mg-card2.js';
|
|
8
|
+
import { d as defineCustomElement$a } from './mg-character-left2.js';
|
|
9
|
+
import { d as defineCustomElement$9 } from './mg-icon2.js';
|
|
9
10
|
import { d as defineCustomElement$7 } from './mg-input-select2.js';
|
|
10
11
|
import { d as defineCustomElement$6 } from './mg-input-text2.js';
|
|
11
12
|
import { d as defineCustomElement$5 } from './mg-input-title2.js';
|
|
@@ -13,12 +14,7 @@ import { d as defineCustomElement$4 } from './mg-pagination2.js';
|
|
|
13
14
|
import { d as defineCustomElement$3 } from './mg-popover2.js';
|
|
14
15
|
import { d as defineCustomElement$2 } from './mg-tooltip2.js';
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
* List of all availables checkbox type
|
|
18
|
-
*/
|
|
19
|
-
const checkboxTypes = ['checkbox', 'multi'];
|
|
20
|
-
|
|
21
|
-
const mgInputCheckboxCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.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{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}fieldset.mg-input{border:0;margin-left:0;margin-right:0;padding:0}fieldset.mg-input input[type=radio],fieldset.mg-input input[type=checkbox]{flex-shrink:0;width:var(--mg-input-check-size);height:var(--mg-input-check-size);margin-top:calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);margin-right:0.6rem;margin-bottom:0;margin-left:0}fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container{margin-top:0.7rem}.mg-input__input-container mg-tooltip{margin-left:3rem}.mg-input__input-group-container{margin:0;padding:0;list-style:none;display:flex;flex-wrap:wrap;column-gap:2.3rem;row-gap:1rem;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2)}.mg-input__input-group-container--vertical{flex-direction:column}.mg-input__input-group{display:flex;align-items:top}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi{display:flex;flex-wrap:wrap;gap:calc(var(--mg-inputs-spacer) * 1.2)}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi--with-values.mg-input__input-checkbox-multi{gap:0.4rem}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-values-container{display:flex;flex-wrap:wrap;gap:0.4rem;margin:0;padding:0;list-style:none}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-value{display:inline-flex;justify-content:center;align-items:center;box-sizing:border-box;min-height:var(--default-size);min-width:var(--default-size);padding:calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;background-color:var(--mg-color-dark-5-hsl);border-radius:0.3rem;font-size:var(--font-size)}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-no-result{text-align:center}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-inputs{margin:0}.mg-input.mg-input--checkbox-multi:not(.mg-input--label-on-top) mg-tooltip{margin-left:var(--mg-inputs-spacer)}.mg-input.mg-input--checkbox-multi mg-popover{--mg-popover-min-width:7rem}.mg-input.mg-input--checkbox-multi mg-popover [slot=content]{display:flex;flex-direction:column;gap:calc(0.4rem * 2)}.mg-input.mg-input--checkbox-multi mg-input-text{--mg-inputs-margin-bottom:0}";
|
|
17
|
+
const mgInputCheckboxCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.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{opacity:var(--mg-disabled-opacity)}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}fieldset.mg-input{border:0;margin-left:0;margin-right:0;padding:0}fieldset.mg-input input[type=radio],fieldset.mg-input input[type=checkbox]{flex-shrink:0;width:var(--mg-input-check-size);height:var(--mg-input-check-size);margin-top:calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);margin-right:0.6rem;margin-bottom:0;margin-left:0}fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container{margin-top:0.7rem}.mg-input__input-container mg-tooltip{margin-left:3rem}.mg-input__input-group-container{margin:0;padding:0;list-style:none;display:flex;flex-wrap:wrap;column-gap:2.3rem;row-gap:1rem;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2)}.mg-input__input-group-container--vertical{flex-direction:column}.mg-input__input-group{display:flex;align-items:top}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi{display:flex;flex-wrap:wrap;gap:calc(var(--mg-inputs-spacer) * 1.2)}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi--with-values.mg-input__input-checkbox-multi{gap:0.4rem}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-values-container{display:flex;flex-wrap:wrap;gap:calc(0.4rem * 1);flex-direction:row;margin:0;padding:0;list-style:none}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-value{display:inline-flex;justify-content:center;align-items:center;box-sizing:border-box;min-height:var(--default-size);min-width:var(--default-size);padding:calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;background-color:hsl(var(--mg-color-dark-5-hsl));border-radius:0.3rem;font-size:var(--font-size)}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-no-result{text-align:center}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-text,.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-title{display:inline;margin:0;color:hsl(var(--mg-color-dark-40-hsl))}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-title{margin:0 1.1rem}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-sections{display:flex;flex-wrap:wrap;gap:calc(0.4rem * 1);flex-direction:column}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-sections-container{display:flex;flex-wrap:nowrap;gap:calc(0.4rem * 0);flex-direction:column;max-height:80vh;padding-right:1rem;overflow-y:auto}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-section-header{display:flex;flex-wrap:wrap;gap:calc(0.4rem * 2);flex-direction:row;align-items:center;min-height:var(--default-size)}.mg-input.mg-input--checkbox-multi .mg-input__input-checkbox-multi-inputs{margin:0;padding:0.4rem calc(0.4rem * 2) 0.4rem calc(0.4rem / 2)}.mg-input.mg-input--checkbox-multi:not(.mg-input--label-on-top) mg-tooltip{margin-left:var(--mg-inputs-spacer)}.mg-input.mg-input--checkbox-multi mg-popover{--mg-popover-min-width:7rem;--mg-card-padding:calc(0.4rem * 2)}.mg-input.mg-input--checkbox-multi mg-popover [slot=content]{display:flex;flex-wrap:wrap;gap:calc(0.4rem * 2);flex-direction:column}.mg-input.mg-input--checkbox-multi mg-popover [slot=content] .mg-input__input-group{margin-left:calc(0.4rem * 2)}.mg-input.mg-input--checkbox-multi mg-input-text{--mg-inputs-margin-bottom:0}";
|
|
22
18
|
|
|
23
19
|
/**
|
|
24
20
|
* type CheckboxItem validation function
|
|
@@ -34,30 +30,20 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
34
30
|
this.__attachShadow();
|
|
35
31
|
this.valueChange = createEvent(this, "value-change", 7);
|
|
36
32
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
37
|
-
/************
|
|
38
|
-
* Internal *
|
|
39
|
-
************/
|
|
40
|
-
// HTML selector
|
|
41
|
-
this.inputs = [];
|
|
42
33
|
// hasDisplayedError (triggered by blur event)
|
|
43
34
|
this.hasDisplayedError = false;
|
|
44
35
|
// style
|
|
45
36
|
this.baseClassName = 'mg-input--checkbox';
|
|
37
|
+
// "multi" setup
|
|
46
38
|
this.multiStart = 5;
|
|
47
39
|
this.searchStart = 10;
|
|
48
|
-
this.searchOffset = 10;
|
|
49
40
|
/**
|
|
50
41
|
* Handle input event
|
|
51
42
|
* @param event - input event
|
|
52
43
|
*/
|
|
53
44
|
this.handleInput = (event) => {
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
item.value = Boolean(event.target.checked);
|
|
57
|
-
}
|
|
58
|
-
return item;
|
|
59
|
-
});
|
|
60
|
-
this.value = this.checkboxItems.map(o => ({ value: o.value, title: o.title, disabled: o.disabled }));
|
|
45
|
+
this.updateCheckboxItems('value', Boolean(event.target.checked), item => item.id === event.target.id);
|
|
46
|
+
this.updateValues();
|
|
61
47
|
this.checkValidity();
|
|
62
48
|
};
|
|
63
49
|
/**
|
|
@@ -68,10 +54,17 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
68
54
|
var _a;
|
|
69
55
|
// track "Tab" key event when popover display (is "multi" type selected)
|
|
70
56
|
if (event.key === 'Tab' && ((_a = this.mgPopover) === null || _a === void 0 ? void 0 : _a.display)) {
|
|
71
|
-
|
|
57
|
+
// when search input and do a back tab we close the popover
|
|
58
|
+
if (Boolean(this.searchInput) && event.shiftKey && this.searchInput.id === event.target.id) {
|
|
59
|
+
this.mgPopover.display = false;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const enableInputs = Array.from(this.element.shadowRoot.querySelectorAll('input'))
|
|
63
|
+
.filter(input => !Boolean(input.getAttribute('disabled')))
|
|
64
|
+
.map(({ id }) => id);
|
|
72
65
|
const originInputIndex = enableInputs.findIndex(id => id === event.target.id);
|
|
73
66
|
// close popover when tab trigger focus outside its DOM
|
|
74
|
-
if ((originInputIndex + 1 >= enableInputs.length && !event.shiftKey) || (originInputIndex === 0 && event.shiftKey))
|
|
67
|
+
if ((originInputIndex + 1 >= enableInputs.length && !event.shiftKey) || (originInputIndex === 0 && event.shiftKey && !Boolean(this.searchInput)))
|
|
75
68
|
this.mgPopover.display = false;
|
|
76
69
|
}
|
|
77
70
|
};
|
|
@@ -91,29 +84,54 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
91
84
|
this.searchValue = event.detail;
|
|
92
85
|
};
|
|
93
86
|
/**
|
|
94
|
-
*
|
|
95
|
-
* @param event -
|
|
87
|
+
* popover display-change handler
|
|
88
|
+
* @param event - mg-popover display-change custom event
|
|
96
89
|
*/
|
|
97
|
-
this.handleCurrentPageChange = (event) => {
|
|
98
|
-
this.currentSearchPage = Number(event.detail);
|
|
99
|
-
};
|
|
100
90
|
this.handleMgPopoverDisplayChange = (event) => {
|
|
101
91
|
// reset search value
|
|
102
92
|
if (!event.detail) {
|
|
103
93
|
this.searchValue = '';
|
|
104
|
-
this.
|
|
94
|
+
this.checkValidity();
|
|
105
95
|
}
|
|
106
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Handle select all button
|
|
99
|
+
* @param event - mass action event trigger a global select/unselect on values
|
|
100
|
+
*/
|
|
101
|
+
this.handleMassAction = (event) => {
|
|
102
|
+
this.updateCheckboxItems('value', event.detail !== 'selected');
|
|
103
|
+
this.updateValues();
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Update values
|
|
107
|
+
*/
|
|
108
|
+
this.updateValues = () => {
|
|
109
|
+
this.value = this.checkboxItems.map(o => ({ value: o.value, title: o.title, disabled: o.disabled }));
|
|
110
|
+
};
|
|
107
111
|
/**
|
|
108
112
|
* get invalid element
|
|
109
113
|
* @returns element
|
|
110
114
|
*/
|
|
111
|
-
this.getInvalidElement = () =>
|
|
115
|
+
this.getInvalidElement = () => {
|
|
116
|
+
const items = Array.from(this.element.shadowRoot.querySelectorAll('input[type="checkbox"]'));
|
|
117
|
+
return items.find(input => input !== null && !input.disabled && !input.checkValidity());
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Method to update searchResults
|
|
121
|
+
*/
|
|
122
|
+
this.updateSearchResults = () => {
|
|
123
|
+
this.searchResults = this.checkboxItems.filter(item => item.title.toLocaleLowerCase().includes(this.searchValue.trim().toLocaleLowerCase()));
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Methode to validate if one of inputs value is checked id required
|
|
127
|
+
* @returns truthy if condition is valid
|
|
128
|
+
*/
|
|
129
|
+
this.validateRequired = () => !this.required || this.checkboxItems.some(({ value }) => value);
|
|
112
130
|
/**
|
|
113
131
|
* Check if input is valid
|
|
114
132
|
*/
|
|
115
133
|
this.checkValidity = () => {
|
|
116
|
-
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
134
|
+
this.valid = this.readonly || this.disabled || (this.getInvalidElement() === undefined && this.validateRequired());
|
|
117
135
|
this.invalid = !this.valid;
|
|
118
136
|
// We need to send valid event even if it is the same value
|
|
119
137
|
this.inputValid.emit(this.valid);
|
|
@@ -133,14 +151,13 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
133
151
|
};
|
|
134
152
|
/**
|
|
135
153
|
* Set input error message
|
|
154
|
+
* @param displayError - dispay error condition
|
|
136
155
|
*/
|
|
137
|
-
this.setErrorMessage = () => {
|
|
138
|
-
const invalidElement = this.getInvalidElement();
|
|
156
|
+
this.setErrorMessage = (displayError = true) => {
|
|
139
157
|
// Set error message
|
|
140
158
|
this.errorMessage = undefined;
|
|
141
|
-
if (!this.valid &&
|
|
159
|
+
if (displayError && !this.valid && !this.validateRequired())
|
|
142
160
|
this.errorMessage = this.messages.errors.required;
|
|
143
|
-
}
|
|
144
161
|
};
|
|
145
162
|
/**
|
|
146
163
|
* Method to get mg-popover identifier
|
|
@@ -152,12 +169,6 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
152
169
|
* @returns items to display
|
|
153
170
|
*/
|
|
154
171
|
this.getDisplayItems = () => (this.searchValue.length > 0 ? this.searchResults : this.checkboxItems);
|
|
155
|
-
/**
|
|
156
|
-
* Method to get pagination total-page
|
|
157
|
-
* @param checkboxes - checkboxes to paginate
|
|
158
|
-
* @returns total page number for pagination
|
|
159
|
-
*/
|
|
160
|
-
this.getPaginationTotalPages = (checkboxes) => Math.ceil(checkboxes.length / this.searchOffset);
|
|
161
172
|
this.value = undefined;
|
|
162
173
|
this.type = checkboxTypes[0];
|
|
163
174
|
this.identifier = undefined;
|
|
@@ -178,7 +189,6 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
178
189
|
this.errorMessage = undefined;
|
|
179
190
|
this.checkboxItems = [];
|
|
180
191
|
this.displaySearchInput = undefined;
|
|
181
|
-
this.currentSearchPage = 0;
|
|
182
192
|
this.searchValue = '';
|
|
183
193
|
this.searchResults = [];
|
|
184
194
|
}
|
|
@@ -189,6 +199,10 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
189
199
|
title: item.title,
|
|
190
200
|
value: item.value,
|
|
191
201
|
disabled: item.disabled,
|
|
202
|
+
required: item.required,
|
|
203
|
+
handleInput: this.handleInput.bind(this),
|
|
204
|
+
handleBlur: this.handleBlur.bind(this),
|
|
205
|
+
handleKeydown: this.handleKeydown.bind(this),
|
|
192
206
|
}));
|
|
193
207
|
this.valueChange.emit(newValue);
|
|
194
208
|
}
|
|
@@ -215,13 +229,12 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
215
229
|
throw new Error('<mg-input-checkbox> prop "displaySelectedValues" can only be used with prop type "multi".');
|
|
216
230
|
}
|
|
217
231
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
232
|
+
if (prop !== 'readonly')
|
|
233
|
+
this.updateCheckboxItems(prop, newValue);
|
|
221
234
|
this.checkValidity();
|
|
222
235
|
if (this.hasDisplayedError) {
|
|
223
|
-
this.
|
|
224
|
-
this.hasDisplayedError
|
|
236
|
+
this.hasDisplayedError = prop !== 'required';
|
|
237
|
+
this.setErrorMessage(this.hasDisplayedError);
|
|
225
238
|
}
|
|
226
239
|
}
|
|
227
240
|
validateDisabled(newValue) {
|
|
@@ -234,13 +247,15 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
234
247
|
validateCheckboxItems(newValue) {
|
|
235
248
|
if (newValue.length > this.multiStart)
|
|
236
249
|
this.type = 'multi';
|
|
237
|
-
if (newValue.length > this.searchStart)
|
|
250
|
+
if (newValue.length > this.searchStart) {
|
|
238
251
|
this.displaySearchInput = this.type === 'multi';
|
|
252
|
+
// refresh search values
|
|
253
|
+
this.updateSearchResults();
|
|
254
|
+
}
|
|
239
255
|
}
|
|
240
|
-
validateSearchValue(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
this.setCurrentSearchPage();
|
|
256
|
+
validateSearchValue() {
|
|
257
|
+
// refresh search values
|
|
258
|
+
this.updateSearchResults();
|
|
244
259
|
}
|
|
245
260
|
/**
|
|
246
261
|
* Public method to display errors
|
|
@@ -251,29 +266,17 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
251
266
|
this.hasDisplayedError = this.invalid;
|
|
252
267
|
}
|
|
253
268
|
/**
|
|
254
|
-
*
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Method to get a array range
|
|
261
|
-
* @param from - array start index
|
|
262
|
-
* @param to - array end index
|
|
263
|
-
* @returns array's range
|
|
264
|
-
*/
|
|
265
|
-
getArrayRange(array, from, to) {
|
|
266
|
-
return array.slice(from, to);
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Get from and to index
|
|
270
|
-
* @returns [from,to] index
|
|
269
|
+
* Update ckecboxes item
|
|
270
|
+
* @param key - property to update
|
|
271
|
+
* @param newValue - value to update with
|
|
272
|
+
* @param condition - condtion to applu change on item
|
|
271
273
|
*/
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
274
|
+
updateCheckboxItems(key, newValue, condition) {
|
|
275
|
+
this.checkboxItems = this.checkboxItems.map(item => {
|
|
276
|
+
if ((typeof condition === 'function' && condition(item)) || condition === undefined)
|
|
277
|
+
item[key] = newValue;
|
|
278
|
+
return item;
|
|
279
|
+
});
|
|
277
280
|
}
|
|
278
281
|
/*************
|
|
279
282
|
* Lifecycle *
|
|
@@ -290,7 +293,6 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
290
293
|
this.validateValue(this.value);
|
|
291
294
|
this.validateDisabled(this.disabled);
|
|
292
295
|
this.validateDisplaySelectedValues(this.displaySelectedValues);
|
|
293
|
-
this.setCurrentSearchPage();
|
|
294
296
|
// Check validity when component is ready
|
|
295
297
|
// return a promise to process action only in the FIRST render().
|
|
296
298
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
@@ -298,6 +300,14 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
298
300
|
this.checkValidity();
|
|
299
301
|
}, 0);
|
|
300
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* add listeners
|
|
305
|
+
*/
|
|
306
|
+
componentDidLoad() {
|
|
307
|
+
var _a, _b;
|
|
308
|
+
this.searchInput = (_a = this.element.shadowRoot.querySelector('mg-input-text')) === null || _a === void 0 ? void 0 : _a.shadowRoot.querySelector('input');
|
|
309
|
+
(_b = this.searchInput) === null || _b === void 0 ? void 0 : _b.addEventListener('keydown', this.handleKeydown);
|
|
310
|
+
}
|
|
301
311
|
/**
|
|
302
312
|
* Render checkbox multi display values
|
|
303
313
|
* @param selectedValuesNb - selected values length
|
|
@@ -314,16 +324,25 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
314
324
|
}
|
|
315
325
|
}
|
|
316
326
|
/**
|
|
317
|
-
* Render
|
|
327
|
+
* Render checkboxes by section
|
|
318
328
|
* @param checkboxes - checkboxes to render
|
|
319
|
-
* @returns
|
|
329
|
+
* @returns render sections of checkboxes
|
|
320
330
|
*/
|
|
321
|
-
|
|
322
|
-
const [
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
331
|
+
renderCheckboxBySection(checkboxes) {
|
|
332
|
+
const [checkedValues, notCheckedValues] = checkboxes.reduce((acc, curr) => {
|
|
333
|
+
acc[curr.value ? 0 : 1].push(curr);
|
|
334
|
+
return acc;
|
|
335
|
+
}, [[], []]);
|
|
336
|
+
const baseSection = {
|
|
337
|
+
readonly: this.readonly,
|
|
338
|
+
disabled: this.disabled,
|
|
339
|
+
identifier: this.identifier,
|
|
340
|
+
};
|
|
341
|
+
const sections = [
|
|
342
|
+
Object.assign(Object.assign({}, baseSection), { sectionKind: SectionKind.SELECTED, checkboxes: checkedValues, messages: this.messages.input.checkbox.sections.selected }),
|
|
343
|
+
Object.assign(Object.assign({}, baseSection), { sectionKind: SectionKind.NOT_SELECTED, checkboxes: notCheckedValues, messages: this.messages.input.checkbox.sections.notSelected }),
|
|
326
344
|
];
|
|
345
|
+
return sections.map(section => h("mg-input-checkbox-paginated", Object.assign({}, section, { "onMass-action": this.handleMassAction })));
|
|
327
346
|
}
|
|
328
347
|
/**
|
|
329
348
|
* render checkbox multi element
|
|
@@ -338,31 +357,14 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
338
357
|
} }, h("mg-button", { variant: "secondary" }, h("mg-icon", { icon: "list" }), this.renderButtonText(selectedValuesNb)), h("div", { slot: "content" }, this.displaySearchInput && [
|
|
339
358
|
h("mg-input-text", { key: "input-search", identifier: `${this.identifier}-input-search`, icon: "magnifying-glass", type: "search", placeholder: this.messages.input.checkbox.label, label: this.messages.input.checkbox.label, mgWidth: "full", value: this.searchValue, labelHide: true, displayCharacterLeft: false, name: "q", "onValue-change": this.handleSearchChange, "aria-controls": "search-results items-list" }),
|
|
340
359
|
h("p", { key: "search-results", role: "status", class: "sr-only", id: "search-results" }, `${checkboxes.length} ${this.messages.input.checkbox[checkboxes.length > 0 ? 'results' : 'result']}`),
|
|
341
|
-
], this.displaySearchInput
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* Render checkbox element
|
|
345
|
-
* @param checkboxes - checkboxes to render
|
|
346
|
-
* @returns HTML Element
|
|
347
|
-
*/
|
|
348
|
-
renderCheckboxes(checkboxes) {
|
|
349
|
-
return (h("ul", { class: {
|
|
350
|
-
'mg-input__input-group-container': true,
|
|
351
|
-
'mg-input__input-group-container--vertical': this.inputVerticalList || (this.type === 'multi' && !this.readonly),
|
|
352
|
-
'mg-input__input-checkbox-multi-inputs': this.type === 'multi' && !this.readonly,
|
|
353
|
-
}, role: "list", "aria-describedby": this.displaySearchInput ? 'search-results' : false, "aria-label": this.displaySearchInput ? this.messages.input.checkbox.searchResults : false, "aria-live": this.displaySearchInput ? 'polite' : false, id: "items-list", key: "checkboxes" }, checkboxes
|
|
354
|
-
.filter(item => !this.readonly || item.value)
|
|
355
|
-
.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 => {
|
|
356
|
-
if (el !== null)
|
|
357
|
-
this.inputs[index] = el;
|
|
358
|
-
} }), h("label", { htmlFor: input.id }, input.title))))));
|
|
360
|
+
], this.displaySearchInput ? (h("div", { class: "mg-input__input-checkbox-multi-sections-container" }, this.renderCheckboxBySection(checkboxes))) : (h(MgInputCheckboxList, { checkboxes: checkboxes, inputVerticalList: true, type: this.type, readonly: this.readonly, displaySearchInput: this.displaySearchInput, messages: this.messages.input.checkbox, id: "checkboxes-list", disabled: this.disabled, name: this.name })), this.displaySearchInput && checkboxes.length === 0 && h("p", { class: "mg-input__input-checkbox-multi-no-result" }, this.messages.input.checkbox.noResult)))));
|
|
359
361
|
}
|
|
360
362
|
/**
|
|
361
363
|
* Render
|
|
362
364
|
* @returns HTML Element
|
|
363
365
|
*/
|
|
364
366
|
render() {
|
|
365
|
-
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.
|
|
367
|
+
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 ? (h(MgInputCheckboxList, { checkboxes: this.checkboxItems, inputVerticalList: this.inputVerticalList, type: this.type, readonly: this.readonly, displaySearchInput: this.displaySearchInput, messages: this.messages.input.checkbox, id: "checkboxes-list", disabled: this.disabled, name: this.name })) : (this.renderCheckboxMulti())));
|
|
366
368
|
}
|
|
367
369
|
get element() { return this; }
|
|
368
370
|
static get watchers() { return {
|
|
@@ -397,7 +399,6 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
397
399
|
"errorMessage": [32],
|
|
398
400
|
"checkboxItems": [32],
|
|
399
401
|
"displaySearchInput": [32],
|
|
400
|
-
"currentSearchPage": [32],
|
|
401
402
|
"searchValue": [32],
|
|
402
403
|
"searchResults": [32],
|
|
403
404
|
"displayError": [64]
|
|
@@ -406,7 +407,7 @@ function defineCustomElement$1() {
|
|
|
406
407
|
if (typeof customElements === "undefined") {
|
|
407
408
|
return;
|
|
408
409
|
}
|
|
409
|
-
const components = ["mg-input-checkbox", "mg-button", "mg-card", "mg-character-left", "mg-icon", "mg-input-select", "mg-input-text", "mg-input-title", "mg-pagination", "mg-popover", "mg-tooltip"];
|
|
410
|
+
const components = ["mg-input-checkbox", "mg-button", "mg-card", "mg-character-left", "mg-icon", "mg-input-checkbox-paginated", "mg-input-select", "mg-input-text", "mg-input-title", "mg-pagination", "mg-popover", "mg-tooltip"];
|
|
410
411
|
components.forEach(tagName => { switch (tagName) {
|
|
411
412
|
case "mg-input-checkbox":
|
|
412
413
|
if (!customElements.get(tagName)) {
|
|
@@ -415,20 +416,25 @@ function defineCustomElement$1() {
|
|
|
415
416
|
break;
|
|
416
417
|
case "mg-button":
|
|
417
418
|
if (!customElements.get(tagName)) {
|
|
418
|
-
defineCustomElement$
|
|
419
|
+
defineCustomElement$c();
|
|
419
420
|
}
|
|
420
421
|
break;
|
|
421
422
|
case "mg-card":
|
|
422
423
|
if (!customElements.get(tagName)) {
|
|
423
|
-
defineCustomElement$
|
|
424
|
+
defineCustomElement$b();
|
|
424
425
|
}
|
|
425
426
|
break;
|
|
426
427
|
case "mg-character-left":
|
|
427
428
|
if (!customElements.get(tagName)) {
|
|
428
|
-
defineCustomElement$
|
|
429
|
+
defineCustomElement$a();
|
|
429
430
|
}
|
|
430
431
|
break;
|
|
431
432
|
case "mg-icon":
|
|
433
|
+
if (!customElements.get(tagName)) {
|
|
434
|
+
defineCustomElement$9();
|
|
435
|
+
}
|
|
436
|
+
break;
|
|
437
|
+
case "mg-input-checkbox-paginated":
|
|
432
438
|
if (!customElements.get(tagName)) {
|
|
433
439
|
defineCustomElement$8();
|
|
434
440
|
}
|
|
@@ -310,7 +310,7 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
310
310
|
[`${this.name}__collapse-container`]: true,
|
|
311
311
|
[`${this.name}__collapse-container--first-level`]: (this.isInMainMenu || this.isItemMore) && this.isDirection(Direction.HORIZONTAL),
|
|
312
312
|
});
|
|
313
|
-
return (h(Host, { role:
|
|
313
|
+
return (h(Host, { role: "listitem" }, this.displayPopover() ? (h("mg-popover", { display: this.expanded, placement: "bottom-start", arrowHide: true, "onDisplay-change": this.handlePopoverDisplay, identifier: this.getPopoverIdentifier() }, this.renderInteractiveElement(), h("div", { class: getContainerClasses(), slot: "content" }, this.renderSlot()))) : ([
|
|
314
314
|
this.renderInteractiveElement(),
|
|
315
315
|
h("div", { key: "vertical-container", class: getContainerClasses(), hidden: !this.expanded }, this.renderSlot()),
|
|
316
316
|
])));
|
|
@@ -159,7 +159,7 @@ const MgMenu = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
159
159
|
* @returns HTML Element
|
|
160
160
|
*/
|
|
161
161
|
render() {
|
|
162
|
-
return (h(Host, { role:
|
|
162
|
+
return (h(Host, { role: "list", "aria-label": this.label }, h("slot", null)));
|
|
163
163
|
}
|
|
164
164
|
get element() { return this; }
|
|
165
165
|
static get watchers() { return {
|