Skip to content

Commit d479484

Browse files
committed
feat(aria/grid): Extend public api with navigation/selection methods
1 parent ecd9039 commit d479484

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

src/aria/grid/grid.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,89 @@ export class Grid {
8585
afterRenderEffect(() => this._pattern.focusEffect());
8686
}
8787

88+
/** Navigates to the cell above the currently active cell. */
89+
up(): boolean {
90+
return this._pattern.gridBehavior.up();
91+
}
92+
93+
/** Navigates to the cell below the currently active cell. */
94+
down(): boolean {
95+
return this._pattern.gridBehavior.down();
96+
}
97+
98+
/** Navigates to the cell to the left of the currently active cell. */
99+
left(): boolean {
100+
return this._pattern.gridBehavior.left();
101+
}
102+
103+
/** Navigates to the cell to the right of the currently active cell. */
104+
right(): boolean {
105+
return this._pattern.gridBehavior.right();
106+
}
107+
108+
/** Navigates to the first focusable cell in the current row. */
109+
firstInRow(): boolean {
110+
return this._pattern.gridBehavior.firstInRow();
111+
}
112+
113+
/** Navigates to the last focusable cell in the current row. */
114+
lastInRow(): boolean {
115+
return this._pattern.gridBehavior.lastInRow();
116+
}
117+
118+
/** Navigates to the first focusable cell in the grid. */
119+
first(): boolean {
120+
return this._pattern.gridBehavior.first();
121+
}
122+
123+
/** Navigates to the last focusable cell in the grid. */
124+
last(): boolean {
125+
return this._pattern.gridBehavior.last();
126+
}
127+
128+
/** Extends the selection to the cell above the selection anchor. */
129+
rangeSelectUp(): void {
130+
if (this._pattern.inputs.enableSelection()) {
131+
this._pattern.gridBehavior.rangeSelectUp();
132+
}
133+
}
134+
135+
/** Extends the selection to the cell below the selection anchor. */
136+
rangeSelectDown(): void {
137+
if (this._pattern.inputs.enableSelection()) {
138+
this._pattern.gridBehavior.rangeSelectDown();
139+
}
140+
}
141+
142+
/** Extends the selection to the cell to the left of the selection anchor. */
143+
rangeSelectLeft(): void {
144+
if (this._pattern.inputs.enableSelection()) {
145+
this._pattern.gridBehavior.rangeSelectLeft();
146+
}
147+
}
148+
149+
/** Extends the selection to the cell to the right of the selection anchor. */
150+
rangeSelectRight(): void {
151+
if (this._pattern.inputs.enableSelection()) {
152+
this._pattern.gridBehavior.rangeSelectRight();
153+
}
154+
}
155+
156+
/** Selects all selectable cells in the grid. */
157+
selectAll(): void {
158+
this._pattern.gridBehavior.selectAll();
159+
}
160+
161+
/** Selects all cells in the current row. */
162+
selectRow(): void {
163+
this._pattern.gridBehavior.selectRow();
164+
}
165+
166+
/** Selects all cells in the current column. */
167+
selectCol(): void {
168+
this._pattern.gridBehavior.selectCol();
169+
}
170+
88171
/** Gets the cell pattern for a given element. */
89172
private _getCell(element: Element): GridCellPattern | undefined {
90173
const cellElement = element.closest('[ngGridCell]');

0 commit comments

Comments
 (0)