@mgdis/mg-components 5.0.0 → 5.2.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 (120) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/{mg-badge_24.cjs.entry.js → mg-badge_27.cjs.entry.js} +892 -295
  3. package/dist/cjs/mg-components.cjs.js +1 -1
  4. package/dist/collection/collection-manifest.json +2 -0
  5. package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -1
  6. package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +1 -0
  7. package/dist/collection/components/atoms/mg-button/mg-button.css +8 -0
  8. package/dist/collection/components/atoms/mg-button/mg-button.js +41 -3
  9. package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +18 -0
  10. package/dist/collection/components/atoms/mg-card/mg-card.css +7 -0
  11. package/dist/collection/components/atoms/mg-card/mg-card.js +26 -0
  12. package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +18 -0
  13. package/dist/collection/components/atoms/mg-divider/mg-divider.css +9 -0
  14. package/dist/collection/components/atoms/mg-divider/mg-divider.js +57 -0
  15. package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
  16. package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -5
  17. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +0 -20
  18. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +1 -1
  19. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +2 -1
  20. package/dist/collection/components/molecules/inputs/MgInput.js +3 -11
  21. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +41 -20
  22. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +50 -39
  23. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +25 -6
  24. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +42 -33
  25. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +25 -6
  26. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +36 -17
  27. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +35 -14
  28. package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +2 -3
  29. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +28 -6
  30. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +36 -17
  31. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +25 -6
  32. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +38 -19
  33. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +25 -6
  34. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +37 -18
  35. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
  36. package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +1 -0
  37. package/dist/collection/components/molecules/mg-details/mg-details.css +29 -0
  38. package/dist/collection/components/molecules/mg-details/mg-details.js +26 -4
  39. package/dist/collection/components/molecules/mg-form/mg-form.js +73 -27
  40. package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +6 -6
  41. package/dist/collection/components/molecules/mg-message/mg-message.js +1 -1
  42. package/dist/collection/components/molecules/mg-modal/mg-modal.css +2 -1
  43. package/dist/collection/components/molecules/mg-modal/mg-modal.js +48 -4
  44. package/dist/collection/components/molecules/mg-panel/mg-panel.css +5 -14
  45. package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -5
  46. package/dist/collection/components/molecules/mg-popover/mg-popover.css +1 -1
  47. package/dist/collection/components/molecules/mg-popover/mg-popover.js +3 -2
  48. package/dist/collection/utils/components.utils.js +10 -6
  49. package/dist/collection/utils/unit.test.utils.js +51 -0
  50. package/dist/collection/variables.css +23 -8
  51. package/dist/components/MgInput.js +4 -12
  52. package/dist/components/components.utils.js +11 -7
  53. package/dist/components/index.d.ts +2 -0
  54. package/dist/components/index.js +2 -0
  55. package/dist/components/mg-badge2.js +1 -1
  56. package/dist/components/mg-button2.js +23 -4
  57. package/dist/components/mg-card.d.ts +11 -0
  58. package/dist/components/mg-card.js +42 -0
  59. package/dist/components/mg-details.js +8 -3
  60. package/dist/components/mg-divider.d.ts +11 -0
  61. package/dist/components/mg-divider.js +51 -0
  62. package/dist/components/mg-form.js +67 -26
  63. package/dist/components/mg-input-checkbox.js +36 -21
  64. package/dist/components/mg-input-date.js +44 -39
  65. package/dist/components/mg-input-numeric.js +37 -34
  66. package/dist/components/mg-input-password.js +32 -19
  67. package/dist/components/mg-input-radio.js +30 -15
  68. package/dist/components/mg-input-select2.js +32 -19
  69. package/dist/components/mg-input-text2.js +34 -21
  70. package/dist/components/mg-input-textarea.js +32 -19
  71. package/dist/components/mg-input-toggle.js +1 -1
  72. package/dist/components/mg-message.js +1 -1
  73. package/dist/components/mg-modal.js +49 -5
  74. package/dist/components/mg-panel.js +1 -1
  75. package/dist/components/mg-popover.js +3 -2
  76. package/dist/components/mg-tag.js +1 -1
  77. package/dist/components/mg-tooltip2.js +2 -4
  78. package/dist/esm/loader.js +1 -1
  79. package/dist/esm/{mg-badge_24.entry.js → mg-badge_27.entry.js} +839 -245
  80. package/dist/esm/mg-components.js +1 -1
  81. package/dist/mg-components/mg-components.css +1 -1
  82. package/dist/mg-components/mg-components.esm.js +1 -1
  83. package/dist/mg-components/p-b2b07c3f.entry.js +1 -0
  84. package/dist/mg-components/variables.css +23 -8
  85. package/dist/types/components/atoms/mg-button/mg-button.d.ts +8 -2
  86. package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +6 -0
  87. package/dist/types/components/atoms/mg-card/mg-card.d.ts +11 -0
  88. package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +6 -0
  89. package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +15 -0
  90. package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -6
  91. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +0 -8
  92. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +1 -1
  93. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +10 -8
  94. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +3 -8
  95. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +3 -8
  96. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -3
  97. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
  98. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -3
  99. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -4
  100. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -3
  101. package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
  102. package/dist/types/components/molecules/mg-form/mg-form.d.ts +21 -1
  103. package/dist/types/components/molecules/mg-message/mg-message.d.ts +3 -0
  104. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +11 -0
  105. package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -6
  106. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +1 -1
  107. package/dist/types/components.d.ts +55 -6
  108. package/dist/types/utils/components.utils.d.ts +7 -3
  109. package/package.json +9 -9
  110. package/dist/cjs/index-179621c8.js +0 -244
  111. package/dist/cjs/mg-modal.cjs.entry.js +0 -128
  112. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +0 -20
  113. package/dist/collection/utils/test.utils.js +0 -38
  114. package/dist/esm/index-7efedd97.js +0 -238
  115. package/dist/esm/mg-modal.entry.js +0 -124
  116. package/dist/mg-components/p-5f89600c.js +0 -1
  117. package/dist/mg-components/p-b60a4c53.entry.js +0 -1
  118. package/dist/mg-components/p-df947fa5.entry.js +0 -1
  119. package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +0 -8
  120. package/dist/types/utils/test.utils.d.ts +0 -17
@@ -3,13 +3,101 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-94497267.js');
6
- const index$1 = require('./index-179621c8.js');
7
6
 
8
7
  /**
9
8
  * List of all possibles variants
10
9
  */
11
10
  const variants$4 = ['info', 'primary', 'secondary', 'success', 'warning', 'danger'];
12
11
 
12
+ /**
13
+ * Create random ID
14
+ *
15
+ * @param {string} prefix add prefix to created ID
16
+ * @param {number} length ID length
17
+ * @returns {string} ID
18
+ */
19
+ const createID = (prefix = '', length = 10) => {
20
+ let ID = '';
21
+ const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
22
+ const charsLength = chars.length;
23
+ for (let i = 0; i < length; i++) {
24
+ ID += chars.charAt(Math.floor(Math.random() * charsLength));
25
+ }
26
+ return (prefix !== '' ? `${prefix}-` : '') + ID;
27
+ };
28
+ /**
29
+ * Class to manage component classlist
30
+ * Set() are not working when imported in project
31
+ */
32
+ class ClassList {
33
+ constructor(classlist = []) {
34
+ /**
35
+ * Add class
36
+ *
37
+ * @param {string} className class name to add
38
+ * @returns {void}
39
+ */
40
+ this.add = (className) => {
41
+ if (!this.has(className)) {
42
+ this.classes.push(className);
43
+ }
44
+ };
45
+ /**
46
+ * Delete class
47
+ *
48
+ * @param {string} className class name to delete
49
+ * @returns {void}
50
+ */
51
+ this.delete = (className) => {
52
+ const index = this.classes.indexOf(className);
53
+ if (index > -1) {
54
+ this.classes.splice(index, 1);
55
+ }
56
+ };
57
+ /**
58
+ * Check if class exist in list
59
+ *
60
+ * @param {string} className class name to check
61
+ * @returns {boolean} class name is in the list
62
+ */
63
+ this.has = (className) => {
64
+ return this.classes.includes(className);
65
+ };
66
+ /**
67
+ * Join classes seperated by spaces
68
+ *
69
+ * @returns {string} joined values
70
+ */
71
+ this.join = () => {
72
+ return this.classes.join(' ');
73
+ };
74
+ this.classes = classlist;
75
+ }
76
+ }
77
+ /**
78
+ * Check if all items are string
79
+ *
80
+ * @param {string[]} items items to check
81
+ * @returns {boolean} all items are string
82
+ */
83
+ const allItemsAreString = (items) => {
84
+ return items && items.every(item => typeof item === 'string');
85
+ };
86
+ /**
87
+ * Check if element is a heading
88
+ *
89
+ * @param {Element} element slotted element
90
+ * @param {string[]} tagNames allowed tag names list
91
+ * @returns {boolean} element is a heading
92
+ */
93
+ const isTagName = (element, tagNames) => {
94
+ return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
95
+ };
96
+ /**
97
+ * Focusable elements query selector
98
+ */
99
+ const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
100
+
13
101
  const mgBadgeCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-badge{padding:0 0.4rem;height:var(--mg-badge-size);min-width:var(--mg-badge-size);box-sizing:border-box;border:0.1rem solid;border-radius:calc(var(--mg-badge-size) / 2);font-size:var(--mg-badge-font-size);font-weight:600;text-align:center;line-height:var(--mg-badge-size)}.mg-badge.mg-badge--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-badge.mg-badge--primary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-badge.mg-badge--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-badge.mg-badge--success.mg-badge--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-badge.mg-badge--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-badge.mg-badge--warning.mg-badge--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-badge.mg-badge--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-badge.mg-badge--danger.mg-badge--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-badge.mg-badge--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-badge.mg-badge--info.mg-badge--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-badge,mg-badge{display:inline-flex;align-items:center;justify-content:center}";
14
102
 
15
103
  const MgBadge = class {
@@ -18,7 +106,7 @@ const MgBadge = class {
18
106
  /************
19
107
  * Internal *
20
108
  ************/
21
- // classes
109
+ // Classes
22
110
  this.classOutline = `mg-badge--outline`;
23
111
  /**
24
112
  * Define button variant
@@ -27,7 +115,7 @@ const MgBadge = class {
27
115
  /**
28
116
  * Component classes
29
117
  */
30
- this.classList = new index$1.ClassList(['mg-badge']);
118
+ this.classList = new ClassList(['mg-badge']);
31
119
  }
32
120
  validateValue(newValue) {
33
121
  if (`${newValue}`.match(/^(\d+|[?*!a-z])$/i) === null) {
@@ -89,7 +177,7 @@ MgBadge.style = mgBadgeCss;
89
177
  */
90
178
  const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success'];
91
179
 
92
- const mgButtonCss = ":host{display:inline-block;vertical-align:middle;max-width:100%}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-button:not(.mg-button--disabled){outline-color:-webkit-focus-ring-color;outline-style:auto;outline-width:0.2rem}:host(:hover) .mg-button--flat:not(.mg-button--disabled),:host(:focus) .mg-button--flat:not(.mg-button--disabled),:host(:active) .mg-button--flat:not(.mg-button--disabled){background:hsla(var(--color-dark), 0.1)}.mg-button.mg-button--primary{border-color:hsl(var(--mg-button-primary-border-color, var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-primary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--primary:not(.mg-button--disabled),:host(:focus) .mg-button--primary:not(.mg-button--disabled),:host(:active) .mg-button--primary:not(.mg-button--disabled){background:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l))}.mg-button.mg-button--secondary{border-color:hsl(var(--mg-button-secondary-border-color, var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-secondary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--secondary:not(.mg-button--disabled),:host(:focus) .mg-button--secondary:not(.mg-button--disabled),:host(:active) .mg-button--secondary:not(.mg-button--disabled){background:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l))}.mg-button.mg-button--danger{border-color:hsl(var(--mg-button-danger-border-color, var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger:not(.mg-button--disabled),:host(:focus) .mg-button--danger:not(.mg-button--disabled),:host(:active) .mg-button--danger:not(.mg-button--disabled){background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-button.mg-button--danger-alt{border-color:hsl(var(--mg-button-danger-alt-border-color, var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-danger));background:linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger-alt:not(.mg-button--disabled),:host(:focus) .mg-button--danger-alt:not(.mg-button--disabled),:host(:active) .mg-button--danger-alt:not(.mg-button--disabled){background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))}.mg-button.mg-button--info{border-color:hsl(var(--mg-button-info-border-color, var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--info:not(.mg-button--disabled),:host(:focus) .mg-button--info:not(.mg-button--disabled),:host(:active) .mg-button--info:not(.mg-button--disabled){background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-button.mg-button--success{border-color:hsl(var(--mg-button-success-border-color, var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-dark));background:linear-gradient(to bottom, hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l)), hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--success:not(.mg-button--disabled),:host(:focus) .mg-button--success:not(.mg-button--disabled),:host(:active) .mg-button--success:not(.mg-button--disabled){background:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))}.mg-button{position:relative;display:inline-flex;align-items:center;column-gap:0.6rem;padding:calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;min-height:var(--default-size);box-sizing:border-box;border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-border-radius));cursor:pointer;background-image:none;border-top-width:var(--mg-button-border-top-width, 0.1rem);border-right-width:var(--mg-button-border-right-width, 0.1rem);border-bottom-width:var(--mg-button-border-bottom-width, 0.1rem);border-left-width:var(--mg-button-border-left-width, 0.1rem);border-style:solid;text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);touch-action:manipulation}.mg-button.mg-button--disabled{opacity:var(--mg-button-disabled-opacity);cursor:default}.mg-button.mg-button--icon{padding:0;justify-content:center;width:var(--default-size);height:var(--default-size);border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-icon-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-icon-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-icon-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-icon-border-radius));font-size:var(--font-size);line-height:var(--font-size)}.mg-button.mg-button--flat{background:none;border:none}.mg-button.mg-button--loading>mg-icon:first-of-type{position:absolute;left:50%;top:50%;transform:translate(-50%, -50%)}.mg-button.mg-button--loading .mg-button__content{opacity:0}.mg-button mg-icon:only-child,.mg-button ::slotted(mg-icon){display:inline-flex;flex-shrink:0;line-height:1;margin:auto 0}.mg-button slot,.mg-button ::slotted(*:not(mg-icon)){text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);display:flex;align-items:center;column-gap:0.6rem}";
180
+ const mgButtonCss = ":host{display:inline-block;vertical-align:middle;max-width:100%}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-button:not(.mg-button--disabled){outline-color:-webkit-focus-ring-color;outline-style:auto;outline-width:0.2rem}:host(:hover) .mg-button--flat:not(.mg-button--disabled),:host(:focus) .mg-button--flat:not(.mg-button--disabled),:host(:active) .mg-button--flat:not(.mg-button--disabled){background:hsla(var(--color-dark), 0.1)}:host([full-width]){display:block}.mg-button.mg-button--primary{border-color:hsl(var(--mg-button-primary-border-color, var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-primary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--primary:not(.mg-button--disabled),:host(:focus) .mg-button--primary:not(.mg-button--disabled),:host(:active) .mg-button--primary:not(.mg-button--disabled){background:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l))}.mg-button.mg-button--secondary{border-color:hsl(var(--mg-button-secondary-border-color, var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-secondary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--secondary:not(.mg-button--disabled),:host(:focus) .mg-button--secondary:not(.mg-button--disabled),:host(:active) .mg-button--secondary:not(.mg-button--disabled){background:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l))}.mg-button.mg-button--danger{border-color:hsl(var(--mg-button-danger-border-color, var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger:not(.mg-button--disabled),:host(:focus) .mg-button--danger:not(.mg-button--disabled),:host(:active) .mg-button--danger:not(.mg-button--disabled){background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-button.mg-button--danger-alt{border-color:hsl(var(--mg-button-danger-alt-border-color, var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-danger));background:linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger-alt:not(.mg-button--disabled),:host(:focus) .mg-button--danger-alt:not(.mg-button--disabled),:host(:active) .mg-button--danger-alt:not(.mg-button--disabled){background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))}.mg-button.mg-button--info{border-color:hsl(var(--mg-button-info-border-color, var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--info:not(.mg-button--disabled),:host(:focus) .mg-button--info:not(.mg-button--disabled),:host(:active) .mg-button--info:not(.mg-button--disabled){background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-button.mg-button--success{border-color:hsl(var(--mg-button-success-border-color, var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-dark));background:linear-gradient(to bottom, hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l)), hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--success:not(.mg-button--disabled),:host(:focus) .mg-button--success:not(.mg-button--disabled),:host(:active) .mg-button--success:not(.mg-button--disabled){background:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))}.mg-button{position:relative;display:inline-flex;align-items:center;column-gap:0.6rem;padding:calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;min-height:var(--default-size);box-sizing:border-box;border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-border-radius));cursor:pointer;background-image:none;border-top-width:var(--mg-button-border-top-width, 0.1rem);border-right-width:var(--mg-button-border-right-width, 0.1rem);border-bottom-width:var(--mg-button-border-bottom-width, 0.1rem);border-left-width:var(--mg-button-border-left-width, 0.1rem);border-style:solid;text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);touch-action:manipulation}.mg-button.mg-button--disabled{opacity:var(--mg-button-disabled-opacity);cursor:default}.mg-button.mg-button--icon{padding:0;justify-content:center;width:var(--default-size);height:var(--default-size);border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-icon-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-icon-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-icon-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-icon-border-radius));font-size:var(--font-size);line-height:var(--font-size)}.mg-button.mg-button--flat{background:none;border:none}.mg-button.mg-button--full-width{display:flex;justify-content:center}.mg-button.mg-button--loading>mg-icon:first-of-type{position:absolute;left:50%;top:50%;transform:translate(-50%, -50%)}.mg-button.mg-button--loading .mg-button__content{opacity:0}.mg-button mg-icon:only-child,.mg-button ::slotted(mg-icon){display:inline-flex;flex-shrink:0;line-height:1;margin:auto 0}.mg-button slot,.mg-button ::slotted(*:not(mg-icon)){text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);display:flex;align-items:center;column-gap:0.6rem}";
93
181
 
94
182
  const MgButton = class {
95
183
  constructor(hostRef) {
@@ -100,10 +188,15 @@ const MgButton = class {
100
188
  this.onClickElementFn = null;
101
189
  this.classDisabled = 'mg-button--disabled';
102
190
  this.classLoading = 'mg-button--loading';
191
+ this.classFullWidth = 'mg-button--full-width';
103
192
  /**
104
193
  * Define button variant
105
194
  */
106
195
  this.variant = variants$3[0]; // Primary
196
+ /**
197
+ * Set button to full-width
198
+ */
199
+ this.fullWidth = false;
107
200
  /**
108
201
  * Define if button is round.
109
202
  * Used for icon button.
@@ -123,7 +216,7 @@ const MgButton = class {
123
216
  /**
124
217
  * Component classes
125
218
  */
126
- this.classList = new index$1.ClassList(['mg-button']);
219
+ this.classList = new ClassList(['mg-button']);
127
220
  /**
128
221
  * Trigger actions onClick event
129
222
  *
@@ -140,7 +233,7 @@ const MgButton = class {
140
233
  }
141
234
  };
142
235
  /**
143
- * Handle onKeyDown event
236
+ * Handle onKeydown event
144
237
  *
145
238
  * @param {KeyboardEvent} event keyboard event
146
239
  * @returns {void}
@@ -155,7 +248,7 @@ const MgButton = class {
155
248
  }
156
249
  };
157
250
  /**
158
- * Handle onKeyUp event
251
+ * Handle onKeyup event
159
252
  *
160
253
  * @param {KeyboardEvent} event keyboard event
161
254
  * @returns {void}
@@ -178,6 +271,17 @@ const MgButton = class {
178
271
  this.classList.add(`mg-button--${newValue}`);
179
272
  }
180
273
  }
274
+ validateFullWidth(newValue) {
275
+ if (newValue && this.isIcon) {
276
+ throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
277
+ }
278
+ else if (newValue) {
279
+ this.classList.add(this.classFullWidth);
280
+ }
281
+ else {
282
+ this.classList.delete(this.classFullWidth);
283
+ }
284
+ }
181
285
  disabledHandler(isDisabled) {
182
286
  // Remove loading when enable
183
287
  // Will be set back onclick
@@ -210,6 +314,7 @@ const MgButton = class {
210
314
  */
211
315
  componentWillLoad() {
212
316
  this.validateVariant(this.variant);
317
+ this.validateFullWidth(this.fullWidth);
213
318
  if (this.isIcon) {
214
319
  this.classList.add(`mg-button--icon`);
215
320
  if (typeof this.label !== 'string' || this.label.trim() === '') {
@@ -226,17 +331,190 @@ const MgButton = class {
226
331
  * @returns {HTMLElement} html element
227
332
  */
228
333
  render() {
229
- return (index.h(index.Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyUp: this.handleKeyup, onKeyDown: this.handleKeydown }, index.h("div", { class: this.classList.join(), id: this.identifier }, this.loading && index.h("mg-icon", { icon: "loader", spin: true }), index.h("div", { class: "mg-button__content" }, index.h("slot", null)))));
334
+ return (index.h(index.Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, index.h("div", { class: this.classList.join(), id: this.identifier }, this.loading && index.h("mg-icon", { icon: "loader", spin: true }), index.h("div", { class: "mg-button__content" }, index.h("slot", null)))));
230
335
  }
231
336
  get element() { return index.getElement(this); }
232
337
  static get watchers() { return {
233
338
  "variant": ["validateVariant"],
339
+ "fullWidth": ["validateFullWidth"],
234
340
  "disabled": ["disabledHandler"],
235
341
  "loading": ["loadingHandler"]
236
342
  }; }
237
343
  };
238
344
  MgButton.style = mgButtonCss;
239
345
 
346
+ const mgCardCss = ".mg-card{padding:var(--mg-card-padding);border-radius:var(--mg-card-border-radius);background:var(--mg-card-background);border:var(--mg-card-border);box-shadow:var(--mg-card-box-shadow)}";
347
+
348
+ const MgCard = class {
349
+ constructor(hostRef) {
350
+ index.registerInstance(this, hostRef);
351
+ }
352
+ /*************
353
+ * Lifecycle *
354
+ *************/
355
+ /**
356
+ * Render
357
+ *
358
+ * @returns {HTMLElement} HTML Element
359
+ */
360
+ render() {
361
+ return (index.h("div", { class: "mg-card" }, index.h("slot", null)));
362
+ }
363
+ };
364
+ MgCard.style = mgCardCss;
365
+
366
+ const errors$1 = {
367
+ required: "This field is required.",
368
+ date: {
369
+ badInput: "The date format must be <span aria-hidden=\"true\">mm/dd/yyyy</span><span class=\"sr-only\">m m / d d / y y y y</span> and the date must be greater than {min}",
370
+ min: "The date cannot be earlier than {min}",
371
+ max: "The date cannot be later than {max}",
372
+ minMax: "The date must be between {min} and {max}"
373
+ },
374
+ numeric: {
375
+ min: "The value cannot be less than {min}",
376
+ max: "The value cannot be greater than {max}",
377
+ minMax: "The value must be between {min} et {max}"
378
+ }
379
+ };
380
+ const nbCharLeft$1 = "{counter} characters left.";
381
+ const input$1 = {
382
+ select: {
383
+ placeholder: "Select a value"
384
+ }
385
+ };
386
+ const form$1 = {
387
+ required: "Fields with a <strong class=\"is-asterisk\">*</strong> are required",
388
+ allRequired: "All fields are required"
389
+ };
390
+ const message$1 = {
391
+ closeButton: "Close message"
392
+ };
393
+ const modal$1 = {
394
+ closeButton: "Close modal"
395
+ };
396
+ const pagination$1 = {
397
+ label: "Pagination",
398
+ page: "page",
399
+ pages: "pages",
400
+ nextPage: "Next page",
401
+ previousPage: "Previous page",
402
+ selectPage: "Select the page to display."
403
+ };
404
+ const panel$1 = {
405
+ editLabel: "Edit section title."
406
+ };
407
+ const general$1 = {
408
+ confirm: "Confirm",
409
+ cancel: "Cancel",
410
+ close: "Close",
411
+ next: "next",
412
+ previous: "previous"
413
+ };
414
+ const en = {
415
+ errors: errors$1,
416
+ nbCharLeft: nbCharLeft$1,
417
+ input: input$1,
418
+ form: form$1,
419
+ message: message$1,
420
+ modal: modal$1,
421
+ pagination: pagination$1,
422
+ panel: panel$1,
423
+ general: general$1
424
+ };
425
+
426
+ const errors = {
427
+ required: "Ce champ est obligatoire.",
428
+ date: {
429
+ badInput: "Le format de la date doit être du type <span aria-hidden=\"true\">jj/mm/aaaa</span><span class=\"sr-only\">j j / m m / a a a a</span> et la date supérieure au {min}",
430
+ min: "La date ne peut pas être antérieure au {min}",
431
+ max: "La date ne peut pas être postérieure au {max}",
432
+ minMax: "La date doit être comprise entre le {min} et le {max}"
433
+ },
434
+ numeric: {
435
+ min: "La valeur ne peut pas être inférieure à {min}",
436
+ max: "La valeur ne peut pas être supérieure à {max}",
437
+ minMax: "La valeur doit être comprise entre {min} et {max}"
438
+ }
439
+ };
440
+ const nbCharLeft = "{counter} caractères disponibles.";
441
+ const input = {
442
+ select: {
443
+ placeholder: "Sélectionnez une valeur"
444
+ }
445
+ };
446
+ const form = {
447
+ required: "Les champs marqués d'un <strong class=\"is-asterisk\">*</strong> sont obligatoires",
448
+ allRequired: "Tous les champs sont obligatoires"
449
+ };
450
+ const message = {
451
+ closeButton: "Fermer le message"
452
+ };
453
+ const modal = {
454
+ closeButton: "Fermer la modale"
455
+ };
456
+ const pagination = {
457
+ label: "Pagination",
458
+ page: "page",
459
+ pages: "pages",
460
+ nextPage: "Page suivante",
461
+ previousPage: "Page précédente",
462
+ selectPage: "Sélectionner la page à afficher."
463
+ };
464
+ const panel = {
465
+ editLabel: "Modifier le titre de la section."
466
+ };
467
+ const general = {
468
+ confirm: "Valider",
469
+ cancel: "Annuler",
470
+ close: "Fermer",
471
+ next: "suivant",
472
+ previous: "précédent"
473
+ };
474
+ const fr = {
475
+ errors: errors,
476
+ nbCharLeft: nbCharLeft,
477
+ input: input,
478
+ form: form,
479
+ message: message,
480
+ modal: modal,
481
+ pagination: pagination,
482
+ panel: panel,
483
+ general: general
484
+ };
485
+
486
+ const defaultLocale = 'en';
487
+ const messages = { en, fr };
488
+ /**
489
+ * Get locale
490
+ *
491
+ * @param {HTMLElement} element element that needs to know the locale to use
492
+ * @returns {string} locale
493
+ */
494
+ const getLocale = (element) => {
495
+ var _a;
496
+ return ((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang) || navigator.language || defaultLocale;
497
+ };
498
+ /**
499
+ * Get Intl object
500
+ * We load the defined locale but for now we only support the first subtag for messages
501
+ *
502
+ * @param {HTMLElement} element element we need to get the language
503
+ * @returns {{ locale: string; messages: unknown }} messages object
504
+ */
505
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
506
+ const initLocales = (element) => {
507
+ // Get local
508
+ const locale = getLocale(element);
509
+ // Only keep first subtag
510
+ const localeSubtag = locale.split('-').shift();
511
+ // Return
512
+ return {
513
+ locale,
514
+ messages: messages[localeSubtag] || messages[defaultLocale],
515
+ };
516
+ };
517
+
240
518
  const mgCharacterLeftCss = "mg-character-left.sc-mg-character-left{display:block}";
241
519
 
242
520
  const MgCharacterLeft = class {
@@ -262,7 +540,7 @@ const MgCharacterLeft = class {
262
540
  */
263
541
  componentWillLoad() {
264
542
  this.validateMaxlength(this.maxlength);
265
- this.messages = index$1.initLocales(this.element).messages;
543
+ this.messages = initLocales(this.element).messages;
266
544
  }
267
545
  /**
268
546
  * Render component
@@ -279,12 +557,16 @@ const MgCharacterLeft = class {
279
557
  };
280
558
  MgCharacterLeft.style = mgCharacterLeftCss;
281
559
 
282
- const mgDetailsCss = ".mg-details summary{display:flex;align-items:baseline;cursor:pointer}.mg-details__toggle{margin-left:1.5rem;flex-shrink:0}.mg-details__details{margin-top:1.5rem}";
560
+ const mgDetailsCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-details summary{display:flex;align-items:baseline;cursor:pointer}.mg-details__toggle{margin-left:1.5rem;flex-shrink:0;display:flex;align-items:center;align-self:flex-start;gap:0.6rem;min-height:calc(var(--font-size) * var(--line-height))}.mg-details__toggle mg-icon{align-self:self-end}.mg-details__details{margin-top:1.5rem}";
283
561
 
284
562
  const MgDetails = class {
285
563
  constructor(hostRef) {
286
564
  index.registerInstance(this, hostRef);
287
565
  this.expandedChange = index.createEvent(this, "expanded-change", 7);
566
+ /**
567
+ * Hide summary element
568
+ */
569
+ this.hideSummary = false;
288
570
  /**
289
571
  * Define if details are diplayed
290
572
  */
@@ -299,7 +581,7 @@ const MgDetails = class {
299
581
  };
300
582
  }
301
583
  validateTitles(newValue) {
302
- if (newValue === undefined || newValue === '') {
584
+ if (newValue === undefined || newValue.trim() === '') {
303
585
  throw new Error('<mg-details> prop "toggleClosed" and "toggleOpened" must be defined.');
304
586
  }
305
587
  }
@@ -324,7 +606,7 @@ const MgDetails = class {
324
606
  * @returns {HTMLElement} HTML Element
325
607
  */
326
608
  render() {
327
- return (index.h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, index.h("summary", null, index.h("slot", { name: "summary" }), index.h("span", { class: "mg-details__toggle" }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), " ", this.expanded ? this.toggleOpened : this.toggleClosed)), index.h("div", { class: "mg-details__details" }, index.h("slot", { name: "details" }))));
609
+ return (index.h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, index.h("summary", null, index.h("slot", { name: "summary" }), index.h("span", { class: "mg-details__toggle" }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), index.h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), index.h("div", { class: "mg-details__details" }, index.h("slot", { name: "details" }))));
328
610
  }
329
611
  static get watchers() { return {
330
612
  "toggleClosed": ["validateTitles"],
@@ -334,6 +616,33 @@ const MgDetails = class {
334
616
  };
335
617
  MgDetails.style = mgDetailsCss;
336
618
 
619
+ const mgDividerCss = ".mg-divider{margin:var(--mg-divider-vertical-spacing) auto;width:12rem;height:var(--mg-divider-thickness);background-color:var(--mg-divider-background-color)}.mg-divider.mg-divider--full{width:100%}";
620
+
621
+ const MgDivider = class {
622
+ constructor(hostRef) {
623
+ index.registerInstance(this, hostRef);
624
+ /**************
625
+ * Decorators *
626
+ **************/
627
+ /**
628
+ * Define component size
629
+ */
630
+ this.size = 'regular';
631
+ }
632
+ /**
633
+ * Render
634
+ *
635
+ * @returns {HTMLElement} HTML Element
636
+ */
637
+ render() {
638
+ return (index.h("div", { class: {
639
+ 'mg-divider': true,
640
+ 'mg-divider--full': this.size === 'full',
641
+ } }));
642
+ }
643
+ };
644
+ MgDivider.style = mgDividerCss;
645
+
337
646
  const mgFormCss = ".is-asterisk{color:hsl(var(--color-danger))}.mg-form,.mg-form-group{--mg-inputs-title-width:var(--mg-form-inputs-title-width, 15rem);--mg-inputs-margin-bottom:1.5rem;--mg-inputs-title-horizontal-space:3rem;--mg-inputs-shrink:0}.mg-form.mg-form--all-required,.mg-form-group.mg-form--all-required{--mg-input-title-display:none}.mg-form>p,.mg-form-group>p{font-size:1.2rem}";
338
647
 
339
648
  const MgForm = class {
@@ -341,11 +650,13 @@ const MgForm = class {
341
650
  index.registerInstance(this, hostRef);
342
651
  this.formValid = index.createEvent(this, "form-valid", 7);
343
652
  this.formSubmit = index.createEvent(this, "form-submit", 7);
653
+ // Classes
654
+ this.classAllRequired = 'mg-form--all-required';
344
655
  /**
345
656
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
346
657
  * If not set, it will be created.
347
658
  */
348
- this.identifier = index$1.createID('mg-form');
659
+ this.identifier = createID('mg-form');
349
660
  /**
350
661
  * Input name
351
662
  * If not set the value equals the identifier
@@ -362,7 +673,7 @@ const MgForm = class {
362
673
  /**
363
674
  * Component classes
364
675
  */
365
- this.classList = new index$1.ClassList(['mg-form']);
676
+ this.classList = new ClassList(['mg-form']);
366
677
  /**
367
678
  * Define required message based on mg-inputs required elements
368
679
  * Also
@@ -370,17 +681,24 @@ const MgForm = class {
370
681
  * @returns {void}
371
682
  */
372
683
  this.setRequiredMessage = () => {
373
- // Get required fields
374
- const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !this.disabled);
375
- // All fields are required
376
- // mg-input-toggle can not be required
377
- if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
378
- this.requiredMessage = this.messages.form.allRequired;
379
- this.classList.add('mg-form--all-required');
380
- }
381
- // Some fields are required
382
- else if (requiredInputs.length > 0) {
383
- this.requiredMessage = this.messages.form.required;
684
+ // init required message
685
+ this.requiredMessage = null;
686
+ this.classList.delete(this.classAllRequired);
687
+ // If the form is disabled or readonly none of them are required
688
+ // Check if all fields are not editable (readonly or disabled)
689
+ if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
690
+ // Get required fields
691
+ const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !input.readonly);
692
+ // All fields are required
693
+ // mg-input-toggle can not be required
694
+ if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
695
+ this.requiredMessage = this.messages.form.allRequired;
696
+ this.classList.add(this.classAllRequired);
697
+ }
698
+ // Some fields are required
699
+ else if (requiredInputs.length > 0) {
700
+ this.requiredMessage = this.messages.form.required;
701
+ }
384
702
  }
385
703
  };
386
704
  /**
@@ -389,15 +707,46 @@ const MgForm = class {
389
707
  * @returns {void}
390
708
  */
391
709
  this.checkValidity = () => {
392
- const validity = !this.mgInputs.some(input => input.invalid);
393
- this.valid = validity;
394
- this.invalid = !validity;
395
- this.formValid.emit(validity);
710
+ // Update required on input event
711
+ this.setRequiredMessage();
712
+ this.valid = !this.mgInputs.some(input => input.invalid);
713
+ this.invalid = !this.valid;
714
+ // We need to send valid event if it is the same value
715
+ this.formValid.emit(this.valid);
396
716
  };
717
+ /**
718
+ * Handle Form Submit
719
+ *
720
+ * @param {SubmitEvent} event submit event
721
+ * @returns {void}
722
+ */
397
723
  this.handleFormSubmit = (event) => {
398
724
  event.preventDefault();
399
725
  this.formSubmit.emit();
400
726
  };
727
+ /**
728
+ * Set mgInputs
729
+ *
730
+ * @returns {void}
731
+ */
732
+ this.setMgInputs = () => {
733
+ // Get slotted mgInputs
734
+ this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
735
+ // Set inputs readonly or disabled based on form configuration
736
+ // Othewise listen to events
737
+ this.mgInputs.map(input => {
738
+ if (this.readonly)
739
+ input.readonly = true;
740
+ else if (this.disabled)
741
+ input.disabled = true;
742
+ else
743
+ input.addEventListener('input-valid', this.checkValidity);
744
+ });
745
+ };
746
+ }
747
+ handleAttributeChange() {
748
+ this.setMgInputs();
749
+ this.setRequiredMessage();
401
750
  }
402
751
  /**
403
752
  * Public method to display errors
@@ -422,27 +771,19 @@ const MgForm = class {
422
771
  */
423
772
  componentWillLoad() {
424
773
  // Get locales
425
- this.messages = index$1.initLocales(this.element).messages;
426
- // Get slotted mgInputs
427
- this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
774
+ this.messages = initLocales(this.element).messages;
428
775
  // Get slotted mgButtons
429
- this.mgButtons = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-BUTTON'));
776
+ this.mgButtons = Array.from(this.element.querySelectorAll('mg-button'));
430
777
  // Set button form identifier
431
778
  this.mgButtons.forEach(mgButton => {
432
779
  mgButton.setAttribute('form', this.identifier);
433
780
  });
781
+ // Set mgInputs
782
+ this.setMgInputs();
434
783
  // Define required message
435
784
  this.setRequiredMessage();
436
785
  // Check validity when slotted mgInputs are ready
437
786
  Promise.all(this.mgInputs.map(async (input) => {
438
- // Set inputs readonly or disabled based on form configuration
439
- // Othewise listen to events
440
- if (this.readonly)
441
- input.readonly = true;
442
- else if (this.disabled)
443
- input.disabled = true;
444
- else
445
- input.addEventListener('input-valid', this.checkValidity);
446
787
  try {
447
788
  await input.componentOnReady();
448
789
  }
@@ -465,6 +806,10 @@ const MgForm = class {
465
806
  });
466
807
  }
467
808
  });
809
+ // Update mgInputs when mgForm content change
810
+ new MutationObserver(() => {
811
+ this.setMgInputs();
812
+ }).observe(this.element, { childList: true });
468
813
  }
469
814
  /**
470
815
  * Render
@@ -475,6 +820,10 @@ const MgForm = class {
475
820
  return (index.h("form", { class: this.classList.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit }, this.requiredMessage && index.h("p", { innerHTML: this.requiredMessage }), index.h("slot", null), !this.readonly && !this.disabled && index.h("slot", { name: "actions" })));
476
821
  }
477
822
  get element() { return index.getElement(this); }
823
+ static get watchers() { return {
824
+ "readonly": ["handleAttributeChange"],
825
+ "disabled": ["handleAttributeChange"]
826
+ }; }
478
827
  };
479
828
  MgForm.style = mgFormCss;
480
829
 
@@ -659,7 +1008,7 @@ const MgIcon = class {
659
1008
  /**
660
1009
  * Component classes
661
1010
  */
662
- this.classList = new index$1.ClassList(['mg-icon']);
1011
+ this.classList = new ClassList(['mg-icon']);
663
1012
  /**
664
1013
  * getIcon
665
1014
  *
@@ -761,10 +1110,10 @@ const MgIllustratedMessage = class {
761
1110
  componentDidLoad() {
762
1111
  const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
763
1112
  const imageTags = ['img', 'svg'];
764
- if (!index$1.isTagName(this.element.querySelector('[slot="title"]'), headingTags)) {
1113
+ if (!isTagName(this.element.querySelector('[slot="title"]'), headingTags)) {
765
1114
  throw new Error(`<mg-illustrated-message> Slotted title must be a heading: ${headingTags.join(', ')}`);
766
1115
  }
767
- else if (!index$1.isTagName(this.element.querySelector('[slot="illustration"]'), imageTags)) {
1116
+ else if (!isTagName(this.element.querySelector('[slot="illustration"]'), imageTags)) {
768
1117
  throw new Error(`<mg-illustrated-message> Slotted illustration must be an image: ${imageTags.join(', ')}`);
769
1118
  }
770
1119
  }
@@ -863,15 +1212,6 @@ const MgInput = (props, children, utils) => {
863
1212
  if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {
864
1213
  ariaDescribedbyIDs.add(helpTextErrorId);
865
1214
  }
866
- /**
867
- * Update input(s) in children
868
- */
869
- if (props.readonly) {
870
- children = children.filter(child => child.$name$ === 'append-input');
871
- }
872
- else {
873
- children = applyAriadescribedBy(children, ariaDescribedbyIDs, utils);
874
- }
875
1215
  /**
876
1216
  * Return template
877
1217
  *
@@ -897,19 +1237,20 @@ const MgInput = (props, children, utils) => {
897
1237
  index.h("mg-icon", { icon: "info-circle" })));
898
1238
  /**
899
1239
  * Get input title (label) node
1240
+ * Display asterisk only if not disabled and not readonly
900
1241
  *
901
1242
  * @returns {VNode[]} mg-input-title
902
1243
  */
903
- const getInputTitle = () => (index.h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled, "is-legend": props.isFieldset }, props.label));
1244
+ const getInputTitle = () => (index.h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
904
1245
  return (index.h(TagName, { class: props.classList.join() },
905
1246
  props.labelOnTop ? (index.h("div", { class: "mg-input__title" },
906
1247
  getInputTitle(),
907
1248
  !props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
908
1249
  props.readonly ? (index.h("div", { class: "mg-input__input-container" },
909
1250
  index.h("strong", null, props.readonlyValue || props.value),
910
- children)) : (index.h("div", { class: "mg-input__input-container" },
1251
+ children.filter(child => child.$name$ === 'append-input'))) : (index.h("div", { class: "mg-input__input-container" },
911
1252
  index.h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } },
912
- children,
1253
+ applyAriadescribedBy(children, ariaDescribedbyIDs, utils),
913
1254
  !props.labelOnTop && props.tooltip && getTooltip()),
914
1255
  props.helpText && index.h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }),
915
1256
  props.errorMessage && !props.readonly && !props.disabled && (index.h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
@@ -934,6 +1275,8 @@ const MgInputCheckbox = class {
934
1275
  ************/
935
1276
  // HTML selector
936
1277
  this.inputs = [];
1278
+ // hasDisplayedError (triggered by blur event)
1279
+ this.hasDisplayedError = false;
937
1280
  /**
938
1281
  * Input name
939
1282
  * If not set the value equals the identifier
@@ -962,7 +1305,7 @@ const MgInputCheckbox = class {
962
1305
  /**
963
1306
  * Component classes
964
1307
  */
965
- this.classList = new index$1.ClassList(['mg-input--checkbox']);
1308
+ this.classList = new ClassList(['mg-input--checkbox']);
966
1309
  /**
967
1310
  * Formated value for display
968
1311
  */
@@ -988,25 +1331,27 @@ const MgInputCheckbox = class {
988
1331
  this.handleBlur = () => {
989
1332
  // Check validity
990
1333
  this.checkValidity();
991
- this.checkError();
1334
+ this.setErrorMessage();
992
1335
  };
1336
+ /**
1337
+ * get invalid element
1338
+ *
1339
+ * @returns {HTMLInputElement} element
1340
+ */
1341
+ this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
993
1342
  /**
994
1343
  * Check if input is valid
995
1344
  */
996
1345
  this.checkValidity = () => {
997
- if (!this.readonly) {
998
- const validity = this.getInvalidElement() === undefined;
999
- // Set validity
1000
- this.valid = validity;
1001
- this.invalid = !validity;
1002
- //Send event
1003
- this.inputValid.emit(validity);
1004
- }
1346
+ this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
1347
+ this.invalid = !this.valid;
1348
+ // We need to send valid event even if it is the same value
1349
+ this.inputValid.emit(this.valid);
1005
1350
  };
1006
1351
  /**
1007
- * Check input errors
1352
+ * Set input error message
1008
1353
  */
1009
- this.checkError = () => {
1354
+ this.setErrorMessage = () => {
1010
1355
  const invalidElement = this.getInvalidElement();
1011
1356
  // Set error message
1012
1357
  this.errorMessage = undefined;
@@ -1014,12 +1359,6 @@ const MgInputCheckbox = class {
1014
1359
  this.errorMessage = this.messages.errors.required;
1015
1360
  }
1016
1361
  };
1017
- /**
1018
- * get invalid element
1019
- *
1020
- * @returns {HTMLInputElement} element
1021
- */
1022
- this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
1023
1362
  }
1024
1363
  validateValue(newValue) {
1025
1364
  if (newValue && newValue.every(item => isCheckboxItem(item))) {
@@ -1035,6 +1374,16 @@ const MgInputCheckbox = class {
1035
1374
  throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
1036
1375
  }
1037
1376
  }
1377
+ handleValidityChange(newValue, _oldValue, prop) {
1378
+ this.inputs.forEach(input => {
1379
+ input[prop] = newValue;
1380
+ });
1381
+ this.checkValidity();
1382
+ if (this.hasDisplayedError) {
1383
+ this.setErrorMessage();
1384
+ this.hasDisplayedError = false;
1385
+ }
1386
+ }
1038
1387
  /**
1039
1388
  * Public method to display errors
1040
1389
  *
@@ -1042,7 +1391,8 @@ const MgInputCheckbox = class {
1042
1391
  */
1043
1392
  async displayError() {
1044
1393
  this.checkValidity();
1045
- this.checkError();
1394
+ this.setErrorMessage();
1395
+ this.hasDisplayedError = this.invalid;
1046
1396
  }
1047
1397
  /*************
1048
1398
  * Lifecycle *
@@ -1054,7 +1404,7 @@ const MgInputCheckbox = class {
1054
1404
  */
1055
1405
  componentWillLoad() {
1056
1406
  // Get locales
1057
- this.messages = index$1.initLocales(this.element).messages;
1407
+ this.messages = initLocales(this.element).messages;
1058
1408
  // Validate
1059
1409
  this.validateValue(this.value);
1060
1410
  // Check validity when component is ready
@@ -1070,15 +1420,21 @@ const MgInputCheckbox = class {
1070
1420
  * @returns {HTMLElement} HTML Element
1071
1421
  */
1072
1422
  render() {
1073
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
1423
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
1074
1424
  .filter(item => {
1075
1425
  return !this.readonly || item.value;
1076
1426
  })
1077
- .map(input => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => this.inputs.push(el) }), index.h("label", { htmlFor: input.id }, input.title)))))));
1427
+ .map((input, index$1) => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
1428
+ if (el !== null)
1429
+ this.inputs[index$1] = el;
1430
+ } }), index.h("label", { htmlFor: input.id }, input.title)))))));
1078
1431
  }
1079
1432
  get element() { return index.getElement(this); }
1080
1433
  static get watchers() { return {
1081
- "value": ["validateValue"]
1434
+ "value": ["validateValue"],
1435
+ "required": ["handleValidityChange"],
1436
+ "readonly": ["handleValidityChange"],
1437
+ "disabled": ["handleValidityChange"]
1082
1438
  }; }
1083
1439
  };
1084
1440
  MgInputCheckbox.style = mgInputCheckboxCss;
@@ -1137,8 +1493,8 @@ const MgInputDate = class {
1137
1493
  index.registerInstance(this, hostRef);
1138
1494
  this.valueChange = index.createEvent(this, "value-change", 7);
1139
1495
  this.inputValid = index.createEvent(this, "input-valid", 7);
1140
- // hasError (triggered by blur event)
1141
- this.hasError = false;
1496
+ // hasDisplayedError (triggered by blur event)
1497
+ this.hasDisplayedError = false;
1142
1498
  /**
1143
1499
  * Input name
1144
1500
  * If not set the value equals the identifier
@@ -1163,14 +1519,14 @@ const MgInputDate = class {
1163
1519
  /**
1164
1520
  * Component classes
1165
1521
  */
1166
- this.classList = new index$1.ClassList(['mg-input--date']);
1522
+ this.classList = new ClassList(['mg-input--date']);
1167
1523
  /**
1168
1524
  * Handle input event
1169
1525
  */
1170
1526
  this.handleInput = () => {
1171
1527
  this.checkValidity();
1172
- if (this.hasError) {
1173
- this.checkError();
1528
+ if (this.hasDisplayedError) {
1529
+ this.setErrorMessage();
1174
1530
  }
1175
1531
  this.value = this.input.value;
1176
1532
  };
@@ -1184,14 +1540,11 @@ const MgInputDate = class {
1184
1540
  * Check if input is valid
1185
1541
  */
1186
1542
  this.checkValidity = () => {
1187
- if (!this.readonly && this.input !== undefined) {
1188
- const validity = this.input.checkValidity();
1189
- // Set validity
1190
- this.valid = validity;
1191
- this.invalid = !validity;
1192
- //Send event
1193
- this.inputValid.emit(validity);
1194
- }
1543
+ var _a;
1544
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
1545
+ this.invalid = !this.valid;
1546
+ // We need to send valid event even if it is the same value
1547
+ this.inputValid.emit(this.valid);
1195
1548
  };
1196
1549
  /**
1197
1550
  * get input error code
@@ -1220,48 +1573,50 @@ const MgInputDate = class {
1220
1573
  return inputError;
1221
1574
  };
1222
1575
  /**
1223
- * Set error message
1576
+ * Check input errors
1224
1577
  *
1225
1578
  * @returns {void}
1226
1579
  */
1227
1580
  this.setErrorMessage = () => {
1228
1581
  var _a;
1229
- const inputError = this.getInputError();
1230
- // required
1231
- if (inputError === InputError$1.REQUIRED) {
1232
- this.errorMessage = this.messages.errors[inputError];
1233
- }
1234
- // min, max & minMax
1235
- else if ([InputError$1.MIN, InputError$1.MAX, InputError$1.MINMAX].includes(inputError)) {
1236
- this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));
1237
- }
1238
- // wrong date format
1239
- // element.validity.badInput is default error message
1240
- else {
1241
- this.errorMessage = this.messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min, this.locale) : localeDate('1900-01-01', this.locale));
1242
- }
1243
- };
1244
- /**
1245
- * Check input errors
1246
- *
1247
- * @returns {void}
1248
- */
1249
- this.checkError = () => {
1250
1582
  // Set error message
1251
1583
  this.errorMessage = undefined;
1252
1584
  if (!this.valid) {
1253
- this.setErrorMessage();
1585
+ const inputError = this.getInputError();
1586
+ // required
1587
+ if (inputError === InputError$1.REQUIRED) {
1588
+ this.errorMessage = this.messages.errors[inputError];
1589
+ }
1590
+ // min, max & minMax
1591
+ else if ([InputError$1.MIN, InputError$1.MAX, InputError$1.MINMAX].includes(inputError)) {
1592
+ this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));
1593
+ }
1594
+ // wrong date format
1595
+ // element.validity.badInput is default error message
1596
+ else {
1597
+ this.errorMessage = this.messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min, this.locale) : localeDate('1900-01-01', this.locale));
1598
+ }
1254
1599
  }
1255
1600
  };
1256
1601
  }
1257
1602
  validateValue(newValue) {
1258
- if (newValue !== undefined && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
1603
+ if (newValue !== undefined && newValue !== null && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
1259
1604
  throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
1260
1605
  }
1261
1606
  else {
1262
1607
  this.valueChange.emit(this.value);
1263
1608
  }
1264
1609
  }
1610
+ handleValidityChange(newValue, _oldValue, prop) {
1611
+ if (this.input !== undefined) {
1612
+ this.input[prop] = newValue;
1613
+ this.checkValidity();
1614
+ if (this.hasDisplayedError) {
1615
+ this.setErrorMessage();
1616
+ this.hasDisplayedError = false;
1617
+ }
1618
+ }
1619
+ }
1265
1620
  validateMinMax(newValue) {
1266
1621
  if ((newValue === null || newValue === void 0 ? void 0 : newValue.length) === 0 || ((newValue === null || newValue === void 0 ? void 0 : newValue.length) > 0 && !(typeof newValue === 'string' && dateRegExp.test(newValue)))) {
1267
1622
  throw new Error("<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd");
@@ -1274,8 +1629,8 @@ const MgInputDate = class {
1274
1629
  */
1275
1630
  async displayError() {
1276
1631
  this.checkValidity();
1277
- this.checkError();
1278
- this.hasError = this.invalid;
1632
+ this.setErrorMessage();
1633
+ this.hasDisplayedError = this.invalid;
1279
1634
  }
1280
1635
  /*************
1281
1636
  * Lifecycle *
@@ -1287,7 +1642,7 @@ const MgInputDate = class {
1287
1642
  */
1288
1643
  componentWillLoad() {
1289
1644
  // Get locales
1290
- const locales = index$1.initLocales(this.element);
1645
+ const locales = initLocales(this.element);
1291
1646
  this.locale = locales.locale;
1292
1647
  this.messages = locales.messages;
1293
1648
  // Validate
@@ -1307,11 +1662,17 @@ const MgInputDate = class {
1307
1662
  * @returns {HTMLElement} HTML Element
1308
1663
  */
1309
1664
  render() {
1310
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el => (this.input = el) })));
1665
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el => {
1666
+ if (el !== null)
1667
+ this.input = el;
1668
+ } })));
1311
1669
  }
1312
1670
  get element() { return index.getElement(this); }
1313
1671
  static get watchers() { return {
1314
1672
  "value": ["validateValue"],
1673
+ "required": ["handleValidityChange"],
1674
+ "readonly": ["handleValidityChange"],
1675
+ "disabled": ["handleValidityChange"],
1315
1676
  "min": ["validateMinMax"],
1316
1677
  "max": ["validateMinMax"]
1317
1678
  }; }
@@ -1330,15 +1691,15 @@ var InputError;
1330
1691
  InputError["REQUIRED"] = "required";
1331
1692
  })(InputError || (InputError = {}));
1332
1693
 
1333
- const mgInputNumericCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input .mg-input__box{text-align:var(--mg-inputs-text-align, right)}";
1694
+ const mgInputNumericCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input .mg-input__box{text-align:var(--mg-inputs-text-align, right)}";
1334
1695
 
1335
1696
  const MgInputNumeric = class {
1336
1697
  constructor(hostRef) {
1337
1698
  index.registerInstance(this, hostRef);
1338
1699
  this.valueChange = index.createEvent(this, "value-change", 7);
1339
1700
  this.inputValid = index.createEvent(this, "input-valid", 7);
1340
- // hasError (triggered by blur event)
1341
- this.hasError = false;
1701
+ // hasDisplayedError (triggered by blur event)
1702
+ this.hasDisplayedError = false;
1342
1703
  /**
1343
1704
  * Input name
1344
1705
  * If not set the value equals the identifier
@@ -1381,7 +1742,7 @@ const MgInputNumeric = class {
1381
1742
  /**
1382
1743
  * Component classes
1383
1744
  */
1384
- this.classList = new index$1.ClassList(['mg-input--numeric']);
1745
+ this.classList = new ClassList(['mg-input--numeric']);
1385
1746
  /**
1386
1747
  * Define if input has focus
1387
1748
  */
@@ -1394,8 +1755,8 @@ const MgInputNumeric = class {
1394
1755
  this.handleInput = () => {
1395
1756
  // Check validity
1396
1757
  this.checkValidity();
1397
- if (this.hasError) {
1398
- this.checkError();
1758
+ if (this.hasDisplayedError) {
1759
+ this.setErrorMessage();
1399
1760
  }
1400
1761
  this.value = this.input.value;
1401
1762
  };
@@ -1423,40 +1784,27 @@ const MgInputNumeric = class {
1423
1784
  * @returns {void}
1424
1785
  */
1425
1786
  this.checkValidity = () => {
1426
- if (!this.readonly) {
1427
- const validity = this.getInputError() === null;
1428
- // Set validity
1429
- this.valid = validity;
1430
- this.invalid = !validity;
1431
- //Send event
1432
- this.inputValid.emit(validity);
1433
- }
1787
+ this.valid = this.readonly || this.disabled || this.getInputError() === null;
1788
+ this.invalid = !this.valid;
1789
+ // We need to send valid event even if it is the same value
1790
+ this.inputValid.emit(this.valid);
1434
1791
  };
1435
1792
  /**
1436
- * Set error message
1793
+ * Set input error message
1437
1794
  *
1438
1795
  * @returns {void}
1439
1796
  */
1440
1797
  this.setErrorMessage = () => {
1441
- const inputError = this.getInputError();
1442
- if (inputError === InputError.REQUIRED) {
1443
- this.errorMessage = this.messages.errors[inputError];
1444
- }
1445
- else {
1446
- this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
1447
- }
1448
- };
1449
- /**
1450
- * Check input errors
1451
- *
1452
- * @returns {void}
1453
- */
1454
- this.checkError = () => {
1455
1798
  // Set error message
1456
1799
  this.errorMessage = undefined;
1457
- // Update class
1458
1800
  if (!this.valid) {
1459
- this.setErrorMessage();
1801
+ const inputError = this.getInputError();
1802
+ if (inputError === InputError.REQUIRED) {
1803
+ this.errorMessage = this.messages.errors[inputError];
1804
+ }
1805
+ else {
1806
+ this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
1807
+ }
1460
1808
  }
1461
1809
  };
1462
1810
  /**
@@ -1466,7 +1814,7 @@ const MgInputNumeric = class {
1466
1814
  */
1467
1815
  this.getInputError = () => {
1468
1816
  let inputError = null;
1469
- if (this.input === undefined)
1817
+ if (this.input === undefined || this.input === null)
1470
1818
  return inputError;
1471
1819
  // required
1472
1820
  if (!this.input.checkValidity() && this.input.validity.valueMissing) {
@@ -1533,6 +1881,16 @@ const MgInputNumeric = class {
1533
1881
  this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
1534
1882
  }
1535
1883
  }
1884
+ handleValidityChange(newValue, _oldValue, prop) {
1885
+ if (this.input !== undefined) {
1886
+ this.input[prop] = newValue;
1887
+ this.checkValidity();
1888
+ if (this.hasDisplayedError) {
1889
+ this.setErrorMessage();
1890
+ this.hasDisplayedError = false;
1891
+ }
1892
+ }
1893
+ }
1536
1894
  validateType(newValue) {
1537
1895
  if (!types.includes(newValue)) {
1538
1896
  throw new Error(`<mg-input-numeric> prop "type" must be one of : ${types.join(', ')}`);
@@ -1555,8 +1913,8 @@ const MgInputNumeric = class {
1555
1913
  */
1556
1914
  async displayError() {
1557
1915
  this.checkValidity();
1558
- this.checkError();
1559
- this.hasError = this.invalid;
1916
+ this.setErrorMessage();
1917
+ this.hasDisplayedError = this.invalid;
1560
1918
  }
1561
1919
  /**
1562
1920
  * Displayed value in input
@@ -1577,7 +1935,7 @@ const MgInputNumeric = class {
1577
1935
  */
1578
1936
  componentWillLoad() {
1579
1937
  // Get locales
1580
- const locales = index$1.initLocales(this.element);
1938
+ const locales = initLocales(this.element);
1581
1939
  this.locale = locales.locale;
1582
1940
  this.messages = locales.messages;
1583
1941
  // Validate
@@ -1599,11 +1957,17 @@ const MgInputNumeric = class {
1599
1957
  * @returns {HTMLElement} HTML Element
1600
1958
  */
1601
1959
  render() {
1602
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), index.h("slot", { name: "append-input" })));
1960
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
1961
+ if (el !== null)
1962
+ this.input = el;
1963
+ } }), index.h("slot", { name: "append-input" })));
1603
1964
  }
1604
1965
  get element() { return index.getElement(this); }
1605
1966
  static get watchers() { return {
1606
1967
  "value": ["validateValue"],
1968
+ "required": ["handleValidityChange"],
1969
+ "readonly": ["handleValidityChange"],
1970
+ "disabled": ["handleValidityChange"],
1607
1971
  "type": ["validateType"],
1608
1972
  "integerLength": ["validateIntegerLength"],
1609
1973
  "decimalLength": ["validateDecimalLength"]
@@ -1611,15 +1975,15 @@ const MgInputNumeric = class {
1611
1975
  };
1612
1976
  MgInputNumeric.style = mgInputNumericCss;
1613
1977
 
1614
- const mgInputPasswordCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}";
1978
+ const mgInputPasswordCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}";
1615
1979
 
1616
1980
  const MgInputPassword = class {
1617
1981
  constructor(hostRef) {
1618
1982
  index.registerInstance(this, hostRef);
1619
1983
  this.valueChange = index.createEvent(this, "value-change", 7);
1620
1984
  this.inputValid = index.createEvent(this, "input-valid", 7);
1621
- // hasError (triggered by blur event)
1622
- this.hasError = false;
1985
+ // hasDisplayedError (triggered by blur event)
1986
+ this.hasDisplayedError = false;
1623
1987
  /**
1624
1988
  * Input name
1625
1989
  * If not set the value equals the identifier
@@ -1648,14 +2012,14 @@ const MgInputPassword = class {
1648
2012
  /**
1649
2013
  * Component classes
1650
2014
  */
1651
- this.classList = new index$1.ClassList(['mg-input--password']);
2015
+ this.classList = new ClassList(['mg-input--password']);
1652
2016
  /**
1653
2017
  * Handle input event
1654
2018
  */
1655
2019
  this.handleInput = () => {
1656
2020
  this.checkValidity();
1657
- if (this.hasError) {
1658
- this.checkError();
2021
+ if (this.hasDisplayedError) {
2022
+ this.setErrorMessage();
1659
2023
  }
1660
2024
  this.value = this.input.value;
1661
2025
  };
@@ -1669,19 +2033,16 @@ const MgInputPassword = class {
1669
2033
  * Check if input is valid
1670
2034
  */
1671
2035
  this.checkValidity = () => {
1672
- if (!this.readonly && this.input !== undefined) {
1673
- const validity = this.input.checkValidity();
1674
- // Set validity
1675
- this.valid = validity;
1676
- this.invalid = !validity;
1677
- //Send event
1678
- this.inputValid.emit(validity);
1679
- }
2036
+ var _a;
2037
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
2038
+ this.invalid = !this.valid;
2039
+ // We need to send valid event even if it is the same value
2040
+ this.inputValid.emit(this.valid);
1680
2041
  };
1681
2042
  /**
1682
- * Check input errors
2043
+ * Set input error message
1683
2044
  */
1684
- this.checkError = () => {
2045
+ this.setErrorMessage = () => {
1685
2046
  // Set error message
1686
2047
  this.errorMessage = undefined;
1687
2048
  // required
@@ -1693,6 +2054,16 @@ const MgInputPassword = class {
1693
2054
  handleValue(newValue) {
1694
2055
  this.valueChange.emit(newValue);
1695
2056
  }
2057
+ handleValidityChange(newValue, _oldValue, prop) {
2058
+ if (this.input !== undefined) {
2059
+ this.input[prop] = newValue;
2060
+ this.checkValidity();
2061
+ if (this.hasDisplayedError) {
2062
+ this.setErrorMessage();
2063
+ this.hasDisplayedError = false;
2064
+ }
2065
+ }
2066
+ }
1696
2067
  /**
1697
2068
  * Public method to display errors
1698
2069
  *
@@ -1700,8 +2071,8 @@ const MgInputPassword = class {
1700
2071
  */
1701
2072
  async displayError() {
1702
2073
  this.checkValidity();
1703
- this.checkError();
1704
- this.hasError = this.invalid;
2074
+ this.setErrorMessage();
2075
+ this.hasDisplayedError = this.invalid;
1705
2076
  }
1706
2077
  /*************
1707
2078
  * Lifecycle *
@@ -1713,7 +2084,7 @@ const MgInputPassword = class {
1713
2084
  */
1714
2085
  componentWillLoad() {
1715
2086
  // Get locales
1716
- this.messages = index$1.initLocales(this.element).messages;
2087
+ this.messages = initLocales(this.element).messages;
1717
2088
  // Check validity when component is ready
1718
2089
  // return a promise to process action only in the FIRST render().
1719
2090
  // https://stenciljs.com/docs/component-lifecycle#componentwillload
@@ -1727,11 +2098,17 @@ const MgInputPassword = class {
1727
2098
  * @returns {HTMLElement} HTML Element
1728
2099
  */
1729
2100
  render() {
1730
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) })));
2101
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
2102
+ if (el !== null)
2103
+ this.input = el;
2104
+ } })));
1731
2105
  }
1732
2106
  get element() { return index.getElement(this); }
1733
2107
  static get watchers() { return {
1734
- "value": ["handleValue"]
2108
+ "value": ["handleValue"],
2109
+ "required": ["handleValidityChange"],
2110
+ "readonly": ["handleValidityChange"],
2111
+ "disabled": ["handleValidityChange"]
1735
2112
  }; }
1736
2113
  };
1737
2114
  MgInputPassword.style = mgInputPasswordCss;
@@ -1755,6 +2132,8 @@ const MgInputRadio = class {
1755
2132
  ************/
1756
2133
  // HTML selector
1757
2134
  this.inputs = [];
2135
+ // hasDisplayedError (triggered by blur event)
2136
+ this.hasDisplayedError = false;
1758
2137
  /**
1759
2138
  * Input name
1760
2139
  * If not set the value equals the identifier
@@ -1787,7 +2166,7 @@ const MgInputRadio = class {
1787
2166
  /**
1788
2167
  * Component classes
1789
2168
  */
1790
- this.classList = new index$1.ClassList(['mg-input--radio']);
2169
+ this.classList = new ClassList(['mg-input--radio']);
1791
2170
  /**
1792
2171
  * Handle input event
1793
2172
  *
@@ -1805,7 +2184,7 @@ const MgInputRadio = class {
1805
2184
  */
1806
2185
  this.handleBlur = () => {
1807
2186
  this.checkValidity();
1808
- this.checkError();
2187
+ this.setErrorMessage();
1809
2188
  };
1810
2189
  /**
1811
2190
  * Check if input is valid
@@ -1813,21 +2192,17 @@ const MgInputRadio = class {
1813
2192
  * @returns {void}
1814
2193
  */
1815
2194
  this.checkValidity = () => {
1816
- if (!this.readonly) {
1817
- const validity = this.getInvalidElement() === undefined;
1818
- // Set validity
1819
- this.valid = validity;
1820
- this.invalid = !validity;
1821
- //Send event
1822
- this.inputValid.emit(validity);
1823
- }
2195
+ this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
2196
+ this.invalid = !this.valid;
2197
+ // We need to send valid event even if it is the same value
2198
+ this.inputValid.emit(this.valid);
1824
2199
  };
1825
2200
  /**
1826
- * Check input errors
2201
+ * Set input error message
1827
2202
  *
1828
2203
  * @returns {void}
1829
2204
  */
1830
- this.checkError = () => {
2205
+ this.setErrorMessage = () => {
1831
2206
  const invalidElement = this.getInvalidElement();
1832
2207
  // Set error message
1833
2208
  this.errorMessage = undefined;
@@ -1840,7 +2215,7 @@ const MgInputRadio = class {
1840
2215
  *
1841
2216
  * @returns {HTMLInputElement} element
1842
2217
  */
1843
- this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
2218
+ this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
1844
2219
  }
1845
2220
  handleValue(newValue) {
1846
2221
  this.valueChange.emit(newValue);
@@ -1851,7 +2226,7 @@ const MgInputRadio = class {
1851
2226
  throw new Error('<mg-input-radio> prop "items" require at least 2 items.');
1852
2227
  }
1853
2228
  // String array
1854
- else if (index$1.allItemsAreString(newValue)) {
2229
+ else if (allItemsAreString(newValue)) {
1855
2230
  this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
1856
2231
  }
1857
2232
  // Object array
@@ -1862,6 +2237,16 @@ const MgInputRadio = class {
1862
2237
  throw new Error('<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption.');
1863
2238
  }
1864
2239
  }
2240
+ handleValidityChange(newValue, _oldValue, prop) {
2241
+ this.inputs.forEach(input => {
2242
+ input[prop] = newValue;
2243
+ });
2244
+ this.checkValidity();
2245
+ if (this.hasDisplayedError) {
2246
+ this.setErrorMessage();
2247
+ this.hasDisplayedError = false;
2248
+ }
2249
+ }
1865
2250
  /**
1866
2251
  * Public method to display errors
1867
2252
  *
@@ -1869,7 +2254,8 @@ const MgInputRadio = class {
1869
2254
  */
1870
2255
  async displayError() {
1871
2256
  this.checkValidity();
1872
- this.checkError();
2257
+ this.setErrorMessage();
2258
+ this.hasDisplayedError = this.invalid;
1873
2259
  }
1874
2260
  /*************
1875
2261
  * Lifecycle *
@@ -1881,7 +2267,7 @@ const MgInputRadio = class {
1881
2267
  */
1882
2268
  componentWillLoad() {
1883
2269
  // Get locales
1884
- this.messages = index$1.initLocales(this.element).messages;
2270
+ this.messages = initLocales(this.element).messages;
1885
2271
  // Validate
1886
2272
  this.validateItems(this.items);
1887
2273
  // Check validity when component is ready
@@ -1897,17 +2283,23 @@ const MgInputRadio = class {
1897
2283
  * @returns {HTMLElement} HTML Element
1898
2284
  */
1899
2285
  render() {
1900
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.options.map((input, index$1) => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "radio", id: this.identifier + '_' + index$1, name: this.identifier, value: index$1, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index$1].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => this.inputs.push(el) }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title)))))));
2286
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.options.map((input, index$1) => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "radio", id: this.identifier + '_' + index$1, name: this.identifier, value: index$1, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index$1].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => {
2287
+ if (el !== null)
2288
+ this.inputs[index$1] = el;
2289
+ } }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title)))))));
1901
2290
  }
1902
2291
  get element() { return index.getElement(this); }
1903
2292
  static get watchers() { return {
1904
2293
  "value": ["handleValue"],
1905
- "items": ["validateItems"]
2294
+ "items": ["validateItems"],
2295
+ "required": ["handleValidityChange"],
2296
+ "readonly": ["handleValidityChange"],
2297
+ "disabled": ["handleValidityChange"]
1906
2298
  }; }
1907
2299
  };
1908
2300
  MgInputRadio.style = mgInputRadioCss;
1909
2301
 
1910
- const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input__box{width:100%;padding-top:0;padding-bottom:0;padding-right:1rem}";
2302
+ const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input__box{width:100%;padding-top:0;padding-bottom:0;padding-right:1rem}.mg-input.mg-input--select:not(.mg-input--label-on-top) .mg-input__box{max-width:unset}";
1911
2303
 
1912
2304
  /**
1913
2305
  * Check if item is a well configured option
@@ -1950,8 +2342,8 @@ const MgInputSelect = class {
1950
2342
  index.registerInstance(this, hostRef);
1951
2343
  this.valueChange = index.createEvent(this, "value-change", 7);
1952
2344
  this.inputValid = index.createEvent(this, "input-valid", 7);
1953
- // hasError (triggered by blur event)
1954
- this.hasError = false;
2345
+ // hasDisplayedError (triggered by blur event)
2346
+ this.hasDisplayedError = false;
1955
2347
  /**
1956
2348
  * Input name
1957
2349
  * If not set the value equals the identifier
@@ -1984,17 +2376,17 @@ const MgInputSelect = class {
1984
2376
  /**
1985
2377
  * Component classes
1986
2378
  */
1987
- this.classList = new index$1.ClassList(['mg-input--select']);
2379
+ this.classList = new ClassList(['mg-input--select']);
1988
2380
  /**
1989
2381
  * Handle input event
1990
2382
  */
1991
2383
  this.handleInput = () => {
1992
2384
  this.checkValidity();
1993
- if (this.hasError) {
1994
- this.checkError();
2385
+ if (this.hasDisplayedError) {
2386
+ this.setErrorMessage();
1995
2387
  }
1996
2388
  if (this.input.value !== '') {
1997
- this.value = index$1.allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.title === this.input.value).value;
2389
+ this.value = allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.title === this.input.value).value;
1998
2390
  }
1999
2391
  else {
2000
2392
  this.value = null;
@@ -2010,19 +2402,16 @@ const MgInputSelect = class {
2010
2402
  * Check if input is valid
2011
2403
  */
2012
2404
  this.checkValidity = () => {
2013
- if (!this.readonly && this.input !== undefined) {
2014
- const validity = this.input.checkValidity && this.input.checkValidity();
2015
- // Set validity
2016
- this.valid = validity;
2017
- this.invalid = !validity;
2018
- //Send event
2019
- this.inputValid.emit(validity);
2020
- }
2405
+ var _a;
2406
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
2407
+ this.invalid = !this.valid;
2408
+ // We need to send valid event even if it is the same value
2409
+ this.inputValid.emit(this.valid);
2021
2410
  };
2022
2411
  /**
2023
- * Check input errors
2412
+ * Set input error message
2024
2413
  */
2025
- this.checkError = () => {
2414
+ this.setErrorMessage = () => {
2026
2415
  // Set error message
2027
2416
  this.errorMessage = undefined;
2028
2417
  if (!this.valid && this.input.validity.valueMissing) {
@@ -2032,7 +2421,7 @@ const MgInputSelect = class {
2032
2421
  }
2033
2422
  handleValue(newValue) {
2034
2423
  if (newValue !== null) {
2035
- this.readonlyValue = index$1.allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.value === newValue).title;
2424
+ this.readonlyValue = allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.value === newValue).title;
2036
2425
  }
2037
2426
  else {
2038
2427
  this.readonlyValue = null;
@@ -2041,7 +2430,7 @@ const MgInputSelect = class {
2041
2430
  }
2042
2431
  validateItems(newValue) {
2043
2432
  // String array
2044
- if (index$1.allItemsAreString(newValue)) {
2433
+ if (allItemsAreString(newValue)) {
2045
2434
  this.valueExist = newValue.includes(this.value);
2046
2435
  this.options = newValue.map((item) => ({ title: item, value: item }));
2047
2436
  }
@@ -2061,6 +2450,16 @@ const MgInputSelect = class {
2061
2450
  throw new Error('<mg-input-select> prop "items" is required and all items must be the same type, string or Option.');
2062
2451
  }
2063
2452
  }
2453
+ handleValidityChange(newValue, _oldValue, prop) {
2454
+ if (this.input !== undefined) {
2455
+ this.input[prop] = newValue;
2456
+ this.checkValidity();
2457
+ if (this.hasDisplayedError) {
2458
+ this.setErrorMessage();
2459
+ this.hasDisplayedError = false;
2460
+ }
2461
+ }
2462
+ }
2064
2463
  /**
2065
2464
  * Public method to display errors
2066
2465
  *
@@ -2068,8 +2467,8 @@ const MgInputSelect = class {
2068
2467
  */
2069
2468
  async displayError() {
2070
2469
  this.checkValidity();
2071
- this.checkError();
2072
- this.hasError = this.invalid;
2470
+ this.setErrorMessage();
2471
+ this.hasDisplayedError = this.invalid;
2073
2472
  }
2074
2473
  /*************
2075
2474
  * Lifecycle *
@@ -2081,7 +2480,7 @@ const MgInputSelect = class {
2081
2480
  */
2082
2481
  componentWillLoad() {
2083
2482
  // Get locales
2084
- this.messages = index$1.initLocales(this.element).messages;
2483
+ this.messages = initLocales(this.element).messages;
2085
2484
  // Validate
2086
2485
  this.validateItems(this.items);
2087
2486
  // Set default placeholder
@@ -2101,18 +2500,24 @@ const MgInputSelect = class {
2101
2500
  * @returns {HTMLElement} HTML Element
2102
2501
  */
2103
2502
  render() {
2104
- return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
2503
+ return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
2504
+ if (el !== null)
2505
+ this.input = el;
2506
+ } }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
2105
2507
  index.h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map(option => option.group !== undefined ? (index.h("optgroup", { label: option.group }, option.options.map(optgroup => (index.h("option", { value: optgroup.title, selected: JSON.stringify(this.value) === JSON.stringify(optgroup.value), disabled: optgroup.disabled }, optgroup.title))))) : (index.h("option", { value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title))))));
2106
2508
  }
2107
2509
  get element() { return index.getElement(this); }
2108
2510
  static get watchers() { return {
2109
2511
  "value": ["handleValue"],
2110
- "items": ["validateItems"]
2512
+ "items": ["validateItems"],
2513
+ "required": ["handleValidityChange"],
2514
+ "readonly": ["handleValidityChange"],
2515
+ "disabled": ["handleValidityChange"]
2111
2516
  }; }
2112
2517
  };
2113
2518
  MgInputSelect.style = mgInputSelectCss;
2114
2519
 
2115
- const mgInputTextCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input.mg-input--has-icon .mg-input__with-character-left>mg-icon{position:absolute;top:50%;left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__with-character-left .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}.mg-input__with-character-left{position:relative;display:inline-flex}.mg-input--width-full .mg-input__with-character-left{width:100%}.mg-input.is-focused .mg-input__with-character-left .mg-input__box{padding-right:calc(var(--mg-character-left-message-length) * 1ch + 0.8rem)}.mg-input__with-character-left mg-character-left{position:absolute;display:none;top:50%;right:1rem;opacity:0.6;transform:translateY(-50%);font-size:1.1rem}.mg-input.is-focused .mg-input__with-character-left mg-character-left{display:block}";
2520
+ const mgInputTextCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input.mg-input--has-icon .mg-input__with-character-left>mg-icon{position:absolute;top:50%;left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__with-character-left .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}.mg-input__with-character-left{position:relative;display:inline-flex}.mg-input--width-full .mg-input__with-character-left{width:100%}.mg-input.is-focused .mg-input__with-character-left .mg-input__box{padding-right:calc(var(--mg-character-left-message-length) * 1ch + 0.8rem)}.mg-input__with-character-left mg-character-left{position:absolute;display:none;top:50%;right:1rem;opacity:0.6;transform:translateY(-50%);font-size:1.1rem}.mg-input.is-focused .mg-input__with-character-left mg-character-left{display:block}";
2116
2521
 
2117
2522
  const MgInputText = class {
2118
2523
  constructor(hostRef) {
@@ -2122,12 +2527,12 @@ const MgInputText = class {
2122
2527
  /************
2123
2528
  * Internal *
2124
2529
  ************/
2125
- // classes
2530
+ // Classes
2126
2531
  this.classFocus = 'is-focused';
2127
2532
  this.classIsInputGroupAppend = 'mg-input--is-input-group-append';
2128
2533
  this.classHasIcon = 'mg-input--has-icon';
2129
- // hasError (triggered by blur event)
2130
- this.hasError = false;
2534
+ // hasDisplayedError (triggered by blur event)
2535
+ this.hasDisplayedError = false;
2131
2536
  /**
2132
2537
  * Input name
2133
2538
  * If not set the value equals the identifier
@@ -2168,7 +2573,7 @@ const MgInputText = class {
2168
2573
  /**
2169
2574
  * Component classes
2170
2575
  */
2171
- this.classList = new index$1.ClassList(['mg-input--text']);
2576
+ this.classList = new ClassList(['mg-input--text']);
2172
2577
  /**
2173
2578
  * Handle input event
2174
2579
  *
@@ -2176,8 +2581,8 @@ const MgInputText = class {
2176
2581
  */
2177
2582
  this.handleInput = () => {
2178
2583
  this.checkValidity();
2179
- if (this.hasError) {
2180
- this.checkError();
2584
+ if (this.hasDisplayedError) {
2585
+ this.setErrorMessage();
2181
2586
  }
2182
2587
  this.value = this.input.value;
2183
2588
  };
@@ -2188,7 +2593,7 @@ const MgInputText = class {
2188
2593
  */
2189
2594
  this.handleFocus = () => {
2190
2595
  this.classList.add(this.classFocus);
2191
- this.classList = new index$1.ClassList(this.classList.classes);
2596
+ this.classList = new ClassList(this.classList.classes);
2192
2597
  };
2193
2598
  /**
2194
2599
  * Handle blur event
@@ -2198,7 +2603,7 @@ const MgInputText = class {
2198
2603
  this.handleBlur = () => {
2199
2604
  // Manage focus
2200
2605
  this.classList.delete(this.classFocus);
2201
- this.classList = new index$1.ClassList(this.classList.classes);
2606
+ this.classList = new ClassList(this.classList.classes);
2202
2607
  // Display Error
2203
2608
  this.displayError();
2204
2609
  };
@@ -2208,21 +2613,18 @@ const MgInputText = class {
2208
2613
  * @returns {void}
2209
2614
  */
2210
2615
  this.checkValidity = () => {
2211
- if (!this.readonly && this.input !== undefined) {
2212
- const validity = this.input.checkValidity();
2213
- // Set validity
2214
- this.valid = validity;
2215
- this.invalid = !validity;
2216
- //Send event
2217
- this.inputValid.emit(validity);
2218
- }
2616
+ var _a;
2617
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined ? this.input.checkValidity() : true);
2618
+ this.invalid = !this.valid;
2619
+ // We need to send valid event even if it is the same value
2620
+ this.inputValid.emit(this.valid);
2219
2621
  };
2220
2622
  /**
2221
- * Check input errors
2623
+ * Set input error message
2222
2624
  *
2223
2625
  * @returns {void}
2224
2626
  */
2225
- this.checkError = () => {
2627
+ this.setErrorMessage = () => {
2226
2628
  // Set error message
2227
2629
  this.errorMessage = undefined;
2228
2630
  // Does not match pattern
@@ -2235,7 +2637,7 @@ const MgInputText = class {
2235
2637
  }
2236
2638
  };
2237
2639
  /**
2238
- * Validate patern configuration
2640
+ * Validate pattern configuration
2239
2641
  *
2240
2642
  * @returns {void}
2241
2643
  */
@@ -2274,6 +2676,16 @@ const MgInputText = class {
2274
2676
  this.classList.delete(this.classHasIcon);
2275
2677
  }
2276
2678
  }
2679
+ handleValidityChange(newValue, _oldValue, prop) {
2680
+ if (this.input !== undefined) {
2681
+ this.input[prop] = newValue;
2682
+ this.checkValidity();
2683
+ if (this.hasDisplayedError) {
2684
+ this.setErrorMessage();
2685
+ this.hasDisplayedError = false;
2686
+ }
2687
+ }
2688
+ }
2277
2689
  /**
2278
2690
  * Public method to play input focus
2279
2691
  *
@@ -2289,8 +2701,8 @@ const MgInputText = class {
2289
2701
  */
2290
2702
  async displayError() {
2291
2703
  this.checkValidity();
2292
- this.checkError();
2293
- this.hasError = this.invalid;
2704
+ this.setErrorMessage();
2705
+ this.hasDisplayedError = this.invalid;
2294
2706
  }
2295
2707
  /*************
2296
2708
  * Lifecycle *
@@ -2302,7 +2714,7 @@ const MgInputText = class {
2302
2714
  */
2303
2715
  componentWillLoad() {
2304
2716
  // Get locales
2305
- this.messages = index$1.initLocales(this.element).messages;
2717
+ this.messages = initLocales(this.element).messages;
2306
2718
  this.characterLeftId = `${this.identifier}-character-left`;
2307
2719
  // Validate
2308
2720
  this.validateIcon(this.icon);
@@ -2325,17 +2737,23 @@ const MgInputText = class {
2325
2737
  '--mg-character-left-message-length': (this.displayCharacterLeft
2326
2738
  ? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
2327
2739
  : 0).toString(),
2328
- } }, this.icon !== undefined && index.h("mg-icon", { icon: this.icon }), index.h("input", { type: this.type, class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), this.displayCharacterLeft && this.maxlength > 0 && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))), index.h("slot", { name: "append-input" })));
2740
+ } }, this.icon !== undefined && index.h("mg-icon", { icon: this.icon }), index.h("input", { type: this.type, class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
2741
+ if (el !== null)
2742
+ this.input = el;
2743
+ } }), this.displayCharacterLeft && this.maxlength > 0 && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))), index.h("slot", { name: "append-input" })));
2329
2744
  }
2330
2745
  get element() { return index.getElement(this); }
2331
2746
  static get watchers() { return {
2332
2747
  "value": ["handleValue"],
2333
- "icon": ["validateIcon"]
2748
+ "icon": ["validateIcon"],
2749
+ "required": ["handleValidityChange"],
2750
+ "readonly": ["handleValidityChange"],
2751
+ "disabled": ["handleValidityChange"]
2334
2752
  }; }
2335
2753
  };
2336
2754
  MgInputText.style = mgInputTextCss;
2337
2755
 
2338
- const mgInputTextareaCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input .mg-input__box{display:block;height:auto;resize:none}.mg-input .mg-input__box.mg-input__box--resizable{resize:both}.mg-input .mg-input__box.mg-input__box--resizable-horizontal{resize:horizontal}.mg-input .mg-input__box.mg-input__box--resizable-vertical{resize:vertical}.mg-input__with-character-left{width:100%}.mg-input__with-character-left mg-character-left{display:block;visibility:hidden;margin-top:0.2rem;text-align:end}.mg-input.is-focused .mg-input__with-character-left mg-character-left{visibility:visible}@-moz-document url-prefix(){.mg-input__box{overflow-x:hidden}}";
2756
+ const mgInputTextareaCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__input mg-icon,.mg-input__error mg-icon{display:flex}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full.mg-input--label-on-top .mg-input__box{width:100%}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{max-width:100%}.mg-input:not(.mg-input--label-on-top) .mg-input__box{width:100%;max-width:calc(17.7rem + var(--mg-inputs-spacer) * 2);min-width:5rem}.mg-input.mg-input--width-16 .mg-input__input-container{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__input{width:100%;max-width:21rem}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__with-character-left{width:100%}.mg-input.mg-input--width-16 .mg-input__input-container .mg-input__box{max-width:21rem;min-width:100%}.mg-input.mg-input--width-4 .mg-input__input-container .mg-input__box{max-width:7rem}.mg-input.mg-input--width-2 .mg-input__input-container .mg-input__box{max-width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input .mg-input__box{display:block;height:auto;resize:none}.mg-input .mg-input__box.mg-input__box--resizable{resize:both}.mg-input .mg-input__box.mg-input__box--resizable-horizontal{resize:horizontal}.mg-input .mg-input__box.mg-input__box--resizable-vertical{resize:vertical}.mg-input__with-character-left{width:100%}.mg-input__with-character-left mg-character-left{display:block;visibility:hidden;margin-top:0.2rem;text-align:end}.mg-input.is-focused .mg-input__with-character-left mg-character-left{visibility:visible}@-moz-document url-prefix(){.mg-input__box{overflow-x:hidden}}";
2339
2757
 
2340
2758
  const MgInputTextarea = class {
2341
2759
  constructor(hostRef) {
@@ -2345,11 +2763,11 @@ const MgInputTextarea = class {
2345
2763
  /************
2346
2764
  * Internal *
2347
2765
  ************/
2348
- // classes
2766
+ // Classes
2349
2767
  this.classFocus = 'is-focused';
2350
2768
  this.classHasDisplayCharacterLeft = 'mg-input--has-display-character-left';
2351
- // hasError (triggered by blur event)
2352
- this.hasError = false;
2769
+ // hasDisplayedError (triggered by blur event)
2770
+ this.hasDisplayedError = false;
2353
2771
  /**
2354
2772
  * Input name
2355
2773
  * If not set the value equals the identifier
@@ -2394,14 +2812,14 @@ const MgInputTextarea = class {
2394
2812
  /**
2395
2813
  * Component classes
2396
2814
  */
2397
- this.classList = new index$1.ClassList(['mg-input--textarea']);
2815
+ this.classList = new ClassList(['mg-input--textarea']);
2398
2816
  /**
2399
2817
  * Handle input event
2400
2818
  */
2401
2819
  this.handleInput = () => {
2402
- if (this.hasError) {
2820
+ if (this.hasDisplayedError) {
2403
2821
  this.checkValidity();
2404
- this.checkError();
2822
+ this.setErrorMessage();
2405
2823
  }
2406
2824
  this.value = this.input.value;
2407
2825
  };
@@ -2410,7 +2828,7 @@ const MgInputTextarea = class {
2410
2828
  */
2411
2829
  this.handleFocus = () => {
2412
2830
  this.classList.add(this.classFocus);
2413
- this.classList = new index$1.ClassList(this.classList.classes);
2831
+ this.classList = new ClassList(this.classList.classes);
2414
2832
  };
2415
2833
  /**
2416
2834
  * Handle blur event
@@ -2418,7 +2836,7 @@ const MgInputTextarea = class {
2418
2836
  this.handleBlur = () => {
2419
2837
  // Manage focus
2420
2838
  this.classList.delete(this.classFocus);
2421
- this.classList = new index$1.ClassList(this.classList.classes);
2839
+ this.classList = new ClassList(this.classList.classes);
2422
2840
  // Display Error
2423
2841
  this.displayError();
2424
2842
  };
@@ -2433,19 +2851,16 @@ const MgInputTextarea = class {
2433
2851
  * Check if input is valid
2434
2852
  */
2435
2853
  this.checkValidity = () => {
2436
- if (!this.readonly && this.input !== undefined) {
2437
- const validity = this.input.checkValidity && this.input.checkValidity() && this.getPatternValidity();
2438
- // Set validity
2439
- this.valid = validity;
2440
- this.invalid = !validity;
2441
- //Send event
2442
- this.inputValid.emit(validity);
2443
- }
2854
+ var _a;
2855
+ this.valid = this.readonly || this.disabled || (((_a = this.input) === null || _a === void 0 ? void 0 : _a.checkValidity) !== undefined && this.input.checkValidity() && this.getPatternValidity());
2856
+ this.invalid = !this.valid;
2857
+ // We need to send valid event even if it is the same value
2858
+ this.inputValid.emit(this.valid);
2444
2859
  };
2445
2860
  /**
2446
- * Check input errors
2861
+ * Set input error message
2447
2862
  */
2448
- this.checkError = () => {
2863
+ this.setErrorMessage = () => {
2449
2864
  // Set error message
2450
2865
  this.errorMessage = undefined;
2451
2866
  // Does not match pattern
@@ -2473,6 +2888,16 @@ const MgInputTextarea = class {
2473
2888
  this.checkValidity();
2474
2889
  this.valueChange.emit(newValue);
2475
2890
  }
2891
+ handleValidityChange(newValue, _oldValue, prop) {
2892
+ if (this.input !== undefined) {
2893
+ this.input[prop] = newValue;
2894
+ this.checkValidity();
2895
+ if (this.hasDisplayedError) {
2896
+ this.setErrorMessage();
2897
+ this.hasDisplayedError = false;
2898
+ }
2899
+ }
2900
+ }
2476
2901
  validateDisplayCharacterLeft(newValue) {
2477
2902
  if (newValue) {
2478
2903
  this.classList.add(this.classHasDisplayCharacterLeft);
@@ -2488,8 +2913,8 @@ const MgInputTextarea = class {
2488
2913
  */
2489
2914
  async displayError() {
2490
2915
  this.checkValidity();
2491
- this.checkError();
2492
- this.hasError = this.invalid;
2916
+ this.setErrorMessage();
2917
+ this.hasDisplayedError = this.invalid;
2493
2918
  }
2494
2919
  /*************
2495
2920
  * Lifecycle *
@@ -2501,7 +2926,7 @@ const MgInputTextarea = class {
2501
2926
  */
2502
2927
  componentWillLoad() {
2503
2928
  // Get locales
2504
- this.messages = index$1.initLocales(this.element).messages;
2929
+ this.messages = initLocales(this.element).messages;
2505
2930
  this.characterLeftId = `${this.identifier}-character-left`;
2506
2931
  // Validate
2507
2932
  this.validateDisplayCharacterLeft(this.displayCharacterLeft);
@@ -2524,11 +2949,17 @@ const MgInputTextarea = class {
2524
2949
  'mg-input__box--resizable': this.resizable === 'both',
2525
2950
  'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
2526
2951
  'mg-input__box--resizable-vertical': this.resizable === 'vertical',
2527
- }, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), this.displayCharacterLeft && this.maxlength > 0 && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
2952
+ }, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => {
2953
+ if (el !== null)
2954
+ this.input = el;
2955
+ } }), this.displayCharacterLeft && this.maxlength > 0 && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
2528
2956
  }
2529
2957
  get element() { return index.getElement(this); }
2530
2958
  static get watchers() { return {
2531
2959
  "value": ["handleValue"],
2960
+ "required": ["handleValidityChange"],
2961
+ "readonly": ["handleValidityChange"],
2962
+ "disabled": ["handleValidityChange"],
2532
2963
  "displayCharacterLeft": ["validateDisplayCharacterLeft"]
2533
2964
  }; }
2534
2965
  };
@@ -2601,7 +3032,7 @@ const MgInputToggle = class {
2601
3032
  /************
2602
3033
  * Internal *
2603
3034
  ************/
2604
- // classes
3035
+ // Classes
2605
3036
  this.classReadonly = 'mg-input--toggle-readonly';
2606
3037
  this.classDisabled = 'mg-input--toggle-disabled';
2607
3038
  this.classIsActive = 'mg-input--toggle-is-active';
@@ -2635,7 +3066,7 @@ const MgInputToggle = class {
2635
3066
  /**
2636
3067
  * Component classes
2637
3068
  */
2638
- this.classList = new index$1.ClassList(['mg-input--toggle']);
3069
+ this.classList = new ClassList(['mg-input--toggle']);
2639
3070
  /**
2640
3071
  * Checked internal value
2641
3072
  */
@@ -2676,7 +3107,7 @@ const MgInputToggle = class {
2676
3107
  throw new Error('<mg-input-toggle> prop "items" require 2 items.');
2677
3108
  }
2678
3109
  // String array
2679
- else if (index$1.allItemsAreString(newValue)) {
3110
+ else if (allItemsAreString(newValue)) {
2680
3111
  this.options = newValue.map(item => ({ title: item, value: item }));
2681
3112
  }
2682
3113
  // Object array
@@ -2799,7 +3230,7 @@ const MgMessage = class {
2799
3230
  /************
2800
3231
  * Internal *
2801
3232
  ************/
2802
- // classes
3233
+ // Classes
2803
3234
  this.classHide = 'mg-message--hide';
2804
3235
  // IDs
2805
3236
  this.closeButtonId = '';
@@ -2809,7 +3240,7 @@ const MgMessage = class {
2809
3240
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2810
3241
  * If not set, it will be created.
2811
3242
  */
2812
- this.identifier = index$1.createID('mg-message');
3243
+ this.identifier = createID('mg-message');
2813
3244
  /**
2814
3245
  * Message variant
2815
3246
  */
@@ -2826,7 +3257,7 @@ const MgMessage = class {
2826
3257
  /**
2827
3258
  * Component classes
2828
3259
  */
2829
- this.classList = new index$1.ClassList(['mg-message']);
3260
+ this.classList = new ClassList(['mg-message']);
2830
3261
  /**
2831
3262
  * Define if component is using actions slot
2832
3263
  */
@@ -2907,7 +3338,7 @@ const MgMessage = class {
2907
3338
  */
2908
3339
  componentWillLoad() {
2909
3340
  // Get locales
2910
- this.messages = index$1.initLocales(this.element).messages;
3341
+ this.messages = initLocales(this.element).messages;
2911
3342
  // Validate
2912
3343
  this.validateVariant(this.variant);
2913
3344
  // Check if close button is an can be activated
@@ -2938,6 +3369,170 @@ const MgMessage = class {
2938
3369
  };
2939
3370
  MgMessage.style = mgMessageCss;
2940
3371
 
3372
+ const mgModalCss = ".mg-modal{display:flex;justify-content:center;align-items:center;position:fixed;top:0;right:0;bottom:0;left:0;z-index:2000;padding:2rem 0;background-color:hsla(var(--color-light), 85%)}.mg-modal__dialog{display:flex;position:relative;flex-direction:column;align-self:center;row-gap:3rem;padding:1.5rem 2.5rem;width:60rem;height:fit-content;max-width:100%;max-height:100%;box-sizing:border-box;background-color:hsl(var(--color-light));box-shadow:var(--box-shadow);border-radius:var(--mg-modal-border-radius)}.mg-modal__header{margin-bottom:0.5rem}.mg-modal__title{margin:0;font-family:var(--font-family-heading);font-size:var(--mg-modal-title-font-size);font-weight:600}.mg-modal__close-button{float:right;height:var(--mg-modal-title-font-size);margin-top:calc((var(--default-size) - var(--mg-modal-title-font-size) * var(--line-height)) / 2 * -1);margin-right:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2 * -1)}.mg-modal__content{overflow-y:auto}.mg-modal__content::slotted(*){font-size:var(--mg-modal-content-font-size)}.mg-modal.mg-modal--hide{display:none}";
3373
+
3374
+ const MgModal = class {
3375
+ constructor(hostRef) {
3376
+ index.registerInstance(this, hostRef);
3377
+ this.componentShow = index.createEvent(this, "component-show", 7);
3378
+ this.componentHide = index.createEvent(this, "component-hide", 7);
3379
+ // Classes
3380
+ this.classHide = 'mg-modal--hide';
3381
+ // IDs
3382
+ this.closeButtonId = '';
3383
+ this.titleId = '';
3384
+ /**
3385
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
3386
+ * If not set, it will be created.
3387
+ */
3388
+ this.identifier = createID('mg-modal');
3389
+ /**
3390
+ * Define if modal has a cross button
3391
+ */
3392
+ this.closeButton = false;
3393
+ /**
3394
+ * Define if modal is hidden
3395
+ */
3396
+ this.hide = false;
3397
+ /**
3398
+ * Define if component is using actions slot
3399
+ */
3400
+ this.hasActions = false;
3401
+ /**
3402
+ * Define if component is using content slot
3403
+ */
3404
+ this.hasContent = false;
3405
+ /**
3406
+ * Component classes
3407
+ */
3408
+ this.classList = new ClassList(['mg-modal']);
3409
+ this.setFocus = () => {
3410
+ // Get all focusable elements
3411
+ this.modalFocusableElements = Array.from(this.element.querySelectorAll(focusableElements)).reduce((acc, focusableElement) => {
3412
+ acc.push(focusableElement.shadowRoot !== null ? focusableElement.shadowRoot.querySelector(focusableElements) || focusableElement : focusableElement);
3413
+ return acc;
3414
+ }, []);
3415
+ // When close button is enabled it's the first focusable element.
3416
+ if (this.closeButton) {
3417
+ this.modalFocusableElements.unshift(this.element.shadowRoot.querySelector(`.mg-modal__close-button mg-button`));
3418
+ }
3419
+ // It at least one
3420
+ if (this.modalFocusableElements.length >= 1) {
3421
+ // Set focus on first element
3422
+ this.modalFocusableElements[0].focus();
3423
+ // Add event listener on last element
3424
+ const lastFocusableElement = this.modalFocusableElements[this.modalFocusableElements.length - 1];
3425
+ lastFocusableElement.addEventListener('keydown', event => {
3426
+ if (event.key === 'Tab' && !event.shiftKey) {
3427
+ event.preventDefault();
3428
+ this.modalFocusableElements[0].focus();
3429
+ }
3430
+ });
3431
+ // Add event listener on first element (case shift + tab)
3432
+ this.modalFocusableElements[0].addEventListener('keydown', event => {
3433
+ if (event.key === 'Tab' && event.shiftKey) {
3434
+ event.preventDefault();
3435
+ lastFocusableElement.focus();
3436
+ }
3437
+ });
3438
+ }
3439
+ };
3440
+ /*************
3441
+ * Handlers *
3442
+ *************/
3443
+ /**
3444
+ * Handle close button
3445
+ *
3446
+ * @returns {void}
3447
+ */
3448
+ this.handleClose = () => {
3449
+ this.hide = true;
3450
+ };
3451
+ }
3452
+ validateModalTitle(newValue) {
3453
+ if (typeof newValue !== 'string' || newValue.trim() === '') {
3454
+ throw new Error('<mg-modal> prop "modalTitle" is required.');
3455
+ }
3456
+ }
3457
+ validateHide(newValue) {
3458
+ if (newValue) {
3459
+ this.componentHide.emit();
3460
+ this.classList.add(this.classHide);
3461
+ document.body.style.overflow = this.bodyOverflow;
3462
+ }
3463
+ else {
3464
+ this.componentShow.emit();
3465
+ this.classList.delete(this.classHide);
3466
+ document.body.style.overflow = 'hidden';
3467
+ }
3468
+ }
3469
+ /**
3470
+ * Handle 'escape' key down
3471
+ *
3472
+ * @param {KeyboardEvent} event keydown event
3473
+ * @returns {void}
3474
+ */
3475
+ handleKeyDown(event) {
3476
+ // we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
3477
+ if (this.closeButton && event.key === 'Escape') {
3478
+ this.hide = true;
3479
+ }
3480
+ }
3481
+ /*************
3482
+ * Lifecycle *
3483
+ *************/
3484
+ /**
3485
+ * Check if component props are well configured on init
3486
+ *
3487
+ * @returns {void}
3488
+ */
3489
+ componentWillLoad() {
3490
+ // Store body overflow
3491
+ this.bodyOverflow = document.body.style.overflow;
3492
+ // Get locales
3493
+ this.messages = initLocales(this.element).messages;
3494
+ // Validate
3495
+ this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
3496
+ this.hasContent = this.element.querySelector('[slot="content"]') !== null;
3497
+ if (this.closeButton) {
3498
+ this.closeButtonId = `${this.identifier}-close-button`;
3499
+ }
3500
+ this.titleId = `${this.identifier}-title`;
3501
+ this.validateModalTitle(this.modalTitle);
3502
+ this.validateHide(this.hide);
3503
+ }
3504
+ /**
3505
+ * Add observer on component to set focus when displayed
3506
+ *
3507
+ * @returns {void}
3508
+ */
3509
+ componentDidLoad() {
3510
+ new MutationObserver(mutationList => {
3511
+ if (mutationList.some(mutation => mutation.attributeName === 'aria-hidden' && mutation.target.ariaHidden === null)) {
3512
+ this.setFocus();
3513
+ }
3514
+ }).observe(this.element.shadowRoot.getElementById(this.identifier), { attributes: true });
3515
+ // Set focus if display on load
3516
+ if (!this.hide) {
3517
+ this.setFocus();
3518
+ }
3519
+ }
3520
+ /**
3521
+ * Render
3522
+ *
3523
+ * @returns {HTMLElement} HTML Element
3524
+ */
3525
+ render() {
3526
+ return (index.h("section", { role: "dialog", id: this.identifier, class: this.classList.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, index.h("article", { class: "mg-modal__dialog" }, index.h("header", { class: "mg-modal__header" }, this.closeButton && (index.h("span", { class: "mg-modal__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" })))), index.h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (index.h("article", { class: "mg-modal__content" }, index.h("slot", { name: "content" }))), this.hasActions && (index.h("footer", { class: "mg-modal__footer" }, index.h("slot", { name: "actions" }))))));
3527
+ }
3528
+ get element() { return index.getElement(this); }
3529
+ static get watchers() { return {
3530
+ "modalTitle": ["validateModalTitle"],
3531
+ "hide": ["validateHide"]
3532
+ }; }
3533
+ };
3534
+ MgModal.style = mgModalCss;
3535
+
2941
3536
  var NavigationAction;
2942
3537
  (function (NavigationAction) {
2943
3538
  NavigationAction["NEXT"] = "next";
@@ -2975,7 +3570,7 @@ const MgPagination = class {
2975
3570
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2976
3571
  * If not set, it will be created.
2977
3572
  */
2978
- this.identifier = index$1.createID('mg-pagination');
3573
+ this.identifier = createID('mg-pagination');
2979
3574
  /**
2980
3575
  * Component total pages
2981
3576
  */
@@ -3041,7 +3636,7 @@ const MgPagination = class {
3041
3636
  */
3042
3637
  componentWillLoad() {
3043
3638
  // Get locales
3044
- this.messages = index$1.initLocales(this.element).messages;
3639
+ this.messages = initLocales(this.element).messages;
3045
3640
  // Validate
3046
3641
  this.validateTotalPages(this.totalPages);
3047
3642
  this.validateCurrentPage(this.currentPage);
@@ -3069,7 +3664,7 @@ const MgPagination = class {
3069
3664
  };
3070
3665
  MgPagination.style = mgPaginationCss;
3071
3666
 
3072
- const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);box-shadow:var(--box-shadow)}.mg-panel__header{display:flex;flex-wrap:wrap;justify-content:space-between;padding:0 1rem 0 0.3rem;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:flex;margin:0.3rem 0}.mg-panel__header-left--full{flex:1 1 auto}.mg-panel__header-right{padding-left:0.3rem;flex:1 auto}.mg-panel__header-left mg-input-text{flex-grow:1;margin-left:0.3rem}.mg-panel__header-left mg-button+mg-button:not([slot=append-input]){margin-left:0.3rem}.mg-panel__collapse-button-content{--font-size:1.4rem;--mg-button-font-weight:600}.mg-panel__content{padding:var(--mg-panel-content-padding)}.mg-panel ::slotted([slot=header-right]){display:flex;flex-wrap:wrap;gap:1rem;margin-left:auto}";
3667
+ const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);box-shadow:var(--mg-panel-box-shadow)}.mg-panel__header{display:flex;flex-wrap:wrap;justify-content:space-between;padding:0 1rem 0 0.3rem;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:flex;margin:0.3rem 0}.mg-panel__header-right{padding-left:0.3rem;flex:1 auto}.mg-panel__header-left mg-input-text{flex-grow:1;margin-left:0.3rem}.mg-panel__header-left mg-button+mg-button:not([slot=append-input]){margin-left:0.3rem}.mg-panel__header-left.mg-panel__header-left--full{flex:1 1 auto}.mg-panel__collapse-button-content{--font-size:1.4rem;--mg-button-font-weight:600}.mg-panel__content{padding:var(--mg-panel-content-padding)}.mg-panel ::slotted([slot=header-right]){display:flex;flex-wrap:wrap;gap:1rem;margin-left:auto}";
3073
3668
 
3074
3669
  const MgPanel = class {
3075
3670
  constructor(hostRef) {
@@ -3080,7 +3675,7 @@ const MgPanel = class {
3080
3675
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
3081
3676
  * If not set, it will be created.
3082
3677
  */
3083
- this.identifier = index$1.createID('mg-panel');
3678
+ this.identifier = createID('mg-panel');
3084
3679
  /**
3085
3680
  * Panel is opened
3086
3681
  */
@@ -3092,7 +3687,7 @@ const MgPanel = class {
3092
3687
  /**
3093
3688
  * Component classes
3094
3689
  */
3095
- this.classList = new index$1.ClassList(['mg-panel']);
3690
+ this.classList = new ClassList(['mg-panel']);
3096
3691
  /**
3097
3692
  * Title is in edition mode
3098
3693
  */
@@ -3209,7 +3804,7 @@ const MgPanel = class {
3209
3804
  */
3210
3805
  componentWillLoad() {
3211
3806
  // Get locales
3212
- this.messages = index$1.initLocales(this.element).messages;
3807
+ this.messages = initLocales(this.element).messages;
3213
3808
  // Validate
3214
3809
  this.validatetitlePattern(this.titlePattern);
3215
3810
  this.validatePanelTitle(this.panelTitle);
@@ -5040,7 +5635,7 @@ var createPopper = /*#__PURE__*/popperGenerator({
5040
5635
  defaultModifiers: defaultModifiers
5041
5636
  }); // eslint-disable-next-line import/no-unused-modules
5042
5637
 
5043
- const mgPopoverCss = "mg-popover{display:contents}mg-popover::slotted(*){display:inline-block}.mg-popover{display:none;padding:1.5rem;z-index:9999;border-radius:0.5rem;background-color:hsl(var(--mg-popover-background-color));box-shadow:var(--box-shadow);color:hsl(var(--mg-popover-font-color))}.mg-popover[data-show]{display:block}.mg-popover mg-button{float:right;margin-right:calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);margin-top:calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);margin-left:3rem}.mg-popover__arrow,.mg-popover__arrow::before{position:absolute;width:2rem;height:2rem;z-index:-1;background:inherit}.mg-popover__arrow{visibility:hidden}.mg-popover__arrow::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow{bottom:-6px}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{top:-6px}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow{right:-6px}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{left:-6px}.mg-popover__title ::slotted([slot=title]){margin:0 0 1rem !important;font-size:var(--mg-popover-title-font-size) !important;font-weight:600}";
5638
+ const mgPopoverCss = "mg-popover{display:contents}mg-popover::slotted(*){display:inline-block}.mg-popover{display:none;padding:1.5rem;z-index:1000;border-radius:0.5rem;background-color:hsl(var(--mg-popover-background-color));box-shadow:var(--box-shadow);color:hsl(var(--mg-popover-font-color))}.mg-popover[data-show]{display:block}.mg-popover mg-button{float:right;margin-right:calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);margin-top:calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);margin-left:3rem}.mg-popover__arrow,.mg-popover__arrow::before{position:absolute;width:2rem;height:2rem;z-index:-1;background:inherit}.mg-popover__arrow{visibility:hidden}.mg-popover__arrow::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow{bottom:-6px}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{top:-6px}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow{right:-6px}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{left:-6px}.mg-popover__title ::slotted([slot=title]){margin:0 0 1rem !important;font-size:var(--mg-popover-title-font-size) !important;font-weight:600}";
5044
5639
 
5045
5640
  const MgPopover = class {
5046
5641
  constructor(hostRef) {
@@ -5051,7 +5646,7 @@ const MgPopover = class {
5051
5646
  * Sets an `id` attribute.
5052
5647
  * Needed by the input for accessibility `aria-decribedby`.
5053
5648
  */
5054
- this.identifier = index$1.createID('mg-popover');
5649
+ this.identifier = createID('mg-popover');
5055
5650
  /**
5056
5651
  * Popover placement
5057
5652
  */
@@ -5138,7 +5733,7 @@ const MgPopover = class {
5138
5733
  */
5139
5734
  componentWillLoad() {
5140
5735
  // Get locales
5141
- this.messages = index$1.initLocales(this.element).messages;
5736
+ this.messages = initLocales(this.element).messages;
5142
5737
  }
5143
5738
  /**
5144
5739
  * Check if component props are well configured on init
@@ -5148,7 +5743,7 @@ const MgPopover = class {
5148
5743
  componentDidLoad() {
5149
5744
  const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
5150
5745
  const slottedTitleElement = this.element.querySelector('[slot="title"]');
5151
- if (slottedTitleElement && !index$1.isTagName(slottedTitleElement, headingTags)) {
5746
+ if (slottedTitleElement && !isTagName(slottedTitleElement, headingTags)) {
5152
5747
  throw new Error(`<mg-popover> Slotted title must be a heading: ${headingTags.join(', ')}`);
5153
5748
  }
5154
5749
  // Set close button id
@@ -5165,6 +5760,7 @@ const MgPopover = class {
5165
5760
  // Create popperjs popover
5166
5761
  this.popper = createPopper(interactiveElement, this.popover, {
5167
5762
  placement: this.placement,
5763
+ strategy: 'fixed',
5168
5764
  modifiers: [
5169
5765
  {
5170
5766
  name: 'offset',
@@ -5192,7 +5788,7 @@ const MgPopover = class {
5192
5788
  * @returns {HTMLElement} HTML Element
5193
5789
  */
5194
5790
  render() {
5195
- return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: "mg-popover" }, !this.disabled && this.closeButton && (index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, index.h("mg-icon", { icon: "cross" }))), index.h("div", { class: "mg-popover__title" }, index.h("slot", { name: "title" })), index.h("slot", { name: "content" }), index.h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
5791
+ return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: "mg-popover" }, this.closeButton && (index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, index.h("mg-icon", { icon: "cross" }))), index.h("div", { class: "mg-popover__title" }, index.h("slot", { name: "title" })), index.h("slot", { name: "content" }), index.h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
5196
5792
  }
5197
5793
  get element() { return index.getElement(this); }
5198
5794
  static get watchers() { return {
@@ -5236,7 +5832,7 @@ const MgTabs = class {
5236
5832
  * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
5237
5833
  * If not set, it will be created.
5238
5834
  */
5239
- this.identifier = index$1.createID('mg-tabs');
5835
+ this.identifier = createID('mg-tabs');
5240
5836
  /**
5241
5837
  * Define tabs size
5242
5838
  */
@@ -5253,7 +5849,7 @@ const MgTabs = class {
5253
5849
  /**
5254
5850
  * Component classes
5255
5851
  */
5256
- this.classList = new index$1.ClassList(['mg-tabs']);
5852
+ this.classList = new ClassList(['mg-tabs']);
5257
5853
  /**
5258
5854
  * Method to set active tab
5259
5855
  *
@@ -5358,7 +5954,7 @@ const MgTabs = class {
5358
5954
  }
5359
5955
  validateItems(newValue) {
5360
5956
  // String array
5361
- if (index$1.allItemsAreString(newValue)) {
5957
+ if (allItemsAreString(newValue)) {
5362
5958
  this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
5363
5959
  }
5364
5960
  // Object array
@@ -5429,7 +6025,7 @@ const MgTag = class {
5429
6025
  /************
5430
6026
  * Internal *
5431
6027
  ************/
5432
- // classes
6028
+ // Classes
5433
6029
  this.classOutline = `mg-tag--outline`;
5434
6030
  /**************
5435
6031
  * Decorators *
@@ -5441,7 +6037,7 @@ const MgTag = class {
5441
6037
  /**
5442
6038
  * Component classes
5443
6039
  */
5444
- this.classList = new index$1.ClassList(['mg-tag']);
6040
+ this.classList = new ClassList(['mg-tag']);
5445
6041
  }
5446
6042
  validateVariant(newValue, oldValue) {
5447
6043
  if (!variants.includes(newValue)) {
@@ -5487,9 +6083,6 @@ const MgTag = class {
5487
6083
  };
5488
6084
  MgTag.style = mgTagCss;
5489
6085
 
5490
- /**
5491
- * List of all possibles placements
5492
- */
5493
6086
  var Guard;
5494
6087
  (function (Guard) {
5495
6088
  Guard["FOCUS"] = "focus";
@@ -5497,7 +6090,7 @@ var Guard;
5497
6090
  Guard["HOVER_TOOLTIPED_ELEMENT"] = "hoverTooltipedGuard";
5498
6091
  })(Guard || (Guard = {}));
5499
6092
 
5500
- const mgTooltipCss = ":host{display:inline-block}.mg-tooltip{display:none;padding:0.5rem 0.8rem;z-index:9999;border-radius:var(--mg-tooltip-border-radius);background-color:hsl(var(--mg-tooltip-background-color));color:hsl(var(--mg-tooltip-font-color));text-align:start}.mg-tooltip[data-show]{display:block}.mg-tooltip .mg-tooltip__arrow,.mg-tooltip .mg-tooltip__arrow::before{position:absolute;width:0.8rem;height:0.8rem;z-index:9999;background:inherit}.mg-tooltip .mg-tooltip__arrow{visibility:hidden}.mg-tooltip .mg-tooltip__arrow::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-tooltip[data-popper-placement^=top]>.mg-tooltip__arrow{bottom:-4px}.mg-tooltip[data-popper-placement^=bottom]>.mg-tooltip__arrow{top:-4px}.mg-tooltip[data-popper-placement^=left]>.mg-tooltip__arrow{right:-4px}.mg-tooltip[data-popper-placement^=right]>.mg-tooltip__arrow{left:-4px}";
6093
+ const mgTooltipCss = ":host{display:inline-block}.mg-tooltip{display:none;padding:0.5rem 0.8rem;z-index:1000;border-radius:var(--mg-tooltip-border-radius);background-color:hsl(var(--mg-tooltip-background-color));color:hsl(var(--mg-tooltip-font-color));text-align:start}.mg-tooltip[data-show]{display:block}.mg-tooltip .mg-tooltip__arrow,.mg-tooltip .mg-tooltip__arrow::before{position:absolute;width:0.8rem;height:0.8rem;z-index:9999;background:inherit}.mg-tooltip .mg-tooltip__arrow{visibility:hidden}.mg-tooltip .mg-tooltip__arrow::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-tooltip[data-popper-placement^=top]>.mg-tooltip__arrow{bottom:-4px}.mg-tooltip[data-popper-placement^=bottom]>.mg-tooltip__arrow{top:-4px}.mg-tooltip[data-popper-placement^=left]>.mg-tooltip__arrow{right:-4px}.mg-tooltip[data-popper-placement^=right]>.mg-tooltip__arrow{left:-4px}";
5501
6094
 
5502
6095
  const MgTooltip = class {
5503
6096
  constructor(hostRef) {
@@ -5506,7 +6099,7 @@ const MgTooltip = class {
5506
6099
  * Sets an `id` attribute.
5507
6100
  * Needed by the input for accessibility `aria-decribedby`.
5508
6101
  */
5509
- this.identifier = index$1.createID('mg-tooltip');
6102
+ this.identifier = createID('mg-tooltip');
5510
6103
  /**
5511
6104
  * Tooltip placement
5512
6105
  */
@@ -5634,6 +6227,7 @@ const MgTooltip = class {
5634
6227
  // Create popperjs tooltip
5635
6228
  this.popper = createPopper(tooltipedElement, this.tooltip, {
5636
6229
  placement: this.placement,
6230
+ strategy: 'fixed',
5637
6231
  modifiers: [
5638
6232
  {
5639
6233
  name: 'offset',
@@ -5691,8 +6285,10 @@ MgTooltip.style = mgTooltipCss;
5691
6285
 
5692
6286
  exports.mg_badge = MgBadge;
5693
6287
  exports.mg_button = MgButton;
6288
+ exports.mg_card = MgCard;
5694
6289
  exports.mg_character_left = MgCharacterLeft;
5695
6290
  exports.mg_details = MgDetails;
6291
+ exports.mg_divider = MgDivider;
5696
6292
  exports.mg_form = MgForm;
5697
6293
  exports.mg_icon = MgIcon;
5698
6294
  exports.mg_illustrated_message = MgIllustratedMessage;
@@ -5707,6 +6303,7 @@ exports.mg_input_textarea = MgInputTextarea;
5707
6303
  exports.mg_input_title = MgInputTitle;
5708
6304
  exports.mg_input_toggle = MgInputToggle;
5709
6305
  exports.mg_message = MgMessage;
6306
+ exports.mg_modal = MgModal;
5710
6307
  exports.mg_pagination = MgPagination;
5711
6308
  exports.mg_panel = MgPanel;
5712
6309
  exports.mg_popover = MgPopover;