@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
|
@@ -4,7 +4,7 @@ var index = require('./index-DCZEYvlH.js');
|
|
|
4
4
|
var index$1 = require('./index-CpENFzEo.js');
|
|
5
5
|
var index$2 = require('./index-TUElr4Wv.js');
|
|
6
6
|
var events_utils = require('./events.utils-D5SAtkpQ.js');
|
|
7
|
-
var mgInput_conf = require('./mg-input.conf-
|
|
7
|
+
var mgInput_conf = require('./mg-input.conf-HYIzRsy7.js');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Available menu item status values
|
|
@@ -173,7 +173,7 @@ const MgActionMore = class {
|
|
|
173
173
|
[`${this.classBase}__chevron--rotate`]: this.expanded === true,
|
|
174
174
|
} }, index.h("mg-icon", { icon: "chevron-down" })));
|
|
175
175
|
}
|
|
176
|
-
return (index.h(index.Host, { key: '
|
|
176
|
+
return (index.h(index.Host, { key: 'd75e1a5326ea3a1414f8048858e5ee3fee51760e', "data-mg-popover-guard": this.mgPopoverIdentifier }, index.h("span", { key: 'b671a6c35cb3a9fa6eb7b2329f0f595e78b573b5', class: this.classBase }, index.h("mg-popover", { key: '38a38123d34ca868d0587123c2ab6b11550da8f0', identifier: this.mgPopoverIdentifier, display: this.expanded, "onDisplay-change": this.handleDisplayChange }, index.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 && index.h("mg-icon", Object.assign({ key: 'a47ca6b078ca160d1cbb13c964df3abede5f373c' }, this.icon)), !this.button.isIcon && buttonContent), index.h("div", { key: 'ac38c705625cb5716a7e8aabd25d596db3d5adef', slot: "content" }, index.h("mg-menu", { key: 'cd382a65f69ba3c303a74d6b7444fcf0ccf9d1c5', direction: directions$1.VERTICAL, label: this.messages.label }, this.items.map(item => {
|
|
177
177
|
var _a, _b;
|
|
178
178
|
return isMgActionMoreDivider(item) ? (index.h("mg-divider", { class: "mg-c-action-more__divider", key: "divider", "full-width": true })) : (index.h("mg-menu-item", { key: item.label, status: item.status || Status$1.VISIBLE, target: item.target, href: item.href,
|
|
179
179
|
// eslint-disable-next-line react/jsx-no-bind
|
|
@@ -659,7 +659,7 @@ const MgDetails = class {
|
|
|
659
659
|
* @returns HTML Element
|
|
660
660
|
*/
|
|
661
661
|
render() {
|
|
662
|
-
return (index.h("details", { key: '
|
|
662
|
+
return (index.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) }, index.h("summary", { key: '2ed8228b63403dd9b386bf3fa70c9094516b6f0e' }, index.h("slot", { key: '5461d77d2b2869b14737a5c7cfc40a1f9584ee03', name: "summary" }), index.h("span", { key: 'bb089365bdeaa7b934b97cff6f5f7c67587048e1', class: "mg-c-details__toggle" }, index.h("mg-icon", { key: 'dc1a30338703ad4182d50f9953a903ae0f68ecb1', icon: "chevron-up", class: { 'mg-c-details__toggle-icon': true, 'mg-c-details__toggle-icon--reverse': !this.expanded } }), index.h("span", { key: 'a32cbaf9e38b71540deeaa8980895c34a7288ecb', class: { 'mg-u-visually-hidden': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), index.h("div", { key: 'b9c2bc7d681da8ac8b4dec5ff25287bc68975fb6', class: "mg-c-details__details" }, index.h("slot", { key: '069f05b4c133ff13055681e0b05bb98744303137', name: "details" }))));
|
|
663
663
|
}
|
|
664
664
|
get element() { return index.getElement(this); }
|
|
665
665
|
static get watchers() { return {
|
|
@@ -856,11 +856,12 @@ const MgForm = class {
|
|
|
856
856
|
this.setRequiredMessage();
|
|
857
857
|
}
|
|
858
858
|
/**
|
|
859
|
-
* Display
|
|
859
|
+
* Display inputs/fieldsets errors if it exists.
|
|
860
860
|
*/
|
|
861
861
|
async displayError() {
|
|
862
862
|
if (!this.readonly) {
|
|
863
|
-
this.
|
|
863
|
+
const mgFieldsets = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-FIELDSET'));
|
|
864
|
+
[...mgFieldsets, ...this.mgInputs].forEach(input => {
|
|
864
865
|
var _a;
|
|
865
866
|
(_a = input.displayError) === null || _a === void 0 ? void 0 : _a.call(input);
|
|
866
867
|
});
|
|
@@ -936,7 +937,7 @@ const MgForm = class {
|
|
|
936
937
|
* @returns HTML Element
|
|
937
938
|
*/
|
|
938
939
|
render() {
|
|
939
|
-
return (index.h("form", { key: '
|
|
940
|
+
return (index.h("form", { key: '8b698b2a33af00e36691abab5adff5488b736218', class: this.classCollection.join(), id: this.identifier, name: this.name, onSubmit: this.handleFormSubmit, role: this.ariaRole }, this.requiredMessageText && index.h("p", { key: '2e1fb5c4030ecb99d1f18c57d5c3fe238db4d12e', innerHTML: this.requiredMessageText }), index.h("slot", { key: '568fb8ac9ab0e3521899c05472592ebd15cc91fa' }), !this.readonly && !this.disabled && index.h("slot", { key: 'd4f38320de58f3b1d491083a34d1b5366d22b935', name: "actions" })));
|
|
940
941
|
}
|
|
941
942
|
get element() { return index.getElement(this); }
|
|
942
943
|
static get watchers() { return {
|
|
@@ -1190,7 +1191,7 @@ const MgIllustratedMessage = class {
|
|
|
1190
1191
|
* @returns HTML Element
|
|
1191
1192
|
*/
|
|
1192
1193
|
render() {
|
|
1193
|
-
return (index.h("div", { key: '
|
|
1194
|
+
return (index.h("div", { key: 'c9d8c8bfd2792b1cf5e78ab9d168d597b20e9a1e', class: this.classCollection.join() }, index.h("div", { key: 'cc8fa03147b9e59e6e8e015be9ed2b8dddd92ded', class: "mg-c-illustrated-message__illustration" }, index.h("slot", { key: '83a4ec2223c4e74511beb7c0abfa10e77cee425d', name: "illustration" })), index.h("div", { key: 'dbb4d13ca5324cab889fa2acc9b9b22522d7a8ec', class: "mg-c-illustrated-message__slots" }, index.h("slot", { key: '9e74d84becf29539ec9c37e8ad1e317714f3c86c', name: "title" }), index.h("slot", { key: 'ae97d25c19b76ca092560d2555ebd6a87f542ffe', name: "details" }))));
|
|
1194
1195
|
}
|
|
1195
1196
|
get element() { return index.getElement(this); }
|
|
1196
1197
|
static get watchers() { return {
|
|
@@ -1200,7 +1201,7 @@ const MgIllustratedMessage = class {
|
|
|
1200
1201
|
};
|
|
1201
1202
|
MgIllustratedMessage.style = mgIllustratedMessageCss;
|
|
1202
1203
|
|
|
1203
|
-
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}}";
|
|
1204
|
+
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}}";
|
|
1204
1205
|
|
|
1205
1206
|
const MgInput = class {
|
|
1206
1207
|
constructor(hostRef) {
|
|
@@ -1212,6 +1213,9 @@ const MgInput = class {
|
|
|
1212
1213
|
this.classInput = 'mg-c-input';
|
|
1213
1214
|
this.classHasError = 'mg-c-input--has-error';
|
|
1214
1215
|
this.classLabelOnTop = 'mg-c-input--label-on-top';
|
|
1216
|
+
this.classHasHeading = 'mg-c-input--has-heading';
|
|
1217
|
+
this.classLabelBorderDisplay = 'mg-c-input--label-border-display';
|
|
1218
|
+
this.classInputsOnBottom = 'mg-c-input--inputs-on-bottom';
|
|
1215
1219
|
/**
|
|
1216
1220
|
* Define if label is displayed on top
|
|
1217
1221
|
*/
|
|
@@ -1220,6 +1224,11 @@ const MgInput = class {
|
|
|
1220
1224
|
* Define if label is visible
|
|
1221
1225
|
*/
|
|
1222
1226
|
this.labelHide = false;
|
|
1227
|
+
/**
|
|
1228
|
+
* Define if label border is visible
|
|
1229
|
+
* You must pair this mode with `labelOnTop`and `fieldset` class
|
|
1230
|
+
*/
|
|
1231
|
+
this.labelBorderDisplay = false;
|
|
1223
1232
|
/**
|
|
1224
1233
|
* Define tooltip position
|
|
1225
1234
|
*/
|
|
@@ -1228,6 +1237,10 @@ const MgInput = class {
|
|
|
1228
1237
|
* Define if input is required
|
|
1229
1238
|
*/
|
|
1230
1239
|
this.required = false;
|
|
1240
|
+
/**
|
|
1241
|
+
* Display inputs after help-text and error message
|
|
1242
|
+
*/
|
|
1243
|
+
this.inputsOnBottom = false;
|
|
1231
1244
|
/**
|
|
1232
1245
|
* Define aria-describedby ids to link with
|
|
1233
1246
|
*/
|
|
@@ -1248,11 +1261,44 @@ const MgInput = class {
|
|
|
1248
1261
|
* Element is disabled
|
|
1249
1262
|
*/
|
|
1250
1263
|
this.isVerticalList = false;
|
|
1264
|
+
/************
|
|
1265
|
+
* Methods *
|
|
1266
|
+
************/
|
|
1267
|
+
/**
|
|
1268
|
+
* Update element aria-describedby
|
|
1269
|
+
* @param element - element to update
|
|
1270
|
+
* @param ariaDescribedbyIDs - ariaDescribedbyIDs references
|
|
1271
|
+
*/
|
|
1272
|
+
this.updateElementAriaDescribedby = (element, ariaDescribedbyIDs) => {
|
|
1273
|
+
if (ariaDescribedbyIDs.size > 0) {
|
|
1274
|
+
element.setAttribute('aria-describedby', Array.from(ariaDescribedbyIDs).join(' '));
|
|
1275
|
+
}
|
|
1276
|
+
else {
|
|
1277
|
+
element.removeAttribute('aria-describedby');
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1251
1280
|
/**
|
|
1252
1281
|
* Get tooltip node
|
|
1253
1282
|
* @returns mg-tooltip
|
|
1254
1283
|
*/
|
|
1255
1284
|
this.renderTooltip = () => (index.h("mg-tooltip", { identifier: `${this.identifier}-tooltip`, message: this.tooltip }, index.h("mg-icon", { icon: "info-circle" })));
|
|
1285
|
+
/**
|
|
1286
|
+
* Get input container element
|
|
1287
|
+
* @returns ordered elements
|
|
1288
|
+
*/
|
|
1289
|
+
this.inputContainerElements = () => {
|
|
1290
|
+
const elements = [
|
|
1291
|
+
this.helptextMessageSlotElement && (index.h("div", { class: "mg-c-input__help-text" }, index.h("slot", { name: this.slotHelpText }))),
|
|
1292
|
+
!this.isDisabled && this.errorMessage && (index.h("div", { class: "mg-c-input__error", "aria-live": "assertive" }, index.h("slot", { name: this.slotError }))),
|
|
1293
|
+
];
|
|
1294
|
+
const inputSlot = (index.h("div", { class: "mg-c-input__input" }, index.h("slot", null), this.tooltip && !this.labelOnTop && (this.tooltipPosition === 'input' || this.labelHide) && this.renderTooltip()));
|
|
1295
|
+
if (this.inputsOnBottom) {
|
|
1296
|
+
return [...elements, inputSlot];
|
|
1297
|
+
}
|
|
1298
|
+
else {
|
|
1299
|
+
return [inputSlot, ...elements];
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1256
1302
|
}
|
|
1257
1303
|
watchIdentifier(newValue) {
|
|
1258
1304
|
if (!index$1.isValidString(newValue)) {
|
|
@@ -1279,6 +1325,26 @@ const MgInput = class {
|
|
|
1279
1325
|
throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide".');
|
|
1280
1326
|
}
|
|
1281
1327
|
}
|
|
1328
|
+
watchlabelHeading(newValue) {
|
|
1329
|
+
if (this.isFieldset && this.labelOnTop && mgInput_conf.labelHeadings.includes(newValue)) {
|
|
1330
|
+
this.element.classList.add(this.classHasHeading);
|
|
1331
|
+
}
|
|
1332
|
+
else {
|
|
1333
|
+
if ((!this.isFieldset && newValue !== undefined) || typeof newValue === 'string') {
|
|
1334
|
+
throw new Error(`<mg-input> prop "labelHeading" must be used with a fieldset and be one of: ${mgInput_conf.labelHeadings.join(', ')}. Passed value: ${index$1.toString(newValue)}.`);
|
|
1335
|
+
}
|
|
1336
|
+
this.labelHeading = undefined;
|
|
1337
|
+
this.element.classList.remove(this.classHasHeading);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
watchLabelBorderDisplay(newValue) {
|
|
1341
|
+
if (this.isFieldset && this.labelOnTop && newValue) {
|
|
1342
|
+
this.element.classList.add(this.classLabelBorderDisplay);
|
|
1343
|
+
}
|
|
1344
|
+
else {
|
|
1345
|
+
this.element.classList.remove(this.classLabelBorderDisplay);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1282
1348
|
watchTooltipPosition(newValue) {
|
|
1283
1349
|
if (!mgInput_conf.tooltipPositions.includes(newValue)) {
|
|
1284
1350
|
throw new Error(`<mg-input> prop "tooltipPosition" must be one of: ${mgInput_conf.tooltipPositions.join(', ')}. Passed value: ${index$1.toString(newValue)}.`);
|
|
@@ -1298,7 +1364,7 @@ const MgInput = class {
|
|
|
1298
1364
|
}
|
|
1299
1365
|
watchHelpText(newValue) {
|
|
1300
1366
|
var _a;
|
|
1301
|
-
if (newValue && !this.isReadonly) {
|
|
1367
|
+
if (index$1.isValidString(newValue) && !this.isReadonly) {
|
|
1302
1368
|
this.renderHelpText();
|
|
1303
1369
|
}
|
|
1304
1370
|
else {
|
|
@@ -1306,6 +1372,14 @@ const MgInput = class {
|
|
|
1306
1372
|
this.helptextMessageSlotElement = undefined;
|
|
1307
1373
|
}
|
|
1308
1374
|
}
|
|
1375
|
+
watchInputsOnBottom(newValue) {
|
|
1376
|
+
if (newValue) {
|
|
1377
|
+
this.element.classList.add(this.classInputsOnBottom);
|
|
1378
|
+
}
|
|
1379
|
+
else {
|
|
1380
|
+
this.element.classList.remove(this.classInputsOnBottom);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1309
1383
|
watchAriaDescribedbyIDs() {
|
|
1310
1384
|
if (this.isReadonly) {
|
|
1311
1385
|
return;
|
|
@@ -1321,23 +1395,26 @@ const MgInput = class {
|
|
|
1321
1395
|
// a11y IDs
|
|
1322
1396
|
const ariaDescribedbyIDs = new Set(this.ariaDescribedbyIDs);
|
|
1323
1397
|
// Help text
|
|
1324
|
-
if (this.helpText
|
|
1398
|
+
if (index$1.isValidString(this.helpText)) {
|
|
1325
1399
|
this.renderHelpText();
|
|
1326
1400
|
if (!ariaDescribedbyIDs.has(this.helpTextId))
|
|
1327
1401
|
ariaDescribedbyIDs.add(this.helpTextId);
|
|
1328
1402
|
}
|
|
1329
1403
|
// Error Message
|
|
1330
|
-
if (this.errorMessage
|
|
1404
|
+
if (index$1.isValidString(this.errorMessage)) {
|
|
1331
1405
|
this.renderErrorMessage();
|
|
1332
1406
|
if (!ariaDescribedbyIDs.has(this.helpTextErrorId))
|
|
1333
1407
|
ariaDescribedbyIDs.add(this.helpTextErrorId);
|
|
1334
1408
|
}
|
|
1335
|
-
this.element.querySelectorAll('input,select,textarea,[role="switch"]')
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1409
|
+
const inputs = this.element.querySelectorAll('input,select,textarea,[role="switch"]');
|
|
1410
|
+
inputs.forEach((element) => {
|
|
1411
|
+
this.updateElementAriaDescribedby(element, ariaDescribedbyIDs);
|
|
1412
|
+
});
|
|
1413
|
+
// use timeout to await for legend render for componentWillLoad hook
|
|
1414
|
+
setTimeout(() => {
|
|
1415
|
+
const legend = this.element.querySelector('legend');
|
|
1416
|
+
if (legend !== null) {
|
|
1417
|
+
this.updateElementAriaDescribedby(legend, ariaDescribedbyIDs);
|
|
1341
1418
|
}
|
|
1342
1419
|
});
|
|
1343
1420
|
}
|
|
@@ -1367,9 +1444,6 @@ const MgInput = class {
|
|
|
1367
1444
|
this.renderLabel();
|
|
1368
1445
|
}
|
|
1369
1446
|
}
|
|
1370
|
-
/************
|
|
1371
|
-
* Methods *
|
|
1372
|
-
************/
|
|
1373
1447
|
/**
|
|
1374
1448
|
* Render input label
|
|
1375
1449
|
*/
|
|
@@ -1389,11 +1463,21 @@ const MgInput = class {
|
|
|
1389
1463
|
labelSlotElement.setAttribute(attr, val);
|
|
1390
1464
|
});
|
|
1391
1465
|
// create label element
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1466
|
+
if (mgInput_conf.labelHeadings.includes(this.labelHeading)) {
|
|
1467
|
+
let label = this.element.shadowRoot.querySelector(this.labelHeading);
|
|
1468
|
+
if (label === null) {
|
|
1469
|
+
label = document.createElement(this.labelHeading);
|
|
1470
|
+
label.classList.add('mg-c-input-title__text');
|
|
1471
|
+
labelSlotElement.appendChild(label);
|
|
1472
|
+
}
|
|
1473
|
+
label.textContent = this.label;
|
|
1474
|
+
}
|
|
1475
|
+
else {
|
|
1476
|
+
labelSlotElement.textContent = this.label;
|
|
1477
|
+
}
|
|
1396
1478
|
this.element.appendChild(labelSlotElement);
|
|
1479
|
+
// update aria-describedby
|
|
1480
|
+
this.watchAriaDescribedbyIDs();
|
|
1397
1481
|
}
|
|
1398
1482
|
/**
|
|
1399
1483
|
* Render error message
|
|
@@ -1436,6 +1520,9 @@ const MgInput = class {
|
|
|
1436
1520
|
this.watchTooltipPosition(this.tooltipPosition);
|
|
1437
1521
|
this.watchHelpText(this.helpText);
|
|
1438
1522
|
this.watchErrorMessage(this.errorMessage);
|
|
1523
|
+
this.watchInputsOnBottom(this.inputsOnBottom);
|
|
1524
|
+
this.watchlabelHeading(this.labelHeading);
|
|
1525
|
+
this.watchLabelBorderDisplay(this.labelBorderDisplay);
|
|
1439
1526
|
}
|
|
1440
1527
|
/**
|
|
1441
1528
|
* Validate slots
|
|
@@ -1452,16 +1539,19 @@ const MgInput = class {
|
|
|
1452
1539
|
*/
|
|
1453
1540
|
render() {
|
|
1454
1541
|
const isGroup = this.isFieldset && !this.isReadonly;
|
|
1455
|
-
return (index.h(index.Host, { key: '
|
|
1542
|
+
return (index.h(index.Host, { key: 'fbab18280a709407c83f324127e8de6cbb05fe7c', class: this.element.classList.toString(), role: isGroup ? 'group' : undefined, "aria-labelledby": isGroup ? `${this.identifier}-title` : undefined }, index.h("div", { key: 'ac0924c244b9fa87d02e659a5710ee93d12a202f', class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': this.labelHide } }, index.h("slot", { key: 'c825af33ba0a6c209d02d6487422347f7d8acfed', name: this.slotLabel }), this.tooltip && (this.tooltipPosition === 'label' || this.labelOnTop) && !this.labelHide && this.renderTooltip()), index.h("div", { key: '805e1eedfdea132f3ea4fd11da761810a3d7c939', class: "mg-c-input__input-container" }, this.inputContainerElements())));
|
|
1456
1543
|
}
|
|
1457
1544
|
get element() { return index.getElement(this); }
|
|
1458
1545
|
static get watchers() { return {
|
|
1459
1546
|
"identifier": ["watchIdentifier", "watchAriaDescribedbyIDs"],
|
|
1460
1547
|
"labelOnTop": ["watchLabelOnTop", "watchLabelConfig"],
|
|
1461
1548
|
"labelHide": ["watchLabelConfig"],
|
|
1549
|
+
"labelHeading": ["watchlabelHeading"],
|
|
1550
|
+
"labelBorderDisplay": ["watchLabelBorderDisplay"],
|
|
1462
1551
|
"tooltipPosition": ["watchTooltipPosition"],
|
|
1463
1552
|
"errorMessage": ["watchErrorMessage", "watchAriaDescribedbyIDs"],
|
|
1464
1553
|
"helpText": ["watchHelpText", "watchAriaDescribedbyIDs"],
|
|
1554
|
+
"inputsOnBottom": ["watchInputsOnBottom"],
|
|
1465
1555
|
"ariaDescribedbyIDs": ["watchAriaDescribedbyIDs"],
|
|
1466
1556
|
"class": ["watchClass", "watchLabel"],
|
|
1467
1557
|
"label": ["watchLabel"],
|
|
@@ -1524,6 +1614,7 @@ const MgInputCheckbox = class {
|
|
|
1524
1614
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
1525
1615
|
// hasDisplayedError (triggered by blur event)
|
|
1526
1616
|
this.hasDisplayedError = false;
|
|
1617
|
+
this.customErrorMessage = { lock: false };
|
|
1527
1618
|
this.mode = 'custom';
|
|
1528
1619
|
// style
|
|
1529
1620
|
this.baseClassName = 'mg-c-input--checkbox';
|
|
@@ -1741,17 +1832,20 @@ const MgInputCheckbox = class {
|
|
|
1741
1832
|
};
|
|
1742
1833
|
/**
|
|
1743
1834
|
* Set input error message
|
|
1744
|
-
* @param
|
|
1745
|
-
* @param errorMessage - errorMessage override
|
|
1835
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
1746
1836
|
*/
|
|
1747
|
-
this.setErrorMessage = (
|
|
1837
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
1748
1838
|
// Set error message
|
|
1749
1839
|
this.errorMessage = undefined;
|
|
1750
|
-
if (
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1840
|
+
if (!this.valid) {
|
|
1841
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
1842
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
1843
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
1844
|
+
}
|
|
1845
|
+
// required
|
|
1846
|
+
else if (!this.validateRequired()) {
|
|
1754
1847
|
this.errorMessage = this.messages.errors.required;
|
|
1848
|
+
}
|
|
1755
1849
|
}
|
|
1756
1850
|
};
|
|
1757
1851
|
/**
|
|
@@ -1845,7 +1939,7 @@ const MgInputCheckbox = class {
|
|
|
1845
1939
|
this.checkValidity();
|
|
1846
1940
|
if (this.hasDisplayedError) {
|
|
1847
1941
|
this.hasDisplayedError = prop !== 'required';
|
|
1848
|
-
this.setErrorMessage(
|
|
1942
|
+
this.setErrorMessage();
|
|
1849
1943
|
}
|
|
1850
1944
|
this.setButtonTextKey();
|
|
1851
1945
|
}
|
|
@@ -1909,17 +2003,22 @@ const MgInputCheckbox = class {
|
|
|
1909
2003
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
1910
2004
|
* @param valid - value indicating the validity
|
|
1911
2005
|
* @param errorMessage - the error message to display
|
|
2006
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
1912
2007
|
*/
|
|
1913
|
-
async setError(valid, errorMessage) {
|
|
2008
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
1914
2009
|
if (typeof valid !== 'boolean') {
|
|
1915
2010
|
throw new Error('<mg-input-checkbox> method "setError()" param "valid" must be a boolean.');
|
|
1916
2011
|
}
|
|
1917
|
-
else if (!index$1.isValidString(errorMessage)) {
|
|
2012
|
+
else if (errorMessage !== undefined && !index$1.isValidString(errorMessage)) {
|
|
1918
2013
|
throw new Error('<mg-input-checkbox> method "setError()" param "errorMessage" must be a string.');
|
|
1919
2014
|
}
|
|
1920
2015
|
else {
|
|
2016
|
+
this.customErrorMessage = {
|
|
2017
|
+
lock: valid ? false : errorMessageLock,
|
|
2018
|
+
message: valid ? undefined : errorMessage,
|
|
2019
|
+
};
|
|
1921
2020
|
this.setValidity(valid);
|
|
1922
|
-
this.setErrorMessage(
|
|
2021
|
+
this.setErrorMessage(true);
|
|
1923
2022
|
this.hasDisplayedError = this.invalid;
|
|
1924
2023
|
}
|
|
1925
2024
|
}
|
|
@@ -1937,6 +2036,8 @@ const MgInputCheckbox = class {
|
|
|
1937
2036
|
// - Keep everything in sync both inside and outside the component
|
|
1938
2037
|
return new Promise(resolve => {
|
|
1939
2038
|
requestAnimationFrame(() => {
|
|
2039
|
+
// unlock validity check by reseting customErrorMessage
|
|
2040
|
+
this.customErrorMessage = { lock: false };
|
|
1940
2041
|
this.checkValidity();
|
|
1941
2042
|
this.errorMessage = undefined;
|
|
1942
2043
|
this.hasDisplayedError = false;
|
|
@@ -1950,11 +2051,13 @@ const MgInputCheckbox = class {
|
|
|
1950
2051
|
* @param newValue - valid new value
|
|
1951
2052
|
*/
|
|
1952
2053
|
setValidity(newValue) {
|
|
1953
|
-
const
|
|
1954
|
-
this.
|
|
2054
|
+
const oldValue = this.valid;
|
|
2055
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
2056
|
+
this.valid = newValue;
|
|
2057
|
+
}
|
|
1955
2058
|
this.invalid = !this.valid;
|
|
1956
2059
|
// We need to send valid event even if it is the same value
|
|
1957
|
-
if (this.valid !==
|
|
2060
|
+
if (this.valid !== oldValue)
|
|
1958
2061
|
this.inputValid.emit(this.valid);
|
|
1959
2062
|
}
|
|
1960
2063
|
/**
|
|
@@ -2073,7 +2176,7 @@ const MgInputCheckbox = class {
|
|
|
2073
2176
|
else {
|
|
2074
2177
|
inputContent = this.renderCheckboxMulti();
|
|
2075
2178
|
}
|
|
2076
|
-
return (index.h("mg-input", { key: '
|
|
2179
|
+
return (index.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));
|
|
2077
2180
|
}
|
|
2078
2181
|
get element() { return index.getElement(this); }
|
|
2079
2182
|
static get watchers() { return {
|
|
@@ -2163,7 +2266,7 @@ const MgInputCheckboxPaginated = class {
|
|
|
2163
2266
|
render() {
|
|
2164
2267
|
const listId = index$1.formatID(this.messages.label);
|
|
2165
2268
|
const tabId = 'tab-info';
|
|
2166
|
-
return (index.h(index.Host, { key: '
|
|
2269
|
+
return (index.h(index.Host, { key: '233ab4fca3f4a3121bc60650ac2f8ae06d47e6e5' }, index.h("slot", { key: '7d1af8c712928c06953743fc5c182e51d9a6256b', name: "header-action" }), index.h("div", { key: '95641bd218e36422a6b5b4ead8dd5498e8ac5fa4', class: "mg-c-input__tabs-content" }, index.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 && (index.h(MgInputCheckboxList, { key: '621077f291a401737157ad0cd9b9348537ef8bdc', checkboxes: this.items, labelledby: tabId, id: listId, disabled: this.disabled, name: this.name, invalid: this.invalid })), this.hasNext() && (index.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 }, index.h("mg-icon", { key: 'cb00bbeb1575475b184cc9623db6c4cefc56c26a', icon: "chevron-down" }), this.messages.showMore)))));
|
|
2167
2270
|
}
|
|
2168
2271
|
static get watchers() { return {
|
|
2169
2272
|
"checkboxes": ["watchCheckboxes"],
|
|
@@ -2182,6 +2285,7 @@ const MgInputDate = class {
|
|
|
2182
2285
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
2183
2286
|
// hasDisplayedError (triggered by blur event)
|
|
2184
2287
|
this.hasDisplayedError = false;
|
|
2288
|
+
this.customErrorMessage = { lock: false };
|
|
2185
2289
|
/**
|
|
2186
2290
|
* Input name
|
|
2187
2291
|
* If not set the value equals the identifier
|
|
@@ -2294,39 +2398,41 @@ const MgInputDate = class {
|
|
|
2294
2398
|
*/
|
|
2295
2399
|
this.getInputError = () => {
|
|
2296
2400
|
var _a;
|
|
2401
|
+
let error;
|
|
2297
2402
|
// bad input or pattern
|
|
2298
2403
|
if (this.input.validity.badInput || (this.value && !this.isValidPattern(this.value))) {
|
|
2299
|
-
|
|
2404
|
+
error = 'badInput';
|
|
2300
2405
|
}
|
|
2301
2406
|
// required
|
|
2302
|
-
if (this.input.validity.valueMissing) {
|
|
2303
|
-
|
|
2407
|
+
else if (this.input.validity.valueMissing) {
|
|
2408
|
+
error = 'required';
|
|
2304
2409
|
}
|
|
2305
2410
|
// min & max
|
|
2306
|
-
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) {
|
|
2307
|
-
|
|
2411
|
+
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) {
|
|
2412
|
+
error = 'minMax';
|
|
2308
2413
|
}
|
|
2309
2414
|
// min
|
|
2310
|
-
if (this.input.validity.rangeUnderflow) {
|
|
2311
|
-
|
|
2415
|
+
else if (this.input.validity.rangeUnderflow) {
|
|
2416
|
+
error = 'min';
|
|
2312
2417
|
}
|
|
2313
2418
|
// max
|
|
2314
|
-
if (this.input.validity.rangeOverflow) {
|
|
2315
|
-
|
|
2419
|
+
else if (this.input.validity.rangeOverflow) {
|
|
2420
|
+
error = 'max';
|
|
2316
2421
|
}
|
|
2317
|
-
return
|
|
2422
|
+
return error;
|
|
2318
2423
|
};
|
|
2319
2424
|
/**
|
|
2320
2425
|
* Check input errors
|
|
2321
|
-
* @param
|
|
2426
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
2322
2427
|
*/
|
|
2323
|
-
this.setErrorMessage = (
|
|
2428
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
2324
2429
|
// Set error message
|
|
2325
2430
|
this.errorMessage = undefined;
|
|
2326
2431
|
if (!this.valid) {
|
|
2327
2432
|
const inputError = this.getInputError();
|
|
2328
|
-
|
|
2329
|
-
|
|
2433
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
2434
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
2435
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
2330
2436
|
}
|
|
2331
2437
|
// required
|
|
2332
2438
|
else if (inputError === 'required') {
|
|
@@ -2438,17 +2544,22 @@ const MgInputDate = class {
|
|
|
2438
2544
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
2439
2545
|
* @param valid - value indicating the validity
|
|
2440
2546
|
* @param errorMessage - the error message to display
|
|
2547
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
2441
2548
|
*/
|
|
2442
|
-
async setError(valid, errorMessage) {
|
|
2549
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
2443
2550
|
if (typeof valid !== 'boolean') {
|
|
2444
2551
|
throw new Error('<mg-input-date> method "setError()" param "valid" must be a boolean.');
|
|
2445
2552
|
}
|
|
2446
|
-
else if (!index$1.isValidString(errorMessage)) {
|
|
2553
|
+
else if (errorMessage !== undefined && !index$1.isValidString(errorMessage)) {
|
|
2447
2554
|
throw new Error('<mg-input-date> method "setError()" param "errorMessage" must be a string.');
|
|
2448
2555
|
}
|
|
2449
2556
|
else {
|
|
2557
|
+
this.customErrorMessage = {
|
|
2558
|
+
lock: valid ? false : errorMessageLock,
|
|
2559
|
+
message: valid ? undefined : errorMessage,
|
|
2560
|
+
};
|
|
2450
2561
|
this.setValidity(valid);
|
|
2451
|
-
this.setErrorMessage(
|
|
2562
|
+
this.setErrorMessage(true);
|
|
2452
2563
|
this.hasDisplayedError = this.invalid;
|
|
2453
2564
|
}
|
|
2454
2565
|
}
|
|
@@ -2466,6 +2577,8 @@ const MgInputDate = class {
|
|
|
2466
2577
|
// - Keep everything in sync both inside and outside the component
|
|
2467
2578
|
return new Promise(resolve => {
|
|
2468
2579
|
requestAnimationFrame(() => {
|
|
2580
|
+
// unlock validity check by reseting customErrorMessage
|
|
2581
|
+
this.customErrorMessage = { lock: false };
|
|
2469
2582
|
this.checkValidity();
|
|
2470
2583
|
this.errorMessage = undefined;
|
|
2471
2584
|
this.hasDisplayedError = false;
|
|
@@ -2479,11 +2592,13 @@ const MgInputDate = class {
|
|
|
2479
2592
|
* @param newValue - valid new value
|
|
2480
2593
|
*/
|
|
2481
2594
|
setValidity(newValue) {
|
|
2482
|
-
const
|
|
2483
|
-
this.
|
|
2595
|
+
const oldValue = this.valid;
|
|
2596
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
2597
|
+
this.valid = newValue;
|
|
2598
|
+
}
|
|
2484
2599
|
this.invalid = !this.valid;
|
|
2485
2600
|
// We need to send valid event even if it is the same value
|
|
2486
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
2601
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
2487
2602
|
this.inputValid.emit(this.valid);
|
|
2488
2603
|
}
|
|
2489
2604
|
/*************
|
|
@@ -2519,7 +2634,7 @@ const MgInputDate = class {
|
|
|
2519
2634
|
* @returns HTML Element
|
|
2520
2635
|
*/
|
|
2521
2636
|
render() {
|
|
2522
|
-
return (index.h("mg-input", { key: '
|
|
2637
|
+
return (index.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 && index.h("b", { class: "mg-c-input__readonly-value" }, index$2.localeDate(this.value, this.locale))) : (index.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) => {
|
|
2523
2638
|
if (el !== null)
|
|
2524
2639
|
this.input = el;
|
|
2525
2640
|
} }))));
|
|
@@ -2551,6 +2666,7 @@ const MgInputNumeric = class {
|
|
|
2551
2666
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
2552
2667
|
// hasDisplayedError (triggered by blur event)
|
|
2553
2668
|
this.hasDisplayedError = false;
|
|
2669
|
+
this.customErrorMessage = { lock: false };
|
|
2554
2670
|
/**
|
|
2555
2671
|
* Input name
|
|
2556
2672
|
* If not set the value equals the identifier
|
|
@@ -2656,19 +2772,22 @@ const MgInputNumeric = class {
|
|
|
2656
2772
|
this.formatErrorValue = (value) => index$2.localeNumber(value, this.locale, !Number.isInteger(value) && this.type === 'decimal' ? this.decimalLength : 0);
|
|
2657
2773
|
/**
|
|
2658
2774
|
* Set input error message
|
|
2659
|
-
* @param
|
|
2775
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
2660
2776
|
*/
|
|
2661
|
-
this.setErrorMessage = (
|
|
2777
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
2662
2778
|
// Set error message
|
|
2663
2779
|
this.errorMessage = undefined;
|
|
2664
2780
|
if (!this.valid) {
|
|
2665
2781
|
const inputError = this.getInputError();
|
|
2666
|
-
|
|
2667
|
-
|
|
2782
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
2783
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
2784
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
2668
2785
|
}
|
|
2786
|
+
// required
|
|
2669
2787
|
else if (inputError === 'required') {
|
|
2670
2788
|
this.errorMessage = this.messages.errors[inputError];
|
|
2671
2789
|
}
|
|
2790
|
+
// min/max
|
|
2672
2791
|
else {
|
|
2673
2792
|
const formattedMin = this.formatErrorValue(this.min);
|
|
2674
2793
|
const formattedMax = this.formatErrorValue(this.max);
|
|
@@ -2870,17 +2989,22 @@ const MgInputNumeric = class {
|
|
|
2870
2989
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
2871
2990
|
* @param valid - value indicating the validity
|
|
2872
2991
|
* @param errorMessage - the error message to display
|
|
2992
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
2873
2993
|
*/
|
|
2874
|
-
async setError(valid, errorMessage) {
|
|
2994
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
2875
2995
|
if (typeof valid !== 'boolean') {
|
|
2876
2996
|
throw new Error('<mg-input-numeric> method "setError()" param "valid" must be a boolean.');
|
|
2877
2997
|
}
|
|
2878
|
-
else if (!index$1.isValidString(errorMessage)) {
|
|
2998
|
+
else if (errorMessage !== undefined && !index$1.isValidString(errorMessage)) {
|
|
2879
2999
|
throw new Error('<mg-input-numeric> method "setError()" param "errorMessage" must be a string.');
|
|
2880
3000
|
}
|
|
2881
3001
|
else {
|
|
3002
|
+
this.customErrorMessage = {
|
|
3003
|
+
lock: valid ? false : errorMessageLock,
|
|
3004
|
+
message: valid ? undefined : errorMessage,
|
|
3005
|
+
};
|
|
2882
3006
|
this.setValidity(valid);
|
|
2883
|
-
this.setErrorMessage(
|
|
3007
|
+
this.setErrorMessage(true);
|
|
2884
3008
|
this.hasDisplayedError = this.invalid;
|
|
2885
3009
|
}
|
|
2886
3010
|
}
|
|
@@ -2898,6 +3022,8 @@ const MgInputNumeric = class {
|
|
|
2898
3022
|
// - Keep everything in sync both inside and outside the component
|
|
2899
3023
|
return new Promise(resolve => {
|
|
2900
3024
|
requestAnimationFrame(() => {
|
|
3025
|
+
// unlock validity check by reseting customErrorMessage
|
|
3026
|
+
this.customErrorMessage = { lock: false };
|
|
2901
3027
|
this.checkValidity();
|
|
2902
3028
|
this.errorMessage = undefined;
|
|
2903
3029
|
this.hasDisplayedError = false;
|
|
@@ -2911,11 +3037,13 @@ const MgInputNumeric = class {
|
|
|
2911
3037
|
* @param newValue - valid new value
|
|
2912
3038
|
*/
|
|
2913
3039
|
setValidity(newValue) {
|
|
2914
|
-
const
|
|
2915
|
-
this.
|
|
3040
|
+
const oldValue = this.valid;
|
|
3041
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
3042
|
+
this.valid = newValue;
|
|
3043
|
+
}
|
|
2916
3044
|
this.invalid = !this.valid;
|
|
2917
3045
|
// We need to send valid event even if it is the same value
|
|
2918
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
3046
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
2919
3047
|
this.inputValid.emit(this.valid);
|
|
2920
3048
|
}
|
|
2921
3049
|
/**
|
|
@@ -2987,7 +3115,7 @@ const MgInputNumeric = class {
|
|
|
2987
3115
|
* @returns HTML Element
|
|
2988
3116
|
*/
|
|
2989
3117
|
render() {
|
|
2990
|
-
return (index.h("mg-input", { key: '
|
|
3118
|
+
return (index.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
|
|
2991
3119
|
? this.readonlyValue && this.renderReadonly()
|
|
2992
3120
|
: [
|
|
2993
3121
|
index.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) => {
|
|
@@ -3023,6 +3151,7 @@ const MgInputPassword = class {
|
|
|
3023
3151
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
3024
3152
|
// hasDisplayedError (triggered by blur event)
|
|
3025
3153
|
this.hasDisplayedError = false;
|
|
3154
|
+
this.customErrorMessage = { lock: false };
|
|
3026
3155
|
/**
|
|
3027
3156
|
* Input name
|
|
3028
3157
|
* If not set the value equals the identifier
|
|
@@ -3098,14 +3227,15 @@ const MgInputPassword = class {
|
|
|
3098
3227
|
};
|
|
3099
3228
|
/**
|
|
3100
3229
|
* Set input error message
|
|
3101
|
-
* @param
|
|
3230
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
3102
3231
|
*/
|
|
3103
|
-
this.setErrorMessage = (
|
|
3232
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
3104
3233
|
// Set error message
|
|
3105
3234
|
this.errorMessage = undefined;
|
|
3106
3235
|
if (!this.valid) {
|
|
3107
|
-
|
|
3108
|
-
|
|
3236
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
3237
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
3238
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
3109
3239
|
}
|
|
3110
3240
|
// required
|
|
3111
3241
|
else if (this.input.validity.valueMissing) {
|
|
@@ -3181,17 +3311,22 @@ const MgInputPassword = class {
|
|
|
3181
3311
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
3182
3312
|
* @param valid - value indicating the validity
|
|
3183
3313
|
* @param errorMessage - the error message to display
|
|
3314
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
3184
3315
|
*/
|
|
3185
|
-
async setError(valid, errorMessage) {
|
|
3316
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
3186
3317
|
if (typeof valid !== 'boolean') {
|
|
3187
3318
|
throw new Error('<mg-input-password> method "setError()" param "valid" must be a boolean.');
|
|
3188
3319
|
}
|
|
3189
|
-
else if (!index$1.isValidString(errorMessage)) {
|
|
3320
|
+
else if (errorMessage !== undefined && !index$1.isValidString(errorMessage)) {
|
|
3190
3321
|
throw new Error('<mg-input-password> method "setError()" param "errorMessage" must be a string.');
|
|
3191
3322
|
}
|
|
3192
3323
|
else {
|
|
3324
|
+
this.customErrorMessage = {
|
|
3325
|
+
lock: valid ? false : errorMessageLock,
|
|
3326
|
+
message: valid ? undefined : errorMessage,
|
|
3327
|
+
};
|
|
3193
3328
|
this.setValidity(valid);
|
|
3194
|
-
this.setErrorMessage(
|
|
3329
|
+
this.setErrorMessage(true);
|
|
3195
3330
|
this.hasDisplayedError = this.invalid;
|
|
3196
3331
|
}
|
|
3197
3332
|
}
|
|
@@ -3209,6 +3344,8 @@ const MgInputPassword = class {
|
|
|
3209
3344
|
// - Keep everything in sync both inside and outside the component
|
|
3210
3345
|
return new Promise(resolve => {
|
|
3211
3346
|
requestAnimationFrame(() => {
|
|
3347
|
+
// unlock validity check by reseting customErrorMessage
|
|
3348
|
+
this.customErrorMessage = { lock: false };
|
|
3212
3349
|
this.checkValidity();
|
|
3213
3350
|
this.errorMessage = undefined;
|
|
3214
3351
|
this.hasDisplayedError = false;
|
|
@@ -3222,11 +3359,13 @@ const MgInputPassword = class {
|
|
|
3222
3359
|
* @param newValue - valid new value
|
|
3223
3360
|
*/
|
|
3224
3361
|
setValidity(newValue) {
|
|
3225
|
-
const
|
|
3226
|
-
this.
|
|
3362
|
+
const oldValue = this.valid;
|
|
3363
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
3364
|
+
this.valid = newValue;
|
|
3365
|
+
}
|
|
3227
3366
|
this.invalid = !this.valid;
|
|
3228
3367
|
// We need to send valid event even if it is the same value
|
|
3229
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
3368
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
3230
3369
|
this.inputValid.emit(this.valid);
|
|
3231
3370
|
}
|
|
3232
3371
|
/*************
|
|
@@ -3254,7 +3393,7 @@ const MgInputPassword = class {
|
|
|
3254
3393
|
* @returns HTML Element
|
|
3255
3394
|
*/
|
|
3256
3395
|
render() {
|
|
3257
|
-
return (index.h("mg-input", { key: '
|
|
3396
|
+
return (index.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 && index.h("b", { class: "mg-c-input__readonly-value" }, '•'.repeat(this.value.length))) : (index.h("span", { class: "mg-c-input__input-group" }, index.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) => {
|
|
3258
3397
|
if (el !== null)
|
|
3259
3398
|
this.input = el;
|
|
3260
3399
|
} }), index.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 }, index.h("mg-icon", { class: "mg-c-input__input-icon", icon: this.displayPassword ? 'eye-slash' : 'eye' }))))));
|
|
@@ -3292,6 +3431,7 @@ const MgInputRadio = class {
|
|
|
3292
3431
|
this.classVerticalList = 'mg-c-input--vertical-list';
|
|
3293
3432
|
// hasDisplayedError (triggered by blur event)
|
|
3294
3433
|
this.hasDisplayedError = false;
|
|
3434
|
+
this.customErrorMessage = { lock: false };
|
|
3295
3435
|
/**
|
|
3296
3436
|
* Input name
|
|
3297
3437
|
* If not set the value equals the identifier
|
|
@@ -3355,16 +3495,18 @@ const MgInputRadio = class {
|
|
|
3355
3495
|
};
|
|
3356
3496
|
/**
|
|
3357
3497
|
* Set input error message
|
|
3358
|
-
* @param
|
|
3498
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
3359
3499
|
*/
|
|
3360
|
-
this.setErrorMessage = (
|
|
3500
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
3361
3501
|
const invalidElement = this.getInvalidElement();
|
|
3362
3502
|
// Set error message
|
|
3363
3503
|
this.errorMessage = undefined;
|
|
3364
3504
|
if (!this.valid) {
|
|
3365
|
-
|
|
3366
|
-
|
|
3505
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
3506
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
3507
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
3367
3508
|
}
|
|
3509
|
+
// required
|
|
3368
3510
|
else if (invalidElement.validity.valueMissing) {
|
|
3369
3511
|
this.errorMessage = this.messages.errors.required;
|
|
3370
3512
|
}
|
|
@@ -3469,17 +3611,22 @@ const MgInputRadio = class {
|
|
|
3469
3611
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
3470
3612
|
* @param valid - value indicating the validity
|
|
3471
3613
|
* @param errorMessage - the error message to display
|
|
3614
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
3472
3615
|
*/
|
|
3473
|
-
async setError(valid, errorMessage) {
|
|
3616
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
3474
3617
|
if (typeof valid !== 'boolean') {
|
|
3475
3618
|
throw new Error('<mg-input-radio> method "setError()" param "valid" must be a boolean.');
|
|
3476
3619
|
}
|
|
3477
|
-
else if (!index$1.isValidString(errorMessage)) {
|
|
3620
|
+
else if (errorMessage !== undefined && !index$1.isValidString(errorMessage)) {
|
|
3478
3621
|
throw new Error('<mg-input-radio> method "setError()" param "errorMessage" must be a string.');
|
|
3479
3622
|
}
|
|
3480
3623
|
else {
|
|
3624
|
+
this.customErrorMessage = {
|
|
3625
|
+
lock: valid ? false : errorMessageLock,
|
|
3626
|
+
message: valid ? undefined : errorMessage,
|
|
3627
|
+
};
|
|
3481
3628
|
this.setValidity(valid);
|
|
3482
|
-
this.setErrorMessage(
|
|
3629
|
+
this.setErrorMessage(true);
|
|
3483
3630
|
this.hasDisplayedError = this.invalid;
|
|
3484
3631
|
}
|
|
3485
3632
|
}
|
|
@@ -3497,6 +3644,8 @@ const MgInputRadio = class {
|
|
|
3497
3644
|
// - Keep everything in sync both inside and outside the component
|
|
3498
3645
|
return new Promise(resolve => {
|
|
3499
3646
|
requestAnimationFrame(() => {
|
|
3647
|
+
// unlock validity check by reseting customErrorMessage
|
|
3648
|
+
this.customErrorMessage = { lock: false };
|
|
3500
3649
|
this.checkValidity();
|
|
3501
3650
|
this.errorMessage = undefined;
|
|
3502
3651
|
this.hasDisplayedError = false;
|
|
@@ -3510,11 +3659,13 @@ const MgInputRadio = class {
|
|
|
3510
3659
|
* @param newValue - valid new value
|
|
3511
3660
|
*/
|
|
3512
3661
|
setValidity(newValue) {
|
|
3513
|
-
const
|
|
3514
|
-
this.
|
|
3662
|
+
const oldValue = this.valid;
|
|
3663
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
3664
|
+
this.valid = newValue;
|
|
3665
|
+
}
|
|
3515
3666
|
this.invalid = !this.valid;
|
|
3516
3667
|
// We need to send valid event even if it is the same value
|
|
3517
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
3668
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
3518
3669
|
this.inputValid.emit(this.valid);
|
|
3519
3670
|
}
|
|
3520
3671
|
/*************
|
|
@@ -3545,7 +3696,7 @@ const MgInputRadio = class {
|
|
|
3545
3696
|
* @returns HTML Element
|
|
3546
3697
|
*/
|
|
3547
3698
|
render() {
|
|
3548
|
-
return (index.h("mg-input", { key: '
|
|
3699
|
+
return (index.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 && index.h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue)) : (index.h("ul", { class: "mg-c-input__input-group-container", role: "list" }, this.options.map((input, index$1) => (index.h("li", { key: input.title, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "radio", id: this.identifier + '_' + index$1, name: this.identifier, value: index$1, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index$1].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: (el) => {
|
|
3549
3700
|
if (el !== null)
|
|
3550
3701
|
this.inputs[index$1] = el;
|
|
3551
3702
|
} }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title))))))));
|
|
@@ -3562,7 +3713,7 @@ const MgInputRadio = class {
|
|
|
3562
3713
|
};
|
|
3563
3714
|
MgInputRadio.style = mgInputRadioCss;
|
|
3564
3715
|
|
|
3565
|
-
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%}}";
|
|
3716
|
+
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%}}";
|
|
3566
3717
|
|
|
3567
3718
|
/**
|
|
3568
3719
|
* Check if item is a well configured option
|
|
@@ -3613,6 +3764,7 @@ const MgInputSelect = class {
|
|
|
3613
3764
|
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
3614
3765
|
// hasDisplayedError (triggered by blur event)
|
|
3615
3766
|
this.hasDisplayedError = false;
|
|
3767
|
+
this.customErrorMessage = { lock: false };
|
|
3616
3768
|
/**
|
|
3617
3769
|
* Input name
|
|
3618
3770
|
* If not set the value equals the identifier
|
|
@@ -3721,15 +3873,17 @@ const MgInputSelect = class {
|
|
|
3721
3873
|
};
|
|
3722
3874
|
/**
|
|
3723
3875
|
* Set input error message
|
|
3724
|
-
* @param
|
|
3876
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
3725
3877
|
*/
|
|
3726
|
-
this.setErrorMessage = (
|
|
3878
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
3727
3879
|
// Set error message
|
|
3728
3880
|
this.errorMessage = undefined;
|
|
3729
3881
|
if (!this.valid) {
|
|
3730
|
-
|
|
3731
|
-
|
|
3882
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
3883
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
3884
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
3732
3885
|
}
|
|
3886
|
+
// required
|
|
3733
3887
|
else if (this.input.validity.valueMissing) {
|
|
3734
3888
|
this.errorMessage = this.messages.errors.required;
|
|
3735
3889
|
}
|
|
@@ -3843,17 +3997,22 @@ const MgInputSelect = class {
|
|
|
3843
3997
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
3844
3998
|
* @param valid - value indicating the validity
|
|
3845
3999
|
* @param errorMessage - the error message to display
|
|
4000
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
3846
4001
|
*/
|
|
3847
|
-
async setError(valid, errorMessage) {
|
|
4002
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
3848
4003
|
if (typeof valid !== 'boolean') {
|
|
3849
4004
|
throw new Error('<mg-input-select> method "setError()" param "valid" must be a boolean.');
|
|
3850
4005
|
}
|
|
3851
|
-
else if (!index$1.isValidString(errorMessage)) {
|
|
4006
|
+
else if (errorMessage !== undefined && !index$1.isValidString(errorMessage)) {
|
|
3852
4007
|
throw new Error('<mg-input-select> method "setError()" param "errorMessage" must be a string.');
|
|
3853
4008
|
}
|
|
3854
4009
|
else {
|
|
4010
|
+
this.customErrorMessage = {
|
|
4011
|
+
lock: valid ? false : errorMessageLock,
|
|
4012
|
+
message: valid ? undefined : errorMessage,
|
|
4013
|
+
};
|
|
3855
4014
|
this.setValidity(valid);
|
|
3856
|
-
this.setErrorMessage(
|
|
4015
|
+
this.setErrorMessage(true);
|
|
3857
4016
|
this.hasDisplayedError = this.invalid;
|
|
3858
4017
|
}
|
|
3859
4018
|
}
|
|
@@ -3871,6 +4030,8 @@ const MgInputSelect = class {
|
|
|
3871
4030
|
// - Keep everything in sync both inside and outside the component
|
|
3872
4031
|
return new Promise(resolve => {
|
|
3873
4032
|
requestAnimationFrame(() => {
|
|
4033
|
+
// unlock validity check by reseting customErrorMessage
|
|
4034
|
+
this.customErrorMessage = { lock: false };
|
|
3874
4035
|
this.checkValidity();
|
|
3875
4036
|
this.errorMessage = undefined;
|
|
3876
4037
|
this.hasDisplayedError = false;
|
|
@@ -3884,11 +4045,13 @@ const MgInputSelect = class {
|
|
|
3884
4045
|
* @param newValue - valid new value
|
|
3885
4046
|
*/
|
|
3886
4047
|
setValidity(newValue) {
|
|
3887
|
-
const
|
|
3888
|
-
this.
|
|
4048
|
+
const oldValue = this.valid;
|
|
4049
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
4050
|
+
this.valid = newValue;
|
|
4051
|
+
}
|
|
3889
4052
|
this.invalid = !this.valid;
|
|
3890
4053
|
// We need to send valid event even if it is the same value
|
|
3891
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
4054
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue)) {
|
|
3892
4055
|
this.inputValid.emit(this.valid);
|
|
3893
4056
|
}
|
|
3894
4057
|
}
|
|
@@ -3925,7 +4088,7 @@ const MgInputSelect = class {
|
|
|
3925
4088
|
*/
|
|
3926
4089
|
render() {
|
|
3927
4090
|
const readonlyValue = this.getReadonlyValue();
|
|
3928
|
-
return (index.h("mg-input", { key: '
|
|
4091
|
+
return (index.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 && index.h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (index.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) => {
|
|
3929
4092
|
if (el !== null)
|
|
3930
4093
|
this.input = el;
|
|
3931
4094
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -3981,6 +4144,7 @@ const MgInputText = class {
|
|
|
3981
4144
|
this.classIsAppendInputSlotContent = 'mg-c-input--is-append-input-slot-content';
|
|
3982
4145
|
// hasDisplayedError (triggered by blur event)
|
|
3983
4146
|
this.hasDisplayedError = false;
|
|
4147
|
+
this.customErrorMessage = { lock: false };
|
|
3984
4148
|
/**
|
|
3985
4149
|
* Input name
|
|
3986
4150
|
* If not set the value equals the identifier
|
|
@@ -4079,27 +4243,29 @@ const MgInputText = class {
|
|
|
4079
4243
|
};
|
|
4080
4244
|
/**
|
|
4081
4245
|
* Set input error message
|
|
4082
|
-
* @param
|
|
4246
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
4083
4247
|
*/
|
|
4084
|
-
this.setErrorMessage = (
|
|
4248
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
4085
4249
|
var _a;
|
|
4086
4250
|
// Set error message
|
|
4087
4251
|
this.errorMessage = undefined;
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
this.
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4252
|
+
if (!this.valid) {
|
|
4253
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
4254
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
4255
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
4256
|
+
}
|
|
4257
|
+
// Does not match type (email, emails, tel, url, etc.)
|
|
4258
|
+
else if (this.input.validity.typeMismatch) {
|
|
4259
|
+
this.errorMessage = this.messages.input.text.errors.typeMismatch[this.type];
|
|
4260
|
+
}
|
|
4261
|
+
// Does not match pattern
|
|
4262
|
+
else if (this.input.validity.patternMismatch) {
|
|
4263
|
+
this.errorMessage = (_a = this.patternErrorMessage) !== null && _a !== void 0 ? _a : this.messages.input.text.errors.typeMismatch[this.type];
|
|
4264
|
+
}
|
|
4265
|
+
// required
|
|
4266
|
+
else if (this.input.validity.valueMissing) {
|
|
4267
|
+
this.errorMessage = this.messages.errors.required;
|
|
4268
|
+
}
|
|
4103
4269
|
}
|
|
4104
4270
|
};
|
|
4105
4271
|
/**
|
|
@@ -4233,17 +4399,22 @@ const MgInputText = class {
|
|
|
4233
4399
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
4234
4400
|
* @param valid - value indicating the validity
|
|
4235
4401
|
* @param errorMessage - the error message to display
|
|
4402
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
4236
4403
|
*/
|
|
4237
|
-
async setError(valid, errorMessage) {
|
|
4404
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
4238
4405
|
if (typeof valid !== 'boolean') {
|
|
4239
4406
|
throw new Error('<mg-input-text> method "setError()" param "valid" must be a boolean.');
|
|
4240
4407
|
}
|
|
4241
|
-
else if (!index$1.isValidString(errorMessage)) {
|
|
4408
|
+
else if (errorMessage !== undefined && !index$1.isValidString(errorMessage)) {
|
|
4242
4409
|
throw new Error('<mg-input-text> method "setError()" param "errorMessage" must be a string.');
|
|
4243
4410
|
}
|
|
4244
4411
|
else {
|
|
4412
|
+
this.customErrorMessage = {
|
|
4413
|
+
lock: valid ? false : errorMessageLock,
|
|
4414
|
+
message: valid ? undefined : errorMessage,
|
|
4415
|
+
};
|
|
4245
4416
|
this.setValidity(valid);
|
|
4246
|
-
this.setErrorMessage(
|
|
4417
|
+
this.setErrorMessage(true);
|
|
4247
4418
|
this.hasDisplayedError = this.invalid;
|
|
4248
4419
|
}
|
|
4249
4420
|
}
|
|
@@ -4261,6 +4432,8 @@ const MgInputText = class {
|
|
|
4261
4432
|
// - Keep everything in sync both inside and outside the component
|
|
4262
4433
|
return new Promise(resolve => {
|
|
4263
4434
|
requestAnimationFrame(() => {
|
|
4435
|
+
// unlock validity check by reseting customErrorMessage
|
|
4436
|
+
this.customErrorMessage = { lock: false };
|
|
4264
4437
|
this.checkValidity();
|
|
4265
4438
|
this.errorMessage = undefined;
|
|
4266
4439
|
this.hasDisplayedError = false;
|
|
@@ -4274,11 +4447,13 @@ const MgInputText = class {
|
|
|
4274
4447
|
* @param newValue - valid new value
|
|
4275
4448
|
*/
|
|
4276
4449
|
setValidity(newValue) {
|
|
4277
|
-
const
|
|
4278
|
-
this.
|
|
4450
|
+
const oldValue = this.valid;
|
|
4451
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
4452
|
+
this.valid = newValue;
|
|
4453
|
+
}
|
|
4279
4454
|
this.invalid = !this.valid;
|
|
4280
4455
|
// We need to send valid event even if it is the same value
|
|
4281
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
4456
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
4282
4457
|
this.inputValid.emit(this.valid);
|
|
4283
4458
|
}
|
|
4284
4459
|
/*************
|
|
@@ -4315,7 +4490,7 @@ const MgInputText = class {
|
|
|
4315
4490
|
* @returns HTML Element
|
|
4316
4491
|
*/
|
|
4317
4492
|
render() {
|
|
4318
|
-
return (index.h("mg-input", { key: '
|
|
4493
|
+
return (index.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
|
|
4319
4494
|
? this.value && this.renderReadonly()
|
|
4320
4495
|
: [
|
|
4321
4496
|
index.h("div", { key: "input", class: "mg-c-input__with-character-left", style: {
|
|
@@ -4359,6 +4534,7 @@ const MgInputTextarea = class {
|
|
|
4359
4534
|
this.classDisplayCharacterLeft = 'mg-c-input--display-character-left';
|
|
4360
4535
|
// hasDisplayedError (triggered by blur event)
|
|
4361
4536
|
this.hasDisplayedError = false;
|
|
4537
|
+
this.customErrorMessage = { lock: false };
|
|
4362
4538
|
/**
|
|
4363
4539
|
* Input name
|
|
4364
4540
|
* If not set the value equals the identifier
|
|
@@ -4457,15 +4633,16 @@ const MgInputTextarea = class {
|
|
|
4457
4633
|
};
|
|
4458
4634
|
/**
|
|
4459
4635
|
* Set input error message
|
|
4460
|
-
* @param
|
|
4636
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
4461
4637
|
*/
|
|
4462
|
-
this.setErrorMessage = (
|
|
4638
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
4463
4639
|
// Set error message
|
|
4464
4640
|
this.errorMessage = undefined;
|
|
4465
|
-
// Does
|
|
4641
|
+
// Does have a new custom error message
|
|
4466
4642
|
if (!this.valid) {
|
|
4467
|
-
|
|
4468
|
-
|
|
4643
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
4644
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
4645
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
4469
4646
|
}
|
|
4470
4647
|
else if (!this.getPatternValidity()) {
|
|
4471
4648
|
this.errorMessage = this.patternErrorMessage;
|
|
@@ -4558,17 +4735,22 @@ const MgInputTextarea = class {
|
|
|
4558
4735
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
4559
4736
|
* @param valid - value indicating the validity
|
|
4560
4737
|
* @param errorMessage - the error message to display
|
|
4738
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
4561
4739
|
*/
|
|
4562
|
-
async setError(valid, errorMessage) {
|
|
4740
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
4563
4741
|
if (typeof valid !== 'boolean') {
|
|
4564
4742
|
throw new Error('<mg-input-textarea> method "setError()" param "valid" must be a boolean.');
|
|
4565
4743
|
}
|
|
4566
|
-
else if (!index$1.isValidString(errorMessage)) {
|
|
4744
|
+
else if (errorMessage !== undefined && !index$1.isValidString(errorMessage)) {
|
|
4567
4745
|
throw new Error('<mg-input-textarea> method "setError()" param "errorMessage" must be a string.');
|
|
4568
4746
|
}
|
|
4569
4747
|
else {
|
|
4748
|
+
this.customErrorMessage = {
|
|
4749
|
+
lock: valid ? false : errorMessageLock,
|
|
4750
|
+
message: valid ? undefined : errorMessage,
|
|
4751
|
+
};
|
|
4570
4752
|
this.setValidity(valid);
|
|
4571
|
-
this.setErrorMessage(
|
|
4753
|
+
this.setErrorMessage(true);
|
|
4572
4754
|
this.hasDisplayedError = this.invalid;
|
|
4573
4755
|
}
|
|
4574
4756
|
}
|
|
@@ -4586,6 +4768,8 @@ const MgInputTextarea = class {
|
|
|
4586
4768
|
// - Keep everything in sync both inside and outside the component
|
|
4587
4769
|
return new Promise(resolve => {
|
|
4588
4770
|
requestAnimationFrame(() => {
|
|
4771
|
+
// unlock validity check by reseting customErrorMessage
|
|
4772
|
+
this.customErrorMessage = { lock: false };
|
|
4589
4773
|
this.checkValidity();
|
|
4590
4774
|
this.errorMessage = undefined;
|
|
4591
4775
|
this.hasDisplayedError = false;
|
|
@@ -4599,11 +4783,13 @@ const MgInputTextarea = class {
|
|
|
4599
4783
|
* @param newValue - valid new value
|
|
4600
4784
|
*/
|
|
4601
4785
|
setValidity(newValue) {
|
|
4602
|
-
const
|
|
4603
|
-
this.
|
|
4786
|
+
const oldValue = this.valid;
|
|
4787
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
4788
|
+
this.valid = newValue;
|
|
4789
|
+
}
|
|
4604
4790
|
this.invalid = !this.valid;
|
|
4605
4791
|
// We need to send valid event even if it is the same value
|
|
4606
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
4792
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
4607
4793
|
this.inputValid.emit(this.valid);
|
|
4608
4794
|
}
|
|
4609
4795
|
/*************
|
|
@@ -4636,7 +4822,7 @@ const MgInputTextarea = class {
|
|
|
4636
4822
|
* @returns HTML Element
|
|
4637
4823
|
*/
|
|
4638
4824
|
render() {
|
|
4639
|
-
return (index.h("mg-input", { key: '
|
|
4825
|
+
return (index.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 && index.h("b", { class: "mg-c-input__readonly-value" }, this.value)) : (index.h("div", { class: "mg-c-input__with-character-left" }, index.h("textarea", { class: {
|
|
4640
4826
|
'mg-c-input__box': true,
|
|
4641
4827
|
'mg-c-input__box--width': true,
|
|
4642
4828
|
'mg-c-input__box--resizable': this.resizable === 'both',
|
|
@@ -4712,7 +4898,7 @@ const MgInputTitle = class {
|
|
|
4712
4898
|
};
|
|
4713
4899
|
MgInputTitle.style = mgInputTitleCss;
|
|
4714
4900
|
|
|
4715
|
-
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:
|
|
4901
|
+
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}";
|
|
4716
4902
|
|
|
4717
4903
|
/**
|
|
4718
4904
|
* type Option validation function
|
|
@@ -4743,7 +4929,9 @@ const MgInputToggle = class {
|
|
|
4743
4929
|
*/
|
|
4744
4930
|
this.labelHide = false;
|
|
4745
4931
|
/**
|
|
4746
|
-
* Define if toggle have on/off style
|
|
4932
|
+
* Define if toggle have on/off style,
|
|
4933
|
+
* the left icon is hidden.
|
|
4934
|
+
* Only available in combination with the "isIcon" prop.
|
|
4747
4935
|
*/
|
|
4748
4936
|
this.isOnOff = false;
|
|
4749
4937
|
/**
|
|
@@ -4778,7 +4966,7 @@ const MgInputToggle = class {
|
|
|
4778
4966
|
// Set error message
|
|
4779
4967
|
this.errorMessage = undefined;
|
|
4780
4968
|
// Does have a custom error message
|
|
4781
|
-
if (!this.valid && errorMessage
|
|
4969
|
+
if (!this.valid && typeof errorMessage === 'string') {
|
|
4782
4970
|
this.errorMessage = errorMessage;
|
|
4783
4971
|
}
|
|
4784
4972
|
};
|
|
@@ -4793,14 +4981,31 @@ const MgInputToggle = class {
|
|
|
4793
4981
|
*/
|
|
4794
4982
|
this.validateSlots = () => {
|
|
4795
4983
|
const slots = Array.from(this.element.children);
|
|
4984
|
+
// validate slots
|
|
4796
4985
|
if (slots.length !== 2) {
|
|
4797
|
-
|
|
4986
|
+
if (this.isOnOff && this.isIcon) {
|
|
4987
|
+
// ONLY slot="item-2" is required in with isOnOff && isIcon
|
|
4988
|
+
if (this.element.querySelector('[slot="item-2"]') === null) {
|
|
4989
|
+
throw new Error('<mg-input-toggle> an element with attribute slot="item-2" is required.');
|
|
4990
|
+
}
|
|
4991
|
+
}
|
|
4992
|
+
else {
|
|
4993
|
+
throw new Error('<mg-input-toggle> 2 slots are required.');
|
|
4994
|
+
}
|
|
4798
4995
|
}
|
|
4799
|
-
|
|
4996
|
+
// update slots
|
|
4997
|
+
if (!this.isIcon) {
|
|
4800
4998
|
// Due to text-overflow set to ellipsis
|
|
4801
4999
|
// we need to ensure that slot element have title to display value on mouse over
|
|
4802
5000
|
slots.forEach(slot => slot.setAttribute('title', slot.textContent));
|
|
4803
5001
|
}
|
|
5002
|
+
else {
|
|
5003
|
+
slots.forEach(slot => {
|
|
5004
|
+
if (slot.nodeName === 'MG-ICON') {
|
|
5005
|
+
slot.size = 'small';
|
|
5006
|
+
}
|
|
5007
|
+
});
|
|
5008
|
+
}
|
|
4804
5009
|
};
|
|
4805
5010
|
/**
|
|
4806
5011
|
* Get checked item
|
|
@@ -4841,10 +5046,16 @@ const MgInputToggle = class {
|
|
|
4841
5046
|
}
|
|
4842
5047
|
}
|
|
4843
5048
|
watchIsOnOff(newValue) {
|
|
4844
|
-
if (newValue)
|
|
5049
|
+
if (newValue) {
|
|
4845
5050
|
this.classCollection.add(this.classOnOff);
|
|
4846
|
-
|
|
5051
|
+
if (!this.isIcon) {
|
|
5052
|
+
this.isOnOff = false;
|
|
5053
|
+
console.warn('<mg-input-toggle> prop "isOnOff" must be used with "isIcon". Setting isOnOff to false.');
|
|
5054
|
+
}
|
|
5055
|
+
}
|
|
5056
|
+
else {
|
|
4847
5057
|
this.classCollection.delete(this.classOnOff);
|
|
5058
|
+
}
|
|
4848
5059
|
}
|
|
4849
5060
|
watchIsIcon(newValue) {
|
|
4850
5061
|
if (newValue)
|
|
@@ -4892,7 +5103,7 @@ const MgInputToggle = class {
|
|
|
4892
5103
|
if (typeof valid !== 'boolean') {
|
|
4893
5104
|
throw new Error('<mg-input-toggle> method "setError()" param "valid" must be a boolean.');
|
|
4894
5105
|
}
|
|
4895
|
-
else if (!index$1.isValidString(errorMessage)) {
|
|
5106
|
+
else if (errorMessage !== undefined && !index$1.isValidString(errorMessage)) {
|
|
4896
5107
|
throw new Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string.');
|
|
4897
5108
|
}
|
|
4898
5109
|
else {
|
|
@@ -4969,7 +5180,7 @@ const MgInputToggle = class {
|
|
|
4969
5180
|
*/
|
|
4970
5181
|
render() {
|
|
4971
5182
|
const checkedItem = this.getCheckedItem(this.checked);
|
|
4972
|
-
return (index.h("mg-input", { key: '
|
|
5183
|
+
return (index.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 && index.h("b", { class: "mg-c-input__readonly-value" }, checkedItem.title)) : (index.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 => {
|
|
4973
5184
|
if (el !== null)
|
|
4974
5185
|
this.button = el;
|
|
4975
5186
|
} }, index.h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, index.h("slot", { name: "item-1" })), index.h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, index.h("slot", { name: "item-2" }))))));
|
|
@@ -5259,6 +5470,10 @@ const MgMenu = class {
|
|
|
5259
5470
|
* @param event - mg-item-loaded "item-loaded" custom event
|
|
5260
5471
|
*/
|
|
5261
5472
|
updateItemListener(event) {
|
|
5473
|
+
// `<mg-action-more>` element doesn't need `data-has-focus` attribute
|
|
5474
|
+
if (event.target.nodeName === 'MG-ACTION-MORE') {
|
|
5475
|
+
return;
|
|
5476
|
+
}
|
|
5262
5477
|
const itemToWatch = event.target.nodeName === 'MG-ITEM-MORE' ? event.target.shadowRoot.querySelector('mg-menu-item') : event.target;
|
|
5263
5478
|
['click', 'focus'].forEach(trigger => {
|
|
5264
5479
|
itemToWatch.addEventListener(trigger, () => {
|
|
@@ -5319,7 +5534,7 @@ const MgMenu = class {
|
|
|
5319
5534
|
* @returns HTML Element
|
|
5320
5535
|
*/
|
|
5321
5536
|
render() {
|
|
5322
|
-
return (index.h(index.Host, { key: '
|
|
5537
|
+
return (index.h(index.Host, { key: '753833b01b86d6983f5d063f5598e2187b147a6e', role: "list", "aria-label": this.label }, index.h("slot", { key: '56702e49f5a97feddeb66e6271bd898061aa0d48' })));
|
|
5323
5538
|
}
|
|
5324
5539
|
get element() { return index.getElement(this); }
|
|
5325
5540
|
static get watchers() { return {
|
|
@@ -5800,9 +6015,9 @@ const MgMessage = class {
|
|
|
5800
6015
|
* @returns HTML Element
|
|
5801
6016
|
*/
|
|
5802
6017
|
render() {
|
|
5803
|
-
return (index.h("div", { key: '
|
|
6018
|
+
return (index.h("div", { key: 'f99bf527eb2c6005eeaec11f89aaa08f8865ea57', class: this.classCollection.join() }, index.h("mg-card", { key: 'beede3cd97b022d947c216b6bba454a104ba5790', shadow: true }, this.variantStyle === 'bar-left' && index.h("span", { key: '515828d725a996c9d57b39ad75e9373150a1b78a', class: "mg-c-message__bar" }), index.h("span", { key: '02ae41c66af25c2611b9b6cb8c87a1ad99346fa3', class: "mg-c-message__icon" }, index.h("mg-icon", { key: '3eadb40ed0dfa5ec51155608a67769c5fee3d402', icon: this.getIcon() })), index.h("div", { key: 'b832251e8f330d00b512bcd508ae9bf6e5f511cb', class: "mg-c-message__content" }, index.h("span", { key: 'c3520fc49bd5c3c187a83823050ceb9ca8c12d46', class: "mg-c-message__content-slot" }, index.h("slot", { key: 'f4064dff9536cbb76e45c5c4c1a89621da9531b2' })), this.hasActions && [
|
|
5804
6019
|
index.h("span", { class: "mg-c-message__content-separator", key: "content-separator" }),
|
|
5805
|
-
index.h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, index.h("slot", { key: '
|
|
6020
|
+
index.h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, index.h("slot", { key: '5585f7c14c2c3896cfdb5319414cd82f4d4b3a8b', name: "actions" })),
|
|
5806
6021
|
]))));
|
|
5807
6022
|
}
|
|
5808
6023
|
get element() { return index.getElement(this); }
|
|
@@ -5924,11 +6139,11 @@ const MgModal = class {
|
|
|
5924
6139
|
* @returns HTML Element
|
|
5925
6140
|
*/
|
|
5926
6141
|
render() {
|
|
5927
|
-
return (index.h("dialog", { key: '
|
|
6142
|
+
return (index.h("dialog", { key: '2d99322fd3c80b8cbfea70589cf579e0c1c6f06b', role: this.dialogRole, id: this.identifier, class: this.classCollection.join(), "aria-labelledby": this.titleId, ref: (el) => {
|
|
5928
6143
|
if (el !== null) {
|
|
5929
6144
|
this.dialog = el;
|
|
5930
6145
|
}
|
|
5931
|
-
} }, index.h("mg-card", { key: '
|
|
6146
|
+
} }, index.h("mg-card", { key: '32692a6d41ef30b3d3e61ddcfea47350d374ed09', shadow: true }, index.h("div", { key: 'c87bb43bb069671b65a9759ee293e77975707597', class: "mg-c-modal__dialog" }, index.h("header", { key: '1272a946878efcf8c69f3b09852ba6938cbe31b0', class: "mg-c-modal__header" }, this.closeButton && (index.h("span", { key: '0704656c7c5ac4c8d405f2cd673e91f72763ee8f', class: "mg-c-modal__close-button" }, index.h("mg-button", { key: '4402971c763ee34145de5bd69d367fde68f9d1a2', "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, index.h("mg-icon", { key: '9e16add6a3e387971507a252671c895b6c94a586', icon: "cross" })))), index.h("h1", { key: '3e4fc2b4419398528565d382b728b8b752758ddd', class: "mg-c-modal__title", id: this.titleId }, this.modalTitle)), index.h("article", { key: '170ff6bd9592687baa4c561615f540ad1c7400e4', class: "mg-c-modal__content" }, index.h("slot", { key: 'cb710e2a57e4c997deac367169b56047af1200b1' })), this.hasActions && (index.h("footer", { key: '1e08d67caeaaaf75eb97faa11528719ea537c24c', class: "mg-c-modal__footer" }, index.h("slot", { key: '461ec8e4117477aef08dc6d346ad0bf6007ec12d', name: "actions" })))))));
|
|
5932
6147
|
}
|
|
5933
6148
|
get element() { return index.getElement(this); }
|
|
5934
6149
|
static get watchers() { return {
|
|
@@ -6149,6 +6364,13 @@ const MgPanel = class {
|
|
|
6149
6364
|
/************
|
|
6150
6365
|
* Methods *
|
|
6151
6366
|
************/
|
|
6367
|
+
/**
|
|
6368
|
+
* Check if panel-title slot is used
|
|
6369
|
+
* @returns true if slot is used
|
|
6370
|
+
*/
|
|
6371
|
+
this.hasPanelTitleSlot = () => {
|
|
6372
|
+
return this.element.querySelector('[slot="panel-title"]') !== null;
|
|
6373
|
+
};
|
|
6152
6374
|
/**
|
|
6153
6375
|
* Toggle is editing state
|
|
6154
6376
|
*/
|
|
@@ -6202,7 +6424,7 @@ const MgPanel = class {
|
|
|
6202
6424
|
* Render collapse button
|
|
6203
6425
|
* @returns collpase button
|
|
6204
6426
|
*/
|
|
6205
|
-
this.renderCollapseButton = () => (index.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 }, index.h("span", { class: "mg-c-panel__collapse-button-content" }, index.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)));
|
|
6427
|
+
this.renderCollapseButton = () => (index.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 }, index.h("span", { class: "mg-c-panel__collapse-button-content" }, index.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() ? index.h("slot", { name: "panel-title" }) : this.panelTitle))));
|
|
6206
6428
|
/**
|
|
6207
6429
|
* Render edit button
|
|
6208
6430
|
* @returns edit Button
|
|
@@ -6219,7 +6441,8 @@ const MgPanel = class {
|
|
|
6219
6441
|
*/
|
|
6220
6442
|
this.renderTitle = () => {
|
|
6221
6443
|
const elementsToRender = [this.renderCollapseButton()];
|
|
6222
|
-
if
|
|
6444
|
+
// Add edit functionality only if not using slot and title is editable
|
|
6445
|
+
if (this.titleEditable && !this.hasPanelTitleSlot()) {
|
|
6223
6446
|
if (!this.isEditing)
|
|
6224
6447
|
elementsToRender.push(this.renderEditButton());
|
|
6225
6448
|
else
|
|
@@ -6245,14 +6468,24 @@ const MgPanel = class {
|
|
|
6245
6468
|
}
|
|
6246
6469
|
}
|
|
6247
6470
|
validatePanelTitle(newValue) {
|
|
6248
|
-
if (
|
|
6249
|
-
|
|
6250
|
-
|
|
6471
|
+
if (newValue !== undefined) {
|
|
6472
|
+
if (!index$1.isValidString(newValue)) {
|
|
6473
|
+
throw new Error(`<mg-panel> prop "panelTitle" must be a string. Passed value: ${index$1.toString(newValue)}.`);
|
|
6474
|
+
}
|
|
6475
|
+
else {
|
|
6476
|
+
this.titleChange.emit(newValue);
|
|
6477
|
+
}
|
|
6478
|
+
}
|
|
6251
6479
|
}
|
|
6252
6480
|
validateTitlePattern(newValue) {
|
|
6253
6481
|
if (newValue !== undefined && !this.titleEditable)
|
|
6254
6482
|
throw new Error(`<mg-panel> prop "titleEditable" must be set to "true".`);
|
|
6255
6483
|
}
|
|
6484
|
+
validateTitleEditable(newValue) {
|
|
6485
|
+
if (newValue && this.hasPanelTitleSlot()) {
|
|
6486
|
+
throw new Error(`<mg-panel> prop "titleEditable" cannot be used with panel-title slot.`);
|
|
6487
|
+
}
|
|
6488
|
+
}
|
|
6256
6489
|
validateTitlePosition(newValue) {
|
|
6257
6490
|
if (!titlePositions.includes(newValue))
|
|
6258
6491
|
throw new Error(`<mg-panel> prop "titlePosition" must be one of: ${titlePositions.join(', ')}. Passed value: ${index$1.toString(newValue)}.`);
|
|
@@ -6265,6 +6498,9 @@ const MgPanel = class {
|
|
|
6265
6498
|
throw new Error(`<mg-panel> prop "expandToggleDisplay" must be one of: ${expandToggleDisplays.join(', ')}. Passed value: ${index$1.toString(newValue)}.`);
|
|
6266
6499
|
if (newValue === 'icon' && this.titleEditable)
|
|
6267
6500
|
this.titleEditable = false;
|
|
6501
|
+
if (newValue === 'icon' && this.hasPanelTitleSlot()) {
|
|
6502
|
+
throw new Error(`<mg-panel> prop "expandToggleDisplay" cannot be "icon" when panel-title slot is used.`);
|
|
6503
|
+
}
|
|
6268
6504
|
}
|
|
6269
6505
|
/*************
|
|
6270
6506
|
* Lifecycle *
|
|
@@ -6279,9 +6515,15 @@ const MgPanel = class {
|
|
|
6279
6515
|
this.watchIdentifier(this.identifier);
|
|
6280
6516
|
this.validateTitlePattern(this.titlePattern);
|
|
6281
6517
|
this.validateTitlePattern(this.titlePatternErrorMessage);
|
|
6282
|
-
|
|
6518
|
+
// Only validate panelTitle if slot is not used
|
|
6519
|
+
if (!this.hasPanelTitleSlot()) {
|
|
6520
|
+
if (!index$1.isValidString(this.panelTitle))
|
|
6521
|
+
throw new Error(`<mg-panel> prop "panelTitle" is required when panel-title slot is not used.`);
|
|
6522
|
+
this.validatePanelTitle(this.panelTitle);
|
|
6523
|
+
}
|
|
6283
6524
|
this.validateExpandToggleDisplay(this.expandToggleDisplay);
|
|
6284
6525
|
this.validateTitlePosition(this.titlePosition);
|
|
6526
|
+
this.validateTitleEditable(this.titleEditable);
|
|
6285
6527
|
}
|
|
6286
6528
|
/**
|
|
6287
6529
|
* Edit DOM after render
|
|
@@ -6297,7 +6539,7 @@ const MgPanel = class {
|
|
|
6297
6539
|
*/
|
|
6298
6540
|
render() {
|
|
6299
6541
|
const headerId = `${this.identifier}-header`;
|
|
6300
|
-
return (index.h("section", { key: '
|
|
6542
|
+
return (index.h("section", { key: '3662204d763051c34ea13de4b7b3f7abc7914b81', class: this.classCollection.join(), id: this.identifier }, index.h("mg-card", { key: '46f113258172b1d040f65a4d312554b0c0551489', shadow: this.shadow }, index.h("header", { key: '1d7e7a48a5c4f89d141a5a7e46b220d4f9c082a5', class: { 'mg-c-panel__header': true, 'mg-c-panel__header--reverse': this.titlePosition === 'right' }, id: headerId }, this.renderHeaderChildren()), index.h("article", { key: 'ab0aec831cc79d982b7556d6e245c80ae2979083', class: "mg-c-panel__content", id: `${this.identifier}-content`, "aria-labelledby": headerId, hidden: !this.expanded }, index.h("slot", { key: 'e831573fe9d5ff783073d123b7e2a54baad73bfc' })))));
|
|
6301
6543
|
}
|
|
6302
6544
|
get element() { return index.getElement(this); }
|
|
6303
6545
|
static get watchers() { return {
|
|
@@ -6305,6 +6547,7 @@ const MgPanel = class {
|
|
|
6305
6547
|
"panelTitle": ["validatePanelTitle"],
|
|
6306
6548
|
"titlePattern": ["validateTitlePattern"],
|
|
6307
6549
|
"titlePatternErrorMessage": ["validateTitlePattern"],
|
|
6550
|
+
"titleEditable": ["validateTitleEditable"],
|
|
6308
6551
|
"titlePosition": ["validateTitlePosition"],
|
|
6309
6552
|
"expanded": ["handleExpanded"],
|
|
6310
6553
|
"expandToggleDisplay": ["validateExpandToggleDisplay"]
|
|
@@ -8342,7 +8585,7 @@ const MgPopover = class {
|
|
|
8342
8585
|
* @returns HTML Element
|
|
8343
8586
|
*/
|
|
8344
8587
|
render() {
|
|
8345
|
-
return (index.h(index.Host, { key: '
|
|
8588
|
+
return (index.h(index.Host, { key: '2c1506b8e2da100519aeeae75fc5c378a81c473c' }, index.h("slot", { key: 'f9aea885e8cbc168614c05761829f0a0740eba9e' }), index.h("slot", { key: 'fa6106a660a73b3761d4783f8d46d401c47b4eb6', name: "content" })));
|
|
8346
8589
|
}
|
|
8347
8590
|
get element() { return index.getElement(this); }
|
|
8348
8591
|
static get watchers() { return {
|
|
@@ -8400,7 +8643,7 @@ const MgPopoverContent = class {
|
|
|
8400
8643
|
* @returns HTML Element
|
|
8401
8644
|
*/
|
|
8402
8645
|
render() {
|
|
8403
|
-
return (index.h(index.Host, { key: '
|
|
8646
|
+
return (index.h(index.Host, { key: '054fc82954b39a488f7fe5cb391d89b5fa4a61fe' }, index.h("mg-card", { key: 'bb89bada37069b50295bd93d988667c3b85eada3', class: this.classCollection.join(), shadow: true }, this.closeButton && (index.h("mg-button", { key: 'a59d6610574b964be1e2ce34ccd8e31c1395b6ff', "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, index.h("mg-icon", { key: '5bcc9e4eb21396f4fc66a6f1e4d6c5cdf68ec1f4', icon: "cross" }))), index.h("div", { key: '57be2022f3b61220e1249faeaf2acee9960027fe', class: "mg-c-popover-content__title" }, index.h("slot", { key: 'c7870e86a9f105cf6b9d4520c77874bce9235d72', name: "title" })), index.h("slot", { key: '5af8462232625d9c7d694bab46351d5e646f62ca', name: "content" })), index.h("slot", { key: '599863410dd7d751e82c440cd6c4fb7f2c48d9f3', name: "arrow" })));
|
|
8404
8647
|
}
|
|
8405
8648
|
get element() { return index.getElement(this); }
|
|
8406
8649
|
};
|
|
@@ -8445,7 +8688,7 @@ const MgSkipLinks = class {
|
|
|
8445
8688
|
* @returns HTML Element
|
|
8446
8689
|
*/
|
|
8447
8690
|
render() {
|
|
8448
|
-
return (index.h("nav", { key: '
|
|
8691
|
+
return (index.h("nav", { key: '5bf4427662bdca6512969bee91aa03f43a126743', class: "mg-c-skip-links", role: "navigation", "aria-label": this.messages.skipLinks.navLabel }, index.h("ul", { key: '1d2b2a56b3960f70a3d37b333c77bf686643e0fd', class: "mg-c-skip-links__list", role: "list" }, this.links.map(link => (index.h("li", { key: link.href }, index.h("a", { class: "mg-c-skip-links__link", href: link.href, onClick: this.handleLinkCLick }, link.label)))))));
|
|
8449
8692
|
}
|
|
8450
8693
|
get element() { return index.getElement(this); }
|
|
8451
8694
|
static get watchers() { return {
|
|
@@ -8965,7 +9208,7 @@ const MgTabs = class {
|
|
|
8965
9208
|
* @returns HTML Element
|
|
8966
9209
|
*/
|
|
8967
9210
|
render() {
|
|
8968
|
-
return (index.h("div", { key: '
|
|
9211
|
+
return (index.h("div", { key: 'ae71d21c9ce3acb07b3adf67bbe25f205d382abc', class: this.classCollection.join() }, index.h("header", { key: 'cf6cdae863602c956aa450a34e91a6d8b950d8f5', role: "tablist", "aria-label": this.label, class: "mg-c-tabs__header" }, this.tabs.map((tab, index$1) => (index.h("button", { key: tab.label, role: "tab", id: this.getElementId(this.identifier, index$1), class: {
|
|
8969
9212
|
[`${this.buttonTabBaseClass}`]: true,
|
|
8970
9213
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
8971
9214
|
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|