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

Class GridCellPattern

src/aria/private/grid/cell.ts:42–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40
41/** The UI pattern for a grid cell. */
42export class GridCellPattern implements GridCell {
43 /** A unique identifier for the cell. */
44 readonly id: SignalLike<string> = () => this.inputs.id();
45
46 /** The html element that should receive focus. */
47 readonly element: SignalLike<HTMLElement> = () => this.inputs.element();
48
49 /** Whether the cell has focus. */
50 readonly isFocused: WritableSignalLike<boolean> = signal(false);
51
52 /** Whether the cell is selected. */
53 readonly selected: WritableSignalLike<boolean>;
54
55 /** Whether the cell is selectable. */
56 readonly selectable: SignalLike<boolean> = () => this.inputs.selectable();
57
58 /** Whether a cell is disabled. */
59 readonly disabled: SignalLike<boolean> = computed(
60 () => this.inputs.disabled() || (this.inputs.widget()?.inputs.disabled() ?? false),
61 );
62
63 /** The number of rows the cell should span. */
64 readonly rowSpan: SignalLike<number> = () => this.inputs.rowSpan();
65
66 /** The number of columns the cell should span. */
67 readonly colSpan: SignalLike<number> = () => this.inputs.colSpan();
68
69 /** Whether the cell is active. */
70 readonly active: SignalLike<boolean> = computed(() => this.inputs.grid().activeCell() === this);
71
72 /** Whether the cell is a selection anchor. */
73 readonly anchor: SignalLike<true | undefined> = computed(() =>
74 this.inputs.grid().anchorCell() === this ? true : undefined,
75 );
76
77 /** The `aria-selected` attribute for the cell. */
78 readonly ariaSelected: SignalLike<boolean | undefined> = computed(() =>
79 this.inputs.grid().inputs.enableSelection() && this.selectable() ? this.selected() : undefined,
80 );
81
82 /** The `aria-rowindex` attribute for the cell. */
83 readonly ariaRowIndex: SignalLike<number | undefined> = computed(
84 () =>
85 this.inputs.row().rowIndex() ??
86 this.inputs.rowIndex() ??
87 this.inputs.grid().gridBehavior.rowIndex(this),
88 );
89
90 /** The `aria-colindex` attribute for the cell. */
91 readonly ariaColIndex: SignalLike<number | undefined> = computed(
92 () => this.inputs.colIndex() ?? this.inputs.grid().gridBehavior.colIndex(this),
93 );
94
95 /** The internal tab index calculation for the cell. */
96 private readonly _tabIndex: SignalLike<-1 | 0> = computed(() =>
97 this.inputs.grid().gridBehavior.cellTabIndex(this),
98 );
99

Callers

nothing calls this directly

Calls 11

signalFunction · 0.90
computedFunction · 0.90
rowIndexMethod · 0.80
colIndexMethod · 0.80
cellTabIndexMethod · 0.80
idMethod · 0.45
elementMethod · 0.45
selectableMethod · 0.45
disabledMethod · 0.45
selectedMethod · 0.45
isActivatedMethod · 0.45

Tested by

no test coverage detected