@zanichelli/albe-web-components 16.3.1 → 16.3.2
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.
- package/CHANGELOG.md +2 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/web-components-library.cjs.js +1 -1
- package/dist/cjs/z-app-header_12.cjs.entry.js +67 -17
- package/dist/cjs/z-app-header_12.cjs.entry.js.map +1 -1
- package/dist/cjs/z-menu-section.cjs.entry.js +28 -13
- package/dist/cjs/z-menu-section.cjs.entry.js.map +1 -1
- package/dist/cjs/z-menu.cjs.entry.js +89 -43
- package/dist/cjs/z-menu.cjs.entry.js.map +1 -1
- package/dist/collection/components/z-app-header/index.js +55 -13
- package/dist/collection/components/z-app-header/index.js.map +1 -1
- package/dist/collection/components/z-app-header/index.stories.js +50 -116
- package/dist/collection/components/z-app-header/index.stories.js.map +1 -1
- package/dist/collection/components/z-app-header/styles.css +34 -25
- package/dist/collection/components/z-menu/index.js +93 -42
- package/dist/collection/components/z-menu/index.js.map +1 -1
- package/dist/collection/components/z-menu/styles.css +40 -52
- package/dist/collection/components/z-menu-section/index.js +31 -16
- package/dist/collection/components/z-menu-section/index.js.map +1 -1
- package/dist/collection/components/z-menu-section/styles.css +8 -0
- package/dist/collection/components/z-searchbar/index.js +14 -5
- package/dist/collection/components/z-searchbar/index.js.map +1 -1
- package/dist/components/index23.js +14 -5
- package/dist/components/index23.js.map +1 -1
- package/dist/components/z-app-header.js +56 -14
- package/dist/components/z-app-header.js.map +1 -1
- package/dist/components/z-menu-section.js +30 -15
- package/dist/components/z-menu-section.js.map +1 -1
- package/dist/components/z-menu.js +89 -44
- package/dist/components/z-menu.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/web-components-library.js +1 -1
- package/dist/esm/z-app-header_12.entry.js +67 -17
- package/dist/esm/z-app-header_12.entry.js.map +1 -1
- package/dist/esm/z-menu-section.entry.js +28 -13
- package/dist/esm/z-menu-section.entry.js.map +1 -1
- package/dist/esm/z-menu.entry.js +89 -43
- package/dist/esm/z-menu.entry.js.map +1 -1
- package/dist/types/components/z-app-header/index.d.ts +4 -3
- package/dist/types/components/z-menu/index.d.ts +9 -1
- package/dist/types/components/z-menu-section/index.d.ts +4 -2
- package/dist/types/components/z-searchbar/index.d.ts +1 -0
- package/dist/web-components-library/p-8e5f1ae0.entry.js +2 -0
- package/dist/web-components-library/p-8e5f1ae0.entry.js.map +1 -0
- package/dist/web-components-library/p-b6e7866f.entry.js +2 -0
- package/dist/web-components-library/p-b6e7866f.entry.js.map +1 -0
- package/dist/web-components-library/p-fb0b11cd.entry.js +2 -0
- package/dist/web-components-library/p-fb0b11cd.entry.js.map +1 -0
- package/dist/web-components-library/web-components-library.esm.js +1 -1
- package/dist/web-components-library/web-components-library.esm.js.map +1 -1
- package/package.json +1 -1
- package/www/build/p-38bf2bfc.js +2 -0
- package/www/build/p-8e5f1ae0.entry.js +2 -0
- package/www/build/p-8e5f1ae0.entry.js.map +1 -0
- package/www/build/p-b6e7866f.entry.js +2 -0
- package/www/build/p-b6e7866f.entry.js.map +1 -0
- package/www/build/p-fb0b11cd.entry.js +2 -0
- package/www/build/p-fb0b11cd.entry.js.map +1 -0
- package/www/build/web-components-library.esm.js +1 -1
- package/www/build/web-components-library.esm.js.map +1 -1
- package/www/index.html +1 -1
- package/dist/web-components-library/p-04c39e8a.entry.js +0 -2
- package/dist/web-components-library/p-04c39e8a.entry.js.map +0 -1
- package/dist/web-components-library/p-0542a3c9.entry.js +0 -2
- package/dist/web-components-library/p-0542a3c9.entry.js.map +0 -1
- package/dist/web-components-library/p-16d625b3.entry.js +0 -2
- package/dist/web-components-library/p-16d625b3.entry.js.map +0 -1
- package/www/build/p-04c39e8a.entry.js +0 -2
- package/www/build/p-04c39e8a.entry.js.map +0 -1
- package/www/build/p-0542a3c9.entry.js +0 -2
- package/www/build/p-0542a3c9.entry.js.map +0 -1
- package/www/build/p-16d625b3.entry.js +0 -2
- package/www/build/p-16d625b3.entry.js.map +0 -1
- package/www/build/p-ae5cec65.js +0 -2
|
@@ -83,7 +83,12 @@
|
|
|
83
83
|
align-items: flex-start;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
.
|
|
86
|
+
.heading-title:not(:last-child) {
|
|
87
|
+
margin-right: var(--space-unit);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.z-logo,
|
|
91
|
+
.search-page-button {
|
|
87
92
|
display: flex;
|
|
88
93
|
height: calc(var(--title-font-size) * var(--title-line-height));
|
|
89
94
|
align-items: center;
|
|
@@ -103,14 +108,19 @@
|
|
|
103
108
|
width: 32px;
|
|
104
109
|
height: 32px;
|
|
105
110
|
margin-right: var(--space-unit);
|
|
106
|
-
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.product-logo ::slotted([slot="product-logo"]) img {
|
|
114
|
+
width: 100%;
|
|
115
|
+
height: 100%;
|
|
116
|
+
object-fit: cover;
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
::slotted([slot="title"]),
|
|
110
120
|
::slotted([slot="stucked-title"]),
|
|
111
121
|
.stucked-title {
|
|
112
122
|
margin: 0;
|
|
113
|
-
color: var(--app-header-text-color, var(--
|
|
123
|
+
color: var(--app-header-text-color, var(--color-default-text));
|
|
114
124
|
font-family: var(--font-family-serif);
|
|
115
125
|
font-weight: var(--font-sb);
|
|
116
126
|
}
|
|
@@ -127,6 +137,10 @@
|
|
|
127
137
|
text-overflow: ellipsis;
|
|
128
138
|
}
|
|
129
139
|
|
|
140
|
+
::slotted(a:is([slot="title"], [slot="stucked-title"])) {
|
|
141
|
+
text-decoration: none;
|
|
142
|
+
}
|
|
143
|
+
|
|
130
144
|
:host([enable-search]) ::slotted([slot="title"]) + * {
|
|
131
145
|
margin-left: calc(var(--space-unit) * 2);
|
|
132
146
|
}
|
|
@@ -150,6 +164,10 @@
|
|
|
150
164
|
line-clamp: 2;
|
|
151
165
|
}
|
|
152
166
|
|
|
167
|
+
.search-page-button {
|
|
168
|
+
margin-left: auto;
|
|
169
|
+
}
|
|
170
|
+
|
|
153
171
|
.menu-container {
|
|
154
172
|
display: flex;
|
|
155
173
|
flex: 1 auto;
|
|
@@ -186,7 +204,6 @@ z-searchbar {
|
|
|
186
204
|
display: flex;
|
|
187
205
|
width: 100%;
|
|
188
206
|
align-items: center;
|
|
189
|
-
padding-top: calc(var(--space-unit) * 2);
|
|
190
207
|
}
|
|
191
208
|
|
|
192
209
|
.heading-stuck {
|
|
@@ -218,10 +235,6 @@ z-searchbar {
|
|
|
218
235
|
align-items: center;
|
|
219
236
|
}
|
|
220
237
|
|
|
221
|
-
.heading-stuck .heading-title:not(:last-child) {
|
|
222
|
-
margin-right: calc(var(--space-unit) * 2);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
238
|
.heading-stuck .stucked-title {
|
|
226
239
|
overflow: hidden;
|
|
227
240
|
font-size: var(--title-font-size);
|
|
@@ -230,10 +243,6 @@ z-searchbar {
|
|
|
230
243
|
white-space: nowrap;
|
|
231
244
|
}
|
|
232
245
|
|
|
233
|
-
.heading-stuck-content z-button.search-page-button {
|
|
234
|
-
margin-left: auto;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
246
|
.drawer-trigger {
|
|
238
247
|
display: flex;
|
|
239
248
|
height: calc(var(--title-font-size) * var(--title-line-height));
|
|
@@ -257,11 +266,7 @@ z-searchbar {
|
|
|
257
266
|
--z-icon-width: calc(var(--space-unit) * 4);
|
|
258
267
|
--z-icon-height: calc(var(--space-unit) * 4);
|
|
259
268
|
|
|
260
|
-
fill:
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.heading-container z-button.search-page-button {
|
|
264
|
-
margin-left: auto;
|
|
269
|
+
fill: var(--color-default-icon);
|
|
265
270
|
}
|
|
266
271
|
|
|
267
272
|
.drawer-content {
|
|
@@ -290,14 +295,23 @@ z-offcanvas[open] .drawer-content ::slotted(z-menu) {
|
|
|
290
295
|
background: transparent;
|
|
291
296
|
border-radius: 0;
|
|
292
297
|
cursor: pointer;
|
|
293
|
-
fill: currentcolor;
|
|
294
298
|
outline: none;
|
|
295
299
|
}
|
|
296
300
|
|
|
297
|
-
.drawer-close
|
|
301
|
+
.drawer-close z-icon {
|
|
302
|
+
fill: var(--color-default-icon);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.drawer-close:focus:focus-visible {
|
|
298
306
|
box-shadow: var(--shadow-focus-primary);
|
|
299
307
|
}
|
|
300
308
|
|
|
309
|
+
@media (max-width: 767px) {
|
|
310
|
+
:host([enable-search]) .heading-panel .heading-container {
|
|
311
|
+
row-gap: calc(var(--space-unit) * 1.5);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
301
315
|
/* Tablet breakpoint */
|
|
302
316
|
@media (min-width: 768px) {
|
|
303
317
|
.heading-panel {
|
|
@@ -325,14 +339,10 @@ z-offcanvas[open] .drawer-content ::slotted(z-menu) {
|
|
|
325
339
|
align-items: center;
|
|
326
340
|
}
|
|
327
341
|
|
|
328
|
-
:host([enable-search]:not([search-page-url])) .heading-container .heading-title {
|
|
329
|
-
flex-wrap: nowrap;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
342
|
z-searchbar {
|
|
333
343
|
width: 30%;
|
|
334
344
|
height: calc(var(--title-font-size) * var(--title-line-height));
|
|
335
|
-
|
|
345
|
+
margin-left: auto;
|
|
336
346
|
}
|
|
337
347
|
|
|
338
348
|
.menu-container {
|
|
@@ -369,7 +379,6 @@ z-offcanvas[open] .drawer-content ::slotted(z-menu) {
|
|
|
369
379
|
@media (min-width: 1152px) {
|
|
370
380
|
z-searchbar {
|
|
371
381
|
min-width: calc(var(--space-unit) * 45);
|
|
372
|
-
flex: initial;
|
|
373
382
|
}
|
|
374
383
|
}
|
|
375
384
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
import { KeyboardCode } from "../../beans";
|
|
3
|
+
import { containsElement } from "../../utils/utils";
|
|
3
4
|
const isZMenuSection = (el) => (el === null || el === void 0 ? void 0 : el.tagName) === "Z-MENU-SECTION";
|
|
4
5
|
/**
|
|
5
6
|
* @slot - Menu label
|
|
@@ -57,12 +58,9 @@ export class ZMenu {
|
|
|
57
58
|
setItemsA11yAttrs() {
|
|
58
59
|
this.items.forEach((item, index) => {
|
|
59
60
|
const tabindex = index === 0 ? 0 : -1;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
61
|
+
this.setItemTabindex(item, tabindex);
|
|
62
|
+
if (!isZMenuSection(item)) {
|
|
64
63
|
item.setAttribute("role", "menuitem");
|
|
65
|
-
item.tabIndex = tabindex;
|
|
66
64
|
}
|
|
67
65
|
});
|
|
68
66
|
}
|
|
@@ -76,6 +74,14 @@ export class ZMenu {
|
|
|
76
74
|
}
|
|
77
75
|
});
|
|
78
76
|
}
|
|
77
|
+
setItemTabindex(item, tabIndex) {
|
|
78
|
+
if (isZMenuSection(item)) {
|
|
79
|
+
item.htmlTabindex = tabIndex;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
item.tabIndex = tabIndex;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
79
85
|
/**
|
|
80
86
|
* Move focus and adjust the tabindex value of `receiver` and `current` elements,
|
|
81
87
|
* setting -1 to the `current` and 0 to the `receiver`, then focus the `receiver` element.
|
|
@@ -94,18 +100,21 @@ export class ZMenu {
|
|
|
94
100
|
if (!current) {
|
|
95
101
|
return;
|
|
96
102
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
+
this.setItemTabindex(current, -1);
|
|
104
|
+
}
|
|
105
|
+
onLabelClick() {
|
|
106
|
+
this.toggle();
|
|
107
|
+
this.setFocus();
|
|
103
108
|
}
|
|
104
109
|
onLabelKeydown(ev) {
|
|
105
110
|
if (ev.key === KeyboardCode.ENTER || ev.key === KeyboardCode.SPACE) {
|
|
106
111
|
ev.preventDefault();
|
|
107
112
|
ev.stopPropagation();
|
|
108
113
|
this.toggle();
|
|
114
|
+
if (this.open) {
|
|
115
|
+
this.moveFocus(this.items[0]);
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
109
118
|
}
|
|
110
119
|
if (!this.verticalContext) {
|
|
111
120
|
return;
|
|
@@ -114,12 +123,7 @@ export class ZMenu {
|
|
|
114
123
|
ev.preventDefault();
|
|
115
124
|
ev.stopPropagation();
|
|
116
125
|
this.open = true;
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
if (ev.key === KeyboardCode.ARROW_LEFT && this.open) {
|
|
120
|
-
ev.preventDefault();
|
|
121
|
-
ev.stopPropagation();
|
|
122
|
-
this.open = false;
|
|
126
|
+
this.moveFocus(this.items[0]);
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
129
|
/** Set tabindex of the label to 0, then focus it. */
|
|
@@ -128,13 +132,18 @@ export class ZMenu {
|
|
|
128
132
|
const label = this.hasContent ? this.labelButton : this.host.firstElementChild;
|
|
129
133
|
label.focus();
|
|
130
134
|
}
|
|
131
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* Focus the last item.
|
|
137
|
+
*/
|
|
132
138
|
async focusLastItem() {
|
|
133
|
-
this.
|
|
134
|
-
|
|
139
|
+
const lastItem = this.items[this.items.length - 1];
|
|
140
|
+
if (isZMenuSection(lastItem) && lastItem.open) {
|
|
141
|
+
lastItem.focusLastItem();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
this.moveFocus(lastItem);
|
|
135
145
|
}
|
|
136
146
|
onOpenChanged() {
|
|
137
|
-
this.setItemsA11yAttrs();
|
|
138
147
|
if (!this.open) {
|
|
139
148
|
cancelAnimationFrame(this.raf);
|
|
140
149
|
this.closed.emit();
|
|
@@ -145,6 +154,7 @@ export class ZMenu {
|
|
|
145
154
|
});
|
|
146
155
|
return;
|
|
147
156
|
}
|
|
157
|
+
this.setItemsA11yAttrs();
|
|
148
158
|
this.opened.emit();
|
|
149
159
|
if (this.floating) {
|
|
150
160
|
this.reflow(true);
|
|
@@ -162,74 +172,108 @@ export class ZMenu {
|
|
|
162
172
|
slottedLabel.role = "menuitem";
|
|
163
173
|
slottedLabel.tabIndex = this.htmlTabindex;
|
|
164
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Set tabindex to -1 to all siblings of the clicked item.
|
|
177
|
+
*/
|
|
178
|
+
onItemClick(ev) {
|
|
179
|
+
const clickedItem = this.items.find((item) => containsElement(item, ev.target));
|
|
180
|
+
if (clickedItem) {
|
|
181
|
+
this.items.forEach((item) => {
|
|
182
|
+
if (item === clickedItem) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (isZMenuSection(item)) {
|
|
186
|
+
item.htmlTabindex = -1;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
item.tabIndex = -1;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
165
194
|
onKeyDown(ev) {
|
|
195
|
+
var _a;
|
|
166
196
|
if (!this.hasContent) {
|
|
167
197
|
return;
|
|
168
198
|
}
|
|
169
199
|
switch (ev.key) {
|
|
170
200
|
case KeyboardCode.ESC:
|
|
201
|
+
if (!this.open) {
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
171
204
|
ev.stopPropagation();
|
|
172
205
|
ev.preventDefault();
|
|
173
206
|
this.open = false;
|
|
174
207
|
this.setFocus();
|
|
175
208
|
break;
|
|
176
209
|
case KeyboardCode.ARROW_DOWN: {
|
|
177
|
-
if (this.verticalContext && document.activeElement === this.host && !this.open) {
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
210
|
if (document.activeElement === this.host) {
|
|
181
|
-
if (!this.open) {
|
|
182
|
-
|
|
211
|
+
if (this.verticalContext && !this.open) {
|
|
212
|
+
break;
|
|
183
213
|
}
|
|
184
214
|
ev.stopPropagation();
|
|
185
215
|
ev.preventDefault();
|
|
216
|
+
if (!this.open) {
|
|
217
|
+
this.open = true;
|
|
218
|
+
}
|
|
186
219
|
this.moveFocus(this.items[0]);
|
|
187
220
|
break;
|
|
188
221
|
}
|
|
189
222
|
const currentIndex = this.items.indexOf(this.focusableItem);
|
|
190
|
-
|
|
191
|
-
|
|
223
|
+
if (this.verticalContext && currentIndex === this.items.length - 1) {
|
|
224
|
+
// navigation is going to leave this menu. restore tabindex to the label and let the parent handle it
|
|
225
|
+
this.setItemTabindex(this.items[currentIndex], -1);
|
|
226
|
+
this.htmlTabindex = 0;
|
|
192
227
|
break;
|
|
193
228
|
}
|
|
194
229
|
ev.stopPropagation();
|
|
195
230
|
ev.preventDefault();
|
|
231
|
+
const receiver = this.items[currentIndex + 1];
|
|
196
232
|
// if the last item is already focused, navigate to the first one
|
|
197
233
|
this.moveFocus(receiver !== null && receiver !== void 0 ? receiver : this.items[0], this.focusableItem);
|
|
198
234
|
break;
|
|
199
235
|
}
|
|
200
236
|
case KeyboardCode.ARROW_UP: {
|
|
201
|
-
if (this.verticalContext && document.activeElement === this.host) {
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
237
|
if (document.activeElement === this.host) {
|
|
238
|
+
if (this.verticalContext) {
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
ev.stopPropagation();
|
|
242
|
+
ev.preventDefault();
|
|
205
243
|
// open the menu and focus the last item
|
|
206
244
|
if (!this.open) {
|
|
207
245
|
this.open = true;
|
|
208
246
|
}
|
|
209
|
-
ev.stopPropagation();
|
|
210
|
-
ev.preventDefault();
|
|
211
247
|
this.moveFocus(this.items[this.items.length - 1], this.focusableItem);
|
|
212
248
|
break;
|
|
213
249
|
}
|
|
214
250
|
ev.stopPropagation();
|
|
215
251
|
ev.preventDefault();
|
|
216
252
|
const currentIndex = this.items.indexOf(this.focusableItem);
|
|
217
|
-
|
|
218
|
-
|
|
253
|
+
if (currentIndex === 0 && this.verticalContext) {
|
|
254
|
+
this.setItemTabindex(this.focusableItem, -1);
|
|
219
255
|
this.setFocus();
|
|
220
256
|
break;
|
|
221
257
|
}
|
|
258
|
+
const receiver = (_a = this.items[currentIndex - 1]) !== null && _a !== void 0 ? _a : this.items[this.items.length - 1];
|
|
259
|
+
// if the receiver is a ZMenuSection and it's open, focus its last item
|
|
222
260
|
if (isZMenuSection(receiver) && receiver.open) {
|
|
223
|
-
|
|
224
|
-
? (this.focusableItem.htmlTabindex = -1)
|
|
225
|
-
: (this.focusableItem.tabIndex = -1);
|
|
261
|
+
this.setItemTabindex(this.focusableItem, -1);
|
|
226
262
|
receiver.focusLastItem();
|
|
227
263
|
break;
|
|
228
264
|
}
|
|
229
|
-
|
|
230
|
-
this.moveFocus(receiver !== null && receiver !== void 0 ? receiver : this.items[this.items.length - 1], this.focusableItem);
|
|
265
|
+
this.moveFocus(receiver, this.focusableItem);
|
|
231
266
|
break;
|
|
232
267
|
}
|
|
268
|
+
case KeyboardCode.ARROW_LEFT:
|
|
269
|
+
if (!this.open || !this.verticalContext) {
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
// close the menu and focus the label
|
|
273
|
+
ev.preventDefault();
|
|
274
|
+
ev.stopPropagation();
|
|
275
|
+
this.open = false;
|
|
276
|
+
this.setFocus();
|
|
233
277
|
}
|
|
234
278
|
}
|
|
235
279
|
constructor() {
|
|
@@ -243,6 +287,7 @@ export class ZMenu {
|
|
|
243
287
|
this.toggle = this.toggle.bind(this);
|
|
244
288
|
this.checkContent = this.checkContent.bind(this);
|
|
245
289
|
this.onLabelSlotChange = this.onLabelSlotChange.bind(this);
|
|
290
|
+
this.onLabelClick = this.onLabelClick.bind(this);
|
|
246
291
|
this.onItemsChange = this.onItemsChange.bind(this);
|
|
247
292
|
this.onLabelKeydown = this.onLabelKeydown.bind(this);
|
|
248
293
|
}
|
|
@@ -252,9 +297,9 @@ export class ZMenu {
|
|
|
252
297
|
}
|
|
253
298
|
render() {
|
|
254
299
|
if (!this.hasContent) {
|
|
255
|
-
return (h("div", { class: "menu-
|
|
300
|
+
return (h("div", { class: "menu-label" }, h("slot", { onSlotchange: this.onLabelSlotChange })));
|
|
256
301
|
}
|
|
257
|
-
return (h(Host, null, h("
|
|
302
|
+
return (h(Host, null, h("button", { ref: (el) => (this.labelButton = el), class: "menu-label", "aria-expanded": `${!!this.open}`, "aria-haspopup": `${this.hasContent}`, "aria-label": this.open ? "Chiudi menù" : "Apri menù", role: "menuitem", tabIndex: this.htmlTabindex, onClick: this.onLabelClick, onKeyDown: this.onLabelKeydown }, h("slot", { onSlotchange: this.onLabelSlotChange }), h("z-icon", { name: this.open ? "chevron-up" : "chevron-down" })), h("div", { class: "content", ref: (el) => (this.content = el) }, this.hasHeader && (h("header", { class: "header" }, h("slot", { name: "header", onSlotchange: this.checkContent }))), h("div", { class: "items", role: "menu" }, h("slot", { name: "item", onSlotchange: this.onItemsChange })))));
|
|
258
303
|
}
|
|
259
304
|
static get is() { return "z-menu"; }
|
|
260
305
|
static get encapsulation() { return "shadow"; }
|
|
@@ -454,6 +499,12 @@ export class ZMenu {
|
|
|
454
499
|
}
|
|
455
500
|
static get listeners() {
|
|
456
501
|
return [{
|
|
502
|
+
"name": "click",
|
|
503
|
+
"method": "onItemClick",
|
|
504
|
+
"target": "document",
|
|
505
|
+
"capture": false,
|
|
506
|
+
"passive": false
|
|
507
|
+
}, {
|
|
457
508
|
"name": "keydown",
|
|
458
509
|
"method": "onKeyDown",
|
|
459
510
|
"target": undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/z-menu/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AACnH,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAEzC,MAAM,cAAc,GAAG,CAAC,EAAyC,EAAiC,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B,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,EACnD,IAAI,EAAC,UAAU,EACf,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,OAAO,EAAE,IAAI,CAAC,MAAM,EACpB,SAAS,EAAE,IAAI,CAAC,cAAc;oBAE9B,WAAK,KAAK,EAAC,oBAAoB;wBAC7B,YAAM,YAAY,EAAE,IAAI,CAAC,iBAAiB,GAAI;wBAC9C,cAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,GAAI,CACvD,CACC,CACL;YAEN,WACE,KAAK,EAAC,SAAS,EACf,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;gBAE/B,IAAI,CAAC,SAAS,IAAI,CACjB,cAAQ,KAAK,EAAC,QAAQ;oBACpB,YACE,IAAI,EAAC,QAAQ,EACb,YAAY,EAAE,IAAI,CAAC,YAAY,GAC/B,CACK,CACV;gBAED,WACE,KAAK,EAAC,OAAO,EACb,IAAI,EAAC,MAAM;oBAEX,YACE,IAAI,EAAC,MAAM,EACX,YAAY,EAAE,IAAI,CAAC,aAAa,GAChC,CACE,CACF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Listen, Method, Prop, State, Watch, h} from \"@stencil/core\";\nimport {KeyboardCode} from \"../../beans\";\n\nconst isZMenuSection = (el: HTMLElement | HTMLZMenuSectionElement): el is HTMLZMenuSectionElement =>\n el?.tagName === \"Z-MENU-SECTION\";\n\n/**\n * @slot - Menu label\n * @slot header - Header to display as the first entry of the open menu.\n * @slot item - Single entry of the section. Can be slotted multiple times to insert items onto the menu. Set the `active` HTML attribute on the element to highlight it. Use `z-menu-section` for submenus.\n * @cssprop --z-menu-label-color - Color of the label's text.\n */\n@Component({\n tag: \"z-menu\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZMenu {\n @Element() host: HTMLZMenuElement;\n\n /** Flag to set the active status of the menu. */\n @Prop({reflect: true})\n active?: boolean;\n\n /**\n * Flag to set the display mode of the list.\n * If true, the list will be absolutely positioned under the menu label,\n * stacked beneath it otherwise.\n */\n @Prop({reflect: true})\n floating? = true;\n\n /** The opening state of the menu. */\n @Prop({mutable: true, reflect: true})\n open = false;\n\n /**\n * Tells the component that it's placed in a vertical context with other `ZMenu`s (usually in the ZAppHeader's offcanvas).\n * A small border is placed under it as a separator from other elements.\n */\n @Prop({reflect: true})\n verticalContext = false;\n\n /**\n * Tabindex value to set on the menu label.\n * Useful to manage keyboard navigation focus with roving tabindex handled by this component's parent (usually ZAppHeader).\n */\n @Prop()\n htmlTabindex = -1;\n\n @State()\n hasHeader: boolean;\n\n @State()\n hasContent: boolean;\n\n /** The menu has been opened. */\n @Event()\n opened: EventEmitter;\n\n /** The menu has been closed. */\n @Event()\n closed: EventEmitter;\n\n private labelButton: HTMLButtonElement;\n\n private content: HTMLElement;\n\n private items: (HTMLElement | HTMLZMenuSectionElement)[];\n\n /** Animation frame request id. */\n private raf: number;\n\n private get focusableItem(): HTMLZMenuSectionElement | HTMLElement | null {\n return this.items.find((item) => (isZMenuSection(item) ? item.htmlTabindex === 0 : item.tabIndex === 0));\n }\n\n private toggle(): void {\n if (!this.hasContent) {\n return;\n }\n\n this.open = !this.open;\n }\n\n /**\n * Sets slotted item text as `data-text` attribute value, to let CSS use it through `attr()`.\n * @param ev Slotchange event\n */\n private onLabelSlotChange(ev: Event): void {\n const labelElement = (ev.target as HTMLSlotElement).assignedElements()[0] as HTMLElement;\n labelElement.dataset.text = labelElement?.textContent;\n this.setLabelA11yAttrs();\n }\n\n /**\n * Correctly set position of the floating menu in order to prevent overflow.\n * @param live Should run the method on every refresh frame.\n */\n private reflow(live = false): void {\n if (this.content && this.hasContent) {\n const {style} = this.content;\n const {left} = this.host.getBoundingClientRect();\n const widthPx = getComputedStyle(this.content).width;\n const width = widthPx ? parseFloat(widthPx.replace(\"px\", \"\")) : 375;\n const safeScrollbarSpace = 30;\n style.left = `${Math.min(window.innerWidth - left - width - safeScrollbarSpace, 0)}px`;\n }\n if (live) {\n this.raf = requestAnimationFrame(this.reflow.bind(this, live));\n }\n }\n\n /**\n * Check if some content slot is set.\n */\n private checkContent(): void {\n this.hasHeader = !!this.host.querySelectorAll(\"[slot=header]\").length;\n this.hasContent = !!this.host.querySelectorAll(\"[slot=item]\").length || this.hasHeader;\n }\n\n /**\n * Set `menuitem` role to all menu items (ZMenuSection items already have it).\n * Set -1 to the tabindex of the items and 0 to the first one.\n */\n private setItemsA11yAttrs(): void {\n this.items.forEach((item, index) => {\n const tabindex = index === 0 ? 0 : -1;\n if (isZMenuSection(item)) {\n item.htmlTabindex = tabindex;\n } else {\n item.setAttribute(\"role\", \"menuitem\");\n item.tabIndex = tabindex;\n }\n });\n }\n\n private onItemsChange(): void {\n this.checkContent();\n this.items = Array.from(this.host.children).filter(({slot}) => slot === \"item\") as HTMLElement[];\n this.setItemsA11yAttrs();\n this.items.forEach((item) => {\n if (!isZMenuSection(item)) {\n item.dataset.text = item.textContent;\n }\n });\n }\n\n /**\n * Move focus and adjust the tabindex value of `receiver` and `current` elements,\n * setting -1 to the `current` and 0 to the `receiver`, then focus the `receiver` element.\n * If the receiver is a ZMenuSection and it's open, focus its first focusable item.\n */\n private moveFocus(\n receiver: HTMLElement | HTMLZMenuSectionElement,\n current?: HTMLElement | HTMLZMenuSectionElement\n ): void {\n if (isZMenuSection(receiver)) {\n receiver.setFocus();\n } else {\n receiver.tabIndex = 0;\n setTimeout(() => {\n receiver.focus();\n }, 100);\n }\n if (!current) {\n return;\n }\n\n if (isZMenuSection(current)) {\n current.htmlTabindex = -1;\n } else {\n current.tabIndex = -1;\n }\n }\n\n private onLabelKeydown(ev: KeyboardEvent): void {\n if (ev.key === KeyboardCode.ENTER || ev.key === KeyboardCode.SPACE) {\n ev.preventDefault();\n ev.stopPropagation();\n this.toggle();\n }\n\n if (!this.verticalContext) {\n return;\n }\n\n if (ev.key === KeyboardCode.ARROW_RIGHT && !this.open) {\n ev.preventDefault();\n ev.stopPropagation();\n this.open = true;\n\n return;\n }\n\n if (ev.key === KeyboardCode.ARROW_LEFT && this.open) {\n ev.preventDefault();\n ev.stopPropagation();\n this.open = false;\n }\n }\n\n /** Set tabindex of the label to 0, then focus it. */\n @Method()\n async setFocus(): Promise<void> {\n this.htmlTabindex = 0;\n const label = this.hasContent ? this.labelButton : (this.host.firstElementChild as HTMLElement);\n label.focus();\n }\n\n /** Focus the last item. */\n @Method()\n async focusLastItem(): Promise<void> {\n this.htmlTabindex = 0;\n this.moveFocus(this.items[this.items.length - 1]);\n }\n\n @Watch(\"open\")\n onOpenChanged(): void {\n this.setItemsA11yAttrs();\n if (!this.open) {\n cancelAnimationFrame(this.raf);\n this.closed.emit();\n this.items.forEach((item) => {\n if (isZMenuSection(item) && item.open) {\n item.open = false;\n }\n });\n\n return;\n }\n\n this.opened.emit();\n if (this.floating) {\n this.reflow(true);\n }\n }\n\n @Watch(\"htmlTabindex\")\n setLabelA11yAttrs(): void {\n if (this.hasContent && !this.labelButton) {\n return;\n }\n\n if (this.hasContent) {\n this.labelButton.tabIndex = this.htmlTabindex;\n\n return;\n }\n\n const slottedLabel = this.host.firstElementChild as HTMLElement;\n slottedLabel.role = \"menuitem\";\n slottedLabel.tabIndex = this.htmlTabindex;\n }\n\n @Listen(\"keydown\")\n onKeyDown(ev: KeyboardEvent): void {\n if (!this.hasContent) {\n return;\n }\n\n switch (ev.key) {\n case KeyboardCode.ESC:\n ev.stopPropagation();\n ev.preventDefault();\n this.open = false;\n this.setFocus();\n break;\n case KeyboardCode.ARROW_DOWN: {\n if (this.verticalContext && document.activeElement === this.host && !this.open) {\n break;\n }\n\n if (document.activeElement === this.host) {\n if (!this.open) {\n this.open = true;\n }\n ev.stopPropagation();\n ev.preventDefault();\n this.moveFocus(this.items[0]);\n break;\n }\n\n const currentIndex = this.items.indexOf(this.focusableItem);\n const receiver = this.items[currentIndex + 1];\n if (this.verticalContext && !receiver) {\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n // if the last item is already focused, navigate to the first one\n this.moveFocus(receiver ?? this.items[0], this.focusableItem);\n break;\n }\n case KeyboardCode.ARROW_UP: {\n if (this.verticalContext && document.activeElement === this.host) {\n break;\n }\n\n if (document.activeElement === this.host) {\n // open the menu and focus the last item\n if (!this.open) {\n this.open = true;\n }\n ev.stopPropagation();\n ev.preventDefault();\n this.moveFocus(this.items[this.items.length - 1], this.focusableItem);\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n const currentIndex = this.items.indexOf(this.focusableItem);\n const receiver = this.items[currentIndex - 1];\n if (!receiver && this.verticalContext) {\n this.setFocus();\n break;\n }\n\n if (isZMenuSection(receiver) && receiver.open) {\n isZMenuSection(this.focusableItem)\n ? (this.focusableItem.htmlTabindex = -1)\n : (this.focusableItem.tabIndex = -1);\n receiver.focusLastItem();\n break;\n }\n\n // if the first item is already focused, navigate to the last one\n this.moveFocus(receiver ?? this.items[this.items.length - 1], this.focusableItem);\n break;\n }\n }\n }\n\n constructor() {\n this.toggle = this.toggle.bind(this);\n this.checkContent = this.checkContent.bind(this);\n this.onLabelSlotChange = this.onLabelSlotChange.bind(this);\n this.onItemsChange = this.onItemsChange.bind(this);\n this.onLabelKeydown = this.onLabelKeydown.bind(this);\n }\n\n connectedCallback(): void {\n this.onItemsChange();\n this.setLabelA11yAttrs();\n }\n\n render(): HTMLDivElement | HTMLZMenuElement {\n if (!this.hasContent) {\n return (\n <div class=\"menu-wrapper\">\n <div class=\"menu-label\">\n <div class=\"menu-label-content\">\n <slot onSlotchange={this.onLabelSlotChange} />\n </div>\n </div>\n </div>\n );\n }\n\n return (\n <Host>\n <div class=\"menu-wrapper\">\n <button\n ref={(el) => (this.labelButton = el)}\n class=\"menu-label\"\n aria-expanded={`${!!this.open}`}\n aria-haspopup={`${this.hasContent}`}\n aria-label={this.open ? \"Chiudi menù\" : \"Apri menù\"}\n role=\"menuitem\"\n tabindex={this.htmlTabindex}\n onClick={this.toggle}\n onKeyDown={this.onLabelKeydown}\n >\n <div class=\"menu-label-content\">\n <slot onSlotchange={this.onLabelSlotChange} />\n <z-icon name={this.open ? \"chevron-up\" : \"chevron-down\"} />\n </div>\n </button>\n </div>\n\n <div\n class=\"content\"\n ref={(el) => (this.content = el)}\n >\n {this.hasHeader && (\n <header class=\"header\">\n <slot\n name=\"header\"\n onSlotchange={this.checkContent}\n />\n </header>\n )}\n\n <div\n class=\"items\"\n role=\"menu\"\n >\n <slot\n name=\"item\"\n onSlotchange={this.onItemsChange}\n />\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/z-menu/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AACnH,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,MAAM,cAAc,GAAG,CAAC,EAAyC,EAAiC,EAAE,CAClG,CAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,OAAO,MAAK,gBAAgB,CAAC;AAEnC;;;;;GAKG;AAMH,MAAM,OAAO,KAAK;IAwDhB,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,K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AE,IAAI,CAAC,YAAY,EAC1B,SAAS,EAAE,IAAI,CAAC,cAAc;gBAE9B,YAAM,YAAY,EAAE,IAAI,CAAC,iBAAiB,GAAI;gBAC9C,cAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,GAAI,CACpD;YAET,WACE,KAAK,EAAC,SAAS,EACf,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;gBAE/B,IAAI,CAAC,SAAS,IAAI,CACjB,cAAQ,KAAK,EAAC,QAAQ;oBACpB,YACE,IAAI,EAAC,QAAQ,EACb,YAAY,EAAE,IAAI,CAAC,YAAY,GAC/B,CACK,CACV;gBAED,WACE,KAAK,EAAC,OAAO,EACb,IAAI,EAAC,MAAM;oBAEX,YACE,IAAI,EAAC,MAAM,EACX,YAAY,EAAE,IAAI,CAAC,aAAa,GAChC,CACE,CACF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Listen, Method, Prop, State, Watch, h} from \"@stencil/core\";\nimport {KeyboardCode} from \"../../beans\";\nimport {containsElement} from \"../../utils/utils\";\n\nconst isZMenuSection = (el: HTMLElement | HTMLZMenuSectionElement): el is HTMLZMenuSectionElement =>\n el?.tagName === \"Z-MENU-SECTION\";\n\n/**\n * @slot - Menu label\n * @slot header - Header to display as the first entry of the open menu.\n * @slot item - Single entry of the section. Can be slotted multiple times to insert items onto the menu. Set the `active` HTML attribute on the element to highlight it. Use `z-menu-section` for submenus.\n * @cssprop --z-menu-label-color - Color of the label's text.\n */\n@Component({\n tag: \"z-menu\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZMenu {\n @Element() host: HTMLZMenuElement;\n\n /** Flag to set the active status of the menu. */\n @Prop({reflect: true})\n active?: boolean;\n\n /**\n * Flag to set the display mode of the list.\n * If true, the list will be absolutely positioned under the menu label,\n * stacked beneath it otherwise.\n */\n @Prop({reflect: true})\n floating? = true;\n\n /** The opening state of the menu. */\n @Prop({mutable: true, reflect: true})\n open = false;\n\n /**\n * Tells the component that it's placed in a vertical context with other `ZMenu`s (usually in the ZAppHeader's offcanvas).\n * A small border is placed under it as a separator from other elements.\n */\n @Prop({reflect: true})\n verticalContext = false;\n\n /**\n * Tabindex value to set on the menu label.\n * Useful to manage keyboard navigation focus with roving tabindex handled by this component's parent (usually ZAppHeader).\n */\n @Prop()\n htmlTabindex = -1;\n\n @State()\n hasHeader: boolean;\n\n @State()\n hasContent: boolean;\n\n /** The menu has been opened. */\n @Event()\n opened: EventEmitter;\n\n /** The menu has been closed. */\n @Event()\n closed: EventEmitter;\n\n private labelButton: HTMLButtonElement;\n\n private content: HTMLElement;\n\n private items: (HTMLElement | HTMLZMenuSectionElement)[];\n\n /** Animation frame request id. */\n private raf: number;\n\n private get focusableItem(): HTMLZMenuSectionElement | HTMLElement | null {\n return this.items.find((item) => (isZMenuSection(item) ? item.htmlTabindex === 0 : item.tabIndex === 0));\n }\n\n private toggle(): void {\n if (!this.hasContent) {\n return;\n }\n\n this.open = !this.open;\n }\n\n /**\n * Sets slotted item text as `data-text` attribute value, to let CSS use it through `attr()`.\n * @param ev Slotchange event\n */\n private onLabelSlotChange(ev: Event): void {\n const labelElement = (ev.target as HTMLSlotElement).assignedElements()[0] as HTMLElement;\n labelElement.dataset.text = labelElement?.textContent;\n this.setLabelA11yAttrs();\n }\n\n /**\n * Correctly set position of the floating menu in order to prevent overflow.\n * @param live Should run the method on every refresh frame.\n */\n private reflow(live = false): void {\n if (this.content && this.hasContent) {\n const {style} = this.content;\n const {left} = this.host.getBoundingClientRect();\n const widthPx = getComputedStyle(this.content).width;\n const width = widthPx ? parseFloat(widthPx.replace(\"px\", \"\")) : 375;\n const safeScrollbarSpace = 30;\n style.left = `${Math.min(window.innerWidth - left - width - safeScrollbarSpace, 0)}px`;\n }\n if (live) {\n this.raf = requestAnimationFrame(this.reflow.bind(this, live));\n }\n }\n\n /**\n * Check if some content slot is set.\n */\n private checkContent(): void {\n this.hasHeader = !!this.host.querySelectorAll(\"[slot=header]\").length;\n this.hasContent = !!this.host.querySelectorAll(\"[slot=item]\").length || this.hasHeader;\n }\n\n /**\n * Set `menuitem` role to all menu items (ZMenuSection items already have it).\n * Set -1 to the tabindex of the items and 0 to the first one.\n */\n private setItemsA11yAttrs(): void {\n this.items.forEach((item, index) => {\n const tabindex = index === 0 ? 0 : -1;\n this.setItemTabindex(item, tabindex);\n if (!isZMenuSection(item)) {\n item.setAttribute(\"role\", \"menuitem\");\n }\n });\n }\n\n private onItemsChange(): void {\n this.checkContent();\n this.items = Array.from(this.host.children).filter(({slot}) => slot === \"item\") as HTMLElement[];\n this.setItemsA11yAttrs();\n this.items.forEach((item) => {\n if (!isZMenuSection(item)) {\n item.dataset.text = item.textContent;\n }\n });\n }\n\n private setItemTabindex(item: HTMLElement | HTMLZMenuSectionElement, tabIndex: number): void {\n if (isZMenuSection(item)) {\n item.htmlTabindex = tabIndex;\n } else {\n item.tabIndex = tabIndex;\n }\n }\n\n /**\n * Move focus and adjust the tabindex value of `receiver` and `current` elements,\n * setting -1 to the `current` and 0 to the `receiver`, then focus the `receiver` element.\n * If the receiver is a ZMenuSection and it's open, focus its first focusable item.\n */\n private moveFocus(\n receiver: HTMLElement | HTMLZMenuSectionElement,\n current?: HTMLElement | HTMLZMenuSectionElement\n ): void {\n if (isZMenuSection(receiver)) {\n receiver.setFocus();\n } else {\n receiver.tabIndex = 0;\n setTimeout(() => {\n receiver.focus();\n }, 100);\n }\n if (!current) {\n return;\n }\n\n this.setItemTabindex(current, -1);\n }\n\n private onLabelClick(): void {\n this.toggle();\n this.setFocus();\n }\n\n private onLabelKeydown(ev: KeyboardEvent): void {\n if (ev.key === KeyboardCode.ENTER || ev.key === KeyboardCode.SPACE) {\n ev.preventDefault();\n ev.stopPropagation();\n this.toggle();\n if (this.open) {\n this.moveFocus(this.items[0]);\n }\n\n return;\n }\n\n if (!this.verticalContext) {\n return;\n }\n\n if (ev.key === KeyboardCode.ARROW_RIGHT && !this.open) {\n ev.preventDefault();\n ev.stopPropagation();\n this.open = true;\n this.moveFocus(this.items[0]);\n }\n }\n\n /** Set tabindex of the label to 0, then focus it. */\n @Method()\n async setFocus(): Promise<void> {\n this.htmlTabindex = 0;\n const label = this.hasContent ? this.labelButton : (this.host.firstElementChild as HTMLElement);\n label.focus();\n }\n\n /**\n * Focus the last item.\n */\n @Method()\n async focusLastItem(): Promise<void> {\n const lastItem = this.items[this.items.length - 1];\n if (isZMenuSection(lastItem) && lastItem.open) {\n lastItem.focusLastItem();\n\n return;\n }\n\n this.moveFocus(lastItem);\n }\n\n @Watch(\"open\")\n onOpenChanged(): void {\n if (!this.open) {\n cancelAnimationFrame(this.raf);\n this.closed.emit();\n this.items.forEach((item) => {\n if (isZMenuSection(item) && item.open) {\n item.open = false;\n }\n });\n\n return;\n }\n\n this.setItemsA11yAttrs();\n this.opened.emit();\n if (this.floating) {\n this.reflow(true);\n }\n }\n\n @Watch(\"htmlTabindex\")\n setLabelA11yAttrs(): void {\n if (this.hasContent && !this.labelButton) {\n return;\n }\n\n if (this.hasContent) {\n this.labelButton.tabIndex = this.htmlTabindex;\n\n return;\n }\n\n const slottedLabel = this.host.firstElementChild as HTMLElement;\n slottedLabel.role = \"menuitem\";\n slottedLabel.tabIndex = this.htmlTabindex;\n }\n\n /**\n * Set tabindex to -1 to all siblings of the clicked item.\n */\n @Listen(\"click\", {target: \"document\"})\n onItemClick(ev: MouseEvent): void {\n const clickedItem = this.items.find((item) => containsElement(item, ev.target as HTMLElement));\n if (clickedItem) {\n this.items.forEach((item) => {\n if (item === clickedItem) {\n return;\n }\n\n if (isZMenuSection(item)) {\n item.htmlTabindex = -1;\n } else {\n item.tabIndex = -1;\n }\n });\n }\n }\n\n @Listen(\"keydown\")\n onKeyDown(ev: KeyboardEvent): void {\n if (!this.hasContent) {\n return;\n }\n\n switch (ev.key) {\n case KeyboardCode.ESC:\n if (!this.open) {\n break;\n }\n ev.stopPropagation();\n ev.preventDefault();\n this.open = false;\n this.setFocus();\n break;\n case KeyboardCode.ARROW_DOWN: {\n if (document.activeElement === this.host) {\n if (this.verticalContext && !this.open) {\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n if (!this.open) {\n this.open = true;\n }\n this.moveFocus(this.items[0]);\n break;\n }\n\n const currentIndex = this.items.indexOf(this.focusableItem);\n if (this.verticalContext && currentIndex === this.items.length - 1) {\n // navigation is going to leave this menu. restore tabindex to the label and let the parent handle it\n this.setItemTabindex(this.items[currentIndex], -1);\n this.htmlTabindex = 0;\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n const receiver = this.items[currentIndex + 1];\n // if the last item is already focused, navigate to the first one\n this.moveFocus(receiver ?? this.items[0], this.focusableItem);\n break;\n }\n case KeyboardCode.ARROW_UP: {\n if (document.activeElement === this.host) {\n if (this.verticalContext) {\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n // open the menu and focus the last item\n if (!this.open) {\n this.open = true;\n }\n this.moveFocus(this.items[this.items.length - 1], this.focusableItem);\n break;\n }\n\n ev.stopPropagation();\n ev.preventDefault();\n const currentIndex = this.items.indexOf(this.focusableItem);\n if (currentIndex === 0 && this.verticalContext) {\n this.setItemTabindex(this.focusableItem, -1);\n this.setFocus();\n break;\n }\n\n const receiver = this.items[currentIndex - 1] ?? this.items[this.items.length - 1];\n // if the receiver is a ZMenuSection and it's open, focus its last item\n if (isZMenuSection(receiver) && receiver.open) {\n this.setItemTabindex(this.focusableItem, -1);\n receiver.focusLastItem();\n break;\n }\n\n this.moveFocus(receiver, this.focusableItem);\n break;\n }\n case KeyboardCode.ARROW_LEFT:\n if (!this.open || !this.verticalContext) {\n break;\n }\n\n // close the menu and focus the label\n ev.preventDefault();\n ev.stopPropagation();\n this.open = false;\n this.setFocus();\n }\n }\n\n constructor() {\n this.toggle = this.toggle.bind(this);\n this.checkContent = this.checkContent.bind(this);\n this.onLabelSlotChange = this.onLabelSlotChange.bind(this);\n this.onLabelClick = this.onLabelClick.bind(this);\n this.onItemsChange = this.onItemsChange.bind(this);\n this.onLabelKeydown = this.onLabelKeydown.bind(this);\n }\n\n connectedCallback(): void {\n this.onItemsChange();\n this.setLabelA11yAttrs();\n }\n\n render(): HTMLDivElement | HTMLZMenuElement {\n if (!this.hasContent) {\n return (\n <div class=\"menu-label\">\n <slot onSlotchange={this.onLabelSlotChange} />\n </div>\n );\n }\n\n return (\n <Host>\n <button\n ref={(el) => (this.labelButton = el)}\n class=\"menu-label\"\n aria-expanded={`${!!this.open}`}\n aria-haspopup={`${this.hasContent}`}\n aria-label={this.open ? \"Chiudi menù\" : \"Apri menù\"}\n role=\"menuitem\"\n tabIndex={this.htmlTabindex}\n onClick={this.onLabelClick}\n onKeyDown={this.onLabelKeydown}\n >\n <slot onSlotchange={this.onLabelSlotChange} />\n <z-icon name={this.open ? \"chevron-up\" : \"chevron-down\"} />\n </button>\n\n <div\n class=\"content\"\n ref={(el) => (this.content = el)}\n >\n {this.hasHeader && (\n <header class=\"header\">\n <slot\n name=\"header\"\n onSlotchange={this.checkContent}\n />\n </header>\n )}\n\n <div\n class=\"items\"\n role=\"menu\"\n >\n <slot\n name=\"item\"\n onSlotchange={this.onItemsChange}\n />\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -26,9 +26,12 @@
|
|
|
26
26
|
|
|
27
27
|
.menu-label {
|
|
28
28
|
position: relative;
|
|
29
|
+
display: flex;
|
|
29
30
|
width: 100%;
|
|
31
|
+
align-items: center;
|
|
30
32
|
padding: 0;
|
|
31
33
|
border: 0;
|
|
34
|
+
border-bottom: var(--border-size-large) solid transparent;
|
|
32
35
|
margin: 0;
|
|
33
36
|
background: transparent;
|
|
34
37
|
border-radius: 0;
|
|
@@ -36,58 +39,39 @@
|
|
|
36
39
|
text-align: left;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
.menu-wrapper {
|
|
40
|
-
display: flex;
|
|
41
|
-
align-items: center;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
42
|
button.menu-label {
|
|
45
43
|
cursor: pointer;
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
.menu-label:focus-
|
|
46
|
+
.menu-label:focus-visible,
|
|
47
|
+
div.menu-label:focus-within {
|
|
49
48
|
box-shadow: var(--shadow-focus-primary);
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
align-items: center;
|
|
56
|
-
border-bottom: var(--border-size-large) solid transparent;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
:host(:is([active], [open])) .menu-label-content,
|
|
60
|
-
.menu-label:focus-within .menu-label-content {
|
|
51
|
+
:host(:is([active], [open])) .menu-label ::slotted(*),
|
|
52
|
+
.menu-label:focus-visible ::slotted(*),
|
|
53
|
+
div.menu-label:focus-within ::slotted(*) {
|
|
61
54
|
color: var(--color-primary01);
|
|
62
55
|
font-weight: var(--font-bd);
|
|
63
56
|
}
|
|
64
57
|
|
|
65
|
-
:host(
|
|
66
|
-
.menu-label:focus-within .menu-label-content ::slotted(*),
|
|
67
|
-
.menu-label:focus-within .menu-label-content z-icon {
|
|
68
|
-
color: var(--color-primary01);
|
|
69
|
-
letter-spacing: normal;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
:host([vertical-context]) .menu-label-content {
|
|
58
|
+
:host([vertical-context]) .menu-label {
|
|
73
59
|
padding: var(--space-unit) 0;
|
|
74
60
|
border-width: var(--border-size-small);
|
|
75
61
|
border-color: var(--color-surface03);
|
|
76
62
|
}
|
|
77
63
|
|
|
78
|
-
:host([
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
:host(:is([active], [open])) .menu-label .menu-label-content,
|
|
83
|
-
.menu-label .menu-label-content:hover,
|
|
84
|
-
.menu-label:focus-within .menu-label-content {
|
|
64
|
+
:host(:is([active], [open])) .menu-label,
|
|
65
|
+
.menu-label:hover,
|
|
66
|
+
.menu-label:focus-visible,
|
|
67
|
+
div.menu-label:focus-within {
|
|
85
68
|
border-color: var(--color-secondary01);
|
|
86
69
|
}
|
|
87
70
|
|
|
88
|
-
:host([vertical-context]:is([active], [open])) .menu-label
|
|
71
|
+
:host([vertical-context]:is([active], [open])) .menu-label::after,
|
|
89
72
|
:host([vertical-context]) .menu-label:hover::after,
|
|
90
|
-
:host([vertical-context]) .menu-label:focus-
|
|
73
|
+
:host([vertical-context]) .menu-label:focus-visible::after,
|
|
74
|
+
:host([vertical-context]) div.menu-label:focus-within::after {
|
|
91
75
|
position: absolute;
|
|
92
76
|
bottom: 0;
|
|
93
77
|
left: 0;
|
|
@@ -97,6 +81,29 @@ button.menu-label {
|
|
|
97
81
|
content: "";
|
|
98
82
|
}
|
|
99
83
|
|
|
84
|
+
:host([vertical-context]) .menu-label ::slotted(*) {
|
|
85
|
+
padding: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.menu-label ::slotted(*) {
|
|
89
|
+
display: inline-flex;
|
|
90
|
+
width: 100%;
|
|
91
|
+
min-width: fit-content;
|
|
92
|
+
padding-bottom: 2px;
|
|
93
|
+
margin: 0;
|
|
94
|
+
appearance: none;
|
|
95
|
+
color: var(--z-menu-label-color, var(--color-default-text));
|
|
96
|
+
font-family: var(--font-family-sans);
|
|
97
|
+
font-size: var(--font-size-3);
|
|
98
|
+
font-weight: inherit;
|
|
99
|
+
line-height: 1.5;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.menu-label z-icon {
|
|
103
|
+
margin-left: calc(var(--space-unit) * 1.5);
|
|
104
|
+
fill: var(--color-default-icon);
|
|
105
|
+
}
|
|
106
|
+
|
|
100
107
|
/* Prevents layout shifts on font-weight changes.
|
|
101
108
|
The trick is to put an hidden copy of the text already set to bold,
|
|
102
109
|
so the needed space is correctly calculated before any hover/active state changes the
|
|
@@ -125,25 +132,6 @@ when placed below the real text using `flex-direction: column`. */
|
|
|
125
132
|
flex-direction: column;
|
|
126
133
|
}
|
|
127
134
|
|
|
128
|
-
.menu-label .menu-label-content ::slotted(*) {
|
|
129
|
-
display: inline-flex;
|
|
130
|
-
width: 100%;
|
|
131
|
-
min-width: fit-content;
|
|
132
|
-
padding-bottom: 2px;
|
|
133
|
-
margin: 0;
|
|
134
|
-
appearance: none;
|
|
135
|
-
color: var(--z-menu-label-color, var(--color-default-text));
|
|
136
|
-
font-family: var(--font-family-sans);
|
|
137
|
-
font-size: var(--font-size-3);
|
|
138
|
-
font-weight: inherit;
|
|
139
|
-
line-height: 1.5;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.menu-label .menu-label-content z-icon {
|
|
143
|
-
margin-left: calc(var(--space-unit) * 1.5);
|
|
144
|
-
fill: currentcolor;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
135
|
.content {
|
|
148
136
|
background: var(--color-surface01);
|
|
149
137
|
}
|
|
@@ -210,7 +198,7 @@ when placed below the real text using `flex-direction: column`. */
|
|
|
210
198
|
border-bottom: var(--border-size-small) solid var(--color-surface03);
|
|
211
199
|
}
|
|
212
200
|
|
|
213
|
-
:host(:not([vertical-context])) .items > ::slotted([slot="item"]:
|
|
201
|
+
:host(:not([vertical-context])) .items > ::slotted([slot="item"]:last-child) {
|
|
214
202
|
border-bottom: 0;
|
|
215
203
|
}
|
|
216
204
|
|