@mgdis/mg-components 6.23.0 → 6.25.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-Acmyl4hv.js +5 -0
- package/dist/cjs/{index-BxB20_Vw.js → index-B6J2EllP.js} +3 -1
- package/dist/cjs/{index-BEF-cqV9.js → index-BmFwLEZT.js} +5 -1
- package/dist/cjs/{index-CpENFzEo.js → index-DrZECzp6.js} +14 -6
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_36.cjs.entry.js +394 -260
- package/dist/cjs/mg-alert.cjs.entry.js +7 -8
- package/dist/cjs/mg-breadcrumb.cjs.entry.js +27 -10
- package/dist/cjs/mg-components.cjs.js +2 -2
- package/dist/cjs/mg-fieldset.cjs.entry.js +8 -8
- package/dist/cjs/mg-illustration.cjs.entry.js +57 -0
- package/dist/cjs/mg-input-combobox.cjs.entry.js +46 -28
- package/dist/cjs/mg-input-file.cjs.entry.js +12 -11
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +3367 -4140
- package/dist/cjs/mg-loader.cjs.entry.js +5 -5
- package/dist/cjs/mg-progress.cjs.entry.js +3 -3
- package/dist/collection/assets/illustrations/index.js +1 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/atoms/internals/mg-character-left/mg-character-left.js +1 -1
- package/dist/collection/components/atoms/internals/mg-input-title/mg-input-title.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +4 -1
- package/dist/collection/components/atoms/mg-card/mg-card.js +1 -1
- package/dist/collection/components/atoms/mg-divider/mg-divider.conf.js +4 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +62 -3
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
- package/dist/collection/components/atoms/mg-illustration/mg-illustration.conf.js +1 -0
- package/dist/collection/components/atoms/mg-illustration/mg-illustration.js +95 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +9 -7
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +49 -19
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +5 -2
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxPaginated.js +5 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +30 -22
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +75 -30
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +14 -8
- package/dist/collection/components/molecules/inputs/mg-input-file/mg-input-file.js +8 -7
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +21 -12
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +7 -7
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +15 -10
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/index.js +29 -3
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +260 -7
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +21 -19
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +18 -13
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +7 -7
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +10 -9
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +1 -1
- package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +7 -5
- package/dist/collection/components/molecules/menus/mg-menu-item/mg-menu-item.js +18 -17
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +7 -4
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +6 -7
- package/dist/collection/components/molecules/mg-breadcrumb/mg-breadcrumb.js +49 -6
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
- package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +6 -6
- package/dist/collection/components/molecules/mg-form/mg-form.js +16 -13
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +2 -2
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +8 -4
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +13 -4
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +29 -37
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +5 -3
- package/dist/collection/components/molecules/mg-table/mg-table.js +10 -6
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +12 -9
- package/dist/collection/utils/behaviors.utils.js +3 -3
- package/dist/collection/utils/playwright.fixture.js +7 -2
- package/dist/components/mg-action-more.js +1 -1
- package/dist/components/mg-alert.js +1 -1
- package/dist/components/mg-badge2.js +1 -1
- package/dist/components/mg-breadcrumb.js +1 -1
- package/dist/components/mg-button2.js +1 -1
- package/dist/components/mg-card2.js +1 -1
- package/dist/components/mg-character-left2.js +1 -1
- package/dist/components/mg-details.js +1 -1
- package/dist/components/mg-divider2.js +1 -1
- package/dist/components/mg-fieldset.js +1 -1
- package/dist/components/mg-form.js +1 -1
- package/dist/components/mg-icon2.js +1 -1
- package/dist/components/mg-illustrated-message.js +1 -1
- package/dist/components/mg-illustration.d.ts +11 -0
- package/dist/components/mg-illustration.js +1 -0
- package/dist/components/mg-input-checkbox.js +1 -1
- package/dist/components/mg-input-combobox.js +1 -1
- package/dist/components/mg-input-date.js +1 -1
- package/dist/components/mg-input-file.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-rich-text-editor.js +298 -289
- 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-title2.js +1 -1
- package/dist/components/mg-input-toggle.js +1 -1
- package/dist/components/mg-input2.js +1 -1
- package/dist/components/mg-item-more2.js +1 -1
- package/dist/components/mg-loader2.js +1 -1
- package/dist/components/mg-menu-item2.js +1 -1
- package/dist/components/mg-message2.js +1 -1
- package/dist/components/mg-modal.js +1 -1
- package/dist/components/mg-pagination.js +1 -1
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-popover-content2.js +1 -1
- package/dist/components/mg-popover2.js +1 -1
- package/dist/components/mg-progress.js +1 -1
- package/dist/components/mg-skip-links.js +1 -1
- package/dist/components/mg-table.js +1 -1
- package/dist/components/mg-tabs2.js +1 -1
- package/dist/components/mg-tag.js +1 -1
- package/dist/components/mg-tooltip-content2.js +1 -1
- package/dist/components/mg-tooltip2.js +1 -1
- package/dist/custom-elements.json +178 -48
- package/dist/esm/{index-C7xjtdiw.js → index-91BOpzAB.js} +14 -6
- package/dist/esm/{index-DSEloqPn.js → index-BfblyCaJ.js} +3 -1
- package/dist/esm/index-Ci9Hv7DG.js +3 -0
- package/dist/esm/{index-DshvCiTL.js → index-D4bO_UCn.js} +5 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_36.entry.js +391 -257
- package/dist/esm/mg-alert.entry.js +7 -8
- package/dist/esm/mg-breadcrumb.entry.js +27 -10
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-fieldset.entry.js +8 -8
- package/dist/esm/mg-illustration.entry.js +55 -0
- package/dist/esm/mg-input-combobox.entry.js +46 -28
- package/dist/esm/mg-input-file.entry.js +12 -11
- package/dist/esm/mg-input-rich-text-editor.entry.js +3352 -4125
- package/dist/esm/mg-loader.entry.js +5 -5
- package/dist/esm/mg-progress.entry.js +3 -3
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-cdb01923.entry.js → p-3ad7441c.entry.js} +1 -1
- package/dist/mg-components/p-413b4536.entry.js +1 -0
- package/dist/mg-components/p-4693077a.entry.js +1 -0
- package/dist/mg-components/p-5dff879a.entry.js +1 -0
- package/dist/mg-components/{p-236bb1d2.entry.js → p-96fc508e.entry.js} +1 -1
- package/dist/mg-components/p-Ci9Hv7DG.js +1 -0
- package/dist/mg-components/p-D4bO_UCn.js +2 -0
- package/dist/mg-components/{p-d0b6d8f5.entry.js → p-ad533d08.entry.js} +1 -1
- package/dist/mg-components/p-b20f3698.entry.js +1 -0
- package/dist/mg-components/p-d0d12800.entry.js +1 -0
- package/dist/mg-components/p-ec4bd337.entry.js +1667 -0
- package/dist/mg-components/p-f8e58181.entry.js +1 -0
- package/dist/types/assets/illustrations/index.d.ts +21 -0
- package/dist/types/components/atoms/mg-divider/mg-divider.conf.d.ts +9 -0
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +13 -0
- package/dist/types/components/atoms/mg-illustration/mg-illustration.conf.d.ts +5 -0
- package/dist/types/components/atoms/mg-illustration/mg-illustration.d.ts +24 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +18 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +10 -5
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.conf.d.ts +4 -0
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.conf.d.ts +25 -0
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +61 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -2
- package/dist/types/components/molecules/menus/mg-menu-item/mg-menu-item.d.ts +2 -2
- package/dist/types/components/molecules/mg-alert/mg-alert.d.ts +2 -2
- package/dist/types/components/molecules/mg-breadcrumb/mg-breadcrumb.d.ts +11 -0
- package/dist/types/components/molecules/mg-popover/mg-popover-content/mg-popover-content.d.ts +1 -1
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +3 -3
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +1 -1
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +1 -1
- package/dist/types/components.d.ts +145 -40
- package/ide/intellij/web-types.json +134 -64
- package/ide/vscode/css-custom-data.json +6 -2
- package/ide/vscode/html-custom-data.json +190 -32
- package/package.json +22 -22
- package/dist/mg-components/p-13feb37a.entry.js +0 -1
- package/dist/mg-components/p-79265ad3.entry.js +0 -1
- package/dist/mg-components/p-7c63e469.entry.js +0 -1
- package/dist/mg-components/p-7fd3e519.entry.js +0 -1
- package/dist/mg-components/p-DshvCiTL.js +0 -2
- package/dist/mg-components/p-a0e2c886.entry.js +0 -1
- package/dist/mg-components/p-d698fa67.entry.js +0 -1658
- /package/dist/mg-components/{p-C7xjtdiw.js → p-91BOpzAB.js} +0 -0
- /package/dist/mg-components/{p-DSEloqPn.js → p-BfblyCaJ.js} +0 -0
|
@@ -3,7 +3,7 @@ import { ClassList, cleanString, isValidString, toString } from "@mgdis/core-ui-
|
|
|
3
3
|
import { normalizeBooleanAttributes } from "@mgdis/core-ui-helpers/dist/stencil";
|
|
4
4
|
import { checkboxTypes, SectionKind, } from "./mg-input-checkbox.conf";
|
|
5
5
|
import { MgInputCheckboxList } from "./MgInputCheckboxList";
|
|
6
|
-
import { classDisabled, classReadonly, classFieldset, classVerticalList } from "../mg-input/mg-input.conf";
|
|
6
|
+
import { classDisabled, classReadonly, classFieldset, classVerticalList, } from "../mg-input/mg-input.conf";
|
|
7
7
|
import { initLocales } from "../../../../locales";
|
|
8
8
|
import { Status } from "../../mg-tabs/mg-tabs.conf";
|
|
9
9
|
import { MgInputCheckboxPaginated } from "./MgInputCheckboxPaginated";
|
|
@@ -13,7 +13,10 @@ import { MgInputCheckboxPaginated } from "./MgInputCheckboxPaginated";
|
|
|
13
13
|
* @returns match item type
|
|
14
14
|
*/
|
|
15
15
|
const isCheckboxItems = (items) => Array.isArray(items) &&
|
|
16
|
-
items.every(item => typeof item === 'object' &&
|
|
16
|
+
items.every((item) => typeof item === 'object' &&
|
|
17
|
+
typeof item.title === 'string' &&
|
|
18
|
+
(item.value === null || typeof item.value === 'boolean') &&
|
|
19
|
+
item.value !== undefined);
|
|
17
20
|
export class MgInputCheckbox {
|
|
18
21
|
constructor() {
|
|
19
22
|
// hasDisplayedError (triggered by blur event)
|
|
@@ -103,7 +106,7 @@ export class MgInputCheckbox {
|
|
|
103
106
|
* @param event - input event
|
|
104
107
|
*/
|
|
105
108
|
this.handleInput = (event) => {
|
|
106
|
-
this.updateCheckboxItems('value', Boolean(event.target.checked), item => item._id === event.target.id);
|
|
109
|
+
this.updateCheckboxItems('value', Boolean(event.target.checked), (item) => item._id === event.target.id);
|
|
107
110
|
this.updateValues();
|
|
108
111
|
this.checkValidity();
|
|
109
112
|
this.setErrorMessage();
|
|
@@ -122,11 +125,12 @@ export class MgInputCheckbox {
|
|
|
122
125
|
return;
|
|
123
126
|
}
|
|
124
127
|
const enableInputs = Array.from(this.element.shadowRoot.querySelectorAll('input'))
|
|
125
|
-
.filter(input => !input.hasAttribute('disabled'))
|
|
128
|
+
.filter((input) => !input.hasAttribute('disabled'))
|
|
126
129
|
.map(({ id }) => id);
|
|
127
|
-
const originInputIndex = enableInputs.findIndex(id => id === event.target.id);
|
|
130
|
+
const originInputIndex = enableInputs.findIndex((id) => id === event.target.id);
|
|
128
131
|
// close popover when tab trigger focus outside its DOM
|
|
129
|
-
if ((originInputIndex + 1 >= enableInputs.length && !event.shiftKey) ||
|
|
132
|
+
if ((originInputIndex + 1 >= enableInputs.length && !event.shiftKey) ||
|
|
133
|
+
(originInputIndex === 0 && event.shiftKey && this.searchInput === undefined))
|
|
130
134
|
this.mgPopover.display = false;
|
|
131
135
|
}
|
|
132
136
|
};
|
|
@@ -172,13 +176,13 @@ export class MgInputCheckbox {
|
|
|
172
176
|
this.checkValidity();
|
|
173
177
|
}
|
|
174
178
|
// init active tab to selected if some values are checked
|
|
175
|
-
this.activeTab = this.checkboxItems.some(items => items.value) ? 2 : 1;
|
|
179
|
+
this.activeTab = this.checkboxItems.some((items) => items.value) ? 2 : 1;
|
|
176
180
|
};
|
|
177
181
|
/**
|
|
178
182
|
* Update values
|
|
179
183
|
*/
|
|
180
184
|
this.updateValues = () => {
|
|
181
|
-
this.value = this.checkboxItems.map(o => {
|
|
185
|
+
this.value = this.checkboxItems.map((o) => {
|
|
182
186
|
delete o._handleBlur;
|
|
183
187
|
delete o._handleInput;
|
|
184
188
|
delete o._handleKeydown;
|
|
@@ -195,7 +199,7 @@ export class MgInputCheckbox {
|
|
|
195
199
|
* Method to update searchResults
|
|
196
200
|
*/
|
|
197
201
|
this.updateSearchResults = () => {
|
|
198
|
-
this.searchResults = this.checkboxItems.filter(item => cleanString(item.title).includes(cleanString(this.searchValue)));
|
|
202
|
+
this.searchResults = this.checkboxItems.filter((item) => cleanString(item.title).includes(cleanString(this.searchValue)));
|
|
199
203
|
};
|
|
200
204
|
/**
|
|
201
205
|
* Method to validate if one of inputs value is checked id required
|
|
@@ -267,7 +271,7 @@ export class MgInputCheckbox {
|
|
|
267
271
|
* Manage items to display depending on the search state
|
|
268
272
|
* @returns items to display
|
|
269
273
|
*/
|
|
270
|
-
this.getDisplayItems = () =>
|
|
274
|
+
this.getDisplayItems = () => this.searchValue.length > 0 ? this.searchResults : this.checkboxItems;
|
|
271
275
|
/**
|
|
272
276
|
* get list of selected checkboxItems
|
|
273
277
|
* @returns selected checkboxItems
|
|
@@ -292,7 +296,7 @@ export class MgInputCheckbox {
|
|
|
292
296
|
* @returns The rendered readonly value.
|
|
293
297
|
*/
|
|
294
298
|
this.renderReadonly = (readonlyValue) => {
|
|
295
|
-
return this.inputVerticalList ? (h("ul", { class: "mg-c-input__readonly-value" }, readonlyValue.map(value => (h("li", { key: value }, h("b", null, value)))))) : (h("b", { class: "mg-c-input__readonly-value" }, readonlyValue.join(', ')));
|
|
299
|
+
return this.inputVerticalList ? (h("ul", { class: "mg-c-input__readonly-value" }, readonlyValue.map((value) => (h("li", { key: value }, h("b", null, value)))))) : (h("b", { class: "mg-c-input__readonly-value" }, readonlyValue.join(', ')));
|
|
296
300
|
};
|
|
297
301
|
/**
|
|
298
302
|
* Renders the MgInputCheckboxList component.
|
|
@@ -403,7 +407,7 @@ export class MgInputCheckbox {
|
|
|
403
407
|
// - Async operations are completed
|
|
404
408
|
// - No timing issues with Stencil's render cycle
|
|
405
409
|
// - Keep everything in sync both inside and outside the component
|
|
406
|
-
return new Promise(resolve => {
|
|
410
|
+
return new Promise((resolve) => {
|
|
407
411
|
requestAnimationFrame(() => {
|
|
408
412
|
this.checkValidity();
|
|
409
413
|
this.setErrorMessage();
|
|
@@ -443,14 +447,14 @@ export class MgInputCheckbox {
|
|
|
443
447
|
*/
|
|
444
448
|
async reset() {
|
|
445
449
|
if (!this.readonly) {
|
|
446
|
-
this.value = this.value.map(item => (Object.assign(Object.assign({}, item), { value: false })));
|
|
450
|
+
this.value = this.value.map((item) => (Object.assign(Object.assign({}, item), { value: false })));
|
|
447
451
|
// Use `Promise` as requested for stencil method
|
|
448
452
|
// Use `requestAnimationFrame` to ensure:
|
|
449
453
|
// - DOM is fully updated before validation
|
|
450
454
|
// - Async operations are completed
|
|
451
455
|
// - No timing issues with Stencil's render cycle
|
|
452
456
|
// - Keep everything in sync both inside and outside the component
|
|
453
|
-
return new Promise(resolve => {
|
|
457
|
+
return new Promise((resolve) => {
|
|
454
458
|
requestAnimationFrame(() => {
|
|
455
459
|
// unlock validity check by reseting customErrorMessage
|
|
456
460
|
this.customErrorMessage = { lock: false };
|
|
@@ -483,7 +487,7 @@ export class MgInputCheckbox {
|
|
|
483
487
|
* @param condition - condtion to applu change on item
|
|
484
488
|
*/
|
|
485
489
|
updateCheckboxItems(key, newValue, condition) {
|
|
486
|
-
this.checkboxItems = this.checkboxItems.map(item => {
|
|
490
|
+
this.checkboxItems = this.checkboxItems.map((item) => {
|
|
487
491
|
if ((typeof condition === 'function' && condition(item)) || condition === undefined)
|
|
488
492
|
item[key] = newValue;
|
|
489
493
|
return item;
|
|
@@ -536,7 +540,7 @@ export class MgInputCheckbox {
|
|
|
536
540
|
const handleMassAction = (kind) => () => {
|
|
537
541
|
const displayItems = this.getDisplayItems();
|
|
538
542
|
// update only displayed items
|
|
539
|
-
displayItems.forEach(item => {
|
|
543
|
+
displayItems.forEach((item) => {
|
|
540
544
|
if (!item.disabled) {
|
|
541
545
|
item.value = kind !== SectionKind.SELECTED;
|
|
542
546
|
}
|
|
@@ -553,9 +557,13 @@ export class MgInputCheckbox {
|
|
|
553
557
|
];
|
|
554
558
|
return (h("mg-tabs", { identifier: `${this.identifier}-tabs`, class: "mg-c-input__tabs", label: this.messages.input.checkbox.sections.label, items: sections.map((section, key) => ({
|
|
555
559
|
label: section.messages.title,
|
|
556
|
-
badge: {
|
|
560
|
+
badge: {
|
|
561
|
+
value: section.checkboxes.length,
|
|
562
|
+
label: this.messages.input.checkbox.sections.badge.label,
|
|
563
|
+
role: 'information',
|
|
564
|
+
},
|
|
557
565
|
status: key + 1 === this.activeTab ? Status.ACTIVE : Status.VISIBLE,
|
|
558
|
-
})), activeTab: this.activeTab, "onActive-tab-change": this.handleActiveTabChange }, sections.map(section => {
|
|
566
|
+
})), activeTab: this.activeTab, "onActive-tab-change": this.handleActiveTabChange }, sections.map((section) => {
|
|
559
567
|
var _a;
|
|
560
568
|
return (h(MgInputCheckboxPaginated, Object.assign({}, section, { limit: (_a = this.paginatedLimits[section.key]) !== null && _a !== void 0 ? _a : this.paginatedStep, handleLoadMore: () => this.handlePaginatedLoadMore(section.key) })));
|
|
561
569
|
})));
|
|
@@ -573,12 +581,12 @@ export class MgInputCheckbox {
|
|
|
573
581
|
checkboxes: this.getDisplayItems(),
|
|
574
582
|
};
|
|
575
583
|
const checkboxesPaginatedSearchProps = Object.assign(Object.assign({}, props), { messages: Object.assign(Object.assign({}, this.messages.input.checkbox.sections.search), { showMore: this.messages.input.showMore }), key: SectionKind.SEARCH, limit: (_a = this.paginatedLimits[SectionKind.SEARCH]) !== null && _a !== void 0 ? _a : this.paginatedStep, handleLoadMore: () => this.handlePaginatedLoadMore(SectionKind.SEARCH) });
|
|
576
|
-
return (h("div", { class: "mg-c-input__input-container" }, h("mg-popover", {
|
|
584
|
+
return (h("div", { class: "mg-c-input__input-container" }, h("mg-popover", { identifier: this.getMgPopoverIdentifier(), display: this.hasOpenedPopover, "onDisplay-change": this.handleMgPopoverDisplayChange, "data-fallback-placement": "bottom-end", ref: (el) => {
|
|
577
585
|
if (el !== null)
|
|
578
586
|
this.mgPopover = el;
|
|
579
587
|
} }, h("mg-button", { variant: "secondary", "aria-describedby": `${this.identifier}-title` }, h("mg-icon", { icon: "list" }), this.getSelectValuesButtonMessage()), h("div", { slot: "content", class: "mg-c-input__content" }, this.displaySearchInput ? ([
|
|
580
588
|
h("mg-input-text", { key: "input-search", identifier: `${this.identifier}-input-search`, icon: "magnifying-glass", type: "search", placeholder: this.messages.input.checkbox.sections.search.label, label: this.messages.input.checkbox.sections.search.label, mgWidth: "full", value: this.searchValue, labelHide: true, characterLeftHide: true, name: "q", "onValue-change": this.handleSearchChange }),
|
|
581
|
-
this.searchValue.length > 0 ? h(MgInputCheckboxPaginated, Object.assign({}, checkboxesPaginatedSearchProps)) : this.renderCheckboxTabs(props),
|
|
589
|
+
this.searchValue.length > 0 ? (h(MgInputCheckboxPaginated, Object.assign({}, checkboxesPaginatedSearchProps))) : (this.renderCheckboxTabs(props)),
|
|
582
590
|
]) : (h(MgInputCheckboxList, Object.assign({}, props, { id: this.checkboxesId, name: this.name, invalid: this.invalid }))))), this.displaySelectedValues ? (selectedValuesNb > 0 && (h("ul", { role: "list", class: "mg-c-input__input-container-list" }, this.getSelectedItems().map(({ title }) => (h("li", { class: "mg-c-input__input-value", key: title }, title)))))) : (h("b", null, this.messages.input.checkbox[selectedValuesNb > 1 ? 'selectedValues' : 'selectedValue'].replace('{nb}', selectedValuesNb)))));
|
|
583
591
|
}
|
|
584
592
|
/**
|
|
@@ -597,7 +605,7 @@ export class MgInputCheckbox {
|
|
|
597
605
|
else {
|
|
598
606
|
inputContent = this.renderCheckboxMulti();
|
|
599
607
|
}
|
|
600
|
-
return (h("mg-input", { key: '
|
|
608
|
+
return (h("mg-input", { key: '8e403fd79ca8a9bb2db5545e946a3763eb156551', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, tooltip: this.tooltip, tooltipPosition: this.readonly && readonlyValue.length === 0 ? 'label' : this.tooltipPosition, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined }, inputContent));
|
|
601
609
|
}
|
|
602
610
|
static get is() { return "mg-input-checkbox"; }
|
|
603
611
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1065,7 +1073,7 @@ export class MgInputCheckbox {
|
|
|
1065
1073
|
"composed": true,
|
|
1066
1074
|
"docs": {
|
|
1067
1075
|
"tags": [],
|
|
1068
|
-
"text": "
|
|
1076
|
+
"text": "Emitted event when checking validity"
|
|
1069
1077
|
},
|
|
1070
1078
|
"complexType": {
|
|
1071
1079
|
"original": "HTMLMgInputCheckboxElement['valid']",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { ClassList, Cursor, Page, Paginate, allItemsAreString, formatID, getObjectValueFromKey, isObject, isValidString, nextTick, toString, } from "@mgdis/core-ui-helpers/dist/utils";
|
|
3
3
|
import { normalizeBooleanAttributes } from "@mgdis/core-ui-helpers/dist/stencil";
|
|
4
|
-
import { widths, classReadonly, classDisabled } from "../mg-input/mg-input.conf";
|
|
4
|
+
import { widths, classReadonly, classDisabled, } from "../mg-input/mg-input.conf";
|
|
5
5
|
import { initLocales } from "../../../../locales";
|
|
6
6
|
import { Keys } from "../../../../utils/events.utils";
|
|
7
7
|
/**
|
|
@@ -9,7 +9,10 @@ import { Keys } from "../../../../utils/events.utils";
|
|
|
9
9
|
* @param item - object to check
|
|
10
10
|
* @returns True if object is an item
|
|
11
11
|
*/
|
|
12
|
-
const isItem = (item) => item &&
|
|
12
|
+
const isItem = (item) => item &&
|
|
13
|
+
typeof item === 'object' &&
|
|
14
|
+
typeof item.title === 'string' &&
|
|
15
|
+
item.value !== undefined;
|
|
13
16
|
/**
|
|
14
17
|
* Check if objects are items
|
|
15
18
|
* @param items - items to check
|
|
@@ -25,9 +28,10 @@ const isFetchmappings = (value) => {
|
|
|
25
28
|
const isValidRoot = isObject(value) && Object.hasOwn(value, 'request') && Object.hasOwn(value, 'response');
|
|
26
29
|
if (isValidRoot) {
|
|
27
30
|
const { request, response } = value;
|
|
28
|
-
if ([request, response].some(property => !isObject(property)))
|
|
31
|
+
if ([request, response].some((property) => !isObject(property)))
|
|
29
32
|
return false;
|
|
30
|
-
const isValidRequest = typeof request.filter === 'string' &&
|
|
33
|
+
const isValidRequest = typeof request.filter === 'string' &&
|
|
34
|
+
(request.filterTransform === undefined || typeof request.filterTransform === 'function');
|
|
31
35
|
const isValidResponse = typeof response === 'object' &&
|
|
32
36
|
typeof response.total === 'string' &&
|
|
33
37
|
typeof response.items === 'string' &&
|
|
@@ -74,6 +78,10 @@ export class MgInputCombobox {
|
|
|
74
78
|
* Define input width
|
|
75
79
|
*/
|
|
76
80
|
this.mgWidth = 'full';
|
|
81
|
+
/**
|
|
82
|
+
* Define the popover placement
|
|
83
|
+
*/
|
|
84
|
+
this.popoverPlacement = 'bottom-start';
|
|
77
85
|
/**
|
|
78
86
|
* Define tooltip position
|
|
79
87
|
*/
|
|
@@ -89,7 +97,11 @@ export class MgInputCombobox {
|
|
|
89
97
|
/**
|
|
90
98
|
* Component classes
|
|
91
99
|
*/
|
|
92
|
-
this.classCollection = new ClassList([
|
|
100
|
+
this.classCollection = new ClassList([
|
|
101
|
+
'mg-c-input--combobox',
|
|
102
|
+
'mg-c-input--has-icon',
|
|
103
|
+
'mg-c-input--input-append',
|
|
104
|
+
]);
|
|
93
105
|
/**
|
|
94
106
|
* Popover display state
|
|
95
107
|
*/
|
|
@@ -99,7 +111,7 @@ export class MgInputCombobox {
|
|
|
99
111
|
* @param event - option element click event
|
|
100
112
|
*/
|
|
101
113
|
this.handleOptionClick = (event) => {
|
|
102
|
-
this.setValue(this.options.items.find(option => toString(option.value) === event.target.dataset.value));
|
|
114
|
+
this.setValue(this.options.items.find((option) => toString(option.value) === event.target.dataset.value));
|
|
103
115
|
this.popoverDisplay = false;
|
|
104
116
|
};
|
|
105
117
|
/**
|
|
@@ -294,7 +306,8 @@ export class MgInputCombobox {
|
|
|
294
306
|
var _a;
|
|
295
307
|
if (!this.popoverDisplay)
|
|
296
308
|
return;
|
|
297
|
-
(_a = this.element.shadowRoot
|
|
309
|
+
(_a = this.element.shadowRoot
|
|
310
|
+
.querySelector(`li:nth-of-type(${(index || 0) + this.page.baseIndex})`)) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ block: 'nearest' });
|
|
298
311
|
});
|
|
299
312
|
};
|
|
300
313
|
/**
|
|
@@ -343,7 +356,7 @@ export class MgInputCombobox {
|
|
|
343
356
|
* Get first page with filter applied
|
|
344
357
|
* @returns first page with filter applied
|
|
345
358
|
*/
|
|
346
|
-
this.getFirstPage = () => this.options.getPage(0, option => this.filter === '' || option.title.toLocaleLowerCase().includes(this.filter.toLocaleLowerCase()));
|
|
359
|
+
this.getFirstPage = () => this.options.getPage(0, (option) => this.filter === '' || option.title.toLocaleLowerCase().includes(this.filter.toLocaleLowerCase()));
|
|
347
360
|
/**
|
|
348
361
|
* Loading wrapper with a given action
|
|
349
362
|
* @param action - wrapped loading action
|
|
@@ -357,7 +370,7 @@ export class MgInputCombobox {
|
|
|
357
370
|
(_a = this.loadingAction) !== null && _a !== void 0 ? _a : (this.loadingAction = action.name);
|
|
358
371
|
// update index
|
|
359
372
|
if (Boolean(this.option) && this.loadingAction !== 'load-more') {
|
|
360
|
-
index = this.page.items.findIndex(option => toString(option.value) === toString(this.option.value));
|
|
373
|
+
index = this.page.items.findIndex((option) => toString(option.value) === toString(this.option.value));
|
|
361
374
|
}
|
|
362
375
|
else if (this.loadingAction === 'load-more') {
|
|
363
376
|
index = this.page.items.length - this.page.baseIndex;
|
|
@@ -387,7 +400,9 @@ export class MgInputCombobox {
|
|
|
387
400
|
return promise()
|
|
388
401
|
.then(() => {
|
|
389
402
|
// parse full items list from options
|
|
390
|
-
const options = this.filter === ''
|
|
403
|
+
const options = this.filter === ''
|
|
404
|
+
? this.options.items
|
|
405
|
+
: this.options.items.filter((option) => option.title.includes(this.filter));
|
|
391
406
|
// update visual focus
|
|
392
407
|
if (action.name !== 'load-data') {
|
|
393
408
|
index = this.page.getIndexFromCursor(action.cursor, this.loadingAction === 'load-more' && index >= 0 ? options[index] : this.option);
|
|
@@ -411,7 +426,7 @@ export class MgInputCombobox {
|
|
|
411
426
|
this.goToNextPage = () => {
|
|
412
427
|
this.showMore.emit();
|
|
413
428
|
if (this.fetchurl !== undefined) {
|
|
414
|
-
return this.getOptions(typeof this.page.next === 'string' ? this.page.next : undefined).then(nextPage => {
|
|
429
|
+
return this.getOptions(typeof this.page.next === 'string' ? this.page.next : undefined).then((nextPage) => {
|
|
415
430
|
if (nextPage !== undefined) {
|
|
416
431
|
// merge items from current page and next page
|
|
417
432
|
const items = [...this.page.items, ...nextPage.items];
|
|
@@ -435,7 +450,7 @@ export class MgInputCombobox {
|
|
|
435
450
|
*/
|
|
436
451
|
this.updatePage = async () => {
|
|
437
452
|
if (this.fetchurl !== undefined) {
|
|
438
|
-
return this.getOptions().then(page => {
|
|
453
|
+
return this.getOptions().then((page) => {
|
|
439
454
|
if (page !== undefined) {
|
|
440
455
|
// reset current options pagination from API response
|
|
441
456
|
this.options = new Paginate(page.items, { total: page.total, next: page.next, top: page.top });
|
|
@@ -453,7 +468,9 @@ export class MgInputCombobox {
|
|
|
453
468
|
*/
|
|
454
469
|
this.getOptions = async (url = this.fetchurl) => {
|
|
455
470
|
// add text filter to url
|
|
456
|
-
const filter = typeof this.fetchmappings.request.filterTransform === 'function'
|
|
471
|
+
const filter = typeof this.fetchmappings.request.filterTransform === 'function'
|
|
472
|
+
? this.fetchmappings.request.filterTransform(this.filter)
|
|
473
|
+
: this.filter;
|
|
457
474
|
const updateUrl = (typeof url === 'string' ? url : url.toString()).replaceAll(this.fetchmappings.request.filter, encodeURIComponent(filter));
|
|
458
475
|
try {
|
|
459
476
|
const response = await fetch(updateUrl, this.fetchoptions);
|
|
@@ -471,11 +488,12 @@ export class MgInputCombobox {
|
|
|
471
488
|
});
|
|
472
489
|
const total = Number(getObjectValueFromKey(json, this.fetchmappings.response.total, 0));
|
|
473
490
|
let next = getObjectValueFromKey(json, this.fetchmappings.response.next);
|
|
474
|
-
if (
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
491
|
+
if (Boolean(next) && !URL.canParse(next)) {
|
|
492
|
+
// `next` is a relative link returned by the API: resolve it against the request URL (RFC 3986).
|
|
493
|
+
// The request URL is first made absolute against the document base so a root-relative `fetchurl`
|
|
494
|
+
// resolves the next page on the API path, not against the document location (which would 404).
|
|
495
|
+
const requestUrl = new URL(updateUrl, this.element.ownerDocument.baseURI);
|
|
496
|
+
next = new URL(next, requestUrl).toString();
|
|
479
497
|
}
|
|
480
498
|
return { items, total, next, top: items.length };
|
|
481
499
|
}
|
|
@@ -502,7 +520,7 @@ export class MgInputCombobox {
|
|
|
502
520
|
}
|
|
503
521
|
// String array
|
|
504
522
|
else if (allItemsAreString(newValue)) {
|
|
505
|
-
this.options = new Paginate(newValue.map(item => ({ title: item, value: item })), { total: newValue.length });
|
|
523
|
+
this.options = new Paginate(newValue.map((item) => ({ title: item, value: item })), { total: newValue.length });
|
|
506
524
|
}
|
|
507
525
|
// Object array
|
|
508
526
|
else if (isItems(newValue)) {
|
|
@@ -544,7 +562,7 @@ export class MgInputCombobox {
|
|
|
544
562
|
}
|
|
545
563
|
watchMgWidth(newValue) {
|
|
546
564
|
// reset width class
|
|
547
|
-
widths.forEach(width => {
|
|
565
|
+
widths.forEach((width) => {
|
|
548
566
|
this.classCollection.delete(`mg-c-input--width-${width}`);
|
|
549
567
|
});
|
|
550
568
|
// apply new width
|
|
@@ -610,7 +628,7 @@ export class MgInputCombobox {
|
|
|
610
628
|
// - Async operations are completed
|
|
611
629
|
// - No timing issues with Stencil's render cycle
|
|
612
630
|
// - Keep everything in sync both inside and outside the component
|
|
613
|
-
return new Promise(resolve => {
|
|
631
|
+
return new Promise((resolve) => {
|
|
614
632
|
requestAnimationFrame(() => {
|
|
615
633
|
this.checkValidity();
|
|
616
634
|
this.setErrorMessage();
|
|
@@ -659,7 +677,7 @@ export class MgInputCombobox {
|
|
|
659
677
|
// - Async operations are completed
|
|
660
678
|
// - No timing issues with Stencil's render cycle
|
|
661
679
|
// - Keep everything in sync both inside and outside the component
|
|
662
|
-
return new Promise(resolve => {
|
|
680
|
+
return new Promise((resolve) => {
|
|
663
681
|
requestAnimationFrame(() => {
|
|
664
682
|
// unlock validity check by reseting customErrorMessage
|
|
665
683
|
this.customErrorMessage = { lock: false };
|
|
@@ -760,14 +778,14 @@ export class MgInputCombobox {
|
|
|
760
778
|
else {
|
|
761
779
|
activeDescendant = (_e = this.value) === null || _e === void 0 ? void 0 : _e.value;
|
|
762
780
|
}
|
|
763
|
-
return (h("mg-input", { key: '
|
|
781
|
+
return (h("mg-input", { key: 'c8cff9468c9bfdcc6dd5c96c1452ad81620e050c', label: this.label, identifier: this.identifier, class: this.classCollection.classes.join(' '), ariaDescribedbyIDs: popoverContent && popoverContent !== 'list' ? popoverContent : undefined, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("mg-popover", { identifier: this.popoverId, placement: this.popoverPlacement, display: this.popoverDisplay, style: {
|
|
764
782
|
'--mg-c-input-list-width': ((_f = this.input) === null || _f === void 0 ? void 0 : _f.offsetWidth) > 0 ? `${this.input.offsetWidth}px` : undefined,
|
|
765
783
|
}, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, h("div", { class: "mg-c-input__input-group-container" }, h("mg-icon", { icon: "magnifying-glass" }), h("input", { type: "text", role: "combobox", class: "mg-c-input__box mg-c-input__box--width", value: this.filter, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-autocomplete": "list", "aria-expanded": this.popoverDisplay.toString(), "aria-controls": listId, "aria-invalid": (this.invalid === true).toString(), "aria-activedescendant": formatID(activeDescendant), onInput: this.handleFilterInput, onBlur: this.handleFilterBlur, onFocus: this.handleFilterFocus, onKeyDown: this.handleFilterKeydown, ref: (el) => {
|
|
766
784
|
if (el !== null)
|
|
767
785
|
this.input = el;
|
|
768
786
|
} }), withResetButton ? (h("mg-button", { class: "mg-c-input__box-append mg-c-input__reset", variant: "flat", "is-icon": true, label: this.messages.general.reset, "aria-controls": this.identifier, tabindex: "-1", onClick: this.handleResetButton }, h("mg-icon", { icon: "cross" }))) : (h("mg-button", { class: "mg-c-input__box-append", variant: "flat", "is-icon": true, label: this.itemsLabel, tabindex: "-1", disabled: this.disabled }, h("mg-icon", { icon: `chevron-${this.popoverDisplay ? 'up' : 'down'}` })))), h("div", { slot: "content", class: "mg-c-input__popover-container" }, popoverContent === 'list' && [
|
|
769
787
|
// eslint-disable-next-line jsx-a11y/role-supports-aria-props
|
|
770
|
-
h("ul", { key: "list", class: "mg-c-input__input-list", role: "listbox", id: listId, "aria-label": this.itemsLabel, "aria-setsize": this.page.total }, this.page.items.map(option => {
|
|
788
|
+
h("ul", { key: "list", class: "mg-c-input__input-list", role: "listbox", id: listId, "aria-label": this.itemsLabel, "aria-setsize": this.page.total }, this.page.items.map((option) => {
|
|
771
789
|
var _a;
|
|
772
790
|
return (
|
|
773
791
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
@@ -777,7 +795,7 @@ export class MgInputCombobox {
|
|
|
777
795
|
'mg-c-input__input-list-item--selected': this.isCurrentOption(option),
|
|
778
796
|
}, key: option.title, id: formatID(option.value), "aria-selected": this.isCurrentOption(option).toString(), "data-value": toString(option.value), onClick: this.handleOptionClick }, option.title, this.isCurrentOption(option) && h("mg-icon", { icon: "check" })));
|
|
779
797
|
})),
|
|
780
|
-
this.isLoading && h("mg-loader", { key: "loader", message: this.messages.input.combobox.search, class: { 'mg-u-visually-hidden': Boolean(this.page.next) } }),
|
|
798
|
+
this.isLoading && (h("mg-loader", { key: "loader", message: this.messages.input.combobox.search, class: { 'mg-u-visually-hidden': Boolean(this.page.next) } })),
|
|
781
799
|
this.page.next && (h("mg-button", { key: "load-more", variant: "flat", class: "mg-c-input__load-more", tabIndex: -1, disabled: this.isLoading, "full-width": true, "disable-on-click": true, onClick: this.handleLoadMoreButton, "aria-controls": listId, ref: (el) => {
|
|
782
800
|
if (el !== null)
|
|
783
801
|
this.loadMoreElement = el;
|
|
@@ -1074,6 +1092,33 @@ export class MgInputCombobox {
|
|
|
1074
1092
|
"attribute": "mg-width",
|
|
1075
1093
|
"defaultValue": "'full'"
|
|
1076
1094
|
},
|
|
1095
|
+
"popoverPlacement": {
|
|
1096
|
+
"type": "string",
|
|
1097
|
+
"mutable": false,
|
|
1098
|
+
"complexType": {
|
|
1099
|
+
"original": "Placement",
|
|
1100
|
+
"resolved": "\"auto\" | \"auto-end\" | \"auto-start\" | \"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
|
|
1101
|
+
"references": {
|
|
1102
|
+
"Placement": {
|
|
1103
|
+
"location": "import",
|
|
1104
|
+
"path": "@popperjs/core",
|
|
1105
|
+
"id": "../../node_modules/.pnpm/@popperjs+core@2.11.8/node_modules/@popperjs/core/index.d.ts::Placement",
|
|
1106
|
+
"referenceLocation": "Placement"
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
},
|
|
1110
|
+
"required": false,
|
|
1111
|
+
"optional": false,
|
|
1112
|
+
"docs": {
|
|
1113
|
+
"tags": [],
|
|
1114
|
+
"text": "Define the popover placement"
|
|
1115
|
+
},
|
|
1116
|
+
"getter": false,
|
|
1117
|
+
"setter": false,
|
|
1118
|
+
"reflect": false,
|
|
1119
|
+
"attribute": "popover-placement",
|
|
1120
|
+
"defaultValue": "'bottom-start'"
|
|
1121
|
+
},
|
|
1077
1122
|
"tooltip": {
|
|
1078
1123
|
"type": "string",
|
|
1079
1124
|
"mutable": false,
|
|
@@ -1287,7 +1332,7 @@ export class MgInputCombobox {
|
|
|
1287
1332
|
"composed": true,
|
|
1288
1333
|
"docs": {
|
|
1289
1334
|
"tags": [],
|
|
1290
|
-
"text": "
|
|
1335
|
+
"text": "Emitted event when value change"
|
|
1291
1336
|
},
|
|
1292
1337
|
"complexType": {
|
|
1293
1338
|
"original": "HTMLMgInputComboboxElement['value']",
|
|
@@ -1307,7 +1352,7 @@ export class MgInputCombobox {
|
|
|
1307
1352
|
"composed": true,
|
|
1308
1353
|
"docs": {
|
|
1309
1354
|
"tags": [],
|
|
1310
|
-
"text": "
|
|
1355
|
+
"text": "Emitted event when filter change"
|
|
1311
1356
|
},
|
|
1312
1357
|
"complexType": {
|
|
1313
1358
|
"original": "string",
|
|
@@ -1322,7 +1367,7 @@ export class MgInputCombobox {
|
|
|
1322
1367
|
"composed": true,
|
|
1323
1368
|
"docs": {
|
|
1324
1369
|
"tags": [],
|
|
1325
|
-
"text": "
|
|
1370
|
+
"text": "Emitted event when `load-more` is called"
|
|
1326
1371
|
},
|
|
1327
1372
|
"complexType": {
|
|
1328
1373
|
"original": "void",
|
|
@@ -1337,7 +1382,7 @@ export class MgInputCombobox {
|
|
|
1337
1382
|
"composed": true,
|
|
1338
1383
|
"docs": {
|
|
1339
1384
|
"tags": [],
|
|
1340
|
-
"text": "
|
|
1385
|
+
"text": "Emitted event when checking validity"
|
|
1341
1386
|
},
|
|
1342
1387
|
"complexType": {
|
|
1343
1388
|
"original": "HTMLMgInputComboboxElement['valid']",
|
|
@@ -1357,7 +1402,7 @@ export class MgInputCombobox {
|
|
|
1357
1402
|
"composed": true,
|
|
1358
1403
|
"docs": {
|
|
1359
1404
|
"tags": [],
|
|
1360
|
-
"text": "
|
|
1405
|
+
"text": "Emitted event when fetch API throw an error"
|
|
1361
1406
|
},
|
|
1362
1407
|
"complexType": {
|
|
1363
1408
|
"original": "Error",
|
|
@@ -72,7 +72,9 @@ export class MgInputDate {
|
|
|
72
72
|
text = text.replace(defaultHelpTextVariable, this.formatHelpText(this.messages.input.date.helpText.expectedFormat));
|
|
73
73
|
}
|
|
74
74
|
// Replace pattern and date variables
|
|
75
|
-
return text
|
|
75
|
+
return text
|
|
76
|
+
.replace('{pattern}', this.renderPattern())
|
|
77
|
+
.replace('{date}', localeDate(dateToString(new Date('2025-12-24')), this.systemLocale));
|
|
76
78
|
};
|
|
77
79
|
/**
|
|
78
80
|
* Handle input event
|
|
@@ -114,7 +116,9 @@ export class MgInputDate {
|
|
|
114
116
|
* Check if input is valid
|
|
115
117
|
*/
|
|
116
118
|
this.checkValidity = () => {
|
|
117
|
-
this.setValidity(this.readonly ||
|
|
119
|
+
this.setValidity(this.readonly ||
|
|
120
|
+
this.disabled ||
|
|
121
|
+
(this.input.checkValidity() && (this.value === null || this.isValidPattern(this.value))));
|
|
118
122
|
};
|
|
119
123
|
/**
|
|
120
124
|
* get input error code
|
|
@@ -132,7 +136,9 @@ export class MgInputDate {
|
|
|
132
136
|
error = 'required';
|
|
133
137
|
}
|
|
134
138
|
// min & max
|
|
135
|
-
else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) &&
|
|
139
|
+
else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) &&
|
|
140
|
+
((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
141
|
+
this.max !== DEFAULT_MAX_DATE) {
|
|
136
142
|
error = 'minMax';
|
|
137
143
|
}
|
|
138
144
|
// min
|
|
@@ -252,7 +258,7 @@ export class MgInputDate {
|
|
|
252
258
|
// - Async operations are completed
|
|
253
259
|
// - No timing issues with Stencil's render cycle
|
|
254
260
|
// - Keep everything in sync both inside and outside the component
|
|
255
|
-
return new Promise(resolve => {
|
|
261
|
+
return new Promise((resolve) => {
|
|
256
262
|
requestAnimationFrame(() => {
|
|
257
263
|
this.checkValidity();
|
|
258
264
|
this.setErrorMessage();
|
|
@@ -299,7 +305,7 @@ export class MgInputDate {
|
|
|
299
305
|
// - Async operations are completed
|
|
300
306
|
// - No timing issues with Stencil's render cycle
|
|
301
307
|
// - Keep everything in sync both inside and outside the component
|
|
302
|
-
return new Promise(resolve => {
|
|
308
|
+
return new Promise((resolve) => {
|
|
303
309
|
requestAnimationFrame(() => {
|
|
304
310
|
// unlock validity check by reseting customErrorMessage
|
|
305
311
|
this.customErrorMessage = { lock: false };
|
|
@@ -359,7 +365,7 @@ export class MgInputDate {
|
|
|
359
365
|
* @returns HTML Element
|
|
360
366
|
*/
|
|
361
367
|
render() {
|
|
362
|
-
return (h("mg-input", { key: '
|
|
368
|
+
return (h("mg-input", { key: 'c13dd54974bd7c8381bcefbe847fe79f2270506c', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === null ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly ? (this.value && h("b", { class: "mg-c-input__readonly-value" }, localeDate(this.value, this.locale))) : (h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, ref: (el) => {
|
|
363
369
|
if (el !== null)
|
|
364
370
|
this.input = el;
|
|
365
371
|
} }))));
|
|
@@ -714,7 +720,7 @@ export class MgInputDate {
|
|
|
714
720
|
"composed": true,
|
|
715
721
|
"docs": {
|
|
716
722
|
"tags": [],
|
|
717
|
-
"text": "
|
|
723
|
+
"text": "Emitted event when value change"
|
|
718
724
|
},
|
|
719
725
|
"complexType": {
|
|
720
726
|
"original": "HTMLMgInputDateElement['value']",
|
|
@@ -734,7 +740,7 @@ export class MgInputDate {
|
|
|
734
740
|
"composed": true,
|
|
735
741
|
"docs": {
|
|
736
742
|
"tags": [],
|
|
737
|
-
"text": "
|
|
743
|
+
"text": "Emitted event when checking validity"
|
|
738
744
|
},
|
|
739
745
|
"complexType": {
|
|
740
746
|
"original": "HTMLMgInputDateElement['valid']",
|
|
@@ -5,7 +5,8 @@ import { localeByte } from "@mgdis/core-ui-helpers/dist/locale";
|
|
|
5
5
|
import { classDisabled } from "../mg-input/mg-input.conf";
|
|
6
6
|
import { initLocales } from "../../../../locales";
|
|
7
7
|
const allItemsAreFile = (items) => {
|
|
8
|
-
return Array.isArray(items) &&
|
|
8
|
+
return (Array.isArray(items) &&
|
|
9
|
+
items.every((item) => isObject(item) && typeof item.name === 'string' && typeof item.size === 'number'));
|
|
9
10
|
};
|
|
10
11
|
export class MgInputFile {
|
|
11
12
|
constructor() {
|
|
@@ -149,7 +150,7 @@ export class MgInputFile {
|
|
|
149
150
|
* @returns boolean - true if max size is exceeded
|
|
150
151
|
*/
|
|
151
152
|
this.isMaxSizeExceeded = () => {
|
|
152
|
-
return this.maxSize >= 0 && this.files.some(file => file.size > this.maxSize);
|
|
153
|
+
return this.maxSize >= 0 && this.files.some((file) => file.size > this.maxSize);
|
|
153
154
|
};
|
|
154
155
|
/**
|
|
155
156
|
* Render files
|
|
@@ -157,7 +158,7 @@ export class MgInputFile {
|
|
|
157
158
|
*/
|
|
158
159
|
this.renderFiles = () => {
|
|
159
160
|
const fileListId = `${this.identifier}-file-list`;
|
|
160
|
-
const renderFileName = (file) => (h("span", { class: "mg-c-input__file-item-name" }, file.name, file.size > 0 ? h("span", { class: "mg-c-input__file-item-size" }, ` ${localeByte(file.size, this.locale)}`) : undefined));
|
|
161
|
+
const renderFileName = (file) => (h("span", { class: "mg-c-input__file-item-name" }, file.name, file.size > 0 ? (h("span", { class: "mg-c-input__file-item-size" }, ` ${localeByte(file.size, this.locale)}`)) : undefined));
|
|
161
162
|
const renderDeleteButton = () => (h("mg-button", { variant: "flat", class: "mg-c-input__file-delete-button", "is-icon": true, label: this.messages.input.file.deleteButton, type: "button", disabled: this.disabled, "aria-controls": [this.identifier, fileListId].join(' '), onClick: this.handleDeleteFileClick }, h("mg-icon", { icon: "cross" })));
|
|
162
163
|
if (this.files.length === 0) {
|
|
163
164
|
return null;
|
|
@@ -246,7 +247,7 @@ export class MgInputFile {
|
|
|
246
247
|
// - Async operations are completed
|
|
247
248
|
// - No timing issues with Stencil's render cycle
|
|
248
249
|
// - Keep everything in sync both inside and outside the component
|
|
249
|
-
return new Promise(resolve => {
|
|
250
|
+
return new Promise((resolve) => {
|
|
250
251
|
requestAnimationFrame(() => {
|
|
251
252
|
this.checkValidity();
|
|
252
253
|
this.setErrorMessage();
|
|
@@ -292,7 +293,7 @@ export class MgInputFile {
|
|
|
292
293
|
// - Async operations are completed
|
|
293
294
|
// - No timing issues with Stencil's render cycle
|
|
294
295
|
// - Keep everything in sync both inside and outside the component
|
|
295
|
-
return new Promise(resolve => {
|
|
296
|
+
return new Promise((resolve) => {
|
|
296
297
|
requestAnimationFrame(() => {
|
|
297
298
|
// unlock validity check by resetting customErrorMessage
|
|
298
299
|
this.customErrorMessage = { lock: false };
|
|
@@ -334,9 +335,9 @@ export class MgInputFile {
|
|
|
334
335
|
* @returns HTML Element
|
|
335
336
|
*/
|
|
336
337
|
render() {
|
|
337
|
-
return (h("mg-input", { key: '
|
|
338
|
+
return (h("mg-input", { key: '3c4c0ebdd1661e381f0002b2ae68dcf454097913', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, h("div", { key: 'bd7665fe8c6e01ec4e04fbbbf9cc21ccc4128b17', class: "mg-c-input__file-container" }, h("input", { key: 'f27d10160115ec1ff5163a1c55aa2658779c6fd7', name: this.name, id: this.identifier, class: "mg-u-visually-hidden", type: "file", multiple: this.multiple === true, capture: this.capture, accept: this.accept, disabled: this.disabled, required: this.files.length === 0 && this.required, onFocus: this.handleInputFocus, onBlur: this.handleInputBlur, onChange: this.handleInputChange, "aria-invalid": (this.invalid === true).toString(), ref: (el) => {
|
|
338
339
|
this.inputElement = el;
|
|
339
|
-
} }), h("mg-button", { key: '
|
|
340
|
+
} }), h("mg-button", { key: 'd16c4cbd95d676bcddb895659aab37f0f9c396eb', variant: "secondary", class: "mg-c-input__file-button", type: "button", disabled: this.disabled, onClick: this.handleButtonClick, onBlur: this.handleButtonBlur, tabindex: "-1", ref: (el) => {
|
|
340
341
|
this.fileButtonElement = el;
|
|
341
342
|
} }, this.messages.input.file.browse), this.renderFiles())));
|
|
342
343
|
}
|