File

src/dialog/overflow-menu/overflow-menu.directive.ts

Description

Directive for extending Dialog to create overflow menus.

class: OverflowMenuDirective (extends DialogDirective)

selector: cdsOverflowMenu

Example :
<div [cdsOverflowMenu]="templateRef"></div>
<ng-template #templateRef>
    <!-- overflow menu options here -->
</ng-template>
Example :
<div [cdsOverflowMenu]="templateRef" [customPane]="true"></div>
<ng-template #templateRef>
 <!-- custom content goes here -->
</ng-template>

Extends

DialogDirective

Metadata

Index

Properties
Methods
Inputs
Outputs
HostBindings
HostListeners
Accessors

Constructor

constructor(elementRef: ElementRef, viewContainerRef: ViewContainerRef, dialogService: DialogService, eventService: EventService)

Creates an instance of OverflowMenuDirective.

Parameters :
Name Type Optional
elementRef ElementRef No
viewContainerRef ViewContainerRef No
dialogService DialogService No
eventService EventService No

Inputs

cdsOverflowMenu
Type : TemplateRef<any>
customPane
Type : boolean
Default value : false

Set to true to for custom content

flip
Type : boolean
Default value : false

Controls wether the overflow menu is flipped

ibmOverflowMenu
Type : TemplateRef<any>
offset
Type : literal type
Inherited from DialogDirective
Defined in DialogDirective:63

This specifies any vertical and horizontal offset for the position of the dialog

wrapperClass
Type : string
Default value : ""
Inherited from DialogDirective
Defined in DialogDirective:67

Classes to add to the dialog container

appendInline
Type : boolean
Default value : false
Inherited from DialogDirective
Defined in DialogDirective:86

Set to true to open the dialog next to the triggering component

cdsDialog
Type : string | TemplateRef<any>
Inherited from DialogDirective
Defined in DialogDirective:52
closeTrigger
Type : "mouseout" | "mouseleave"
Default value : "mouseleave"
Inherited from DialogDirective
Defined in DialogDirective:66

Defines how the Dialog close event is triggered.

See here for more on the difference between mouseleave and mouseout.

Defaults to click when trigger is set to click.

data
Type : {}
Default value : {}
Inherited from DialogDirective
Defined in DialogDirective:90

Optional data for templates

disabled
Type : boolean
Default value : false
Inherited from DialogDirective
Defined in DialogDirective:96

This prevents the dialog from being toggled

gap
Type : number
Default value : 0
Inherited from DialogDirective
Defined in DialogDirective:82

Spacing between the dialog and it's triggering element

ibmDialog
Type : string | TemplateRef
Inherited from DialogDirective
Defined in DialogDirective:48
isOpen
Type : boolean
Default value : false
Inherited from DialogDirective
Defined in DialogDirective:92
placement
Type : string
Default value : "left"
Inherited from DialogDirective
Defined in DialogDirective:70

Placement of the dialog, usually relative to the element the directive is on.

shouldClose
Type : function
Inherited from DialogDirective

This input allows explicit control over how the dialog should close

title
Type : string
Default value : ""
Inherited from DialogDirective
Defined in DialogDirective:43

Title for the dialog

trigger
Type : "click" | "hover" | "mouseenter"
Default value : "click"
Inherited from DialogDirective
Defined in DialogDirective:57

Defines how the Dialog is triggered.(Hover and click behave the same on mobile - both respond to a single tap). Do not add focusable elements if trigger is hover or mouseenter.

Outputs

isOpenChange
Type : EventEmitter
Inherited from DialogDirective

Emits an event when the state of isOpen changes. Allows isOpen to be double bound

onClose
Type : EventEmitter<any>
Inherited from DialogDirective

Emits an event when the dialog is closed

onOpen
Type : EventEmitter<any>
Inherited from DialogDirective

Emits an event when the dialog is opened

HostBindings

attr.aria-haspopup
Type : boolean
Default value : true
Inherited from DialogDirective
attr.aria-owns
Type : string
Inherited from DialogDirective
attr.role
Type : string
Default value : "button"
Inherited from DialogDirective

HostListeners

keydown
Arguments : '$event'

Methods

hostkeys
hostkeys(event: KeyboardEvent)
Decorators :
@HostListener('keydown', ['$event'])
Parameters :
Name Type Optional
event KeyboardEvent No
Returns : void
open
open()
Inherited from DialogDirective
Returns : any
updateConfig
updateConfig()
Inherited from DialogDirective
Defined in DialogDirective:85
Returns : void
close
close(meta: CloseMeta)
Inherited from DialogDirective

Helper method to close the dialogRef.

Parameters :
Name Type Optional Default value
meta CloseMeta No { reason: CloseReasons.interaction }
Returns : void
ngOnChanges
ngOnChanges(changes: SimpleChanges)
Inherited from DialogDirective
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void
ngOnDestroy
ngOnDestroy()
Inherited from DialogDirective

When the host dies, kill the popover.

  • Useful for use in a modal or similar.
Returns : void
ngOnInit
ngOnInit()
Inherited from DialogDirective

Sets the config object and binds events for hovering or clicking before running code from child class.

Returns : void
Protected onDialogChanges
onDialogChanges(_changes: SimpleChanges)
Inherited from DialogDirective

Empty method for child to override and specify additional on changes steps. run after DialogDirective completes it's ngOnChanges.

Parameters :
Name Type Optional
_changes SimpleChanges No
Returns : void
Protected onDialogInit
onDialogInit()
Inherited from DialogDirective

Empty method for child classes to override and specify additional init steps. Run after DialogDirective completes it's ngOnInit.

Returns : void
toggle
toggle(meta: CloseMeta)
Inherited from DialogDirective

Helper method to toggle the open state of the dialog

Parameters :
Name Type Optional Default value
meta CloseMeta No { reason: CloseReasons.interaction }
Returns : void

Properties

dialogConfig
Type : DialogConfig
Inherited from DialogDirective

Config object passed to the rendered component

Static dialogCounter
Type : number
Default value : 0
Inherited from DialogDirective
Defined in DialogDirective:39
Protected dialogRef
Type : ComponentRef<Dialog>
Inherited from DialogDirective

Keeps a reference to the currently opened dialog

hasPopup
Default value : true
Decorators :
@HostBinding('attr.aria-haspopup')
Inherited from DialogDirective
role
Type : string
Default value : "button"
Decorators :
@HostBinding('attr.role')
Inherited from DialogDirective
Private subscriptions
Type : Subscription[]
Default value : []
Inherited from DialogDirective

Accessors

ibmOverflowMenu
setibmOverflowMenu(template: TemplateRef)

Takes a template ref of OverflowMenuOptionss

Parameters :
Name Type Optional
template TemplateRef<any> No
Returns : void
import {
	Directive,
	ElementRef,
	ViewContainerRef,
	Input,
	TemplateRef,
	HostListener
} from "@angular/core";
import { DialogDirective } from "../dialog.directive";
import { DialogService } from "../dialog.service";
import { OverflowMenuPane } from "./overflow-menu-pane.component";
import { OverflowMenuCustomPane } from "./overflow-menu-custom-pane.component";
import { EventService } from "carbon-components-angular/utils";


/**
 * Directive for extending `Dialog` to create overflow menus.
 *
 * class: OverflowMenuDirective (extends DialogDirective)
 *
 *
 * selector: `cdsOverflowMenu`
 *
 *
 * ```html
 * <div [cdsOverflowMenu]="templateRef"></div>
 * <ng-template #templateRef>
 * 	<!-- overflow menu options here -->
 * </ng-template>
 * ```
 *
 * ```html
 * <div [cdsOverflowMenu]="templateRef" [customPane]="true"></div>
 * <ng-template #templateRef>
 *  <!-- custom content goes here -->
 * </ng-template>
 * ```
 */
@Directive({
	selector: "[cdsOverflowMenu], [ibmOverflowMenu]",
	exportAs: "overflowMenu",
	providers: [
		DialogService
	]
})
export class OverflowMenuDirective extends DialogDirective {
	/**
	 * @deprecated as of v5
	 * Takes a template ref of `OverflowMenuOptions`s
	 */
	@Input() set ibmOverflowMenu(template: TemplateRef<any>) {
		this.cdsOverflowMenu = template;
	}

	@Input() cdsOverflowMenu: TemplateRef<any>;
	/**
	 * Controls wether the overflow menu is flipped
	 */
	@Input() flip = false;
	/**
	 * This specifies any vertical and horizontal offset for the position of the dialog
	 */
	@Input() offset: { x: number, y: number };
	/**
	 * Classes to add to the dialog container
	 */
	@Input() wrapperClass = "";
	/**
	 * Set to true to for custom content
	 */
	@Input() customPane = false;

	/**
	 * Creates an instance of `OverflowMenuDirective`.
	 */
	constructor(
		protected elementRef: ElementRef,
		protected viewContainerRef: ViewContainerRef,
		protected dialogService: DialogService,
		protected eventService: EventService
	) {
		super(elementRef, viewContainerRef, dialogService, eventService);
	}

	updateConfig() {
		this.dialogConfig.content = this.cdsOverflowMenu;
		this.dialogConfig.flip = this.flip;
		this.dialogConfig.offset = this.offset;
		this.dialogConfig.wrapperClass = this.wrapperClass;
	}

	@HostListener("keydown", ["$event"])
	hostkeys(event: KeyboardEvent) {
		switch (event.key) {
			case "Enter":
			case " ":
				event.preventDefault();
				break;
		}
	}

	open() {
		return super.open(this.customPane ? OverflowMenuCustomPane : OverflowMenuPane);
	}
}

results matching ""

    No results matching ""