@mgdis/mg-components 4.1.1 → 4.2.1

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 (130) hide show
  1. package/dist/cjs/{index-dd2c7f7b.js → index-94497267.js} +455 -317
  2. package/dist/cjs/loader.cjs.js +3 -3
  3. package/dist/cjs/{mg-badge_24.cjs.entry.js → mg-badge_23.cjs.entry.js} +219 -2181
  4. package/dist/cjs/mg-components.cjs.js +3 -26
  5. package/dist/cjs/mg-modal.cjs.entry.js +15 -2
  6. package/dist/cjs/mg-popover.cjs.entry.js +171 -0
  7. package/dist/cjs/popper-11d5f714.js +1801 -0
  8. package/dist/collection/collection-manifest.json +2 -2
  9. package/dist/collection/components/atoms/mg-badge/mg-badge.js +118 -99
  10. package/dist/collection/components/atoms/mg-button/mg-button.js +221 -220
  11. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +72 -69
  12. package/dist/collection/components/atoms/mg-icon/doc/mg-icon.stories.js +1 -2
  13. package/dist/collection/components/atoms/mg-icon/mg-icon.js +102 -92
  14. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +85 -67
  15. package/dist/collection/components/atoms/mg-tag/mg-tag.js +64 -55
  16. package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +3 -6
  17. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +122 -106
  18. package/dist/collection/components/molecules/inputs/MgInput.js +10 -17
  19. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +323 -318
  20. package/dist/collection/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.js +3 -2
  21. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +356 -361
  22. package/dist/collection/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.js +1 -2
  23. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +463 -457
  24. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +347 -340
  25. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +348 -343
  26. package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +4 -3
  27. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +406 -401
  28. package/dist/collection/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.js +12 -15
  29. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +2 -0
  30. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +476 -473
  31. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +461 -456
  32. package/dist/collection/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.js +2 -8
  33. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +1 -0
  34. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +299 -298
  35. package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +1 -3
  36. package/dist/collection/components/molecules/mg-details/mg-details.js +95 -93
  37. package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +13 -27
  38. package/dist/collection/components/molecules/mg-form/mg-form.js +175 -166
  39. package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +2 -6
  40. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +37 -37
  41. package/dist/collection/components/molecules/mg-message/doc/mg-message.stories.js +1 -3
  42. package/dist/collection/components/molecules/mg-message/mg-message.js +154 -153
  43. package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +11 -15
  44. package/dist/collection/components/molecules/mg-modal/mg-modal.css +2 -2
  45. package/dist/collection/components/molecules/mg-modal/mg-modal.js +153 -134
  46. package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +5 -6
  47. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +112 -117
  48. package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +1 -8
  49. package/dist/collection/components/molecules/mg-panel/mg-panel.css +2 -2
  50. package/dist/collection/components/molecules/mg-panel/mg-panel.js +194 -189
  51. package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +1 -4
  52. package/dist/collection/components/molecules/mg-popover/mg-popover.css +3 -5
  53. package/dist/collection/components/molecules/mg-popover/mg-popover.js +129 -127
  54. package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +1 -5
  55. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +1 -0
  56. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +152 -135
  57. package/dist/collection/fonts/OpenSans-Bold.ttf +0 -0
  58. package/dist/collection/locales/en/messages.json +50 -0
  59. package/dist/collection/locales/fr/messages.json +50 -0
  60. package/dist/collection/stories/grids.stories.js +1 -44
  61. package/dist/collection/stories/helpers.stories.js +1 -19
  62. package/dist/collection/stories/icons.stories.js +1 -4
  63. package/dist/collection/stories/typography.stories.js +1 -12
  64. package/dist/collection/variables.css +3 -2
  65. package/dist/collection/variables.scss +3 -2
  66. package/dist/components/MgInput.js +8 -3
  67. package/dist/components/mg-badge2.js +9 -0
  68. package/dist/components/mg-button2.js +2 -7
  69. package/dist/components/mg-input-checkbox.js +1 -6
  70. package/dist/components/mg-input-date.js +10 -27
  71. package/dist/components/mg-input-numeric.js +2 -7
  72. package/dist/components/mg-input-password.js +1 -6
  73. package/dist/components/mg-input-radio.js +1 -6
  74. package/dist/components/mg-input-select2.js +1 -6
  75. package/dist/components/mg-input-text2.js +3 -8
  76. package/dist/components/mg-input-textarea.js +2 -7
  77. package/dist/components/mg-input-title2.js +11 -0
  78. package/dist/components/mg-input-toggle.js +2 -7
  79. package/dist/components/mg-modal.js +14 -1
  80. package/dist/components/mg-pagination.js +3 -3
  81. package/dist/components/mg-panel.js +10 -4
  82. package/dist/components/mg-popover.js +1 -1
  83. package/dist/components/mg-tabs.js +10 -1
  84. package/dist/components/mg-tooltip2.js +9 -0
  85. package/dist/components/popper.js +60 -49
  86. package/dist/esm/{index-f58b769f.js → index-aad0184c.js} +456 -317
  87. package/dist/esm/loader.js +3 -3
  88. package/dist/esm/{mg-badge_24.entry.js → mg-badge_23.entry.js} +220 -2181
  89. package/dist/esm/mg-components.js +3 -26
  90. package/dist/esm/mg-modal.entry.js +15 -2
  91. package/dist/esm/mg-popover.entry.js +167 -0
  92. package/dist/esm/polyfills/css-shim.js +1 -1
  93. package/dist/esm/popper-f860750c.js +1799 -0
  94. package/dist/mg-components/fonts/OpenSans-Bold.ttf +0 -0
  95. package/dist/mg-components/locales/en/messages.json +50 -0
  96. package/dist/mg-components/locales/fr/messages.json +50 -0
  97. package/dist/mg-components/mg-components.css +1 -1
  98. package/dist/mg-components/mg-components.esm.js +1 -1
  99. package/dist/mg-components/p-25452f60.entry.js +1 -0
  100. package/dist/mg-components/p-3899d5d2.js +2 -0
  101. package/dist/mg-components/p-a20fc541.entry.js +1 -0
  102. package/dist/mg-components/p-e08bc19a.entry.js +1 -0
  103. package/dist/mg-components/p-ec26fc38.js +1 -0
  104. package/dist/mg-components/variables.css +3 -2
  105. package/dist/mg-components/variables.scss +3 -2
  106. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +1 -0
  107. package/dist/types/components/atoms/mg-button/mg-button.d.ts +0 -1
  108. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -0
  109. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +1 -0
  110. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +0 -1
  111. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +1 -10
  112. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +0 -1
  113. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +0 -1
  114. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +0 -1
  115. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +0 -1
  116. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +0 -1
  117. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +0 -1
  118. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +0 -1
  119. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +2 -0
  120. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +1 -1
  121. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +1 -0
  122. package/dist/types/components.d.ts +29 -29
  123. package/dist/types/stencil-public-runtime.d.ts +15 -4
  124. package/loader/package.json +1 -0
  125. package/package.json +9 -9
  126. package/dist/collection/fonts/Poppins-Bold.ttf +0 -0
  127. package/dist/mg-components/fonts/Poppins-Bold.ttf +0 -0
  128. package/dist/mg-components/p-2a3d8f60.entry.js +0 -1
  129. package/dist/mg-components/p-b6df1cac.js +0 -2
  130. package/dist/mg-components/p-c8779533.entry.js +0 -1
@@ -2,8 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-dd2c7f7b.js');
5
+ const index = require('./index-94497267.js');
6
6
  const index$1 = require('./index-179621c8.js');
7
+ const popper = require('./popper-11d5f714.js');
7
8
 
8
9
  /**
9
10
  * List of all possibles variants
@@ -34,6 +35,13 @@ const MgBadge = class {
34
35
  throw new Error('<mg-badge> prop "value" must be interger or ponctuation character.');
35
36
  }
36
37
  }
38
+ validateLabel(newValue) {
39
+ if (typeof newValue !== 'string' || newValue.trim() === '') {
40
+ // TODO: throw new Error on next major (5.0.0)
41
+ // throw new Error('<mg-badge> prop "label" is required.');
42
+ console.error('<mg-badge> prop "label" is required.');
43
+ }
44
+ }
37
45
  validateVariant(newValue, oldValue) {
38
46
  if (!variants$4.includes(newValue)) {
39
47
  throw new Error(`<mg-badge> prop "variant" must be one of : ${variants$4.join(', ')}.`);
@@ -58,6 +66,7 @@ const MgBadge = class {
58
66
  */
59
67
  componentWillLoad() {
60
68
  this.validateValue(this.value);
69
+ this.validateLabel(this.label);
61
70
  this.validateVariant(this.variant);
62
71
  this.validateOutline(this.outline);
63
72
  }
@@ -71,6 +80,7 @@ const MgBadge = class {
71
80
  }
72
81
  static get watchers() { return {
73
82
  "value": ["validateValue"],
83
+ "label": ["validateLabel"],
74
84
  "variant": ["validateVariant"],
75
85
  "outline": ["validateOutline"]
76
86
  }; }
@@ -95,11 +105,6 @@ const MgButton = class {
95
105
  * Define button variant
96
106
  */
97
107
  this.variant = variants$3[0]; // Primary
98
- /**
99
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
100
- * If not set, it will be created.
101
- */
102
- this.identifier = index$1.createID('mg-button');
103
108
  /**
104
109
  * Define if button is round.
105
110
  * Used for icon button.
@@ -174,7 +179,7 @@ const MgButton = class {
174
179
  this.validateVariant(this.variant);
175
180
  if (this.isIcon) {
176
181
  this.classList.add(`mg-button--icon`);
177
- if (typeof this.label !== 'string' || this.label === '') {
182
+ if (typeof this.label !== 'string' || this.label.trim() === '') {
178
183
  throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
179
184
  }
180
185
  }
@@ -792,11 +797,16 @@ const MgInput = (props, children, utils) => {
792
797
  /**
793
798
  * Check required properties
794
799
  */
795
- if (typeof props.label !== 'string' || props.label === '') {
796
- throw new Error('<mg-input> prop "label" is required');
800
+ if (typeof props.identifier !== 'string' || props.identifier.trim() === '') {
801
+ // TODO: throw new Error on next major (5.0.0)
802
+ // throw new Error('<mg-input> prop "identifier" is required.');
803
+ console.error('<mg-input> prop "identifier" is required.');
804
+ }
805
+ if (typeof props.label !== 'string' || props.label.trim() === '') {
806
+ throw new Error('<mg-input> prop "label" is required.');
797
807
  }
798
808
  if (props.labelOnTop && props.labelHide) {
799
- throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide"');
809
+ throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide".');
800
810
  }
801
811
  /**
802
812
  * Component classes
@@ -887,11 +897,6 @@ const MgInputCheckbox = class {
887
897
  ************/
888
898
  // HTML selector
889
899
  this.inputs = [];
890
- /**
891
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
892
- * If not set, it will be created.
893
- */
894
- this.identifier = index$1.createID('mg-input-checkbox');
895
900
  /**
896
901
  * Input name
897
902
  * If not set the value equals the identifier
@@ -1097,11 +1102,6 @@ const MgInputDate = class {
1097
1102
  this.inputValid = index.createEvent(this, "input-valid", 7);
1098
1103
  // hasError (triggered by blur event)
1099
1104
  this.hasError = false;
1100
- /**
1101
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1102
- * If not set, it will be created.
1103
- */
1104
- this.identifier = index$1.createID('mg-input-date');
1105
1105
  /**
1106
1106
  * Input name
1107
1107
  * If not set the value equals the identifier
@@ -1218,18 +1218,17 @@ const MgInputDate = class {
1218
1218
  };
1219
1219
  }
1220
1220
  validateValue(newValue) {
1221
- if (newValue !== undefined && newValue !== '' && !(typeof newValue === 'string' && dateRegExp.test(newValue))) {
1221
+ if (newValue !== undefined && (typeof newValue !== 'string' || !dateRegExp.test(newValue))) {
1222
1222
  throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
1223
1223
  }
1224
1224
  else {
1225
1225
  this.valueChange.emit(this.value);
1226
1226
  }
1227
1227
  }
1228
- validateMin(newValue) {
1229
- this.validateDateFormat(newValue);
1230
- }
1231
- validateMax(newValue) {
1232
- this.validateDateFormat(newValue);
1228
+ validateMinMax(newValue) {
1229
+ 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)))) {
1230
+ throw new Error("<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd");
1231
+ }
1233
1232
  }
1234
1233
  /**
1235
1234
  * Public method to display errors
@@ -1241,17 +1240,6 @@ const MgInputDate = class {
1241
1240
  this.checkError();
1242
1241
  this.hasError = this.invalid;
1243
1242
  }
1244
- /**
1245
- * Date format validation
1246
- *
1247
- * @param {string} date date to validate
1248
- * @returns {void}
1249
- */
1250
- validateDateFormat(date) {
1251
- if ((date === null || date === void 0 ? void 0 : date.length) > 0 && !(typeof date === 'string' && dateRegExp.test(date))) {
1252
- throw new Error("<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd");
1253
- }
1254
- }
1255
1243
  /*************
1256
1244
  * Lifecycle *
1257
1245
  *************/
@@ -1267,8 +1255,8 @@ const MgInputDate = class {
1267
1255
  this.messages = locales.messages;
1268
1256
  // Validate
1269
1257
  this.validateValue(this.value);
1270
- this.validateMin(this.min);
1271
- this.validateMax(this.max);
1258
+ this.validateMinMax(this.min);
1259
+ this.validateMinMax(this.max);
1272
1260
  // Check validity when component is ready
1273
1261
  // return a promise to process action only in the FIRST render().
1274
1262
  // https://stenciljs.com/docs/component-lifecycle#componentwillload
@@ -1287,8 +1275,8 @@ const MgInputDate = class {
1287
1275
  get element() { return index.getElement(this); }
1288
1276
  static get watchers() { return {
1289
1277
  "value": ["validateValue"],
1290
- "min": ["validateMin"],
1291
- "max": ["validateMax"]
1278
+ "min": ["validateMinMax"],
1279
+ "max": ["validateMinMax"]
1292
1280
  }; }
1293
1281
  };
1294
1282
  MgInputDate.style = mgInputDateCss;
@@ -1314,11 +1302,6 @@ const MgInputNumeric = class {
1314
1302
  this.inputValid = index.createEvent(this, "input-valid", 7);
1315
1303
  // hasError (triggered by blur event)
1316
1304
  this.hasError = false;
1317
- /**
1318
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1319
- * If not set, it will be created.
1320
- */
1321
- this.identifier = index$1.createID('mg-input-numeric');
1322
1305
  /**
1323
1306
  * Input name
1324
1307
  * If not set the value equals the identifier
@@ -1491,7 +1474,7 @@ const MgInputNumeric = class {
1491
1474
  // Split number and decimal
1492
1475
  const [integer, decimal = ''] = newValue.replace('-', '').split(/[\.,]/);
1493
1476
  // Regex
1494
- const regex = this.type === 'integer' ? /^[\-]?\d+$/ : /^[\-]?\d+[.,]?\d*$/;
1477
+ const regex = this.type === 'integer' ? /^-?\d+$/ : /^-?\d+[.,]?\d*$/;
1495
1478
  // Filter input
1496
1479
  if (newValue === '' || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
1497
1480
  this.storedValue = newValue;
@@ -1600,11 +1583,6 @@ const MgInputPassword = class {
1600
1583
  this.inputValid = index.createEvent(this, "input-valid", 7);
1601
1584
  // hasError (triggered by blur event)
1602
1585
  this.hasError = false;
1603
- /**
1604
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1605
- * If not set, it will be created.
1606
- */
1607
- this.identifier = index$1.createID('mg-input-password');
1608
1586
  /**
1609
1587
  * Input name
1610
1588
  * If not set the value equals the identifier
@@ -1740,11 +1718,6 @@ const MgInputRadio = class {
1740
1718
  ************/
1741
1719
  // HTML selector
1742
1720
  this.inputs = [];
1743
- /**
1744
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1745
- * If not set, it will be created.
1746
- */
1747
- this.identifier = index$1.createID('mg-input-radio');
1748
1721
  /**
1749
1722
  * Input name
1750
1723
  * If not set the value equals the identifier
@@ -1942,11 +1915,6 @@ const MgInputSelect = class {
1942
1915
  this.inputValid = index.createEvent(this, "input-valid", 7);
1943
1916
  // hasError (triggered by blur event)
1944
1917
  this.hasError = false;
1945
- /**
1946
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
1947
- * If not set, it will be created.
1948
- */
1949
- this.identifier = index$1.createID('mg-input-select');
1950
1918
  /**
1951
1919
  * Input name
1952
1920
  * If not set the value equals the identifier
@@ -2107,7 +2075,7 @@ const MgInputSelect = class {
2107
2075
  };
2108
2076
  MgInputSelect.style = mgInputSelectCss;
2109
2077
 
2110
- 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;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}";
2078
+ 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}";
2111
2079
 
2112
2080
  const MgInputText = class {
2113
2081
  constructor(hostRef) {
@@ -2123,11 +2091,6 @@ const MgInputText = class {
2123
2091
  this.classHasIcon = 'mg-input--has-icon';
2124
2092
  // hasError (triggered by blur event)
2125
2093
  this.hasError = false;
2126
- /**
2127
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2128
- * If not set, it will be created.
2129
- */
2130
- this.identifier = index$1.createID('mg-input-text');
2131
2094
  /**
2132
2095
  * Input name
2133
2096
  * If not set the value equals the identifier
@@ -2325,7 +2288,7 @@ const MgInputText = class {
2325
2288
  '--mg-character-left-message-length': (this.displayCharacterLeft
2326
2289
  ? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
2327
2290
  : 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 && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))), index.h("slot", { name: "append-input" })));
2291
+ } }, 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" })));
2329
2292
  }
2330
2293
  get element() { return index.getElement(this); }
2331
2294
  static get watchers() { return {
@@ -2350,11 +2313,6 @@ const MgInputTextarea = class {
2350
2313
  this.classHasDisplayCharacterLeft = 'mg-input--has-display-character-left';
2351
2314
  // hasError (triggered by blur event)
2352
2315
  this.hasError = false;
2353
- /**
2354
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2355
- * If not set, it will be created.
2356
- */
2357
- this.identifier = index$1.createID('mg-input-textarea');
2358
2316
  /**
2359
2317
  * Input name
2360
2318
  * If not set the value equals the identifier
@@ -2529,7 +2487,7 @@ const MgInputTextarea = class {
2529
2487
  'mg-input__box--resizable': this.resizable === 'both',
2530
2488
  'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
2531
2489
  'mg-input__box--resizable-vertical': this.resizable === 'vertical',
2532
- }, 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 && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
2490
+ }, 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 })))));
2533
2491
  }
2534
2492
  get element() { return index.getElement(this); }
2535
2493
  static get watchers() { return {
@@ -2556,6 +2514,13 @@ const MgInputTitle = class {
2556
2514
  this.tagName = this.isLegend ? 'legend' : 'label';
2557
2515
  };
2558
2516
  }
2517
+ validateIdentifier(newValue) {
2518
+ if (typeof newValue !== 'string' || newValue.trim() === '') {
2519
+ // TODO: throw new Error on next major (5.0.0)
2520
+ // throw new Error('<mg-input-title> prop "identifier" is required.');
2521
+ console.error('<mg-input-title> prop "identifier" is required.');
2522
+ }
2523
+ }
2559
2524
  /*************
2560
2525
  * Lifecycle *
2561
2526
  *************/
@@ -2565,6 +2530,7 @@ const MgInputTitle = class {
2565
2530
  * @returns {void}
2566
2531
  */
2567
2532
  componentWillLoad() {
2533
+ this.validateIdentifier(this.identifier);
2568
2534
  this.getTagName();
2569
2535
  }
2570
2536
  /**
@@ -2577,10 +2543,13 @@ const MgInputTitle = class {
2577
2543
  // \u00A0 represent a &nbsp;
2578
2544
  return (index.h(TagName, { class: "mg-input-title", htmlFor: this.isLegend ? undefined : this.identifier }, index.h("slot", null), this.required && (index.h("span", { class: "mg-input-title__required" }, "\u00A0", index.h("span", { class: "is-asterisk" }, "*")))));
2579
2545
  }
2546
+ static get watchers() { return {
2547
+ "identifier": ["validateIdentifier"]
2548
+ }; }
2580
2549
  };
2581
2550
  MgInputTitle.style = mgInputTitleCss;
2582
2551
 
2583
- const mgInputToggleCss = ":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}.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.mg-input--toggle .mg-input__input-container{flex:auto;min-width:0}.mg-input__button-toggle{display:flex;padding:0.2rem;min-width:0;background-color:hsl(var(--color-light));border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:calc((var(--font-size) * var(--line-height) + 2 * (0.7rem + var(--mg-inputs-border-width))) / var(--mg-input-toggle-border-radius-ratio));font-size:inherit;line-height:inherit;cursor:pointer}.mg-input__button-toggle:disabled{cursor:default}.mg-input__toggle-item-container{padding:0.5rem 0.9rem;border:0;box-sizing:border-box;border-radius:calc((var(--font-size) * var(--line-height) + 1rem) / var(--mg-input-toggle-border-radius-ratio));background-color:unset;font-weight:unset;color:hsl(var(--color-dark));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container{display:flex;justify-content:center;align-items:center;width:calc(var(--font-size) * var(--line-height) + 1rem);height:calc(var(--font-size) * var(--line-height) + 1rem);padding:0;visibility:hidden}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container:first-of-type{visibility:visible}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container ::slotted(mg-icon){display:flex}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{visibility:hidden}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{visibility:visible}.mg-input.mg-input--toggle-on-off .mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-dark));background-color:hsl(var(--color-dark-h), calc(var(--color-dark-s) - 30%), calc(var(--color-dark-l) + 75%))}.mg-input.mg-input--toggle-on-off.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-readonly .mg-input__button-toggle{border-color:transparent;background-color:transparent;cursor:initial}.mg-input.mg-input--toggle-readonly .mg-input__toggle-item-container:last-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{display:flex}.mg-input.mg-input--toggle-disabled .mg-input__button-toggle{opacity:0.3}";
2552
+ const mgInputToggleCss = ":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}.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.mg-input--toggle .mg-input__input-container{flex:auto;min-width:0}.mg-input__button-toggle{display:flex;padding:0.2rem;min-width:0;background-color:hsl(var(--color-light));border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:calc((var(--font-size) * var(--line-height) + 2 * (0.7rem + var(--mg-inputs-border-width))) / var(--mg-input-toggle-border-radius-ratio));font-family:var(--font-family);font-size:inherit;line-height:inherit;cursor:pointer}.mg-input__button-toggle:disabled{cursor:default}.mg-input__toggle-item-container{padding:0.5rem 0.9rem;border:0;box-sizing:border-box;border-radius:calc((var(--font-size) * var(--line-height) + 1rem) / var(--mg-input-toggle-border-radius-ratio));background-color:unset;font-weight:unset;color:hsl(var(--color-dark));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container{display:flex;justify-content:center;align-items:center;width:calc(var(--font-size) * var(--line-height) + 1rem);height:calc(var(--font-size) * var(--line-height) + 1rem);padding:0;visibility:hidden}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container:first-of-type{visibility:visible}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container ::slotted(mg-icon){display:flex}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{visibility:hidden}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{visibility:visible}.mg-input.mg-input--toggle-on-off .mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-dark));background-color:hsl(var(--color-dark-h), calc(var(--color-dark-s) - 30%), calc(var(--color-dark-l) + 75%))}.mg-input.mg-input--toggle-on-off.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-readonly .mg-input__button-toggle{border-color:transparent;background-color:transparent;cursor:initial}.mg-input.mg-input--toggle-readonly .mg-input__toggle-item-container:last-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{display:flex}.mg-input.mg-input--toggle-disabled .mg-input__button-toggle{opacity:0.3}";
2584
2553
 
2585
2554
  /**
2586
2555
  * type Option validation function
@@ -2603,11 +2572,6 @@ const MgInputToggle = class {
2603
2572
  this.classIsActive = 'mg-input--toggle-is-active';
2604
2573
  this.classOnOff = 'mg-input--toggle-on-off';
2605
2574
  this.classIcon = 'mg-input--toggle-icon';
2606
- /**
2607
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
2608
- * If not set, it will be created.
2609
- */
2610
- this.identifier = index$1.createID('mg-input-toggle');
2611
2575
  /**
2612
2576
  * Input name
2613
2577
  * If not set the value equals the identifier
@@ -2945,7 +2909,7 @@ var NavigationAction;
2945
2909
  NavigationAction["PREVIOUS"] = "previous";
2946
2910
  })(NavigationAction || (NavigationAction = {}));
2947
2911
 
2948
- const mgPaginationCss = ".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-pagination__nav{display:flex;align-items:center;flex-direction:row}.mg-pagination__nav mg-input-select{margin-right:0.5rem}.mg-pagination__button{display:flex}.mg-pagination__button:first-of-type{margin-right:1rem}.mg-pagination__button:last-of-type{margin-left:1rem}";
2912
+ const mgPaginationCss = ".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-pagination{display:flex;align-items:center;flex-direction:row}.mg-pagination mg-input-select{margin-right:0.5rem}.mg-pagination mg-button{display:flex}.mg-pagination mg-button:first-of-type{margin-right:1rem}.mg-pagination mg-button:last-of-type{margin-left:1rem}";
2949
2913
 
2950
2914
  /**
2951
2915
  * Range generator
@@ -3056,10 +3020,10 @@ const MgPagination = class {
3056
3020
  * @returns {HTMLElement} HTML Element
3057
3021
  */
3058
3022
  render() {
3059
- const navigationActionButton = (disabled, action) => (index.h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: this.messages.pagination[`${action}Page`],
3023
+ const navigationActionButton = (disabled, action) => (index.h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
3060
3024
  // eslint-disable-next-line react/jsx-no-bind
3061
3025
  onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" }, action === NavigationAction.PREVIOUS && index.h("mg-icon", { icon: "chevron-left" }), this.messages.general[action], action === NavigationAction.NEXT && index.h("mg-icon", { icon: "chevron-right" })));
3062
- return (index.h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination__nav" }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), index.h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), index.h("span", { class: "sr-only" }, this.messages.pagination.page, " ", this.currentPage), index.h("span", null, "/ ", this.totalPages, " ", this.totalPages > 1 ? this.messages.pagination.pages : this.messages.pagination.page), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
3026
+ return (index.h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination" }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), index.h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), index.h("span", { class: "sr-only" }, this.messages.pagination.page, " ", this.currentPage), index.h("span", null, "/ ", this.totalPages, " ", this.totalPages > 1 ? this.messages.pagination.pages : this.messages.pagination.page), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
3063
3027
  }
3064
3028
  get element() { return index.getElement(this); }
3065
3029
  static get watchers() { return {
@@ -3069,7 +3033,7 @@ const MgPagination = class {
3069
3033
  };
3070
3034
  MgPagination.style = mgPaginationCss;
3071
3035
 
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{flex:1 auto}.mg-panel__header-left mg-input-text{flex-grow:1}.mg-panel__header-left mg-button:not([slot=append-input]){margin:0 0.3rem 0 0}.mg-panel__header-left mg-button:not([slot=append-input])>*:first-of-type{font-family:var(--font-family-heading);font-size:1.4rem;font-weight:500}.mg-panel__content{padding:1.5rem}.mg-panel ::slotted([slot=header-right]){display:flex;flex-wrap:wrap;gap:1rem;margin-left:auto}";
3036
+ 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{flex:1 auto}.mg-panel__header-left mg-input-text{flex-grow:1}.mg-panel__header-left mg-button:not([slot=append-input]){margin:0 0.3rem 0 0}.mg-panel__header-left mg-button:not([slot=append-input])>*:first-of-type{font-family:var(--font-family-heading);font-size:1.4rem;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
3037
 
3074
3038
  const MgPanel = class {
3075
3039
  constructor(hostRef) {
@@ -3182,14 +3146,19 @@ const MgPanel = class {
3182
3146
  return collapseButton();
3183
3147
  };
3184
3148
  }
3185
- handelTileChange(newValue) {
3149
+ validatePanelTitle(newValue) {
3150
+ if (typeof newValue !== 'string' || newValue.trim() === '') {
3151
+ // TODO: throw new Error on next major (5.0.0)
3152
+ // throw new Error('<mg-panel> prop "panelTitle" is required.');
3153
+ console.error('<mg-panel> prop "panelTitle" is required.');
3154
+ }
3186
3155
  this.titleChange.emit(newValue);
3187
3156
  }
3188
3157
  validatetitlePattern(newValue) {
3189
3158
  if (newValue && !this.titleEditable) {
3190
3159
  throw new Error('<mg-panel> prop "titleEditable" must be set to `true`.');
3191
3160
  }
3192
- if (newValue && this.titlePatternErrorMessage === undefined) {
3161
+ if (newValue && (this.titlePatternErrorMessage === undefined || this.titlePatternErrorMessage.trim() === '')) {
3193
3162
  throw new Error('<mg-panel> prop "titlePattern" must be paired with the prop "titlePatternErrorMessage".');
3194
3163
  }
3195
3164
  }
@@ -3209,6 +3178,7 @@ const MgPanel = class {
3209
3178
  this.messages = index$1.initLocales(this.element).messages;
3210
3179
  // Validate
3211
3180
  this.validatetitlePattern(this.titlePattern);
3181
+ this.validatePanelTitle(this.panelTitle);
3212
3182
  }
3213
3183
  /**
3214
3184
  * Edit DOM after render
@@ -3231,2111 +3201,169 @@ const MgPanel = class {
3231
3201
  }
3232
3202
  get element() { return index.getElement(this); }
3233
3203
  static get watchers() { return {
3234
- "panelTitle": ["handelTileChange"],
3204
+ "panelTitle": ["validatePanelTitle"],
3235
3205
  "titlePattern": ["validatetitlePattern"],
3236
3206
  "expanded": ["handleExpanded"]
3237
3207
  }; }
3238
3208
  };
3239
3209
  MgPanel.style = mgPanelCss;
3240
3210
 
3241
- var top = 'top';
3242
- var bottom = 'bottom';
3243
- var right = 'right';
3244
- var left = 'left';
3245
- var auto = 'auto';
3246
- var basePlacements = [top, bottom, right, left];
3247
- var start = 'start';
3248
- var end = 'end';
3249
- var clippingParents = 'clippingParents';
3250
- var viewport = 'viewport';
3251
- var popper = 'popper';
3252
- var reference = 'reference';
3253
- var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
3254
- return acc.concat([placement + "-" + start, placement + "-" + end]);
3255
- }, []);
3256
- var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
3257
- return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
3258
- }, []); // modifiers that need to read the DOM
3259
-
3260
- var beforeRead = 'beforeRead';
3261
- var read = 'read';
3262
- var afterRead = 'afterRead'; // pure-logic modifiers
3263
-
3264
- var beforeMain = 'beforeMain';
3265
- var main = 'main';
3266
- var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
3267
-
3268
- var beforeWrite = 'beforeWrite';
3269
- var write = 'write';
3270
- var afterWrite = 'afterWrite';
3271
- var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
3272
-
3273
- function getNodeName(element) {
3274
- return element ? (element.nodeName || '').toLowerCase() : null;
3275
- }
3276
-
3277
- function getWindow(node) {
3278
- if (node == null) {
3279
- return window;
3280
- }
3281
-
3282
- if (node.toString() !== '[object Window]') {
3283
- var ownerDocument = node.ownerDocument;
3284
- return ownerDocument ? ownerDocument.defaultView || window : window;
3285
- }
3286
-
3287
- return node;
3288
- }
3289
-
3290
- function isElement(node) {
3291
- var OwnElement = getWindow(node).Element;
3292
- return node instanceof OwnElement || node instanceof Element;
3293
- }
3294
-
3295
- function isHTMLElement(node) {
3296
- var OwnElement = getWindow(node).HTMLElement;
3297
- return node instanceof OwnElement || node instanceof HTMLElement;
3298
- }
3299
-
3300
- function isShadowRoot(node) {
3301
- // IE 11 has no ShadowRoot
3302
- if (typeof ShadowRoot === 'undefined') {
3303
- return false;
3304
- }
3305
-
3306
- var OwnElement = getWindow(node).ShadowRoot;
3307
- return node instanceof OwnElement || node instanceof ShadowRoot;
3308
- }
3309
-
3310
- // and applies them to the HTMLElements such as popper and arrow
3311
-
3312
- function applyStyles(_ref) {
3313
- var state = _ref.state;
3314
- Object.keys(state.elements).forEach(function (name) {
3315
- var style = state.styles[name] || {};
3316
- var attributes = state.attributes[name] || {};
3317
- var element = state.elements[name]; // arrow is optional + virtual elements
3318
-
3319
- if (!isHTMLElement(element) || !getNodeName(element)) {
3320
- return;
3321
- } // Flow doesn't support to extend this property, but it's the most
3322
- // effective way to apply styles to an HTMLElement
3323
- // $FlowFixMe[cannot-write]
3324
-
3211
+ var Status;
3212
+ (function (Status) {
3213
+ Status["VISIBLE"] = "visible";
3214
+ Status["HIDDEN"] = "hidden";
3215
+ Status["DISABLED"] = "disabled";
3216
+ Status["ACTIVE"] = "active";
3217
+ })(Status || (Status = {}));
3218
+ /**
3219
+ * List of all possibles sizes
3220
+ */
3221
+ const sizes = ['regular', 'large'];
3325
3222
 
3326
- Object.assign(element.style, style);
3327
- Object.keys(attributes).forEach(function (name) {
3328
- var value = attributes[name];
3223
+ const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button{padding:calc(1rem + 0.3rem) calc(1rem * 1.3) 1rem}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button{padding:calc(1.8rem + 0.3rem) calc(1.8rem * 1.3) 1.8rem}.mg-tabs__header{display:flex;flex-direction:row;flex-wrap:wrap}.mg-tabs__navigation-button{display:flex;align-items:center;column-gap:0.5rem;background:none;border:none;border-bottom:0.3rem solid transparent;font-family:var(--font-family);color:hsl(var(--color-dark));line-height:var(--line-height);cursor:pointer}.mg-tabs__navigation-button:disabled,.mg-tabs__navigation-button--disabled{cursor:default;opacity:30%}.mg-tabs__navigation-button:hover:not(:disabled),.mg-tabs__navigation-button:focus:not(:disabled){background-color:hsla(var(--color-info-h), var(--color-info-s), var(--color-info-l), 10%)}.mg-tabs__navigation-button.mg-tabs__navigation-button--active{color:hsl(var(--color-info));border-bottom-color:hsl(var(--color-info));font-weight:700}.mg-tabs__navigation-button.mg-tabs__navigation-button--hidden{display:none}.mg-tabs__content-container:focus-visible{outline:none}";
3329
3224
 
3330
- if (value === false) {
3331
- element.removeAttribute(name);
3332
- } else {
3333
- element.setAttribute(name, value === true ? '' : value);
3225
+ /**
3226
+ * type TabItem validation function
3227
+ *
3228
+ * @param {TabItem} tab tab item
3229
+ * @returns {boolean} tab item type is valid
3230
+ */
3231
+ const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
3232
+ const MgTabs = class {
3233
+ constructor(hostRef) {
3234
+ index.registerInstance(this, hostRef);
3235
+ this.activeTabChange = index.createEvent(this, "active-tab-change", 7);
3236
+ /************
3237
+ * Internal *
3238
+ ************/
3239
+ this.tabPanel = 'panel';
3240
+ this.startIndex = 1;
3241
+ this.buttonTabBaseClass = 'mg-tabs__navigation-button';
3242
+ /**
3243
+ * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
3244
+ * If not set, it will be created.
3245
+ */
3246
+ this.identifier = index$1.createID('mg-tabs');
3247
+ /**
3248
+ * Define tabs size
3249
+ */
3250
+ this.size = 'regular';
3251
+ /**
3252
+ * Active tab number
3253
+ * default: first is 1
3254
+ */
3255
+ this.activeTab = 1;
3256
+ /**
3257
+ * Component tabs
3258
+ */
3259
+ this.tabs = [];
3260
+ /**
3261
+ * Component classes
3262
+ */
3263
+ this.classList = new index$1.ClassList(['mg-tabs']);
3264
+ /**
3265
+ * Method to set active tab
3266
+ *
3267
+ * @param {number} tabKey item tab key to set to ACTIVE status
3268
+ * @returns {void}
3269
+ */
3270
+ this.setActiveTab = (tabKey) => {
3271
+ // reset active tabs
3272
+ this.tabs.forEach(tab => {
3273
+ if (this.tabHasGivenStatus(tab, Status.ACTIVE))
3274
+ tab.status = Status.VISIBLE;
3275
+ });
3276
+ // set active tab from given tab key
3277
+ this.tabs[tabKey - this.startIndex].status = Status.ACTIVE;
3278
+ // emit change active tab key event
3279
+ this.activeTabChange.emit(tabKey);
3280
+ };
3281
+ /**
3282
+ * Method to know if given tab has the given status
3283
+ *
3284
+ * @param {TabItem} tab item tab key to set to ACTIVE status
3285
+ * @param {Status} status status to valide
3286
+ * @returns {boolean} status comparaison
3287
+ */
3288
+ this.tabHasGivenStatus = (tab, status) => tab.status === status;
3289
+ /**
3290
+ * Method to get element id from index
3291
+ *
3292
+ * @param {string} element to get id
3293
+ * @param {number} index to generate id
3294
+ * @returns {string} generated element id
3295
+ */
3296
+ this.getElementId = (element, index) => `${element}-${this.getTabIndex(index)}`;
3297
+ /**
3298
+ * Method to get tab index
3299
+ *
3300
+ * @param {number} index to get
3301
+ * @returns {number} index
3302
+ */
3303
+ this.getTabIndex = (index) => index + this.startIndex;
3304
+ /**
3305
+ * Handle click events on tabs
3306
+ *
3307
+ * @param {MouseEvent} event mouse event
3308
+ */
3309
+ this.handleClick = (event) => {
3310
+ const tabId = event.currentTarget.getAttribute('data-index');
3311
+ this.activeTab = Number(tabId);
3312
+ };
3313
+ /**
3314
+ * get navigation button class from given status
3315
+ *
3316
+ * @param {Status} status button tab status
3317
+ * @param {boolean} isSelector set if we need a CSS selector with the dot '.' at the begin. default value = false.
3318
+ * @returns {string} button class/selector variant
3319
+ */
3320
+ this.getNavigationButtonClass = (status, isSelector = false) => `${isSelector ? '.' : ''}${this.buttonTabBaseClass}--${status}`;
3321
+ /**
3322
+ * Handle keyboard event on tabs
3323
+ *
3324
+ * @param {MouseEvent} event mouse event
3325
+ * @returns {void}
3326
+ */
3327
+ this.handleKeydown = (event) => {
3328
+ let tabId = Number(event.target.getAttribute('data-index'));
3329
+ const parent = event.target.parentElement;
3330
+ // change selected id from key code
3331
+ if (event.key === 'ArrowRight') {
3332
+ tabId++;
3334
3333
  }
3335
- });
3336
- });
3337
- }
3338
-
3339
- function effect$2(_ref2) {
3340
- var state = _ref2.state;
3341
- var initialStyles = {
3342
- popper: {
3343
- position: state.options.strategy,
3344
- left: '0',
3345
- top: '0',
3346
- margin: '0'
3347
- },
3348
- arrow: {
3349
- position: 'absolute'
3350
- },
3351
- reference: {}
3352
- };
3353
- Object.assign(state.elements.popper.style, initialStyles.popper);
3354
- state.styles = initialStyles;
3355
-
3356
- if (state.elements.arrow) {
3357
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
3358
- }
3359
-
3360
- return function () {
3361
- Object.keys(state.elements).forEach(function (name) {
3362
- var element = state.elements[name];
3363
- var attributes = state.attributes[name] || {};
3364
- var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
3365
-
3366
- var style = styleProperties.reduce(function (style, property) {
3367
- style[property] = '';
3368
- return style;
3369
- }, {}); // arrow is optional + virtual elements
3370
-
3371
- if (!isHTMLElement(element) || !getNodeName(element)) {
3372
- return;
3334
+ else if (event.key === 'ArrowLeft') {
3335
+ tabId--;
3373
3336
  }
3374
-
3375
- Object.assign(element.style, style);
3376
- Object.keys(attributes).forEach(function (attribute) {
3377
- element.removeAttribute(attribute);
3378
- });
3379
- });
3380
- };
3381
- } // eslint-disable-next-line import/no-unused-modules
3382
-
3383
-
3384
- const applyStyles$1 = {
3385
- name: 'applyStyles',
3386
- enabled: true,
3387
- phase: 'write',
3388
- fn: applyStyles,
3389
- effect: effect$2,
3390
- requires: ['computeStyles']
3391
- };
3392
-
3393
- function getBasePlacement(placement) {
3394
- return placement.split('-')[0];
3395
- }
3396
-
3397
- var max = Math.max;
3398
- var min = Math.min;
3399
- var round = Math.round;
3400
-
3401
- function getBoundingClientRect(element, includeScale) {
3402
- if (includeScale === void 0) {
3403
- includeScale = false;
3337
+ // get selected tab if NOT hidden, disabled
3338
+ const selectedTab = parent.querySelector(`[data-index="${tabId}"]:not(${[this.getNavigationButtonClass(Status.HIDDEN, true), this.getNavigationButtonClass(Status.DISABLED, true)].join()})`);
3339
+ // apply selected tab if exist
3340
+ if (selectedTab !== null) {
3341
+ selectedTab.focus();
3342
+ this.activeTab = tabId;
3343
+ }
3344
+ };
3345
+ /**
3346
+ * Validate slots setting
3347
+ */
3348
+ this.validateSlots = () => {
3349
+ const slots = Array.from(this.element.children).filter(slot => { var _a; return (_a = slot.getAttribute('slot')) === null || _a === void 0 ? void 0 : _a.includes('tab_content-'); });
3350
+ if (slots.length !== this.tabs.length) {
3351
+ throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
3352
+ }
3353
+ };
3404
3354
  }
3405
-
3406
- var rect = element.getBoundingClientRect();
3407
- var scaleX = 1;
3408
- var scaleY = 1;
3409
-
3410
- if (isHTMLElement(element) && includeScale) {
3411
- var offsetHeight = element.offsetHeight;
3412
- var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
3413
- // Fallback to 1 in case both values are `0`
3414
-
3415
- if (offsetWidth > 0) {
3416
- scaleX = round(rect.width) / offsetWidth || 1;
3355
+ validateLabel(newValue) {
3356
+ if (typeof newValue !== 'string' || newValue.trim() === '') {
3357
+ // TODO: throw new Error on next major (5.0.0)
3358
+ // throw new Error('<mg-tabs> prop "label" is required.');
3359
+ console.error('<mg-tabs> prop "label" is required.');
3417
3360
  }
3418
-
3419
- if (offsetHeight > 0) {
3420
- scaleY = round(rect.height) / offsetHeight || 1;
3421
- }
3422
- }
3423
-
3424
- return {
3425
- width: rect.width / scaleX,
3426
- height: rect.height / scaleY,
3427
- top: rect.top / scaleY,
3428
- right: rect.right / scaleX,
3429
- bottom: rect.bottom / scaleY,
3430
- left: rect.left / scaleX,
3431
- x: rect.left / scaleX,
3432
- y: rect.top / scaleY
3433
- };
3434
- }
3435
-
3436
- // means it doesn't take into account transforms.
3437
-
3438
- function getLayoutRect(element) {
3439
- var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
3440
- // Fixes https://github.com/popperjs/popper-core/issues/1223
3441
-
3442
- var width = element.offsetWidth;
3443
- var height = element.offsetHeight;
3444
-
3445
- if (Math.abs(clientRect.width - width) <= 1) {
3446
- width = clientRect.width;
3447
3361
  }
3448
-
3449
- if (Math.abs(clientRect.height - height) <= 1) {
3450
- height = clientRect.height;
3451
- }
3452
-
3453
- return {
3454
- x: element.offsetLeft,
3455
- y: element.offsetTop,
3456
- width: width,
3457
- height: height
3458
- };
3459
- }
3460
-
3461
- function contains(parent, child) {
3462
- var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
3463
-
3464
- if (parent.contains(child)) {
3465
- return true;
3466
- } // then fallback to custom implementation with Shadow DOM support
3467
- else if (rootNode && isShadowRoot(rootNode)) {
3468
- var next = child;
3469
-
3470
- do {
3471
- if (next && parent.isSameNode(next)) {
3472
- return true;
3473
- } // $FlowFixMe[prop-missing]: need a better way to handle this...
3474
-
3475
-
3476
- next = next.parentNode || next.host;
3477
- } while (next);
3478
- } // Give up, the result is false
3479
-
3480
-
3481
- return false;
3482
- }
3483
-
3484
- function getComputedStyle(element) {
3485
- return getWindow(element).getComputedStyle(element);
3486
- }
3487
-
3488
- function isTableElement(element) {
3489
- return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
3490
- }
3491
-
3492
- function getDocumentElement(element) {
3493
- // $FlowFixMe[incompatible-return]: assume body is always available
3494
- return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
3495
- element.document) || window.document).documentElement;
3496
- }
3497
-
3498
- function getParentNode(element) {
3499
- if (getNodeName(element) === 'html') {
3500
- return element;
3501
- }
3502
-
3503
- return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
3504
- // $FlowFixMe[incompatible-return]
3505
- // $FlowFixMe[prop-missing]
3506
- element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
3507
- element.parentNode || ( // DOM Element detected
3508
- isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
3509
- // $FlowFixMe[incompatible-call]: HTMLElement is a Node
3510
- getDocumentElement(element) // fallback
3511
-
3512
- );
3513
- }
3514
-
3515
- function getTrueOffsetParent(element) {
3516
- if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
3517
- getComputedStyle(element).position === 'fixed') {
3518
- return null;
3519
- }
3520
-
3521
- return element.offsetParent;
3522
- } // `.offsetParent` reports `null` for fixed elements, while absolute elements
3523
- // return the containing block
3524
-
3525
-
3526
- function getContainingBlock(element) {
3527
- var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
3528
- var isIE = navigator.userAgent.indexOf('Trident') !== -1;
3529
-
3530
- if (isIE && isHTMLElement(element)) {
3531
- // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
3532
- var elementCss = getComputedStyle(element);
3533
-
3534
- if (elementCss.position === 'fixed') {
3535
- return null;
3536
- }
3537
- }
3538
-
3539
- var currentNode = getParentNode(element);
3540
-
3541
- if (isShadowRoot(currentNode)) {
3542
- currentNode = currentNode.host;
3543
- }
3544
-
3545
- while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
3546
- var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
3547
- // create a containing block.
3548
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
3549
-
3550
- if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
3551
- return currentNode;
3552
- } else {
3553
- currentNode = currentNode.parentNode;
3554
- }
3555
- }
3556
-
3557
- return null;
3558
- } // Gets the closest ancestor positioned element. Handles some edge cases,
3559
- // such as table ancestors and cross browser bugs.
3560
-
3561
-
3562
- function getOffsetParent(element) {
3563
- var window = getWindow(element);
3564
- var offsetParent = getTrueOffsetParent(element);
3565
-
3566
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
3567
- offsetParent = getTrueOffsetParent(offsetParent);
3568
- }
3569
-
3570
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
3571
- return window;
3572
- }
3573
-
3574
- return offsetParent || getContainingBlock(element) || window;
3575
- }
3576
-
3577
- function getMainAxisFromPlacement(placement) {
3578
- return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
3579
- }
3580
-
3581
- function within(min$1, value, max$1) {
3582
- return max(min$1, min(value, max$1));
3583
- }
3584
- function withinMaxClamp(min, value, max) {
3585
- var v = within(min, value, max);
3586
- return v > max ? max : v;
3587
- }
3588
-
3589
- function getFreshSideObject() {
3590
- return {
3591
- top: 0,
3592
- right: 0,
3593
- bottom: 0,
3594
- left: 0
3595
- };
3596
- }
3597
-
3598
- function mergePaddingObject(paddingObject) {
3599
- return Object.assign({}, getFreshSideObject(), paddingObject);
3600
- }
3601
-
3602
- function expandToHashMap(value, keys) {
3603
- return keys.reduce(function (hashMap, key) {
3604
- hashMap[key] = value;
3605
- return hashMap;
3606
- }, {});
3607
- }
3608
-
3609
- var toPaddingObject = function toPaddingObject(padding, state) {
3610
- padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
3611
- placement: state.placement
3612
- })) : padding;
3613
- return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
3614
- };
3615
-
3616
- function arrow(_ref) {
3617
- var _state$modifiersData$;
3618
-
3619
- var state = _ref.state,
3620
- name = _ref.name,
3621
- options = _ref.options;
3622
- var arrowElement = state.elements.arrow;
3623
- var popperOffsets = state.modifiersData.popperOffsets;
3624
- var basePlacement = getBasePlacement(state.placement);
3625
- var axis = getMainAxisFromPlacement(basePlacement);
3626
- var isVertical = [left, right].indexOf(basePlacement) >= 0;
3627
- var len = isVertical ? 'height' : 'width';
3628
-
3629
- if (!arrowElement || !popperOffsets) {
3630
- return;
3631
- }
3632
-
3633
- var paddingObject = toPaddingObject(options.padding, state);
3634
- var arrowRect = getLayoutRect(arrowElement);
3635
- var minProp = axis === 'y' ? top : left;
3636
- var maxProp = axis === 'y' ? bottom : right;
3637
- var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
3638
- var startDiff = popperOffsets[axis] - state.rects.reference[axis];
3639
- var arrowOffsetParent = getOffsetParent(arrowElement);
3640
- var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
3641
- var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
3642
- // outside of the popper bounds
3643
-
3644
- var min = paddingObject[minProp];
3645
- var max = clientSize - arrowRect[len] - paddingObject[maxProp];
3646
- var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
3647
- var offset = within(min, center, max); // Prevents breaking syntax highlighting...
3648
-
3649
- var axisProp = axis;
3650
- state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
3651
- }
3652
-
3653
- function effect$1(_ref2) {
3654
- var state = _ref2.state,
3655
- options = _ref2.options;
3656
- var _options$element = options.element,
3657
- arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
3658
-
3659
- if (arrowElement == null) {
3660
- return;
3661
- } // CSS selector
3662
-
3663
-
3664
- if (typeof arrowElement === 'string') {
3665
- arrowElement = state.elements.popper.querySelector(arrowElement);
3666
-
3667
- if (!arrowElement) {
3668
- return;
3669
- }
3670
- }
3671
-
3672
- if (!contains(state.elements.popper, arrowElement)) {
3673
-
3674
- return;
3675
- }
3676
-
3677
- state.elements.arrow = arrowElement;
3678
- } // eslint-disable-next-line import/no-unused-modules
3679
-
3680
-
3681
- const arrow$1 = {
3682
- name: 'arrow',
3683
- enabled: true,
3684
- phase: 'main',
3685
- fn: arrow,
3686
- effect: effect$1,
3687
- requires: ['popperOffsets'],
3688
- requiresIfExists: ['preventOverflow']
3689
- };
3690
-
3691
- function getVariation(placement) {
3692
- return placement.split('-')[1];
3693
- }
3694
-
3695
- var unsetSides = {
3696
- top: 'auto',
3697
- right: 'auto',
3698
- bottom: 'auto',
3699
- left: 'auto'
3700
- }; // Round the offsets to the nearest suitable subpixel based on the DPR.
3701
- // Zooming can change the DPR, but it seems to report a value that will
3702
- // cleanly divide the values into the appropriate subpixels.
3703
-
3704
- function roundOffsetsByDPR(_ref) {
3705
- var x = _ref.x,
3706
- y = _ref.y;
3707
- var win = window;
3708
- var dpr = win.devicePixelRatio || 1;
3709
- return {
3710
- x: round(x * dpr) / dpr || 0,
3711
- y: round(y * dpr) / dpr || 0
3712
- };
3713
- }
3714
-
3715
- function mapToStyles(_ref2) {
3716
- var _Object$assign2;
3717
-
3718
- var popper = _ref2.popper,
3719
- popperRect = _ref2.popperRect,
3720
- placement = _ref2.placement,
3721
- variation = _ref2.variation,
3722
- offsets = _ref2.offsets,
3723
- position = _ref2.position,
3724
- gpuAcceleration = _ref2.gpuAcceleration,
3725
- adaptive = _ref2.adaptive,
3726
- roundOffsets = _ref2.roundOffsets,
3727
- isFixed = _ref2.isFixed;
3728
- var _offsets$x = offsets.x,
3729
- x = _offsets$x === void 0 ? 0 : _offsets$x,
3730
- _offsets$y = offsets.y,
3731
- y = _offsets$y === void 0 ? 0 : _offsets$y;
3732
-
3733
- var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
3734
- x: x,
3735
- y: y
3736
- }) : {
3737
- x: x,
3738
- y: y
3739
- };
3740
-
3741
- x = _ref3.x;
3742
- y = _ref3.y;
3743
- var hasX = offsets.hasOwnProperty('x');
3744
- var hasY = offsets.hasOwnProperty('y');
3745
- var sideX = left;
3746
- var sideY = top;
3747
- var win = window;
3748
-
3749
- if (adaptive) {
3750
- var offsetParent = getOffsetParent(popper);
3751
- var heightProp = 'clientHeight';
3752
- var widthProp = 'clientWidth';
3753
-
3754
- if (offsetParent === getWindow(popper)) {
3755
- offsetParent = getDocumentElement(popper);
3756
-
3757
- if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
3758
- heightProp = 'scrollHeight';
3759
- widthProp = 'scrollWidth';
3760
- }
3761
- } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
3762
-
3763
-
3764
- offsetParent = offsetParent;
3765
-
3766
- if (placement === top || (placement === left || placement === right) && variation === end) {
3767
- sideY = bottom;
3768
- var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
3769
- offsetParent[heightProp];
3770
- y -= offsetY - popperRect.height;
3771
- y *= gpuAcceleration ? 1 : -1;
3772
- }
3773
-
3774
- if (placement === left || (placement === top || placement === bottom) && variation === end) {
3775
- sideX = right;
3776
- var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
3777
- offsetParent[widthProp];
3778
- x -= offsetX - popperRect.width;
3779
- x *= gpuAcceleration ? 1 : -1;
3780
- }
3781
- }
3782
-
3783
- var commonStyles = Object.assign({
3784
- position: position
3785
- }, adaptive && unsetSides);
3786
-
3787
- var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
3788
- x: x,
3789
- y: y
3790
- }) : {
3791
- x: x,
3792
- y: y
3793
- };
3794
-
3795
- x = _ref4.x;
3796
- y = _ref4.y;
3797
-
3798
- if (gpuAcceleration) {
3799
- var _Object$assign;
3800
-
3801
- return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
3802
- }
3803
-
3804
- return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
3805
- }
3806
-
3807
- function computeStyles(_ref5) {
3808
- var state = _ref5.state,
3809
- options = _ref5.options;
3810
- var _options$gpuAccelerat = options.gpuAcceleration,
3811
- gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
3812
- _options$adaptive = options.adaptive,
3813
- adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
3814
- _options$roundOffsets = options.roundOffsets,
3815
- roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
3816
-
3817
- var commonStyles = {
3818
- placement: getBasePlacement(state.placement),
3819
- variation: getVariation(state.placement),
3820
- popper: state.elements.popper,
3821
- popperRect: state.rects.popper,
3822
- gpuAcceleration: gpuAcceleration,
3823
- isFixed: state.options.strategy === 'fixed'
3824
- };
3825
-
3826
- if (state.modifiersData.popperOffsets != null) {
3827
- state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
3828
- offsets: state.modifiersData.popperOffsets,
3829
- position: state.options.strategy,
3830
- adaptive: adaptive,
3831
- roundOffsets: roundOffsets
3832
- })));
3833
- }
3834
-
3835
- if (state.modifiersData.arrow != null) {
3836
- state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
3837
- offsets: state.modifiersData.arrow,
3838
- position: 'absolute',
3839
- adaptive: false,
3840
- roundOffsets: roundOffsets
3841
- })));
3842
- }
3843
-
3844
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
3845
- 'data-popper-placement': state.placement
3846
- });
3847
- } // eslint-disable-next-line import/no-unused-modules
3848
-
3849
-
3850
- const computeStyles$1 = {
3851
- name: 'computeStyles',
3852
- enabled: true,
3853
- phase: 'beforeWrite',
3854
- fn: computeStyles,
3855
- data: {}
3856
- };
3857
-
3858
- var passive = {
3859
- passive: true
3860
- };
3861
-
3862
- function effect(_ref) {
3863
- var state = _ref.state,
3864
- instance = _ref.instance,
3865
- options = _ref.options;
3866
- var _options$scroll = options.scroll,
3867
- scroll = _options$scroll === void 0 ? true : _options$scroll,
3868
- _options$resize = options.resize,
3869
- resize = _options$resize === void 0 ? true : _options$resize;
3870
- var window = getWindow(state.elements.popper);
3871
- var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
3872
-
3873
- if (scroll) {
3874
- scrollParents.forEach(function (scrollParent) {
3875
- scrollParent.addEventListener('scroll', instance.update, passive);
3876
- });
3877
- }
3878
-
3879
- if (resize) {
3880
- window.addEventListener('resize', instance.update, passive);
3881
- }
3882
-
3883
- return function () {
3884
- if (scroll) {
3885
- scrollParents.forEach(function (scrollParent) {
3886
- scrollParent.removeEventListener('scroll', instance.update, passive);
3887
- });
3888
- }
3889
-
3890
- if (resize) {
3891
- window.removeEventListener('resize', instance.update, passive);
3892
- }
3893
- };
3894
- } // eslint-disable-next-line import/no-unused-modules
3895
-
3896
-
3897
- const eventListeners = {
3898
- name: 'eventListeners',
3899
- enabled: true,
3900
- phase: 'write',
3901
- fn: function fn() {},
3902
- effect: effect,
3903
- data: {}
3904
- };
3905
-
3906
- var hash$1 = {
3907
- left: 'right',
3908
- right: 'left',
3909
- bottom: 'top',
3910
- top: 'bottom'
3911
- };
3912
- function getOppositePlacement(placement) {
3913
- return placement.replace(/left|right|bottom|top/g, function (matched) {
3914
- return hash$1[matched];
3915
- });
3916
- }
3917
-
3918
- var hash = {
3919
- start: 'end',
3920
- end: 'start'
3921
- };
3922
- function getOppositeVariationPlacement(placement) {
3923
- return placement.replace(/start|end/g, function (matched) {
3924
- return hash[matched];
3925
- });
3926
- }
3927
-
3928
- function getWindowScroll(node) {
3929
- var win = getWindow(node);
3930
- var scrollLeft = win.pageXOffset;
3931
- var scrollTop = win.pageYOffset;
3932
- return {
3933
- scrollLeft: scrollLeft,
3934
- scrollTop: scrollTop
3935
- };
3936
- }
3937
-
3938
- function getWindowScrollBarX(element) {
3939
- // If <html> has a CSS width greater than the viewport, then this will be
3940
- // incorrect for RTL.
3941
- // Popper 1 is broken in this case and never had a bug report so let's assume
3942
- // it's not an issue. I don't think anyone ever specifies width on <html>
3943
- // anyway.
3944
- // Browsers where the left scrollbar doesn't cause an issue report `0` for
3945
- // this (e.g. Edge 2019, IE11, Safari)
3946
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
3947
- }
3948
-
3949
- function getViewportRect(element) {
3950
- var win = getWindow(element);
3951
- var html = getDocumentElement(element);
3952
- var visualViewport = win.visualViewport;
3953
- var width = html.clientWidth;
3954
- var height = html.clientHeight;
3955
- var x = 0;
3956
- var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
3957
- // can be obscured underneath it.
3958
- // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
3959
- // if it isn't open, so if this isn't available, the popper will be detected
3960
- // to overflow the bottom of the screen too early.
3961
-
3962
- if (visualViewport) {
3963
- width = visualViewport.width;
3964
- height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
3965
- // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
3966
- // errors due to floating point numbers, so we need to check precision.
3967
- // Safari returns a number <= 0, usually < -1 when pinch-zoomed
3968
- // Feature detection fails in mobile emulation mode in Chrome.
3969
- // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
3970
- // 0.001
3971
- // Fallback here: "Not Safari" userAgent
3972
-
3973
- if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
3974
- x = visualViewport.offsetLeft;
3975
- y = visualViewport.offsetTop;
3976
- }
3977
- }
3978
-
3979
- return {
3980
- width: width,
3981
- height: height,
3982
- x: x + getWindowScrollBarX(element),
3983
- y: y
3984
- };
3985
- }
3986
-
3987
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
3988
-
3989
- function getDocumentRect(element) {
3990
- var _element$ownerDocumen;
3991
-
3992
- var html = getDocumentElement(element);
3993
- var winScroll = getWindowScroll(element);
3994
- var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
3995
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
3996
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
3997
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
3998
- var y = -winScroll.scrollTop;
3999
-
4000
- if (getComputedStyle(body || html).direction === 'rtl') {
4001
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
4002
- }
4003
-
4004
- return {
4005
- width: width,
4006
- height: height,
4007
- x: x,
4008
- y: y
4009
- };
4010
- }
4011
-
4012
- function isScrollParent(element) {
4013
- // Firefox wants us to check `-x` and `-y` variations as well
4014
- var _getComputedStyle = getComputedStyle(element),
4015
- overflow = _getComputedStyle.overflow,
4016
- overflowX = _getComputedStyle.overflowX,
4017
- overflowY = _getComputedStyle.overflowY;
4018
-
4019
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
4020
- }
4021
-
4022
- function getScrollParent(node) {
4023
- if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
4024
- // $FlowFixMe[incompatible-return]: assume body is always available
4025
- return node.ownerDocument.body;
4026
- }
4027
-
4028
- if (isHTMLElement(node) && isScrollParent(node)) {
4029
- return node;
4030
- }
4031
-
4032
- return getScrollParent(getParentNode(node));
4033
- }
4034
-
4035
- /*
4036
- given a DOM element, return the list of all scroll parents, up the list of ancesors
4037
- until we get to the top window object. This list is what we attach scroll listeners
4038
- to, because if any of these parent elements scroll, we'll need to re-calculate the
4039
- reference element's position.
4040
- */
4041
-
4042
- function listScrollParents(element, list) {
4043
- var _element$ownerDocumen;
4044
-
4045
- if (list === void 0) {
4046
- list = [];
4047
- }
4048
-
4049
- var scrollParent = getScrollParent(element);
4050
- var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
4051
- var win = getWindow(scrollParent);
4052
- var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
4053
- var updatedList = list.concat(target);
4054
- return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
4055
- updatedList.concat(listScrollParents(getParentNode(target)));
4056
- }
4057
-
4058
- function rectToClientRect(rect) {
4059
- return Object.assign({}, rect, {
4060
- left: rect.x,
4061
- top: rect.y,
4062
- right: rect.x + rect.width,
4063
- bottom: rect.y + rect.height
4064
- });
4065
- }
4066
-
4067
- function getInnerBoundingClientRect(element) {
4068
- var rect = getBoundingClientRect(element);
4069
- rect.top = rect.top + element.clientTop;
4070
- rect.left = rect.left + element.clientLeft;
4071
- rect.bottom = rect.top + element.clientHeight;
4072
- rect.right = rect.left + element.clientWidth;
4073
- rect.width = element.clientWidth;
4074
- rect.height = element.clientHeight;
4075
- rect.x = rect.left;
4076
- rect.y = rect.top;
4077
- return rect;
4078
- }
4079
-
4080
- function getClientRectFromMixedType(element, clippingParent) {
4081
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
4082
- } // A "clipping parent" is an overflowable container with the characteristic of
4083
- // clipping (or hiding) overflowing elements with a position different from
4084
- // `initial`
4085
-
4086
-
4087
- function getClippingParents(element) {
4088
- var clippingParents = listScrollParents(getParentNode(element));
4089
- var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
4090
- var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
4091
-
4092
- if (!isElement(clipperElement)) {
4093
- return [];
4094
- } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
4095
-
4096
-
4097
- return clippingParents.filter(function (clippingParent) {
4098
- return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
4099
- });
4100
- } // Gets the maximum area that the element is visible in due to any number of
4101
- // clipping parents
4102
-
4103
-
4104
- function getClippingRect(element, boundary, rootBoundary) {
4105
- var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
4106
- var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
4107
- var firstClippingParent = clippingParents[0];
4108
- var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
4109
- var rect = getClientRectFromMixedType(element, clippingParent);
4110
- accRect.top = max(rect.top, accRect.top);
4111
- accRect.right = min(rect.right, accRect.right);
4112
- accRect.bottom = min(rect.bottom, accRect.bottom);
4113
- accRect.left = max(rect.left, accRect.left);
4114
- return accRect;
4115
- }, getClientRectFromMixedType(element, firstClippingParent));
4116
- clippingRect.width = clippingRect.right - clippingRect.left;
4117
- clippingRect.height = clippingRect.bottom - clippingRect.top;
4118
- clippingRect.x = clippingRect.left;
4119
- clippingRect.y = clippingRect.top;
4120
- return clippingRect;
4121
- }
4122
-
4123
- function computeOffsets(_ref) {
4124
- var reference = _ref.reference,
4125
- element = _ref.element,
4126
- placement = _ref.placement;
4127
- var basePlacement = placement ? getBasePlacement(placement) : null;
4128
- var variation = placement ? getVariation(placement) : null;
4129
- var commonX = reference.x + reference.width / 2 - element.width / 2;
4130
- var commonY = reference.y + reference.height / 2 - element.height / 2;
4131
- var offsets;
4132
-
4133
- switch (basePlacement) {
4134
- case top:
4135
- offsets = {
4136
- x: commonX,
4137
- y: reference.y - element.height
4138
- };
4139
- break;
4140
-
4141
- case bottom:
4142
- offsets = {
4143
- x: commonX,
4144
- y: reference.y + reference.height
4145
- };
4146
- break;
4147
-
4148
- case right:
4149
- offsets = {
4150
- x: reference.x + reference.width,
4151
- y: commonY
4152
- };
4153
- break;
4154
-
4155
- case left:
4156
- offsets = {
4157
- x: reference.x - element.width,
4158
- y: commonY
4159
- };
4160
- break;
4161
-
4162
- default:
4163
- offsets = {
4164
- x: reference.x,
4165
- y: reference.y
4166
- };
4167
- }
4168
-
4169
- var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
4170
-
4171
- if (mainAxis != null) {
4172
- var len = mainAxis === 'y' ? 'height' : 'width';
4173
-
4174
- switch (variation) {
4175
- case start:
4176
- offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
4177
- break;
4178
-
4179
- case end:
4180
- offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
4181
- break;
4182
- }
4183
- }
4184
-
4185
- return offsets;
4186
- }
4187
-
4188
- function detectOverflow(state, options) {
4189
- if (options === void 0) {
4190
- options = {};
4191
- }
4192
-
4193
- var _options = options,
4194
- _options$placement = _options.placement,
4195
- placement = _options$placement === void 0 ? state.placement : _options$placement,
4196
- _options$boundary = _options.boundary,
4197
- boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
4198
- _options$rootBoundary = _options.rootBoundary,
4199
- rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
4200
- _options$elementConte = _options.elementContext,
4201
- elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
4202
- _options$altBoundary = _options.altBoundary,
4203
- altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
4204
- _options$padding = _options.padding,
4205
- padding = _options$padding === void 0 ? 0 : _options$padding;
4206
- var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
4207
- var altContext = elementContext === popper ? reference : popper;
4208
- var popperRect = state.rects.popper;
4209
- var element = state.elements[altBoundary ? altContext : elementContext];
4210
- var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
4211
- var referenceClientRect = getBoundingClientRect(state.elements.reference);
4212
- var popperOffsets = computeOffsets({
4213
- reference: referenceClientRect,
4214
- element: popperRect,
4215
- strategy: 'absolute',
4216
- placement: placement
4217
- });
4218
- var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
4219
- var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
4220
- // 0 or negative = within the clipping rect
4221
-
4222
- var overflowOffsets = {
4223
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
4224
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
4225
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
4226
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
4227
- };
4228
- var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
4229
-
4230
- if (elementContext === popper && offsetData) {
4231
- var offset = offsetData[placement];
4232
- Object.keys(overflowOffsets).forEach(function (key) {
4233
- var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
4234
- var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
4235
- overflowOffsets[key] += offset[axis] * multiply;
4236
- });
4237
- }
4238
-
4239
- return overflowOffsets;
4240
- }
4241
-
4242
- function computeAutoPlacement(state, options) {
4243
- if (options === void 0) {
4244
- options = {};
4245
- }
4246
-
4247
- var _options = options,
4248
- placement = _options.placement,
4249
- boundary = _options.boundary,
4250
- rootBoundary = _options.rootBoundary,
4251
- padding = _options.padding,
4252
- flipVariations = _options.flipVariations,
4253
- _options$allowedAutoP = _options.allowedAutoPlacements,
4254
- allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
4255
- var variation = getVariation(placement);
4256
- var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
4257
- return getVariation(placement) === variation;
4258
- }) : basePlacements;
4259
- var allowedPlacements = placements$1.filter(function (placement) {
4260
- return allowedAutoPlacements.indexOf(placement) >= 0;
4261
- });
4262
-
4263
- if (allowedPlacements.length === 0) {
4264
- allowedPlacements = placements$1;
4265
- } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
4266
-
4267
-
4268
- var overflows = allowedPlacements.reduce(function (acc, placement) {
4269
- acc[placement] = detectOverflow(state, {
4270
- placement: placement,
4271
- boundary: boundary,
4272
- rootBoundary: rootBoundary,
4273
- padding: padding
4274
- })[getBasePlacement(placement)];
4275
- return acc;
4276
- }, {});
4277
- return Object.keys(overflows).sort(function (a, b) {
4278
- return overflows[a] - overflows[b];
4279
- });
4280
- }
4281
-
4282
- function getExpandedFallbackPlacements(placement) {
4283
- if (getBasePlacement(placement) === auto) {
4284
- return [];
4285
- }
4286
-
4287
- var oppositePlacement = getOppositePlacement(placement);
4288
- return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
4289
- }
4290
-
4291
- function flip(_ref) {
4292
- var state = _ref.state,
4293
- options = _ref.options,
4294
- name = _ref.name;
4295
-
4296
- if (state.modifiersData[name]._skip) {
4297
- return;
4298
- }
4299
-
4300
- var _options$mainAxis = options.mainAxis,
4301
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
4302
- _options$altAxis = options.altAxis,
4303
- checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
4304
- specifiedFallbackPlacements = options.fallbackPlacements,
4305
- padding = options.padding,
4306
- boundary = options.boundary,
4307
- rootBoundary = options.rootBoundary,
4308
- altBoundary = options.altBoundary,
4309
- _options$flipVariatio = options.flipVariations,
4310
- flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
4311
- allowedAutoPlacements = options.allowedAutoPlacements;
4312
- var preferredPlacement = state.options.placement;
4313
- var basePlacement = getBasePlacement(preferredPlacement);
4314
- var isBasePlacement = basePlacement === preferredPlacement;
4315
- var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
4316
- var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
4317
- return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
4318
- placement: placement,
4319
- boundary: boundary,
4320
- rootBoundary: rootBoundary,
4321
- padding: padding,
4322
- flipVariations: flipVariations,
4323
- allowedAutoPlacements: allowedAutoPlacements
4324
- }) : placement);
4325
- }, []);
4326
- var referenceRect = state.rects.reference;
4327
- var popperRect = state.rects.popper;
4328
- var checksMap = new Map();
4329
- var makeFallbackChecks = true;
4330
- var firstFittingPlacement = placements[0];
4331
-
4332
- for (var i = 0; i < placements.length; i++) {
4333
- var placement = placements[i];
4334
-
4335
- var _basePlacement = getBasePlacement(placement);
4336
-
4337
- var isStartVariation = getVariation(placement) === start;
4338
- var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
4339
- var len = isVertical ? 'width' : 'height';
4340
- var overflow = detectOverflow(state, {
4341
- placement: placement,
4342
- boundary: boundary,
4343
- rootBoundary: rootBoundary,
4344
- altBoundary: altBoundary,
4345
- padding: padding
4346
- });
4347
- var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
4348
-
4349
- if (referenceRect[len] > popperRect[len]) {
4350
- mainVariationSide = getOppositePlacement(mainVariationSide);
4351
- }
4352
-
4353
- var altVariationSide = getOppositePlacement(mainVariationSide);
4354
- var checks = [];
4355
-
4356
- if (checkMainAxis) {
4357
- checks.push(overflow[_basePlacement] <= 0);
4358
- }
4359
-
4360
- if (checkAltAxis) {
4361
- checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
4362
- }
4363
-
4364
- if (checks.every(function (check) {
4365
- return check;
4366
- })) {
4367
- firstFittingPlacement = placement;
4368
- makeFallbackChecks = false;
4369
- break;
4370
- }
4371
-
4372
- checksMap.set(placement, checks);
4373
- }
4374
-
4375
- if (makeFallbackChecks) {
4376
- // `2` may be desired in some cases – research later
4377
- var numberOfChecks = flipVariations ? 3 : 1;
4378
-
4379
- var _loop = function _loop(_i) {
4380
- var fittingPlacement = placements.find(function (placement) {
4381
- var checks = checksMap.get(placement);
4382
-
4383
- if (checks) {
4384
- return checks.slice(0, _i).every(function (check) {
4385
- return check;
4386
- });
4387
- }
4388
- });
4389
-
4390
- if (fittingPlacement) {
4391
- firstFittingPlacement = fittingPlacement;
4392
- return "break";
4393
- }
4394
- };
4395
-
4396
- for (var _i = numberOfChecks; _i > 0; _i--) {
4397
- var _ret = _loop(_i);
4398
-
4399
- if (_ret === "break") break;
4400
- }
4401
- }
4402
-
4403
- if (state.placement !== firstFittingPlacement) {
4404
- state.modifiersData[name]._skip = true;
4405
- state.placement = firstFittingPlacement;
4406
- state.reset = true;
4407
- }
4408
- } // eslint-disable-next-line import/no-unused-modules
4409
-
4410
-
4411
- const flip$1 = {
4412
- name: 'flip',
4413
- enabled: true,
4414
- phase: 'main',
4415
- fn: flip,
4416
- requiresIfExists: ['offset'],
4417
- data: {
4418
- _skip: false
4419
- }
4420
- };
4421
-
4422
- function getSideOffsets(overflow, rect, preventedOffsets) {
4423
- if (preventedOffsets === void 0) {
4424
- preventedOffsets = {
4425
- x: 0,
4426
- y: 0
4427
- };
4428
- }
4429
-
4430
- return {
4431
- top: overflow.top - rect.height - preventedOffsets.y,
4432
- right: overflow.right - rect.width + preventedOffsets.x,
4433
- bottom: overflow.bottom - rect.height + preventedOffsets.y,
4434
- left: overflow.left - rect.width - preventedOffsets.x
4435
- };
4436
- }
4437
-
4438
- function isAnySideFullyClipped(overflow) {
4439
- return [top, right, bottom, left].some(function (side) {
4440
- return overflow[side] >= 0;
4441
- });
4442
- }
4443
-
4444
- function hide(_ref) {
4445
- var state = _ref.state,
4446
- name = _ref.name;
4447
- var referenceRect = state.rects.reference;
4448
- var popperRect = state.rects.popper;
4449
- var preventedOffsets = state.modifiersData.preventOverflow;
4450
- var referenceOverflow = detectOverflow(state, {
4451
- elementContext: 'reference'
4452
- });
4453
- var popperAltOverflow = detectOverflow(state, {
4454
- altBoundary: true
4455
- });
4456
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
4457
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
4458
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
4459
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
4460
- state.modifiersData[name] = {
4461
- referenceClippingOffsets: referenceClippingOffsets,
4462
- popperEscapeOffsets: popperEscapeOffsets,
4463
- isReferenceHidden: isReferenceHidden,
4464
- hasPopperEscaped: hasPopperEscaped
4465
- };
4466
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
4467
- 'data-popper-reference-hidden': isReferenceHidden,
4468
- 'data-popper-escaped': hasPopperEscaped
4469
- });
4470
- } // eslint-disable-next-line import/no-unused-modules
4471
-
4472
-
4473
- const hide$1 = {
4474
- name: 'hide',
4475
- enabled: true,
4476
- phase: 'main',
4477
- requiresIfExists: ['preventOverflow'],
4478
- fn: hide
4479
- };
4480
-
4481
- function distanceAndSkiddingToXY(placement, rects, offset) {
4482
- var basePlacement = getBasePlacement(placement);
4483
- var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
4484
-
4485
- var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
4486
- placement: placement
4487
- })) : offset,
4488
- skidding = _ref[0],
4489
- distance = _ref[1];
4490
-
4491
- skidding = skidding || 0;
4492
- distance = (distance || 0) * invertDistance;
4493
- return [left, right].indexOf(basePlacement) >= 0 ? {
4494
- x: distance,
4495
- y: skidding
4496
- } : {
4497
- x: skidding,
4498
- y: distance
4499
- };
4500
- }
4501
-
4502
- function offset(_ref2) {
4503
- var state = _ref2.state,
4504
- options = _ref2.options,
4505
- name = _ref2.name;
4506
- var _options$offset = options.offset,
4507
- offset = _options$offset === void 0 ? [0, 0] : _options$offset;
4508
- var data = placements.reduce(function (acc, placement) {
4509
- acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
4510
- return acc;
4511
- }, {});
4512
- var _data$state$placement = data[state.placement],
4513
- x = _data$state$placement.x,
4514
- y = _data$state$placement.y;
4515
-
4516
- if (state.modifiersData.popperOffsets != null) {
4517
- state.modifiersData.popperOffsets.x += x;
4518
- state.modifiersData.popperOffsets.y += y;
4519
- }
4520
-
4521
- state.modifiersData[name] = data;
4522
- } // eslint-disable-next-line import/no-unused-modules
4523
-
4524
-
4525
- const offset$1 = {
4526
- name: 'offset',
4527
- enabled: true,
4528
- phase: 'main',
4529
- requires: ['popperOffsets'],
4530
- fn: offset
4531
- };
4532
-
4533
- function popperOffsets(_ref) {
4534
- var state = _ref.state,
4535
- name = _ref.name;
4536
- // Offsets are the actual position the popper needs to have to be
4537
- // properly positioned near its reference element
4538
- // This is the most basic placement, and will be adjusted by
4539
- // the modifiers in the next step
4540
- state.modifiersData[name] = computeOffsets({
4541
- reference: state.rects.reference,
4542
- element: state.rects.popper,
4543
- strategy: 'absolute',
4544
- placement: state.placement
4545
- });
4546
- } // eslint-disable-next-line import/no-unused-modules
4547
-
4548
-
4549
- const popperOffsets$1 = {
4550
- name: 'popperOffsets',
4551
- enabled: true,
4552
- phase: 'read',
4553
- fn: popperOffsets,
4554
- data: {}
4555
- };
4556
-
4557
- function getAltAxis(axis) {
4558
- return axis === 'x' ? 'y' : 'x';
4559
- }
4560
-
4561
- function preventOverflow(_ref) {
4562
- var state = _ref.state,
4563
- options = _ref.options,
4564
- name = _ref.name;
4565
- var _options$mainAxis = options.mainAxis,
4566
- checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
4567
- _options$altAxis = options.altAxis,
4568
- checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
4569
- boundary = options.boundary,
4570
- rootBoundary = options.rootBoundary,
4571
- altBoundary = options.altBoundary,
4572
- padding = options.padding,
4573
- _options$tether = options.tether,
4574
- tether = _options$tether === void 0 ? true : _options$tether,
4575
- _options$tetherOffset = options.tetherOffset,
4576
- tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
4577
- var overflow = detectOverflow(state, {
4578
- boundary: boundary,
4579
- rootBoundary: rootBoundary,
4580
- padding: padding,
4581
- altBoundary: altBoundary
4582
- });
4583
- var basePlacement = getBasePlacement(state.placement);
4584
- var variation = getVariation(state.placement);
4585
- var isBasePlacement = !variation;
4586
- var mainAxis = getMainAxisFromPlacement(basePlacement);
4587
- var altAxis = getAltAxis(mainAxis);
4588
- var popperOffsets = state.modifiersData.popperOffsets;
4589
- var referenceRect = state.rects.reference;
4590
- var popperRect = state.rects.popper;
4591
- var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
4592
- placement: state.placement
4593
- })) : tetherOffset;
4594
- var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
4595
- mainAxis: tetherOffsetValue,
4596
- altAxis: tetherOffsetValue
4597
- } : Object.assign({
4598
- mainAxis: 0,
4599
- altAxis: 0
4600
- }, tetherOffsetValue);
4601
- var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
4602
- var data = {
4603
- x: 0,
4604
- y: 0
4605
- };
4606
-
4607
- if (!popperOffsets) {
4608
- return;
4609
- }
4610
-
4611
- if (checkMainAxis) {
4612
- var _offsetModifierState$;
4613
-
4614
- var mainSide = mainAxis === 'y' ? top : left;
4615
- var altSide = mainAxis === 'y' ? bottom : right;
4616
- var len = mainAxis === 'y' ? 'height' : 'width';
4617
- var offset = popperOffsets[mainAxis];
4618
- var min$1 = offset + overflow[mainSide];
4619
- var max$1 = offset - overflow[altSide];
4620
- var additive = tether ? -popperRect[len] / 2 : 0;
4621
- var minLen = variation === start ? referenceRect[len] : popperRect[len];
4622
- var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
4623
- // outside the reference bounds
4624
-
4625
- var arrowElement = state.elements.arrow;
4626
- var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
4627
- width: 0,
4628
- height: 0
4629
- };
4630
- var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
4631
- var arrowPaddingMin = arrowPaddingObject[mainSide];
4632
- var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
4633
- // to include its full size in the calculation. If the reference is small
4634
- // and near the edge of a boundary, the popper can overflow even if the
4635
- // reference is not overflowing as well (e.g. virtual elements with no
4636
- // width or height)
4637
-
4638
- var arrowLen = within(0, referenceRect[len], arrowRect[len]);
4639
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
4640
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
4641
- var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
4642
- var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
4643
- var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
4644
- var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
4645
- var tetherMax = offset + maxOffset - offsetModifierValue;
4646
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
4647
- popperOffsets[mainAxis] = preventedOffset;
4648
- data[mainAxis] = preventedOffset - offset;
4649
- }
4650
-
4651
- if (checkAltAxis) {
4652
- var _offsetModifierState$2;
4653
-
4654
- var _mainSide = mainAxis === 'x' ? top : left;
4655
-
4656
- var _altSide = mainAxis === 'x' ? bottom : right;
4657
-
4658
- var _offset = popperOffsets[altAxis];
4659
-
4660
- var _len = altAxis === 'y' ? 'height' : 'width';
4661
-
4662
- var _min = _offset + overflow[_mainSide];
4663
-
4664
- var _max = _offset - overflow[_altSide];
4665
-
4666
- var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
4667
-
4668
- var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
4669
-
4670
- var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
4671
-
4672
- var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
4673
-
4674
- var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
4675
-
4676
- popperOffsets[altAxis] = _preventedOffset;
4677
- data[altAxis] = _preventedOffset - _offset;
4678
- }
4679
-
4680
- state.modifiersData[name] = data;
4681
- } // eslint-disable-next-line import/no-unused-modules
4682
-
4683
-
4684
- const preventOverflow$1 = {
4685
- name: 'preventOverflow',
4686
- enabled: true,
4687
- phase: 'main',
4688
- fn: preventOverflow,
4689
- requiresIfExists: ['offset']
4690
- };
4691
-
4692
- function getHTMLElementScroll(element) {
4693
- return {
4694
- scrollLeft: element.scrollLeft,
4695
- scrollTop: element.scrollTop
4696
- };
4697
- }
4698
-
4699
- function getNodeScroll(node) {
4700
- if (node === getWindow(node) || !isHTMLElement(node)) {
4701
- return getWindowScroll(node);
4702
- } else {
4703
- return getHTMLElementScroll(node);
4704
- }
4705
- }
4706
-
4707
- function isElementScaled(element) {
4708
- var rect = element.getBoundingClientRect();
4709
- var scaleX = round(rect.width) / element.offsetWidth || 1;
4710
- var scaleY = round(rect.height) / element.offsetHeight || 1;
4711
- return scaleX !== 1 || scaleY !== 1;
4712
- } // Returns the composite rect of an element relative to its offsetParent.
4713
- // Composite means it takes into account transforms as well as layout.
4714
-
4715
-
4716
- function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
4717
- if (isFixed === void 0) {
4718
- isFixed = false;
4719
- }
4720
-
4721
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
4722
- var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
4723
- var documentElement = getDocumentElement(offsetParent);
4724
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
4725
- var scroll = {
4726
- scrollLeft: 0,
4727
- scrollTop: 0
4728
- };
4729
- var offsets = {
4730
- x: 0,
4731
- y: 0
4732
- };
4733
-
4734
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4735
- if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
4736
- isScrollParent(documentElement)) {
4737
- scroll = getNodeScroll(offsetParent);
4738
- }
4739
-
4740
- if (isHTMLElement(offsetParent)) {
4741
- offsets = getBoundingClientRect(offsetParent, true);
4742
- offsets.x += offsetParent.clientLeft;
4743
- offsets.y += offsetParent.clientTop;
4744
- } else if (documentElement) {
4745
- offsets.x = getWindowScrollBarX(documentElement);
4746
- }
4747
- }
4748
-
4749
- return {
4750
- x: rect.left + scroll.scrollLeft - offsets.x,
4751
- y: rect.top + scroll.scrollTop - offsets.y,
4752
- width: rect.width,
4753
- height: rect.height
4754
- };
4755
- }
4756
-
4757
- function order(modifiers) {
4758
- var map = new Map();
4759
- var visited = new Set();
4760
- var result = [];
4761
- modifiers.forEach(function (modifier) {
4762
- map.set(modifier.name, modifier);
4763
- }); // On visiting object, check for its dependencies and visit them recursively
4764
-
4765
- function sort(modifier) {
4766
- visited.add(modifier.name);
4767
- var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
4768
- requires.forEach(function (dep) {
4769
- if (!visited.has(dep)) {
4770
- var depModifier = map.get(dep);
4771
-
4772
- if (depModifier) {
4773
- sort(depModifier);
4774
- }
4775
- }
4776
- });
4777
- result.push(modifier);
4778
- }
4779
-
4780
- modifiers.forEach(function (modifier) {
4781
- if (!visited.has(modifier.name)) {
4782
- // check for visited object
4783
- sort(modifier);
4784
- }
4785
- });
4786
- return result;
4787
- }
4788
-
4789
- function orderModifiers(modifiers) {
4790
- // order based on dependencies
4791
- var orderedModifiers = order(modifiers); // order based on phase
4792
-
4793
- return modifierPhases.reduce(function (acc, phase) {
4794
- return acc.concat(orderedModifiers.filter(function (modifier) {
4795
- return modifier.phase === phase;
4796
- }));
4797
- }, []);
4798
- }
4799
-
4800
- function debounce(fn) {
4801
- var pending;
4802
- return function () {
4803
- if (!pending) {
4804
- pending = new Promise(function (resolve) {
4805
- Promise.resolve().then(function () {
4806
- pending = undefined;
4807
- resolve(fn());
4808
- });
4809
- });
4810
- }
4811
-
4812
- return pending;
4813
- };
4814
- }
4815
-
4816
- function mergeByName(modifiers) {
4817
- var merged = modifiers.reduce(function (merged, current) {
4818
- var existing = merged[current.name];
4819
- merged[current.name] = existing ? Object.assign({}, existing, current, {
4820
- options: Object.assign({}, existing.options, current.options),
4821
- data: Object.assign({}, existing.data, current.data)
4822
- }) : current;
4823
- return merged;
4824
- }, {}); // IE11 does not support Object.values
4825
-
4826
- return Object.keys(merged).map(function (key) {
4827
- return merged[key];
4828
- });
4829
- }
4830
-
4831
- var DEFAULT_OPTIONS = {
4832
- placement: 'bottom',
4833
- modifiers: [],
4834
- strategy: 'absolute'
4835
- };
4836
-
4837
- function areValidElements() {
4838
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4839
- args[_key] = arguments[_key];
4840
- }
4841
-
4842
- return !args.some(function (element) {
4843
- return !(element && typeof element.getBoundingClientRect === 'function');
4844
- });
4845
- }
4846
-
4847
- function popperGenerator(generatorOptions) {
4848
- if (generatorOptions === void 0) {
4849
- generatorOptions = {};
4850
- }
4851
-
4852
- var _generatorOptions = generatorOptions,
4853
- _generatorOptions$def = _generatorOptions.defaultModifiers,
4854
- defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
4855
- _generatorOptions$def2 = _generatorOptions.defaultOptions,
4856
- defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
4857
- return function createPopper(reference, popper, options) {
4858
- if (options === void 0) {
4859
- options = defaultOptions;
4860
- }
4861
-
4862
- var state = {
4863
- placement: 'bottom',
4864
- orderedModifiers: [],
4865
- options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
4866
- modifiersData: {},
4867
- elements: {
4868
- reference: reference,
4869
- popper: popper
4870
- },
4871
- attributes: {},
4872
- styles: {}
4873
- };
4874
- var effectCleanupFns = [];
4875
- var isDestroyed = false;
4876
- var instance = {
4877
- state: state,
4878
- setOptions: function setOptions(setOptionsAction) {
4879
- var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
4880
- cleanupModifierEffects();
4881
- state.options = Object.assign({}, defaultOptions, state.options, options);
4882
- state.scrollParents = {
4883
- reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
4884
- popper: listScrollParents(popper)
4885
- }; // Orders the modifiers based on their dependencies and `phase`
4886
- // properties
4887
-
4888
- var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
4889
-
4890
- state.orderedModifiers = orderedModifiers.filter(function (m) {
4891
- return m.enabled;
4892
- }); // Validate the provided modifiers so that the consumer will get warned
4893
-
4894
- runModifierEffects();
4895
- return instance.update();
4896
- },
4897
- // Sync update – it will always be executed, even if not necessary. This
4898
- // is useful for low frequency updates where sync behavior simplifies the
4899
- // logic.
4900
- // For high frequency updates (e.g. `resize` and `scroll` events), always
4901
- // prefer the async Popper#update method
4902
- forceUpdate: function forceUpdate() {
4903
- if (isDestroyed) {
4904
- return;
4905
- }
4906
-
4907
- var _state$elements = state.elements,
4908
- reference = _state$elements.reference,
4909
- popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
4910
- // anymore
4911
-
4912
- if (!areValidElements(reference, popper)) {
4913
-
4914
- return;
4915
- } // Store the reference and popper rects to be read by modifiers
4916
-
4917
-
4918
- state.rects = {
4919
- reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
4920
- popper: getLayoutRect(popper)
4921
- }; // Modifiers have the ability to reset the current update cycle. The
4922
- // most common use case for this is the `flip` modifier changing the
4923
- // placement, which then needs to re-run all the modifiers, because the
4924
- // logic was previously ran for the previous placement and is therefore
4925
- // stale/incorrect
4926
-
4927
- state.reset = false;
4928
- state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
4929
- // is filled with the initial data specified by the modifier. This means
4930
- // it doesn't persist and is fresh on each update.
4931
- // To ensure persistent data, use `${name}#persistent`
4932
-
4933
- state.orderedModifiers.forEach(function (modifier) {
4934
- return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
4935
- });
4936
-
4937
- for (var index = 0; index < state.orderedModifiers.length; index++) {
4938
-
4939
- if (state.reset === true) {
4940
- state.reset = false;
4941
- index = -1;
4942
- continue;
4943
- }
4944
-
4945
- var _state$orderedModifie = state.orderedModifiers[index],
4946
- fn = _state$orderedModifie.fn,
4947
- _state$orderedModifie2 = _state$orderedModifie.options,
4948
- _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
4949
- name = _state$orderedModifie.name;
4950
-
4951
- if (typeof fn === 'function') {
4952
- state = fn({
4953
- state: state,
4954
- options: _options,
4955
- name: name,
4956
- instance: instance
4957
- }) || state;
4958
- }
4959
- }
4960
- },
4961
- // Async and optimistically optimized update – it will not be executed if
4962
- // not necessary (debounced to run at most once-per-tick)
4963
- update: debounce(function () {
4964
- return new Promise(function (resolve) {
4965
- instance.forceUpdate();
4966
- resolve(state);
4967
- });
4968
- }),
4969
- destroy: function destroy() {
4970
- cleanupModifierEffects();
4971
- isDestroyed = true;
4972
- }
4973
- };
4974
-
4975
- if (!areValidElements(reference, popper)) {
4976
-
4977
- return instance;
4978
- }
4979
-
4980
- instance.setOptions(options).then(function (state) {
4981
- if (!isDestroyed && options.onFirstUpdate) {
4982
- options.onFirstUpdate(state);
4983
- }
4984
- }); // Modifiers have the ability to execute arbitrary code before the first
4985
- // update cycle runs. They will be executed in the same order as the update
4986
- // cycle. This is useful when a modifier adds some persistent data that
4987
- // other modifiers need to use, but the modifier is run after the dependent
4988
- // one.
4989
-
4990
- function runModifierEffects() {
4991
- state.orderedModifiers.forEach(function (_ref3) {
4992
- var name = _ref3.name,
4993
- _ref3$options = _ref3.options,
4994
- options = _ref3$options === void 0 ? {} : _ref3$options,
4995
- effect = _ref3.effect;
4996
-
4997
- if (typeof effect === 'function') {
4998
- var cleanupFn = effect({
4999
- state: state,
5000
- name: name,
5001
- instance: instance,
5002
- options: options
5003
- });
5004
-
5005
- var noopFn = function noopFn() {};
5006
-
5007
- effectCleanupFns.push(cleanupFn || noopFn);
5008
- }
5009
- });
5010
- }
5011
-
5012
- function cleanupModifierEffects() {
5013
- effectCleanupFns.forEach(function (fn) {
5014
- return fn();
5015
- });
5016
- effectCleanupFns = [];
5017
- }
5018
-
5019
- return instance;
5020
- };
5021
- }
5022
-
5023
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
5024
- var createPopper = /*#__PURE__*/popperGenerator({
5025
- defaultModifiers: defaultModifiers
5026
- }); // eslint-disable-next-line import/no-unused-modules
5027
-
5028
- const mgPopoverCss = "mg-popover.sc-mg-popover{display:contents}mg-popover.sc-mg-popover-s>*{display:inline-block}.mg-popover.sc-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].sc-mg-popover{display:block}.mg-popover.sc-mg-popover mg-button.sc-mg-popover{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.sc-mg-popover .mg-popover__arrow.sc-mg-popover,.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover::before{position:absolute;width:2rem;height:2rem;z-index:-1;background:inherit}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover{visibility:hidden}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-popover[data-popper-placement^=top].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{bottom:-6px}.mg-popover[data-popper-placement^=bottom].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{top:-6px}.mg-popover[data-popper-placement^=left].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{right:-6px}.mg-popover[data-popper-placement^=right].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{left:-6px}.mg-popover__title.sc-mg-popover-s>[slot=title],.mg-popover__title .sc-mg-popover-s>[slot=title]{margin:0 0 1rem;font-size:var(--mg-popover-title-font-size);font-weight:600}";
5029
-
5030
- const MgPopover = class {
5031
- constructor(hostRef) {
5032
- index.registerInstance(this, hostRef);
5033
- this.displayChange = index.createEvent(this, "display-change", 7);
5034
- this.closeButtonId = '';
5035
- /**
5036
- * Sets an `id` attribute.
5037
- * Needed by the input for accessibility `aria-decribedby`.
5038
- */
5039
- this.identifier = index$1.createID('mg-popover');
5040
- /**
5041
- * Popover placement
5042
- */
5043
- this.placement = 'bottom';
5044
- /**
5045
- * Define if popover has a cross button
5046
- */
5047
- this.closeButton = false;
5048
- /**
5049
- * Display popover
5050
- */
5051
- this.display = false;
5052
- /**
5053
- * Disable popover
5054
- */
5055
- this.disabled = false;
5056
- /**
5057
- * Check if clicked outside of component
5058
- *
5059
- * @param {MouseEvent} event mouse event
5060
- * @returns {void}
5061
- */
5062
- this.clickOutside = (event) => {
5063
- var _a;
5064
- if (!this.disabled && ((_a = event.target.closest(`#${this.identifier}`)) === null || _a === void 0 ? void 0 : _a.parentElement.nodeName) !== 'MG-POPOVER') {
5065
- this.display = false;
5066
- }
5067
- };
5068
- /**
5069
- * Show popover
5070
- *
5071
- * @returns {void}
5072
- */
5073
- this.show = () => {
5074
- // Make the popover visible
5075
- this.popover.setAttribute('data-show', '');
5076
- // Enable the event listeners
5077
- this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
5078
- // Update its position
5079
- this.popper.update();
5080
- // hide when click outside
5081
- // setTimeout is used to prevent event to trigger after creation
5082
- setTimeout(() => {
5083
- document.addEventListener('click', this.clickOutside, false);
5084
- }, 0);
5085
- };
5086
- /**
5087
- * Hide popover
5088
- *
5089
- * @returns {void}
5090
- */
5091
- this.hide = () => {
5092
- // Hide the popover
5093
- this.popover.removeAttribute('data-show');
5094
- // Disable the event listeners
5095
- this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
5096
- // Remove event listener
5097
- document.removeEventListener('click', this.clickOutside, false);
5098
- };
5099
- /**
5100
- * Handle action for close button
5101
- *
5102
- * @returns {void}
5103
- */
5104
- this.handleCloseButton = () => {
5105
- this.display = false;
5106
- };
5107
- }
5108
- handleDisplay(newValue) {
5109
- if (newValue) {
5110
- this.show();
5111
- }
5112
- else {
5113
- this.hide();
5114
- }
5115
- this.displayChange.emit(newValue);
5116
- }
5117
- /*************
5118
- * Lifecycle *
5119
- *************/
5120
- /**
5121
- * Check if component props are well configured on init
5122
- *
5123
- * @returns {void} timeout
5124
- */
5125
- componentWillLoad() {
5126
- // Get locales
5127
- this.messages = index$1.initLocales(this.element).messages;
5128
- }
5129
- /**
5130
- * Check if component props are well configured on init
5131
- *
5132
- * @returns {void}
5133
- */
5134
- componentDidLoad() {
5135
- const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
5136
- const slotedTitleElement = this.element.querySelector('[slot="title"]');
5137
- if (slotedTitleElement && !index$1.isTagName(slotedTitleElement, headingTags)) {
5138
- throw new Error(`<mg-popover> Slotted title must be a heading: ${headingTags.join(', ')}`);
5139
- }
5140
- // Set close button id
5141
- if (this.closeButton) {
5142
- this.closeButtonId = `${this.identifier}-close-button`;
5143
- }
5144
- // Get popover content
5145
- this.popover = this.element.querySelector(`#${this.identifier}`);
5146
- //Get interactive element
5147
- const interactiveElement = this.element.firstElementChild;
5148
- // Add aria attributes
5149
- interactiveElement.setAttribute('aria-controls', this.identifier);
5150
- interactiveElement.setAttribute('aria-expanded', `${this.display}`);
5151
- // Create popperjs popover
5152
- this.popper = createPopper(interactiveElement, this.popover, {
5153
- placement: this.placement,
5154
- modifiers: [
5155
- {
5156
- name: 'offset',
5157
- options: {
5158
- offset: [0, 10],
5159
- },
5160
- },
5161
- ],
5162
- });
5163
- // Add events to toggle display
5164
- interactiveElement.addEventListener('click', () => {
5165
- if (!this.disabled)
5166
- this.display = !this.display;
5167
- });
5168
- // Add events to hide popover
5169
- this.element.addEventListener('keydown', e => {
5170
- if (!this.disabled && e.code === 'Escape')
5171
- this.display = false;
5172
- });
5173
- this.handleDisplay(this.display);
5174
- }
5175
- /**
5176
- * Render
5177
- *
5178
- * @returns {HTMLElement} HTML Element
5179
- */
5180
- render() {
5181
- 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 }))));
5182
- }
5183
- get element() { return index.getElement(this); }
5184
- static get watchers() { return {
5185
- "display": ["handleDisplay"]
5186
- }; }
5187
- };
5188
- MgPopover.style = mgPopoverCss;
5189
-
5190
- var Status;
5191
- (function (Status) {
5192
- Status["VISIBLE"] = "visible";
5193
- Status["HIDDEN"] = "hidden";
5194
- Status["DISABLED"] = "disabled";
5195
- Status["ACTIVE"] = "active";
5196
- })(Status || (Status = {}));
5197
- /**
5198
- * List of all possibles sizes
5199
- */
5200
- const sizes = ['regular', 'large'];
5201
-
5202
- const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button{padding:calc(1rem + 0.3rem) calc(1rem * 1.3) 1rem}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button{padding:calc(1.8rem + 0.3rem) calc(1.8rem * 1.3) 1.8rem}.mg-tabs__header{display:flex;flex-direction:row;flex-wrap:wrap}.mg-tabs__navigation-button{display:flex;align-items:center;column-gap:0.5rem;background:none;border:none;border-bottom:0.3rem solid transparent;color:hsl(var(--color-dark));line-height:var(--line-height);cursor:pointer}.mg-tabs__navigation-button:disabled,.mg-tabs__navigation-button--disabled{cursor:default;opacity:30%}.mg-tabs__navigation-button:hover:not(:disabled),.mg-tabs__navigation-button:focus:not(:disabled){background-color:hsla(var(--color-info-h), var(--color-info-s), var(--color-info-l), 10%)}.mg-tabs__navigation-button.mg-tabs__navigation-button--active{color:hsl(var(--color-info));border-bottom-color:hsl(var(--color-info));font-weight:700}.mg-tabs__navigation-button.mg-tabs__navigation-button--hidden{display:none}.mg-tabs__content-container:focus-visible{outline:none}";
5203
-
5204
- /**
5205
- * type TabItem validation function
5206
- *
5207
- * @param {TabItem} tab tab item
5208
- * @returns {boolean} tab item type is valid
5209
- */
5210
- const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
5211
- const MgTabs = class {
5212
- constructor(hostRef) {
5213
- index.registerInstance(this, hostRef);
5214
- this.activeTabChange = index.createEvent(this, "active-tab-change", 7);
5215
- /************
5216
- * Internal *
5217
- ************/
5218
- this.tabPanel = 'panel';
5219
- this.startIndex = 1;
5220
- this.buttonTabBaseClass = 'mg-tabs__navigation-button';
5221
- /**
5222
- * Identifier is used for the element ID (id is a reserved prop in Stencil.js)
5223
- * If not set, it will be created.
5224
- */
5225
- this.identifier = index$1.createID('mg-tabs');
5226
- /**
5227
- * Define tabs size
5228
- */
5229
- this.size = 'regular';
5230
- /**
5231
- * Active tab number
5232
- * default: first is 1
5233
- */
5234
- this.activeTab = 1;
5235
- /**
5236
- * Component tabs
5237
- */
5238
- this.tabs = [];
5239
- /**
5240
- * Component classes
5241
- */
5242
- this.classList = new index$1.ClassList(['mg-tabs']);
5243
- /**
5244
- * Method to set active tab
5245
- *
5246
- * @param {number} tabKey item tab key to set to ACTIVE status
5247
- * @returns {void}
5248
- */
5249
- this.setActiveTab = (tabKey) => {
5250
- // reset active tabs
5251
- this.tabs.forEach(tab => {
5252
- if (this.tabHasGivenStatus(tab, Status.ACTIVE))
5253
- tab.status = Status.VISIBLE;
5254
- });
5255
- // set active tab from given tab key
5256
- this.tabs[tabKey - this.startIndex].status = Status.ACTIVE;
5257
- // emit change active tab key event
5258
- this.activeTabChange.emit(tabKey);
5259
- };
5260
- /**
5261
- * Method to know if given tab has the given status
5262
- *
5263
- * @param {TabItem} tab item tab key to set to ACTIVE status
5264
- * @param {Status} status status to valide
5265
- * @returns {boolean} status comparaison
5266
- */
5267
- this.tabHasGivenStatus = (tab, status) => tab.status === status;
5268
- /**
5269
- * Method to get element id from index
5270
- *
5271
- * @param {string} element to get id
5272
- * @param {number} index to generate id
5273
- * @returns {string} generated element id
5274
- */
5275
- this.getElementId = (element, index) => `${element}-${this.getTabIndex(index)}`;
5276
- /**
5277
- * Method to get tab index
5278
- *
5279
- * @param {number} index to get
5280
- * @returns {number} index
5281
- */
5282
- this.getTabIndex = (index) => index + this.startIndex;
5283
- /**
5284
- * Handle click events on tabs
5285
- *
5286
- * @param {MouseEvent} event mouse event
5287
- */
5288
- this.handleClick = (event) => {
5289
- const tabId = event.currentTarget.getAttribute('data-index');
5290
- this.activeTab = Number(tabId);
5291
- };
5292
- /**
5293
- * get navigation button class from given status
5294
- *
5295
- * @param {Status} status button tab status
5296
- * @param {boolean} isSelector set if we need a CSS selector with the dot '.' at the begin. default value = false.
5297
- * @returns {string} button class/selector variant
5298
- */
5299
- this.getNavigationButtonClass = (status, isSelector = false) => `${isSelector ? '.' : ''}${this.buttonTabBaseClass}--${status}`;
5300
- /**
5301
- * Handle keyboard event on tabs
5302
- *
5303
- * @param {MouseEvent} event mouse event
5304
- * @returns {void}
5305
- */
5306
- this.handleKeydown = (event) => {
5307
- let tabId = Number(event.target.getAttribute('data-index'));
5308
- const parent = event.target.parentElement;
5309
- // change selected id from key code
5310
- if (event.key === 'ArrowRight') {
5311
- tabId++;
5312
- }
5313
- else if (event.key === 'ArrowLeft') {
5314
- tabId--;
5315
- }
5316
- // get selected tab if NOT hidden, disabled
5317
- const selectedTab = parent.querySelector(`[data-index="${tabId}"]:not(${[this.getNavigationButtonClass(Status.HIDDEN, true), this.getNavigationButtonClass(Status.DISABLED, true)].join()})`);
5318
- // apply selected tab if exist
5319
- if (selectedTab !== null) {
5320
- selectedTab.focus();
5321
- this.activeTab = tabId;
5322
- }
5323
- };
5324
- /**
5325
- * Validate slots setting
5326
- */
5327
- this.validateSlots = () => {
5328
- const slots = Array.from(this.element.children).filter(slot => { var _a; return (_a = slot.getAttribute('slot')) === null || _a === void 0 ? void 0 : _a.includes('tab_content-'); });
5329
- if (slots.length !== this.tabs.length) {
5330
- throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
5331
- }
5332
- };
5333
- }
5334
- validateSize(newValue) {
5335
- if (!sizes.includes(newValue)) {
5336
- throw new Error(`<mg-tabs> prop "size" must be one of : ${sizes.join(', ')}`);
5337
- }
5338
- this.classList.add(`mg-tabs--size-${this.size}`);
3362
+ validateSize(newValue) {
3363
+ if (!sizes.includes(newValue)) {
3364
+ throw new Error(`<mg-tabs> prop "size" must be one of : ${sizes.join(', ')}`);
3365
+ }
3366
+ this.classList.add(`mg-tabs--size-${this.size}`);
5339
3367
  }
5340
3368
  validateItems(newValue) {
5341
3369
  // String array
@@ -5368,6 +3396,7 @@ const MgTabs = class {
5368
3396
  */
5369
3397
  componentWillLoad() {
5370
3398
  // Check tabs format
3399
+ this.validateLabel(this.label);
5371
3400
  this.validateItems(this.items);
5372
3401
  this.validateActiveTab(this.activeTab);
5373
3402
  this.validateSize(this.size);
@@ -5388,6 +3417,7 @@ const MgTabs = class {
5388
3417
  }
5389
3418
  get element() { return index.getElement(this); }
5390
3419
  static get watchers() { return {
3420
+ "label": ["validateLabel"],
5391
3421
  "size": ["validateSize"],
5392
3422
  "items": ["validateItems"],
5393
3423
  "activeTab": ["validateActiveTab"]
@@ -5565,6 +3595,13 @@ const MgTooltip = class {
5565
3595
  this.guard = undefined;
5566
3596
  };
5567
3597
  }
3598
+ validateMessage(newValue) {
3599
+ if (typeof newValue !== 'string' || newValue.trim() === '') {
3600
+ // TODO: throw new Error on next major (5.0.0)
3601
+ // throw new Error('<mg-tooltip> prop "message" is required.');
3602
+ console.error('<mg-tooltip> prop "message" is required.');
3603
+ }
3604
+ }
5568
3605
  handleDisplay(newValue) {
5569
3606
  if (newValue) {
5570
3607
  this.show();
@@ -5606,7 +3643,7 @@ const MgTooltip = class {
5606
3643
  slotElement.setAttribute('aria-describedby', `${ariaDescribedby} ${this.identifier}`);
5607
3644
  }
5608
3645
  // Create popperjs tooltip
5609
- this.popper = createPopper(tooltipedElement, this.tooltip, {
3646
+ this.popper = popper.createPopper(tooltipedElement, this.tooltip, {
5610
3647
  placement: this.placement,
5611
3648
  modifiers: [
5612
3649
  {
@@ -5645,6 +3682,7 @@ const MgTooltip = class {
5645
3682
  });
5646
3683
  });
5647
3684
  this.handleDisplay(this.display);
3685
+ this.validateMessage(this.message);
5648
3686
  }
5649
3687
  /**
5650
3688
  * Render
@@ -5656,6 +3694,7 @@ const MgTooltip = class {
5656
3694
  }
5657
3695
  get element() { return index.getElement(this); }
5658
3696
  static get watchers() { return {
3697
+ "message": ["validateMessage"],
5659
3698
  "display": ["handleDisplay"]
5660
3699
  }; }
5661
3700
  };
@@ -5681,7 +3720,6 @@ exports.mg_input_toggle = MgInputToggle;
5681
3720
  exports.mg_message = MgMessage;
5682
3721
  exports.mg_pagination = MgPagination;
5683
3722
  exports.mg_panel = MgPanel;
5684
- exports.mg_popover = MgPopover;
5685
3723
  exports.mg_tabs = MgTabs;
5686
3724
  exports.mg_tag = MgTag;
5687
3725
  exports.mg_tooltip = MgTooltip;