dce-reactkit 4.1.1 → 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.
@@ -2,7 +2,10 @@
2
2
  * Generate a CSV file
3
3
  * @author Gabe Abrams
4
4
  * @param data list of row data in the form of json objects
5
- * @param columns list of columns to include in the csv
5
+ * @param columns list of columns to include in the csv where each column is an object with:
6
+ * - title: the column title
7
+ * - param: the key in the data object to use for this column
8
+ * - textIfUndefined: optional text to use if the value is undefined (defaults to empty string)
6
9
  * @returns multiline csv string
7
10
  */
8
11
  declare const genCSV: (data: {
@@ -10,5 +13,6 @@ declare const genCSV: (data: {
10
13
  }[], columns: {
11
14
  title: string;
12
15
  param: string;
16
+ textIfUndefined?: string;
13
17
  }[]) => string;
14
18
  export default genCSV;
@@ -4,7 +4,7 @@
4
4
  * @author Gabe Abrams
5
5
  * @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
6
6
  * @returns object with timestamp (ms since epoch) and numbers
7
- * corresponding to ET time values for year, month, day, hour, hour12, minute, isPM
7
+ * corresponding to ET time values for year, month, day, hour, hour12, minute, second, isPM
8
8
  * where hour is in 24hr time and hour12 is in 12hr time.
9
9
  */
10
10
  declare const getTimeInfoInET: (dateOrTimestamp?: Date | number) => {
@@ -15,6 +15,7 @@ declare const getTimeInfoInET: (dateOrTimestamp?: Date | number) => {
15
15
  hour: number;
16
16
  hour12: number;
17
17
  minute: number;
18
+ second: number;
18
19
  isPM: boolean;
19
20
  };
20
21
  export default getTimeInfoInET;
package/dist/esm/index.js CHANGED
@@ -2571,7 +2571,7 @@ const getMonthName = (month) => {
2571
2571
  * @author Gabe Abrams
2572
2572
  * @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
2573
2573
  * @returns object with timestamp (ms since epoch) and numbers
2574
- * corresponding to ET time values for year, month, day, hour, hour12, minute, isPM
2574
+ * corresponding to ET time values for year, month, day, hour, hour12, minute, second, isPM
2575
2575
  * where hour is in 24hr time and hour12 is in 12hr time.
2576
2576
  */
2577
2577
  const getTimeInfoInET = (dateOrTimestamp) => {
@@ -2601,6 +2601,9 @@ const getTimeInfoInET = (dateOrTimestamp) => {
2601
2601
  const month = Number.parseInt(monthStr, 10);
2602
2602
  const day = Number.parseInt(dayStr, 10);
2603
2603
  const minute = Number.parseInt(minStr, 10);
2604
+ const second = (ending.split(' ')[0]
2605
+ ? Number.parseInt(ending.split(' ')[0], 10)
2606
+ : 0);
2604
2607
  const hour12 = Number.parseInt(hourStr, 10);
2605
2608
  // Convert from am/pm to 24hr
2606
2609
  const isAM = ending.toLowerCase().includes('am');
@@ -2622,6 +2625,7 @@ const getTimeInfoInET = (dateOrTimestamp) => {
2622
2625
  hour12,
2623
2626
  isPM,
2624
2627
  minute,
2628
+ second,
2625
2629
  };
2626
2630
  };
2627
2631
 
@@ -3898,7 +3902,10 @@ const escapeCellText = (text) => {
3898
3902
  * Generate a CSV file
3899
3903
  * @author Gabe Abrams
3900
3904
  * @param data list of row data in the form of json objects
3901
- * @param columns list of columns to include in the csv
3905
+ * @param columns list of columns to include in the csv where each column is an object with:
3906
+ * - title: the column title
3907
+ * - param: the key in the data object to use for this column
3908
+ * - textIfUndefined: optional text to use if the value is undefined (defaults to empty string)
3902
3909
  * @returns multiline csv string
3903
3910
  */
3904
3911
  const genCSV = (data, columns) => {
@@ -3914,16 +3921,19 @@ const genCSV = (data, columns) => {
3914
3921
  csv += '\n';
3915
3922
  csv += (columns
3916
3923
  .map((column) => {
3924
+ var _a;
3917
3925
  let contents;
3918
3926
  const cell = datum[column.param];
3919
3927
  if (typeof cell === 'string'
3920
3928
  || typeof cell === 'number') {
3921
3929
  contents = String(cell);
3922
3930
  }
3923
- else if (typeof cell === 'undefined'
3924
- || cell === null) {
3931
+ else if (cell === null) {
3925
3932
  contents = '';
3926
3933
  }
3934
+ else if (typeof cell === 'undefined') {
3935
+ contents = ((_a = column.textIfUndefined) !== null && _a !== void 0 ? _a : '');
3936
+ }
3927
3937
  else if (typeof cell === 'object') {
3928
3938
  contents = JSON.stringify(cell);
3929
3939
  }