@mgdis/mg-components 5.8.2 → 5.10.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 (149) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/mg-action-more_31.cjs.entry.js +216 -277
  3. package/dist/cjs/mg-components.cjs.js +1 -1
  4. package/dist/cjs/mg-item-more.cjs.entry.js +1 -16
  5. package/dist/cjs/{mg-menu.conf-9afe6571.js → mg-menu.conf-1942ac70.js} +0 -5
  6. package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -3
  7. package/dist/collection/components/atoms/mg-button/mg-button.js +2 -7
  8. package/dist/collection/components/atoms/mg-card/mg-card.conf.js +8 -0
  9. package/dist/collection/components/atoms/mg-card/mg-card.css +54 -0
  10. package/dist/collection/components/atoms/mg-card/mg-card.js +113 -2
  11. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +0 -2
  12. package/dist/collection/components/atoms/mg-divider/mg-divider.js +0 -1
  13. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +38 -7
  14. package/dist/collection/components/atoms/mg-icon/mg-icon.css +70 -11
  15. package/dist/collection/components/atoms/mg-icon/mg-icon.js +65 -24
  16. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +0 -2
  17. package/dist/collection/components/atoms/mg-tag/mg-tag.css +12 -12
  18. package/dist/collection/components/atoms/mg-tag/mg-tag.js +0 -3
  19. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +42 -15
  20. package/dist/collection/components/molecules/inputs/MgInput.js +0 -6
  21. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +0 -6
  22. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +0 -5
  23. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +12 -21
  24. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +0 -3
  25. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +0 -9
  26. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +0 -13
  27. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +1 -12
  28. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -5
  29. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +0 -5
  30. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +1 -12
  31. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +1 -0
  32. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +1 -19
  33. package/dist/collection/components/molecules/mg-action-more/mg-action-more.css +1 -0
  34. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +0 -8
  35. package/dist/collection/components/molecules/mg-details/mg-details.css +0 -3
  36. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -4
  37. package/dist/collection/components/molecules/mg-form/mg-form.js +0 -8
  38. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +0 -2
  39. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +0 -5
  40. package/dist/collection/components/molecules/mg-message/mg-message.css +1 -19
  41. package/dist/collection/components/molecules/mg-message/mg-message.js +11 -11
  42. package/dist/collection/components/molecules/mg-modal/mg-modal.css +1 -0
  43. package/dist/collection/components/molecules/mg-modal/mg-modal.js +1 -6
  44. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +0 -6
  45. package/dist/collection/components/molecules/mg-panel/mg-panel.css +1 -0
  46. package/dist/collection/components/molecules/mg-panel/mg-panel.js +5 -15
  47. package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -0
  48. package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -8
  49. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -4
  50. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +0 -12
  51. package/dist/collection/locales/index.js +0 -1
  52. package/dist/collection/styles/reset-mg-card-slotted-variables.scss +1 -0
  53. package/dist/collection/utils/behaviors.utils.js +0 -10
  54. package/dist/collection/utils/components.utils.js +1 -10
  55. package/dist/collection/utils/locale.utils.js +0 -4
  56. package/dist/collection/utils/unit.test.utils.js +0 -5
  57. package/dist/collection/variables.css +7 -1
  58. package/dist/components/MgInput.js +0 -6
  59. package/dist/components/components.utils.js +1 -10
  60. package/dist/components/index2.js +0 -5
  61. package/dist/components/mg-action-more.js +1 -9
  62. package/dist/components/mg-badge2.js +1 -3
  63. package/dist/components/mg-button2.js +2 -7
  64. package/dist/components/mg-card2.js +67 -4
  65. package/dist/components/mg-character-left2.js +0 -2
  66. package/dist/components/mg-details.js +2 -5
  67. package/dist/components/mg-divider.js +0 -1
  68. package/dist/components/mg-form.js +0 -8
  69. package/dist/components/mg-icon2.js +74 -25
  70. package/dist/components/mg-illustrated-message.js +0 -2
  71. package/dist/components/mg-input-checkbox.js +0 -6
  72. package/dist/components/mg-input-date.js +0 -5
  73. package/dist/components/mg-input-numeric.js +12 -21
  74. package/dist/components/mg-input-password.js +0 -3
  75. package/dist/components/mg-input-radio.js +0 -9
  76. package/dist/components/mg-input-select2.js +0 -13
  77. package/dist/components/mg-input-text2.js +1 -12
  78. package/dist/components/mg-input-textarea.js +1 -5
  79. package/dist/components/mg-input-title2.js +0 -2
  80. package/dist/components/mg-input-toggle.js +0 -5
  81. package/dist/components/mg-item-more.js +0 -15
  82. package/dist/components/mg-menu-item2.js +2 -20
  83. package/dist/components/mg-menu2.js +0 -11
  84. package/dist/components/mg-message.js +4 -9
  85. package/dist/components/mg-modal.js +2 -7
  86. package/dist/components/mg-pagination.js +0 -6
  87. package/dist/components/mg-panel.js +6 -16
  88. package/dist/components/mg-popover2.js +2 -9
  89. package/dist/components/mg-skip-links.js +1 -4
  90. package/dist/components/mg-tabs.js +0 -12
  91. package/dist/components/mg-tag.js +1 -4
  92. package/dist/components/mg-tooltip2.js +42 -15
  93. package/dist/components/popper.js +3 -4
  94. package/dist/esm/loader.js +1 -1
  95. package/dist/esm/mg-action-more_31.entry.js +216 -277
  96. package/dist/esm/mg-components.js +1 -1
  97. package/dist/esm/mg-item-more.entry.js +1 -16
  98. package/dist/esm/{mg-menu.conf-881fbd82.js → mg-menu.conf-2cc1bb67.js} +0 -5
  99. package/dist/mg-components/mg-components.css +1 -1
  100. package/dist/mg-components/mg-components.esm.js +1 -1
  101. package/dist/mg-components/{p-67ce7cb8.entry.js → p-a56a3157.entry.js} +1 -1
  102. package/dist/mg-components/p-eb32bb18.entry.js +1 -0
  103. package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +1 -0
  104. package/dist/mg-components/variables.css +7 -1
  105. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +0 -2
  106. package/dist/types/components/atoms/mg-button/mg-button.d.ts +0 -5
  107. package/dist/types/components/atoms/mg-card/mg-card.conf.d.ts +16 -0
  108. package/dist/types/components/atoms/mg-card/mg-card.d.ts +37 -1
  109. package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +0 -2
  110. package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +0 -1
  111. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +10 -2
  112. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +19 -8
  113. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +0 -2
  114. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +0 -3
  115. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +18 -9
  116. package/dist/types/components/molecules/inputs/MgInput.d.ts +0 -1
  117. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +0 -5
  118. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +0 -5
  119. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +5 -17
  120. package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +0 -3
  121. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +0 -8
  122. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +0 -9
  123. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +0 -11
  124. package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +0 -4
  125. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +0 -5
  126. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +0 -11
  127. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +0 -18
  128. package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +0 -5
  129. package/dist/types/components/molecules/mg-details/mg-details.d.ts +0 -3
  130. package/dist/types/components/molecules/mg-form/mg-form.d.ts +0 -8
  131. package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +0 -2
  132. package/dist/types/components/molecules/mg-item-more/mg-item-more.d.ts +0 -5
  133. package/dist/types/components/molecules/mg-message/mg-message.conf.d.ts +5 -1
  134. package/dist/types/components/molecules/mg-message/mg-message.d.ts +7 -11
  135. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +0 -5
  136. package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +0 -5
  137. package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +0 -10
  138. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +0 -7
  139. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +0 -3
  140. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +0 -11
  141. package/dist/types/components.d.ts +35 -9
  142. package/dist/types/locales/index.d.ts +0 -1
  143. package/dist/types/utils/behaviors.utils.d.ts +0 -9
  144. package/dist/types/utils/components.utils.d.ts +1 -9
  145. package/dist/types/utils/locale.utils.d.ts +0 -4
  146. package/dist/types/utils/unit.test.utils.d.ts +0 -7
  147. package/package.json +15 -16
  148. package/dist/mg-components/p-0b68c4b4.entry.js +0 -1
  149. /package/dist/mg-components/{p-367f92d2.js → p-73156ac9.js} +0 -0
@@ -30,37 +30,96 @@
30
30
  vertical-align: middle;
31
31
  }
32
32
 
33
+ .mg-icon {
34
+ color: currentColor;
35
+ }
33
36
  .mg-icon[size=small], .mg-icon.mg-icon--size-small {
34
37
  width: var(--mg-icon-small-size);
35
38
  height: var(--mg-icon-small-size);
36
39
  }
40
+ .mg-icon[size=small][class*=mg-icon--variant-]:not(.mg-icon--variant-style-icon), .mg-icon.mg-icon--size-small[class*=mg-icon--variant-]:not(.mg-icon--variant-style-icon) {
41
+ padding: calc(var(--mg-icon-small-size) / 2);
42
+ }
37
43
  .mg-icon[size=regular], .mg-icon.mg-icon--size-regular {
38
44
  width: var(--mg-icon-regular-size);
39
45
  height: var(--mg-icon-regular-size);
40
46
  }
47
+ .mg-icon[size=regular][class*=mg-icon--variant-]:not(.mg-icon--variant-style-icon), .mg-icon.mg-icon--size-regular[class*=mg-icon--variant-]:not(.mg-icon--variant-style-icon) {
48
+ padding: calc(var(--mg-icon-regular-size) / 2);
49
+ }
50
+ .mg-icon[size=medium], .mg-icon.mg-icon--size-medium {
51
+ width: var(--mg-icon-medium-size);
52
+ height: var(--mg-icon-medium-size);
53
+ }
54
+ .mg-icon[size=medium][class*=mg-icon--variant-]:not(.mg-icon--variant-style-icon), .mg-icon.mg-icon--size-medium[class*=mg-icon--variant-]:not(.mg-icon--variant-style-icon) {
55
+ padding: calc(var(--mg-icon-medium-size) / 2);
56
+ }
41
57
  .mg-icon[size=large], .mg-icon.mg-icon--size-large {
42
58
  width: var(--mg-icon-large-size);
43
59
  height: var(--mg-icon-large-size);
44
60
  }
61
+ .mg-icon[size=large][class*=mg-icon--variant-]:not(.mg-icon--variant-style-icon), .mg-icon.mg-icon--size-large[class*=mg-icon--variant-]:not(.mg-icon--variant-style-icon) {
62
+ padding: calc(var(--mg-icon-large-size) / 2);
63
+ }
45
64
  .mg-icon[size=extra-large], .mg-icon.mg-icon--size-extra-large {
46
65
  width: var(--mg-icon-extra-large-size);
47
66
  height: var(--mg-icon-extra-large-size);
48
67
  }
49
- .mg-icon[class*=mg-icon--variant-] {
50
- border-radius: var(--mg-message-border-radius);
51
- padding: 0.3rem;
68
+ .mg-icon[size=extra-large][class*=mg-icon--variant-]:not(.mg-icon--variant-style-icon), .mg-icon.mg-icon--size-extra-large[class*=mg-icon--variant-]:not(.mg-icon--variant-style-icon) {
69
+ padding: calc(var(--mg-icon-extra-large-size) / 2);
70
+ }
71
+ .mg-icon.mg-icon--variant-success.mg-icon--variant-style-icon {
72
+ color: hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l));
73
+ }
74
+ .mg-icon.mg-icon--variant-warning.mg-icon--variant-style-icon {
75
+ color: hsl(var(--color-warning-h), var(--color-warning-s), var(--color-warning-l));
76
+ }
77
+ .mg-icon.mg-icon--variant-danger.mg-icon--variant-style-icon {
78
+ color: hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));
52
79
  }
53
- .mg-icon.mg-icon--variant-success {
54
- background-color: hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) + 20%));
80
+ .mg-icon.mg-icon--variant-info.mg-icon--variant-style-icon {
81
+ color: hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));
55
82
  }
56
- .mg-icon.mg-icon--variant-warning {
57
- background-color: hsl(var(--color-warning-h), var(--color-warning-s), calc(var(--color-warning-l) + 20%));
83
+ .mg-icon.mg-icon--variant-app.mg-icon--variant-style-icon {
84
+ color: hsl(var(--mg-color-app-h), var(--mg-color-app-s), var(--mg-color-app-l));
58
85
  }
59
- .mg-icon.mg-icon--variant-danger {
60
- background-color: hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) + 20%));
86
+ .mg-icon.mg-icon--variant-success.mg-icon--variant-style-background {
87
+ background-color: hsl(var(--color-success-h), var(--color-success-s), var(--mg-color-soft-l));
61
88
  }
62
- .mg-icon.mg-icon--variant-info {
63
- background-color: hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) + 20%));
89
+ .mg-icon.mg-icon--variant-warning.mg-icon--variant-style-background {
90
+ background-color: hsl(var(--color-warning-h), var(--color-warning-s), var(--mg-color-soft-l));
91
+ }
92
+ .mg-icon.mg-icon--variant-danger.mg-icon--variant-style-background {
93
+ background-color: hsl(var(--color-danger-h), var(--color-danger-s), var(--mg-color-soft-l));
94
+ }
95
+ .mg-icon.mg-icon--variant-info.mg-icon--variant-style-background {
96
+ background-color: hsl(var(--color-info-h), var(--color-info-s), var(--mg-color-soft-l));
97
+ }
98
+ .mg-icon.mg-icon--variant-app.mg-icon--variant-style-background {
99
+ background-color: hsl(var(--mg-color-app-h), var(--mg-color-app-s), var(--mg-color-soft-l));
100
+ }
101
+ .mg-icon.mg-icon--variant-success.mg-icon--variant-style-full {
102
+ color: hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l));
103
+ background-color: hsl(var(--color-success-h), var(--color-success-s), var(--mg-color-soft-l));
104
+ }
105
+ .mg-icon.mg-icon--variant-warning.mg-icon--variant-style-full {
106
+ color: hsl(var(--color-warning-h), var(--color-warning-s), var(--color-warning-l));
107
+ background-color: hsl(var(--color-warning-h), var(--color-warning-s), var(--mg-color-soft-l));
108
+ }
109
+ .mg-icon.mg-icon--variant-danger.mg-icon--variant-style-full {
110
+ color: hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));
111
+ background-color: hsl(var(--color-danger-h), var(--color-danger-s), var(--mg-color-soft-l));
112
+ }
113
+ .mg-icon.mg-icon--variant-info.mg-icon--variant-style-full {
114
+ color: hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));
115
+ background-color: hsl(var(--color-info-h), var(--color-info-s), var(--mg-color-soft-l));
116
+ }
117
+ .mg-icon.mg-icon--variant-app.mg-icon--variant-style-full {
118
+ color: hsl(var(--mg-color-app-h), var(--mg-color-app-s), var(--mg-color-app-l));
119
+ background-color: hsl(var(--mg-color-app-h), var(--mg-color-app-s), var(--mg-color-soft-l));
120
+ }
121
+ .mg-icon[class*=mg-icon--variant-] {
122
+ border-radius: var(--mg-icon-border-radius);
64
123
  }
65
124
 
66
125
  /**
@@ -1,51 +1,68 @@
1
1
  import { h } from '@stencil/core';
2
- import { icons, sizes, variants } from './mg-icon.conf';
2
+ import { icons, sizes, variants, variantStyles } from './mg-icon.conf';
3
3
  import { ClassList } from '../../../utils/components.utils';
4
4
  export class MgIcon {
5
5
  constructor() {
6
6
  /**
7
7
  * getIcon
8
- *
9
8
  * @returns {HTMLElement} icon html
10
9
  */
11
10
  this.getIcon = () => icons[this.icon]();
11
+ /**
12
+ * Method to set default varianStyle props
13
+ * needeed has stencil doesn't know that props is mutated when updated in prop watcher
14
+ * @returns {void}
15
+ */
16
+ this.setDefaultVariantStyle = () => {
17
+ if (this.variantStyle === undefined)
18
+ this.variantStyle = 'background';
19
+ };
12
20
  this.icon = undefined;
13
21
  this.size = 'regular';
14
22
  this.variant = undefined;
23
+ this.variantStyle = undefined;
15
24
  this.spin = false;
16
25
  this.classList = new ClassList(['mg-icon']);
17
26
  }
18
27
  validateIcon(newValue, oldValue) {
19
- if (!Object.keys(icons).includes(newValue)) {
28
+ if (!Object.keys(icons).includes(newValue))
20
29
  throw new Error(`<mg-icon> prop "icon" must be one of: ${Object.keys(icons).join(', ')}`);
21
- }
22
30
  else {
23
- if (oldValue !== undefined) {
31
+ if (oldValue !== undefined)
24
32
  this.classList.delete(`mg-icon--${oldValue}`);
25
- }
26
33
  this.classList.add(`mg-icon--${newValue}`);
27
34
  }
28
35
  }
29
36
  validateSize(newValue, oldValue) {
30
- if (!sizes.includes(newValue)) {
37
+ if (!sizes.includes(newValue))
31
38
  throw new Error(`<mg-icon> prop "size" must be one of: ${sizes.join(', ')}`);
32
- }
33
39
  else {
34
- if (oldValue !== undefined) {
40
+ if (oldValue !== undefined)
35
41
  this.classList.delete(`mg-icon--size-${oldValue}`);
36
- }
37
42
  this.classList.add(`mg-icon--size-${newValue}`);
38
43
  }
39
44
  }
40
45
  validateVariant(newValue, oldValue) {
41
- if (newValue !== undefined && !variants.includes(newValue)) {
42
- throw new Error(`<mg-icon> prop "variant" must be one of: ${variants.join(', ')}`);
46
+ if (Boolean(newValue)) {
47
+ if (!variants.includes(newValue))
48
+ throw new Error(`<mg-icon> prop "variant" must be one of: ${variants.join(', ')}`);
49
+ else {
50
+ this.setDefaultVariantStyle();
51
+ if (oldValue !== undefined)
52
+ this.classList.delete(`mg-icon--variant-${oldValue}`);
53
+ this.classList.add(`mg-icon--variant-${newValue}`);
54
+ }
43
55
  }
44
- else if (newValue !== undefined) {
45
- if (oldValue !== undefined) {
46
- this.classList.delete(`mg-icon--variant-${oldValue}`);
56
+ }
57
+ validateVariantStyle(newValue, oldValue) {
58
+ if (Boolean(newValue)) {
59
+ if (!variantStyles.includes(newValue))
60
+ throw new Error(`<mg-icon> prop "variantStyle" must be one of: ${variantStyles.join(', ')}`);
61
+ else {
62
+ if (oldValue !== undefined)
63
+ this.classList.delete(`mg-icon--variant-style-${oldValue}`);
64
+ this.classList.add(`mg-icon--variant-style-${newValue}`);
47
65
  }
48
- this.classList.add(`mg-icon--variant-${newValue}`);
49
66
  }
50
67
  }
51
68
  handleSpin(newValue) {
@@ -60,18 +77,17 @@ export class MgIcon {
60
77
  }
61
78
  /**
62
79
  * Check if props are well configured on init
63
- *
64
80
  * @returns {void}
65
81
  */
66
82
  componentWillLoad() {
67
83
  this.validateIcon(this.icon);
68
84
  this.validateSize(this.size);
69
85
  this.validateVariant(this.variant);
86
+ this.validateVariantStyle(this.variantStyle);
70
87
  this.handleSpin(this.spin);
71
88
  }
72
89
  /**
73
90
  * Render component
74
- *
75
91
  * @returns {HTMLElement} HTML Element
76
92
  */
77
93
  render() {
@@ -99,11 +115,11 @@ export class MgIcon {
99
115
  "resolved": "string",
100
116
  "references": {}
101
117
  },
102
- "required": false,
118
+ "required": true,
103
119
  "optional": false,
104
120
  "docs": {
105
121
  "tags": [],
106
- "text": "Icon to display"
122
+ "text": "Icon to display."
107
123
  },
108
124
  "attribute": "icon",
109
125
  "reflect": false
@@ -113,7 +129,7 @@ export class MgIcon {
113
129
  "mutable": false,
114
130
  "complexType": {
115
131
  "original": "IconSizeType",
116
- "resolved": "\"extra-large\" | \"large\" | \"regular\" | \"small\"",
132
+ "resolved": "\"extra-large\" | \"large\" | \"medium\" | \"regular\" | \"small\"",
117
133
  "references": {
118
134
  "IconSizeType": {
119
135
  "location": "import",
@@ -136,7 +152,7 @@ export class MgIcon {
136
152
  "mutable": false,
137
153
  "complexType": {
138
154
  "original": "IconVariantType",
139
- "resolved": "\"danger\" | \"info\" | \"success\" | \"warning\"",
155
+ "resolved": "\"app\" | \"danger\" | \"info\" | \"success\" | \"warning\"",
140
156
  "references": {
141
157
  "IconVariantType": {
142
158
  "location": "import",
@@ -145,14 +161,36 @@ export class MgIcon {
145
161
  }
146
162
  },
147
163
  "required": false,
148
- "optional": true,
164
+ "optional": false,
149
165
  "docs": {
150
166
  "tags": [],
151
- "text": "Define icon variant\nAdd a background to the icon based on variant color"
167
+ "text": "Define icon variant color"
152
168
  },
153
169
  "attribute": "variant",
154
170
  "reflect": false
155
171
  },
172
+ "variantStyle": {
173
+ "type": "string",
174
+ "mutable": true,
175
+ "complexType": {
176
+ "original": "IconVariantStyleType",
177
+ "resolved": "\"background\" | \"full\" | \"icon\"",
178
+ "references": {
179
+ "IconVariantStyleType": {
180
+ "location": "import",
181
+ "path": "./mg-icon.conf"
182
+ }
183
+ }
184
+ },
185
+ "required": false,
186
+ "optional": false,
187
+ "docs": {
188
+ "tags": [],
189
+ "text": "Define icon color variant style\nAdd a color to the icon based on variant color with given style\n'full': Used to set a circular background with variant soft color and icon variant color\n'background': Used to set a circular background with variant soft color\n'icon': Used to set a color only to the icon"
190
+ },
191
+ "attribute": "variant-style",
192
+ "reflect": false
193
+ },
156
194
  "spin": {
157
195
  "type": "boolean",
158
196
  "mutable": false,
@@ -188,6 +226,9 @@ export class MgIcon {
188
226
  }, {
189
227
  "propName": "variant",
190
228
  "methodName": "validateVariant"
229
+ }, {
230
+ "propName": "variantStyle",
231
+ "methodName": "validateVariantStyle"
191
232
  }, {
192
233
  "propName": "spin",
193
234
  "methodName": "handleSpin"
@@ -19,7 +19,6 @@ export class MgInputTitle {
19
19
  *************/
20
20
  /**
21
21
  * Init tag name
22
- *
23
22
  * @returns {void}
24
23
  */
25
24
  componentWillLoad() {
@@ -28,7 +27,6 @@ export class MgInputTitle {
28
27
  }
29
28
  /**
30
29
  * Render
31
- *
32
30
  * @returns {HTMLElement} HTML Element
33
31
  */
34
32
  render() {
@@ -22,8 +22,8 @@
22
22
  }
23
23
  .mg-tag.mg-tag--primary.mg-tag--soft {
24
24
  font-weight: 400;
25
- background-color: hsl(var(--color-dark-h), var(--color-dark-s), 90%);
26
- border-color: hsl(var(--color-dark-h), var(--color-dark-s), 90%);
25
+ background-color: hsl(var(--color-dark-h), var(--color-dark-s), var(--mg-color-soft-l));
26
+ border-color: hsl(var(--color-dark-h), var(--color-dark-s), var(--mg-color-soft-l));
27
27
  color: hsl(var(--color-dark));
28
28
  }
29
29
  .mg-tag.mg-tag--primary.mg-tag--soft ::slotted(mg-icon) {
@@ -40,8 +40,8 @@
40
40
  }
41
41
  .mg-tag.mg-tag--secondary.mg-tag--soft {
42
42
  font-weight: 400;
43
- background-color: hsl(var(--color-light-h), var(--color-light-s), 90%);
44
- border-color: hsl(var(--color-light-h), var(--color-light-s), 90%);
43
+ background-color: hsl(var(--color-light-h), var(--color-light-s), var(--mg-color-soft-l));
44
+ border-color: hsl(var(--color-light-h), var(--color-light-s), var(--mg-color-soft-l));
45
45
  color: hsl(var(--color-dark));
46
46
  }
47
47
  .mg-tag.mg-tag--secondary.mg-tag--soft ::slotted(mg-icon) {
@@ -58,8 +58,8 @@
58
58
  }
59
59
  .mg-tag.mg-tag--success.mg-tag--soft {
60
60
  font-weight: 400;
61
- background-color: hsl(var(--color-success-h), var(--color-success-s), 90%);
62
- border-color: hsl(var(--color-success-h), var(--color-success-s), 90%);
61
+ background-color: hsl(var(--color-success-h), var(--color-success-s), var(--mg-color-soft-l));
62
+ border-color: hsl(var(--color-success-h), var(--color-success-s), var(--mg-color-soft-l));
63
63
  color: hsl(var(--color-dark));
64
64
  }
65
65
  .mg-tag.mg-tag--success.mg-tag--soft ::slotted(mg-icon) {
@@ -76,8 +76,8 @@
76
76
  }
77
77
  .mg-tag.mg-tag--warning.mg-tag--soft {
78
78
  font-weight: 400;
79
- background-color: hsl(var(--color-warning-h), var(--color-warning-s), 90%);
80
- border-color: hsl(var(--color-warning-h), var(--color-warning-s), 90%);
79
+ background-color: hsl(var(--color-warning-h), var(--color-warning-s), var(--mg-color-soft-l));
80
+ border-color: hsl(var(--color-warning-h), var(--color-warning-s), var(--mg-color-soft-l));
81
81
  color: hsl(var(--color-dark));
82
82
  }
83
83
  .mg-tag.mg-tag--warning.mg-tag--soft ::slotted(mg-icon) {
@@ -94,8 +94,8 @@
94
94
  }
95
95
  .mg-tag.mg-tag--danger.mg-tag--soft {
96
96
  font-weight: 400;
97
- background-color: hsl(var(--color-danger-h), var(--color-danger-s), 90%);
98
- border-color: hsl(var(--color-danger-h), var(--color-danger-s), 90%);
97
+ background-color: hsl(var(--color-danger-h), var(--color-danger-s), var(--mg-color-soft-l));
98
+ border-color: hsl(var(--color-danger-h), var(--color-danger-s), var(--mg-color-soft-l));
99
99
  color: hsl(var(--color-dark));
100
100
  }
101
101
  .mg-tag.mg-tag--danger.mg-tag--soft ::slotted(mg-icon) {
@@ -112,8 +112,8 @@
112
112
  }
113
113
  .mg-tag.mg-tag--info.mg-tag--soft {
114
114
  font-weight: 400;
115
- background-color: hsl(var(--color-info-h), var(--color-info-s), 90%);
116
- border-color: hsl(var(--color-info-h), var(--color-info-s), 90%);
115
+ background-color: hsl(var(--color-info-h), var(--color-info-s), var(--mg-color-soft-l));
116
+ border-color: hsl(var(--color-info-h), var(--color-info-s), var(--mg-color-soft-l));
117
117
  color: hsl(var(--color-dark));
118
118
  }
119
119
  .mg-tag.mg-tag--info.mg-tag--soft ::slotted(mg-icon) {
@@ -46,7 +46,6 @@ export class MgTag {
46
46
  *************/
47
47
  /**
48
48
  * Validate the given textContent
49
- *
50
49
  * @param {string} textContent html element textContent property
51
50
  * @returns {void}
52
51
  */
@@ -59,7 +58,6 @@ export class MgTag {
59
58
  *************/
60
59
  /**
61
60
  * Check if props are well configured on init
62
- *
63
61
  * @returns {void}
64
62
  */
65
63
  componentWillLoad() {
@@ -70,7 +68,6 @@ export class MgTag {
70
68
  }
71
69
  /**
72
70
  * Render
73
- *
74
71
  * @returns {HTMLElement} HTML Element
75
72
  */
76
73
  render() {
@@ -1,12 +1,11 @@
1
1
  import { h, Host } from '@stencil/core';
2
- import { createID, focusableElements } from '../../../utils/components.utils';
2
+ import { createID, focusableElements, getWindows } from '../../../utils/components.utils';
3
3
  import { createPopper } from '@popperjs/core';
4
4
  import { Guard } from './mg-tooltip.conf';
5
5
  export class MgTooltip {
6
6
  constructor() {
7
7
  /**
8
8
  * Show tooltip
9
- *
10
9
  * @returns {void}
11
10
  */
12
11
  this.show = () => {
@@ -16,10 +15,17 @@ export class MgTooltip {
16
15
  this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
17
16
  // Update its position
18
17
  this.popper.update();
18
+ // hide when click outside
19
+ // setTimeout is used to prevent event to trigger after creation
20
+ setTimeout(() => {
21
+ this.windows.forEach((localWindow) => {
22
+ localWindow.addEventListener('click', this.clickOutside, false);
23
+ localWindow.addEventListener('keydown', this.pressEscape, false);
24
+ });
25
+ }, 0);
19
26
  };
20
27
  /**
21
28
  * Hide tooltip
22
- *
23
29
  * @returns {void}
24
30
  */
25
31
  this.hide = () => {
@@ -27,10 +33,32 @@ export class MgTooltip {
27
33
  this.tooltip.removeAttribute('data-show');
28
34
  // Disable the event listeners
29
35
  this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
36
+ // Remove event listener
37
+ this.windows.forEach((localWindow) => {
38
+ localWindow.removeEventListener('click', this.clickOutside, false);
39
+ localWindow.removeEventListener('keyboard', this.pressEscape, false);
40
+ });
41
+ };
42
+ /**
43
+ * Check if clicked outside of component and hidde tooltip
44
+ * @param {MouseEvent} event mouse event
45
+ * @returns {void}
46
+ */
47
+ this.clickOutside = (event) => {
48
+ if (event.target.closest('mg-tooltip') !== this.element)
49
+ this.setDisplay(false);
50
+ };
51
+ /**
52
+ * Check if 'Escape' key is pressed of component and hidde tooltip
53
+ * @param {KeyboardEvent} event keyboard event
54
+ * @returns {void}
55
+ */
56
+ this.pressEscape = (event) => {
57
+ if (event.code === 'Escape')
58
+ this.setDisplay(false);
30
59
  };
31
60
  /**
32
61
  * Method to set display prop
33
- *
34
62
  * @param {boolean} newValue display prop new value
35
63
  * @param {boolean} condition additionnal condition to apply display prop newValue
36
64
  * @returns {void}
@@ -41,7 +69,6 @@ export class MgTooltip {
41
69
  };
42
70
  /**
43
71
  * Action for tooltip element and tooltiped element mouse listener
44
- *
45
72
  * @param {Guard} elementGuard tooltip element guard
46
73
  * @param {boolean} isMouseenter mouseenter validation
47
74
  * @param {Guard} conditionalGuard guard condition
@@ -64,7 +91,6 @@ export class MgTooltip {
64
91
  };
65
92
  /**
66
93
  * Method to reset guard value
67
- *
68
94
  * @returns {void}
69
95
  */
70
96
  this.resetGuard = () => {
@@ -72,7 +98,6 @@ export class MgTooltip {
72
98
  };
73
99
  /**
74
100
  * Update slot content when it is a mg-button
75
- *
76
101
  * @param {HTMLMgButtonElement} mgButton slotted mg-button
77
102
  * @returns {void}
78
103
  */
@@ -91,7 +116,6 @@ export class MgTooltip {
91
116
  };
92
117
  /**
93
118
  * Init tooltip
94
- *
95
119
  * @param {HTMLElement} slotElement slotted element
96
120
  * @param {HTMLElement} interactiveElement interactive element
97
121
  */
@@ -130,10 +154,7 @@ export class MgTooltip {
130
154
  this.resetGuard();
131
155
  this.setDisplay(false);
132
156
  });
133
- document.addEventListener('keydown', (event) => {
134
- if (event.code === 'Escape')
135
- this.setDisplay(false);
136
- });
157
+ document.addEventListener('keydown', this.pressEscape);
137
158
  // manage tooltipElement & tooltipedElement mouseenter/mouseleave events
138
159
  ['mouseenter', 'mouseleave'].forEach(eventType => {
139
160
  const isMouseenter = eventType === 'mouseenter';
@@ -170,11 +191,18 @@ export class MgTooltip {
170
191
  /*************
171
192
  * Lifecycle *
172
193
  *************/
194
+ /**
195
+ * set variables
196
+ * @returns {void}
197
+ */
198
+ componentWillLoad() {
199
+ // Get windows to attach events
200
+ this.windows = getWindows(window);
201
+ }
173
202
  /**
174
203
  * Get slotted element
175
204
  * Check if it already contain an interactive element, if not we need to add a tabIndex attribute
176
205
  * We need to attach the focused element to the tooltip (aria-describedby)
177
- *
178
206
  * @returns {void}
179
207
  */
180
208
  componentDidLoad() {
@@ -208,7 +236,6 @@ export class MgTooltip {
208
236
  }
209
237
  /**
210
238
  * Render
211
- *
212
239
  * @returns {HTMLElement} HTML Element
213
240
  */
214
241
  render() {
@@ -306,7 +333,7 @@ export class MgTooltip {
306
333
  },
307
334
  "disabled": {
308
335
  "type": "boolean",
309
- "mutable": true,
336
+ "mutable": false,
310
337
  "complexType": {
311
338
  "original": "boolean",
312
339
  "resolved": "boolean",
@@ -1,7 +1,6 @@
1
1
  import { h } from '@stencil/core';
2
2
  /**
3
3
  * Apply in all input child node the aria-describedby attribute
4
- *
5
4
  * @param {VNode[]} children Represent scoped elements
6
5
  * @param {Set<string>} ariaDescribedbyIDs List of IDs
7
6
  * @param {FunctionalUtilities} utils Stencil.js utils
@@ -18,7 +17,6 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
18
17
  });
19
18
  /**
20
19
  * Add classes based on props
21
- *
22
20
  * @param {MgInputProps} props MgInput Interface Props
23
21
  */
24
22
  const manageClasses = (props) => {
@@ -32,14 +30,12 @@ const manageClasses = (props) => {
32
30
  };
33
31
  /**
34
32
  * Get tagname
35
- *
36
33
  * @param {boolean} isFieldset is fieldset
37
34
  * @returns {string} tag name
38
35
  */
39
36
  const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
40
37
  /**
41
38
  * Get input template
42
- *
43
39
  * @param {MgInputProps} props MgInput Interface Props
44
40
  * @param {VNode[]} children Represent scoped elements
45
41
  * @param {FunctionalUtilities} utils Stencil.js utils
@@ -99,14 +95,12 @@ export const MgInput = (props, children, utils) => {
99
95
  const TagName = getTagName(props.isFieldset);
100
96
  /**
101
97
  * Get tooltip node
102
- *
103
98
  * @returns {VNode[]} mg-tooltip
104
99
  */
105
100
  const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip }, h("mg-icon", { icon: "info-circle" })));
106
101
  /**
107
102
  * Get input title (label) node
108
103
  * Display asterisk only if not disabled and not readonly
109
- *
110
104
  * @returns {VNode[]} mg-input-title
111
105
  */
112
106
  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));
@@ -5,7 +5,6 @@ import { ClassList } from '../../../../utils/components.utils';
5
5
  import { initLocales } from '../../../../locales';
6
6
  /**
7
7
  * type CheckboxItem validation function
8
- *
9
8
  * @param {unknown} items Checkbox item
10
9
  * @returns {boolean} match item type
11
10
  */
@@ -22,7 +21,6 @@ export class MgInputCheckbox {
22
21
  this.hasDisplayedError = false;
23
22
  /**
24
23
  * Handle input event
25
- *
26
24
  * @param {InputEvent} event input event
27
25
  */
28
26
  this.handleInput = (event) => {
@@ -45,7 +43,6 @@ export class MgInputCheckbox {
45
43
  };
46
44
  /**
47
45
  * get invalid element
48
- *
49
46
  * @returns {HTMLInputElement} element
50
47
  */
51
48
  this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
@@ -113,7 +110,6 @@ export class MgInputCheckbox {
113
110
  }
114
111
  /**
115
112
  * Public method to display errors
116
- *
117
113
  * @returns {Promise<void>}
118
114
  */
119
115
  async displayError() {
@@ -126,7 +122,6 @@ export class MgInputCheckbox {
126
122
  *************/
127
123
  /**
128
124
  * Check if component props are well configured on init
129
- *
130
125
  * @returns {ReturnType<typeof setTimeout>} timeout
131
126
  */
132
127
  componentWillLoad() {
@@ -143,7 +138,6 @@ export class MgInputCheckbox {
143
138
  }
144
139
  /**
145
140
  * Render
146
- *
147
141
  * @returns {HTMLElement} HTML Element
148
142
  */
149
143
  render() {
@@ -36,7 +36,6 @@ export class MgInputDate {
36
36
  };
37
37
  /**
38
38
  * get input error code
39
- *
40
39
  * @returns {null | InputError} error code
41
40
  */
42
41
  this.getInputError = () => {
@@ -62,7 +61,6 @@ export class MgInputDate {
62
61
  };
63
62
  /**
64
63
  * Check input errors
65
- *
66
64
  * @returns {void}
67
65
  */
68
66
  this.setErrorMessage = () => {
@@ -132,7 +130,6 @@ export class MgInputDate {
132
130
  }
133
131
  /**
134
132
  * Public method to display errors
135
- *
136
133
  * @returns {Promise<void>}
137
134
  */
138
135
  async displayError() {
@@ -145,7 +142,6 @@ export class MgInputDate {
145
142
  *************/
146
143
  /**
147
144
  * Check if component props are well configured on init
148
- *
149
145
  * @returns {ReturnType<typeof setTimeout>} timeout
150
146
  */
151
147
  componentWillLoad() {
@@ -166,7 +162,6 @@ export class MgInputDate {
166
162
  }
167
163
  /**
168
164
  * Render
169
- *
170
165
  * @returns {HTMLElement} HTML Element
171
166
  */
172
167
  render() {