File

src/dialog/overflow-menu/overflow-menu-custom-pane.component.ts

Deprecated

as of v5 Use Toggletip or Popover components instead

Description

Use Toggletip or Popover components instead

Extends

Dialog

Implements

AfterViewInit

Metadata

Index

Properties
Methods
Inputs
Outputs
HostListeners

Constructor

constructor(elementRef: ElementRef, i18n: I18n, animationFrameService: AnimationFrameService, elementService: ElementService)
Parameters :
Name Type Optional
elementRef ElementRef No
i18n I18n No
animationFrameService AnimationFrameService No
elementService ElementService No

Inputs

dialogConfig
Type : DialogConfig
Inherited from Dialog
Defined in Dialog:41

Receives DialogConfig interface object with properties of Dialog explicitly defined.

Outputs

close
Type : EventEmitter<CloseMeta>
Inherited from Dialog
Defined in Dialog:36

Emits event that handles the closing of a Dialog object.

HostListeners

document:click
Arguments : '$event'
document:click(event)
Inherited from Dialog
Defined in Dialog:229

Sets up a event Listener to close Dialog if click event occurs outside Dialog object.

Parameters :
Name Optional
event No
keydown
Arguments : '$event'
keydown(event: KeyboardEvent)
Inherited from Dialog
Defined in Dialog:206

Sets up a KeyboardEvent to close Dialog with Escape key.

Parameters :
Name Optional
event No

Methods

onClick
onClick(event)
Parameters :
Name Optional
event No
Returns : void
onDialogInit
onDialogInit()
Inherited from Dialog
Defined in Dialog:51
Returns : void
afterDialogViewInit
afterDialogViewInit()
Inherited from Dialog
Defined in Dialog:157

Empty method to be overridden by consuming classes to run any additional initialization code after the view is available. NOTE: this does not guarantee the dialog will be positioned, simply that it will exist in the DOM

Returns : void
clickClose
clickClose(event)
Decorators :
@HostListener('document:click', ['$event'])
Inherited from Dialog
Defined in Dialog:229

Sets up a event Listener to close Dialog if click event occurs outside Dialog object.

Parameters :
Name Optional
event No
Returns : void
Public doClose
doClose(meta: CloseMeta)
Inherited from Dialog
Defined in Dialog:242

Closes Dialog object by emitting the close event upwards to parents.

Parameters :
Name Type Optional Default value
meta CloseMeta No { reason: CloseReasons.interaction }
Returns : void
escapeClose
escapeClose(event: KeyboardEvent)
Decorators :
@HostListener('keydown', ['$event'])
Inherited from Dialog
Defined in Dialog:206

Sets up a KeyboardEvent to close Dialog with Escape key.

Parameters :
Name Type Optional
event KeyboardEvent No
Returns : void
ngAfterViewInit
ngAfterViewInit()
Inherited from Dialog
Defined in Dialog:105

After the DOM is ready, focus is set and dialog is placed in respect to the parent element.

Returns : void
ngOnDestroy
ngOnDestroy()
Inherited from Dialog
Defined in Dialog:249

At destruction of component, Dialog unsubscribes from all the subscriptions.

Returns : void
ngOnInit
ngOnInit()
Inherited from Dialog
Defined in Dialog:93

Initialize the Dialog, set the placement and gap, and add a Subscription to resize events.

Returns : void
placeDialog
placeDialog()
Inherited from Dialog
Defined in Dialog:162

Uses the position service to position the Dialog in screen space

Returns : void

Properties

Protected addGap
Type : object
Default value : { "left": pos => position.addOffset(pos, 0, -this.dialogConfig.gap), "right": pos => position.addOffset(pos, 0, this.dialogConfig.gap), "top": pos => position.addOffset(pos, -this.dialogConfig.gap), "bottom": pos => position.addOffset(pos, this.dialogConfig.gap), "left-bottom": pos => position.addOffset(pos, 0, -this.dialogConfig.gap), "right-bottom": pos => position.addOffset(pos, 0, this.dialogConfig.gap) }
Inherited from Dialog
Defined in Dialog:65

Handles offsetting the Dialog item based on the defined position to not obscure the content beneath.

Protected animationFrameSubscription
Default value : new Subscription()
Inherited from Dialog
Defined in Dialog:59
Public data
Type : object
Default value : {}
Inherited from Dialog
Defined in Dialog:50

Stores the data received from dialogConfig.

dialog
Type : ElementRef
Decorators :
@ViewChild('dialog')
Inherited from Dialog
Defined in Dialog:45

Maintains a reference to the view DOM element of the Dialog.

Public placement
Type : string
Inherited from Dialog
Defined in Dialog:55

The placement of the Dialog is received from the Position service.

Protected placements
Type : Positions
Default value : {}
Inherited from Dialog
Defined in Dialog:77

Extra placements. Child classes can add to this for use in placeDialog.

Protected visibilitySubscription
Default value : new Subscription()
Inherited from Dialog
Defined in Dialog:57
import { AfterViewInit, Component, ElementRef, Optional } from "@angular/core";
import { position } from "@carbon/utils-position";
import { I18n } from "carbon-components-angular/i18n";
import { AnimationFrameService, ElementService } from "carbon-components-angular/utils";
import { closestAttr } from "carbon-components-angular/utils";
import { CloseReasons } from "../dialog-config.interface";
import { Dialog } from "../dialog.component";

/**
 * @deprecated as of v5
 * Use Toggletip or Popover components instead
 */
@Component({
	selector: "cds-overflow-custom-menu-pane, ibm-overflow-custom-menu-pane",
	template: `
		<div
			[attr.id]="dialogConfig.compID"
			[attr.aria-label]="dialogConfig.menuLabel"
			[attr.data-floating-menu-direction]="placement ? placement : null"
			[ngClass]="{'cds--overflow-menu--flip': dialogConfig.flip}"
			class="cds--overflow-menu-options cds--overflow-menu-options--open"
			role="menu"
			(click)="onClick($event)"
			#dialog
			[attr.aria-label]="dialogConfig.menuLabel">
			<ng-template
				[ngTemplateOutlet]="dialogConfig.content"
				[ngTemplateOutletContext]="{overflowMenu: this}">
			</ng-template>
		</div>
	`
})
export class OverflowMenuCustomPane extends Dialog implements AfterViewInit {
	constructor(
		protected elementRef: ElementRef,
		protected i18n: I18n,
		@Optional() protected animationFrameService: AnimationFrameService = null,
		// mark `elementService` as optional since making it mandatory would be a breaking change
		@Optional() protected elementService: ElementService = null
	) {
		super(elementRef, elementService, animationFrameService);
	}

	onClick(event) {
		this.doClose({
			reason: CloseReasons.interaction,
			target: event.target
		});
	}

	onDialogInit() {
		const positionOverflowMenu = pos => {
			let offset;
			/*
			* 20 is half the width of the overflow menu trigger element.
			* we also move the element by half of it's own width, since
			* position service will try and center everything
			*/
			const closestRel = closestAttr("position", ["relative", "fixed", "absolute"], this.elementRef.nativeElement);
			const topFix = closestRel ? closestRel.getBoundingClientRect().top * -1 : 0;
			const leftFix = closestRel ? closestRel.getBoundingClientRect().left * -1 : 0;

			offset = Math.round(this.dialog.nativeElement.offsetWidth / 2) - 20;
			if (this.dialogConfig.flip) {
				return position.addOffset(pos, topFix, (-offset + leftFix));
			}
			return position.addOffset(pos, topFix, (offset + leftFix));
		};

		this.addGap["bottom"] = positionOverflowMenu;

		this.addGap["top"] = positionOverflowMenu;

		if (!this.dialogConfig.menuLabel) {
			this.dialogConfig.menuLabel = this.i18n.get().OVERFLOW_MENU.OVERFLOW;
		}
	}
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""