@mgdis/mg-components 5.19.0 → 5.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_34.cjs.entry.js +84 -40
- package/dist/cjs/mg-action-more_34.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-item-more.cjs.entry.js +2 -1
- package/dist/cjs/mg-item-more.cjs.entry.js.map +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.js.map +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js +2 -1
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.js +4 -4
- package/dist/collection/components/atoms/mg-card/mg-card.js.map +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +2 -2
- package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +19 -1
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js.map +1 -1
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.playwright.js +12 -0
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.playwright.js.map +1 -0
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.spec.js +1 -5
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.spec.js.map +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +3 -3
- package/dist/collection/components/molecules/inputs/MgInput.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +4 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +19 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +6 -5
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js +5 -2
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/test/mg-input-checkbox.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +5 -4
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js +3 -2
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +4 -10
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/test/mg-input-text.spec.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +78 -2
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.playwright.js +108 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js +44 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.spec.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
- package/dist/collection/components/molecules/menu/mg-menu/test/{mg-menu.e2e.js → mg-menu.e2e.playwright.js} +67 -96
- package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.playwright.js +100 -0
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.playwright.js.map +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js.map +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js +2 -1
- package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +1 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
- package/dist/collection/utils/behaviors.utils.js +2 -1
- package/dist/collection/utils/behaviors.utils.js.map +1 -1
- package/dist/collection/utils/playwright.e2e.test.utils.js +3 -3
- package/dist/collection/utils/playwright.e2e.test.utils.js.map +1 -1
- package/dist/collection/utils/unit.test.utils.js +0 -3
- package/dist/collection/utils/unit.test.utils.js.map +1 -1
- package/dist/components/MgInput.js +3 -3
- package/dist/components/MgInput.js.map +1 -1
- package/dist/components/mg-action-more.js +1 -1
- package/dist/components/mg-action-more.js.map +1 -1
- package/dist/components/mg-badge2.js +1 -1
- package/dist/components/mg-badge2.js.map +1 -1
- package/dist/components/mg-button2.js +2 -1
- package/dist/components/mg-button2.js.map +1 -1
- package/dist/components/mg-card2.js +4 -4
- package/dist/components/mg-card2.js.map +1 -1
- package/dist/components/mg-form.js +2 -1
- package/dist/components/mg-form.js.map +1 -1
- package/dist/components/mg-icon2.js +2 -2
- package/dist/components/mg-icon2.js.map +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +9 -4
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
- package/dist/components/mg-input-checkbox.js +6 -5
- package/dist/components/mg-input-checkbox.js.map +1 -1
- package/dist/components/mg-input-date.js +1 -1
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +5 -4
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-password.js +1 -1
- package/dist/components/mg-input-password.js.map +1 -1
- package/dist/components/mg-input-select2.js +3 -3
- package/dist/components/mg-input-select2.js.map +1 -1
- package/dist/components/mg-input-text2.js +2 -2
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-input-textarea.js +1 -1
- package/dist/components/mg-input-textarea.js.map +1 -1
- package/dist/components/mg-input-title2.js +3 -1
- package/dist/components/mg-input-title2.js.map +1 -1
- package/dist/components/mg-input-toggle.js +41 -3
- package/dist/components/mg-input-toggle.js.map +1 -1
- package/dist/components/mg-item-more.js +2 -1
- package/dist/components/mg-item-more.js.map +1 -1
- package/dist/components/mg-menu2.js +1 -1
- package/dist/components/mg-menu2.js.map +1 -1
- package/dist/components/mg-pagination2.js +1 -1
- package/dist/components/mg-pagination2.js.map +1 -1
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-panel.js.map +1 -1
- package/dist/components/mg-tooltip2.js +1 -1
- package/dist/components/mg-tooltip2.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_34.entry.js +84 -40
- package/dist/esm/mg-action-more_34.entry.js.map +1 -1
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-item-more.entry.js +2 -1
- package/dist/esm/mg-item-more.entry.js.map +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/mg-components.esm.js.map +1 -1
- package/dist/mg-components/p-01ebc95a.entry.js +2 -0
- package/dist/mg-components/p-01ebc95a.entry.js.map +1 -0
- package/dist/mg-components/p-71a5a848.entry.js +2 -0
- package/dist/mg-components/p-71a5a848.entry.js.map +1 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +4 -0
- package/dist/types/components/atoms/mg-input-title/test/mg-input-title.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.d.ts +4 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +1 -4
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.conf.d.ts +3 -6
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +22 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/menu/mg-menu/test/mg-menu.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.playwright.d.ts +1 -0
- package/dist/types/components/molecules/mg-action-more/mg-action-more.conf.d.ts +1 -3
- package/dist/types/components.d.ts +26 -4
- package/package.json +6 -6
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.js +0 -18
- package/dist/collection/components/atoms/mg-input-title/test/mg-input-title.e2e.js.map +0 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.js +0 -125
- package/dist/collection/components/molecules/inputs/mg-input-toggle/test/mg-input-toggle.e2e.js.map +0 -1
- package/dist/collection/components/molecules/menu/mg-menu/test/mg-menu.e2e.js.map +0 -1
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.js +0 -119
- package/dist/collection/components/molecules/menu/mg-menu-item/test/mg-menu-item.e2e.js.map +0 -1
- package/dist/mg-components/p-768fc594.entry.js +0 -2
- package/dist/mg-components/p-768fc594.entry.js.map +0 -1
- package/dist/mg-components/p-d2d6afec.entry.js +0 -2
- package/dist/mg-components/p-d2d6afec.entry.js.map +0 -1
|
@@ -99,7 +99,7 @@ const MgActionMore = class {
|
|
|
99
99
|
if (newValue && !isMgActionMoreIcon(newValue)) {
|
|
100
100
|
throw new Error(`<${this.name}> prop icon must match MgActionMoreIconType.`);
|
|
101
101
|
}
|
|
102
|
-
else if (!
|
|
102
|
+
else if (!(newValue === null || newValue === void 0 ? void 0 : newValue.icon) && Boolean(this.button.isIcon)) {
|
|
103
103
|
this.icon = { icon: 'ellipsis' };
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -183,7 +183,7 @@ const MgBadge = class {
|
|
|
183
183
|
this.classCollection = new ClassList(['mg-c-badge']);
|
|
184
184
|
}
|
|
185
185
|
validateValue(newValue) {
|
|
186
|
-
if (
|
|
186
|
+
if (/^(\d+\+*|[?*!a-z])$/i.exec(`${newValue}`) === null) {
|
|
187
187
|
throw new Error('<mg-badge> prop "value" must be integer or ponctuation character.');
|
|
188
188
|
}
|
|
189
189
|
}
|
|
@@ -370,7 +370,8 @@ const MgButton = class {
|
|
|
370
370
|
* @returns html element
|
|
371
371
|
*/
|
|
372
372
|
render() {
|
|
373
|
-
|
|
373
|
+
var _a;
|
|
374
|
+
return (h(Host, { role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": (_a = this.disabled) === null || _a === void 0 ? void 0 : _a.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, h("div", { class: this.classCollection.join(), id: this.identifier }, this.loading && h("mg-icon", { icon: "loader", spin: true }), h("div", { class: "mg-c-button__content" }, h("slot", null)))));
|
|
374
375
|
}
|
|
375
376
|
get element() { return getElement(this); }
|
|
376
377
|
static get watchers() { return {
|
|
@@ -416,11 +417,11 @@ const MgCard = class {
|
|
|
416
417
|
validateVariant(newValue, oldValue) {
|
|
417
418
|
if (newValue && !variants$3.includes(newValue))
|
|
418
419
|
throw new Error(`<${this.name}> prop "variant" must match VariantType type.`);
|
|
419
|
-
if (
|
|
420
|
+
if (newValue) {
|
|
420
421
|
this.setDefaultVariantStyle();
|
|
421
422
|
this.classCollection.add(`${this.classBase}--${newValue}`);
|
|
422
423
|
}
|
|
423
|
-
if (
|
|
424
|
+
if (oldValue)
|
|
424
425
|
this.classCollection.delete(`${this.classBase}--${oldValue}`);
|
|
425
426
|
}
|
|
426
427
|
validateVariantStyle(newValue, oldValue) {
|
|
@@ -428,9 +429,9 @@ const MgCard = class {
|
|
|
428
429
|
throw new Error(`<${this.name}> prop "variantStyle" must match VariantStyleType type.`);
|
|
429
430
|
else if (Boolean(newValue) && !variants$3.includes(this.variant))
|
|
430
431
|
throw new Error(`<${this.name}> prop "variantStyle" must be paired with ${JSON.stringify(variants$3)} "variant" prop.`);
|
|
431
|
-
if (
|
|
432
|
+
if (newValue)
|
|
432
433
|
this.classCollection.add(`${this.classBase}--${newValue}`);
|
|
433
|
-
if (
|
|
434
|
+
if (oldValue)
|
|
434
435
|
this.classCollection.delete(`${this.classBase}--${oldValue}`);
|
|
435
436
|
}
|
|
436
437
|
/*************
|
|
@@ -667,7 +668,8 @@ const MgForm = class {
|
|
|
667
668
|
async displayError() {
|
|
668
669
|
if (!this.readonly) {
|
|
669
670
|
this.mgInputs.forEach(input => {
|
|
670
|
-
|
|
671
|
+
var _a;
|
|
672
|
+
(_a = input.displayError) === null || _a === void 0 ? void 0 : _a.call(input);
|
|
671
673
|
});
|
|
672
674
|
this.checkValidity();
|
|
673
675
|
}
|
|
@@ -1168,7 +1170,7 @@ const MgIcon = class {
|
|
|
1168
1170
|
}
|
|
1169
1171
|
}
|
|
1170
1172
|
validateVariant(newValue, oldValue) {
|
|
1171
|
-
if (
|
|
1173
|
+
if (newValue) {
|
|
1172
1174
|
if (!variants$2.includes(newValue))
|
|
1173
1175
|
throw new Error(`<mg-icon> prop "variant" must be one of: ${variants$2.join(', ')}`);
|
|
1174
1176
|
else {
|
|
@@ -1180,7 +1182,7 @@ const MgIcon = class {
|
|
|
1180
1182
|
}
|
|
1181
1183
|
}
|
|
1182
1184
|
validateVariantStyle(newValue, oldValue) {
|
|
1183
|
-
if (
|
|
1185
|
+
if (newValue) {
|
|
1184
1186
|
if (!variantStyles.includes(newValue))
|
|
1185
1187
|
throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
|
|
1186
1188
|
else {
|
|
@@ -1315,7 +1317,7 @@ const manageClasses = (props) => {
|
|
|
1315
1317
|
* @param isFieldset - is fieldset
|
|
1316
1318
|
* @returns tag name
|
|
1317
1319
|
*/
|
|
1318
|
-
const getTagName = (isFieldset) => (isFieldset ? '
|
|
1320
|
+
const getTagName = (isFieldset, readOnly) => (!isFieldset || readOnly ? 'div' : 'fieldset');
|
|
1319
1321
|
/**
|
|
1320
1322
|
* Get input template
|
|
1321
1323
|
* @param props - MgInput Interface Props
|
|
@@ -1374,7 +1376,7 @@ const MgInput = (props, children, utils) => {
|
|
|
1374
1376
|
*
|
|
1375
1377
|
* Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change
|
|
1376
1378
|
*/
|
|
1377
|
-
const TagName = getTagName(props.isFieldset);
|
|
1379
|
+
const TagName = getTagName(props.isFieldset, props.readonly);
|
|
1378
1380
|
/**
|
|
1379
1381
|
* Get tooltip node
|
|
1380
1382
|
* @returns mg-tooltip
|
|
@@ -1386,7 +1388,7 @@ const MgInput = (props, children, utils) => {
|
|
|
1386
1388
|
* Display asterisk only if not disabled and not readonly
|
|
1387
1389
|
* @returns mg-input-title
|
|
1388
1390
|
*/
|
|
1389
|
-
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'mg-u-visually-hidden' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
|
|
1391
|
+
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, readonly: props.readonly, class: props.labelHide ? 'mg-u-visually-hidden' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
|
|
1390
1392
|
return (h(TagName, { class: props.classCollection.join() },
|
|
1391
1393
|
props.labelOnTop ? (h("div", { class: "mg-c-input__title" },
|
|
1392
1394
|
getInputTitle(),
|
|
@@ -1435,9 +1437,12 @@ h("ul", { class: {
|
|
|
1435
1437
|
'mg-c-input__input-checkbox-multi-inputs': props.type === 'multi' && !props.readonly,
|
|
1436
1438
|
}, role: "list", "aria-describedby": props.displaySearchInput ? 'search-results' : undefined, "aria-label": props.displaySearchInput ? props.messages.searchResults : undefined, "aria-live": props.displaySearchInput ? 'polite' : undefined, id: props.id }, props.checkboxes
|
|
1437
1439
|
.filter(item => !props.readonly || item.value)
|
|
1438
|
-
.map(input =>
|
|
1439
|
-
|
|
1440
|
-
h("
|
|
1440
|
+
.map(input => {
|
|
1441
|
+
var _a;
|
|
1442
|
+
return (h("li", { key: input._id, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': props.disabled || input.disabled } },
|
|
1443
|
+
h("input", { type: "checkbox", id: input._id, name: props.name, value: input.value && input.value.toString(), checked: Boolean(input.value), required: input.required, "aria-invalid": ((_a = props.invalid) === null || _a === void 0 ? void 0 : _a.toString()) || 'false', disabled: props.readonly || props.disabled || input.disabled, indeterminate: input.value === null, onInput: input._handleInput, onBlur: input._handleBlur, onKeyDown: input._handleKeydown }),
|
|
1444
|
+
h("label", { htmlFor: input._id }, input.title)));
|
|
1445
|
+
})));
|
|
1441
1446
|
|
|
1442
1447
|
const mgInputCheckboxCss = ":host{display:block}.mg-c-input__input mg-icon,.mg-c-input__error mg-icon{display:flex}.mg-c-input{display:flex;max-width:100%;min-height:var(--default-size);align-items:flex-start;margin-bottom:var(--mg-inputs-margin-bottom, 0)}.mg-c-input mg-input-title{width:var(--mg-inputs-title-width, auto);flex-shrink:var(--mg-inputs-shrink, 1);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-c-input__error{display:inline-block;padding:.3rem .8rem;border-radius:.3rem;margin-top:.2rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-c-input__input-container{min-height:var(--default-size)}.mg-c-input__input-container>strong{display:inline-block;min-height:var(--font-size);margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2)}.mg-c-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-c-input__input-container .mg-c-input__help-text,.mg-c-input__input-container .mg-c-input__error{font-size:1.2rem;text-align:start}.mg-c-input.mg-c-input--label-on-top{flex-direction:column}.mg-c-input.mg-c-input--label-on-top .mg-c-input__input-container{width:100%}.mg-c-input__title{display:flex;align-items:baseline;margin-bottom:.3rem}.mg-c-input__title mg-input-title{width:auto;flex-shrink:1;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-c-input__title mg-tooltip{margin-top:0}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__input{display:flex}.mg-c-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size))/2)}.mg-c-input__input.mg-c-input__input--has-error .mg-c-input__box{border-color:hsl(var(--color-danger))}.mg-c-input__input+.mg-c-input__help-text,.mg-c-input__input+.mg-c-input__error{margin-top:.5rem}.mg-c-input__input .mg-c-input__box:disabled,.mg-c-input__input-group--disabled label,.mg-c-input.mg-c-input--toggle-disabled .mg-c-input__input .mg-c-input__button-toggle,.mg-c-input.mg-c-input--checkbox-multi-disabled .mg-c-input__input strong{opacity:var(--mg-disabled-opacity)}.mg-c-input__input-group-container{display:flex;flex-wrap:wrap;padding:0;margin:0;margin-top:calc((var(--default-size) - var(--font-size)*var(--line-height))/2);column-gap:2.3rem;list-style:none;row-gap:1rem}.mg-c-input__input-group-container--vertical{flex-direction:column}fieldset.mg-c-input{padding:0;border:0;margin-right:0;margin-left:0}fieldset.mg-c-input input[type=radio],fieldset.mg-c-input input[type=checkbox]{width:var(--mg-input-check-size);height:var(--mg-input-check-size);flex-shrink:0;margin:calc((var(--font-size)*var(--line-height) - var(--mg-input-check-size))/2) .6rem 0 0}fieldset.mg-c-input.mg-c-input--label-on-top .mg-c-input__input-group-container{margin-top:.7rem}.mg-c-input__input-container mg-tooltip{margin-left:3rem}.mg-c-input__input-group{display:flex;align-items:start}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi{display:flex;flex-wrap:wrap;gap:calc(var(--mg-inputs-spacer)*1.2)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi--with-values.mg-c-input__input-checkbox-multi{gap:.4rem}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-values-container{display:flex;flex-flow:row wrap;gap:calc(0.4rem * 1);padding:0;margin:0;list-style:none}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-value{display:inline-flex;min-width:var(--default-size);min-height:var(--default-size);box-sizing:border-box;align-items:center;justify-content:center;padding:calc((var(--default-size) - .2rem - var(--font-size)*var(--line-height))/2) 1.1rem;border-radius:.3rem;background-color:hsl(var(--mg-color-dark-5-hsl));font-size:var(--font-size)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-no-result{text-align:center}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-text,.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-title{display:inline;margin:0;color:hsl(var(--mg-color-dark-40-hsl))}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-title{margin:0 1.1rem}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-sections{display:flex;flex-flow:column wrap;gap:calc(0.4rem * 1)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-sections-container{display:flex;flex-flow:column nowrap;gap:calc(0.4rem * 0);max-height:80vh;padding-right:1rem;overflow-y:auto}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-section-header{display:flex;flex-flow:row wrap;gap:calc(0.4rem * 2);min-height:var(--default-size);align-items:center}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-checkbox-multi-inputs{padding:.4rem calc(0.4rem * 2) .4rem calc(0.4rem / 2);margin:0}.mg-c-input.mg-c-input--checkbox-multi:not(.mg-c-input--label-on-top) mg-tooltip{margin-left:var(--mg-inputs-spacer)}.mg-c-input.mg-c-input--checkbox-multi mg-popover{--mg-popover-min-width:7rem;--mg-card-padding:calc(0.4rem * 2)}.mg-c-input.mg-c-input--checkbox-multi mg-popover-content [slot=content]{display:flex;flex-flow:column wrap;gap:calc(0.4rem * 2)}.mg-c-input.mg-c-input--checkbox-multi mg-popover-content [slot=content] .mg-c-input__input-group{margin-left:calc(0.4rem * 2)}.mg-c-input.mg-c-input--checkbox-multi mg-input-text{--mg-inputs-margin-bottom:0}";
|
|
1443
1448
|
|
|
@@ -1484,11 +1489,11 @@ const MgInputCheckbox = class {
|
|
|
1484
1489
|
return;
|
|
1485
1490
|
}
|
|
1486
1491
|
const enableInputs = Array.from(this.element.shadowRoot.querySelectorAll('input'))
|
|
1487
|
-
.filter(input => !
|
|
1492
|
+
.filter(input => !input.getAttribute('disabled'))
|
|
1488
1493
|
.map(({ id }) => id);
|
|
1489
1494
|
const originInputIndex = enableInputs.findIndex(id => id === event.target.id);
|
|
1490
1495
|
// close popover when tab trigger focus outside its DOM
|
|
1491
|
-
if ((originInputIndex + 1 >= enableInputs.length && !event.shiftKey) || (originInputIndex === 0 && event.shiftKey && !
|
|
1496
|
+
if ((originInputIndex + 1 >= enableInputs.length && !event.shiftKey) || (originInputIndex === 0 && event.shiftKey && !this.searchInput))
|
|
1492
1497
|
this.mgPopover.display = false;
|
|
1493
1498
|
}
|
|
1494
1499
|
};
|
|
@@ -1810,19 +1815,20 @@ const MgInputCheckbox = class {
|
|
|
1810
1815
|
const selectedValuesNb = this.checkboxItems.filter(({ value }) => value).length;
|
|
1811
1816
|
const checkboxes = this.getDisplayItems();
|
|
1812
1817
|
return (h("div", { class: { 'mg-c-input__input-container': true, 'mg-c-input__input-checkbox-multi': true, 'mg-c-input__input-checkbox-multi--with-values': this.displaySelectedValues } }, this.renderCheckboxMultiDisplaySelectedValues(selectedValuesNb), h("mg-popover", { arrowHide: true, identifier: this.getMgPopoverIdentifier(), "onDisplay-change": this.handleMgPopoverDisplayChange, ref: (el) => {
|
|
1813
|
-
if (
|
|
1818
|
+
if (el)
|
|
1814
1819
|
this.mgPopover = el;
|
|
1815
1820
|
} }, h("mg-button", { variant: "secondary" }, h("mg-icon", { icon: "list" }), this.renderButtonText(selectedValuesNb)), h("div", { slot: "content" }, this.displaySearchInput && [
|
|
1816
1821
|
h("mg-input-text", { key: "input-search", identifier: `${this.identifier}-input-search`, icon: "magnifying-glass", type: "search", placeholder: this.messages.input.checkbox.label, label: this.messages.input.checkbox.label, mgWidth: "full", value: this.searchValue, labelHide: true, displayCharacterLeft: false, name: "q", "onValue-change": this.handleSearchChange, "aria-controls": "search-results items-list" }),
|
|
1817
1822
|
h("p", { key: "search-results", role: "status", class: "mg-u-visually-hidden", id: "search-results" }, `${checkboxes.length} ${this.messages.input.checkbox[checkboxes.length > 0 ? 'results' : 'result']}`),
|
|
1818
|
-
], this.displaySearchInput ? (h("div", { class: "mg-c-input__input-checkbox-multi-sections-container" }, this.renderCheckboxBySection(checkboxes))) : (h(MgInputCheckboxList, { checkboxes: checkboxes, inputVerticalList: true, type: this.type, readonly: this.readonly, displaySearchInput: this.displaySearchInput, messages: this.messages.input.checkbox, id: "checkboxes-list", disabled: this.disabled, name: this.name })), this.displaySearchInput && checkboxes.length === 0 && h("p", { class: "mg-c-input__input-checkbox-multi-no-result" }, this.messages.input.checkbox.noResult)))));
|
|
1823
|
+
], this.displaySearchInput ? (h("div", { class: "mg-c-input__input-checkbox-multi-sections-container" }, this.renderCheckboxBySection(checkboxes))) : (h(MgInputCheckboxList, { checkboxes: checkboxes, inputVerticalList: true, type: this.type, readonly: this.readonly, displaySearchInput: this.displaySearchInput, messages: this.messages.input.checkbox, id: "checkboxes-list", disabled: this.disabled, name: this.name, invalid: this.invalid })), this.displaySearchInput && checkboxes.length === 0 && h("p", { class: "mg-c-input__input-checkbox-multi-no-result" }, this.messages.input.checkbox.noResult)))));
|
|
1819
1824
|
}
|
|
1820
1825
|
/**
|
|
1821
1826
|
* Render
|
|
1822
1827
|
* @returns HTML Element
|
|
1823
1828
|
*/
|
|
1824
1829
|
render() {
|
|
1825
|
-
|
|
1830
|
+
var _a;
|
|
1831
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: (_a = this.value) === null || _a === void 0 ? void 0 : _a.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, this.type === 'checkbox' || this.readonly ? (h(MgInputCheckboxList, { checkboxes: this.checkboxItems, inputVerticalList: this.inputVerticalList, type: this.type, readonly: this.readonly, displaySearchInput: this.displaySearchInput, messages: this.messages.input.checkbox, id: "checkboxes-list", disabled: this.disabled, name: this.name, invalid: this.invalid })) : (this.renderCheckboxMulti())));
|
|
1826
1832
|
}
|
|
1827
1833
|
get element() { return getElement(this); }
|
|
1828
1834
|
static get watchers() { return {
|
|
@@ -1884,6 +1890,7 @@ const MgInputCheckboxPaginated = class {
|
|
|
1884
1890
|
this.readonly = undefined;
|
|
1885
1891
|
this.disabled = undefined;
|
|
1886
1892
|
this.name = undefined;
|
|
1893
|
+
this.invalid = undefined;
|
|
1887
1894
|
this.checkboxes = [];
|
|
1888
1895
|
this.sectionKind = undefined;
|
|
1889
1896
|
this.messages = undefined;
|
|
@@ -1933,7 +1940,7 @@ const MgInputCheckboxPaginated = class {
|
|
|
1933
1940
|
const [checkboxItemsFromIndex, checkboxItemsToIndex] = this.getFromToIndexes();
|
|
1934
1941
|
const itemsContainerId = `items-${this.sectionKind}-container`;
|
|
1935
1942
|
const getText = (checkboxes) => h("em", null, `${this.messages[checkboxes.length > 1 ? 'titlePlurial' : 'title']} (${checkboxes.length})`);
|
|
1936
|
-
return (h(Host, { hidden: this.checkboxes.length < 1 }, h("div", { class: "mg-c-input__input-checkbox-multi-section-header" }, this.titleKind === SectionTitleKind.BUTTON ? (h("mg-button", { variant: "flat", onClick: this.handleToggleClick, "aria-controls": itemsContainerId, "aria-expanded": this.expanded.toString() }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down', size: "small" }), h("span", { class: "mg-c-input__input-checkbox-multi-text" }, getText(this.checkboxes)))) : (h("p", { class: "mg-c-input__input-checkbox-multi-title" }, getText(this.checkboxes))), ((this.sectionKind === SectionKind.SELECTED && this.expanded) || this.sectionKind === SectionKind.NOT_SELECTED) && (h("mg-button", { variant: "link", onClick: this.massActionHandler }, this.messages.action)), this.expanded && this.getPageCount(this.checkboxes) > 1 && (h("mg-pagination", { key: "search-pagination", totalPages: this.getPageCount(this.checkboxes), currentPage: this.currentPage > 1 ? this.currentPage : 1, "onCurrent-page-change": this.handleCurrentPageChange, hideNavigationLabels: true, hidePageCount: true, identifier: `input-checkbox-pagination-${this.sectionKind}` }))), h("div", { hidden: !this.expanded, id: itemsContainerId, class: "mg-c-input__input-checkbox-multi-section-content" }, h(MgInputCheckboxList, { checkboxes: this.getArrayRange(this.checkboxes, checkboxItemsFromIndex, checkboxItemsToIndex), inputVerticalList: true, type: 'multi', displaySearchInput: true, messages: this.messages, id: `items-${this.sectionKind}`, readonly: this.readonly, disabled: this.disabled, name: this.name }))));
|
|
1943
|
+
return (h(Host, { hidden: this.checkboxes.length < 1 }, h("div", { class: "mg-c-input__input-checkbox-multi-section-header" }, this.titleKind === SectionTitleKind.BUTTON ? (h("mg-button", { variant: "flat", onClick: this.handleToggleClick, "aria-controls": itemsContainerId, "aria-expanded": this.expanded.toString() }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down', size: "small" }), h("span", { class: "mg-c-input__input-checkbox-multi-text" }, getText(this.checkboxes)))) : (h("p", { class: "mg-c-input__input-checkbox-multi-title" }, getText(this.checkboxes))), ((this.sectionKind === SectionKind.SELECTED && this.expanded) || this.sectionKind === SectionKind.NOT_SELECTED) && (h("mg-button", { variant: "link", onClick: this.massActionHandler }, this.messages.action)), this.expanded && this.getPageCount(this.checkboxes) > 1 && (h("mg-pagination", { key: "search-pagination", totalPages: this.getPageCount(this.checkboxes), currentPage: this.currentPage > 1 ? this.currentPage : 1, "onCurrent-page-change": this.handleCurrentPageChange, hideNavigationLabels: true, hidePageCount: true, identifier: `input-checkbox-pagination-${this.sectionKind}` }))), h("div", { hidden: !this.expanded, id: itemsContainerId, class: "mg-c-input__input-checkbox-multi-section-content" }, h(MgInputCheckboxList, { checkboxes: this.getArrayRange(this.checkboxes, checkboxItemsFromIndex, checkboxItemsToIndex), inputVerticalList: true, type: 'multi', displaySearchInput: true, messages: this.messages, id: `items-${this.sectionKind}`, readonly: this.readonly, disabled: this.disabled, name: this.name, invalid: this.invalid }))));
|
|
1937
1944
|
}
|
|
1938
1945
|
static get watchers() { return {
|
|
1939
1946
|
"checkboxes": ["validateCheckboxes"],
|
|
@@ -2145,7 +2152,7 @@ const MgInputDate = class {
|
|
|
2145
2152
|
* @returns HTML Element
|
|
2146
2153
|
*/
|
|
2147
2154
|
render() {
|
|
2148
|
-
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
2155
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-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, ref: (el) => {
|
|
2149
2156
|
if (el !== null)
|
|
2150
2157
|
this.input = el;
|
|
2151
2158
|
} })));
|
|
@@ -2308,7 +2315,7 @@ const MgInputNumeric = class {
|
|
|
2308
2315
|
// has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type
|
|
2309
2316
|
if (typeof newValue === 'string') {
|
|
2310
2317
|
// Split number and decimal
|
|
2311
|
-
const [integer, decimal = ''] = newValue.replace('-', '').split(/[
|
|
2318
|
+
const [integer, decimal = ''] = newValue.replace('-', '').split(/[.,]/);
|
|
2312
2319
|
// Regex
|
|
2313
2320
|
const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+(?:[.,]\d*)?$/;
|
|
2314
2321
|
// Filter input
|
|
@@ -2395,14 +2402,15 @@ const MgInputNumeric = class {
|
|
|
2395
2402
|
* @returns Returns true if the value is valid, otherwise false.
|
|
2396
2403
|
*/
|
|
2397
2404
|
isValidValue(value, regex, integer, decimal) {
|
|
2398
|
-
return ['', '-'].includes(value) || (
|
|
2405
|
+
return (['', '-'].includes(value) || (regex.exec(value) !== null && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength)));
|
|
2399
2406
|
}
|
|
2400
2407
|
/**
|
|
2401
2408
|
* Handles invalid input values and returns a corrected value.
|
|
2402
2409
|
* @returns The corrected value.
|
|
2403
2410
|
*/
|
|
2404
2411
|
handleInvalidValue() {
|
|
2405
|
-
|
|
2412
|
+
var _a;
|
|
2413
|
+
return (_a = this.storedValue) !== null && _a !== void 0 ? _a : null;
|
|
2406
2414
|
}
|
|
2407
2415
|
/**
|
|
2408
2416
|
* Updates the component values based on the validated input value.
|
|
@@ -2455,7 +2463,7 @@ const MgInputNumeric = class {
|
|
|
2455
2463
|
* @returns HTML Element
|
|
2456
2464
|
*/
|
|
2457
2465
|
render() {
|
|
2458
|
-
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-c-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
2466
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "text", class: "mg-c-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
2459
2467
|
if (el !== null)
|
|
2460
2468
|
this.input = el;
|
|
2461
2469
|
} }), h("slot", { name: "append-input" })));
|
|
@@ -2614,7 +2622,7 @@ const MgInputPassword = class {
|
|
|
2614
2622
|
* @returns HTML Element
|
|
2615
2623
|
*/
|
|
2616
2624
|
render() {
|
|
2617
|
-
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "password", class: "mg-c-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
2625
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "password", class: "mg-c-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
2618
2626
|
if (el !== null)
|
|
2619
2627
|
this.input = el;
|
|
2620
2628
|
} })));
|
|
@@ -2979,7 +2987,7 @@ const MgInputSelect = class {
|
|
|
2979
2987
|
validateValue(newValue) {
|
|
2980
2988
|
var _a, _b;
|
|
2981
2989
|
if (allItemsAreString(this.items) && typeof newValue === 'string') {
|
|
2982
|
-
this.readonlyValue =
|
|
2990
|
+
this.readonlyValue = ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) ? this.input.value : newValue;
|
|
2983
2991
|
}
|
|
2984
2992
|
else if (allItemsAreOptions(this.items)) {
|
|
2985
2993
|
this.readonlyValue = (_b = this.items.find(item => item.value === newValue)) === null || _b === void 0 ? void 0 : _b.title;
|
|
@@ -3094,11 +3102,11 @@ const MgInputSelect = class {
|
|
|
3094
3102
|
* @returns HTML Element
|
|
3095
3103
|
*/
|
|
3096
3104
|
render() {
|
|
3097
|
-
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: undefined, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("select", { class: "mg-c-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
3105
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: undefined, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("select", { class: "mg-c-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
3098
3106
|
if (el !== null)
|
|
3099
3107
|
this.input = el;
|
|
3100
3108
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
3101
|
-
h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map(option => isOptGroup(option) ? h("optgroup", { label: option.group }, option.options.map(this.renderOption)) : isOption$1(option) && this.renderOption(option)))));
|
|
3109
|
+
h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map(option => isOptGroup(option) ? (h("optgroup", { label: option.group, key: option.group }, option.options.map(this.renderOption))) : (isOption$1(option) && this.renderOption(option))))));
|
|
3102
3110
|
}
|
|
3103
3111
|
get element() { return getElement(this); }
|
|
3104
3112
|
static get watchers() { return {
|
|
@@ -3238,7 +3246,7 @@ const MgInputText = class {
|
|
|
3238
3246
|
}
|
|
3239
3247
|
validateDatalistoptions(newValue) {
|
|
3240
3248
|
if (Boolean(newValue) && !isDatalistOption(newValue)) {
|
|
3241
|
-
throw new Error('<mg-input-text> prop "datalistoptions" values must be the same type,
|
|
3249
|
+
throw new Error('<mg-input-text> prop "datalistoptions" values must be the same type, string.');
|
|
3242
3250
|
}
|
|
3243
3251
|
}
|
|
3244
3252
|
handleValidityChange(newValue, _oldValue, prop) {
|
|
@@ -3335,7 +3343,7 @@ const MgInputText = class {
|
|
|
3335
3343
|
'--mg-character-left-message-length': (this.displayCharacterLeft
|
|
3336
3344
|
? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
|
|
3337
3345
|
: 0).toString(),
|
|
3338
|
-
} }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type, class: "mg-c-input__box", value: this.value, id: this.identifier, list: this.hasDatalist() ? this.datalistId : undefined, autocomplete: this.hasDatalist() ? 'off' : undefined, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
3346
|
+
} }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type, class: "mg-c-input__box", value: this.value, id: this.identifier, list: this.hasDatalist() ? this.datalistId : undefined, autocomplete: this.hasDatalist() ? 'off' : undefined, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
3339
3347
|
if (el !== null)
|
|
3340
3348
|
this.input = el;
|
|
3341
3349
|
} }), this.hasDatalist() && (h("datalist", { id: this.datalistId }, this.datalistoptions.map(option => (h("option", { value: option, key: option }))))), this.displayCharacterLeft && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))), h("slot", { name: "append-input" })));
|
|
@@ -3552,7 +3560,7 @@ const MgInputTextarea = class {
|
|
|
3552
3560
|
'mg-c-input__box--resizable': this.resizable === 'both',
|
|
3553
3561
|
'mg-c-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
3554
3562
|
'mg-c-input__box--resizable-vertical': this.resizable === 'vertical',
|
|
3555
|
-
}, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
3563
|
+
}, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
3556
3564
|
if (el !== null)
|
|
3557
3565
|
this.input = el;
|
|
3558
3566
|
} }), this.displayCharacterLeft && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
|
|
@@ -3577,6 +3585,7 @@ const MgInputTitle = class {
|
|
|
3577
3585
|
registerInstance(this, hostRef);
|
|
3578
3586
|
this.identifier = undefined;
|
|
3579
3587
|
this.required = undefined;
|
|
3588
|
+
this.readonly = undefined;
|
|
3580
3589
|
this.isLegend = false;
|
|
3581
3590
|
this.tagName = 'label';
|
|
3582
3591
|
}
|
|
@@ -3603,7 +3612,7 @@ const MgInputTitle = class {
|
|
|
3603
3612
|
* @returns HTML element
|
|
3604
3613
|
*/
|
|
3605
3614
|
render() {
|
|
3606
|
-
const TagName = this.tagName;
|
|
3615
|
+
const TagName = this.readonly ? 'span' : this.tagName;
|
|
3607
3616
|
// \u00A0 represent a
|
|
3608
3617
|
return (h(TagName, { class: "mg-c-input-title", htmlFor: this.isLegend ? undefined : this.identifier }, h("slot", null), this.required && (h("span", { class: "mg-c-input-title__required" }, "\u00A0", h("span", { class: "mg-u-is-asterisk" }, "*")))));
|
|
3609
3618
|
}
|
|
@@ -3636,6 +3645,18 @@ const MgInputToggle = class {
|
|
|
3636
3645
|
this.classIsActive = 'mg-c-input--toggle-is-active';
|
|
3637
3646
|
this.classOnOff = 'mg-c-input--toggle-on-off';
|
|
3638
3647
|
this.classIcon = 'mg-c-input--toggle-icon';
|
|
3648
|
+
/**
|
|
3649
|
+
* Set input error message
|
|
3650
|
+
* @param errorMessage - errorMessage override
|
|
3651
|
+
*/
|
|
3652
|
+
this.setErrorMessage = (errorMessage) => {
|
|
3653
|
+
// Set error message
|
|
3654
|
+
this.errorMessage = undefined;
|
|
3655
|
+
// Does have a custom error message
|
|
3656
|
+
if (!this.valid && errorMessage !== undefined) {
|
|
3657
|
+
this.errorMessage = errorMessage;
|
|
3658
|
+
}
|
|
3659
|
+
};
|
|
3639
3660
|
/**
|
|
3640
3661
|
* Change checked value
|
|
3641
3662
|
*/
|
|
@@ -3671,6 +3692,8 @@ const MgInputToggle = class {
|
|
|
3671
3692
|
this.helpText = undefined;
|
|
3672
3693
|
this.classCollection = new ClassList(['mg-c-input--toggle']);
|
|
3673
3694
|
this.options = undefined;
|
|
3695
|
+
this.errorMessage = undefined;
|
|
3696
|
+
this.valid = undefined;
|
|
3674
3697
|
this.checked = false;
|
|
3675
3698
|
}
|
|
3676
3699
|
handleValue(newValue) {
|
|
@@ -3728,6 +3751,27 @@ const MgInputToggle = class {
|
|
|
3728
3751
|
// update value
|
|
3729
3752
|
this.value = this.options[newValue ? 1 : 0].value;
|
|
3730
3753
|
}
|
|
3754
|
+
/**
|
|
3755
|
+
* Set an error and display a custom error message.
|
|
3756
|
+
* This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.
|
|
3757
|
+
* It must be paired with an error message to display for the given context.
|
|
3758
|
+
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
3759
|
+
* @param valid - value indicating the validity
|
|
3760
|
+
* @param errorMessage - the error message to display
|
|
3761
|
+
*/
|
|
3762
|
+
async setError(valid, errorMessage) {
|
|
3763
|
+
if (typeof valid !== 'boolean') {
|
|
3764
|
+
throw new Error('<mg-input-toggle> method "setError()" param "valid" must be a boolean');
|
|
3765
|
+
}
|
|
3766
|
+
else if (!isValidString(errorMessage)) {
|
|
3767
|
+
throw new Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string');
|
|
3768
|
+
}
|
|
3769
|
+
else {
|
|
3770
|
+
this.valid = valid;
|
|
3771
|
+
this.inputValid.emit(valid);
|
|
3772
|
+
this.setErrorMessage(valid ? undefined : errorMessage);
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3731
3775
|
/**
|
|
3732
3776
|
* set checked state
|
|
3733
3777
|
*/
|
|
@@ -3774,7 +3818,7 @@ const MgInputToggle = class {
|
|
|
3774
3818
|
* @returns HTML Element
|
|
3775
3819
|
*/
|
|
3776
3820
|
render() {
|
|
3777
|
-
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage:
|
|
3821
|
+
return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-c-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-2" })))));
|
|
3778
3822
|
}
|
|
3779
3823
|
get element() { return getElement(this); }
|
|
3780
3824
|
static get watchers() { return {
|
|
@@ -3833,7 +3877,7 @@ const MgMenu = class {
|
|
|
3833
3877
|
(item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, () => {
|
|
3834
3878
|
this.focusedMenuItem = index;
|
|
3835
3879
|
// reset expanded on previous active menu item
|
|
3836
|
-
(
|
|
3880
|
+
(this.getItemMoreMenuItem() ? [...this.menuItems, this.getItemMoreMenuItem()] : this.menuItems).forEach((item, index) => {
|
|
3837
3881
|
this.closeMenuItem(item, index !== this.focusedMenuItem);
|
|
3838
3882
|
});
|
|
3839
3883
|
});
|
|
@@ -4704,7 +4748,7 @@ const MgPagination = class {
|
|
|
4704
4748
|
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
|
|
4705
4749
|
// eslint-disable-next-line react/jsx-no-bind
|
|
4706
4750
|
onClick: () => this.handleGoToPage(action, disabled), disabled: disabled, variant: "flat", isIcon: this.hideNavigationLabels }, action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }), !this.hideNavigationLabels && this.messages.general[action], action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
|
|
4707
|
-
return (h(Host, { hidden: this.totalPages < 2 }, h("nav", { "aria-label": this.label, id: this.identifier, class: { 'mg-c-pagination': true, 'mg-c-pagination--hide-page-count': this.hidePageCount } }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), !this.hidePageCount && (h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true })), h("span", { class: "mg-u-visually-hidden" }, this.messages.pagination.page, " ", this.currentPage), h("span", { class: { 'mg-u-visually-hidden': this.hidePageCount } }, "/ ", this.totalPages, " ", this.totalPages > 1 ? this.messages.pagination.pages : this.messages.pagination.page), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT))));
|
|
4751
|
+
return (h(Host, { hidden: this.totalPages < 2 }, h("nav", { role: "navigation", "aria-label": this.label, id: this.identifier, class: { 'mg-c-pagination': true, 'mg-c-pagination--hide-page-count': this.hidePageCount } }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), !this.hidePageCount && (h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true })), h("span", { class: "mg-u-visually-hidden" }, this.messages.pagination.page, " ", this.currentPage), h("span", { class: { 'mg-u-visually-hidden': this.hidePageCount } }, "/ ", this.totalPages, " ", this.totalPages > 1 ? this.messages.pagination.pages : this.messages.pagination.page), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT))));
|
|
4708
4752
|
}
|
|
4709
4753
|
get element() { return getElement(this); }
|
|
4710
4754
|
static get watchers() { return {
|
|
@@ -4786,7 +4830,7 @@ const MgPanel = class {
|
|
|
4786
4830
|
* Render collapse button
|
|
4787
4831
|
* @returns collpase button
|
|
4788
4832
|
*/
|
|
4789
|
-
this.renderCollapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", identifier: `${this.identifier}-collapse-button`, "aria-expanded": this.expanded
|
|
4833
|
+
this.renderCollapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", identifier: `${this.identifier}-collapse-button`, "aria-expanded": this.expanded.toString(), "aria-controls": `${this.identifier}-content`, disabled: this.expandToggleDisabled, isIcon: this.expandToggleDisplay === 'icon', label: this.panelTitle }, h("span", { class: "mg-c-panel__collapse-button-content" }, h("mg-icon", { icon: "chevron-up", class: { 'mg-c-panel__collapse-button-icon': true, 'mg-c-panel__collapse-button-icon--reverse': !this.expanded } }), !this.isEditing && this.expandToggleDisplay !== 'icon' && this.panelTitle)));
|
|
4790
4834
|
/**
|
|
4791
4835
|
* Render edit button
|
|
4792
4836
|
* @returns edit Button
|
|
@@ -7437,7 +7481,7 @@ const MgTooltip = class {
|
|
|
7437
7481
|
*/
|
|
7438
7482
|
this.initTooltip = (slotElement, interactiveElement) => {
|
|
7439
7483
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
7440
|
-
if (!this.disabled && !
|
|
7484
|
+
if (!this.disabled && !interactiveElement) {
|
|
7441
7485
|
this.hasCustomTabIndex = true;
|
|
7442
7486
|
slotElement.tabIndex = 0;
|
|
7443
7487
|
// Add role on non-interactive element to work with "aria-describedby" for screen readers
|