diff options
Diffstat (limited to 'web/src/components/grid')
| -rw-r--r-- | web/src/components/grid/index.ts | 11 | ||||
| -rw-r--r-- | web/src/components/grid/selection.ts | 5 |
2 files changed, 15 insertions, 1 deletions
diff --git a/web/src/components/grid/index.ts b/web/src/components/grid/index.ts index 78bb14e..3189409 100644 --- a/web/src/components/grid/index.ts +++ b/web/src/components/grid/index.ts @@ -12,7 +12,16 @@ import { extendSelection, GridSelection } from "./selection"; export class NotiveGridElement extends NotiveElement { #internals: ElementInternals = this.attachInternals(); - grid?: RenderedGrid; + #grid?: RenderedGrid; + + get grid(): RenderedGrid | undefined { + return this.#grid; + } + + set grid(grid: RenderedGrid | undefined) { + this.#grid = grid; + this.draw(); + } #selection?: GridSelection; diff --git a/web/src/components/grid/selection.ts b/web/src/components/grid/selection.ts index a24bbf5..517f8ae 100644 --- a/web/src/components/grid/selection.ts +++ b/web/src/components/grid/selection.ts @@ -1,4 +1,5 @@ import { CellRef, cellRefEquals } from "../../types"; +import { RenderedGrid } from "./renderGrid"; export type CellRange = [start: CellRef, end: CellRef]; @@ -21,3 +22,7 @@ export function extendSelection( return { ...selection, range: [selection.activeCellRef, cellRef] }; } + +export function getSelectionRange(selection: GridSelection): CellRange { + return selection.range ?? [selection.activeCellRef, selection.activeCellRef]; +} |
