MCPcopy Index your code
hub / github.com/angular/components / MenuItemPattern

Class MenuItemPattern

src/aria/private/menu/menu.ts:759–866  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…