MCPcopy Create free account
hub / github.com/angular/components / MenuItemPattern

Class MenuItemPattern

src/aria/private/menu/menu.ts:760–867  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

758
759/** The menu item ui pattern class. */
760export class MenuItemPattern<V> implements ListItem<V> {
761 /** The value of the menu item. */
762 readonly value: SignalLike<V>;
763
764 /** The unique ID of the menu item. */
765 readonly id: SignalLike<string>;
766
767 /** Whether the menu item is disabled. */
768 readonly disabled = () => this.inputs.parent()?.disabled() || this.inputs.disabled();
769
770 /** The search term for the menu item. */
771 readonly searchTerm: SignalLike<string>;
772
773 /** The element of the menu item. */
774 readonly element: SignalLike<HTMLElement | undefined>;
775
776 /** Whether the menu item is active. */
777 readonly active = computed(() => this.inputs.parent()?.inputs.activeItem() === this);
778
779 /** Whether the menu item has received interaction. */
780 readonly hasBeenInteracted = signal(false);
781
782 /** The tab index of the menu item. */
783 readonly tabIndex = computed(() => {
784 if (this.submenu() && this.submenu()?.inputs.activeItem()) {
785 return -1;
786 }
787 return this.inputs.parent()?.listBehavior.getItemTabindex(this) ?? -1;
788 });
789
790 /** The position of the menu item in the menu. */
791 readonly index = computed(() => this.inputs.parent()?.inputs.items().indexOf(this) ?? -1);
792
793 /** Whether the menu item is expanded. */
794 readonly expanded = computed(() => (this.submenu() ? this._expanded() : null));
795
796 /** Whether the menu item is expanded. */
797 readonly _expanded = signal(false);
798
799 /** The ID of the menu that the menu item controls. */
800 readonly controls = signal<string | undefined>(undefined);
801
802 /** The role of the menu item. */
803 readonly role = () => this.inputs.role();
804
805 /** Whether the menu item has a popup. */
806 readonly hasPopup = computed(() => !!this.submenu());
807
808 /** The submenu associated with the menu item. */
809 readonly submenu: SignalLike<MenuPattern<V> | undefined>;
810
811 /** Whether the menu item is selectable. */
812 readonly selectable: SignalLike<boolean>;
813
814 constructor(readonly inputs: MenuItemInputs<V>) {
815 this.id = inputs.id;
816 this.value = inputs.value;
817 this.element = inputs.element;

Callers

nothing calls this directly

Calls 7

computedFunction · 0.90
signalFunction · 0.90
parentMethod · 0.80
activeItemMethod · 0.80
disabledMethod · 0.45
getItemTabindexMethod · 0.45
roleMethod · 0.45

Tested by

no test coverage detected