@sapudex/web-components 0.224.0 → 0.225.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.
- package/dist/FilterMenu.d.ts +7 -0
- package/dist/FilterMenu.js +3 -0
- package/dist/FilterMenu.js.map +1 -1
- package/dist/HeroBanner.js.map +1 -1
- package/dist/MastheadItem.d.ts +48 -2
- package/dist/MastheadItem.js +99 -19
- package/dist/MastheadItem.js.map +1 -1
- package/dist/MastheadMenu.d.ts +1 -0
- package/dist/MastheadMenu.js +14 -5
- package/dist/MastheadMenu.js.map +1 -1
- package/dist/MastheadMobileMenu.d.ts +4 -1
- package/dist/MastheadMobileMenu.js +15 -3
- package/dist/MastheadMobileMenu.js.map +1 -1
- package/dist/MastheadShell.d.ts +17 -3
- package/dist/MastheadShell.js +64 -42
- package/dist/MastheadShell.js.map +1 -1
- package/dist/PasswordField.d.ts +12 -0
- package/dist/PasswordField.js +13 -0
- package/dist/PasswordField.js.map +1 -1
- package/dist/Table.d.ts +5 -0
- package/dist/Table.js +4 -1
- package/dist/Table.js.map +1 -1
- package/dist/TextField.d.ts +8 -0
- package/dist/TextField.js +9 -0
- package/dist/TextField.js.map +1 -1
- package/dist/assets/{bundle.esm-fe0b0d94.js → bundle.esm-062c2857.js} +194 -193
- package/dist/assets/messagebundle_en-5423ac88.js +1 -0
- package/dist/css/themes/PasswordField.css +1 -0
- package/dist/css/themes/RatingIndicator.css +1 -1
- package/dist/css/themes/Slider.css +1 -1
- package/dist/custom-elements-internal.json +125 -0
- package/dist/custom-elements.json +114 -0
- package/dist/generated/assets/i18n/messagebundle_en.json +1 -1
- package/dist/generated/i18n/i18n-defaults.d.ts +3 -1
- package/dist/generated/i18n/i18n-defaults.js +3 -1
- package/dist/generated/i18n/i18n-defaults.js.map +1 -1
- package/dist/generated/templates/FilterMenuTemplate.lit.js +1 -1
- package/dist/generated/templates/FilterMenuTemplate.lit.js.map +1 -1
- package/dist/generated/templates/MastheadItemTemplate.lit.js +2 -2
- package/dist/generated/templates/MastheadItemTemplate.lit.js.map +1 -1
- package/dist/generated/templates/MastheadMenuTemplate.lit.js +1 -1
- package/dist/generated/templates/MastheadMenuTemplate.lit.js.map +1 -1
- package/dist/generated/templates/MastheadMobileMenuTemplate.lit.js +2 -2
- package/dist/generated/templates/MastheadMobileMenuTemplate.lit.js.map +1 -1
- package/dist/generated/templates/MastheadShellTemplate.lit.js +1 -1
- package/dist/generated/templates/MastheadShellTemplate.lit.js.map +1 -1
- package/dist/generated/templates/PasswordFieldTemplate.lit.js +1 -1
- package/dist/generated/templates/PasswordFieldTemplate.lit.js.map +1 -1
- package/dist/generated/templates/TextFieldTemplate.lit.js +1 -1
- package/dist/generated/templates/TextFieldTemplate.lit.js.map +1 -1
- package/dist/generated/themes/PasswordField.css.d.ts +3 -0
- package/dist/generated/themes/PasswordField.css.js +9 -0
- package/dist/generated/themes/PasswordField.css.js.map +1 -0
- package/dist/generated/themes/RatingIndicator.css.js +1 -1
- package/dist/generated/themes/RatingIndicator.css.js.map +1 -1
- package/dist/generated/themes/Slider.css.js +1 -1
- package/dist/generated/themes/Slider.css.js.map +1 -1
- package/dist/i18n/messagebundle.properties +7 -2
- package/dist/i18n/messagebundle_en.properties +3 -1
- package/dist/vscode.html-custom-data.json +22 -2
- package/dist/web-types.json +83 -3
- package/package.json +1 -1
- package/src/FilterMenu.hbs +1 -0
- package/src/FilterMenu.ts +9 -0
- package/src/HeroBanner.ts +1 -1
- package/src/MastheadItem.hbs +2 -2
- package/src/MastheadItem.ts +120 -21
- package/src/MastheadMenu.hbs +4 -1
- package/src/MastheadMenu.ts +16 -5
- package/src/MastheadMobileMenu.hbs +2 -2
- package/src/MastheadMobileMenu.ts +18 -3
- package/src/MastheadShell.hbs +6 -3
- package/src/MastheadShell.ts +68 -44
- package/src/PasswordField.hbs +1 -0
- package/src/PasswordField.ts +19 -1
- package/src/Table.ts +8 -1
- package/src/TextField.hbs +2 -0
- package/src/TextField.ts +16 -0
- package/src/generated/i18n/i18n-defaults.ts +2 -2
- package/src/generated/templates/FilterMenuTemplate.lit.ts +1 -1
- package/src/generated/templates/MastheadItemTemplate.lit.ts +2 -2
- package/src/generated/templates/MastheadMenuTemplate.lit.ts +1 -1
- package/src/generated/templates/MastheadMobileMenuTemplate.lit.ts +2 -2
- package/src/generated/templates/MastheadShellTemplate.lit.ts +1 -1
- package/src/generated/templates/PasswordFieldTemplate.lit.ts +1 -1
- package/src/generated/templates/TextFieldTemplate.lit.ts +1 -1
- package/src/generated/themes/PasswordField.css.ts +13 -0
- package/src/generated/themes/RatingIndicator.css.ts +1 -1
- package/src/generated/themes/Slider.css.ts +1 -1
- package/src/i18n/messagebundle.properties +7 -2
- package/src/i18n/messagebundle_en.properties +3 -1
- package/src/themes/PasswordField.css +3 -0
- package/dist/assets/messagebundle_en-d1666c5e.js +0 -1
package/src/MastheadItem.ts
CHANGED
|
@@ -10,7 +10,9 @@ import "@ui5/webcomponents-icons/dist/search.js";
|
|
|
10
10
|
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
|
|
11
11
|
import { isEscape } from "@ui5/webcomponents-base/dist/Keys.js";
|
|
12
12
|
import { isDesktop } from "@ui5/webcomponents-base/dist/Device.js";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
OPENS_IN_A_NEW_WINDOW, PROFILE, CART, COUNTRY_SELECTOR,
|
|
15
|
+
} from "./generated/i18n/i18n-defaults.js";
|
|
14
16
|
import UDExMastheadMenu from "./MastheadMenu.js";
|
|
15
17
|
import UDExAvatar from "./Avatar.js";
|
|
16
18
|
import "@ui5/webcomponents-icons/dist/slim-arrow-down.js";
|
|
@@ -21,6 +23,12 @@ import { BreakpointUtils } from "./utils/Breakpoints.js";
|
|
|
21
23
|
// Styles
|
|
22
24
|
import MastheadItemCss from "./generated/themes/MastheadItem.css.js";
|
|
23
25
|
|
|
26
|
+
export enum DropdownItemAction {
|
|
27
|
+
Open = "Open",
|
|
28
|
+
Close = "Close",
|
|
29
|
+
ClickOutside = "Click Outside",
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
export interface IMastheadItem {
|
|
25
33
|
text?: string;
|
|
26
34
|
selected?: boolean;
|
|
@@ -51,6 +59,29 @@ export type ItemClickEventDetail = {
|
|
|
51
59
|
item: UDExMastheadItem,
|
|
52
60
|
}
|
|
53
61
|
|
|
62
|
+
export type DropdownEventDetail = {
|
|
63
|
+
title: string,
|
|
64
|
+
action: DropdownItemAction,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const DropdownBaseEventDetail = {
|
|
68
|
+
detail: {
|
|
69
|
+
title: { type: String },
|
|
70
|
+
action: { type: DropdownItemAction },
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const ItemBaseEvent = {
|
|
75
|
+
detail: {
|
|
76
|
+
item: {
|
|
77
|
+
type: HTMLElement,
|
|
78
|
+
},
|
|
79
|
+
originalEvent: {
|
|
80
|
+
type: Event,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
54
85
|
/**
|
|
55
86
|
* @class
|
|
56
87
|
*
|
|
@@ -86,16 +117,23 @@ export type ItemClickEventDetail = {
|
|
|
86
117
|
* @allowPreventDefault
|
|
87
118
|
* @public
|
|
88
119
|
*/
|
|
89
|
-
@event("item-click",
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
120
|
+
@event("item-click", ItemBaseEvent)
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Fires when item is clicked
|
|
124
|
+
*
|
|
125
|
+
* @allowPreventDefault
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
128
|
+
@event("dropdown-closed", DropdownBaseEventDetail)
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Fires when item is clicked
|
|
132
|
+
*
|
|
133
|
+
* @allowPreventDefault
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
@event("dropdown-opened", DropdownBaseEventDetail)
|
|
99
137
|
|
|
100
138
|
class UDExMastheadItem extends UI5Element implements IMastheadItem {
|
|
101
139
|
/**
|
|
@@ -258,6 +296,7 @@ class UDExMastheadItem extends UI5Element implements IMastheadItem {
|
|
|
258
296
|
|
|
259
297
|
_profileAvatar!: UDExAvatar;
|
|
260
298
|
_mastheadShell!: UDExMastheadShell;
|
|
299
|
+
_isEscPress!: boolean;
|
|
261
300
|
|
|
262
301
|
static i18nBundle: I18nBundle;
|
|
263
302
|
|
|
@@ -278,10 +317,27 @@ class UDExMastheadItem extends UI5Element implements IMastheadItem {
|
|
|
278
317
|
if (this.selected && this.hasDropdownSlot && !this.isMobile && !this.isExploreBtn) {
|
|
279
318
|
this.setDropdownInsetStart();
|
|
280
319
|
}
|
|
320
|
+
|
|
321
|
+
this.handleOutsideClick();
|
|
322
|
+
this._isEscPress = false;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
handleOutsideClick(): void {
|
|
326
|
+
document.addEventListener("click", (e: Event) => {
|
|
327
|
+
const target = e.target as HTMLElement;
|
|
328
|
+
const item = target.closest("[udex-masthead-item]");
|
|
329
|
+
if (item !== this && !this.isMobile) {
|
|
330
|
+
if (this.isDropdownOpened) {
|
|
331
|
+
this.fireDropdownCloseEvent(this.eventItemTitle, DropdownItemAction.ClickOutside);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
this.selected = false;
|
|
335
|
+
}
|
|
336
|
+
});
|
|
281
337
|
}
|
|
282
338
|
|
|
283
339
|
handleFocusout(e: FocusEvent): void {
|
|
284
|
-
if (e.relatedTarget === null) {
|
|
340
|
+
if (e.relatedTarget === null || this._isEscPress) {
|
|
285
341
|
return;
|
|
286
342
|
}
|
|
287
343
|
|
|
@@ -302,6 +358,7 @@ class UDExMastheadItem extends UI5Element implements IMastheadItem {
|
|
|
302
358
|
}
|
|
303
359
|
|
|
304
360
|
handleKeyEscape(): void {
|
|
361
|
+
this._isEscPress = true;
|
|
305
362
|
this.closeDropdown();
|
|
306
363
|
if (this.isProfileBtn) {
|
|
307
364
|
this._profileAvatar.focus();
|
|
@@ -311,23 +368,48 @@ class UDExMastheadItem extends UI5Element implements IMastheadItem {
|
|
|
311
368
|
}
|
|
312
369
|
|
|
313
370
|
handleKeyEscapeMobile(): void {
|
|
371
|
+
this.fireDropdownCloseEvent(this.eventItemTitle, DropdownItemAction.Close);
|
|
314
372
|
this._mastheadShell.closeMobileMenu();
|
|
315
373
|
this._mastheadShell.mobileBtn?.focus();
|
|
316
374
|
}
|
|
317
375
|
|
|
318
376
|
handleItemClick(e: Event): void {
|
|
377
|
+
this.fireItemClickEvent(e);
|
|
319
378
|
this.handleSelectedChange();
|
|
379
|
+
this.fireDropdownEvents();
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
handleSelectedChange(): void {
|
|
383
|
+
this.selected = this.isMobile ? true : !this.selected;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
fireDropdownEvents(): void {
|
|
387
|
+
if (this.hasDropdownSlot) {
|
|
388
|
+
const { Open, Close } = DropdownItemAction;
|
|
389
|
+
const action = this.selected ? Open : Close;
|
|
390
|
+
if (this.selected) {
|
|
391
|
+
this.fireDropdownOpenEvent(this.eventItemTitle, action);
|
|
392
|
+
} else {
|
|
393
|
+
this.fireDropdownCloseEvent(this.eventItemTitle, action);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
fireDropdownCloseEvent(title: string, action: DropdownItemAction): void {
|
|
399
|
+
this.fireEvent<DropdownEventDetail>("dropdown-closed", { title, action });
|
|
400
|
+
}
|
|
320
401
|
|
|
402
|
+
fireDropdownOpenEvent(title: string, action: DropdownItemAction): void {
|
|
403
|
+
this.fireEvent<DropdownEventDetail>("dropdown-opened", { title, action });
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
fireItemClickEvent(e: Event): void {
|
|
321
407
|
this.fireEvent<ItemClickEventDetail>("item-click", {
|
|
322
408
|
item: this,
|
|
323
409
|
originalEvent: e,
|
|
324
410
|
});
|
|
325
411
|
}
|
|
326
412
|
|
|
327
|
-
handleSelectedChange(): void {
|
|
328
|
-
this.selected = this.isMobile ? true : !this.selected;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
413
|
setDropdownInsetStart(): void {
|
|
332
414
|
const dropdown = this.getDomElement(".udex-masthead-item__dropdown");
|
|
333
415
|
if (dropdown) {
|
|
@@ -376,6 +458,7 @@ class UDExMastheadItem extends UI5Element implements IMastheadItem {
|
|
|
376
458
|
|
|
377
459
|
closeDropdown(): void {
|
|
378
460
|
this.selected = false;
|
|
461
|
+
this.fireDropdownCloseEvent(this.eventItemTitle, DropdownItemAction.Close);
|
|
379
462
|
}
|
|
380
463
|
|
|
381
464
|
getDomElement(selector: string): HTMLElement | undefined | null {
|
|
@@ -444,7 +527,7 @@ class UDExMastheadItem extends UI5Element implements IMastheadItem {
|
|
|
444
527
|
return labels.join(" ").trim();
|
|
445
528
|
}
|
|
446
529
|
|
|
447
|
-
get
|
|
530
|
+
get isDropdownOpened(): boolean {
|
|
448
531
|
return this.hasDropdownSlot && this.selected;
|
|
449
532
|
}
|
|
450
533
|
|
|
@@ -468,12 +551,12 @@ class UDExMastheadItem extends UI5Element implements IMastheadItem {
|
|
|
468
551
|
return this.getAttribute("slot") === "countrySelector";
|
|
469
552
|
}
|
|
470
553
|
|
|
471
|
-
get
|
|
472
|
-
return this.
|
|
554
|
+
get isCartBtn(): boolean {
|
|
555
|
+
return this.getAttribute("slot") === "cart";
|
|
473
556
|
}
|
|
474
557
|
|
|
475
|
-
get
|
|
476
|
-
return
|
|
558
|
+
get accessibleLabel(): string {
|
|
559
|
+
return this.accessibleName || this.innerText || (this.isProfileBtn ? UDExMastheadItem.i18nBundle.getText(PROFILE) : "");
|
|
477
560
|
}
|
|
478
561
|
|
|
479
562
|
get isMobile(): boolean {
|
|
@@ -487,6 +570,22 @@ class UDExMastheadItem extends UI5Element implements IMastheadItem {
|
|
|
487
570
|
get openInNewWindowText(): string {
|
|
488
571
|
return UDExMastheadItem.i18nBundle.getText(OPENS_IN_A_NEW_WINDOW);
|
|
489
572
|
}
|
|
573
|
+
|
|
574
|
+
get eventItemTitle(): string {
|
|
575
|
+
if (this.isCartBtn) {
|
|
576
|
+
return UDExMastheadItem.i18nBundle.getText(CART);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if (this.isProfileBtn) {
|
|
580
|
+
return UDExMastheadItem.i18nBundle.getText(PROFILE);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if (this.isCountrySelectorBtn) {
|
|
584
|
+
return UDExMastheadItem.i18nBundle.getText(COUNTRY_SELECTOR);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
return this.innerText.trim();
|
|
588
|
+
}
|
|
490
589
|
}
|
|
491
590
|
|
|
492
591
|
UDExMastheadItem.define();
|
package/src/MastheadMenu.hbs
CHANGED
|
@@ -34,7 +34,10 @@
|
|
|
34
34
|
{{/inline}}
|
|
35
35
|
|
|
36
36
|
{{#*inline "list"}}
|
|
37
|
-
<ul
|
|
37
|
+
<ul
|
|
38
|
+
class="udex-masthead-menu__list"
|
|
39
|
+
aria-labelledby="category-{{categoryId}}"
|
|
40
|
+
category="{{this.category}}">
|
|
38
41
|
{{#each this.items}}
|
|
39
42
|
<li>
|
|
40
43
|
{{#if this.url}}
|
package/src/MastheadMenu.ts
CHANGED
|
@@ -8,7 +8,7 @@ import "@ui5/webcomponents-icons/dist/slim-arrow-right.js";
|
|
|
8
8
|
import "@ui5/webcomponents-icons/dist/action.js";
|
|
9
9
|
import { isUp, isDown } from "@ui5/webcomponents-base/dist/Keys.js";
|
|
10
10
|
import UDExBadge from "./Badge.js";
|
|
11
|
-
import UDExMastheadMenuItem from "./MastheadMenuItem.js";
|
|
11
|
+
import UDExMastheadMenuItem, { ItemType } from "./MastheadMenuItem.js";
|
|
12
12
|
import UDExDivider from "./Divider.js";
|
|
13
13
|
import MastheadMenuTemplate from "./generated/templates/MastheadMenuTemplate.lit.js";
|
|
14
14
|
|
|
@@ -35,6 +35,7 @@ export type MenuItem = {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
export type MenuItemClickEventDetail = {
|
|
38
|
+
category?: string,
|
|
38
39
|
originalEvent: Event,
|
|
39
40
|
item: UDExMastheadMenuItem,
|
|
40
41
|
}
|
|
@@ -72,6 +73,9 @@ export type MenuItemClickEventDetail = {
|
|
|
72
73
|
*/
|
|
73
74
|
@event("menu-item-click", {
|
|
74
75
|
detail: {
|
|
76
|
+
category: {
|
|
77
|
+
type: String,
|
|
78
|
+
},
|
|
75
79
|
item: {
|
|
76
80
|
type: HTMLElement,
|
|
77
81
|
},
|
|
@@ -130,10 +134,17 @@ class UDExMastheadMenu extends UI5Element {
|
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
handleMenuItemClick(e: Event): void {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
const item = e.target as UDExMastheadMenuItem;
|
|
138
|
+
const { url, type } = item;
|
|
139
|
+
|
|
140
|
+
if (url?.length) {
|
|
141
|
+
const list = item.closest(".udex-masthead-menu__list") as HTMLElement;
|
|
142
|
+
this.fireEvent<MenuItemClickEventDetail>("menu-item-click", {
|
|
143
|
+
item,
|
|
144
|
+
originalEvent: e,
|
|
145
|
+
...(type !== ItemType.Heading && { category: list?.getAttribute("category") || "" }),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
137
148
|
}
|
|
138
149
|
|
|
139
150
|
focusPreviousItem(item: UDExMastheadMenuItem): void {
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
{{#if _category.url}}
|
|
149
149
|
<li class="udex-masthead-mobile-menu__list-item" role="menuitem">
|
|
150
150
|
<udex-masthead-menu-item
|
|
151
|
-
@click="{{../
|
|
151
|
+
@click="{{../handleMobileCategoryItemEvent}}"
|
|
152
152
|
url="{{this._category.url}}"
|
|
153
153
|
label="{{overviewLinkText}}"
|
|
154
154
|
has-border>
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
{{#if this.url}}
|
|
160
160
|
<li class="udex-masthead-mobile-menu__list-item" role="menuitem">
|
|
161
161
|
<udex-masthead-menu-item
|
|
162
|
-
@click="{{../
|
|
162
|
+
@click="{{../handleMobileCategoryItemEvent}}"
|
|
163
163
|
label="{{this.title}}"
|
|
164
164
|
url="{{this.url}}"
|
|
165
165
|
has-border>
|
|
@@ -19,6 +19,8 @@ import MastheadMobileMenuTemplate from "./generated/templates/MastheadMobileMenu
|
|
|
19
19
|
import MastheadMobileMenuCss from "./generated/themes/MastheadMobileMenu.css.js";
|
|
20
20
|
|
|
21
21
|
export type MobileItemClickEventDetail = {
|
|
22
|
+
category?: string,
|
|
23
|
+
isMobile: boolean,
|
|
22
24
|
originalEvent: Event,
|
|
23
25
|
item: UDExMastheadMenuItem,
|
|
24
26
|
}
|
|
@@ -71,7 +73,13 @@ export type MobileItemClickEventDetail = {
|
|
|
71
73
|
* @allowPreventDefault
|
|
72
74
|
* @public
|
|
73
75
|
*/
|
|
74
|
-
@event("explorer-menu-click"
|
|
76
|
+
@event("explorer-menu-click", {
|
|
77
|
+
detail: {
|
|
78
|
+
originalEvent: {
|
|
79
|
+
type: Event,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
})
|
|
75
83
|
|
|
76
84
|
class UDExMastheadMobileMenu extends UI5Element {
|
|
77
85
|
/**
|
|
@@ -152,7 +160,7 @@ class UDExMastheadMobileMenu extends UI5Element {
|
|
|
152
160
|
e.preventDefault();
|
|
153
161
|
this.openExploreSapMenu(e);
|
|
154
162
|
this.setFocusItemByIndex(0);
|
|
155
|
-
this.fireEvent("explorer-menu-click");
|
|
163
|
+
this.fireEvent("explorer-menu-click", { originalEvent: e });
|
|
156
164
|
}
|
|
157
165
|
|
|
158
166
|
handleBackToMenuItems(e: Event) {
|
|
@@ -239,6 +247,11 @@ class UDExMastheadMobileMenu extends UI5Element {
|
|
|
239
247
|
this.fireMobileItemEvent(e);
|
|
240
248
|
}
|
|
241
249
|
|
|
250
|
+
handleMobileCategoryItemEvent(e: PointerEvent) {
|
|
251
|
+
e.stopPropagation();
|
|
252
|
+
this.fireMobileItemEvent(e, this._category.category);
|
|
253
|
+
}
|
|
254
|
+
|
|
242
255
|
handleMenuMode() {
|
|
243
256
|
if (this.isNoMenuItemsMode && this.hasExploreBtnSlot) {
|
|
244
257
|
this.openCategories(this.exploreItem);
|
|
@@ -406,8 +419,10 @@ class UDExMastheadMobileMenu extends UI5Element {
|
|
|
406
419
|
this._showCategoryItems = false;
|
|
407
420
|
}
|
|
408
421
|
|
|
409
|
-
fireMobileItemEvent(e: Event) {
|
|
422
|
+
fireMobileItemEvent(e: Event, category?: string) {
|
|
410
423
|
this.fireEvent<MobileItemClickEventDetail>("item-click", {
|
|
424
|
+
...(category && { category }),
|
|
425
|
+
isMobile: true,
|
|
411
426
|
item: e.target as UDExMastheadMenuItem,
|
|
412
427
|
originalEvent: e,
|
|
413
428
|
}, true, false);
|
package/src/MastheadShell.hbs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
<header
|
|
1
|
+
<header
|
|
2
|
+
class="udex-masthead-shell"
|
|
3
|
+
@keydown="{{handleKeyDown}}">
|
|
2
4
|
<div class="udex-masthead-shell__main-content">
|
|
3
5
|
<div class="udex-masthead-shell__landing-wrap">
|
|
4
6
|
{{#if logoUrl}}
|
|
@@ -26,7 +28,9 @@
|
|
|
26
28
|
</div>
|
|
27
29
|
|
|
28
30
|
{{#if isSearchVisible}}
|
|
29
|
-
<div
|
|
31
|
+
<div
|
|
32
|
+
class="udex-masthead-shell__search-container"
|
|
33
|
+
@ui5-search-keydown="{{handleSearchKeyDown}}">
|
|
30
34
|
<slot name="search"></slot>
|
|
31
35
|
</div>
|
|
32
36
|
{{#if _isSearchOpened}}
|
|
@@ -96,7 +100,6 @@
|
|
|
96
100
|
<slot name="countrySelector"></slot>
|
|
97
101
|
</div>
|
|
98
102
|
{{/if}}
|
|
99
|
-
|
|
100
103
|
{{#if hasMobileMenuButtons}}
|
|
101
104
|
<udex-masthead-item
|
|
102
105
|
@keydown="{{handleEnterAndSpaceOnCloseBtn}}"
|
package/src/MastheadShell.ts
CHANGED
|
@@ -7,7 +7,7 @@ import UI5Icon from "@ui5/webcomponents/dist/Icon.js";
|
|
|
7
7
|
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
|
|
8
8
|
import ResizeHandler, { ResizeObserverCallback } from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js";
|
|
9
9
|
import {
|
|
10
|
-
isLeft, isRight, isSpace, isEnter,
|
|
10
|
+
isLeft, isRight, isSpace, isEnter, isEscape,
|
|
11
11
|
} from "@ui5/webcomponents-base/dist/Keys.js";
|
|
12
12
|
import "@ui5/webcomponents-icons/dist/decline.js";
|
|
13
13
|
import "@ui5/webcomponents-icons/dist/menu2.js";
|
|
@@ -16,7 +16,7 @@ import "@ui5/webcomponents-icons/dist/cart.js";
|
|
|
16
16
|
import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
|
17
17
|
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
|
18
18
|
import { MAIN_LINKS } from "./generated/i18n/i18n-defaults.js";
|
|
19
|
-
import UDExMastheadItem from "./MastheadItem.js";
|
|
19
|
+
import UDExMastheadItem, { DropdownItemAction } from "./MastheadItem.js";
|
|
20
20
|
import UDExMastheadMenu from "./MastheadMenu.js";
|
|
21
21
|
import UDExControlButton from "./ControlButton.js";
|
|
22
22
|
import UDExSearch from "./Search.js";
|
|
@@ -32,6 +32,12 @@ import MastheadShellCss from "./generated/themes/MastheadShell.css.js";
|
|
|
32
32
|
const canvasContentFont = "16px '72 Brand Variable'";
|
|
33
33
|
type MastheadSlottedItem = UDExMastheadItem | UDExMastheadProfileMenu | UDExMastheadMenu | UDExMastheadCountrySelector | undefined | null;
|
|
34
34
|
type MastheadItemType = UDExMastheadItem | null | undefined;
|
|
35
|
+
export const MastheadOriginalEvent = {
|
|
36
|
+
detail: {
|
|
37
|
+
originalEvent: { type: Event },
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
35
41
|
/**
|
|
36
42
|
* @class
|
|
37
43
|
*
|
|
@@ -83,54 +89,64 @@ type MastheadItemType = UDExMastheadItem | null | undefined;
|
|
|
83
89
|
*
|
|
84
90
|
* @public
|
|
85
91
|
*/
|
|
86
|
-
@event("search-click")
|
|
92
|
+
@event("search-click", MastheadOriginalEvent)
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Fired event when the user clicks the search close button.
|
|
96
|
+
*
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
@event("search-close-click", MastheadOriginalEvent)
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Fired event when the search panel is opened.
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
@event("search-opened")
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Fired event when the search panel is closed.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
@event("search-closed")
|
|
87
114
|
|
|
88
115
|
/**
|
|
89
116
|
* Fired event when the user clicks the cart button trigger.
|
|
90
117
|
*
|
|
91
118
|
* @public
|
|
92
119
|
*/
|
|
93
|
-
@event("cart-click")
|
|
120
|
+
@event("cart-click", MastheadOriginalEvent)
|
|
94
121
|
|
|
95
122
|
/**
|
|
96
123
|
* Fired event when the user clicks the profile button trigger.
|
|
97
124
|
*
|
|
98
125
|
* @public
|
|
99
126
|
*/
|
|
100
|
-
@event("profile-click")
|
|
127
|
+
@event("profile-click", MastheadOriginalEvent)
|
|
101
128
|
|
|
102
129
|
/**
|
|
103
130
|
* Fired event when the user clicks the country selector button trigger.
|
|
104
131
|
*
|
|
105
132
|
* @public
|
|
106
133
|
*/
|
|
107
|
-
@event("country-selector-click")
|
|
134
|
+
@event("country-selector-click", MastheadOriginalEvent)
|
|
108
135
|
|
|
109
136
|
/**
|
|
110
137
|
* Fired event when the user clicks the logo.
|
|
111
138
|
*
|
|
112
139
|
* @public
|
|
113
140
|
*/
|
|
114
|
-
@event("logo-click",
|
|
115
|
-
detail: {
|
|
116
|
-
originalEvent: {
|
|
117
|
-
type: Event,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
})
|
|
141
|
+
@event("logo-click", MastheadOriginalEvent)
|
|
121
142
|
|
|
122
143
|
/**
|
|
123
144
|
* Fired event when the user clicks the site label.
|
|
124
145
|
*
|
|
125
146
|
* @public
|
|
147
|
+
* @public
|
|
126
148
|
*/
|
|
127
|
-
@event("site-label-click",
|
|
128
|
-
detail: {
|
|
129
|
-
originalEvent: {
|
|
130
|
-
type: Event,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
})
|
|
149
|
+
@event("site-label-click", MastheadOriginalEvent)
|
|
134
150
|
|
|
135
151
|
class UDExMastheadShell extends UI5Element {
|
|
136
152
|
/**
|
|
@@ -350,8 +366,6 @@ class UDExMastheadShell extends UI5Element {
|
|
|
350
366
|
this._searchOpener = this.searchOpener;
|
|
351
367
|
this._mobileMenu = this.mastheadMobileMenu;
|
|
352
368
|
|
|
353
|
-
this.handleOutsideClick();
|
|
354
|
-
|
|
355
369
|
if (this._isSearchOpened) {
|
|
356
370
|
this.focusSearchInput();
|
|
357
371
|
}
|
|
@@ -380,6 +394,7 @@ class UDExMastheadShell extends UI5Element {
|
|
|
380
394
|
|
|
381
395
|
if (this._shouldHandleResize && this._isMobileMenuOpen) {
|
|
382
396
|
this.closeMobileMenu();
|
|
397
|
+
this.resetSelectedItems();
|
|
383
398
|
return;
|
|
384
399
|
}
|
|
385
400
|
|
|
@@ -409,6 +424,19 @@ class UDExMastheadShell extends UI5Element {
|
|
|
409
424
|
this.handleRightArrow(e);
|
|
410
425
|
}
|
|
411
426
|
|
|
427
|
+
handleSearchKeyDown(e: CustomEvent): void {
|
|
428
|
+
e.stopPropagation();
|
|
429
|
+
const keyEvent = e.detail as KeyboardEvent;
|
|
430
|
+
|
|
431
|
+
if (isEscape(keyEvent)) {
|
|
432
|
+
if (this.showSearchByDefault && this.isAtLeastBreakpointSizeM) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
this.closeSearch();
|
|
436
|
+
this.focusSearchBtn();
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
412
440
|
handleLeftArrow(e: KeyboardEvent): void {
|
|
413
441
|
if (isLeft(e)) {
|
|
414
442
|
const currentItem = e.target as UDExMastheadItem;
|
|
@@ -443,23 +471,23 @@ class UDExMastheadShell extends UI5Element {
|
|
|
443
471
|
|
|
444
472
|
handleSearchClick(e: CustomEvent): void {
|
|
445
473
|
e.stopPropagation();
|
|
474
|
+
this.fireEvent("search-click", { originalEvent: e });
|
|
446
475
|
this.openSearch();
|
|
447
|
-
this.fireEvent("search-click");
|
|
448
476
|
}
|
|
449
477
|
|
|
450
478
|
handleCartClick(e: CustomEvent): void {
|
|
451
479
|
e.stopPropagation();
|
|
452
|
-
this.fireEvent("cart-click");
|
|
480
|
+
this.fireEvent("cart-click", { originalEvent: e });
|
|
453
481
|
}
|
|
454
482
|
|
|
455
483
|
handleProfileClick(e: CustomEvent): void {
|
|
456
484
|
e.stopPropagation();
|
|
457
|
-
this.fireEvent("profile-click");
|
|
485
|
+
this.fireEvent("profile-click", { originalEvent: e });
|
|
458
486
|
}
|
|
459
487
|
|
|
460
488
|
handleCountrySelectorClick(e: CustomEvent): void {
|
|
461
489
|
e.stopPropagation();
|
|
462
|
-
this.fireEvent("country-selector-click");
|
|
490
|
+
this.fireEvent("country-selector-click", { originalEvent: e });
|
|
463
491
|
}
|
|
464
492
|
|
|
465
493
|
handleOpenMobileMenu(): void {
|
|
@@ -478,9 +506,10 @@ class UDExMastheadShell extends UI5Element {
|
|
|
478
506
|
this.fireEvent("mobile-menu-open");
|
|
479
507
|
}
|
|
480
508
|
|
|
481
|
-
handleCloseSearch(): void {
|
|
482
|
-
this.closeSearch();
|
|
509
|
+
handleCloseSearch(e: CustomEvent): void {
|
|
483
510
|
this._closeBtnClicked = true;
|
|
511
|
+
this.fireEvent("search-close-click", { originalEvent: e });
|
|
512
|
+
this.closeSearch();
|
|
484
513
|
}
|
|
485
514
|
|
|
486
515
|
handleEnterAndSpaceOnCloseBtn(e: KeyboardEvent): void {
|
|
@@ -491,17 +520,6 @@ class UDExMastheadShell extends UI5Element {
|
|
|
491
520
|
}
|
|
492
521
|
}
|
|
493
522
|
|
|
494
|
-
handleOutsideClick(): void {
|
|
495
|
-
document.addEventListener("click", (e: Event) => {
|
|
496
|
-
const el = e.target as UDExMastheadItem;
|
|
497
|
-
const isMobile = window.innerWidth < 1280 || this._isMobileMode;
|
|
498
|
-
const isDropdownSlot = el.getAttribute("slot") === "dropdown";
|
|
499
|
-
if (!isDropdownSlot && !el.isMenuItem && !isMobile) {
|
|
500
|
-
this.resetSelectedItems();
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
|
|
505
523
|
focusSearchInput(): void {
|
|
506
524
|
const searchSlot = this.querySelector<UDExSearch>("[udex-search]");
|
|
507
525
|
if (searchSlot) {
|
|
@@ -527,7 +545,10 @@ class UDExMastheadShell extends UI5Element {
|
|
|
527
545
|
|
|
528
546
|
resetSelectedItems(clickedId?: string): void {
|
|
529
547
|
this.getSelectedItems().forEach(item => {
|
|
530
|
-
if (item._id !== clickedId) {
|
|
548
|
+
if (item._id !== clickedId && item.selected) {
|
|
549
|
+
if (item.hasDropdownSlot) {
|
|
550
|
+
item.fireDropdownCloseEvent(item.eventItemTitle, DropdownItemAction.ClickOutside);
|
|
551
|
+
}
|
|
531
552
|
item.selected = false;
|
|
532
553
|
}
|
|
533
554
|
});
|
|
@@ -673,6 +694,7 @@ class UDExMastheadShell extends UI5Element {
|
|
|
673
694
|
*/
|
|
674
695
|
closeSearch(): void {
|
|
675
696
|
this._isSearchOpened = false;
|
|
697
|
+
this.fireEvent("search-closed");
|
|
676
698
|
}
|
|
677
699
|
|
|
678
700
|
/**
|
|
@@ -683,7 +705,7 @@ class UDExMastheadShell extends UI5Element {
|
|
|
683
705
|
const shouldPreventOpeningSearch = this._isSearchOpened
|
|
684
706
|
|| (this.isBreakpointSizeM && !this.showSearchByDefault)
|
|
685
707
|
|| this._isMobileMode
|
|
686
|
-
|| (this.
|
|
708
|
+
|| (this.isAtLeastBreakpointSizeM && this.showSearchByDefault);
|
|
687
709
|
|
|
688
710
|
if (shouldPreventOpeningSearch) {
|
|
689
711
|
return;
|
|
@@ -695,6 +717,8 @@ class UDExMastheadShell extends UI5Element {
|
|
|
695
717
|
if (this._searchOpener) {
|
|
696
718
|
this._searchOpener.selected = false;
|
|
697
719
|
}
|
|
720
|
+
|
|
721
|
+
this.fireEvent("search-opened");
|
|
698
722
|
}
|
|
699
723
|
|
|
700
724
|
/**
|
|
@@ -703,7 +727,7 @@ class UDExMastheadShell extends UI5Element {
|
|
|
703
727
|
*/
|
|
704
728
|
openMobileMenu(): void {
|
|
705
729
|
if (!this._isMobileMenuOpen && (this._isMobileMode || this.isBreakpointSizeM)) {
|
|
706
|
-
|
|
730
|
+
this.mobileBtn?.handleSelectedChange();
|
|
707
731
|
this.handleOpenMobileMenu();
|
|
708
732
|
}
|
|
709
733
|
}
|
|
@@ -717,8 +741,8 @@ class UDExMastheadShell extends UI5Element {
|
|
|
717
741
|
return;
|
|
718
742
|
}
|
|
719
743
|
|
|
744
|
+
(this.mobileBtn as UDExMastheadItem).selected = false;
|
|
720
745
|
this._isMobileMenuOpen = false;
|
|
721
|
-
this.resetSelectedItems();
|
|
722
746
|
this._mobileMenu?.showFirstLevelMenu();
|
|
723
747
|
|
|
724
748
|
if (this.bodyOverflow) {
|
|
@@ -812,7 +836,7 @@ class UDExMastheadShell extends UI5Element {
|
|
|
812
836
|
return BreakpointUtils.isAtMost("M");
|
|
813
837
|
}
|
|
814
838
|
|
|
815
|
-
get
|
|
839
|
+
get isAtLeastBreakpointSizeM(): boolean {
|
|
816
840
|
return BreakpointUtils.isAtLeast("M");
|
|
817
841
|
}
|
|
818
842
|
|