UNPKG

@aibsweb/faceted-search

Version:
48 lines (43 loc) 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } /** * Pivot Cell Renderer: * Cell Renderer is a higher-order function that takes the label data as a dependency * and returns a function that accesses the label data for each cell for a row and column index. * The returned function is compatible with the React-Virtualized cellRenderer API. * See: https://github.com/bvaughn/react-virtualized/blob/master/docs/Grid.md#cellrenderer * * @param {Array} labels Array of an array of label strings * @param {String} textKey key to access text * @returns {Function} cellRenderer * @param {Object} * @param columnIndex - Horizontal (column) index of cell * @param isScrolling - The Grid is currently being scrolled * @param isVisible - This cell is visible within the grid (eg it is not an overscanned cell) * @param key - Unique key within array of cells * @param parent - Reference to the parent Grid (instance) * @param rowIndex - Vertical (row) index of cell * @param style - Style object to be applied to cell (to position it) */ var textCellRenderer = function textCellRenderer(data, textKey) { return function (_ref) { var columnIndex = _ref.columnIndex, key = _ref.key, rowIndex = _ref.rowIndex, style = _ref.style; return _react["default"].createElement("div", { key: key, className: "pivot-header__label", style: style }, _react["default"].createElement("div", { className: "pivot-header__label-text" }, data[rowIndex][columnIndex][textKey])); }; }; var _default = textCellRenderer; exports["default"] = _default;