dce-reactkit 3.2.2-beta.1 → 3.2.2-beta.11
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/.vscode/settings.json +3 -0
- package/dist/cjs/index.js +2019 -274
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/ButtonInputGroup.d.ts +1 -0
- package/dist/cjs/types/components/CSVDownloadButton.d.ts +19 -0
- package/dist/cjs/types/components/IntelliTable.d.ts +17 -0
- package/dist/cjs/types/components/ItemPicker/index.d.ts +1 -0
- package/dist/cjs/types/components/LogReviewer.d.ts +13 -0
- package/dist/cjs/types/components/SimpleDateChooser.d.ts +1 -0
- package/dist/cjs/types/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.d.ts +6 -0
- package/dist/cjs/types/constants/LOG_REVIEW_STATUS_ROUTE.d.ts +7 -0
- package/dist/cjs/types/helpers/canReviewLogs.d.ts +7 -0
- package/dist/cjs/types/helpers/genCSV.d.ts +14 -0
- package/dist/cjs/types/helpers/getMonthName.d.ts +14 -0
- package/dist/cjs/types/index.d.ts +9 -1
- package/dist/cjs/types/server/initServer.d.ts +8 -0
- package/dist/cjs/types/types/IntelliTableColumn.d.ts +12 -0
- package/dist/cjs/types/types/LogMetadataType.d.ts +19 -0
- package/dist/cjs/types/types/ReactKitErrorCode.d.ts +2 -1
- package/dist/esm/index.js +2015 -276
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/ButtonInputGroup.d.ts +1 -0
- package/dist/esm/types/components/CSVDownloadButton.d.ts +19 -0
- package/dist/esm/types/components/IntelliTable.d.ts +17 -0
- package/dist/esm/types/components/ItemPicker/index.d.ts +1 -0
- package/dist/esm/types/components/LogReviewer.d.ts +13 -0
- package/dist/esm/types/components/SimpleDateChooser.d.ts +1 -0
- package/dist/esm/types/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.d.ts +6 -0
- package/dist/esm/types/constants/LOG_REVIEW_STATUS_ROUTE.d.ts +7 -0
- package/dist/esm/types/helpers/canReviewLogs.d.ts +7 -0
- package/dist/esm/types/helpers/genCSV.d.ts +14 -0
- package/dist/esm/types/helpers/getMonthName.d.ts +14 -0
- package/dist/esm/types/index.d.ts +9 -1
- package/dist/esm/types/server/initServer.d.ts +8 -0
- package/dist/esm/types/types/IntelliTableColumn.d.ts +12 -0
- package/dist/esm/types/types/LogMetadataType.d.ts +19 -0
- package/dist/esm/types/types/ReactKitErrorCode.d.ts +2 -1
- package/dist/index.d.ts +171 -47
- package/package.json +1 -1
- package/sandbox.js +78 -17
- package/src/components/AppWrapper.tsx +5 -1
- package/src/components/ButtonInputGroup.tsx +4 -1
- package/src/components/CSVDownloadButton.tsx +102 -0
- package/src/components/IntelliTable.tsx +610 -0
- package/src/components/ItemPicker/index.tsx +4 -0
- package/src/components/LogReviewer.tsx +2097 -0
- package/src/components/SimpleDateChooser.tsx +26 -27
- package/src/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.ts +9 -0
- package/src/constants/LOG_REVIEW_STATUS_ROUTE.ts +10 -0
- package/src/helpers/canReviewLogs.ts +33 -0
- package/src/helpers/genCSV.ts +59 -0
- package/src/helpers/getHumanReadableDate.ts +6 -17
- package/src/helpers/getMonthName.ts +29 -0
- package/src/helpers/logClientEvent.tsx +5 -0
- package/src/index.ts +16 -0
- package/src/server/initServer.ts +125 -3
- package/src/types/IntelliTableColumn.ts +24 -0
- package/src/types/LogMetadataType.ts +23 -0
- package/src/types/ReactKitErrorCode.tsx +2 -1
package/sandbox.js
CHANGED
|
@@ -1,20 +1,81 @@
|
|
|
1
|
-
const
|
|
1
|
+
const monthNames = [
|
|
2
|
+
{ short: 'Jan', full: 'January' },
|
|
3
|
+
{ short: 'Feb', full: 'February' },
|
|
4
|
+
{ short: 'Mar', full: 'March' },
|
|
5
|
+
{ short: 'Apr', full: 'April' },
|
|
6
|
+
{ short: 'May', full: 'May' },
|
|
7
|
+
{ short: 'Jun', full: 'June' },
|
|
8
|
+
{ short: 'Jul', full: 'July' },
|
|
9
|
+
{ short: 'Aug', full: 'August' },
|
|
10
|
+
{ short: 'Sep', full: 'September' },
|
|
11
|
+
{ short: 'Oct', full: 'October' },
|
|
12
|
+
{ short: 'Nov', full: 'November' },
|
|
13
|
+
{ short: 'Dec', full: 'December' },
|
|
14
|
+
];
|
|
2
15
|
|
|
3
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Get the name of a month given the month number (1 = January, etc.)
|
|
18
|
+
* If an invalid number is provided, we will treat it like January
|
|
19
|
+
* @author Gabe Abrams
|
|
20
|
+
* @param month the number of the month
|
|
21
|
+
* @returns object containing multiple month name formats:
|
|
22
|
+
* { short, full } where short will look like "Jan" and full will look like
|
|
23
|
+
* "January"
|
|
24
|
+
*/
|
|
25
|
+
const getMonthName = (month) => {
|
|
26
|
+
return (monthNames[month - 1] ?? monthNames[0]);
|
|
27
|
+
};
|
|
4
28
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
29
|
+
today = {
|
|
30
|
+
year: 2023,
|
|
31
|
+
month: 1,
|
|
32
|
+
day: 11,
|
|
33
|
+
};
|
|
34
|
+
numMonthsToShow = 6;
|
|
35
|
+
chooseFromPast = true;
|
|
36
|
+
|
|
37
|
+
const choices = [];
|
|
38
|
+
let startYear = today.year;
|
|
39
|
+
let startMonth = today.month;
|
|
40
|
+
if (chooseFromPast) {
|
|
41
|
+
startMonth -= Math.max(0, numMonthsToShow - 1);
|
|
42
|
+
if (startMonth <= 0) {
|
|
43
|
+
startMonth += 12;
|
|
44
|
+
startYear -= 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
for (let i = 0; i < numMonthsToShow; i++) {
|
|
48
|
+
// Get month and year info
|
|
49
|
+
const unmoddedMonth = (startMonth + i);
|
|
50
|
+
const month = (
|
|
51
|
+
unmoddedMonth > 12
|
|
52
|
+
? unmoddedMonth - 12
|
|
53
|
+
: unmoddedMonth
|
|
54
|
+
);
|
|
55
|
+
const monthName = getMonthName(month).full;
|
|
56
|
+
const year = (
|
|
57
|
+
unmoddedMonth > 12
|
|
58
|
+
? startYear + 1
|
|
59
|
+
: startYear
|
|
60
|
+
);
|
|
18
61
|
|
|
19
|
-
|
|
20
|
-
|
|
62
|
+
// Figure out which days are allowed
|
|
63
|
+
const days = [];
|
|
64
|
+
const numDaysInMonth = (new Date(year, month, 0)).getDate();
|
|
65
|
+
const firstDay = (
|
|
66
|
+
month === today.month
|
|
67
|
+
? today.day // Current month: start at current date
|
|
68
|
+
: 1 // Future month: start at beginning of month
|
|
69
|
+
);
|
|
70
|
+
for (let day = firstDay; day <= numDaysInMonth; day++) {
|
|
71
|
+
days.push(day);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
choices.push({
|
|
75
|
+
choiceName: `${monthName} ${year}`,
|
|
76
|
+
month,
|
|
77
|
+
year,
|
|
78
|
+
days,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
console.log(choices);
|
|
@@ -227,7 +227,11 @@ export const showFatalError = (
|
|
|
227
227
|
// Add log
|
|
228
228
|
logClientEvent({
|
|
229
229
|
context: LogBuiltInMetadata.Context.ClientFatalError,
|
|
230
|
-
error
|
|
230
|
+
error: {
|
|
231
|
+
message,
|
|
232
|
+
code,
|
|
233
|
+
stack: (error ?? {}).stack,
|
|
234
|
+
},
|
|
231
235
|
metadata: {
|
|
232
236
|
errorTitle,
|
|
233
237
|
},
|
|
@@ -18,6 +18,8 @@ type Props = {
|
|
|
18
18
|
minLabelWidth?: string,
|
|
19
19
|
// Buttons
|
|
20
20
|
children: React.ReactNode,
|
|
21
|
+
// Additional class names to add to the outer container
|
|
22
|
+
className?: string,
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
/*------------------------------------------------------------------------*/
|
|
@@ -36,6 +38,7 @@ const ButtonInputGroup: React.FC<Props> = (props) => {
|
|
|
36
38
|
label,
|
|
37
39
|
minLabelWidth,
|
|
38
40
|
children,
|
|
41
|
+
className,
|
|
39
42
|
} = props;
|
|
40
43
|
|
|
41
44
|
/*------------------------------------------------------------------------*/
|
|
@@ -47,7 +50,7 @@ const ButtonInputGroup: React.FC<Props> = (props) => {
|
|
|
47
50
|
/*----------------------------------------*/
|
|
48
51
|
|
|
49
52
|
return (
|
|
50
|
-
<div className=
|
|
53
|
+
<div className={`input-group ${className ?? ''}`}>
|
|
51
54
|
<div className="input-group-prepend d-flex w-100">
|
|
52
55
|
{/* Label */}
|
|
53
56
|
<span
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button for downloading a csv file
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Import React
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
// Import FontAwesome
|
|
10
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
11
|
+
import { faCloudDownloadAlt } from '@fortawesome/free-solid-svg-icons';
|
|
12
|
+
|
|
13
|
+
/*------------------------------------------------------------------------*/
|
|
14
|
+
/* Types */
|
|
15
|
+
/*------------------------------------------------------------------------*/
|
|
16
|
+
|
|
17
|
+
// Props definition
|
|
18
|
+
type Props = {
|
|
19
|
+
// The filename
|
|
20
|
+
filename: string,
|
|
21
|
+
// The contents of the CSV file to download
|
|
22
|
+
csv: string,
|
|
23
|
+
// Id of the button
|
|
24
|
+
id?: string,
|
|
25
|
+
// Class name of the button
|
|
26
|
+
className?: string,
|
|
27
|
+
// Aria label for the button
|
|
28
|
+
ariaLabel?: string,
|
|
29
|
+
// Style for the button
|
|
30
|
+
style?: { [k: string]: any },
|
|
31
|
+
// Handler for when the button is clicked (in addition to download)
|
|
32
|
+
onClick?: () => void,
|
|
33
|
+
// Contents of button
|
|
34
|
+
children?: React.ReactNode,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/*------------------------------------------------------------------------*/
|
|
38
|
+
/* Component */
|
|
39
|
+
/*------------------------------------------------------------------------*/
|
|
40
|
+
|
|
41
|
+
const CSVDownloadButton: React.FC<Props> = (props) => {
|
|
42
|
+
/*------------------------------------------------------------------------*/
|
|
43
|
+
/* Setup */
|
|
44
|
+
/*------------------------------------------------------------------------*/
|
|
45
|
+
|
|
46
|
+
/* -------------- Props ------------- */
|
|
47
|
+
|
|
48
|
+
// Destructure all props
|
|
49
|
+
const {
|
|
50
|
+
filename,
|
|
51
|
+
csv,
|
|
52
|
+
id,
|
|
53
|
+
className,
|
|
54
|
+
ariaLabel,
|
|
55
|
+
style,
|
|
56
|
+
onClick,
|
|
57
|
+
children,
|
|
58
|
+
} = props;
|
|
59
|
+
|
|
60
|
+
/*------------------------------------------------------------------------*/
|
|
61
|
+
/* Render */
|
|
62
|
+
/*------------------------------------------------------------------------*/
|
|
63
|
+
|
|
64
|
+
/*----------------------------------------*/
|
|
65
|
+
/* Main UI */
|
|
66
|
+
/*----------------------------------------*/
|
|
67
|
+
|
|
68
|
+
// Render the button
|
|
69
|
+
return (
|
|
70
|
+
<a
|
|
71
|
+
id={id}
|
|
72
|
+
download={filename}
|
|
73
|
+
href={`data:application/octet-stream,${csv}`}
|
|
74
|
+
className={`CSVDownloadButton-button ${className ?? 'btn btn-secondary'}`}
|
|
75
|
+
aria-label={(
|
|
76
|
+
ariaLabel
|
|
77
|
+
? `Click to download ${filename}`
|
|
78
|
+
: ariaLabel
|
|
79
|
+
)}
|
|
80
|
+
style={style}
|
|
81
|
+
onClick={onClick}
|
|
82
|
+
>
|
|
83
|
+
{!children && (
|
|
84
|
+
<>
|
|
85
|
+
<FontAwesomeIcon
|
|
86
|
+
icon={faCloudDownloadAlt}
|
|
87
|
+
className="mr-2"
|
|
88
|
+
/>
|
|
89
|
+
Download CSV
|
|
90
|
+
</>
|
|
91
|
+
)}
|
|
92
|
+
{children}
|
|
93
|
+
</a>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/*------------------------------------------------------------------------*/
|
|
98
|
+
/* Wrap Up */
|
|
99
|
+
/*------------------------------------------------------------------------*/
|
|
100
|
+
|
|
101
|
+
// Export component
|
|
102
|
+
export default CSVDownloadButton;
|