import type { CellContext, DrawCellInfo, GridCanvasHelperAPI, } from "../../ts-types"; import type { GridInternal } from "../../ts-types-internal"; import { BaseColumn } from "./BaseColumn"; import { CheckStyle } from "../style/CheckStyle"; import { CHECK_COLUMN_STATE_ID } from "../../internal/symbolManager"; import { toBoolean } from "../utils"; export class CheckColumn extends BaseColumn { get StyleClass(): typeof CheckStyle { return CheckStyle; } clone(): CheckColumn { return new CheckColumn(this); } convertInternal(value: unknown): boolean { return toBoolean(value); } drawInternal( value: boolean, context: CellContext, style: CheckStyle, helper: GridCanvasHelperAPI, grid: GridInternal, { drawCellBase }: DrawCellInfo ): void { const { textAlign, textBaseline, padding, borderColor, checkBgColor, uncheckBgColor, bgColor, visibility, } = style; if (bgColor) { drawCellBase({ bgColor, }); } if (visibility === "hidden") { return; } const { col, row } = context; const range = grid.getCellRange(col, row); const cellKey = `${range.start.col}:${range.start.row}`; const elapsed = grid[CHECK_COLUMN_STATE_ID]?.elapsed[cellKey]; const opt: Parameters[2] = { textAlign, textBaseline, borderColor, checkBgColor, uncheckBgColor, padding, }; if (elapsed != null) { opt.animElapsedTime = elapsed; } helper.checkbox(value, context, opt); } }