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/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
|
|
|
@@ -2869,12 +2870,12 @@ const SimpleDateChooser = (props) => {
|
|
|
2869
2870
|
});
|
|
2870
2871
|
// Create body
|
|
2871
2872
|
body = (React__default.createElement("div", { className: "SimpleDateChooser-inner-container d-inline-block", "aria-label": `date chooser with selected date: ${month}/${day}/${year}` },
|
|
2872
|
-
React__default.createElement("select", { "aria-label": `month for ${ariaLabel}`, className: "custom-select d-inline-block mr-1", style: { width: 'auto' }, id: `SimpleDateChooser-${name}-month`, value: `${month}-${year}`, onChange: (e) => {
|
|
2873
|
+
React__default.createElement("select", { "aria-label": `month for ${ariaLabel}`, className: "custom-select form-select d-inline-block mr-1", style: { width: 'auto' }, id: `SimpleDateChooser-${name}-month`, value: `${month}-${year}`, onChange: (e) => {
|
|
2873
2874
|
const choice = choices[e.target.selectedIndex];
|
|
2874
2875
|
// Change day, month, and year
|
|
2875
2876
|
onChange(choice.month, choice.days[0], choice.year);
|
|
2876
2877
|
} }, monthOptions),
|
|
2877
|
-
React__default.createElement("select", { "aria-label": `day for ${ariaLabel}`, className: "custom-select d-inline-block", style: { width: 'auto' }, id: `SimpleDateChooser-${name}-day`, value: day, onChange: (e) => {
|
|
2878
|
+
React__default.createElement("select", { "aria-label": `day for ${ariaLabel}`, className: "custom-select form-select d-inline-block", style: { width: 'auto' }, id: `SimpleDateChooser-${name}-day`, value: day, onChange: (e) => {
|
|
2878
2879
|
// Only change the day
|
|
2879
2880
|
onChange(month, Number.parseInt(e.target.value, 10), year);
|
|
2880
2881
|
} }, dayOptions)));
|
|
@@ -3007,7 +3008,7 @@ const SimpleTimeChooser = (props) => {
|
|
|
3007
3008
|
return (React__default.createElement("option", { key: numMinutesForChoice, value: numMinutesForChoice, "aria-label": `choose ${timeString}` }, timeString));
|
|
3008
3009
|
});
|
|
3009
3010
|
return (React__default.createElement("div", { className: "SimpleTimeChooser-container", "aria-label": `time chooser with selected time: ${formatTime(selectedTimeMin)}` },
|
|
3010
|
-
React__default.createElement("select", { "aria-label": `time for ${ariaLabel}`, className: "custom-select d-inline-block", style: { width: 'auto' }, id: `SimpleTimeChooser-${name}-time`, value: selectedTimeMin, onChange: (e) => {
|
|
3011
|
+
React__default.createElement("select", { "aria-label": `time for ${ariaLabel}`, className: "custom-select form-select d-inline-block", style: { width: 'auto' }, id: `SimpleTimeChooser-${name}-time`, value: selectedTimeMin, onChange: (e) => {
|
|
3011
3012
|
// Parse selector value (string)
|
|
3012
3013
|
const newTime = Number.parseInt(e.target.value, 10);
|
|
3013
3014
|
// Convert minutes since midnight to hour and minute
|
|
@@ -16346,6 +16347,48 @@ const getWordCount = (text) => {
|
|
|
16346
16347
|
return trimmedTextWithoutPunctuation.split(/\s+/g).length;
|
|
16347
16348
|
};
|
|
16348
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
|
+
|
|
16349
16392
|
/**
|
|
16350
16393
|
* Days of the week
|
|
16351
16394
|
* @author Gabe Abrams
|
|
@@ -16362,5 +16405,5 @@ var DayOfWeek;
|
|
|
16362
16405
|
})(DayOfWeek || (DayOfWeek = {}));
|
|
16363
16406
|
var DayOfWeek$1 = DayOfWeek;
|
|
16364
16407
|
|
|
16365
|
-
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 };
|
|
16366
16409
|
//# sourceMappingURL=index.js.map
|