@mgdis/mg-components 6.15.0 → 6.16.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/events.utils-D5SAtkpQ.js +25 -0
- package/dist/cjs/{index-BGxkpQwi.js → index-T3-qWqFE.js} +2 -2
- package/dist/cjs/{index-iUZvsp-F.js → index-YM1EJx9X.js} +8 -20
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_37.cjs.entry.js +68 -305
- package/dist/cjs/mg-alert.cjs.entry.js +2 -2
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-input-combobox.cjs.entry.js +78 -140
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +3 -3
- package/dist/cjs/{mg-input.conf-CwjEAih3.js → mg-input.conf-WTsvDfpC.js} +0 -7
- package/dist/cjs/mg-loader.cjs.entry.js +2 -2
- package/dist/cjs/mg-progress.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +0 -6
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +22 -93
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +1 -2
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +13 -69
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +54 -136
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -63
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +6 -54
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +9 -142
- package/dist/collection/locales/en/messages.json +3 -8
- package/dist/collection/locales/fr/messages.json +3 -8
- package/dist/components/index2.js +1 -1
- package/dist/components/index3.js +8 -20
- package/dist/components/mg-details.js +97 -1
- package/dist/components/mg-input-checkbox-paginated2.js +1 -2
- package/dist/components/mg-input-checkbox.js +19 -63
- package/dist/components/mg-input-combobox.js +60 -130
- package/dist/components/mg-input-date.js +1 -7
- package/dist/components/mg-input-numeric.js +1 -7
- package/dist/components/mg-input-password.js +2 -8
- package/dist/components/mg-input-radio.js +12 -53
- package/dist/components/mg-input-rich-text-editor.js +1 -7
- package/dist/components/mg-input-select2.js +8 -44
- package/dist/components/mg-input-text2.js +2 -8
- package/dist/components/mg-input-textarea.js +2 -8
- package/dist/components/mg-input-toggle.js +11 -96
- package/dist/components/mg-input2.js +22 -99
- package/dist/components/mg-pagination.js +2 -8
- package/dist/components/mg-panel.js +7 -13
- package/dist/esm/events.utils-yMGqY8YG.js +23 -0
- package/dist/esm/{index-CKB-AnCZ.js → index-Bab8_u8S.js} +8 -20
- package/dist/esm/{index-DhAOnZJn.js → index-JHj_9FSs.js} +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_37.entry.js +64 -301
- package/dist/esm/mg-alert.entry.js +2 -2
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-input-combobox.entry.js +59 -121
- package/dist/esm/mg-input-rich-text-editor.entry.js +3 -3
- package/dist/esm/{mg-input.conf-BAUTlb6r.js → mg-input.conf-CNgv8hc5.js} +1 -7
- package/dist/esm/mg-loader.entry.js +2 -2
- package/dist/esm/mg-progress.entry.js +1 -1
- package/dist/mg-components/locales/en/messages.json +3 -8
- package/dist/mg-components/locales/fr/messages.json +3 -8
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-420daa1e.entry.js → p-42a90251.entry.js} +1 -1
- package/dist/mg-components/p-54156253.entry.js +1 -0
- package/dist/mg-components/{p-47e19783.entry.js → p-658f828c.entry.js} +1 -1
- package/dist/mg-components/{p-67af6274.entry.js → p-82455ac7.entry.js} +1 -1
- package/dist/mg-components/p-Bab8_u8S.js +1 -0
- package/dist/mg-components/p-CNgv8hc5.js +1 -0
- package/dist/mg-components/{p-DhAOnZJn.js → p-JHj_9FSs.js} +1 -1
- package/dist/mg-components/p-abbd151c.entry.js +1 -0
- package/dist/mg-components/{p-a0fa44cf.entry.js → p-c85b5d10.entry.js} +1 -1
- package/dist/mg-components/p-yMGqY8YG.js +1 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +0 -13
- package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +4 -15
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +3 -21
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +2 -16
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +0 -18
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +0 -18
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -40
- package/dist/types/components.d.ts +7 -63
- package/ide/intellij/web-types.json +10 -136
- package/ide/vscode/html-custom-data.json +6 -104
- package/package.json +20 -20
- package/dist/cjs/mg-input.utils-D-ASK4ua.js +0 -49
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.utils.js +0 -21
- package/dist/components/mg-details2.js +0 -99
- package/dist/components/mg-input.utils.js +0 -24
- package/dist/esm/mg-input.utils-BYI03zSi.js +0 -46
- package/dist/mg-components/p-31856cff.entry.js +0 -1
- package/dist/mg-components/p-698dfc6c.entry.js +0 -1
- package/dist/mg-components/p-BAUTlb6r.js +0 -1
- package/dist/mg-components/p-CKB-AnCZ.js +0 -1
- package/dist/mg-components/p-PuX-pdL4.js +0 -1
- package/dist/types/components/molecules/inputs/mg-input/mg-input.utils.d.ts +0 -8
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host, a as getElement, c as createEvent } from './index-
|
|
2
|
-
import { h as createID, t as toString, C as ClassList, c as isValidString, n as nextTick, j as isValideID, k as isTagName,
|
|
3
|
-
import { i as initLocales, l as localeDate, a as localeDatePattern, b as localeNumber, c as localeUnit, d as localePercent, e as localeCurrency } from './index-
|
|
4
|
-
import { K as Keys
|
|
5
|
-
import { t as tooltipPositions, b as classFieldset, c as classReadonly, a as classDisabled, d as classVerticalList, w as widths } from './mg-input.conf-
|
|
1
|
+
import { r as registerInstance, h, H as Host, a as getElement, c as createEvent } from './index-JHj_9FSs.js';
|
|
2
|
+
import { h as createID, t as toString, C as ClassList, c as isValidString, n as nextTick, j as isValideID, k as isTagName, l as cleanString, f as formatID, m as dateRegExp, o as dateToString, b as allItemsAreString, p as getWindows, q as focusableElements } from './index-WtiuOkLj.js';
|
|
3
|
+
import { i as initLocales, l as localeDate, a as localeDatePattern, b as localeNumber, c as localeUnit, d as localePercent, e as localeCurrency } from './index-Bab8_u8S.js';
|
|
4
|
+
import { K as Keys } from './events.utils-yMGqY8YG.js';
|
|
5
|
+
import { t as tooltipPositions, b as classFieldset, c as classReadonly, a as classDisabled, d as classVerticalList, w as widths } from './mg-input.conf-CNgv8hc5.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Available menu item status values
|
|
@@ -1192,16 +1192,13 @@ const MgIllustratedMessage = class {
|
|
|
1192
1192
|
};
|
|
1193
1193
|
MgIllustratedMessage.style = mgIllustratedMessageCss;
|
|
1194
1194
|
|
|
1195
|
-
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{
|
|
1195
|
+
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}}";
|
|
1196
1196
|
|
|
1197
|
-
const isValidErrorMessageType = (msg) => isObject(msg) && ['summary', 'details'].every(key => typeof msg[key] === 'string');
|
|
1198
1197
|
const MgInput = class {
|
|
1199
1198
|
constructor(hostRef) {
|
|
1200
1199
|
registerInstance(this, hostRef);
|
|
1201
1200
|
this.slotLabel = 'label';
|
|
1202
1201
|
this.slotError = 'error';
|
|
1203
|
-
this.slotSummary = 'summary';
|
|
1204
|
-
this.slotDetails = 'details';
|
|
1205
1202
|
this.slotHelpText = 'help-text';
|
|
1206
1203
|
// style
|
|
1207
1204
|
this.classInput = 'mg-c-input';
|
|
@@ -1243,44 +1240,6 @@ const MgInput = class {
|
|
|
1243
1240
|
* Element is disabled
|
|
1244
1241
|
*/
|
|
1245
1242
|
this.isVerticalList = false;
|
|
1246
|
-
/**
|
|
1247
|
-
* Render error message details element
|
|
1248
|
-
*/
|
|
1249
|
-
this.renderErrorDetailsMessage = (message) => {
|
|
1250
|
-
var _a, _b;
|
|
1251
|
-
// remove error slot if it is NOT a MG-DETAIL
|
|
1252
|
-
if (((_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.nodeName) !== 'MG-DETAILS') {
|
|
1253
|
-
(_b = this.errorMessageSlotElement) === null || _b === void 0 ? void 0 : _b.remove();
|
|
1254
|
-
}
|
|
1255
|
-
// create OR update error summary
|
|
1256
|
-
let summarySlotElement = this.element.querySelector(`[slot=${this.slotError}] [slot=${this.slotSummary}]`);
|
|
1257
|
-
if (summarySlotElement === null) {
|
|
1258
|
-
summarySlotElement = document.createElement('span');
|
|
1259
|
-
summarySlotElement.setAttribute('slot', this.slotSummary);
|
|
1260
|
-
}
|
|
1261
|
-
summarySlotElement.innerHTML = message.summary;
|
|
1262
|
-
// create OR update error details
|
|
1263
|
-
let detailsSlotElement = this.element.querySelector(`[slot=${this.slotError}] [slot=${this.slotDetails}]`);
|
|
1264
|
-
if (detailsSlotElement === null) {
|
|
1265
|
-
detailsSlotElement = document.createElement('p');
|
|
1266
|
-
detailsSlotElement.setAttribute('slot', this.slotDetails);
|
|
1267
|
-
detailsSlotElement.classList.add('mg-c-input__error-details');
|
|
1268
|
-
}
|
|
1269
|
-
detailsSlotElement.innerHTML = message.details;
|
|
1270
|
-
// create error mg-details
|
|
1271
|
-
let mgDetails = this.element.querySelector(`mg-details[slot=${this.slotError}]`);
|
|
1272
|
-
if (mgDetails === null) {
|
|
1273
|
-
mgDetails = document.createElement('mg-details');
|
|
1274
|
-
mgDetails.classList.add('mg-c-input__error');
|
|
1275
|
-
mgDetails.toggleClosed = this.messages.details.toggleClosed;
|
|
1276
|
-
mgDetails.toggleOpened = this.messages.details.toggleOpened;
|
|
1277
|
-
mgDetails.hideSummary = true;
|
|
1278
|
-
mgDetails.appendChild(summarySlotElement);
|
|
1279
|
-
mgDetails.appendChild(detailsSlotElement);
|
|
1280
|
-
this.element.appendChild(mgDetails);
|
|
1281
|
-
}
|
|
1282
|
-
this.errorMessageSlotElement = mgDetails;
|
|
1283
|
-
};
|
|
1284
1243
|
/**
|
|
1285
1244
|
* Get tooltip node
|
|
1286
1245
|
* @returns mg-tooltip
|
|
@@ -1318,14 +1277,16 @@ const MgInput = class {
|
|
|
1318
1277
|
}
|
|
1319
1278
|
}
|
|
1320
1279
|
watchErrorMessage(newValue) {
|
|
1321
|
-
|
|
1280
|
+
var _a;
|
|
1281
|
+
if (newValue !== undefined) {
|
|
1322
1282
|
this.element.classList.add(this.classHasError);
|
|
1283
|
+
this.renderErrorMessage();
|
|
1323
1284
|
}
|
|
1324
1285
|
else {
|
|
1325
1286
|
this.element.classList.remove(this.classHasError);
|
|
1287
|
+
(_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.remove();
|
|
1288
|
+
this.errorMessageSlotElement = undefined;
|
|
1326
1289
|
}
|
|
1327
|
-
// update error message slot
|
|
1328
|
-
this.renderErrorMessageSlot();
|
|
1329
1290
|
}
|
|
1330
1291
|
watchHelpText(newValue) {
|
|
1331
1292
|
var _a;
|
|
@@ -1354,12 +1315,14 @@ const MgInput = class {
|
|
|
1354
1315
|
// Help text
|
|
1355
1316
|
if (this.helpText !== undefined) {
|
|
1356
1317
|
this.renderHelpText();
|
|
1357
|
-
ariaDescribedbyIDs.
|
|
1318
|
+
if (!ariaDescribedbyIDs.has(this.helpTextId))
|
|
1319
|
+
ariaDescribedbyIDs.add(this.helpTextId);
|
|
1358
1320
|
}
|
|
1359
1321
|
// Error Message
|
|
1360
1322
|
if (this.errorMessage !== undefined) {
|
|
1361
|
-
this.
|
|
1362
|
-
ariaDescribedbyIDs.
|
|
1323
|
+
this.renderErrorMessage();
|
|
1324
|
+
if (!ariaDescribedbyIDs.has(this.helpTextErrorId))
|
|
1325
|
+
ariaDescribedbyIDs.add(this.helpTextErrorId);
|
|
1363
1326
|
}
|
|
1364
1327
|
this.element.querySelectorAll('input,select,textarea,[role="switch"]').forEach(element => {
|
|
1365
1328
|
if (ariaDescribedbyIDs.size > 0) {
|
|
@@ -1425,41 +1388,17 @@ const MgInput = class {
|
|
|
1425
1388
|
this.element.appendChild(labelSlotElement);
|
|
1426
1389
|
}
|
|
1427
1390
|
/**
|
|
1428
|
-
* Render error message
|
|
1391
|
+
* Render error message
|
|
1429
1392
|
*/
|
|
1430
|
-
|
|
1431
|
-
var _a;
|
|
1432
|
-
// remove error slot if it is a MG-DETAIL
|
|
1433
|
-
if (((_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.nodeName) === 'MG-DETAILS') {
|
|
1434
|
-
this.errorMessageSlotElement.remove();
|
|
1435
|
-
}
|
|
1436
|
-
// create element if it does NOT exist
|
|
1437
|
-
else if (this.errorMessageSlotElement === null) {
|
|
1438
|
-
this.errorMessageSlotElement = document.createElement('div');
|
|
1439
|
-
this.element.appendChild(this.errorMessageSlotElement);
|
|
1440
|
-
}
|
|
1441
|
-
this.errorMessageSlotElement.innerHTML = message;
|
|
1442
|
-
}
|
|
1443
|
-
/**
|
|
1444
|
-
* Render error message slot element
|
|
1445
|
-
*/
|
|
1446
|
-
renderErrorMessageSlot() {
|
|
1447
|
-
var _a;
|
|
1393
|
+
renderErrorMessage() {
|
|
1448
1394
|
this.errorMessageSlotElement = this.element.querySelector(`[slot=${this.slotError}]`);
|
|
1449
|
-
if (this.
|
|
1450
|
-
|
|
1451
|
-
this.renderErrorStringMessage(this.errorMessage);
|
|
1452
|
-
}
|
|
1453
|
-
else {
|
|
1454
|
-
this.renderErrorDetailsMessage(this.errorMessage);
|
|
1455
|
-
}
|
|
1395
|
+
if (this.errorMessageSlotElement === null) {
|
|
1396
|
+
this.errorMessageSlotElement = document.createElement('div');
|
|
1456
1397
|
this.errorMessageSlotElement.setAttribute('slot', this.slotError);
|
|
1457
|
-
this.
|
|
1458
|
-
}
|
|
1459
|
-
else {
|
|
1460
|
-
(_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.remove();
|
|
1461
|
-
this.errorMessageSlotElement = undefined;
|
|
1398
|
+
this.element.appendChild(this.errorMessageSlotElement);
|
|
1462
1399
|
}
|
|
1400
|
+
this.errorMessageSlotElement.setAttribute('id', this.helpTextErrorId);
|
|
1401
|
+
this.errorMessageSlotElement.innerHTML = this.errorMessage;
|
|
1463
1402
|
}
|
|
1464
1403
|
/**
|
|
1465
1404
|
* Render help text message
|
|
@@ -1481,9 +1420,6 @@ const MgInput = class {
|
|
|
1481
1420
|
* Check if component props are well configured on init
|
|
1482
1421
|
*/
|
|
1483
1422
|
componentWillLoad() {
|
|
1484
|
-
// Get locales
|
|
1485
|
-
this.messages = initLocales(this.element).messages;
|
|
1486
|
-
// Validate
|
|
1487
1423
|
this.watchIdentifier(this.identifier);
|
|
1488
1424
|
this.watchLabel();
|
|
1489
1425
|
this.watchClass();
|
|
@@ -1508,7 +1444,7 @@ const MgInput = class {
|
|
|
1508
1444
|
*/
|
|
1509
1445
|
render() {
|
|
1510
1446
|
const isGroup = this.isFieldset && !this.isReadonly;
|
|
1511
|
-
return (h(Host, { key: '
|
|
1447
|
+
return (h(Host, { key: '7c4c22aaa8f8d250eafa9159a103a11e637b0cca', class: this.element.classList.toString(), role: isGroup ? 'group' : undefined, "aria-labelledby": isGroup ? `${this.identifier}-title` : undefined }, h("div", { key: '2215e7b2d96e08507579a39d8e05b3e8a3d901fb', class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': this.labelHide } }, h("slot", { key: 'a4dbf4e36dd3ae5437d6dcb05d807f4faa0924b7', name: this.slotLabel }), this.tooltip && (this.tooltipPosition === 'label' || this.labelOnTop) && !this.labelHide && this.renderTooltip()), h("div", { key: '8e382a4857f469a9d6f77cad613183798df4d1e1', class: "mg-c-input__input-container" }, h("div", { key: 'f9897f90d44aab19614d4d40d77a8eb270c92847', class: "mg-c-input__input" }, h("slot", { key: 'c8d809d4ff0d0e660849825f016f9267da3a2d7e' }), this.tooltip && !this.labelOnTop && (this.tooltipPosition === 'input' || this.labelHide) && this.renderTooltip()), this.helptextMessageSlotElement && (h("div", { key: 'cebd6c083d088aebcdae6f032c6cdcf2387c3e27', class: "mg-c-input__help-text" }, h("slot", { key: '923fcc78b309d197e32522052b297ef0f58b1495', name: this.slotHelpText }))), !this.isDisabled && this.errorMessage && (h("div", { key: 'e706bff54ce21191a8c0940c60f6e99a91cfb9ec', class: "mg-c-input__error", "aria-live": "assertive" }, h("slot", { key: '6524debd3640df7b5e73ef4aa4415569eef1ecd8', name: this.slotError }))))));
|
|
1512
1448
|
}
|
|
1513
1449
|
get element() { return getElement(this); }
|
|
1514
1450
|
static get watchers() { return {
|
|
@@ -1545,8 +1481,7 @@ const SectionKind = {
|
|
|
1545
1481
|
* @param props - MgInputCheckboxList Interface Props
|
|
1546
1482
|
* @returns input template
|
|
1547
1483
|
*/
|
|
1548
|
-
const MgInputCheckboxList = (props) =>
|
|
1549
|
-
props.checkboxes.length > 0 && (h("ul", { class: "mg-c-input__input-group-container", role: "list", "aria-labelledby": props.labelledby, id: props.id }, props.checkboxes.map(input => {
|
|
1484
|
+
const MgInputCheckboxList = (props) => (h("ul", { class: "mg-c-input__input-group-container", role: "list", "aria-labelledby": props.labelledby, id: props.id }, props.checkboxes.map(input => {
|
|
1550
1485
|
var _a, _b;
|
|
1551
1486
|
return (h("li", { key: input._id, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': props.disabled || input.disabled } },
|
|
1552
1487
|
h("input", { type: "checkbox", id: input._id, name: props.name, value: (_a = input.value) === null || _a === void 0 ? void 0 : _a.toString(), checked: Boolean(input.value), required: input.required, "aria-invalid": ((_b = props.invalid) === null || _b === void 0 ? void 0 : _b.toString()) || 'false', disabled: props.disabled || input.disabled, indeterminate: input.value === null, onInput: input._handleInput, onBlur: input._handleBlur, onKeyDown: input._handleKeydown }),
|
|
@@ -1567,7 +1502,7 @@ const Status = {
|
|
|
1567
1502
|
*/
|
|
1568
1503
|
const sizes$1 = ['medium', 'large'];
|
|
1569
1504
|
|
|
1570
|
-
const mgInputCheckboxCss = ".mg-c-
|
|
1505
|
+
const mgInputCheckboxCss = ".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.mg-c-input--fieldset{padding:0;border:0;margin-right:0;margin-left:0}.mg-c-input.mg-c-input--fieldset input[type=radio],.mg-c-input.mg-c-input--fieldset input[type=checkbox]{width:var(--mg-c-input-check-size);height:var(--mg-c-input-check-size);flex-shrink:0;margin:calc((var(--mg-b-font-size)*var(--mg-b-line-height) - var(--mg-c-input-check-size))/2) var(--mg-b-size-8) 0 0}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group{display:flex;align-items:start}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group-container{display:flex;flex-wrap:wrap;padding:0;margin:0;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);gap:var(--mg-b-size-12) var(--mg-b-size-24);list-style:none}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group.mg-c-input__input-group--disabled label{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--fieldset.mg-c-input--vertical-list .mg-c-input__input-group-container,.mg-c-input.mg-c-input--fieldset.mg-c-input--checkbox-multi .mg-c-input__input-group-container{flex-direction:column}.mg-c-input.mg-c-input--fieldset.mg-c-input--label-on-top .mg-c-input__input-group-container{margin-top:var(--mg-b-size-8)}.mg-c-input__popover-info{padding:var(--mg-b-size-8);margin:0;color:var(--mg-b-color-neutral-90);text-align:center}.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.mg-c-input--checkbox-multi .mg-c-input__input-group-container{padding:var(--mg-b-size-4) var(--mg-b-size-8);margin:0}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-container{display:flex;width:unset;flex:unset;flex-wrap:wrap;column-gap:var(--mg-b-size-8)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-container-list{display:flex;flex-flow:row wrap;padding:0;margin:0;gap:var(--mg-b-size-4);list-style:none}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__tab{display:block;min-height:calc(var(--mg-b-size-4)*55)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__tabs{min-height:0;flex-shrink:1}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__tabs-action{padding-top:var(--mg-b-size-16);padding-bottom:var(--mg-b-size-12)}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__tabs-content{height:calc(24*var(--mg-b-size-8) - 2*var(--mg-b-size-8));overflow-y:auto}.mg-c-input.mg-c-input--checkbox-multi .mg-c-input__input-value{display:inline-flex;min-width:var(--mg-b-size-min-height);min-height:var(--mg-b-size-min-height);box-sizing:border-box;align-items:center;justify-content:center;padding:calc((var(--mg-b-size-min-height) - 2*var(--mg-b-size-border) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-12);border-radius:var(--mg-b-size-4);background-color:var(--mg-b-color-neutral-20);font-size:var(--mg-b-font-size)}.mg-c-input.mg-c-input--checkbox-multi b{margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2)}.mg-c-input.mg-c-input--checkbox-multi.mg-c-input--disabled .mg-c-input__input-container b{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--checkbox-multi.mg-c-input--with-values .mg-c-input__input-container{gap:var(--mg-b-size-4)}.mg-c-input.mg-c-input--checkbox-multi.mg-c-input--search-mode .mg-c-input__content{display:flex;width:calc(var(--mg-b-size-floating-element-max-width) - var(--mg-b-size-16));flex-direction:column;gap:var(--mg-b-size-4)}.mg-c-input.mg-c-input--checkbox-multi.mg-c-input--search-mode .mg-c-input__content .mg-c-input__tabs-content{min-height:calc(var(--mg-b-size-4)*55)}.mg-c-input.mg-c-input--checkbox-multi:not(.mg-c-input--label-on-top) mg-tooltip:not(.mg-c-input__section-header-tootlip){margin-left:var(--mg-b-size-8)}.mg-c-input.mg-c-input--checkbox-multi mg-popover{--mg-c-card-spacing:var(--mg-b-size-8)}.mg-c-input.mg-c-input--readonly ul{display:flex;min-height:var(--mg-b-font-size);flex-flow:column wrap;padding:0;margin:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) 0 0;list-style:none;row-gap:var(--mg-b-size-8)}";
|
|
1571
1506
|
|
|
1572
1507
|
/**
|
|
1573
1508
|
* type CheckboxItem validation function
|
|
@@ -1764,18 +1699,8 @@ const MgInputCheckbox = class {
|
|
|
1764
1699
|
* Check if input is valid
|
|
1765
1700
|
*/
|
|
1766
1701
|
this.checkValidity = () => {
|
|
1767
|
-
this.setValidity(this.readonly || this.disabled || (
|
|
1702
|
+
this.setValidity(this.readonly || this.disabled || (!this.hasInvalidInput() && this.validateRequired()));
|
|
1768
1703
|
};
|
|
1769
|
-
/**
|
|
1770
|
-
* Test if component has items
|
|
1771
|
-
* @returns truthy if component has items
|
|
1772
|
-
*/
|
|
1773
|
-
this.hasInputValue = () => { var _a; return ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) > 0; };
|
|
1774
|
-
/**
|
|
1775
|
-
* Test if component has no value error message displayed
|
|
1776
|
-
* @returns truthy if compent display no value error message
|
|
1777
|
-
*/
|
|
1778
|
-
this.hasNoValueErrorMessageDisplay = () => this.errorMessage === this.messages.errors.noValue;
|
|
1779
1704
|
/**
|
|
1780
1705
|
* Set button text locale key
|
|
1781
1706
|
*/
|
|
@@ -1817,25 +1742,12 @@ const MgInputCheckbox = class {
|
|
|
1817
1742
|
// Set error message
|
|
1818
1743
|
this.errorMessage = undefined;
|
|
1819
1744
|
if (displayError && !this.valid) {
|
|
1820
|
-
if (errorMessage !== undefined)
|
|
1745
|
+
if (errorMessage !== undefined)
|
|
1821
1746
|
this.errorMessage = errorMessage;
|
|
1822
|
-
|
|
1823
|
-
else if (!this.hasInputValue()) {
|
|
1824
|
-
this.errorMessage = this.messages.errors.noValue;
|
|
1825
|
-
}
|
|
1826
|
-
else if (!this.validateRequired()) {
|
|
1747
|
+
else if (!this.validateRequired())
|
|
1827
1748
|
this.errorMessage = this.messages.errors.required;
|
|
1828
|
-
}
|
|
1829
1749
|
}
|
|
1830
1750
|
};
|
|
1831
|
-
/**
|
|
1832
|
-
* Reset error message
|
|
1833
|
-
*/
|
|
1834
|
-
this.resetErrorMessage = () => {
|
|
1835
|
-
this.checkValidity();
|
|
1836
|
-
this.errorMessage = undefined;
|
|
1837
|
-
this.hasDisplayedError = false;
|
|
1838
|
-
};
|
|
1839
1751
|
/**
|
|
1840
1752
|
* Method to get mg-popover identifier
|
|
1841
1753
|
* @returns MgPopover identifier
|
|
@@ -1864,14 +1776,7 @@ const MgInputCheckbox = class {
|
|
|
1864
1776
|
* @returns The rendered readonly value.
|
|
1865
1777
|
*/
|
|
1866
1778
|
this.renderReadonly = (readonlyValue) => {
|
|
1867
|
-
|
|
1868
|
-
if (this.inputVerticalList) {
|
|
1869
|
-
return (h("ul", { class: "mg-c-input__readonly-value" }, readonlyValue.map(value => (h("li", { key: value }, h("b", null, value))))));
|
|
1870
|
-
}
|
|
1871
|
-
else {
|
|
1872
|
-
return h("b", { class: "mg-c-input__readonly-value" }, readonlyValue.join(', '));
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1779
|
+
return this.inputVerticalList ? (h("ul", { class: "mg-c-input__readonly-value" }, readonlyValue.map(value => (h("li", { key: value }, h("b", null, value)))))) : (h("b", { class: "mg-c-input__readonly-value" }, readonlyValue.join(', ')));
|
|
1875
1780
|
};
|
|
1876
1781
|
/**
|
|
1877
1782
|
* Renders the MgInputCheckboxList component.
|
|
@@ -1880,16 +1785,9 @@ const MgInputCheckbox = class {
|
|
|
1880
1785
|
this.renderMgInputCheckboxList = () => (h(MgInputCheckboxList, { checkboxes: this.checkboxItems, id: this.checkboxesId, disabled: this.disabled, name: this.name, invalid: this.invalid }));
|
|
1881
1786
|
}
|
|
1882
1787
|
validateValue(newValue) {
|
|
1883
|
-
if (
|
|
1884
|
-
this.displayError();
|
|
1885
|
-
}
|
|
1886
|
-
else if (newValue.length > 0 && isCheckboxItems(newValue)) {
|
|
1788
|
+
if (isCheckboxItems(newValue)) {
|
|
1887
1789
|
this.checkboxItems = newValue.map((item, index) => (Object.assign(Object.assign({}, item), { _id: `${this.identifier}_${index}`, _handleInput: this.handleInput.bind(this), _handleBlur: this.handleBlur.bind(this), _handleKeydown: this.handleKeydown.bind(this) })));
|
|
1888
1790
|
this.valueChange.emit(newValue);
|
|
1889
|
-
// force to reset error when noValueError is displaied
|
|
1890
|
-
if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
|
|
1891
|
-
this.resetErrorMessage();
|
|
1892
|
-
}
|
|
1893
1791
|
}
|
|
1894
1792
|
else {
|
|
1895
1793
|
throw new Error(`<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem. Passed value: ${toString(newValue)}.`);
|
|
@@ -2033,7 +1931,9 @@ const MgInputCheckbox = class {
|
|
|
2033
1931
|
// - Keep everything in sync both inside and outside the component
|
|
2034
1932
|
return new Promise(resolve => {
|
|
2035
1933
|
requestAnimationFrame(() => {
|
|
2036
|
-
this.
|
|
1934
|
+
this.checkValidity();
|
|
1935
|
+
this.errorMessage = undefined;
|
|
1936
|
+
this.hasDisplayedError = false;
|
|
2037
1937
|
resolve();
|
|
2038
1938
|
});
|
|
2039
1939
|
});
|
|
@@ -2156,9 +2056,8 @@ const MgInputCheckbox = class {
|
|
|
2156
2056
|
* @returns HTML Element
|
|
2157
2057
|
*/
|
|
2158
2058
|
render() {
|
|
2159
|
-
var _a;
|
|
2160
2059
|
let inputContent;
|
|
2161
|
-
const readonlyValue =
|
|
2060
|
+
const readonlyValue = this.value.filter(({ value }) => value).map(({ title }) => title);
|
|
2162
2061
|
if (this.readonly) {
|
|
2163
2062
|
inputContent = this.renderReadonly(readonlyValue);
|
|
2164
2063
|
}
|
|
@@ -2168,7 +2067,7 @@ const MgInputCheckbox = class {
|
|
|
2168
2067
|
else {
|
|
2169
2068
|
inputContent = this.renderCheckboxMulti();
|
|
2170
2069
|
}
|
|
2171
|
-
return (h("mg-input", { key: '
|
|
2070
|
+
return (h("mg-input", { key: '84d13ac702497773013daa72357e4d1dcf4ebb30', 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));
|
|
2172
2071
|
}
|
|
2173
2072
|
get element() { return getElement(this); }
|
|
2174
2073
|
static get watchers() { return {
|
|
@@ -3397,7 +3296,7 @@ const MgInputPassword = class {
|
|
|
3397
3296
|
};
|
|
3398
3297
|
MgInputPassword.style = mgInputPasswordCss;
|
|
3399
3298
|
|
|
3400
|
-
const mgInputRadioCss = ".mg-c-
|
|
3299
|
+
const mgInputRadioCss = ".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.mg-c-input--fieldset{padding:0;border:0;margin-right:0;margin-left:0}.mg-c-input.mg-c-input--fieldset input[type=radio],.mg-c-input.mg-c-input--fieldset input[type=checkbox]{width:var(--mg-c-input-check-size);height:var(--mg-c-input-check-size);flex-shrink:0;margin:calc((var(--mg-b-font-size)*var(--mg-b-line-height) - var(--mg-c-input-check-size))/2) var(--mg-b-size-8) 0 0}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group{display:flex;align-items:start}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group-container{display:flex;flex-wrap:wrap;padding:0;margin:0;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);gap:var(--mg-b-size-12) var(--mg-b-size-24);list-style:none}.mg-c-input.mg-c-input--fieldset .mg-c-input__input-group.mg-c-input__input-group--disabled label{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--fieldset.mg-c-input--vertical-list .mg-c-input__input-group-container,.mg-c-input.mg-c-input--fieldset.mg-c-input--checkbox-multi .mg-c-input__input-group-container{flex-direction:column}.mg-c-input.mg-c-input--fieldset.mg-c-input--label-on-top .mg-c-input__input-group-container{margin-top:var(--mg-b-size-8)}.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}";
|
|
3401
3300
|
|
|
3402
3301
|
/**
|
|
3403
3302
|
* type Option validation function
|
|
@@ -3474,21 +3373,11 @@ const MgInputRadio = class {
|
|
|
3474
3373
|
// reset guard
|
|
3475
3374
|
this.handlerInProgress = undefined;
|
|
3476
3375
|
};
|
|
3477
|
-
/**
|
|
3478
|
-
* Test if component has items
|
|
3479
|
-
* @returns truthy if component has items
|
|
3480
|
-
*/
|
|
3481
|
-
this.hasInputValue = () => { var _a; return ((_a = this.items) === null || _a === void 0 ? void 0 : _a.length) > 0; };
|
|
3482
|
-
/**
|
|
3483
|
-
* Test if component has no value error message displayed
|
|
3484
|
-
* @returns truthy if compent display no value error message
|
|
3485
|
-
*/
|
|
3486
|
-
this.hasNoValueErrorMessageDisplay = () => this.errorMessage === this.messages.errors.noValue;
|
|
3487
3376
|
/**
|
|
3488
3377
|
* Check if input is valid
|
|
3489
3378
|
*/
|
|
3490
3379
|
this.checkValidity = () => {
|
|
3491
|
-
this.setValidity(this.readonly || this.disabled ||
|
|
3380
|
+
this.setValidity(this.readonly || this.disabled || this.getInvalidElement() === undefined);
|
|
3492
3381
|
};
|
|
3493
3382
|
/**
|
|
3494
3383
|
* Set input error message
|
|
@@ -3502,22 +3391,11 @@ const MgInputRadio = class {
|
|
|
3502
3391
|
if (errorMessage !== undefined) {
|
|
3503
3392
|
this.errorMessage = errorMessage;
|
|
3504
3393
|
}
|
|
3505
|
-
else if (!this.hasInputValue()) {
|
|
3506
|
-
this.errorMessage = this.messages.errors.noValue;
|
|
3507
|
-
}
|
|
3508
3394
|
else if (invalidElement.validity.valueMissing) {
|
|
3509
3395
|
this.errorMessage = this.messages.errors.required;
|
|
3510
3396
|
}
|
|
3511
3397
|
}
|
|
3512
3398
|
};
|
|
3513
|
-
/**
|
|
3514
|
-
* Reset error message
|
|
3515
|
-
*/
|
|
3516
|
-
this.resetErrorMessage = () => {
|
|
3517
|
-
this.checkValidity();
|
|
3518
|
-
this.errorMessage = undefined;
|
|
3519
|
-
this.hasDisplayedError = false;
|
|
3520
|
-
};
|
|
3521
3399
|
/**
|
|
3522
3400
|
* get invalid element
|
|
3523
3401
|
* @returns element
|
|
@@ -3539,29 +3417,17 @@ const MgInputRadio = class {
|
|
|
3539
3417
|
this.valueChange.emit(newValue);
|
|
3540
3418
|
}
|
|
3541
3419
|
validateItems(newValue) {
|
|
3542
|
-
if ([undefined, null].includes(newValue) || (Array.isArray(newValue) && newValue.length === 0)) {
|
|
3543
|
-
this.options = [];
|
|
3544
|
-
this.displayError();
|
|
3545
|
-
}
|
|
3546
3420
|
// Validate if items have required min length
|
|
3547
|
-
|
|
3421
|
+
if (typeof newValue === 'object' && newValue.length < 2) {
|
|
3548
3422
|
throw new Error(`<mg-input-radio> prop "items" require at least 2 items. Passed value: ${toString(newValue)}.`);
|
|
3549
3423
|
}
|
|
3550
3424
|
// String array
|
|
3551
3425
|
else if (allItemsAreString(newValue)) {
|
|
3552
3426
|
this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
|
|
3553
|
-
// force to reset error when noValueError is displaied
|
|
3554
|
-
if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
|
|
3555
|
-
this.resetErrorMessage();
|
|
3556
|
-
}
|
|
3557
3427
|
}
|
|
3558
3428
|
// Object array
|
|
3559
|
-
else if (
|
|
3429
|
+
else if (newValue && newValue.every(item => isOption$3(item))) {
|
|
3560
3430
|
this.options = newValue;
|
|
3561
|
-
// force to reset error when noValueError is displaied
|
|
3562
|
-
if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
|
|
3563
|
-
this.resetErrorMessage();
|
|
3564
|
-
}
|
|
3565
3431
|
}
|
|
3566
3432
|
else {
|
|
3567
3433
|
throw new Error(`<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption. Passed value: ${toString(newValue)}.`);
|
|
@@ -3657,7 +3523,9 @@ const MgInputRadio = class {
|
|
|
3657
3523
|
// - Keep everything in sync both inside and outside the component
|
|
3658
3524
|
return new Promise(resolve => {
|
|
3659
3525
|
requestAnimationFrame(() => {
|
|
3660
|
-
this.
|
|
3526
|
+
this.checkValidity();
|
|
3527
|
+
this.errorMessage = undefined;
|
|
3528
|
+
this.hasDisplayedError = false;
|
|
3661
3529
|
resolve();
|
|
3662
3530
|
});
|
|
3663
3531
|
});
|
|
@@ -3703,12 +3571,10 @@ const MgInputRadio = class {
|
|
|
3703
3571
|
* @returns HTML Element
|
|
3704
3572
|
*/
|
|
3705
3573
|
render() {
|
|
3706
|
-
return (h("mg-input", { key: '
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
this.inputs[index] = el;
|
|
3711
|
-
} }), h("label", { htmlFor: this.identifier + '_' + index }, input.title))))))));
|
|
3574
|
+
return (h("mg-input", { key: '048aa732e7f8593701c9397e571b97584bc5e37b', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && !this.value ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (this.readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, this.readonlyValue)) : (h("ul", { class: "mg-c-input__input-group-container", role: "list" }, this.options.map((input, index) => (h("li", { key: input.title, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "radio", id: this.identifier + '_' + index, name: this.identifier, value: index, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: (el) => {
|
|
3575
|
+
if (el !== null)
|
|
3576
|
+
this.inputs[index] = el;
|
|
3577
|
+
} }), h("label", { htmlFor: this.identifier + '_' + index }, input.title))))))));
|
|
3712
3578
|
}
|
|
3713
3579
|
get element() { return getElement(this); }
|
|
3714
3580
|
static get watchers() { return {
|
|
@@ -3722,7 +3588,7 @@ const MgInputRadio = class {
|
|
|
3722
3588
|
};
|
|
3723
3589
|
MgInputRadio.style = mgInputRadioCss;
|
|
3724
3590
|
|
|
3725
|
-
const mgInputSelectCss = ".mg-c-
|
|
3591
|
+
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%}}";
|
|
3726
3592
|
|
|
3727
3593
|
/**
|
|
3728
3594
|
* Check if item is a well configured option
|
|
@@ -3858,16 +3724,6 @@ const MgInputSelect = class {
|
|
|
3858
3724
|
* @returns truthy if input.value is an item
|
|
3859
3725
|
*/
|
|
3860
3726
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
3861
|
-
/**
|
|
3862
|
-
* Test if component has items
|
|
3863
|
-
* @returns truthy if component has items
|
|
3864
|
-
*/
|
|
3865
|
-
this.hasInputValue = () => { var _a; return ((_a = this.items) === null || _a === void 0 ? void 0 : _a.length) > 0; };
|
|
3866
|
-
/**
|
|
3867
|
-
* Test if component has no value error message displayed
|
|
3868
|
-
* @returns truthy if compent display no value error message
|
|
3869
|
-
*/
|
|
3870
|
-
this.hasNoValueErrorMessageDisplay = () => this.errorMessage === this.messages.errors.noValue;
|
|
3871
3727
|
/**
|
|
3872
3728
|
* Handle blur event
|
|
3873
3729
|
*/
|
|
@@ -3887,7 +3743,7 @@ const MgInputSelect = class {
|
|
|
3887
3743
|
* Check if input is valid
|
|
3888
3744
|
*/
|
|
3889
3745
|
this.checkValidity = () => {
|
|
3890
|
-
this.setValidity(!this.isDisabledValue() && (this.readonly || this.disabled ||
|
|
3746
|
+
this.setValidity(!this.isDisabledValue() && (this.readonly || this.disabled || this.input.checkValidity()));
|
|
3891
3747
|
};
|
|
3892
3748
|
/**
|
|
3893
3749
|
* Set input error message
|
|
@@ -3900,22 +3756,11 @@ const MgInputSelect = class {
|
|
|
3900
3756
|
if (errorMessage !== undefined) {
|
|
3901
3757
|
this.errorMessage = errorMessage;
|
|
3902
3758
|
}
|
|
3903
|
-
else if (!this.hasInputValue()) {
|
|
3904
|
-
this.errorMessage = this.messages.errors.noValue;
|
|
3905
|
-
}
|
|
3906
3759
|
else if (this.input.validity.valueMissing) {
|
|
3907
3760
|
this.errorMessage = this.messages.errors.required;
|
|
3908
3761
|
}
|
|
3909
3762
|
}
|
|
3910
3763
|
};
|
|
3911
|
-
/**
|
|
3912
|
-
* Reset error message
|
|
3913
|
-
*/
|
|
3914
|
-
this.resetErrorMessage = () => {
|
|
3915
|
-
this.checkValidity();
|
|
3916
|
-
this.errorMessage = undefined;
|
|
3917
|
-
this.hasDisplayedError = false;
|
|
3918
|
-
};
|
|
3919
3764
|
/**
|
|
3920
3765
|
* Render option
|
|
3921
3766
|
* @param option - to render
|
|
@@ -3933,11 +3778,9 @@ const MgInputSelect = class {
|
|
|
3933
3778
|
this.valueChange.emit(newValue);
|
|
3934
3779
|
}
|
|
3935
3780
|
validateItems(newValue) {
|
|
3936
|
-
let resetMessage = false;
|
|
3937
3781
|
// Empty options
|
|
3938
|
-
if (
|
|
3782
|
+
if (newValue.length === 0) {
|
|
3939
3783
|
this.options = [];
|
|
3940
|
-
this.displayError();
|
|
3941
3784
|
}
|
|
3942
3785
|
// String array
|
|
3943
3786
|
else if (allItemsAreString(newValue)) {
|
|
@@ -3945,8 +3788,6 @@ const MgInputSelect = class {
|
|
|
3945
3788
|
this.valueExist = newValue.includes(this.value);
|
|
3946
3789
|
}
|
|
3947
3790
|
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
3948
|
-
// force to reset error when noValueError is displaied
|
|
3949
|
-
resetMessage = this.invalid && this.hasNoValueErrorMessageDisplay();
|
|
3950
3791
|
}
|
|
3951
3792
|
// Object array
|
|
3952
3793
|
else if (allItemsAreOptions(newValue)) {
|
|
@@ -3959,15 +3800,10 @@ const MgInputSelect = class {
|
|
|
3959
3800
|
else {
|
|
3960
3801
|
this.options = newValue;
|
|
3961
3802
|
}
|
|
3962
|
-
// force to reset error when noValueError is displaied
|
|
3963
|
-
resetMessage = this.invalid && this.hasNoValueErrorMessageDisplay();
|
|
3964
3803
|
}
|
|
3965
3804
|
else {
|
|
3966
3805
|
throw new Error(`<mg-input-select> prop "items" is required, can be an empty Array or all items must be the same type: string or Option. Passed value: ${toString(newValue)}.`);
|
|
3967
3806
|
}
|
|
3968
|
-
if (resetMessage) {
|
|
3969
|
-
this.resetErrorMessage();
|
|
3970
|
-
}
|
|
3971
3807
|
}
|
|
3972
3808
|
watchReadonly(newValue) {
|
|
3973
3809
|
if (newValue)
|
|
@@ -4061,7 +3897,9 @@ const MgInputSelect = class {
|
|
|
4061
3897
|
// - Keep everything in sync both inside and outside the component
|
|
4062
3898
|
return new Promise(resolve => {
|
|
4063
3899
|
requestAnimationFrame(() => {
|
|
4064
|
-
this.
|
|
3900
|
+
this.checkValidity();
|
|
3901
|
+
this.errorMessage = undefined;
|
|
3902
|
+
this.hasDisplayedError = false;
|
|
4065
3903
|
resolve();
|
|
4066
3904
|
});
|
|
4067
3905
|
});
|
|
@@ -4113,7 +3951,7 @@ const MgInputSelect = class {
|
|
|
4113
3951
|
*/
|
|
4114
3952
|
render() {
|
|
4115
3953
|
const readonlyValue = this.getReadonlyValue();
|
|
4116
|
-
return (h("mg-input", { key: '
|
|
3954
|
+
return (h("mg-input", { key: '1394827503d3f2dd71efc6efa389ac707573d2ec', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && readonlyValue === null ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("select", { class: "mg-c-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, ref: (el) => {
|
|
4117
3955
|
if (el !== null)
|
|
4118
3956
|
this.input = el;
|
|
4119
3957
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -4900,7 +4738,7 @@ const MgInputTitle = class {
|
|
|
4900
4738
|
};
|
|
4901
4739
|
MgInputTitle.style = mgInputTitleCss;
|
|
4902
4740
|
|
|
4903
|
-
const mgInputToggleCss = ".mg-c-
|
|
4741
|
+
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:0;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));background-color:unset;color:var(--mg-b-color-dark);font-weight:unset;text-overflow:ellipsis;white-space:nowrap}.mg-c-input__toggle-item-container:first-of-type{background-color:color-mix(in srgb, var(--mg-b-color-app), white 80%);color:var(--mg-b-color-app);font-weight:600}.mg-c-input__button-toggle{display:flex;min-width:0;padding:var(--mg-b-size-4);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);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-light);cursor:pointer;font-family:var(--mg-b-font-family);font-size:inherit;line-height:inherit}.mg-c-input__button-toggle:disabled{cursor:default}.mg-c-input.mg-c-input--toggle .mg-c-input__input-container{min-width:0;flex:auto}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:first-of-type{background-color:unset;color:var(--mg-b-color-dark);font-weight:unset}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:last-of-type{background-color:color-mix(in srgb, var(--mg-b-color-app), white 80%);color:var(--mg-b-color-info);font-weight:600}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container{display:flex;width:calc(var(--mg-b-font-size)*var(--mg-b-line-height) + 2*var(--mg-b-size-4));height:calc(var(--mg-b-font-size)*var(--mg-b-line-height) + 2*var(--mg-b-size-4));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 ::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{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{visibility:visible}.mg-c-input.mg-c-input--toggle-on-off .mg-c-input__toggle-item-container:first-of-type{background-color:var(--mg-b-color-neutral-30);color:var(--mg-b-color-dark);font-weight:600}.mg-c-input.mg-c-input--toggle-on-off.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:first-of-type{background-color:unset;color:var(--mg-b-color-dark);font-weight:unset}";
|
|
4904
4742
|
|
|
4905
4743
|
/**
|
|
4906
4744
|
* type Option validation function
|
|
@@ -4958,29 +4796,6 @@ const MgInputToggle = class {
|
|
|
4958
4796
|
* Checked internal value
|
|
4959
4797
|
*/
|
|
4960
4798
|
this.checked = false;
|
|
4961
|
-
/**
|
|
4962
|
-
* Check if input is valid
|
|
4963
|
-
*/
|
|
4964
|
-
this.checkValidity = () => {
|
|
4965
|
-
this.setValidity(this.readonly || this.disabled || this.hasInputItems());
|
|
4966
|
-
};
|
|
4967
|
-
/**
|
|
4968
|
-
* Reset error message
|
|
4969
|
-
*/
|
|
4970
|
-
this.resetErrorMessage = () => {
|
|
4971
|
-
this.checkValidity();
|
|
4972
|
-
this.errorMessage = undefined;
|
|
4973
|
-
};
|
|
4974
|
-
/**
|
|
4975
|
-
* Test if component has items
|
|
4976
|
-
* @returns truthy if component has items
|
|
4977
|
-
*/
|
|
4978
|
-
this.hasInputItems = () => { var _a; return ((_a = this.items) === null || _a === void 0 ? void 0 : _a.length) > 0; };
|
|
4979
|
-
/**
|
|
4980
|
-
* Test if component has no value error message displayed
|
|
4981
|
-
* @returns truthy if compent display no value error message
|
|
4982
|
-
*/
|
|
4983
|
-
this.hasNoValueErrorMessageDisplay = () => this.errorMessage === this.messages.errors.noValue;
|
|
4984
4799
|
/**
|
|
4985
4800
|
* Set input error message
|
|
4986
4801
|
* @param errorMessage - errorMessage override
|
|
@@ -4989,13 +4804,8 @@ const MgInputToggle = class {
|
|
|
4989
4804
|
// Set error message
|
|
4990
4805
|
this.errorMessage = undefined;
|
|
4991
4806
|
// Does have a custom error message
|
|
4992
|
-
if (!this.valid) {
|
|
4993
|
-
|
|
4994
|
-
this.errorMessage = errorMessage;
|
|
4995
|
-
}
|
|
4996
|
-
else if (!this.hasInputItems()) {
|
|
4997
|
-
this.errorMessage = this.messages.errors.noValue;
|
|
4998
|
-
}
|
|
4807
|
+
if (!this.valid && errorMessage !== undefined) {
|
|
4808
|
+
this.errorMessage = errorMessage;
|
|
4999
4809
|
}
|
|
5000
4810
|
};
|
|
5001
4811
|
/**
|
|
@@ -5010,7 +4820,7 @@ const MgInputToggle = class {
|
|
|
5010
4820
|
this.validateSlots = () => {
|
|
5011
4821
|
const slots = Array.from(this.element.children);
|
|
5012
4822
|
if (slots.length !== 2) {
|
|
5013
|
-
|
|
4823
|
+
throw new Error('<mg-input-toggle> 2 slots are required.');
|
|
5014
4824
|
}
|
|
5015
4825
|
else if (!this.isIcon) {
|
|
5016
4826
|
// Due to text-overflow set to ellipsis
|
|
@@ -5041,28 +4851,16 @@ const MgInputToggle = class {
|
|
|
5041
4851
|
this.valueChange.emit(newValue);
|
|
5042
4852
|
}
|
|
5043
4853
|
validateItems(newValue) {
|
|
5044
|
-
if (
|
|
5045
|
-
this.options = [];
|
|
5046
|
-
this.displayError();
|
|
5047
|
-
}
|
|
5048
|
-
else if (Array.isArray(newValue) && this.items.length !== 2) {
|
|
4854
|
+
if (typeof newValue === 'object' && this.items.length !== 2) {
|
|
5049
4855
|
throw new Error(`<mg-input-toggle> prop "items" require 2 items. Passed value: ${toString(newValue)}.`);
|
|
5050
4856
|
}
|
|
5051
4857
|
// String array
|
|
5052
4858
|
else if (allItemsAreString(newValue)) {
|
|
5053
4859
|
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
5054
|
-
// force to reset error when noValueError is displaied
|
|
5055
|
-
if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
|
|
5056
|
-
this.resetErrorMessage();
|
|
5057
|
-
}
|
|
5058
4860
|
}
|
|
5059
4861
|
// Object array
|
|
5060
4862
|
else if (Array.isArray(newValue) && newValue.every(isOption)) {
|
|
5061
4863
|
this.options = newValue;
|
|
5062
|
-
// force to reset error when noValueError is displaied
|
|
5063
|
-
if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
|
|
5064
|
-
this.resetErrorMessage();
|
|
5065
|
-
}
|
|
5066
4864
|
}
|
|
5067
4865
|
else {
|
|
5068
4866
|
throw new Error(`<mg-input-toggle> prop "items" is required and all items must be the same type: ToggleValue. Passed value: ${toString(newValue)}.`);
|
|
@@ -5124,7 +4922,8 @@ const MgInputToggle = class {
|
|
|
5124
4922
|
throw new Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string.');
|
|
5125
4923
|
}
|
|
5126
4924
|
else {
|
|
5127
|
-
this.
|
|
4925
|
+
this.valid = valid;
|
|
4926
|
+
this.inputValid.emit(valid);
|
|
5128
4927
|
this.setErrorMessage(valid ? undefined : errorMessage);
|
|
5129
4928
|
}
|
|
5130
4929
|
}
|
|
@@ -5143,43 +4942,12 @@ const MgInputToggle = class {
|
|
|
5143
4942
|
// - Keep everything in sync both inside and outside the component
|
|
5144
4943
|
return new Promise(resolve => {
|
|
5145
4944
|
requestAnimationFrame(() => {
|
|
5146
|
-
this.
|
|
4945
|
+
this.errorMessage = undefined;
|
|
5147
4946
|
resolve();
|
|
5148
4947
|
});
|
|
5149
4948
|
});
|
|
5150
4949
|
}
|
|
5151
4950
|
}
|
|
5152
|
-
/**
|
|
5153
|
-
* Display input error if it exists.
|
|
5154
|
-
*/
|
|
5155
|
-
displayError() {
|
|
5156
|
-
// Use `Promise` as requested for stencil method
|
|
5157
|
-
// Use `requestAnimationFrame` to ensure:
|
|
5158
|
-
// - DOM is fully updated before validation
|
|
5159
|
-
// - Async operations are completed
|
|
5160
|
-
// - No timing issues with Stencil's render cycle
|
|
5161
|
-
// - Keep everything in sync both inside and outside the component
|
|
5162
|
-
return new Promise(resolve => {
|
|
5163
|
-
requestAnimationFrame(() => {
|
|
5164
|
-
this.checkValidity();
|
|
5165
|
-
this.setErrorMessage();
|
|
5166
|
-
resolve();
|
|
5167
|
-
});
|
|
5168
|
-
});
|
|
5169
|
-
}
|
|
5170
|
-
/**
|
|
5171
|
-
* Method to set validity values
|
|
5172
|
-
* @param newValue - valid new value
|
|
5173
|
-
*/
|
|
5174
|
-
setValidity(newValue) {
|
|
5175
|
-
const oldValidValue = this.valid;
|
|
5176
|
-
this.valid = newValue;
|
|
5177
|
-
this.invalid = !this.valid;
|
|
5178
|
-
// We need to send valid event even if it is the same value
|
|
5179
|
-
if (this.valid !== oldValidValue) {
|
|
5180
|
-
this.inputValid.emit(this.valid);
|
|
5181
|
-
}
|
|
5182
|
-
}
|
|
5183
4951
|
/**
|
|
5184
4952
|
* set checked state
|
|
5185
4953
|
*/
|
|
@@ -5198,9 +4966,6 @@ const MgInputToggle = class {
|
|
|
5198
4966
|
const selectedValue = this.value === this.options[optionTrueValueIndex].value;
|
|
5199
4967
|
this.checked = optionTrueValueIndex === 0 ? !selectedValue : selectedValue;
|
|
5200
4968
|
}
|
|
5201
|
-
else if (Array.isArray(this.options) && this.options.length === 0) {
|
|
5202
|
-
return;
|
|
5203
|
-
}
|
|
5204
4969
|
else {
|
|
5205
4970
|
this.checked = this.value === this.options[1].value;
|
|
5206
4971
|
}
|
|
@@ -5212,8 +4977,6 @@ const MgInputToggle = class {
|
|
|
5212
4977
|
* Check if component props are well configured on init
|
|
5213
4978
|
*/
|
|
5214
4979
|
componentWillLoad() {
|
|
5215
|
-
// Get locales
|
|
5216
|
-
this.messages = initLocales(this.element).messages;
|
|
5217
4980
|
// Check items format
|
|
5218
4981
|
this.validateItems(this.items);
|
|
5219
4982
|
// Check slots
|
|
@@ -5232,7 +4995,7 @@ const MgInputToggle = class {
|
|
|
5232
4995
|
*/
|
|
5233
4996
|
render() {
|
|
5234
4997
|
const checkedItem = this.getCheckedItem(this.checked);
|
|
5235
|
-
return (h("mg-input", { key: '
|
|
4998
|
+
return (h("mg-input", { key: '7611cffaf1c01e30c3fa7a27555f94ab357dd374', label: this.label, helpText: this.helpText, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, errorMessage: this.errorMessage }, this.readonly ? (checkedItem && h("b", { class: "mg-c-input__readonly-value" }, checkedItem.title)) : (h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-c-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked, ref: el => {
|
|
5236
4999
|
if (el !== null)
|
|
5237
5000
|
this.button = el;
|
|
5238
5001
|
} }, h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-2" }))))));
|
|
@@ -6365,7 +6128,7 @@ const expandToggleDisplays = ['text', 'icon'];
|
|
|
6365
6128
|
*/
|
|
6366
6129
|
const titlePositions = ['left', 'right'];
|
|
6367
6130
|
|
|
6368
|
-
const mgPanelCss = "/*!\n * @prop --mg-c-panel-border-radius: Defines the border radius of the panel. Default value: `--mg-b-size-radius`.\n * @prop --mg-c-panel-color-background: Defines the background of the panel.\n * @prop --mg-c-panel-box-shadow: Defines the box shadow of the panel. Default value: `--mg-b-box-shadow`.\n * @prop --mg-c-panel-content-spacing: Defines the padding of the panel content. Default value: `--mg-b-size-16`.\n */:host{--mg-c-card-
|
|
6131
|
+
const mgPanelCss = "/*!\n * @prop --mg-c-panel-border-radius: Defines the border radius of the panel. Default value: `--mg-b-size-radius`.\n * @prop --mg-c-panel-color-background: Defines the background of the panel.\n * @prop --mg-c-panel-box-shadow: Defines the box shadow of the panel. Default value: `--mg-b-box-shadow`.\n * @prop --mg-c-panel-content-spacing: Defines the padding of the panel content. Default value: `--mg-b-size-16`.\n */:host{--mg-c-card-spacing:0;--mg-c-card-border-radius:var(--mg-c-panel-border-radius);--mg-c-card-color-background:var(--mg-c-panel-color-background);--mg-c-card-box-shadow:var(--mg-c-panel-box-shadow)}.mg-c-panel__header{display:flex;flex-wrap:wrap;align-items:flex-start;justify-content:space-between;padding:0 var(--mg-b-size-4)}.mg-c-panel__header-title,.mg-c-panel__header-content{display:flex;margin:var(--mg-b-size-4) 0}.mg-c-panel__header-content{min-height:var(--mg-b-size-min-height);flex:1 auto;align-items:center;padding-left:var(--mg-b-size-4)}.mg-c-panel__header-title mg-input-text{flex-grow:1;margin-left:var(--mg-b-size-4)}.mg-c-panel__header-title mg-button+mg-button:not([slot=append-input]){margin-left:var(--mg-b-size-4)}.mg-c-panel__header-title.mg-c-panel__header-title--full{flex:1 1 auto}.mg-c-panel__collapse-button-content{--mg-b-font-size:var(--mg-b-font-size-h5);--mg-c-button-font-weight:600}.mg-c-panel__collapse-button-icon.mg-c-panel__collapse-button-icon--reverse{transform:rotate(180deg)}.mg-c-panel__content{padding:var(--mg-c-panel-content-spacing)}.mg-c-panel ::slotted([slot=header-right]){display:flex;flex-wrap:wrap;margin-left:auto;gap:var(--mg-b-spacing-actions)}.mg-c-panel ::slotted(*:not(mg-panel,mg-message,mg-modal)){--mg-c-card-border:var(--mg-c-card-border-default);--mg-c-card-spacing:var(--mg-c-card-spacing-default);--mg-c-card-border-radius:var(--mg-c-card-border-radius-default);--mg-c-card-color-background:var(--mg-c-card-color-background-default);--mg-c-card-box-shadow:var(--mg-c-card-box-shadow-default);--mg-c-card-max-width:unset;--mg-c-card-min-width:unset}";
|
|
6369
6132
|
|
|
6370
6133
|
const MgPanel = class {
|
|
6371
6134
|
constructor(hostRef) {
|