Skip to content

Commit 406df23

Browse files
committed
feat(aria/grid): Extend public api with navigation/selection methods
1 parent 4d55040 commit 406df23

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
@@ -89,6 +89,89 @@ export class Grid {
8989
afterRenderEffect(() => this._pattern.focusEffect());
9090
}
9191

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

0 commit comments

Comments
 (0)