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.
- package/dist/cjs/index.js +14 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/genCSV.d.ts +5 -1
- package/dist/cjs/types/helpers/getTimeInfoInET.d.ts +2 -1
- package/dist/esm/index.js +14 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/genCSV.d.ts +5 -1
- package/dist/esm/types/helpers/getTimeInfoInET.d.ts +2 -1
- package/dist/index.d.ts +7 -2
- package/package.json +1 -1
- package/src/helpers/genCSV.test.ts +18 -4
- package/src/helpers/genCSV.ts +11 -5
- package/src/helpers/getTimeInfoInET.ts +8 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2598,7 +2598,7 @@ const getMonthName = (month) => {
|
|
|
2598
2598
|
* @author Gabe Abrams
|
|
2599
2599
|
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
2600
2600
|
* @returns object with timestamp (ms since epoch) and numbers
|
|
2601
|
-
* corresponding to ET time values for year, month, day, hour, hour12, minute, isPM
|
|
2601
|
+
* corresponding to ET time values for year, month, day, hour, hour12, minute, second, isPM
|
|
2602
2602
|
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
2603
2603
|
*/
|
|
2604
2604
|
const getTimeInfoInET = (dateOrTimestamp) => {
|
|
@@ -2628,6 +2628,9 @@ const getTimeInfoInET = (dateOrTimestamp) => {
|
|
|
2628
2628
|
const month = Number.parseInt(monthStr, 10);
|
|
2629
2629
|
const day = Number.parseInt(dayStr, 10);
|
|
2630
2630
|
const minute = Number.parseInt(minStr, 10);
|
|
2631
|
+
const second = (ending.split(' ')[0]
|
|
2632
|
+
? Number.parseInt(ending.split(' ')[0], 10)
|
|
2633
|
+
: 0);
|
|
2631
2634
|
const hour12 = Number.parseInt(hourStr, 10);
|
|
2632
2635
|
// Convert from am/pm to 24hr
|
|
2633
2636
|
const isAM = ending.toLowerCase().includes('am');
|
|
@@ -2649,6 +2652,7 @@ const getTimeInfoInET = (dateOrTimestamp) => {
|
|
|
2649
2652
|
hour12,
|
|
2650
2653
|
isPM,
|
|
2651
2654
|
minute,
|
|
2655
|
+
second,
|
|
2652
2656
|
};
|
|
2653
2657
|
};
|
|
2654
2658
|
|
|
@@ -3925,7 +3929,10 @@ const escapeCellText = (text) => {
|
|
|
3925
3929
|
* Generate a CSV file
|
|
3926
3930
|
* @author Gabe Abrams
|
|
3927
3931
|
* @param data list of row data in the form of json objects
|
|
3928
|
-
* @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)
|
|
3929
3936
|
* @returns multiline csv string
|
|
3930
3937
|
*/
|
|
3931
3938
|
const genCSV = (data, columns) => {
|
|
@@ -3941,16 +3948,19 @@ const genCSV = (data, columns) => {
|
|
|
3941
3948
|
csv += '\n';
|
|
3942
3949
|
csv += (columns
|
|
3943
3950
|
.map((column) => {
|
|
3951
|
+
var _a;
|
|
3944
3952
|
let contents;
|
|
3945
3953
|
const cell = datum[column.param];
|
|
3946
3954
|
if (typeof cell === 'string'
|
|
3947
3955
|
|| typeof cell === 'number') {
|
|
3948
3956
|
contents = String(cell);
|
|
3949
3957
|
}
|
|
3950
|
-
else if (
|
|
3951
|
-
|| cell === null) {
|
|
3958
|
+
else if (cell === null) {
|
|
3952
3959
|
contents = '';
|
|
3953
3960
|
}
|
|
3961
|
+
else if (typeof cell === 'undefined') {
|
|
3962
|
+
contents = ((_a = column.textIfUndefined) !== null && _a !== void 0 ? _a : '');
|
|
3963
|
+
}
|
|
3954
3964
|
else if (typeof cell === 'object') {
|
|
3955
3965
|
contents = JSON.stringify(cell);
|
|
3956
3966
|
}
|