@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.
Files changed (115) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/index-1a5a1081.js +2 -2
  3. package/dist/cjs/{index-b7923724.js → index-234e834a.js} +75 -39
  4. package/dist/cjs/index-234e834a.js.map +1 -0
  5. package/dist/cjs/{index.es-903492c5.js → index.es-b90f74d4.js} +2 -2
  6. package/dist/cjs/index.es-b90f74d4.js.map +1 -0
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/cjs/{mg-action-more_36.cjs.entry.js → mg-action-more_37.cjs.entry.js} +477 -91
  9. package/dist/cjs/mg-action-more_37.cjs.entry.js.map +1 -0
  10. package/dist/cjs/mg-alert.cjs.entry.js +2 -2
  11. package/dist/cjs/mg-components.cjs.js +1 -1
  12. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +2 -2
  13. package/dist/cjs/mg-loader.cjs.entry.js +3 -3
  14. package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
  15. package/dist/cjs/mg-progress.cjs.entry.js +1 -1
  16. package/dist/collection/collection-manifest.json +1 -0
  17. package/dist/collection/components/atoms/mg-button/mg-button.js +10 -10
  18. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  19. package/dist/collection/components/atoms/mg-icon/mg-icon.js +21 -6
  20. package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
  21. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +2 -2
  22. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
  23. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +1 -1
  24. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js.map +1 -1
  25. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +46 -19
  26. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
  27. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +57 -28
  28. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
  29. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js +7 -1
  30. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js.map +1 -1
  31. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +43 -12
  32. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
  33. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  34. package/dist/collection/components/molecules/mg-loader/mg-loader.js.map +1 -1
  35. package/dist/collection/components/molecules/mg-table/mg-table.conf.js +13 -0
  36. package/dist/collection/components/molecules/mg-table/mg-table.conf.js.map +1 -0
  37. package/dist/collection/components/molecules/mg-table/mg-table.js +364 -0
  38. package/dist/collection/components/molecules/mg-table/mg-table.js.map +1 -0
  39. package/dist/collection/locales/en/messages.json +33 -16
  40. package/dist/collection/locales/fr/messages.json +36 -19
  41. package/dist/components/index.es.js +1 -1
  42. package/dist/components/index.es.js.map +1 -1
  43. package/dist/components/index2.js +73 -37
  44. package/dist/components/index2.js.map +1 -1
  45. package/dist/components/mg-button2.js +10 -10
  46. package/dist/components/mg-button2.js.map +1 -1
  47. package/dist/components/mg-icon2.js +21 -6
  48. package/dist/components/mg-icon2.js.map +1 -1
  49. package/dist/components/mg-input-checkbox-paginated2.js +2 -2
  50. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
  51. package/dist/components/mg-input-date.js +47 -19
  52. package/dist/components/mg-input-date.js.map +1 -1
  53. package/dist/components/mg-input-numeric.js +58 -29
  54. package/dist/components/mg-input-numeric.js.map +1 -1
  55. package/dist/components/mg-input-text2.js +50 -14
  56. package/dist/components/mg-input-text2.js.map +1 -1
  57. package/dist/components/mg-loader.js +1 -1
  58. package/dist/components/mg-loader.js.map +1 -1
  59. package/dist/components/mg-table.d.ts +11 -0
  60. package/dist/components/mg-table.js +320 -0
  61. package/dist/components/mg-table.js.map +1 -0
  62. package/dist/esm/index-5059254f.js +2 -2
  63. package/dist/esm/{index-a58f8b91.js → index-544778a7.js} +75 -39
  64. package/dist/esm/index-544778a7.js.map +1 -0
  65. package/dist/esm/{index.es-b80b758c.js → index.es-517b1bf2.js} +2 -2
  66. package/dist/esm/index.es-517b1bf2.js.map +1 -0
  67. package/dist/esm/loader.js +1 -1
  68. package/dist/esm/{mg-action-more_36.entry.js → mg-action-more_37.entry.js} +477 -92
  69. package/dist/esm/mg-action-more_37.entry.js.map +1 -0
  70. package/dist/esm/mg-alert.entry.js +2 -2
  71. package/dist/esm/mg-components.js +1 -1
  72. package/dist/esm/mg-input-rich-text-editor.entry.js +2 -2
  73. package/dist/esm/mg-loader.entry.js +3 -3
  74. package/dist/esm/mg-loader.entry.js.map +1 -1
  75. package/dist/esm/mg-progress.entry.js +1 -1
  76. package/dist/mg-components/locales/en/messages.json +33 -16
  77. package/dist/mg-components/locales/fr/messages.json +36 -19
  78. package/dist/mg-components/mg-components.esm.js +1 -1
  79. package/dist/mg-components/mg-components.esm.js.map +1 -1
  80. package/dist/mg-components/{p-3c6710be.js → p-12a1edee.js} +2 -2
  81. package/dist/mg-components/p-12a1edee.js.map +1 -0
  82. package/dist/mg-components/p-9bc53279.js +2 -0
  83. package/dist/mg-components/{p-ac8a5083.js.map → p-9bc53279.js.map} +1 -1
  84. package/dist/mg-components/{p-bc6ec847.entry.js → p-ad98f3d8.entry.js} +2 -2
  85. package/dist/mg-components/p-ad98f3d8.entry.js.map +1 -0
  86. package/dist/mg-components/{p-2a633b29.entry.js → p-c10433db.entry.js} +2 -2
  87. package/dist/mg-components/{p-f2e6e7ae.entry.js → p-c67e4934.entry.js} +2 -2
  88. package/dist/mg-components/p-f72efb64.entry.js +2 -0
  89. package/dist/mg-components/p-f72efb64.entry.js.map +1 -0
  90. package/dist/mg-components/{p-361cc090.entry.js → p-fd4a7980.entry.js} +2 -2
  91. package/dist/types/components/atoms/mg-button/mg-button.d.ts +1 -1
  92. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +1 -0
  93. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +6 -5
  94. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.conf.d.ts +4 -2
  95. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +8 -2
  96. package/dist/types/components/molecules/mg-table/mg-table.conf.d.ts +19 -0
  97. package/dist/types/components/molecules/mg-table/mg-table.d.ts +58 -0
  98. package/dist/types/components.d.ts +39 -0
  99. package/ide/intellij/web-types.json +69 -5
  100. package/ide/vscode/html-custom-data.json +85 -1
  101. package/package.json +22 -22
  102. package/dist/cjs/index-b7923724.js.map +0 -1
  103. package/dist/cjs/index.es-903492c5.js.map +0 -1
  104. package/dist/cjs/mg-action-more_36.cjs.entry.js.map +0 -1
  105. package/dist/esm/index-a58f8b91.js.map +0 -1
  106. package/dist/esm/index.es-b80b758c.js.map +0 -1
  107. package/dist/esm/mg-action-more_36.entry.js.map +0 -1
  108. package/dist/mg-components/p-3afebdab.entry.js +0 -2
  109. package/dist/mg-components/p-3afebdab.entry.js.map +0 -1
  110. package/dist/mg-components/p-3c6710be.js.map +0 -1
  111. package/dist/mg-components/p-ac8a5083.js +0 -2
  112. package/dist/mg-components/p-bc6ec847.entry.js.map +0 -1
  113. /package/dist/mg-components/{p-2a633b29.entry.js.map → p-c10433db.entry.js.map} +0 -0
  114. /package/dist/mg-components/{p-f2e6e7ae.entry.js.map → p-c67e4934.entry.js.map} +0 -0
  115. /package/dist/mg-components/{p-361cc090.entry.js.map → p-fd4a7980.entry.js.map} +0 -0
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-1a5a1081.js');
6
- const index_es = require('./index.es-903492c5.js');
7
- const index$1 = require('./index-b7923724.js');
6
+ const index_es = require('./index.es-b90f74d4.js');
7
+ const index$1 = require('./index-234e834a.js');
8
8
  const mgInput_conf = require('./mg-input.conf-5bbcea79.js');
9
9
 
10
10
  /**
@@ -31,7 +31,7 @@ const directions$1 = {
31
31
  /**
32
32
  * List of all possibles sizes
33
33
  */
34
- const sizes$4 = ['medium', 'large', 'xlarge'];
34
+ const sizes$5 = ['medium', 'large', 'xlarge'];
35
35
 
36
36
  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)}";
37
37
  const MgActionMoreStyle0 = mgActionMoreCss;
@@ -268,7 +268,7 @@ MgBadge.style = MgBadgeStyle0;
268
268
  /**
269
269
  * List of all possibles sizes
270
270
  */
271
- const sizes$3 = ['medium', 'large'];
271
+ const sizes$4 = ['medium', 'large'];
272
272
  /**
273
273
  * List of all possibles variants
274
274
  */
@@ -295,7 +295,7 @@ const MgButton = class {
295
295
  /**
296
296
  * Define button size
297
297
  */
298
- this.size = sizes$3[0]; // medium
298
+ this.size = sizes$4[0]; // medium
299
299
  /**
300
300
  * Set button to full-width
301
301
  */
@@ -362,7 +362,7 @@ const MgButton = class {
362
362
  this.setIconSize = () => {
363
363
  var _a, _b;
364
364
  if (this.size === 'medium') {
365
- (_a = this.element.querySelector('mg-icon')) === null || _a === void 0 ? void 0 : _a.removeAttribute('size');
365
+ (_a = this.element.querySelector('mg-icon[size]')) === null || _a === void 0 ? void 0 : _a.removeAttribute('size');
366
366
  }
367
367
  else if (this.isIcon) {
368
368
  (_b = this.element.querySelector('mg-icon')) === null || _b === void 0 ? void 0 : _b.setAttribute('size', this.size);
@@ -388,8 +388,8 @@ const MgButton = class {
388
388
  }
389
389
  validateSize(newValue, oldValue) {
390
390
  // validate new value
391
- if (!sizes$3.includes(newValue)) {
392
- throw new Error(`<mg-button> prop "size" must be one of: ${sizes$3.join(', ')}. Passed value: ${index_es.Ve(newValue)}.`);
391
+ if (!sizes$4.includes(newValue)) {
392
+ throw new Error(`<mg-button> prop "size" must be one of: ${sizes$4.join(', ')}. Passed value: ${index_es.Ve(newValue)}.`);
393
393
  }
394
394
  else {
395
395
  if (oldValue !== undefined) {
@@ -428,7 +428,13 @@ const MgButton = class {
428
428
  // emit value update
429
429
  this.disabledChange.emit(isDisabled);
430
430
  }
431
- watchIsIcon() {
431
+ watchIsIcon(newValue) {
432
+ if (newValue) {
433
+ this.classCollection.add(`mg-c-button--icon`);
434
+ if (!index_es.me(this.label)) {
435
+ throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
436
+ }
437
+ }
432
438
  this.setIconSize();
433
439
  }
434
440
  loadingHandler(newValue) {
@@ -447,13 +453,7 @@ const MgButton = class {
447
453
  this.validateVariant(this.variant);
448
454
  this.validateFullWidth(this.fullWidth);
449
455
  this.validateSize(this.size);
450
- this.watchIsIcon();
451
- if (this.isIcon) {
452
- this.classCollection.add(`mg-c-button--icon`);
453
- if (!index_es.me(this.label)) {
454
- throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
455
- }
456
- }
456
+ this.watchIsIcon(this.isIcon);
457
457
  // Store the onclick fn
458
458
  this.onClickElementFn = this.element.onclick;
459
459
  this.disabledHandler(this.disabled);
@@ -479,7 +479,7 @@ const MgButton = class {
479
479
  */
480
480
  render() {
481
481
  var _a;
482
- return (index.h(index.Host, { key: 'a56efb7c3e49a4aadf6751b10bacb39f20c260df', 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 }, index.h("div", { key: '2d47d068d188161b603b26117256d0e828393348', class: this.classCollection.join() }, this.loading && index.h("mg-icon", { key: 'ba84820c70834f1e345af506265222340659f8ec', icon: "loader", spin: true }), index.h("div", { key: 'db6c3437d5de7f828cca7df9d83670de9d3a8ed6', class: "mg-c-button__content" }, index.h("slot", { key: 'b00f76d92e1e2f9e4dd834bf41419c68c2635d1a' })))));
482
+ return (index.h(index.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 }, index.h("div", { key: '9c7c1adfb0c6752d745bfb0b407f6be65c08b82a', class: this.classCollection.join() }, this.loading && index.h("mg-icon", { key: '0d6471de739aa33ec60e69aab941c73eadefab54', icon: "loader", spin: true }), index.h("div", { key: 'cecf5647a5dcb0538e514abf47bc09ab1efcfc9c', class: "mg-c-button__content" }, index.h("slot", { key: '15a6d2e63e6ec4668697bf74f2271432598faf06' })))));
483
483
  }
484
484
  get element() { return index.getElement(this); }
485
485
  static get watchers() { return {
@@ -893,7 +893,7 @@ MgForm.style = MgFormStyle0;
893
893
  /**
894
894
  * List of all possibles sizes
895
895
  */
896
- const sizes$2 = ['small', 'medium', 'large', 'xlarge', 'xxlarge'];
896
+ const sizes$3 = ['small', 'medium', 'large', 'xlarge', 'xxlarge'];
897
897
  /**
898
898
  * List of all possibles variants
899
899
  */
@@ -936,30 +936,45 @@ const MgIcon = class {
936
936
  * @param icon - icon to render
937
937
  */
938
938
  this.renderIcon = (icon) => {
939
- this.element.shadowRoot.innerHTML = icons[icon];
940
- this.svg = this.element.shadowRoot.querySelector('svg');
939
+ var _a;
940
+ // Remove existing SVG from ShadowRoot
941
+ (_a = this.element.shadowRoot.querySelector('svg')) === null || _a === void 0 ? void 0 : _a.remove();
942
+ // Append new SVG to ShadowRoot
943
+ const svgContainer = document.createElement('div');
944
+ svgContainer.innerHTML = icons[icon];
945
+ this.element.shadowRoot.append(svgContainer.firstChild);
946
+ svgContainer.remove();
941
947
  // update svg attributes
948
+ this.svg = this.element.shadowRoot.querySelector('svg');
942
949
  this.svg.setAttribute('aria-hidden', 'true');
943
950
  this.svg.setAttribute('focusable', 'false');
944
951
  this.svg.setAttribute('class', this.classCollection.join());
945
952
  };
946
953
  }
947
954
  validateIcon(newValue, oldValue) {
948
- if (!Object.keys(icons).includes(newValue))
955
+ if (!Object.keys(icons).includes(newValue)) {
949
956
  throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}. Passed value: ${index_es.Ve(newValue)}.`);
957
+ }
950
958
  else {
951
- if (oldValue !== undefined)
959
+ if (oldValue !== undefined) {
952
960
  this.classCollection.delete(`mg-c-icon--${oldValue}`);
961
+ }
953
962
  this.classCollection.add(`mg-c-icon--${newValue}`);
954
963
  this.renderIcon(newValue);
955
964
  }
956
965
  }
957
966
  validateSize(newValue, oldValue) {
958
- if (!sizes$2.includes(newValue))
959
- throw new Error(`<mg-icon> prop "size" must be one of: ${sizes$2.join(', ')}. Passed value: ${index_es.Ve(newValue)}.`);
967
+ // When removing size attribute, it is set to null
968
+ if (newValue === null) {
969
+ newValue = 'medium';
970
+ }
971
+ if (!sizes$3.includes(newValue)) {
972
+ throw new Error(`<mg-icon> prop "size" must be one of: ${sizes$3.join(', ')}. Passed value: ${index_es.Ve(newValue)}.`);
973
+ }
960
974
  else {
961
- if (oldValue !== undefined)
975
+ if (oldValue !== undefined) {
962
976
  this.classCollection.delete(`mg-c-icon--size-${oldValue}`);
977
+ }
963
978
  this.classCollection.add(`mg-c-icon--size-${newValue}`);
964
979
  }
965
980
  }
@@ -1026,7 +1041,7 @@ MgIcon.style = MgIconStyle0;
1026
1041
  /**
1027
1042
  * List of all possibles sizes
1028
1043
  */
1029
- const sizes$1 = ['small', 'medium', 'large'];
1044
+ const sizes$2 = ['small', 'medium', 'large'];
1030
1045
  /**
1031
1046
  * List of all possibles directions
1032
1047
  */
@@ -1052,8 +1067,8 @@ const MgIllustratedMessage = class {
1052
1067
  this.classCollection = new index_es.Ze(['mg-c-illustrated-message']);
1053
1068
  }
1054
1069
  watchSize(newValue, oldValue) {
1055
- if (!sizes$1.includes(newValue)) {
1056
- throw new Error(`<mg-illustrated-message> prop "size" must be one of: ${sizes$1.join(', ')}. Passed value: ${index_es.Ve(newValue)}.`);
1070
+ if (!sizes$2.includes(newValue)) {
1071
+ throw new Error(`<mg-illustrated-message> prop "size" must be one of: ${sizes$2.join(', ')}. Passed value: ${index_es.Ve(newValue)}.`);
1057
1072
  }
1058
1073
  else {
1059
1074
  if (oldValue !== undefined) {
@@ -2025,16 +2040,18 @@ const MgInputCheckboxPaginated = class {
2025
2040
  * @returns HTML Element
2026
2041
  */
2027
2042
  render() {
2028
- const getText = (checkboxes) => (index.h("em", { key: '8f20e5be81047106e04cd101385b9c6555c0c38d', class: "mg-c-input__section-header-title-label" }, `${this.messages[checkboxes.length > 1 ? 'titlePlurial' : 'title']} (${checkboxes.length})`));
2043
+ const getText = (checkboxes) => (index.h("em", { key: '8f20e5be81047106e04cd101385b9c6555c0c38d', class: "mg-c-input__section-header-title-label" }, `${this.messages[checkboxes.length > 1 ? 'titlePlural' : 'title']} (${checkboxes.length})`));
2029
2044
  const [from, to] = this.getFromToIndexes();
2030
2045
  const itemsContainerId = `items-${this.sectionKind}-container`;
2031
- return (index.h(index.Host, { key: '39d0fc41abe4b537b240bdc14e80fc42cb41033d', hidden: this.checkboxes.length < 1 }, index.h("div", { key: 'fec430cfffc005a217694f9a4ba68412a6a08c7b', class: "mg-c-input__section-header" }, this.sectionKind === SectionKind.SELECTED ? (index.h("mg-button", { variant: "flat", onClick: this.handleToggleClick, "aria-controls": itemsContainerId, "aria-expanded": this.expanded.toString() }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), index.h("span", { class: "mg-c-input__section-header-title" }, getText(this.checkboxes)))) : (index.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) && (index.h("mg-tooltip", { key: 'e1b38d93875962af3024ac27e1892c040dbf9bdb', class: "mg-c-input__section-header-tootlip", message: this.messages.tooltip }, index.h("mg-button", { key: 'f593b3d5ca5bd8b3080253842a5c513709f16e3a', variant: "link", onClick: this.massActionHandler }, this.messages.action))), this.expanded && this.getPageCount(this.checkboxes) > 1 && (index.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}` }))), index.h("div", { key: '74c18984938188e2861cd79b56d919a94f32064f', hidden: !this.expanded, id: itemsContainerId, class: "mg-c-input__section-content" }, index.h(MgInputCheckboxList, { key: '15c2f6fe98d772ce5b0a0d4ec448986e91592107', 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 }))));
2046
+ return (index.h(index.Host, { key: 'ed5b99164dd8b03ce07b60b373eaacd17a030f4b', hidden: this.checkboxes.length < 1 }, index.h("div", { key: 'bd8f69a280da86a7eba42f5bd4eaaa1df75f0303', class: "mg-c-input__section-header" }, this.sectionKind === SectionKind.SELECTED ? (index.h("mg-button", { variant: "flat", onClick: this.handleToggleClick, "aria-controls": itemsContainerId, "aria-expanded": this.expanded.toString() }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), index.h("span", { class: "mg-c-input__section-header-title" }, getText(this.checkboxes)))) : (index.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) && (index.h("mg-tooltip", { key: 'e33ca1a20b2fb420b678a884e24e53913b6024d6', class: "mg-c-input__section-header-tootlip", message: this.messages.tooltip }, index.h("mg-button", { key: '6d2e26d70c22b633085cc3d1dd735fe68398326b', variant: "link", onClick: this.massActionHandler }, this.messages.action))), this.expanded && this.getPageCount(this.checkboxes) > 1 && (index.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}` }))), index.h("div", { key: '32468986664f58c857ab733e2ed814f09723b2c2', hidden: !this.expanded, id: itemsContainerId, class: "mg-c-input__section-content" }, index.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 }))));
2032
2047
  }
2033
2048
  static get watchers() { return {
2034
2049
  "checkboxes": ["watchCheckboxes"]
2035
2050
  }; }
2036
2051
  };
2037
2052
 
2053
+ const DEFAULT_MAX_DATE = '9999-12-31';
2054
+
2038
2055
  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}}";
2039
2056
  const MgInputDateStyle0 = mgInputDateCss;
2040
2057
 
@@ -2066,7 +2083,7 @@ const MgInputDate = class {
2066
2083
  * Define input maximum date
2067
2084
  * format: yyyy-mm-dd
2068
2085
  */
2069
- this.max = '9999-12-31';
2086
+ this.max = '9999-12-31'; // Hardcoded value matching DEFAULT_MAX_DATE for documentation
2070
2087
  /**
2071
2088
  * Define if input is disabled
2072
2089
  */
@@ -2091,11 +2108,36 @@ const MgInputDate = class {
2091
2108
  * @returns formated pattern help text. Ex: Format attendu : jj/mm/aaaa (ex : 20/12/2020)
2092
2109
  */
2093
2110
  this.formatHelpText = (helpText) => {
2111
+ var _a, _b;
2112
+ // If the component is in readonly mode, return directly because the message will not be rendered
2113
+ if (this.readonly) {
2114
+ return undefined;
2115
+ }
2094
2116
  const defaultHelpTextVariable = '{defaultHelpText}';
2095
- let text = index_es.me(helpText) ? helpText : this.messages.input.date.helpText;
2096
- if (text.includes(defaultHelpTextVariable))
2097
- text = text.replace(defaultHelpTextVariable, this.formatHelpText(this.messages.input.date.helpText));
2098
- return text.replace('{pattern}', this.renderPattern()).replace('{date}', index_es.ze(index_es.$t(new Date('2023-12-24')), this.systemLocale));
2117
+ // If a custom helpText is provided, store it but don't return it directly
2118
+ let text = index_es.me(helpText) ? helpText : this.messages.input.date.helpText.expectedFormat;
2119
+ // Handle defaultHelpText
2120
+ if (text.includes(defaultHelpTextVariable)) {
2121
+ text = text.replace(defaultHelpTextVariable, this.formatHelpText(this.messages.input.date.helpText.expectedFormat));
2122
+ }
2123
+ // Replace pattern and date variables
2124
+ text = text.replace('{pattern}', this.renderPattern()).replace('{date}', index_es.ze(index_es.$t(new Date('2025-12-24')), this.systemLocale));
2125
+ // Add additional message for min/max if necessary
2126
+ let rangeMessage;
2127
+ if (((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== DEFAULT_MAX_DATE) {
2128
+ rangeMessage = this.messages.input.date.helpText.minMax.replace('{min}', index_es.ze(this.min, this.systemLocale)).replace('{max}', index_es.ze(this.max, this.systemLocale));
2129
+ }
2130
+ else if (((_b = this.min) === null || _b === void 0 ? void 0 : _b.length) > 0) {
2131
+ rangeMessage = this.messages.input.date.helpText.min.replace('{min}', index_es.ze(this.min, this.systemLocale));
2132
+ }
2133
+ else if (this.max !== DEFAULT_MAX_DATE) {
2134
+ rangeMessage = this.messages.input.date.helpText.max.replace('{max}', index_es.ze(this.max, this.systemLocale));
2135
+ }
2136
+ // Combine custom helpText with range message if both exist
2137
+ if (text !== undefined && rangeMessage !== undefined) {
2138
+ return `${text}<br>${rangeMessage}`;
2139
+ }
2140
+ return text;
2099
2141
  };
2100
2142
  /**
2101
2143
  * Handle input event
@@ -2145,28 +2187,27 @@ const MgInputDate = class {
2145
2187
  */
2146
2188
  this.getInputError = () => {
2147
2189
  var _a;
2148
- let inputError = null;
2149
2190
  // bad input or pattern
2150
2191
  if (this.input.validity.badInput || (this.value && !this.isValidPattern(this.value))) {
2151
- inputError = 'badInput';
2192
+ return 'badInput';
2152
2193
  }
2153
2194
  // required
2154
- else if (this.input.validity.valueMissing) {
2155
- inputError = 'required';
2195
+ if (this.input.validity.valueMissing) {
2196
+ return 'required';
2156
2197
  }
2157
2198
  // min & max
2158
- else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.max !== '9999-12-31') {
2159
- inputError = 'minMax';
2199
+ 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) {
2200
+ return 'minMax';
2160
2201
  }
2161
2202
  // min
2162
- else if (this.input.validity.rangeUnderflow) {
2163
- inputError = 'min';
2203
+ if (this.input.validity.rangeUnderflow) {
2204
+ return 'min';
2164
2205
  }
2165
2206
  // max
2166
- else if (this.input.validity.rangeOverflow) {
2167
- inputError = 'max';
2207
+ if (this.input.validity.rangeOverflow) {
2208
+ return 'max';
2168
2209
  }
2169
- return inputError;
2210
+ return null;
2170
2211
  };
2171
2212
  /**
2172
2213
  * Check input errors
@@ -2186,14 +2227,16 @@ const MgInputDate = class {
2186
2227
  }
2187
2228
  // min, max & minMax
2188
2229
  else if (['min', 'max', 'minMax'].includes(inputError)) {
2189
- this.errorMessage = this.messages.errors.date[inputError]
2230
+ this.errorMessage = this.messages.input.date.helpText[inputError]
2190
2231
  .replace('{min}', index_es.ze(this.min, this.systemLocale))
2191
2232
  .replace('{max}', index_es.ze(this.max, this.systemLocale));
2192
2233
  }
2193
2234
  // wrong date format
2194
2235
  // element.validity.badInput is default error message
2195
2236
  else {
2196
- this.errorMessage = this.messages.errors.date.badInput.replace('{pattern}', this.renderPattern());
2237
+ this.errorMessage = this.messages.input.date.error.badInput
2238
+ .replace('{pattern}', this.renderPattern())
2239
+ .replace('{date}', index_es.ze(index_es.$t(new Date('2025-12-24')), this.systemLocale));
2197
2240
  }
2198
2241
  }
2199
2242
  };
@@ -2352,7 +2395,7 @@ const MgInputDate = class {
2352
2395
  * @returns HTML Element
2353
2396
  */
2354
2397
  render() {
2355
- return (index.h("mg-input", { key: '78d4b2b8adb5aa39757e9e077a3d597d72b5c61b', 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 && index.h("b", { class: "mg-c-input__readonly-value" }, index_es.ze(this.value, this.locale))) : (index.h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, ref: (el) => {
2398
+ return (index.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 && index.h("b", { class: "mg-c-input__readonly-value" }, index_es.ze(this.value, this.locale))) : (index.h("input", { type: "date", class: "mg-c-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, ref: (el) => {
2356
2399
  if (el !== null)
2357
2400
  this.input = el;
2358
2401
  } }))));
@@ -2502,7 +2545,7 @@ const MgInputNumeric = class {
2502
2545
  else {
2503
2546
  const formattedMin = this.formatErrorValue(this.min);
2504
2547
  const formattedMax = this.formatErrorValue(this.max);
2505
- this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', formattedMin).replace('{max}', formattedMax);
2548
+ this.errorMessage = this.messages.input.numeric.helpText[inputError].replace('{min}', formattedMin).replace('{max}', formattedMax);
2506
2549
  }
2507
2550
  }
2508
2551
  };
@@ -2511,26 +2554,24 @@ const MgInputNumeric = class {
2511
2554
  * @returns error code
2512
2555
  */
2513
2556
  this.getInputError = () => {
2514
- let inputError = null;
2515
2557
  const hasNotEmptyValues = (toControl) => !toControl.some(value => [null, undefined].includes(value));
2516
2558
  // required
2517
2559
  if (!this.input.checkValidity() && this.input.validity.valueMissing) {
2518
- inputError = 'required';
2560
+ return 'required';
2519
2561
  }
2520
- // Min & Max
2521
- else if (hasNotEmptyValues([this.min, this.numericValue]) && this.numericValue < this.min && this.max === undefined) {
2522
- // Only a min value is set
2523
- inputError = 'min';
2562
+ // Only a min value is set
2563
+ if (hasNotEmptyValues([this.min, this.numericValue]) && this.numericValue < this.min && this.max === undefined) {
2564
+ return 'min';
2524
2565
  }
2525
- else if (hasNotEmptyValues([this.max, this.numericValue]) && this.numericValue > this.max && this.min === undefined) {
2526
- // Only a max value is set
2527
- inputError = 'max';
2566
+ // Only a max value is set
2567
+ if (hasNotEmptyValues([this.max, this.numericValue]) && this.numericValue > this.max && this.min === undefined) {
2568
+ return 'max';
2528
2569
  }
2529
- else if (hasNotEmptyValues([this.min, this.max, this.numericValue]) && (this.numericValue < this.min || this.numericValue > this.max)) {
2530
- // both min and max values are set
2531
- inputError = 'minMax';
2570
+ // both min and max values are set
2571
+ if (hasNotEmptyValues([this.min, this.max, this.numericValue]) && (this.numericValue < this.min || this.numericValue > this.max)) {
2572
+ return 'minMax';
2532
2573
  }
2533
- return inputError;
2574
+ return null;
2534
2575
  };
2535
2576
  /**
2536
2577
  * Format value based on type
@@ -2566,6 +2607,41 @@ const MgInputNumeric = class {
2566
2607
  }
2567
2608
  }
2568
2609
  };
2610
+ /**
2611
+ * Format help text to display
2612
+ * @param helpText - help text format
2613
+ * @returns formatted help text with range information if applicable
2614
+ */
2615
+ this.formatHelpText = (helpText) => {
2616
+ // If the component is in readonly mode, return undefined because the message will not be rendered
2617
+ if (this.readonly) {
2618
+ return undefined;
2619
+ }
2620
+ // If a custom helpText is provided, store it but don't return it directly
2621
+ const text = index_es.me(helpText) ? helpText : undefined;
2622
+ // If neither min nor max are defined, and there's no custom helpText,
2623
+ // we can return undefined as there's no message to display
2624
+ if (this.min === undefined && this.max === undefined && text === undefined) {
2625
+ return undefined;
2626
+ }
2627
+ // Generate range message based on available constraints
2628
+ let rangeMessage;
2629
+ if (this.min !== undefined && this.max !== undefined) {
2630
+ rangeMessage = this.messages.input.numeric.helpText.minMax.replace('{min}', this.formatErrorValue(this.min)).replace('{max}', this.formatErrorValue(this.max));
2631
+ }
2632
+ else if (this.min !== undefined) {
2633
+ rangeMessage = this.messages.input.numeric.helpText.min.replace('{min}', this.formatErrorValue(this.min));
2634
+ }
2635
+ else if (this.max !== undefined) {
2636
+ rangeMessage = this.messages.input.numeric.helpText.max.replace('{max}', this.formatErrorValue(this.max));
2637
+ }
2638
+ // Combine custom helpText with range message if both exist
2639
+ if (text !== undefined && rangeMessage !== undefined) {
2640
+ return `${text}<br>${rangeMessage}`;
2641
+ }
2642
+ // Return either custom helpText or range message
2643
+ return text || rangeMessage;
2644
+ };
2569
2645
  /**
2570
2646
  * Renders the readonly content of the input component.
2571
2647
  * @returns The readonly content element.
@@ -2575,18 +2651,19 @@ const MgInputNumeric = class {
2575
2651
  };
2576
2652
  }
2577
2653
  validateValue(newValue) {
2654
+ var _a;
2578
2655
  // has input value is always render as string we get a stringified value or a '' for nullish value, so we test string type
2579
2656
  if (typeof newValue === 'string') {
2580
2657
  // Split number and decimal
2581
2658
  const [integer, decimal = ''] = newValue.replace('-', '').split(/[.,]/);
2582
2659
  // Regex
2583
- const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+(?:[.,]\d*)?$/;
2660
+ const regex = this.type === 'integer' ? /^(?!-?0\d)-?\d+$/ : /^(?!-?0\d)-?\d+(?:[.,]\d*)?$/;
2584
2661
  // Filter input
2585
2662
  if (this.isValidValue(newValue, regex, integer, decimal)) {
2586
2663
  this.storedValue = newValue;
2587
2664
  }
2588
2665
  else {
2589
- newValue = this.handleInvalidValue();
2666
+ newValue = (_a = this.storedValue) !== null && _a !== void 0 ? _a : null;
2590
2667
  }
2591
2668
  // Set value and input value
2592
2669
  this.updateValues(newValue);
@@ -2717,24 +2794,19 @@ const MgInputNumeric = class {
2717
2794
  isValidValue(value, regex, integer, decimal) {
2718
2795
  return (['', '-'].includes(value) || (regex.exec(value) !== null && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength)));
2719
2796
  }
2720
- /**
2721
- * Handles invalid input values and returns a corrected value.
2722
- * @returns The corrected value.
2723
- */
2724
- handleInvalidValue() {
2725
- var _a;
2726
- return (_a = this.storedValue) !== null && _a !== void 0 ? _a : null;
2727
- }
2728
2797
  /**
2729
2798
  * Updates the component values based on the validated input value.
2730
2799
  * @param newValue - The validated input value.
2731
2800
  */
2732
2801
  updateValues(newValue) {
2733
2802
  this.value = newValue;
2734
- if (this.input !== undefined)
2803
+ if (this.input !== undefined) {
2735
2804
  this.input.value = this.value;
2736
- this.numericValue = !['', null].includes(this.value) ? parseFloat(this.value.replace(',', '.')) : null;
2737
- this.valueChange.emit(this.numericValue);
2805
+ }
2806
+ this.numericValue = !['', null].includes(this.value) && !isNaN(parseFloat(this.value)) ? parseFloat(this.value.replace(',', '.')) : null;
2807
+ if (newValue === null || (newValue === this.storedValue && !Object.is(this.numericValue, -0))) {
2808
+ this.valueChange.emit(this.numericValue);
2809
+ }
2738
2810
  this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
2739
2811
  }
2740
2812
  /**
@@ -2780,7 +2852,7 @@ const MgInputNumeric = class {
2780
2852
  * @returns HTML Element
2781
2853
  */
2782
2854
  render() {
2783
- return (index.h("mg-input", { key: '1607a9811037ae2e3a5c1f444f6ec05da38b990b', 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.helpText, errorMessage: this.errorMessage }, this.readonly
2855
+ return (index.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
2784
2856
  ? this.readonlyValue && this.renderReadonly()
2785
2857
  : [
2786
2858
  index.h("input", { key: "input", type: "text", class: "mg-c-input__box mg-c-input__box--width", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-invalid": (this.invalid === true).toString(), onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: (el) => {
@@ -3674,6 +3746,14 @@ const MgInputSelect = class {
3674
3746
  };
3675
3747
  MgInputSelect.style = MgInputSelectStyle0;
3676
3748
 
3749
+ /**
3750
+ * TextType from text types
3751
+ */
3752
+ // Define possible text types with help text
3753
+ const helpTextTypes = ['email', 'emails', 'url'];
3754
+ // Define possible text types
3755
+ const textTypes = ['text', 'search', 'tel', ...helpTextTypes];
3756
+
3677
3757
  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)}";
3678
3758
  const MgInputTextStyle0 = mgInputTextCss;
3679
3759
 
@@ -3750,6 +3830,16 @@ const MgInputText = class {
3750
3830
  * Component classes
3751
3831
  */
3752
3832
  this.classCollection = new index_es.Ze(['mg-c-input--text']);
3833
+ /**
3834
+ * Validate pattern configuration
3835
+ */
3836
+ this.validatePattern = () => {
3837
+ if ((this.pattern !== undefined || this.patternErrorMessage !== undefined) && // At least one is defined
3838
+ (!index_es.me(this.pattern) || (!helpTextTypes.includes(this.type) && !index_es.me(this.patternErrorMessage))) // Both must be defined
3839
+ ) {
3840
+ 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}'".`);
3841
+ }
3842
+ };
3753
3843
  /**
3754
3844
  * Handle input event
3755
3845
  */
@@ -3792,15 +3882,20 @@ const MgInputText = class {
3792
3882
  * @param errorMessage - errorMessage override
3793
3883
  */
3794
3884
  this.setErrorMessage = (errorMessage) => {
3885
+ var _a;
3795
3886
  // Set error message
3796
3887
  this.errorMessage = undefined;
3797
3888
  // Does have a custom error message
3798
3889
  if (!this.valid && errorMessage !== undefined) {
3799
3890
  this.errorMessage = errorMessage;
3800
3891
  }
3892
+ // Does not match type (email, emails, tel, url, etc.)
3893
+ else if (!this.valid && this.input.validity.typeMismatch) {
3894
+ this.errorMessage = `${this.messages.input.text.errors.typeMismatch} ${this.messages.input.text.helpText[this.type]}`;
3895
+ }
3801
3896
  // Does not match pattern
3802
3897
  else if (!this.valid && this.input.validity.patternMismatch) {
3803
- this.errorMessage = this.patternErrorMessage;
3898
+ this.errorMessage = (_a = this.patternErrorMessage) !== null && _a !== void 0 ? _a : `${this.messages.input.text.errors.typeMismatch} ${this.messages.input.text.helpText[this.type]}`;
3804
3899
  }
3805
3900
  // required
3806
3901
  else if (!this.valid && this.input.validity.valueMissing) {
@@ -3848,6 +3943,11 @@ const MgInputText = class {
3848
3943
  this.valueChange.emit(newValue);
3849
3944
  }
3850
3945
  }
3946
+ validateType(newValue) {
3947
+ if (!textTypes.includes(newValue)) {
3948
+ throw new Error(`<mg-input-text> prop "type" must be one of the following values: ${textTypes.join(', ')}. Passed value: ${newValue}.`);
3949
+ }
3950
+ }
3851
3951
  validateIcon(newValue) {
3852
3952
  if (newValue !== undefined) {
3853
3953
  this.classCollection.add(this.classHasIcon);
@@ -3892,9 +3992,12 @@ const MgInputText = class {
3892
3992
  if (newValue !== undefined)
3893
3993
  this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
3894
3994
  }
3895
- validatePattern(newValue) {
3896
- if (newValue !== undefined && !(index_es.me(this.pattern) && index_es.me(this.patternErrorMessage))) {
3897
- throw new Error(`<mg-input-text> props "pattern" and "patternErrorMessage" must be non-empty string and paired. Passed value: "pattern='${index_es.Ve(this.pattern)}'" and "patternErrorMessage='${index_es.Ve(this.patternErrorMessage)}'".`);
3995
+ watchPattern() {
3996
+ this.validatePattern();
3997
+ }
3998
+ watchHelpText(newValue) {
3999
+ if (!index_es.me(newValue) && helpTextTypes.includes(this.type)) {
4000
+ this.helpText = this.messages.input.text.helpText[this.type];
3898
4001
  }
3899
4002
  }
3900
4003
  /**
@@ -3981,12 +4084,13 @@ const MgInputText = class {
3981
4084
  // Validate
3982
4085
  this.validateIcon(this.icon);
3983
4086
  this.validateDatalistoptions(this.datalistoptions);
3984
- this.validatePattern(this.pattern);
3985
- this.validatePattern(this.patternErrorMessage);
4087
+ this.watchPattern();
3986
4088
  this.validateAppendSlot();
3987
4089
  this.watchMgWidth(this.mgWidth);
3988
4090
  this.watchReadonly(this.readonly);
3989
4091
  this.watchDisabled(this.disabled);
4092
+ this.validateType(this.type);
4093
+ this.watchHelpText(this.helpText);
3990
4094
  // Check validity when component is ready
3991
4095
  // return a promise to process action only in the FIRST render().
3992
4096
  // https://stenciljs.com/docs/component-lifecycle#componentwillload
@@ -3999,12 +4103,12 @@ const MgInputText = class {
3999
4103
  * @returns HTML Element
4000
4104
  */
4001
4105
  render() {
4002
- return (index.h("mg-input", { key: '3677b48b65765727f36e9379af1282d5a8f3762c', 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
4106
+ return (index.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
4003
4107
  ? this.value && this.renderReadonly()
4004
4108
  : [
4005
4109
  index.h("div", { key: "input", class: "mg-c-input__with-character-left", style: {
4006
4110
  '--mg-c-character-left-message-length': (!this.characterLeftHide ? this.maxlength.toString().length * 2 + 1 : 0).toString(),
4007
- } }, this.icon !== undefined && index.h("mg-icon", { icon: this.icon }), index.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) => {
4111
+ } }, this.icon !== undefined && index.h("mg-icon", { icon: this.icon }), index.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) => {
4008
4112
  if (el !== null)
4009
4113
  this.input = el;
4010
4114
  } }), this.hasDatalist() && (index.h("datalist", { id: this.datalistId }, this.datalistoptions.map(option => (index.h("option", { value: isOption$1(option) ? option.title : option, key: option }))))), !this.characterLeftHide && this.maxlength > 0 && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))),
@@ -4014,14 +4118,16 @@ const MgInputText = class {
4014
4118
  get element() { return index.getElement(this); }
4015
4119
  static get watchers() { return {
4016
4120
  "value": ["handleValue"],
4121
+ "type": ["validateType"],
4017
4122
  "icon": ["validateIcon"],
4018
4123
  "datalistoptions": ["validateDatalistoptions"],
4019
4124
  "readonly": ["watchReadonly", "handleValidityChange"],
4020
4125
  "required": ["handleValidityChange"],
4021
4126
  "disabled": ["handleValidityChange", "watchDisabled"],
4022
4127
  "mgWidth": ["watchMgWidth"],
4023
- "pattern": ["validatePattern"],
4024
- "patternErrorMessage": ["validatePattern"]
4128
+ "pattern": ["watchPattern"],
4129
+ "patternErrorMessage": ["watchPattern"],
4130
+ "helpText": ["watchHelpText"]
4025
4131
  }; }
4026
4132
  };
4027
4133
  MgInputText.style = MgInputTextStyle0;
@@ -4739,7 +4845,7 @@ const MgItemMore = class {
4739
4845
  this.slotlabel.label = this.messages.menuLabel;
4740
4846
  }
4741
4847
  validateSize(newValue) {
4742
- if (newValue && !sizes$4.includes(newValue))
4848
+ if (newValue && !sizes$5.includes(newValue))
4743
4849
  throw new Error(`<${this.name}> prop "size" must match MgItemMore['size'] type. Passed value: ${index_es.Ve(newValue)}.`);
4744
4850
  }
4745
4851
  /*************
@@ -4894,8 +5000,8 @@ const MgMenu = class {
4894
5000
  }
4895
5001
  }
4896
5002
  validateSize(newValue) {
4897
- if (!sizes$4.includes(newValue)) {
4898
- throw new Error(`<${this.name}> prop "size" must be one of: ${sizes$4.join(', ')}. Passed value: ${index_es.Ve(newValue)}.`);
5003
+ if (!sizes$5.includes(newValue)) {
5004
+ throw new Error(`<${this.name}> prop "size" must be one of: ${sizes$5.join(', ')}. Passed value: ${index_es.Ve(newValue)}.`);
4899
5005
  }
4900
5006
  }
4901
5007
  /**
@@ -8450,6 +8556,285 @@ const MgSkipLinks = class {
8450
8556
  };
8451
8557
  MgSkipLinks.style = MgSkipLinksStyle0;
8452
8558
 
8559
+ /**
8560
+ * Sizes
8561
+ */
8562
+ // Define possible sizes
8563
+ const sizes$1 = ['small', 'medium', 'large', 'xlarge'];
8564
+ /**
8565
+ * Columns
8566
+ */
8567
+ // Define possible text alignments
8568
+ const textAlignments = ['left', 'center', 'right'];
8569
+ // Define possible data types
8570
+ const dataTypes = ['string', 'numeric', 'date'];
8571
+
8572
+ 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%)}";
8573
+ const MgTableStyle0 = mgTableCss;
8574
+
8575
+ /**
8576
+ * Check if value is a valid align object
8577
+ * @param newValue - New value
8578
+ * @returns True if value is a valid align object
8579
+ */
8580
+ const isValidColumnsObject = (newValue) =>
8581
+ // ensure newValue is an object
8582
+ typeof newValue === 'object' &&
8583
+ !Array.isArray(newValue) &&
8584
+ // Ensure every property is well formatted
8585
+ Object.entries(newValue).every(([key, value]) =>
8586
+ // ensure key is a number
8587
+ !isNaN(parseInt(key)) &&
8588
+ // ensure value is an object
8589
+ typeof value === 'object' &&
8590
+ !Array.isArray(value) &&
8591
+ // ensure value has at least one of the following properties
8592
+ ((value.align !== undefined && textAlignments.includes(value.align)) ||
8593
+ (value.sortable !== undefined && typeof value.sortable === 'boolean') ||
8594
+ (value.datatype !== undefined && dataTypes.includes(value.datatype))) &&
8595
+ // ensure no extra properties are present
8596
+ Object.keys(value).every(key => ['align', 'sortable', 'datatype'].includes(key)));
8597
+ /**
8598
+ * Compare values
8599
+ * @param firstValue - First value
8600
+ * @param secondValue - Second value
8601
+ * @param descending - Define descending order
8602
+ * @param datatype - Data type
8603
+ * @returns Comparison result
8604
+ * @example
8605
+ * compareValues('a', 'b', false, 'string'); // -1
8606
+ */
8607
+ const compareValues = (firstValue, secondValue, descending, datatype) => {
8608
+ if (descending) {
8609
+ const temp = firstValue;
8610
+ firstValue = secondValue;
8611
+ secondValue = temp;
8612
+ }
8613
+ if (datatype === 'date') {
8614
+ return new Date(firstValue).getTime() - new Date(secondValue).getTime();
8615
+ }
8616
+ return firstValue.localeCompare(secondValue, undefined, { numeric: datatype === 'numeric' });
8617
+ };
8618
+ const MgTable = class {
8619
+ constructor(hostRef) {
8620
+ index.registerInstance(this, hostRef);
8621
+ // Classes
8622
+ this.componentClass = 'mg-c-table';
8623
+ this.componentWrapperClass = 'mg-c-table-wrapper';
8624
+ this.classFullWidth = 'mg-c-table--full-width';
8625
+ // Alignment stylesheet
8626
+ this.alignmentStylesheet = new CSSStyleSheet();
8627
+ /**
8628
+ * Define table size
8629
+ */
8630
+ this.size = 'medium';
8631
+ /**
8632
+ * Define if table fits its parent element
8633
+ */
8634
+ this.fullWidth = false;
8635
+ /**
8636
+ * Class collection
8637
+ */
8638
+ this.classCollection = new index_es.Ze([this.componentClass]);
8639
+ }
8640
+ watchSize(newValue, oldValue) {
8641
+ if (!sizes$1.includes(newValue)) {
8642
+ throw new Error(`<mg-table> prop "size" must be one of: ${sizes$1.join(', ')}. Passed value: ${index_es.Ve(newValue)}.`);
8643
+ }
8644
+ else {
8645
+ if (oldValue !== undefined) {
8646
+ this.classCollection.delete(`mg-c-table--size-${oldValue}`);
8647
+ }
8648
+ this.classCollection.add(`mg-c-table--size-${newValue}`);
8649
+ }
8650
+ }
8651
+ watchFullWidth(newValue) {
8652
+ if (newValue) {
8653
+ this.classCollection.add(this.classFullWidth);
8654
+ }
8655
+ else {
8656
+ this.classCollection.delete(this.classFullWidth);
8657
+ }
8658
+ }
8659
+ watchColumns(newValue) {
8660
+ if (newValue !== undefined && !isValidColumnsObject(newValue)) {
8661
+ throw new Error(`<mg-table> prop "columns" must be a ColumnsType object. Passed value: ${index_es.Ve(newValue)}.`);
8662
+ }
8663
+ }
8664
+ /**
8665
+ * Render Table
8666
+ * @param table - Table element
8667
+ */
8668
+ renderTable(table) {
8669
+ let isSortable = false;
8670
+ // Remove table classes
8671
+ table.className = '';
8672
+ // Add table classes
8673
+ table.classList.add(...this.classCollection.classes);
8674
+ // Set columns based on columns prop
8675
+ if (this.columns !== undefined) {
8676
+ // Store original rows
8677
+ const rowsDefault = Array.from(table.querySelectorAll('tbody tr'));
8678
+ // Apply columns settings
8679
+ Object.entries(this.columns).forEach(([key, value]) => {
8680
+ // Add alignment to stylesheet
8681
+ if (value.align !== undefined) {
8682
+ this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:${value.align}}}`);
8683
+ }
8684
+ // if align is not defined and datatype is number, align right
8685
+ else if (value.datatype === 'numeric') {
8686
+ this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:right}}`);
8687
+ }
8688
+ // Define if column is sortable
8689
+ if (value.sortable) {
8690
+ isSortable = true;
8691
+ // Add sortable class to table header
8692
+ const sortableHeader = table.querySelector(`thead td:nth-child(${key}),thead th:nth-child(${key})`);
8693
+ // Create button
8694
+ const button = document.createElement('button');
8695
+ button.classList.add('mg-c-table__sort-button');
8696
+ // Append button to header
8697
+ const sortableHeaderContent = sortableHeader.innerHTML;
8698
+ sortableHeader.innerHTML = '';
8699
+ button.innerHTML = sortableHeaderContent;
8700
+ // Set icon
8701
+ const icon = document.createElement('mg-icon');
8702
+ icon.setAttribute('icon', 'arrows-up-down');
8703
+ // Append icon to button
8704
+ button.append(icon);
8705
+ sortableHeader.append(button);
8706
+ // Add event listener
8707
+ button.addEventListener('click', () => {
8708
+ // Reset aria pressed
8709
+ table.querySelectorAll(`thead td:not(:nth-child(${key})) [aria-pressed],thead th:not(:nth-child(${key})) [aria-pressed]`).forEach(ariaPressed => {
8710
+ ariaPressed.removeAttribute('aria-pressed');
8711
+ ariaPressed.querySelector('mg-icon').setAttribute('icon', 'arrows-up-down');
8712
+ });
8713
+ // Reset aria sort
8714
+ table.querySelectorAll(`thead td:not(:nth-child(${key}))[aria-sort],thead th:not(:nth-child(${key}))[aria-sort]`).forEach(ariaSort => {
8715
+ ariaSort.removeAttribute('aria-sort');
8716
+ });
8717
+ // Set aria pressed
8718
+ button.setAttribute('aria-pressed', 'true');
8719
+ // Manage sort order
8720
+ // Get sort order
8721
+ let sortOrder = sortableHeader.getAttribute('aria-sort');
8722
+ // First click sort asc
8723
+ if ([null, 'none'].includes(sortOrder)) {
8724
+ sortableHeader.setAttribute('aria-sort', 'ascending');
8725
+ }
8726
+ // Second click sort desc
8727
+ else if (sortOrder === 'ascending') {
8728
+ sortableHeader.setAttribute('aria-sort', 'descending');
8729
+ }
8730
+ // Third click remove sort
8731
+ else {
8732
+ sortableHeader.setAttribute('aria-sort', 'none');
8733
+ }
8734
+ // Update sort order
8735
+ sortOrder = sortableHeader.getAttribute('aria-sort');
8736
+ // Update button icon
8737
+ const icon = button.querySelector('mg-icon');
8738
+ let iconType = 'arrows-up-down';
8739
+ if (sortOrder === 'ascending') {
8740
+ iconType = 'arrow-up';
8741
+ }
8742
+ else if (sortOrder === 'descending') {
8743
+ iconType = 'arrow-down';
8744
+ }
8745
+ icon.setAttribute('icon', iconType);
8746
+ // If sort order is none, return to original order
8747
+ if (sortOrder === 'none') {
8748
+ // Append rows to table
8749
+ rowsDefault.forEach(row => table.querySelector('tbody').append(row));
8750
+ return;
8751
+ }
8752
+ // Set a copy of rows
8753
+ const rows = Array.from(table.querySelectorAll('tbody tr'));
8754
+ // Sort rows
8755
+ rows.sort((a, b) => {
8756
+ var _a, _b;
8757
+ // Get cells
8758
+ const cellA = a.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);
8759
+ const cellB = b.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);
8760
+ // Get cell values
8761
+ const cellValueA = (_a = cellA.dataset.sort) !== null && _a !== void 0 ? _a : cellA.textContent;
8762
+ const cellValueB = (_b = cellB.dataset.sort) !== null && _b !== void 0 ? _b : cellB.textContent;
8763
+ // Sort cells based on sort order
8764
+ return compareValues(cellValueA, cellValueB, sortOrder === 'descending', value.datatype);
8765
+ });
8766
+ // Append rows to table
8767
+ rows.forEach(row => table.querySelector('tbody').append(row));
8768
+ });
8769
+ }
8770
+ });
8771
+ }
8772
+ // Add alignment to columns
8773
+ this.element.shadowRoot.adoptedStyleSheets = [...this.element.shadowRoot.adoptedStyleSheets, this.alignmentStylesheet];
8774
+ // Create div wrapper for responsive behavior
8775
+ const divWrapper = document.createElement('div');
8776
+ divWrapper.setAttribute('class', this.componentWrapperClass);
8777
+ divWrapper.setAttribute('tabindex', '0');
8778
+ divWrapper.setAttribute('role', 'region');
8779
+ // Get table title
8780
+ let captionTable = table.querySelector('caption');
8781
+ // If table is sortable we must add a caption
8782
+ if (captionTable === null && isSortable) {
8783
+ captionTable = document.createElement('caption');
8784
+ table.prepend(captionTable);
8785
+ }
8786
+ if (captionTable !== null) {
8787
+ // Ensure caption is not visible (otherwhise the table does not have rounded corners)
8788
+ captionTable.className = 'mg-u-visually-hidden';
8789
+ // Link caption to div
8790
+ if (!index_es.me(captionTable.id)) {
8791
+ captionTable.setAttribute('id', index_es.Ge(`${this.componentClass}-caption`));
8792
+ }
8793
+ divWrapper.setAttribute('aria-labelledby', captionTable.id);
8794
+ // Add sortable caption if neeeded
8795
+ if (isSortable) {
8796
+ captionTable.innerHTML = `${captionTable.innerHTML} ${this.messages.table.sortableCaption}`.trim();
8797
+ }
8798
+ }
8799
+ divWrapper.append(table);
8800
+ // Remove existing table from shadow root
8801
+ const existingTable = this.element.shadowRoot.querySelector(`.${this.componentWrapperClass}`);
8802
+ if (existingTable !== null) {
8803
+ existingTable.remove();
8804
+ }
8805
+ // Append table
8806
+ this.element.shadowRoot.append(divWrapper);
8807
+ }
8808
+ /*************
8809
+ * Lifecycle *
8810
+ *************/
8811
+ componentWillLoad() {
8812
+ this.messages = index$1.initLocales(this.element).messages;
8813
+ }
8814
+ /**
8815
+ * Set variables and validate props
8816
+ */
8817
+ componentDidLoad() {
8818
+ this.watchSize(this.size);
8819
+ this.watchFullWidth(this.fullWidth);
8820
+ this.watchColumns(this.columns);
8821
+ this.renderTable(this.element.querySelector('table'));
8822
+ }
8823
+ /**
8824
+ * Update table
8825
+ */
8826
+ componentWillUpdate() {
8827
+ this.renderTable(this.element.shadowRoot.querySelector('table'));
8828
+ }
8829
+ get element() { return index.getElement(this); }
8830
+ static get watchers() { return {
8831
+ "size": ["watchSize"],
8832
+ "fullWidth": ["watchFullWidth"],
8833
+ "columns": ["watchColumns"]
8834
+ }; }
8835
+ };
8836
+ MgTable.style = MgTableStyle0;
8837
+
8453
8838
  /**
8454
8839
  * Available tabs items status
8455
8840
  */
@@ -9271,9 +9656,10 @@ exports.mg_panel = MgPanel;
9271
9656
  exports.mg_popover = MgPopover;
9272
9657
  exports.mg_popover_content = MgPopoverContent;
9273
9658
  exports.mg_skip_links = MgSkipLinks;
9659
+ exports.mg_table = MgTable;
9274
9660
  exports.mg_tabs = MgTabs;
9275
9661
  exports.mg_tag = MgTag;
9276
9662
  exports.mg_tooltip = MgTooltip;
9277
9663
  exports.mg_tooltip_content = MgTooltipContent;
9278
9664
 
9279
- //# sourceMappingURL=mg-action-more_36.cjs.entry.js.map
9665
+ //# sourceMappingURL=mg-action-more_37.cjs.entry.js.map