@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,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-T3-qWqFE.js');
|
|
4
4
|
var index$1 = require('./index-CpENFzEo.js');
|
|
5
|
-
var index$2 = require('./index-
|
|
6
|
-
var
|
|
7
|
-
var mgInput_conf = require('./mg-input.conf-
|
|
5
|
+
var index$2 = require('./index-YM1EJx9X.js');
|
|
6
|
+
var events_utils = require('./events.utils-D5SAtkpQ.js');
|
|
7
|
+
var mgInput_conf = require('./mg-input.conf-WTsvDfpC.js');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Available menu item status values
|
|
@@ -345,7 +345,7 @@ const MgButton = class {
|
|
|
345
345
|
if (!this.disabled && event.key === ' ') {
|
|
346
346
|
event.preventDefault();
|
|
347
347
|
}
|
|
348
|
-
else if (!this.disabled && [
|
|
348
|
+
else if (!this.disabled && [events_utils.Keys.ENTER, events_utils.Keys.NUMPADENTER, events_utils.Keys.SPACE].includes(event.key)) {
|
|
349
349
|
event.preventDefault();
|
|
350
350
|
this.element.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
351
351
|
}
|
|
@@ -1194,16 +1194,13 @@ const MgIllustratedMessage = class {
|
|
|
1194
1194
|
};
|
|
1195
1195
|
MgIllustratedMessage.style = mgIllustratedMessageCss;
|
|
1196
1196
|
|
|
1197
|
-
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{
|
|
1197
|
+
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}}";
|
|
1198
1198
|
|
|
1199
|
-
const isValidErrorMessageType = (msg) => index$1.isObject(msg) && ['summary', 'details'].every(key => typeof msg[key] === 'string');
|
|
1200
1199
|
const MgInput = class {
|
|
1201
1200
|
constructor(hostRef) {
|
|
1202
1201
|
index.registerInstance(this, hostRef);
|
|
1203
1202
|
this.slotLabel = 'label';
|
|
1204
1203
|
this.slotError = 'error';
|
|
1205
|
-
this.slotSummary = 'summary';
|
|
1206
|
-
this.slotDetails = 'details';
|
|
1207
1204
|
this.slotHelpText = 'help-text';
|
|
1208
1205
|
// style
|
|
1209
1206
|
this.classInput = 'mg-c-input';
|
|
@@ -1245,44 +1242,6 @@ const MgInput = class {
|
|
|
1245
1242
|
* Element is disabled
|
|
1246
1243
|
*/
|
|
1247
1244
|
this.isVerticalList = false;
|
|
1248
|
-
/**
|
|
1249
|
-
* Render error message details element
|
|
1250
|
-
*/
|
|
1251
|
-
this.renderErrorDetailsMessage = (message) => {
|
|
1252
|
-
var _a, _b;
|
|
1253
|
-
// remove error slot if it is NOT a MG-DETAIL
|
|
1254
|
-
if (((_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.nodeName) !== 'MG-DETAILS') {
|
|
1255
|
-
(_b = this.errorMessageSlotElement) === null || _b === void 0 ? void 0 : _b.remove();
|
|
1256
|
-
}
|
|
1257
|
-
// create OR update error summary
|
|
1258
|
-
let summarySlotElement = this.element.querySelector(`[slot=${this.slotError}] [slot=${this.slotSummary}]`);
|
|
1259
|
-
if (summarySlotElement === null) {
|
|
1260
|
-
summarySlotElement = document.createElement('span');
|
|
1261
|
-
summarySlotElement.setAttribute('slot', this.slotSummary);
|
|
1262
|
-
}
|
|
1263
|
-
summarySlotElement.innerHTML = message.summary;
|
|
1264
|
-
// create OR update error details
|
|
1265
|
-
let detailsSlotElement = this.element.querySelector(`[slot=${this.slotError}] [slot=${this.slotDetails}]`);
|
|
1266
|
-
if (detailsSlotElement === null) {
|
|
1267
|
-
detailsSlotElement = document.createElement('p');
|
|
1268
|
-
detailsSlotElement.setAttribute('slot', this.slotDetails);
|
|
1269
|
-
detailsSlotElement.classList.add('mg-c-input__error-details');
|
|
1270
|
-
}
|
|
1271
|
-
detailsSlotElement.innerHTML = message.details;
|
|
1272
|
-
// create error mg-details
|
|
1273
|
-
let mgDetails = this.element.querySelector(`mg-details[slot=${this.slotError}]`);
|
|
1274
|
-
if (mgDetails === null) {
|
|
1275
|
-
mgDetails = document.createElement('mg-details');
|
|
1276
|
-
mgDetails.classList.add('mg-c-input__error');
|
|
1277
|
-
mgDetails.toggleClosed = this.messages.details.toggleClosed;
|
|
1278
|
-
mgDetails.toggleOpened = this.messages.details.toggleOpened;
|
|
1279
|
-
mgDetails.hideSummary = true;
|
|
1280
|
-
mgDetails.appendChild(summarySlotElement);
|
|
1281
|
-
mgDetails.appendChild(detailsSlotElement);
|
|
1282
|
-
this.element.appendChild(mgDetails);
|
|
1283
|
-
}
|
|
1284
|
-
this.errorMessageSlotElement = mgDetails;
|
|
1285
|
-
};
|
|
1286
1245
|
/**
|
|
1287
1246
|
* Get tooltip node
|
|
1288
1247
|
* @returns mg-tooltip
|
|
@@ -1320,14 +1279,16 @@ const MgInput = class {
|
|
|
1320
1279
|
}
|
|
1321
1280
|
}
|
|
1322
1281
|
watchErrorMessage(newValue) {
|
|
1323
|
-
|
|
1282
|
+
var _a;
|
|
1283
|
+
if (newValue !== undefined) {
|
|
1324
1284
|
this.element.classList.add(this.classHasError);
|
|
1285
|
+
this.renderErrorMessage();
|
|
1325
1286
|
}
|
|
1326
1287
|
else {
|
|
1327
1288
|
this.element.classList.remove(this.classHasError);
|
|
1289
|
+
(_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.remove();
|
|
1290
|
+
this.errorMessageSlotElement = undefined;
|
|
1328
1291
|
}
|
|
1329
|
-
// update error message slot
|
|
1330
|
-
this.renderErrorMessageSlot();
|
|
1331
1292
|
}
|
|
1332
1293
|
watchHelpText(newValue) {
|
|
1333
1294
|
var _a;
|
|
@@ -1356,12 +1317,14 @@ const MgInput = class {
|
|
|
1356
1317
|
// Help text
|
|
1357
1318
|
if (this.helpText !== undefined) {
|
|
1358
1319
|
this.renderHelpText();
|
|
1359
|
-
ariaDescribedbyIDs.
|
|
1320
|
+
if (!ariaDescribedbyIDs.has(this.helpTextId))
|
|
1321
|
+
ariaDescribedbyIDs.add(this.helpTextId);
|
|
1360
1322
|
}
|
|
1361
1323
|
// Error Message
|
|
1362
1324
|
if (this.errorMessage !== undefined) {
|
|
1363
|
-
this.
|
|
1364
|
-
ariaDescribedbyIDs.
|
|
1325
|
+
this.renderErrorMessage();
|
|
1326
|
+
if (!ariaDescribedbyIDs.has(this.helpTextErrorId))
|
|
1327
|
+
ariaDescribedbyIDs.add(this.helpTextErrorId);
|
|
1365
1328
|
}
|
|
1366
1329
|
this.element.querySelectorAll('input,select,textarea,[role="switch"]').forEach(element => {
|
|
1367
1330
|
if (ariaDescribedbyIDs.size > 0) {
|
|
@@ -1427,41 +1390,17 @@ const MgInput = class {
|
|
|
1427
1390
|
this.element.appendChild(labelSlotElement);
|
|
1428
1391
|
}
|
|
1429
1392
|
/**
|
|
1430
|
-
* Render error message
|
|
1393
|
+
* Render error message
|
|
1431
1394
|
*/
|
|
1432
|
-
|
|
1433
|
-
var _a;
|
|
1434
|
-
// remove error slot if it is a MG-DETAIL
|
|
1435
|
-
if (((_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.nodeName) === 'MG-DETAILS') {
|
|
1436
|
-
this.errorMessageSlotElement.remove();
|
|
1437
|
-
}
|
|
1438
|
-
// create element if it does NOT exist
|
|
1439
|
-
else if (this.errorMessageSlotElement === null) {
|
|
1440
|
-
this.errorMessageSlotElement = document.createElement('div');
|
|
1441
|
-
this.element.appendChild(this.errorMessageSlotElement);
|
|
1442
|
-
}
|
|
1443
|
-
this.errorMessageSlotElement.innerHTML = message;
|
|
1444
|
-
}
|
|
1445
|
-
/**
|
|
1446
|
-
* Render error message slot element
|
|
1447
|
-
*/
|
|
1448
|
-
renderErrorMessageSlot() {
|
|
1449
|
-
var _a;
|
|
1395
|
+
renderErrorMessage() {
|
|
1450
1396
|
this.errorMessageSlotElement = this.element.querySelector(`[slot=${this.slotError}]`);
|
|
1451
|
-
if (this.
|
|
1452
|
-
|
|
1453
|
-
this.renderErrorStringMessage(this.errorMessage);
|
|
1454
|
-
}
|
|
1455
|
-
else {
|
|
1456
|
-
this.renderErrorDetailsMessage(this.errorMessage);
|
|
1457
|
-
}
|
|
1397
|
+
if (this.errorMessageSlotElement === null) {
|
|
1398
|
+
this.errorMessageSlotElement = document.createElement('div');
|
|
1458
1399
|
this.errorMessageSlotElement.setAttribute('slot', this.slotError);
|
|
1459
|
-
this.
|
|
1460
|
-
}
|
|
1461
|
-
else {
|
|
1462
|
-
(_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.remove();
|
|
1463
|
-
this.errorMessageSlotElement = undefined;
|
|
1400
|
+
this.element.appendChild(this.errorMessageSlotElement);
|
|
1464
1401
|
}
|
|
1402
|
+
this.errorMessageSlotElement.setAttribute('id', this.helpTextErrorId);
|
|
1403
|
+
this.errorMessageSlotElement.innerHTML = this.errorMessage;
|
|
1465
1404
|
}
|
|
1466
1405
|
/**
|
|
1467
1406
|
* Render help text message
|
|
@@ -1483,9 +1422,6 @@ const MgInput = class {
|
|
|
1483
1422
|
* Check if component props are well configured on init
|
|
1484
1423
|
*/
|
|
1485
1424
|
componentWillLoad() {
|
|
1486
|
-
// Get locales
|
|
1487
|
-
this.messages = index$2.initLocales(this.element).messages;
|
|
1488
|
-
// Validate
|
|
1489
1425
|
this.watchIdentifier(this.identifier);
|
|
1490
1426
|
this.watchLabel();
|
|
1491
1427
|
this.watchClass();
|
|
@@ -1510,7 +1446,7 @@ const MgInput = class {
|
|
|
1510
1446
|
*/
|
|
1511
1447
|
render() {
|
|
1512
1448
|
const isGroup = this.isFieldset && !this.isReadonly;
|
|
1513
|
-
return (index.h(index.Host, { key: '
|
|
1449
|
+
return (index.h(index.Host, { key: '7c4c22aaa8f8d250eafa9159a103a11e637b0cca', class: this.element.classList.toString(), role: isGroup ? 'group' : undefined, "aria-labelledby": isGroup ? `${this.identifier}-title` : undefined }, index.h("div", { key: '2215e7b2d96e08507579a39d8e05b3e8a3d901fb', class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': this.labelHide } }, index.h("slot", { key: 'a4dbf4e36dd3ae5437d6dcb05d807f4faa0924b7', name: this.slotLabel }), this.tooltip && (this.tooltipPosition === 'label' || this.labelOnTop) && !this.labelHide && this.renderTooltip()), index.h("div", { key: '8e382a4857f469a9d6f77cad613183798df4d1e1', class: "mg-c-input__input-container" }, index.h("div", { key: 'f9897f90d44aab19614d4d40d77a8eb270c92847', class: "mg-c-input__input" }, index.h("slot", { key: 'c8d809d4ff0d0e660849825f016f9267da3a2d7e' }), this.tooltip && !this.labelOnTop && (this.tooltipPosition === 'input' || this.labelHide) && this.renderTooltip()), this.helptextMessageSlotElement && (index.h("div", { key: 'cebd6c083d088aebcdae6f032c6cdcf2387c3e27', class: "mg-c-input__help-text" }, index.h("slot", { key: '923fcc78b309d197e32522052b297ef0f58b1495', name: this.slotHelpText }))), !this.isDisabled && this.errorMessage && (index.h("div", { key: 'e706bff54ce21191a8c0940c60f6e99a91cfb9ec', class: "mg-c-input__error", "aria-live": "assertive" }, index.h("slot", { key: '6524debd3640df7b5e73ef4aa4415569eef1ecd8', name: this.slotError }))))));
|
|
1514
1450
|
}
|
|
1515
1451
|
get element() { return index.getElement(this); }
|
|
1516
1452
|
static get watchers() { return {
|
|
@@ -1547,8 +1483,7 @@ const SectionKind = {
|
|
|
1547
1483
|
* @param props - MgInputCheckboxList Interface Props
|
|
1548
1484
|
* @returns input template
|
|
1549
1485
|
*/
|
|
1550
|
-
const MgInputCheckboxList = (props) =>
|
|
1551
|
-
props.checkboxes.length > 0 && (index.h("ul", { class: "mg-c-input__input-group-container", role: "list", "aria-labelledby": props.labelledby, id: props.id }, props.checkboxes.map(input => {
|
|
1486
|
+
const MgInputCheckboxList = (props) => (index.h("ul", { class: "mg-c-input__input-group-container", role: "list", "aria-labelledby": props.labelledby, id: props.id }, props.checkboxes.map(input => {
|
|
1552
1487
|
var _a, _b;
|
|
1553
1488
|
return (index.h("li", { key: input._id, class: { 'mg-c-input__input-group': true, 'mg-c-input__input-group--disabled': props.disabled || input.disabled } },
|
|
1554
1489
|
index.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 }),
|
|
@@ -1569,7 +1504,7 @@ const Status = {
|
|
|
1569
1504
|
*/
|
|
1570
1505
|
const sizes$1 = ['medium', 'large'];
|
|
1571
1506
|
|
|
1572
|
-
const mgInputCheckboxCss = ".mg-c-
|
|
1507
|
+
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)}";
|
|
1573
1508
|
|
|
1574
1509
|
/**
|
|
1575
1510
|
* type CheckboxItem validation function
|
|
@@ -1766,18 +1701,8 @@ const MgInputCheckbox = class {
|
|
|
1766
1701
|
* Check if input is valid
|
|
1767
1702
|
*/
|
|
1768
1703
|
this.checkValidity = () => {
|
|
1769
|
-
this.setValidity(this.readonly || this.disabled || (
|
|
1704
|
+
this.setValidity(this.readonly || this.disabled || (!this.hasInvalidInput() && this.validateRequired()));
|
|
1770
1705
|
};
|
|
1771
|
-
/**
|
|
1772
|
-
* Test if component has items
|
|
1773
|
-
* @returns truthy if component has items
|
|
1774
|
-
*/
|
|
1775
|
-
this.hasInputValue = () => { var _a; return ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) > 0; };
|
|
1776
|
-
/**
|
|
1777
|
-
* Test if component has no value error message displayed
|
|
1778
|
-
* @returns truthy if compent display no value error message
|
|
1779
|
-
*/
|
|
1780
|
-
this.hasNoValueErrorMessageDisplay = () => this.errorMessage === this.messages.errors.noValue;
|
|
1781
1706
|
/**
|
|
1782
1707
|
* Set button text locale key
|
|
1783
1708
|
*/
|
|
@@ -1819,25 +1744,12 @@ const MgInputCheckbox = class {
|
|
|
1819
1744
|
// Set error message
|
|
1820
1745
|
this.errorMessage = undefined;
|
|
1821
1746
|
if (displayError && !this.valid) {
|
|
1822
|
-
if (errorMessage !== undefined)
|
|
1747
|
+
if (errorMessage !== undefined)
|
|
1823
1748
|
this.errorMessage = errorMessage;
|
|
1824
|
-
|
|
1825
|
-
else if (!this.hasInputValue()) {
|
|
1826
|
-
this.errorMessage = this.messages.errors.noValue;
|
|
1827
|
-
}
|
|
1828
|
-
else if (!this.validateRequired()) {
|
|
1749
|
+
else if (!this.validateRequired())
|
|
1829
1750
|
this.errorMessage = this.messages.errors.required;
|
|
1830
|
-
}
|
|
1831
1751
|
}
|
|
1832
1752
|
};
|
|
1833
|
-
/**
|
|
1834
|
-
* Reset error message
|
|
1835
|
-
*/
|
|
1836
|
-
this.resetErrorMessage = () => {
|
|
1837
|
-
this.checkValidity();
|
|
1838
|
-
this.errorMessage = undefined;
|
|
1839
|
-
this.hasDisplayedError = false;
|
|
1840
|
-
};
|
|
1841
1753
|
/**
|
|
1842
1754
|
* Method to get mg-popover identifier
|
|
1843
1755
|
* @returns MgPopover identifier
|
|
@@ -1866,14 +1778,7 @@ const MgInputCheckbox = class {
|
|
|
1866
1778
|
* @returns The rendered readonly value.
|
|
1867
1779
|
*/
|
|
1868
1780
|
this.renderReadonly = (readonlyValue) => {
|
|
1869
|
-
|
|
1870
|
-
if (this.inputVerticalList) {
|
|
1871
|
-
return (index.h("ul", { class: "mg-c-input__readonly-value" }, readonlyValue.map(value => (index.h("li", { key: value }, index.h("b", null, value))))));
|
|
1872
|
-
}
|
|
1873
|
-
else {
|
|
1874
|
-
return index.h("b", { class: "mg-c-input__readonly-value" }, readonlyValue.join(', '));
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1781
|
+
return this.inputVerticalList ? (index.h("ul", { class: "mg-c-input__readonly-value" }, readonlyValue.map(value => (index.h("li", { key: value }, index.h("b", null, value)))))) : (index.h("b", { class: "mg-c-input__readonly-value" }, readonlyValue.join(', ')));
|
|
1877
1782
|
};
|
|
1878
1783
|
/**
|
|
1879
1784
|
* Renders the MgInputCheckboxList component.
|
|
@@ -1882,16 +1787,9 @@ const MgInputCheckbox = class {
|
|
|
1882
1787
|
this.renderMgInputCheckboxList = () => (index.h(MgInputCheckboxList, { checkboxes: this.checkboxItems, id: this.checkboxesId, disabled: this.disabled, name: this.name, invalid: this.invalid }));
|
|
1883
1788
|
}
|
|
1884
1789
|
validateValue(newValue) {
|
|
1885
|
-
if (
|
|
1886
|
-
this.displayError();
|
|
1887
|
-
}
|
|
1888
|
-
else if (newValue.length > 0 && isCheckboxItems(newValue)) {
|
|
1790
|
+
if (isCheckboxItems(newValue)) {
|
|
1889
1791
|
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) })));
|
|
1890
1792
|
this.valueChange.emit(newValue);
|
|
1891
|
-
// force to reset error when noValueError is displaied
|
|
1892
|
-
if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
|
|
1893
|
-
this.resetErrorMessage();
|
|
1894
|
-
}
|
|
1895
1793
|
}
|
|
1896
1794
|
else {
|
|
1897
1795
|
throw new Error(`<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem. Passed value: ${index$1.toString(newValue)}.`);
|
|
@@ -2035,7 +1933,9 @@ const MgInputCheckbox = class {
|
|
|
2035
1933
|
// - Keep everything in sync both inside and outside the component
|
|
2036
1934
|
return new Promise(resolve => {
|
|
2037
1935
|
requestAnimationFrame(() => {
|
|
2038
|
-
this.
|
|
1936
|
+
this.checkValidity();
|
|
1937
|
+
this.errorMessage = undefined;
|
|
1938
|
+
this.hasDisplayedError = false;
|
|
2039
1939
|
resolve();
|
|
2040
1940
|
});
|
|
2041
1941
|
});
|
|
@@ -2158,9 +2058,8 @@ const MgInputCheckbox = class {
|
|
|
2158
2058
|
* @returns HTML Element
|
|
2159
2059
|
*/
|
|
2160
2060
|
render() {
|
|
2161
|
-
var _a;
|
|
2162
2061
|
let inputContent;
|
|
2163
|
-
const readonlyValue =
|
|
2062
|
+
const readonlyValue = this.value.filter(({ value }) => value).map(({ title }) => title);
|
|
2164
2063
|
if (this.readonly) {
|
|
2165
2064
|
inputContent = this.renderReadonly(readonlyValue);
|
|
2166
2065
|
}
|
|
@@ -2170,7 +2069,7 @@ const MgInputCheckbox = class {
|
|
|
2170
2069
|
else {
|
|
2171
2070
|
inputContent = this.renderCheckboxMulti();
|
|
2172
2071
|
}
|
|
2173
|
-
return (index.h("mg-input", { key: '
|
|
2072
|
+
return (index.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));
|
|
2174
2073
|
}
|
|
2175
2074
|
get element() { return index.getElement(this); }
|
|
2176
2075
|
static get watchers() { return {
|
|
@@ -3399,7 +3298,7 @@ const MgInputPassword = class {
|
|
|
3399
3298
|
};
|
|
3400
3299
|
MgInputPassword.style = mgInputPasswordCss;
|
|
3401
3300
|
|
|
3402
|
-
const mgInputRadioCss = ".mg-c-
|
|
3301
|
+
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}";
|
|
3403
3302
|
|
|
3404
3303
|
/**
|
|
3405
3304
|
* type Option validation function
|
|
@@ -3476,21 +3375,11 @@ const MgInputRadio = class {
|
|
|
3476
3375
|
// reset guard
|
|
3477
3376
|
this.handlerInProgress = undefined;
|
|
3478
3377
|
};
|
|
3479
|
-
/**
|
|
3480
|
-
* Test if component has items
|
|
3481
|
-
* @returns truthy if component has items
|
|
3482
|
-
*/
|
|
3483
|
-
this.hasInputValue = () => { var _a; return ((_a = this.items) === null || _a === void 0 ? void 0 : _a.length) > 0; };
|
|
3484
|
-
/**
|
|
3485
|
-
* Test if component has no value error message displayed
|
|
3486
|
-
* @returns truthy if compent display no value error message
|
|
3487
|
-
*/
|
|
3488
|
-
this.hasNoValueErrorMessageDisplay = () => this.errorMessage === this.messages.errors.noValue;
|
|
3489
3378
|
/**
|
|
3490
3379
|
* Check if input is valid
|
|
3491
3380
|
*/
|
|
3492
3381
|
this.checkValidity = () => {
|
|
3493
|
-
this.setValidity(this.readonly || this.disabled ||
|
|
3382
|
+
this.setValidity(this.readonly || this.disabled || this.getInvalidElement() === undefined);
|
|
3494
3383
|
};
|
|
3495
3384
|
/**
|
|
3496
3385
|
* Set input error message
|
|
@@ -3504,22 +3393,11 @@ const MgInputRadio = class {
|
|
|
3504
3393
|
if (errorMessage !== undefined) {
|
|
3505
3394
|
this.errorMessage = errorMessage;
|
|
3506
3395
|
}
|
|
3507
|
-
else if (!this.hasInputValue()) {
|
|
3508
|
-
this.errorMessage = this.messages.errors.noValue;
|
|
3509
|
-
}
|
|
3510
3396
|
else if (invalidElement.validity.valueMissing) {
|
|
3511
3397
|
this.errorMessage = this.messages.errors.required;
|
|
3512
3398
|
}
|
|
3513
3399
|
}
|
|
3514
3400
|
};
|
|
3515
|
-
/**
|
|
3516
|
-
* Reset error message
|
|
3517
|
-
*/
|
|
3518
|
-
this.resetErrorMessage = () => {
|
|
3519
|
-
this.checkValidity();
|
|
3520
|
-
this.errorMessage = undefined;
|
|
3521
|
-
this.hasDisplayedError = false;
|
|
3522
|
-
};
|
|
3523
3401
|
/**
|
|
3524
3402
|
* get invalid element
|
|
3525
3403
|
* @returns element
|
|
@@ -3541,29 +3419,17 @@ const MgInputRadio = class {
|
|
|
3541
3419
|
this.valueChange.emit(newValue);
|
|
3542
3420
|
}
|
|
3543
3421
|
validateItems(newValue) {
|
|
3544
|
-
if ([undefined, null].includes(newValue) || (Array.isArray(newValue) && newValue.length === 0)) {
|
|
3545
|
-
this.options = [];
|
|
3546
|
-
this.displayError();
|
|
3547
|
-
}
|
|
3548
3422
|
// Validate if items have required min length
|
|
3549
|
-
|
|
3423
|
+
if (typeof newValue === 'object' && newValue.length < 2) {
|
|
3550
3424
|
throw new Error(`<mg-input-radio> prop "items" require at least 2 items. Passed value: ${index$1.toString(newValue)}.`);
|
|
3551
3425
|
}
|
|
3552
3426
|
// String array
|
|
3553
3427
|
else if (index$1.allItemsAreString(newValue)) {
|
|
3554
3428
|
this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
|
|
3555
|
-
// force to reset error when noValueError is displaied
|
|
3556
|
-
if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
|
|
3557
|
-
this.resetErrorMessage();
|
|
3558
|
-
}
|
|
3559
3429
|
}
|
|
3560
3430
|
// Object array
|
|
3561
|
-
else if (
|
|
3431
|
+
else if (newValue && newValue.every(item => isOption$3(item))) {
|
|
3562
3432
|
this.options = newValue;
|
|
3563
|
-
// force to reset error when noValueError is displaied
|
|
3564
|
-
if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
|
|
3565
|
-
this.resetErrorMessage();
|
|
3566
|
-
}
|
|
3567
3433
|
}
|
|
3568
3434
|
else {
|
|
3569
3435
|
throw new Error(`<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption. Passed value: ${index$1.toString(newValue)}.`);
|
|
@@ -3659,7 +3525,9 @@ const MgInputRadio = class {
|
|
|
3659
3525
|
// - Keep everything in sync both inside and outside the component
|
|
3660
3526
|
return new Promise(resolve => {
|
|
3661
3527
|
requestAnimationFrame(() => {
|
|
3662
|
-
this.
|
|
3528
|
+
this.checkValidity();
|
|
3529
|
+
this.errorMessage = undefined;
|
|
3530
|
+
this.hasDisplayedError = false;
|
|
3663
3531
|
resolve();
|
|
3664
3532
|
});
|
|
3665
3533
|
});
|
|
@@ -3705,12 +3573,10 @@ const MgInputRadio = class {
|
|
|
3705
3573
|
* @returns HTML Element
|
|
3706
3574
|
*/
|
|
3707
3575
|
render() {
|
|
3708
|
-
return (index.h("mg-input", { key: '
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
this.inputs[index$1] = el;
|
|
3713
|
-
} }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title))))))));
|
|
3576
|
+
return (index.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 && 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) => {
|
|
3577
|
+
if (el !== null)
|
|
3578
|
+
this.inputs[index$1] = el;
|
|
3579
|
+
} }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title))))))));
|
|
3714
3580
|
}
|
|
3715
3581
|
get element() { return index.getElement(this); }
|
|
3716
3582
|
static get watchers() { return {
|
|
@@ -3724,7 +3590,7 @@ const MgInputRadio = class {
|
|
|
3724
3590
|
};
|
|
3725
3591
|
MgInputRadio.style = mgInputRadioCss;
|
|
3726
3592
|
|
|
3727
|
-
const mgInputSelectCss = ".mg-c-
|
|
3593
|
+
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%}}";
|
|
3728
3594
|
|
|
3729
3595
|
/**
|
|
3730
3596
|
* Check if item is a well configured option
|
|
@@ -3860,16 +3726,6 @@ const MgInputSelect = class {
|
|
|
3860
3726
|
* @returns truthy if input.value is an item
|
|
3861
3727
|
*/
|
|
3862
3728
|
this.isInputValue = (item) => { var _a; return item.title === ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value); };
|
|
3863
|
-
/**
|
|
3864
|
-
* Test if component has items
|
|
3865
|
-
* @returns truthy if component has items
|
|
3866
|
-
*/
|
|
3867
|
-
this.hasInputValue = () => { var _a; return ((_a = this.items) === null || _a === void 0 ? void 0 : _a.length) > 0; };
|
|
3868
|
-
/**
|
|
3869
|
-
* Test if component has no value error message displayed
|
|
3870
|
-
* @returns truthy if compent display no value error message
|
|
3871
|
-
*/
|
|
3872
|
-
this.hasNoValueErrorMessageDisplay = () => this.errorMessage === this.messages.errors.noValue;
|
|
3873
3729
|
/**
|
|
3874
3730
|
* Handle blur event
|
|
3875
3731
|
*/
|
|
@@ -3889,7 +3745,7 @@ const MgInputSelect = class {
|
|
|
3889
3745
|
* Check if input is valid
|
|
3890
3746
|
*/
|
|
3891
3747
|
this.checkValidity = () => {
|
|
3892
|
-
this.setValidity(!this.isDisabledValue() && (this.readonly || this.disabled ||
|
|
3748
|
+
this.setValidity(!this.isDisabledValue() && (this.readonly || this.disabled || this.input.checkValidity()));
|
|
3893
3749
|
};
|
|
3894
3750
|
/**
|
|
3895
3751
|
* Set input error message
|
|
@@ -3902,22 +3758,11 @@ const MgInputSelect = class {
|
|
|
3902
3758
|
if (errorMessage !== undefined) {
|
|
3903
3759
|
this.errorMessage = errorMessage;
|
|
3904
3760
|
}
|
|
3905
|
-
else if (!this.hasInputValue()) {
|
|
3906
|
-
this.errorMessage = this.messages.errors.noValue;
|
|
3907
|
-
}
|
|
3908
3761
|
else if (this.input.validity.valueMissing) {
|
|
3909
3762
|
this.errorMessage = this.messages.errors.required;
|
|
3910
3763
|
}
|
|
3911
3764
|
}
|
|
3912
3765
|
};
|
|
3913
|
-
/**
|
|
3914
|
-
* Reset error message
|
|
3915
|
-
*/
|
|
3916
|
-
this.resetErrorMessage = () => {
|
|
3917
|
-
this.checkValidity();
|
|
3918
|
-
this.errorMessage = undefined;
|
|
3919
|
-
this.hasDisplayedError = false;
|
|
3920
|
-
};
|
|
3921
3766
|
/**
|
|
3922
3767
|
* Render option
|
|
3923
3768
|
* @param option - to render
|
|
@@ -3935,11 +3780,9 @@ const MgInputSelect = class {
|
|
|
3935
3780
|
this.valueChange.emit(newValue);
|
|
3936
3781
|
}
|
|
3937
3782
|
validateItems(newValue) {
|
|
3938
|
-
let resetMessage = false;
|
|
3939
3783
|
// Empty options
|
|
3940
|
-
if (
|
|
3784
|
+
if (newValue.length === 0) {
|
|
3941
3785
|
this.options = [];
|
|
3942
|
-
this.displayError();
|
|
3943
3786
|
}
|
|
3944
3787
|
// String array
|
|
3945
3788
|
else if (index$1.allItemsAreString(newValue)) {
|
|
@@ -3947,8 +3790,6 @@ const MgInputSelect = class {
|
|
|
3947
3790
|
this.valueExist = newValue.includes(this.value);
|
|
3948
3791
|
}
|
|
3949
3792
|
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
3950
|
-
// force to reset error when noValueError is displaied
|
|
3951
|
-
resetMessage = this.invalid && this.hasNoValueErrorMessageDisplay();
|
|
3952
3793
|
}
|
|
3953
3794
|
// Object array
|
|
3954
3795
|
else if (allItemsAreOptions(newValue)) {
|
|
@@ -3961,15 +3802,10 @@ const MgInputSelect = class {
|
|
|
3961
3802
|
else {
|
|
3962
3803
|
this.options = newValue;
|
|
3963
3804
|
}
|
|
3964
|
-
// force to reset error when noValueError is displaied
|
|
3965
|
-
resetMessage = this.invalid && this.hasNoValueErrorMessageDisplay();
|
|
3966
3805
|
}
|
|
3967
3806
|
else {
|
|
3968
3807
|
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: ${index$1.toString(newValue)}.`);
|
|
3969
3808
|
}
|
|
3970
|
-
if (resetMessage) {
|
|
3971
|
-
this.resetErrorMessage();
|
|
3972
|
-
}
|
|
3973
3809
|
}
|
|
3974
3810
|
watchReadonly(newValue) {
|
|
3975
3811
|
if (newValue)
|
|
@@ -4063,7 +3899,9 @@ const MgInputSelect = class {
|
|
|
4063
3899
|
// - Keep everything in sync both inside and outside the component
|
|
4064
3900
|
return new Promise(resolve => {
|
|
4065
3901
|
requestAnimationFrame(() => {
|
|
4066
|
-
this.
|
|
3902
|
+
this.checkValidity();
|
|
3903
|
+
this.errorMessage = undefined;
|
|
3904
|
+
this.hasDisplayedError = false;
|
|
4067
3905
|
resolve();
|
|
4068
3906
|
});
|
|
4069
3907
|
});
|
|
@@ -4115,7 +3953,7 @@ const MgInputSelect = class {
|
|
|
4115
3953
|
*/
|
|
4116
3954
|
render() {
|
|
4117
3955
|
const readonlyValue = this.getReadonlyValue();
|
|
4118
|
-
return (index.h("mg-input", { key: '
|
|
3956
|
+
return (index.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 && 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) => {
|
|
4119
3957
|
if (el !== null)
|
|
4120
3958
|
this.input = el;
|
|
4121
3959
|
} }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
@@ -4902,7 +4740,7 @@ const MgInputTitle = class {
|
|
|
4902
4740
|
};
|
|
4903
4741
|
MgInputTitle.style = mgInputTitleCss;
|
|
4904
4742
|
|
|
4905
|
-
const mgInputToggleCss = ".mg-c-
|
|
4743
|
+
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}";
|
|
4906
4744
|
|
|
4907
4745
|
/**
|
|
4908
4746
|
* type Option validation function
|
|
@@ -4960,29 +4798,6 @@ const MgInputToggle = class {
|
|
|
4960
4798
|
* Checked internal value
|
|
4961
4799
|
*/
|
|
4962
4800
|
this.checked = false;
|
|
4963
|
-
/**
|
|
4964
|
-
* Check if input is valid
|
|
4965
|
-
*/
|
|
4966
|
-
this.checkValidity = () => {
|
|
4967
|
-
this.setValidity(this.readonly || this.disabled || this.hasInputItems());
|
|
4968
|
-
};
|
|
4969
|
-
/**
|
|
4970
|
-
* Reset error message
|
|
4971
|
-
*/
|
|
4972
|
-
this.resetErrorMessage = () => {
|
|
4973
|
-
this.checkValidity();
|
|
4974
|
-
this.errorMessage = undefined;
|
|
4975
|
-
};
|
|
4976
|
-
/**
|
|
4977
|
-
* Test if component has items
|
|
4978
|
-
* @returns truthy if component has items
|
|
4979
|
-
*/
|
|
4980
|
-
this.hasInputItems = () => { var _a; return ((_a = this.items) === null || _a === void 0 ? void 0 : _a.length) > 0; };
|
|
4981
|
-
/**
|
|
4982
|
-
* Test if component has no value error message displayed
|
|
4983
|
-
* @returns truthy if compent display no value error message
|
|
4984
|
-
*/
|
|
4985
|
-
this.hasNoValueErrorMessageDisplay = () => this.errorMessage === this.messages.errors.noValue;
|
|
4986
4801
|
/**
|
|
4987
4802
|
* Set input error message
|
|
4988
4803
|
* @param errorMessage - errorMessage override
|
|
@@ -4991,13 +4806,8 @@ const MgInputToggle = class {
|
|
|
4991
4806
|
// Set error message
|
|
4992
4807
|
this.errorMessage = undefined;
|
|
4993
4808
|
// Does have a custom error message
|
|
4994
|
-
if (!this.valid) {
|
|
4995
|
-
|
|
4996
|
-
this.errorMessage = errorMessage;
|
|
4997
|
-
}
|
|
4998
|
-
else if (!this.hasInputItems()) {
|
|
4999
|
-
this.errorMessage = this.messages.errors.noValue;
|
|
5000
|
-
}
|
|
4809
|
+
if (!this.valid && errorMessage !== undefined) {
|
|
4810
|
+
this.errorMessage = errorMessage;
|
|
5001
4811
|
}
|
|
5002
4812
|
};
|
|
5003
4813
|
/**
|
|
@@ -5012,7 +4822,7 @@ const MgInputToggle = class {
|
|
|
5012
4822
|
this.validateSlots = () => {
|
|
5013
4823
|
const slots = Array.from(this.element.children);
|
|
5014
4824
|
if (slots.length !== 2) {
|
|
5015
|
-
|
|
4825
|
+
throw new Error('<mg-input-toggle> 2 slots are required.');
|
|
5016
4826
|
}
|
|
5017
4827
|
else if (!this.isIcon) {
|
|
5018
4828
|
// Due to text-overflow set to ellipsis
|
|
@@ -5043,28 +4853,16 @@ const MgInputToggle = class {
|
|
|
5043
4853
|
this.valueChange.emit(newValue);
|
|
5044
4854
|
}
|
|
5045
4855
|
validateItems(newValue) {
|
|
5046
|
-
if (
|
|
5047
|
-
this.options = [];
|
|
5048
|
-
this.displayError();
|
|
5049
|
-
}
|
|
5050
|
-
else if (Array.isArray(newValue) && this.items.length !== 2) {
|
|
4856
|
+
if (typeof newValue === 'object' && this.items.length !== 2) {
|
|
5051
4857
|
throw new Error(`<mg-input-toggle> prop "items" require 2 items. Passed value: ${index$1.toString(newValue)}.`);
|
|
5052
4858
|
}
|
|
5053
4859
|
// String array
|
|
5054
4860
|
else if (index$1.allItemsAreString(newValue)) {
|
|
5055
4861
|
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
5056
|
-
// force to reset error when noValueError is displaied
|
|
5057
|
-
if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
|
|
5058
|
-
this.resetErrorMessage();
|
|
5059
|
-
}
|
|
5060
4862
|
}
|
|
5061
4863
|
// Object array
|
|
5062
4864
|
else if (Array.isArray(newValue) && newValue.every(isOption)) {
|
|
5063
4865
|
this.options = newValue;
|
|
5064
|
-
// force to reset error when noValueError is displaied
|
|
5065
|
-
if (this.invalid && this.hasNoValueErrorMessageDisplay()) {
|
|
5066
|
-
this.resetErrorMessage();
|
|
5067
|
-
}
|
|
5068
4866
|
}
|
|
5069
4867
|
else {
|
|
5070
4868
|
throw new Error(`<mg-input-toggle> prop "items" is required and all items must be the same type: ToggleValue. Passed value: ${index$1.toString(newValue)}.`);
|
|
@@ -5126,7 +4924,8 @@ const MgInputToggle = class {
|
|
|
5126
4924
|
throw new Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string.');
|
|
5127
4925
|
}
|
|
5128
4926
|
else {
|
|
5129
|
-
this.
|
|
4927
|
+
this.valid = valid;
|
|
4928
|
+
this.inputValid.emit(valid);
|
|
5130
4929
|
this.setErrorMessage(valid ? undefined : errorMessage);
|
|
5131
4930
|
}
|
|
5132
4931
|
}
|
|
@@ -5145,43 +4944,12 @@ const MgInputToggle = class {
|
|
|
5145
4944
|
// - Keep everything in sync both inside and outside the component
|
|
5146
4945
|
return new Promise(resolve => {
|
|
5147
4946
|
requestAnimationFrame(() => {
|
|
5148
|
-
this.
|
|
4947
|
+
this.errorMessage = undefined;
|
|
5149
4948
|
resolve();
|
|
5150
4949
|
});
|
|
5151
4950
|
});
|
|
5152
4951
|
}
|
|
5153
4952
|
}
|
|
5154
|
-
/**
|
|
5155
|
-
* Display input error if it exists.
|
|
5156
|
-
*/
|
|
5157
|
-
displayError() {
|
|
5158
|
-
// Use `Promise` as requested for stencil method
|
|
5159
|
-
// Use `requestAnimationFrame` to ensure:
|
|
5160
|
-
// - DOM is fully updated before validation
|
|
5161
|
-
// - Async operations are completed
|
|
5162
|
-
// - No timing issues with Stencil's render cycle
|
|
5163
|
-
// - Keep everything in sync both inside and outside the component
|
|
5164
|
-
return new Promise(resolve => {
|
|
5165
|
-
requestAnimationFrame(() => {
|
|
5166
|
-
this.checkValidity();
|
|
5167
|
-
this.setErrorMessage();
|
|
5168
|
-
resolve();
|
|
5169
|
-
});
|
|
5170
|
-
});
|
|
5171
|
-
}
|
|
5172
|
-
/**
|
|
5173
|
-
* Method to set validity values
|
|
5174
|
-
* @param newValue - valid new value
|
|
5175
|
-
*/
|
|
5176
|
-
setValidity(newValue) {
|
|
5177
|
-
const oldValidValue = this.valid;
|
|
5178
|
-
this.valid = newValue;
|
|
5179
|
-
this.invalid = !this.valid;
|
|
5180
|
-
// We need to send valid event even if it is the same value
|
|
5181
|
-
if (this.valid !== oldValidValue) {
|
|
5182
|
-
this.inputValid.emit(this.valid);
|
|
5183
|
-
}
|
|
5184
|
-
}
|
|
5185
4953
|
/**
|
|
5186
4954
|
* set checked state
|
|
5187
4955
|
*/
|
|
@@ -5200,9 +4968,6 @@ const MgInputToggle = class {
|
|
|
5200
4968
|
const selectedValue = this.value === this.options[optionTrueValueIndex].value;
|
|
5201
4969
|
this.checked = optionTrueValueIndex === 0 ? !selectedValue : selectedValue;
|
|
5202
4970
|
}
|
|
5203
|
-
else if (Array.isArray(this.options) && this.options.length === 0) {
|
|
5204
|
-
return;
|
|
5205
|
-
}
|
|
5206
4971
|
else {
|
|
5207
4972
|
this.checked = this.value === this.options[1].value;
|
|
5208
4973
|
}
|
|
@@ -5214,8 +4979,6 @@ const MgInputToggle = class {
|
|
|
5214
4979
|
* Check if component props are well configured on init
|
|
5215
4980
|
*/
|
|
5216
4981
|
componentWillLoad() {
|
|
5217
|
-
// Get locales
|
|
5218
|
-
this.messages = index$2.initLocales(this.element).messages;
|
|
5219
4982
|
// Check items format
|
|
5220
4983
|
this.validateItems(this.items);
|
|
5221
4984
|
// Check slots
|
|
@@ -5234,7 +4997,7 @@ const MgInputToggle = class {
|
|
|
5234
4997
|
*/
|
|
5235
4998
|
render() {
|
|
5236
4999
|
const checkedItem = this.getCheckedItem(this.checked);
|
|
5237
|
-
return (index.h("mg-input", { key: '
|
|
5000
|
+
return (index.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 && 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 => {
|
|
5238
5001
|
if (el !== null)
|
|
5239
5002
|
this.button = el;
|
|
5240
5003
|
} }, 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" }))))));
|
|
@@ -6367,7 +6130,7 @@ const expandToggleDisplays = ['text', 'icon'];
|
|
|
6367
6130
|
*/
|
|
6368
6131
|
const titlePositions = ['left', 'right'];
|
|
6369
6132
|
|
|
6370
|
-
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-
|
|
6133
|
+
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}";
|
|
6371
6134
|
|
|
6372
6135
|
const MgPanel = class {
|
|
6373
6136
|
constructor(hostRef) {
|
|
@@ -9085,18 +8848,18 @@ const MgTabs = class {
|
|
|
9085
8848
|
*/
|
|
9086
8849
|
this.handleKeydown = (event) => {
|
|
9087
8850
|
const parent = event.target.parentElement;
|
|
9088
|
-
if ([
|
|
8851
|
+
if ([events_utils.Keys.ARROWLEFT, events_utils.Keys.ARROWRIGHT].includes(event.key)) {
|
|
9089
8852
|
this.tabFocus = Number(event.target.dataset.index);
|
|
9090
8853
|
parent.querySelector(`[data-index="${this.tabFocus}"]`).setAttribute('tabindex', '-1');
|
|
9091
8854
|
// Move right
|
|
9092
|
-
if (event.key ===
|
|
8855
|
+
if (event.key === events_utils.Keys.ARROWRIGHT) {
|
|
9093
8856
|
this.tabFocus++;
|
|
9094
8857
|
// If we're at the end, go to the start
|
|
9095
8858
|
if (this.tabFocus > this.tabs.length)
|
|
9096
8859
|
this.tabFocus = this.startIndex;
|
|
9097
8860
|
// Move left
|
|
9098
8861
|
}
|
|
9099
|
-
else if (event.key ===
|
|
8862
|
+
else if (event.key === events_utils.Keys.ARROWLEFT) {
|
|
9100
8863
|
this.tabFocus--;
|
|
9101
8864
|
// If we're at the start, move to the end
|
|
9102
8865
|
if (this.tabFocus < this.startIndex)
|
|
@@ -9113,7 +8876,7 @@ const MgTabs = class {
|
|
|
9113
8876
|
parentButtonElement.focus();
|
|
9114
8877
|
}
|
|
9115
8878
|
}
|
|
9116
|
-
else if (event.key ===
|
|
8879
|
+
else if (event.key === events_utils.Keys.TAB) {
|
|
9117
8880
|
this.resetFocus();
|
|
9118
8881
|
}
|
|
9119
8882
|
};
|