@mgdis/mg-components 5.3.0 → 5.5.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 (144) hide show
  1. package/dist/cjs/{index-94497267.js → index-c3450336.js} +0 -0
  2. package/dist/cjs/loader.cjs.js +3 -3
  3. package/dist/cjs/{mg-badge_29.cjs.entry.js → mg-badge_30.cjs.entry.js} +517 -715
  4. package/dist/cjs/mg-components.cjs.js +3 -3
  5. package/dist/collection/collection-manifest.json +3 -2
  6. package/dist/collection/components/atoms/mg-badge/doc/mg-badge.stories.js +0 -7
  7. package/dist/collection/components/atoms/mg-badge/mg-badge.css +6 -0
  8. package/dist/collection/components/atoms/mg-badge/mg-badge.js +5 -8
  9. package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +0 -7
  10. package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
  11. package/dist/collection/components/atoms/mg-button/mg-button.css +19 -1
  12. package/dist/collection/components/atoms/mg-button/mg-button.js +13 -30
  13. package/dist/collection/components/atoms/mg-card/mg-card.css +6 -1
  14. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +2 -3
  15. package/dist/collection/components/atoms/mg-divider/mg-divider.js +0 -6
  16. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +20 -4
  17. package/dist/collection/components/atoms/mg-icon/mg-icon.css +27 -0
  18. package/dist/collection/components/atoms/mg-icon/mg-icon.js +7 -12
  19. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +4 -8
  20. package/dist/collection/components/atoms/mg-tag/doc/mg-tag.stories.js +1 -9
  21. package/dist/collection/components/atoms/mg-tag/mg-tag.css +58 -0
  22. package/dist/collection/components/atoms/mg-tag/mg-tag.js +60 -15
  23. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +97 -68
  24. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +7 -0
  25. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +17 -33
  26. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +7 -0
  27. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +17 -25
  28. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +6 -0
  29. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +24 -47
  30. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +7 -0
  31. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +17 -29
  32. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +7 -0
  33. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +18 -33
  34. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +6 -0
  35. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +23 -33
  36. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +6 -0
  37. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +23 -41
  38. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +6 -0
  39. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +23 -45
  40. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +6 -0
  41. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +16 -33
  42. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +1 -1
  43. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +8 -23
  44. package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +8 -1
  45. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +55 -24
  46. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +18 -33
  47. package/dist/collection/components/molecules/mg-details/mg-details.css +6 -0
  48. package/dist/collection/components/molecules/mg-details/mg-details.js +4 -8
  49. package/dist/collection/components/molecules/mg-form/mg-form.js +9 -23
  50. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.css +2 -2
  51. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +0 -6
  52. package/dist/collection/components/molecules/mg-message/mg-message.css +13 -19
  53. package/dist/collection/components/molecules/mg-message/mg-message.js +8 -27
  54. package/dist/collection/components/molecules/mg-modal/mg-modal.css +12 -7
  55. package/dist/collection/components/molecules/mg-modal/mg-modal.js +8 -26
  56. package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +6 -0
  57. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +4 -13
  58. package/dist/collection/components/molecules/mg-panel/mg-panel.css +10 -5
  59. package/dist/collection/components/molecules/mg-panel/mg-panel.js +11 -22
  60. package/dist/collection/components/molecules/mg-popover/mg-popover.css +13 -9
  61. package/dist/collection/components/molecules/mg-popover/mg-popover.js +7 -23
  62. package/dist/collection/components/molecules/mg-skip-links/doc/mg-skip-links.stories.js +24 -0
  63. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.conf.js +1 -0
  64. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.css +28 -0
  65. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +77 -0
  66. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +10 -23
  67. package/dist/collection/locales/en/messages.json +3 -0
  68. package/dist/collection/locales/fr/messages.json +3 -0
  69. package/dist/components/index.d.ts +1 -0
  70. package/dist/components/index.js +1 -0
  71. package/dist/components/index2.js +8 -0
  72. package/dist/components/mg-badge2.js +6 -9
  73. package/dist/components/mg-button2.js +14 -31
  74. package/dist/components/mg-card.js +1 -37
  75. package/dist/components/mg-card2.js +39 -0
  76. package/dist/components/mg-character-left2.js +2 -3
  77. package/dist/components/mg-details.js +5 -9
  78. package/dist/components/mg-divider.js +0 -6
  79. package/dist/components/mg-form.js +9 -23
  80. package/dist/components/mg-icon2.js +28 -17
  81. package/dist/components/mg-illustrated-message.js +1 -7
  82. package/dist/components/mg-input-checkbox.js +18 -34
  83. package/dist/components/mg-input-date.js +18 -26
  84. package/dist/components/mg-input-numeric.js +25 -48
  85. package/dist/components/mg-input-password.js +18 -30
  86. package/dist/components/mg-input-radio.js +19 -34
  87. package/dist/components/mg-input-select2.js +25 -35
  88. package/dist/components/mg-input-text2.js +24 -42
  89. package/dist/components/mg-input-textarea.js +24 -46
  90. package/dist/components/mg-input-title2.js +4 -8
  91. package/dist/components/mg-input-toggle.js +17 -34
  92. package/dist/components/mg-menu-item.js +18 -33
  93. package/dist/components/mg-menu.js +9 -24
  94. package/dist/components/mg-message.js +17 -30
  95. package/dist/components/mg-modal.js +18 -30
  96. package/dist/components/mg-pagination.js +5 -14
  97. package/dist/components/mg-panel.js +20 -25
  98. package/dist/components/mg-popover.js +16 -26
  99. package/dist/components/mg-skip-links.d.ts +11 -0
  100. package/dist/components/mg-skip-links.js +66 -0
  101. package/dist/components/mg-tabs.js +10 -23
  102. package/dist/components/mg-tag.js +34 -12
  103. package/dist/components/mg-tooltip2.js +97 -68
  104. package/dist/esm/{index-aad0184c.js → index-78edde1d.js} +0 -0
  105. package/dist/esm/loader.js +3 -3
  106. package/dist/esm/{mg-badge_29.entry.js → mg-badge_30.entry.js} +517 -716
  107. package/dist/esm/mg-components.js +3 -3
  108. package/dist/esm/polyfills/core-js.js +0 -0
  109. package/dist/esm/polyfills/dom.js +0 -0
  110. package/dist/esm/polyfills/es5-html-element.js +0 -0
  111. package/dist/esm/polyfills/index.js +0 -0
  112. package/dist/esm/polyfills/system.js +0 -0
  113. package/dist/mg-components/locales/en/messages.json +3 -0
  114. package/dist/mg-components/locales/fr/messages.json +3 -0
  115. package/dist/mg-components/mg-components.css +1 -1
  116. package/dist/mg-components/mg-components.esm.js +1 -1
  117. package/dist/mg-components/{p-3899d5d2.js → p-125c54ca.js} +0 -0
  118. package/dist/mg-components/p-4961c96c.entry.js +1 -0
  119. package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +0 -11
  120. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +1 -1
  121. package/dist/types/components/atoms/mg-button/doc/mg-button.stories.d.ts +0 -11
  122. package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +2 -2
  123. package/dist/types/components/atoms/mg-button/mg-button.d.ts +6 -6
  124. package/dist/types/components/atoms/mg-tag/doc/mg-tag.stories.d.ts +0 -13
  125. package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +5 -1
  126. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +27 -6
  127. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +15 -0
  128. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +0 -5
  129. package/dist/types/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.d.ts +1 -0
  130. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +0 -4
  131. package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
  132. package/dist/types/components/molecules/mg-message/mg-message.d.ts +1 -1
  133. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +1 -1
  134. package/dist/types/components/molecules/mg-skip-links/doc/mg-skip-links.stories.d.ts +11 -0
  135. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.conf.d.ts +7 -0
  136. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +34 -0
  137. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +2 -2
  138. package/dist/types/components.d.ts +37 -6
  139. package/dist/types/locales/index.d.ts +6 -0
  140. package/dist/types/stencil-public-runtime.d.ts +5 -0
  141. package/dist/types/utils/unit.test.utils.d.ts +42 -0
  142. package/package.json +36 -31
  143. package/readme.md +3 -1
  144. package/dist/mg-components/p-204af46f.entry.js +0 -1
@@ -20,39 +20,6 @@ export class MgInputRadio {
20
20
  this.inputs = [];
21
21
  // hasDisplayedError (triggered by blur event)
22
22
  this.hasDisplayedError = false;
23
- /**
24
- * Input name
25
- * If not set the value equals the identifier
26
- */
27
- this.name = this.identifier;
28
- /**
29
- * Define if label is displayed on top
30
- */
31
- this.labelOnTop = false;
32
- /**
33
- * Define if label is visible
34
- */
35
- this.labelHide = false;
36
- /**
37
- * Define if inputs are display verticaly
38
- */
39
- this.inputVerticalList = false;
40
- /**
41
- * Define if input is required
42
- */
43
- this.required = false;
44
- /**
45
- * Define if input is readonly
46
- */
47
- this.readonly = false;
48
- /**
49
- * Define if input is disabled
50
- */
51
- this.disabled = false;
52
- /**
53
- * Component classes
54
- */
55
- this.classList = new ClassList(['mg-input--radio']);
56
23
  /**
57
24
  * Handle input event
58
25
  *
@@ -102,6 +69,24 @@ export class MgInputRadio {
102
69
  * @returns {HTMLInputElement} element
103
70
  */
104
71
  this.getInvalidElement = () => this.inputs.find((input) => !input.disabled && !input.readOnly && !input.checkValidity());
72
+ this.value = undefined;
73
+ this.items = undefined;
74
+ this.identifier = undefined;
75
+ this.name = this.identifier;
76
+ this.label = undefined;
77
+ this.labelOnTop = false;
78
+ this.labelHide = false;
79
+ this.inputVerticalList = false;
80
+ this.required = false;
81
+ this.readonly = false;
82
+ this.disabled = false;
83
+ this.tooltip = undefined;
84
+ this.helpText = undefined;
85
+ this.valid = undefined;
86
+ this.invalid = undefined;
87
+ this.classList = new ClassList(['mg-input--radio']);
88
+ this.errorMessage = undefined;
89
+ this.options = undefined;
105
90
  }
106
91
  handleValue(newValue) {
107
92
  this.valueChange.emit(newValue);
@@ -242,6 +242,12 @@
242
242
  outline: none;
243
243
  }
244
244
 
245
+ @media (prefers-reduced-motion) {
246
+ .mg-a11y-animation {
247
+ animation: none !important;
248
+ transition: none !important;
249
+ }
250
+ }
245
251
  .mg-input__box {
246
252
  width: 100%;
247
253
  padding-top: 0;
@@ -44,39 +44,6 @@ export class MgInputSelect {
44
44
  constructor() {
45
45
  // hasDisplayedError (triggered by blur event)
46
46
  this.hasDisplayedError = false;
47
- /**
48
- * Input name
49
- * If not set the value equals the identifier
50
- */
51
- this.name = this.identifier;
52
- /**
53
- * Define if label is visible
54
- */
55
- this.labelHide = false;
56
- /**
57
- * Option to remove placeholder
58
- */
59
- this.placeholderHide = false;
60
- /**
61
- * Option to disable placeholder
62
- */
63
- this.placeholderDisabled = false;
64
- /**
65
- * Define if input is required
66
- */
67
- this.required = false;
68
- /**
69
- * Define if input is readonly
70
- */
71
- this.readonly = false;
72
- /**
73
- * Define if input is disabled
74
- */
75
- this.disabled = false;
76
- /**
77
- * Component classes
78
- */
79
- this.classList = new ClassList(['mg-input--select']);
80
47
  /**
81
48
  * Handle input event
82
49
  */
@@ -118,6 +85,29 @@ export class MgInputSelect {
118
85
  this.errorMessage = this.messages.errors.required;
119
86
  }
120
87
  };
88
+ this.value = undefined;
89
+ this.items = undefined;
90
+ this.identifier = undefined;
91
+ this.name = this.identifier;
92
+ this.label = undefined;
93
+ this.labelOnTop = undefined;
94
+ this.labelHide = false;
95
+ this.placeholder = undefined;
96
+ this.placeholderHide = false;
97
+ this.placeholderDisabled = false;
98
+ this.required = false;
99
+ this.readonly = false;
100
+ this.disabled = false;
101
+ this.mgWidth = undefined;
102
+ this.tooltip = undefined;
103
+ this.helpText = undefined;
104
+ this.valid = undefined;
105
+ this.invalid = undefined;
106
+ this.classList = new ClassList(['mg-input--select']);
107
+ this.errorMessage = undefined;
108
+ this.options = undefined;
109
+ this.valueExist = undefined;
110
+ this.readonlyValue = undefined;
121
111
  }
122
112
  handleValue(newValue) {
123
113
  if (newValue !== null) {
@@ -253,6 +253,12 @@
253
253
  outline: none;
254
254
  }
255
255
 
256
+ @media (prefers-reduced-motion) {
257
+ .mg-a11y-animation {
258
+ animation: none !important;
259
+ transition: none !important;
260
+ }
261
+ }
256
262
  /**
257
263
  * Icon in input
258
264
  */
@@ -13,47 +13,6 @@ export class MgInputText {
13
13
  this.classHasIcon = 'mg-input--has-icon';
14
14
  // hasDisplayedError (triggered by blur event)
15
15
  this.hasDisplayedError = false;
16
- /**
17
- * Input name
18
- * If not set the value equals the identifier
19
- */
20
- this.name = this.identifier;
21
- /**
22
- * Input type
23
- */
24
- this.type = 'text';
25
- /**
26
- * Define if label is visible
27
- */
28
- this.labelHide = false;
29
- /**
30
- * Input max length
31
- */
32
- this.maxlength = 400;
33
- /**
34
- * Define if input is required
35
- */
36
- this.required = false;
37
- /**
38
- * Define if input is readonly
39
- */
40
- this.readonly = false;
41
- /**
42
- * Define if input is disabled
43
- */
44
- this.disabled = false;
45
- /**
46
- * Define input width
47
- */
48
- this.mgWidth = 'full';
49
- /**
50
- * Define if component should display character left
51
- */
52
- this.displayCharacterLeft = true;
53
- /**
54
- * Component classes
55
- */
56
- this.classList = new ClassList(['mg-input--text']);
57
16
  /**
58
17
  * Handle input event
59
18
  *
@@ -144,6 +103,29 @@ export class MgInputText {
144
103
  this.classList.add('mg-input--has-buttons-group-append');
145
104
  }
146
105
  };
106
+ this.value = undefined;
107
+ this.identifier = undefined;
108
+ this.name = this.identifier;
109
+ this.label = undefined;
110
+ this.type = 'text';
111
+ this.icon = undefined;
112
+ this.labelOnTop = undefined;
113
+ this.labelHide = false;
114
+ this.placeholder = undefined;
115
+ this.maxlength = 400;
116
+ this.required = false;
117
+ this.readonly = false;
118
+ this.disabled = false;
119
+ this.mgWidth = 'full';
120
+ this.pattern = undefined;
121
+ this.patternErrorMessage = undefined;
122
+ this.tooltip = undefined;
123
+ this.displayCharacterLeft = true;
124
+ this.helpText = undefined;
125
+ this.valid = undefined;
126
+ this.invalid = undefined;
127
+ this.classList = new ClassList(['mg-input--text']);
128
+ this.errorMessage = undefined;
147
129
  }
148
130
  handleValue(newValue) {
149
131
  this.valueChange.emit(newValue);
@@ -253,6 +253,12 @@
253
253
  outline: none;
254
254
  }
255
255
 
256
+ @media (prefers-reduced-motion) {
257
+ .mg-a11y-animation {
258
+ animation: none !important;
259
+ transition: none !important;
260
+ }
261
+ }
256
262
  /* Component Custom Style */
257
263
  .mg-input .mg-input__box {
258
264
  display: block;
@@ -12,51 +12,6 @@ export class MgInputTextarea {
12
12
  this.classHasDisplayCharacterLeft = 'mg-input--has-display-character-left';
13
13
  // hasDisplayedError (triggered by blur event)
14
14
  this.hasDisplayedError = false;
15
- /**
16
- * Input name
17
- * If not set the value equals the identifier
18
- */
19
- this.name = this.identifier;
20
- /**
21
- * Define if label is visible
22
- */
23
- this.labelHide = false;
24
- /**
25
- * Input max length
26
- */
27
- this.maxlength = 4000;
28
- /**
29
- * Define if input is required
30
- */
31
- this.required = false;
32
- /**
33
- * Define if input is readonly
34
- */
35
- this.readonly = false;
36
- /**
37
- * Define if input is disabled
38
- */
39
- this.disabled = false;
40
- /**
41
- * Define input width
42
- */
43
- this.mgWidth = 'full';
44
- /**
45
- * Define the number of visible text lines for the control
46
- */
47
- this.rows = 3;
48
- /**
49
- * Define if component should display character left
50
- */
51
- this.displayCharacterLeft = true;
52
- /**
53
- * Define if input is resizable
54
- */
55
- this.resizable = 'none';
56
- /**
57
- * Component classes
58
- */
59
- this.classList = new ClassList(['mg-input--textarea']);
60
15
  /**
61
16
  * Handle input event
62
17
  */
@@ -127,6 +82,29 @@ export class MgInputTextarea {
127
82
  throw new Error('<mg-input-textarea> prop "pattern" must be paired with the prop "patternErrorMessage"');
128
83
  }
129
84
  };
85
+ this.value = undefined;
86
+ this.identifier = undefined;
87
+ this.name = this.identifier;
88
+ this.label = undefined;
89
+ this.labelOnTop = undefined;
90
+ this.labelHide = false;
91
+ this.placeholder = undefined;
92
+ this.maxlength = 4000;
93
+ this.required = false;
94
+ this.readonly = false;
95
+ this.disabled = false;
96
+ this.mgWidth = 'full';
97
+ this.pattern = undefined;
98
+ this.patternErrorMessage = undefined;
99
+ this.rows = 3;
100
+ this.tooltip = undefined;
101
+ this.displayCharacterLeft = true;
102
+ this.helpText = undefined;
103
+ this.valid = undefined;
104
+ this.invalid = undefined;
105
+ this.resizable = 'none';
106
+ this.classList = new ClassList(['mg-input--textarea']);
107
+ this.errorMessage = undefined;
130
108
  }
131
109
  handleValue(newValue) {
132
110
  this.checkValidity();
@@ -118,6 +118,12 @@
118
118
  outline: none;
119
119
  }
120
120
 
121
+ @media (prefers-reduced-motion) {
122
+ .mg-a11y-animation {
123
+ animation: none !important;
124
+ transition: none !important;
125
+ }
126
+ }
121
127
  /**
122
128
  * Toogle
123
129
  */
@@ -21,39 +21,6 @@ export class MgInputToggle {
21
21
  this.classIsActive = 'mg-input--toggle-is-active';
22
22
  this.classOnOff = 'mg-input--toggle-on-off';
23
23
  this.classIcon = 'mg-input--toggle-icon';
24
- /**
25
- * Input name
26
- * If not set the value equals the identifier
27
- */
28
- this.name = this.identifier;
29
- /**
30
- * Define if label is visible
31
- */
32
- this.labelHide = false;
33
- /**
34
- * Define if toggle have on/off style
35
- */
36
- this.isOnOff = false;
37
- /**
38
- * Define if toggle display icon
39
- */
40
- this.isIcon = false;
41
- /**
42
- * Define if input is readonly
43
- */
44
- this.readonly = false;
45
- /**
46
- * Define if input is disabled
47
- */
48
- this.disabled = false;
49
- /**
50
- * Component classes
51
- */
52
- this.classList = new ClassList(['mg-input--toggle']);
53
- /**
54
- * Checked internal value
55
- */
56
- this.checked = false;
57
24
  /**
58
25
  * Change checked value
59
26
  *
@@ -78,6 +45,22 @@ export class MgInputToggle {
78
45
  slots.forEach(slot => slot.setAttribute('title', slot.textContent));
79
46
  }
80
47
  };
48
+ this.value = undefined;
49
+ this.items = undefined;
50
+ this.identifier = undefined;
51
+ this.name = this.identifier;
52
+ this.label = undefined;
53
+ this.labelOnTop = undefined;
54
+ this.labelHide = false;
55
+ this.isOnOff = false;
56
+ this.isIcon = false;
57
+ this.readonly = false;
58
+ this.disabled = false;
59
+ this.tooltip = undefined;
60
+ this.helpText = undefined;
61
+ this.classList = new ClassList(['mg-input--toggle']);
62
+ this.options = undefined;
63
+ this.checked = false;
81
64
  }
82
65
  handleValue(newValue) {
83
66
  // Swich to the right option
@@ -3,7 +3,7 @@
3
3
  background-color: hsl(var(--mg-menu-background-color-hsl, var(--color-light)));
4
4
  }
5
5
 
6
- :host(.mg-menu--vertical) {
6
+ :host([direction=vertical]) {
7
7
  flex-direction: column;
8
8
  height: 100%;
9
9
  overflow-y: auto;
@@ -1,5 +1,4 @@
1
1
  import { h, Host } from '@stencil/core';
2
- import { ClassList } from '../../../../utils/components.utils';
3
2
  import { Direction } from './mg-menu.conf';
4
3
  export class MgMenu {
5
4
  constructor() {
@@ -8,14 +7,6 @@ export class MgMenu {
8
7
  ************/
9
8
  this.name = 'mg-menu';
10
9
  this.focusedMenuItem = 0;
11
- /**
12
- * Component display direction. Default: "horizontal"
13
- */
14
- this.direction = Direction.HORIZONTAL;
15
- /**
16
- * Component classes
17
- */
18
- this.classList = new ClassList([this.name]);
19
10
  /**
20
11
  * Close matching menu-item
21
12
  *
@@ -37,9 +28,7 @@ export class MgMenu {
37
28
  // add listeners on menu item and edit index
38
29
  this.menuItems.forEach((item, menuItemIndex) => {
39
30
  ['click', 'focus'].forEach(trigger => {
40
- (item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, (event) => {
41
- event.preventDefault();
42
- event.stopPropagation();
31
+ (item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, () => {
43
32
  this.focusedMenuItem = menuItemIndex;
44
33
  // reset expanded on previous active menu item
45
34
  this.menuItems.forEach((item, index) => {
@@ -49,6 +38,9 @@ export class MgMenu {
49
38
  });
50
39
  });
51
40
  };
41
+ this.label = undefined;
42
+ this.direction = Direction.HORIZONTAL;
43
+ this.isChildMenu = undefined;
52
44
  }
53
45
  validateLabel(newValue) {
54
46
  if (newValue === undefined) {
@@ -56,13 +48,7 @@ export class MgMenu {
56
48
  }
57
49
  }
58
50
  validateDirection(newValue) {
59
- if (newValue === Direction.VERTICAL) {
60
- this.classList.add(`${this.name}--${Direction.VERTICAL}`);
61
- }
62
- else if (newValue === Direction.HORIZONTAL) {
63
- this.classList.add(`${this.name}--${Direction.HORIZONTAL}`);
64
- }
65
- else {
51
+ if (![Direction.VERTICAL, Direction.HORIZONTAL].includes(newValue)) {
66
52
  throw new Error(`<${this.name}> prop "direction" must be one of : ${Direction.HORIZONTAL}, ${Direction.VERTICAL}.`);
67
53
  }
68
54
  }
@@ -84,11 +70,11 @@ export class MgMenu {
84
70
  * @returns {ReturnType<typeof setTimeout>} timeout
85
71
  */
86
72
  componentDidLoad() {
87
- this.initMenuItems();
88
73
  // update props and states after componentDidLoad hook
89
74
  // return a promise to process action only in the FIRST render().
90
75
  // https://stenciljs.com/docs/component-lifecycle#componentwillload
91
76
  return setTimeout(() => {
77
+ this.initMenuItems();
92
78
  this.isChildMenu = this.element.closest('mg-menu-item') !== null;
93
79
  // click outside management for child vertical menu
94
80
  if (!this.isChildMenu && this.direction === Direction.HORIZONTAL) {
@@ -108,7 +94,7 @@ export class MgMenu {
108
94
  * @returns {HTMLElement} HTML Element
109
95
  */
110
96
  render() {
111
- return (h(Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label, classList: this.classList.join() }, h("slot", null)));
97
+ return (h(Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, h("slot", null)));
112
98
  }
113
99
  static get is() { return "mg-menu"; }
114
100
  static get encapsulation() { return "shadow"; }
@@ -168,8 +154,7 @@ export class MgMenu {
168
154
  }
169
155
  static get states() {
170
156
  return {
171
- "isChildMenu": {},
172
- "classList": {}
157
+ "isChildMenu": {}
173
158
  };
174
159
  }
175
160
  static get elementRef() { return "element"; }
@@ -1,5 +1,6 @@
1
1
  import { h } from '@stencil/core';
2
2
  import { filterArgs } from '../../../../../../.storybook/utils';
3
+ import { Direction } from '../../mg-menu/mg-menu.conf';
3
4
  export default {
4
5
  component: 'mg-menu-item',
5
6
  title: 'Beta/menus/mg-menu-item',
@@ -17,6 +18,12 @@ MgMenuItem.args = {
17
18
  identifier: 'identifier',
18
19
  slot: h("span", { slot: "label" }, "My label"),
19
20
  };
21
+ export const MgMenuItemAsLink = Template.bind({});
22
+ MgMenuItemAsLink.args = {
23
+ identifier: 'identifier',
24
+ href: './',
25
+ slot: h("span", { slot: "label" }, "My label"),
26
+ };
20
27
  export const MgMenuItemWhitIcon = Template.bind({});
21
28
  MgMenuItemWhitIcon.args = Object.assign(Object.assign({}, MgMenuItem.args), { slot: [h("span", { slot: "label" }, "My label"), h("mg-icon", { icon: "user", slot: "illustration" })] });
22
29
  export const MgMenuItemWhitBadge = Template.bind({});
@@ -28,5 +35,5 @@ MgMenuItemWhitMetadata.args = Object.assign(Object.assign({}, MgMenuItem.args),
28
35
  export const MgMenuItemWhithSubmenu = Template.bind({});
29
36
  MgMenuItemWhithSubmenu.args = Object.assign(Object.assign({}, MgMenuItem.args), { slot: [
30
37
  h("span", { slot: "label" }, "My label"),
31
- h("mg-menu-vertical", { label: "submenu" }, h("mg-menu-item", null, h("span", { slot: "label" }, "Subitem 1")), h("mg-menu-item", null, h("mg-icon", { icon: "user", slot: "illustration" }), h("span", { slot: "label" }, "Subitem 2")), h("mg-menu-item", null, h("span", { slot: "label" }, "Subitem 3"), h("mg-icon", { icon: "user", slot: "illustration" }), h("mg-badge", { value: "2", label: "hello", slot: "information" }))),
38
+ h("mg-menu", { direction: Direction.VERTICAL, label: "submenu" }, h("mg-menu-item", null, h("span", { slot: "label" }, "Subitem 1")), h("mg-menu-item", null, h("mg-icon", { icon: "user", slot: "illustration" }), h("span", { slot: "label" }, "Subitem 2")), h("mg-menu-item", null, h("span", { slot: "label" }, "Subitem 3"), h("mg-icon", { icon: "user", slot: "illustration" }), h("mg-badge", { value: "2", label: "hello", slot: "information" }))),
32
39
  ] });