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

Class GridCell

src/aria/grid/grid-cell.ts:48–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 providers: [{provide: GRID_CELL, useExisting: GridCell}],
47})
48export class GridCell implements OnInit, OnDestroy {
49 private readonly _elementRef = inject(ElementRef);
50 private readonly _renderer = inject(Renderer2);
51
52 /** A reference to the host element. */
53 readonly element = this._elementRef.nativeElement as HTMLElement;
54
55 /** Whether the cell is currently active (focused). */
56 readonly active = computed(() => this._pattern.active());
57
58 /** The widget contained within this cell, if any. */
59 private readonly _widget = contentChild(GridCellWidget, {descendants: true});
60
61 /** The UI pattern for the widget in this cell. */
62 private readonly _widgetPattern: Signal<GridCellWidgetPattern | undefined> = computed(
63 () => this._widget()?._pattern,
64 );
65
66 /** The parent row. */
67 private readonly _row = inject(GRID_ROW);
68
69 /** Text direction. */
70 readonly textDirection = inject(Directionality).valueSignal;
71
72 /** A unique identifier for the cell. */
73 readonly id = input(inject(_IdGenerator).getId('ng-grid-cell-', true));
74
75 /** The ARIA role for the cell. */
76 readonly role = input<'gridcell' | 'columnheader' | 'rowheader'>('gridcell');
77
78 /** The number of rows the cell should span. */
79 readonly rowSpan = input<number>(1);
80
81 /** The number of columns the cell should span. */
82 readonly colSpan = input<number>(1);
83
84 /** The index of this cell's row within the grid. */
85 readonly rowIndex = input<number>();
86
87 /** The index of this cell's column within the grid. */
88 readonly colIndex = input<number>();
89
90 /** Whether the cell is disabled. */
91 readonly disabled = input(false, {transform: booleanAttribute});
92
93 /** Whether the cell is selected. */
94 readonly selected = model<boolean>(false);
95
96 /** Whether the cell is selectable. */
97 readonly selectable = input<boolean>(true);
98
99 /** The tabindex override. */
100 readonly tabindex = input<number | undefined>();
101
102 /**
103 * The tabindex value set to the element.
104 * If a focus target exists then return -1. Unless an override.
105 */

Callers

nothing calls this directly

Implementers 1

GridCellPatternsrc/aria/private/grid/cell.ts

Calls 6

_getWidgetMethod · 0.95
computedFunction · 0.85
inputFunction · 0.85
activeMethod · 0.45
getIdMethod · 0.45
tabIndexMethod · 0.45

Tested by

no test coverage detected