@mgdis/mg-components 5.2.0 → 5.4.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 (90) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/{mg-badge_27.cjs.entry.js → mg-badge_29.cjs.entry.js} +496 -79
  3. package/dist/cjs/mg-components.cjs.js +1 -1
  4. package/dist/collection/collection-manifest.json +3 -1
  5. package/dist/collection/components/atoms/mg-badge/mg-badge.css +6 -0
  6. package/dist/collection/components/atoms/mg-badge/mg-badge.js +14 -19
  7. package/dist/collection/components/atoms/mg-button/mg-button.css +6 -1
  8. package/dist/collection/components/atoms/mg-button/mg-button.js +1 -1
  9. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +20 -4
  10. package/dist/collection/components/atoms/mg-icon/mg-icon.css +27 -0
  11. package/dist/collection/components/atoms/mg-icon/mg-icon.js +19 -7
  12. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +94 -52
  13. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +7 -0
  14. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +7 -0
  15. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +6 -0
  16. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +7 -0
  17. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +7 -0
  18. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +6 -0
  19. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +6 -0
  20. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +6 -0
  21. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +6 -0
  22. package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +87 -0
  23. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +8 -0
  24. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +10 -0
  25. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +173 -0
  26. package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +32 -0
  27. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +22 -0
  28. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +343 -0
  29. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +320 -0
  30. package/dist/collection/components/molecules/mg-details/mg-details.css +6 -0
  31. package/dist/collection/components/molecules/mg-form/mg-form.js +1 -1
  32. package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +6 -0
  33. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +3 -0
  34. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +67 -17
  35. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +10 -4
  36. package/dist/collection/locales/index.js +3 -1
  37. package/dist/collection/variables.css +23 -1
  38. package/dist/components/index.d.ts +2 -0
  39. package/dist/components/index.js +2 -0
  40. package/dist/components/index2.js +3 -1
  41. package/dist/components/mg-badge2.js +2 -2
  42. package/dist/components/mg-button2.js +2 -2
  43. package/dist/components/mg-details.js +1 -1
  44. package/dist/components/mg-form.js +1 -1
  45. package/dist/components/mg-icon2.js +23 -5
  46. package/dist/components/mg-input-checkbox.js +1 -1
  47. package/dist/components/mg-input-date.js +1 -1
  48. package/dist/components/mg-input-numeric.js +1 -1
  49. package/dist/components/mg-input-password.js +1 -1
  50. package/dist/components/mg-input-radio.js +1 -1
  51. package/dist/components/mg-input-select2.js +1 -1
  52. package/dist/components/mg-input-text2.js +1 -1
  53. package/dist/components/mg-input-textarea.js +1 -1
  54. package/dist/components/mg-input-toggle.js +1 -1
  55. package/dist/components/mg-menu-item.d.ts +11 -0
  56. package/dist/components/mg-menu-item.js +269 -0
  57. package/dist/components/mg-menu.conf.js +10 -0
  58. package/dist/components/mg-menu.d.ts +11 -0
  59. package/dist/components/mg-menu.js +137 -0
  60. package/dist/components/mg-pagination.js +1 -1
  61. package/dist/components/mg-tabs.js +6 -2
  62. package/dist/components/mg-tooltip2.js +94 -52
  63. package/dist/esm/loader.js +1 -1
  64. package/dist/esm/{mg-badge_27.entry.js → mg-badge_29.entry.js} +495 -80
  65. package/dist/esm/mg-components.js +1 -1
  66. package/dist/mg-components/mg-components.css +1 -1
  67. package/dist/mg-components/mg-components.esm.js +1 -1
  68. package/dist/mg-components/p-059a9a59.entry.js +1 -0
  69. package/dist/mg-components/variables.css +23 -1
  70. package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +2 -2
  71. package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +5 -5
  72. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -8
  73. package/dist/types/components/atoms/mg-icon/doc/mg-icon.stories.d.ts +2 -2
  74. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +10 -2
  75. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +7 -6
  76. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +15 -0
  77. package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +17 -0
  78. package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +7 -0
  79. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +64 -0
  80. package/dist/types/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.d.ts +11 -0
  81. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +24 -0
  82. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +115 -0
  83. package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +1 -1
  84. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +12 -4
  85. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +6 -6
  86. package/dist/types/components.d.ts +91 -14
  87. package/dist/types/locales/index.d.ts +7 -1
  88. package/dist/types/stories/icons.stories.d.ts +1 -1
  89. package/package.json +2 -2
  90. package/dist/mg-components/p-b2b07c3f.entry.js +0 -1
@@ -0,0 +1,343 @@
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
+ }
28
+ .mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button,
29
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular {
30
+ padding: 1rem 2rem;
31
+ }
32
+ .mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button,
33
+ .mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button ::slotted([slot=label]),
34
+ .mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button ::slotted([slot=metadata]),
35
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular,
36
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular ::slotted([slot=label]),
37
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular ::slotted([slot=metadata]) {
38
+ font-size: 1.3rem;
39
+ }
40
+ .mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,
41
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular.mg-menu-item__navigation-button--horizontal {
42
+ padding-bottom: calc(1rem - 0.3rem);
43
+ }
44
+ .mg-menu-item.mg-menu-item--size-regular .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,
45
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular.mg-menu-item__navigation-button--vertical {
46
+ padding-left: calc(2rem - 0.3rem);
47
+ }
48
+
49
+ .mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button,
50
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium {
51
+ padding: 1.5rem 3rem;
52
+ }
53
+ .mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button,
54
+ .mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button ::slotted([slot=label]),
55
+ .mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button ::slotted([slot=metadata]),
56
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium,
57
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium ::slotted([slot=label]),
58
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium ::slotted([slot=metadata]) {
59
+ font-size: 1.5rem;
60
+ }
61
+ .mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,
62
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium.mg-menu-item__navigation-button--horizontal {
63
+ padding-bottom: calc(1.5rem - 0.3rem);
64
+ }
65
+ .mg-menu-item.mg-menu-item--size-medium .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,
66
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium.mg-menu-item__navigation-button--vertical {
67
+ padding-left: calc(3rem - 0.3rem);
68
+ }
69
+
70
+ .mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button,
71
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large {
72
+ padding: 2.5rem 4rem;
73
+ }
74
+ .mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button,
75
+ .mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button ::slotted([slot=label]),
76
+ .mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button ::slotted([slot=metadata]),
77
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large,
78
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large ::slotted([slot=label]),
79
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large ::slotted([slot=metadata]) {
80
+ font-size: 1.5rem;
81
+ }
82
+ .mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal,
83
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large.mg-menu-item__navigation-button--horizontal {
84
+ padding-bottom: calc(2.5rem - 0.3rem);
85
+ }
86
+ .mg-menu-item.mg-menu-item--size-large .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical,
87
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large.mg-menu-item__navigation-button--vertical {
88
+ padding-left: calc(4rem - 0.3rem);
89
+ }
90
+
91
+ .mg-menu-item__navigation-button {
92
+ display: flex;
93
+ align-items: center;
94
+ column-gap: 1rem;
95
+ background-color: unset;
96
+ border: none;
97
+ font-family: var(--font-family);
98
+ color: hsl(var(--mg-menu-item-color-hsl, var(--color-dark)));
99
+ line-height: var(--line-height);
100
+ text-decoration: none;
101
+ cursor: pointer;
102
+ }
103
+ .mg-menu-item__navigation-button:disabled, .mg-menu-item__navigation-button--disabled {
104
+ cursor: default;
105
+ opacity: 30%;
106
+ }
107
+ .mg-menu-item__navigation-button:focus-visible {
108
+ z-index: 10;
109
+ }
110
+ .mg-menu-item__navigation-button:hover:not(.mg-menu-item__navigation-button--disabled), .mg-menu-item__navigation-button:focus:not(.mg-menu-item__navigation-button--disabled) {
111
+ background-color: hsla(var(--mg-menu-item-focused-background-color-hsl), 10%);
112
+ }
113
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--active {
114
+ color: hsl(var(--mg-menu-item-color-active-hsl));
115
+ font-weight: 700;
116
+ }
117
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--active.mg-menu-item__navigation-button--horizontal {
118
+ border-bottom-color: hsl(var(--mg-menu-item-border-color-active-hsl));
119
+ }
120
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--active.mg-menu-item__navigation-button--vertical {
121
+ border-left-color: hsl(var(--mg-menu-item-border-color-active-hsl));
122
+ }
123
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--hidden {
124
+ display: none;
125
+ }
126
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--horizontal {
127
+ border-bottom: 0.3rem solid transparent;
128
+ }
129
+ .mg-menu-item__navigation-button.mg-menu-item__navigation-button--vertical {
130
+ border-left: 0.3rem solid transparent;
131
+ }
132
+
133
+ :host([data-style-direction-vertical][data-level="1"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular {
134
+ padding-left: calc(1 * 2rem - 0.3rem);
135
+ }
136
+
137
+ :host([data-level="1"]) .mg-menu-item__collapse-container {
138
+ z-index: calc(1 * 10);
139
+ }
140
+
141
+ :host([data-style-direction-vertical][data-level="2"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular {
142
+ padding-left: calc(2 * 2rem - 0.3rem);
143
+ }
144
+
145
+ :host([data-level="2"]) .mg-menu-item__collapse-container {
146
+ z-index: calc(2 * 10);
147
+ }
148
+
149
+ :host([data-style-direction-vertical][data-level="3"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular {
150
+ padding-left: calc(3 * 2rem - 0.3rem);
151
+ }
152
+
153
+ :host([data-level="3"]) .mg-menu-item__collapse-container {
154
+ z-index: calc(3 * 10);
155
+ }
156
+
157
+ :host([data-style-direction-vertical][data-level="4"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular {
158
+ padding-left: calc(4 * 2rem - 0.3rem);
159
+ }
160
+
161
+ :host([data-level="4"]) .mg-menu-item__collapse-container {
162
+ z-index: calc(4 * 10);
163
+ }
164
+
165
+ :host([data-style-direction-vertical][data-level="5"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular {
166
+ padding-left: calc(5 * 2rem - 0.3rem);
167
+ }
168
+
169
+ :host([data-level="5"]) .mg-menu-item__collapse-container {
170
+ z-index: calc(5 * 10);
171
+ }
172
+
173
+ :host([data-style-direction-vertical][data-level="6"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-regular {
174
+ padding-left: calc(6 * 2rem - 0.3rem);
175
+ }
176
+
177
+ :host([data-level="6"]) .mg-menu-item__collapse-container {
178
+ z-index: calc(6 * 10);
179
+ }
180
+
181
+ :host([data-style-direction-vertical][data-level="1"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium {
182
+ padding-left: calc(1 * 3rem - 0.3rem);
183
+ }
184
+
185
+ :host([data-level="1"]) .mg-menu-item__collapse-container {
186
+ z-index: calc(1 * 10);
187
+ }
188
+
189
+ :host([data-style-direction-vertical][data-level="2"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium {
190
+ padding-left: calc(2 * 3rem - 0.3rem);
191
+ }
192
+
193
+ :host([data-level="2"]) .mg-menu-item__collapse-container {
194
+ z-index: calc(2 * 10);
195
+ }
196
+
197
+ :host([data-style-direction-vertical][data-level="3"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium {
198
+ padding-left: calc(3 * 3rem - 0.3rem);
199
+ }
200
+
201
+ :host([data-level="3"]) .mg-menu-item__collapse-container {
202
+ z-index: calc(3 * 10);
203
+ }
204
+
205
+ :host([data-style-direction-vertical][data-level="4"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium {
206
+ padding-left: calc(4 * 3rem - 0.3rem);
207
+ }
208
+
209
+ :host([data-level="4"]) .mg-menu-item__collapse-container {
210
+ z-index: calc(4 * 10);
211
+ }
212
+
213
+ :host([data-style-direction-vertical][data-level="5"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium {
214
+ padding-left: calc(5 * 3rem - 0.3rem);
215
+ }
216
+
217
+ :host([data-level="5"]) .mg-menu-item__collapse-container {
218
+ z-index: calc(5 * 10);
219
+ }
220
+
221
+ :host([data-style-direction-vertical][data-level="6"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-medium {
222
+ padding-left: calc(6 * 3rem - 0.3rem);
223
+ }
224
+
225
+ :host([data-level="6"]) .mg-menu-item__collapse-container {
226
+ z-index: calc(6 * 10);
227
+ }
228
+
229
+ :host([data-style-direction-vertical][data-level="1"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large {
230
+ padding-left: calc(1 * 4rem - 0.3rem);
231
+ }
232
+
233
+ :host([data-level="1"]) .mg-menu-item__collapse-container {
234
+ z-index: calc(1 * 10);
235
+ }
236
+
237
+ :host([data-style-direction-vertical][data-level="2"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large {
238
+ padding-left: calc(2 * 4rem - 0.3rem);
239
+ }
240
+
241
+ :host([data-level="2"]) .mg-menu-item__collapse-container {
242
+ z-index: calc(2 * 10);
243
+ }
244
+
245
+ :host([data-style-direction-vertical][data-level="3"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large {
246
+ padding-left: calc(3 * 4rem - 0.3rem);
247
+ }
248
+
249
+ :host([data-level="3"]) .mg-menu-item__collapse-container {
250
+ z-index: calc(3 * 10);
251
+ }
252
+
253
+ :host([data-style-direction-vertical][data-level="4"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large {
254
+ padding-left: calc(4 * 4rem - 0.3rem);
255
+ }
256
+
257
+ :host([data-level="4"]) .mg-menu-item__collapse-container {
258
+ z-index: calc(4 * 10);
259
+ }
260
+
261
+ :host([data-style-direction-vertical][data-level="5"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large {
262
+ padding-left: calc(5 * 4rem - 0.3rem);
263
+ }
264
+
265
+ :host([data-level="5"]) .mg-menu-item__collapse-container {
266
+ z-index: calc(5 * 10);
267
+ }
268
+
269
+ :host([data-style-direction-vertical][data-level="6"]) .mg-menu-item__navigation-button.mg-menu-item__navigation-button--size-large {
270
+ padding-left: calc(6 * 4rem - 0.3rem);
271
+ }
272
+
273
+ :host([data-level="6"]) .mg-menu-item__collapse-container {
274
+ z-index: calc(6 * 10);
275
+ }
276
+
277
+ :host {
278
+ position: relative;
279
+ display: flex;
280
+ }
281
+
282
+ :host([data-style-position-last]) .mg-menu-item__collapse-container {
283
+ left: unset;
284
+ right: 0;
285
+ }
286
+
287
+ :host([data-style-direction-vertical]) {
288
+ flex-direction: column;
289
+ }
290
+ :host([data-style-direction-vertical]) .mg-menu-item__collapse-container {
291
+ left: unset;
292
+ top: unset;
293
+ position: unset;
294
+ width: unset;
295
+ }
296
+ :host([data-style-direction-vertical]) .mg-menu-item-chevron {
297
+ margin-left: auto;
298
+ }
299
+
300
+ :host([data-style-direction-horizontal]) .mg-menu-item__collapse-container.mg-menu-item__collapse-container--first-level {
301
+ box-shadow: var(--box-shadow);
302
+ background-color: hsl(var(--color-light));
303
+ }
304
+ :host([data-style-direction-horizontal]) .mg-menu-item__collapse-container.mg-menu-item__collapse-container--first-level ::slotted(mg-menu) {
305
+ padding: 1rem 0;
306
+ }
307
+
308
+ .mg-menu-item {
309
+ max-width: var(--mg-menu-item-navigation-button-max-width);
310
+ }
311
+ .mg-menu-item__collapse-container {
312
+ position: absolute;
313
+ top: 100%;
314
+ left: 0;
315
+ width: max-content;
316
+ z-index: 10;
317
+ }
318
+ .mg-menu-item__navigation-button-center {
319
+ min-width: 0;
320
+ }
321
+ .mg-menu-item__navigation-button-text-content {
322
+ width: 100%;
323
+ display: flex;
324
+ }
325
+ .mg-menu-item__navigation-button-text-content ::slotted([slot=information]) {
326
+ margin-left: 1rem;
327
+ }
328
+ .mg-menu-item__navigation-button-chevron {
329
+ margin-left: auto;
330
+ transition: 200ms;
331
+ }
332
+ .mg-menu-item__navigation-button-chevron--rotate.mg-menu-item__navigation-button-chevron {
333
+ transform: rotate(180deg);
334
+ }
335
+
336
+ ::slotted([slot=label]),
337
+ ::slotted([slot=metadata]) {
338
+ display: block;
339
+ text-align: left;
340
+ white-space: nowrap;
341
+ overflow: hidden;
342
+ text-overflow: ellipsis;
343
+ }
@@ -0,0 +1,320 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import { ClassList } from '../../../../utils/components.utils';
3
+ import { Direction } from '../mg-menu/mg-menu.conf';
4
+ import { sizes, Status } from './mg-menu-item.conf';
5
+ export class MgMenuItem {
6
+ constructor() {
7
+ /************
8
+ * Internal *
9
+ ************/
10
+ this.name = 'mg-menu-item';
11
+ this.navigationButton = `${this.name}__navigation-button`;
12
+ /**
13
+ * Define menu-item status. Default: "visible"
14
+ */
15
+ this.status = Status.VISIBLE;
16
+ /**
17
+ * Define menu-item size. Default: "large".
18
+ */
19
+ this.size = 'large';
20
+ /**
21
+ * Define menu-item content expanded. Default: false.
22
+ */
23
+ this.expanded = false;
24
+ /************
25
+ * States *
26
+ ************/
27
+ /**
28
+ * Component button classes
29
+ */
30
+ this.navigationButtonClassList = new ClassList([this.navigationButton]);
31
+ /**
32
+ * Does component have children. Default: false.
33
+ */
34
+ this.hasChildren = false;
35
+ /************
36
+ * Methods *
37
+ ************/
38
+ /**
39
+ * Toggle expanded prop value
40
+ *
41
+ * @returns {void}
42
+ */
43
+ this.toggleExpanded = () => {
44
+ this.expanded = !this.expanded;
45
+ };
46
+ /**
47
+ * Does an HTMLElement contain child with given Status
48
+ *
49
+ * @param {HTMLElement} element to parse
50
+ * @param {MgMenuItem['status']} status to check
51
+ * @returns {boolean} true if element with status is found
52
+ */
53
+ this.hasChildElementStatus = (element, status) => element.querySelector(`${this.name}[status="${status}"]`) !== null;
54
+ /**
55
+ * Is component contextual direction match the given direction
56
+ *
57
+ * @param {MgMenuItem['direction']} direction in parent menu
58
+ * @returns {boolean} true is direction match the direction propertie
59
+ */
60
+ this.isdirection = (direction) => this.direction === direction;
61
+ /************
62
+ * Handlers *
63
+ ************/
64
+ /**
65
+ * Handle interacrtive element click
66
+ *
67
+ * @param {MouseEvent} event click on element
68
+ * @returns {void}
69
+ */
70
+ this.handleElementCLick = (event) => {
71
+ event.preventDefault();
72
+ if (this.hasChildren)
73
+ this.toggleExpanded();
74
+ };
75
+ }
76
+ validateStatus(newValue, oldValue) {
77
+ if (oldValue !== undefined) {
78
+ this.navigationButtonClassList.delete(`${this.navigationButton}--${oldValue}`);
79
+ }
80
+ this.navigationButtonClassList.add(`${this.navigationButton}--${newValue}`);
81
+ }
82
+ validateSize(newValue, oldValue) {
83
+ if (!sizes.includes(newValue)) {
84
+ throw new Error(`<${this.name}> prop "size" must be one of : ${sizes.join(', ')}.`);
85
+ }
86
+ this.navigationButtonClassList.delete(`${this.navigationButton}--size-${oldValue}`);
87
+ this.navigationButtonClassList.add(`${this.navigationButton}--size-${newValue}`);
88
+ }
89
+ validateExpanded(newValue) {
90
+ if (typeof newValue !== 'boolean')
91
+ throw new Error(`<${this.name}> prop "expanded" must be a boolean.`);
92
+ // if menu-item has sub-menu we have to apply some updates:
93
+ if (this.hasChildren) {
94
+ const subItems = Array.from(this.element.querySelectorAll(this.name));
95
+ if (!newValue) {
96
+ // - when main menu item is NOT expanded we need NOT expanded sub-items and NOT expanded sub-content
97
+ subItems.forEach(item => {
98
+ item.expanded = false;
99
+ });
100
+ }
101
+ else if (newValue && this.hasChildElementStatus(this.element, Status.ACTIVE)) {
102
+ // - when expanded and contain an active item parents are expended too
103
+ subItems.forEach(item => {
104
+ if (this.hasChildElementStatus(item, Status.ACTIVE)) {
105
+ item.expanded = true;
106
+ }
107
+ });
108
+ }
109
+ }
110
+ }
111
+ validateHasChildren(newValue) {
112
+ if (newValue && this.element.href !== undefined) {
113
+ throw new Error(`<${this.name}> prop "href" is unauthorizied when element is a parent.`);
114
+ }
115
+ }
116
+ /*************
117
+ * Lifecycle *
118
+ *************/
119
+ /**
120
+ * Validate props
121
+ *
122
+ * @returns {void}
123
+ */
124
+ componentWillLoad() {
125
+ // has children items that is NOT [slot="illustration"] || [slot="information"] element
126
+ // we store only matching elements
127
+ this.hasChildren = Array.from(this.element.children).filter(child => !['illustration', 'information', 'label', 'metadata'].includes(child.getAttribute('slot'))).length > 0;
128
+ // Validate props
129
+ this.validateSize(this.size);
130
+ this.validateStatus(this.status);
131
+ this.validateExpanded(this.expanded);
132
+ }
133
+ /**
134
+ * Check if component slots configuration
135
+ *
136
+ * @returns {ReturnType<typeof setTimeout>} timeout
137
+ */
138
+ componentDidLoad() {
139
+ // slot title AND metadata validation
140
+ // add title on label AND metada slots due to text-overflow on these element
141
+ if (Array.from(this.element.children).find(child => child.getAttribute('slot') === 'label') === undefined)
142
+ throw new Error(`<${this.name}> slot "label" is required.`);
143
+ ['label', 'metadata'].forEach(slot => {
144
+ Array.from(this.element.querySelectorAll(`[slot="${slot}"]`)).forEach(element => {
145
+ if (element.textContent.trim().length < 1)
146
+ throw new Error(`<${this.name}> slot "${slot}" must have text content.`);
147
+ if (element.getAttribute('title') === null)
148
+ element.setAttribute('title', element.textContent);
149
+ });
150
+ });
151
+ // update props and states after componentDidLoad hook
152
+ // return a promise to process action only in the FIRST render().
153
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
154
+ return setTimeout(() => {
155
+ var _a, _b;
156
+ // define menu-item context states
157
+ if (this.element.parentElement.nodeName === 'MG-MENU') {
158
+ this.direction = this.element.parentElement.direction;
159
+ }
160
+ this.isInMainMenu = this.element.parentElement.className.includes('mg-menu-item') === false;
161
+ const hasNextMenuItem = ((_a = this.element.nextElementSibling) === null || _a === void 0 ? void 0 : _a.nodeName) === 'MG-MENU-ITEM';
162
+ const hasPreviousMenuItem = ((_b = this.element.previousElementSibling) === null || _b === void 0 ? void 0 : _b.nodeName) === 'MG-MENU-ITEM';
163
+ // manage last menu item
164
+ if (!hasNextMenuItem && hasPreviousMenuItem && this.isdirection(Direction.HORIZONTAL)) {
165
+ this.element.setAttribute('data-style-position-last', '');
166
+ }
167
+ // when main menu item contain an active item it will get the active style
168
+ // AND if item is in vertical menu it will be expanded
169
+ if (this.isInMainMenu && this.hasChildElementStatus(this.element, Status.ACTIVE)) {
170
+ this.status = Status.ACTIVE;
171
+ this.expanded = this.direction === Direction.VERTICAL;
172
+ }
173
+ // manage menu items style depending to parent menu horientation
174
+ this.element.setAttribute(`data-style-direction-${this.direction}`, '');
175
+ this.navigationButtonClassList.add(`${this.navigationButton}--${this.direction}`);
176
+ // manage child items level
177
+ const childItems = Array.from(this.element.querySelectorAll('mg-menu-item'));
178
+ childItems.forEach(item => {
179
+ if (this.direction === Direction.VERTICAL) {
180
+ const itemLevel = Number(item.getAttribute('data-level')) || 1;
181
+ item.setAttribute('data-level', `${itemLevel + 1}`);
182
+ }
183
+ });
184
+ }, 0);
185
+ }
186
+ /**
187
+ * Render
188
+ *
189
+ * @returns {HTMLElement} HTML Element
190
+ */
191
+ render() {
192
+ const TagName = this.href !== undefined ? 'a' : 'button';
193
+ return (h(Host, { role: "menuitem", "aria-haspopup": this.hasChildren.toString() }, h(TagName, { href: this.href, class: this.navigationButtonClassList.join(), tabindex: [Status.DISABLED, Status.HIDDEN].includes(this.status) ? -1 : 0, disabled: this.status === Status.DISABLED, "aria-expanded": this.hasChildren && this.expanded.toString(), "aria-current": this.status === Status.ACTIVE && 'page', onClick: this.handleElementCLick }, h("slot", { name: "illustration" }), h("div", { class: `${this.navigationButton}-center` }, h("div", { class: `${this.navigationButton}-text-content` }, h("slot", { name: "label" }), h("slot", { name: "information" })), h("slot", { name: "metadata" })), this.hasChildren && this.href === undefined && (h("span", { class: {
194
+ [`${this.navigationButton}-chevron`]: true,
195
+ [`${this.navigationButton}-chevron--rotate`]: this.expanded === true,
196
+ 'mg-a11y-animation': true,
197
+ } }, h("mg-icon", { icon: "chevron-down" })))), h("div", { class: { [`${this.name}__collapse-container`]: true, [`${this.name}__collapse-container--first-level`]: this.isInMainMenu && this.isdirection(Direction.HORIZONTAL) }, hidden: !this.expanded }, h("slot", null))));
198
+ }
199
+ static get is() { return "mg-menu-item"; }
200
+ static get encapsulation() { return "shadow"; }
201
+ static get originalStyleUrls() {
202
+ return {
203
+ "$": ["mg-menu-item.scss"]
204
+ };
205
+ }
206
+ static get styleUrls() {
207
+ return {
208
+ "$": ["mg-menu-item.css"]
209
+ };
210
+ }
211
+ static get properties() {
212
+ return {
213
+ "href": {
214
+ "type": "string",
215
+ "mutable": false,
216
+ "complexType": {
217
+ "original": "string",
218
+ "resolved": "string",
219
+ "references": {}
220
+ },
221
+ "required": false,
222
+ "optional": false,
223
+ "docs": {
224
+ "tags": [],
225
+ "text": "Define menu-item badge\nwhen defined menu-item contain an anchor instead of button"
226
+ },
227
+ "attribute": "href",
228
+ "reflect": false
229
+ },
230
+ "status": {
231
+ "type": "string",
232
+ "mutable": true,
233
+ "complexType": {
234
+ "original": "Status",
235
+ "resolved": "Status.ACTIVE | Status.DISABLED | Status.HIDDEN | Status.VISIBLE",
236
+ "references": {
237
+ "Status": {
238
+ "location": "import",
239
+ "path": "./mg-menu-item.conf"
240
+ }
241
+ }
242
+ },
243
+ "required": false,
244
+ "optional": false,
245
+ "docs": {
246
+ "tags": [],
247
+ "text": "Define menu-item status. Default: \"visible\""
248
+ },
249
+ "attribute": "status",
250
+ "reflect": true,
251
+ "defaultValue": "Status.VISIBLE"
252
+ },
253
+ "size": {
254
+ "type": "string",
255
+ "mutable": false,
256
+ "complexType": {
257
+ "original": "MenuItemSizeType",
258
+ "resolved": "\"large\" | \"medium\" | \"regular\"",
259
+ "references": {
260
+ "MenuItemSizeType": {
261
+ "location": "import",
262
+ "path": "./mg-menu-item.conf"
263
+ }
264
+ }
265
+ },
266
+ "required": false,
267
+ "optional": false,
268
+ "docs": {
269
+ "tags": [],
270
+ "text": "Define menu-item size. Default: \"large\"."
271
+ },
272
+ "attribute": "size",
273
+ "reflect": false,
274
+ "defaultValue": "'large'"
275
+ },
276
+ "expanded": {
277
+ "type": "boolean",
278
+ "mutable": true,
279
+ "complexType": {
280
+ "original": "boolean",
281
+ "resolved": "boolean",
282
+ "references": {}
283
+ },
284
+ "required": false,
285
+ "optional": false,
286
+ "docs": {
287
+ "tags": [],
288
+ "text": "Define menu-item content expanded. Default: false."
289
+ },
290
+ "attribute": "expanded",
291
+ "reflect": false,
292
+ "defaultValue": "false"
293
+ }
294
+ };
295
+ }
296
+ static get states() {
297
+ return {
298
+ "navigationButtonClassList": {},
299
+ "direction": {},
300
+ "isInMainMenu": {},
301
+ "hasChildren": {}
302
+ };
303
+ }
304
+ static get elementRef() { return "element"; }
305
+ static get watchers() {
306
+ return [{
307
+ "propName": "status",
308
+ "methodName": "validateStatus"
309
+ }, {
310
+ "propName": "size",
311
+ "methodName": "validateSize"
312
+ }, {
313
+ "propName": "expanded",
314
+ "methodName": "validateExpanded"
315
+ }, {
316
+ "propName": "hasChildren",
317
+ "methodName": "validateHasChildren"
318
+ }];
319
+ }
320
+ }
@@ -19,6 +19,12 @@
19
19
  outline: none;
20
20
  }
21
21
 
22
+ @media (prefers-reduced-motion) {
23
+ .mg-a11y-animation {
24
+ animation: none !important;
25
+ transition: none !important;
26
+ }
27
+ }
22
28
  .mg-details summary {
23
29
  display: flex;
24
30
  align-items: baseline;
@@ -87,7 +87,7 @@ export class MgForm {
87
87
  this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
88
88
  // Set inputs readonly or disabled based on form configuration
89
89
  // Othewise listen to events
90
- this.mgInputs.map(input => {
90
+ this.mgInputs.forEach(input => {
91
91
  if (this.readonly)
92
92
  input.readonly = true;
93
93
  else if (this.disabled)
@@ -19,6 +19,12 @@
19
19
  outline: none;
20
20
  }
21
21
 
22
+ @media (prefers-reduced-motion) {
23
+ .mg-a11y-animation {
24
+ animation: none !important;
25
+ transition: none !important;
26
+ }
27
+ }
22
28
  .mg-pagination {
23
29
  display: flex;
24
30
  align-items: center;