dce-reactkit 4.1.2 → 4.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -3929,7 +3929,10 @@ const escapeCellText = (text) => {
3929
3929
  * Generate a CSV file
3930
3930
  * @author Gabe Abrams
3931
3931
  * @param data list of row data in the form of json objects
3932
- * @param columns list of columns to include in the csv
3932
+ * @param columns list of columns to include in the csv where each column is an object with:
3933
+ * - title: the column title
3934
+ * - param: the key in the data object to use for this column
3935
+ * - textIfUndefined: optional text to use if the value is undefined (defaults to empty string)
3933
3936
  * @returns multiline csv string
3934
3937
  */
3935
3938
  const genCSV = (data, columns) => {
@@ -3945,16 +3948,19 @@ const genCSV = (data, columns) => {
3945
3948
  csv += '\n';
3946
3949
  csv += (columns
3947
3950
  .map((column) => {
3951
+ var _a;
3948
3952
  let contents;
3949
3953
  const cell = datum[column.param];
3950
3954
  if (typeof cell === 'string'
3951
3955
  || typeof cell === 'number') {
3952
3956
  contents = String(cell);
3953
3957
  }
3954
- else if (typeof cell === 'undefined'
3955
- || cell === null) {
3958
+ else if (cell === null) {
3956
3959
  contents = '';
3957
3960
  }
3961
+ else if (typeof cell === 'undefined') {
3962
+ contents = ((_a = column.textIfUndefined) !== null && _a !== void 0 ? _a : '');
3963
+ }
3958
3964
  else if (typeof cell === 'object') {
3959
3965
  contents = JSON.stringify(cell);
3960
3966
  }