@mgdis/mg-components 6.17.0 → 6.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/cjs/index-DCZEYvlH.js +4 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/mg-action-more_37.cjs.entry.js +411 -168
  4. package/dist/cjs/mg-alert.cjs.entry.js +1 -1
  5. package/dist/cjs/mg-components.cjs.js +1 -1
  6. package/dist/cjs/mg-fieldset.cjs.entry.js +141 -0
  7. package/dist/cjs/mg-input-combobox.cjs.entry.js +71 -55
  8. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +33 -20
  9. package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-HYIzRsy7.js} +5 -0
  10. package/dist/cjs/mg-loader.cjs.entry.js +1 -1
  11. package/dist/cjs/mg-progress.cjs.entry.js +1 -1
  12. package/dist/collection/collection-manifest.json +1 -0
  13. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +4 -0
  14. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +178 -18
  15. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +1 -1
  16. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +36 -16
  17. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +78 -55
  18. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +41 -22
  19. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +32 -12
  20. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +30 -12
  21. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +31 -12
  22. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +40 -20
  23. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +31 -12
  24. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +44 -25
  25. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +31 -13
  26. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +36 -11
  27. package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +5 -1
  28. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
  29. package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
  30. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  31. package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +404 -0
  32. package/dist/collection/components/molecules/mg-form/mg-form.js +13 -4
  33. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
  34. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  35. package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
  36. package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
  37. package/dist/collection/components/molecules/mg-panel/mg-panel.js +40 -9
  38. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  39. package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
  40. package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
  41. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  42. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
  43. package/dist/components/mg-action-more.js +1 -1
  44. package/dist/components/mg-alert.js +1 -1
  45. package/dist/components/mg-details.js +1 -1
  46. package/dist/components/mg-fieldset.d.ts +11 -0
  47. package/dist/components/mg-fieldset.js +209 -0
  48. package/dist/components/mg-form.js +4 -3
  49. package/dist/components/mg-illustrated-message.js +1 -1
  50. package/dist/components/mg-input-checkbox-paginated2.js +1 -1
  51. package/dist/components/mg-input-checkbox.js +28 -15
  52. package/dist/components/mg-input-combobox.js +71 -55
  53. package/dist/components/mg-input-date.js +33 -21
  54. package/dist/components/mg-input-numeric.js +24 -11
  55. package/dist/components/mg-input-password.js +22 -11
  56. package/dist/components/mg-input-radio.js +23 -11
  57. package/dist/components/mg-input-rich-text-editor.js +32 -19
  58. package/dist/components/mg-input-select2.js +24 -12
  59. package/dist/components/mg-input-text2.js +36 -24
  60. package/dist/components/mg-input-textarea.js +23 -12
  61. package/dist/components/mg-input-toggle.js +35 -10
  62. package/dist/components/mg-input2.js +117 -18
  63. package/dist/components/mg-item-more2.js +5 -1
  64. package/dist/components/mg-loader2.js +1 -1
  65. package/dist/components/mg-message2.js +2 -2
  66. package/dist/components/mg-modal.js +2 -2
  67. package/dist/components/mg-panel.js +36 -7
  68. package/dist/components/mg-popover-content2.js +1 -1
  69. package/dist/components/mg-popover2.js +1 -1
  70. package/dist/components/mg-progress.js +1 -1
  71. package/dist/components/mg-skip-links.js +1 -1
  72. package/dist/components/mg-tabs2.js +1 -1
  73. package/dist/esm/{index-WtiuOkLj.js → index-C7xjtdiw.js} +1 -1
  74. package/dist/esm/index-T6kOJXP1.js +4 -0
  75. package/dist/esm/loader.js +1 -1
  76. package/dist/esm/mg-action-more_37.entry.js +412 -169
  77. package/dist/esm/mg-alert.entry.js +2 -2
  78. package/dist/esm/mg-components.js +1 -1
  79. package/dist/esm/mg-fieldset.entry.js +139 -0
  80. package/dist/esm/mg-input-combobox.entry.js +72 -56
  81. package/dist/esm/mg-input-rich-text-editor.entry.js +34 -21
  82. package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-D9V2v4n2.js} +5 -1
  83. package/dist/esm/mg-loader.entry.js +2 -2
  84. package/dist/esm/mg-progress.entry.js +2 -2
  85. package/dist/mg-components/mg-components.esm.js +1 -1
  86. package/dist/mg-components/p-2bab89c2.entry.js +1 -0
  87. package/dist/mg-components/{p-0e6b40d6.entry.js → p-5abc77cd.entry.js} +1 -1
  88. package/dist/mg-components/p-7d2e43b2.entry.js +1 -0
  89. package/dist/mg-components/{p-5dc3a1fb.entry.js → p-92e5e5a6.entry.js} +1 -1
  90. package/dist/mg-components/{p-c5da335e.entry.js → p-952288bd.entry.js} +1 -1
  91. package/dist/mg-components/{p-WtiuOkLj.js → p-C7xjtdiw.js} +1 -1
  92. package/dist/mg-components/p-D9V2v4n2.js +1 -0
  93. package/dist/mg-components/p-f2cddd52.entry.js +1 -0
  94. package/dist/mg-components/{p-397bf67b.entry.js → p-f6afaeb8.entry.js} +1 -1
  95. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +5 -0
  96. package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +32 -1
  97. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -3
  98. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +4 -2
  99. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -2
  100. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +4 -2
  101. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -2
  102. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
  103. package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -2
  104. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -2
  105. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +4 -2
  106. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -2
  107. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -2
  108. package/dist/types/components/molecules/mg-fieldset/mg-fieldset.d.ts +105 -0
  109. package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
  110. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +8 -1
  111. package/dist/types/components.d.ts +168 -18
  112. package/ide/intellij/web-types.json +272 -9
  113. package/ide/vscode/html-custom-data.json +243 -5
  114. package/package.json +15 -15
  115. package/dist/mg-components/p-8a69175b.entry.js +0 -1
  116. package/dist/mg-components/p-CNgv8hc5.js +0 -1
  117. package/dist/mg-components/p-d84d87ea.entry.js +0 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  var index$1 = require('./index-DCZEYvlH.js');
4
4
  var index = require('./index-CpENFzEo.js');
5
- var mgInput_conf = require('./mg-input.conf-WTsvDfpC.js');
5
+ var mgInput_conf = require('./mg-input.conf-HYIzRsy7.js');
6
6
  var index$2 = require('./index-TUElr4Wv.js');
7
7
 
8
8
  /** Detect free variable `global` from Node.js. */
@@ -16389,6 +16389,7 @@ const MgInputRichTextEditor = class {
16389
16389
  this.valueChange = index$1.createEvent(this, "value-change", 7);
16390
16390
  // hasDisplayedError (triggered by blur event)
16391
16391
  this.hasDisplayedError = false;
16392
+ this.customErrorMessage = { lock: false };
16392
16393
  // Classes
16393
16394
  this.classFocus = 'mg-u-is-focused';
16394
16395
  /**
@@ -16454,20 +16455,23 @@ const MgInputRichTextEditor = class {
16454
16455
  };
16455
16456
  /**
16456
16457
  * Set input error message
16457
- * @param errorMessage - errorMessage override
16458
+ * @param fromSetErrorContext - context come from `setError` method
16458
16459
  */
16459
- this.setErrorMessage = (errorMessage) => {
16460
+ this.setErrorMessage = (fromSetErrorContext = false) => {
16461
+ // Set error message
16460
16462
  this.errorMessage = undefined;
16461
- if (this.valid)
16462
- return;
16463
- else if (index.isValidString(errorMessage)) {
16464
- this.errorMessage = errorMessage;
16465
- }
16466
- else if (this.required && this.isEmpty()) {
16467
- this.errorMessage = this.messages.errors.required;
16468
- }
16469
- else if (!this.getPatternValidity()) {
16470
- this.errorMessage = this.patternErrorMessage;
16463
+ // Does have a new custom error message
16464
+ if (!this.valid) {
16465
+ // Does have a new custom error message OR does have a custom error message locked
16466
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
16467
+ this.errorMessage = this.customErrorMessage.message;
16468
+ }
16469
+ else if (this.required && this.isEmpty()) {
16470
+ this.errorMessage = this.messages.errors.required;
16471
+ }
16472
+ else if (!this.getPatternValidity()) {
16473
+ this.errorMessage = this.patternErrorMessage;
16474
+ }
16471
16475
  }
16472
16476
  };
16473
16477
  /**
@@ -16595,17 +16599,22 @@ const MgInputRichTextEditor = class {
16595
16599
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
16596
16600
  * @param valid - value indicating the validity
16597
16601
  * @param errorMessage - the error message to display
16602
+ * @param errorMessageLock - lock the error message and validity state
16598
16603
  */
16599
- async setError(valid, errorMessage) {
16604
+ async setError(valid, errorMessage, errorMessageLock = false) {
16600
16605
  if (typeof valid !== 'boolean') {
16601
16606
  throw new Error('<mg-input-rich-text-editor> method "setError()" param "valid" must be a boolean.');
16602
16607
  }
16603
- else if (!index.isValidString(errorMessage)) {
16608
+ else if (errorMessage !== undefined && !index.isValidString(errorMessage)) {
16604
16609
  throw new Error('<mg-input-rich-text-editor> method "setError()" param "errorMessage" must be a string.');
16605
16610
  }
16606
16611
  else {
16612
+ this.customErrorMessage = {
16613
+ lock: valid ? false : errorMessageLock,
16614
+ message: valid ? undefined : errorMessage,
16615
+ };
16607
16616
  this.setValidity(valid);
16608
- this.setErrorMessage(valid ? undefined : errorMessage);
16617
+ this.setErrorMessage(true);
16609
16618
  this.hasDisplayedError = this.invalid;
16610
16619
  }
16611
16620
  }
@@ -16624,6 +16633,8 @@ const MgInputRichTextEditor = class {
16624
16633
  // - Keep everything in sync both inside and outside the component
16625
16634
  return new Promise(resolve => {
16626
16635
  requestAnimationFrame(() => {
16636
+ // unlock validity check by reseting customErrorMessage
16637
+ this.customErrorMessage = { lock: false };
16627
16638
  this.checkValidity();
16628
16639
  this.errorMessage = undefined;
16629
16640
  this.hasDisplayedError = false;
@@ -16637,10 +16648,12 @@ const MgInputRichTextEditor = class {
16637
16648
  * @param newValue - valid new value
16638
16649
  */
16639
16650
  setValidity(newValue) {
16640
- const oldValidValue = this.valid;
16641
- this.valid = newValue;
16651
+ const oldValue = this.valid;
16652
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
16653
+ this.valid = newValue;
16654
+ }
16642
16655
  this.invalid = !this.valid;
16643
- if (this.valid !== oldValidValue) {
16656
+ if (this.valid !== oldValue) {
16644
16657
  this.inputValid.emit(this.valid);
16645
16658
  }
16646
16659
  }
@@ -16689,7 +16702,7 @@ const MgInputRichTextEditor = class {
16689
16702
  * @returns HTML mg-input Element
16690
16703
  */
16691
16704
  render() {
16692
- return (index$1.h("mg-input", { key: 'b7f7fe282aa00b695418fe7f055955045bbd932d', identifier: this.identifier, class: this.classCollection.join(), label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, helpText: this.helpText, errorMessage: this.hasDisplayedError ? this.errorMessage : undefined }, this.readonly ? (index$1.h("div", { class: "mg-c-input__readonly-value", innerHTML: this.value })) : (index$1.h("div", { ref: el => {
16705
+ return (index$1.h("mg-input", { key: '2f8f244cb60996c9cbe891b04168b5aea420d3a0', identifier: this.identifier, class: this.classCollection.join(), label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, helpText: this.helpText, errorMessage: this.hasDisplayedError ? this.errorMessage : undefined }, this.readonly ? (index$1.h("div", { class: "mg-c-input__readonly-value", innerHTML: this.value })) : (index$1.h("div", { ref: el => {
16693
16706
  this.wrapperElement = el;
16694
16707
  }, id: this.identifier, class: "mg-c-input__wrapper" }, index$1.h("div", null)))));
16695
16708
  }
@@ -8,6 +8,10 @@ const widths = [2, 4, 16, 'full'];
8
8
  * Possible tootltip postions
9
9
  */
10
10
  const tooltipPositions = ['input', 'label'];
11
+ /**
12
+ * Possible label headings
13
+ */
14
+ const labelHeadings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
11
15
  const classFieldset = 'mg-c-input--fieldset';
12
16
  const classDisabled = 'mg-c-input--disabled';
13
17
  const classReadonly = 'mg-c-input--readonly';
@@ -17,5 +21,6 @@ exports.classDisabled = classDisabled;
17
21
  exports.classFieldset = classFieldset;
18
22
  exports.classReadonly = classReadonly;
19
23
  exports.classVerticalList = classVerticalList;
24
+ exports.labelHeadings = labelHeadings;
20
25
  exports.tooltipPositions = tooltipPositions;
21
26
  exports.widths = widths;
@@ -35,7 +35,7 @@ const MgLoader = class {
35
35
  * @returns HTML Element
36
36
  */
37
37
  render() {
38
- return (index.h("div", { key: 'b74028455b7003824fa5618b1751d05a91ab7071', class: "mg-c-loader", "aria-live": "polite" }, index.h("mg-icon", { key: '204acdb8f881b348148020214c05269878852c4f', icon: "loader", spin: true }), index.h("span", { key: '40f1792354df01ec9af61ab128575ea166f34cb5', class: { 'mg-u-visually-hidden': this.messageHide } }, this.message || this.messages.loader.inProgress)));
38
+ return (index.h("div", { key: '739b4cbacd8a8da056dbb1445c40fac2cf26766a', class: "mg-c-loader", "aria-live": "polite" }, index.h("mg-icon", { key: '95d3cbf26fcd6dbf0dad4853bf55aa66385f1aba', icon: "loader", spin: true }), index.h("span", { key: 'f6322cd3054d8976bd2ec24f86a2d6bb60ca7ae1', class: { 'mg-u-visually-hidden': this.messageHide } }, this.message || this.messages.loader.inProgress)));
39
39
  }
40
40
  get element() { return index.getElement(this); }
41
41
  static get watchers() { return {
@@ -75,7 +75,7 @@ const MgProgress = class {
75
75
  * @returns HTML Element
76
76
  */
77
77
  render() {
78
- return (index.h(index.Host, { key: '62c66dbd93249bfde3eb8ff449b49884edfe49c3', role: this.ariaRole, "aria-label": this.label, "aria-valuenow": this.value, "aria-valuemin": this.min, "aria-valuemax": this.max }, index.h("div", { key: 'b349c9d7358086ca4668705a1935fd8bbdb86afa', class: "mg-c-progress" }, index.h("div", { key: '57cc19d07c0f006f8ecf3a1f86ec12e37ffd8d6b', class: { 'mg-c-progress__bar': true, 'mg-c-progress__bar--active': this.value > this.min } }, index.h("div", { key: 'b4c49d94d9cfe2e1a6d8013aa4a39cde51b36d04', class: "mg-c-progress__fill", style: {
78
+ return (index.h(index.Host, { key: '8e6c727e9416fa777fd94b32d618a9137e8e08f7', role: this.ariaRole, "aria-label": this.label, "aria-valuenow": this.value, "aria-valuemin": this.min, "aria-valuemax": this.max }, index.h("div", { key: 'ac42ee9c5dda55d70aad7391895e4a013aaa27f9', class: "mg-c-progress" }, index.h("div", { key: '34c77bc6c133bc59b9daa68d7d6c8534f13f7d37', class: { 'mg-c-progress__bar': true, 'mg-c-progress__bar--active': this.value > this.min } }, index.h("div", { key: '7ea03a3f0c54ca0c81616c7c070d178a510dd7e1', class: "mg-c-progress__fill", style: {
79
79
  width: `${Math.round(((this.value - this.min) / (this.max - this.min)) * 100)}%`,
80
80
  } })))));
81
81
  }
@@ -29,6 +29,7 @@
29
29
  "components/molecules/mg-action-more/mg-action-more.js",
30
30
  "components/molecules/mg-alert/mg-alert.js",
31
31
  "components/molecules/mg-details/mg-details.js",
32
+ "components/molecules/mg-fieldset/mg-fieldset.js",
32
33
  "components/molecules/mg-form/mg-form.js",
33
34
  "components/molecules/mg-illustrated-message/mg-illustrated-message.js",
34
35
  "components/molecules/mg-loader/mg-loader.js",
@@ -6,6 +6,10 @@ export const widths = [2, 4, 16, 'full'];
6
6
  * Possible tootltip postions
7
7
  */
8
8
  export const tooltipPositions = ['input', 'label'];
9
+ /**
10
+ * Possible label headings
11
+ */
12
+ export const labelHeadings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
9
13
  export const classFieldset = 'mg-c-input--fieldset';
10
14
  export const classDisabled = 'mg-c-input--disabled';
11
15
  export const classReadonly = 'mg-c-input--readonly';
@@ -1,6 +1,6 @@
1
1
  import { h, Host } from "@stencil/core";
2
2
  import { isValideID, isValidString, toString } from "@mgdis/core-ui-helpers/dist/utils";
3
- import { tooltipPositions, classFieldset, classReadonly, classDisabled, classVerticalList } from "./mg-input.conf";
3
+ import { tooltipPositions, classFieldset, classReadonly, classDisabled, classVerticalList, labelHeadings } from "./mg-input.conf";
4
4
  /**
5
5
  * @slot - Input content
6
6
  */
@@ -13,6 +13,9 @@ export class MgInput {
13
13
  this.classInput = 'mg-c-input';
14
14
  this.classHasError = 'mg-c-input--has-error';
15
15
  this.classLabelOnTop = 'mg-c-input--label-on-top';
16
+ this.classHasHeading = 'mg-c-input--has-heading';
17
+ this.classLabelBorderDisplay = 'mg-c-input--label-border-display';
18
+ this.classInputsOnBottom = 'mg-c-input--inputs-on-bottom';
16
19
  /**
17
20
  * Define if label is displayed on top
18
21
  */
@@ -21,6 +24,11 @@ export class MgInput {
21
24
  * Define if label is visible
22
25
  */
23
26
  this.labelHide = false;
27
+ /**
28
+ * Define if label border is visible
29
+ * You must pair this mode with `labelOnTop`and `fieldset` class
30
+ */
31
+ this.labelBorderDisplay = false;
24
32
  /**
25
33
  * Define tooltip position
26
34
  */
@@ -29,6 +37,10 @@ export class MgInput {
29
37
  * Define if input is required
30
38
  */
31
39
  this.required = false;
40
+ /**
41
+ * Display inputs after help-text and error message
42
+ */
43
+ this.inputsOnBottom = false;
32
44
  /**
33
45
  * Define aria-describedby ids to link with
34
46
  */
@@ -49,11 +61,44 @@ export class MgInput {
49
61
  * Element is disabled
50
62
  */
51
63
  this.isVerticalList = false;
64
+ /************
65
+ * Methods *
66
+ ************/
67
+ /**
68
+ * Update element aria-describedby
69
+ * @param element - element to update
70
+ * @param ariaDescribedbyIDs - ariaDescribedbyIDs references
71
+ */
72
+ this.updateElementAriaDescribedby = (element, ariaDescribedbyIDs) => {
73
+ if (ariaDescribedbyIDs.size > 0) {
74
+ element.setAttribute('aria-describedby', Array.from(ariaDescribedbyIDs).join(' '));
75
+ }
76
+ else {
77
+ element.removeAttribute('aria-describedby');
78
+ }
79
+ };
52
80
  /**
53
81
  * Get tooltip node
54
82
  * @returns mg-tooltip
55
83
  */
56
84
  this.renderTooltip = () => (h("mg-tooltip", { identifier: `${this.identifier}-tooltip`, message: this.tooltip }, h("mg-icon", { icon: "info-circle" })));
85
+ /**
86
+ * Get input container element
87
+ * @returns ordered elements
88
+ */
89
+ this.inputContainerElements = () => {
90
+ const elements = [
91
+ this.helptextMessageSlotElement && (h("div", { class: "mg-c-input__help-text" }, h("slot", { name: this.slotHelpText }))),
92
+ !this.isDisabled && this.errorMessage && (h("div", { class: "mg-c-input__error", "aria-live": "assertive" }, h("slot", { name: this.slotError }))),
93
+ ];
94
+ const inputSlot = (h("div", { class: "mg-c-input__input" }, h("slot", null), this.tooltip && !this.labelOnTop && (this.tooltipPosition === 'input' || this.labelHide) && this.renderTooltip()));
95
+ if (this.inputsOnBottom) {
96
+ return [...elements, inputSlot];
97
+ }
98
+ else {
99
+ return [inputSlot, ...elements];
100
+ }
101
+ };
57
102
  }
58
103
  watchIdentifier(newValue) {
59
104
  if (!isValidString(newValue)) {
@@ -80,6 +125,26 @@ export class MgInput {
80
125
  throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide".');
81
126
  }
82
127
  }
128
+ watchlabelHeading(newValue) {
129
+ if (this.isFieldset && this.labelOnTop && labelHeadings.includes(newValue)) {
130
+ this.element.classList.add(this.classHasHeading);
131
+ }
132
+ else {
133
+ if ((!this.isFieldset && newValue !== undefined) || typeof newValue === 'string') {
134
+ throw new Error(`<mg-input> prop "labelHeading" must be used with a fieldset and be one of: ${labelHeadings.join(', ')}. Passed value: ${toString(newValue)}.`);
135
+ }
136
+ this.labelHeading = undefined;
137
+ this.element.classList.remove(this.classHasHeading);
138
+ }
139
+ }
140
+ watchLabelBorderDisplay(newValue) {
141
+ if (this.isFieldset && this.labelOnTop && newValue) {
142
+ this.element.classList.add(this.classLabelBorderDisplay);
143
+ }
144
+ else {
145
+ this.element.classList.remove(this.classLabelBorderDisplay);
146
+ }
147
+ }
83
148
  watchTooltipPosition(newValue) {
84
149
  if (!tooltipPositions.includes(newValue)) {
85
150
  throw new Error(`<mg-input> prop "tooltipPosition" must be one of: ${tooltipPositions.join(', ')}. Passed value: ${toString(newValue)}.`);
@@ -99,7 +164,7 @@ export class MgInput {
99
164
  }
100
165
  watchHelpText(newValue) {
101
166
  var _a;
102
- if (newValue && !this.isReadonly) {
167
+ if (isValidString(newValue) && !this.isReadonly) {
103
168
  this.renderHelpText();
104
169
  }
105
170
  else {
@@ -107,6 +172,14 @@ export class MgInput {
107
172
  this.helptextMessageSlotElement = undefined;
108
173
  }
109
174
  }
175
+ watchInputsOnBottom(newValue) {
176
+ if (newValue) {
177
+ this.element.classList.add(this.classInputsOnBottom);
178
+ }
179
+ else {
180
+ this.element.classList.remove(this.classInputsOnBottom);
181
+ }
182
+ }
110
183
  watchAriaDescribedbyIDs() {
111
184
  if (this.isReadonly) {
112
185
  return;
@@ -122,23 +195,26 @@ export class MgInput {
122
195
  // a11y IDs
123
196
  const ariaDescribedbyIDs = new Set(this.ariaDescribedbyIDs);
124
197
  // Help text
125
- if (this.helpText !== undefined) {
198
+ if (isValidString(this.helpText)) {
126
199
  this.renderHelpText();
127
200
  if (!ariaDescribedbyIDs.has(this.helpTextId))
128
201
  ariaDescribedbyIDs.add(this.helpTextId);
129
202
  }
130
203
  // Error Message
131
- if (this.errorMessage !== undefined) {
204
+ if (isValidString(this.errorMessage)) {
132
205
  this.renderErrorMessage();
133
206
  if (!ariaDescribedbyIDs.has(this.helpTextErrorId))
134
207
  ariaDescribedbyIDs.add(this.helpTextErrorId);
135
208
  }
136
- this.element.querySelectorAll('input,select,textarea,[role="switch"]').forEach(element => {
137
- if (ariaDescribedbyIDs.size > 0) {
138
- element.setAttribute('aria-describedby', Array.from(ariaDescribedbyIDs).join(' '));
139
- }
140
- else {
141
- element.removeAttribute('aria-describedby');
209
+ const inputs = this.element.querySelectorAll('input,select,textarea,[role="switch"]');
210
+ inputs.forEach((element) => {
211
+ this.updateElementAriaDescribedby(element, ariaDescribedbyIDs);
212
+ });
213
+ // use timeout to await for legend render for componentWillLoad hook
214
+ setTimeout(() => {
215
+ const legend = this.element.querySelector('legend');
216
+ if (legend !== null) {
217
+ this.updateElementAriaDescribedby(legend, ariaDescribedbyIDs);
142
218
  }
143
219
  });
144
220
  }
@@ -168,9 +244,6 @@ export class MgInput {
168
244
  this.renderLabel();
169
245
  }
170
246
  }
171
- /************
172
- * Methods *
173
- ************/
174
247
  /**
175
248
  * Render input label
176
249
  */
@@ -190,11 +263,21 @@ export class MgInput {
190
263
  labelSlotElement.setAttribute(attr, val);
191
264
  });
192
265
  // create label element
193
- const label = document.createElement('span');
194
- label.classList.add('mg-c-input-title__text');
195
- label.textContent = this.label;
196
- labelSlotElement.appendChild(label);
266
+ if (labelHeadings.includes(this.labelHeading)) {
267
+ let label = this.element.shadowRoot.querySelector(this.labelHeading);
268
+ if (label === null) {
269
+ label = document.createElement(this.labelHeading);
270
+ label.classList.add('mg-c-input-title__text');
271
+ labelSlotElement.appendChild(label);
272
+ }
273
+ label.textContent = this.label;
274
+ }
275
+ else {
276
+ labelSlotElement.textContent = this.label;
277
+ }
197
278
  this.element.appendChild(labelSlotElement);
279
+ // update aria-describedby
280
+ this.watchAriaDescribedbyIDs();
198
281
  }
199
282
  /**
200
283
  * Render error message
@@ -237,6 +320,9 @@ export class MgInput {
237
320
  this.watchTooltipPosition(this.tooltipPosition);
238
321
  this.watchHelpText(this.helpText);
239
322
  this.watchErrorMessage(this.errorMessage);
323
+ this.watchInputsOnBottom(this.inputsOnBottom);
324
+ this.watchlabelHeading(this.labelHeading);
325
+ this.watchLabelBorderDisplay(this.labelBorderDisplay);
240
326
  }
241
327
  /**
242
328
  * Validate slots
@@ -253,7 +339,7 @@ export class MgInput {
253
339
  */
254
340
  render() {
255
341
  const isGroup = this.isFieldset && !this.isReadonly;
256
- return (h(Host, { key: '7c4c22aaa8f8d250eafa9159a103a11e637b0cca', class: this.element.classList.toString(), role: isGroup ? 'group' : undefined, "aria-labelledby": isGroup ? `${this.identifier}-title` : undefined }, h("div", { key: '2215e7b2d96e08507579a39d8e05b3e8a3d901fb', class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': this.labelHide } }, h("slot", { key: 'a4dbf4e36dd3ae5437d6dcb05d807f4faa0924b7', name: this.slotLabel }), this.tooltip && (this.tooltipPosition === 'label' || this.labelOnTop) && !this.labelHide && this.renderTooltip()), h("div", { key: '8e382a4857f469a9d6f77cad613183798df4d1e1', class: "mg-c-input__input-container" }, h("div", { key: 'f9897f90d44aab19614d4d40d77a8eb270c92847', class: "mg-c-input__input" }, h("slot", { key: 'c8d809d4ff0d0e660849825f016f9267da3a2d7e' }), this.tooltip && !this.labelOnTop && (this.tooltipPosition === 'input' || this.labelHide) && this.renderTooltip()), this.helptextMessageSlotElement && (h("div", { key: 'cebd6c083d088aebcdae6f032c6cdcf2387c3e27', class: "mg-c-input__help-text" }, h("slot", { key: '923fcc78b309d197e32522052b297ef0f58b1495', name: this.slotHelpText }))), !this.isDisabled && this.errorMessage && (h("div", { key: 'e706bff54ce21191a8c0940c60f6e99a91cfb9ec', class: "mg-c-input__error", "aria-live": "assertive" }, h("slot", { key: '6524debd3640df7b5e73ef4aa4415569eef1ecd8', name: this.slotError }))))));
342
+ return (h(Host, { key: 'fbab18280a709407c83f324127e8de6cbb05fe7c', class: this.element.classList.toString(), role: isGroup ? 'group' : undefined, "aria-labelledby": isGroup ? `${this.identifier}-title` : undefined }, h("div", { key: 'ac0924c244b9fa87d02e659a5710ee93d12a202f', class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': this.labelHide } }, h("slot", { key: 'c825af33ba0a6c209d02d6487422347f7d8acfed', name: this.slotLabel }), this.tooltip && (this.tooltipPosition === 'label' || this.labelOnTop) && !this.labelHide && this.renderTooltip()), h("div", { key: '805e1eedfdea132f3ea4fd11da761810a3d7c939', class: "mg-c-input__input-container" }, this.inputContainerElements())));
257
343
  }
258
344
  static get is() { return "mg-input"; }
259
345
  static get encapsulation() { return "shadow"; }
@@ -347,6 +433,51 @@ export class MgInput {
347
433
  "attribute": "label-hide",
348
434
  "defaultValue": "false"
349
435
  },
436
+ "labelHeading": {
437
+ "type": "string",
438
+ "mutable": true,
439
+ "complexType": {
440
+ "original": "labelHeading",
441
+ "resolved": "\"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\"",
442
+ "references": {
443
+ "labelHeading": {
444
+ "location": "import",
445
+ "path": "./mg-input.conf",
446
+ "id": "src/components/molecules/inputs/mg-input/mg-input.conf.ts::labelHeading"
447
+ }
448
+ }
449
+ },
450
+ "required": false,
451
+ "optional": true,
452
+ "docs": {
453
+ "tags": [],
454
+ "text": "Define label heading, use to define label with associated semantic\nYou must pair this mode with `labelOnTop`and `fieldset` class"
455
+ },
456
+ "getter": false,
457
+ "setter": false,
458
+ "reflect": false,
459
+ "attribute": "label-heading"
460
+ },
461
+ "labelBorderDisplay": {
462
+ "type": "boolean",
463
+ "mutable": false,
464
+ "complexType": {
465
+ "original": "boolean",
466
+ "resolved": "boolean",
467
+ "references": {}
468
+ },
469
+ "required": false,
470
+ "optional": false,
471
+ "docs": {
472
+ "tags": [],
473
+ "text": "Define if label border is visible\nYou must pair this mode with `labelOnTop`and `fieldset` class"
474
+ },
475
+ "getter": false,
476
+ "setter": false,
477
+ "reflect": false,
478
+ "attribute": "label-border-display",
479
+ "defaultValue": "false"
480
+ },
350
481
  "tooltip": {
351
482
  "type": "string",
352
483
  "mutable": false,
@@ -450,6 +581,26 @@ export class MgInput {
450
581
  "reflect": false,
451
582
  "attribute": "help-text"
452
583
  },
584
+ "inputsOnBottom": {
585
+ "type": "boolean",
586
+ "mutable": false,
587
+ "complexType": {
588
+ "original": "boolean",
589
+ "resolved": "boolean",
590
+ "references": {}
591
+ },
592
+ "required": false,
593
+ "optional": true,
594
+ "docs": {
595
+ "tags": [],
596
+ "text": "Display inputs after help-text and error message"
597
+ },
598
+ "getter": false,
599
+ "setter": false,
600
+ "reflect": false,
601
+ "attribute": "inputs-on-bottom",
602
+ "defaultValue": "false"
603
+ },
453
604
  "ariaDescribedbyIDs": {
454
605
  "type": "string",
455
606
  "mutable": true,
@@ -494,6 +645,12 @@ export class MgInput {
494
645
  }, {
495
646
  "propName": "labelOnTop",
496
647
  "methodName": "watchLabelConfig"
648
+ }, {
649
+ "propName": "labelHeading",
650
+ "methodName": "watchlabelHeading"
651
+ }, {
652
+ "propName": "labelBorderDisplay",
653
+ "methodName": "watchLabelBorderDisplay"
497
654
  }, {
498
655
  "propName": "tooltipPosition",
499
656
  "methodName": "watchTooltipPosition"
@@ -503,6 +660,9 @@ export class MgInput {
503
660
  }, {
504
661
  "propName": "helpText",
505
662
  "methodName": "watchHelpText"
663
+ }, {
664
+ "propName": "inputsOnBottom",
665
+ "methodName": "watchInputsOnBottom"
506
666
  }, {
507
667
  "propName": "identifier",
508
668
  "methodName": "watchAriaDescribedbyIDs"
@@ -76,7 +76,7 @@ export class MgInputCheckboxPaginated {
76
76
  render() {
77
77
  const listId = formatID(this.messages.label);
78
78
  const tabId = 'tab-info';
79
- return (h(Host, { key: '8e58037e78fcd7990bbd681053758b0ec4d0c4e0' }, h("slot", { key: 'c64e9c8f65a526b2289d3663fff64df02a282c96', name: "header-action" }), h("div", { key: 'c5953bb7e970384b231865d7fa4708fe2da4b407', class: "mg-c-input__tabs-content" }, h("p", { key: 'c0899cb7e7a6dea282f05aacf0fb05acd60a9d20', id: tabId, class: { 'mg-c-input__popover-info': true, 'mg-u-visually-hidden': this.items.length !== 0 }, "aria-live": this.items.length !== 0 ? 'polite' : undefined }, this.items.length === 0 ? this.messages.noValue : this.messages.values.replace('{count}', this.items.length.toString())), this.items.length > 0 && (h(MgInputCheckboxList, { key: '0bb1b4160d75b00d3fb5d9c08f3a560a16105e57', checkboxes: this.items, labelledby: tabId, id: listId, disabled: this.disabled, name: this.name, invalid: this.invalid })), this.hasNext() && (h("mg-button", { key: "load-more", variant: "flat", class: "mg-c-input__load-more", tabIndex: -1, "full-width": true, onClick: this.handleLoadMore, "aria-controls": listId }, h("mg-icon", { key: 'fd1560d7254f437f284925427130f69539b5fd3b', icon: "chevron-down" }), this.messages.showMore)))));
79
+ return (h(Host, { key: '233ab4fca3f4a3121bc60650ac2f8ae06d47e6e5' }, h("slot", { key: '7d1af8c712928c06953743fc5c182e51d9a6256b', name: "header-action" }), h("div", { key: '95641bd218e36422a6b5b4ead8dd5498e8ac5fa4', class: "mg-c-input__tabs-content" }, h("p", { key: '34814dd1afc9f871cd032500b931e692d63cbd25', id: tabId, class: { 'mg-c-input__popover-info': true, 'mg-u-visually-hidden': this.items.length !== 0 }, "aria-live": this.items.length !== 0 ? 'polite' : undefined }, this.items.length === 0 ? this.messages.noValue : this.messages.values.replace('{count}', this.items.length.toString())), this.items.length > 0 && (h(MgInputCheckboxList, { key: '621077f291a401737157ad0cd9b9348537ef8bdc', checkboxes: this.items, labelledby: tabId, id: listId, disabled: this.disabled, name: this.name, invalid: this.invalid })), this.hasNext() && (h("mg-button", { key: "load-more", variant: "flat", class: "mg-c-input__load-more", tabIndex: -1, "full-width": true, onClick: this.handleLoadMore, "aria-controls": listId }, h("mg-icon", { key: 'cb00bbeb1575475b184cc9623db6c4cefc56c26a', icon: "chevron-down" }), this.messages.showMore)))));
80
80
  }
81
81
  static get is() { return "mg-input-checkbox-paginated"; }
82
82
  static get encapsulation() { return "scoped"; }
@@ -16,6 +16,7 @@ export class MgInputCheckbox {
16
16
  constructor() {
17
17
  // hasDisplayedError (triggered by blur event)
18
18
  this.hasDisplayedError = false;
19
+ this.customErrorMessage = { lock: false };
19
20
  this.mode = 'custom';
20
21
  // style
21
22
  this.baseClassName = 'mg-c-input--checkbox';
@@ -233,17 +234,20 @@ export class MgInputCheckbox {
233
234
  };
234
235
  /**
235
236
  * Set input error message
236
- * @param displayError - dispay error condition
237
- * @param errorMessage - errorMessage override
237
+ * @param fromSetErrorContext - context come from `setError` method
238
238
  */
239
- this.setErrorMessage = (displayError = true, errorMessage) => {
239
+ this.setErrorMessage = (fromSetErrorContext = false) => {
240
240
  // Set error message
241
241
  this.errorMessage = undefined;
242
- if (displayError && !this.valid) {
243
- if (errorMessage !== undefined)
244
- this.errorMessage = errorMessage;
245
- else if (!this.validateRequired())
242
+ if (!this.valid) {
243
+ // Does have a new custom error message OR does have a custom error message locked
244
+ if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
245
+ this.errorMessage = this.customErrorMessage.message;
246
+ }
247
+ // required
248
+ else if (!this.validateRequired()) {
246
249
  this.errorMessage = this.messages.errors.required;
250
+ }
247
251
  }
248
252
  };
249
253
  /**
@@ -337,7 +341,7 @@ export class MgInputCheckbox {
337
341
  this.checkValidity();
338
342
  if (this.hasDisplayedError) {
339
343
  this.hasDisplayedError = prop !== 'required';
340
- this.setErrorMessage(this.hasDisplayedError);
344
+ this.setErrorMessage();
341
345
  }
342
346
  this.setButtonTextKey();
343
347
  }
@@ -401,17 +405,22 @@ export class MgInputCheckbox {
401
405
  * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
402
406
  * @param valid - value indicating the validity
403
407
  * @param errorMessage - the error message to display
408
+ * @param errorMessageLock - lock the error message and validity state
404
409
  */
405
- async setError(valid, errorMessage) {
410
+ async setError(valid, errorMessage, errorMessageLock = false) {
406
411
  if (typeof valid !== 'boolean') {
407
412
  throw new Error('<mg-input-checkbox> method "setError()" param "valid" must be a boolean.');
408
413
  }
409
- else if (!isValidString(errorMessage)) {
414
+ else if (errorMessage !== undefined && !isValidString(errorMessage)) {
410
415
  throw new Error('<mg-input-checkbox> method "setError()" param "errorMessage" must be a string.');
411
416
  }
412
417
  else {
418
+ this.customErrorMessage = {
419
+ lock: valid ? false : errorMessageLock,
420
+ message: valid ? undefined : errorMessage,
421
+ };
413
422
  this.setValidity(valid);
414
- this.setErrorMessage(undefined, valid ? undefined : errorMessage);
423
+ this.setErrorMessage(true);
415
424
  this.hasDisplayedError = this.invalid;
416
425
  }
417
426
  }
@@ -429,6 +438,8 @@ export class MgInputCheckbox {
429
438
  // - Keep everything in sync both inside and outside the component
430
439
  return new Promise(resolve => {
431
440
  requestAnimationFrame(() => {
441
+ // unlock validity check by reseting customErrorMessage
442
+ this.customErrorMessage = { lock: false };
432
443
  this.checkValidity();
433
444
  this.errorMessage = undefined;
434
445
  this.hasDisplayedError = false;
@@ -442,11 +453,13 @@ export class MgInputCheckbox {
442
453
  * @param newValue - valid new value
443
454
  */
444
455
  setValidity(newValue) {
445
- const oldValidValue = this.valid;
446
- this.valid = newValue;
456
+ const oldValue = this.valid;
457
+ if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
458
+ this.valid = newValue;
459
+ }
447
460
  this.invalid = !this.valid;
448
461
  // We need to send valid event even if it is the same value
449
- if (this.valid !== oldValidValue)
462
+ if (this.valid !== oldValue)
450
463
  this.inputValid.emit(this.valid);
451
464
  }
452
465
  /**
@@ -565,7 +578,7 @@ export class MgInputCheckbox {
565
578
  else {
566
579
  inputContent = this.renderCheckboxMulti();
567
580
  }
568
- return (h("mg-input", { key: '84d13ac702497773013daa72357e4d1dcf4ebb30', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, tooltip: this.tooltip, tooltipPosition: this.readonly && readonlyValue.length === 0 ? 'label' : this.tooltipPosition, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined }, inputContent));
581
+ return (h("mg-input", { key: '5addea288b5c87fec33a56449d14f861aefd465d', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, tooltip: this.tooltip, tooltipPosition: this.readonly && readonlyValue.length === 0 ? 'label' : this.tooltipPosition, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined }, inputContent));
569
582
  }
570
583
  static get is() { return "mg-input-checkbox"; }
571
584
  static get encapsulation() { return "shadow"; }
@@ -1081,7 +1094,7 @@ export class MgInputCheckbox {
1081
1094
  },
1082
1095
  "setError": {
1083
1096
  "complexType": {
1084
- "signature": "(valid: MgInputCheckbox[\"valid\"], errorMessage: string) => Promise<void>",
1097
+ "signature": "(valid: MgInputCheckbox[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
1085
1098
  "parameters": [{
1086
1099
  "name": "valid",
1087
1100
  "type": "boolean",
@@ -1090,6 +1103,10 @@ export class MgInputCheckbox {
1090
1103
  "name": "errorMessage",
1091
1104
  "type": "string",
1092
1105
  "docs": "- the error message to display"
1106
+ }, {
1107
+ "name": "errorMessageLock",
1108
+ "type": "boolean",
1109
+ "docs": "- lock the error message and validity state"
1093
1110
  }],
1094
1111
  "references": {
1095
1112
  "Promise": {
@@ -1111,6 +1128,9 @@ export class MgInputCheckbox {
1111
1128
  }, {
1112
1129
  "name": "param",
1113
1130
  "text": "errorMessage - the error message to display"
1131
+ }, {
1132
+ "name": "param",
1133
+ "text": "errorMessageLock - lock the error message and validity state"
1114
1134
  }]
1115
1135
  }
1116
1136
  },