Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

35 rindas
926 B

pirms 4 gadiem
  1. import _ from 'lodash';
  2. import calculateCellHeight from './calculateCellHeight';
  3. /**
  4. * Calculates the vertical row span index.
  5. *
  6. * @param {Array[]} rows
  7. * @param {Object} config
  8. * @returns {number[]}
  9. */
  10. export default (rows, config) => {
  11. const tableWidth = rows[0].length;
  12. const rowSpanIndex = [];
  13. rows.forEach((cells) => {
  14. const cellHeightIndex = new Array(tableWidth).fill(1);
  15. cells.forEach((value, index1) => {
  16. if (!_.isNumber(config.columns[index1].width)) {
  17. throw new TypeError('column[index].width must be a number.');
  18. }
  19. if (!_.isBoolean(config.columns[index1].wrapWord)) {
  20. throw new TypeError('column[index].wrapWord must be a boolean.');
  21. }
  22. cellHeightIndex[index1] = calculateCellHeight(value, config.columns[index1].width, config.columns[index1].wrapWord);
  23. });
  24. rowSpanIndex.push(_.max(cellHeightIndex));
  25. });
  26. return rowSpanIndex;
  27. };