@mgdis/mg-components 5.27.3 → 5.27.4
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-8e9b0d9b.js → index-11b35234.js} +47 -47
- package/dist/cjs/index-11b35234.js.map +1 -0
- package/dist/cjs/{index-7bb96ccc.js → index-3198e64e.js} +79 -27
- package/dist/cjs/index-3198e64e.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_36.cjs.entry.js +237 -191
- package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-components.cjs.js.map +1 -1
- package/dist/cjs/mg-loader.cjs.entry.js +3 -3
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +124 -97
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +1 -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.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +21 -3
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
- package/dist/components/index.es.js +39 -39
- package/dist/components/index.es.js.map +1 -1
- package/dist/components/index2.js +2 -2
- package/dist/components/mg-action-more.js +2 -2
- package/dist/components/mg-badge2.js +3 -3
- package/dist/components/mg-button2.js +4 -4
- package/dist/components/mg-card2.js +2 -2
- package/dist/components/mg-details.js +2 -2
- package/dist/components/mg-form.js +3 -3
- package/dist/components/mg-icon2.js +2 -2
- package/dist/components/mg-illustrated-message.js +2 -2
- package/dist/components/mg-input-checkbox-paginated2.js +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
- package/dist/components/mg-input-checkbox.js +25 -7
- package/dist/components/mg-input-checkbox.js.map +1 -1
- package/dist/components/mg-input-date.js +11 -11
- package/dist/components/mg-input-numeric.js +5 -5
- package/dist/components/mg-input-password.js +3 -3
- package/dist/components/mg-input-radio.js +4 -4
- package/dist/components/mg-input-select2.js +6 -6
- package/dist/components/mg-input-text2.js +6 -6
- package/dist/components/mg-input-textarea.js +6 -6
- package/dist/components/mg-input-title2.js +2 -2
- package/dist/components/mg-input-toggle.js +4 -4
- package/dist/components/mg-input2.js +4 -3
- package/dist/components/mg-input2.js.map +1 -1
- package/dist/components/mg-item-more2.js +2 -2
- package/dist/components/mg-loader.js +2 -2
- package/dist/components/mg-menu-item2.js +5 -5
- package/dist/components/mg-message.js +3 -3
- package/dist/components/mg-modal.js +6 -6
- package/dist/components/mg-pagination2.js +2 -2
- package/dist/components/mg-panel.js +4 -4
- package/dist/components/mg-popover-content2.js +3 -3
- package/dist/components/mg-popover2.js +3 -3
- package/dist/components/mg-skip-links.js +2 -2
- package/dist/components/mg-tabs.js +6 -6
- package/dist/components/mg-tag.js +3 -3
- package/dist/components/mg-tooltip2.js +134 -107
- package/dist/components/mg-tooltip2.js.map +1 -1
- package/dist/esm/{index-138ea119.js → index-00abd8c1.js} +41 -41
- package/dist/esm/index-00abd8c1.js.map +1 -0
- package/dist/esm/{index-c4faef56.js → index-99317ec3.js} +79 -27
- package/dist/esm/index-99317ec3.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_36.entry.js +237 -191
- package/dist/esm/mg-action-more_36.entry.js.map +1 -1
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-components.js.map +1 -1
- package/dist/esm/mg-loader.entry.js +3 -3
- package/dist/mg-components/index.esm.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-48c0a0bf.entry.js +2 -0
- package/dist/mg-components/p-48c0a0bf.entry.js.map +1 -0
- package/dist/mg-components/p-4cfcbdc2.js +2 -0
- package/dist/mg-components/p-4cfcbdc2.js.map +1 -0
- package/dist/mg-components/p-815362e4.js +3 -0
- package/dist/mg-components/p-815362e4.js.map +1 -0
- package/dist/mg-components/{p-bac6ca1f.entry.js → p-d3e15dd7.entry.js} +2 -2
- package/dist/mg-components/{p-bac6ca1f.entry.js.map → p-d3e15dd7.entry.js.map} +1 -1
- package/dist/mg-components/p-e1255160.js.map +1 -1
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +25 -12
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +2 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +2 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +8 -0
- package/dist/types/stencil-public-runtime.d.ts +3 -8
- package/ide/intellij/web-types.json +1 -1
- package/ide/vscode/html-custom-data.json +1 -1
- package/loader/cdn.js +1 -3
- package/loader/index.cjs.js +1 -3
- package/loader/index.es2017.js +1 -3
- package/loader/index.js +1 -3
- package/package.json +24 -24
- package/dist/cjs/index-7bb96ccc.js.map +0 -1
- package/dist/cjs/index-8e9b0d9b.js.map +0 -1
- package/dist/esm/index-138ea119.js.map +0 -1
- package/dist/esm/index-c4faef56.js.map +0 -1
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/mg-components/p-284c8327.entry.js +0 -2
- package/dist/mg-components/p-284c8327.entry.js.map +0 -1
- package/dist/mg-components/p-4c68f6ea.js +0 -3
- package/dist/mg-components/p-4c68f6ea.js.map +0 -1
- package/dist/mg-components/p-e9433a87.js +0 -2
- package/dist/mg-components/p-e9433a87.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-
|
|
2
|
-
import {
|
|
1
|
+
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-99317ec3.js';
|
|
2
|
+
import { C as Ce, i as initLocales, H as He, I as Ie, G as Ge, B as Be, q as qe, h as he, y as ye, Z as Ze, Q as Qe, J as Je, Y as Ye, P as Pe, W as We, z as ze } from './index-00abd8c1.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Available menu-item positions
|
|
@@ -75,7 +75,7 @@ const MgActionMore = class {
|
|
|
75
75
|
************/
|
|
76
76
|
this.name = 'mg-action-more';
|
|
77
77
|
this.classBase = 'mg-c-action-more';
|
|
78
|
-
this.mgPopoverIdentifier =
|
|
78
|
+
this.mgPopoverIdentifier = Ce(this.name);
|
|
79
79
|
/************
|
|
80
80
|
* Methods *
|
|
81
81
|
***********/
|
|
@@ -199,7 +199,7 @@ const MgBadge = class {
|
|
|
199
199
|
this.label = undefined;
|
|
200
200
|
this.variant = variants$5[0];
|
|
201
201
|
this.outline = undefined;
|
|
202
|
-
this.classCollection = new
|
|
202
|
+
this.classCollection = new He(['mg-c-badge']);
|
|
203
203
|
}
|
|
204
204
|
validateValue(newValue) {
|
|
205
205
|
if (/^(\d+\+*|[?*!a-z])$/i.exec(`${newValue}`) === null) {
|
|
@@ -207,7 +207,7 @@ const MgBadge = class {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
validateLabel(newValue) {
|
|
210
|
-
if (!
|
|
210
|
+
if (!Ie(newValue)) {
|
|
211
211
|
throw new Error('<mg-badge> prop "label" is required.');
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -318,7 +318,7 @@ const MgButton = class {
|
|
|
318
318
|
this.isIcon = false;
|
|
319
319
|
this.disableOnClick = false;
|
|
320
320
|
this.loading = false;
|
|
321
|
-
this.classCollection = new
|
|
321
|
+
this.classCollection = new He(['mg-c-button']);
|
|
322
322
|
}
|
|
323
323
|
validateVariant(newValue, oldValue) {
|
|
324
324
|
if (!variants$4.includes(newValue)) {
|
|
@@ -377,7 +377,7 @@ const MgButton = class {
|
|
|
377
377
|
this.validateFullWidth(this.fullWidth);
|
|
378
378
|
if (this.isIcon) {
|
|
379
379
|
this.classCollection.add(`mg-c-button--icon`);
|
|
380
|
-
if (!
|
|
380
|
+
if (!Ie(this.label)) {
|
|
381
381
|
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
382
382
|
}
|
|
383
383
|
}
|
|
@@ -389,7 +389,7 @@ const MgButton = class {
|
|
|
389
389
|
* Add listners
|
|
390
390
|
*/
|
|
391
391
|
componentDidLoad() {
|
|
392
|
-
|
|
392
|
+
Ge(() => {
|
|
393
393
|
var _a;
|
|
394
394
|
const closestForm = this.element.closest('form') || ((_a = this.element.closest('mg-form')) === null || _a === void 0 ? void 0 : _a.shadowRoot.querySelector('form'));
|
|
395
395
|
// submit buttons should trigger form submition;
|
|
@@ -448,7 +448,7 @@ const MgCard = class {
|
|
|
448
448
|
};
|
|
449
449
|
this.variant = undefined;
|
|
450
450
|
this.variantStyle = undefined;
|
|
451
|
-
this.classCollection = new
|
|
451
|
+
this.classCollection = new He([this.classBase]);
|
|
452
452
|
}
|
|
453
453
|
validateVariant(newValue, oldValue) {
|
|
454
454
|
if (newValue && !variants$3.includes(newValue))
|
|
@@ -553,7 +553,7 @@ const MgDetails = class {
|
|
|
553
553
|
this.expanded = false;
|
|
554
554
|
}
|
|
555
555
|
validateTitles(newValue) {
|
|
556
|
-
if (!
|
|
556
|
+
if (!Ie(newValue)) {
|
|
557
557
|
throw new Error('<mg-details> prop "toggleClosed" and "toggleOpened" must be defined.');
|
|
558
558
|
}
|
|
559
559
|
}
|
|
@@ -711,7 +711,7 @@ const MgForm = class {
|
|
|
711
711
|
}
|
|
712
712
|
});
|
|
713
713
|
};
|
|
714
|
-
this.identifier =
|
|
714
|
+
this.identifier = Ce('mg-form');
|
|
715
715
|
this.name = this.identifier;
|
|
716
716
|
this.readonly = false;
|
|
717
717
|
this.requiredMessage = undefined;
|
|
@@ -720,7 +720,7 @@ const MgForm = class {
|
|
|
720
720
|
this.disabled = false;
|
|
721
721
|
this.valid = undefined;
|
|
722
722
|
this.invalid = undefined;
|
|
723
|
-
this.classCollection = new
|
|
723
|
+
this.classCollection = new He(['mg-c-form']);
|
|
724
724
|
this.requiredMessageText = undefined;
|
|
725
725
|
}
|
|
726
726
|
validateRequiredMessage(newValue) {
|
|
@@ -861,7 +861,7 @@ const MgIcon = class {
|
|
|
861
861
|
this.variant = undefined;
|
|
862
862
|
this.variantStyle = undefined;
|
|
863
863
|
this.spin = false;
|
|
864
|
-
this.classCollection = new
|
|
864
|
+
this.classCollection = new He(['mg-c-icon']);
|
|
865
865
|
}
|
|
866
866
|
validateIcon(newValue, oldValue) {
|
|
867
867
|
if (!Object.keys(icons).includes(newValue))
|
|
@@ -960,7 +960,7 @@ const MgIllustratedMessage = class {
|
|
|
960
960
|
componentDidLoad() {
|
|
961
961
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
962
962
|
const slottedIllustrations = this.element.querySelectorAll('[slot="illustration"]');
|
|
963
|
-
if (!
|
|
963
|
+
if (!Be(this.element.querySelector('[slot="title"]'), headingTags)) {
|
|
964
964
|
throw new Error(`<mg-illustrated-message> Slotted title must be a heading: ${headingTags.join(', ')}`);
|
|
965
965
|
}
|
|
966
966
|
else if (slottedIllustrations.length !== 1) {
|
|
@@ -1000,6 +1000,7 @@ var Handler;
|
|
|
1000
1000
|
(function (Handler) {
|
|
1001
1001
|
Handler["BLUR"] = "blur";
|
|
1002
1002
|
Handler["FOCUS"] = "focus";
|
|
1003
|
+
Handler["MOUSEENTER"] = "mouseenter";
|
|
1003
1004
|
})(Handler || (Handler = {}));
|
|
1004
1005
|
const classFieldset = 'mg-c-input--fieldset';
|
|
1005
1006
|
const classDisabled = 'mg-c-input--disabled';
|
|
@@ -1060,7 +1061,7 @@ const MgInput = class {
|
|
|
1060
1061
|
this.isVerticalList = false;
|
|
1061
1062
|
}
|
|
1062
1063
|
watchIdentifier(newValue) {
|
|
1063
|
-
if (!
|
|
1064
|
+
if (!Ie(newValue)) {
|
|
1064
1065
|
throw new Error('<mg-input> prop "identifier" is required.');
|
|
1065
1066
|
}
|
|
1066
1067
|
else {
|
|
@@ -1145,7 +1146,7 @@ const MgInput = class {
|
|
|
1145
1146
|
*/
|
|
1146
1147
|
// eslint-disable-next-line @stencil-community/no-unused-watch
|
|
1147
1148
|
watchLabel() {
|
|
1148
|
-
if (!
|
|
1149
|
+
if (!Ie(this.label)) {
|
|
1149
1150
|
throw new Error('<mg-input> prop "label" is required.');
|
|
1150
1151
|
}
|
|
1151
1152
|
else {
|
|
@@ -1306,7 +1307,7 @@ h("ul", { class: "mg-c-input__input-group-container", role: "list", "aria-descri
|
|
|
1306
1307
|
var _a, _b;
|
|
1307
1308
|
return (h("li", { key: input._id, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': props.disabled || input.disabled } },
|
|
1308
1309
|
h("input", { type: "checkbox", id: input._id, name: props.name, value: (_a = input.value) === null || _a === void 0 ? void 0 : _a.toString(), checked: Boolean(input.value), required: input.required, "aria-invalid": ((_b = props.invalid) === null || _b === void 0 ? void 0 : _b.toString()) || 'false', disabled: props.disabled || input.disabled, indeterminate: input.value === null, onInput: input._handleInput, onBlur: input._handleBlur, onKeyDown: input._handleKeydown }),
|
|
1309
|
-
h("label", { htmlFor: input._id }, input.title)));
|
|
1310
|
+
h("label", { htmlFor: input._id, onMouseEnter: input._handleMouseEnter, onMouseLeave: input._handleMouseLeave }, input.title)));
|
|
1310
1311
|
})));
|
|
1311
1312
|
|
|
1312
1313
|
const mgInputCheckboxCss = ".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__input-container{width:100%;flex:1 auto}.mg-c-input__box.mg-c-input__box--width{width:100%;min-width:5rem;max-width:calc(17.7rem + var(--mg-inputs-spacer)*2)}.mg-c-input.mg-c-input--width-2 .mg-c-input__box,.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left{max-width:5rem}.mg-c-input.mg-c-input--width-4 .mg-c-input__box,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left{max-width:7rem}.mg-c-input.mg-c-input--width-16 .mg-c-input__box,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{max-width:21rem}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%;max-width:100%}.mg-c-input.mg-c-input--label-on-top.mg-c-input--width-2 .mg-c-input__box,.mg-c-input.mg-c-input--label-on-top.mg-c-input--width-2 .mg-c-input__with-character-left{max-width:5rem}.mg-c-input.mg-c-input--label-on-top.mg-c-input--width-4 .mg-c-input__box,.mg-c-input.mg-c-input--label-on-top.mg-c-input--width-4 .mg-c-input__with-character-left{max-width:7rem}.mg-c-input.mg-c-input--label-on-top.mg-c-input--width-16 .mg-c-input__box,.mg-c-input.mg-c-input--label-on-top.mg-c-input--width-16 .mg-c-input__with-character-left{max-width:21rem}.mg-c-input.mg-c-input--label-on-top.mg-c-input--width-full .mg-c-input__box{width:100%;max-width:100%}.mg-c-input.mg-c-input--label-on-top .mg-c-input__box{width:auto}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.mg-c-input.mg-c-input--fieldset{padding:0;border:0;margin-right:0;margin-left:0}.mg-c-input.mg-c-input--fieldset input[type=radio],.mg-c-input.mg-c-input--fieldset 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}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group{display:flex;align-items:start}.mg-c-input.mg-c-input--fieldset .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);gap:1rem 2.3rem;list-style:none}.mg-c-input.mg-c-input--fieldset.mg-c-input--vertical-list .mg-c-input__input-group-container,.mg-c-input.mg-c-input--fieldset.mg-c-input--checkbox-multi .mg-c-input__input-group-container{flex-direction:column}.mg-c-input.mg-c-input--fieldset.mg-c-input--label-on-top .mg-c-input__input-group-container{margin-top:.7rem}:host(.mg-c-input.mg-c-input--fieldset:not(.mg-c-input--checkbox-multi)) .mg-c-input__input-container mg-tooltip{margin-left:3rem}:host(.mg-c-input.mg-c-input--checkbox) .mg-c-input__input,:host(.mg-c-input.mg-c-input--radio) .mg-c-input__input{min-height:unset;align-items:flex-start}:host{display:block}.mg-c-input__input mg-icon,.mg-c-input__error mg-icon{display:flex}.mg-c-input{display:flex;min-height:var(--default-size);align-items:flex-start;margin-bottom:var(--mg-inputs-margin-bottom, 0)}.mg-c-input__input-container{min-height:var(--default-size)}.mg-c-input__input-container>ul{display:flex;flex-flow:column wrap;padding:0;margin:0;list-style:none;row-gap:.8rem}.mg-c-input__input-container>strong{display:inline-block}.mg-c-input__input-container>strong,.mg-c-input__input-container>ul{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{display:flex;min-height:var(--default-size);align-items:center;justify-content:start}.mg-c-input__input mg-tooltip{align-self:baseline;margin-top:calc((var(--default-size) - var(--mg-icon-regular-size))/2)}.mg-c-input__input .mg-c-input__box:disabled,.mg-c-input__input ::slotted(.mg-c-input__button-toggle:disabled),.mg-c-input__input-group--disabled label,.mg-c-input.mg-c-input--checkbox-multi.mg-c-input--disabled .mg-c-input__input-container strong{opacity:var(--mg-disabled-opacity)}.mg-c-input__title{display:flex;width:var(--mg-inputs-title-width, auto);flex-shrink:0;align-items:baseline;justify-content:flex-end;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__title slot[name=label]+mg-tooltip{margin-left:.4rem}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__error{display:inline-block;padding:.3rem .8rem;border-radius:.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-c-input__error ::slotted(*),.mg-c-input__help-text ::slotted(*){font-size:1.2rem;text-align:start}.mg-c-input__help-text+.mg-c-input__error{margin-top:.2rem}:host(:not(.mg-c-input--textarea)) .mg-c-input__input+.mg-c-input__error,:host(:not(.mg-c-input--textarea)) .mg-c-input__input+.mg-c-input__help-text{margin-top:.5rem}.mg-c-input.mg-c-input--readonly>*:not([slot=label],[name=append-input]),.mg-c-input.mg-c-input--readonly ::slotted(mg-button[slot=append-input]){display:none}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:hsl(var(--color-danger))}:host(.mg-c-input){display:flex}:host(.mg-c-input.mg-c-input--textarea.mg-c-input--readonly) .mg-c-input__input-container{white-space:pre-line}:host(.mg-c-input.mg-c-input--checkbox,.mg-c-input.mg-c-input--radio) .mg-c-input__input{min-height:unset}:host(.mg-c-input.mg-c-input--label-on-top){flex-direction:column}:host(.mg-c-input.mg-c-input--label-on-top) .mg-c-input__title{width:100%;flex:0;justify-content:flex-start;margin-top:0;margin-right:0;margin-bottom:.3rem;text-align:left}:host(.mg-c-input.mg-c-input--label-on-top) .mg-c-input__title ::slotted(mg-input-title){flex-shrink:1}@media screen and (max-width: 767px){:host(.mg-c-input){flex-direction:column}:host(.mg-c-input) .mg-c-input__title{width:100%;flex:0;justify-content:flex-start;margin-top:0;margin-right:0;margin-bottom:.3rem;text-align:left}:host(.mg-c-input) .mg-c-input__title ::slotted(mg-input-title){flex-shrink:1}}.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-group-container{padding:.4rem calc(0.4rem*2) .4rem calc(0.4rem/2);margin:0}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-container{display:flex;width:unset;flex:unset;flex-wrap:wrap;column-gap:calc(var(--mg-inputs-spacer)*1.2)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-container-list{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__sections{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__section-header{display:flex;flex-flow:row wrap;gap:calc(0.4rem*2);min-height:var(--default-size);flex-wrap:nowrap;align-items:center;text-wrap:nowrap}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__section-header-tootlip{display:inline-block;width:auto;height:auto;margin:0}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__section-header-title{display:inline;margin:0;color:hsl(var(--mg-color-dark-40-hsl))}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__section-header-title-label{font-size:var(--font-size)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__section-header-title--static.mg-c-input__section-header-title{margin:0 1.1rem}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-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__content{display:flex;flex-flow:column nowrap;gap:calc(0.4rem*2)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-group{margin-left:calc(0.4rem*2)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-no-result{text-align:center}.mg-c-input.mg-c-input--checkbox-multi.mg-c-input--with-values .mg-c-input__input-container{gap:.4rem}.mg-c-input.mg-c-input--checkbox-multi.mg-c-input--search-mode .mg-c-input__content{width:37rem;height:40rem}.mg-c-input.mg-c-input--checkbox-multi:not(.mg-c-input--label-on-top) mg-tooltip:not(.mg-c-input__section-header-tootlip){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-input-text{--mg-inputs-margin-bottom:0}";
|
|
@@ -1371,7 +1372,11 @@ const MgInputCheckbox = class {
|
|
|
1371
1372
|
/**
|
|
1372
1373
|
* Handle blur event
|
|
1373
1374
|
*/
|
|
1374
|
-
this.handleBlur = () => {
|
|
1375
|
+
this.handleBlur = (event) => {
|
|
1376
|
+
if (this.handlerInProgress === Handler.MOUSEENTER) {
|
|
1377
|
+
event.preventDefault();
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1375
1380
|
// set guard
|
|
1376
1381
|
this.handlerInProgress = Handler.BLUR;
|
|
1377
1382
|
// Check validity
|
|
@@ -1420,6 +1425,18 @@ const MgInputCheckbox = class {
|
|
|
1420
1425
|
});
|
|
1421
1426
|
this.updateValues();
|
|
1422
1427
|
};
|
|
1428
|
+
/**
|
|
1429
|
+
* Handle input label mouseenter event
|
|
1430
|
+
*/
|
|
1431
|
+
this.handleMouseEnter = () => {
|
|
1432
|
+
this.handlerInProgress = Handler.MOUSEENTER;
|
|
1433
|
+
};
|
|
1434
|
+
/**
|
|
1435
|
+
* Handle input label leave event
|
|
1436
|
+
*/
|
|
1437
|
+
this.handleMouseLeave = () => {
|
|
1438
|
+
this.handlerInProgress = undefined;
|
|
1439
|
+
};
|
|
1423
1440
|
/**
|
|
1424
1441
|
* Update values
|
|
1425
1442
|
*/
|
|
@@ -1428,6 +1445,8 @@ const MgInputCheckbox = class {
|
|
|
1428
1445
|
delete o._handleBlur;
|
|
1429
1446
|
delete o._handleInput;
|
|
1430
1447
|
delete o._handleKeydown;
|
|
1448
|
+
delete o._handleMouseEnter;
|
|
1449
|
+
delete o._handleMouseLeave;
|
|
1431
1450
|
delete o._id;
|
|
1432
1451
|
return o;
|
|
1433
1452
|
});
|
|
@@ -1441,7 +1460,7 @@ const MgInputCheckbox = class {
|
|
|
1441
1460
|
* Method to update searchResults
|
|
1442
1461
|
*/
|
|
1443
1462
|
this.updateSearchResults = () => {
|
|
1444
|
-
this.searchResults = this.checkboxItems.filter(item =>
|
|
1463
|
+
this.searchResults = this.checkboxItems.filter(item => qe(item.title).includes(qe(this.searchValue)));
|
|
1445
1464
|
};
|
|
1446
1465
|
/**
|
|
1447
1466
|
* Method to validate if one of inputs value is checked id required
|
|
@@ -1515,7 +1534,7 @@ const MgInputCheckbox = class {
|
|
|
1515
1534
|
this.helpText = undefined;
|
|
1516
1535
|
this.valid = undefined;
|
|
1517
1536
|
this.invalid = undefined;
|
|
1518
|
-
this.classCollection = new
|
|
1537
|
+
this.classCollection = new He([this.baseClassName, classFieldset]);
|
|
1519
1538
|
this.errorMessage = undefined;
|
|
1520
1539
|
this.checkboxItems = [];
|
|
1521
1540
|
this.displaySearchInput = undefined;
|
|
@@ -1525,7 +1544,7 @@ const MgInputCheckbox = class {
|
|
|
1525
1544
|
}
|
|
1526
1545
|
validateValue(newValue) {
|
|
1527
1546
|
if (isCheckboxItems(newValue)) {
|
|
1528
|
-
this.checkboxItems = newValue.map((item, index) => (Object.assign(Object.assign({}, item), { _id: `${this.identifier}_${index}`, _handleInput: this.handleInput.bind(this), _handleBlur: this.handleBlur.bind(this), _handleKeydown: this.handleKeydown.bind(this) })));
|
|
1547
|
+
this.checkboxItems = newValue.map((item, index) => (Object.assign(Object.assign({}, item), { _id: `${this.identifier}_${index}`, _handleInput: this.handleInput.bind(this), _handleBlur: this.handleBlur.bind(this), _handleKeydown: this.handleKeydown.bind(this), _handleMouseEnter: this.handleMouseEnter.bind(this), _handleMouseLeave: this.handleMouseLeave.bind(this) })));
|
|
1529
1548
|
this.valueChange.emit(newValue);
|
|
1530
1549
|
}
|
|
1531
1550
|
else {
|
|
@@ -1623,7 +1642,7 @@ const MgInputCheckbox = class {
|
|
|
1623
1642
|
if (typeof valid !== 'boolean') {
|
|
1624
1643
|
throw new Error('<mg-input-checkbox> method "setError()" param "valid" must be a boolean');
|
|
1625
1644
|
}
|
|
1626
|
-
else if (!
|
|
1645
|
+
else if (!Ie(errorMessage)) {
|
|
1627
1646
|
throw new Error('<mg-input-checkbox> method "setError()" param "errorMessage" must be a string');
|
|
1628
1647
|
}
|
|
1629
1648
|
else {
|
|
@@ -1736,7 +1755,7 @@ const MgInputCheckbox = class {
|
|
|
1736
1755
|
* @returns HTML Element
|
|
1737
1756
|
*/
|
|
1738
1757
|
render() {
|
|
1739
|
-
return (h("mg-input", { key: '
|
|
1758
|
+
return (h("mg-input", { key: '619a108d13b49c7b74dded7afa759202aa909abb', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonlyValue: this.value.filter(({ value }) => value).map(({ title }) => title), tooltip: !this.readonly ? this.tooltip : undefined, tooltipPosition: this.tooltipPosition, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined }, this.type === 'checkbox' || this.readonly ? (h(MgInputCheckboxList, { checkboxes: this.checkboxItems, displaySearchInput: this.displaySearchInput, messages: this.messages.input.checkbox, id: "checkboxes-list", disabled: this.disabled, name: this.name, invalid: this.invalid })) : (this.renderCheckboxMulti())));
|
|
1740
1759
|
}
|
|
1741
1760
|
get element() { return getElement(this); }
|
|
1742
1761
|
static get watchers() { return {
|
|
@@ -1886,7 +1905,7 @@ const MgInputDate = class {
|
|
|
1886
1905
|
* @param value - value to test
|
|
1887
1906
|
* @returns truthy when value match the pattern
|
|
1888
1907
|
*/
|
|
1889
|
-
this.isValidPattern = (value) =>
|
|
1908
|
+
this.isValidPattern = (value) => Ie(value) && he.test(value);
|
|
1890
1909
|
/**
|
|
1891
1910
|
* Format help text to display
|
|
1892
1911
|
* @param helpText - help text format
|
|
@@ -1894,10 +1913,10 @@ const MgInputDate = class {
|
|
|
1894
1913
|
*/
|
|
1895
1914
|
this.formatHelpText = (helpText) => {
|
|
1896
1915
|
const defaultHelpTextVariable = '{defaultHelpText}';
|
|
1897
|
-
let text =
|
|
1916
|
+
let text = Ie(helpText) ? helpText : this.messages.input.date.helpText;
|
|
1898
1917
|
if (text.includes(defaultHelpTextVariable))
|
|
1899
1918
|
text = text.replace(defaultHelpTextVariable, this.formatHelpText(this.messages.input.date.helpText));
|
|
1900
|
-
return text.replace('{pattern}', this.renderPattern()).replace('{date}',
|
|
1919
|
+
return text.replace('{pattern}', this.renderPattern()).replace('{date}', ye(Ze(new Date('2023-12-24')), this.systemLocale));
|
|
1901
1920
|
};
|
|
1902
1921
|
/**
|
|
1903
1922
|
* Handle input event
|
|
@@ -1989,8 +2008,8 @@ const MgInputDate = class {
|
|
|
1989
2008
|
// min, max & minMax
|
|
1990
2009
|
else if ([InputError$1.MIN, InputError$1.MAX, InputError$1.MINMAX].includes(inputError)) {
|
|
1991
2010
|
this.errorMessage = this.messages.errors.date[inputError]
|
|
1992
|
-
.replace('{min}',
|
|
1993
|
-
.replace('{max}',
|
|
2011
|
+
.replace('{min}', ye(this.min, this.systemLocale))
|
|
2012
|
+
.replace('{max}', ye(this.max, this.systemLocale));
|
|
1994
2013
|
}
|
|
1995
2014
|
// wrong date format
|
|
1996
2015
|
// element.validity.badInput is default error message
|
|
@@ -2004,7 +2023,7 @@ const MgInputDate = class {
|
|
|
2004
2023
|
* @returns translated html pattern
|
|
2005
2024
|
*/
|
|
2006
2025
|
this.renderPattern = () => {
|
|
2007
|
-
let patternLocal =
|
|
2026
|
+
let patternLocal = Qe(this.systemLocale);
|
|
2008
2027
|
for (const key in this.messages.input.date.pattern) {
|
|
2009
2028
|
patternLocal = patternLocal.replace(key, this.messages.input.date.pattern[key]);
|
|
2010
2029
|
}
|
|
@@ -2026,7 +2045,7 @@ const MgInputDate = class {
|
|
|
2026
2045
|
this.helpText = undefined;
|
|
2027
2046
|
this.valid = undefined;
|
|
2028
2047
|
this.invalid = undefined;
|
|
2029
|
-
this.classCollection = new
|
|
2048
|
+
this.classCollection = new He(['mg-c-input--date']);
|
|
2030
2049
|
this.errorMessage = undefined;
|
|
2031
2050
|
}
|
|
2032
2051
|
validateValue(newValue) {
|
|
@@ -2034,7 +2053,7 @@ const MgInputDate = class {
|
|
|
2034
2053
|
if (newValue === '')
|
|
2035
2054
|
newValue = null;
|
|
2036
2055
|
// check value validity
|
|
2037
|
-
if (newValue && !
|
|
2056
|
+
if (newValue && !Ie(newValue)) {
|
|
2038
2057
|
throw new Error("<mg-input-date> props 'value' must be a valid string");
|
|
2039
2058
|
}
|
|
2040
2059
|
else if (!newValue || (newValue && this.isValidPattern(newValue))) {
|
|
@@ -2091,7 +2110,7 @@ const MgInputDate = class {
|
|
|
2091
2110
|
if (typeof valid !== 'boolean') {
|
|
2092
2111
|
throw new Error('<mg-input-date> method "setError()" param "valid" must be a boolean');
|
|
2093
2112
|
}
|
|
2094
|
-
else if (!
|
|
2113
|
+
else if (!Ie(errorMessage)) {
|
|
2095
2114
|
throw new Error('<mg-input-date> method "setError()" param "errorMessage" must be a string');
|
|
2096
2115
|
}
|
|
2097
2116
|
else {
|
|
@@ -2145,7 +2164,7 @@ const MgInputDate = class {
|
|
|
2145
2164
|
* @returns HTML Element
|
|
2146
2165
|
*/
|
|
2147
2166
|
render() {
|
|
2148
|
-
return (h("mg-input", { key: 'f38d79cb71311149b4d15885b65cd8f025dde15d', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonlyValue:
|
|
2167
|
+
return (h("mg-input", { key: 'f38d79cb71311149b4d15885b65cd8f025dde15d', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonlyValue: ye(this.value, this.locale), tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, h("input", { key: '67bf6f0ad58ee1a506ffd0d3d41d5954db68465c', 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) => {
|
|
2149
2168
|
if (el !== null)
|
|
2150
2169
|
this.input = el;
|
|
2151
2170
|
} })));
|
|
@@ -2276,9 +2295,9 @@ const MgInputNumeric = class {
|
|
|
2276
2295
|
this.formatValue = (value) => {
|
|
2277
2296
|
switch (this.format) {
|
|
2278
2297
|
case 'number':
|
|
2279
|
-
return
|
|
2298
|
+
return Ye(value, this.locale, this.type === 'decimal' ? this.decimalLength : undefined);
|
|
2280
2299
|
case 'currency':
|
|
2281
|
-
return
|
|
2300
|
+
return Je(value, this.locale, this.currency);
|
|
2282
2301
|
case 'none':
|
|
2283
2302
|
return value.toString();
|
|
2284
2303
|
}
|
|
@@ -2315,7 +2334,7 @@ const MgInputNumeric = class {
|
|
|
2315
2334
|
this.decimalLength = 2;
|
|
2316
2335
|
this.valid = undefined;
|
|
2317
2336
|
this.invalid = undefined;
|
|
2318
|
-
this.classCollection = new
|
|
2337
|
+
this.classCollection = new He(['mg-c-input--numeric']);
|
|
2319
2338
|
this.errorMessage = undefined;
|
|
2320
2339
|
this.hasFocus = undefined;
|
|
2321
2340
|
}
|
|
@@ -2411,7 +2430,7 @@ const MgInputNumeric = class {
|
|
|
2411
2430
|
if (typeof valid !== 'boolean') {
|
|
2412
2431
|
throw new Error('<mg-input-numeric> method "setError()" param "valid" must be a boolean');
|
|
2413
2432
|
}
|
|
2414
|
-
else if (!
|
|
2433
|
+
else if (!Ie(errorMessage)) {
|
|
2415
2434
|
throw new Error('<mg-input-numeric> method "setError()" param "errorMessage" must be a string');
|
|
2416
2435
|
}
|
|
2417
2436
|
else {
|
|
@@ -2603,7 +2622,7 @@ const MgInputPassword = class {
|
|
|
2603
2622
|
this.helpText = undefined;
|
|
2604
2623
|
this.valid = undefined;
|
|
2605
2624
|
this.invalid = undefined;
|
|
2606
|
-
this.classCollection = new
|
|
2625
|
+
this.classCollection = new He(['mg-c-input--password']);
|
|
2607
2626
|
this.errorMessage = undefined;
|
|
2608
2627
|
this.displayPassword = false;
|
|
2609
2628
|
}
|
|
@@ -2661,7 +2680,7 @@ const MgInputPassword = class {
|
|
|
2661
2680
|
if (typeof valid !== 'boolean') {
|
|
2662
2681
|
throw new Error('<mg-input-password> method "setError()" param "valid" must be a boolean');
|
|
2663
2682
|
}
|
|
2664
|
-
else if (!
|
|
2683
|
+
else if (!Ie(errorMessage)) {
|
|
2665
2684
|
throw new Error('<mg-input-password> method "setError()" param "errorMessage" must be a string');
|
|
2666
2685
|
}
|
|
2667
2686
|
else {
|
|
@@ -2808,7 +2827,7 @@ const MgInputRadio = class {
|
|
|
2808
2827
|
this.helpText = undefined;
|
|
2809
2828
|
this.valid = undefined;
|
|
2810
2829
|
this.invalid = undefined;
|
|
2811
|
-
this.classCollection = new
|
|
2830
|
+
this.classCollection = new He(['mg-c-input--radio', classFieldset]);
|
|
2812
2831
|
this.errorMessage = undefined;
|
|
2813
2832
|
this.options = undefined;
|
|
2814
2833
|
}
|
|
@@ -2821,7 +2840,7 @@ const MgInputRadio = class {
|
|
|
2821
2840
|
throw new Error('<mg-input-radio> prop "items" require at least 2 items.');
|
|
2822
2841
|
}
|
|
2823
2842
|
// String array
|
|
2824
|
-
else if (
|
|
2843
|
+
else if (Pe(newValue)) {
|
|
2825
2844
|
this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
|
|
2826
2845
|
}
|
|
2827
2846
|
// Object array
|
|
@@ -2880,7 +2899,7 @@ const MgInputRadio = class {
|
|
|
2880
2899
|
if (typeof valid !== 'boolean') {
|
|
2881
2900
|
throw new Error('<mg-input-radio> method "setError()" param "valid" must be a boolean');
|
|
2882
2901
|
}
|
|
2883
|
-
else if (!
|
|
2902
|
+
else if (!Ie(errorMessage)) {
|
|
2884
2903
|
throw new Error('<mg-input-radio> method "setError()" param "errorMessage" must be a string');
|
|
2885
2904
|
}
|
|
2886
2905
|
else {
|
|
@@ -3027,7 +3046,7 @@ const MgInputSelect = class {
|
|
|
3027
3046
|
if (this.input.value === '') {
|
|
3028
3047
|
this.setValue(null);
|
|
3029
3048
|
}
|
|
3030
|
-
else if (
|
|
3049
|
+
else if (Pe(this.items) && this.items.includes(this.input.value)) {
|
|
3031
3050
|
this.setValue(this.input.value);
|
|
3032
3051
|
}
|
|
3033
3052
|
else if (allItemsAreOptions(this.items) && typeof this.input.value === 'string' && this.items.some(this.isInputValue)) {
|
|
@@ -3101,7 +3120,7 @@ const MgInputSelect = class {
|
|
|
3101
3120
|
this.helpText = undefined;
|
|
3102
3121
|
this.valid = undefined;
|
|
3103
3122
|
this.invalid = undefined;
|
|
3104
|
-
this.classCollection = new
|
|
3123
|
+
this.classCollection = new He(['mg-c-input--select']);
|
|
3105
3124
|
this.errorMessage = undefined;
|
|
3106
3125
|
this.options = undefined;
|
|
3107
3126
|
this.valueExist = undefined;
|
|
@@ -3109,7 +3128,7 @@ const MgInputSelect = class {
|
|
|
3109
3128
|
}
|
|
3110
3129
|
validateValue(newValue) {
|
|
3111
3130
|
var _a, _b;
|
|
3112
|
-
if (
|
|
3131
|
+
if (Pe(this.items) && typeof newValue === 'string') {
|
|
3113
3132
|
this.readonlyValue = ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) ? this.input.value : newValue;
|
|
3114
3133
|
}
|
|
3115
3134
|
else if (allItemsAreOptions(this.items)) {
|
|
@@ -3126,7 +3145,7 @@ const MgInputSelect = class {
|
|
|
3126
3145
|
this.options = [];
|
|
3127
3146
|
}
|
|
3128
3147
|
// String array
|
|
3129
|
-
else if (
|
|
3148
|
+
else if (Pe(newValue)) {
|
|
3130
3149
|
if (typeof this.value === 'string')
|
|
3131
3150
|
this.valueExist = newValue.includes(this.value);
|
|
3132
3151
|
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
@@ -3198,7 +3217,7 @@ const MgInputSelect = class {
|
|
|
3198
3217
|
if (typeof valid !== 'boolean') {
|
|
3199
3218
|
throw new Error('<mg-input-select> method "setError()" param "valid" must be a boolean');
|
|
3200
3219
|
}
|
|
3201
|
-
else if (!
|
|
3220
|
+
else if (!Ie(errorMessage)) {
|
|
3202
3221
|
throw new Error('<mg-input-select> method "setError()" param "errorMessage" must be a string');
|
|
3203
3222
|
}
|
|
3204
3223
|
else {
|
|
@@ -3310,7 +3329,7 @@ const MgInputText = class {
|
|
|
3310
3329
|
*/
|
|
3311
3330
|
this.handleFocus = () => {
|
|
3312
3331
|
this.classCollection.add(this.classFocus);
|
|
3313
|
-
this.classCollection = new
|
|
3332
|
+
this.classCollection = new He(this.classCollection.classes);
|
|
3314
3333
|
};
|
|
3315
3334
|
/**
|
|
3316
3335
|
* Handle blur event
|
|
@@ -3318,7 +3337,7 @@ const MgInputText = class {
|
|
|
3318
3337
|
this.handleBlur = () => {
|
|
3319
3338
|
// Manage focus
|
|
3320
3339
|
this.classCollection.delete(this.classFocus);
|
|
3321
|
-
this.classCollection = new
|
|
3340
|
+
this.classCollection = new He(this.classCollection.classes);
|
|
3322
3341
|
// Display Error
|
|
3323
3342
|
this.handlerInProgress = Handler.BLUR;
|
|
3324
3343
|
this.displayError().finally(() => {
|
|
@@ -3393,7 +3412,7 @@ const MgInputText = class {
|
|
|
3393
3412
|
this.helpText = undefined;
|
|
3394
3413
|
this.valid = undefined;
|
|
3395
3414
|
this.invalid = undefined;
|
|
3396
|
-
this.classCollection = new
|
|
3415
|
+
this.classCollection = new He(['mg-c-input--text']);
|
|
3397
3416
|
this.errorMessage = undefined;
|
|
3398
3417
|
}
|
|
3399
3418
|
handleValue(newValue) {
|
|
@@ -3444,7 +3463,7 @@ const MgInputText = class {
|
|
|
3444
3463
|
this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
|
|
3445
3464
|
}
|
|
3446
3465
|
validatePattern(newValue) {
|
|
3447
|
-
if (newValue !== undefined && !(
|
|
3466
|
+
if (newValue !== undefined && !(Ie(this.pattern) && Ie(this.patternErrorMessage))) {
|
|
3448
3467
|
throw new Error('<mg-input-text> props "pattern" and "patternErrorMessage" must be non-empty string and paired.');
|
|
3449
3468
|
}
|
|
3450
3469
|
}
|
|
@@ -3474,7 +3493,7 @@ const MgInputText = class {
|
|
|
3474
3493
|
if (typeof valid !== 'boolean') {
|
|
3475
3494
|
throw new Error('<mg-input-text> method "setError()" param "valid" must be a boolean');
|
|
3476
3495
|
}
|
|
3477
|
-
else if (!
|
|
3496
|
+
else if (!Ie(errorMessage)) {
|
|
3478
3497
|
throw new Error('<mg-input-text> method "setError()" param "errorMessage" must be a string');
|
|
3479
3498
|
}
|
|
3480
3499
|
else {
|
|
@@ -3583,7 +3602,7 @@ const MgInputTextarea = class {
|
|
|
3583
3602
|
*/
|
|
3584
3603
|
this.handleFocus = () => {
|
|
3585
3604
|
this.classCollection.add(this.classFocus);
|
|
3586
|
-
this.classCollection = new
|
|
3605
|
+
this.classCollection = new He(this.classCollection.classes);
|
|
3587
3606
|
};
|
|
3588
3607
|
/**
|
|
3589
3608
|
* Handle blur event
|
|
@@ -3591,7 +3610,7 @@ const MgInputTextarea = class {
|
|
|
3591
3610
|
this.handleBlur = () => {
|
|
3592
3611
|
// Manage focus
|
|
3593
3612
|
this.classCollection.delete(this.classFocus);
|
|
3594
|
-
this.classCollection = new
|
|
3613
|
+
this.classCollection = new He(this.classCollection.classes);
|
|
3595
3614
|
// Display Error
|
|
3596
3615
|
this.handlerInProgress = Handler.BLUR;
|
|
3597
3616
|
this.displayError().finally(() => {
|
|
@@ -3654,7 +3673,7 @@ const MgInputTextarea = class {
|
|
|
3654
3673
|
this.valid = undefined;
|
|
3655
3674
|
this.invalid = undefined;
|
|
3656
3675
|
this.resizable = 'none';
|
|
3657
|
-
this.classCollection = new
|
|
3676
|
+
this.classCollection = new He(['mg-c-input--textarea']);
|
|
3658
3677
|
this.errorMessage = undefined;
|
|
3659
3678
|
}
|
|
3660
3679
|
handleValue(newValue) {
|
|
@@ -3693,7 +3712,7 @@ const MgInputTextarea = class {
|
|
|
3693
3712
|
this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
|
|
3694
3713
|
}
|
|
3695
3714
|
validatePattern(newValue) {
|
|
3696
|
-
if (newValue !== undefined && !(
|
|
3715
|
+
if (newValue !== undefined && !(Ie(this.pattern) && Ie(this.patternErrorMessage))) {
|
|
3697
3716
|
throw new Error('<mg-input-textarea> props "pattern" and "patternErrorMessage" must be non-empty string and paired.');
|
|
3698
3717
|
}
|
|
3699
3718
|
}
|
|
@@ -3725,7 +3744,7 @@ const MgInputTextarea = class {
|
|
|
3725
3744
|
if (typeof valid !== 'boolean') {
|
|
3726
3745
|
throw new Error('<mg-input-textarea> method "setError()" param "valid" must be a boolean');
|
|
3727
3746
|
}
|
|
3728
|
-
else if (!
|
|
3747
|
+
else if (!Ie(errorMessage)) {
|
|
3729
3748
|
throw new Error('<mg-input-textarea> method "setError()" param "errorMessage" must be a string');
|
|
3730
3749
|
}
|
|
3731
3750
|
else {
|
|
@@ -3814,7 +3833,7 @@ const MgInputTitle = class {
|
|
|
3814
3833
|
this.tagName = 'label';
|
|
3815
3834
|
}
|
|
3816
3835
|
validateIdentifier(newValue) {
|
|
3817
|
-
if (!
|
|
3836
|
+
if (!Ie(newValue)) {
|
|
3818
3837
|
throw new Error('<mg-input-title> prop "identifier" is required.');
|
|
3819
3838
|
}
|
|
3820
3839
|
}
|
|
@@ -3928,7 +3947,7 @@ const MgInputToggle = class {
|
|
|
3928
3947
|
this.tooltip = undefined;
|
|
3929
3948
|
this.tooltipPosition = 'input';
|
|
3930
3949
|
this.helpText = undefined;
|
|
3931
|
-
this.classCollection = new
|
|
3950
|
+
this.classCollection = new He(['mg-c-input--toggle']);
|
|
3932
3951
|
this.options = undefined;
|
|
3933
3952
|
this.errorMessage = undefined;
|
|
3934
3953
|
this.valid = undefined;
|
|
@@ -3945,7 +3964,7 @@ const MgInputToggle = class {
|
|
|
3945
3964
|
throw new Error('<mg-input-toggle> prop "items" require 2 items.');
|
|
3946
3965
|
}
|
|
3947
3966
|
// String array
|
|
3948
|
-
else if (
|
|
3967
|
+
else if (Pe(newValue)) {
|
|
3949
3968
|
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
3950
3969
|
}
|
|
3951
3970
|
// Object array
|
|
@@ -4001,7 +4020,7 @@ const MgInputToggle = class {
|
|
|
4001
4020
|
if (typeof valid !== 'boolean') {
|
|
4002
4021
|
throw new Error('<mg-input-toggle> method "setError()" param "valid" must be a boolean');
|
|
4003
4022
|
}
|
|
4004
|
-
else if (!
|
|
4023
|
+
else if (!Ie(errorMessage)) {
|
|
4005
4024
|
throw new Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string');
|
|
4006
4025
|
}
|
|
4007
4026
|
else {
|
|
@@ -4247,7 +4266,7 @@ const MgItemMore = class {
|
|
|
4247
4266
|
navElement.click();
|
|
4248
4267
|
});
|
|
4249
4268
|
// add id suffix to prevent duplicate key. default html id is: '';
|
|
4250
|
-
if (
|
|
4269
|
+
if (Ie(proxy.id))
|
|
4251
4270
|
proxy.id = `${proxy.id}-proxy`;
|
|
4252
4271
|
// update properties and DOM when proxyfied item is updated
|
|
4253
4272
|
proxified.addEventListener('item-updated', (event) => {
|
|
@@ -4577,7 +4596,7 @@ const MgMenuItem = class {
|
|
|
4577
4596
|
throw new Error(`<${this.name}> slot "label" is required.`);
|
|
4578
4597
|
['label', 'metadata'].forEach(slot => {
|
|
4579
4598
|
Array.from(this.element.querySelectorAll(`[slot="${slot}"]`)).forEach(element => {
|
|
4580
|
-
if (!
|
|
4599
|
+
if (!Ie(element.textContent))
|
|
4581
4600
|
throw new Error(`<${this.name}> slot "${slot}" must have text content.`);
|
|
4582
4601
|
if ((guard && element.getAttribute('title') === null) || !guard)
|
|
4583
4602
|
element.setAttribute('title', element.textContent);
|
|
@@ -4646,13 +4665,13 @@ const MgMenuItem = class {
|
|
|
4646
4665
|
* @returns HTML Element
|
|
4647
4666
|
*/
|
|
4648
4667
|
this.renderSlot = () => h("slot", null);
|
|
4649
|
-
this.identifier =
|
|
4668
|
+
this.identifier = Ce('mg-menu-item');
|
|
4650
4669
|
this.href = undefined;
|
|
4651
4670
|
this.target = undefined;
|
|
4652
4671
|
this.status = Status$1.VISIBLE;
|
|
4653
4672
|
this.expanded = false;
|
|
4654
4673
|
this.size = 'regular';
|
|
4655
|
-
this.navigationButtonClassList = new
|
|
4674
|
+
this.navigationButtonClassList = new He([this.navigationButton]);
|
|
4656
4675
|
this.direction = undefined;
|
|
4657
4676
|
this.isInMainMenu = undefined;
|
|
4658
4677
|
this.isItemMore = undefined;
|
|
@@ -4799,7 +4818,7 @@ const MgMenuItem = class {
|
|
|
4799
4818
|
* Emit event when component is updated
|
|
4800
4819
|
*/
|
|
4801
4820
|
componentShouldUpdate() {
|
|
4802
|
-
return
|
|
4821
|
+
return Ge(() => {
|
|
4803
4822
|
this.itemUpdated.emit();
|
|
4804
4823
|
});
|
|
4805
4824
|
}
|
|
@@ -4906,13 +4925,13 @@ const MgMessage = class {
|
|
|
4906
4925
|
return 'exclamation-circle';
|
|
4907
4926
|
}
|
|
4908
4927
|
};
|
|
4909
|
-
this.identifier =
|
|
4928
|
+
this.identifier = Ce('mg-message');
|
|
4910
4929
|
this.delay = undefined;
|
|
4911
4930
|
this.variant = variants$1[0];
|
|
4912
4931
|
this.closeButton = false;
|
|
4913
4932
|
this.hide = false;
|
|
4914
4933
|
this.noAriaRole = undefined;
|
|
4915
|
-
this.classCollection = new
|
|
4934
|
+
this.classCollection = new He(['mg-c-message']);
|
|
4916
4935
|
this.hasActions = false;
|
|
4917
4936
|
}
|
|
4918
4937
|
validateDelay(newValue) {
|
|
@@ -5055,12 +5074,12 @@ const MgModal = class {
|
|
|
5055
5074
|
*/
|
|
5056
5075
|
this.setFocus = () => {
|
|
5057
5076
|
// Get all focusable elements
|
|
5058
|
-
const slottedFocusableElements = Array.from(this.element.querySelectorAll(
|
|
5077
|
+
const slottedFocusableElements = Array.from(this.element.querySelectorAll(We));
|
|
5059
5078
|
// If close button is enabled or at least one of the slotted element is focusable
|
|
5060
5079
|
if (this.closeButton || slottedFocusableElements.length > 0) {
|
|
5061
5080
|
// Check if slotted focusable elements have shadowDom with focusable elements
|
|
5062
5081
|
this.modalFocusableElements = slottedFocusableElements.reduce((acc, focusableElement) => {
|
|
5063
|
-
acc.push(focusableElement.shadowRoot !== null ? focusableElement.shadowRoot.querySelector(
|
|
5082
|
+
acc.push(focusableElement.shadowRoot !== null ? focusableElement.shadowRoot.querySelector(We) || focusableElement : focusableElement);
|
|
5064
5083
|
return acc;
|
|
5065
5084
|
}, []);
|
|
5066
5085
|
// When close button is enabled it's the first focusable element.
|
|
@@ -5082,21 +5101,21 @@ const MgModal = class {
|
|
|
5082
5101
|
this.handleClose = () => {
|
|
5083
5102
|
this.hide = true;
|
|
5084
5103
|
};
|
|
5085
|
-
this.identifier =
|
|
5104
|
+
this.identifier = Ce('mg-modal');
|
|
5086
5105
|
this.dialogRole = dialogRoles[0];
|
|
5087
5106
|
this.modalTitle = undefined;
|
|
5088
5107
|
this.closeButton = false;
|
|
5089
5108
|
this.hide = undefined;
|
|
5090
5109
|
this.hasActions = false;
|
|
5091
5110
|
this.hasContent = false;
|
|
5092
|
-
this.classCollection = new
|
|
5111
|
+
this.classCollection = new He(['mg-c-modal']);
|
|
5093
5112
|
}
|
|
5094
5113
|
validateDialogRole(newValue) {
|
|
5095
5114
|
if (!dialogRoles.includes(newValue))
|
|
5096
5115
|
throw new Error(`<mg-modal> prop "dialogRole" must be one of: ${dialogRoles.join(', ')}.`);
|
|
5097
5116
|
}
|
|
5098
5117
|
validateModalTitle(newValue) {
|
|
5099
|
-
if (!
|
|
5118
|
+
if (!Ie(newValue)) {
|
|
5100
5119
|
throw new Error('<mg-modal> prop "modalTitle" is required.');
|
|
5101
5120
|
}
|
|
5102
5121
|
}
|
|
@@ -5243,7 +5262,7 @@ const MgPagination = class {
|
|
|
5243
5262
|
this.handleGoToPage = (action, disabled) => {
|
|
5244
5263
|
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
5245
5264
|
};
|
|
5246
|
-
this.identifier =
|
|
5265
|
+
this.identifier = Ce('mg-pagination');
|
|
5247
5266
|
this.label = undefined;
|
|
5248
5267
|
this.hideNavigationLabels = undefined;
|
|
5249
5268
|
this.hidePageCount = undefined;
|
|
@@ -5408,7 +5427,7 @@ const MgPanel = class {
|
|
|
5408
5427
|
];
|
|
5409
5428
|
return this.titlePosition === 'right' ? children.reverse() : children;
|
|
5410
5429
|
};
|
|
5411
|
-
this.identifier =
|
|
5430
|
+
this.identifier = Ce('mg-panel');
|
|
5412
5431
|
this.panelTitle = undefined;
|
|
5413
5432
|
this.titlePattern = undefined;
|
|
5414
5433
|
this.titlePatternErrorMessage = undefined;
|
|
@@ -5417,12 +5436,12 @@ const MgPanel = class {
|
|
|
5417
5436
|
this.expanded = false;
|
|
5418
5437
|
this.expandToggleDisplay = expandToggleDisplays[0];
|
|
5419
5438
|
this.expandToggleDisabled = undefined;
|
|
5420
|
-
this.classCollection = new
|
|
5439
|
+
this.classCollection = new He(['mg-c-panel']);
|
|
5421
5440
|
this.isEditing = false;
|
|
5422
5441
|
this.updatedPanelTitle = undefined;
|
|
5423
5442
|
}
|
|
5424
5443
|
validatePanelTitle(newValue) {
|
|
5425
|
-
if (!
|
|
5444
|
+
if (!Ie(newValue))
|
|
5426
5445
|
throw new Error('<mg-panel> prop "panelTitle" is required.');
|
|
5427
5446
|
this.titleChange.emit(newValue);
|
|
5428
5447
|
}
|
|
@@ -7373,7 +7392,7 @@ const MgPopover = class {
|
|
|
7373
7392
|
mgPopoverContent.setAttribute('id', this.identifier);
|
|
7374
7393
|
}
|
|
7375
7394
|
};
|
|
7376
|
-
this.identifier =
|
|
7395
|
+
this.identifier = Ce('mg-popover');
|
|
7377
7396
|
this.placement = 'bottom';
|
|
7378
7397
|
this.arrowHide = false;
|
|
7379
7398
|
this.closeButton = false;
|
|
@@ -7416,7 +7435,7 @@ const MgPopover = class {
|
|
|
7416
7435
|
*/
|
|
7417
7436
|
componentWillLoad() {
|
|
7418
7437
|
// Get windows to attach events
|
|
7419
|
-
this.windows =
|
|
7438
|
+
this.windows = ze(window);
|
|
7420
7439
|
// render mg-popover-content slot
|
|
7421
7440
|
this.renderPopoverContent();
|
|
7422
7441
|
this.validateCloseButton(this.closeButton);
|
|
@@ -7508,7 +7527,7 @@ const MgPopoverContent = class {
|
|
|
7508
7527
|
this.hideContent.emit();
|
|
7509
7528
|
};
|
|
7510
7529
|
this.closeButton = false;
|
|
7511
|
-
this.classCollection = new
|
|
7530
|
+
this.classCollection = new He(['mg-c-popover-content']);
|
|
7512
7531
|
}
|
|
7513
7532
|
/*************
|
|
7514
7533
|
* Lifecycle *
|
|
@@ -7526,7 +7545,7 @@ const MgPopoverContent = class {
|
|
|
7526
7545
|
componentDidLoad() {
|
|
7527
7546
|
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
7528
7547
|
const slottedTitleElement = this.element.querySelector('[slot="title"]');
|
|
7529
|
-
if (slottedTitleElement && !
|
|
7548
|
+
if (slottedTitleElement && !Be(slottedTitleElement, headingTags)) {
|
|
7530
7549
|
throw new Error(`<mg-popover> Slotted title must be a heading: ${headingTags.join(', ')}`);
|
|
7531
7550
|
}
|
|
7532
7551
|
}
|
|
@@ -7562,7 +7581,7 @@ const MgSkipLinks = class {
|
|
|
7562
7581
|
this.links = undefined;
|
|
7563
7582
|
}
|
|
7564
7583
|
validateLinks(links) {
|
|
7565
|
-
if (links === undefined || links.length === 0 || links.some(link => !
|
|
7584
|
+
if (links === undefined || links.length === 0 || links.some(link => !Ie(link.href) || !link.href.startsWith('#') || !Ie(link.label))) {
|
|
7566
7585
|
throw new Error(`<mg-skip-links> prop "links": Cannot be empty and each link must contains an href starting with a "#" and a non empty label attributes.`);
|
|
7567
7586
|
}
|
|
7568
7587
|
}
|
|
@@ -7714,7 +7733,7 @@ const MgTabs = class {
|
|
|
7714
7733
|
*/
|
|
7715
7734
|
this.resetFocus = () => {
|
|
7716
7735
|
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
7717
|
-
|
|
7736
|
+
Ge(() => {
|
|
7718
7737
|
this.tabFocus = undefined;
|
|
7719
7738
|
Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {
|
|
7720
7739
|
tab.setAttribute('tabindex', this.activeTab - this.startIndex !== index ? '-1' : '0');
|
|
@@ -7729,16 +7748,16 @@ const MgTabs = class {
|
|
|
7729
7748
|
if (slots.length !== this.tabs.length)
|
|
7730
7749
|
throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
|
|
7731
7750
|
};
|
|
7732
|
-
this.identifier =
|
|
7751
|
+
this.identifier = Ce('mg-tabs');
|
|
7733
7752
|
this.label = undefined;
|
|
7734
7753
|
this.size = 'regular';
|
|
7735
7754
|
this.items = undefined;
|
|
7736
7755
|
this.activeTab = undefined;
|
|
7737
7756
|
this.tabs = [];
|
|
7738
|
-
this.classCollection = new
|
|
7757
|
+
this.classCollection = new He(['mg-c-tabs']);
|
|
7739
7758
|
}
|
|
7740
7759
|
validateLabel(newValue) {
|
|
7741
|
-
if (!
|
|
7760
|
+
if (!Ie(newValue)) {
|
|
7742
7761
|
throw new Error('<mg-tabs> prop "label" is required.');
|
|
7743
7762
|
}
|
|
7744
7763
|
}
|
|
@@ -7750,7 +7769,7 @@ const MgTabs = class {
|
|
|
7750
7769
|
}
|
|
7751
7770
|
validateItems(newValue) {
|
|
7752
7771
|
// String array
|
|
7753
|
-
if (
|
|
7772
|
+
if (Pe(newValue))
|
|
7754
7773
|
this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
|
|
7755
7774
|
// Object array
|
|
7756
7775
|
else if (Array.isArray(newValue) && newValue.length > 0 && newValue.every(isTabItem))
|
|
@@ -7850,7 +7869,7 @@ const MgTag = class {
|
|
|
7850
7869
|
this.variant = variants[0];
|
|
7851
7870
|
this.outline = undefined;
|
|
7852
7871
|
this.soft = undefined;
|
|
7853
|
-
this.classCollection = new
|
|
7872
|
+
this.classCollection = new He(['mg-c-tag']);
|
|
7854
7873
|
}
|
|
7855
7874
|
validateVariant(newValue, oldValue) {
|
|
7856
7875
|
if (!variants.includes(newValue)) {
|
|
@@ -7887,7 +7906,7 @@ const MgTag = class {
|
|
|
7887
7906
|
* @param textContent - html element textContent property
|
|
7888
7907
|
*/
|
|
7889
7908
|
validateTextContent(textContent) {
|
|
7890
|
-
if (!
|
|
7909
|
+
if (!Ie(textContent))
|
|
7891
7910
|
throw new Error('<mg-tag> slot must contain a text content.');
|
|
7892
7911
|
}
|
|
7893
7912
|
/*************
|
|
@@ -7947,10 +7966,10 @@ const MgTooltip = class {
|
|
|
7947
7966
|
// Enable the event listeners
|
|
7948
7967
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
7949
7968
|
// hide when click outside on nextTick to prevent event to trigger after creation
|
|
7950
|
-
|
|
7969
|
+
Ge(() => {
|
|
7951
7970
|
this.windows.forEach((localWindow) => {
|
|
7952
|
-
localWindow.addEventListener('click', this.
|
|
7953
|
-
localWindow.addEventListener('keydown', this.
|
|
7971
|
+
localWindow.addEventListener('click', this.handleClickOutside, false);
|
|
7972
|
+
localWindow.addEventListener('keydown', this.handlePressEscape, false);
|
|
7954
7973
|
});
|
|
7955
7974
|
});
|
|
7956
7975
|
};
|
|
@@ -7964,15 +7983,15 @@ const MgTooltip = class {
|
|
|
7964
7983
|
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
|
|
7965
7984
|
// Remove event listener
|
|
7966
7985
|
this.windows.forEach((localWindow) => {
|
|
7967
|
-
localWindow.removeEventListener('click', this.
|
|
7968
|
-
localWindow.removeEventListener('keyboard', this.
|
|
7986
|
+
localWindow.removeEventListener('click', this.handleClickOutside, false);
|
|
7987
|
+
localWindow.removeEventListener('keyboard', this.handlePressEscape, false);
|
|
7969
7988
|
});
|
|
7970
7989
|
};
|
|
7971
7990
|
/**
|
|
7972
7991
|
* Check if clicked outside of component and hidde tooltip
|
|
7973
7992
|
* @param event - mouse event
|
|
7974
7993
|
*/
|
|
7975
|
-
this.
|
|
7994
|
+
this.handleClickOutside = (event) => {
|
|
7976
7995
|
if (event.target.closest('mg-tooltip') !== this.element)
|
|
7977
7996
|
this.setDisplay(false);
|
|
7978
7997
|
};
|
|
@@ -7980,7 +7999,7 @@ const MgTooltip = class {
|
|
|
7980
7999
|
* Check if 'Escape' key is pressed of component and hidde tooltip
|
|
7981
8000
|
* @param event - keyboard event
|
|
7982
8001
|
*/
|
|
7983
|
-
this.
|
|
8002
|
+
this.handlePressEscape = (event) => {
|
|
7984
8003
|
if (event.code === 'Escape') {
|
|
7985
8004
|
this.setDisplay(false);
|
|
7986
8005
|
this.resetGuard();
|
|
@@ -7998,23 +8017,25 @@ const MgTooltip = class {
|
|
|
7998
8017
|
/**
|
|
7999
8018
|
* Action for tooltip element and tooltiped element mouse listener
|
|
8000
8019
|
* @param elementGuard - tooltip element guard
|
|
8001
|
-
* @param
|
|
8020
|
+
* @param eventName - event name
|
|
8002
8021
|
* @param conditionalGuard - guard condition
|
|
8003
8022
|
*/
|
|
8004
|
-
this.tooltipMouseListenerAction = (elementGuard,
|
|
8005
|
-
//
|
|
8006
|
-
if (
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8023
|
+
this.tooltipMouseListenerAction = (elementGuard, eventName, conditionalGuard) => {
|
|
8024
|
+
// active FOCUS guard cancel process
|
|
8025
|
+
if ([Guard.FOCUS, Guard.DISABLE_ON_CLICK].includes(this.guard)) {
|
|
8026
|
+
return;
|
|
8027
|
+
}
|
|
8028
|
+
// Update guard by element guard
|
|
8029
|
+
this.guard = elementGuard;
|
|
8030
|
+
if (eventName !== 'mouseenter') {
|
|
8031
|
+
// process action in the next event loop macro task
|
|
8032
|
+
setTimeout(() => {
|
|
8033
|
+
this.setDisplay(false, this.guard !== conditionalGuard);
|
|
8034
|
+
this.resetGuard();
|
|
8035
|
+
}, 100);
|
|
8036
|
+
}
|
|
8037
|
+
else if (this.guard === Guard.HOVER_TOOLTIPED_ELEMENT) {
|
|
8038
|
+
this.setDisplay(true);
|
|
8018
8039
|
}
|
|
8019
8040
|
};
|
|
8020
8041
|
/**
|
|
@@ -8041,27 +8062,9 @@ const MgTooltip = class {
|
|
|
8041
8062
|
}
|
|
8042
8063
|
};
|
|
8043
8064
|
/**
|
|
8044
|
-
*
|
|
8045
|
-
* @param slotElement - slotted element
|
|
8046
|
-
* @param interactiveElement - interactive element
|
|
8065
|
+
* Set popper instance
|
|
8047
8066
|
*/
|
|
8048
|
-
this.
|
|
8049
|
-
// Add tabindex to slotted element if we can't find any interactive element
|
|
8050
|
-
if (!this.disabled && !interactiveElement) {
|
|
8051
|
-
this.hasCustomTabIndex = true;
|
|
8052
|
-
slotElement.tabIndex = 0;
|
|
8053
|
-
// Add role on non-interactive element to work with "aria-describedby" for screen readers
|
|
8054
|
-
slotElement.setAttribute('role', 'button');
|
|
8055
|
-
}
|
|
8056
|
-
// Set aria-describedby
|
|
8057
|
-
const ariaDescribedby = slotElement.getAttribute('aria-describedby');
|
|
8058
|
-
if (ariaDescribedby === null) {
|
|
8059
|
-
this.tooltipedElement.setAttribute('aria-describedby', this.identifier);
|
|
8060
|
-
}
|
|
8061
|
-
else {
|
|
8062
|
-
// We ensure to have uniq ids
|
|
8063
|
-
slotElement.setAttribute('aria-describedby', `${[...new Set([...ariaDescribedby.split(' '), this.identifier])].join(' ')}`);
|
|
8064
|
-
}
|
|
8067
|
+
this.setPopper = () => {
|
|
8065
8068
|
// use element data attribute: `data-popper-strategy`, in order to get popper strategy configuration
|
|
8066
8069
|
const strategy = (this.element.dataset.popperStrategy || 'fixed');
|
|
8067
8070
|
// Create popperjs tooltip
|
|
@@ -8083,13 +8086,14 @@ const MgTooltip = class {
|
|
|
8083
8086
|
},
|
|
8084
8087
|
],
|
|
8085
8088
|
});
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8089
|
+
};
|
|
8090
|
+
/**
|
|
8091
|
+
* Define selected element to become tooltip selector and init listeners
|
|
8092
|
+
* @param element - tooltiped element
|
|
8093
|
+
*/
|
|
8094
|
+
this.setTooltipedElement = (element) => {
|
|
8095
|
+
this.tooltipedElement = element;
|
|
8096
|
+
// Manage tooltipedElement focus events
|
|
8093
8097
|
this.tooltipedElement.addEventListener('focus', () => {
|
|
8094
8098
|
this.guard = Guard.FOCUS;
|
|
8095
8099
|
this.setDisplay(true);
|
|
@@ -8104,37 +8108,71 @@ const MgTooltip = class {
|
|
|
8104
8108
|
this.resetGuard();
|
|
8105
8109
|
this.setDisplay(false);
|
|
8106
8110
|
});
|
|
8107
|
-
document.addEventListener('keydown', this.pressEscape);
|
|
8108
8111
|
// manage tooltipElement & tooltipedElement mouseenter/mouseleave events
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
].forEach(({ element, action }) => {
|
|
8115
|
-
element.addEventListener(eventType, () => {
|
|
8116
|
-
action();
|
|
8117
|
-
});
|
|
8118
|
-
});
|
|
8112
|
+
this.tooltipedElement.addEventListener('mouseenter', () => {
|
|
8113
|
+
this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, 'mouseenter', Guard.HOVER_TOOLTIP_ELEMENT);
|
|
8114
|
+
});
|
|
8115
|
+
this.tooltipedElement.addEventListener('mouseleave', () => {
|
|
8116
|
+
this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIPED_ELEMENT, 'mouseleave', Guard.HOVER_TOOLTIP_ELEMENT);
|
|
8119
8117
|
});
|
|
8120
8118
|
};
|
|
8121
|
-
|
|
8119
|
+
/**
|
|
8120
|
+
* Set button mutation observer
|
|
8121
|
+
* @param mgButton - mg-button to observe
|
|
8122
|
+
*/
|
|
8123
|
+
this.setMgButtonMutationObserver = (mgButton) => {
|
|
8124
|
+
new MutationObserver(mutationList => {
|
|
8125
|
+
// stop process when none of mutations attributed is disabled
|
|
8126
|
+
if (!mutationList.some(mutation => ['aria-disabled', 'disabled'].includes(mutation.attributeName)))
|
|
8127
|
+
return;
|
|
8128
|
+
// set guard when one of mutations is for a disabled with disabled-on-click
|
|
8129
|
+
if (mutationList.some((mutation) => mutation.target.disabled && mutation.target.disableOnClick)) {
|
|
8130
|
+
this.guard = Guard.DISABLE_ON_CLICK;
|
|
8131
|
+
}
|
|
8132
|
+
// when the disabled-on-click guard is running we stop process
|
|
8133
|
+
if (this.guard === Guard.DISABLE_ON_CLICK)
|
|
8134
|
+
return;
|
|
8135
|
+
// update button wrapper
|
|
8136
|
+
this.setMgButtonWrapper(mgButton);
|
|
8137
|
+
// Since Firefox doesn't trigger a "blur" event when the "disabled" attribute is added or removed from a button
|
|
8138
|
+
// we have to manually unlock the guard because the "blur" handler of the tooltipedElement won't do it.
|
|
8139
|
+
this.resetGuard();
|
|
8140
|
+
// update popper instance
|
|
8141
|
+
this.popper.update();
|
|
8142
|
+
}).observe(mgButton, { attributes: true });
|
|
8143
|
+
};
|
|
8144
|
+
/**
|
|
8145
|
+
* Set tooltiped element aria-describedby
|
|
8146
|
+
* @param element - element to update
|
|
8147
|
+
*/
|
|
8148
|
+
this.setAriaDescribedby = (element) => {
|
|
8149
|
+
// Set aria-describedby
|
|
8150
|
+
const ariaDescribedby = element.getAttribute('aria-describedby');
|
|
8151
|
+
if (ariaDescribedby === null) {
|
|
8152
|
+
this.tooltipedElement.setAttribute('aria-describedby', this.identifier);
|
|
8153
|
+
}
|
|
8154
|
+
else {
|
|
8155
|
+
// We ensure to have uniq ids
|
|
8156
|
+
element.setAttribute('aria-describedby', `${[...new Set([...ariaDescribedby.split(' '), this.identifier])].join(' ')}`);
|
|
8157
|
+
}
|
|
8158
|
+
};
|
|
8159
|
+
this.identifier = Ce('mg-tooltip');
|
|
8122
8160
|
this.message = undefined;
|
|
8123
8161
|
this.placement = 'bottom';
|
|
8124
8162
|
this.display = false;
|
|
8125
8163
|
this.disabled = false;
|
|
8126
8164
|
}
|
|
8127
|
-
|
|
8165
|
+
watchIdentifier() {
|
|
8128
8166
|
// use renderTooltipContent to update tooltip-content id
|
|
8129
8167
|
this.renderTooltipContent();
|
|
8130
8168
|
}
|
|
8131
|
-
|
|
8132
|
-
if (!
|
|
8169
|
+
watchMessage(newValue) {
|
|
8170
|
+
if (!Ie(newValue)) {
|
|
8133
8171
|
throw new Error('<mg-tooltip> prop "message" is required.');
|
|
8134
8172
|
}
|
|
8135
8173
|
this.mgTooltipContent.message = newValue;
|
|
8136
8174
|
}
|
|
8137
|
-
|
|
8175
|
+
watchDisplay(newValue) {
|
|
8138
8176
|
if (newValue) {
|
|
8139
8177
|
this.show();
|
|
8140
8178
|
}
|
|
@@ -8142,7 +8180,7 @@ const MgTooltip = class {
|
|
|
8142
8180
|
this.hide();
|
|
8143
8181
|
}
|
|
8144
8182
|
}
|
|
8145
|
-
|
|
8183
|
+
watchDisabled(newValue) {
|
|
8146
8184
|
if (this.hasCustomTabIndex) {
|
|
8147
8185
|
if (newValue)
|
|
8148
8186
|
this.tooltipedElement.removeAttribute('tabindex');
|
|
@@ -8151,23 +8189,29 @@ const MgTooltip = class {
|
|
|
8151
8189
|
}
|
|
8152
8190
|
}
|
|
8153
8191
|
/**
|
|
8154
|
-
* Render tooltip content element
|
|
8192
|
+
* Render tooltip content element and init listeners
|
|
8155
8193
|
*/
|
|
8156
8194
|
renderTooltipContent() {
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
mgTooltipContent.
|
|
8195
|
+
if (this.mgTooltipContent) {
|
|
8196
|
+
this.mgTooltipContent.setAttribute('id', this.identifier);
|
|
8197
|
+
}
|
|
8198
|
+
else {
|
|
8199
|
+
this.mgTooltipContent = document.createElement('mg-tooltip-content');
|
|
8200
|
+
this.mgTooltipContent.setAttribute('slot', 'content');
|
|
8201
|
+
this.mgTooltipContent.setAttribute('id', this.identifier);
|
|
8162
8202
|
const arrow = document.createElement('div');
|
|
8163
8203
|
arrow.setAttribute('slot', 'arrow');
|
|
8164
8204
|
arrow.dataset.popperArrow = '';
|
|
8165
|
-
mgTooltipContent.appendChild(arrow);
|
|
8205
|
+
this.mgTooltipContent.appendChild(arrow);
|
|
8206
|
+
// manage tooltipElement & tooltipedElement mouseenter/mouseleave events
|
|
8207
|
+
this.mgTooltipContent.addEventListener('mouseenter', () => {
|
|
8208
|
+
this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, 'mouseenter', Guard.HOVER_TOOLTIPED_ELEMENT);
|
|
8209
|
+
});
|
|
8210
|
+
this.mgTooltipContent.addEventListener('mouseleave', () => {
|
|
8211
|
+
this.tooltipMouseListenerAction(Guard.HOVER_TOOLTIP_ELEMENT, 'mouseleave', Guard.HOVER_TOOLTIPED_ELEMENT);
|
|
8212
|
+
});
|
|
8166
8213
|
// append tooltip element to component
|
|
8167
|
-
this.element.appendChild(mgTooltipContent);
|
|
8168
|
-
}
|
|
8169
|
-
else {
|
|
8170
|
-
mgTooltipContent.setAttribute('id', this.identifier);
|
|
8214
|
+
this.element.appendChild(this.mgTooltipContent);
|
|
8171
8215
|
}
|
|
8172
8216
|
}
|
|
8173
8217
|
/*************
|
|
@@ -8178,14 +8222,13 @@ const MgTooltip = class {
|
|
|
8178
8222
|
*/
|
|
8179
8223
|
componentWillLoad() {
|
|
8180
8224
|
// Get windows to attach events
|
|
8181
|
-
this.windows =
|
|
8225
|
+
this.windows = ze(window);
|
|
8182
8226
|
// Get tooltip element
|
|
8183
8227
|
this.renderTooltipContent();
|
|
8184
|
-
this.mgTooltipContent = this.element.querySelector(`#${this.identifier}`);
|
|
8185
8228
|
//validate properties
|
|
8186
|
-
this.
|
|
8187
|
-
this.
|
|
8188
|
-
this.
|
|
8229
|
+
this.watchDisabled(this.disabled);
|
|
8230
|
+
this.watchMessage(this.message);
|
|
8231
|
+
this.watchIdentifier();
|
|
8189
8232
|
}
|
|
8190
8233
|
/**
|
|
8191
8234
|
* Get slotted element
|
|
@@ -8197,26 +8240,29 @@ const MgTooltip = class {
|
|
|
8197
8240
|
// get slotted element wich is not the tooltip
|
|
8198
8241
|
const slotElement = this.element.querySelector(`*:not(#${this.identifier})`);
|
|
8199
8242
|
// Get interactive element
|
|
8200
|
-
const interactiveElement = slotElement.matches(
|
|
8201
|
-
|
|
8202
|
-
this.tooltipedElement = interactiveElement || slotElement;
|
|
8243
|
+
const interactiveElement = slotElement.matches(We) ? slotElement : (_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(We);
|
|
8244
|
+
this.setTooltipedElement(interactiveElement || slotElement);
|
|
8203
8245
|
// Check if slotted element is a disabled mg-button
|
|
8204
8246
|
// In this case we wrap the mg-button into a div to enable the tooltip
|
|
8205
8247
|
if (isButton(slotElement)) {
|
|
8206
|
-
|
|
8207
|
-
if (mutationList.some(mutation => ['aria-disabled', 'disabled'].includes(mutation.attributeName)) && this.guard !== Guard.DISABLE_ON_CLICK) {
|
|
8208
|
-
this.setMgButtonWrapper(slotElement);
|
|
8209
|
-
// Since Firefox doesn't trigger a "blur" event when the "disabled" attribute is added or removed from a button
|
|
8210
|
-
// we have to manually unlock the guard because the "blur" handler of the tooltipedElement won't do it.
|
|
8211
|
-
this.resetGuard();
|
|
8212
|
-
this.initTooltip(slotElement, interactiveElement);
|
|
8213
|
-
}
|
|
8214
|
-
}).observe(slotElement, { attributes: true });
|
|
8248
|
+
this.setMgButtonMutationObserver(slotElement);
|
|
8215
8249
|
this.setMgButtonWrapper(slotElement);
|
|
8216
8250
|
}
|
|
8217
|
-
//
|
|
8218
|
-
this.
|
|
8219
|
-
|
|
8251
|
+
// Add tabindex to slotted element if we can't find any interactive element
|
|
8252
|
+
if (!this.disabled && !interactiveElement) {
|
|
8253
|
+
this.hasCustomTabIndex = true;
|
|
8254
|
+
slotElement.tabIndex = 0;
|
|
8255
|
+
// Add role on non-interactive element to work with "aria-describedby" for screen readers
|
|
8256
|
+
slotElement.setAttribute('role', 'button');
|
|
8257
|
+
}
|
|
8258
|
+
// apply a11y aria
|
|
8259
|
+
this.setAriaDescribedby(slotElement);
|
|
8260
|
+
// set Tooltip
|
|
8261
|
+
this.setPopper();
|
|
8262
|
+
// add document keyboard handler
|
|
8263
|
+
document.addEventListener('keydown', this.handlePressEscape);
|
|
8264
|
+
// check props
|
|
8265
|
+
this.watchDisplay(this.display);
|
|
8220
8266
|
}
|
|
8221
8267
|
/**
|
|
8222
8268
|
* update popper position after props change on component did update hook to benefit from render ended
|
|
@@ -8229,14 +8275,14 @@ const MgTooltip = class {
|
|
|
8229
8275
|
* @returns HTML Element
|
|
8230
8276
|
*/
|
|
8231
8277
|
render() {
|
|
8232
|
-
return (h(Host, { key: '
|
|
8278
|
+
return (h(Host, { key: '9d7c428ba22f6b8e41ad1b62837d7b369e38314d' }, h("slot", { key: 'f5bdcac81a64674dd57e88e1c00b540dd49310f6' }), h("slot", { key: '8d40b6f4f1d3f385dcdf582509f89b3ec0dbd676', name: "content" })));
|
|
8233
8279
|
}
|
|
8234
8280
|
get element() { return getElement(this); }
|
|
8235
8281
|
static get watchers() { return {
|
|
8236
|
-
"identifier": ["
|
|
8237
|
-
"message": ["
|
|
8238
|
-
"display": ["
|
|
8239
|
-
"disabled": ["
|
|
8282
|
+
"identifier": ["watchIdentifier"],
|
|
8283
|
+
"message": ["watchMessage"],
|
|
8284
|
+
"display": ["watchDisplay"],
|
|
8285
|
+
"disabled": ["watchDisabled"]
|
|
8240
8286
|
}; }
|
|
8241
8287
|
};
|
|
8242
8288
|
MgTooltip.style = MgTooltipStyle0;
|