Skip to content

feat(cdk-experimental/ui-patterns): add grid selection behavior #31320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class GridFocus<T extends GridFocusCell> {
}

/** Finds the top-left anchor coordinates of a given cell instance in the grid. */
getCoordinates(cellToFind: T): RowCol | void {
getCoordinates(cellToFind: T): RowCol | undefined {
const grid = this.inputs.cells();
const occupiedCells = new Set<string>();

Expand Down Expand Up @@ -203,10 +203,12 @@ export class GridFocus<T extends GridFocusCell> {
colindex += colspan;
}
}

return undefined;
}

/** Gets the cell that covers the given coordinates, considering rowspan and colspan. */
getCell(coords: RowCol): T | void {
getCell(coords: RowCol): T | undefined {
for (const row of this.inputs.cells()) {
for (const cell of row) {
if (
Expand All @@ -219,5 +221,6 @@ export class GridFocus<T extends GridFocusCell> {
}
}
}
return undefined;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load("//tools:defaults.bzl", "ng_web_test_suite", "ts_project")

package(default_visibility = ["//visibility:public"])

ts_project(
name = "grid-selection",
srcs = ["grid-selection.ts"],
deps = [
"//:node_modules/@angular/core",
"//src/cdk-experimental/ui-patterns/behaviors/grid-focus",
"//src/cdk-experimental/ui-patterns/behaviors/signal-like",
],
)

ts_project(
name = "unit_test_sources",
testonly = True,
srcs = ["grid-selection.spec.ts"],
deps = [
":grid-selection",
"//:node_modules/@angular/core",
],
)

ng_web_test_suite(
name = "unit_tests",
deps = [":unit_test_sources"],
)
Loading
Loading