@tomino/dynamic-form-semantic-ui
Version:
Semantic UI form renderer based on dynamic form generation
40 lines • 1.27 kB
JavaScript
import { observable, action } from 'mobx';
export class CellHighlighter {
constructor(rows = 1, columns = 1) {
this.lastHightLight = [];
this.highlightMultiple = action((cells) => {
for (let cell of cells) {
this.grid[cell.row][cell.column] = cell.className;
this.lastHightLight.push([cell.row, cell.column]);
}
});
this.grid = [];
this.lastHightLight = [];
for (let i = 1; i <= rows; i++) {
let row = {};
for (let j = 1; j <= columns; j++) {
row[j] = '';
}
this.grid[i] = observable(row);
}
}
clearHighlight() {
for (let cell of this.lastHightLight) {
this.grid[cell[0]][cell[1]] = '';
}
this.lastHightLight = [];
}
highlight(row = 1, column = 1, className = '', width = 1) {
if (row === '' || column === '') {
return;
}
for (let i = 0; i < width; i++) {
this.grid[row][column + i] = className;
this.lastHightLight.push([row, column + i]);
}
}
find(row = 1, column = 1) {
return this.grid[row][column];
}
}
//# sourceMappingURL=cell_highlighter.js.map