@mgdis/mg-components 5.4.0 → 5.6.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 (194) hide show
  1. package/dist/cjs/{index-94497267.js → index-4dcc1812.js} +11 -1
  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} +1112 -859
  4. package/dist/cjs/mg-components.cjs.js +3 -3
  5. package/dist/collection/collection-manifest.json +5 -4
  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.conf.js +1 -1
  8. package/dist/collection/components/atoms/mg-badge/mg-badge.css +13 -0
  9. package/dist/collection/components/atoms/mg-badge/mg-badge.js +7 -10
  10. package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +0 -7
  11. package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
  12. package/dist/collection/components/atoms/mg-button/mg-button.css +15 -1
  13. package/dist/collection/components/atoms/mg-button/mg-button.js +12 -29
  14. package/dist/collection/components/atoms/mg-card/mg-card.css +17 -5
  15. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +2 -3
  16. package/dist/collection/components/atoms/mg-divider/mg-divider.js +0 -6
  17. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +13 -3
  18. package/dist/collection/components/atoms/mg-icon/mg-icon.js +5 -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 +61 -16
  23. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +2 -0
  24. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +9 -22
  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 +3 -3
  27. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +21 -26
  28. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +3 -3
  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 +3 -3
  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.js +18 -33
  33. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +3 -3
  34. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +30 -36
  35. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +3 -3
  36. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +23 -41
  37. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +3 -3
  38. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +23 -45
  39. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +16 -33
  40. package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +43 -11
  41. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +17 -0
  42. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +27 -0
  43. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +145 -25
  44. package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +7 -5
  45. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +0 -4
  46. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +51 -21
  47. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +129 -92
  48. package/dist/collection/components/molecules/mg-details/mg-details.js +4 -8
  49. package/dist/collection/components/molecules/mg-form/mg-form.js +8 -22
  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 +4 -9
  52. package/dist/collection/components/molecules/mg-message/mg-message.css +20 -19
  53. package/dist/collection/components/molecules/mg-message/mg-message.js +55 -33
  54. package/dist/collection/components/molecules/mg-modal/mg-modal.css +20 -8
  55. package/dist/collection/components/molecules/mg-modal/mg-modal.js +8 -26
  56. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +4 -13
  57. package/dist/collection/components/molecules/mg-panel/mg-panel.css +17 -5
  58. package/dist/collection/components/molecules/mg-panel/mg-panel.js +11 -22
  59. package/dist/collection/components/molecules/mg-popover/mg-popover.css +82 -20
  60. package/dist/collection/components/molecules/mg-popover/mg-popover.js +54 -26
  61. package/dist/collection/components/molecules/mg-skip-links/doc/mg-skip-links.stories.js +24 -0
  62. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.conf.js +1 -0
  63. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.css +28 -0
  64. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +108 -0
  65. package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +5 -3
  66. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +11 -7
  67. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +109 -75
  68. package/dist/collection/locales/en/messages.json +7 -0
  69. package/dist/collection/locales/fr/messages.json +7 -0
  70. package/dist/collection/locales/index.js +2 -25
  71. package/dist/collection/styles/a11y.scss +32 -0
  72. package/dist/collection/styles/components.scss +3 -0
  73. package/dist/collection/styles/fonts.scss +21 -0
  74. package/dist/collection/styles/form.scss +3 -0
  75. package/dist/collection/styles/global.scss +87 -0
  76. package/dist/collection/styles/layout.scss +29 -0
  77. package/dist/collection/styles/main.scss +23 -0
  78. package/dist/collection/styles/navigation-button.scss +76 -0
  79. package/dist/collection/styles/reset-mg-card-slotted-variables.scss +9 -0
  80. package/dist/collection/styles/typography.scss +75 -0
  81. package/dist/collection/styles/utilities.scss +21 -0
  82. package/dist/collection/utils/behaviors.utils.js +169 -0
  83. package/dist/collection/utils/components.utils.js +50 -0
  84. package/dist/collection/utils/locale.utils.js +22 -0
  85. package/dist/collection/utils/unit.test.utils.js +37 -32
  86. package/dist/collection/variables.css +9 -9
  87. package/dist/components/components.utils.js +51 -1
  88. package/dist/components/index.d.ts +1 -0
  89. package/dist/components/index.js +1 -0
  90. package/dist/components/index2.js +73 -18
  91. package/dist/components/mg-badge2.js +8 -11
  92. package/dist/components/mg-button2.js +13 -30
  93. package/dist/components/mg-card.js +1 -37
  94. package/dist/components/mg-card2.js +39 -0
  95. package/dist/components/mg-character-left2.js +2 -3
  96. package/dist/components/mg-details.js +4 -8
  97. package/dist/components/mg-divider.js +0 -6
  98. package/dist/components/mg-form.js +8 -22
  99. package/dist/components/mg-icon2.js +18 -15
  100. package/dist/components/mg-illustrated-message.js +5 -10
  101. package/dist/components/mg-input-checkbox.js +17 -33
  102. package/dist/components/mg-input-date.js +23 -29
  103. package/dist/components/mg-input-numeric.js +26 -50
  104. package/dist/components/mg-input-password.js +18 -30
  105. package/dist/components/mg-input-radio.js +18 -33
  106. package/dist/components/mg-input-select2.js +32 -38
  107. package/dist/components/mg-input-text2.js +24 -42
  108. package/dist/components/mg-input-textarea.js +24 -46
  109. package/dist/components/mg-input-title2.js +4 -8
  110. package/dist/components/mg-input-toggle.js +16 -33
  111. package/dist/components/mg-menu-item.js +1 -264
  112. package/dist/components/mg-menu-item2.js +517 -0
  113. package/dist/components/mg-menu.js +142 -28
  114. package/dist/components/mg-message.js +64 -36
  115. package/dist/components/mg-modal.js +18 -30
  116. package/dist/components/mg-pagination.js +4 -13
  117. package/dist/components/mg-panel.js +20 -25
  118. package/dist/components/mg-popover.js +1 -200
  119. package/dist/components/mg-popover2.js +212 -0
  120. package/dist/components/mg-skip-links.d.ts +11 -0
  121. package/dist/components/mg-skip-links.js +80 -0
  122. package/dist/components/mg-tabs.js +108 -73
  123. package/dist/components/mg-tag.js +35 -13
  124. package/dist/components/mg-tooltip2.js +10 -23
  125. package/dist/esm/{index-aad0184c.js → index-dc9a2348.js} +11 -1
  126. package/dist/esm/loader.js +3 -3
  127. package/dist/esm/{mg-badge_29.entry.js → mg-badge_30.entry.js} +1112 -860
  128. package/dist/esm/mg-components.js +3 -3
  129. package/dist/esm/polyfills/core-js.js +0 -0
  130. package/dist/esm/polyfills/css-shim.js +1 -1
  131. package/dist/esm/polyfills/dom.js +0 -0
  132. package/dist/esm/polyfills/es5-html-element.js +0 -0
  133. package/dist/esm/polyfills/index.js +0 -0
  134. package/dist/esm/polyfills/system.js +0 -0
  135. package/dist/mg-components/locales/en/messages.json +7 -0
  136. package/dist/mg-components/locales/fr/messages.json +7 -0
  137. package/dist/mg-components/mg-components.css +1 -1
  138. package/dist/mg-components/mg-components.esm.js +1 -1
  139. package/dist/mg-components/{p-3899d5d2.js → p-182bd802.js} +2 -2
  140. package/dist/mg-components/p-f7da9dd2.entry.js +1 -0
  141. package/dist/mg-components/styles/a11y.scss +32 -0
  142. package/dist/mg-components/styles/components.scss +3 -0
  143. package/dist/mg-components/styles/fonts.scss +21 -0
  144. package/dist/mg-components/styles/form.scss +3 -0
  145. package/dist/mg-components/styles/global.scss +87 -0
  146. package/dist/mg-components/styles/layout.scss +29 -0
  147. package/dist/mg-components/styles/main.scss +23 -0
  148. package/dist/mg-components/styles/navigation-button.scss +76 -0
  149. package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +9 -0
  150. package/dist/mg-components/styles/typography.scss +75 -0
  151. package/dist/mg-components/styles/utilities.scss +21 -0
  152. package/dist/mg-components/variables.css +9 -9
  153. package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +0 -11
  154. package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +2 -2
  155. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +1 -1
  156. package/dist/types/components/atoms/mg-button/doc/mg-button.stories.d.ts +0 -11
  157. package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +4 -4
  158. package/dist/types/components/atoms/mg-button/mg-button.d.ts +6 -6
  159. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +2 -2
  160. package/dist/types/components/atoms/mg-tag/doc/mg-tag.stories.d.ts +0 -13
  161. package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +5 -1
  162. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +27 -6
  163. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -2
  164. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +2 -2
  165. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
  166. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
  167. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
  168. package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +5 -0
  169. package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +37 -0
  170. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +51 -3
  171. package/dist/types/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.d.ts +1 -0
  172. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +0 -8
  173. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +55 -15
  174. package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
  175. package/dist/types/components/molecules/mg-message/mg-message.d.ts +22 -5
  176. package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +1 -1
  177. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +12 -0
  178. package/dist/types/components/molecules/mg-skip-links/doc/mg-skip-links.stories.d.ts +11 -0
  179. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.conf.d.ts +7 -0
  180. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +49 -0
  181. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +5 -3
  182. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +24 -14
  183. package/dist/types/components.d.ts +81 -18
  184. package/dist/types/locales/index.d.ts +16 -9
  185. package/dist/types/stencil-public-runtime.d.ts +44 -3
  186. package/dist/types/utils/behaviors.utils.d.ts +83 -0
  187. package/dist/types/utils/components.utils.d.ts +14 -0
  188. package/dist/types/utils/locale.utils.d.ts +13 -0
  189. package/dist/types/utils/unit.test.utils.d.ts +78 -0
  190. package/package.json +51 -46
  191. package/readme.md +25 -14
  192. package/dist/components/locale.utils.js +0 -40
  193. package/dist/components/mg-menu.conf.js +0 -10
  194. package/dist/mg-components/p-059a9a59.entry.js +0 -1
@@ -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) {
@@ -129,13 +119,17 @@ export class MgInputSelect {
129
119
  this.valueChange.emit(newValue);
130
120
  }
131
121
  validateItems(newValue) {
122
+ // Empty options
123
+ if (newValue.length === 0) {
124
+ this.options = [];
125
+ }
132
126
  // String array
133
- if (allItemsAreString(newValue)) {
127
+ else if (allItemsAreString(newValue)) {
134
128
  this.valueExist = newValue.includes(this.value);
135
129
  this.options = newValue.map((item) => ({ title: item, value: item }));
136
130
  }
137
131
  // Object array
138
- else if (newValue && newValue.every(item => isOption(item))) {
132
+ else if (newValue.every(item => isOption(item))) {
139
133
  this.valueExist = newValue.map(item => item.value).includes(this.value);
140
134
  // Grouped object options
141
135
  if (newValue.some(item => item.group !== undefined)) {
@@ -147,7 +141,7 @@ export class MgInputSelect {
147
141
  }
148
142
  }
149
143
  else {
150
- throw new Error('<mg-input-select> prop "items" is required and all items must be the same type, string or Option.');
144
+ throw new Error('<mg-input-select> prop "items" is required, can be an empty Array or all items must be the same type: string or Option.');
151
145
  }
152
146
  }
153
147
  handleValidityChange(newValue, _oldValue, prop) {
@@ -124,7 +124,7 @@
124
124
  font-style: italic;
125
125
  }
126
126
  .mg-input__box:focus {
127
- box-shadow: 0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);
127
+ box-shadow: 0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5);
128
128
  }
129
129
  .mg-input__box:disabled {
130
130
  opacity: 0.3;
@@ -145,8 +145,8 @@
145
145
  }
146
146
  .mg-input.mg-input--is-input-group-append .mg-input__box {
147
147
  margin-right: -0.1rem;
148
- border-top-right-radius: 0%;
149
- border-bottom-right-radius: 0%;
148
+ border-top-right-radius: 0;
149
+ border-bottom-right-radius: 0;
150
150
  }
151
151
  .mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible {
152
152
  outline-style: solid;
@@ -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);
@@ -124,7 +124,7 @@
124
124
  font-style: italic;
125
125
  }
126
126
  .mg-input__box:focus {
127
- box-shadow: 0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5);
127
+ box-shadow: 0 0 0.6rem hsl(var(--mg-inputs-color-shadow-focus-hsl), 0.5);
128
128
  }
129
129
  .mg-input__box:disabled {
130
130
  opacity: 0.3;
@@ -145,8 +145,8 @@
145
145
  }
146
146
  .mg-input.mg-input--is-input-group-append .mg-input__box {
147
147
  margin-right: -0.1rem;
148
- border-top-right-radius: 0%;
149
- border-bottom-right-radius: 0%;
148
+ border-top-right-radius: 0;
149
+ border-bottom-right-radius: 0;
150
150
  }
151
151
  .mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible {
152
152
  outline-style: solid;
@@ -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();
@@ -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
@@ -1,19 +1,27 @@
1
1
  import { h } from '@stencil/core';
2
2
  import { filterArgs } from '../../../../../../.storybook/utils';
3
- import { Status } from '../../mg-menu-item/mg-menu-item.conf';
4
3
  import { Direction } from '../mg-menu.conf';
4
+ import { Status } from '../../mg-menu-item/mg-menu-item.conf';
5
5
  export default {
6
6
  component: 'mg-menu',
7
- title: 'Beta/menus/mg-menu',
7
+ title: 'Beta/Menus/mg-menu',
8
8
  argTypes: {
9
9
  direction: {
10
10
  options: [undefined, Direction.HORIZONTAL, Direction.VERTICAL],
11
11
  control: { type: 'select' },
12
12
  },
13
+ moreitem: {
14
+ control: { type: 'object' },
15
+ },
13
16
  },
14
17
  };
15
- const getItemArgs = ({ size, label, direction, status, metadata, icon, badge, content, submenu }) => ({
16
- size: size !== undefined ? size : direction === Direction.VERTICAL ? 'medium' : undefined,
18
+ /**
19
+ * Format item args from given params
20
+ *
21
+ * @param {ItemArgType} itemArgs - item arguments
22
+ * @returns {ItemFormatedArgs} items formated args object
23
+ */
24
+ const getItemArgs = ({ label, status, metadata, icon, badge, content, submenu }) => ({
17
25
  status,
18
26
  slot: {
19
27
  label,
@@ -24,9 +32,32 @@ const getItemArgs = ({ size, label, direction, status, metadata, icon, badge, co
24
32
  submenu,
25
33
  },
26
34
  });
27
- const getMenuArgs = (direction, level = 0, isSubmenu = false) => ({
35
+ /**
36
+ * Render mg-menu-item
37
+ *
38
+ * @param {ItemFormatedArgs} args mg-menu-item args
39
+ * @returns {HTMLElement} rendered mg-menu-item
40
+ */
41
+ const menuItem = (args) => {
42
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
43
+ return (h("mg-menu-item", Object.assign({}, filterArgs(args)), ((_a = args.slot) === null || _a === void 0 ? void 0 : _a.label) && h("span", { slot: "label" }, (_b = args.slot) === null || _b === void 0 ? void 0 : _b.label), ((_c = args.slot) === null || _c === void 0 ? void 0 : _c.metadata) && h("span", { slot: "metadata" }, (_d = args.slot) === null || _d === void 0 ? void 0 : _d.metadata), ((_e = args.slot) === null || _e === void 0 ? void 0 : _e.icon) && h("mg-icon", { slot: "image", icon: "user" }), ((_f = args.slot) === null || _f === void 0 ? void 0 : _f.badge) && (h("mg-badge", { slot: "information", label: "information", value: "1" }, (_g = args.slot) === null || _g === void 0 ? void 0 : _g.icon)), ((_h = args.slot) === null || _h === void 0 ? void 0 : _h.content) && (h("div", null, h("h3", null, "Demo title"), h("p", null, "some content"))), ((_j = args.slot) === null || _j === void 0 ? void 0 : _j.submenu) && menu(getMenuArgs(Direction.VERTICAL, ((_k = args.slot) === null || _k === void 0 ? void 0 : _k.submenu) - 1, 'medium'))));
44
+ };
45
+ /***********
46
+ * mg-menu *
47
+ **********/
48
+ /**
49
+ * Format menu args from given params
50
+ *
51
+ * @param {Direction} direction menu direction
52
+ * @param {number} level menu level. Default: 0.
53
+ * @param {MenuSizeType} size menu size. Default: 'regular'
54
+ * @returns {MenuFormatedArgs} menu formated args object
55
+ */
56
+ const getMenuArgs = (direction, level = 0, size = 'regular') => ({
28
57
  label: 'Batman menu',
29
58
  direction,
59
+ size,
60
+ moreitem: undefined,
30
61
  slot: {
31
62
  items: [
32
63
  getItemArgs({
@@ -58,16 +89,17 @@ const getMenuArgs = (direction, level = 0, isSubmenu = false) => ({
58
89
  icon: true,
59
90
  metadata: 'my metadata',
60
91
  content: true,
61
- size: !isSubmenu && direction === Direction.HORIZONTAL ? 'regular' : undefined,
62
92
  }),
63
93
  ],
64
94
  },
65
95
  });
66
- const menu = args => h("mg-menu", Object.assign({}, filterArgs(args, { direction: Direction.HORIZONTAL })), args.slot.items.map(item => menuItem(item)));
67
- const menuItem = args => {
68
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
69
- return (h("mg-menu-item", Object.assign({}, filterArgs(args)), ((_a = args.slot) === null || _a === void 0 ? void 0 : _a.label) && h("span", { slot: "label" }, (_b = args.slot) === null || _b === void 0 ? void 0 : _b.label), ((_c = args.slot) === null || _c === void 0 ? void 0 : _c.metadata) && h("span", { slot: "metadata" }, (_d = args.slot) === null || _d === void 0 ? void 0 : _d.metadata), ((_e = args.slot) === null || _e === void 0 ? void 0 : _e.icon) && h("mg-icon", { slot: "illustration", icon: "user" }), ((_f = args.slot) === null || _f === void 0 ? void 0 : _f.badge) && (h("mg-badge", { slot: "information", label: "information", value: "1" }, (_g = args.slot) === null || _g === void 0 ? void 0 : _g.icon)), ((_h = args.slot) === null || _h === void 0 ? void 0 : _h.content) && (h("div", null, h("h3", null, "Demo title"), h("p", null, "some content"))), ((_j = args.slot) === null || _j === void 0 ? void 0 : _j.submenu) && menu(getMenuArgs(Direction.VERTICAL, ((_k = args.slot) === null || _k === void 0 ? void 0 : _k.submenu) - 1, true))));
70
- };
96
+ /**
97
+ * Render mg-menu
98
+ *
99
+ * @param {MenuFormatedArgs} args mg-menu args
100
+ * @returns {HTMLElement} rendered mg-menu
101
+ */
102
+ const menu = (args) => (h("mg-menu", Object.assign({}, filterArgs(args, { direction: Direction.HORIZONTAL })), args.slot.items.map(item => menuItem(item))));
71
103
  /**
72
104
  * Template
73
105
  *
@@ -6,3 +6,20 @@ export var Direction;
6
6
  Direction["VERTICAL"] = "vertical";
7
7
  Direction["HORIZONTAL"] = "horizontal";
8
8
  })(Direction || (Direction = {}));
9
+ /**
10
+ * More item type guard
11
+ *
12
+ * @param {unknown} element element to control
13
+ * @returns {boolean} truthy if element is more-item
14
+ */
15
+ export const isMoreItem = (element) => {
16
+ var _a, _b, _c;
17
+ const item = element;
18
+ return (item === undefined ||
19
+ (typeof item === 'object' &&
20
+ (typeof item.size === 'string' || typeof ((_a = item.mgIcon) === null || _a === void 0 ? void 0 : _a.icon) === 'string' || typeof ((_b = item.slotLabel) === null || _b === void 0 ? void 0 : _b.label) === 'string' || typeof ((_c = item.slotLabel) === null || _c === void 0 ? void 0 : _c.display) === 'boolean')));
21
+ };
22
+ /**
23
+ * List of all possibles sizes
24
+ */
25
+ export const sizes = ['regular', 'medium', 'large'];
@@ -1,3 +1,30 @@
1
+ /**
2
+ * A11Y
3
+ */
4
+ .sr-only {
5
+ border: 0 !important;
6
+ clip: rect(1px, 1px, 1px, 1px) !important;
7
+ -webkit-clip-path: inset(50%) !important;
8
+ clip-path: inset(50%) !important;
9
+ height: 1px !important;
10
+ margin: -1px !important;
11
+ overflow: hidden !important;
12
+ padding: 0 !important;
13
+ position: absolute !important;
14
+ width: 1px !important;
15
+ white-space: nowrap !important;
16
+ }
17
+
18
+ *:focus:not(:focus-visible) {
19
+ outline: none;
20
+ }
21
+
22
+ @media (prefers-reduced-motion) {
23
+ .mg-a11y-animation {
24
+ animation: none !important;
25
+ transition: none !important;
26
+ }
27
+ }
1
28
  :host {
2
29
  display: flex;
3
30
  background-color: hsl(var(--mg-menu-background-color-hsl, var(--color-light)));