UNPKG

handsontable

Version:

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

40 lines (37 loc) 1.4 kB
"use strict"; exports.__esModule = true; exports.passwordRenderer = passwordRenderer; exports.valueFormatter = valueFormatter; var _element = require("../../helpers/dom/element"); var _mixed = require("../../helpers/mixed"); const RENDERER_TYPE = exports.RENDERER_TYPE = 'password'; /** * Formats the value using the password format. * * @param {*} value Value to be formatted. * @param {CellMeta} cellProperties Cell meta object. * @returns {*} Returns the formatted value. */ function valueFormatter(value, cellProperties) { const hashLength = cellProperties.hashLength || (0, _mixed.stringify)(value).length; const hashSymbol = cellProperties.hashSymbol || '*'; let hash = ''; for (let i = 0; i < hashLength; i++) { hash += hashSymbol; } return hash; } /** * @private * @param {Core} hotInstance The Handsontable instance. * @param {HTMLTableCellElement} TD The rendered cell element. * @param {number} row The visual row index. * @param {number} col The visual column index. * @param {number|string} prop The column property (passed when datasource is an array of objects). * @param {*} value The rendered value. */ function passwordRenderer(hotInstance, TD, row, col, prop, value) { (0, _element.fastInnerHTML)(TD, value, hotInstance.getSettings().sanitizer); } passwordRenderer.valueFormatter = valueFormatter; passwordRenderer.RENDERER_TYPE = RENDERER_TYPE;