@mgdis/mg-components 6.7.0 → 6.8.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/README.md +1 -1
- package/dist/cjs/index-1a5a1081.js +2 -2
- package/dist/cjs/{index-b7923724.js → index-234e834a.js} +75 -39
- package/dist/cjs/index-234e834a.js.map +1 -0
- package/dist/cjs/{index.es-903492c5.js → index.es-b90f74d4.js} +2 -2
- package/dist/cjs/index.es-b90f74d4.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{mg-action-more_36.cjs.entry.js → mg-action-more_37.cjs.entry.js} +477 -91
- package/dist/cjs/mg-action-more_37.cjs.entry.js.map +1 -0
- package/dist/cjs/mg-alert.cjs.entry.js +2 -2
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +2 -2
- package/dist/cjs/mg-loader.cjs.entry.js +3 -3
- package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-progress.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +10 -10
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +21 -6
- package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +46 -19
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +57 -28
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js +7 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +43 -12
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js.map +1 -1
- package/dist/collection/components/molecules/mg-table/mg-table.conf.js +13 -0
- package/dist/collection/components/molecules/mg-table/mg-table.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-table/mg-table.js +364 -0
- package/dist/collection/components/molecules/mg-table/mg-table.js.map +1 -0
- package/dist/collection/locales/en/messages.json +33 -16
- package/dist/collection/locales/fr/messages.json +36 -19
- package/dist/components/index.es.js +1 -1
- package/dist/components/index.es.js.map +1 -1
- package/dist/components/index2.js +73 -37
- package/dist/components/index2.js.map +1 -1
- package/dist/components/mg-button2.js +10 -10
- package/dist/components/mg-button2.js.map +1 -1
- package/dist/components/mg-icon2.js +21 -6
- package/dist/components/mg-icon2.js.map +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +2 -2
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
- package/dist/components/mg-input-date.js +47 -19
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +58 -29
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-text2.js +50 -14
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-loader.js +1 -1
- package/dist/components/mg-loader.js.map +1 -1
- package/dist/components/mg-table.d.ts +11 -0
- package/dist/components/mg-table.js +320 -0
- package/dist/components/mg-table.js.map +1 -0
- package/dist/esm/index-5059254f.js +2 -2
- package/dist/esm/{index-a58f8b91.js → index-544778a7.js} +75 -39
- package/dist/esm/index-544778a7.js.map +1 -0
- package/dist/esm/{index.es-b80b758c.js → index.es-517b1bf2.js} +2 -2
- package/dist/esm/index.es-517b1bf2.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mg-action-more_36.entry.js → mg-action-more_37.entry.js} +477 -92
- package/dist/esm/mg-action-more_37.entry.js.map +1 -0
- package/dist/esm/mg-alert.entry.js +2 -2
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-input-rich-text-editor.entry.js +2 -2
- package/dist/esm/mg-loader.entry.js +3 -3
- package/dist/esm/mg-loader.entry.js.map +1 -1
- package/dist/esm/mg-progress.entry.js +1 -1
- package/dist/mg-components/locales/en/messages.json +33 -16
- package/dist/mg-components/locales/fr/messages.json +36 -19
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/mg-components.esm.js.map +1 -1
- package/dist/mg-components/{p-3c6710be.js → p-12a1edee.js} +2 -2
- package/dist/mg-components/p-12a1edee.js.map +1 -0
- package/dist/mg-components/p-9bc53279.js +2 -0
- package/dist/mg-components/{p-ac8a5083.js.map → p-9bc53279.js.map} +1 -1
- package/dist/mg-components/{p-bc6ec847.entry.js → p-ad98f3d8.entry.js} +2 -2
- package/dist/mg-components/p-ad98f3d8.entry.js.map +1 -0
- package/dist/mg-components/{p-2a633b29.entry.js → p-c10433db.entry.js} +2 -2
- package/dist/mg-components/{p-f2e6e7ae.entry.js → p-c67e4934.entry.js} +2 -2
- package/dist/mg-components/p-f72efb64.entry.js +2 -0
- package/dist/mg-components/p-f72efb64.entry.js.map +1 -0
- package/dist/mg-components/{p-361cc090.entry.js → p-fd4a7980.entry.js} +2 -2
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +6 -5
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.conf.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +8 -2
- package/dist/types/components/molecules/mg-table/mg-table.conf.d.ts +19 -0
- package/dist/types/components/molecules/mg-table/mg-table.d.ts +58 -0
- package/dist/types/components.d.ts +39 -0
- package/ide/intellij/web-types.json +69 -5
- package/ide/vscode/html-custom-data.json +85 -1
- package/package.json +22 -22
- package/dist/cjs/index-b7923724.js.map +0 -1
- package/dist/cjs/index.es-903492c5.js.map +0 -1
- package/dist/cjs/mg-action-more_36.cjs.entry.js.map +0 -1
- package/dist/esm/index-a58f8b91.js.map +0 -1
- package/dist/esm/index.es-b80b758c.js.map +0 -1
- package/dist/esm/mg-action-more_36.entry.js.map +0 -1
- package/dist/mg-components/p-3afebdab.entry.js +0 -2
- package/dist/mg-components/p-3afebdab.entry.js.map +0 -1
- package/dist/mg-components/p-3c6710be.js.map +0 -1
- package/dist/mg-components/p-ac8a5083.js +0 -2
- package/dist/mg-components/p-bc6ec847.entry.js.map +0 -1
- /package/dist/mg-components/{p-2a633b29.entry.js.map → p-c10433db.entry.js.map} +0 -0
- /package/dist/mg-components/{p-f2e6e7ae.entry.js.map → p-c67e4934.entry.js.map} +0 -0
- /package/dist/mg-components/{p-361cc090.entry.js.map → p-fd4a7980.entry.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-5059254f.js';
|
|
2
|
-
import { G as Ge, V as Ve, Z as Ze, m as me, s as st, X as Xe, K as Ke, t as tt, w as we, z as ze, $ as $t, f as ft, d as dt, p as pt, g as gt, u as ut, J as Je, Y as Ye, Q as Qe } from './index.es-
|
|
3
|
-
import { i as initLocales } from './index-
|
|
2
|
+
import { G as Ge, V as Ve, Z as Ze, m as me, s as st, X as Xe, K as Ke, t as tt, w as we, z as ze, $ as $t, f as ft, d as dt, p as pt, g as gt, u as ut, J as Je, Y as Ye, Q as Qe } from './index.es-517b1bf2.js';
|
|
3
|
+
import { i as initLocales } from './index-544778a7.js';
|
|
4
4
|
import { t as tooltipPositions, c as classFieldset, a as classReadonly, b as classDisabled, d as classVerticalList, w as widths } from './mg-input.conf-712c7bb6.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -27,7 +27,7 @@ const directions$1 = {
|
|
|
27
27
|
/**
|
|
28
28
|
* List of all possibles sizes
|
|
29
29
|
*/
|
|
30
|
-
const sizes$
|
|
30
|
+
const sizes$5 = ['medium', 'large', 'xlarge'];
|
|
31
31
|
|
|
32
32
|
const mgActionMoreCss = ".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}}:host{--mg-c-popover-padding-vertical:var(--mg-b-size-8);--mg-c-popover-padding-horizontal:0;--mg-c-popover-max-width:unset}.mg-c-action-more__divider{--mg-c-divider-spacing-vertical:var(--mg-b-size-4)}.mg-c-action-more__chevron{transition:200ms}.mg-c-action-more__chevron--rotate.mg-c-action-more__chevron{transform:rotate(180deg)}";
|
|
33
33
|
const MgActionMoreStyle0 = mgActionMoreCss;
|
|
@@ -264,7 +264,7 @@ MgBadge.style = MgBadgeStyle0;
|
|
|
264
264
|
/**
|
|
265
265
|
* List of all possibles sizes
|
|
266
266
|
*/
|
|
267
|
-
const sizes$
|
|
267
|
+
const sizes$4 = ['medium', 'large'];
|
|
268
268
|
/**
|
|
269
269
|
* List of all possibles variants
|
|
270
270
|
*/
|
|
@@ -291,7 +291,7 @@ const MgButton = class {
|
|
|
291
291
|
/**
|
|
292
292
|
* Define button size
|
|
293
293
|
*/
|
|
294
|
-
this.size = sizes$
|
|
294
|
+
this.size = sizes$4[0]; // medium
|
|
295
295
|
/**
|
|
296
296
|
* Set button to full-width
|
|
297
297
|
*/
|
|
@@ -358,7 +358,7 @@ const MgButton = class {
|
|
|
358
358
|
this.setIconSize = () => {
|
|
359
359
|
var _a, _b;
|
|
360
360
|
if (this.size === 'medium') {
|
|
361
|
-
(_a = this.element.querySelector('mg-icon')) === null || _a === void 0 ? void 0 : _a.removeAttribute('size');
|
|
361
|
+
(_a = this.element.querySelector('mg-icon[size]')) === null || _a === void 0 ? void 0 : _a.removeAttribute('size');
|
|
362
362
|
}
|
|
363
363
|
else if (this.isIcon) {
|
|
364
364
|
(_b = this.element.querySelector('mg-icon')) === null || _b === void 0 ? void 0 : _b.setAttribute('size', this.size);
|
|
@@ -384,8 +384,8 @@ const MgButton = class {
|
|
|
384
384
|
}
|
|
385
385
|
validateSize(newValue, oldValue) {
|
|
386
386
|
// validate new value
|
|
387
|
-
if (!sizes$
|
|
388
|
-
throw new Error(`<mg-button> prop "size" must be one of: ${sizes$
|
|
387
|
+
if (!sizes$4.includes(newValue)) {
|
|
388
|
+
throw new Error(`<mg-button> prop "size" must be one of: ${sizes$4.join(', ')}. Passed value: ${Ve(newValue)}.`);
|
|
389
389
|
}
|
|
390
390
|
else {
|
|
391
391
|
if (oldValue !== undefined) {
|
|
@@ -424,7 +424,13 @@ const MgButton = class {
|
|
|
424
424
|
// emit value update
|
|
425
425
|
this.disabledChange.emit(isDisabled);
|
|
426
426
|
}
|
|
427
|
-
watchIsIcon() {
|
|
427
|
+
watchIsIcon(newValue) {
|
|
428
|
+
if (newValue) {
|
|
429
|
+
this.classCollection.add(`mg-c-button--icon`);
|
|
430
|
+
if (!me(this.label)) {
|
|
431
|
+
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
428
434
|
this.setIconSize();
|
|
429
435
|
}
|
|
430
436
|
loadingHandler(newValue) {
|
|
@@ -443,13 +449,7 @@ const MgButton = class {
|
|
|
443
449
|
this.validateVariant(this.variant);
|
|
444
450
|
this.validateFullWidth(this.fullWidth);
|
|
445
451
|
this.validateSize(this.size);
|
|
446
|
-
this.watchIsIcon();
|
|
447
|
-
if (this.isIcon) {
|
|
448
|
-
this.classCollection.add(`mg-c-button--icon`);
|
|
449
|
-
if (!me(this.label)) {
|
|
450
|
-
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
452
|
+
this.watchIsIcon(this.isIcon);
|
|
453
453
|
// Store the onclick fn
|
|
454
454
|
this.onClickElementFn = this.element.onclick;
|
|
455
455
|
this.disabledHandler(this.disabled);
|
|
@@ -475,7 +475,7 @@ const MgButton = class {
|
|
|
475
475
|
*/
|
|
476
476
|
render() {
|
|
477
477
|
var _a;
|
|
478
|
-
return (h(Host, { key: '
|
|
478
|
+
return (h(Host, { key: 'bb6328d9245f36de9f6f3d503b16961fc34206fc', role: "button", tabIndex: 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": (_a = this.disabled) === null || _a === void 0 ? void 0 : _a.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, h("div", { key: '9c7c1adfb0c6752d745bfb0b407f6be65c08b82a', class: this.classCollection.join() }, this.loading && h("mg-icon", { key: '0d6471de739aa33ec60e69aab941c73eadefab54', icon: "loader", spin: true }), h("div", { key: 'cecf5647a5dcb0538e514abf47bc09ab1efcfc9c', class: "mg-c-button__content" }, h("slot", { key: '15a6d2e63e6ec4668697bf74f2271432598faf06' })))));
|
|
479
479
|
}
|
|
480
480
|
get element() { return getElement(this); }
|
|
481
481
|
static get watchers() { return {
|
|
@@ -889,7 +889,7 @@ MgForm.style = MgFormStyle0;
|
|
|
889
889
|
/**
|
|
890
890
|
* List of all possibles sizes
|
|
891
891
|
*/
|
|
892
|
-
const sizes$
|
|
892
|
+
const sizes$3 = ['small', 'medium', 'large', 'xlarge', 'xxlarge'];
|
|
893
893
|
/**
|
|
894
894
|
* List of all possibles variants
|
|
895
895
|
*/
|
|
@@ -932,30 +932,45 @@ const MgIcon = class {
|
|
|
932
932
|
* @param icon - icon to render
|
|
933
933
|
*/
|
|
934
934
|
this.renderIcon = (icon) => {
|
|
935
|
-
|
|
936
|
-
|
|
935
|
+
var _a;
|
|
936
|
+
// Remove existing SVG from ShadowRoot
|
|
937
|
+
(_a = this.element.shadowRoot.querySelector('svg')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
938
|
+
// Append new SVG to ShadowRoot
|
|
939
|
+
const svgContainer = document.createElement('div');
|
|
940
|
+
svgContainer.innerHTML = icons[icon];
|
|
941
|
+
this.element.shadowRoot.append(svgContainer.firstChild);
|
|
942
|
+
svgContainer.remove();
|
|
937
943
|
// update svg attributes
|
|
944
|
+
this.svg = this.element.shadowRoot.querySelector('svg');
|
|
938
945
|
this.svg.setAttribute('aria-hidden', 'true');
|
|
939
946
|
this.svg.setAttribute('focusable', 'false');
|
|
940
947
|
this.svg.setAttribute('class', this.classCollection.join());
|
|
941
948
|
};
|
|
942
949
|
}
|
|
943
950
|
validateIcon(newValue, oldValue) {
|
|
944
|
-
if (!Object.keys(icons).includes(newValue))
|
|
951
|
+
if (!Object.keys(icons).includes(newValue)) {
|
|
945
952
|
throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}. Passed value: ${Ve(newValue)}.`);
|
|
953
|
+
}
|
|
946
954
|
else {
|
|
947
|
-
if (oldValue !== undefined)
|
|
955
|
+
if (oldValue !== undefined) {
|
|
948
956
|
this.classCollection.delete(`mg-c-icon--${oldValue}`);
|
|
957
|
+
}
|
|
949
958
|
this.classCollection.add(`mg-c-icon--${newValue}`);
|
|
950
959
|
this.renderIcon(newValue);
|
|
951
960
|
}
|
|
952
961
|
}
|
|
953
962
|
validateSize(newValue, oldValue) {
|
|
954
|
-
|
|
955
|
-
|
|
963
|
+
// When removing size attribute, it is set to null
|
|
964
|
+
if (newValue === null) {
|
|
965
|
+
newValue = 'medium';
|
|
966
|
+
}
|
|
967
|
+
if (!sizes$3.includes(newValue)) {
|
|
968
|
+
throw new Error(`<mg-icon> prop "size" must be one of: ${sizes$3.join(', ')}. Passed value: ${Ve(newValue)}.`);
|
|
969
|
+
}
|
|
956
970
|
else {
|
|
957
|
-
if (oldValue !== undefined)
|
|
971
|
+
if (oldValue !== undefined) {
|
|
958
972
|
this.classCollection.delete(`mg-c-icon--size-${oldValue}`);
|
|
973
|
+
}
|
|
959
974
|
this.classCollection.add(`mg-c-icon--size-${newValue}`);
|
|
960
975
|
}
|
|
961
976
|
}
|
|
@@ -1022,7 +1037,7 @@ MgIcon.style = MgIconStyle0;
|
|
|
1022
1037
|
/**
|
|
1023
1038
|
* List of all possibles sizes
|
|
1024
1039
|
*/
|
|
1025
|
-
const sizes$
|
|
1040
|
+
const sizes$2 = ['small', 'medium', 'large'];
|
|
1026
1041
|
/**
|
|
1027
1042
|
* List of all possibles directions
|
|
1028
1043
|
*/
|
|
@@ -1048,8 +1063,8 @@ const MgIllustratedMessage = class {
|
|
|
1048
1063
|
this.classCollection = new Ze(['mg-c-illustrated-message']);
|
|
1049
1064
|
}
|
|
1050
1065
|
watchSize(newValue, oldValue) {
|
|
1051
|
-
if (!sizes$
|
|
1052
|
-
throw new Error(`<mg-illustrated-message> prop "size" must be one of: ${sizes$
|
|
1066
|
+
if (!sizes$2.includes(newValue)) {
|
|
1067
|
+
throw new Error(`<mg-illustrated-message> prop "size" must be one of: ${sizes$2.join(', ')}. Passed value: ${Ve(newValue)}.`);
|
|
1053
1068
|
}
|
|
1054
1069
|
else {
|
|
1055
1070
|
if (oldValue !== undefined) {
|
|
@@ -2021,16 +2036,18 @@ const MgInputCheckboxPaginated = class {
|
|
|
2021
2036
|
* @returns HTML Element
|
|
2022
2037
|
*/
|
|
2023
2038
|
render() {
|
|
2024
|
-
const getText = (checkboxes) => (h("em", { key: '8f20e5be81047106e04cd101385b9c6555c0c38d', class: "mg-c-input__section-header-title-label" }, `${this.messages[checkboxes.length > 1 ? '
|
|
2039
|
+
const getText = (checkboxes) => (h("em", { key: '8f20e5be81047106e04cd101385b9c6555c0c38d', class: "mg-c-input__section-header-title-label" }, `${this.messages[checkboxes.length > 1 ? 'titlePlural' : 'title']} (${checkboxes.length})`));
|
|
2025
2040
|
const [from, to] = this.getFromToIndexes();
|
|
2026
2041
|
const itemsContainerId = `items-${this.sectionKind}-container`;
|
|
2027
|
-
return (h(Host, { key: '
|
|
2042
|
+
return (h(Host, { key: 'ed5b99164dd8b03ce07b60b373eaacd17a030f4b', hidden: this.checkboxes.length < 1 }, h("div", { key: 'bd8f69a280da86a7eba42f5bd4eaaa1df75f0303', class: "mg-c-input__section-header" }, this.sectionKind === SectionKind.SELECTED ? (h("mg-button", { variant: "flat", onClick: this.handleToggleClick, "aria-controls": itemsContainerId, "aria-expanded": this.expanded.toString() }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), h("span", { class: "mg-c-input__section-header-title" }, getText(this.checkboxes)))) : (h("p", { class: "mg-c-input__section-header-title mg-c-input__section-header-title--static" }, getText(this.checkboxes))), ((this.sectionKind === SectionKind.SELECTED && this.expanded) || this.sectionKind === SectionKind.NOT_SELECTED) && (h("mg-tooltip", { key: 'e33ca1a20b2fb420b678a884e24e53913b6024d6', class: "mg-c-input__section-header-tootlip", message: this.messages.tooltip }, h("mg-button", { key: '6d2e26d70c22b633085cc3d1dd735fe68398326b', variant: "link", onClick: this.massActionHandler }, this.messages.action))), this.expanded && this.getPageCount(this.checkboxes) > 1 && (h("mg-pagination", { key: "search-pagination", totalPages: this.getPageCount(this.checkboxes), currentPage: this.currentPage, "onCurrent-page-change": this.handleCurrentPageChange, hideNavigationLabels: true, hidePageCount: true, identifier: `input-checkbox-pagination-${this.sectionKind}` }))), h("div", { key: '32468986664f58c857ab733e2ed814f09723b2c2', hidden: !this.expanded, id: itemsContainerId, class: "mg-c-input__section-content" }, h(MgInputCheckboxList, { key: 'f86f3e0bdec85575699b101c3b21147c3b9bc8e2', checkboxes: this.getArrayRange(this.checkboxes, from, to), displaySearchInput: true, messages: this.messages, id: `items-${this.sectionKind}`, disabled: this.disabled, name: this.name, invalid: this.invalid }))));
|
|
2028
2043
|
}
|
|
2029
2044
|
static get watchers() { return {
|
|
2030
2045
|
"checkboxes": ["watchCheckboxes"]
|
|
2031
2046
|
}; }
|
|
2032
2047
|
};
|
|
2033
2048
|
|
|
2049
|
+
const DEFAULT_MAX_DATE = '9999-12-31';
|
|
2050
|
+
|
|
2034
2051
|
const mgInputDateCss = ".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);word-break:break-word}.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-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}}";
|
|
2035
2052
|
const MgInputDateStyle0 = mgInputDateCss;
|
|
2036
2053
|
|
|
@@ -2062,7 +2079,7 @@ const MgInputDate = class {
|
|
|
2062
2079
|
* Define input maximum date
|
|
2063
2080
|
* format: yyyy-mm-dd
|
|
2064
2081
|
*/
|
|
2065
|
-
this.max = '9999-12-31';
|
|
2082
|
+
this.max = '9999-12-31'; // Hardcoded value matching DEFAULT_MAX_DATE for documentation
|
|
2066
2083
|
/**
|
|
2067
2084
|
* Define if input is disabled
|
|
2068
2085
|
*/
|
|
@@ -2087,11 +2104,36 @@ const MgInputDate = class {
|
|
|
2087
2104
|
* @returns formated pattern help text. Ex: Format attendu : jj/mm/aaaa (ex : 20/12/2020)
|
|
2088
2105
|
*/
|
|
2089
2106
|
this.formatHelpText = (helpText) => {
|
|
2107
|
+
var _a, _b;
|
|
2108
|
+
// If the component is in readonly mode, return directly because the message will not be rendered
|
|
2109
|
+
if (this.readonly) {
|
|
2110
|
+
return undefined;
|
|
2111
|
+
}
|
|
2090
2112
|
const defaultHelpTextVariable = '{defaultHelpText}';
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2113
|
+
// If a custom helpText is provided, store it but don't return it directly
|
|
2114
|
+
let text = me(helpText) ? helpText : this.messages.input.date.helpText.expectedFormat;
|
|
2115
|
+
// Handle defaultHelpText
|
|
2116
|
+
if (text.includes(defaultHelpTextVariable)) {
|
|
2117
|
+
text = text.replace(defaultHelpTextVariable, this.formatHelpText(this.messages.input.date.helpText.expectedFormat));
|
|
2118
|
+
}
|
|
2119
|
+
// Replace pattern and date variables
|
|
2120
|
+
text = text.replace('{pattern}', this.renderPattern()).replace('{date}', ze($t(new Date('2025-12-24')), this.systemLocale));
|
|
2121
|
+
// Add additional message for min/max if necessary
|
|
2122
|
+
let rangeMessage;
|
|
2123
|
+
if (((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== DEFAULT_MAX_DATE) {
|
|
2124
|
+
rangeMessage = this.messages.input.date.helpText.minMax.replace('{min}', ze(this.min, this.systemLocale)).replace('{max}', ze(this.max, this.systemLocale));
|
|
2125
|
+
}
|
|
2126
|
+
else if (((_b = this.min) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
2127
|
+
rangeMessage = this.messages.input.date.helpText.min.replace('{min}', ze(this.min, this.systemLocale));
|
|
2128
|
+
}
|
|
2129
|
+
else if (this.max !== DEFAULT_MAX_DATE) {
|
|
2130
|
+
rangeMessage = this.messages.input.date.helpText.max.replace('{max}', ze(this.max, this.systemLocale));
|
|
2131
|
+
}
|
|
2132
|
+
// Combine custom helpText with range message if both exist
|
|
2133
|
+
if (text !== undefined && rangeMessage !== undefined) {
|
|
2134
|
+
return `${text}<br>${rangeMessage}`;
|
|
2135
|
+
}
|
|
2136
|
+
return text;
|
|
2095
2137
|
};
|
|
2096
2138
|
/**
|
|
2097
2139
|
* Handle input event
|
|
@@ -2141,28 +2183,27 @@ const MgInputDate = class {
|
|
|
2141
2183
|
*/
|
|
2142
2184
|
this.getInputError = () => {
|
|
2143
2185
|
var _a;
|
|
2144
|
-
let inputError = null;
|
|
2145
2186
|
// bad input or pattern
|
|
2146
2187
|
if (this.input.validity.badInput || (this.value && !this.isValidPattern(this.value))) {
|
|
2147
|
-
|
|
2188
|
+
return 'badInput';
|
|
2148
2189
|
}
|
|
2149
2190
|
// required
|
|
2150
|
-
|
|
2151
|
-
|
|
2191
|
+
if (this.input.validity.valueMissing) {
|
|
2192
|
+
return 'required';
|
|
2152
2193
|
}
|
|
2153
2194
|
// min & max
|
|
2154
|
-
|
|
2155
|
-
|
|
2195
|
+
if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== DEFAULT_MAX_DATE) {
|
|
2196
|
+
return 'minMax';
|
|
2156
2197
|
}
|
|
2157
2198
|
// min
|
|
2158
|
-
|
|
2159
|
-
|
|
2199
|
+
if (this.input.validity.rangeUnderflow) {
|
|
2200
|
+
return 'min';
|
|
2160
2201
|
}
|
|
2161
2202
|
// max
|
|
2162
|
-
|
|
2163
|
-
|
|
2203
|
+
if (this.input.validity.rangeOverflow) {
|
|
2204
|
+
return 'max';
|
|
2164
2205
|
}
|
|
2165
|
-
return
|
|
2206
|
+
return null;
|
|
2166
2207
|
};
|
|
2167
2208
|
/**
|
|
2168
2209
|
* Check input errors
|
|
@@ -2182,14 +2223,16 @@ const MgInputDate = class {
|
|
|
2182
2223
|
}
|
|
2183
2224
|
// min, max & minMax
|
|
2184
2225
|
else if (['min', 'max', 'minMax'].includes(inputError)) {
|
|
2185
|
-
this.errorMessage = this.messages.
|
|
2226
|
+
this.errorMessage = this.messages.input.date.helpText[inputError]
|
|
2186
2227
|
.replace('{min}', ze(this.min, this.systemLocale))
|
|
2187
2228
|
.replace('{max}', ze(this.max, this.systemLocale));
|
|
2188
2229
|
}
|
|
2189
2230
|
// wrong date format
|
|
2190
2231
|
// element.validity.badInput is default error message
|
|
2191
2232
|
else {
|
|
2192
|
-
this.errorMessage = this.messages.
|
|
2233
|
+
this.errorMessage = this.messages.input.date.error.badInput
|
|
2234
|
+
.replace('{pattern}', this.renderPattern())
|
|
2235
|
+
.replace('{date}', ze($t(new Date('2025-12-24')), this.systemLocale));
|
|
2193
2236
|
}
|
|
2194
2237
|
}
|
|
2195
2238
|
};
|
|
@@ -2348,7 +2391,7 @@ const MgInputDate = class {
|
|
|
2348
2391
|
* @returns HTML Element
|
|
2349
2392
|
*/
|
|
2350
2393
|
render() {
|
|
2351
|
-
return (h("mg-input", { key: '
|
|
2394
|
+
return (h("mg-input", { key: '81d2fbf8eef1bcfcf4520a82825b252b6256e72d', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === null ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly ? (this.value && h("b", { class: "mg-c-input__readonly-value" }, ze(this.value, this.locale))) : (h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, ref: (el) => {
|
|
2352
2395
|
if (el !== null)
|
|
2353
2396
|
this.input = el;
|
|
2354
2397
|
} }))));
|
|
@@ -2498,7 +2541,7 @@ const MgInputNumeric = class {
|
|
|
2498
2541
|
else {
|
|
2499
2542
|
const formattedMin = this.formatErrorValue(this.min);
|
|
2500
2543
|
const formattedMax = this.formatErrorValue(this.max);
|
|
2501
|
-
this.errorMessage = this.messages.
|
|
2544
|
+
this.errorMessage = this.messages.input.numeric.helpText[inputError].replace('{min}', formattedMin).replace('{max}', formattedMax);
|
|
2502
2545
|
}
|
|
2503
2546
|
}
|
|
2504
2547
|
};
|
|
@@ -2507,26 +2550,24 @@ const MgInputNumeric = class {
|
|
|
2507
2550
|
* @returns error code
|
|
2508
2551
|
*/
|
|
2509
2552
|
this.getInputError = () => {
|
|
2510
|
-
let inputError = null;
|
|
2511
2553
|
const hasNotEmptyValues = (toControl) => !toControl.some(value => [null, undefined].includes(value));
|
|
2512
2554
|
// required
|
|
2513
2555
|
if (!this.input.checkValidity() && this.input.validity.valueMissing) {
|
|
2514
|
-
|
|
2556
|
+
return 'required';
|
|
2515
2557
|
}
|
|
2516
|
-
//
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
inputError = 'min';
|
|
2558
|
+
// Only a min value is set
|
|
2559
|
+
if (hasNotEmptyValues([this.min, this.numericValue]) && this.numericValue < this.min && this.max === undefined) {
|
|
2560
|
+
return 'min';
|
|
2520
2561
|
}
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2562
|
+
// Only a max value is set
|
|
2563
|
+
if (hasNotEmptyValues([this.max, this.numericValue]) && this.numericValue > this.max && this.min === undefined) {
|
|
2564
|
+
return 'max';
|
|
2524
2565
|
}
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2566
|
+
// both min and max values are set
|
|
2567
|
+
if (hasNotEmptyValues([this.min, this.max, this.numericValue]) && (this.numericValue < this.min || this.numericValue > this.max)) {
|
|
2568
|
+
return 'minMax';
|
|
2528
2569
|
}
|
|
2529
|
-
return
|
|
2570
|
+
return null;
|
|
2530
2571
|
};
|
|
2531
2572
|
/**
|
|
2532
2573
|
* Format value based on type
|
|
@@ -2562,6 +2603,41 @@ const MgInputNumeric = class {
|
|
|
2562
2603
|
}
|
|
2563
2604
|
}
|
|
2564
2605
|
};
|
|
2606
|
+
/**
|
|
2607
|
+
* Format help text to display
|
|
2608
|
+
* @param helpText - help text format
|
|
2609
|
+
* @returns formatted help text with range information if applicable
|
|
2610
|
+
*/
|
|
2611
|
+
this.formatHelpText = (helpText) => {
|
|
2612
|
+
// If the component is in readonly mode, return undefined because the message will not be rendered
|
|
2613
|
+
if (this.readonly) {
|
|
2614
|
+
return undefined;
|
|
2615
|
+
}
|
|
2616
|
+
// If a custom helpText is provided, store it but don't return it directly
|
|
2617
|
+
const text = me(helpText) ? helpText : undefined;
|
|
2618
|
+
// If neither min nor max are defined, and there's no custom helpText,
|
|
2619
|
+
// we can return undefined as there's no message to display
|
|
2620
|
+
if (this.min === undefined && this.max === undefined && text === undefined) {
|
|
2621
|
+
return undefined;
|
|
2622
|
+
}
|
|
2623
|
+
// Generate range message based on available constraints
|
|
2624
|
+
let rangeMessage;
|
|
2625
|
+
if (this.min !== undefined && this.max !== undefined) {
|
|
2626
|
+
rangeMessage = this.messages.input.numeric.helpText.minMax.replace('{min}', this.formatErrorValue(this.min)).replace('{max}', this.formatErrorValue(this.max));
|
|
2627
|
+
}
|
|
2628
|
+
else if (this.min !== undefined) {
|
|
2629
|
+
rangeMessage = this.messages.input.numeric.helpText.min.replace('{min}', this.formatErrorValue(this.min));
|
|
2630
|
+
}
|
|
2631
|
+
else if (this.max !== undefined) {
|
|
2632
|
+
rangeMessage = this.messages.input.numeric.helpText.max.replace('{max}', this.formatErrorValue(this.max));
|
|
2633
|
+
}
|
|
2634
|
+
// Combine custom helpText with range message if both exist
|
|
2635
|
+
if (text !== undefined && rangeMessage !== undefined) {
|
|
2636
|
+
return `${text}<br>${rangeMessage}`;
|
|
2637
|
+
}
|
|
2638
|
+
// Return either custom helpText or range message
|
|
2639
|
+
return text || rangeMessage;
|
|
2640
|
+
};
|
|
2565
2641
|
/**
|
|
2566
2642
|
* Renders the readonly content of the input component.
|
|
2567
2643
|
* @returns The readonly content element.
|
|
@@ -2571,18 +2647,19 @@ const MgInputNumeric = class {
|
|
|
2571
2647
|
};
|
|
2572
2648
|
}
|
|
2573
2649
|
validateValue(newValue) {
|
|
2650
|
+
var _a;
|
|
2574
2651
|
// has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type
|
|
2575
2652
|
if (typeof newValue === 'string') {
|
|
2576
2653
|
// Split number and decimal
|
|
2577
2654
|
const [integer, decimal = ''] = newValue.replace('-', '').split(/[.,]/);
|
|
2578
2655
|
// Regex
|
|
2579
|
-
const regex = this.type === 'integer' ?
|
|
2656
|
+
const regex = this.type === 'integer' ? /^(?!-?0\d)-?\d+$/ : /^(?!-?0\d)-?\d+(?:[.,]\d*)?$/;
|
|
2580
2657
|
// Filter input
|
|
2581
2658
|
if (this.isValidValue(newValue, regex, integer, decimal)) {
|
|
2582
2659
|
this.storedValue = newValue;
|
|
2583
2660
|
}
|
|
2584
2661
|
else {
|
|
2585
|
-
newValue = this.
|
|
2662
|
+
newValue = (_a = this.storedValue) !== null && _a !== void 0 ? _a : null;
|
|
2586
2663
|
}
|
|
2587
2664
|
// Set value and input value
|
|
2588
2665
|
this.updateValues(newValue);
|
|
@@ -2713,24 +2790,19 @@ const MgInputNumeric = class {
|
|
|
2713
2790
|
isValidValue(value, regex, integer, decimal) {
|
|
2714
2791
|
return (['', '-'].includes(value) || (regex.exec(value) !== null && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength)));
|
|
2715
2792
|
}
|
|
2716
|
-
/**
|
|
2717
|
-
* Handles invalid input values and returns a corrected value.
|
|
2718
|
-
* @returns The corrected value.
|
|
2719
|
-
*/
|
|
2720
|
-
handleInvalidValue() {
|
|
2721
|
-
var _a;
|
|
2722
|
-
return (_a = this.storedValue) !== null && _a !== void 0 ? _a : null;
|
|
2723
|
-
}
|
|
2724
2793
|
/**
|
|
2725
2794
|
* Updates the component values based on the validated input value.
|
|
2726
2795
|
* @param newValue - The validated input value.
|
|
2727
2796
|
*/
|
|
2728
2797
|
updateValues(newValue) {
|
|
2729
2798
|
this.value = newValue;
|
|
2730
|
-
if (this.input !== undefined)
|
|
2799
|
+
if (this.input !== undefined) {
|
|
2731
2800
|
this.input.value = this.value;
|
|
2732
|
-
|
|
2733
|
-
this.
|
|
2801
|
+
}
|
|
2802
|
+
this.numericValue = !['', null].includes(this.value) && !isNaN(parseFloat(this.value)) ? parseFloat(this.value.replace(',', '.')) : null;
|
|
2803
|
+
if (newValue === null || (newValue === this.storedValue && !Object.is(this.numericValue, -0))) {
|
|
2804
|
+
this.valueChange.emit(this.numericValue);
|
|
2805
|
+
}
|
|
2734
2806
|
this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
|
|
2735
2807
|
}
|
|
2736
2808
|
/**
|
|
@@ -2776,7 +2848,7 @@ const MgInputNumeric = class {
|
|
|
2776
2848
|
* @returns HTML Element
|
|
2777
2849
|
*/
|
|
2778
2850
|
render() {
|
|
2779
|
-
return (h("mg-input", { key: '
|
|
2851
|
+
return (h("mg-input", { key: '18969e04e5a1c865142ea70ad9a6aaba79489631', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.formatHelpText(this.helpText), errorMessage: this.errorMessage }, this.readonly
|
|
2780
2852
|
? this.readonlyValue && this.renderReadonly()
|
|
2781
2853
|
: [
|
|
2782
2854
|
h("input", { key: "input", type: "text", class: "mg-c-input__box mg-c-input__box--width", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
@@ -3670,6 +3742,14 @@ const MgInputSelect = class {
|
|
|
3670
3742
|
};
|
|
3671
3743
|
MgInputSelect.style = MgInputSelectStyle0;
|
|
3672
3744
|
|
|
3745
|
+
/**
|
|
3746
|
+
* TextType from text types
|
|
3747
|
+
*/
|
|
3748
|
+
// Define possible text types with help text
|
|
3749
|
+
const helpTextTypes = ['email', 'emails', 'url'];
|
|
3750
|
+
// Define possible text types
|
|
3751
|
+
const textTypes = ['text', 'search', 'tel', ...helpTextTypes];
|
|
3752
|
+
|
|
3673
3753
|
const mgInputTextCss = ".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__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-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);word-break:break-word}.mg-c-input.mg-c-input--display-character-left mg-character-left{font-size:var(--mg-b-font-size-small);opacity:.6}.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__help-text ::slotted(*),.mg-c-input.mg-c-input--display-character-left .mg-c-input__input+.mg-c-input__error ::slotted(*){margin-top:0}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}.mg-c-input__with-character-left{position:relative;width:100%}.mg-c-input.mg-u-is-focused .mg-c-input__with-character-left .mg-c-input__box{padding-right:max(var(--mg-c-character-left-message-length)*(.35ch + .3rem) + var(--mg-b-size-16)*clamp(0,var(--mg-c-character-left-message-length),1),var(--mg-b-size-8))}.mg-c-input__with-character-left mg-character-left{position:absolute;top:50%;right:var(--mg-b-size-8);display:none;font-size:var(--mg-b-font-size-small);opacity:.6;transform:translateY(-50%)}.mg-c-input.mg-u-is-focused .mg-c-input__with-character-left mg-character-left{display:block}.mg-c-input.mg-c-input--readonly b{min-height:var(--mg-b-font-size);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--has-icon .mg-c-input__with-character-left>mg-icon{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{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}";
|
|
3674
3754
|
const MgInputTextStyle0 = mgInputTextCss;
|
|
3675
3755
|
|
|
@@ -3746,6 +3826,16 @@ const MgInputText = class {
|
|
|
3746
3826
|
* Component classes
|
|
3747
3827
|
*/
|
|
3748
3828
|
this.classCollection = new Ze(['mg-c-input--text']);
|
|
3829
|
+
/**
|
|
3830
|
+
* Validate pattern configuration
|
|
3831
|
+
*/
|
|
3832
|
+
this.validatePattern = () => {
|
|
3833
|
+
if ((this.pattern !== undefined || this.patternErrorMessage !== undefined) && // At least one is defined
|
|
3834
|
+
(!me(this.pattern) || (!helpTextTypes.includes(this.type) && !me(this.patternErrorMessage))) // Both must be defined
|
|
3835
|
+
) {
|
|
3836
|
+
throw new Error(`<mg-input-text> props "pattern" and "patternErrorMessage" must be non-empty string and paired. Passed value: "pattern='${this.pattern}'" and "patternErrorMessage='${this.patternErrorMessage}'".`);
|
|
3837
|
+
}
|
|
3838
|
+
};
|
|
3749
3839
|
/**
|
|
3750
3840
|
* Handle input event
|
|
3751
3841
|
*/
|
|
@@ -3788,15 +3878,20 @@ const MgInputText = class {
|
|
|
3788
3878
|
* @param errorMessage - errorMessage override
|
|
3789
3879
|
*/
|
|
3790
3880
|
this.setErrorMessage = (errorMessage) => {
|
|
3881
|
+
var _a;
|
|
3791
3882
|
// Set error message
|
|
3792
3883
|
this.errorMessage = undefined;
|
|
3793
3884
|
// Does have a custom error message
|
|
3794
3885
|
if (!this.valid && errorMessage !== undefined) {
|
|
3795
3886
|
this.errorMessage = errorMessage;
|
|
3796
3887
|
}
|
|
3888
|
+
// Does not match type (email, emails, tel, url, etc.)
|
|
3889
|
+
else if (!this.valid && this.input.validity.typeMismatch) {
|
|
3890
|
+
this.errorMessage = `${this.messages.input.text.errors.typeMismatch} ${this.messages.input.text.helpText[this.type]}`;
|
|
3891
|
+
}
|
|
3797
3892
|
// Does not match pattern
|
|
3798
3893
|
else if (!this.valid && this.input.validity.patternMismatch) {
|
|
3799
|
-
this.errorMessage = this.patternErrorMessage
|
|
3894
|
+
this.errorMessage = (_a = this.patternErrorMessage) !== null && _a !== void 0 ? _a : `${this.messages.input.text.errors.typeMismatch} ${this.messages.input.text.helpText[this.type]}`;
|
|
3800
3895
|
}
|
|
3801
3896
|
// required
|
|
3802
3897
|
else if (!this.valid && this.input.validity.valueMissing) {
|
|
@@ -3844,6 +3939,11 @@ const MgInputText = class {
|
|
|
3844
3939
|
this.valueChange.emit(newValue);
|
|
3845
3940
|
}
|
|
3846
3941
|
}
|
|
3942
|
+
validateType(newValue) {
|
|
3943
|
+
if (!textTypes.includes(newValue)) {
|
|
3944
|
+
throw new Error(`<mg-input-text> prop "type" must be one of the following values: ${textTypes.join(', ')}. Passed value: ${newValue}.`);
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3847
3947
|
validateIcon(newValue) {
|
|
3848
3948
|
if (newValue !== undefined) {
|
|
3849
3949
|
this.classCollection.add(this.classHasIcon);
|
|
@@ -3888,9 +3988,12 @@ const MgInputText = class {
|
|
|
3888
3988
|
if (newValue !== undefined)
|
|
3889
3989
|
this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
|
|
3890
3990
|
}
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3991
|
+
watchPattern() {
|
|
3992
|
+
this.validatePattern();
|
|
3993
|
+
}
|
|
3994
|
+
watchHelpText(newValue) {
|
|
3995
|
+
if (!me(newValue) && helpTextTypes.includes(this.type)) {
|
|
3996
|
+
this.helpText = this.messages.input.text.helpText[this.type];
|
|
3894
3997
|
}
|
|
3895
3998
|
}
|
|
3896
3999
|
/**
|
|
@@ -3977,12 +4080,13 @@ const MgInputText = class {
|
|
|
3977
4080
|
// Validate
|
|
3978
4081
|
this.validateIcon(this.icon);
|
|
3979
4082
|
this.validateDatalistoptions(this.datalistoptions);
|
|
3980
|
-
this.
|
|
3981
|
-
this.validatePattern(this.patternErrorMessage);
|
|
4083
|
+
this.watchPattern();
|
|
3982
4084
|
this.validateAppendSlot();
|
|
3983
4085
|
this.watchMgWidth(this.mgWidth);
|
|
3984
4086
|
this.watchReadonly(this.readonly);
|
|
3985
4087
|
this.watchDisabled(this.disabled);
|
|
4088
|
+
this.validateType(this.type);
|
|
4089
|
+
this.watchHelpText(this.helpText);
|
|
3986
4090
|
// Check validity when component is ready
|
|
3987
4091
|
// return a promise to process action only in the FIRST render().
|
|
3988
4092
|
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
@@ -3995,12 +4099,12 @@ const MgInputText = class {
|
|
|
3995
4099
|
* @returns HTML Element
|
|
3996
4100
|
*/
|
|
3997
4101
|
render() {
|
|
3998
|
-
return (h("mg-input", { key: '
|
|
4102
|
+
return (h("mg-input", { key: '388b69180071e34fa5ed51643126f5df43e14a7e', label: this.label, identifier: this.identifier, class: this.classCollection.join(), ariaDescribedbyIDs: [this.characterLeftId], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly
|
|
3999
4103
|
? this.value && this.renderReadonly()
|
|
4000
4104
|
: [
|
|
4001
4105
|
h("div", { key: "input", class: "mg-c-input__with-character-left", style: {
|
|
4002
4106
|
'--mg-c-character-left-message-length': (!this.characterLeftHide ? this.maxlength.toString().length * 2 + 1 : 0).toString(),
|
|
4003
|
-
} }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type, class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, list: this.hasDatalist() ? this.datalistId : undefined, autocomplete: this.hasDatalist() ? 'off' : undefined, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
4107
|
+
} }, this.icon !== undefined && h("mg-icon", { icon: this.icon }), h("input", { type: this.type === 'emails' ? 'email' : this.type, multiple: this.type === 'emails', class: "mg-c-input__box mg-c-input__box--width", value: this.value, id: this.identifier, list: this.hasDatalist() ? this.datalistId : undefined, autocomplete: this.hasDatalist() ? 'off' : undefined, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
|
|
4004
4108
|
if (el !== null)
|
|
4005
4109
|
this.input = el;
|
|
4006
4110
|
} }), this.hasDatalist() && (h("datalist", { id: this.datalistId }, this.datalistoptions.map(option => (h("option", { value: isOption$1(option) ? option.title : option, key: option }))))), !this.characterLeftHide && this.maxlength > 0 && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))),
|
|
@@ -4010,14 +4114,16 @@ const MgInputText = class {
|
|
|
4010
4114
|
get element() { return getElement(this); }
|
|
4011
4115
|
static get watchers() { return {
|
|
4012
4116
|
"value": ["handleValue"],
|
|
4117
|
+
"type": ["validateType"],
|
|
4013
4118
|
"icon": ["validateIcon"],
|
|
4014
4119
|
"datalistoptions": ["validateDatalistoptions"],
|
|
4015
4120
|
"readonly": ["watchReadonly", "handleValidityChange"],
|
|
4016
4121
|
"required": ["handleValidityChange"],
|
|
4017
4122
|
"disabled": ["handleValidityChange", "watchDisabled"],
|
|
4018
4123
|
"mgWidth": ["watchMgWidth"],
|
|
4019
|
-
"pattern": ["
|
|
4020
|
-
"patternErrorMessage": ["
|
|
4124
|
+
"pattern": ["watchPattern"],
|
|
4125
|
+
"patternErrorMessage": ["watchPattern"],
|
|
4126
|
+
"helpText": ["watchHelpText"]
|
|
4021
4127
|
}; }
|
|
4022
4128
|
};
|
|
4023
4129
|
MgInputText.style = MgInputTextStyle0;
|
|
@@ -4735,7 +4841,7 @@ const MgItemMore = class {
|
|
|
4735
4841
|
this.slotlabel.label = this.messages.menuLabel;
|
|
4736
4842
|
}
|
|
4737
4843
|
validateSize(newValue) {
|
|
4738
|
-
if (newValue && !sizes$
|
|
4844
|
+
if (newValue && !sizes$5.includes(newValue))
|
|
4739
4845
|
throw new Error(`<${this.name}> prop "size" must match MgItemMore['size'] type. Passed value: ${Ve(newValue)}.`);
|
|
4740
4846
|
}
|
|
4741
4847
|
/*************
|
|
@@ -4890,8 +4996,8 @@ const MgMenu = class {
|
|
|
4890
4996
|
}
|
|
4891
4997
|
}
|
|
4892
4998
|
validateSize(newValue) {
|
|
4893
|
-
if (!sizes$
|
|
4894
|
-
throw new Error(`<${this.name}> prop "size" must be one of: ${sizes$
|
|
4999
|
+
if (!sizes$5.includes(newValue)) {
|
|
5000
|
+
throw new Error(`<${this.name}> prop "size" must be one of: ${sizes$5.join(', ')}. Passed value: ${Ve(newValue)}.`);
|
|
4895
5001
|
}
|
|
4896
5002
|
}
|
|
4897
5003
|
/**
|
|
@@ -8446,6 +8552,285 @@ const MgSkipLinks = class {
|
|
|
8446
8552
|
};
|
|
8447
8553
|
MgSkipLinks.style = MgSkipLinksStyle0;
|
|
8448
8554
|
|
|
8555
|
+
/**
|
|
8556
|
+
* Sizes
|
|
8557
|
+
*/
|
|
8558
|
+
// Define possible sizes
|
|
8559
|
+
const sizes$1 = ['small', 'medium', 'large', 'xlarge'];
|
|
8560
|
+
/**
|
|
8561
|
+
* Columns
|
|
8562
|
+
*/
|
|
8563
|
+
// Define possible text alignments
|
|
8564
|
+
const textAlignments = ['left', 'center', 'right'];
|
|
8565
|
+
// Define possible data types
|
|
8566
|
+
const dataTypes = ['string', 'numeric', 'date'];
|
|
8567
|
+
|
|
8568
|
+
const mgTableCss = ".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}}@font-face{font-family:\"Open Sans\";src:url(\"fonts/OpenSans-Regular.ttf\") format(\"truetype\")}@font-face{font-family:\"Open Sans\";font-weight:600;src:url(\"fonts/OpenSans-SemiBold.ttf\") format(\"truetype\")}@font-face{font-family:\"Open Sans\";font-weight:700;src:url(\"fonts/OpenSans-Bold.ttf\") format(\"truetype\")}p{margin:0}p+p{margin-top:var(--mg-b-size-8)}h1,.mg-u-h1{font-family:var(--mg-b-font-family-heading);font-weight:bold}h2,.mg-u-h2{font-family:var(--mg-b-font-family-heading);font-weight:bold}h3,.mg-u-h3{font-family:var(--mg-b-font-family-heading);font-weight:bold}h4,.mg-u-h4{font-family:var(--mg-b-font-family-heading);font-weight:bold}h5,.mg-u-h5{font-family:var(--mg-b-font-family-heading);font-weight:bold}h6,.mg-u-h6{font-family:var(--mg-b-font-family-heading);font-weight:bold}h1,.mg-u-h1{font-size:var(--mg-b-font-size-h1)}h2,.mg-u-h2{font-size:var(--mg-b-font-size-h2)}h3,.mg-u-h3{font-size:var(--mg-b-font-size-h3)}h4,.mg-u-h4{font-size:var(--mg-b-font-size-h4)}h5,.mg-u-h5{font-size:var(--mg-b-font-size-h5)}h6,.mg-u-h6{font-size:var(--mg-b-font-size-h6)}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}small{font-size:var(--mg-b-small-font-size)}.mg-u-text-left{text-align:left !important}.mg-u-text-center{text-align:center !important}.mg-u-text-right{text-align:right !important}.mg-c-table{--mg-c-table-cell-spacing:var(--mg-b-size-8) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-40);--mg-c-table-header-cell-height:calc(var(--mg-b-size-min-height) + 2 * var(--mg-b-size-8));overflow:hidden;border:none;border-radius:var(--mg-b-size-8);background:var(--mg-b-color-light);border-collapse:separate;border-spacing:0;color:var(--mg-b-color-dark)}.mg-c-table td,.mg-c-table th{height:var(--mg-c-table-cell-height);box-sizing:border-box;padding:var(--mg-c-table-cell-spacing);text-align:start}.mg-c-table thead td,.mg-c-table th{font-weight:600}.mg-c-table thead{height:var(--mg-c-table-header-cell-height);background-color:var(--mg-b-color-app);color:var(--mg-b-color-light)}.mg-c-table :not(thead) tr:nth-child(even){background:color-mix(in srgb, var(--mg-b-color-app), transparent 80%)}.mg-c-table.mg-c-table--size-small{--mg-c-table-cell-spacing:var(--mg-b-size-4) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-32);--mg-c-table-header-cell-height:var(--mg-b-size-32)}.mg-c-table.mg-c-table--size-large{--mg-c-table-cell-height:var(--mg-c-table-header-cell-height)}.mg-c-table.mg-c-table--size-xlarge{--mg-c-table-cell-spacing:var(--mg-b-size-12) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-64);--mg-c-table-header-cell-height:var(--mg-b-size-64)}.mg-c-table.mg-c-table--full-width{width:100%}.mg-c-table-wrapper{overflow:auto}.mg-c-table thead td,.mg-c-table thead th{position:relative}.mg-c-table thead td .mg-c-table__sort-button,.mg-c-table thead th .mg-c-table__sort-button{padding:0;border:none;margin:0;background:none;color:inherit;font-size:inherit;font-weight:600}.mg-c-table thead td .mg-c-table__sort-button::after,.mg-c-table thead th .mg-c-table__sort-button::after{position:absolute;content:\"\";inset:0}.mg-c-table thead td .mg-c-table__sort-button:hover,.mg-c-table thead th .mg-c-table__sort-button:hover{cursor:pointer}.mg-c-table thead td .mg-c-table__sort-button mg-icon,.mg-c-table thead th .mg-c-table__sort-button mg-icon{margin-left:var(--mg-b-size-4)}.mg-c-table thead td:has(.mg-c-table__sort-button):hover,.mg-c-table thead td[aria-sort=descending],.mg-c-table thead td[aria-sort=ascending],.mg-c-table thead th:has(.mg-c-table__sort-button):hover,.mg-c-table thead th[aria-sort=descending],.mg-c-table thead th[aria-sort=ascending]{background-color:color-mix(in srgb, var(--mg-b-color-app), black 10%)}";
|
|
8569
|
+
const MgTableStyle0 = mgTableCss;
|
|
8570
|
+
|
|
8571
|
+
/**
|
|
8572
|
+
* Check if value is a valid align object
|
|
8573
|
+
* @param newValue - New value
|
|
8574
|
+
* @returns True if value is a valid align object
|
|
8575
|
+
*/
|
|
8576
|
+
const isValidColumnsObject = (newValue) =>
|
|
8577
|
+
// ensure newValue is an object
|
|
8578
|
+
typeof newValue === 'object' &&
|
|
8579
|
+
!Array.isArray(newValue) &&
|
|
8580
|
+
// Ensure every property is well formatted
|
|
8581
|
+
Object.entries(newValue).every(([key, value]) =>
|
|
8582
|
+
// ensure key is a number
|
|
8583
|
+
!isNaN(parseInt(key)) &&
|
|
8584
|
+
// ensure value is an object
|
|
8585
|
+
typeof value === 'object' &&
|
|
8586
|
+
!Array.isArray(value) &&
|
|
8587
|
+
// ensure value has at least one of the following properties
|
|
8588
|
+
((value.align !== undefined && textAlignments.includes(value.align)) ||
|
|
8589
|
+
(value.sortable !== undefined && typeof value.sortable === 'boolean') ||
|
|
8590
|
+
(value.datatype !== undefined && dataTypes.includes(value.datatype))) &&
|
|
8591
|
+
// ensure no extra properties are present
|
|
8592
|
+
Object.keys(value).every(key => ['align', 'sortable', 'datatype'].includes(key)));
|
|
8593
|
+
/**
|
|
8594
|
+
* Compare values
|
|
8595
|
+
* @param firstValue - First value
|
|
8596
|
+
* @param secondValue - Second value
|
|
8597
|
+
* @param descending - Define descending order
|
|
8598
|
+
* @param datatype - Data type
|
|
8599
|
+
* @returns Comparison result
|
|
8600
|
+
* @example
|
|
8601
|
+
* compareValues('a', 'b', false, 'string'); // -1
|
|
8602
|
+
*/
|
|
8603
|
+
const compareValues = (firstValue, secondValue, descending, datatype) => {
|
|
8604
|
+
if (descending) {
|
|
8605
|
+
const temp = firstValue;
|
|
8606
|
+
firstValue = secondValue;
|
|
8607
|
+
secondValue = temp;
|
|
8608
|
+
}
|
|
8609
|
+
if (datatype === 'date') {
|
|
8610
|
+
return new Date(firstValue).getTime() - new Date(secondValue).getTime();
|
|
8611
|
+
}
|
|
8612
|
+
return firstValue.localeCompare(secondValue, undefined, { numeric: datatype === 'numeric' });
|
|
8613
|
+
};
|
|
8614
|
+
const MgTable = class {
|
|
8615
|
+
constructor(hostRef) {
|
|
8616
|
+
registerInstance(this, hostRef);
|
|
8617
|
+
// Classes
|
|
8618
|
+
this.componentClass = 'mg-c-table';
|
|
8619
|
+
this.componentWrapperClass = 'mg-c-table-wrapper';
|
|
8620
|
+
this.classFullWidth = 'mg-c-table--full-width';
|
|
8621
|
+
// Alignment stylesheet
|
|
8622
|
+
this.alignmentStylesheet = new CSSStyleSheet();
|
|
8623
|
+
/**
|
|
8624
|
+
* Define table size
|
|
8625
|
+
*/
|
|
8626
|
+
this.size = 'medium';
|
|
8627
|
+
/**
|
|
8628
|
+
* Define if table fits its parent element
|
|
8629
|
+
*/
|
|
8630
|
+
this.fullWidth = false;
|
|
8631
|
+
/**
|
|
8632
|
+
* Class collection
|
|
8633
|
+
*/
|
|
8634
|
+
this.classCollection = new Ze([this.componentClass]);
|
|
8635
|
+
}
|
|
8636
|
+
watchSize(newValue, oldValue) {
|
|
8637
|
+
if (!sizes$1.includes(newValue)) {
|
|
8638
|
+
throw new Error(`<mg-table> prop "size" must be one of: ${sizes$1.join(', ')}. Passed value: ${Ve(newValue)}.`);
|
|
8639
|
+
}
|
|
8640
|
+
else {
|
|
8641
|
+
if (oldValue !== undefined) {
|
|
8642
|
+
this.classCollection.delete(`mg-c-table--size-${oldValue}`);
|
|
8643
|
+
}
|
|
8644
|
+
this.classCollection.add(`mg-c-table--size-${newValue}`);
|
|
8645
|
+
}
|
|
8646
|
+
}
|
|
8647
|
+
watchFullWidth(newValue) {
|
|
8648
|
+
if (newValue) {
|
|
8649
|
+
this.classCollection.add(this.classFullWidth);
|
|
8650
|
+
}
|
|
8651
|
+
else {
|
|
8652
|
+
this.classCollection.delete(this.classFullWidth);
|
|
8653
|
+
}
|
|
8654
|
+
}
|
|
8655
|
+
watchColumns(newValue) {
|
|
8656
|
+
if (newValue !== undefined && !isValidColumnsObject(newValue)) {
|
|
8657
|
+
throw new Error(`<mg-table> prop "columns" must be a ColumnsType object. Passed value: ${Ve(newValue)}.`);
|
|
8658
|
+
}
|
|
8659
|
+
}
|
|
8660
|
+
/**
|
|
8661
|
+
* Render Table
|
|
8662
|
+
* @param table - Table element
|
|
8663
|
+
*/
|
|
8664
|
+
renderTable(table) {
|
|
8665
|
+
let isSortable = false;
|
|
8666
|
+
// Remove table classes
|
|
8667
|
+
table.className = '';
|
|
8668
|
+
// Add table classes
|
|
8669
|
+
table.classList.add(...this.classCollection.classes);
|
|
8670
|
+
// Set columns based on columns prop
|
|
8671
|
+
if (this.columns !== undefined) {
|
|
8672
|
+
// Store original rows
|
|
8673
|
+
const rowsDefault = Array.from(table.querySelectorAll('tbody tr'));
|
|
8674
|
+
// Apply columns settings
|
|
8675
|
+
Object.entries(this.columns).forEach(([key, value]) => {
|
|
8676
|
+
// Add alignment to stylesheet
|
|
8677
|
+
if (value.align !== undefined) {
|
|
8678
|
+
this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:${value.align}}}`);
|
|
8679
|
+
}
|
|
8680
|
+
// if align is not defined and datatype is number, align right
|
|
8681
|
+
else if (value.datatype === 'numeric') {
|
|
8682
|
+
this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:right}}`);
|
|
8683
|
+
}
|
|
8684
|
+
// Define if column is sortable
|
|
8685
|
+
if (value.sortable) {
|
|
8686
|
+
isSortable = true;
|
|
8687
|
+
// Add sortable class to table header
|
|
8688
|
+
const sortableHeader = table.querySelector(`thead td:nth-child(${key}),thead th:nth-child(${key})`);
|
|
8689
|
+
// Create button
|
|
8690
|
+
const button = document.createElement('button');
|
|
8691
|
+
button.classList.add('mg-c-table__sort-button');
|
|
8692
|
+
// Append button to header
|
|
8693
|
+
const sortableHeaderContent = sortableHeader.innerHTML;
|
|
8694
|
+
sortableHeader.innerHTML = '';
|
|
8695
|
+
button.innerHTML = sortableHeaderContent;
|
|
8696
|
+
// Set icon
|
|
8697
|
+
const icon = document.createElement('mg-icon');
|
|
8698
|
+
icon.setAttribute('icon', 'arrows-up-down');
|
|
8699
|
+
// Append icon to button
|
|
8700
|
+
button.append(icon);
|
|
8701
|
+
sortableHeader.append(button);
|
|
8702
|
+
// Add event listener
|
|
8703
|
+
button.addEventListener('click', () => {
|
|
8704
|
+
// Reset aria pressed
|
|
8705
|
+
table.querySelectorAll(`thead td:not(:nth-child(${key})) [aria-pressed],thead th:not(:nth-child(${key})) [aria-pressed]`).forEach(ariaPressed => {
|
|
8706
|
+
ariaPressed.removeAttribute('aria-pressed');
|
|
8707
|
+
ariaPressed.querySelector('mg-icon').setAttribute('icon', 'arrows-up-down');
|
|
8708
|
+
});
|
|
8709
|
+
// Reset aria sort
|
|
8710
|
+
table.querySelectorAll(`thead td:not(:nth-child(${key}))[aria-sort],thead th:not(:nth-child(${key}))[aria-sort]`).forEach(ariaSort => {
|
|
8711
|
+
ariaSort.removeAttribute('aria-sort');
|
|
8712
|
+
});
|
|
8713
|
+
// Set aria pressed
|
|
8714
|
+
button.setAttribute('aria-pressed', 'true');
|
|
8715
|
+
// Manage sort order
|
|
8716
|
+
// Get sort order
|
|
8717
|
+
let sortOrder = sortableHeader.getAttribute('aria-sort');
|
|
8718
|
+
// First click sort asc
|
|
8719
|
+
if ([null, 'none'].includes(sortOrder)) {
|
|
8720
|
+
sortableHeader.setAttribute('aria-sort', 'ascending');
|
|
8721
|
+
}
|
|
8722
|
+
// Second click sort desc
|
|
8723
|
+
else if (sortOrder === 'ascending') {
|
|
8724
|
+
sortableHeader.setAttribute('aria-sort', 'descending');
|
|
8725
|
+
}
|
|
8726
|
+
// Third click remove sort
|
|
8727
|
+
else {
|
|
8728
|
+
sortableHeader.setAttribute('aria-sort', 'none');
|
|
8729
|
+
}
|
|
8730
|
+
// Update sort order
|
|
8731
|
+
sortOrder = sortableHeader.getAttribute('aria-sort');
|
|
8732
|
+
// Update button icon
|
|
8733
|
+
const icon = button.querySelector('mg-icon');
|
|
8734
|
+
let iconType = 'arrows-up-down';
|
|
8735
|
+
if (sortOrder === 'ascending') {
|
|
8736
|
+
iconType = 'arrow-up';
|
|
8737
|
+
}
|
|
8738
|
+
else if (sortOrder === 'descending') {
|
|
8739
|
+
iconType = 'arrow-down';
|
|
8740
|
+
}
|
|
8741
|
+
icon.setAttribute('icon', iconType);
|
|
8742
|
+
// If sort order is none, return to original order
|
|
8743
|
+
if (sortOrder === 'none') {
|
|
8744
|
+
// Append rows to table
|
|
8745
|
+
rowsDefault.forEach(row => table.querySelector('tbody').append(row));
|
|
8746
|
+
return;
|
|
8747
|
+
}
|
|
8748
|
+
// Set a copy of rows
|
|
8749
|
+
const rows = Array.from(table.querySelectorAll('tbody tr'));
|
|
8750
|
+
// Sort rows
|
|
8751
|
+
rows.sort((a, b) => {
|
|
8752
|
+
var _a, _b;
|
|
8753
|
+
// Get cells
|
|
8754
|
+
const cellA = a.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);
|
|
8755
|
+
const cellB = b.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);
|
|
8756
|
+
// Get cell values
|
|
8757
|
+
const cellValueA = (_a = cellA.dataset.sort) !== null && _a !== void 0 ? _a : cellA.textContent;
|
|
8758
|
+
const cellValueB = (_b = cellB.dataset.sort) !== null && _b !== void 0 ? _b : cellB.textContent;
|
|
8759
|
+
// Sort cells based on sort order
|
|
8760
|
+
return compareValues(cellValueA, cellValueB, sortOrder === 'descending', value.datatype);
|
|
8761
|
+
});
|
|
8762
|
+
// Append rows to table
|
|
8763
|
+
rows.forEach(row => table.querySelector('tbody').append(row));
|
|
8764
|
+
});
|
|
8765
|
+
}
|
|
8766
|
+
});
|
|
8767
|
+
}
|
|
8768
|
+
// Add alignment to columns
|
|
8769
|
+
this.element.shadowRoot.adoptedStyleSheets = [...this.element.shadowRoot.adoptedStyleSheets, this.alignmentStylesheet];
|
|
8770
|
+
// Create div wrapper for responsive behavior
|
|
8771
|
+
const divWrapper = document.createElement('div');
|
|
8772
|
+
divWrapper.setAttribute('class', this.componentWrapperClass);
|
|
8773
|
+
divWrapper.setAttribute('tabindex', '0');
|
|
8774
|
+
divWrapper.setAttribute('role', 'region');
|
|
8775
|
+
// Get table title
|
|
8776
|
+
let captionTable = table.querySelector('caption');
|
|
8777
|
+
// If table is sortable we must add a caption
|
|
8778
|
+
if (captionTable === null && isSortable) {
|
|
8779
|
+
captionTable = document.createElement('caption');
|
|
8780
|
+
table.prepend(captionTable);
|
|
8781
|
+
}
|
|
8782
|
+
if (captionTable !== null) {
|
|
8783
|
+
// Ensure caption is not visible (otherwhise the table does not have rounded corners)
|
|
8784
|
+
captionTable.className = 'mg-u-visually-hidden';
|
|
8785
|
+
// Link caption to div
|
|
8786
|
+
if (!me(captionTable.id)) {
|
|
8787
|
+
captionTable.setAttribute('id', Ge(`${this.componentClass}-caption`));
|
|
8788
|
+
}
|
|
8789
|
+
divWrapper.setAttribute('aria-labelledby', captionTable.id);
|
|
8790
|
+
// Add sortable caption if neeeded
|
|
8791
|
+
if (isSortable) {
|
|
8792
|
+
captionTable.innerHTML = `${captionTable.innerHTML} ${this.messages.table.sortableCaption}`.trim();
|
|
8793
|
+
}
|
|
8794
|
+
}
|
|
8795
|
+
divWrapper.append(table);
|
|
8796
|
+
// Remove existing table from shadow root
|
|
8797
|
+
const existingTable = this.element.shadowRoot.querySelector(`.${this.componentWrapperClass}`);
|
|
8798
|
+
if (existingTable !== null) {
|
|
8799
|
+
existingTable.remove();
|
|
8800
|
+
}
|
|
8801
|
+
// Append table
|
|
8802
|
+
this.element.shadowRoot.append(divWrapper);
|
|
8803
|
+
}
|
|
8804
|
+
/*************
|
|
8805
|
+
* Lifecycle *
|
|
8806
|
+
*************/
|
|
8807
|
+
componentWillLoad() {
|
|
8808
|
+
this.messages = initLocales(this.element).messages;
|
|
8809
|
+
}
|
|
8810
|
+
/**
|
|
8811
|
+
* Set variables and validate props
|
|
8812
|
+
*/
|
|
8813
|
+
componentDidLoad() {
|
|
8814
|
+
this.watchSize(this.size);
|
|
8815
|
+
this.watchFullWidth(this.fullWidth);
|
|
8816
|
+
this.watchColumns(this.columns);
|
|
8817
|
+
this.renderTable(this.element.querySelector('table'));
|
|
8818
|
+
}
|
|
8819
|
+
/**
|
|
8820
|
+
* Update table
|
|
8821
|
+
*/
|
|
8822
|
+
componentWillUpdate() {
|
|
8823
|
+
this.renderTable(this.element.shadowRoot.querySelector('table'));
|
|
8824
|
+
}
|
|
8825
|
+
get element() { return getElement(this); }
|
|
8826
|
+
static get watchers() { return {
|
|
8827
|
+
"size": ["watchSize"],
|
|
8828
|
+
"fullWidth": ["watchFullWidth"],
|
|
8829
|
+
"columns": ["watchColumns"]
|
|
8830
|
+
}; }
|
|
8831
|
+
};
|
|
8832
|
+
MgTable.style = MgTableStyle0;
|
|
8833
|
+
|
|
8449
8834
|
/**
|
|
8450
8835
|
* Available tabs items status
|
|
8451
8836
|
*/
|
|
@@ -9235,6 +9620,6 @@ const MgTooltipContent = class {
|
|
|
9235
9620
|
};
|
|
9236
9621
|
MgTooltipContent.style = MgTooltipContentStyle0;
|
|
9237
9622
|
|
|
9238
|
-
export { MgActionMore as mg_action_more, MgBadge as mg_badge, MgButton as mg_button, MgCard as mg_card, MgCharacterLeft as mg_character_left, MgDetails as mg_details, MgDivider as mg_divider, MgForm as mg_form, MgIcon as mg_icon, MgIllustratedMessage as mg_illustrated_message, MgInput as mg_input, MgInputCheckbox as mg_input_checkbox, MgInputCheckboxPaginated as mg_input_checkbox_paginated, MgInputDate as mg_input_date, MgInputNumeric as mg_input_numeric, MgInputPassword as mg_input_password, MgInputRadio as mg_input_radio, MgInputSelect as mg_input_select, MgInputText as mg_input_text, MgInputTextarea as mg_input_textarea, MgInputTitle as mg_input_title, MgInputToggle as mg_input_toggle, MgItemMore as mg_item_more, MgMenu as mg_menu, MgMenuItem as mg_menu_item, MgMessage as mg_message, MgModal as mg_modal, MgPagination as mg_pagination, MgPanel as mg_panel, MgPopover as mg_popover, MgPopoverContent as mg_popover_content, MgSkipLinks as mg_skip_links, MgTabs as mg_tabs, MgTag as mg_tag, MgTooltip as mg_tooltip, MgTooltipContent as mg_tooltip_content };
|
|
9623
|
+
export { MgActionMore as mg_action_more, MgBadge as mg_badge, MgButton as mg_button, MgCard as mg_card, MgCharacterLeft as mg_character_left, MgDetails as mg_details, MgDivider as mg_divider, MgForm as mg_form, MgIcon as mg_icon, MgIllustratedMessage as mg_illustrated_message, MgInput as mg_input, MgInputCheckbox as mg_input_checkbox, MgInputCheckboxPaginated as mg_input_checkbox_paginated, MgInputDate as mg_input_date, MgInputNumeric as mg_input_numeric, MgInputPassword as mg_input_password, MgInputRadio as mg_input_radio, MgInputSelect as mg_input_select, MgInputText as mg_input_text, MgInputTextarea as mg_input_textarea, MgInputTitle as mg_input_title, MgInputToggle as mg_input_toggle, MgItemMore as mg_item_more, MgMenu as mg_menu, MgMenuItem as mg_menu_item, MgMessage as mg_message, MgModal as mg_modal, MgPagination as mg_pagination, MgPanel as mg_panel, MgPopover as mg_popover, MgPopoverContent as mg_popover_content, MgSkipLinks as mg_skip_links, MgTable as mg_table, MgTabs as mg_tabs, MgTag as mg_tag, MgTooltip as mg_tooltip, MgTooltipContent as mg_tooltip_content };
|
|
9239
9624
|
|
|
9240
|
-
//# sourceMappingURL=mg-action-
|
|
9625
|
+
//# sourceMappingURL=mg-action-more_37.entry.js.map
|