1 |
- {"version":3,"sources":["../src/calculateCellHeight.js"],"names":["value","columnWidth","useWrapWord","_","isString","TypeError","Number","isInteger","Error","length","Math","ceil"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEA;;;;;;6BAMgBA,K,EAAOC,W,EAAaC,WAAW,GAAG,K,KAAU;AAC1D,MAAI,CAACC,gBAAEC,QAAF,CAAWJ,KAAX,CAAL,EAAwB;AACtB,UAAM,IAAIK,SAAJ,CAAc,yBAAd,CAAN;AACD;;AAED,MAAI,CAACC,MAAM,CAACC,SAAP,CAAiBN,WAAjB,CAAL,EAAoC;AAClC,UAAM,IAAII,SAAJ,CAAc,kCAAd,CAAN;AACD;;AAED,MAAIJ,WAAW,GAAG,CAAlB,EAAqB;AACnB,UAAM,IAAIO,KAAJ,CAAU,sCAAV,CAAN;AACD;;AAED,MAAIN,WAAJ,EAAiB;AACf,WAAO,uBAASF,KAAT,EAAgBC,WAAhB,EAA6BQ,MAApC;AACD;;AAED,SAAOC,IAAI,CAACC,IAAL,CAAU,0BAAYX,KAAZ,IAAqBC,WAA/B,CAAP;AACD,C","sourcesContent":["import _ from 'lodash';\nimport stringWidth from 'string-width';\nimport wrapWord from './wrapWord';\n\n/**\n * @param {string} value\n * @param {number} columnWidth\n * @param {boolean} useWrapWord\n * @returns {number}\n */\nexport default (value, columnWidth, useWrapWord = false) => {\n if (!_.isString(value)) {\n throw new TypeError('Value must be a string.');\n }\n\n if (!Number.isInteger(columnWidth)) {\n throw new TypeError('Column width must be an integer.');\n }\n\n if (columnWidth < 1) {\n throw new Error('Column width must be greater than 0.');\n }\n\n if (useWrapWord) {\n return wrapWord(value, columnWidth).length;\n }\n\n return Math.ceil(stringWidth(value) / columnWidth);\n};\n"],"file":"calculateCellHeight.js"}
|