dce-reactkit 4.1.4 → 4.1.6
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 +48 -4
- package/dist/cjs/index.js.map +1 -1
- 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 +48 -5
- package/dist/esm/index.js.map +1 -1
- 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 +23 -2
- package/package.json +1 -1
- package/src/components/SimpleDateChooser.tsx +2 -2
- package/src/components/SimpleTimeChooser.tsx +1 -1
- 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/index.d.ts
CHANGED
|
@@ -1554,6 +1554,26 @@ declare const getWordCount: (text: string) => number;
|
|
|
1554
1554
|
*/
|
|
1555
1555
|
declare const cloneDeep: <T>(obj: T) => T;
|
|
1556
1556
|
|
|
1557
|
+
/**
|
|
1558
|
+
* Get a timestamp (ms since epoch) from time info (year, month, day, hour, minute, etc.) in Eastern Time (ET)
|
|
1559
|
+
* @author Gardenia Liu
|
|
1560
|
+
* @author Gabe Abrams
|
|
1561
|
+
* @param opts object containing all arguments
|
|
1562
|
+
* @param opts.year Year (e.g. 2023)
|
|
1563
|
+
* @param opts.month Month (1-12)
|
|
1564
|
+
* @param opts.day Day of the month (1-31)
|
|
1565
|
+
* @param opts.hour Hour (0-23)
|
|
1566
|
+
* @param opts.minute Minute (0-59))
|
|
1567
|
+
* @returns Timestamp in milliseconds since epoch
|
|
1568
|
+
*/
|
|
1569
|
+
declare const getTimestampFromTimeInfoInET: (opts: {
|
|
1570
|
+
year: number;
|
|
1571
|
+
month: number;
|
|
1572
|
+
day: number;
|
|
1573
|
+
hour: number;
|
|
1574
|
+
minute: number;
|
|
1575
|
+
}) => number;
|
|
1576
|
+
|
|
1557
1577
|
/**
|
|
1558
1578
|
* Days of the week
|
|
1559
1579
|
* @author Gabe Abrams
|
|
@@ -1594,7 +1614,8 @@ declare enum ReactKitErrorCode {
|
|
|
1594
1614
|
SessionExpired = "DRK3",
|
|
1595
1615
|
NoCACCLSendRequestFunction = "DRK7",
|
|
1596
1616
|
SimpleDateChooserInvalidDateRange = "DRK35",
|
|
1597
|
-
SimpleDateChooserInvalidNumMonths = "DRK36"
|
|
1617
|
+
SimpleDateChooserInvalidNumMonths = "DRK36",
|
|
1618
|
+
ETTimestampInvalid = "DRK37"
|
|
1598
1619
|
}
|
|
1599
1620
|
|
|
1600
1621
|
/**
|
|
@@ -1680,4 +1701,4 @@ type LogReviewerFilterState = {
|
|
|
1680
1701
|
advancedFilterState: AdvancedFilterState;
|
|
1681
1702
|
};
|
|
1682
1703
|
|
|
1683
|
-
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, Dropdown, DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogFunction, LogLevel, LogMainInfo, LogMetadataType, LogReviewer, LogReviewerFilterState, LogSource, LogSourceSpecificInfo, LogType, LogTypeSpecificInfo, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, 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 };
|
|
1704
|
+
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, Dropdown, DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogFunction, LogLevel, LogMainInfo, LogMetadataType, LogReviewer, LogReviewerFilterState, LogSource, LogSourceSpecificInfo, LogType, LogTypeSpecificInfo, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, 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 };
|
package/package.json
CHANGED
|
@@ -421,7 +421,7 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
|
|
|
421
421
|
{/* Month Chooser */}
|
|
422
422
|
<select
|
|
423
423
|
aria-label={`month for ${ariaLabel}`}
|
|
424
|
-
className="custom-select d-inline-block mr-1"
|
|
424
|
+
className="custom-select form-select d-inline-block mr-1"
|
|
425
425
|
style={{ width: 'auto' }}
|
|
426
426
|
id={`SimpleDateChooser-${name}-month`}
|
|
427
427
|
value={`${month}-${year}`}
|
|
@@ -442,7 +442,7 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
|
|
|
442
442
|
{/* Day Chooser */}
|
|
443
443
|
<select
|
|
444
444
|
aria-label={`day for ${ariaLabel}`}
|
|
445
|
-
className="custom-select d-inline-block"
|
|
445
|
+
className="custom-select form-select d-inline-block"
|
|
446
446
|
style={{ width: 'auto' }}
|
|
447
447
|
id={`SimpleDateChooser-${name}-day`}
|
|
448
448
|
value={day}
|
|
@@ -167,7 +167,7 @@ const SimpleTimeChooser: React.FC<Props> = (props) => {
|
|
|
167
167
|
{/* Time Chooser */}
|
|
168
168
|
<select
|
|
169
169
|
aria-label={`time for ${ariaLabel}`}
|
|
170
|
-
className="custom-select d-inline-block"
|
|
170
|
+
className="custom-select form-select d-inline-block"
|
|
171
171
|
style={{ width: 'auto' }}
|
|
172
172
|
id={`SimpleTimeChooser-${name}-time`}
|
|
173
173
|
value={selectedTimeMin}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Import shared types
|
|
2
|
+
import ErrorWithCode from '../errors/ErrorWithCode';
|
|
3
|
+
import ReactKitErrorCode from '../types/ReactKitErrorCode';
|
|
4
|
+
|
|
5
|
+
// Import shared helpers
|
|
6
|
+
import getTimeInfoInET from './getTimeInfoInET';
|
|
7
|
+
import padZerosLeft from './padZerosLeft';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get a timestamp (ms since epoch) from time info (year, month, day, hour, minute, etc.) in Eastern Time (ET)
|
|
11
|
+
* @author Gardenia Liu
|
|
12
|
+
* @author Gabe Abrams
|
|
13
|
+
* @param opts object containing all arguments
|
|
14
|
+
* @param opts.year Year (e.g. 2023)
|
|
15
|
+
* @param opts.month Month (1-12)
|
|
16
|
+
* @param opts.day Day of the month (1-31)
|
|
17
|
+
* @param opts.hour Hour (0-23)
|
|
18
|
+
* @param opts.minute Minute (0-59))
|
|
19
|
+
* @returns Timestamp in milliseconds since epoch
|
|
20
|
+
*/
|
|
21
|
+
const getTimestampFromTimeInfoInET = (
|
|
22
|
+
opts: {
|
|
23
|
+
year: number,
|
|
24
|
+
month: number,
|
|
25
|
+
day: number,
|
|
26
|
+
hour: number,
|
|
27
|
+
minute: number,
|
|
28
|
+
},
|
|
29
|
+
): number => {
|
|
30
|
+
// Destructure opts
|
|
31
|
+
const {
|
|
32
|
+
year,
|
|
33
|
+
month,
|
|
34
|
+
day,
|
|
35
|
+
hour,
|
|
36
|
+
minute,
|
|
37
|
+
} = opts;
|
|
38
|
+
|
|
39
|
+
// Determine if the date is in DST in Eastern Time
|
|
40
|
+
const tempDate = new Date(year, month - 1, day);
|
|
41
|
+
const janOffset = new Date(year, 0, 1).getTimezoneOffset();
|
|
42
|
+
const isDST = tempDate.getTimezoneOffset() < janOffset;
|
|
43
|
+
const etOffset = isDST ? '-04:00' : '-05:00';
|
|
44
|
+
|
|
45
|
+
// Format with leading zeroes
|
|
46
|
+
const mm = padZerosLeft(month, 2);
|
|
47
|
+
const dd = padZerosLeft(day, 2);
|
|
48
|
+
const hh = padZerosLeft(hour, 2);
|
|
49
|
+
const min = padZerosLeft(minute, 2);
|
|
50
|
+
|
|
51
|
+
// Build ET ISO string and convert to UTC timestamp
|
|
52
|
+
const etISOString = `${year}-${mm}-${dd}T${hh}:${min}:00${etOffset}`;
|
|
53
|
+
const timestamp = (new Date(etISOString)).getTime();
|
|
54
|
+
|
|
55
|
+
// Verify that the timestamp is correct
|
|
56
|
+
const timeInfoInET = getTimeInfoInET(timestamp);
|
|
57
|
+
if (
|
|
58
|
+
timeInfoInET.year !== year
|
|
59
|
+
|| timeInfoInET.month !== month
|
|
60
|
+
|| timeInfoInET.day !== day
|
|
61
|
+
|| timeInfoInET.hour !== hour
|
|
62
|
+
|| timeInfoInET.minute !== minute
|
|
63
|
+
) {
|
|
64
|
+
throw new ErrorWithCode(
|
|
65
|
+
`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)}`,
|
|
66
|
+
ReactKitErrorCode.ETTimestampInvalid,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Valid! Return the timestamp
|
|
71
|
+
return timestamp;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default getTimestampFromTimeInfoInET;
|
package/src/index.ts
CHANGED
|
@@ -95,6 +95,7 @@ import capitalize from './helpers/capitalize';
|
|
|
95
95
|
import shuffleArray from './helpers/shuffleArray';
|
|
96
96
|
import getWordCount from './helpers/getWordCount';
|
|
97
97
|
import cloneDeep from './helpers/cloneDeep';
|
|
98
|
+
import getTimestampFromTimeInfoInET from './helpers/getTimestampFromTimeInfoInET';
|
|
98
99
|
|
|
99
100
|
// Import types
|
|
100
101
|
import ParamType from './types/ParamType';
|
|
@@ -213,6 +214,7 @@ export {
|
|
|
213
214
|
shuffleArray,
|
|
214
215
|
getWordCount,
|
|
215
216
|
cloneDeep,
|
|
217
|
+
getTimestampFromTimeInfoInET,
|
|
216
218
|
// Client helpers
|
|
217
219
|
initClient,
|
|
218
220
|
visitServerEndpoint,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Highest error code =
|
|
1
|
+
// Highest error code = DRK37
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* List of error codes built into the react kit
|
|
@@ -11,6 +11,7 @@ enum ReactKitErrorCode {
|
|
|
11
11
|
NoCACCLSendRequestFunction = 'DRK7',
|
|
12
12
|
SimpleDateChooserInvalidDateRange = 'DRK35',
|
|
13
13
|
SimpleDateChooserInvalidNumMonths = 'DRK36',
|
|
14
|
+
ETTimestampInvalid = 'DRK37',
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export default ReactKitErrorCode;
|