dce-reactkit 4.1.3 → 4.1.5
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/.copilot/instructions.md +17 -0
- package/dist/cjs/index.js +49 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/CSVDownloadButton.d.ts +1 -0
- package/dist/cjs/types/helpers/getTimestampFromTimeInfoInET.d.ts +20 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/types/types/ReactKitErrorCode.d.ts +2 -1
- package/dist/esm/index.js +49 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/CSVDownloadButton.d.ts +1 -0
- package/dist/esm/types/helpers/getTimestampFromTimeInfoInET.d.ts +20 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/types/types/ReactKitErrorCode.d.ts +2 -1
- package/dist/index.d.ts +24 -2
- package/package.json +1 -1
- package/src/components/CSVDownloadButton.tsx +4 -1
- package/src/helpers/genCSV.ts +1 -0
- package/src/helpers/getTimestampFromTimeInfoInET.ts +74 -0
- package/src/index.ts +2 -0
- package/src/types/ReactKitErrorCode.tsx +2 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a timestamp (ms since epoch) from time info (year, month, day, hour, minute, etc.) in Eastern Time (ET)
|
|
3
|
+
* @author Gardenia Liu
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param opts object containing all arguments
|
|
6
|
+
* @param opts.year Year (e.g. 2023)
|
|
7
|
+
* @param opts.month Month (1-12)
|
|
8
|
+
* @param opts.day Day of the month (1-31)
|
|
9
|
+
* @param opts.hour Hour (0-23)
|
|
10
|
+
* @param opts.minute Minute (0-59))
|
|
11
|
+
* @returns Timestamp in milliseconds since epoch
|
|
12
|
+
*/
|
|
13
|
+
declare const getTimestampFromTimeInfoInET: (opts: {
|
|
14
|
+
year: number;
|
|
15
|
+
month: number;
|
|
16
|
+
day: number;
|
|
17
|
+
hour: number;
|
|
18
|
+
minute: number;
|
|
19
|
+
}) => number;
|
|
20
|
+
export default getTimestampFromTimeInfoInET;
|
|
@@ -79,6 +79,7 @@ import capitalize from './helpers/capitalize';
|
|
|
79
79
|
import shuffleArray from './helpers/shuffleArray';
|
|
80
80
|
import getWordCount from './helpers/getWordCount';
|
|
81
81
|
import cloneDeep from './helpers/cloneDeep';
|
|
82
|
+
import getTimestampFromTimeInfoInET from './helpers/getTimestampFromTimeInfoInET';
|
|
82
83
|
import ParamType from './types/ParamType';
|
|
83
84
|
import ModalButtonType from './types/ModalButtonType';
|
|
84
85
|
import ModalSize from './types/ModalSize';
|
|
@@ -104,4 +105,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
|
104
105
|
import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
|
|
105
106
|
import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
|
|
106
107
|
import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
|
|
107
|
-
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, SimpleTimeChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, LOG_REVIEW_GET_LOGS_ROUTE, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, ParamType, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, IntelliTableColumn, DropdownItemType, LogReviewerFilterState, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, };
|
|
108
|
+
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, SimpleTimeChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, LOG_REVIEW_GET_LOGS_ROUTE, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, cloneDeep, getTimestampFromTimeInfoInET, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, ParamType, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, IntelliTableColumn, DropdownItemType, LogReviewerFilterState, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, };
|
|
@@ -8,6 +8,7 @@ declare enum ReactKitErrorCode {
|
|
|
8
8
|
SessionExpired = "DRK3",
|
|
9
9
|
NoCACCLSendRequestFunction = "DRK7",
|
|
10
10
|
SimpleDateChooserInvalidDateRange = "DRK35",
|
|
11
|
-
SimpleDateChooserInvalidNumMonths = "DRK36"
|
|
11
|
+
SimpleDateChooserInvalidNumMonths = "DRK36",
|
|
12
|
+
ETTimestampInvalid = "DRK37"
|
|
12
13
|
}
|
|
13
14
|
export default ReactKitErrorCode;
|
package/dist/esm/index.js
CHANGED
|
@@ -30,7 +30,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// Highest error code =
|
|
33
|
+
// Highest error code = DRK37
|
|
34
34
|
/**
|
|
35
35
|
* List of error codes built into the react kit
|
|
36
36
|
* @author Gabe Abrams
|
|
@@ -43,6 +43,7 @@ var ReactKitErrorCode;
|
|
|
43
43
|
ReactKitErrorCode["NoCACCLSendRequestFunction"] = "DRK7";
|
|
44
44
|
ReactKitErrorCode["SimpleDateChooserInvalidDateRange"] = "DRK35";
|
|
45
45
|
ReactKitErrorCode["SimpleDateChooserInvalidNumMonths"] = "DRK36";
|
|
46
|
+
ReactKitErrorCode["ETTimestampInvalid"] = "DRK37";
|
|
46
47
|
})(ReactKitErrorCode || (ReactKitErrorCode = {}));
|
|
47
48
|
var ReactKitErrorCode$1 = ReactKitErrorCode;
|
|
48
49
|
|
|
@@ -3925,7 +3926,8 @@ const genCSV = (data, columns) => {
|
|
|
3925
3926
|
let contents;
|
|
3926
3927
|
const cell = datum[column.param];
|
|
3927
3928
|
if (typeof cell === 'string'
|
|
3928
|
-
|| typeof cell === 'number'
|
|
3929
|
+
|| typeof cell === 'number'
|
|
3930
|
+
|| typeof cell === 'boolean') {
|
|
3929
3931
|
contents = String(cell);
|
|
3930
3932
|
}
|
|
3931
3933
|
else if (cell === null) {
|
|
@@ -3961,7 +3963,7 @@ const CSVDownloadButton = (props) => {
|
|
|
3961
3963
|
/*------------------------------------------------------------------------*/
|
|
3962
3964
|
/* -------------- Props ------------- */
|
|
3963
3965
|
// Destructure all props
|
|
3964
|
-
const { filename, csv, id, className, ariaLabel, style, onClick, children, } = props;
|
|
3966
|
+
const { filename, csv, id, className, ariaLabel, style, onClick, children, label = 'Download CSV', } = props;
|
|
3965
3967
|
/*------------------------------------------------------------------------*/
|
|
3966
3968
|
/* ------------------------------- Render ------------------------------- */
|
|
3967
3969
|
/*------------------------------------------------------------------------*/
|
|
@@ -3975,7 +3977,7 @@ const CSVDownloadButton = (props) => {
|
|
|
3975
3977
|
!children && (React__default.createElement(React__default.Fragment, null,
|
|
3976
3978
|
React__default.createElement(FontAwesomeIcon, { icon: faCloudDownloadAlt }),
|
|
3977
3979
|
' ',
|
|
3978
|
-
|
|
3980
|
+
label)),
|
|
3979
3981
|
children));
|
|
3980
3982
|
};
|
|
3981
3983
|
|
|
@@ -16345,6 +16347,48 @@ const getWordCount = (text) => {
|
|
|
16345
16347
|
return trimmedTextWithoutPunctuation.split(/\s+/g).length;
|
|
16346
16348
|
};
|
|
16347
16349
|
|
|
16350
|
+
// Import shared types
|
|
16351
|
+
/**
|
|
16352
|
+
* Get a timestamp (ms since epoch) from time info (year, month, day, hour, minute, etc.) in Eastern Time (ET)
|
|
16353
|
+
* @author Gardenia Liu
|
|
16354
|
+
* @author Gabe Abrams
|
|
16355
|
+
* @param opts object containing all arguments
|
|
16356
|
+
* @param opts.year Year (e.g. 2023)
|
|
16357
|
+
* @param opts.month Month (1-12)
|
|
16358
|
+
* @param opts.day Day of the month (1-31)
|
|
16359
|
+
* @param opts.hour Hour (0-23)
|
|
16360
|
+
* @param opts.minute Minute (0-59))
|
|
16361
|
+
* @returns Timestamp in milliseconds since epoch
|
|
16362
|
+
*/
|
|
16363
|
+
const getTimestampFromTimeInfoInET = (opts) => {
|
|
16364
|
+
// Destructure opts
|
|
16365
|
+
const { year, month, day, hour, minute, } = opts;
|
|
16366
|
+
// Determine if the date is in DST in Eastern Time
|
|
16367
|
+
const tempDate = new Date(year, month - 1, day);
|
|
16368
|
+
const janOffset = new Date(year, 0, 1).getTimezoneOffset();
|
|
16369
|
+
const isDST = tempDate.getTimezoneOffset() < janOffset;
|
|
16370
|
+
const etOffset = isDST ? '-04:00' : '-05:00';
|
|
16371
|
+
// Format with leading zeroes
|
|
16372
|
+
const mm = padZerosLeft(month, 2);
|
|
16373
|
+
const dd = padZerosLeft(day, 2);
|
|
16374
|
+
const hh = padZerosLeft(hour, 2);
|
|
16375
|
+
const min = padZerosLeft(minute, 2);
|
|
16376
|
+
// Build ET ISO string and convert to UTC timestamp
|
|
16377
|
+
const etISOString = `${year}-${mm}-${dd}T${hh}:${min}:00${etOffset}`;
|
|
16378
|
+
const timestamp = (new Date(etISOString)).getTime();
|
|
16379
|
+
// Verify that the timestamp is correct
|
|
16380
|
+
const timeInfoInET = getTimeInfoInET(timestamp);
|
|
16381
|
+
if (timeInfoInET.year !== year
|
|
16382
|
+
|| timeInfoInET.month !== month
|
|
16383
|
+
|| timeInfoInET.day !== day
|
|
16384
|
+
|| timeInfoInET.hour !== hour
|
|
16385
|
+
|| timeInfoInET.minute !== minute) {
|
|
16386
|
+
throw new ErrorWithCode(`Timestamp mismatch: expected ${year}-${mm}-${dd} ${hh}:${min}, got ${timeInfoInET.year}-${padZerosLeft(timeInfoInET.month, 2)}-${padZerosLeft(timeInfoInET.day, 2)} ${padZerosLeft(timeInfoInET.hour, 2)}:${padZerosLeft(timeInfoInET.minute, 2)}`, ReactKitErrorCode$1.ETTimestampInvalid);
|
|
16387
|
+
}
|
|
16388
|
+
// Valid! Return the timestamp
|
|
16389
|
+
return timestamp;
|
|
16390
|
+
};
|
|
16391
|
+
|
|
16348
16392
|
/**
|
|
16349
16393
|
* Days of the week
|
|
16350
16394
|
* @author Gabe Abrams
|
|
@@ -16361,5 +16405,5 @@ var DayOfWeek;
|
|
|
16361
16405
|
})(DayOfWeek || (DayOfWeek = {}));
|
|
16362
16406
|
var DayOfWeek$1 = DayOfWeek;
|
|
16363
16407
|
|
|
16364
|
-
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, Dropdown, DropdownItemType$1 as DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogLevel$1 as LogLevel, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, cloneDeep, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getWordCount, idify, initClient, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
|
|
16408
|
+
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, Dropdown, DropdownItemType$1 as DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogLevel$1 as LogLevel, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, cloneDeep, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getTimestampFromTimeInfoInET, getWordCount, idify, initClient, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
|
|
16365
16409
|
//# sourceMappingURL=index.js.map
|