UNPKG

handsontable

Version:

Handsontable is a JavaScript Data Grid available for React, Angular and Vue.

26 lines (25 loc) 838 B
"use strict"; exports.__esModule = true; exports.valueSetter = valueSetter; var _mixed = require("../../../helpers/mixed"); /** * Defines what value is set to a checkbox-typed cell. * * @param {*} newValue The value to be set. * @param {number} row The row index. * @param {number} column The column index. * @returns {*} The new value to be set. */ function valueSetter(newValue, row, column) { const { checkedTemplate, uncheckedTemplate } = this.getCellMeta(row, column); const stringifiedValue = (0, _mixed.stringify)(newValue); const isChecked = stringifiedValue === (0, _mixed.stringify)(checkedTemplate); const isUnchecked = stringifiedValue === (0, _mixed.stringify)(uncheckedTemplate); if (isChecked || isUnchecked) { return isChecked ? checkedTemplate : uncheckedTemplate; } return newValue; }