@mgdis/mg-components 6.24.0 → 6.26.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 +452 -261
- 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 +40 -23
- package/dist/cjs/mg-input-file.cjs.entry.js +12 -11
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +2565 -4013
- 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/assets/jodit/jodit.css +5821 -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 +84 -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 +69 -25
- 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 +9 -8
- 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/custom-properties.css +50 -0
- 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 +262 -9
- 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.conf.js +4 -0
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +51 -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 +24 -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 +294 -284
- 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 +197 -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 +449 -258
- 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 +40 -23
- package/dist/esm/mg-input-file.entry.js +12 -11
- package/dist/esm/mg-input-rich-text-editor.entry.js +2550 -3998
- 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-206505b5.entry.js +1667 -0
- 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-5dff879a.entry.js +1 -0
- package/dist/mg-components/{p-08d3d957.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-bf2252c9.entry.js +1 -0
- package/dist/mg-components/p-d0d12800.entry.js +1 -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 +19 -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-illustrated-message/mg-illustrated-message.conf.d.ts +8 -0
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +9 -1
- 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 +158 -42
- package/ide/intellij/web-types.json +145 -65
- package/ide/vscode/css-custom-data.json +6 -2
- package/ide/vscode/html-custom-data.json +216 -33
- package/package.json +22 -22
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/custom-properties.scss +0 -212
- package/dist/mg-components/p-13feb37a.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-9953b835.entry.js +0 -1
- package/dist/mg-components/p-9c0a9fc7.entry.js +0 -1657
- package/dist/mg-components/p-DshvCiTL.js +0 -2
- package/dist/mg-components/p-a338088e.entry.js +0 -1
- /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);
|
|
@@ -503,7 +520,7 @@ export class MgInputCombobox {
|
|
|
503
520
|
}
|
|
504
521
|
// String array
|
|
505
522
|
else if (allItemsAreString(newValue)) {
|
|
506
|
-
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 });
|
|
507
524
|
}
|
|
508
525
|
// Object array
|
|
509
526
|
else if (isItems(newValue)) {
|
|
@@ -545,7 +562,7 @@ export class MgInputCombobox {
|
|
|
545
562
|
}
|
|
546
563
|
watchMgWidth(newValue) {
|
|
547
564
|
// reset width class
|
|
548
|
-
widths.forEach(width => {
|
|
565
|
+
widths.forEach((width) => {
|
|
549
566
|
this.classCollection.delete(`mg-c-input--width-${width}`);
|
|
550
567
|
});
|
|
551
568
|
// apply new width
|
|
@@ -611,7 +628,7 @@ export class MgInputCombobox {
|
|
|
611
628
|
// - Async operations are completed
|
|
612
629
|
// - No timing issues with Stencil's render cycle
|
|
613
630
|
// - Keep everything in sync both inside and outside the component
|
|
614
|
-
return new Promise(resolve => {
|
|
631
|
+
return new Promise((resolve) => {
|
|
615
632
|
requestAnimationFrame(() => {
|
|
616
633
|
this.checkValidity();
|
|
617
634
|
this.setErrorMessage();
|
|
@@ -660,7 +677,7 @@ export class MgInputCombobox {
|
|
|
660
677
|
// - Async operations are completed
|
|
661
678
|
// - No timing issues with Stencil's render cycle
|
|
662
679
|
// - Keep everything in sync both inside and outside the component
|
|
663
|
-
return new Promise(resolve => {
|
|
680
|
+
return new Promise((resolve) => {
|
|
664
681
|
requestAnimationFrame(() => {
|
|
665
682
|
// unlock validity check by reseting customErrorMessage
|
|
666
683
|
this.customErrorMessage = { lock: false };
|
|
@@ -761,14 +778,14 @@ export class MgInputCombobox {
|
|
|
761
778
|
else {
|
|
762
779
|
activeDescendant = (_e = this.value) === null || _e === void 0 ? void 0 : _e.value;
|
|
763
780
|
}
|
|
764
|
-
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: {
|
|
765
782
|
'--mg-c-input-list-width': ((_f = this.input) === null || _f === void 0 ? void 0 : _f.offsetWidth) > 0 ? `${this.input.offsetWidth}px` : undefined,
|
|
766
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) => {
|
|
767
784
|
if (el !== null)
|
|
768
785
|
this.input = el;
|
|
769
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' && [
|
|
770
787
|
// eslint-disable-next-line jsx-a11y/role-supports-aria-props
|
|
771
|
-
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) => {
|
|
772
789
|
var _a;
|
|
773
790
|
return (
|
|
774
791
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
@@ -778,7 +795,7 @@ export class MgInputCombobox {
|
|
|
778
795
|
'mg-c-input__input-list-item--selected': this.isCurrentOption(option),
|
|
779
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" })));
|
|
780
797
|
})),
|
|
781
|
-
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) } })),
|
|
782
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) => {
|
|
783
800
|
if (el !== null)
|
|
784
801
|
this.loadMoreElement = el;
|
|
@@ -1075,6 +1092,33 @@ export class MgInputCombobox {
|
|
|
1075
1092
|
"attribute": "mg-width",
|
|
1076
1093
|
"defaultValue": "'full'"
|
|
1077
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
|
+
},
|
|
1078
1122
|
"tooltip": {
|
|
1079
1123
|
"type": "string",
|
|
1080
1124
|
"mutable": false,
|
|
@@ -1288,7 +1332,7 @@ export class MgInputCombobox {
|
|
|
1288
1332
|
"composed": true,
|
|
1289
1333
|
"docs": {
|
|
1290
1334
|
"tags": [],
|
|
1291
|
-
"text": "
|
|
1335
|
+
"text": "Emitted event when value change"
|
|
1292
1336
|
},
|
|
1293
1337
|
"complexType": {
|
|
1294
1338
|
"original": "HTMLMgInputComboboxElement['value']",
|
|
@@ -1308,7 +1352,7 @@ export class MgInputCombobox {
|
|
|
1308
1352
|
"composed": true,
|
|
1309
1353
|
"docs": {
|
|
1310
1354
|
"tags": [],
|
|
1311
|
-
"text": "
|
|
1355
|
+
"text": "Emitted event when filter change"
|
|
1312
1356
|
},
|
|
1313
1357
|
"complexType": {
|
|
1314
1358
|
"original": "string",
|
|
@@ -1323,7 +1367,7 @@ export class MgInputCombobox {
|
|
|
1323
1367
|
"composed": true,
|
|
1324
1368
|
"docs": {
|
|
1325
1369
|
"tags": [],
|
|
1326
|
-
"text": "
|
|
1370
|
+
"text": "Emitted event when `load-more` is called"
|
|
1327
1371
|
},
|
|
1328
1372
|
"complexType": {
|
|
1329
1373
|
"original": "void",
|
|
@@ -1338,7 +1382,7 @@ export class MgInputCombobox {
|
|
|
1338
1382
|
"composed": true,
|
|
1339
1383
|
"docs": {
|
|
1340
1384
|
"tags": [],
|
|
1341
|
-
"text": "
|
|
1385
|
+
"text": "Emitted event when checking validity"
|
|
1342
1386
|
},
|
|
1343
1387
|
"complexType": {
|
|
1344
1388
|
"original": "HTMLMgInputComboboxElement['valid']",
|
|
@@ -1358,7 +1402,7 @@ export class MgInputCombobox {
|
|
|
1358
1402
|
"composed": true,
|
|
1359
1403
|
"docs": {
|
|
1360
1404
|
"tags": [],
|
|
1361
|
-
"text": "
|
|
1405
|
+
"text": "Emitted event when fetch API throw an error"
|
|
1362
1406
|
},
|
|
1363
1407
|
"complexType": {
|
|
1364
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
|
}
|