import { Component, signal } from '@angular/core'; import { RouterLink } from '@angular/router'; import { ActionMenuComponent, ActionMenuTriggerDirective, type AfricaniesMenuItem, ButtonComponent, } from '@africanies/africanies-ui'; import { DemoSectionComponent } from '../shared/demo-section.component'; import { PageHeaderComponent } from '../shared/page-header.component'; import { ACTION_MENU_CUSTOM, ACTION_MENU_DEFAULT, ACTION_MENU_DISABLED, ACTION_MENU_VARIANTS, } from '../snippets'; /** * */ @Component({ selector: 'app-action-menu-page', standalone: true, imports: [ ActionMenuComponent, ActionMenuTriggerDirective, ButtonComponent, PageHeaderComponent, DemoSectionComponent, RouterLink, ], template: `

Overflow (…) menu for row and toolbar actions that do not deserve a full button. Uses a CDK overlay so it is not clipped by table overflow. Default ellipsis trigger, or point africaniesActionMenuTrigger at your own control.

Last action: {{ lastAction() ?? '—' }}

`, }) export class ActionMenuPage { protected readonly lastAction = signal(null); protected readonly demoItems: AfricaniesMenuItem[] = [ { label: 'Open', icon: 'eye', onClick: () => this.lastAction.set('Open'), }, { label: 'Edit', icon: 'edit', onClick: () => this.lastAction.set('Edit'), }, { label: 'Copy reference', icon: 'copy', onClick: () => this.lastAction.set('Copy reference'), }, { label: 'Delete', icon: 'trash', danger: true, dividerBefore: true, onClick: () => this.lastAction.set('Delete'), }, ]; protected readonly variantItems: AfricaniesMenuItem[] = [ { label: 'Download PDF', icon: 'download', onClick: () => undefined, }, { label: 'Archive', disabled: true, onClick: () => undefined, }, { label: 'Void shipment', icon: 'trash', danger: true, dividerBefore: true, onClick: () => undefined, }, ]; protected readonly defaultCode = ACTION_MENU_DEFAULT; protected readonly customCode = ACTION_MENU_CUSTOM; protected readonly variantsCode = ACTION_MENU_VARIANTS; protected readonly disabledCode = ACTION_MENU_DISABLED; }