|
3 | 3 | CellRenderer, |
4 | 4 | DataGrid, |
5 | 5 | HyperlinkRenderer, |
6 | | - Private, |
7 | 6 | TextRenderer, |
8 | 7 | } from '@lumino/datagrid'; |
9 | 8 | import { Platform } from '@lumino/domutils'; |
@@ -75,7 +74,7 @@ export class MouseHandler extends BasicMouseHandler { |
75 | 74 | } |
76 | 75 | if (grid) { |
77 | 76 | // Create cell config object. |
78 | | - const config = Private.createCellConfigObject(grid, hit); |
| 77 | + const config = MouseHandler.createCellConfigObject(grid, hit); |
79 | 78 |
|
80 | 79 | // Bail if no cell config object is defined for the region. |
81 | 80 | if (!config) { |
@@ -138,6 +137,34 @@ export class MouseHandler extends BasicMouseHandler { |
138 | 137 | return this._cellClicked; |
139 | 138 | } |
140 | 139 |
|
| 140 | + /** |
| 141 | + * Creates a CellConfig object from a hit region. |
| 142 | + */ |
| 143 | + private static createCellConfigObject( |
| 144 | + grid: DataGrid, |
| 145 | + hit: DataGrid.HitTestResult |
| 146 | + ): CellRenderer.CellConfig | undefined { |
| 147 | + const { region, row, column } = hit; |
| 148 | + |
| 149 | + // Terminate call if region is void. |
| 150 | + if (region === 'void') { |
| 151 | + return undefined; |
| 152 | + } |
| 153 | + |
| 154 | + // Augment hit region params with value and metadata. |
| 155 | + const value = grid.dataModel!.data(region, row, column); |
| 156 | + const metadata = grid.dataModel!.metadata(region, row, column); |
| 157 | + |
| 158 | + // Create cell config object to retrieve cell renderer. |
| 159 | + const config = { |
| 160 | + ...hit, |
| 161 | + value: value, |
| 162 | + metadata: metadata |
| 163 | + } as CellRenderer.CellConfig; |
| 164 | + |
| 165 | + return config; |
| 166 | + } |
| 167 | + |
141 | 168 | private _grid: FeatherGrid; |
142 | 169 | private _mouseIsDown = false; |
143 | 170 | private _cellClicked = new Signal<this, DataGrid.HitTestResult>(this); |
|
0 commit comments