@mgdis/mg-components 6.17.0 → 6.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index-DCZEYvlH.js +4 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_37.cjs.entry.js +411 -168
- package/dist/cjs/mg-alert.cjs.entry.js +1 -1
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-fieldset.cjs.entry.js +141 -0
- package/dist/cjs/mg-input-combobox.cjs.entry.js +71 -55
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +33 -20
- package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-HYIzRsy7.js} +5 -0
- package/dist/cjs/mg-loader.cjs.entry.js +1 -1
- package/dist/cjs/mg-progress.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +4 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +178 -18
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +36 -16
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +78 -55
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +41 -22
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +32 -12
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +30 -12
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +31 -12
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +40 -20
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +31 -12
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +44 -25
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +31 -13
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +36 -11
- package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +5 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
- package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +404 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +13 -4
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +40 -9
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
- package/dist/components/mg-action-more.js +1 -1
- package/dist/components/mg-alert.js +1 -1
- package/dist/components/mg-details.js +1 -1
- package/dist/components/mg-fieldset.d.ts +11 -0
- package/dist/components/mg-fieldset.js +209 -0
- package/dist/components/mg-form.js +4 -3
- package/dist/components/mg-illustrated-message.js +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +1 -1
- package/dist/components/mg-input-checkbox.js +28 -15
- package/dist/components/mg-input-combobox.js +71 -55
- package/dist/components/mg-input-date.js +33 -21
- package/dist/components/mg-input-numeric.js +24 -11
- package/dist/components/mg-input-password.js +22 -11
- package/dist/components/mg-input-radio.js +23 -11
- package/dist/components/mg-input-rich-text-editor.js +32 -19
- package/dist/components/mg-input-select2.js +24 -12
- package/dist/components/mg-input-text2.js +36 -24
- package/dist/components/mg-input-textarea.js +23 -12
- package/dist/components/mg-input-toggle.js +35 -10
- package/dist/components/mg-input2.js +117 -18
- package/dist/components/mg-item-more2.js +5 -1
- package/dist/components/mg-loader2.js +1 -1
- package/dist/components/mg-message2.js +2 -2
- package/dist/components/mg-modal.js +2 -2
- package/dist/components/mg-panel.js +36 -7
- package/dist/components/mg-popover-content2.js +1 -1
- package/dist/components/mg-popover2.js +1 -1
- package/dist/components/mg-progress.js +1 -1
- package/dist/components/mg-skip-links.js +1 -1
- package/dist/components/mg-tabs2.js +1 -1
- package/dist/esm/{index-WtiuOkLj.js → index-C7xjtdiw.js} +1 -1
- package/dist/esm/index-T6kOJXP1.js +4 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_37.entry.js +412 -169
- package/dist/esm/mg-alert.entry.js +2 -2
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-fieldset.entry.js +139 -0
- package/dist/esm/mg-input-combobox.entry.js +72 -56
- package/dist/esm/mg-input-rich-text-editor.entry.js +34 -21
- package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-D9V2v4n2.js} +5 -1
- package/dist/esm/mg-loader.entry.js +2 -2
- package/dist/esm/mg-progress.entry.js +2 -2
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-2bab89c2.entry.js +1 -0
- package/dist/mg-components/{p-0e6b40d6.entry.js → p-5abc77cd.entry.js} +1 -1
- package/dist/mg-components/p-7d2e43b2.entry.js +1 -0
- package/dist/mg-components/{p-5dc3a1fb.entry.js → p-92e5e5a6.entry.js} +1 -1
- package/dist/mg-components/{p-c5da335e.entry.js → p-952288bd.entry.js} +1 -1
- package/dist/mg-components/{p-WtiuOkLj.js → p-C7xjtdiw.js} +1 -1
- package/dist/mg-components/p-D9V2v4n2.js +1 -0
- package/dist/mg-components/p-f2cddd52.entry.js +1 -0
- package/dist/mg-components/{p-397bf67b.entry.js → p-f6afaeb8.entry.js} +1 -1
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +32 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -2
- package/dist/types/components/molecules/mg-fieldset/mg-fieldset.d.ts +105 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +8 -1
- package/dist/types/components.d.ts +168 -18
- package/ide/intellij/web-types.json +272 -9
- package/ide/vscode/html-custom-data.json +243 -5
- package/package.json +15 -15
- package/dist/mg-components/p-8a69175b.entry.js +0 -1
- package/dist/mg-components/p-CNgv8hc5.js +0 -1
- package/dist/mg-components/p-d84d87ea.entry.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, a as getElement, c as createEvent } from './index-T6kOJXP1.js';
|
|
2
|
-
import { h as createID, t as toString, C as ClassList,
|
|
2
|
+
import { h as createID, t as toString, C as ClassList, i as isValidString, n as nextTick, j as isValideID, k as isTagName, l as cleanString, f as formatID, m as dateRegExp, o as dateToString, b as allItemsAreString, p as getWindows, q as focusableElements } from './index-C7xjtdiw.js';
|
|
3
3
|
import { i as initLocales, l as localeDate, a as localeDatePattern, b as localeNumber, c as localeUnit, d as localePercent, e as localeCurrency } from './index-CNX6lq0x.js';
|
|
4
4
|
import { K as Keys } from './events.utils-yMGqY8YG.js';
|
|
5
|
-
import { t as tooltipPositions, b as classFieldset, c as classReadonly, a as classDisabled, d as classVerticalList, w as widths } from './mg-input.conf-
|
|
5
|
+
import { l as labelHeadings, t as tooltipPositions, b as classFieldset, c as classReadonly, a as classDisabled, d as classVerticalList, w as widths } from './mg-input.conf-D9V2v4n2.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Available menu item status values
|
|
@@ -171,7 +171,7 @@ const MgActionMore = class {
|
|
|
171
171
|
[`${this.classBase}__chevron--rotate`]: this.expanded === true,
|
|
172
172
|
} }, h("mg-icon", { icon: "chevron-down" })));
|
|
173
173
|
}
|
|
174
|
-
return (h(Host, { key: '
|
|
174
|
+
return (h(Host, { key: 'd75e1a5326ea3a1414f8048858e5ee3fee51760e', "data-mg-popover-guard": this.mgPopoverIdentifier }, h("span", { key: 'b671a6c35cb3a9fa6eb7b2329f0f595e78b573b5', class: this.classBase }, h("mg-popover", { key: '38a38123d34ca868d0587123c2ab6b11550da8f0', identifier: this.mgPopoverIdentifier, display: this.expanded, "onDisplay-change": this.handleDisplayChange }, h("mg-button", { key: '030b9360917b79edfc8df325d5ca5cfa08356c81', variant: this.button.variant, isIcon: this.button.isIcon, disabled: this.button.disabled, type: "button", label: buttonLabel, onClick: this.handleButton }, this.icon && h("mg-icon", Object.assign({ key: 'a47ca6b078ca160d1cbb13c964df3abede5f373c' }, this.icon)), !this.button.isIcon && buttonContent), h("div", { key: 'ac38c705625cb5716a7e8aabd25d596db3d5adef', slot: "content" }, h("mg-menu", { key: 'cd382a65f69ba3c303a74d6b7444fcf0ccf9d1c5', direction: directions$1.VERTICAL, label: this.messages.label }, this.items.map(item => {
|
|
175
175
|
var _a, _b;
|
|
176
176
|
return isMgActionMoreDivider(item) ? (h("mg-divider", { class: "mg-c-action-more__divider", key: "divider", "full-width": true })) : (h("mg-menu-item", { key: item.label, status: item.status || Status$1.VISIBLE, target: item.target, href: item.href,
|
|
177
177
|
// eslint-disable-next-line react/jsx-no-bind
|
|
@@ -657,7 +657,7 @@ const MgDetails = class {
|
|
|
657
657
|
* @returns HTML Element
|
|
658
658
|
*/
|
|
659
659
|
render() {
|
|
660
|
-
return (h("details", { key: '
|
|
660
|
+
return (h("details", { key: 'bbaac6909fa5f3fbd3236b2a8ace0f7c80b2580b', class: { 'mg-c-details': true, 'mg-c-details--empty-summary': this.isEmptySummary }, onToggle: this.handleToggle, open: this.expanded, ref: (el) => (this.details = el) }, h("summary", { key: '2ed8228b63403dd9b386bf3fa70c9094516b6f0e' }, h("slot", { key: '5461d77d2b2869b14737a5c7cfc40a1f9584ee03', name: "summary" }), h("span", { key: 'bb089365bdeaa7b934b97cff6f5f7c67587048e1', class: "mg-c-details__toggle" }, h("mg-icon", { key: 'dc1a30338703ad4182d50f9953a903ae0f68ecb1', icon: "chevron-up", class: { 'mg-c-details__toggle-icon': true, 'mg-c-details__toggle-icon--reverse': !this.expanded } }), h("span", { key: 'a32cbaf9e38b71540deeaa8980895c34a7288ecb', class: { 'mg-u-visually-hidden': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), h("div", { key: 'b9c2bc7d681da8ac8b4dec5ff25287bc68975fb6', class: "mg-c-details__details" }, h("slot", { key: '069f05b4c133ff13055681e0b05bb98744303137', name: "details" }))));
|
|
661
661
|
}
|
|
662
662
|
get element() { return getElement(this); }
|
|
663
663
|
static get watchers() { return {
|
|
@@ -854,11 +854,12 @@ const MgForm = class {
|
|
|
854
854
|
this.setRequiredMessage();
|
|
855
855
|
}
|
|
856
856
|
/**
|
|
857
|
-
* Display
|
|
857
|
+
* Display inputs/fieldsets errors if it exists.
|
|
858
858
|
*/
|
|
859
859
|
async displayError() {
|
|
860
860
|
if (!this.readonly) {
|
|
861
|
-
this.
|
|
861
|
+
const mgFieldsets = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-FIELDSET'));
|
|
862
|
+
[...mgFieldsets, ...this.mgInputs].forEach(input => {
|
|
862
863
|
var _a;
|
|
863
864
|
(_a = input.displayError) === null || _a === void 0 ? void 0 : _a.call(input);
|
|
864
865
|
});
|
|
@@ -934,7 +935,7 @@ const MgForm = class {
|
|
|
934
935
|
* @returns HTML Element
|
|
935
936
|
*/
|
|
936
937
|
render() {
|
|
937
|
-
return (h("form", { key: '
|
|
938
|
+
return (h("form", { key: '8b698b2a33af00e36691abab5adff5488b736218', class: this.classCollection.join(), id: this.identifier, name: this.name, onSubmit: this.handleFormSubmit, role: this.ariaRole }, this.requiredMessageText && h("p", { key: '2e1fb5c4030ecb99d1f18c57d5c3fe238db4d12e', innerHTML: this.requiredMessageText }), h("slot", { key: '568fb8ac9ab0e3521899c05472592ebd15cc91fa' }), !this.readonly && !this.disabled && h("slot", { key: 'd4f38320de58f3b1d491083a34d1b5366d22b935', name: "actions" })));
|
|
938
939
|
}
|
|
939
940
|
get element() { return getElement(this); }
|
|
940
941
|
static get watchers() { return {
|
|
@@ -1188,7 +1189,7 @@ const MgIllustratedMessage = class {
|
|
|
1188
1189
|
* @returns HTML Element
|
|
1189
1190
|
*/
|
|
1190
1191
|
render() {
|
|
1191
|
-
return (h("div", { key: '
|
|
1192
|
+
return (h("div", { key: 'c9d8c8bfd2792b1cf5e78ab9d168d597b20e9a1e', class: this.classCollection.join() }, h("div", { key: 'cc8fa03147b9e59e6e8e015be9ed2b8dddd92ded', class: "mg-c-illustrated-message__illustration" }, h("slot", { key: '83a4ec2223c4e74511beb7c0abfa10e77cee425d', name: "illustration" })), h("div", { key: 'dbb4d13ca5324cab889fa2acc9b9b22522d7a8ec', class: "mg-c-illustrated-message__slots" }, h("slot", { key: '9e74d84becf29539ec9c37e8ad1e317714f3c86c', name: "title" }), h("slot", { key: 'ae97d25c19b76ca092560d2555ebd6a87f542ffe', name: "details" }))));
|
|
1192
1193
|
}
|
|
1193
1194
|
get element() { return getElement(this); }
|
|
1194
1195
|
static get watchers() { return {
|
|
@@ -1198,7 +1199,7 @@ const MgIllustratedMessage = class {
|
|
|
1198
1199
|
};
|
|
1199
1200
|
MgIllustratedMessage.style = mgIllustratedMessageCss;
|
|
1200
1201
|
|
|
1201
|
-
const mgInputCss = ".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}}/*!\n * @prop --mg-c-input-border-width: Defines the width of the input border. Default value is `--mg-b-size-border`.\n * @prop --mg-c-input-border-radius: Defines the border radius of the input. Default value is `--mg-b-size-radius`.\n * @prop --mg-c-input-color-border: Defines the color of the input border. Default value is `rgb(181, 194, 201)`.\n * @prop --mg-c-input-placeholder-color-text: Defines the color of the placeholder text. Default value is `rgb(181, 194, 201)`.\n * @prop --mg-c-input-color-box-shadow-focus: Defines the shadow color of the input when focused. Default value is `rgba(0, 221, 255, 0.5)`.\n * @prop --mg-c-input-error-color-background: Defines the background color of the input error message. Default value is `color-mix(in srgb, var(--mg-b-color-danger), white 95%)`.\n * @prop --mg-c-input-toggle-border-radius-ratio: Defines the border radius ratio of the input toggle. Default value is `2`.\n * @prop --mg-c-input-check-size: Defines the size of the input check. Default value is `--mg-b-size-16`.\n */: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(--mg-b-size-min-height);align-items:flex-start}.mg-c-input__input-container{width:100%;min-height:var(--mg-b-size-min-height)}.mg-c-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-b-size-16);height:var(--mg-b-size-16);margin-left:var(--mg-b-size-8)}@media print{.mg-c-input__input-container mg-tooltip{display:none}}.mg-c-input__input{display:flex;min-height:var(--mg-b-size-min-height);align-items:center;justify-content:start}.mg-c-input__input mg-tooltip{align-self:baseline;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__input ::slotted(.mg-c-input__button-toggle:disabled){opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input__title{display:flex;width:var(--mg-c-input-title-width, auto);flex-shrink:0;align-items:baseline;justify-content:flex-end;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);margin-right:var(--mg-c-input-title-horizontal-space, var(--mg-b-size-8));text-align:right}.mg-c-input__title slot[name=label]+mg-tooltip{margin-left:var(--mg-b-size-4)}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__error{display:inline-block;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-radius:var(--mg-b-size-radius);background:var(--mg-c-input-error-color-background);color:var(--mg-b-color-danger)}.mg-c-input__error ::slotted(*),.mg-c-input__help-text ::slotted(*){font-size:var(--mg-b-font-size-small);text-align:start}: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:var(--mg-b-size-4)}:host(.mg-c-input.mg-c-input--readonly) .mg-c-input__input mg-tooltip{margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2)}:host(.mg-c-input){display:flex;margin-bottom:var(--mg-c-input-margin-bottom, 0)}: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(.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--fieldset:not(.mg-c-input--checkbox-multi,.mg-c-input--readonly)) .mg-c-input__input-container mg-tooltip{margin-left:var(--mg-b-size-32)}: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:var(--mg-b-size-4);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:var(--mg-b-size-4);text-align:left}:host(.mg-c-input) .mg-c-input__title ::slotted(mg-input-title){flex-shrink:1}}";
|
|
1202
|
+
const mgInputCss = ".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}}/*!\n * @prop --mg-c-input-border-width: Defines the width of the input border. Default value is `--mg-b-size-border`.\n * @prop --mg-c-input-border-radius: Defines the border radius of the input. Default value is `--mg-b-size-radius`.\n * @prop --mg-c-input-color-border: Defines the color of the input border. Default value is `rgb(181, 194, 201)`.\n * @prop --mg-c-input-placeholder-color-text: Defines the color of the placeholder text. Default value is `rgb(181, 194, 201)`.\n * @prop --mg-c-input-color-box-shadow-focus: Defines the shadow color of the input when focused. Default value is `rgba(0, 221, 255, 0.5)`.\n * @prop --mg-c-input-error-color-background: Defines the background color of the input error message. Default value is `color-mix(in srgb, var(--mg-b-color-danger), white 95%)`.\n * @prop --mg-c-input-toggle-border-radius-ratio: Defines the border radius ratio of the input toggle. Default value is `2`.\n * @prop --mg-c-input-check-size: Defines the size of the input check. Default value is `--mg-b-size-16`.\n */: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(--mg-b-size-min-height);align-items:flex-start}.mg-c-input__input-container{width:100%;min-height:var(--mg-b-size-min-height)}.mg-c-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-b-size-16);height:var(--mg-b-size-16);margin-left:var(--mg-b-size-8)}@media print{.mg-c-input__input-container mg-tooltip{display:none}}.mg-c-input__input{display:flex;min-height:var(--mg-b-size-min-height);align-items:center;justify-content:start}.mg-c-input__input mg-tooltip{align-self:baseline;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__input ::slotted(.mg-c-input__button-toggle:disabled){opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input__title{display:flex;width:var(--mg-c-input-title-width, auto);flex-shrink:0;align-items:baseline;justify-content:flex-end;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);margin-right:var(--mg-c-input-title-horizontal-space, var(--mg-b-size-8));text-align:right}.mg-c-input__title slot[name=label]+mg-tooltip{margin-left:var(--mg-b-size-4)}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__error{display:inline-block;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-radius:var(--mg-b-size-radius);background:var(--mg-c-input-error-color-background);color:var(--mg-b-color-danger)}.mg-c-input__error ::slotted(*),.mg-c-input__help-text ::slotted(*){font-size:var(--mg-b-font-size-small);text-align:start}: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:var(--mg-b-size-4)}:host(.mg-c-input.mg-c-input--readonly) .mg-c-input__input mg-tooltip{margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2)}:host(.mg-c-input){display:flex;margin-bottom:var(--mg-c-input-margin-bottom, 0)}:host(.mg-c-input.mg-c-input--checkbox) .mg-c-input__input,:host(.mg-c-input.mg-c-input--toggle) .mg-c-input__input,:host(.mg-c-input.mg-c-input--radio) .mg-c-input__input{min-height:unset;align-items:flex-start}: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--fieldset:not(.mg-c-input--checkbox-multi,.mg-c-input--readonly)) .mg-c-input__input-container mg-tooltip{margin-left:var(--mg-b-size-32)}:host(.mg-c-input.mg-c-input--toggle) .mg-c-input__input-container{min-width:0;flex:1}: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:var(--mg-b-size-4);text-align:left}:host(.mg-c-input.mg-c-input--label-on-top) .mg-c-input__title ::slotted(mg-input-title){flex-shrink:1}:host(.mg-c-input.mg-c-input--inputs-on-bottom) .mg-c-input__help-text{margin-top:var(--mg-b-size-4);margin-bottom:var(--mg-b-size-12)}:host(.mg-c-input.mg-c-input--inputs-on-bottom) .mg-c-input__error{margin-bottom:var(--mg-b-size-20)}:host(.mg-c-input.mg-c-input--inputs-on-bottom.mg-c-input--fieldset){--mg-c-input-title-width:var(--mg-c-form-inputs-title-width, calc(28 * var(--mg-b-size-8)));--mg-c-input-title-horizontal-space:var(--mg-b-size-32)}:host(.mg-c-input.mg-c-input--inputs-on-bottom.mg-c-input--fieldset) ::slotted(*){--mg-c-input-margin-bottom:var(--mg-b-size-16)}:host(.mg-c-input.mg-c-input--label-border-display) .mg-c-input__title{border-bottom:var(--mg-b-size-border) solid var(--mg-c-divider-color-background)}:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__title{margin-bottom:0}:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input-title__text{margin-top:var(--mg-b-font-size-8);margin-bottom:var(--mg-b-font-size-8)}:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__help-text,:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__error{margin-top:0;margin-bottom:var(--mg-b-size-4)}:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__help-text+.mg-c-input__input,:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__error+.mg-c-input__input{margin-top:var(--mg-b-size-12)}:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__help-text+.mg-c-input__error{margin-top:var(--mg-b-size-4)}:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__title{margin-bottom:var(--mg-b-size-16)}:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__help-text,:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__error{margin-bottom:0}:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__help-text+.mg-c-input__input,:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__error+.mg-c-input__input{margin-top:var(--mg-b-size-16)}:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__help-text+.mg-c-input__error{margin-top:var(--mg-b-size-8)}@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:var(--mg-b-size-4);text-align:left}:host(.mg-c-input) .mg-c-input__title ::slotted(mg-input-title){flex-shrink:1}}";
|
|
1202
1203
|
|
|
1203
1204
|
const MgInput = class {
|
|
1204
1205
|
constructor(hostRef) {
|
|
@@ -1210,6 +1211,9 @@ const MgInput = class {
|
|
|
1210
1211
|
this.classInput = 'mg-c-input';
|
|
1211
1212
|
this.classHasError = 'mg-c-input--has-error';
|
|
1212
1213
|
this.classLabelOnTop = 'mg-c-input--label-on-top';
|
|
1214
|
+
this.classHasHeading = 'mg-c-input--has-heading';
|
|
1215
|
+
this.classLabelBorderDisplay = 'mg-c-input--label-border-display';
|
|
1216
|
+
this.classInputsOnBottom = 'mg-c-input--inputs-on-bottom';
|
|
1213
1217
|
/**
|
|
1214
1218
|
* Define if label is displayed on top
|
|
1215
1219
|
*/
|
|
@@ -1218,6 +1222,11 @@ const MgInput = class {
|
|
|
1218
1222
|
* Define if label is visible
|
|
1219
1223
|
*/
|
|
1220
1224
|
this.labelHide = false;
|
|
1225
|
+
/**
|
|
1226
|
+
* Define if label border is visible
|
|
1227
|
+
* You must pair this mode with `labelOnTop`and `fieldset` class
|
|
1228
|
+
*/
|
|
1229
|
+
this.labelBorderDisplay = false;
|
|
1221
1230
|
/**
|
|
1222
1231
|
* Define tooltip position
|
|
1223
1232
|
*/
|
|
@@ -1226,6 +1235,10 @@ const MgInput = class {
|
|
|
1226
1235
|
* Define if input is required
|
|
1227
1236
|
*/
|
|
1228
1237
|
this.required = false;
|
|
1238
|
+
/**
|
|
1239
|
+
* Display inputs after help-text and error message
|
|
1240
|
+
*/
|
|
1241
|
+
this.inputsOnBottom = false;
|
|
1229
1242
|
/**
|
|
1230
1243
|
* Define aria-describedby ids to link with
|
|
1231
1244
|
*/
|
|
@@ -1246,11 +1259,44 @@ const MgInput = class {
|
|
|
1246
1259
|
* Element is disabled
|
|
1247
1260
|
*/
|
|
1248
1261
|
this.isVerticalList = false;
|
|
1262
|
+
/************
|
|
1263
|
+
* Methods *
|
|
1264
|
+
************/
|
|
1265
|
+
/**
|
|
1266
|
+
* Update element aria-describedby
|
|
1267
|
+
* @param element - element to update
|
|
1268
|
+
* @param ariaDescribedbyIDs - ariaDescribedbyIDs references
|
|
1269
|
+
*/
|
|
1270
|
+
this.updateElementAriaDescribedby = (element, ariaDescribedbyIDs) => {
|
|
1271
|
+
if (ariaDescribedbyIDs.size > 0) {
|
|
1272
|
+
element.setAttribute('aria-describedby', Array.from(ariaDescribedbyIDs).join(' '));
|
|
1273
|
+
}
|
|
1274
|
+
else {
|
|
1275
|
+
element.removeAttribute('aria-describedby');
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1249
1278
|
/**
|
|
1250
1279
|
* Get tooltip node
|
|
1251
1280
|
* @returns mg-tooltip
|
|
1252
1281
|
*/
|
|
1253
1282
|
this.renderTooltip = () => (h("mg-tooltip", { identifier: `${this.identifier}-tooltip`, message: this.tooltip }, h("mg-icon", { icon: "info-circle" })));
|
|
1283
|
+
/**
|
|
1284
|
+
* Get input container element
|
|
1285
|
+
* @returns ordered elements
|
|
1286
|
+
*/
|
|
1287
|
+
this.inputContainerElements = () => {
|
|
1288
|
+
const elements = [
|
|
1289
|
+
this.helptextMessageSlotElement && (h("div", { class: "mg-c-input__help-text" }, h("slot", { name: this.slotHelpText }))),
|
|
1290
|
+
!this.isDisabled && this.errorMessage && (h("div", { class: "mg-c-input__error", "aria-live": "assertive" }, h("slot", { name: this.slotError }))),
|
|
1291
|
+
];
|
|
1292
|
+
const inputSlot = (h("div", { class: "mg-c-input__input" }, h("slot", null), this.tooltip && !this.labelOnTop && (this.tooltipPosition === 'input' || this.labelHide) && this.renderTooltip()));
|
|
1293
|
+
if (this.inputsOnBottom) {
|
|
1294
|
+
return [...elements, inputSlot];
|
|
1295
|
+
}
|
|
1296
|
+
else {
|
|
1297
|
+
return [inputSlot, ...elements];
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1254
1300
|
}
|
|
1255
1301
|
watchIdentifier(newValue) {
|
|
1256
1302
|
if (!isValidString(newValue)) {
|
|
@@ -1277,6 +1323,26 @@ const MgInput = class {
|
|
|
1277
1323
|
throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide".');
|
|
1278
1324
|
}
|
|
1279
1325
|
}
|
|
1326
|
+
watchlabelHeading(newValue) {
|
|
1327
|
+
if (this.isFieldset && this.labelOnTop && labelHeadings.includes(newValue)) {
|
|
1328
|
+
this.element.classList.add(this.classHasHeading);
|
|
1329
|
+
}
|
|
1330
|
+
else {
|
|
1331
|
+
if ((!this.isFieldset && newValue !== undefined) || typeof newValue === 'string') {
|
|
1332
|
+
throw new Error(`<mg-input> prop "labelHeading" must be used with a fieldset and be one of: ${labelHeadings.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
1333
|
+
}
|
|
1334
|
+
this.labelHeading = undefined;
|
|
1335
|
+
this.element.classList.remove(this.classHasHeading);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
watchLabelBorderDisplay(newValue) {
|
|
1339
|
+
if (this.isFieldset && this.labelOnTop && newValue) {
|
|
1340
|
+
this.element.classList.add(this.classLabelBorderDisplay);
|
|
1341
|
+
}
|
|
1342
|
+
else {
|
|
1343
|
+
this.element.classList.remove(this.classLabelBorderDisplay);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1280
1346
|
watchTooltipPosition(newValue) {
|
|
1281
1347
|
if (!tooltipPositions.includes(newValue)) {
|
|
1282
1348
|
throw new Error(`<mg-input> prop "tooltipPosition" must be one of: ${tooltipPositions.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
@@ -1296,7 +1362,7 @@ const MgInput = class {
|
|
|
1296
1362
|
}
|
|
1297
1363
|
watchHelpText(newValue) {
|
|
1298
1364
|
var _a;
|
|
1299
|
-
if (newValue && !this.isReadonly) {
|
|
1365
|
+
if (isValidString(newValue) && !this.isReadonly) {
|
|
1300
1366
|
this.renderHelpText();
|
|
1301
1367
|
}
|
|
1302
1368
|
else {
|
|
@@ -1304,6 +1370,14 @@ const MgInput = class {
|
|
|
1304
1370
|
this.helptextMessageSlotElement = undefined;
|
|
1305
1371
|
}
|
|
1306
1372
|
}
|
|
1373
|
+
watchInputsOnBottom(newValue) {
|
|
1374
|
+
if (newValue) {
|
|
1375
|
+
this.element.classList.add(this.classInputsOnBottom);
|
|
1376
|
+
}
|
|
1377
|
+
else {
|
|
1378
|
+
this.element.classList.remove(this.classInputsOnBottom);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1307
1381
|
watchAriaDescribedbyIDs() {
|
|
1308
1382
|
if (this.isReadonly) {
|
|
1309
1383
|
return;
|
|
@@ -1319,23 +1393,26 @@ const MgInput = class {
|
|
|
1319
1393
|
// a11y IDs
|
|
1320
1394
|
const ariaDescribedbyIDs = new Set(this.ariaDescribedbyIDs);
|
|
1321
1395
|
// Help text
|
|
1322
|
-
if (this.helpText
|
|
1396
|
+
if (isValidString(this.helpText)) {
|
|
1323
1397
|
this.renderHelpText();
|
|
1324
1398
|
if (!ariaDescribedbyIDs.has(this.helpTextId))
|
|
1325
1399
|
ariaDescribedbyIDs.add(this.helpTextId);
|
|
1326
1400
|
}
|
|
1327
1401
|
// Error Message
|
|
1328
|
-
if (this.errorMessage
|
|
1402
|
+
if (isValidString(this.errorMessage)) {
|
|
1329
1403
|
this.renderErrorMessage();
|
|
1330
1404
|
if (!ariaDescribedbyIDs.has(this.helpTextErrorId))
|
|
1331
1405
|
ariaDescribedbyIDs.add(this.helpTextErrorId);
|
|
1332
1406
|
}
|
|
1333
|
-
this.element.querySelectorAll('input,select,textarea,[role="switch"]')
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1407
|
+
const inputs = this.element.querySelectorAll('input,select,textarea,[role="switch"]');
|
|
1408
|
+
inputs.forEach((element) => {
|
|
1409
|
+
this.updateElementAriaDescribedby(element, ariaDescribedbyIDs);
|
|
1410
|
+
});
|
|
1411
|
+
// use timeout to await for legend render for componentWillLoad hook
|
|
1412
|
+
setTimeout(() => {
|
|
1413
|
+
const legend = this.element.querySelector('legend');
|
|
1414
|
+
if (legend !== null) {
|
|
1415
|
+
this.updateElementAriaDescribedby(legend, ariaDescribedbyIDs);
|
|
1339
1416
|
}
|
|
1340
1417
|
});
|
|
1341
1418
|
}
|
|
@@ -1365,9 +1442,6 @@ const MgInput = class {
|
|
|
1365
1442
|
this.renderLabel();
|
|
1366
1443
|
}
|
|
1367
1444
|
}
|
|
1368
|
-
/************
|
|
1369
|
-
* Methods *
|
|
1370
|
-
************/
|
|
1371
1445
|
/**
|
|
1372
1446
|
* Render input label
|
|
1373
1447
|
*/
|
|
@@ -1387,11 +1461,21 @@ const MgInput = class {
|
|
|
1387
1461
|
labelSlotElement.setAttribute(attr, val);
|
|
1388
1462
|
});
|
|
1389
1463
|
// create label element
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1464
|
+
if (labelHeadings.includes(this.labelHeading)) {
|
|
1465
|
+
let label = this.element.shadowRoot.querySelector(this.labelHeading);
|
|
1466
|
+
if (label === null) {
|
|
1467
|
+
label = document.createElement(this.labelHeading);
|
|
1468
|
+
label.classList.add('mg-c-input-title__text');
|
|
1469
|
+
labelSlotElement.appendChild(label);
|
|
1470
|
+
}
|
|
1471
|
+
label.textContent = this.label;
|
|
1472
|
+
}
|
|
1473
|
+
else {
|
|
1474
|
+
labelSlotElement.textContent = this.label;
|
|
1475
|
+
}
|
|
1394
1476
|
this.element.appendChild(labelSlotElement);
|
|
1477
|
+
// update aria-describedby
|
|
1478
|
+
this.watchAriaDescribedbyIDs();
|
|
1395
1479
|
}
|
|
1396
1480
|
/**
|
|
1397
1481
|
* Render error message
|
|
@@ -1434,6 +1518,9 @@ const MgInput = class {
|
|
|
1434
1518
|
this.watchTooltipPosition(this.tooltipPosition);
|
|
1435
1519
|
this.watchHelpText(this.helpText);
|
|
1436
1520
|
this.watchErrorMessage(this.errorMessage);
|
|
1521
|
+
this.watchInputsOnBottom(this.inputsOnBottom);
|
|
1522
|
+
this.watchlabelHeading(this.labelHeading);
|
|
1523
|
+
this.watchLabelBorderDisplay(this.labelBorderDisplay);
|
|
1437
1524
|
}
|
|
1438
1525
|
/**
|
|
1439
1526
|
* Validate slots
|
|
@@ -1450,16 +1537,19 @@ const MgInput = class {
|
|
|
1450
1537
|
*/
|
|
1451
1538
|
render() {
|
|
1452
1539
|
const isGroup = this.isFieldset && !this.isReadonly;
|
|
1453
|
-
return (h(Host, { key: '
|
|
1540
|
+
return (h(Host, { key: 'fbab18280a709407c83f324127e8de6cbb05fe7c', class: this.element.classList.toString(), role: isGroup ? 'group' : undefined, "aria-labelledby": isGroup ? `${this.identifier}-title` : undefined }, h("div", { key: 'ac0924c244b9fa87d02e659a5710ee93d12a202f', class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': this.labelHide } }, h("slot", { key: 'c825af33ba0a6c209d02d6487422347f7d8acfed', name: this.slotLabel }), this.tooltip && (this.tooltipPosition === 'label' || this.labelOnTop) && !this.labelHide && this.renderTooltip()), h("div", { key: '805e1eedfdea132f3ea4fd11da761810a3d7c939', class: "mg-c-input__input-container" }, this.inputContainerElements())));
|
|
1454
1541
|
}
|
|
1455
1542
|
get element() { return getElement(this); }
|
|
1456
1543
|
static get watchers() { return {
|
|
1457
1544
|
"identifier": ["watchIdentifier", "watchAriaDescribedbyIDs"],
|
|
1458
1545
|
"labelOnTop": ["watchLabelOnTop", "watchLabelConfig"],
|
|
1459
1546
|
"labelHide": ["watchLabelConfig"],
|
|
1547
|
+
"labelHeading": ["watchlabelHeading"],
|
|
1548
|
+
"labelBorderDisplay": ["watchLabelBorderDisplay"],
|
|
1460
1549
|
"tooltipPosition": ["watchTooltipPosition"],
|
|
1461
1550
|
"errorMessage": ["watchErrorMessage", "watchAriaDescribedbyIDs"],
|
|
1462
1551
|
"helpText": ["watchHelpText", "watchAriaDescribedbyIDs"],
|
|
1552
|
+
"inputsOnBottom": ["watchInputsOnBottom"],
|
|
1463
1553
|
"ariaDescribedbyIDs": ["watchAriaDescribedbyIDs"],
|
|
1464
1554
|
"class": ["watchClass", "watchLabel"],
|
|
1465
1555
|
"label": ["watchLabel"],
|
|
@@ -1522,6 +1612,7 @@ const MgInputCheckbox = class {
|
|
|
1522
1612
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
1523
1613
|
// hasDisplayedError (triggered by blur event)
|
|
1524
1614
|
this.hasDisplayedError = false;
|
|
1615
|
+
this.customErrorMessage = { lock: false };
|
|
1525
1616
|
this.mode = 'custom';
|
|
1526
1617
|
// style
|
|
1527
1618
|
this.baseClassName = 'mg-c-input--checkbox';
|
|
@@ -1739,17 +1830,20 @@ const MgInputCheckbox = class {
|
|
|
1739
1830
|
};
|
|
1740
1831
|
/**
|
|
1741
1832
|
* Set input error message
|
|
1742
|
-
* @param
|
|
1743
|
-
* @param errorMessage - errorMessage override
|
|
1833
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
1744
1834
|
*/
|
|
1745
|
-
this.setErrorMessage = (
|
|
1835
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
1746
1836
|
// Set error message
|
|
1747
1837
|
this.errorMessage = undefined;
|
|
1748
|
-
if (
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1838
|
+
if (!this.valid) {
|
|
1839
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
1840
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
1841
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
1842
|
+
}
|
|
1843
|
+
// required
|
|
1844
|
+
else if (!this.validateRequired()) {
|
|
1752
1845
|
this.errorMessage = this.messages.errors.required;
|
|
1846
|
+
}
|
|
1753
1847
|
}
|
|
1754
1848
|
};
|
|
1755
1849
|
/**
|
|
@@ -1843,7 +1937,7 @@ const MgInputCheckbox = class {
|
|
|
1843
1937
|
this.checkValidity();
|
|
1844
1938
|
if (this.hasDisplayedError) {
|
|
1845
1939
|
this.hasDisplayedError = prop !== 'required';
|
|
1846
|
-
this.setErrorMessage(
|
|
1940
|
+
this.setErrorMessage();
|
|
1847
1941
|
}
|
|
1848
1942
|
this.setButtonTextKey();
|
|
1849
1943
|
}
|
|
@@ -1907,17 +2001,22 @@ const MgInputCheckbox = class {
|
|
|
1907
2001
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
1908
2002
|
* @param valid - value indicating the validity
|
|
1909
2003
|
* @param errorMessage - the error message to display
|
|
2004
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
1910
2005
|
*/
|
|
1911
|
-
async setError(valid, errorMessage) {
|
|
2006
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
1912
2007
|
if (typeof valid !== 'boolean') {
|
|
1913
2008
|
throw new Error('<mg-input-checkbox> method "setError()" param "valid" must be a boolean.');
|
|
1914
2009
|
}
|
|
1915
|
-
else if (!isValidString(errorMessage)) {
|
|
2010
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
1916
2011
|
throw new Error('<mg-input-checkbox> method "setError()" param "errorMessage" must be a string.');
|
|
1917
2012
|
}
|
|
1918
2013
|
else {
|
|
2014
|
+
this.customErrorMessage = {
|
|
2015
|
+
lock: valid ? false : errorMessageLock,
|
|
2016
|
+
message: valid ? undefined : errorMessage,
|
|
2017
|
+
};
|
|
1919
2018
|
this.setValidity(valid);
|
|
1920
|
-
this.setErrorMessage(
|
|
2019
|
+
this.setErrorMessage(true);
|
|
1921
2020
|
this.hasDisplayedError = this.invalid;
|
|
1922
2021
|
}
|
|
1923
2022
|
}
|
|
@@ -1935,6 +2034,8 @@ const MgInputCheckbox = class {
|
|
|
1935
2034
|
// - Keep everything in sync both inside and outside the component
|
|
1936
2035
|
return new Promise(resolve => {
|
|
1937
2036
|
requestAnimationFrame(() => {
|
|
2037
|
+
// unlock validity check by reseting customErrorMessage
|
|
2038
|
+
this.customErrorMessage = { lock: false };
|
|
1938
2039
|
this.checkValidity();
|
|
1939
2040
|
this.errorMessage = undefined;
|
|
1940
2041
|
this.hasDisplayedError = false;
|
|
@@ -1948,11 +2049,13 @@ const MgInputCheckbox = class {
|
|
|
1948
2049
|
* @param newValue - valid new value
|
|
1949
2050
|
*/
|
|
1950
2051
|
setValidity(newValue) {
|
|
1951
|
-
const
|
|
1952
|
-
this.
|
|
2052
|
+
const oldValue = this.valid;
|
|
2053
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
2054
|
+
this.valid = newValue;
|
|
2055
|
+
}
|
|
1953
2056
|
this.invalid = !this.valid;
|
|
1954
2057
|
// We need to send valid event even if it is the same value
|
|
1955
|
-
if (this.valid !==
|
|
2058
|
+
if (this.valid !== oldValue)
|
|
1956
2059
|
this.inputValid.emit(this.valid);
|
|
1957
2060
|
}
|
|
1958
2061
|
/**
|
|
@@ -2071,7 +2174,7 @@ const MgInputCheckbox = class {
|
|
|
2071
2174
|
else {
|
|
2072
2175
|
inputContent = this.renderCheckboxMulti();
|
|
2073
2176
|
}
|
|
2074
|
-
return (h("mg-input", { key: '
|
|
2177
|
+
return (h("mg-input", { key: '5addea288b5c87fec33a56449d14f861aefd465d', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, tooltip: this.tooltip, tooltipPosition: this.readonly && readonlyValue.length === 0 ? 'label' : this.tooltipPosition, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined }, inputContent));
|
|
2075
2178
|
}
|
|
2076
2179
|
get element() { return getElement(this); }
|
|
2077
2180
|
static get watchers() { return {
|
|
@@ -2161,7 +2264,7 @@ const MgInputCheckboxPaginated = class {
|
|
|
2161
2264
|
render() {
|
|
2162
2265
|
const listId = formatID(this.messages.label);
|
|
2163
2266
|
const tabId = 'tab-info';
|
|
2164
|
-
return (h(Host, { key: '
|
|
2267
|
+
return (h(Host, { key: '233ab4fca3f4a3121bc60650ac2f8ae06d47e6e5' }, h("slot", { key: '7d1af8c712928c06953743fc5c182e51d9a6256b', name: "header-action" }), h("div", { key: '95641bd218e36422a6b5b4ead8dd5498e8ac5fa4', class: "mg-c-input__tabs-content" }, h("p", { key: '34814dd1afc9f871cd032500b931e692d63cbd25', id: tabId, class: { 'mg-c-input__popover-info': true, 'mg-u-visually-hidden': this.items.length !== 0 }, "aria-live": this.items.length !== 0 ? 'polite' : undefined }, this.items.length === 0 ? this.messages.noValue : this.messages.values.replace('{count}', this.items.length.toString())), this.items.length > 0 && (h(MgInputCheckboxList, { key: '621077f291a401737157ad0cd9b9348537ef8bdc', checkboxes: this.items, labelledby: tabId, id: listId, disabled: this.disabled, name: this.name, invalid: this.invalid })), this.hasNext() && (h("mg-button", { key: "load-more", variant: "flat", class: "mg-c-input__load-more", tabIndex: -1, "full-width": true, onClick: this.handleLoadMore, "aria-controls": listId }, h("mg-icon", { key: 'cb00bbeb1575475b184cc9623db6c4cefc56c26a', icon: "chevron-down" }), this.messages.showMore)))));
|
|
2165
2268
|
}
|
|
2166
2269
|
static get watchers() { return {
|
|
2167
2270
|
"checkboxes": ["watchCheckboxes"],
|
|
@@ -2180,6 +2283,7 @@ const MgInputDate = class {
|
|
|
2180
2283
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
2181
2284
|
// hasDisplayedError (triggered by blur event)
|
|
2182
2285
|
this.hasDisplayedError = false;
|
|
2286
|
+
this.customErrorMessage = { lock: false };
|
|
2183
2287
|
/**
|
|
2184
2288
|
* Input name
|
|
2185
2289
|
* If not set the value equals the identifier
|
|
@@ -2292,39 +2396,41 @@ const MgInputDate = class {
|
|
|
2292
2396
|
*/
|
|
2293
2397
|
this.getInputError = () => {
|
|
2294
2398
|
var _a;
|
|
2399
|
+
let error;
|
|
2295
2400
|
// bad input or pattern
|
|
2296
2401
|
if (this.input.validity.badInput || (this.value && !this.isValidPattern(this.value))) {
|
|
2297
|
-
|
|
2402
|
+
error = 'badInput';
|
|
2298
2403
|
}
|
|
2299
2404
|
// required
|
|
2300
|
-
if (this.input.validity.valueMissing) {
|
|
2301
|
-
|
|
2405
|
+
else if (this.input.validity.valueMissing) {
|
|
2406
|
+
error = 'required';
|
|
2302
2407
|
}
|
|
2303
2408
|
// min & max
|
|
2304
|
-
if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== DEFAULT_MAX_DATE) {
|
|
2305
|
-
|
|
2409
|
+
else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== DEFAULT_MAX_DATE) {
|
|
2410
|
+
error = 'minMax';
|
|
2306
2411
|
}
|
|
2307
2412
|
// min
|
|
2308
|
-
if (this.input.validity.rangeUnderflow) {
|
|
2309
|
-
|
|
2413
|
+
else if (this.input.validity.rangeUnderflow) {
|
|
2414
|
+
error = 'min';
|
|
2310
2415
|
}
|
|
2311
2416
|
// max
|
|
2312
|
-
if (this.input.validity.rangeOverflow) {
|
|
2313
|
-
|
|
2417
|
+
else if (this.input.validity.rangeOverflow) {
|
|
2418
|
+
error = 'max';
|
|
2314
2419
|
}
|
|
2315
|
-
return
|
|
2420
|
+
return error;
|
|
2316
2421
|
};
|
|
2317
2422
|
/**
|
|
2318
2423
|
* Check input errors
|
|
2319
|
-
* @param
|
|
2424
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
2320
2425
|
*/
|
|
2321
|
-
this.setErrorMessage = (
|
|
2426
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
2322
2427
|
// Set error message
|
|
2323
2428
|
this.errorMessage = undefined;
|
|
2324
2429
|
if (!this.valid) {
|
|
2325
2430
|
const inputError = this.getInputError();
|
|
2326
|
-
|
|
2327
|
-
|
|
2431
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
2432
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
2433
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
2328
2434
|
}
|
|
2329
2435
|
// required
|
|
2330
2436
|
else if (inputError === 'required') {
|
|
@@ -2436,17 +2542,22 @@ const MgInputDate = class {
|
|
|
2436
2542
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
2437
2543
|
* @param valid - value indicating the validity
|
|
2438
2544
|
* @param errorMessage - the error message to display
|
|
2545
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
2439
2546
|
*/
|
|
2440
|
-
async setError(valid, errorMessage) {
|
|
2547
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
2441
2548
|
if (typeof valid !== 'boolean') {
|
|
2442
2549
|
throw new Error('<mg-input-date> method "setError()" param "valid" must be a boolean.');
|
|
2443
2550
|
}
|
|
2444
|
-
else if (!isValidString(errorMessage)) {
|
|
2551
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
2445
2552
|
throw new Error('<mg-input-date> method "setError()" param "errorMessage" must be a string.');
|
|
2446
2553
|
}
|
|
2447
2554
|
else {
|
|
2555
|
+
this.customErrorMessage = {
|
|
2556
|
+
lock: valid ? false : errorMessageLock,
|
|
2557
|
+
message: valid ? undefined : errorMessage,
|
|
2558
|
+
};
|
|
2448
2559
|
this.setValidity(valid);
|
|
2449
|
-
this.setErrorMessage(
|
|
2560
|
+
this.setErrorMessage(true);
|
|
2450
2561
|
this.hasDisplayedError = this.invalid;
|
|
2451
2562
|
}
|
|
2452
2563
|
}
|
|
@@ -2464,6 +2575,8 @@ const MgInputDate = class {
|
|
|
2464
2575
|
// - Keep everything in sync both inside and outside the component
|
|
2465
2576
|
return new Promise(resolve => {
|
|
2466
2577
|
requestAnimationFrame(() => {
|
|
2578
|
+
// unlock validity check by reseting customErrorMessage
|
|
2579
|
+
this.customErrorMessage = { lock: false };
|
|
2467
2580
|
this.checkValidity();
|
|
2468
2581
|
this.errorMessage = undefined;
|
|
2469
2582
|
this.hasDisplayedError = false;
|
|
@@ -2477,11 +2590,13 @@ const MgInputDate = class {
|
|
|
2477
2590
|
* @param newValue - valid new value
|
|
2478
2591
|
*/
|
|
2479
2592
|
setValidity(newValue) {
|
|
2480
|
-
const
|
|
2481
|
-
this.
|
|
2593
|
+
const oldValue = this.valid;
|
|
2594
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
2595
|
+
this.valid = newValue;
|
|
2596
|
+
}
|
|
2482
2597
|
this.invalid = !this.valid;
|
|
2483
2598
|
// We need to send valid event even if it is the same value
|
|
2484
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
2599
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
2485
2600
|
this.inputValid.emit(this.valid);
|
|
2486
2601
|
}
|
|
2487
2602
|
/*************
|
|
@@ -2517,7 +2632,7 @@ const MgInputDate = class {
|
|
|
2517
2632
|
* @returns HTML Element
|
|
2518
2633
|
*/
|
|
2519
2634
|
render() {
|
|
2520
|
-
return (h("mg-input", { key: '
|
|
2635
|
+
return (h("mg-input", { key: '1428f0f9f11d829ec8d3ed507c8690d63839ff17', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === null ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly ? (this.value && h("b", { class: "mg-c-input__readonly-value" }, localeDate(this.value, this.locale))) : (h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, ref: (el) => {
|
|
2521
2636
|
if (el !== null)
|
|
2522
2637
|
this.input = el;
|
|
2523
2638
|
} }))));
|
|
@@ -2549,6 +2664,7 @@ const MgInputNumeric = class {
|
|
|
2549
2664
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
2550
2665
|
// hasDisplayedError (triggered by blur event)
|
|
2551
2666
|
this.hasDisplayedError = false;
|
|
2667
|
+
this.customErrorMessage = { lock: false };
|
|
2552
2668
|
/**
|
|
2553
2669
|
* Input name
|
|
2554
2670
|
* If not set the value equals the identifier
|
|
@@ -2654,19 +2770,22 @@ const MgInputNumeric = class {
|
|
|
2654
2770
|
this.formatErrorValue = (value) => localeNumber(value, this.locale, !Number.isInteger(value) && this.type === 'decimal' ? this.decimalLength : 0);
|
|
2655
2771
|
/**
|
|
2656
2772
|
* Set input error message
|
|
2657
|
-
* @param
|
|
2773
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
2658
2774
|
*/
|
|
2659
|
-
this.setErrorMessage = (
|
|
2775
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
2660
2776
|
// Set error message
|
|
2661
2777
|
this.errorMessage = undefined;
|
|
2662
2778
|
if (!this.valid) {
|
|
2663
2779
|
const inputError = this.getInputError();
|
|
2664
|
-
|
|
2665
|
-
|
|
2780
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
2781
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
2782
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
2666
2783
|
}
|
|
2784
|
+
// required
|
|
2667
2785
|
else if (inputError === 'required') {
|
|
2668
2786
|
this.errorMessage = this.messages.errors[inputError];
|
|
2669
2787
|
}
|
|
2788
|
+
// min/max
|
|
2670
2789
|
else {
|
|
2671
2790
|
const formattedMin = this.formatErrorValue(this.min);
|
|
2672
2791
|
const formattedMax = this.formatErrorValue(this.max);
|
|
@@ -2868,17 +2987,22 @@ const MgInputNumeric = class {
|
|
|
2868
2987
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
2869
2988
|
* @param valid - value indicating the validity
|
|
2870
2989
|
* @param errorMessage - the error message to display
|
|
2990
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
2871
2991
|
*/
|
|
2872
|
-
async setError(valid, errorMessage) {
|
|
2992
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
2873
2993
|
if (typeof valid !== 'boolean') {
|
|
2874
2994
|
throw new Error('<mg-input-numeric> method "setError()" param "valid" must be a boolean.');
|
|
2875
2995
|
}
|
|
2876
|
-
else if (!isValidString(errorMessage)) {
|
|
2996
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
2877
2997
|
throw new Error('<mg-input-numeric> method "setError()" param "errorMessage" must be a string.');
|
|
2878
2998
|
}
|
|
2879
2999
|
else {
|
|
3000
|
+
this.customErrorMessage = {
|
|
3001
|
+
lock: valid ? false : errorMessageLock,
|
|
3002
|
+
message: valid ? undefined : errorMessage,
|
|
3003
|
+
};
|
|
2880
3004
|
this.setValidity(valid);
|
|
2881
|
-
this.setErrorMessage(
|
|
3005
|
+
this.setErrorMessage(true);
|
|
2882
3006
|
this.hasDisplayedError = this.invalid;
|
|
2883
3007
|
}
|
|
2884
3008
|
}
|
|
@@ -2896,6 +3020,8 @@ const MgInputNumeric = class {
|
|
|
2896
3020
|
// - Keep everything in sync both inside and outside the component
|
|
2897
3021
|
return new Promise(resolve => {
|
|
2898
3022
|
requestAnimationFrame(() => {
|
|
3023
|
+
// unlock validity check by reseting customErrorMessage
|
|
3024
|
+
this.customErrorMessage = { lock: false };
|
|
2899
3025
|
this.checkValidity();
|
|
2900
3026
|
this.errorMessage = undefined;
|
|
2901
3027
|
this.hasDisplayedError = false;
|
|
@@ -2909,11 +3035,13 @@ const MgInputNumeric = class {
|
|
|
2909
3035
|
* @param newValue - valid new value
|
|
2910
3036
|
*/
|
|
2911
3037
|
setValidity(newValue) {
|
|
2912
|
-
const
|
|
2913
|
-
this.
|
|
3038
|
+
const oldValue = this.valid;
|
|
3039
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
3040
|
+
this.valid = newValue;
|
|
3041
|
+
}
|
|
2914
3042
|
this.invalid = !this.valid;
|
|
2915
3043
|
// We need to send valid event even if it is the same value
|
|
2916
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
3044
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
2917
3045
|
this.inputValid.emit(this.valid);
|
|
2918
3046
|
}
|
|
2919
3047
|
/**
|
|
@@ -2985,7 +3113,7 @@ const MgInputNumeric = class {
|
|
|
2985
3113
|
* @returns HTML Element
|
|
2986
3114
|
*/
|
|
2987
3115
|
render() {
|
|
2988
|
-
return (h("mg-input", { key: '
|
|
3116
|
+
return (h("mg-input", { key: 'c47f7c310587fc3bb4e7d5ffd07854a2297958df', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly
|
|
2989
3117
|
? this.readonlyValue && this.renderReadonly()
|
|
2990
3118
|
: [
|
|
2991
3119
|
h("input", { key: "input", type: "text", class: "mg-c-input__box mg-c-input__box--width", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
@@ -3021,6 +3149,7 @@ const MgInputPassword = class {
|
|
|
3021
3149
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
3022
3150
|
// hasDisplayedError (triggered by blur event)
|
|
3023
3151
|
this.hasDisplayedError = false;
|
|
3152
|
+
this.customErrorMessage = { lock: false };
|
|
3024
3153
|
/**
|
|
3025
3154
|
* Input name
|
|
3026
3155
|
* If not set the value equals the identifier
|
|
@@ -3096,14 +3225,15 @@ const MgInputPassword = class {
|
|
|
3096
3225
|
};
|
|
3097
3226
|
/**
|
|
3098
3227
|
* Set input error message
|
|
3099
|
-
* @param
|
|
3228
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
3100
3229
|
*/
|
|
3101
|
-
this.setErrorMessage = (
|
|
3230
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
3102
3231
|
// Set error message
|
|
3103
3232
|
this.errorMessage = undefined;
|
|
3104
3233
|
if (!this.valid) {
|
|
3105
|
-
|
|
3106
|
-
|
|
3234
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
3235
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
3236
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
3107
3237
|
}
|
|
3108
3238
|
// required
|
|
3109
3239
|
else if (this.input.validity.valueMissing) {
|
|
@@ -3179,17 +3309,22 @@ const MgInputPassword = class {
|
|
|
3179
3309
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
3180
3310
|
* @param valid - value indicating the validity
|
|
3181
3311
|
* @param errorMessage - the error message to display
|
|
3312
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
3182
3313
|
*/
|
|
3183
|
-
async setError(valid, errorMessage) {
|
|
3314
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
3184
3315
|
if (typeof valid !== 'boolean') {
|
|
3185
3316
|
throw new Error('<mg-input-password> method "setError()" param "valid" must be a boolean.');
|
|
3186
3317
|
}
|
|
3187
|
-
else if (!isValidString(errorMessage)) {
|
|
3318
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
3188
3319
|
throw new Error('<mg-input-password> method "setError()" param "errorMessage" must be a string.');
|
|
3189
3320
|
}
|
|
3190
3321
|
else {
|
|
3322
|
+
this.customErrorMessage = {
|
|
3323
|
+
lock: valid ? false : errorMessageLock,
|
|
3324
|
+
message: valid ? undefined : errorMessage,
|
|
3325
|
+
};
|
|
3191
3326
|
this.setValidity(valid);
|
|
3192
|
-
this.setErrorMessage(
|
|
3327
|
+
this.setErrorMessage(true);
|
|
3193
3328
|
this.hasDisplayedError = this.invalid;
|
|
3194
3329
|
}
|
|
3195
3330
|
}
|
|
@@ -3207,6 +3342,8 @@ const MgInputPassword = class {
|
|
|
3207
3342
|
// - Keep everything in sync both inside and outside the component
|
|
3208
3343
|
return new Promise(resolve => {
|
|
3209
3344
|
requestAnimationFrame(() => {
|
|
3345
|
+
// unlock validity check by reseting customErrorMessage
|
|
3346
|
+
this.customErrorMessage = { lock: false };
|
|
3210
3347
|
this.checkValidity();
|
|
3211
3348
|
this.errorMessage = undefined;
|
|
3212
3349
|
this.hasDisplayedError = false;
|
|
@@ -3220,11 +3357,13 @@ const MgInputPassword = class {
|
|
|
3220
3357
|
* @param newValue - valid new value
|
|
3221
3358
|
*/
|
|
3222
3359
|
setValidity(newValue) {
|
|
3223
|
-
const
|
|
3224
|
-
this.
|
|
3360
|
+
const oldValue = this.valid;
|
|
3361
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
3362
|
+
this.valid = newValue;
|
|
3363
|
+
}
|
|
3225
3364
|
this.invalid = !this.valid;
|
|
3226
3365
|
// We need to send valid event even if it is the same value
|
|
3227
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
3366
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
3228
3367
|
this.inputValid.emit(this.valid);
|
|
3229
3368
|
}
|
|
3230
3369
|
/*************
|
|
@@ -3252,7 +3391,7 @@ const MgInputPassword = class {
|
|
|
3252
3391
|
* @returns HTML Element
|
|
3253
3392
|
*/
|
|
3254
3393
|
render() {
|
|
3255
|
-
return (h("mg-input", { key: '
|
|
3394
|
+
return (h("mg-input", { key: '845c075a44c50043776b7577642254d772629eef', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.value !== undefined && h("b", { class: "mg-c-input__readonly-value" }, '•'.repeat(this.value.length))) : (h("span", { class: "mg-c-input__input-group" }, h("input", { type: this.displayPassword ? 'text' : 'password', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, maxlength: this.maxlength, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
3256
3395
|
if (el !== null)
|
|
3257
3396
|
this.input = el;
|
|
3258
3397
|
} }), h("mg-button", { label: this.messages.input.password[this.displayPassword ? 'hide' : 'display'], disabled: this.disabled, variant: "flat", class: "mg-c-input__append-button", "is-icon": true, onClick: this.toggleDisplayPassword, "aria-controls": this.identifier }, h("mg-icon", { class: "mg-c-input__input-icon", icon: this.displayPassword ? 'eye-slash' : 'eye' }))))));
|
|
@@ -3290,6 +3429,7 @@ const MgInputRadio = class {
|
|
|
3290
3429
|
this.classVerticalList = 'mg-c-input--vertical-list';
|
|
3291
3430
|
// hasDisplayedError (triggered by blur event)
|
|
3292
3431
|
this.hasDisplayedError = false;
|
|
3432
|
+
this.customErrorMessage = { lock: false };
|
|
3293
3433
|
/**
|
|
3294
3434
|
* Input name
|
|
3295
3435
|
* If not set the value equals the identifier
|
|
@@ -3353,16 +3493,18 @@ const MgInputRadio = class {
|
|
|
3353
3493
|
};
|
|
3354
3494
|
/**
|
|
3355
3495
|
* Set input error message
|
|
3356
|
-
* @param
|
|
3496
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
3357
3497
|
*/
|
|
3358
|
-
this.setErrorMessage = (
|
|
3498
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
3359
3499
|
const invalidElement = this.getInvalidElement();
|
|
3360
3500
|
// Set error message
|
|
3361
3501
|
this.errorMessage = undefined;
|
|
3362
3502
|
if (!this.valid) {
|
|
3363
|
-
|
|
3364
|
-
|
|
3503
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
3504
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
3505
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
3365
3506
|
}
|
|
3507
|
+
// required
|
|
3366
3508
|
else if (invalidElement.validity.valueMissing) {
|
|
3367
3509
|
this.errorMessage = this.messages.errors.required;
|
|
3368
3510
|
}
|
|
@@ -3467,17 +3609,22 @@ const MgInputRadio = class {
|
|
|
3467
3609
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
3468
3610
|
* @param valid - value indicating the validity
|
|
3469
3611
|
* @param errorMessage - the error message to display
|
|
3612
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
3470
3613
|
*/
|
|
3471
|
-
async setError(valid, errorMessage) {
|
|
3614
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
3472
3615
|
if (typeof valid !== 'boolean') {
|
|
3473
3616
|
throw new Error('<mg-input-radio> method "setError()" param "valid" must be a boolean.');
|
|
3474
3617
|
}
|
|
3475
|
-
else if (!isValidString(errorMessage)) {
|
|
3618
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
3476
3619
|
throw new Error('<mg-input-radio> method "setError()" param "errorMessage" must be a string.');
|
|
3477
3620
|
}
|
|
3478
3621
|
else {
|
|
3622
|
+
this.customErrorMessage = {
|
|
3623
|
+
lock: valid ? false : errorMessageLock,
|
|
3624
|
+
message: valid ? undefined : errorMessage,
|
|
3625
|
+
};
|
|
3479
3626
|
this.setValidity(valid);
|
|
3480
|
-
this.setErrorMessage(
|
|
3627
|
+
this.setErrorMessage(true);
|
|
3481
3628
|
this.hasDisplayedError = this.invalid;
|
|
3482
3629
|
}
|
|
3483
3630
|
}
|
|
@@ -3495,6 +3642,8 @@ const MgInputRadio = class {
|
|
|
3495
3642
|
// - Keep everything in sync both inside and outside the component
|
|
3496
3643
|
return new Promise(resolve => {
|
|
3497
3644
|
requestAnimationFrame(() => {
|
|
3645
|
+
// unlock validity check by reseting customErrorMessage
|
|
3646
|
+
this.customErrorMessage = { lock: false };
|
|
3498
3647
|
this.checkValidity();
|
|
3499
3648
|
this.errorMessage = undefined;
|
|
3500
3649
|
this.hasDisplayedError = false;
|
|
@@ -3508,11 +3657,13 @@ const MgInputRadio = class {
|
|
|
3508
3657
|
* @param newValue - valid new value
|
|
3509
3658
|
*/
|
|
3510
3659
|
setValidity(newValue) {
|
|
3511
|
-
const
|
|
3512
|
-
this.
|
|
3660
|
+
const oldValue = this.valid;
|
|
3661
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
3662
|
+
this.valid = newValue;
|
|
3663
|
+
}
|
|
3513
3664
|
this.invalid = !this.valid;
|
|
3514
3665
|
// We need to send valid event even if it is the same value
|
|
3515
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
3666
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
3516
3667
|
this.inputValid.emit(this.valid);
|
|
3517
3668
|
}
|
|
3518
3669
|
/*************
|
|
@@ -3543,7 +3694,7 @@ const MgInputRadio = class {
|
|
|
3543
3694
|
* @returns HTML Element
|
|
3544
3695
|
*/
|
|
3545
3696
|
render() {
|
|
3546
|
-
return (h("mg-input", { key: '
|
|
3697
|
+
return (h("mg-input", { key: '9290ab8e5048dd6806985ab55d13bd8b0dd93bd1', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && !this.value ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue)) : (h("ul", { class: "mg-c-input__input-group-container", role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: (el) => {
|
|
3547
3698
|
if (el !== null)
|
|
3548
3699
|
this.inputs[index] = el;
|
|
3549
3700
|
} }), h("label", { htmlFor: this.identifier + '_' + index }, input.title))))))));
|
|
@@ -3560,7 +3711,7 @@ const MgInputRadio = class {
|
|
|
3560
3711
|
};
|
|
3561
3712
|
MgInputRadio.style = mgInputRadioCss;
|
|
3562
3713
|
|
|
3563
|
-
const mgInputSelectCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__with-character-left>mg-icon:first-of-type,.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__with-character-left .mg-c-input__box,.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.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-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}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input__box{padding-top:0;padding-right:var(--mg-b-size-8);padding-bottom:0}@media screen and (max-width: 767px){.mg-c-input__box{width:100%}}";
|
|
3714
|
+
const mgInputSelectCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__with-character-left>mg-icon:first-of-type,.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__with-character-left .mg-c-input__box,.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.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-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}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input__box{max-width:100%;padding-top:0;padding-right:var(--mg-b-size-8);padding-bottom:0}@media screen and (max-width: 767px){.mg-c-input__box{width:100%}}";
|
|
3564
3715
|
|
|
3565
3716
|
/**
|
|
3566
3717
|
* Check if item is a well configured option
|
|
@@ -3611,6 +3762,7 @@ const MgInputSelect = class {
|
|
|
3611
3762
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
3612
3763
|
// hasDisplayedError (triggered by blur event)
|
|
3613
3764
|
this.hasDisplayedError = false;
|
|
3765
|
+
this.customErrorMessage = { lock: false };
|
|
3614
3766
|
/**
|
|
3615
3767
|
* Input name
|
|
3616
3768
|
* If not set the value equals the identifier
|
|
@@ -3719,15 +3871,17 @@ const MgInputSelect = class {
|
|
|
3719
3871
|
};
|
|
3720
3872
|
/**
|
|
3721
3873
|
* Set input error message
|
|
3722
|
-
* @param
|
|
3874
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
3723
3875
|
*/
|
|
3724
|
-
this.setErrorMessage = (
|
|
3876
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
3725
3877
|
// Set error message
|
|
3726
3878
|
this.errorMessage = undefined;
|
|
3727
3879
|
if (!this.valid) {
|
|
3728
|
-
|
|
3729
|
-
|
|
3880
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
3881
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
3882
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
3730
3883
|
}
|
|
3884
|
+
// required
|
|
3731
3885
|
else if (this.input.validity.valueMissing) {
|
|
3732
3886
|
this.errorMessage = this.messages.errors.required;
|
|
3733
3887
|
}
|
|
@@ -3841,17 +3995,22 @@ const MgInputSelect = class {
|
|
|
3841
3995
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
3842
3996
|
* @param valid - value indicating the validity
|
|
3843
3997
|
* @param errorMessage - the error message to display
|
|
3998
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
3844
3999
|
*/
|
|
3845
|
-
async setError(valid, errorMessage) {
|
|
4000
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
3846
4001
|
if (typeof valid !== 'boolean') {
|
|
3847
4002
|
throw new Error('<mg-input-select> method "setError()" param "valid" must be a boolean.');
|
|
3848
4003
|
}
|
|
3849
|
-
else if (!isValidString(errorMessage)) {
|
|
4004
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
3850
4005
|
throw new Error('<mg-input-select> method "setError()" param "errorMessage" must be a string.');
|
|
3851
4006
|
}
|
|
3852
4007
|
else {
|
|
4008
|
+
this.customErrorMessage = {
|
|
4009
|
+
lock: valid ? false : errorMessageLock,
|
|
4010
|
+
message: valid ? undefined : errorMessage,
|
|
4011
|
+
};
|
|
3853
4012
|
this.setValidity(valid);
|
|
3854
|
-
this.setErrorMessage(
|
|
4013
|
+
this.setErrorMessage(true);
|
|
3855
4014
|
this.hasDisplayedError = this.invalid;
|
|
3856
4015
|
}
|
|
3857
4016
|
}
|
|
@@ -3869,6 +4028,8 @@ const MgInputSelect = class {
|
|
|
3869
4028
|
// - Keep everything in sync both inside and outside the component
|
|
3870
4029
|
return new Promise(resolve => {
|
|
3871
4030
|
requestAnimationFrame(() => {
|
|
4031
|
+
// unlock validity check by reseting customErrorMessage
|
|
4032
|
+
this.customErrorMessage = { lock: false };
|
|
3872
4033
|
this.checkValidity();
|
|
3873
4034
|
this.errorMessage = undefined;
|
|
3874
4035
|
this.hasDisplayedError = false;
|
|
@@ -3882,11 +4043,13 @@ const MgInputSelect = class {
|
|
|
3882
4043
|
* @param newValue - valid new value
|
|
3883
4044
|
*/
|
|
3884
4045
|
setValidity(newValue) {
|
|
3885
|
-
const
|
|
3886
|
-
this.
|
|
4046
|
+
const oldValue = this.valid;
|
|
4047
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
4048
|
+
this.valid = newValue;
|
|
4049
|
+
}
|
|
3887
4050
|
this.invalid = !this.valid;
|
|
3888
4051
|
// We need to send valid event even if it is the same value
|
|
3889
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
4052
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue)) {
|
|
3890
4053
|
this.inputValid.emit(this.valid);
|
|
3891
4054
|
}
|
|
3892
4055
|
}
|
|
@@ -3923,7 +4086,7 @@ const MgInputSelect = class {
|
|
|
3923
4086
|
*/
|
|
3924
4087
|
render() {
|
|
3925
4088
|
const readonlyValue = this.getReadonlyValue();
|
|
3926
|
-
return (h("mg-input", { key: '
|
|
4089
|
+
return (h("mg-input", { key: '928c7d4ebccfe38ae86630d2cb8c06f07ca09a8a', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && readonlyValue === null ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (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) => {
|
|
3927
4090
|
if (el !== null)
|
|
3928
4091
|
this.input = el;
|
|
3929
4092
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -3979,6 +4142,7 @@ const MgInputText = class {
|
|
|
3979
4142
|
this.classIsAppendInputSlotContent = 'mg-c-input--is-append-input-slot-content';
|
|
3980
4143
|
// hasDisplayedError (triggered by blur event)
|
|
3981
4144
|
this.hasDisplayedError = false;
|
|
4145
|
+
this.customErrorMessage = { lock: false };
|
|
3982
4146
|
/**
|
|
3983
4147
|
* Input name
|
|
3984
4148
|
* If not set the value equals the identifier
|
|
@@ -4077,27 +4241,29 @@ const MgInputText = class {
|
|
|
4077
4241
|
};
|
|
4078
4242
|
/**
|
|
4079
4243
|
* Set input error message
|
|
4080
|
-
* @param
|
|
4244
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
4081
4245
|
*/
|
|
4082
|
-
this.setErrorMessage = (
|
|
4246
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
4083
4247
|
var _a;
|
|
4084
4248
|
// Set error message
|
|
4085
4249
|
this.errorMessage = undefined;
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
this.
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4250
|
+
if (!this.valid) {
|
|
4251
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
4252
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
4253
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
4254
|
+
}
|
|
4255
|
+
// Does not match type (email, emails, tel, url, etc.)
|
|
4256
|
+
else if (this.input.validity.typeMismatch) {
|
|
4257
|
+
this.errorMessage = this.messages.input.text.errors.typeMismatch[this.type];
|
|
4258
|
+
}
|
|
4259
|
+
// Does not match pattern
|
|
4260
|
+
else if (this.input.validity.patternMismatch) {
|
|
4261
|
+
this.errorMessage = (_a = this.patternErrorMessage) !== null && _a !== void 0 ? _a : this.messages.input.text.errors.typeMismatch[this.type];
|
|
4262
|
+
}
|
|
4263
|
+
// required
|
|
4264
|
+
else if (this.input.validity.valueMissing) {
|
|
4265
|
+
this.errorMessage = this.messages.errors.required;
|
|
4266
|
+
}
|
|
4101
4267
|
}
|
|
4102
4268
|
};
|
|
4103
4269
|
/**
|
|
@@ -4231,17 +4397,22 @@ const MgInputText = class {
|
|
|
4231
4397
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
4232
4398
|
* @param valid - value indicating the validity
|
|
4233
4399
|
* @param errorMessage - the error message to display
|
|
4400
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
4234
4401
|
*/
|
|
4235
|
-
async setError(valid, errorMessage) {
|
|
4402
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
4236
4403
|
if (typeof valid !== 'boolean') {
|
|
4237
4404
|
throw new Error('<mg-input-text> method "setError()" param "valid" must be a boolean.');
|
|
4238
4405
|
}
|
|
4239
|
-
else if (!isValidString(errorMessage)) {
|
|
4406
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
4240
4407
|
throw new Error('<mg-input-text> method "setError()" param "errorMessage" must be a string.');
|
|
4241
4408
|
}
|
|
4242
4409
|
else {
|
|
4410
|
+
this.customErrorMessage = {
|
|
4411
|
+
lock: valid ? false : errorMessageLock,
|
|
4412
|
+
message: valid ? undefined : errorMessage,
|
|
4413
|
+
};
|
|
4243
4414
|
this.setValidity(valid);
|
|
4244
|
-
this.setErrorMessage(
|
|
4415
|
+
this.setErrorMessage(true);
|
|
4245
4416
|
this.hasDisplayedError = this.invalid;
|
|
4246
4417
|
}
|
|
4247
4418
|
}
|
|
@@ -4259,6 +4430,8 @@ const MgInputText = class {
|
|
|
4259
4430
|
// - Keep everything in sync both inside and outside the component
|
|
4260
4431
|
return new Promise(resolve => {
|
|
4261
4432
|
requestAnimationFrame(() => {
|
|
4433
|
+
// unlock validity check by reseting customErrorMessage
|
|
4434
|
+
this.customErrorMessage = { lock: false };
|
|
4262
4435
|
this.checkValidity();
|
|
4263
4436
|
this.errorMessage = undefined;
|
|
4264
4437
|
this.hasDisplayedError = false;
|
|
@@ -4272,11 +4445,13 @@ const MgInputText = class {
|
|
|
4272
4445
|
* @param newValue - valid new value
|
|
4273
4446
|
*/
|
|
4274
4447
|
setValidity(newValue) {
|
|
4275
|
-
const
|
|
4276
|
-
this.
|
|
4448
|
+
const oldValue = this.valid;
|
|
4449
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
4450
|
+
this.valid = newValue;
|
|
4451
|
+
}
|
|
4277
4452
|
this.invalid = !this.valid;
|
|
4278
4453
|
// We need to send valid event even if it is the same value
|
|
4279
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
4454
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
4280
4455
|
this.inputValid.emit(this.valid);
|
|
4281
4456
|
}
|
|
4282
4457
|
/*************
|
|
@@ -4313,7 +4488,7 @@ const MgInputText = class {
|
|
|
4313
4488
|
* @returns HTML Element
|
|
4314
4489
|
*/
|
|
4315
4490
|
render() {
|
|
4316
|
-
return (h("mg-input", { key: '
|
|
4491
|
+
return (h("mg-input", { key: '69e40a90a6e4be8aa1eb3ac1b53acfe899c20453', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: this.characterLeftId, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly
|
|
4317
4492
|
? this.value && this.renderReadonly()
|
|
4318
4493
|
: [
|
|
4319
4494
|
h("div", { key: "input", class: "mg-c-input__with-character-left", style: {
|
|
@@ -4357,6 +4532,7 @@ const MgInputTextarea = class {
|
|
|
4357
4532
|
this.classDisplayCharacterLeft = 'mg-c-input--display-character-left';
|
|
4358
4533
|
// hasDisplayedError (triggered by blur event)
|
|
4359
4534
|
this.hasDisplayedError = false;
|
|
4535
|
+
this.customErrorMessage = { lock: false };
|
|
4360
4536
|
/**
|
|
4361
4537
|
* Input name
|
|
4362
4538
|
* If not set the value equals the identifier
|
|
@@ -4455,15 +4631,16 @@ const MgInputTextarea = class {
|
|
|
4455
4631
|
};
|
|
4456
4632
|
/**
|
|
4457
4633
|
* Set input error message
|
|
4458
|
-
* @param
|
|
4634
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
4459
4635
|
*/
|
|
4460
|
-
this.setErrorMessage = (
|
|
4636
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
4461
4637
|
// Set error message
|
|
4462
4638
|
this.errorMessage = undefined;
|
|
4463
|
-
// Does
|
|
4639
|
+
// Does have a new custom error message
|
|
4464
4640
|
if (!this.valid) {
|
|
4465
|
-
|
|
4466
|
-
|
|
4641
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
4642
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
4643
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
4467
4644
|
}
|
|
4468
4645
|
else if (!this.getPatternValidity()) {
|
|
4469
4646
|
this.errorMessage = this.patternErrorMessage;
|
|
@@ -4556,17 +4733,22 @@ const MgInputTextarea = class {
|
|
|
4556
4733
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
4557
4734
|
* @param valid - value indicating the validity
|
|
4558
4735
|
* @param errorMessage - the error message to display
|
|
4736
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
4559
4737
|
*/
|
|
4560
|
-
async setError(valid, errorMessage) {
|
|
4738
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
4561
4739
|
if (typeof valid !== 'boolean') {
|
|
4562
4740
|
throw new Error('<mg-input-textarea> method "setError()" param "valid" must be a boolean.');
|
|
4563
4741
|
}
|
|
4564
|
-
else if (!isValidString(errorMessage)) {
|
|
4742
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
4565
4743
|
throw new Error('<mg-input-textarea> method "setError()" param "errorMessage" must be a string.');
|
|
4566
4744
|
}
|
|
4567
4745
|
else {
|
|
4746
|
+
this.customErrorMessage = {
|
|
4747
|
+
lock: valid ? false : errorMessageLock,
|
|
4748
|
+
message: valid ? undefined : errorMessage,
|
|
4749
|
+
};
|
|
4568
4750
|
this.setValidity(valid);
|
|
4569
|
-
this.setErrorMessage(
|
|
4751
|
+
this.setErrorMessage(true);
|
|
4570
4752
|
this.hasDisplayedError = this.invalid;
|
|
4571
4753
|
}
|
|
4572
4754
|
}
|
|
@@ -4584,6 +4766,8 @@ const MgInputTextarea = class {
|
|
|
4584
4766
|
// - Keep everything in sync both inside and outside the component
|
|
4585
4767
|
return new Promise(resolve => {
|
|
4586
4768
|
requestAnimationFrame(() => {
|
|
4769
|
+
// unlock validity check by reseting customErrorMessage
|
|
4770
|
+
this.customErrorMessage = { lock: false };
|
|
4587
4771
|
this.checkValidity();
|
|
4588
4772
|
this.errorMessage = undefined;
|
|
4589
4773
|
this.hasDisplayedError = false;
|
|
@@ -4597,11 +4781,13 @@ const MgInputTextarea = class {
|
|
|
4597
4781
|
* @param newValue - valid new value
|
|
4598
4782
|
*/
|
|
4599
4783
|
setValidity(newValue) {
|
|
4600
|
-
const
|
|
4601
|
-
this.
|
|
4784
|
+
const oldValue = this.valid;
|
|
4785
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
4786
|
+
this.valid = newValue;
|
|
4787
|
+
}
|
|
4602
4788
|
this.invalid = !this.valid;
|
|
4603
4789
|
// We need to send valid event even if it is the same value
|
|
4604
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
4790
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
4605
4791
|
this.inputValid.emit(this.valid);
|
|
4606
4792
|
}
|
|
4607
4793
|
/*************
|
|
@@ -4634,7 +4820,7 @@ const MgInputTextarea = class {
|
|
|
4634
4820
|
* @returns HTML Element
|
|
4635
4821
|
*/
|
|
4636
4822
|
render() {
|
|
4637
|
-
return (h("mg-input", { key: '
|
|
4823
|
+
return (h("mg-input", { key: '9b58ccb9f0b150f5de8cc9f895f4cdea2bbbeecd', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: this.characterLeftId, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.value && h("b", { class: "mg-c-input__readonly-value" }, this.value)) : (h("div", { class: "mg-c-input__with-character-left" }, h("textarea", { class: {
|
|
4638
4824
|
'mg-c-input__box': true,
|
|
4639
4825
|
'mg-c-input__box--width': true,
|
|
4640
4826
|
'mg-c-input__box--resizable': this.resizable === 'both',
|
|
@@ -4710,7 +4896,7 @@ const MgInputTitle = class {
|
|
|
4710
4896
|
};
|
|
4711
4897
|
MgInputTitle.style = mgInputTitleCss;
|
|
4712
4898
|
|
|
4713
|
-
const mgInputToggleCss = ".mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.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}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input__toggle-item-container{overflow:hidden;box-sizing:border-box;padding:var(--mg-b-size-4) var(--mg-b-size-8);border:
|
|
4899
|
+
const mgInputToggleCss = ".mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.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}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input__toggle-item-container{overflow:hidden;box-sizing:border-box;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-width:var(--mg-b-size-border);border-radius:calc((var(--mg-b-font-size)*var(--mg-b-line-height) + 2*var(--mg-b-size-4))/var(--mg-c-input-toggle-border-radius-ratio));color:var(--mg-b-color-neutral-110);font-weight:unset;text-overflow:ellipsis;white-space:nowrap}.mg-c-input__toggle-item-container:first-of-type{border-style:solid;border-color:var(--mg-b-color-neutral-80);background-color:var(--mg-b-color-light);font-weight:600}.mg-c-input__button-toggle{display:flex;overflow:hidden;min-width:0;align-items:center;padding:.1rem;border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-b-color-neutral-80);border-radius:calc((var(--mg-b-font-size)*var(--mg-b-line-height) + 2*(var(--mg-b-size-4) + var(--mg-b-size-4) + var(--mg-c-input-border-width)))/var(--mg-c-input-toggle-border-radius-ratio));background-color:var(--mg-b-color-neutral-20);cursor:pointer;font-family:var(--mg-b-font-family);font-size:var(--mg-b-small-font-size);line-height:var(--mg-b-size-12)}.mg-c-input__button-toggle:disabled{cursor:default}.mg-c-input__button-toggle:focus{outline-offset:var(--mg-b-size-4)}.mg-c-input.mg-c-input--toggle:not(.mg-c-input--readonly) .mg-c-input__button-toggle{margin-top:var(--mg-b-size-4)}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__button-toggle{background-color:var(--mg-b-color-neutral-110)}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:first-of-type{border:unset;background-color:unset;color:var(--mg-b-color-light);font-weight:unset}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:last-of-type{border-style:solid;background-color:var(--mg-b-color-neutral-20);font-weight:600}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__button-toggle{width:100%;min-width:calc(var(--mg-b-size-20)*2);max-width:calc(var(--mg-b-size-20)*2)}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container{display:flex;overflow:unset;min-width:var(--mg-b-size-20);max-width:var(--mg-b-size-20);height:var(--mg-b-size-20);align-items:center;justify-content:center;padding:0;visibility:hidden}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:first-of-type{visibility:visible}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:last-of-type{width:unset}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container ::slotted(mg-icon){display:flex}.mg-c-input.mg-c-input--toggle-icon.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:first-of-type{min-width:unset;visibility:hidden}.mg-c-input.mg-c-input--toggle-icon.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:last-of-type{margin-left:auto;visibility:visible}.mg-c-input.mg-c-input--toggle-on-off.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:first-of-type ::slotted(*){display:none}";
|
|
4714
4900
|
|
|
4715
4901
|
/**
|
|
4716
4902
|
* type Option validation function
|
|
@@ -4741,7 +4927,9 @@ const MgInputToggle = class {
|
|
|
4741
4927
|
*/
|
|
4742
4928
|
this.labelHide = false;
|
|
4743
4929
|
/**
|
|
4744
|
-
* Define if toggle have on/off style
|
|
4930
|
+
* Define if toggle have on/off style,
|
|
4931
|
+
* the left icon is hidden.
|
|
4932
|
+
* Only available in combination with the "isIcon" prop.
|
|
4745
4933
|
*/
|
|
4746
4934
|
this.isOnOff = false;
|
|
4747
4935
|
/**
|
|
@@ -4776,7 +4964,7 @@ const MgInputToggle = class {
|
|
|
4776
4964
|
// Set error message
|
|
4777
4965
|
this.errorMessage = undefined;
|
|
4778
4966
|
// Does have a custom error message
|
|
4779
|
-
if (!this.valid && errorMessage
|
|
4967
|
+
if (!this.valid && typeof errorMessage === 'string') {
|
|
4780
4968
|
this.errorMessage = errorMessage;
|
|
4781
4969
|
}
|
|
4782
4970
|
};
|
|
@@ -4791,14 +4979,31 @@ const MgInputToggle = class {
|
|
|
4791
4979
|
*/
|
|
4792
4980
|
this.validateSlots = () => {
|
|
4793
4981
|
const slots = Array.from(this.element.children);
|
|
4982
|
+
// validate slots
|
|
4794
4983
|
if (slots.length !== 2) {
|
|
4795
|
-
|
|
4984
|
+
if (this.isOnOff && this.isIcon) {
|
|
4985
|
+
// ONLY slot="item-2" is required in with isOnOff && isIcon
|
|
4986
|
+
if (this.element.querySelector('[slot="item-2"]') === null) {
|
|
4987
|
+
throw new Error('<mg-input-toggle> an element with attribute slot="item-2" is required.');
|
|
4988
|
+
}
|
|
4989
|
+
}
|
|
4990
|
+
else {
|
|
4991
|
+
throw new Error('<mg-input-toggle> 2 slots are required.');
|
|
4992
|
+
}
|
|
4796
4993
|
}
|
|
4797
|
-
|
|
4994
|
+
// update slots
|
|
4995
|
+
if (!this.isIcon) {
|
|
4798
4996
|
// Due to text-overflow set to ellipsis
|
|
4799
4997
|
// we need to ensure that slot element have title to display value on mouse over
|
|
4800
4998
|
slots.forEach(slot => slot.setAttribute('title', slot.textContent));
|
|
4801
4999
|
}
|
|
5000
|
+
else {
|
|
5001
|
+
slots.forEach(slot => {
|
|
5002
|
+
if (slot.nodeName === 'MG-ICON') {
|
|
5003
|
+
slot.size = 'small';
|
|
5004
|
+
}
|
|
5005
|
+
});
|
|
5006
|
+
}
|
|
4802
5007
|
};
|
|
4803
5008
|
/**
|
|
4804
5009
|
* Get checked item
|
|
@@ -4839,10 +5044,16 @@ const MgInputToggle = class {
|
|
|
4839
5044
|
}
|
|
4840
5045
|
}
|
|
4841
5046
|
watchIsOnOff(newValue) {
|
|
4842
|
-
if (newValue)
|
|
5047
|
+
if (newValue) {
|
|
4843
5048
|
this.classCollection.add(this.classOnOff);
|
|
4844
|
-
|
|
5049
|
+
if (!this.isIcon) {
|
|
5050
|
+
this.isOnOff = false;
|
|
5051
|
+
console.warn('<mg-input-toggle> prop "isOnOff" must be used with "isIcon". Setting isOnOff to false.');
|
|
5052
|
+
}
|
|
5053
|
+
}
|
|
5054
|
+
else {
|
|
4845
5055
|
this.classCollection.delete(this.classOnOff);
|
|
5056
|
+
}
|
|
4846
5057
|
}
|
|
4847
5058
|
watchIsIcon(newValue) {
|
|
4848
5059
|
if (newValue)
|
|
@@ -4890,7 +5101,7 @@ const MgInputToggle = class {
|
|
|
4890
5101
|
if (typeof valid !== 'boolean') {
|
|
4891
5102
|
throw new Error('<mg-input-toggle> method "setError()" param "valid" must be a boolean.');
|
|
4892
5103
|
}
|
|
4893
|
-
else if (!isValidString(errorMessage)) {
|
|
5104
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
4894
5105
|
throw new Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string.');
|
|
4895
5106
|
}
|
|
4896
5107
|
else {
|
|
@@ -4967,7 +5178,7 @@ const MgInputToggle = class {
|
|
|
4967
5178
|
*/
|
|
4968
5179
|
render() {
|
|
4969
5180
|
const checkedItem = this.getCheckedItem(this.checked);
|
|
4970
|
-
return (h("mg-input", { key: '
|
|
5181
|
+
return (h("mg-input", { key: '4d87ed13bbd3d3a54303c21001247e1251417326', label: this.label, helpText: this.helpText, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, errorMessage: this.errorMessage }, this.readonly ? (checkedItem && h("b", { class: "mg-c-input__readonly-value" }, checkedItem.title)) : (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, ref: el => {
|
|
4971
5182
|
if (el !== null)
|
|
4972
5183
|
this.button = el;
|
|
4973
5184
|
} }, 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" }))))));
|
|
@@ -5257,6 +5468,10 @@ const MgMenu = class {
|
|
|
5257
5468
|
* @param event - mg-item-loaded "item-loaded" custom event
|
|
5258
5469
|
*/
|
|
5259
5470
|
updateItemListener(event) {
|
|
5471
|
+
// `<mg-action-more>` element doesn't need `data-has-focus` attribute
|
|
5472
|
+
if (event.target.nodeName === 'MG-ACTION-MORE') {
|
|
5473
|
+
return;
|
|
5474
|
+
}
|
|
5260
5475
|
const itemToWatch = event.target.nodeName === 'MG-ITEM-MORE' ? event.target.shadowRoot.querySelector('mg-menu-item') : event.target;
|
|
5261
5476
|
['click', 'focus'].forEach(trigger => {
|
|
5262
5477
|
itemToWatch.addEventListener(trigger, () => {
|
|
@@ -5317,7 +5532,7 @@ const MgMenu = class {
|
|
|
5317
5532
|
* @returns HTML Element
|
|
5318
5533
|
*/
|
|
5319
5534
|
render() {
|
|
5320
|
-
return (h(Host, { key: '
|
|
5535
|
+
return (h(Host, { key: '753833b01b86d6983f5d063f5598e2187b147a6e', role: "list", "aria-label": this.label }, h("slot", { key: '56702e49f5a97feddeb66e6271bd898061aa0d48' })));
|
|
5321
5536
|
}
|
|
5322
5537
|
get element() { return getElement(this); }
|
|
5323
5538
|
static get watchers() { return {
|
|
@@ -5798,9 +6013,9 @@ const MgMessage = class {
|
|
|
5798
6013
|
* @returns HTML Element
|
|
5799
6014
|
*/
|
|
5800
6015
|
render() {
|
|
5801
|
-
return (h("div", { key: '
|
|
6016
|
+
return (h("div", { key: 'f99bf527eb2c6005eeaec11f89aaa08f8865ea57', class: this.classCollection.join() }, h("mg-card", { key: 'beede3cd97b022d947c216b6bba454a104ba5790', shadow: true }, this.variantStyle === 'bar-left' && h("span", { key: '515828d725a996c9d57b39ad75e9373150a1b78a', class: "mg-c-message__bar" }), h("span", { key: '02ae41c66af25c2611b9b6cb8c87a1ad99346fa3', class: "mg-c-message__icon" }, h("mg-icon", { key: '3eadb40ed0dfa5ec51155608a67769c5fee3d402', icon: this.getIcon() })), h("div", { key: 'b832251e8f330d00b512bcd508ae9bf6e5f511cb', class: "mg-c-message__content" }, h("span", { key: 'c3520fc49bd5c3c187a83823050ceb9ca8c12d46', class: "mg-c-message__content-slot" }, h("slot", { key: 'f4064dff9536cbb76e45c5c4c1a89621da9531b2' })), this.hasActions && [
|
|
5802
6017
|
h("span", { class: "mg-c-message__content-separator", key: "content-separator" }),
|
|
5803
|
-
h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, h("slot", { key: '
|
|
6018
|
+
h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, h("slot", { key: '5585f7c14c2c3896cfdb5319414cd82f4d4b3a8b', name: "actions" })),
|
|
5804
6019
|
]))));
|
|
5805
6020
|
}
|
|
5806
6021
|
get element() { return getElement(this); }
|
|
@@ -5922,11 +6137,11 @@ const MgModal = class {
|
|
|
5922
6137
|
* @returns HTML Element
|
|
5923
6138
|
*/
|
|
5924
6139
|
render() {
|
|
5925
|
-
return (h("dialog", { key: '
|
|
6140
|
+
return (h("dialog", { key: '2d99322fd3c80b8cbfea70589cf579e0c1c6f06b', role: this.dialogRole, id: this.identifier, class: this.classCollection.join(), "aria-labelledby": this.titleId, ref: (el) => {
|
|
5926
6141
|
if (el !== null) {
|
|
5927
6142
|
this.dialog = el;
|
|
5928
6143
|
}
|
|
5929
|
-
} }, h("mg-card", { key: '
|
|
6144
|
+
} }, h("mg-card", { key: '32692a6d41ef30b3d3e61ddcfea47350d374ed09', shadow: true }, h("div", { key: 'c87bb43bb069671b65a9759ee293e77975707597', class: "mg-c-modal__dialog" }, h("header", { key: '1272a946878efcf8c69f3b09852ba6938cbe31b0', class: "mg-c-modal__header" }, this.closeButton && (h("span", { key: '0704656c7c5ac4c8d405f2cd673e91f72763ee8f', class: "mg-c-modal__close-button" }, h("mg-button", { key: '4402971c763ee34145de5bd69d367fde68f9d1a2', "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, h("mg-icon", { key: '9e16add6a3e387971507a252671c895b6c94a586', icon: "cross" })))), h("h1", { key: '3e4fc2b4419398528565d382b728b8b752758ddd', class: "mg-c-modal__title", id: this.titleId }, this.modalTitle)), h("article", { key: '170ff6bd9592687baa4c561615f540ad1c7400e4', class: "mg-c-modal__content" }, h("slot", { key: 'cb710e2a57e4c997deac367169b56047af1200b1' })), this.hasActions && (h("footer", { key: '1e08d67caeaaaf75eb97faa11528719ea537c24c', class: "mg-c-modal__footer" }, h("slot", { key: '461ec8e4117477aef08dc6d346ad0bf6007ec12d', name: "actions" })))))));
|
|
5930
6145
|
}
|
|
5931
6146
|
get element() { return getElement(this); }
|
|
5932
6147
|
static get watchers() { return {
|
|
@@ -6147,6 +6362,13 @@ const MgPanel = class {
|
|
|
6147
6362
|
/************
|
|
6148
6363
|
* Methods *
|
|
6149
6364
|
************/
|
|
6365
|
+
/**
|
|
6366
|
+
* Check if panel-title slot is used
|
|
6367
|
+
* @returns true if slot is used
|
|
6368
|
+
*/
|
|
6369
|
+
this.hasPanelTitleSlot = () => {
|
|
6370
|
+
return this.element.querySelector('[slot="panel-title"]') !== null;
|
|
6371
|
+
};
|
|
6150
6372
|
/**
|
|
6151
6373
|
* Toggle is editing state
|
|
6152
6374
|
*/
|
|
@@ -6200,7 +6422,7 @@ const MgPanel = class {
|
|
|
6200
6422
|
* Render collapse button
|
|
6201
6423
|
* @returns collpase button
|
|
6202
6424
|
*/
|
|
6203
|
-
this.renderCollapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", "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)));
|
|
6425
|
+
this.renderCollapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", "aria-expanded": this.expanded.toString(), "aria-controls": `${this.identifier}-content`, disabled: this.expandToggleDisabled, isIcon: this.expandToggleDisplay === 'icon', label: this.expandToggleDisplay === 'icon' ? this.panelTitle : undefined }, 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.hasPanelTitleSlot() ? h("slot", { name: "panel-title" }) : this.panelTitle))));
|
|
6204
6426
|
/**
|
|
6205
6427
|
* Render edit button
|
|
6206
6428
|
* @returns edit Button
|
|
@@ -6217,7 +6439,8 @@ const MgPanel = class {
|
|
|
6217
6439
|
*/
|
|
6218
6440
|
this.renderTitle = () => {
|
|
6219
6441
|
const elementsToRender = [this.renderCollapseButton()];
|
|
6220
|
-
if
|
|
6442
|
+
// Add edit functionality only if not using slot and title is editable
|
|
6443
|
+
if (this.titleEditable && !this.hasPanelTitleSlot()) {
|
|
6221
6444
|
if (!this.isEditing)
|
|
6222
6445
|
elementsToRender.push(this.renderEditButton());
|
|
6223
6446
|
else
|
|
@@ -6243,14 +6466,24 @@ const MgPanel = class {
|
|
|
6243
6466
|
}
|
|
6244
6467
|
}
|
|
6245
6468
|
validatePanelTitle(newValue) {
|
|
6246
|
-
if (
|
|
6247
|
-
|
|
6248
|
-
|
|
6469
|
+
if (newValue !== undefined) {
|
|
6470
|
+
if (!isValidString(newValue)) {
|
|
6471
|
+
throw new Error(`<mg-panel> prop "panelTitle" must be a string. Passed value: ${toString(newValue)}.`);
|
|
6472
|
+
}
|
|
6473
|
+
else {
|
|
6474
|
+
this.titleChange.emit(newValue);
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6249
6477
|
}
|
|
6250
6478
|
validateTitlePattern(newValue) {
|
|
6251
6479
|
if (newValue !== undefined && !this.titleEditable)
|
|
6252
6480
|
throw new Error(`<mg-panel> prop "titleEditable" must be set to "true".`);
|
|
6253
6481
|
}
|
|
6482
|
+
validateTitleEditable(newValue) {
|
|
6483
|
+
if (newValue && this.hasPanelTitleSlot()) {
|
|
6484
|
+
throw new Error(`<mg-panel> prop "titleEditable" cannot be used with panel-title slot.`);
|
|
6485
|
+
}
|
|
6486
|
+
}
|
|
6254
6487
|
validateTitlePosition(newValue) {
|
|
6255
6488
|
if (!titlePositions.includes(newValue))
|
|
6256
6489
|
throw new Error(`<mg-panel> prop "titlePosition" must be one of: ${titlePositions.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
@@ -6263,6 +6496,9 @@ const MgPanel = class {
|
|
|
6263
6496
|
throw new Error(`<mg-panel> prop "expandToggleDisplay" must be one of: ${expandToggleDisplays.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
6264
6497
|
if (newValue === 'icon' && this.titleEditable)
|
|
6265
6498
|
this.titleEditable = false;
|
|
6499
|
+
if (newValue === 'icon' && this.hasPanelTitleSlot()) {
|
|
6500
|
+
throw new Error(`<mg-panel> prop "expandToggleDisplay" cannot be "icon" when panel-title slot is used.`);
|
|
6501
|
+
}
|
|
6266
6502
|
}
|
|
6267
6503
|
/*************
|
|
6268
6504
|
* Lifecycle *
|
|
@@ -6277,9 +6513,15 @@ const MgPanel = class {
|
|
|
6277
6513
|
this.watchIdentifier(this.identifier);
|
|
6278
6514
|
this.validateTitlePattern(this.titlePattern);
|
|
6279
6515
|
this.validateTitlePattern(this.titlePatternErrorMessage);
|
|
6280
|
-
|
|
6516
|
+
// Only validate panelTitle if slot is not used
|
|
6517
|
+
if (!this.hasPanelTitleSlot()) {
|
|
6518
|
+
if (!isValidString(this.panelTitle))
|
|
6519
|
+
throw new Error(`<mg-panel> prop "panelTitle" is required when panel-title slot is not used.`);
|
|
6520
|
+
this.validatePanelTitle(this.panelTitle);
|
|
6521
|
+
}
|
|
6281
6522
|
this.validateExpandToggleDisplay(this.expandToggleDisplay);
|
|
6282
6523
|
this.validateTitlePosition(this.titlePosition);
|
|
6524
|
+
this.validateTitleEditable(this.titleEditable);
|
|
6283
6525
|
}
|
|
6284
6526
|
/**
|
|
6285
6527
|
* Edit DOM after render
|
|
@@ -6295,7 +6537,7 @@ const MgPanel = class {
|
|
|
6295
6537
|
*/
|
|
6296
6538
|
render() {
|
|
6297
6539
|
const headerId = `${this.identifier}-header`;
|
|
6298
|
-
return (h("section", { key: '
|
|
6540
|
+
return (h("section", { key: '3662204d763051c34ea13de4b7b3f7abc7914b81', class: this.classCollection.join(), id: this.identifier }, h("mg-card", { key: '46f113258172b1d040f65a4d312554b0c0551489', shadow: this.shadow }, h("header", { key: '1d7e7a48a5c4f89d141a5a7e46b220d4f9c082a5', class: { 'mg-c-panel__header': true, 'mg-c-panel__header--reverse': this.titlePosition === 'right' }, id: headerId }, this.renderHeaderChildren()), h("article", { key: 'ab0aec831cc79d982b7556d6e245c80ae2979083', class: "mg-c-panel__content", id: `${this.identifier}-content`, "aria-labelledby": headerId, hidden: !this.expanded }, h("slot", { key: 'e831573fe9d5ff783073d123b7e2a54baad73bfc' })))));
|
|
6299
6541
|
}
|
|
6300
6542
|
get element() { return getElement(this); }
|
|
6301
6543
|
static get watchers() { return {
|
|
@@ -6303,6 +6545,7 @@ const MgPanel = class {
|
|
|
6303
6545
|
"panelTitle": ["validatePanelTitle"],
|
|
6304
6546
|
"titlePattern": ["validateTitlePattern"],
|
|
6305
6547
|
"titlePatternErrorMessage": ["validateTitlePattern"],
|
|
6548
|
+
"titleEditable": ["validateTitleEditable"],
|
|
6306
6549
|
"titlePosition": ["validateTitlePosition"],
|
|
6307
6550
|
"expanded": ["handleExpanded"],
|
|
6308
6551
|
"expandToggleDisplay": ["validateExpandToggleDisplay"]
|
|
@@ -8340,7 +8583,7 @@ const MgPopover = class {
|
|
|
8340
8583
|
* @returns HTML Element
|
|
8341
8584
|
*/
|
|
8342
8585
|
render() {
|
|
8343
|
-
return (h(Host, { key: '
|
|
8586
|
+
return (h(Host, { key: '2c1506b8e2da100519aeeae75fc5c378a81c473c' }, h("slot", { key: 'f9aea885e8cbc168614c05761829f0a0740eba9e' }), h("slot", { key: 'fa6106a660a73b3761d4783f8d46d401c47b4eb6', name: "content" })));
|
|
8344
8587
|
}
|
|
8345
8588
|
get element() { return getElement(this); }
|
|
8346
8589
|
static get watchers() { return {
|
|
@@ -8398,7 +8641,7 @@ const MgPopoverContent = class {
|
|
|
8398
8641
|
* @returns HTML Element
|
|
8399
8642
|
*/
|
|
8400
8643
|
render() {
|
|
8401
|
-
return (h(Host, { key: '
|
|
8644
|
+
return (h(Host, { key: '054fc82954b39a488f7fe5cb391d89b5fa4a61fe' }, h("mg-card", { key: 'bb89bada37069b50295bd93d988667c3b85eada3', class: this.classCollection.join(), shadow: true }, this.closeButton && (h("mg-button", { key: 'a59d6610574b964be1e2ce34ccd8e31c1395b6ff', "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, h("mg-icon", { key: '5bcc9e4eb21396f4fc66a6f1e4d6c5cdf68ec1f4', icon: "cross" }))), h("div", { key: '57be2022f3b61220e1249faeaf2acee9960027fe', class: "mg-c-popover-content__title" }, h("slot", { key: 'c7870e86a9f105cf6b9d4520c77874bce9235d72', name: "title" })), h("slot", { key: '5af8462232625d9c7d694bab46351d5e646f62ca', name: "content" })), h("slot", { key: '599863410dd7d751e82c440cd6c4fb7f2c48d9f3', name: "arrow" })));
|
|
8402
8645
|
}
|
|
8403
8646
|
get element() { return getElement(this); }
|
|
8404
8647
|
};
|
|
@@ -8443,7 +8686,7 @@ const MgSkipLinks = class {
|
|
|
8443
8686
|
* @returns HTML Element
|
|
8444
8687
|
*/
|
|
8445
8688
|
render() {
|
|
8446
|
-
return (h("nav", { key: '
|
|
8689
|
+
return (h("nav", { key: '5bf4427662bdca6512969bee91aa03f43a126743', class: "mg-c-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, h("ul", { key: '1d2b2a56b3960f70a3d37b333c77bf686643e0fd', class: "mg-c-skip-links__list", role: "list" }, this.links.map(link => (h("li", { key: link.href }, h("a", { class: "mg-c-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
|
|
8447
8690
|
}
|
|
8448
8691
|
get element() { return getElement(this); }
|
|
8449
8692
|
static get watchers() { return {
|
|
@@ -8963,7 +9206,7 @@ const MgTabs = class {
|
|
|
8963
9206
|
* @returns HTML Element
|
|
8964
9207
|
*/
|
|
8965
9208
|
render() {
|
|
8966
|
-
return (h("div", { key: '
|
|
9209
|
+
return (h("div", { key: 'ae71d21c9ce3acb07b3adf67bbe25f205d382abc', class: this.classCollection.join() }, h("header", { key: 'cf6cdae863602c956aa450a34e91a6d8b950d8f5', role: "tablist", "aria-label": this.label, class: "mg-c-tabs__header" }, this.tabs.map((tab, index) => (h("button", { key: tab.label, role: "tab", id: this.getElementId(this.identifier, index), class: {
|
|
8967
9210
|
[`${this.buttonTabBaseClass}`]: true,
|
|
8968
9211
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
8969
9212
|
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|