Skip to content

Commit 8197304

Browse files
authored
chore: correct docs hierarchy (#13187)
1 parent 570513f commit 8197304

9 files changed

Lines changed: 240 additions & 161 deletions

File tree

packages/main/cypress/specs/ToolbarItem.cy.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ describe("Toolbar Item Closing Events - closeOverflowSet functionality", () => {
523523
});
524524

525525
/**
526-
* Custom component that implements IOverflowToolbarItem with overflowCloseEvents
526+
* Custom component that implements IToolbarItemContent with overflowCloseEvents
527527
* This simulates a component that defines its own custom closing events
528528
*/
529529
class CustomOverflowComponent extends HTMLElement {
@@ -535,7 +535,7 @@ class CustomOverflowComponent extends HTMLElement {
535535
`;
536536
}
537537

538-
// Implements IOverflowToolbarItem.overflowCloseEvents
538+
// Implements IToolbarItemContent.overflowCloseEvents
539539
get overflowCloseEvents(): string[] {
540540
return ["custom-action", "custom-change"];
541541
}
@@ -555,7 +555,7 @@ if (!customElements.get("custom-overflow-component")) {
555555
}
556556

557557
/**
558-
* Custom component that implements IOverflowToolbarItem with additional custom events
558+
* Custom component that implements IToolbarItemContent with additional custom events
559559
* Used to test combining predefined closeOverflowSet events with component's overflowCloseEvents
560560
*/
561561
class CustomButtonWithExtraEvents extends HTMLElement {
@@ -582,7 +582,7 @@ if (!customElements.get("custom-button-extra")) {
582582
// @ts-ignore - Custom element JSX type
583583
const CustomOverflowComponentRenderer = (props: { id: string }) => <custom-overflow-component id={props.id} />;
584584

585-
describe("Toolbar Item Closing Events - overflowCloseEvents functionality (IOverflowToolbarItem)", () => {
585+
describe("Toolbar Item Closing Events - overflowCloseEvents functionality (IToolbarItemContent)", () => {
586586
it("Should close overflow popover when custom component fires 'custom-action' event from overflowCloseEvents", () => {
587587
cy.viewport(300, 600);
588588

packages/main/src/Breadcrumbs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import BreadcrumbsDesign from "./types/BreadcrumbsDesign.js";
2424
import "./BreadcrumbsItem.js";
2525
import type BreadcrumbsItem from "./BreadcrumbsItem.js";
2626
import type BreadcrumbsSeparator from "./types/BreadcrumbsSeparator.js";
27-
import type { IOverflowToolbarItem } from "./ToolbarItem.js";
27+
import type { IToolbarItemContent } from "./ToolbarItem.js";
2828

2929
import {
3030
BREADCRUMB_ITEM_POS,
@@ -85,7 +85,7 @@ type FocusAdaptor = ITabbable & {
8585
* - [End] - Navigates to the last item.
8686
* @constructor
8787
* @extends UI5Element
88-
* @implements {IOverflowToolbarItem}
88+
* @implements {IToolbarItemContent}
8989
* @public
9090
* @since 1.0.0-rc.15
9191
*/
@@ -111,7 +111,7 @@ type FocusAdaptor = ITabbable & {
111111
bubbles: true,
112112
cancelable: true,
113113
})
114-
class Breadcrumbs extends UI5Element implements IOverflowToolbarItem {
114+
class Breadcrumbs extends UI5Element implements IToolbarItemContent {
115115
eventDetails!: {
116116
"item-click": BreadcrumbsItemClickEventDetail,
117117
}

packages/main/src/Toolbar.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import type ToolbarAlign from "./types/ToolbarAlign.js";
2727
import type ToolbarDesign from "./types/ToolbarDesign.js";
2828
import ToolbarItemOverflowBehavior from "./types/ToolbarItemOverflowBehavior.js";
2929

30-
import type ToolbarItem from "./ToolbarItem.js";
30+
import type ToolbarItemBase from "./ToolbarItemBase.js";
3131
import type ToolbarSeparator from "./ToolbarSeparator.js";
3232

3333
import type Button from "./Button.js";
@@ -155,11 +155,11 @@ class Toolbar extends UI5Element {
155155
@slot({
156156
"default": true, type: HTMLElement, invalidateOnChildChange: true, individualSlots: true,
157157
})
158-
items!: DefaultSlot<ToolbarItem>
158+
items!: DefaultSlot<ToolbarItemBase>
159159

160160
_onResize!: ResizeObserverCallback;
161161
_onCloseOverflow!: EventListener;
162-
itemsToOverflow: Array<ToolbarItem> = [];
162+
itemsToOverflow: Array<ToolbarItemBase> = [];
163163
itemsWidth = 0;
164164
minContentWidth = 0;
165165

@@ -194,11 +194,11 @@ class Toolbar extends UI5Element {
194194
}
195195

196196
get alwaysOverflowItems() {
197-
return this.items.filter((item: ToolbarItem) => item.overflowPriority === ToolbarItemOverflowBehavior.AlwaysOverflow);
197+
return this.items.filter(item => item.overflowPriority === ToolbarItemOverflowBehavior.AlwaysOverflow);
198198
}
199199

200200
get movableItems() {
201-
return this.items.filter((item: ToolbarItem) => item.overflowPriority !== ToolbarItemOverflowBehavior.AlwaysOverflow && item.overflowPriority !== ToolbarItemOverflowBehavior.NeverOverflow);
201+
return this.items.filter(item => item.overflowPriority !== ToolbarItemOverflowBehavior.AlwaysOverflow && item.overflowPriority !== ToolbarItemOverflowBehavior.NeverOverflow);
202202
}
203203

204204
get overflowItems() {
@@ -216,7 +216,7 @@ class Toolbar extends UI5Element {
216216
}
217217

218218
get interactiveItems() {
219-
return this.items.filter((item: ToolbarItem) => item.isInteractive);
219+
return this.items.filter((item: ToolbarItemBase) => item.isInteractive);
220220
}
221221

222222
/**
@@ -264,7 +264,7 @@ class Toolbar extends UI5Element {
264264
}
265265

266266
get hasFlexibleSpacers() {
267-
return this.items.some((item: ToolbarItem) => item.hasFlexibleWidth);
267+
return this.items.some((item: ToolbarItemBase) => item.hasFlexibleWidth);
268268
}
269269

270270
/**
@@ -306,7 +306,7 @@ class Toolbar extends UI5Element {
306306
});
307307
}
308308

309-
addItemsAdditionalProperties(item: ToolbarItem) {
309+
addItemsAdditionalProperties(item: ToolbarItemBase) {
310310
item.isOverflowed = this.overflowItems.indexOf(item) !== -1;
311311
const itemWrapper = this.shadowRoot!.querySelector(`#${item._individualSlot}`) as HTMLElement;
312312
if (item.hasOverflow && !item.isOverflowed && itemWrapper) {
@@ -386,7 +386,7 @@ class Toolbar extends UI5Element {
386386
let totalWidth = 0,
387387
minWidth = 0;
388388

389-
this.items.forEach((item: ToolbarItem) => {
389+
this.items.forEach(item => {
390390
const itemWidth = this.getItemWidth(item);
391391
totalWidth += itemWidth;
392392
if (item.overflowPriority === ToolbarItemOverflowBehavior.NeverOverflow) {
@@ -437,7 +437,7 @@ class Toolbar extends UI5Element {
437437
}
438438

439439
distributeItemsThatAlwaysOverflow() {
440-
this.alwaysOverflowItems.forEach((item: ToolbarItem) => {
440+
this.alwaysOverflowItems.forEach((item: ToolbarItemBase) => {
441441
this.itemsToOverflow.push(item);
442442
});
443443
}
@@ -450,7 +450,7 @@ class Toolbar extends UI5Element {
450450
});
451451
}
452452

453-
shouldShowSeparatorInOverflow(separatorIdx: number, overflowItems: Array<ToolbarItem>) {
453+
shouldShowSeparatorInOverflow(separatorIdx: number, overflowItems: Array<ToolbarItemBase>) {
454454
let foundPrevNonSeparatorItem = false;
455455
let foundNextNonSeperatorItem = false;
456456

@@ -514,7 +514,7 @@ class Toolbar extends UI5Element {
514514
this.contentWidth = 0; // re-render
515515
}
516516

517-
getItemWidth(item: ToolbarItem): number {
517+
getItemWidth(item: ToolbarItemBase): number {
518518
// Spacer width - always 0 for flexible spacers, so that they shrink, otherwise - measure the width normally
519519
if (item.ignoreSpace || item.isSeparator) {
520520
return 0;

packages/main/src/ToolbarButton.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import property from "@ui5/webcomponents-base/dist/decorators/property.js";
44
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
55
import type { ButtonAccessibilityAttributes } from "./Button.js";
66
import type ButtonDesign from "./types/ButtonDesign.js";
7+
import type ToolbarItemOverflowBehavior from "./types/ToolbarItemOverflowBehavior.js";
78

8-
import ToolbarItem from "./ToolbarItem.js";
9+
import ToolbarItemBase from "./ToolbarItemBase.js";
10+
import type { ToolbarItemEventDetail } from "./ToolbarItemBase.js";
911
import ToolbarButtonTemplate from "./ToolbarButtonTemplate.js";
1012
import ToolbarButtonCss from "./generated/themes/ToolbarButton.css.js";
1113

@@ -22,7 +24,7 @@ type ToolbarButtonAccessibilityAttributes = ButtonAccessibilityAttributes;
2224
* `import "@ui5/webcomponents/dist/ToolbarButton.js";`
2325
* @constructor
2426
* @abstract
25-
* @extends ToolbarItem
27+
* @extends ToolbarItemBase
2628
* @public
2729
* @since 1.17.0
2830
*/
@@ -45,7 +47,37 @@ type ToolbarButtonAccessibilityAttributes = ButtonAccessibilityAttributes;
4547
bubbles: true,
4648
cancelable: true,
4749
})
48-
class ToolbarButton extends ToolbarItem {
50+
51+
/**
52+
* Fired when the overflow popover is closed.
53+
* @public
54+
*/
55+
@event("close-overflow", {
56+
bubbles: true,
57+
})
58+
class ToolbarButton extends ToolbarItemBase {
59+
eventDetails!: ToolbarItemBase["eventDetails"] & {
60+
click: ToolbarItemEventDetail,
61+
}
62+
63+
/**
64+
* Property used to define the access of the item to the overflow Popover. If "NeverOverflow" option is set,
65+
* the item never goes in the Popover, if "AlwaysOverflow" - it never comes out of it.
66+
* @public
67+
* @default "Default"
68+
*/
69+
@property()
70+
overflowPriority: `${ToolbarItemOverflowBehavior}` = "Default";
71+
72+
/**
73+
* Defines if the toolbar overflow popup should close upon interaction with the item.
74+
* It will close by default.
75+
* @default false
76+
* @public
77+
*/
78+
@property({ type: Boolean })
79+
preventOverflowClosing = false;
80+
4981
/**
5082
* Defines if the action is disabled.
5183
*

0 commit comments

Comments
 (0)