Sha256: 62eeba70080f425684ba3e8cf7ea0d755934b2693aa915e4fcf00d0874ec9259

Contents?: true

Size: 902 Bytes

Versions: 23

Compression:

Stored size: 902 Bytes

Contents

import _ from 'lodash';
import wrapCell from './wrapCell';

/**
 * @param {Array} unmappedRows
 * @param {number[]} rowHeightIndex
 * @param {Object} config
 * @returns {Array}
 */
export default (unmappedRows, rowHeightIndex, config) => {
  const tableWidth = unmappedRows[0].length;

  const mappedRows = unmappedRows.map((cells, index0) => {
    const rowHeight = _.times(rowHeightIndex[index0], () => {
      return new Array(tableWidth).fill('');
    });

    // rowHeight
    //     [{row index within rowSaw; index2}]
    //     [{cell index within a virtual row; index1}]

    cells.forEach((value, index1) => {
      const cellLines = wrapCell(value, config.columns[index1].width, config.columns[index1].wrapWord);

      cellLines.forEach((cellLine, index2) => {
        rowHeight[index2][index1] = cellLine;
      });
    });

    return rowHeight;
  });

  return _.flatten(mappedRows);
};

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
trusty-cms-5.0.7 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-5.0.6 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-5.0.5 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-5.0.4 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-5.0.3 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-5.0.2 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-5.0.1 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.3.5 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-5.0.0 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.3.4 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.3.3 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.3.2 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.3.1 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.3 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.2.3 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.2.2 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.2.1 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.2 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.1.9 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow
trusty-cms-4.1.8 node_modules/table/dist/mapDataUsingRowHeightIndex.js.flow