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

Class GridCellPattern

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

Source from the content-addressed store, hash-verified

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

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