@mgdis/mg-components 5.10.0 → 5.10.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 (131) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/mg-action-more_31.cjs.entry.js +318 -427
  3. package/dist/cjs/mg-components.cjs.js +1 -1
  4. package/dist/cjs/mg-item-more.cjs.entry.js +19 -28
  5. package/dist/cjs/{mg-menu.conf-1942ac70.js → mg-menu.conf-196151fe.js} +16 -16
  6. package/dist/collection/components/atoms/mg-badge/mg-badge.js +8 -9
  7. package/dist/collection/components/atoms/mg-button/mg-button.js +16 -20
  8. package/dist/collection/components/atoms/mg-card/mg-card.js +10 -12
  9. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +1 -2
  10. package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
  11. package/dist/collection/components/atoms/mg-icon/mg-icon.js +17 -19
  12. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -2
  13. package/dist/collection/components/atoms/mg-tag/mg-tag.js +11 -13
  14. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +11 -21
  15. package/dist/collection/components/molecules/inputs/MgInput.conf.js +4 -1
  16. package/dist/collection/components/molecules/inputs/MgInput.js +26 -18
  17. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +10 -14
  18. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +7 -12
  19. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +14 -22
  20. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +6 -10
  21. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -18
  22. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +21 -32
  23. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +16 -31
  24. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +13 -17
  25. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +17 -23
  26. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +11 -18
  27. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +20 -29
  28. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +11 -15
  29. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -3
  30. package/dist/collection/components/molecules/mg-form/mg-form.js +8 -19
  31. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -2
  32. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +4 -7
  33. package/dist/collection/components/molecules/mg-message/mg-message.js +11 -14
  34. package/dist/collection/components/molecules/mg-modal/mg-modal.js +7 -11
  35. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +11 -13
  36. package/dist/collection/components/molecules/mg-panel/mg-panel.js +6 -15
  37. package/dist/collection/components/molecules/mg-popover/mg-popover.js +7 -13
  38. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +2 -4
  39. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +20 -24
  40. package/dist/collection/locales/index.js +2 -2
  41. package/dist/collection/utils/behaviors.utils.js +16 -22
  42. package/dist/collection/utils/components.utils.js +21 -23
  43. package/dist/collection/utils/locale.utils.js +14 -14
  44. package/dist/collection/utils/unit.test.utils.js +7 -10
  45. package/dist/components/MgInput.js +30 -18
  46. package/dist/components/components.utils.js +21 -23
  47. package/dist/components/index2.js +16 -16
  48. package/dist/components/mg-action-more.js +9 -13
  49. package/dist/components/mg-badge2.js +8 -9
  50. package/dist/components/mg-button2.js +16 -20
  51. package/dist/components/mg-card2.js +8 -10
  52. package/dist/components/mg-character-left2.js +1 -2
  53. package/dist/components/mg-details.js +1 -3
  54. package/dist/components/mg-divider.js +1 -1
  55. package/dist/components/mg-form.js +7 -15
  56. package/dist/components/mg-icon2.js +17 -19
  57. package/dist/components/mg-illustrated-message.js +1 -2
  58. package/dist/components/mg-input-checkbox.js +9 -10
  59. package/dist/components/mg-input-date.js +6 -8
  60. package/dist/components/mg-input-numeric.js +13 -18
  61. package/dist/components/mg-input-password.js +5 -6
  62. package/dist/components/mg-input-radio.js +9 -14
  63. package/dist/components/mg-input-select2.js +20 -28
  64. package/dist/components/mg-input-text2.js +14 -23
  65. package/dist/components/mg-input-textarea.js +12 -13
  66. package/dist/components/mg-input-title2.js +1 -2
  67. package/dist/components/mg-input-toggle.js +16 -19
  68. package/dist/components/mg-item-more.js +18 -27
  69. package/dist/components/mg-menu-item2.js +17 -26
  70. package/dist/components/mg-menu2.js +9 -16
  71. package/dist/components/mg-message.js +11 -14
  72. package/dist/components/mg-modal.js +7 -11
  73. package/dist/components/mg-pagination.js +11 -13
  74. package/dist/components/mg-panel.js +6 -15
  75. package/dist/components/mg-popover2.js +7 -13
  76. package/dist/components/mg-skip-links.js +2 -4
  77. package/dist/components/mg-tabs.js +20 -24
  78. package/dist/components/mg-tag.js +11 -13
  79. package/dist/components/mg-tooltip2.js +11 -21
  80. package/dist/esm/loader.js +1 -1
  81. package/dist/esm/mg-action-more_31.entry.js +318 -427
  82. package/dist/esm/mg-components.js +1 -1
  83. package/dist/esm/mg-item-more.entry.js +19 -28
  84. package/dist/esm/{mg-menu.conf-2cc1bb67.js → mg-menu.conf-9ca023ee.js} +16 -16
  85. package/dist/mg-components/mg-components.esm.js +1 -1
  86. package/dist/mg-components/{p-a56a3157.entry.js → p-97aaca3e.entry.js} +1 -1
  87. package/dist/mg-components/p-d891e707.entry.js +1 -0
  88. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +2 -3
  89. package/dist/types/components/atoms/mg-button/mg-button.d.ts +5 -9
  90. package/dist/types/components/atoms/mg-card/mg-card.d.ts +2 -6
  91. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +1 -2
  92. package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +1 -1
  93. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +3 -5
  94. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -2
  95. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +3 -5
  96. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -21
  97. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -1
  98. package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -5
  99. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -6
  100. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -6
  101. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +7 -14
  102. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +3 -4
  103. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -10
  104. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
  105. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +9 -13
  106. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +3 -12
  107. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -5
  108. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -6
  109. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +10 -18
  110. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +21 -31
  111. package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +3 -10
  112. package/dist/types/components/molecules/mg-details/mg-details.d.ts +1 -3
  113. package/dist/types/components/molecules/mg-form/mg-form.d.ts +3 -11
  114. package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +1 -2
  115. package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +2 -7
  116. package/dist/types/components/molecules/mg-message/mg-message.d.ts +4 -7
  117. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +3 -7
  118. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +5 -9
  119. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +4 -13
  120. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +3 -9
  121. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +2 -4
  122. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +15 -19
  123. package/dist/types/components.d.ts +22 -34
  124. package/dist/types/locales/index.d.ts +2 -2
  125. package/dist/types/utils/behaviors.utils.d.ts +14 -20
  126. package/dist/types/utils/components.utils.d.ts +18 -20
  127. package/dist/types/utils/locale.utils.d.ts +14 -14
  128. package/dist/types/utils/unit.test.utils.d.ts +11 -17
  129. package/package.json +1 -1
  130. package/dist/mg-components/p-eb32bb18.entry.js +0 -1
  131. /package/dist/mg-components/{p-73156ac9.js → p-0d3146d9.js} +0 -0
@@ -5,13 +5,12 @@ export class MgIcon {
5
5
  constructor() {
6
6
  /**
7
7
  * getIcon
8
- * @returns {HTMLElement} icon html
8
+ * @returns icon html
9
9
  */
10
10
  this.getIcon = () => icons[this.icon]();
11
11
  /**
12
12
  * Method to set default varianStyle props
13
13
  * needeed has stencil doesn't know that props is mutated when updated in prop watcher
14
- * @returns {void}
15
14
  */
16
15
  this.setDefaultVariantStyle = () => {
17
16
  if (this.variantStyle === undefined)
@@ -22,15 +21,15 @@ export class MgIcon {
22
21
  this.variant = undefined;
23
22
  this.variantStyle = undefined;
24
23
  this.spin = false;
25
- this.classList = new ClassList(['mg-icon']);
24
+ this.classCollection = new ClassList(['mg-icon']);
26
25
  }
27
26
  validateIcon(newValue, oldValue) {
28
27
  if (!Object.keys(icons).includes(newValue))
29
28
  throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
30
29
  else {
31
30
  if (oldValue !== undefined)
32
- this.classList.delete(`mg-icon--${oldValue}`);
33
- this.classList.add(`mg-icon--${newValue}`);
31
+ this.classCollection.delete(`mg-icon--${oldValue}`);
32
+ this.classCollection.add(`mg-icon--${newValue}`);
34
33
  }
35
34
  }
36
35
  validateSize(newValue, oldValue) {
@@ -38,8 +37,8 @@ export class MgIcon {
38
37
  throw new Error(`<mg-icon> prop "size" must be one of: ${sizes.join(', ')}`);
39
38
  else {
40
39
  if (oldValue !== undefined)
41
- this.classList.delete(`mg-icon--size-${oldValue}`);
42
- this.classList.add(`mg-icon--size-${newValue}`);
40
+ this.classCollection.delete(`mg-icon--size-${oldValue}`);
41
+ this.classCollection.add(`mg-icon--size-${newValue}`);
43
42
  }
44
43
  }
45
44
  validateVariant(newValue, oldValue) {
@@ -49,8 +48,8 @@ export class MgIcon {
49
48
  else {
50
49
  this.setDefaultVariantStyle();
51
50
  if (oldValue !== undefined)
52
- this.classList.delete(`mg-icon--variant-${oldValue}`);
53
- this.classList.add(`mg-icon--variant-${newValue}`);
51
+ this.classCollection.delete(`mg-icon--variant-${oldValue}`);
52
+ this.classCollection.add(`mg-icon--variant-${newValue}`);
54
53
  }
55
54
  }
56
55
  }
@@ -60,24 +59,23 @@ export class MgIcon {
60
59
  throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
61
60
  else {
62
61
  if (oldValue !== undefined)
63
- this.classList.delete(`mg-icon--variant-style-${oldValue}`);
64
- this.classList.add(`mg-icon--variant-style-${newValue}`);
62
+ this.classCollection.delete(`mg-icon--variant-style-${oldValue}`);
63
+ this.classCollection.add(`mg-icon--variant-style-${newValue}`);
65
64
  }
66
65
  }
67
66
  }
68
67
  handleSpin(newValue) {
69
68
  if (newValue) {
70
- this.classList.add('mg-icon--spin');
71
- this.classList.add('mg-a11y-animation');
69
+ this.classCollection.add('mg-icon--spin');
70
+ this.classCollection.add('mg-a11y-animation');
72
71
  }
73
72
  else {
74
- this.classList.delete('mg-icon--spin');
75
- this.classList.delete('mg-a11y-animation');
73
+ this.classCollection.delete('mg-icon--spin');
74
+ this.classCollection.delete('mg-a11y-animation');
76
75
  }
77
76
  }
78
77
  /**
79
78
  * Check if props are well configured on init
80
- * @returns {void}
81
79
  */
82
80
  componentWillLoad() {
83
81
  this.validateIcon(this.icon);
@@ -88,10 +86,10 @@ export class MgIcon {
88
86
  }
89
87
  /**
90
88
  * Render component
91
- * @returns {HTMLElement} HTML Element
89
+ * @returns HTML Element
92
90
  */
93
91
  render() {
94
- return (h("svg", { class: this.classList.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
92
+ return (h("svg", { class: this.classCollection.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
95
93
  }
96
94
  static get is() { return "mg-icon"; }
97
95
  static get encapsulation() { return "shadow"; }
@@ -213,7 +211,7 @@ export class MgIcon {
213
211
  }
214
212
  static get states() {
215
213
  return {
216
- "classList": {}
214
+ "classCollection": {}
217
215
  };
218
216
  }
219
217
  static get watchers() {
@@ -19,7 +19,6 @@ export class MgInputTitle {
19
19
  *************/
20
20
  /**
21
21
  * Init tag name
22
- * @returns {void}
23
22
  */
24
23
  componentWillLoad() {
25
24
  this.validateIdentifier(this.identifier);
@@ -27,7 +26,7 @@ export class MgInputTitle {
27
26
  }
28
27
  /**
29
28
  * Render
30
- * @returns {HTMLElement} HTML Element
29
+ * @returns HTML element
31
30
  */
32
31
  render() {
33
32
  const TagName = this.tagName;
@@ -12,7 +12,7 @@ export class MgTag {
12
12
  this.variant = variants[0];
13
13
  this.outline = undefined;
14
14
  this.soft = undefined;
15
- this.classList = new ClassList(['mg-tag']);
15
+ this.classCollection = new ClassList(['mg-tag']);
16
16
  }
17
17
  validateVariant(newValue, oldValue) {
18
18
  if (!variants.includes(newValue)) {
@@ -20,16 +20,16 @@ export class MgTag {
20
20
  }
21
21
  else {
22
22
  if (oldValue !== undefined) {
23
- this.classList.delete(`mg-tag--${oldValue}`);
23
+ this.classCollection.delete(`mg-tag--${oldValue}`);
24
24
  }
25
- this.classList.add(`mg-tag--${newValue}`);
25
+ this.classCollection.add(`mg-tag--${newValue}`);
26
26
  }
27
27
  }
28
28
  validateOutline(newValue) {
29
29
  if (newValue)
30
- this.classList.add(this.classOutline);
30
+ this.classCollection.add(this.classOutline);
31
31
  else
32
- this.classList.delete(this.classOutline);
32
+ this.classCollection.delete(this.classOutline);
33
33
  }
34
34
  validateSoft(newValue) {
35
35
  // usage validation
@@ -37,17 +37,16 @@ export class MgTag {
37
37
  throw new Error('<mg-tag> prop "soft" can NOT be used with prop "outline".');
38
38
  // apply class
39
39
  if (newValue)
40
- this.classList.add(this.classSoft);
40
+ this.classCollection.add(this.classSoft);
41
41
  else
42
- this.classList.delete(this.classSoft);
42
+ this.classCollection.delete(this.classSoft);
43
43
  }
44
44
  /*************
45
45
  * Methods *
46
46
  *************/
47
47
  /**
48
48
  * Validate the given textContent
49
- * @param {string} textContent html element textContent property
50
- * @returns {void}
49
+ * @param textContent - html element textContent property
51
50
  */
52
51
  validateTextContent(textContent) {
53
52
  if (typeof textContent !== 'string' || textContent.trim() === '')
@@ -58,7 +57,6 @@ export class MgTag {
58
57
  *************/
59
58
  /**
60
59
  * Check if props are well configured on init
61
- * @returns {void}
62
60
  */
63
61
  componentWillLoad() {
64
62
  this.validateVariant(this.variant);
@@ -68,10 +66,10 @@ export class MgTag {
68
66
  }
69
67
  /**
70
68
  * Render
71
- * @returns {HTMLElement} HTML Element
69
+ * @returns HTML Element
72
70
  */
73
71
  render() {
74
- return (h("span", { class: this.classList.join() }, h("slot", null)));
72
+ return (h("span", { class: this.classCollection.join() }, h("slot", null)));
75
73
  }
76
74
  static get is() { return "mg-tag"; }
77
75
  static get encapsulation() { return "shadow"; }
@@ -148,7 +146,7 @@ export class MgTag {
148
146
  }
149
147
  static get states() {
150
148
  return {
151
- "classList": {}
149
+ "classCollection": {}
152
150
  };
153
151
  }
154
152
  static get elementRef() { return "element"; }
@@ -6,7 +6,6 @@ export class MgTooltip {
6
6
  constructor() {
7
7
  /**
8
8
  * Show tooltip
9
- * @returns {void}
10
9
  */
11
10
  this.show = () => {
12
11
  // Make the tooltip visible
@@ -26,7 +25,6 @@ export class MgTooltip {
26
25
  };
27
26
  /**
28
27
  * Hide tooltip
29
- * @returns {void}
30
28
  */
31
29
  this.hide = () => {
32
30
  // Hide the tooltip
@@ -41,8 +39,7 @@ export class MgTooltip {
41
39
  };
42
40
  /**
43
41
  * Check if clicked outside of component and hidde tooltip
44
- * @param {MouseEvent} event mouse event
45
- * @returns {void}
42
+ * @param event - mouse event
46
43
  */
47
44
  this.clickOutside = (event) => {
48
45
  if (event.target.closest('mg-tooltip') !== this.element)
@@ -50,8 +47,7 @@ export class MgTooltip {
50
47
  };
51
48
  /**
52
49
  * Check if 'Escape' key is pressed of component and hidde tooltip
53
- * @param {KeyboardEvent} event keyboard event
54
- * @returns {void}
50
+ * @param event - keyboard event
55
51
  */
56
52
  this.pressEscape = (event) => {
57
53
  if (event.code === 'Escape')
@@ -59,9 +55,8 @@ export class MgTooltip {
59
55
  };
60
56
  /**
61
57
  * Method to set display prop
62
- * @param {boolean} newValue display prop new value
63
- * @param {boolean} condition additionnal condition to apply display prop newValue
64
- * @returns {void}
58
+ * @param newValue - display prop new value
59
+ * @param condition - additionnal condition to apply display prop newValue
65
60
  */
66
61
  this.setDisplay = (newValue, condition = true) => {
67
62
  if (!this.disabled && condition)
@@ -69,10 +64,9 @@ export class MgTooltip {
69
64
  };
70
65
  /**
71
66
  * Action for tooltip element and tooltiped element mouse listener
72
- * @param {Guard} elementGuard tooltip element guard
73
- * @param {boolean} isMouseenter mouseenter validation
74
- * @param {Guard} conditionalGuard guard condition
75
- * @returns {void}
67
+ * @param elementGuard - tooltip element guard
68
+ * @param isMouseenter - mouseenter validation
69
+ * @param conditionalGuard - guard condition
76
70
  */
77
71
  this.tooltipMouseListenerAction = (elementGuard, isMouseenter, conditionalGuard) => {
78
72
  // we mutate elementGuard
@@ -91,15 +85,13 @@ export class MgTooltip {
91
85
  };
92
86
  /**
93
87
  * Method to reset guard value
94
- * @returns {void}
95
88
  */
96
89
  this.resetGuard = () => {
97
90
  this.guard = undefined;
98
91
  };
99
92
  /**
100
93
  * Update slot content when it is a mg-button
101
- * @param {HTMLMgButtonElement} mgButton slotted mg-button
102
- * @returns {void}
94
+ * @param mgButton - slotted mg-button
103
95
  */
104
96
  this.setMgButtonWrapper = (mgButton) => {
105
97
  if (mgButton.disabled) {
@@ -116,8 +108,8 @@ export class MgTooltip {
116
108
  };
117
109
  /**
118
110
  * Init tooltip
119
- * @param {HTMLElement} slotElement slotted element
120
- * @param {HTMLElement} interactiveElement interactive element
111
+ * @param slotElement - slotted element
112
+ * @param interactiveElement - interactive element
121
113
  */
122
114
  this.initTooltip = (slotElement, interactiveElement) => {
123
115
  // Add tabindex to slotted element if we can't find any interactive element
@@ -193,7 +185,6 @@ export class MgTooltip {
193
185
  *************/
194
186
  /**
195
187
  * set variables
196
- * @returns {void}
197
188
  */
198
189
  componentWillLoad() {
199
190
  // Get windows to attach events
@@ -203,7 +194,6 @@ export class MgTooltip {
203
194
  * Get slotted element
204
195
  * Check if it already contain an interactive element, if not we need to add a tabIndex attribute
205
196
  * We need to attach the focused element to the tooltip (aria-describedby)
206
- * @returns {void}
207
197
  */
208
198
  componentDidLoad() {
209
199
  var _a;
@@ -236,7 +226,7 @@ export class MgTooltip {
236
226
  }
237
227
  /**
238
228
  * Render
239
- * @returns {HTMLElement} HTML Element
229
+ * @returns HTML Element
240
230
  */
241
231
  render() {
242
232
  return (h(Host, null, h("slot", null), h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip" }, h("span", { innerHTML: this.message }), h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
@@ -1 +1,4 @@
1
- export {};
1
+ /**
2
+ * Possible input width
3
+ */
4
+ export const widths = [2, 4, 16, 'full'];
@@ -1,10 +1,11 @@
1
1
  import { h } from '@stencil/core';
2
+ import { widths } from './MgInput.conf';
2
3
  /**
3
4
  * Apply in all input child node the aria-describedby attribute
4
- * @param {VNode[]} children Represent scoped elements
5
- * @param {Set<string>} ariaDescribedbyIDs List of IDs
6
- * @param {FunctionalUtilities} utils Stencil.js utils
7
- * @returns {VNode[]} Children with aria-describedby attribute
5
+ * @param children - Represent scoped elements
6
+ * @param ariaDescribedbyIDs - List of IDs
7
+ * @param utils - Stencil.js utils
8
+ * @returns Children with aria-describedby attribute
8
9
  */
9
10
  const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
10
11
  if (['input', 'select', 'textarea'].includes(child.vtag)) {
@@ -17,29 +18,36 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
17
18
  });
18
19
  /**
19
20
  * Add classes based on props
20
- * @param {MgInputProps} props MgInput Interface Props
21
+ * @param props - MgInput Interface Props
21
22
  */
22
23
  const manageClasses = (props) => {
23
- props.classList.add('mg-input');
24
+ props.classCollection.add('mg-input');
24
25
  if (props.labelOnTop)
25
- props.classList.add('mg-input--label-on-top');
26
+ props.classCollection.add('mg-input--label-on-top');
27
+ else
28
+ props.classCollection.delete('mg-input--label-on-top');
26
29
  if (props.readonly)
27
- props.classList.add('mg-input--readonly');
30
+ props.classCollection.add('mg-input--readonly');
31
+ else
32
+ props.classCollection.delete('mg-input--readonly');
33
+ widths.forEach(width => {
34
+ props.classCollection.delete(`mg-input--width-${width}`);
35
+ });
28
36
  if (props.mgWidth !== undefined)
29
- props.classList.add(`mg-input--width-${props.mgWidth}`);
37
+ props.classCollection.add(`mg-input--width-${props.mgWidth}`);
30
38
  };
31
39
  /**
32
40
  * Get tagname
33
- * @param {boolean} isFieldset is fieldset
34
- * @returns {string} tag name
41
+ * @param isFieldset - is fieldset
42
+ * @returns tag name
35
43
  */
36
44
  const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
37
45
  /**
38
46
  * Get input template
39
- * @param {MgInputProps} props MgInput Interface Props
40
- * @param {VNode[]} children Represent scoped elements
41
- * @param {FunctionalUtilities} utils Stencil.js utils
42
- * @returns {VNode[]} input template
47
+ * @param props - MgInput Interface Props
48
+ * @param children - Represent scoped elements
49
+ * @param utils - Stencil.js utils
50
+ * @returns input template
43
51
  */
44
52
  export const MgInput = (props, children, utils) => {
45
53
  /**
@@ -95,14 +103,14 @@ export const MgInput = (props, children, utils) => {
95
103
  const TagName = getTagName(props.isFieldset);
96
104
  /**
97
105
  * Get tooltip node
98
- * @returns {VNode[]} mg-tooltip
106
+ * @returns mg-tooltip
99
107
  */
100
108
  const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip }, h("mg-icon", { icon: "info-circle" })));
101
109
  /**
102
110
  * Get input title (label) node
103
111
  * Display asterisk only if not disabled and not readonly
104
- * @returns {VNode[]} mg-input-title
112
+ * @returns mg-input-title
105
113
  */
106
114
  const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled && !props.readonly, "is-legend": props.isFieldset }, props.label));
107
- return (h(TagName, { class: props.classList.join() }, props.labelOnTop ? (h("div", { class: "mg-input__title" }, getInputTitle(), !props.readonly && props.tooltip && getTooltip())) : (getInputTitle()), props.readonly ? (h("div", { class: "mg-input__input-container" }, h("strong", null, props.readonlyValue), children.filter(child => child.$name$ === 'append-input'))) : (h("div", { class: "mg-input__input-container" }, h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } }, applyAriadescribedBy(children, ariaDescribedbyIDs, utils), !props.labelOnTop && props.tooltip && getTooltip()), props.helpText && h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }), props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
115
+ return (h(TagName, { class: props.classCollection.join() }, props.labelOnTop ? (h("div", { class: "mg-input__title" }, getInputTitle(), !props.readonly && props.tooltip && getTooltip())) : (getInputTitle()), props.readonly ? (h("div", { class: "mg-input__input-container" }, h("strong", null, props.readonlyValue), children.filter(child => child.$name$ === 'append-input'))) : (h("div", { class: "mg-input__input-container" }, h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } }, applyAriadescribedBy(children, ariaDescribedbyIDs, utils), !props.labelOnTop && props.tooltip && getTooltip()), props.helpText && h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }), props.errorMessage && !props.readonly && !props.disabled && (h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
108
116
  };
@@ -5,8 +5,8 @@ import { ClassList } from '../../../../utils/components.utils';
5
5
  import { initLocales } from '../../../../locales';
6
6
  /**
7
7
  * type CheckboxItem validation function
8
- * @param {unknown} items Checkbox item
9
- * @returns {boolean} match item type
8
+ * @param items - Checkbox item
9
+ * @returns match item type
10
10
  */
11
11
  const isCheckboxItems = (items) => Array.isArray(items) &&
12
12
  items.every(item => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined);
@@ -21,7 +21,7 @@ export class MgInputCheckbox {
21
21
  this.hasDisplayedError = false;
22
22
  /**
23
23
  * Handle input event
24
- * @param {InputEvent} event input event
24
+ * @param event - input event
25
25
  */
26
26
  this.handleInput = (event) => {
27
27
  this.checkboxItems = this.checkboxItems.map(item => {
@@ -43,7 +43,7 @@ export class MgInputCheckbox {
43
43
  };
44
44
  /**
45
45
  * get invalid element
46
- * @returns {HTMLInputElement} element
46
+ * @returns element
47
47
  */
48
48
  this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
49
49
  /**
@@ -80,7 +80,7 @@ export class MgInputCheckbox {
80
80
  this.helpText = undefined;
81
81
  this.valid = undefined;
82
82
  this.invalid = undefined;
83
- this.classList = new ClassList(['mg-input--checkbox']);
83
+ this.classCollection = new ClassList(['mg-input--checkbox']);
84
84
  this.errorMessage = undefined;
85
85
  this.checkboxItems = [];
86
86
  }
@@ -110,7 +110,6 @@ export class MgInputCheckbox {
110
110
  }
111
111
  /**
112
112
  * Public method to display errors
113
- * @returns {Promise<void>}
114
113
  */
115
114
  async displayError() {
116
115
  this.checkValidity();
@@ -122,7 +121,7 @@ export class MgInputCheckbox {
122
121
  *************/
123
122
  /**
124
123
  * Check if component props are well configured on init
125
- * @returns {ReturnType<typeof setTimeout>} timeout
124
+ * @returns timeout
126
125
  */
127
126
  componentWillLoad() {
128
127
  // Get locales
@@ -138,10 +137,10 @@ export class MgInputCheckbox {
138
137
  }
139
138
  /**
140
139
  * Render
141
- * @returns {HTMLElement} HTML Element
140
+ * @returns HTML Element
142
141
  */
143
142
  render() {
144
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.checkboxItems
143
+ return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList }, role: "list" }, this.checkboxItems
145
144
  .filter(item => {
146
145
  return !this.readonly || item.value;
147
146
  })
@@ -415,7 +414,7 @@ export class MgInputCheckbox {
415
414
  }
416
415
  static get states() {
417
416
  return {
418
- "classList": {},
417
+ "classCollection": {},
419
418
  "errorMessage": {},
420
419
  "checkboxItems": {}
421
420
  };
@@ -476,10 +475,7 @@ export class MgInputCheckbox {
476
475
  },
477
476
  "docs": {
478
477
  "text": "Public method to display errors",
479
- "tags": [{
480
- "name": "returns",
481
- "text": undefined
482
- }]
478
+ "tags": []
483
479
  }
484
480
  }
485
481
  };
@@ -36,7 +36,7 @@ export class MgInputDate {
36
36
  };
37
37
  /**
38
38
  * get input error code
39
- * @returns {null | InputError} error code
39
+ * @returns error code
40
40
  */
41
41
  this.getInputError = () => {
42
42
  var _a, _b;
@@ -61,7 +61,6 @@ export class MgInputDate {
61
61
  };
62
62
  /**
63
63
  * Check input errors
64
- * @returns {void}
65
64
  */
66
65
  this.setErrorMessage = () => {
67
66
  var _a;
@@ -99,7 +98,7 @@ export class MgInputDate {
99
98
  this.invalid = undefined;
100
99
  this.min = undefined;
101
100
  this.max = undefined;
102
- this.classList = new ClassList(['mg-input--date']);
101
+ this.classCollection = new ClassList(['mg-input--date']);
103
102
  this.errorMessage = undefined;
104
103
  }
105
104
  validateValue(newValue) {
@@ -130,7 +129,6 @@ export class MgInputDate {
130
129
  }
131
130
  /**
132
131
  * Public method to display errors
133
- * @returns {Promise<void>}
134
132
  */
135
133
  async displayError() {
136
134
  this.checkValidity();
@@ -142,7 +140,7 @@ export class MgInputDate {
142
140
  *************/
143
141
  /**
144
142
  * Check if component props are well configured on init
145
- * @returns {ReturnType<typeof setTimeout>} timeout
143
+ * @returns timeout
146
144
  */
147
145
  componentWillLoad() {
148
146
  // Get locales
@@ -162,10 +160,10 @@ export class MgInputDate {
162
160
  }
163
161
  /**
164
162
  * Render
165
- * @returns {HTMLElement} HTML Element
163
+ * @returns HTML Element
166
164
  */
167
165
  render() {
168
- return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
166
+ return (h(MgInput, { identifier: this.identifier, classCollection: this.classCollection, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
169
167
  if (el !== null)
170
168
  this.input = el;
171
169
  } })));
@@ -448,7 +446,7 @@ export class MgInputDate {
448
446
  }
449
447
  static get states() {
450
448
  return {
451
- "classList": {},
449
+ "classCollection": {},
452
450
  "errorMessage": {}
453
451
  };
454
452
  }
@@ -500,10 +498,7 @@ export class MgInputDate {
500
498
  },
501
499
  "docs": {
502
500
  "text": "Public method to display errors",
503
- "tags": [{
504
- "name": "returns",
505
- "text": undefined
506
- }]
501
+ "tags": []
507
502
  }
508
503
  }
509
504
  };