src/dialog/overflow-menu/overflow-menu.component.ts
The OverFlow menu component encapsulates the OverFlowMenu directive, and the menu iconography into one convienent component.
Get started with importing the module:
Example :import { DialogModule } from 'carbon-components-angular';
<cds-overflow-menu>
<cds-overflow-menu-option>Option 1</cds-overflow-menu-option>
<cds-overflow-menu-option>Option 2</cds-overflow-menu-option>
</cds-overflow-menu>
encapsulation | ViewEncapsulation.None |
selector | cds-overflow-menu, ibm-overflow-menu |
styles |
.cds--overflow-menu--open {
opacity: 1
}
/*
Rotate the overflow menu container as well as the icon, since
we calculate our menu position based on the container, not the icon.
*/
.cds--data-table-v2 .cds--overflow-menu {
transform: rotate(90deg);
}
.cds--data-table-v2 .cds--overflow-menu__icon {
transform: rotate(180deg);
}
|
template |
|
Properties |
Methods |
Inputs |
Outputs |
constructor(elementRef: ElementRef, i18n: I18n)
|
|||||||||
Parameters :
|
buttonLabel | |
Type : any
|
|
Default value : this.i18n.get().OVERFLOW_MENU.OVERFLOW
|
|
customTrigger | |
Type : TemplateRef<any>
|
|
Sets the custom overflow menu trigger |
description | |
Type : any
|
|
Default value : this.i18n.get().OVERFLOW_MENU.ICON_DESCRIPTION
|
|
flip | |
Type : boolean
|
|
Default value : false
|
|
offset | |
Type : literal type
|
|
This specifies any vertical and horizontal offset for the position of the dialog |
open | |
Type : boolean
|
|
Default value : false
|
|
placement | |
Type : "bottom" | "top" | "bottom,top" | "top,bottom"
|
|
Default value : "bottom"
|
|
triggerClass | |
Type : string
|
|
Default value : ""
|
|
This appends additional classes to the overflow trigger/button. |
wrapperClass | |
Type : string
|
|
Default value : ""
|
|
align | |
Type : "top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "left-bottom" | "left-top" | "right" | "right-bottom" | "right-top"
|
|
Default value : "bottom"
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:32
|
|
Set popover alignment |
autoAlign | |
Type : boolean
|
|
Default value : false
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:40
|
|
Experimental: Use floating-ui to position the tooltip This is not toggleable - should be assigned once |
caret | |
Type : boolean
|
|
Default value : true
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:16
|
|
Set to |
dropShadow | |
Type : boolean
|
|
Default value : true
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:20
|
|
Set to |
enterDelayMs | |
Type : number
|
|
Default value : 100
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:44
|
|
Set delay before tooltip is shown |
highContrast | |
Type : boolean
|
|
Default value : true
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:24
|
|
Set to |
isOpen | |
Type : boolean
|
|
Default value : false
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:28
|
|
Set to |
leaveDelayMs | |
Type : number
|
|
Default value : 300
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:48
|
|
Set delay when tooltip disappears |
openChange | |
Type : EventEmitter
|
|
handleOpenChange | ||||||
handleOpenChange(event: boolean)
|
||||||
Parameters :
Returns :
void
|
overflowMenuDirective |
Type : OverflowMenuDirective
|
Decorators :
@ContentChild(OverflowMenuDirective)
|
import {
Component,
ContentChild,
ElementRef,
EventEmitter,
Input,
Output,
TemplateRef,
ViewEncapsulation
} from "@angular/core";
import { I18n } from "carbon-components-angular/i18n";
import { OverflowMenuDirective } from "./overflow-menu.directive";
import { BaseIconButton } from "carbon-components-angular/button";
/**
* The OverFlow menu component encapsulates the OverFlowMenu directive, and the menu iconography into one convienent component.
*
* Get started with importing the module:
*
* ```typescript
* import { DialogModule } from 'carbon-components-angular';
* ```
*
* ```html
* <cds-overflow-menu>
* <cds-overflow-menu-option>Option 1</cds-overflow-menu-option>
* <cds-overflow-menu-option>Option 2</cds-overflow-menu-option>
* </cds-overflow-menu>
* ```
*
* [See demo](../../?path=/story/components-overflow-menu--basic)
*/
@Component({
selector: "cds-overflow-menu, ibm-overflow-menu",
template: `
<cds-tooltip
class="cds--icon-tooltip"
[description]="description"
[caret]="caret"
[dropShadow]="dropShadow"
[highContrast]="highContrast"
[isOpen]="isOpen"
[align]="align"
[autoAlign]="autoAlign"
[enterDelayMs]="enterDelayMs"
[leaveDelayMs]="leaveDelayMs">
<button
cdsButton="ghost"
[cdsOverflowMenu]="options"
[ngClass]="{'cds--overflow-menu--open': open}"
class="cds--overflow-menu {{triggerClass}}"
[iconOnly]="true"
[attr.aria-label]="buttonLabel"
[flip]="flip"
[isOpen]="open"
(isOpenChange)="handleOpenChange($event)"
[offset]="offset"
[wrapperClass]="wrapperClass"
aria-haspopup="true"
type="button"
[placement]="placement">
<ng-template *ngIf="customTrigger; else defaultIcon" [ngTemplateOutlet]="customTrigger"></ng-template>
</button>
</cds-tooltip>
<ng-template #options>
<ng-content></ng-content>
</ng-template>
<ng-template #defaultIcon>
<svg cdsIcon="overflow-menu--vertical" size="16" class="cds--overflow-menu__icon"></svg>
</ng-template>
`,
styles: [`
.cds--overflow-menu--open {
opacity: 1
}
/*
Rotate the overflow menu container as well as the icon, since
we calculate our menu position based on the container, not the icon.
*/
.cds--data-table-v2 .cds--overflow-menu {
transform: rotate(90deg);
}
.cds--data-table-v2 .cds--overflow-menu__icon {
transform: rotate(180deg);
}
`],
encapsulation: ViewEncapsulation.None
})
export class OverflowMenu extends BaseIconButton {
@Input() buttonLabel = this.i18n.get().OVERFLOW_MENU.OVERFLOW;
@Input() description = this.i18n.get().OVERFLOW_MENU.ICON_DESCRIPTION;
@Input() flip = false;
@Input() placement: "bottom" | "top" | "bottom,top" | "top,bottom" = "bottom";
@Input() open = false;
@Output() openChange = new EventEmitter<boolean>();
/**
* Sets the custom overflow menu trigger
*/
@Input() customTrigger: TemplateRef<any>;
/**
* This specifies any vertical and horizontal offset for the position of the dialog
*/
@Input() offset: { x: number, y: number };
@Input() wrapperClass = "";
/**
* This appends additional classes to the overflow trigger/button.
*/
@Input() triggerClass = "";
@ContentChild(OverflowMenuDirective) overflowMenuDirective: OverflowMenuDirective;
constructor(protected elementRef: ElementRef, protected i18n: I18n) {
super();
}
handleOpenChange(event: boolean) {
this.open = event;
this.openChange.emit(event);
}
}
.cds--overflow-menu--open {
opacity: 1
}
/*
Rotate the overflow menu container as well as the icon, since
we calculate our menu position based on the container, not the icon.
*/
.cds--data-table-v2 .cds--overflow-menu {
transform: rotate(90deg);
}
.cds--data-table-v2 .cds--overflow-menu__icon {
transform: rotate(180deg);
}